From patchwork Mon Dec 7 20:37:09 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 40540 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9CDF8B6F07 for ; Tue, 8 Dec 2009 08:20:46 +1100 (EST) Received: from localhost ([127.0.0.1]:60609 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NHl0c-0007HP-Og for incoming@patchwork.ozlabs.org; Mon, 07 Dec 2009 16:20:42 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NHkKy-000361-PI for qemu-devel@nongnu.org; Mon, 07 Dec 2009 15:37:41 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NHkKp-0002zc-CW for qemu-devel@nongnu.org; Mon, 07 Dec 2009 15:37:34 -0500 Received: from [199.232.76.173] (port=46536 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NHkKo-0002zW-Bv for qemu-devel@nongnu.org; Mon, 07 Dec 2009 15:37:30 -0500 Received: from oxygen.pond.sub.org ([213.239.205.148]:47593) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NHkKn-0001TE-C7 for qemu-devel@nongnu.org; Mon, 07 Dec 2009 15:37:30 -0500 Received: from crossbow.pond.sub.org (pD9E38C82.dip.t-dialin.net [217.227.140.130]) by oxygen.pond.sub.org (Postfix) with ESMTPA id AED59276D59 for ; Mon, 7 Dec 2009 21:37:24 +0100 (CET) Received: by crossbow.pond.sub.org (Postfix, from userid 500) id 1B87720BED; Mon, 7 Dec 2009 21:37:17 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Dec 2009 21:37:09 +0100 Message-Id: <1260218236-22143-12-git-send-email-armbru@redhat.com> X-Mailer: git-send-email 1.6.2.5 In-Reply-To: <1260218236-22143-1-git-send-email-armbru@redhat.com> References: <1260218236-22143-1-git-send-email-armbru@redhat.com> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: lcapitulino@redhat.com Subject: [Qemu-devel] [FOR 0.12 PATCH 11/18] monitor: convert do_change() to QObject, QError X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Markus Armbruster --- monitor.c | 19 +++++++++++-------- qemu-monitor.hx | 3 ++- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/monitor.c b/monitor.c index 62d2ef5..05233cc 100644 --- a/monitor.c +++ b/monitor.c @@ -830,13 +830,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; } } @@ -846,17 +846,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); } @@ -868,17 +868,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 cf2ef9b..c788c73 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