From patchwork Tue Dec 6 17:54:27 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 129798 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 67B1B1007D5 for ; Wed, 7 Dec 2011 06:20:44 +1100 (EST) Received: from localhost ([::1]:53724 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RY0Kg-0006Uz-RQ for incoming@patchwork.ozlabs.org; Tue, 06 Dec 2011 14:05:38 -0500 Received: from eggs.gnu.org ([140.186.70.92]:45600) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RY0KB-00051i-Jw for qemu-devel@nongnu.org; Tue, 06 Dec 2011 14:05:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RY0K7-0004I9-JP for qemu-devel@nongnu.org; Tue, 06 Dec 2011 14:05:07 -0500 Received: from mx1.redhat.com ([209.132.183.28]:21901) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RY0K7-0004HQ-9C for qemu-devel@nongnu.org; Tue, 06 Dec 2011 14:05:03 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pB6J4UUY006950 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 6 Dec 2011 14:05:02 -0500 Received: from localhost (ovpn-113-121.phx2.redhat.com [10.3.113.121]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id pB6HtEKX006284; Tue, 6 Dec 2011 12:55:14 -0500 From: Luiz Capitulino To: aliguori@us.ibm.com Date: Tue, 6 Dec 2011 15:54:27 -0200 Message-Id: <1323194072-20046-18-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1323194072-20046-1-git-send-email-lcapitulino@redhat.com> References: <1323194072-20046-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 17/22] qapi: Convert block_resize 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 Signed-off-by: Luiz Capitulino --- blockdev.c | 18 +++++++----------- blockdev.h | 1 - hmp-commands.hx | 3 +-- hmp.c | 10 ++++++++++ hmp.h | 1 + qapi-schema.json | 18 ++++++++++++++++++ qmp-commands.hx | 5 +---- 7 files changed, 38 insertions(+), 18 deletions(-) diff --git a/blockdev.c b/blockdev.c index aba7aaf..5270404 100644 --- a/blockdev.c +++ b/blockdev.c @@ -861,27 +861,23 @@ int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data) * existing QERR_ macro mess is cleaned up. A good example for better * error reports can be found in the qemu-img resize code. */ -int do_block_resize(Monitor *mon, const QDict *qdict, QObject **ret_data) +void qmp_block_resize(const char *device, int64_t size, Error **errp) { - const char *device = qdict_get_str(qdict, "device"); - int64_t size = qdict_get_int(qdict, "size"); BlockDriverState *bs; bs = bdrv_find(device); if (!bs) { - qerror_report(QERR_DEVICE_NOT_FOUND, device); - return -1; + error_set(errp, QERR_DEVICE_NOT_FOUND, device); + return; } if (size < 0) { - qerror_report(QERR_UNDEFINED_ERROR); - return -1; + error_set(errp, QERR_UNDEFINED_ERROR); + return; } if (bdrv_truncate(bs, size)) { - qerror_report(QERR_UNDEFINED_ERROR); - return -1; + error_set(errp, QERR_UNDEFINED_ERROR); + return; } - - return 0; } diff --git a/blockdev.h b/blockdev.h index 93311a9..b69a549 100644 --- a/blockdev.h +++ b/blockdev.h @@ -65,6 +65,5 @@ int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data); int do_block_set_io_throttle(Monitor *mon, const QDict *qdict, QObject **ret_data); int do_snapshot_blkdev(Monitor *mon, const QDict *qdict, QObject **ret_data); -int do_block_resize(Monitor *mon, const QDict *qdict, QObject **ret_data); #endif diff --git a/hmp-commands.hx b/hmp-commands.hx index ea52271..734a364 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -57,8 +57,7 @@ ETEXI .args_type = "device:B,size:o", .params = "device size", .help = "resize a block image", - .user_print = monitor_user_noop, - .mhandler.cmd_new = do_block_resize, + .mhandler.cmd = hmp_block_resize, }, STEXI diff --git a/hmp.c b/hmp.c index e9d1711..db199b2 100644 --- a/hmp.c +++ b/hmp.c @@ -633,3 +633,13 @@ void hmp_balloon(Monitor *mon, const QDict *qdict) error_free(errp); } } + +void hmp_block_resize(Monitor *mon, const QDict *qdict) +{ + const char *device = qdict_get_str(qdict, "device"); + int64_t size = qdict_get_int(qdict, "size"); + Error *errp = NULL; + + qmp_block_resize(device, size, &errp); + hmp_handle_error(mon, &errp); +} diff --git a/hmp.h b/hmp.h index b0984ac..c236fd2 100644 --- a/hmp.h +++ b/hmp.h @@ -44,5 +44,6 @@ void hmp_inject_nmi(Monitor *mon, const QDict *qdict); void hmp_set_link(Monitor *mon, const QDict *qdict); void hmp_block_passwd(Monitor *mon, const QDict *qdict); void hmp_balloon(Monitor *mon, const QDict *qdict); +void hmp_block_resize(Monitor *mon, const QDict *qdict); #endif diff --git a/qapi-schema.json b/qapi-schema.json index 9bfdc39..f33fe00 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1052,3 +1052,21 @@ # Since: 0.14.0 ## { 'command': 'balloon', 'data': {'value': 'int'} } + +## +# @block_resize +# +# Resize a block image while a guest is running. +# +# @device: the name of the device to get the image resized +# +# @size: new image size in bytes +# +# Returns: nothing on success +# If @device is not a valid block device, DeviceNotFound +# +# Notes: This command returns UndefinedError in a number of error conditions. +# +# Since: 0.14.0 +## +{ 'command': 'block_resize', 'data': { 'device': 'str', 'size': 'int' }} diff --git a/qmp-commands.hx b/qmp-commands.hx index 7c377f0..721b157 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -642,10 +642,7 @@ EQMP { .name = "block_resize", .args_type = "device:B,size:o", - .params = "device size", - .help = "resize a block image", - .user_print = monitor_user_noop, - .mhandler.cmd_new = do_block_resize, + .mhandler.cmd_new = qmp_marshal_input_block_resize, }, SQMP