From patchwork Fri Sep 10 01:43:34 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: disheng.su@gmail.com X-Patchwork-Id: 64346 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 601B9B712D for ; Fri, 10 Sep 2010 11:48:19 +1000 (EST) Received: from localhost ([127.0.0.1]:60818 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Otsiu-0000RO-9d for incoming@patchwork.ozlabs.org; Thu, 09 Sep 2010 21:48:16 -0400 Received: from [140.186.70.92] (port=50975 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Otsi7-0000QX-VO for qemu-devel@nongnu.org; Thu, 09 Sep 2010 21:47:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Otsi6-0003dO-Ou for qemu-devel@nongnu.org; Thu, 09 Sep 2010 21:47:27 -0400 Received: from mail-px0-f173.google.com ([209.85.212.173]:41454) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Otsi6-0003dE-I4 for qemu-devel@nongnu.org; Thu, 09 Sep 2010 21:47:26 -0400 Received: by pxi12 with SMTP id 12so789246pxi.4 for ; Thu, 09 Sep 2010 18:47:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=A012fTKfAbup710IFWQv6uzBIeYeM0LHU0XovbjgqvI=; b=eBHlZzfTDVB3jtuskZVZqcxZfSR8Kzn20fKCa3Jx5aletvl9XW4Q6S6ztBeGqM0lvl j7mCqojpyFVj5CIdrsJO7vaUX8gq1tPKHdMlUeJR+7OWzrElfyzVfEkRn3Dz0PBnIUQq dl9xjOiYQzIR+OkMbSSu2rLZ/g3wnJ2o5/EPA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=WYNl0YdYxxbSSmBs5irKod5KjFsqmYvPwgIayzmq2FcowHXGTFrlvI0ZFI8zpFyqUe MQSKlbjRsY6gnbFLbUktnyHrD/IF+w0PW87QBm7v2VtQw4I/sQZRQiJaBSF98gEuaRgd C6oqwcwFnQhbfnfA+XrDtfENB5Ao3DVgwu/K8= Received: by 10.143.164.14 with SMTP id r14mr238883wfo.53.1284083245505; Thu, 09 Sep 2010 18:47:25 -0700 (PDT) Received: from localhost.localdomain (adsl-99-57-184-141.dsl.pltn13.sbcglobal.net [99.57.184.141]) by mx.google.com with ESMTPS id l41sm2314635wfa.1.2010.09.09.18.47.22 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 09 Sep 2010 18:47:24 -0700 (PDT) From: disheng.su@gmail.com To: qemu-devel@nongnu.org Date: Thu, 9 Sep 2010 18:43:34 -0700 Message-Id: <1284083014-8198-1-git-send-email-disheng.su@gmail.com> X-Mailer: git-send-email 1.7.2.2 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: edison Subject: [Qemu-devel] [PATCH] [RFC] savevm only saves disk state X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: edison Add a new option when "savevm": savevm -n snapshotName, which only takes snapshot on disk, but doesn't save vm state(memory,cpu,devices...). Saving vm state on QCOW2 disk will take a long time, per my test, it will take 1~2 minutes to "savevm" on VM with 1G memory. Even worse, the VM is wholely stopped at that time, makes "savevm" not that useful. All we know the side effect of it:) but does it make sense to give user the choice? --- qemu-monitor.hx | 6 +++--- savevm.c | 34 ++++++++++++++++++++++------------ 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/qemu-monitor.hx b/qemu-monitor.hx index 49bcd8d..724e0a2 100644 --- a/qemu-monitor.hx +++ b/qemu-monitor.hx @@ -327,9 +327,9 @@ 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 = "nostate:-n,name:s?", + .params = "[-n] [tag|id]", + .help = "save a VM snapshot. If no tag or id are provided, a new snapshot is created. If -n is specified, do not save vm state", .mhandler.cmd = do_savevm, }, diff --git a/savevm.c b/savevm.c index 6fa7a5f..b0963b5 100644 --- a/savevm.c +++ b/savevm.c @@ -1834,7 +1834,8 @@ void do_savevm(Monitor *mon, const QDict *qdict) int ret; QEMUFile *f; int saved_vm_running; - uint32_t vm_state_size; + uint32_t vm_state_size = 0; + #ifdef _WIN32 struct _timeb tb; struct tm *ptm; @@ -1844,6 +1845,8 @@ void do_savevm(Monitor *mon, const QDict *qdict) #endif const char *name = qdict_get_try_str(qdict, "name"); + int nostate = qdict_get_try_bool(qdict, "nostate", 0); + /* Verify if there is a device that doesn't support snapshots and is writable */ bs = NULL; while ((bs = bdrv_next(bs))) { @@ -1909,17 +1912,19 @@ void do_savevm(Monitor *mon, const QDict *qdict) } /* save the VM state */ - f = qemu_fopen_bdrv(bs, 1); - if (!f) { - monitor_printf(mon, "Could not open VM state file\n"); - goto the_end; - } - ret = qemu_savevm_state(mon, f); - vm_state_size = qemu_ftell(f); - qemu_fclose(f); - if (ret < 0) { - monitor_printf(mon, "Error %d while writing VM\n", ret); - goto the_end; + if (!nostate) { + f = qemu_fopen_bdrv(bs, 1); + if (!f) { + monitor_printf(mon, "Could not open VM state file\n"); + goto the_end; + } + ret = qemu_savevm_state(mon, f); + vm_state_size = qemu_ftell(f); + qemu_fclose(f); + if (ret < 0) { + monitor_printf(mon, "Error %d while writing VM\n", ret); + goto the_end; + } } /* create the snapshots */ @@ -1984,6 +1989,11 @@ int load_vmstate(const char *name) bdrv_get_device_name(bs), name); return ret; } + + if (sn.vm_state_size == 0) { + error_report("No vm state stored on snapshot: '%s'.", name); + return -ENOTSUP; + } } /* Flush all IO requests so they don't interfere with the new state. */