diff options
author | Markus Armbruster <armbru@redhat.com> | 2009-12-07 21:37:09 +0100 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-12-07 16:34:35 -0600 |
commit | ec3b82afaa0c4c06689d6a6381d351eefc4ee171 (patch) | |
tree | 165db07f30b3f36af23fb41e0a198ce4a95aa3d9 | |
parent | a6906e31a8d025a0dd626ee3c14dd58e7b9ab445 (diff) |
monitor: convert do_change() to QObject, QError
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
-rw-r--r-- | monitor.c | 19 | ||||
-rw-r--r-- | qemu-monitor.hx | 3 |
2 files changed, 13 insertions, 9 deletions
@@ -800,13 +800,13 @@ static void do_change_block(Monitor *mon, const char *device, bs = bdrv_find(device); if (!bs) { - monitor_printf(mon, "device not found\n"); + qemu_error_new(QERR_DEVICE_NOT_FOUND, device); return; } if (fmt) { drv = bdrv_find_whitelisted_format(fmt); if (!drv) { - monitor_printf(mon, "invalid format %s\n", fmt); + qemu_error_new(QERR_INVALID_BLOCK_FORMAT, fmt); return; } } @@ -816,17 +816,17 @@ static void do_change_block(Monitor *mon, const char *device, monitor_read_bdrv_key_start(mon, bs, NULL, NULL); } -static void change_vnc_password(Monitor *mon, const char *password) +static void change_vnc_password(const char *password) { if (vnc_display_password(NULL, password) < 0) - monitor_printf(mon, "could not set VNC server password\n"); + qemu_error_new(QERR_SET_PASSWD_FAILED); } static void change_vnc_password_cb(Monitor *mon, const char *password, void *opaque) { - change_vnc_password(mon, password); + change_vnc_password(password); monitor_read_command(mon, 1); } @@ -838,17 +838,20 @@ static void do_change_vnc(Monitor *mon, const char *target, const char *arg) char password[9]; strncpy(password, arg, sizeof(password)); password[sizeof(password) - 1] = '\0'; - change_vnc_password(mon, password); + change_vnc_password(password); } else { monitor_read_password(mon, change_vnc_password_cb, NULL); } } else { if (vnc_display_open(NULL, target) < 0) - monitor_printf(mon, "could not start VNC server on %s\n", target); + qemu_error_new(QERR_VNC_SERVER_FAILED, target); } } -static void do_change(Monitor *mon, const QDict *qdict) +/** + * do_change(): Change a removable medium, or VNC configuration + */ +static void do_change(Monitor *mon, const QDict *qdict, QObject **ret_data) { const char *device = qdict_get_str(qdict, "device"); const char *target = qdict_get_str(qdict, "target"); diff --git a/qemu-monitor.hx b/qemu-monitor.hx index c2670ee1d9..0657b2d160 100644 --- a/qemu-monitor.hx +++ b/qemu-monitor.hx @@ -147,7 +147,8 @@ ETEXI .args_type = "device:B,target:F,arg:s?", .params = "device filename [format]", .help = "change a removable medium, optional format", - .mhandler.cmd = do_change, + .user_print = monitor_user_noop, + .mhandler.cmd_new = do_change, }, STEXI |