From patchwork Mon Oct 26 20:39:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 536209 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 10B8A14016A for ; Tue, 27 Oct 2015 07:48:37 +1100 (AEDT) Received: from localhost ([::1]:55172 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zqoh1-00053X-0Q for incoming@patchwork.ozlabs.org; Mon, 26 Oct 2015 16:48:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39330) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZqoYi-0008C3-6U for qemu-devel@nongnu.org; Mon, 26 Oct 2015 16:40:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZqoYg-0004cL-Vd for qemu-devel@nongnu.org; Mon, 26 Oct 2015 16:40:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51088) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZqoYe-0004Zx-J4; Mon, 26 Oct 2015 16:39:56 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 4A9C88F2FE; Mon, 26 Oct 2015 20:39:56 +0000 (UTC) Received: from localhost (ovpn-116-20.ams2.redhat.com [10.36.116.20]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t9QKds1Q005379 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 26 Oct 2015 16:39:55 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 26 Oct 2015 21:39:16 +0100 Message-Id: <1445891959-27432-13-git-send-email-mreitz@redhat.com> In-Reply-To: <1445891959-27432-1-git-send-email-mreitz@redhat.com> References: <1445891959-27432-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Alberto Garcia , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , John Snow , Stefan Hajnoczi Subject: [Qemu-devel] [PATCH v8 12/15] hmp: Use blockdev-change-medium for change command X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Use separate code paths for the two overloaded functions of the 'change' HMP command, and invoke the 'blockdev-change-medium' QMP command if used on a block device (by calling qmp_blockdev_change_medium()). Signed-off-by: Max Reitz Reviewed-by: Eric Blake Reviewed-by: Kevin Wolf --- hmp.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/hmp.c b/hmp.c index 5048eee..b91821b 100644 --- a/hmp.c +++ b/hmp.c @@ -1338,22 +1338,25 @@ void hmp_change(Monitor *mon, const QDict *qdict) const char *arg = qdict_get_try_str(qdict, "arg"); Error *err = NULL; - if (strcmp(device, "vnc") == 0 && - (strcmp(target, "passwd") == 0 || - strcmp(target, "password") == 0)) { - if (!arg) { - monitor_read_password(mon, hmp_change_read_arg, NULL); + if (strcmp(device, "vnc") == 0) { + if (strcmp(target, "passwd") == 0 || + strcmp(target, "password") == 0) { + if (!arg) { + monitor_read_password(mon, hmp_change_read_arg, NULL); + return; + } + } + qmp_change("vnc", target, !!arg, arg, &err); + } else { + qmp_blockdev_change_medium(device, target, !!arg, arg, &err); + if (err && + error_get_class(err) == ERROR_CLASS_DEVICE_ENCRYPTED) { + error_free(err); + monitor_read_block_device_key(mon, device, NULL, NULL); return; } } - qmp_change(device, target, !!arg, arg, &err); - if (err && - error_get_class(err) == ERROR_CLASS_DEVICE_ENCRYPTED) { - error_free(err); - monitor_read_block_device_key(mon, device, NULL, NULL); - return; - } hmp_handle_error(mon, &err); }