From: Avihai Horon <avihaih@nvidia.com>
To: <qemu-devel@nongnu.org>
Cc: "Alex Williamson" <alex.williamson@redhat.com>,
"Cédric Le Goater" <clg@redhat.com>,
"Juan Quintela" <quintela@redhat.com>,
"Peter Xu" <peterx@redhat.com>,
"Leonardo Bras" <leobras@redhat.com>,
"Yanghang Liu" <yanghliu@redhat.com>,
"Avihai Horon" <avihaih@nvidia.com>
Subject: [PATCH v2 5/5] vfio/migration: Block VFIO migration with background snapshot
Date: Thu, 31 Aug 2023 15:57:02 +0300 [thread overview]
Message-ID: <20230831125702.11263-6-avihaih@nvidia.com> (raw)
In-Reply-To: <20230831125702.11263-1-avihaih@nvidia.com>
Background snapshot allows creating a snapshot of the VM while it's
running and keeping it small by not including dirty RAM pages.
The way it works is by first stopping the VM, saving the non-iterable
devices' state and then starting the VM and saving the RAM while write
protecting it with UFFD. The resulting snapshot represents the VM state
at snapshot start.
VFIO migration is not compatible with background snapshot.
First of all, VFIO device state is not even saved in background snapshot
because only non-iterable device state is saved. But even if it was
saved, after starting the VM, a VFIO device could dirty pages without it
being detected by UFFD write protection. This would corrupt the
snapshot, as the RAM in it would not represent the RAM at snapshot
start.
To prevent this, block VFIO migration with background snapshot.
Signed-off-by: Avihai Horon <avihaih@nvidia.com>
---
hw/vfio/migration.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c
index 20994dc1d6..da43dcd2fe 100644
--- a/hw/vfio/migration.c
+++ b/hw/vfio/migration.c
@@ -340,7 +340,8 @@ static int vfio_save_prepare(void *opaque, Error **errp)
VFIODevice *vbasedev = opaque;
/*
- * Snapshot doesn't use postcopy, so allow snapshot even if postcopy is on.
+ * Snapshot doesn't use postcopy nor background snapshot, so allow snapshot
+ * even if they are on.
*/
if (runstate_check(RUN_STATE_SAVE_VM)) {
return 0;
@@ -353,6 +354,14 @@ static int vfio_save_prepare(void *opaque, Error **errp)
return -EOPNOTSUPP;
}
+ if (migrate_background_snapshot()) {
+ error_setg(
+ errp,
+ "%s: VFIO migration is not supported with background snapshot",
+ vbasedev->name);
+ return -EOPNOTSUPP;
+ }
+
return 0;
}
--
2.26.3
next prev parent reply other threads:[~2023-08-31 13:13 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-31 12:56 [PATCH v2 0/5] vfio/migration: Block VFIO migration with postcopy and background snapshot Avihai Horon
2023-08-31 12:56 ` [PATCH v2 1/5] migration: Add migration prefix to functions in target.c Avihai Horon
2023-08-31 12:56 ` [PATCH v2 2/5] vfio/migration: Fail adding device with enable-migration=on and existing blocker Avihai Horon
2023-08-31 12:57 ` [PATCH v2 3/5] migration: Add .save_prepare() handler to struct SaveVMHandlers Avihai Horon
2023-09-01 15:49 ` Peter Xu
2023-09-05 16:13 ` Cédric Le Goater
2023-09-06 14:11 ` Avihai Horon
2023-09-06 14:21 ` Cédric Le Goater
2023-08-31 12:57 ` [PATCH v2 4/5] vfio/migration: Block VFIO migration with postcopy migration Avihai Horon
2023-09-01 10:14 ` YangHang Liu
2023-09-01 15:51 ` Peter Xu
2023-09-03 7:52 ` Avihai Horon
2023-08-31 12:57 ` Avihai Horon [this message]
2023-09-01 15:51 ` [PATCH v2 5/5] vfio/migration: Block VFIO migration with background snapshot Peter Xu
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=20230831125702.11263-6-avihaih@nvidia.com \
--to=avihaih@nvidia.com \
--cc=alex.williamson@redhat.com \
--cc=clg@redhat.com \
--cc=leobras@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=yanghliu@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).