WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 7/7] libxl, Use QMP to insert a passthrough device wh

To: Xen Devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH 7/7] libxl, Use QMP to insert a passthrough device when using upstream QEMU
From: Anthony PERARD <anthony.perard@xxxxxxxxxx>
Date: Fri, 7 Oct 2011 13:10:18 +0100
Cc: Anthony PERARD <anthony.perard@xxxxxxxxxx>, Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Delivery-date: Fri, 07 Oct 2011 05:15:55 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1317989418-25463-1-git-send-email-anthony.perard@xxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <1317989418-25463-1-git-send-email-anthony.perard@xxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
---
 tools/libxl/libxl_pci.c |   58 ++++++++++++++++++++++++++++++-----------------
 1 files changed, 37 insertions(+), 21 deletions(-)

diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c
index 1523cf0..b6cb4a3 100644
--- a/tools/libxl/libxl_pci.c
+++ b/tools/libxl/libxl_pci.c
@@ -613,27 +613,43 @@ static int do_pci_add(libxl__gc *gc, uint32_t domid, 
libxl_device_pci *pcidev, i
                                          NULL, NULL, NULL) < 0) {
             return ERROR_FAIL;
         }
-        path = libxl__sprintf(gc, "/local/domain/0/device-model/%d/state", 
domid);
-        state = libxl__xs_read(gc, XBT_NULL, path);
-        path = libxl__sprintf(gc, "/local/domain/0/device-model/%d/parameter", 
domid);
-        if (pcidev->vdevfn)
-            libxl__xs_write(gc, XBT_NULL, path, PCI_BDF_VDEVFN, pcidev->domain,
-                           pcidev->bus, pcidev->dev, pcidev->func, 
pcidev->vdevfn);
-        else
-            libxl__xs_write(gc, XBT_NULL, path, PCI_BDF, pcidev->domain,
-                           pcidev->bus, pcidev->dev, pcidev->func);
-        path = libxl__sprintf(gc, "/local/domain/0/device-model/%d/command", 
domid);
-        xs_write(ctx->xsh, XBT_NULL, path, "pci-ins", strlen("pci-ins"));
-        rc = libxl__wait_for_device_model(gc, domid, NULL, NULL,
-                                          pci_ins_check, state);
-        path = libxl__sprintf(gc, "/local/domain/0/device-model/%d/parameter", 
domid);
-        vdevfn = libxl__xs_read(gc, XBT_NULL, path);
-        path = libxl__sprintf(gc, "/local/domain/0/device-model/%d/state", 
domid);
-        if ( rc < 0 )
-            LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "qemu refused to add device: 
%s", vdevfn);
-        else if ( sscanf(vdevfn, "0x%x", &pcidev->vdevfn) != 1 )
-            rc = -1;
-        xs_write(ctx->xsh, XBT_NULL, path, state, strlen(state));
+        if (libxl__device_model_version_running(gc, domid)
+            == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) {
+            rc = libxl__qmp_pci_add(gc, domid, pcidev);
+        } else {
+            path = libxl__sprintf(gc, "/local/domain/0/device-model/%d/state",
+                                  domid);
+            state = libxl__xs_read(gc, XBT_NULL, path);
+            path = libxl__sprintf(gc,
+                                  "/local/domain/0/device-model/%d/parameter",
+                                  domid);
+            if (pcidev->vdevfn) {
+                libxl__xs_write(gc, XBT_NULL, path, PCI_BDF_VDEVFN,
+                                pcidev->domain, pcidev->bus, pcidev->dev,
+                                pcidev->func, pcidev->vdevfn);
+            } else {
+                libxl__xs_write(gc, XBT_NULL, path, PCI_BDF, pcidev->domain,
+                                pcidev->bus, pcidev->dev, pcidev->func);
+            }
+            path = libxl__sprintf(gc,
+                                  "/local/domain/0/device-model/%d/command",
+                                  domid);
+            xs_write(ctx->xsh, XBT_NULL, path, "pci-ins", strlen("pci-ins"));
+            rc = libxl__wait_for_device_model(gc, domid, NULL, NULL,
+                                              pci_ins_check, state);
+            path = libxl__sprintf(gc,
+                                  "/local/domain/0/device-model/%d/parameter",
+                                  domid);
+            vdevfn = libxl__xs_read(gc, XBT_NULL, path);
+            path = libxl__sprintf(gc, "/local/domain/0/device-model/%d/state",
+                                  domid);
+            if ( rc < 0 )
+                LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
+                           "qemu refused to add device: %s", vdevfn);
+            else if ( sscanf(vdevfn, "0x%x", &pcidev->vdevfn) != 1 )
+                rc = -1;
+            xs_write(ctx->xsh, XBT_NULL, path, state, strlen(state));
+        }
         if ( rc )
             return ERROR_FAIL;
         break;
-- 
Anthony PERARD


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>