Skip to contentSkip to conversation

Migration 20240104 patches

GIT PULL Applied [email protected] 3 participants 35 messages Jan 4, 2024 – Jan 8, 2024

lore
Share & tools
lore
#0 lore raw

From: Peter Xu <[email protected]>

The following changes since commit 7425b6277f12e82952cede1f531bfc689bf77fb1:

Merge tag 'tracing-pull-request' of https://gitlab.com/stefanha/qemu into staging (2023-12-27 05:15:32 -0500)

are available in the Git repository at:

https://gitlab.com/peterx/qemu.git tags/migration-20240104-pull-request

for you to fetch changes up to b12635ff08ab2e5a6a955c6866ef4525fb3deb5d:

migration: fix coverity migrate_mode finding (2024-01-04 09:52:42 +0800)

----------------------------------------------------------------
migration 1st pull for 9.0

- We lost Juan and Leo in the maintainers file
- Steven's suspend state fix
- Steven's fix for coverity on migrate_mode
- Avihai's migration cleanup series

----------------------------------------------------------------

Avihai Horon (11):
migration: Remove migrate_max_downtime() declaration
migration: Remove nulling of hostname in migrate_init()
migration: Refactor migration_incoming_setup()
migration: Remove errp parameter in migration_fd_process_incoming() migration/multifd: Fix error message in multifd_recv_initial_packet() migration/multifd: Simplify multifd_channel_connect() if else
statement
migration/multifd: Fix leaking of Error in TLS error flow migration/multifd: Remove error_setg() in
migration_ioc_process_incoming()
migration: Fix migration_channel_read_peek() error path
migration: Remove unnecessary usage of local Error migration/multifd: Remove unnecessary usage of local Error

Juan Quintela (1):
MAINTAINERS: Leaving Migration

Leonardo Bras (1):
MAINTAINERS: Remove myself as reviewer from Live Migration

Steve Sistare (13):
cpus: vm_was_suspended
cpus: stop vm in suspended runstate
cpus: check running not RUN_STATE_RUNNING
cpus: vm_resume
migration: propagate suspended runstate
migration: preserve suspended runstate
migration: preserve suspended for snapshot
migration: preserve suspended for bg_migration
tests/qtest: migration events
tests/qtest: option to suspend during migration
tests/qtest: precopy migration with suspend
tests/qtest: postcopy migration with suspend
migration: fix coverity migrate_mode finding

 MAINTAINERS                          |   5 -
 qapi/misc.json                       |  11 +-
 qapi/run-state.json                  |   6 +-
 include/migration/snapshot.h         |   7 ++
 include/sysemu/runstate.h            |  20 +++
 migration/migration.h                |   4 +-
 tests/migration/i386/a-b-bootblock.h |  26 ++--
 tests/qtest/migration-helpers.h      |  11 +-
 backends/tpm/tpm_emulator.c          |   2 +-
 hw/usb/hcd-ehci.c                    |   2 +-
 hw/usb/redirect.c                    |   2 +-
 hw/xen/xen-hvm-common.c              |   2 +-
 migration/channel.c                  |   9 +-
 migration/global_state.c             |  47 ++++---
 migration/migration-hmp-cmds.c       |   8 +-
 migration/migration.c                |  42 ++-----
 migration/multifd.c                  |  27 ++--
 migration/options.c                  |   4 +-
 migration/rdma.c                     |   6 +-
 migration/savevm.c                   |  23 ++--
 system/cpus.c                        |  47 +++++--
 system/runstate.c                    |   9 ++
 system/vl.c                          |   2 +
 tests/qtest/migration-helpers.c      |  25 ++--
 tests/qtest/migration-test.c         | 181 +++++++++++++++++++--------
 .mailmap                             |   1 +
 tests/migration/i386/Makefile        |   5 +-
 tests/migration/i386/a-b-bootblock.S |  50 +++++++-
 28 files changed, 385 insertions(+), 199 deletions(-)
Signature · 1 line
2.41.0
#1 lore raw

[PULL 07/26] migration: propagate suspended runstate

From: Steve Sistare <[email protected]>

If the outgoing machine was previously suspended, propagate that to the incoming side via global_state, so a subsequent vm_start restores the suspended state. To maintain backward and forward compatibility, reclaim some space from the runstate member.

---
 migration/global_state.c | 47 +++++++++++++++++++++++-----------------
 1 file changed, 27 insertions(+), 20 deletions(-)
migration/global_state.c +27 -20
index 4e2a9d8ec0..64a573c683 100644
@@ -22,7 +22,16 @@
 
 typedef struct {
     uint32_t size;
-    uint8_t runstate[100];
+
+    /*
+     * runstate was 100 bytes, zero padded, but we trimmed it to add a
+     * few fields and maintain backwards compatibility.
+     */
+    uint8_t runstate[32];
+    uint8_t has_vm_was_suspended;
+    uint8_t vm_was_suspended;
+    uint8_t unused[66];
+
     RunState state;
     bool received;
 } GlobalState;
@@ -35,6 +44,10 @@ static void global_state_do_store(RunState state)
     assert(strlen(state_str) < sizeof(global_state.runstate));
     strpadcpy((char *)global_state.runstate, sizeof(global_state.runstate),
               state_str, '\0');
+    global_state.has_vm_was_suspended = true;
+    global_state.vm_was_suspended = vm_get_suspended();
+
+    memset(global_state.unused, 0, sizeof(global_state.unused));
 }
 
 void global_state_store(void)
@@ -59,24 +72,7 @@ RunState global_state_get_runstate(void)
 
 static bool global_state_needed(void *opaque)
 {
-    GlobalState *s = opaque;
-    char *runstate = (char *)s->runstate;
-
-    /* If it is not optional, it is mandatory */
-
-    if (migrate_get_current()->store_global_state) {
-        return true;
-    }
-
-    /* If state is running or paused, it is not needed */
-
-    if (strcmp(runstate, "running") == 0 ||
-        strcmp(runstate, "paused") == 0) {
-        return false;
-    }
-
-    /* for any other state it is needed */
-    return true;
+    return migrate_get_current()->store_global_state;
 }
 
 static int global_state_post_load(void *opaque, int version_id)
@@ -93,7 +89,7 @@ static int global_state_post_load(void *opaque, int version_id)
                 sizeof(s->runstate)) == sizeof(s->runstate)) {
         /*
          * This condition should never happen during migration, because
-         * all runstate names are shorter than 100 bytes (the size of
+         * all runstate names are shorter than 32 bytes (the size of
          * s->runstate). However, a malicious stream could overflow
          * the qapi_enum_parse() call, so we force the last character
          * to a NUL byte.
@@ -110,6 +106,14 @@ static int global_state_post_load(void *opaque, int version_id)
     }
     s->state = r;
 
+    /*
+     * global_state is saved on the outgoing side before forcing a stopped
+     * state, so it may have saved state=suspended and vm_was_suspended=0.
+     * Now we are in a paused state, and when we later call vm_start, it must
+     * restore the suspended state, so we must set vm_was_suspended=1 here.
+     */
+    vm_set_suspended(s->vm_was_suspended || r == RUN_STATE_SUSPENDED);
+
     return 0;
 }
 
@@ -134,6 +138,9 @@ static const VMStateDescription vmstate_globalstate = {
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(size, GlobalState),
         VMSTATE_BUFFER(runstate, GlobalState),
+        VMSTATE_UINT8(has_vm_was_suspended, GlobalState),
+        VMSTATE_UINT8(vm_was_suspended, GlobalState),
+        VMSTATE_BUFFER(unused, GlobalState),
         VMSTATE_END_OF_LIST()
     },
 };
Signature · 1 line
2.41.0
#2 lore raw

[PULL 01/26] MAINTAINERS: Leaving Migration

In reply to [email protected]

From: Juan Quintela <[email protected]>

I am leaving Red Hat, and as part of that I am leaving Migration maintenarship.

You are left in good hands with Peter and Fabiano.

Thanks for all the fish.

---
 MAINTAINERS | 3 ---
 .mailmap    | 1 +
 2 files changed, 1 insertion(+), 3 deletions(-)
MAINTAINERS +0 -3
index 395f26ba86..56464cd916 100644
@@ -70,7 +70,6 @@ R: Daniel P. Berrangé <[email protected]>
 R: Thomas Huth <[email protected]>
 R: Markus Armbruster <[email protected]>
 R: Philippe Mathieu-Daudé <[email protected]>
-R: Juan Quintela <[email protected]>
 W: https://www.qemu.org/docs/master/devel/index.html
 S: Odd Fixes
 F: docs/devel/style.rst
@@ -3355,7 +3354,6 @@ S: Odd Fixes
 F: scripts/checkpatch.pl
 
 Migration
-M: Juan Quintela <[email protected]>
 M: Peter Xu <[email protected]>
 M: Fabiano Rosas <[email protected]>
 R: Leonardo Bras <[email protected]>
@@ -3375,7 +3373,6 @@ F: util/userfaultfd.c
 X: migration/rdma*
 
 RDMA Migration
-M: Juan Quintela <[email protected]>
 R: Li Zhijian <[email protected]>
 R: Peter Xu <[email protected]>
 R: Leonardo Bras <[email protected]>
.mailmap +1 -0
index e12e19f691..d94572af05 100644
@@ -81,6 +81,7 @@ Greg Kurz <[email protected]> <[email protected]>
 Huacai Chen <[email protected]> <[email protected]>
 Huacai Chen <[email protected]> <[email protected]>
 James Hogan <[email protected]> <[email protected]>
+Juan Quintela <[email protected]> <[email protected]>
 Leif Lindholm <[email protected]> <[email protected]>
 Leif Lindholm <[email protected]> <[email protected]>
 Luc Michel <[email protected]> <[email protected]>
Signature · 1 line
2.41.0
#3 lore raw

[PULL 04/26] cpus: stop vm in suspended runstate

In reply to [email protected]

From: Steve Sistare <[email protected]>

Currently, a vm in the suspended state is not completely stopped. The VCPUs have been paused, but the cpu clock still runs, and runstate notifiers for the transition to stopped have not been called. This causes problems for live migration. Stale cpu timers_state is saved to the migration stream, causing time errors in the guest when it wakes from suspend, and state that would have been modified by runstate notifiers is wrong.

Modify vm_stop to completely stop the vm if the current state is suspended, transition to RUN_STATE_PAUSED, and remember that the machine was suspended. Modify vm_start to restore the suspended state.

This affects all callers of vm_stop and vm_start, notably, the qapi stop and cont commands:

old behavior:

    RUN_STATE_SUSPENDED --> stop --> RUN_STATE_SUSPENDED

new behavior:

    RUN_STATE_SUSPENDED --> stop --> RUN_STATE_PAUSED
    RUN_STATE_PAUSED    --> cont --> RUN_STATE_SUSPENDED

For example:

(qemu) info status
VM status: paused (suspended)

(qemu) stop
(qemu) info status
VM status: paused

(qemu) system_wakeup
Error: Unable to wake up: guest is not in suspended state

(qemu) cont
(qemu) info status
VM status: paused (suspended)

(qemu) system_wakeup
(qemu) info status
VM status: running

---
 qapi/misc.json            | 11 +++++++++--
 qapi/run-state.json       |  6 +++---
 include/sysemu/runstate.h |  9 +++++++++
 system/cpus.c             | 23 +++++++++++++++--------
 system/runstate.c         |  3 +++
 5 files changed, 39 insertions(+), 13 deletions(-)
qapi/misc.json +9 -2
index cda2effa81..3622d98d01 100644
@@ -134,7 +134,7 @@
 ##
 # @stop:
 #
-# Stop all guest VCPU execution.
+# Stop guest VM execution.
 #
 # Since: 0.14
 #
@@ -143,6 +143,9 @@
 #     the guest remains paused once migration finishes, as if the -S
 #     option was passed on the command line.
 #
+#     In the "suspended" state, it will completely stop the VM and
+#     cause a transition to the "paused" state. (Since 9.0)
+#
 # Example:
 #
 # -> { "execute": "stop" }
@@ -153,7 +156,7 @@
 ##
 # @cont:
 #
-# Resume guest VCPU execution.
+# Resume guest VM execution.
 #
 # Since: 0.14
 #
@@ -165,6 +168,10 @@
 #     guest starts once migration finishes, removing the effect of the
 #     -S command line option if it was passed.
 #
+#     If the VM was previously suspended, and not been reset or woken,
+#     this command will transition back to the "suspended" state.
+#     (Since 9.0)
+#
 # Example:
 #
 # -> { "execute": "cont" }
qapi/run-state.json +3 -3
index f216ba54ec..ca05502e0a 100644
@@ -102,7 +102,7 @@
 ##
 # @StatusInfo:
 #
-# Information about VCPU run state
+# Information about VM run state
 #
 # @running: true if all VCPUs are runnable, false if not runnable
 #
@@ -130,9 +130,9 @@
 ##
 # @query-status:
 #
-# Query the run status of all VCPUs
+# Query the run status of the VM
 #
-# Returns: @StatusInfo reflecting all VCPUs
+# Returns: @StatusInfo reflecting the VM
 #
 # Since: 0.14
 #
include/sysemu/runstate.h +9 -0
index 88a67e22b0..618eb491af 100644
@@ -40,6 +40,15 @@ static inline bool shutdown_caused_by_guest(ShutdownCause cause)
     return cause >= SHUTDOWN_CAUSE_GUEST_SHUTDOWN;
 }
 
+/*
+ * In a "live" state, the vcpu clock is ticking, and the runstate notifiers
+ * think we are running.
+ */
+static inline bool runstate_is_live(RunState state)
+{
+    return state == RUN_STATE_RUNNING || state == RUN_STATE_SUSPENDED;
+}
+
 void vm_start(void);
 
 /**
system/cpus.c +15 -8
index 9f631ab734..f162435dd4 100644
@@ -277,11 +277,15 @@ bool vm_get_suspended(void)
 static int do_vm_stop(RunState state, bool send_stop)
 {
     int ret = 0;
+    RunState oldstate = runstate_get();
 
-    if (runstate_is_running()) {
+    if (runstate_is_live(oldstate)) {
+        vm_was_suspended = (oldstate == RUN_STATE_SUSPENDED);
         runstate_set(state);
         cpu_disable_ticks();
-        pause_all_vcpus();
+        if (oldstate == RUN_STATE_RUNNING) {
+            pause_all_vcpus();
+        }
         vm_state_notify(0, state);
         if (send_stop) {
             qapi_event_send_stop();
@@ -694,11 +698,13 @@ int vm_stop(RunState state)
 
 /**
  * Prepare for (re)starting the VM.
- * Returns -1 if the vCPUs are not to be restarted (e.g. if they are already
- * running or in case of an error condition), 0 otherwise.
+ * Returns 0 if the vCPUs should be restarted, -1 on an error condition,
+ * and 1 otherwise.
  */
 int vm_prepare_start(bool step_pending)
 {
+    int ret = vm_was_suspended ? 1 : 0;
+    RunState state = vm_was_suspended ? RUN_STATE_SUSPENDED : RUN_STATE_RUNNING;
     RunState requested;
 
     qemu_vmstop_requested(&requested);
@@ -729,9 +735,10 @@ int vm_prepare_start(bool step_pending)
     qapi_event_send_resume();
 
     cpu_enable_ticks();
-    runstate_set(RUN_STATE_RUNNING);
-    vm_state_notify(1, RUN_STATE_RUNNING);
-    return 0;
+    runstate_set(state);
+    vm_state_notify(1, state);
+    vm_was_suspended = false;
+    return ret;
 }
 
 void vm_start(void)
@@ -745,7 +752,7 @@ void vm_start(void)
    current state is forgotten forever */
 int vm_stop_force_state(RunState state)
 {
-    if (runstate_is_running()) {
+    if (runstate_is_live(runstate_get())) {
         return vm_stop(state);
     } else {
         int ret;
system/runstate.c +3 -0
index ea9d6c2a32..e2fa2040cb 100644
@@ -108,6 +108,7 @@ static const RunStateTransition runstate_transitions_def[] = {
     { RUN_STATE_PAUSED, RUN_STATE_POSTMIGRATE },
     { RUN_STATE_PAUSED, RUN_STATE_PRELAUNCH },
     { RUN_STATE_PAUSED, RUN_STATE_COLO},
+    { RUN_STATE_PAUSED, RUN_STATE_SUSPENDED},
 
     { RUN_STATE_POSTMIGRATE, RUN_STATE_RUNNING },
     { RUN_STATE_POSTMIGRATE, RUN_STATE_FINISH_MIGRATE },
@@ -161,6 +162,7 @@ static const RunStateTransition runstate_transitions_def[] = {
     { RUN_STATE_SUSPENDED, RUN_STATE_FINISH_MIGRATE },
     { RUN_STATE_SUSPENDED, RUN_STATE_PRELAUNCH },
     { RUN_STATE_SUSPENDED, RUN_STATE_COLO},
+    { RUN_STATE_SUSPENDED, RUN_STATE_PAUSED},
 
     { RUN_STATE_WATCHDOG, RUN_STATE_RUNNING },
     { RUN_STATE_WATCHDOG, RUN_STATE_FINISH_MIGRATE },
@@ -502,6 +504,7 @@ void qemu_system_reset(ShutdownCause reason)
         qapi_event_send_reset(shutdown_caused_by_guest(reason), reason);
     }
     cpu_synchronize_all_post_reset();
+    vm_set_suspended(false);
 }
 
 /*
Signature · 1 line
2.41.0
#4 lore raw

[PULL 08/26] migration: preserve suspended runstate

In reply to [email protected]

From: Steve Sistare <[email protected]>

A guest that is migrated in the suspended state automaticaly wakes and continues execution. This is wrong; the guest should end migration in the same state it started. The root cause is that the outgoing migration code automatically wakes the guest, then saves the RUNNING runstate in global_state_store(), hence the incoming migration code thinks the guest is running and continues the guest if autostart is true.

On the outgoing side, delete the call to qemu_system_wakeup_request(). Now that vm_stop completely stops a vm in the suspended state (from the preceding patches), the existing call to vm_stop_force_state is sufficient to correctly migrate all vmstate.

On the incoming side, call vm_start if the pre-migration state was running or suspended. For the latter, vm_start correctly restores the suspended state, and a future system_wakeup monitor request will cause the vm to resume running.

---
 migration/migration.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
migration/migration.c +3 -5
index 3ce04b2aaf..8124811045 100644
@@ -604,7 +604,7 @@ static void process_incoming_migration_bh(void *opaque)
      */
     if (!migrate_late_block_activate() ||
          (autostart && (!global_state_received() ||
-            global_state_get_runstate() == RUN_STATE_RUNNING))) {
+            runstate_is_live(global_state_get_runstate())))) {
         /* Make sure all file formats throw away their mutable metadata.
          * If we get an error here, just don't restart the VM yet. */
         bdrv_activate_all(&local_err);
@@ -628,7 +628,7 @@ static void process_incoming_migration_bh(void *opaque)
     dirty_bitmap_mig_before_vm_start();
 
     if (!global_state_received() ||
-        global_state_get_runstate() == RUN_STATE_RUNNING) {
+        runstate_is_live(global_state_get_runstate())) {
         if (autostart) {
             vm_start();
         } else {
@@ -2416,7 +2416,6 @@ static int postcopy_start(MigrationState *ms, Error **errp)
 
     migration_downtime_start(ms);
 
-    qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL);
     global_state_store();
     ret = migration_stop_vm(RUN_STATE_FINISH_MIGRATE);
     if (ret < 0) {
@@ -2615,7 +2614,6 @@ static int migration_completion_precopy(MigrationState *s,
 
     qemu_mutex_lock_iothread();
     migration_downtime_start(s);
-    qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL);
 
     s->vm_old_state = runstate_get();
     global_state_store();
@@ -3136,7 +3134,7 @@ static void migration_iteration_finish(MigrationState *s)
     case MIGRATION_STATUS_FAILED:
     case MIGRATION_STATUS_CANCELLED:
     case MIGRATION_STATUS_CANCELLING:
-        if (s->vm_old_state == RUN_STATE_RUNNING) {
+        if (runstate_is_live(s->vm_old_state)) {
             if (!runstate_check(RUN_STATE_SHUTDOWN)) {
                 vm_start();
             }
Signature · 1 line
2.41.0
#5 lore raw

[PULL 06/26] cpus: vm_resume

In reply to [email protected]

From: Steve Sistare <[email protected]>

Define the vm_resume helper, for use in subsequent patches.

---
 include/sysemu/runstate.h | 9 +++++++++
 system/cpus.c             | 9 +++++++++
 2 files changed, 18 insertions(+)
include/sysemu/runstate.h +9 -0
index 618eb491af..0117d243c4 100644
@@ -57,6 +57,15 @@ void vm_start(void);
  * @step_pending: whether any of the CPUs is about to be single-stepped by gdb
  */
 int vm_prepare_start(bool step_pending);
+
+/**
+ * vm_resume: If @state is a live state, start the vm and set the state,
+ * else just set the state.
+ *
+ * @state: the state to restore
+ */
+void vm_resume(RunState state);
+
 int vm_stop(RunState state);
 int vm_stop_force_state(RunState state);
 int vm_shutdown(void);
system/cpus.c +9 -0
index f162435dd4..7d2c28b1d1 100644
@@ -748,6 +748,15 @@ void vm_start(void)
     }
 }
 
+void vm_resume(RunState state)
+{
+    if (runstate_is_live(state)) {
+        vm_start();
+    } else {
+        runstate_set(state);
+    }
+}
+
 /* does a state transition even if the VM is already stopped,
    current state is forgotten forever */
 int vm_stop_force_state(RunState state)
Signature · 1 line
2.41.0
#6 lore raw

[PULL 20/26] migration/multifd: Simplify multifd_channel_connect() if else statement

In reply to [email protected]

From: Avihai Horon <[email protected]>

The else branch in multifd_channel_connect() is redundant because when the if branch is taken the function returns.

Simplify the code by removing the else branch.

---
 migration/multifd.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
migration/multifd.c +6 -7
index a6204fc72f..55d5fd55f8 100644
@@ -847,14 +847,13 @@ static bool multifd_channel_connect(MultiFDSendParams *p,
          * so we mustn't call multifd_send_thread until then
          */
         return multifd_tls_channel_connect(p, ioc, errp);
-
-    } else {
-        migration_ioc_register_yank(ioc);
-        p->registered_yank = true;
-        p->c = ioc;
-        qemu_thread_create(&p->thread, p->name, multifd_send_thread, p,
-                           QEMU_THREAD_JOINABLE);
     }
+
+    migration_ioc_register_yank(ioc);
+    p->registered_yank = true;
+    p->c = ioc;
+    qemu_thread_create(&p->thread, p->name, multifd_send_thread, p,
+                       QEMU_THREAD_JOINABLE);
     return true;
 }
 
Signature · 1 line
2.41.0
#7 lore raw

[PULL 05/26] cpus: check running not RUN_STATE_RUNNING

In reply to [email protected]

From: Steve Sistare <[email protected]>

When a vm transitions from running to suspended, runstate notifiers are not called, so the notifiers still think the vm is running. Hence, when we call vm_start to restore the suspended state, we call vm_state_notify with running=1. However, some notifiers check for RUN_STATE_RUNNING. They must check the running boolean instead.

No functional change.

---
 backends/tpm/tpm_emulator.c | 2 +-
 hw/usb/hcd-ehci.c           | 2 +-
 hw/usb/redirect.c           | 2 +-
 hw/xen/xen-hvm-common.c     | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
backends/tpm/tpm_emulator.c +1 -1
index f7f1b4ad7a..254fce7764 100644
@@ -904,7 +904,7 @@ static void tpm_emulator_vm_state_change(void *opaque, bool running,
 
     trace_tpm_emulator_vm_state_change(running, state);
 
-    if (!running || state != RUN_STATE_RUNNING || !tpm_emu->relock_storage) {
+    if (!running || !tpm_emu->relock_storage) {
         return;
     }
 
hw/usb/hcd-ehci.c +1 -1
index 19b4534c20..10c82ce472 100644
@@ -2451,7 +2451,7 @@ static void usb_ehci_vm_state_change(void *opaque, bool running, RunState state)
      * USB-devices which have async handled packages have a packet in the
      * ep queue to match the completion with.
      */
-    if (state == RUN_STATE_RUNNING) {
+    if (running) {
         ehci_advance_async_state(ehci);
     }
 
hw/usb/redirect.c +1 -1
index c9893df867..3785bb057b 100644
@@ -1403,7 +1403,7 @@ static void usbredir_vm_state_change(void *priv, bool running, RunState state)
 {
     USBRedirDevice *dev = priv;
 
-    if (state == RUN_STATE_RUNNING && dev->parser != NULL) {
+    if (running && dev->parser != NULL) {
         usbredirparser_do_write(dev->parser); /* Flush any pending writes */
     }
 }
hw/xen/xen-hvm-common.c +1 -1
index 565dc39c8f..47e6cb1db3 100644
@@ -623,7 +623,7 @@ void xen_hvm_change_state_handler(void *opaque, bool running,
 
     xen_set_ioreq_server_state(xen_domid,
                                state->ioservid,
-                               (rstate == RUN_STATE_RUNNING));
+                               running);
 }
 
 void xen_exit_notifier(Notifier *n, void *data)
Signature · 1 line
2.41.0
#8 lore raw

[PULL 19/26] migration/multifd: Fix error message in multifd_recv_initial_packet()

In reply to [email protected]

From: Avihai Horon <[email protected]>

In multifd_recv_initial_packet(), if MultiFDInit_t->id is greater than the configured number of multifd channels, an irrelevant error message about multifd version is printed.

Change the error message to a relevant one about the channel id.

---
 migration/multifd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
migration/multifd.c +2 -2
index 409460684f..a6204fc72f 100644
@@ -228,8 +228,8 @@ static int multifd_recv_initial_packet(QIOChannel *c, Error **errp)
     }
 
     if (msg.id > migrate_multifd_channels()) {
-        error_setg(errp, "multifd: received channel version %u "
-                   "expected %u", msg.version, MULTIFD_VERSION);
+        error_setg(errp, "multifd: received channel id %u is greater than "
+                   "number of channels %u", msg.id, migrate_multifd_channels());
         return -1;
     }
 
Signature · 1 line
2.41.0
#9 lore raw

[PULL 23/26] migration: Fix migration_channel_read_peek() error path

In reply to [email protected]

From: Avihai Horon <[email protected]>

migration_channel_read_peek() calls qio_channel_readv_full() and handles both cases of return value == 0 and return value < 0 the same way, by calling error_setg() with errp. However, if return value < 0, errp is already set, so calling error_setg() with errp will lead to an assert.

Fix it by handling these cases separately, calling error_setg() with errp only in return value == 0 case.

Fixes 6720c2b32725 ("migration: check magic value for deciding the mapping of channels")
---
 migration/channel.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
migration/channel.c +6 -3
index ca3319a309..f9de064f3b 100644
@@ -117,9 +117,12 @@ int migration_channel_read_peek(QIOChannel *ioc,
         len = qio_channel_readv_full(ioc, &iov, 1, NULL, NULL,
                                      QIO_CHANNEL_READ_FLAG_MSG_PEEK, errp);
 
-        if (len <= 0 && len != QIO_CHANNEL_ERR_BLOCK) {
-            error_setg(errp,
-                       "Failed to peek at channel");
+        if (len < 0 && len != QIO_CHANNEL_ERR_BLOCK) {
+            return -1;
+        }
+
+        if (len == 0) {
+            error_setg(errp, "Failed to peek at channel");
             return -1;
         }
 
Signature · 1 line
2.41.0
#10 lore raw

[PULL 24/26] migration: Remove unnecessary usage of local Error

In reply to [email protected]

From: Avihai Horon <[email protected]>

According to Error API, usage of ERRP_GUARD() or a local Error instead of errp is needed if errp is passed to void functions, where it is later dereferenced to see if an error occurred.

There are several places in migration.c that use local Error although it is not needed. Change these places to use errp directly.

---
 migration/migration.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
migration/migration.c +2 -6
index 9524c22a50..454cd4ec1f 100644
@@ -830,10 +830,9 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp)
          * issue is not possible.
          */
         ret = migration_channel_read_peek(ioc, (void *)&channel_magic,
-                                          sizeof(channel_magic), &local_err);
+                                          sizeof(channel_magic), errp);
 
         if (ret != 0) {
-            error_propagate(errp, local_err);
             return;
         }
 
@@ -1825,8 +1824,6 @@ bool migration_is_blocked(Error **errp)
 static bool migrate_prepare(MigrationState *s, bool blk, bool blk_inc,
                             bool resume, Error **errp)
 {
-    Error *local_err = NULL;
-
     if (blk_inc) {
         warn_report("parameter 'inc' is deprecated;"
                     " use blockdev-mirror with NBD instead");
@@ -1896,8 +1893,7 @@ static bool migrate_prepare(MigrationState *s, bool blk, bool blk_inc,
                        "current migration capabilities");
             return false;
         }
-        if (!migrate_cap_set(MIGRATION_CAPABILITY_BLOCK, true, &local_err)) {
-            error_propagate(errp, local_err);
+        if (!migrate_cap_set(MIGRATION_CAPABILITY_BLOCK, true, errp)) {
             return false;
         }
         s->must_remove_block_options = true;
Signature · 1 line
2.41.0
#11 lore raw

[PULL 17/26] migration: Refactor migration_incoming_setup()

In reply to [email protected]

From: Avihai Horon <[email protected]>

Commit 6720c2b32725 ("migration: check magic value for deciding the mapping of channels") extracted the only code that could fail in migration_incoming_setup().

Now migration_incoming_setup() can't fail, so refactor it to return void and remove errp parameter.

---
 migration/migration.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)
migration/migration.c +3 -12
index 15dc8aa21c..e7d342ab59 100644
@@ -724,11 +724,8 @@ fail:
 /**
  * migration_incoming_setup: Setup incoming migration
  * @f: file for main migration channel
- * @errp: where to put errors
- *
- * Returns: %true on success, %false on error.
  */
-static bool migration_incoming_setup(QEMUFile *f, Error **errp)
+static void migration_incoming_setup(QEMUFile *f)
 {
     MigrationIncomingState *mis = migration_incoming_get_current();
 
@@ -736,7 +733,6 @@ static bool migration_incoming_setup(QEMUFile *f, Error **errp)
         mis->from_src_file = f;
     }
     qemu_file_set_blocking(f, false);
-    return true;
 }
 
 void migration_incoming_process(void)
@@ -780,9 +776,7 @@ static bool postcopy_try_recover(void)
 
 void migration_fd_process_incoming(QEMUFile *f, Error **errp)
 {
-    if (!migration_incoming_setup(f, errp)) {
-        return;
-    }
+    migration_incoming_setup(f);
     if (postcopy_try_recover()) {
         return;
     }
@@ -855,10 +849,7 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp)
 
     if (default_channel) {
         f = qemu_file_new_input(ioc);
-
-        if (!migration_incoming_setup(f, errp)) {
-            return;
-        }
+        migration_incoming_setup(f);
     } else {
         /* Multiple connections */
         assert(migration_needs_multiple_sockets());
Signature · 1 line
2.41.0
#12 lore raw

[PULL 02/26] MAINTAINERS: Remove myself as reviewer from Live Migration

In reply to [email protected]

From: Leonardo Bras <[email protected]>

I am currently focusing in kernel development, so I will probably not be of much help in reviewing general Live Migration changes.

For above reason I am removing my Reviewer status from Migration and RDMA Migration.

---
 MAINTAINERS | 2 --
 1 file changed, 2 deletions(-)
MAINTAINERS +0 -2
index 56464cd916..00ec1f7eca 100644
@@ -3356,7 +3356,6 @@ F: scripts/checkpatch.pl
 Migration
 M: Peter Xu <[email protected]>
 M: Fabiano Rosas <[email protected]>
-R: Leonardo Bras <[email protected]>
 S: Maintained
 F: hw/core/vmstate-if.c
 F: include/hw/vmstate-if.h
@@ -3375,7 +3374,6 @@ X: migration/rdma*
 RDMA Migration
 R: Li Zhijian <[email protected]>
 R: Peter Xu <[email protected]>
-R: Leonardo Bras <[email protected]>
 S: Odd Fixes
 F: migration/rdma*
 
Signature · 1 line
2.41.0
#13 lore raw

[PULL 14/26] tests/qtest: postcopy migration with suspend

In reply to [email protected]

From: Steve Sistare <[email protected]>

Add a test case to verify that the suspended state is handled correctly by live migration postcopy. The test suspends the src, migrates, then wakes the dest.

---
 tests/qtest/migration-test.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
tests/qtest/migration-test.c +19 -1
index a3bfbf2654..136e5df06c 100644
@@ -1347,6 +1347,7 @@ static int migrate_postcopy_prepare(QTestState **from_ptr,
 
     /* Wait for the first serial output from the source */
     wait_for_serial("src_serial");
+    wait_for_suspend(from, &src_state);
 
     g_autofree char *uri = migrate_get_socket_address(to, "socket-address");
     migrate_qmp(from, uri, "{}");
@@ -1364,6 +1365,11 @@ static void migrate_postcopy_complete(QTestState *from, QTestState *to,
 {
     wait_for_migration_complete(from);
 
+    if (args->start.suspend_me) {
+        /* wakeup succeeds only if guest is suspended */
+        qtest_qmp_assert_success(to, "{'execute': 'system_wakeup'}");
+    }
+
     /* Make sure we get at least one "B" on destination */
     wait_for_serial("dest_serial");
 
@@ -1397,6 +1403,15 @@ static void test_postcopy(void)
     test_postcopy_common(&args);
 }
 
+static void test_postcopy_suspend(void)
+{
+    MigrateCommon args = {
+        .start.suspend_me = true,
+    };
+
+    test_postcopy_common(&args);
+}
+
 static void test_postcopy_compress(void)
 {
     MigrateCommon args = {
@@ -3412,7 +3427,10 @@ int main(int argc, char **argv)
         qtest_add_func("/migration/postcopy/recovery/double-failures",
                        test_postcopy_recovery_double_fail);
 #endif /* _WIN32 */
-
+        if (is_x86) {
+            qtest_add_func("/migration/postcopy/suspend",
+                           test_postcopy_suspend);
+        }
     }
 
     qtest_add_func("/migration/bad_dest", test_baddest);
Signature · 1 line
2.41.0
#14 lore raw

[PULL 10/26] migration: preserve suspended for bg_migration

In reply to [email protected]

From: Steve Sistare <[email protected]>

Do not wake a suspended guest during bg_migration, and restore the prior state at finish rather than unconditionally running. Allow the additional state transitions that occur.

---
 migration/migration.c | 7 +------
 system/runstate.c     | 1 +
 2 files changed, 2 insertions(+), 6 deletions(-)
migration/migration.c +1 -6
index 8124811045..2cc7e2a56c 100644
@@ -3390,7 +3390,7 @@ static void bg_migration_vm_start_bh(void *opaque)
     qemu_bh_delete(s->vm_start_bh);
     s->vm_start_bh = NULL;
 
-    vm_start();
+    vm_resume(s->vm_old_state);
     migration_downtime_end(s);
 }
 
@@ -3462,11 +3462,6 @@ static void *bg_migration_thread(void *opaque)
 
     qemu_mutex_lock_iothread();
 
-    /*
-     * If VM is currently in suspended state, then, to make a valid runstate
-     * transition in vm_stop_force_state() we need to wakeup it up.
-     */
-    qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL);
     s->vm_old_state = runstate_get();
 
     global_state_store();
system/runstate.c +1 -0
index ca9eb54cde..621a023120 100644
@@ -168,6 +168,7 @@ static const RunStateTransition runstate_transitions_def[] = {
     { RUN_STATE_SUSPENDED, RUN_STATE_PAUSED},
     { RUN_STATE_SUSPENDED, RUN_STATE_SAVE_VM },
     { RUN_STATE_SUSPENDED, RUN_STATE_RESTORE_VM },
+    { RUN_STATE_SUSPENDED, RUN_STATE_SHUTDOWN },
 
     { RUN_STATE_WATCHDOG, RUN_STATE_RUNNING },
     { RUN_STATE_WATCHDOG, RUN_STATE_FINISH_MIGRATE },
Signature · 1 line
2.41.0
#15 lore raw

[PULL 22/26] migration/multifd: Remove error_setg() in migration_ioc_process_incoming()

In reply to [email protected]

From: Avihai Horon <[email protected]>

If multifd_load_setup() fails in migration_ioc_process_incoming(), error_setg() is called with errp. This will lead to an assert because in that case errp already contains an error.

Fix it by removing the redundant error_setg().

Fixes 6720c2b32725 ("migration: check magic value for deciding the mapping of channels")
---
 migration/migration.c | 1 -
 1 file changed, 1 deletion(-)
migration/migration.c +0 -1
index 8bb1a8134e..9524c22a50 100644
@@ -843,7 +843,6 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp)
     }
 
     if (multifd_load_setup(errp) != 0) {
-        error_setg(errp, "Failed to setup multifd channels");
         return;
     }
 
Signature · 1 line
2.41.0
#16 lore raw

[PULL 25/26] migration/multifd: Remove unnecessary usage of local Error

In reply to [email protected]

From: Avihai Horon <[email protected]>

According to Error API, usage of ERRP_GUARD() or a local Error instead of errp is needed if errp is passed to void functions, where it is later dereferenced to see if an error occurred.

There are several places in multifd.c that use local Error although it is not needed. Change these places to use errp directly.

---
 migration/multifd.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
migration/multifd.c +2 -6
index 9ac24866ad..9f353aecfa 100644
@@ -951,12 +951,10 @@ int multifd_save_setup(Error **errp)
 
     for (i = 0; i < thread_count; i++) {
         MultiFDSendParams *p = &multifd_send_state->params[i];
-        Error *local_err = NULL;
         int ret;
 
-        ret = multifd_send_state->ops->send_setup(p, &local_err);
+        ret = multifd_send_state->ops->send_setup(p, errp);
         if (ret) {
-            error_propagate(errp, local_err);
             return ret;
         }
     }
@@ -1195,12 +1193,10 @@ int multifd_load_setup(Error **errp)
 
     for (i = 0; i < thread_count; i++) {
         MultiFDRecvParams *p = &multifd_recv_state->params[i];
-        Error *local_err = NULL;
         int ret;
 
-        ret = multifd_recv_state->ops->recv_setup(p, &local_err);
+        ret = multifd_recv_state->ops->recv_setup(p, errp);
         if (ret) {
-            error_propagate(errp, local_err);
             return ret;
         }
     }
Signature · 1 line
2.41.0
#17 lore raw

[PULL 16/26] migration: Remove nulling of hostname in migrate_init()

In reply to [email protected]

From: Avihai Horon <[email protected]>

MigrationState->hostname is set to NULL in migrate_init(). This is redundant because it is already freed and set to NULL in migrade_fd_cleanup(). Remove it.

---
 migration/migration.c | 1 -
 1 file changed, 1 deletion(-)
migration/migration.c +0 -1
index 2cc7e2a56c..15dc8aa21c 100644
@@ -1588,7 +1588,6 @@ int migrate_init(MigrationState *s, Error **errp)
     s->migration_thread_running = false;
     error_free(s->error);
     s->error = NULL;
-    s->hostname = NULL;
     s->vmdesc = NULL;
 
     migrate_set_state(&s->state, MIGRATION_STATUS_NONE, MIGRATION_STATUS_SETUP);
Signature · 1 line
2.41.0
#18 lore raw

[PULL 15/26] migration: Remove migrate_max_downtime() declaration

In reply to [email protected]

From: Avihai Horon <[email protected]>

migrate_max_downtime() has been removed long ago, but its declaration was mistakenly left. Remove it.

---
 migration/migration.h | 2 --
 1 file changed, 2 deletions(-)
migration/migration.h +0 -2
index cf2c9c88e0..b3c9288c38 100644
@@ -480,8 +480,6 @@ void migration_incoming_process(void);
 
 bool  migration_has_all_channels(void);
 
-uint64_t migrate_max_downtime(void);
-
 void migrate_set_error(MigrationState *s, const Error *error);
 bool migrate_has_error(MigrationState *s);
 
Signature · 1 line
2.41.0
#19 lore raw

[PULL 13/26] tests/qtest: precopy migration with suspend

In reply to [email protected]

From: Steve Sistare <[email protected]>

Add a test case to verify that the suspended state is handled correctly during live migration precopy. The test suspends the src, migrates, then wakes the dest.

---
 tests/qtest/migration-helpers.h |  2 ++
 tests/qtest/migration-helpers.c |  3 ++
 tests/qtest/migration-test.c    | 62 +++++++++++++++++++++++++++++++--
 3 files changed, 64 insertions(+), 3 deletions(-)
tests/qtest/migration-helpers.h +2 -0
index 3d32699c45..b478549096 100644
@@ -18,6 +18,8 @@
 typedef struct QTestMigrationState {
     bool stop_seen;
     bool resume_seen;
+    bool suspend_seen;
+    bool suspend_me;
 } QTestMigrationState;
 
 bool migrate_watch_for_events(QTestState *who, const char *name,
tests/qtest/migration-helpers.c +3 -0
index fd3b94efa2..37e8e812c5 100644
@@ -32,6 +32,9 @@ bool migrate_watch_for_events(QTestState *who, const char *name,
     if (g_str_equal(name, "STOP")) {
         state->stop_seen = true;
         return true;
+    } else if (g_str_equal(name, "SUSPEND")) {
+        state->suspend_seen = true;
+        return true;
     } else if (g_str_equal(name, "RESUME")) {
         state->resume_seen = true;
         return true;
tests/qtest/migration-test.c +59 -3

128 lines not on this page · raw message

Signature · 1 line
2.41.0
#20 lore raw

[PULL 18/26] migration: Remove errp parameter in migration_fd_process_incoming()

In reply to [email protected]

From: Avihai Horon <[email protected]>

Errp parameter in migration_fd_process_incoming() is unused. Remove it.

---
 migration/migration.h | 2 +-
 migration/migration.c | 2 +-
 migration/rdma.c      | 6 +-----
 3 files changed, 3 insertions(+), 7 deletions(-)
migration/migration.h +1 -1
index b3c9288c38..17972dac34 100644
@@ -474,7 +474,7 @@ struct MigrationState {
 
 void migrate_set_state(int *state, int old_state, int new_state);
 
-void migration_fd_process_incoming(QEMUFile *f, Error **errp);
+void migration_fd_process_incoming(QEMUFile *f);
 void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp);
 void migration_incoming_process(void);
 
migration/migration.c +1 -1
index e7d342ab59..8bb1a8134e 100644
@@ -774,7 +774,7 @@ static bool postcopy_try_recover(void)
     return false;
 }
 
-void migration_fd_process_incoming(QEMUFile *f, Error **errp)
+void migration_fd_process_incoming(QEMUFile *f)
 {
     migration_incoming_setup(f);
     if (postcopy_try_recover()) {
migration/rdma.c +1 -5
index 04debab5d9..94c0f871f0 100644
@@ -4035,7 +4035,6 @@ static void rdma_accept_incoming_migration(void *opaque)
 {
     RDMAContext *rdma = opaque;
     QEMUFile *f;
-    Error *local_err = NULL;
 
     trace_qemu_rdma_accept_incoming_migration();
     if (qemu_rdma_accept(rdma) < 0) {
@@ -4057,10 +4056,7 @@ static void rdma_accept_incoming_migration(void *opaque)
     }
 
     rdma->migration_started_on_destination = 1;
-    migration_fd_process_incoming(f, &local_err);
-    if (local_err) {
-        error_reportf_err(local_err, "RDMA ERROR:");
-    }
+    migration_fd_process_incoming(f);
 }
 
 void rdma_start_incoming_migration(InetSocketAddress *host_port,
Signature · 1 line
2.41.0
#21 lore raw

[PULL 21/26] migration/multifd: Fix leaking of Error in TLS error flow

In reply to [email protected]

From: Avihai Horon <[email protected]>

If there is an error in multifd TLS handshake task, multifd_tls_outgoing_handshake() retrieves the error with qio_task_propagate_error() but never frees it.

Fix it by freeing the obtained Error.

In addition, the error is not reported at all, so report it with migrate_set_error().

Fixes 29647140157a ("migration/tls: add support for multifd tls-handshake")
---
 migration/multifd.c | 2 ++
 1 file changed, 2 insertions(+)
migration/multifd.c +2 -0
index 55d5fd55f8..9ac24866ad 100644
@@ -787,6 +787,7 @@ static void multifd_tls_outgoing_handshake(QIOTask *task,
 
     trace_multifd_tls_outgoing_handshake_error(ioc, error_get_pretty(err));
 
+    migrate_set_error(migrate_get_current(), err);
     /*
      * Error happen, mark multifd_send_thread status as 'quit' although it
      * is not created, and then tell who pay attention to me.
@@ -794,6 +795,7 @@ static void multifd_tls_outgoing_handshake(QIOTask *task,
     p->quit = true;
     qemu_sem_post(&multifd_send_state->channels_ready);
     qemu_sem_post(&p->sem_sync);
+    error_free(err);
 }
 
 static void *multifd_tls_handshake_thread(void *opaque)
Signature · 1 line
2.41.0
#22 lore raw

[PULL 11/26] tests/qtest: migration events

In reply to [email protected]

From: Steve Sistare <[email protected]>

Define a state object to capture events seen by migration tests, to allow more events to be captured in a subsequent patch, and simplify event checking in wait_for_migration_pass. No functional change.

---
 tests/qtest/migration-helpers.h |  9 ++--
 tests/qtest/migration-helpers.c | 22 +++-----
 tests/qtest/migration-test.c    | 91 ++++++++++++++++-----------------
 3 files changed, 55 insertions(+), 67 deletions(-)
tests/qtest/migration-helpers.h +6 -3
index e31dc85cc7..3d32699c45 100644
@@ -15,9 +15,12 @@
 
 #include "libqtest.h"
 
-bool migrate_watch_for_stop(QTestState *who, const char *name,
-                            QDict *event, void *opaque);
-bool migrate_watch_for_resume(QTestState *who, const char *name,
+typedef struct QTestMigrationState {
+    bool stop_seen;
+    bool resume_seen;
+} QTestMigrationState;
+
+bool migrate_watch_for_events(QTestState *who, const char *name,
                               QDict *event, void *opaque);
 
 G_GNUC_PRINTF(3, 4)
tests/qtest/migration-helpers.c +6 -16
index 24fb7b3525..fd3b94efa2 100644
@@ -24,26 +24,16 @@
  */
 #define MIGRATION_STATUS_WAIT_TIMEOUT 120
 
-bool migrate_watch_for_stop(QTestState *who, const char *name,
-                            QDict *event, void *opaque)
+bool migrate_watch_for_events(QTestState *who, const char *name,
+                              QDict *event, void *opaque)
 {
-    bool *seen = opaque;
+    QTestMigrationState *state = opaque;
 
     if (g_str_equal(name, "STOP")) {
-        *seen = true;
+        state->stop_seen = true;
         return true;
-    }
-
-    return false;
-}
-
-bool migrate_watch_for_resume(QTestState *who, const char *name,
-                              QDict *event, void *opaque)
-{
-    bool *seen = opaque;
-
-    if (g_str_equal(name, "RESUME")) {
-        *seen = true;
+    } else if (g_str_equal(name, "RESUME")) {
+        state->resume_seen = true;
         return true;
     }
 
tests/qtest/migration-test.c +43 -48

204 lines not on this page · raw message

Signature · 1 line
2.41.0
#23 lore raw

[PULL 03/26] cpus: vm_was_suspended

In reply to [email protected]

From: Steve Sistare <[email protected]>

Add a state variable to remember if a vm previously transitioned into a suspended state.

---
 include/sysemu/runstate.h |  2 ++
 system/cpus.c             | 15 +++++++++++++++
 2 files changed, 17 insertions(+)
include/sysemu/runstate.h +2 -0
index c8c2bd8a61..88a67e22b0 100644
@@ -51,6 +51,8 @@ int vm_prepare_start(bool step_pending);
 int vm_stop(RunState state);
 int vm_stop_force_state(RunState state);
 int vm_shutdown(void);
+void vm_set_suspended(bool suspended);
+bool vm_get_suspended(void);
 
 typedef enum WakeupReason {
     /* Always keep QEMU_WAKEUP_REASON_NONE = 0 */
system/cpus.c +15 -0
index a444a747f0..9f631ab734 100644
@@ -259,6 +259,21 @@ void cpu_interrupt(CPUState *cpu, int mask)
     }
 }
 
+/*
+ * True if the vm was previously suspended, and has not been woken or reset.
+ */
+static int vm_was_suspended;
+
+void vm_set_suspended(bool suspended)
+{
+    vm_was_suspended = suspended;
+}
+
+bool vm_get_suspended(void)
+{
+    return vm_was_suspended;
+}
+
 static int do_vm_stop(RunState state, bool send_stop)
 {
     int ret = 0;
Signature · 1 line
2.41.0
#24 lore raw

[PULL 09/26] migration: preserve suspended for snapshot

In reply to [email protected]

From: Steve Sistare <[email protected]>

Restoring a snapshot can break a suspended guest. Snapshots suffer from the same suspended-state issues that affect live migration, plus they must handle an additional problematic scenario, which is that a running vm must remain running if it loads a suspended snapshot.

To save, the existing vm_stop call now completely stops the suspended state. Finish with vm_resume to leave the vm in the state it had prior to the save, correctly restoring the suspended state.

To load, if the snapshot is not suspended, then vm_stop + vm_resume correctly handles all states, and leaves the vm in the state it had prior to the load. However, if the snapshot is suspended, restoration is trickier. First, call vm_resume to restore the state to suspended so the current state matches the saved state. Then, if the pre-load state is running, call wakeup to resume running.

Prior to these changes, the vm_stop to RUN_STATE_SAVE_VM and RUN_STATE_RESTORE_VM did not change runstate if the current state was suspended, but now it does, so allow these transitions.

---
 include/migration/snapshot.h   |  7 +++++++
 migration/migration-hmp-cmds.c |  8 +++++---
 migration/savevm.c             | 23 +++++++++++++----------
 system/runstate.c              |  5 +++++
 system/vl.c                    |  2 ++
 5 files changed, 32 insertions(+), 13 deletions(-)
include/migration/snapshot.h +7 -0
index e72083b117..9e4dcaaa75 100644
@@ -16,6 +16,7 @@
 #define QEMU_MIGRATION_SNAPSHOT_H
 
 #include "qapi/qapi-builtin-types.h"
+#include "qapi/qapi-types-run-state.h"
 
 /**
  * save_snapshot: Save an internal snapshot.
@@ -61,4 +62,10 @@ bool delete_snapshot(const char *name,
                     bool has_devices, strList *devices,
                     Error **errp);
 
+/**
+ * load_snapshot_resume: Restore runstate after loading snapshot.
+ * @state: state to restore
+ */
+void load_snapshot_resume(RunState state);
+
 #endif
migration/migration-hmp-cmds.c +5 -3
index 99710c8ffb..740a219aa4 100644
@@ -399,15 +399,17 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)
 
 void hmp_loadvm(Monitor *mon, const QDict *qdict)
 {
-    int saved_vm_running  = runstate_is_running();
+    RunState saved_state = runstate_get();
+
     const char *name = qdict_get_str(qdict, "name");
     Error *err = NULL;
 
     vm_stop(RUN_STATE_RESTORE_VM);
 
-    if (load_snapshot(name, NULL, false, NULL, &err) && saved_vm_running) {
-        vm_start();
+    if (load_snapshot(name, NULL, false, NULL, &err)) {
+        load_snapshot_resume(saved_state);
     }
+
     hmp_handle_error(mon, err);
 }
 
migration/savevm.c +13 -10
index 1b9ab7b8ee..74f915f3ac 100644
@@ -3046,7 +3046,7 @@ bool save_snapshot(const char *name, bool overwrite, const char *vmstate,
     QEMUSnapshotInfo sn1, *sn = &sn1;
     int ret = -1, ret2;
     QEMUFile *f;
-    int saved_vm_running;
+    RunState saved_state = runstate_get();
     uint64_t vm_state_size;
     g_autoptr(GDateTime) now = g_date_time_new_now_local();
 
@@ -3092,8 +3092,6 @@ bool save_snapshot(const char *name, bool overwrite, const char *vmstate,
         return false;
     }
 
-    saved_vm_running = runstate_is_running();
-
     global_state_store();
     vm_stop(RUN_STATE_SAVE_VM);
 
@@ -3147,9 +3145,7 @@ bool save_snapshot(const char *name, bool overwrite, const char *vmstate,
  the_end:
     bdrv_drain_all_end();
 
-    if (saved_vm_running) {
-        vm_start();
-    }
+    vm_resume(saved_state);
     return ret == 0;
 }
 
@@ -3317,6 +3313,14 @@ err_drain:
     return false;
 }
 
+void load_snapshot_resume(RunState state)
+{
+    vm_resume(state);
+    if (state == RUN_STATE_RUNNING && runstate_get() == RUN_STATE_SUSPENDED) {
+        qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, &error_abort);
+    }
+}
+
 bool delete_snapshot(const char *name, bool has_devices,
                      strList *devices, Error **errp)
 {
@@ -3381,16 +3385,15 @@ static void snapshot_load_job_bh(void *opaque)
 {
     Job *job = opaque;
     SnapshotJob *s = container_of(job, SnapshotJob, common);
-    int orig_vm_running;
+    RunState orig_state = runstate_get();
 
     job_progress_set_remaining(&s->common, 1);
 
-    orig_vm_running = runstate_is_running();
     vm_stop(RUN_STATE_RESTORE_VM);
 
     s->ret = load_snapshot(s->tag, s->vmstate, true, s->devices, s->errp);
-    if (s->ret && orig_vm_running) {
-        vm_start();
+    if (s->ret) {
+        load_snapshot_resume(orig_state);
     }
 
     job_progress_update(&s->common, 1);
system/runstate.c +5 -0
index e2fa2040cb..ca9eb54cde 100644
@@ -77,6 +77,7 @@ typedef struct {
 
 static const RunStateTransition runstate_transitions_def[] = {
     { RUN_STATE_PRELAUNCH, RUN_STATE_INMIGRATE },
+    { RUN_STATE_PRELAUNCH, RUN_STATE_SUSPENDED },
 
     { RUN_STATE_DEBUG, RUN_STATE_RUNNING },
     { RUN_STATE_DEBUG, RUN_STATE_FINISH_MIGRATE },
@@ -132,6 +133,7 @@ static const RunStateTransition runstate_transitions_def[] = {
 
     { RUN_STATE_RESTORE_VM, RUN_STATE_RUNNING },
     { RUN_STATE_RESTORE_VM, RUN_STATE_PRELAUNCH },
+    { RUN_STATE_RESTORE_VM, RUN_STATE_SUSPENDED },
 
     { RUN_STATE_COLO, RUN_STATE_RUNNING },
     { RUN_STATE_COLO, RUN_STATE_PRELAUNCH },
@@ -150,6 +152,7 @@ static const RunStateTransition runstate_transitions_def[] = {
     { RUN_STATE_RUNNING, RUN_STATE_COLO},
 
     { RUN_STATE_SAVE_VM, RUN_STATE_RUNNING },
+    { RUN_STATE_SAVE_VM, RUN_STATE_SUSPENDED },
 
     { RUN_STATE_SHUTDOWN, RUN_STATE_PAUSED },
     { RUN_STATE_SHUTDOWN, RUN_STATE_FINISH_MIGRATE },
@@ -163,6 +166,8 @@ static const RunStateTransition runstate_transitions_def[] = {
     { RUN_STATE_SUSPENDED, RUN_STATE_PRELAUNCH },
     { RUN_STATE_SUSPENDED, RUN_STATE_COLO},
     { RUN_STATE_SUSPENDED, RUN_STATE_PAUSED},
+    { RUN_STATE_SUSPENDED, RUN_STATE_SAVE_VM },
+    { RUN_STATE_SUSPENDED, RUN_STATE_RESTORE_VM },
 
     { RUN_STATE_WATCHDOG, RUN_STATE_RUNNING },
     { RUN_STATE_WATCHDOG, RUN_STATE_FINISH_MIGRATE },
system/vl.c +2 -0
index 6b87bfa32c..1eec5f627f 100644
@@ -2710,7 +2710,9 @@ void qmp_x_exit_preconfig(Error **errp)
     qemu_machine_creation_done();
 
     if (loadvm) {
+        RunState state = autostart ? RUN_STATE_RUNNING : runstate_get();
         load_snapshot(loadvm, NULL, false, NULL, &error_fatal);
+        load_snapshot_resume(state);
     }
     if (replay_mode != REPLAY_MODE_NONE) {
         replay_vmstate_init();
Signature · 1 line
2.41.0
#25 lore raw

[PULL 26/26] migration: fix coverity migrate_mode finding

In reply to [email protected]

From: Steve Sistare <[email protected]>

Coverity diagnoses a possible out-of-range array index here ...

    static GSList *migration_blockers[MIG_MODE__MAX];

    fill_source_migration_info() {
        GSList *cur_blocker = migration_blockers[migrate_mode()];

... because it does not know that MIG_MODE__MAX will never be returned as a migration mode. To fix, assert so in migrate_mode().

Fixes fa3673e497a1 ("migration: per-mode blockers")
---
 migration/options.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
migration/options.c +3 -1
index 8d8ec73ad9..3e3e0b93b4 100644
@@ -833,8 +833,10 @@ uint64_t migrate_max_postcopy_bandwidth(void)
 MigMode migrate_mode(void)
 {
     MigrationState *s = migrate_get_current();
+    MigMode mode = s->parameters.mode;
 
-    return s->parameters.mode;
+    assert(mode >= 0 && mode < MIG_MODE__MAX);
+    return mode;
 }
 
 int migrate_multifd_channels(void)
Signature · 1 line
2.41.0
#26 lore raw

[PULL 12/26] tests/qtest: option to suspend during migration

In reply to [email protected]

From: Steve Sistare <[email protected]>

Add an option to suspend the src in a-b-bootblock.S, which puts the guest in S3 state after one round of writing to memory. The option is enabled by poking a 1 into the suspend_me word in the boot block prior to starting the src vm. Generate symbol offsets in a-b-bootblock.h so that the suspend_me offset is known. Generate the bootblock for each test, because suspend_me may differ for each.

---
 tests/migration/i386/a-b-bootblock.h | 26 ++++++++++-----
 tests/qtest/migration-test.c         | 12 +++++--
 tests/migration/i386/Makefile        |  5 +--
 tests/migration/i386/a-b-bootblock.S | 50 ++++++++++++++++++++++++++--
 4 files changed, 77 insertions(+), 16 deletions(-)
tests/migration/i386/a-b-bootblock.h +18 -8
index 5b523917ce..c83f8711db 100644
@@ -4,7 +4,7 @@
  * the header and the assembler differences in your patch submission.
  */
 unsigned char x86_bootsect[] = {
-  0xfa, 0x0f, 0x01, 0x16, 0x8c, 0x7c, 0x66, 0xb8, 0x01, 0x00, 0x00, 0x00,
+  0xfa, 0x0f, 0x01, 0x16, 0xb8, 0x7c, 0x66, 0xb8, 0x01, 0x00, 0x00, 0x00,
   0x0f, 0x22, 0xc0, 0x66, 0xea, 0x20, 0x7c, 0x00, 0x00, 0x08, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe4, 0x92, 0x0c, 0x02,
   0xe6, 0x92, 0xb8, 0x10, 0x00, 0x00, 0x00, 0x8e, 0xd8, 0x66, 0xb8, 0x41,
@@ -13,13 +13,13 @@ unsigned char x86_bootsect[] = {
   0x40, 0x06, 0x7c, 0xf1, 0xb8, 0x00, 0x00, 0x10, 0x00, 0xfe, 0x00, 0x05,
   0x00, 0x10, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x40, 0x06, 0x7c, 0xf2, 0xfe,
   0xc3, 0x80, 0xe3, 0x3f, 0x75, 0xe6, 0x66, 0xb8, 0x42, 0x00, 0x66, 0xba,
-  0xf8, 0x03, 0xee, 0xeb, 0xdb, 0x8d, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x9a, 0xcf, 0x00,
-  0xff, 0xff, 0x00, 0x00, 0x00, 0x92, 0xcf, 0x00, 0x27, 0x00, 0x74, 0x7c,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0xf8, 0x03, 0xee, 0xa1, 0xbe, 0x7c, 0x00, 0x00, 0x83, 0xf8, 0x00, 0x74,
+  0xd3, 0xb8, 0x04, 0x00, 0x10, 0x00, 0x8b, 0x00, 0x83, 0xf8, 0x01, 0x74,
+  0xc7, 0xb0, 0xf1, 0xe6, 0xb2, 0xb8, 0x04, 0x00, 0x10, 0x00, 0xc7, 0x00,
+  0x01, 0x00, 0x00, 0x00, 0x66, 0xb8, 0x01, 0x24, 0x66, 0xba, 0x04, 0x06,
+  0x66, 0xef, 0x66, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0xff, 0xff, 0x00, 0x00, 0x00, 0x9a, 0xcf, 0x00, 0xff, 0xff, 0x00, 0x00,
+  0x00, 0x92, 0xcf, 0x00, 0x27, 0x00, 0xa0, 0x7c, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -49,3 +49,13 @@ unsigned char x86_bootsect[] = {
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xaa
 };
 
+#define SYM_do_zero 0x00007c3d
+#define SYM_gdt 0x00007ca0
+#define SYM_gdtdesc 0x00007cb8
+#define SYM_innerloop 0x00007c51
+#define SYM_mainloop 0x00007c4c
+#define SYM_pre_zero 0x00007c38
+#define SYM_start 0x00007c00
+#define SYM_suspend_me 0x00007cbe
+#define SYM_TEST_MEM_END 0x06400000
+#define SYM_TEST_MEM_START 0x00100000
tests/qtest/migration-test.c +9 -3
index 41fc837f36..2e2ab6af3c 100644
@@ -133,7 +133,7 @@ static char *bootpath;
 #include "tests/migration/aarch64/a-b-kernel.h"
 #include "tests/migration/s390x/a-b-bios.h"
 
-static void bootfile_create(char *dir)
+static void bootfile_create(char *dir, bool suspend_me)
 {
     const char *arch = qtest_get_arch();
     unsigned char *content;
@@ -143,6 +143,7 @@ static void bootfile_create(char *dir)
     if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
         /* the assembled x86 boot sector should be exactly one sector large */
         g_assert(sizeof(x86_bootsect) == 512);
+        x86_bootsect[SYM_suspend_me - SYM_start] = suspend_me;
         content = x86_bootsect;
         len = sizeof(x86_bootsect);
     } else if (g_str_equal(arch, "s390x")) {
@@ -646,6 +647,8 @@ typedef struct {
     bool use_dirty_ring;
     const char *opts_source;
     const char *opts_target;
+    /* suspend the src before migrating to dest. */
+    bool suspend_me;
 } MigrateStart;
 
 /*
@@ -767,6 +770,8 @@ static int test_migrate_start(QTestState **from, QTestState **to,
 
     dst_state = (QTestMigrationState) { };
     src_state = (QTestMigrationState) { };
+    bootfile_create(tmpfs, args->suspend_me);
+
     if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
         memory_size = "150M";
 
@@ -2980,7 +2985,9 @@ static int64_t get_limit_rate(QTestState *who)
 static QTestState *dirtylimit_start_vm(void)
 {
     QTestState *vm = NULL;
-    g_autofree gchar *
+    g_autofree gchar *cmd = NULL;
+
+    bootfile_create(tmpfs, false);
     cmd = g_strdup_printf("-accel kvm,dirty-ring-size=4096 "
                           "-name dirtylimit-test,debug-threads=on "
                           "-m 150M -smp 1 "
@@ -3329,7 +3336,6 @@ int main(int argc, char **argv)
                        g_get_tmp_dir(), err->message);
     }
     g_assert(tmpfs);
-    bootfile_create(tmpfs);
 
     module_call_init(MODULE_INIT_QOM);
 
tests/migration/i386/Makefile +3 -2
index 5c0324134a..37a72ae353 100644
@@ -4,9 +4,10 @@
 .PHONY: all clean
 all: a-b-bootblock.h
 
-a-b-bootblock.h: x86.bootsect
+a-b-bootblock.h: x86.bootsect x86.o
 	echo "$$__note" > header.tmp
 	xxd -i $< | sed -e 's/.*int.*//' >> header.tmp
+	nm x86.o | awk '{print "#define SYM_"$$3" 0x"$$1}' >> header.tmp
 	mv header.tmp $@
 
 x86.bootsect: x86.boot
@@ -16,7 +17,7 @@ x86.boot: x86.o
 	$(CROSS_PREFIX)objcopy -O binary $< $@
 
 x86.o: a-b-bootblock.S
-	$(CROSS_PREFIX)gcc -m32 -march=i486 -c $< -o $@
+	$(CROSS_PREFIX)gcc -I.. -m32 -march=i486 -c $< -o $@
 
 clean:
 	@rm -rf *.boot *.o *.bootsect
tests/migration/i386/a-b-bootblock.S +47 -3

74 lines not on this page · raw message

Signature · 1 line
2.41.0
#27 lore raw
In reply to [email protected]
Quoted 18 lines · On Thu, 4 Jan 2024 at 04:33, <[email protected]> wrote:

From: Peter Xu <[email protected]>

The following changes since commit 7425b6277f12e82952cede1f531bfc689bf77fb1:

Merge tag 'tracing-pull-request' of https://gitlab.com/stefanha/qemu into staging (2023-12-27 05:15:32 -0500)

are available in the Git repository at:

https://gitlab.com/peterx/qemu.git tags/migration-20240104-pull-request

for you to fetch changes up to b12635ff08ab2e5a6a955c6866ef4525fb3deb5d:

migration: fix coverity migrate_mode finding (2024-01-04 09:52:42 +0800)

----------------------------------------------------------------
migration 1st pull for 9.0

Quoted 6 lines

- We lost Juan and Leo in the maintainers file
- Steven's suspend state fix
- Steven's fix for coverity on migrate_mode
- Avihai's migration cleanup series

----------------------------------------------------------------

I notice that your gpg key doesn't seem to be signed by anybody else; you might look at whether it's easy to get it signed by somebody else (eg some of your redhat colleagues).

Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/9.0
for any user-visible changes.

-- PMM

author
#28 lore raw
Quoted 3 lines · Peter Maydell

I notice that your gpg key doesn't seem to be signed by anybody else; you might look at whether it's easy to get it signed by somebody else (eg some of your redhat colleagues).

Hmm, I think I have signed with at least Juan and Stefan. Which is the key server we normally use? Maybe I missed some steps there?

Thanks,

Signature · 1 line
Peter Xu
#29 lore raw
Quoted 8 lines · Peter Xu
Quoted 3 lines · Peter Maydell

I notice that your gpg key doesn't seem to be signed by anybody else; you might look at whether it's easy to get it signed by somebody else (eg some of your redhat colleagues).

Hmm, I think I have signed with at least Juan and Stefan. Which is the key server we normally use? Maybe I missed some steps there?

Yes, Peter's key is signed by me:

$ gpg --list-signatures 3B5FCCCDF3ABD706
pub   ed25519/0x3B5FCCCDF3ABD706 2023-10-03 [SC]
      Key fingerprint = B918 4DC2 0CC4 57DA CF7D  D1A9 3B5F CCCD F3AB D706
uid                   [  full  ] Peter Xu <[email protected]>
sig 3        0x3B5FCCCDF3ABD706 2023-10-03  [self-signature]
sig          0x9CA4ABB381AB73C8 2023-10-10  Stefan Hajnoczi
<[email protected]>
uid                   [  full  ] Peter Xu <[email protected]>
sig 3        0x3B5FCCCDF3ABD706 2023-10-03  [self-signature]
sig          0x9CA4ABB381AB73C8 2023-10-10  Stefan Hajnoczi
<[email protected]>
sub   cv25519/0xD5261EB1CB0C6E45 2023-10-03 [E]
sig          0x3B5FCCCDF3ABD706 2023-10-03  [self-signature]

I have pushed to the keyservers again in case I forget.

Stefan

#30 lore raw
Quoted 27 lines · Stefan Hajnoczi
Quoted 8 lines · Peter Xu
Quoted 3 lines · Peter Maydell

I notice that your gpg key doesn't seem to be signed by anybody else; you might look at whether it's easy to get it signed by somebody else (eg some of your redhat colleagues).

Hmm, I think I have signed with at least Juan and Stefan. Which is the key server we normally use? Maybe I missed some steps there?

Yes, Peter's key is signed by me:

$ gpg --list-signatures 3B5FCCCDF3ABD706
pub   ed25519/0x3B5FCCCDF3ABD706 2023-10-03 [SC]
      Key fingerprint = B918 4DC2 0CC4 57DA CF7D  D1A9 3B5F CCCD F3AB D706
uid                   [  full  ] Peter Xu <[email protected]>
sig 3        0x3B5FCCCDF3ABD706 2023-10-03  [self-signature]
sig          0x9CA4ABB381AB73C8 2023-10-10  Stefan Hajnoczi
<[email protected]>
uid                   [  full  ] Peter Xu <[email protected]>
sig 3        0x3B5FCCCDF3ABD706 2023-10-03  [self-signature]
sig          0x9CA4ABB381AB73C8 2023-10-10  Stefan Hajnoczi
<[email protected]>
sub   cv25519/0xD5261EB1CB0C6E45 2023-10-03 [E]
sig          0x3B5FCCCDF3ABD706 2023-10-03  [self-signature]
Quoted 1 line

I have pushed to the keyservers again in case I forget.

Thanks. Which keyservers did you use? I think these days the keyserver infrastructure is unfortunately fragmented; I probably didn't try refreshing from the right keyserver.

-- PMM

#31 lore raw
Quoted 29 lines · Peter Maydell
Quoted 27 lines · Stefan Hajnoczi
Quoted 8 lines · Peter Xu
Quoted 3 lines · Peter Maydell

I notice that your gpg key doesn't seem to be signed by anybody else; you might look at whether it's easy to get it signed by somebody else (eg some of your redhat colleagues).

Hmm, I think I have signed with at least Juan and Stefan. Which is the key server we normally use? Maybe I missed some steps there?

Yes, Peter's key is signed by me:

$ gpg --list-signatures 3B5FCCCDF3ABD706
pub   ed25519/0x3B5FCCCDF3ABD706 2023-10-03 [SC]
      Key fingerprint = B918 4DC2 0CC4 57DA CF7D  D1A9 3B5F CCCD F3AB D706
uid                   [  full  ] Peter Xu <[email protected]>
sig 3        0x3B5FCCCDF3ABD706 2023-10-03  [self-signature]
sig          0x9CA4ABB381AB73C8 2023-10-10  Stefan Hajnoczi
<[email protected]>
uid                   [  full  ] Peter Xu <[email protected]>
sig 3        0x3B5FCCCDF3ABD706 2023-10-03  [self-signature]
sig          0x9CA4ABB381AB73C8 2023-10-10  Stefan Hajnoczi
<[email protected]>
sub   cv25519/0xD5261EB1CB0C6E45 2023-10-03 [E]
sig          0x3B5FCCCDF3ABD706 2023-10-03  [self-signature]
Quoted 5 lines
Quoted 1 line

I have pushed to the keyservers again in case I forget.

Thanks. Which keyservers did you use? I think these days the keyserver infrastructure is unfortunately fragmented; I probably didn't try refreshing from the right keyserver.

I ran gpg --send-key again and it said hkps://keyserver.ubuntu.com.

Stefan

author
#32 lore raw
Quoted 30 lines · Stefan Hajnoczi
Quoted 29 lines · Peter Maydell
Quoted 27 lines · Stefan Hajnoczi
Quoted 8 lines · Peter Xu
Quoted 3 lines · Peter Maydell

I notice that your gpg key doesn't seem to be signed by anybody else; you might look at whether it's easy to get it signed by somebody else (eg some of your redhat colleagues).

Hmm, I think I have signed with at least Juan and Stefan. Which is the key server we normally use? Maybe I missed some steps there?

Yes, Peter's key is signed by me:

$ gpg --list-signatures 3B5FCCCDF3ABD706
pub   ed25519/0x3B5FCCCDF3ABD706 2023-10-03 [SC]
      Key fingerprint = B918 4DC2 0CC4 57DA CF7D  D1A9 3B5F CCCD F3AB D706
uid                   [  full  ] Peter Xu <[email protected]>
sig 3        0x3B5FCCCDF3ABD706 2023-10-03  [self-signature]
sig          0x9CA4ABB381AB73C8 2023-10-10  Stefan Hajnoczi
<[email protected]>
uid                   [  full  ] Peter Xu <[email protected]>
sig 3        0x3B5FCCCDF3ABD706 2023-10-03  [self-signature]
sig          0x9CA4ABB381AB73C8 2023-10-10  Stefan Hajnoczi
<[email protected]>
sub   cv25519/0xD5261EB1CB0C6E45 2023-10-03 [E]
sig          0x3B5FCCCDF3ABD706 2023-10-03  [self-signature]
Quoted 7 lines
Quoted 5 lines
Quoted 1 line

I have pushed to the keyservers again in case I forget.

Thanks. Which keyservers did you use? I think these days the keyserver infrastructure is unfortunately fragmented; I probably didn't try refreshing from the right keyserver.

I ran gpg --send-key again and it said hkps://keyserver.ubuntu.com.

Thanks Stefan. Indeed I can only see Stefan's sig there on the key server:

https://keyserver.ubuntu.com/pks/lookup?search=3b5fcccdf3abd706&fingerprint=on&op=index

I am guessing Juan forgot to do a "gpg --send-keys 3B5FCCCDF3ABD706". I'll also try to ask maybe one or two more people to exchange keys. Maybe that'll also help.

Thanks,

Signature · 1 line
Peter Xu
author
#33 lore raw
Quoted 39 lines · Peter Xu
Quoted 30 lines · Stefan Hajnoczi
Quoted 29 lines · Peter Maydell
Quoted 27 lines · Stefan Hajnoczi
Quoted 8 lines · Peter Xu
Quoted 3 lines · Peter Maydell

I notice that your gpg key doesn't seem to be signed by anybody else; you might look at whether it's easy to get it signed by somebody else (eg some of your redhat colleagues).

Hmm, I think I have signed with at least Juan and Stefan. Which is the key server we normally use? Maybe I missed some steps there?

Yes, Peter's key is signed by me:

$ gpg --list-signatures 3B5FCCCDF3ABD706
pub   ed25519/0x3B5FCCCDF3ABD706 2023-10-03 [SC]
      Key fingerprint = B918 4DC2 0CC4 57DA CF7D  D1A9 3B5F CCCD F3AB D706
uid                   [  full  ] Peter Xu <[email protected]>
sig 3        0x3B5FCCCDF3ABD706 2023-10-03  [self-signature]
sig          0x9CA4ABB381AB73C8 2023-10-10  Stefan Hajnoczi
<[email protected]>
uid                   [  full  ] Peter Xu <[email protected]>
sig 3        0x3B5FCCCDF3ABD706 2023-10-03  [self-signature]
sig          0x9CA4ABB381AB73C8 2023-10-10  Stefan Hajnoczi
<[email protected]>
sub   cv25519/0xD5261EB1CB0C6E45 2023-10-03 [E]
sig          0x3B5FCCCDF3ABD706 2023-10-03  [self-signature]
Quoted 7 lines
Quoted 5 lines
Quoted 1 line

I have pushed to the keyservers again in case I forget.

Thanks. Which keyservers did you use? I think these days the keyserver infrastructure is unfortunately fragmented; I probably didn't try refreshing from the right keyserver.

I ran gpg --send-key again and it said hkps://keyserver.ubuntu.com.

Quoted 7 lines

Thanks Stefan. Indeed I can only see Stefan's sig there on the key server:

https://keyserver.ubuntu.com/pks/lookup?search=3b5fcccdf3abd706&fingerprint=on&op=index

I am guessing Juan forgot to do a "gpg --send-keys 3B5FCCCDF3ABD706". I'll also try to ask maybe one or two more people to exchange keys. Maybe that'll also help.

Besides that, just now I also tried to do a remote --recv-keys on my own key and I found that indeed the signature from Stefan was not attached.

Then I found this:

https://daniel-lange.com/archives/178-Getting-gpg-to-import-signatures-again.html

So it seems the default behavior of gpg command changed recently that it'll stop to receive signatures besides the self signature to avoid DoS to the keyservers.

https://dev.gnupg.org/rG23c978640812d123eaffd4108744bdfcf48f7c93

In short, now we seem to need:

  $ gpg --recv-keys --keyserver-option no-self-sigs-only $KEY_ID

To recover the old behavior to receive signs from others.

Thanks,

Signature · 1 line
Peter Xu
#34 lore raw
Quoted 60 lines · Peter Xu
Quoted 39 lines · Peter Xu
Quoted 30 lines · Stefan Hajnoczi
Quoted 29 lines · Peter Maydell
Quoted 27 lines · Stefan Hajnoczi
Quoted 8 lines · Peter Xu
Quoted 3 lines · Peter Maydell

I notice that your gpg key doesn't seem to be signed by anybody else; you might look at whether it's easy to get it signed by somebody else (eg some of your redhat colleagues).

Hmm, I think I have signed with at least Juan and Stefan. Which is the key server we normally use? Maybe I missed some steps there?

Yes, Peter's key is signed by me:

$ gpg --list-signatures 3B5FCCCDF3ABD706
pub   ed25519/0x3B5FCCCDF3ABD706 2023-10-03 [SC]
      Key fingerprint = B918 4DC2 0CC4 57DA CF7D  D1A9 3B5F CCCD F3AB D706
uid                   [  full  ] Peter Xu <[email protected]>
sig 3        0x3B5FCCCDF3ABD706 2023-10-03  [self-signature]
sig          0x9CA4ABB381AB73C8 2023-10-10  Stefan Hajnoczi
<[email protected]>
uid                   [  full  ] Peter Xu <[email protected]>
sig 3        0x3B5FCCCDF3ABD706 2023-10-03  [self-signature]
sig          0x9CA4ABB381AB73C8 2023-10-10  Stefan Hajnoczi
<[email protected]>
sub   cv25519/0xD5261EB1CB0C6E45 2023-10-03 [E]
sig          0x3B5FCCCDF3ABD706 2023-10-03  [self-signature]
Quoted 7 lines
Quoted 5 lines
Quoted 1 line

I have pushed to the keyservers again in case I forget.

Thanks. Which keyservers did you use? I think these days the keyserver infrastructure is unfortunately fragmented; I probably didn't try refreshing from the right keyserver.

I ran gpg --send-key again and it said hkps://keyserver.ubuntu.com.

Quoted 7 lines

Thanks Stefan. Indeed I can only see Stefan's sig there on the key server:

https://keyserver.ubuntu.com/pks/lookup?search=3b5fcccdf3abd706&fingerprint=on&op=index

I am guessing Juan forgot to do a "gpg --send-keys 3B5FCCCDF3ABD706". I'll also try to ask maybe one or two more people to exchange keys. Maybe that'll also help.

Besides that, just now I also tried to do a remote --recv-keys on my own key and I found that indeed the signature from Stefan was not attached.

Then I found this:

https://daniel-lange.com/archives/178-Getting-gpg-to-import-signatures-again.html

So it seems the default behavior of gpg command changed recently that it'll stop to receive signatures besides the self signature to avoid DoS to the keyservers.

Quoted 7 lines

https://dev.gnupg.org/rG23c978640812d123eaffd4108744bdfcf48f7c93

In short, now we seem to need:

  $ gpg --recv-keys --keyserver-option no-self-sigs-only $KEY_ID

To recover the old behavior to receive signs from others.

Ah, thank you. Yes, that did the trick and I now can see the signatures on your key from other people.

-- PMM