monitor: add Error * argument to monitor_get_fd
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
parent
9a3a88956c
commit
a9940fc4cb
3
dump.c
3
dump.c
|
@ -836,9 +836,8 @@ void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin,
|
||||||
|
|
||||||
#if !defined(WIN32)
|
#if !defined(WIN32)
|
||||||
if (strstart(file, "fd:", &p)) {
|
if (strstart(file, "fd:", &p)) {
|
||||||
fd = monitor_get_fd(cur_mon, p);
|
fd = monitor_get_fd(cur_mon, p, errp);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
error_set(errp, QERR_FD_NOT_FOUND, p);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ static int fd_close(MigrationState *s)
|
||||||
|
|
||||||
int fd_start_outgoing_migration(MigrationState *s, const char *fdname)
|
int fd_start_outgoing_migration(MigrationState *s, const char *fdname)
|
||||||
{
|
{
|
||||||
s->fd = monitor_get_fd(cur_mon, fdname);
|
s->fd = monitor_get_fd(cur_mon, fdname, NULL);
|
||||||
if (s->fd == -1) {
|
if (s->fd == -1) {
|
||||||
DPRINTF("fd_migration: invalid file descriptor identifier\n");
|
DPRINTF("fd_migration: invalid file descriptor identifier\n");
|
||||||
goto err_after_get_fd;
|
goto err_after_get_fd;
|
||||||
|
|
15
monitor.c
15
monitor.c
|
@ -951,7 +951,7 @@ static int add_graphics_client(Monitor *mon, const QDict *qdict, QObject **ret_d
|
||||||
CharDriverState *s;
|
CharDriverState *s;
|
||||||
|
|
||||||
if (strcmp(protocol, "spice") == 0) {
|
if (strcmp(protocol, "spice") == 0) {
|
||||||
int fd = monitor_get_fd(mon, fdname);
|
int fd = monitor_get_fd(mon, fdname, NULL);
|
||||||
int skipauth = qdict_get_try_bool(qdict, "skipauth", 0);
|
int skipauth = qdict_get_try_bool(qdict, "skipauth", 0);
|
||||||
int tls = qdict_get_try_bool(qdict, "tls", 0);
|
int tls = qdict_get_try_bool(qdict, "tls", 0);
|
||||||
if (!using_spice) {
|
if (!using_spice) {
|
||||||
|
@ -965,13 +965,13 @@ static int add_graphics_client(Monitor *mon, const QDict *qdict, QObject **ret_d
|
||||||
return 0;
|
return 0;
|
||||||
#ifdef CONFIG_VNC
|
#ifdef CONFIG_VNC
|
||||||
} else if (strcmp(protocol, "vnc") == 0) {
|
} else if (strcmp(protocol, "vnc") == 0) {
|
||||||
int fd = monitor_get_fd(mon, fdname);
|
int fd = monitor_get_fd(mon, fdname, NULL);
|
||||||
int skipauth = qdict_get_try_bool(qdict, "skipauth", 0);
|
int skipauth = qdict_get_try_bool(qdict, "skipauth", 0);
|
||||||
vnc_display_add_client(NULL, fd, skipauth);
|
vnc_display_add_client(NULL, fd, skipauth);
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
} else if ((s = qemu_chr_find(protocol)) != NULL) {
|
} else if ((s = qemu_chr_find(protocol)) != NULL) {
|
||||||
int fd = monitor_get_fd(mon, fdname);
|
int fd = monitor_get_fd(mon, fdname, NULL);
|
||||||
if (qemu_chr_add_client(s, fd) < 0) {
|
if (qemu_chr_add_client(s, fd) < 0) {
|
||||||
qerror_report(QERR_ADD_CLIENT_FAILED);
|
qerror_report(QERR_ADD_CLIENT_FAILED);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -2118,7 +2118,7 @@ static void do_loadvm(Monitor *mon, const QDict *qdict)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int monitor_get_fd(Monitor *mon, const char *fdname)
|
int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp)
|
||||||
{
|
{
|
||||||
mon_fd_t *monfd;
|
mon_fd_t *monfd;
|
||||||
|
|
||||||
|
@ -2139,6 +2139,7 @@ int monitor_get_fd(Monitor *mon, const char *fdname)
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
error_setg(errp, "File descriptor named '%s' has not been found", fdname);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2410,12 +2411,14 @@ int monitor_fdset_dup_fd_remove(int dup_fd)
|
||||||
int monitor_handle_fd_param(Monitor *mon, const char *fdname)
|
int monitor_handle_fd_param(Monitor *mon, const char *fdname)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
Error *local_err = NULL;
|
||||||
|
|
||||||
if (!qemu_isdigit(fdname[0]) && mon) {
|
if (!qemu_isdigit(fdname[0]) && mon) {
|
||||||
|
|
||||||
fd = monitor_get_fd(mon, fdname);
|
fd = monitor_get_fd(mon, fdname, &local_err);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
error_report("No file descriptor named %s found", fdname);
|
qerror_report_err(local_err);
|
||||||
|
error_free(local_err);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -66,7 +66,7 @@ int monitor_read_block_device_key(Monitor *mon, const char *device,
|
||||||
BlockDriverCompletionFunc *completion_cb,
|
BlockDriverCompletionFunc *completion_cb,
|
||||||
void *opaque);
|
void *opaque);
|
||||||
|
|
||||||
int monitor_get_fd(Monitor *mon, const char *fdname);
|
int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp);
|
||||||
int monitor_handle_fd_param(Monitor *mon, const char *fdname);
|
int monitor_handle_fd_param(Monitor *mon, const char *fdname);
|
||||||
|
|
||||||
void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap)
|
void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap)
|
||||||
|
|
Loading…
Reference in a new issue