diff mbox series

[26/35] libxl_pci: Only check if qemu-dm is running in qemu-trad case

Message ID 20190802153606.32061-27-anthony.perard@citrix.com (mailing list archive)
State Superseded
Headers show
Series libxl refactoring to use ev_qmp (with API changes) | expand

Commit Message

Anthony PERARD Aug. 2, 2019, 3:35 p.m. UTC
QEMU upstream (or qemu-xen) may not have set "running" state in
xenstore. "running" with QEMU doesn't mean that the binary is
running, it means that the emulation have started. When adding a
pci-passthrough device to QEMU, we do so via QMP, we have a direct
answer to whether QEMU is running or not, no need to check ahead.

Moving the check to do it only with qemu-trad makes upcoming changes
simpler.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/libxl/libxl_pci.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

Comments

Ian Jackson Sept. 17, 2019, 5:16 p.m. UTC | #1
Anthony PERARD writes ("[PATCH 26/35] libxl_pci: Only check if qemu-dm is running in qemu-trad case"):
> QEMU upstream (or qemu-xen) may not have set "running" state in
> xenstore. "running" with QEMU doesn't mean that the binary is
> running, it means that the emulation have started. When adding a
> pci-passthrough device to QEMU, we do so via QMP, we have a direct
> answer to whether QEMU is running or not, no need to check ahead.
> 
> Moving the check to do it only with qemu-trad makes upcoming changes
> simpler.

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
diff mbox series

Patch

diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c
index b9ca69f5f0..071880b855 100644
--- a/tools/libxl/libxl_pci.c
+++ b/tools/libxl/libxl_pci.c
@@ -1004,13 +1004,13 @@  static int do_pci_add(libxl__gc *gc, uint32_t domid,
 
     if (type == LIBXL_DOMAIN_TYPE_HVM) {
         hvm = 1;
-        if (libxl__wait_for_device_model_deprecated(gc, domid, "running",
-                                         NULL, NULL, NULL) < 0) {
-            rc = ERROR_FAIL;
-            goto out;
-        }
         switch (libxl__device_model_version_running(gc, domid)) {
             case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL:
+                if (libxl__wait_for_device_model_deprecated(gc, domid,
+                        "running", NULL, NULL, NULL) < 0) {
+                    rc = ERROR_FAIL;
+                    goto out;
+                }
                 rc = qemu_pci_add_xenstore(gc, domid, pcidev);
                 break;
             case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN:
@@ -1395,12 +1395,11 @@  static int do_pci_remove(libxl__gc *gc, uint32_t domid,
     rc = ERROR_FAIL;
     if (type == LIBXL_DOMAIN_TYPE_HVM) {
         hvm = 1;
-        if (libxl__wait_for_device_model_deprecated(gc, domid, "running",
-                                         NULL, NULL, NULL) < 0)
-            goto out_fail;
-
         switch (libxl__device_model_version_running(gc, domid)) {
         case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL:
+            if (libxl__wait_for_device_model_deprecated(gc, domid,
+                    "running", NULL, NULL, NULL) < 0)
+                goto out_fail;
             rc = qemu_pci_remove_xenstore(gc, domid, pcidev, force);
             break;
         case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN: