From patchwork Wed Aug 15 07:41:56 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Hrdina X-Patchwork-Id: 177575 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 C12F12C008B for ; Wed, 15 Aug 2012 18:45:50 +1000 (EST) Received: from localhost ([::1]:40385 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T1YGC-0007IW-Hm for incoming@patchwork.ozlabs.org; Wed, 15 Aug 2012 03:43:24 -0400 Received: from eggs.gnu.org ([208.118.235.92]:56044) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T1YFC-0005qo-Ix for qemu-devel@nongnu.org; Wed, 15 Aug 2012 03:42:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T1YFB-00005E-BI for qemu-devel@nongnu.org; Wed, 15 Aug 2012 03:42:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:62246) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T1YFB-000059-3m for qemu-devel@nongnu.org; Wed, 15 Aug 2012 03:42:21 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q7F7gKwO021396 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 15 Aug 2012 03:42:20 -0400 Received: from antique-laptop.brq.redhat.com (dhcp-27-198.brq.redhat.com [10.34.27.198]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q7F7g0er009478; Wed, 15 Aug 2012 03:42:19 -0400 From: Pavel Hrdina To: qemu-devel@nongnu.org Date: Wed, 15 Aug 2012 09:41:56 +0200 Message-Id: <4238536125b714c789796f24091077f8c135b004.1345016001.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Pavel Hrdina Subject: [Qemu-devel] [PATCH 15/18] qapi: Convert delvm 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 --- hmp-commands.hx | 2 +- hmp.c | 10 ++++++++++ hmp.h | 1 + qapi-schema.json | 14 ++++++++++++++ qmp-commands.hx | 24 ++++++++++++++++++++++++ savevm.c | 17 +++-------------- sysemu.h | 1 - 7 files changed, 53 insertions(+), 16 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index f9709d9..d6cd94c 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -299,7 +299,7 @@ ETEXI .args_type = "name:s", .params = "tag|id", .help = "delete a VM snapshot from its tag or id", - .mhandler.cmd = do_delvm, + .mhandler.cmd = hmp_vm_snapshot_delete, }, STEXI diff --git a/hmp.c b/hmp.c index c2db7b2..a3fd8ca 100644 --- a/hmp.c +++ b/hmp.c @@ -1122,3 +1122,13 @@ void hmp_vm_snapshot_load(Monitor *mon, const QDict *qdict) hmp_handle_error(mon, &err); } + +void hmp_vm_snapshot_delete(Monitor *mon, const QDict *qdict) +{ + const char *name = qdict_get_str(qdict, "name"); + Error *err = NULL; + + qmp_vm_snapshot_delete(name, &err); + + hmp_handle_error(mon, &err); +} diff --git a/hmp.h b/hmp.h index b669b66..738d9bc 100644 --- a/hmp.h +++ b/hmp.h @@ -73,5 +73,6 @@ void hmp_getfd(Monitor *mon, const QDict *qdict); void hmp_closefd(Monitor *mon, const QDict *qdict); void hmp_vm_snapshot_save(Monitor *mon, const QDict *qdict); void hmp_vm_snapshot_load(Monitor *mon, const QDict *qdict); +void hmp_vm_snapshot_delete(Monitor *mon, const QDict *qdict); #endif diff --git a/qapi-schema.json b/qapi-schema.json index c477b26..feea992 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -2390,3 +2390,17 @@ # Since: 1.2 ## { 'command': 'vm-snapshot-load', 'data': {'name': 'str'} } + +## +# @vm-snapshot-delete: +# +# Delete the snapshot identified by 'tag' or 'id'. +# +# @name: tag or id of existing snapshot +# +# Returns: Nothing on success +# If an error occurs, GenericError with error message +# +# Since: 1.2 +## +{ 'command': 'vm-snapshot-delete', 'data': {'name': 'str'} } diff --git a/qmp-commands.hx b/qmp-commands.hx index a044345..bca4267 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -1165,6 +1165,30 @@ Example: EQMP { + .name = "vm-snapshot-delete", + .args_type = "name:s", + .params = "tag|id", + .help = "delete a VM snapshot from its tag or id", + .mhandler.cmd_new = qmp_marshal_input_vm_snapshot_delete + }, + +SQMP +vm-snapshot-delete +------ + +Delete the snapshot identified by 'tag' or 'id'. + +Arguments: + +- "name": tag or id of existing snapshot + +Example: + +-> { "execute": "vm-snapshot-delete", "arguments": { "name": "my_snapshot" } } +<- { "return": {} } + +EQMP + { .name = "qmp_capabilities", .args_type = "", .params = "", diff --git a/savevm.c b/savevm.c index 0b95646..3f7ec44 100644 --- a/savevm.c +++ b/savevm.c @@ -2314,31 +2314,20 @@ void qmp_vm_snapshot_load(const char *name, Error **errp) } } -void do_delvm(Monitor *mon, const QDict *qdict) +void qmp_vm_snapshot_delete(const char *name, Error **errp) { BlockDriverState *bs, *bs1; - int ret; - const char *name = qdict_get_str(qdict, "name"); bs = bdrv_snapshots(); if (!bs) { - monitor_printf(mon, "No block device supports snapshots\n"); + error_set(errp, QERR_NOT_SUPPORTED); return; } bs1 = NULL; while ((bs1 = bdrv_next(bs1))) { if (bdrv_can_snapshot(bs1)) { - ret = bdrv_snapshot_delete(bs1, name, NULL); - if (ret < 0) { - if (ret == -ENOTSUP) - monitor_printf(mon, - "Snapshots not supported on device '%s'\n", - bdrv_get_device_name(bs1)); - else - monitor_printf(mon, "Error %d while deleting snapshot on " - "'%s'\n", ret, bdrv_get_device_name(bs1)); - } + bdrv_snapshot_delete(bs1, name, errp); } } } diff --git a/sysemu.h b/sysemu.h index 3327c49..44afe61 100644 --- a/sysemu.h +++ b/sysemu.h @@ -69,7 +69,6 @@ void qemu_remove_exit_notifier(Notifier *notify); void qemu_add_machine_init_done_notifier(Notifier *notify); -void do_delvm(Monitor *mon, const QDict *qdict); void do_info_snapshots(Monitor *mon); void qemu_announce_self(void);