From: Juan Quintela <quintela@redhat.com>
To: qemu-devel@nongnu.org
Cc: Juan Quintela <quintela@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>, Peter Xu <peterx@redhat.com>
Subject: [PULL 18/20] migration/postcopy: Detect file system on dest host
Date: Thu, 20 Apr 2023 15:17:49 +0200 [thread overview]
Message-ID: <20230420131751.28534-19-quintela@redhat.com> (raw)
In-Reply-To: <20230420131751.28534-1-quintela@redhat.com>
From: Peter Xu <peterx@redhat.com>
Postcopy requires the memory support userfaultfd to work. Right now we
check it but it's a bit too late (when switching to postcopy migration).
Do that early right at enabling of postcopy.
Note that this is still only a best effort because ramblocks can be
dynamically created. We can add check in hostmem creations and fail if
postcopy enabled, but maybe that's too aggressive.
Still, we have chance to fail the most obvious where we know there's an
existing unsupported ramblock.
Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
migration/postcopy-ram.c | 34 ++++++++++++++++++++++++++++++----
1 file changed, 30 insertions(+), 4 deletions(-)
diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
index 7d24dac397..d7b48dd920 100644
--- a/migration/postcopy-ram.c
+++ b/migration/postcopy-ram.c
@@ -36,6 +36,7 @@
#include "yank_functions.h"
#include "tls.h"
#include "qemu/userfaultfd.h"
+#include "qemu/mmap-alloc.h"
/* Arbitrary limit on size of each discard command,
* keeps them around ~200 bytes
@@ -336,11 +337,12 @@ static bool ufd_check_and_apply(int ufd, MigrationIncomingState *mis)
/* Callback from postcopy_ram_supported_by_host block iterator.
*/
-static int test_ramblock_postcopiable(RAMBlock *rb, void *opaque)
+static int test_ramblock_postcopiable(RAMBlock *rb)
{
const char *block_name = qemu_ram_get_idstr(rb);
ram_addr_t length = qemu_ram_get_used_length(rb);
size_t pagesize = qemu_ram_pagesize(rb);
+ QemuFsType fs;
if (length % pagesize) {
error_report("Postcopy requires RAM blocks to be a page size multiple,"
@@ -348,6 +350,15 @@ static int test_ramblock_postcopiable(RAMBlock *rb, void *opaque)
"page size of 0x%zx", block_name, length, pagesize);
return 1;
}
+
+ if (rb->fd >= 0) {
+ fs = qemu_fd_getfs(rb->fd);
+ if (fs != QEMU_FS_TYPE_TMPFS && fs != QEMU_FS_TYPE_HUGETLBFS) {
+ error_report("Host backend files need to be TMPFS or HUGETLBFS only");
+ return 1;
+ }
+ }
+
return 0;
}
@@ -366,6 +377,7 @@ bool postcopy_ram_supported_by_host(MigrationIncomingState *mis)
struct uffdio_range range_struct;
uint64_t feature_mask;
Error *local_err = NULL;
+ RAMBlock *block;
if (qemu_target_page_size() > pagesize) {
error_report("Target page size bigger than host page size");
@@ -390,9 +402,23 @@ bool postcopy_ram_supported_by_host(MigrationIncomingState *mis)
goto out;
}
- /* We don't support postcopy with shared RAM yet */
- if (foreach_not_ignored_block(test_ramblock_postcopiable, NULL)) {
- goto out;
+ /*
+ * We don't support postcopy with some type of ramblocks.
+ *
+ * NOTE: we explicitly ignored ramblock_is_ignored() instead we checked
+ * all possible ramblocks. This is because this function can be called
+ * when creating the migration object, during the phase RAM_MIGRATABLE
+ * is not even properly set for all the ramblocks.
+ *
+ * A side effect of this is we'll also check against RAM_SHARED
+ * ramblocks even if migrate_ignore_shared() is set (in which case
+ * we'll never migrate RAM_SHARED at all), but normally this shouldn't
+ * affect in reality, or we can revisit.
+ */
+ RAMBLOCK_FOREACH(block) {
+ if (test_ramblock_postcopiable(block)) {
+ goto out;
+ }
}
/*
--
2.39.2
next prev parent reply other threads:[~2023-04-20 13:19 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-20 13:17 [PULL 00/20] Migration 20230420 patches Juan Quintela
2023-04-20 13:17 ` [PULL 01/20] migration: remove extra whitespace character for code style Juan Quintela
2023-04-20 13:17 ` [PULL 02/20] postcopy-ram: do not use qatomic_mb_read Juan Quintela
2023-04-20 13:17 ` [PULL 03/20] migration: Merge ram_counters and ram_atomic_counters Juan Quintela
2023-04-20 13:17 ` [PULL 04/20] migration: Update atomic stats out of the mutex Juan Quintela
2023-04-20 13:17 ` [PULL 05/20] migration: Make multifd_bytes atomic Juan Quintela
2023-04-20 13:17 ` [PULL 06/20] migration: Make dirty_sync_missed_zero_copy atomic Juan Quintela
2023-04-20 13:17 ` [PULL 07/20] migration: Make precopy_bytes atomic Juan Quintela
2023-04-20 13:17 ` [PULL 08/20] migration: Make downtime_bytes atomic Juan Quintela
2023-04-20 13:17 ` [PULL 09/20] migration: Make dirty_sync_count atomic Juan Quintela
2023-04-20 13:17 ` [PULL 10/20] migration: Make postcopy_requests atomic Juan Quintela
2023-04-20 13:17 ` [PULL 11/20] migration: Make dirty_pages_rate atomic Juan Quintela
2023-04-20 13:17 ` [PULL 12/20] migration: Make dirty_bytes_last_sync atomic Juan Quintela
2023-04-20 13:17 ` [PULL 13/20] migration: Rename duplicate to zero_pages Juan Quintela
2023-04-20 13:17 ` [PULL 14/20] migration: Rename normal to normal_pages Juan Quintela
2023-04-20 13:17 ` [PULL 15/20] migration: Handle block device inactivation failures better Juan Quintela
2023-04-20 13:17 ` [PULL 16/20] util/mmap-alloc: qemu_fd_getfs() Juan Quintela
2023-04-20 13:17 ` [PULL 17/20] vl.c: Create late backends before migration object Juan Quintela
2023-04-20 13:17 ` Juan Quintela [this message]
2023-04-20 13:17 ` [PULL 19/20] migration: rename enabled_capabilities to capabilities Juan Quintela
2023-04-20 13:17 ` [PULL 20/20] migration: Pass migrate_caps_check() the old and new caps Juan Quintela
2023-04-22 5:09 ` [PULL 00/20] Migration 20230420 patches Richard Henderson
2023-04-22 9:21 ` Juan Quintela
2023-04-22 9:57 ` Richard Henderson
2023-04-23 9:45 ` Juan Quintela
2023-04-23 15:00 ` Richard Henderson
2023-04-24 9:57 ` Juan Quintela
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=20230420131751.28534-19-quintela@redhat.com \
--to=quintela@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterx@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).