Skip to contentSkip to conversation

libxl: introduce libxl_need_xenpv_qemu

PATCH Applied Stefano Stabellini 2 participants 2 messages Nov 29, 2010 – Dec 14, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxl: introduce libxl_need_xenpv_qemu

Introduce libxl_need_xenpv_qemu to detect if the caller needs to create a pv qemu instance (using libxl_create_xenpv_qemu).
A positive reply depends on the number of pv console and vfbs, and the type of disk backends.

---

tools/libxl/libxl.c +33 -0
diff -r 79b71c77907b tools/libxl/libxl.c
@@ -2632,6 +2632,39 @@ static int libxl_build_xenpv_qemu_args(l
     return 0;
 }
 
+int libxl_need_xenpv_qemu(libxl_ctx *ctx,
+        int nr_consoles, libxl_device_console *consoles,
+        int nr_vfbs, libxl_device_vfb *vfbs,
+        int nr_disks, libxl_device_disk *disks)
+{
+    int i, ret = 0;
+    libxl__gc gc = LIBXL_INIT_GC(ctx);
+
+    if (nr_consoles > 1) {
+        ret = 1;
+        goto out;
+    }
+
+    for (i = 0; i < nr_consoles; i++) {
+        if (consoles[i].consback == LIBXL_CONSBACK_IOEMU) {
+            ret = 1;
+            goto out;
+        }
+    }
+
+    if (nr_vfbs > 0) {
+        ret = 1;
+        goto out;
+    }
+
+    if (nr_disks > 0 && !libxl__blktap_enabled(&gc))
+        ret = 1;
+
+out:
+    libxl__free_all(&gc);
+    return ret;
+}
+
 int libxl_create_xenpv_qemu(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb *vfb,
                             libxl_device_model_starting **starting_r)
 {
tools/libxl/libxl.h +4 -0
diff -r 79b71c77907b tools/libxl/libxl.h
@@ -376,6 +376,10 @@ int libxl_create_device_model(libxl_ctx 
                               libxl_device_model_starting **starting_r);
 int libxl_create_xenpv_qemu(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb *vfb,
                             libxl_device_model_starting **starting_r);
+int libxl_need_xenpv_qemu(libxl_ctx *ctx,
+        int nr_consoles, libxl_device_console *consoles,
+        int nr_vfbs, libxl_device_vfb *vfbs,
+        int nr_disks, libxl_device_disk *disks);
   /* Caller must either: pass starting_r==0, or on successful
    * return pass *starting_r (which will be non-0) to
    * libxl_confirm_device_model or libxl_detach_device_model. */
tools/libxl/xl_cmdimpl.c +9 -2
diff -r 79b71c77907b tools/libxl/xl_cmdimpl.c
@@ -1675,6 +1675,7 @@ start:
                                         d_config.vifs, d_config.num_vifs,
                                         &dm_starting) );
     } else {
+        int need_qemu = 0;
         libxl_device_console console;
 
         for (i = 0; i < d_config.num_vfbs; i++) {
@@ -1686,12 +1687,18 @@ start:
 
         init_console_info(&console, 0, &state);
         console.domid = domid;
-        if (d_config.num_vfbs)
+
+        need_qemu = libxl_need_xenpv_qemu(&ctx, 1, &console,
+                d_config.num_vfbs, d_config.vfbs,
+                d_config.num_disks, &d_config.disks[0]);
+
+        if (need_qemu)
              console.consback = LIBXL_CONSBACK_IOEMU;
+
         libxl_device_console_add(&ctx, domid, &console);
         libxl_device_console_destroy(&console);
 
-        if (d_config.num_vfbs)
+        if (need_qemu)
             libxl_create_xenpv_qemu(&ctx, domid, d_config.vfbs, &dm_starting);
     }
Applied
#1 lore raw

Stefano Stabellini writes ("[Xen-devel] [PATCH] libxl: introduce libxl_need_xenpv_qemu"):

Quoted 4 lines

Introduce libxl_need_xenpv_qemu to detect if the caller needs to create a pv qemu instance (using libxl_create_xenpv_qemu).
A positive reply depends on the number of pv console and vfbs, and the type of disk backends.

Applied, thanks.

Ian.