[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] libxl: wait for QEMU exit before restarting a domain


  • To: Jiaqing Zhao <Zhao.Jiaqing@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jason Andryuk <jason.andryuk@xxxxxxx>
  • Date: Wed, 4 Nov 2026 12:33:17 -0500
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=KH0cjcSzGgPO3uZLJv4e8L2XyUvuLRkjrWF6x9bITw8=; b=Dc7kixC6R+ScFYhUU+mOMFXHZnLdiR7IYQhE642lyV6Sy7gMNh812YTEEmsr5Jn7MHJH+eAW68JzOWjK5wk0kQb3BkONh9qmIYY8pOFy6aWkpvUIBUaTC1U3Qc8QEiM7rD1L1pbAXbc0UnMKb6cs+ByxN12dxArZP/c8eqpZ3PnCaT6Fl/MbeIAVhNf1qE6Wdnc2Dil+YwcHu7toneZaj0LUn3to4hIXBmIC09aPR+EncO/NW9rUyT+6i3GJaT+H1K9nQgoXJDUjrwZI8MqG0fgJ6MLT7IPLQVslnmcqCcJNnNRyLebrq5jNRzy+En3H+XmrS1L2FEmQlMfpqJawbQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jpNTTe8ywusT/7uWiEMDzFJyqxt3+vIj9Q5yOhoOUhqSQUwqSGe53Tzx9ZO5x8jt6faf5SG+obDxSXvZNCqU5RSIN3E3BrCtl0xPWLV/sq6KpZF2nuHzcC2zcyHxCsEnBPuvOxsPATCpIjIPxNNZWacUnTJFiK850dW3WzgAPLdhFlvQpHWVuK/HfpOb68C7YirArmwi2dPaQV9ff3Zi72G5HVtZTJh4ZkIh+w3rUrZ33JJUK3rfeewyP+OjnlUijIjGJv1MBjFvbUcHLh2v8guMseoFGf7KY3qsOAndEDJPgc42cJ4ubzwT8fnh1KN1syZavUe2jp15fMbLYhnydA==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=amd.com header.i="@amd.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Cc: Anthony PERARD <anthony.perard@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Roger Pau Monné <roger@xxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Penny Zheng <penny.zheng@xxxxxxx>
  • Delivery-date: Wed, 04 Nov 2026 17:33:31 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 2026-11-04 01:46, Jiaqing Zhao wrote:
The PID-based device model destruction path returns immediately after
sending SIGHUP, before QEMU has necessarily exited. When an HVM guest
reboots with VNC enabled, the new QEMU process may fail to bind the VNC
port because the old process still holds it.

Wait for QEMU to exit in a child process after singaling it for at most

"signaling"

60 seconds. If waiting fails or times out, log the error and retain the
existing domain destruction behaviour.

60 seconds seems like a lot. Did you measure the time to see how long it takes? It's an upper bound, but maybe 10 seconds would be better?

Signed-off-by: Jiaqing Zhao <Zhao.Jiaqing@xxxxxxx>

@@ -3547,12 +3564,28 @@ void libxl__destroy_device_model(libxl__egc *egc,
      LOGD(DEBUG, domid, "Didn't find dm UID; destroying by pid");
path = GCSPRINTF("/local/domain/%d/image/device-model-pid", domid);
-    rc = kill_device_model(gc, path);
-
+    rc = kill_device_model(gc, path, &dm_pid);

If you just read the pid directly here, you don't need to change kill_device_model(). But your approach is only a single read, so maybe it's better. I'm undecided, but maybe someone else has an opinion.

      if (rc) {
          ACCUMULATE_RC(ddms->rc);
          LOGD(ERROR, domid, "Killing device model pid from path %s", path);
+        goto out;
+    }
+
+    LOGD(DEBUG, domid, "Waiting for device model [%d] to exit", dm_pid);
+    reaper_pid = libxl__ev_child_fork(gc, &ddms->destroyer,
+                                      kill_device_model_uid_cb);

The reaper_pid handling below is duplicated from
`if (dm_kill_uid_str) {`

Put the above pid code in an else, and use a single implementation of the reaper_pid handling.

+    if (reaper_pid < 0) {
+        rc = ERROR_FAIL;
+        ACCUMULATE_RC(ddms->rc);
+        LOGD(ERROR, domid, "Unable to fork device model exit waiter");
+        goto out;
      }
+    if (!reaper_pid) {
+        rc = wait_device_model_pid_child(gc, domid, dm_pid);

Though this would need an additional conditional.

Thanks,
Jason

+        assert(rc <= 0 && rc >= -125);
+        _exit(-rc);
+    }
+    return;
out:
      /*



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.