diff mbox series

[V1,23/26] migration: misc cpr-exec blockers

Message ID 1714406135-451286-24-git-send-email-steven.sistare@oracle.com (mailing list archive)
State New, archived
Headers show
Series Live update: cpr-exec | expand

Commit Message

Steven Sistare April 29, 2024, 3:55 p.m. UTC
Add blockers for cpr-exec migration mode for devices and options that do
not support it.

Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
---
 accel/xen/xen-all.c    |  5 +++++
 backends/hostmem-epc.c | 12 ++++++++++--
 hw/vfio/migration.c    |  3 ++-
 replay/replay.c        |  6 ++++++
 4 files changed, 23 insertions(+), 3 deletions(-)

Comments

Fabiano Rosas May 9, 2024, 6:05 p.m. UTC | #1
Steve Sistare <steven.sistare@oracle.com> writes:

> Add blockers for cpr-exec migration mode for devices and options that do
> not support it.
>
> Signed-off-by: Steve Sistare <steven.sistare@oracle.com>

Reviewed-by: Fabiano Rosas <farosas@suse.de>
Fabiano Rosas May 24, 2024, 12:40 p.m. UTC | #2
Steve Sistare <steven.sistare@oracle.com> writes:

> Add blockers for cpr-exec migration mode for devices and options that do
> not support it.
>
> Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
> ---
>  accel/xen/xen-all.c    |  5 +++++
>  backends/hostmem-epc.c | 12 ++++++++++--
>  hw/vfio/migration.c    |  3 ++-
>  replay/replay.c        |  6 ++++++
>  4 files changed, 23 insertions(+), 3 deletions(-)
>
> diff --git a/accel/xen/xen-all.c b/accel/xen/xen-all.c
> index 0bdefce..9a7ed0f 100644
> --- a/accel/xen/xen-all.c
> +++ b/accel/xen/xen-all.c

This file is missing the migration/blocker.h include.
Steven Sistare May 27, 2024, 7:02 p.m. UTC | #3
On 5/24/2024 8:40 AM, Fabiano Rosas wrote:
> Steve Sistare <steven.sistare@oracle.com> writes:
> 
>> Add blockers for cpr-exec migration mode for devices and options that do
>> not support it.
>>
>> Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
>> ---
>>   accel/xen/xen-all.c    |  5 +++++
>>   backends/hostmem-epc.c | 12 ++++++++++--
>>   hw/vfio/migration.c    |  3 ++-
>>   replay/replay.c        |  6 ++++++
>>   4 files changed, 23 insertions(+), 3 deletions(-)
>>
>> diff --git a/accel/xen/xen-all.c b/accel/xen/xen-all.c
>> index 0bdefce..9a7ed0f 100644
>> --- a/accel/xen/xen-all.c
>> +++ b/accel/xen/xen-all.c
> 
> This file is missing the migration/blocker.h include.

Good eyes, will fix - steve
diff mbox series

Patch

diff --git a/accel/xen/xen-all.c b/accel/xen/xen-all.c
index 0bdefce..9a7ed0f 100644
--- a/accel/xen/xen-all.c
+++ b/accel/xen/xen-all.c
@@ -78,6 +78,7 @@  static void xen_setup_post(MachineState *ms, AccelState *accel)
 static int xen_init(MachineState *ms)
 {
     MachineClass *mc = MACHINE_GET_CLASS(ms);
+    Error *blocker = NULL;
 
     xen_xc = xc_interface_open(0, 0, 0);
     if (xen_xc == NULL) {
@@ -112,6 +113,10 @@  static int xen_init(MachineState *ms)
     mc->default_ram_id = NULL;
 
     xen_mode = XEN_ATTACH;
+
+    error_setg(&blocker, "xen does not support cpr exec");
+    migrate_add_blocker_mode(&blocker, MIG_MODE_CPR_EXEC, &error_fatal);
+
     return 0;
 }
 
diff --git a/backends/hostmem-epc.c b/backends/hostmem-epc.c
index 735e2e1..837300f 100644
--- a/backends/hostmem-epc.c
+++ b/backends/hostmem-epc.c
@@ -15,6 +15,7 @@ 
 #include "qom/object_interfaces.h"
 #include "qapi/error.h"
 #include "sysemu/hostmem.h"
+#include "migration/blocker.h"
 #include "hw/i386/hostmem-epc.h"
 
 static bool
@@ -23,6 +24,7 @@  sgx_epc_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
     g_autofree char *name = NULL;
     uint32_t ram_flags;
     int fd;
+    Error *blocker = NULL;
 
     if (!backend->size) {
         error_setg(errp, "can't create backend with size 0");
@@ -38,8 +40,14 @@  sgx_epc_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
 
     name = object_get_canonical_path(OBJECT(backend));
     ram_flags = (backend->share ? RAM_SHARED : 0) | RAM_PROTECTED;
-    return memory_region_init_ram_from_fd(&backend->mr, OBJECT(backend), name,
-                                          backend->size, ram_flags, fd, 0, errp);
+    if (!memory_region_init_ram_from_fd(&backend->mr, OBJECT(backend),
+                                        name, backend->size, ram_flags,
+                                        fd, 0, errp)) {
+        return false;
+    }
+    error_setg(&blocker, "memory-backend-epc does not support cpr exec");
+    migrate_add_blocker_mode(&blocker, MIG_MODE_CPR_EXEC, &error_fatal);
+    return true;
 }
 
 static void sgx_epc_backend_instance_init(Object *obj)
diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c
index 06ae409..b9cd783 100644
--- a/hw/vfio/migration.c
+++ b/hw/vfio/migration.c
@@ -898,7 +898,8 @@  static int vfio_block_migration(VFIODevice *vbasedev, Error *err, Error **errp)
     vbasedev->migration_blocker = error_copy(err);
     error_free(err);
 
-    return migrate_add_blocker_normal(&vbasedev->migration_blocker, errp);
+    return migrate_add_blocker_modes(&vbasedev->migration_blocker, errp,
+                                     MIG_MODE_NORMAL, MIG_MODE_CPR_EXEC, -1);
 }
 
 /* ---------------------------------------------------------------------- */
diff --git a/replay/replay.c b/replay/replay.c
index a2c576c..1bf3f38 100644
--- a/replay/replay.c
+++ b/replay/replay.c
@@ -19,6 +19,7 @@ 
 #include "qemu/option.h"
 #include "sysemu/cpus.h"
 #include "qemu/error-report.h"
+#include "migration/blocker.h"
 
 /* Current version of the replay mechanism.
    Increase it when file format changes. */
@@ -339,6 +340,11 @@  G_NORETURN void replay_sync_error(const char *error)
 static void replay_enable(const char *fname, int mode)
 {
     const char *fmode = NULL;
+    Error *blocker = NULL;
+
+    error_setg(&blocker, "replay is not compatible with cpr");
+    migrate_add_blocker_mode(&blocker, MIG_MODE_CPR_EXEC, &error_fatal);
+
     assert(!replay_file);
 
     switch (mode) {