From patchwork Thu Jun 14 07:32:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Hrdina X-Patchwork-Id: 164857 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4ADD610080F for ; Thu, 14 Jun 2012 17:32:46 +1000 (EST) Received: from localhost ([::1]:32786 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sf4Xs-000345-6N for incoming@patchwork.ozlabs.org; Thu, 14 Jun 2012 03:32:44 -0400 Received: from eggs.gnu.org ([208.118.235.92]:47423) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sf4Xk-000340-HW for qemu-devel@nongnu.org; Thu, 14 Jun 2012 03:32:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sf4Xf-0004g8-Ir for qemu-devel@nongnu.org; Thu, 14 Jun 2012 03:32:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:19889) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sf4Xf-0004g1-Aa for qemu-devel@nongnu.org; Thu, 14 Jun 2012 03:32:31 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q5E7WTjO022454 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 14 Jun 2012 03:32:30 -0400 Received: from antique-laptop.brq.redhat.com (dhcp-27-171.brq.redhat.com [10.34.27.171]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q5E7WSZ1023940; Thu, 14 Jun 2012 03:32:28 -0400 From: Pavel Hrdina To: qemu-devel@nongnu.org Date: Thu, 14 Jun 2012 09:32:27 +0200 Message-Id: <806c66b2f071f03bec0b7d45a71512e394386885.1339617170.git.phrdina@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, Pavel Hrdina , lcapitulino@redhat.com Subject: [Qemu-devel] [PATCH] qapi: converted commit 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: Pavel Hrdina --- blockdev.c | 9 ++++----- blockdev.h | 1 - hmp-commands.hx | 2 +- hmp.c | 9 +++++++++ hmp.h | 1 + qapi-schema.json | 15 +++++++++++++++ qmp-commands.hx | 24 ++++++++++++++++++++++++ 7 files changed, 54 insertions(+), 7 deletions(-) diff --git a/blockdev.c b/blockdev.c index 622ecba..d78af31 100644 --- a/blockdev.c +++ b/blockdev.c @@ -631,27 +631,26 @@ err: return NULL; } -void do_commit(Monitor *mon, const QDict *qdict) +void qmp_commit(const char *device, Error **errp) { - const char *device = qdict_get_str(qdict, "device"); BlockDriverState *bs; int ret; if (!strcmp(device, "all")) { ret = bdrv_commit_all(); if (ret == -EBUSY) { - qerror_report(QERR_DEVICE_IN_USE, device); + error_set(errp, QERR_DEVICE_IN_USE, device); return; } } else { bs = bdrv_find(device); if (!bs) { - qerror_report(QERR_DEVICE_NOT_FOUND, device); + error_set(errp, QERR_DEVICE_NOT_FOUND, device); return; } ret = bdrv_commit(bs); if (ret == -EBUSY) { - qerror_report(QERR_DEVICE_IN_USE, device); + error_set(errp, QERR_DEVICE_IN_USE, device); return; } } diff --git a/blockdev.h b/blockdev.h index 260e16b..c2e52bb 100644 --- a/blockdev.h +++ b/blockdev.h @@ -60,6 +60,5 @@ DriveInfo *add_init_drive(const char *opts); void qmp_change_blockdev(const char *device, const char *filename, bool has_format, const char *format, Error **errp); -void do_commit(Monitor *mon, const QDict *qdict); int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data); #endif diff --git a/hmp-commands.hx b/hmp-commands.hx index f5d9d91..53d2c34 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -28,7 +28,7 @@ ETEXI .args_type = "device:B", .params = "device|all", .help = "commit changes to the disk images (if -snapshot is used) or backing files", - .mhandler.cmd = do_commit, + .mhandler.cmd = hmp_commit, }, STEXI diff --git a/hmp.c b/hmp.c index 2ce8cb9..176defa 100644 --- a/hmp.c +++ b/hmp.c @@ -999,3 +999,12 @@ void hmp_netdev_del(Monitor *mon, const QDict *qdict) qmp_netdev_del(id, &err); hmp_handle_error(mon, &err); } + +void hmp_commit(Monitor *mon, const QDict *qdict) +{ + const char *device = qdict_get_str(qdict, "device"); + Error *err = NULL; + + qmp_commit(device, &err); + hmp_handle_error(mon, &err); +} diff --git a/hmp.h b/hmp.h index 79d138d..99d57c0 100644 --- a/hmp.h +++ b/hmp.h @@ -64,5 +64,6 @@ void hmp_device_del(Monitor *mon, const QDict *qdict); void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict); void hmp_netdev_add(Monitor *mon, const QDict *qdict); void hmp_netdev_del(Monitor *mon, const QDict *qdict); +void hmp_commit(Monitor *mon, const QDict *qdict); #endif diff --git a/qapi-schema.json b/qapi-schema.json index 3b6e346..10cb22b 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1169,6 +1169,21 @@ { 'command': 'block_resize', 'data': { 'device': 'str', 'size': 'int' }} ## +# @commit +# +# Commit changes to the disk images (if -snapshot is used) or backing files. +# +# @device: the name of the device or the "all" to commit all devices +# +# Returns: nothing on success +# If @device is not a valid block device, DeviceNotFound +# If a long-running operation is using the device, DeviceInUse +# +# Since: 1.1 +## +{ 'command': 'commit', 'data': { 'device': 'str' }} + +## # @NewImageMode # # An enumeration that tells QEMU how to set the backing file path in diff --git a/qmp-commands.hx b/qmp-commands.hx index 2e1a38e..8b6bfbc 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -714,6 +714,30 @@ Example: -> { "execute": "block_resize", "arguments": { "device": "scratch", "size": 1073741824 } } <- { "return": {} } + +EQMP + + { + .name = "commit", + .args_type = "device:B", + .mhandler.cmd_new = qmp_marshal_input_commit, + }, + +SQMP +commit +------ + +Commit changes to the disk images (if -snapshot is used) or backing files. + +Arguments: + +- "device": the device's ID, or all (json-string) + +Example: + +-> { "execute": "commit", "arguments": { "device": "all" } } +<- { "return": {} } + EQMP {