From: "Daniel P. Berrangé" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Kevin Wolf" <kwolf@redhat.com>,
"Peter Krempa" <pkrempa@redhat.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
qemu-block@nongnu.org, "Juan Quintela" <quintela@redhat.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Pavel Dovgalyuk" <pavel.dovgaluk@ispras.ru>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Max Reitz" <mreitz@redhat.com>
Subject: [PATCH 4/6] block: allow specifying name of block device for vmstate storage
Date: Thu, 2 Jul 2020 18:57:52 +0100 [thread overview]
Message-ID: <20200702175754.2211821-5-berrange@redhat.com> (raw)
In-Reply-To: <20200702175754.2211821-1-berrange@redhat.com>
Currently the vmstate will be stored in the first block device that
supports snapshots. Historically this would have usually been the
root device, but with UEFI it might be the variable store. There
needs to be a way to override the choice of block device to store
the state in.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
block/monitor/block-hmp-cmds.c | 2 +-
block/snapshot.c | 33 +++++++++++++++++++++++++++++----
include/block/snapshot.h | 4 +++-
migration/savevm.c | 6 ++----
4 files changed, 35 insertions(+), 10 deletions(-)
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
index 0ee6e7a4be..a698fac027 100644
--- a/block/monitor/block-hmp-cmds.c
+++ b/block/monitor/block-hmp-cmds.c
@@ -899,7 +899,7 @@ void hmp_info_snapshots(Monitor *mon, const QDict *qdict)
ImageEntry *image_entry, *next_ie;
SnapshotEntry *snapshot_entry;
- bs = bdrv_all_find_vmstate_bs(NULL);
+ bs = bdrv_all_find_vmstate_bs(NULL, NULL, NULL);
if (!bs) {
monitor_printf(mon, "No available block device supports snapshots\n");
return;
diff --git a/block/snapshot.c b/block/snapshot.c
index c8950b0b86..4774a1890d 100644
--- a/block/snapshot.c
+++ b/block/snapshot.c
@@ -552,7 +552,9 @@ fail:
return err;
}
-BlockDriverState *bdrv_all_find_vmstate_bs(strList *exclude_bs)
+BlockDriverState *bdrv_all_find_vmstate_bs(const char *vmstate_bs,
+ strList *exclude_bs,
+ Error **errp)
{
BlockDriverState *bs;
BdrvNextIterator it;
@@ -560,16 +562,39 @@ BlockDriverState *bdrv_all_find_vmstate_bs(strList *exclude_bs)
for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) {
AioContext *ctx = bdrv_get_aio_context(bs);
bool found;
+ Error *err = NULL;
aio_context_acquire(ctx);
- found = bdrv_all_snapshots_includes_bs(bs, exclude_bs) &&
- bdrv_can_snapshot(bs);
+ if (vmstate_bs == NULL) {
+ found = bdrv_all_snapshots_includes_bs(bs, exclude_bs) &&
+ bdrv_can_snapshot(bs);
+ } else {
+ if (g_str_equal(vmstate_bs, bdrv_get_node_name(bs))) {
+ found = bdrv_all_snapshots_includes_bs(bs, exclude_bs) &&
+ bdrv_can_snapshot(bs);
+ if (!found) {
+ error_setg(&err,
+ "block device '%s' cannot accept snapshots",
+ vmstate_bs);
+ }
+ } else {
+ found = false;
+ }
+ }
aio_context_release(ctx);
- if (found) {
+ if (found || err) {
bdrv_next_cleanup(&it);
+ if (err) {
+ error_propagate(errp, err);
+ return NULL;
+ }
break;
}
}
+
+ if (!bs) {
+ error_setg(errp, "No block device can accept snapshots");
+ }
return bs;
}
diff --git a/include/block/snapshot.h b/include/block/snapshot.h
index f20986ca37..ff627df5cb 100644
--- a/include/block/snapshot.h
+++ b/include/block/snapshot.h
@@ -90,6 +90,8 @@ int bdrv_all_create_snapshot(QEMUSnapshotInfo *sn,
strList *exclude_bs,
BlockDriverState **first_bad_bs);
-BlockDriverState *bdrv_all_find_vmstate_bs(strList *exclude_bs);
+BlockDriverState *bdrv_all_find_vmstate_bs(const char *vmstate_bs,
+ strList *exclude_bs,
+ Error **errp);
#endif
diff --git a/migration/savevm.c b/migration/savevm.c
index 4251aa0dde..b11c6a882d 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -2662,9 +2662,8 @@ int save_snapshot(const char *name, Error **errp)
}
}
- bs = bdrv_all_find_vmstate_bs(NULL);
+ bs = bdrv_all_find_vmstate_bs(NULL, NULL, errp);
if (bs == NULL) {
- error_setg(errp, "No block device can accept snapshots");
return ret;
}
aio_context = bdrv_get_aio_context(bs);
@@ -2857,9 +2856,8 @@ int load_snapshot(const char *name, Error **errp)
return ret;
}
- bs_vm_state = bdrv_all_find_vmstate_bs(NULL);
+ bs_vm_state = bdrv_all_find_vmstate_bs(NULL, NULL, errp);
if (!bs_vm_state) {
- error_setg(errp, "No block device supports snapshots");
return -ENOTSUP;
}
aio_context = bdrv_get_aio_context(bs_vm_state);
--
2.26.2
next prev parent reply other threads:[~2020-07-02 18:01 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-02 17:57 [PATCH 0/6] migration: bring savevm/loadvm/delvm over to QMP Daniel P. Berrangé
2020-07-02 17:57 ` [PATCH 1/6] migration: improve error reporting of block driver state name Daniel P. Berrangé
2020-07-02 18:36 ` Eric Blake
2020-07-02 19:13 ` Dr. David Alan Gilbert
2020-07-02 17:57 ` [PATCH 2/6] migration: introduce savevm, loadvm, delvm QMP commands Daniel P. Berrangé
2020-07-02 18:12 ` Eric Blake
2020-07-02 18:24 ` Daniel P. Berrangé
2020-07-03 15:49 ` Dr. David Alan Gilbert
2020-07-03 16:02 ` Daniel P. Berrangé
2020-07-03 16:10 ` Dr. David Alan Gilbert
2020-07-03 16:16 ` Daniel P. Berrangé
2020-07-03 16:22 ` Dr. David Alan Gilbert
2020-07-03 16:49 ` Daniel P. Berrangé
2020-07-03 17:00 ` Dr. David Alan Gilbert
2020-07-03 17:10 ` Daniel P. Berrangé
2020-07-03 17:26 ` Dr. David Alan Gilbert
2020-07-03 16:24 ` Peter Krempa
2020-07-03 16:26 ` Dr. David Alan Gilbert
2020-07-06 16:15 ` Kevin Wolf
2020-07-07 6:38 ` Peter Krempa
2020-07-07 10:33 ` Kevin Wolf
2020-07-07 10:41 ` Peter Krempa
2020-07-03 17:22 ` Denis V. Lunev
2020-07-02 17:57 ` [PATCH 3/6] block: add ability to filter out blockdevs during snapshot Daniel P. Berrangé
2020-07-02 17:57 ` Daniel P. Berrangé [this message]
2020-07-02 17:57 ` [PATCH 5/6] migration: support excluding block devs in QMP snapshot commands Daniel P. Berrangé
2020-07-06 15:57 ` Kevin Wolf
2020-07-07 9:14 ` Daniel P. Berrangé
2020-07-07 10:11 ` Kevin Wolf
2020-07-02 17:57 ` [PATCH 6/6] migration: support picking vmstate disk " Daniel P. Berrangé
2020-07-02 18:19 ` Eric Blake
2020-07-03 8:37 ` Daniel P. Berrangé
2020-07-02 18:53 ` [PATCH 0/6] migration: bring savevm/loadvm/delvm over to QMP no-reply
2020-07-02 19:07 ` no-reply
2020-07-03 17:15 ` Denis V. Lunev
2020-07-03 17:22 ` Daniel P. Berrangé
2020-07-03 17:29 ` Denis V. Lunev
2020-07-06 14:28 ` Daniel P. Berrangé
2020-07-06 16:07 ` Denis V. Lunev
2020-07-06 15:27 ` Kevin Wolf
2020-07-06 15:29 ` Daniel P. Berrangé
2020-07-06 15:50 ` Kevin Wolf
2020-07-06 16:03 ` Daniel P. Berrangé
2020-07-06 16:10 ` Denis V. Lunev
2020-07-06 16:15 ` Daniel P. Berrangé
2020-07-06 16:21 ` Kevin Wolf
2020-07-07 9:07 ` Daniel P. Berrangé
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=20200702175754.2211821-5-berrange@redhat.com \
--to=berrange@redhat.com \
--cc=armbru@redhat.com \
--cc=dgilbert@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=pavel.dovgaluk@ispras.ru \
--cc=pbonzini@redhat.com \
--cc=pkrempa@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
/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).