@@ -36,6 +36,7 @@
#include "qapi/qapi-visit-sockets.h"
#include "chardev/char-io.h"
+#include "sysemu/sysemu.h"
#include "qemu/env.h"
/***********************************************************/
@@ -2271,6 +2271,9 @@ static void ram_block_add(RAMBlock *new_block, Error **errp, bool shared)
new_block->flags |= RAM_SHARED;
addr = file_ram_alloc(new_block, maxlen, mfd, false, errp);
trace_anon_memfd_alloc(name, maxlen, addr, mfd);
+ } else if (only_cpr_capable) {
+ error_report("only-cpr-capable requires memfd-alloc");
+ errno = 0;
} else {
addr = phys_mem_alloc(maxlen, &mr->align, shared);
}
@@ -14,6 +14,7 @@ extern const char *qemu_name;
extern QemuUUID qemu_uuid;
extern bool qemu_uuid_set;
extern bool memfd_alloc;
+extern bool only_cpr_capable;
extern int start_on_wake;
void qemu_add_data_dir(const char *path);
@@ -1099,6 +1099,12 @@ static bool migrate_caps_check(bool *cap_list,
}
}
+ if (cap_list[MIGRATION_CAPABILITY_X_COLO] && only_cpr_capable) {
+ error_setg(errp, "x-colo is not compatible with -only-cpr-capable");
+ return false;
+ }
+
+
return true;
}
@@ -4116,6 +4116,14 @@ SRST
an unmigratable state.
ERST
+DEF("only-cpr-capable", 0, QEMU_OPTION_only_cpr_capable, \
+ "-only-cpr-capable allow only cpr capable devices\n", QEMU_ARCH_ALL)
+SRST
+``-only-cpr-capable``
+ Only allow cpr capable devices, which guarantees that cprsave will not fail
+ with an unsupported device error.
+ERST
+
#ifdef __linux__
DEF("memfd-alloc", 0, QEMU_OPTION_memfd_alloc, \
"-memfd-alloc allocate anonymous memory using memfd_create\n",
@@ -164,6 +164,7 @@ bool boot_strict;
uint8_t *boot_splash_filedata;
int only_migratable; /* turn it off unless user states otherwise */
bool wakeup_suspend_enabled;
+bool only_cpr_capable;
bool memfd_alloc;
int start_on_wake;
static char **argv_main;
@@ -3679,6 +3680,9 @@ void qemu_init(int argc, char **argv, char **envp)
case QEMU_OPTION_only_migratable:
only_migratable = 1;
break;
+ case QEMU_OPTION_only_cpr_capable:
+ only_cpr_capable = true;
+ break;
case QEMU_OPTION_memfd_alloc:
memfd_alloc = true;
break;
@@ -4433,6 +4437,15 @@ void qemu_init(int argc, char **argv, char **envp)
cpu_synchronize_all_post_init();
+ if (only_cpr_capable && replay_mode != REPLAY_MODE_NONE) {
+ error_report("replay is not compatible with -only-cpr-capable");
+ exit(1);
+ }
+ if (only_cpr_capable && !qemu_chr_cpr_capable(&err)) {
+ error_report_err(err);
+ exit(1);
+ }
+
rom_reset_order_override();
/* Did we create any drives that we failed to create a device for? */
Add the only-cpr-capable option, which causes qemu to exit with an error if any devices that are not capable of cpr are added. This guarantees that a cprsave operation will not fail with an unsupported device error. Signed-off-by: Steve Sistare <steven.sistare@oracle.com> --- chardev/char-socket.c | 1 + exec.c | 3 +++ include/sysemu/sysemu.h | 1 + migration/migration.c | 6 ++++++ qemu-options.hx | 8 ++++++++ softmmu/vl.c | 13 +++++++++++++ 6 files changed, 32 insertions(+)