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

[Xen-devel] [RFC PATCH 05/17] libxl: use xenstore for pci hotplug qemu-in-linux-stubdom commands



From: Simon Gaiser <simon@xxxxxxxxxxxxxxxxxxxxxx>

There is no QMP socket access, re-use the same mechanism as for MiniOS
based stubdom.
---
 tools/libxl/libxl_pci.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c
index 4755a0c..311fad4 100644
--- a/tools/libxl/libxl_pci.c
+++ b/tools/libxl/libxl_pci.c
@@ -995,6 +995,7 @@ static int do_pci_add(libxl__gc *gc, uint32_t domid, 
libxl_device_pci *pcidev, i
     uint32_t flag = XEN_DOMCTL_DEV_RDM_RELAXED;
     uint32_t domainid = domid;
     bool isstubdom = libxl_is_stubdom(ctx, domid, &domainid);
+    uint32_t dm_domid;
 
     if (type == LIBXL_DOMAIN_TYPE_INVALID)
         return ERROR_FAIL;
@@ -1010,7 +1011,15 @@ static int do_pci_add(libxl__gc *gc, uint32_t domid, 
libxl_device_pci *pcidev, i
                 rc = qemu_pci_add_xenstore(gc, domid, pcidev);
                 break;
             case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN:
-                rc = libxl__qmp_pci_add(gc, domid, pcidev);
+                dm_domid = libxl_get_stubdom_id(ctx, domid);
+
+                if (dm_domid != 0
+                    && libxl__stubdomain_version_running(gc, dm_domid) ==
+                         LIBXL_STUBDOMAIN_VERSION_LINUX) {
+                    rc = qemu_pci_add_xenstore(gc, domid, pcidev);
+                } else {
+                    rc = libxl__qmp_pci_add(gc, domid, pcidev);
+                }
                 break;
             default:
                 return ERROR_INVAL;
@@ -1362,7 +1371,7 @@ static int do_pci_remove(libxl__gc *gc, uint32_t domid,
     libxl_device_pci *assigned;
     libxl_domain_type type = libxl__domain_type(gc, domid);
     int hvm = 0, rc, num;
-    int stubdomid = 0;
+    int stubdomid = libxl_get_stubdom_id(ctx, domid);
     uint32_t domainid = domid;
     bool isstubdom = libxl_is_stubdom(ctx, domid, &domainid);
 
@@ -1390,7 +1399,13 @@ static int do_pci_remove(libxl__gc *gc, uint32_t domid,
             rc = qemu_pci_remove_xenstore(gc, domid, pcidev, force);
             break;
         case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN:
-            rc = libxl__qmp_pci_del(gc, domid, pcidev);
+            if (stubdomid != 0
+                && libxl__stubdomain_version_running(gc, stubdomid) ==
+                     LIBXL_STUBDOMAIN_VERSION_LINUX) {
+                rc = qemu_pci_remove_xenstore(gc, domid, pcidev, force);
+            } else {
+                rc = libxl__qmp_pci_del(gc, domid, pcidev);
+            }
             break;
         default:
             rc = ERROR_INVAL;
@@ -1470,7 +1485,6 @@ out:
             LOGED(ERROR, domainid, "xc_deassign_device failed");
     }
 
-    stubdomid = libxl_get_stubdom_id(ctx, domid);
     if (stubdomid != 0) {
         libxl_device_pci pcidev_s = *pcidev;
         libxl__device_pci_remove_common(gc, stubdomid, &pcidev_s, force);
-- 
git-series 0.9.1

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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