From: Federico Simoncelli <fsimonce@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, Federico Simoncelli <fsimonce@redhat.com>,
mtosatti@redhat.com
Subject: [Qemu-devel] [PATCH 3/3] Add nocreate option to snapshot_blkdev
Date: Wed, 22 Feb 2012 17:13:35 +0000 [thread overview]
Message-ID: <1329930815-7995-4-git-send-email-fsimonce@redhat.com> (raw)
In-Reply-To: <1329930815-7995-1-git-send-email-fsimonce@redhat.com>
Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
---
blockdev.c | 14 ++++++++------
hmp-commands.hx | 16 ++++++++++------
hmp.c | 4 +++-
qapi-schema.json | 8 +++++++-
qmp-commands.hx | 2 +-
5 files changed, 29 insertions(+), 15 deletions(-)
diff --git a/blockdev.c b/blockdev.c
index 7a6613a..2c3e10a 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -647,7 +647,7 @@ void do_commit(Monitor *mon, const QDict *qdict)
void qmp_blockdev_snapshot_sync(const char *device, const char *snapshot_file,
bool has_format, const char *format,
- Error **errp)
+ bool has_nocreate, bool nocreate, Error **errp)
{
BlockDriverState *bs;
BlockDriver *drv, *old_drv, *proto_drv;
@@ -686,11 +686,13 @@ void qmp_blockdev_snapshot_sync(const char *device, const char *snapshot_file,
return;
}
- ret = bdrv_img_create(snapshot_file, format, bs->filename,
- bs->drv->format_name, NULL, -1, flags);
- if (ret) {
- error_set(errp, QERR_UNDEFINED_ERROR);
- return;
+ if (!(has_nocreate && nocreate)) {
+ ret = bdrv_img_create(snapshot_file, format, bs->filename,
+ bs->drv->format_name, NULL, -1, flags);
+ if (ret) {
+ error_set(errp, QERR_UNDEFINED_ERROR);
+ return;
+ }
}
bdrv_drain_all();
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 573b823..ff49412 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -868,14 +868,18 @@ ETEXI
{
.name = "snapshot_blkdev",
- .args_type = "device:B,snapshot-file:s?,format:s?",
- .params = "device [new-image-file] [format]",
+ .args_type = "nocreate:-n,device:B,snapshot-file:s?,format:s?",
+ .params = "[-n] device [new-image-file] [format]",
.help = "initiates a live snapshot\n\t\t\t"
"of device. If a new image file is specified, the\n\t\t\t"
- "new image file will become the new root image.\n\t\t\t"
- "If format is specified, the snapshot file will\n\t\t\t"
- "be created in that format. Otherwise the\n\t\t\t"
- "snapshot will be internal! (currently unsupported)",
+ "new image file will be created (unless -n is\n\t\t\t"
+ "specified) and will become the new root image.\n\t\t\t"
+ "The -n (nocreate) option is potentially dangerous\n\t\t\t"
+ "if the image wasn't prepared in the correct way\n\t\t\t"
+ "by an external manager. If format is specified,\n\t\t\t"
+ "the snapshot file will be created in that format.\n\t\t\t"
+ "Otherwise the snapshot will be internal!\n\t\t\t"
+ "(currently unsupported)",
.mhandler.cmd = hmp_snapshot_blkdev,
},
diff --git a/hmp.c b/hmp.c
index 8ff8c94..44868c7 100644
--- a/hmp.c
+++ b/hmp.c
@@ -684,6 +684,7 @@ void hmp_block_resize(Monitor *mon, const QDict *qdict)
void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
{
+ int nocreate = qdict_get_try_bool(qdict, "nocreate", 0);
const char *device = qdict_get_str(qdict, "device");
const char *filename = qdict_get_try_str(qdict, "snapshot-file");
const char *format = qdict_get_try_str(qdict, "format");
@@ -697,7 +698,8 @@ void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
return;
}
- qmp_blockdev_snapshot_sync(device, filename, !!format, format, &errp);
+ qmp_blockdev_snapshot_sync(device, filename,
+ !!format, format, true, nocreate, &errp);
hmp_handle_error(mon, &errp);
}
diff --git a/qapi-schema.json b/qapi-schema.json
index d02ee86..ac652c2 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1116,9 +1116,14 @@
# @snapshot-file: the target of the new image. If the file exists, or if it
# is a device, the snapshot will be created in the existing
# file/device. If does not exist, a new file will be created.
+# This behavior can be overridden using the nocreate option.
#
# @format: #optional the format of the snapshot image, default is 'qcow2'.
#
+# @nocreate: #optional use the target image avoiding the creation. This is
+# a potentially dangerous option if the image wasn't prepared
+# in the correct way by an external manager.
+#
# Returns: nothing on success
# If @device is not a valid block device, DeviceNotFound
# If @snapshot-file can't be opened, OpenFileFailed
@@ -1133,7 +1138,8 @@
# Since 0.14.0
##
{ 'command': 'blockdev-snapshot-sync',
- 'data': { 'device': 'str', 'snapshot-file': 'str', '*format': 'str' } }
+ 'data': { 'device': 'str', 'snapshot-file': 'str', '*format': 'str',
+ '*nocreate': 'bool' } }
##
# @human-monitor-command:
diff --git a/qmp-commands.hx b/qmp-commands.hx
index b5e2ab8..e717826 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -668,7 +668,7 @@ EQMP
{
.name = "blockdev-snapshot-sync",
- .args_type = "device:B,snapshot-file:s,format:s?",
+ .args_type = "nocreate:-n,device:B,snapshot-file:s,format:s?",
.mhandler.cmd_new = qmp_marshal_input_blockdev_snapshot_sync,
},
--
1.7.1
next prev parent reply other threads:[~2012-02-22 17:14 UTC|newest]
Thread overview: 95+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-22 17:13 [Qemu-devel] Live Block Migration using Mirroring Federico Simoncelli
2012-02-22 17:13 ` [Qemu-devel] [PATCH 1/3] Add blkmirror block driver Federico Simoncelli
2012-02-23 16:14 ` Stefan Hajnoczi
2012-02-23 16:18 ` Stefan Hajnoczi
2012-02-23 16:20 ` Federico Simoncelli
2012-02-23 16:28 ` Stefan Hajnoczi
2012-02-23 16:51 ` Federico Simoncelli
2012-02-23 16:18 ` Federico Simoncelli
2012-02-27 9:23 ` Stefan Hajnoczi
2012-02-27 11:37 ` Paolo Bonzini
2012-02-27 11:42 ` Stefan Hajnoczi
2012-02-27 11:48 ` Paolo Bonzini
2012-02-27 13:09 ` Stefan Hajnoczi
2012-02-27 13:47 ` Paolo Bonzini
2012-02-27 14:49 ` Stefan Hajnoczi
2012-02-27 14:59 ` Stefan Hajnoczi
2012-02-27 15:08 ` Paolo Bonzini
2012-02-22 17:13 ` [Qemu-devel] [PATCH 2/3] Update the " Federico Simoncelli
2012-02-23 7:18 ` Paolo Bonzini
2012-02-23 9:44 ` Federico Simoncelli
2012-02-23 9:45 ` Paolo Bonzini
2012-02-22 17:13 ` Federico Simoncelli [this message]
2012-02-23 7:19 ` [Qemu-devel] [PATCH 3/3] Add nocreate option to snapshot_blkdev Paolo Bonzini
2012-02-23 7:38 ` Paolo Bonzini
2012-02-23 9:39 ` Federico Simoncelli
2012-02-23 9:48 ` Paolo Bonzini
2012-02-23 10:19 ` Federico Simoncelli
2012-02-23 11:30 ` Paolo Bonzini
2012-02-23 15:47 ` [Qemu-devel] Live Block Migration using Mirroring Stefan Hajnoczi
2012-02-23 16:10 ` Federico Simoncelli
2012-02-23 16:35 ` Stefan Hajnoczi
2012-02-23 17:06 ` Federico Simoncelli
2012-02-24 11:37 ` [Qemu-devel] [PATCH 1/2] Add blkmirror block driver Federico Simoncelli
2012-02-24 11:37 ` [Qemu-devel] [PATCH 2/2] Add the blockdev-reopen and blockdev-migrate commands Federico Simoncelli
2012-02-24 12:03 ` Kevin Wolf
2012-02-24 12:12 ` Federico Simoncelli
2012-02-24 13:11 ` Paolo Bonzini
2012-02-24 17:04 ` Luiz Capitulino
2012-02-27 14:57 ` Markus Armbruster
2012-02-24 16:49 ` [Qemu-devel] [PATCH 1/2 v2] Add blkmirror block driver Federico Simoncelli
2012-02-24 17:02 ` Eric Blake
2012-02-24 17:15 ` Federico Simoncelli
2012-02-24 18:49 ` Paolo Bonzini
2012-02-24 18:17 ` Luiz Capitulino
2012-02-27 9:17 ` Federico Simoncelli
2012-02-24 16:49 ` [Qemu-devel] [PATCH 2/2 v2] Add the blockdev-reopen and blockdev-migrate commands Federico Simoncelli
2012-02-24 17:46 ` Eric Blake
2012-02-24 18:57 ` Paolo Bonzini
2012-02-24 19:37 ` Eric Blake
2012-02-24 19:01 ` Luiz Capitulino
2012-02-24 19:40 ` Eric Blake
2012-02-24 20:26 ` Luiz Capitulino
2012-02-24 22:46 ` Eric Blake
2012-02-24 20:32 ` Paolo Bonzini
2012-02-24 20:36 ` Luiz Capitulino
2012-02-24 21:05 ` Paolo Bonzini
2012-02-24 22:30 ` Eric Blake
2012-02-25 6:47 ` Paolo Bonzini
2012-02-27 11:29 ` Federico Simoncelli
2012-02-27 12:12 ` Luiz Capitulino
2012-02-27 12:49 ` Paolo Bonzini
2012-02-27 13:06 ` Luiz Capitulino
2012-02-27 14:39 ` [Qemu-devel] drive transactions (was Re: [PATCH 2/2 v2] Add the blockdev-reopen and blockdev-migrate commands) Paolo Bonzini
2012-02-27 14:46 ` Anthony Liguori
2012-02-27 14:54 ` Paolo Bonzini
2012-02-27 14:59 ` Anthony Liguori
2012-02-27 15:03 ` Paolo Bonzini
2012-02-27 15:06 ` Anthony Liguori
2012-02-27 15:17 ` Kevin Wolf
2012-02-27 15:24 ` Anthony Liguori
2012-02-27 16:51 ` Paolo Bonzini
2012-02-27 16:58 ` Anthony Liguori
2012-02-27 17:06 ` Paolo Bonzini
2012-02-27 16:33 ` Federico Simoncelli
2012-02-27 16:41 ` Paolo Bonzini
2012-02-27 16:42 ` Anthony Liguori
2012-02-27 16:50 ` Federico Simoncelli
2012-02-27 16:53 ` Anthony Liguori
2012-02-27 16:54 ` Paolo Bonzini
2012-02-27 16:59 ` Anthony Liguori
2012-02-27 17:37 ` Luiz Capitulino
2012-02-28 15:47 ` [Qemu-devel] Live Block Migration using Mirroring Stefan Hajnoczi
2012-02-28 17:15 ` Federico Simoncelli
2012-02-28 17:36 ` Paolo Bonzini
2012-02-28 17:46 ` Federico Simoncelli
2012-02-28 18:02 ` Paolo Bonzini
2012-02-28 18:21 ` Federico Simoncelli
2012-02-28 17:26 ` Paolo Bonzini
2012-02-29 12:28 ` [Qemu-devel] [PATCHv3] Add blkmirror block driver Federico Simoncelli
2012-02-29 13:02 ` Federico Simoncelli
2012-02-29 17:01 ` [Qemu-devel] [PATCHv4] " Federico Simoncelli
2012-03-05 16:59 ` [Qemu-devel] Live Block Migration using Mirroring Marcelo Tosatti
2012-03-05 17:20 ` Eric Blake
2012-03-05 17:44 ` Marcelo Tosatti
2012-03-05 18:05 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1329930815-7995-4-git-send-email-fsimonce@redhat.com \
--to=fsimonce@redhat.com \
--cc=kwolf@redhat.com \
--cc=mtosatti@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).