[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH V9 25/46] cpr: only-cpr-capable
From: |
Steve Sistare |
Subject: |
[PATCH V9 25/46] cpr: only-cpr-capable |
Date: |
Tue, 26 Jul 2022 09:10:22 -0700 |
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(+)
diff --git a/include/migration/cpr.h b/include/migration/cpr.h
index c48be2d..f2dfb1b 100644
--- a/include/migration/cpr.h
+++ b/include/migration/cpr.h
@@ -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);
diff --git a/migration/migration.c b/migration/migration.c
index 7b46213..e0fc2b8 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -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);
}
diff --git a/qemu-options.hx b/qemu-options.hx
index 7797d3d..3ed9270 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -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
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 5f6cd8c..bed147c 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -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));
--
1.8.3.1
- [PATCH V9 02/46] memory: RAM_NAMED_FILE flag, (continued)
- [PATCH V9 02/46] memory: RAM_NAMED_FILE flag, Steve Sistare, 2022/07/26
- [PATCH V9 01/46] migration: fix populate_vfio_info, Steve Sistare, 2022/07/26
- [PATCH V9 14/46] qapi: strList unit tests, Steve Sistare, 2022/07/26
- [PATCH V9 13/46] qapi: strv_from_strList, Steve Sistare, 2022/07/26
- [PATCH V9 18/46] memory: flat section iterator, Steve Sistare, 2022/07/26
- [PATCH V9 04/46] migration: mode parameter, Steve Sistare, 2022/07/26
- [PATCH V9 21/46] cpr: preserve extra state, Steve Sistare, 2022/07/26
- [PATCH V9 19/46] oslib: qemu_clear_cloexec, Steve Sistare, 2022/07/26
- [PATCH V9 30/46] vfio-pci: refactor for cpr, Steve Sistare, 2022/07/26
- [PATCH V9 27/46] hostmem-memfd: cpr support, Steve Sistare, 2022/07/26
- [PATCH V9 25/46] cpr: only-cpr-capable,
Steve Sistare <=
- [PATCH V9 20/46] vl: helper to request re-exec, Steve Sistare, 2022/07/26
- [PATCH V9 05/46] migration: migrate-enable-mode option, Steve Sistare, 2022/07/26
- [PATCH V9 24/46] cpr: ram block blockers, Steve Sistare, 2022/07/26
- [PATCH V9 08/46] cpr: relax some blockers, Steve Sistare, 2022/07/26
- [PATCH V9 28/46] hostmem-epc: cpr support, Steve Sistare, 2022/07/26
- [PATCH V9 33/46] vfio-pci: cpr part 3 (intx), Steve Sistare, 2022/07/26
- [PATCH V9 06/46] migration: simplify blockers, Steve Sistare, 2022/07/26
- [PATCH V9 10/46] qdev-properties: strList, Steve Sistare, 2022/07/26
- [PATCH V9 29/46] pci: export msix_is_pending, Steve Sistare, 2022/07/26
- [PATCH V9 11/46] qapi: strList_from_string, Steve Sistare, 2022/07/26