Skip to contentSkip to conversation

Refactor libxl domain creation

PATCH In review Gianni Tedesco 1 participant 6 messages Jan 4, 2011 – Jan 5, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Refactor libxl domain creation

Introduce libxl_domain_create_new() and libxl_domain_create_restore() rendering redundant several other, more complex, API's and simplifying the xl create implementation.

Gianni

#1 lore raw

PATCH 1/1 xl: idl: Abolish keyed union types

 tools/libxl/gentypes.py        |  10 +----
 tools/libxl/libxl.c            |  44 +++++++++++-----------
 tools/libxl/libxl.idl          |  42 ++++++++++-----------
 tools/libxl/libxl_bootloader.c |  30 +++++++-------
 tools/libxl/libxl_dom.c        |  32 ++++++++--------
 tools/libxl/libxltypes.py      |  15 -------
 tools/libxl/xl_cmdimpl.c       |  80 +++++++++++++++++++++---------------------
 tools/ocaml/libs/xl/xl_stubs.c |  26 ++++++------
 8 files changed, 127 insertions(+), 152 deletions(-)

# HG changeset patch
# User Gianni Tedesco <[email protected]> # Date 1294156918 0
# Node ID 01a1ce470640c67cf507e1f64a32561443b43061 # Parent a8d69de8eb315b3b18c8a86c4d1505f53b84a443
xl: idl: Abolish keyed union types

Since the IDL file has become useful for generating language bindings it has become apparent that the KeyedUnion type has no straightforward translation to scripting languages which have no notion of unions.

Turns out this is only used in domain_build_info which is hardly a memory criticial structure.

This patch simply abolishes the notion replacing it in domain_build_info with hvm and pv structures and renaming the key to 'is_hvm'.

tools/libxl/gentypes.py +1 -9
diff -r a8d69de8eb31 -r 01a1ce470640 tools/libxl/gentypes.py
@@ -71,15 +71,7 @@ def libxl_C_type_destroy(ty, v, referenc
         makeref = ""
 
     s = ""
-    if isinstance(ty, libxltypes.KeyedUnion):
-        if parent is None:
-            raise Exception("KeyedUnion type must have a parent")
-        for f in ty.fields:
-            keyvar_expr = f.keyvar_expr % (parent + ty.keyvar_name)
-            s += "if (" + keyvar_expr + ") {\n"
-            s += libxl_C_type_destroy(f.type, deref + f.name, False, indent + "    ", deref)
-            s += "}\n"
-    elif isinstance(ty, libxltypes.Reference):
+    if isinstance(ty, libxltypes.Reference):
         s += libxl_C_type_destroy(ty.ref_type, v, True, indent, v)
         if ty.destructor_fn is not None:
             s += "%s(%s);\n" % (ty.destructor_fn, makeref + v)
tools/libxl/libxl.c +22 -22

111 lines not on this page · raw message

tools/libxl/libxl.idl +20 -22

48 lines not on this page · raw message

tools/libxl/libxl_bootloader.c +15 -15
diff -r a8d69de8eb31 -r 01a1ce470640 tools/libxl/libxl_bootloader.c
@@ -42,23 +42,23 @@ static char **make_bootloader_args(libxl
     if (!args)
         return NULL;
 
-    flexarray_set(args, nr++, (char *)info->u.pv.bootloader);
+    flexarray_set(args, nr++, (char *)info->pv.bootloader);
 
     if (info->kernel.path)
         flexarray_set(args, nr++, libxl__sprintf(gc, "--kernel=%s", info->kernel.path));
-    if (info->u.pv.ramdisk.path)
-        flexarray_set(args, nr++, libxl__sprintf(gc, "--ramdisk=%s", info->u.pv.ramdisk.path));
-    if (info->u.pv.cmdline && *info->u.pv.cmdline != '\0')
-        flexarray_set(args, nr++, libxl__sprintf(gc, "--args=%s", info->u.pv.cmdline));
+    if (info->pv.ramdisk.path)
+        flexarray_set(args, nr++, libxl__sprintf(gc, "--ramdisk=%s", info->pv.ramdisk.path));
+    if (info->pv.cmdline && *info->pv.cmdline != '\0')
+        flexarray_set(args, nr++, libxl__sprintf(gc, "--args=%s", info->pv.cmdline));
 
     flexarray_set(args, nr++, libxl__sprintf(gc, "--output=%s", fifo));
     flexarray_set(args, nr++, "--output-format=simple0");
     flexarray_set(args, nr++, libxl__sprintf(gc, "--output-directory=%s", "/var/run/libxl/"));
 
-    if (info->u.pv.bootloader_args) {
+    if (info->pv.bootloader_args) {
         char *saveptr;
         /* Operate on a duplicate since strtok modifes the argument */
-        char *dup = libxl__strdup(gc, info->u.pv.bootloader_args);
+        char *dup = libxl__strdup(gc, info->pv.bootloader_args);
         char *t = strtok_r(dup, " \t\n", &saveptr);
         do {
             flexarray_set(args, nr++, t);
@@ -282,13 +282,13 @@ static void parse_bootloader_result(libx
             libxl__file_reference_map(&info->kernel);
             unlink(info->kernel.path);
         } else if (strncmp("ramdisk ", o, strlen("ramdisk ")) == 0) {
-            free(info->u.pv.ramdisk.path);
-            info->u.pv.ramdisk.path = strdup(o + strlen("ramdisk "));
-            libxl__file_reference_map(&info->u.pv.ramdisk);
-            unlink(info->u.pv.ramdisk.path);
+            free(info->pv.ramdisk.path);
+            info->pv.ramdisk.path = strdup(o + strlen("ramdisk "));
+            libxl__file_reference_map(&info->pv.ramdisk);
+            unlink(info->pv.ramdisk.path);
         } else if (strncmp("args ", o, strlen("args ")) == 0) {
-            free(info->u.pv.cmdline);
-            info->u.pv.cmdline = strdup(o + strlen("args "));
+            free(info->pv.cmdline);
+            info->pv.cmdline = strdup(o + strlen("args "));
         }
 
         o = o + strlen(o) + 1;
@@ -321,7 +321,7 @@ int libxl_run_bootloader(libxl_ctx *ctx,
 
     struct stat st_buf;
 
-    if (info->hvm || !info->u.pv.bootloader)
+    if (info->is_hvm || !info->pv.bootloader)
         goto out;
 
     rc = ERROR_INVAL;
@@ -386,7 +386,7 @@ int libxl_run_bootloader(libxl_ctx *ctx,
     dom_console_xs_path = libxl__sprintf(&gc, "%s/console/tty", libxl__xs_get_dompath(&gc, domid));
     libxl__xs_write(&gc, XBT_NULL, dom_console_xs_path, "%s", dom_console_slave_tty_path);
 
-    pid = fork_exec_bootloader(&bootloader_fd, info->u.pv.bootloader, args);
+    pid = fork_exec_bootloader(&bootloader_fd, info->pv.bootloader, args);
     if (pid < 0) {
         goto out_close;
     }
tools/libxl/libxl_dom.c +16 -16
diff -r a8d69de8eb31 -r 01a1ce470640 tools/libxl/libxl_dom.c
@@ -70,13 +70,13 @@ int libxl__build_pre(libxl_ctx *ctx, uin
     xc_domain_max_vcpus(ctx->xch, domid, info->max_vcpus);
     xc_domain_setmaxmem(ctx->xch, domid, info->target_memkb + LIBXL_MAXMEM_CONSTANT);
     xc_domain_set_memmap_limit(ctx->xch, domid, 
-            (info->hvm) ? info->max_memkb : 
-            (info->max_memkb + info->u.pv.slack_memkb));
+            (info->is_hvm) ? info->max_memkb : 
+            (info->max_memkb + info->pv.slack_memkb));
     xc_domain_set_tsc_info(ctx->xch, domid, info->tsc_mode, 0, 0, 0);
     if ( info->disable_migrate )
         xc_domain_disable_migrate(ctx->xch, domid);
 
-    if (info->hvm) {
+    if (info->is_hvm) {
         unsigned long shadow;
         shadow = (info->shadow_memkb + 1023) / 1024;
         xc_shadow_control(ctx->xch, domid, XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION, NULL, 0, &shadow, 0, NULL);
@@ -152,7 +152,7 @@ int libxl__build_pv(libxl_ctx *ctx, uint
 
     xc_dom_loginit(ctx->xch);
 
-    dom = xc_dom_allocate(ctx->xch, info->u.pv.cmdline, info->u.pv.features);
+    dom = xc_dom_allocate(ctx->xch, info->pv.cmdline, info->pv.features);
     if (!dom) {
         LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_allocate failed");
         return ERROR_FAIL;
@@ -170,14 +170,14 @@ int libxl__build_pv(libxl_ctx *ctx, uint
         }
     }
 
-    if ( info->u.pv.ramdisk.path && strlen(info->u.pv.ramdisk.path) ) {
-        if (info->u.pv.ramdisk.mapped) {
-            if ( (ret = xc_dom_ramdisk_mem(dom, info->u.pv.ramdisk.data, info->u.pv.ramdisk.size)) != 0 ) {
+    if ( info->pv.ramdisk.path && strlen(info->pv.ramdisk.path) ) {
+        if (info->pv.ramdisk.mapped) {
+            if ( (ret = xc_dom_ramdisk_mem(dom, info->pv.ramdisk.data, info->pv.ramdisk.size)) != 0 ) {
                 LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_ramdisk_mem failed");
                 goto out;
             }
         } else {
-            if ( (ret = xc_dom_ramdisk_file(dom, info->u.pv.ramdisk.path)) != 0 ) {
+            if ( (ret = xc_dom_ramdisk_file(dom, info->pv.ramdisk.path)) != 0 ) {
                 LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_ramdisk_file failed");
                 goto out;
             }
@@ -238,8 +238,8 @@ static int hvm_build_set_params(xc_inter
         return -1;
 
     va_hvm = (struct hvm_info_table *)(va_map + HVM_INFO_OFFSET);
-    va_hvm->acpi_enabled = info->u.hvm.acpi;
-    va_hvm->apic_mode = info->u.hvm.apic;
+    va_hvm->acpi_enabled = info->hvm.acpi;
+    va_hvm->apic_mode = info->hvm.apic;
     va_hvm->nr_vcpus = info->max_vcpus;
     memcpy(va_hvm->vcpu_online, &info->cur_vcpus, sizeof(info->cur_vcpus));
     for (i = 0, sum = 0; i < va_hvm->length; i++)
@@ -249,13 +249,13 @@ static int hvm_build_set_params(xc_inter
 
     xc_get_hvm_param(handle, domid, HVM_PARAM_STORE_PFN, store_mfn);
     xc_get_hvm_param(handle, domid, HVM_PARAM_CONSOLE_PFN, console_mfn);
-    xc_set_hvm_param(handle, domid, HVM_PARAM_PAE_ENABLED, info->u.hvm.pae);
+    xc_set_hvm_param(handle, domid, HVM_PARAM_PAE_ENABLED, info->hvm.pae);
 #if defined(__i386__) || defined(__x86_64__)
-    xc_set_hvm_param(handle, domid, HVM_PARAM_VIRIDIAN, info->u.hvm.viridian);
-    xc_set_hvm_param(handle, domid, HVM_PARAM_HPET_ENABLED, (unsigned long) info->u.hvm.hpet);
+    xc_set_hvm_param(handle, domid, HVM_PARAM_VIRIDIAN, info->hvm.viridian);
+    xc_set_hvm_param(handle, domid, HVM_PARAM_HPET_ENABLED, (unsigned long) info->hvm.hpet);
 #endif
-    xc_set_hvm_param(handle, domid, HVM_PARAM_TIMER_MODE, (unsigned long) info->u.hvm.timer_mode);
-    xc_set_hvm_param(handle, domid, HVM_PARAM_VPT_ALIGN, (unsigned long) info->u.hvm.vpt_align);
+    xc_set_hvm_param(handle, domid, HVM_PARAM_TIMER_MODE, (unsigned long) info->hvm.timer_mode);
+    xc_set_hvm_param(handle, domid, HVM_PARAM_VPT_ALIGN, (unsigned long) info->hvm.vpt_align);
     xc_set_hvm_param(handle, domid, HVM_PARAM_STORE_EVTCHN, store_evtchn);
     xc_set_hvm_param(handle, domid, HVM_PARAM_CONSOLE_EVTCHN, console_evtchn);
     return 0;
@@ -305,7 +305,7 @@ int libxl__domain_restore_common(libxl_c
     rc = xc_domain_restore(ctx->xch, fd, domid,
                              state->store_port, &state->store_mfn,
                              state->console_port, &state->console_mfn,
-                             info->hvm, info->u.hvm.pae, 0);
+                             info->is_hvm, info->hvm.pae, 0);
     if ( rc ) {
         LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "restoring domain");
         return ERROR_FAIL;
tools/libxl/libxltypes.py +0 -15
diff -r a8d69de8eb31 -r 01a1ce470640 tools/libxl/libxltypes.py
@@ -104,21 +104,6 @@ class Union(Aggregate):
         kwargs.setdefault('destructor_fn', None)
         Aggregate.__init__(self, "union", name, fields, **kwargs)
 
-class KeyedUnion(Aggregate):
-    """A union which is keyed of another variable in the parent structure"""
-    def __init__(self, name, keyvar_name, fields, **kwargs):
-        Aggregate.__init__(self, "union", name, [], **kwargs)
-
-        self.keyvar_name = keyvar_name
-
-        for f in fields:
-            # (name, keyvar_expr, type)
-
-            # keyvar_expr must contain exactly one %s which will be replaced with the keyvar_name
-
-            n, kve, ty = f
-            self.fields.append(Field(ty, n, keyvar_expr=kve))
-
 class Reference(Type):
     """A reference to another type"""
     def __init__(self, ty, **kwargs):
tools/libxl/xl_cmdimpl.c +40 -40

135 lines not on this page · raw message

tools/ocaml/libs/xl/xl_stubs.c +13 -13
diff -r a8d69de8eb31 -r 01a1ce470640 tools/ocaml/libs/xl/xl_stubs.c
@@ -166,20 +166,20 @@ static int domain_build_info_val (caml_g
 	c_val->hvm = Tag_val(Field(v, 7)) == 0;
 	infopriv = Field(Field(v, 7), 0);
 	if (c_val->hvm) {
-		c_val->u.hvm.pae = Bool_val(Field(infopriv, 0));
-		c_val->u.hvm.apic = Bool_val(Field(infopriv, 1));
-		c_val->u.hvm.acpi = Bool_val(Field(infopriv, 2));
-		c_val->u.hvm.nx = Bool_val(Field(infopriv, 3));
-		c_val->u.hvm.viridian = Bool_val(Field(infopriv, 4));
-		c_val->u.hvm.timeoffset = dup_String_val(gc, Field(infopriv, 5));
-		c_val->u.hvm.timer_mode = Int_val(Field(infopriv, 6));
-		c_val->u.hvm.hpet = Int_val(Field(infopriv, 7));
-		c_val->u.hvm.vpt_align = Int_val(Field(infopriv, 8));
+		c_val->hvm.pae = Bool_val(Field(infopriv, 0));
+		c_val->hvm.apic = Bool_val(Field(infopriv, 1));
+		c_val->hvm.acpi = Bool_val(Field(infopriv, 2));
+		c_val->hvm.nx = Bool_val(Field(infopriv, 3));
+		c_val->hvm.viridian = Bool_val(Field(infopriv, 4));
+		c_val->hvm.timeoffset = dup_String_val(gc, Field(infopriv, 5));
+		c_val->hvm.timer_mode = Int_val(Field(infopriv, 6));
+		c_val->hvm.hpet = Int_val(Field(infopriv, 7));
+		c_val->hvm.vpt_align = Int_val(Field(infopriv, 8));
 	} else {
-		c_val->u.pv.slack_memkb = Int64_val(Field(infopriv, 0));
-		c_val->u.pv.cmdline = dup_String_val(gc, Field(infopriv, 1));
-		c_val->u.pv.ramdisk.path = dup_String_val(gc, Field(infopriv, 2));
-		c_val->u.pv.features = dup_String_val(gc, Field(infopriv, 3));
+		c_val->pv.slack_memkb = Int64_val(Field(infopriv, 0));
+		c_val->pv.cmdline = dup_String_val(gc, Field(infopriv, 1));
+		c_val->pv.ramdisk.path = dup_String_val(gc, Field(infopriv, 2));
+		c_val->pv.features = dup_String_val(gc, Field(infopriv, 3));
 	}
 
 	CAMLreturn(0);
#2 lore raw

PATCH 1/1 xl: Remove libxl_need_xenpv_qemu()

In reply to Gianni Tedesco
 tools/libxl/libxl.c |  33 ---------------------------------
 tools/libxl/libxl.h |   4 ----
 2 files changed, 0 insertions(+), 37 deletions(-)

# HG changeset patch
# User Gianni Tedesco <[email protected]> # Date 1294158577 0
# Node ID deb521c7f86fe761a9eed8e3ef55942087eb90fa # Parent 01a1ce470640c67cf507e1f64a32561443b43061
xl: Remove libxl_need_xenpv_qemu()

It appears to have been made redundant with no users in-tree.

tools/libxl/libxl.c +0 -33
diff -r 01a1ce470640 -r deb521c7f86f tools/libxl/libxl.c
@@ -2654,39 +2654,6 @@ 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 +0 -4
diff -r 01a1ce470640 -r deb521c7f86f tools/libxl/libxl.h
@@ -383,10 +383,6 @@ 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. */
#3 lore raw

PATCH 1/1 xl: Introduce libxl_domain_create_new() and libxl_domain_create_restore()

In reply to Gianni Tedesco
 tools/libxl/Makefile           |    4 +-
 tools/libxl/libxl.c            |  284 +----------------------
 tools/libxl/libxl.h            |   58 +++-
 tools/libxl/libxl_create.c     |  475 +++++++++++++++++++++++++++++++++++++++++
 tools/libxl/libxl_exec.c       |    2 +-
 tools/libxl/libxl_internal.h   |   24 +-
 tools/libxl/xl_cmdimpl.c       |  328 ++++++---------------------
 tools/ocaml/libs/xl/xl_stubs.c |   85 +------
 8 files changed, 644 insertions(+), 616 deletions(-)

# HG changeset patch
# User Gianni Tedesco <[email protected]>
# Date 1294159328 0
# Node ID 35fab5f9eb393daaaa35bfe5960cd80c04f78d37
# Parent deb521c7f86fe761a9eed8e3ef55942087eb90fa
xl: Introduce libxl_domain_create_new() and libxl_domain_create_restore()

These functions are introduced as the new way to create domains with libxl they prevent the callers from need to know about low-level implementation details such as:
- libxl_domain_make()
- libxl_domain_build()
- libxl_domain_restore()
- when to attach the console
- how to start the device model

Above mentioned functions and all API's for the device model, which are now redundant, have been made internal to libxl and no longer accessible.

The ocaml binding for libxl has not been properly updated to reflect the changes, wrappers for the old functions have been removed but the code to wrap the new functions has not been added.

tools/libxl/Makefile +2 -2
diff -r deb521c7f86f -r 35fab5f9eb39 tools/libxl/Makefile
@@ -20,7 +20,7 @@ ifeq ($(CONFIG_Linux),y)
 LIBS += -luuid
 endif
 
-LIBXL_OBJS-y = osdeps.o libxl_paths.o libxl_bootloader.o
+LIBXL_OBJS-y = osdeps.o libxl_paths.o libxl_bootloader.o flexarray.o
 ifeq ($(LIBXL_BLKTAP),y)
 LIBXL_OBJS-y += libxl_blktap2.o
 else
@@ -29,7 +29,7 @@ endif
 LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o
 LIBXL_OBJS-$(CONFIG_IA64) += libxl_nocpuid.o
 
-LIBXL_OBJS = flexarray.o libxl.o libxl_pci.o libxl_dom.o libxl_exec.o libxl_xshelp.o libxl_device.o libxl_internal.o libxl_utils.o $(LIBXL_OBJS-y)
+LIBXL_OBJS = libxl.o libxl_create.o libxl_pci.o libxl_dom.o libxl_exec.o libxl_xshelp.o libxl_device.o libxl_internal.o libxl_utils.o $(LIBXL_OBJS-y)
 LIBXL_OBJS += _libxl_types.o
 
 AUTOINCS= libxlu_cfg_y.h libxlu_cfg_l.h
tools/libxl/libxl.c +21 -263

386 lines not on this page · raw message

tools/libxl/libxl.h +36 -22

76 lines not on this page · raw message

tools/libxl/libxl_create.c new file +475 -0

475 lines not on this page · raw message

tools/libxl/libxl_exec.c +1 -1
diff -r deb521c7f86f -r 35fab5f9eb39 tools/libxl/libxl_exec.c
@@ -90,7 +90,7 @@ void libxl_report_child_exitstatus(libxl
 }
 
 int libxl__spawn_spawn(libxl_ctx *ctx,
-                      libxl_device_model_starting *starting,
+                      libxl__device_model_starting *starting,
                       const char *what,
                       void (*intermediate_hook)(void *for_spawn,
                                                 pid_t innerchild))
tools/libxl/libxl_internal.h +21 -3
diff -r deb521c7f86f -r 35fab5f9eb39 tools/libxl/libxl_internal.h
@@ -194,14 +194,32 @@ typedef struct {
     char *what; /* malloc'd in spawn_spawn */
 } libxl__spawn_starting;
 
-struct libxl__device_model_starting {
+typedef struct {
     libxl__spawn_starting *for_spawn; /* first! */
     char *dom_path; /* from libxl_malloc, only for dm_xenstore_record_pid */
     int domid;
-};
+} libxl__device_model_starting;
+
+/* from xl_create */
+_hidden int libxl__domain_make(libxl_ctx *ctx, libxl_domain_create_info *info, uint32_t *domid);
+_hidden int libxl__domain_build(libxl_ctx *ctx, libxl_domain_build_info *info, uint32_t domid, /* out */ libxl_domain_build_state *state);
+
+/* for device model creation */
+_hidden int libxl__create_device_model(libxl_ctx *ctx,
+                              libxl_device_model_info *info,
+                              libxl_device_disk *disk, int num_disks,
+                              libxl_device_nic *vifs, int num_vifs,
+                              libxl__device_model_starting **starting_r);
+_hidden int libxl__create_xenpv_qemu(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb *vfb,
+                            libxl__device_model_starting **starting_r);
+  /* 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. */
+_hidden int libxl__confirm_device_model_startup(libxl_ctx *ctx,
+                              libxl__device_model_starting *starting);
 
 _hidden int libxl__spawn_spawn(libxl_ctx *ctx,
-                      libxl_device_model_starting *starting,
+                      libxl__device_model_starting *starting,
                       const char *what,
                       void (*intermediate_hook)(void *for_spawn, pid_t innerchild));
   /* Logs errors.  A copy of "what" is taken.  Return values:
tools/libxl/xl_cmdimpl.c +75 -253

480 lines not on this page · raw message

tools/ocaml/libs/xl/xl_stubs.c +13 -72

121 lines not on this page · raw message

#4 lore raw
In reply to Gianni Tedesco

Just thought of a fourth patch for this series. It leaves libxl.c ~800 lines slimmer and looking good for it.

--
xl: Move device model functions in to a separate file

No functional changes.

# HG changeset patch
# Parent 1ff6243eba261a0ae731b62a5c55bcbb18b6069a

tools/libxl/Makefile +1 -1
diff -r 1ff6243eba26 tools/libxl/Makefile
@@ -29,7 +29,7 @@ endif
 LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o
 LIBXL_OBJS-$(CONFIG_IA64) += libxl_nocpuid.o
 
-LIBXL_OBJS = libxl.o libxl_create.o libxl_pci.o libxl_dom.o libxl_exec.o libxl_xshelp.o libxl_device.o libxl_internal.o libxl_utils.o $(LIBXL_OBJS-y)
+LIBXL_OBJS = libxl.o libxl_create.o libxl_dm.o libxl_pci.o libxl_dom.o libxl_exec.o libxl_xshelp.o libxl_device.o libxl_internal.o libxl_utils.o $(LIBXL_OBJS-y)
 LIBXL_OBJS += _libxl_types.o
 
 AUTOINCS= libxlu_cfg_y.h libxlu_cfg_l.h
tools/libxl/libxl.c +2 -772

798 lines not on this page · raw message

tools/libxl/libxl_dm.c new file +798 -0

798 lines not on this page · raw message

tools/libxl/libxl_internal.h +2 -0
diff -r 1ff6243eba26 tools/libxl/libxl_internal.h
@@ -222,6 +222,8 @@ _hidden int libxl__spawn_spawn(libxl_ctx
                       libxl__device_model_starting *starting,
                       const char *what,
                       void (*intermediate_hook)(void *for_spawn, pid_t innerchild));
+_hidden int libxl__destroy_device_model(libxl_ctx *ctx, uint32_t domid);
+
   /* Logs errors.  A copy of "what" is taken.  Return values:
    *  < 0   error, for_spawn need not be detached
    *   +1   caller is the parent, must call detach on *for_spawn eventually
#5 lore raw
In reply to Gianni Tedesco
Quoted 3 lines · Gianni Tedesco

Introduce libxl_domain_create_new() and libxl_domain_create_restore() rendering redundant several other, more complex, API's and simplifying the xl create implementation.

Damnit, please do not apply, I screwed this up somewhere for the PV case.

libxl_need_xenpv_qemu() *is* required and can't remember editing this out of the code?! So maybe it's a mis-paste.

Please wait for second version.

Gianni