@@ -8,6 +8,8 @@
#ifndef MIGRATION_CPR_H
#define MIGRATION_CPR_H
+#define CPR_MODES (BIT(MIG_MODE_CPR_REBOOT) | BIT(MIG_MODE_CPR_EXEC))
+
extern bool only_cpr_capable;
void cpr_init(void);
@@ -2181,6 +2181,11 @@ bool migrate_mode_enabled(MigMode mode)
return !!(migrate_enabled_modes & BIT(mode));
}
+static bool migrate_modes_enabled(int modes)
+{
+ return (modes & migrate_enabled_modes) == modes;
+}
+
static int migrate_check_enabled(Error **errp)
{
MigMode mode = migrate_mode();
@@ -2262,6 +2267,14 @@ static int check_blockers(Error **reasonp, Error **errp, int modes)
return -EACCES;
}
+ if (only_cpr_capable && (modes & CPR_MODES) &&
+ migrate_modes_enabled(modes & CPR_MODES)) {
+ error_propagate_prepend(errp, *reasonp,
+ "-only-cpr-capable specified, but: ");
+ *reasonp = NULL;
+ return -EACCES;
+ }
+
return add_blockers(reasonp, errp, modes);
}
@@ -4501,6 +4501,14 @@ SRST
migration using any mode except 'normal'.
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 cpr will not
+ fail due to a cpr blocker.
+ERST
+
DEF("nodefaults", 0, QEMU_OPTION_nodefaults, \
"-nodefaults don't create default devices\n", QEMU_ARCH_ALL)
SRST
@@ -77,6 +77,7 @@
#include "hw/block/block.h"
#include "hw/i386/x86.h"
#include "hw/i386/pc.h"
+#include "migration/cpr.h"
#include "migration/misc.h"
#include "migration/snapshot.h"
#include "sysemu/tpm.h"
@@ -3366,6 +3367,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_migrate_mode_enable:
migrate_enable_mode(qapi_enum_parse(&MigMode_lookup, optarg, -1,
&error_fatal));
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 the migrate commanmd will not fail due to a blocker. Signed-off-by: Steve Sistare <steven.sistare@oracle.com> --- include/migration/cpr.h | 2 ++ migration/migration.c | 13 +++++++++++++ qemu-options.hx | 8 ++++++++ softmmu/vl.c | 4 ++++ 4 files changed, 27 insertions(+)