Skip to contentSkip to conversation

libxl: make libxl_device_{vkb, vfb}_add take a dummy ao

PATCH In review Roger Pau Monne 1 participant 2 messages Apr 16, 2012 – May 9, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxl: make libxl_device_{vkb, vfb}_add take a dummy ao

Add a dummy ao parameter to both functions, since they may become slow in the future.

---

Requires Ian Jackson's "libxl: Allow AO_GC and EGC_GC even if not used"

 tools/libxl/libxl.c        |   20 ++++++++++++--------
 tools/libxl/libxl.h        |    6 ++++--
 tools/libxl/libxl_create.c |    6 +++---
 tools/libxl/libxl_dm.c     |    4 ++--
 4 files changed, 21 insertions(+), 15 deletions(-)
tools/libxl/libxl.c +12 -8
index 44a54cb..3fd8d5b 100644
@@ -2208,9 +2208,10 @@ static int libxl__device_from_vkb(libxl__gc *gc, uint32_t domid,
     return 0;
 }
 
-int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb)
+int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb,
+                         const libxl_asyncop_how *ao_how)
 {
-    GC_INIT(ctx);
+    AO_CREATE(ctx, domid, ao_how);
     flexarray_t *front;
     flexarray_t *back;
     libxl__device device;
@@ -2255,8 +2256,9 @@ out_free:
     flexarray_free(back);
     flexarray_free(front);
 out:
-    GC_FREE;
-    return rc;
+    /* Dummy ao */
+    libxl__ao_complete(egc, ao, rc);
+    return AO_INPROGRESS;
 }
 
 int libxl_device_vkb_remove(libxl_ctx *ctx, uint32_t domid,
@@ -2339,9 +2341,10 @@ static int libxl__device_from_vfb(libxl__gc *gc, uint32_t domid,
     return 0;
 }
 
-int libxl_device_vfb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb *vfb)
+int libxl_device_vfb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb *vfb,
+                         const libxl_asyncop_how *ao_how)
 {
-    GC_INIT(ctx);
+    AO_CREATE(ctx, domid, ao_how);
     flexarray_t *front;
     flexarray_t *back;
     libxl__device device;
@@ -2399,8 +2402,9 @@ out_free:
     flexarray_free(front);
     flexarray_free(back);
 out:
-    GC_FREE;
-    return rc;
+    /* Dummy ao */
+    libxl__ao_complete(egc, ao, rc);
+    return AO_INPROGRESS;
 }
 
 int libxl_device_vfb_remove(libxl_ctx *ctx, uint32_t domid,
tools/libxl/libxl.h +4 -2
index 6da6107..ce89b31 100644
@@ -563,14 +563,16 @@ int libxl_device_nic_getinfo(libxl_ctx *ctx, uint32_t domid,
                               libxl_device_nic *nic, libxl_nicinfo *nicinfo);
 
 /* Keyboard */
-int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb);
+int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb,
+                         const libxl_asyncop_how *ao_how);
 int libxl_device_vkb_remove(libxl_ctx *ctx, uint32_t domid,
                             libxl_device_vkb *vkb,
                             const libxl_asyncop_how *ao_how);
 int libxl_device_vkb_destroy(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb);
 
 /* Framebuffer */
-int libxl_device_vfb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb *vfb);
+int libxl_device_vfb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb *vfb,
+                         const libxl_asyncop_how *ao_how);
 int libxl_device_vfb_remove(libxl_ctx *ctx, uint32_t domid,
                             libxl_device_vfb *vfb,
                             const libxl_asyncop_how *ao_how);
tools/libxl/libxl_create.c +3 -3
index a1f5731..39e9257 100644
@@ -628,7 +628,7 @@ static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config,
         libxl__device_console_dispose(&console);
 
         libxl_device_vkb_init(&vkb);
-        libxl_device_vkb_add(ctx, domid, &vkb);
+        libxl_device_vkb_add(ctx, domid, &vkb, 0);
         libxl_device_vkb_dispose(&vkb);
 
         ret = libxl__create_device_model(gc, domid, d_config,
@@ -646,8 +646,8 @@ static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config,
         libxl__device_console console;
 
         for (i = 0; i < d_config->num_vfbs; i++) {
-            libxl_device_vfb_add(ctx, domid, &d_config->vfbs[i]);
-            libxl_device_vkb_add(ctx, domid, &d_config->vkbs[i]);
+            libxl_device_vfb_add(ctx, domid, &d_config->vfbs[i], 0);
+            libxl_device_vkb_add(ctx, domid, &d_config->vkbs[i], 0);
         }
 
         ret = init_console_info(&console, 0);
tools/libxl/libxl_dm.c +2 -2
index 8dc588d..4a2b5c1 100644
@@ -804,10 +804,10 @@ retry_transaction:
         if (ret)
             goto out_free;
     }
-    ret = libxl_device_vfb_add(ctx, dm_domid, &dm_config.vfbs[0]);
+    ret = libxl_device_vfb_add(ctx, dm_domid, &dm_config.vfbs[0], 0);
     if (ret)
         goto out_free;
-    ret = libxl_device_vkb_add(ctx, dm_domid, &dm_config.vkbs[0]);
+    ret = libxl_device_vkb_add(ctx, dm_domid, &dm_config.vkbs[0], 0);
     if (ret)
         goto out_free;
 
Signature · 1 line
1.7.7.5 (Apple Git-26)
#1 lore raw
Quoted 4 lines · Roger Pau Monne

Add a dummy ao parameter to both functions, since they may become slow in the future.

This is completely wrong, please don't even review it.

Quoted 128 lines

---

Requires Ian Jackson's "libxl: Allow AO_GC and EGC_GC even if not used"

  tools/libxl/libxl.c        |   20 ++++++++++++--------
  tools/libxl/libxl.h        |    6 ++++--
  tools/libxl/libxl_create.c |    6 +++---
  tools/libxl/libxl_dm.c     |    4 ++--
  4 files changed, 21 insertions(+), 15 deletions(-)
tools/libxl/libxl.c +12 -8
index 44a54cb..3fd8d5b 100644
@@ -2208,9 +2208,10 @@ static int libxl__device_from_vkb(libxl__gc *gc, uint32_t domid,
      return 0;
  }
 
-int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb)
+int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb,
+                         const libxl_asyncop_how *ao_how)
  {
-    GC_INIT(ctx);
+    AO_CREATE(ctx, domid, ao_how);
      flexarray_t *front;
      flexarray_t *back;
      libxl__device device;
@@ -2255,8 +2256,9 @@ out_free:
      flexarray_free(back);
      flexarray_free(front);
  out:
-    GC_FREE;
-    return rc;
+    /* Dummy ao */
+    libxl__ao_complete(egc, ao, rc);
+    return AO_INPROGRESS;
  }
 
  int libxl_device_vkb_remove(libxl_ctx *ctx, uint32_t domid,
@@ -2339,9 +2341,10 @@ static int libxl__device_from_vfb(libxl__gc *gc, uint32_t domid,
      return 0;
  }
 
-int libxl_device_vfb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb *vfb)
+int libxl_device_vfb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb *vfb,
+                         const libxl_asyncop_how *ao_how)
  {
-    GC_INIT(ctx);
+    AO_CREATE(ctx, domid, ao_how);
      flexarray_t *front;
      flexarray_t *back;
      libxl__device device;
@@ -2399,8 +2402,9 @@ out_free:
      flexarray_free(front);
      flexarray_free(back);
  out:
-    GC_FREE;
-    return rc;
+    /* Dummy ao */
+    libxl__ao_complete(egc, ao, rc);
+    return AO_INPROGRESS;
  }
 
  int libxl_device_vfb_remove(libxl_ctx *ctx, uint32_t domid,
tools/libxl/libxl.h +4 -2
index 6da6107..ce89b31 100644
@@ -563,14 +563,16 @@ int libxl_device_nic_getinfo(libxl_ctx *ctx, uint32_t domid,
                                libxl_device_nic *nic, libxl_nicinfo *nicinfo);
 
  /* Keyboard */
-int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb);
+int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb,
+                         const libxl_asyncop_how *ao_how);
  int libxl_device_vkb_remove(libxl_ctx *ctx, uint32_t domid,
                              libxl_device_vkb *vkb,
                              const libxl_asyncop_how *ao_how);
  int libxl_device_vkb_destroy(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb);
 
  /* Framebuffer */
-int libxl_device_vfb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb *vfb);
+int libxl_device_vfb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb *vfb,
+                         const libxl_asyncop_how *ao_how);
  int libxl_device_vfb_remove(libxl_ctx *ctx, uint32_t domid,
                              libxl_device_vfb *vfb,
                              const libxl_asyncop_how *ao_how);
tools/libxl/libxl_create.c +3 -3
index a1f5731..39e9257 100644
@@ -628,7 +628,7 @@ static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config,
          libxl__device_console_dispose(&console);
 
          libxl_device_vkb_init(&vkb);
-        libxl_device_vkb_add(ctx, domid,&vkb);
+        libxl_device_vkb_add(ctx, domid,&vkb, 0);
          libxl_device_vkb_dispose(&vkb);
 
          ret = libxl__create_device_model(gc, domid, d_config,
@@ -646,8 +646,8 @@ static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config,
          libxl__device_console console;
 
          for (i = 0; i<  d_config->num_vfbs; i++) {
-            libxl_device_vfb_add(ctx, domid,&d_config->vfbs[i]);
-            libxl_device_vkb_add(ctx, domid,&d_config->vkbs[i]);
+            libxl_device_vfb_add(ctx, domid,&d_config->vfbs[i], 0);
+            libxl_device_vkb_add(ctx, domid,&d_config->vkbs[i], 0);
          }
 
          ret = init_console_info(&console, 0);
tools/libxl/libxl_dm.c +2 -2
index 8dc588d..4a2b5c1 100644
@@ -804,10 +804,10 @@ retry_transaction:
          if (ret)
              goto out_free;
      }
-    ret = libxl_device_vfb_add(ctx, dm_domid,&dm_config.vfbs[0]);
+    ret = libxl_device_vfb_add(ctx, dm_domid,&dm_config.vfbs[0], 0);
      if (ret)
          goto out_free;
-    ret = libxl_device_vkb_add(ctx, dm_domid,&dm_config.vkbs[0]);
+    ret = libxl_device_vkb_add(ctx, dm_domid,&dm_config.vkbs[0], 0);
      if (ret)
          goto out_free;