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

[Xen-changelog] [xen-unstable] libxl: make libxl_device_pci_{add, remove, destroy} interfaces asynchronous


  • To: xen-changelog@xxxxxxxxxxxxxxxxxxx
  • From: Xen patchbot-unstable <patchbot@xxxxxxx>
  • Date: Tue, 07 Aug 2012 20:33:10 +0000
  • Delivery-date: Tue, 07 Aug 2012 20:33:25 +0000
  • List-id: "Change log for Mercurial \(receive only\)" <xen-changelog.lists.xen.org>

# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1343984043 -3600
# Node ID 65ae31da1c536b2551c6465d796642ba42e594a2
# Parent  7fd5facb608427b7e5890ff10cee8ed0da6a7703
libxl: make libxl_device_pci_{add,remove,destroy} interfaces asynchronous

This does not make the implementation fully asynchronous but just
updates the API to support asynchrony in the future.

Currently although these functions do not call hotplug scripts etc and
therefore are not "slow" (per the comment about ao machinery in
libxl_internal.h) they do interact with the device model and so are
not quite "fast" either. We can live with this for now.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Committed-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---


diff -r 7fd5facb6084 -r 65ae31da1c53 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h       Fri Aug 03 09:50:28 2012 +0200
+++ b/tools/libxl/libxl.h       Fri Aug 03 09:54:03 2012 +0100
@@ -757,10 +757,21 @@ int libxl_device_vfb_destroy(libxl_ctx *
                              LIBXL_EXTERNAL_CALLERS_ONLY;
 
 /* PCI Passthrough */
-int libxl_device_pci_add(libxl_ctx *ctx, uint32_t domid, libxl_device_pci 
*pcidev);
-int libxl_device_pci_remove(libxl_ctx *ctx, uint32_t domid, libxl_device_pci 
*pcidev);
-int libxl_device_pci_destroy(libxl_ctx *ctx, uint32_t domid, libxl_device_pci 
*pcidev);
-libxl_device_pci *libxl_device_pci_list(libxl_ctx *ctx, uint32_t domid, int 
*num);
+int libxl_device_pci_add(libxl_ctx *ctx, uint32_t domid,
+                         libxl_device_pci *pcidev,
+                         const libxl_asyncop_how *ao_how)
+                         LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_device_pci_remove(libxl_ctx *ctx, uint32_t domid,
+                            libxl_device_pci *pcidev,
+                            const libxl_asyncop_how *ao_how)
+                            LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_device_pci_destroy(libxl_ctx *ctx, uint32_t domid,
+                             libxl_device_pci *pcidev,
+                             const libxl_asyncop_how *ao_how)
+                             LIBXL_EXTERNAL_CALLERS_ONLY;
+
+libxl_device_pci *libxl_device_pci_list(libxl_ctx *ctx, uint32_t domid,
+                                        int *num);
 
 /*
  * Functions related to making devices assignable -- that is, bound to
diff -r 7fd5facb6084 -r 65ae31da1c53 tools/libxl/libxl_pci.c
--- a/tools/libxl/libxl_pci.c   Fri Aug 03 09:50:28 2012 +0200
+++ b/tools/libxl/libxl_pci.c   Fri Aug 03 09:54:03 2012 +0100
@@ -1010,13 +1010,15 @@ int libxl__device_pci_setdefault(libxl__
     return 0;
 }
 
-int libxl_device_pci_add(libxl_ctx *ctx, uint32_t domid, libxl_device_pci 
*pcidev)
+int libxl_device_pci_add(libxl_ctx *ctx, uint32_t domid,
+                         libxl_device_pci *pcidev,
+                         const libxl_asyncop_how *ao_how)
 {
-    GC_INIT(ctx);
+    AO_CREATE(ctx, domid, ao_how);
     int rc;
     rc = libxl__device_pci_add(gc, domid, pcidev, 0);
-    GC_FREE;
-    return rc;
+    libxl__ao_complete(egc, ao, rc);
+    return AO_INPROGRESS;
 }
 
 static int libxl_pcidev_assignable(libxl_ctx *ctx, libxl_device_pci *pcidev)
@@ -1150,6 +1152,9 @@ static int qemu_pci_remove_xenstore(libx
     return 0;
 }
 
+static int libxl__device_pci_remove_common(libxl__gc *gc, uint32_t domid,
+                                           libxl_device_pci *pcidev, int 
force);
+
 static int do_pci_remove(libxl__gc *gc, uint32_t domid,
                          libxl_device_pci *pcidev, int force)
 {
@@ -1263,10 +1268,7 @@ out:
     stubdomid = libxl_get_stubdom_id(ctx, domid);
     if (stubdomid != 0) {
         libxl_device_pci pcidev_s = *pcidev;
-        if (force)
-                libxl_device_pci_destroy(ctx, stubdomid, &pcidev_s);
-        else
-                libxl_device_pci_remove(ctx, stubdomid, &pcidev_s);
+        libxl__device_pci_remove_common(gc, stubdomid, &pcidev_s, force);
     }
 
     libxl__device_pci_remove_xenstore(gc, domid, pcidev);
@@ -1313,27 +1315,31 @@ out:
     return rc;
 }
 
-int libxl_device_pci_remove(libxl_ctx *ctx, uint32_t domid, libxl_device_pci 
*pcidev)
+int libxl_device_pci_remove(libxl_ctx *ctx, uint32_t domid,
+                            libxl_device_pci *pcidev,
+                            const libxl_asyncop_how *ao_how)
+
 {
-    GC_INIT(ctx);
+    AO_CREATE(ctx, domid, ao_how);
     int rc;
 
     rc = libxl__device_pci_remove_common(gc, domid, pcidev, 0);
 
-    GC_FREE;
-    return rc;
+    libxl__ao_complete(egc, ao, rc);
+    return AO_INPROGRESS;
 }
 
 int libxl_device_pci_destroy(libxl_ctx *ctx, uint32_t domid,
-                                  libxl_device_pci *pcidev)
+                             libxl_device_pci *pcidev,
+                             const libxl_asyncop_how *ao_how)
 {
-    GC_INIT(ctx);
+    AO_CREATE(ctx, domid, ao_how);
     int rc;
 
     rc = libxl__device_pci_remove_common(gc, domid, pcidev, 1);
 
-    GC_FREE;
-    return rc;
+    libxl__ao_complete(egc, ao, rc);
+    return AO_INPROGRESS;
 }
 
 static void libxl__device_pci_from_xs_be(libxl__gc *gc,
@@ -1415,7 +1421,7 @@ int libxl__device_pci_destroy_all(libxl_
          * respond to SCI interrupt because the guest kernel has shut down the
          * devices by the time we even get here!
          */
-        if (libxl_device_pci_destroy(ctx, domid, pcidevs + i) < 0)
+        if (libxl__device_pci_remove_common(gc, domid, pcidevs + i, 1) < 0)
             rc = ERROR_FAIL;
     }
 
diff -r 7fd5facb6084 -r 65ae31da1c53 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Fri Aug 03 09:50:28 2012 +0200
+++ b/tools/libxl/xl_cmdimpl.c  Fri Aug 03 09:54:03 2012 +0100
@@ -2389,9 +2389,9 @@ static void pcidetach(const char *dom, c
         exit(2);
     }
     if (force)
-        libxl_device_pci_destroy(ctx, domid, &pcidev);
+        libxl_device_pci_destroy(ctx, domid, &pcidev, 0);
     else
-        libxl_device_pci_remove(ctx, domid, &pcidev);
+        libxl_device_pci_remove(ctx, domid, &pcidev, 0);
 
     libxl_device_pci_dispose(&pcidev);
     xlu_cfg_destroy(config);
@@ -2435,7 +2435,7 @@ static void pciattach(const char *dom, c
         fprintf(stderr, "pci-attach: malformed BDF specification \"%s\"\n", 
bdf);
         exit(2);
     }
-    libxl_device_pci_add(ctx, domid, &pcidev);
+    libxl_device_pci_add(ctx, domid, &pcidev, 0);
 
     libxl_device_pci_dispose(&pcidev);
     xlu_cfg_destroy(config);
diff -r 7fd5facb6084 -r 65ae31da1c53 tools/ocaml/libs/xl/xenlight_stubs.c
--- a/tools/ocaml/libs/xl/xenlight_stubs.c      Fri Aug 03 09:50:28 2012 +0200
+++ b/tools/ocaml/libs/xl/xenlight_stubs.c      Fri Aug 03 09:54:03 2012 +0100
@@ -423,7 +423,7 @@ value stub_xl_device_pci_add(value info,
        device_pci_val(&gc, &lg, &c_info, info);
 
        INIT_CTX();
-       ret = libxl_device_pci_add(ctx, Int_val(domid), &c_info);
+       ret = libxl_device_pci_add(ctx, Int_val(domid), &c_info, 0);
        if (ret != 0)
                failwith_xl("pci_add", &lg);
        FREE_CTX();
@@ -441,7 +441,7 @@ value stub_xl_device_pci_remove(value in
        device_pci_val(&gc, &lg, &c_info, info);
 
        INIT_CTX();
-       ret = libxl_device_pci_remove(ctx, Int_val(domid), &c_info);
+       ret = libxl_device_pci_remove(ctx, Int_val(domid), &c_info, 0);
        if (ret != 0)
                failwith_xl("pci_remove", &lg);
        FREE_CTX();
diff -r 7fd5facb6084 -r 65ae31da1c53 tools/python/xen/lowlevel/xl/xl.c
--- a/tools/python/xen/lowlevel/xl/xl.c Fri Aug 03 09:50:28 2012 +0200
+++ b/tools/python/xen/lowlevel/xl/xl.c Fri Aug 03 09:54:03 2012 +0100
@@ -497,7 +497,7 @@ static PyObject *pyxl_pci_add(XlObject *
         return NULL;
     }
     pci = (Py_device_pci *)obj;
-    if ( libxl_device_pci_add(self->ctx, domid, &pci->obj) ) {
+    if ( libxl_device_pci_add(self->ctx, domid, &pci->obj, 0) ) {
         PyErr_SetString(xl_error_obj, "cannot add pci device");
         return NULL;
     }
@@ -519,12 +519,12 @@ static PyObject *pyxl_pci_del(XlObject *
     }
     pci = (Py_device_pci *)obj;
     if ( force ) {
-        if ( libxl_device_pci_destroy(self->ctx, domid, &pci->obj) ) {
+        if ( libxl_device_pci_destroy(self->ctx, domid, &pci->obj, 0) ) {
             PyErr_SetString(xl_error_obj, "cannot remove pci device");
             return NULL;
         }
     } else {
-        if ( libxl_device_pci_remove(self->ctx, domid, &pci->obj) ) {
+        if ( libxl_device_pci_remove(self->ctx, domid, &pci->obj, 0) ) {
             PyErr_SetString(xl_error_obj, "cannot remove pci device");
             return NULL;
         }

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

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