From patchwork Thu Mar 28 16:47:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Hrdina X-Patchwork-Id: 232128 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 C0EAB2C007C for ; Fri, 29 Mar 2013 03:59:48 +1100 (EST) Received: from localhost ([::1]:39181 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ULGB1-00035E-41 for incoming@patchwork.ozlabs.org; Thu, 28 Mar 2013 12:59:47 -0400 Received: from eggs.gnu.org ([208.118.235.92]:48129) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ULFzL-0007HO-TH for qemu-devel@nongnu.org; Thu, 28 Mar 2013 12:47:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ULFzK-0004Oj-59 for qemu-devel@nongnu.org; Thu, 28 Mar 2013 12:47:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48600) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ULFzJ-0004OR-TA for qemu-devel@nongnu.org; Thu, 28 Mar 2013 12:47:42 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r2SGlfKa017313 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 28 Mar 2013 12:47:41 -0400 Received: from localhost.localdomain.com (dhcp-27-230.brq.redhat.com [10.34.27.230]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r2SGlIRL018303; Thu, 28 Mar 2013 12:47:39 -0400 From: Pavel Hrdina To: qemu-devel@nongnu.org Date: Thu, 28 Mar 2013 17:47:15 +0100 Message-Id: <72b352c53d8684c210c57c49e35e81fab019f61f.1364487348.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: phrdina@redhat.com, armbru@redhat.com, lcapitulino@redhat.com Subject: [Qemu-devel] [PATCH v3 11/11] savevm: add force parameter to HMP command and return snapshot info 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 HMP command "savevm" now takes extra optional force parameter to specify whether replace existing snapshot or not. It also returns information about created snapshot. Signed-off-by: Pavel Hrdina Reviewed-by: Eric Blake --- hmp-commands.hx | 16 ++++++++-------- hmp.c | 18 +++++++++++++++++- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index 382b87d..9719cc0 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -307,19 +307,19 @@ ETEXI { .name = "savevm", - .args_type = "name:s?", - .params = "[tag|id]", - .help = "save a VM snapshot. If no tag or id are provided, a new snapshot is created", + .args_type = "force:-f,name:s?", + .params = "[-f] [tag|id]", + .help = "save a VM snapshot, to replace existing snapshot use force flag", .mhandler.cmd = hmp_vm_snapshot_save, }, STEXI -@item savevm [@var{tag}|@var{id}] +@item savevm [@var{-f}] @var{tag}|@var{id} @findex savevm -Create a snapshot of the whole virtual machine. If @var{tag} is -provided, it is used as human readable identifier. If there is already -a snapshot with the same @var{tag} or @var{id}, it is replaced. More info at -@ref{vm_snapshots}. +Create a snapshot of the whole virtual machine. Parameter "name" is optional. +If @var{tag} is provided, it is used as human readable identifier. If there is +already a snapshot with the same @var{tag} or @var{id}, @var{-f} flag needs to +be specified. More info at @ref{vm_snapshots}. ETEXI { diff --git a/hmp.c b/hmp.c index b38b6ce..adf586b 100644 --- a/hmp.c +++ b/hmp.c @@ -1437,10 +1437,26 @@ void hmp_chardev_remove(Monitor *mon, const QDict *qdict) void hmp_vm_snapshot_save(Monitor *mon, const QDict *qdict) { const char *name = qdict_get_try_str(qdict, "name"); + bool force = qdict_get_try_bool(qdict, "force", 0); Error *err = NULL; SnapshotInfo *info = NULL; - info = qmp_vm_snapshot_save(!!name, name, true, true, &err); + info = qmp_vm_snapshot_save(!!name, name, !!force, force, &err); + + if (info) { + char buf[256]; + QEMUSnapshotInfo sn = { + .vm_state_size = info->vm_state_size, + .date_sec = info->date_sec, + .date_nsec = info->date_nsec, + .vm_clock_nsec = info->vm_clock_sec * 1000000000 + + info->vm_clock_nsec, + }; + pstrcpy(sn.id_str, sizeof(sn.id_str), info->id); + pstrcpy(sn.name, sizeof(sn.name), info->name); + monitor_printf(mon, "%s\n", bdrv_snapshot_dump(buf, sizeof(buf), &sn)); + } + qapi_free_SnapshotInfo(info); hmp_handle_error(mon, &err); }