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

[Xen-changelog] [xen-unstable] libxl: change some structures to unit arrays


  • To: xen-changelog@xxxxxxxxxxxxxxxxxxx
  • From: Xen patchbot-unstable <patchbot@xxxxxxx>
  • Date: Mon, 14 May 2012 16:32:40 +0000
  • Delivery-date: Mon, 14 May 2012 16:33:07 +0000
  • List-id: "Change log for Mercurial \(receive only\)" <xen-changelog.lists.xen.org>

# HG changeset patch
# User Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
# Date 1336759142 -3600
# Node ID 9524eb476e930960a579bd9e0219450dd4462527
# Parent  635eb1d6d43376c1897711ac6b7c012f453cca62
libxl: change some structures to unit arrays

In the next patch these variables will turn into actual pointers.

To clarify that patch, prepare the ground by changing these variables
from "struct foo var" to "struct foo var[1]".  This enables accesses
to them and their members to be made as if they were pointers.

No functional change.

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


diff -r 635eb1d6d433 -r 9524eb476e93 tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c        Fri May 11 18:59:02 2012 +0100
+++ b/tools/libxl/libxl_create.c        Fri May 11 18:59:02 2012 +0100
@@ -564,7 +564,7 @@ static int do_domain_create(libxl__gc *g
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
     libxl__spawner_starting *dm_starting = 0;
-    libxl__domain_build_state state;
+    libxl__domain_build_state state[1];
     uint32_t domid;
     int i, ret;
 
@@ -606,12 +606,12 @@ static int do_domain_create(libxl__gc *g
         }
     }
 
-    memset(&state, 0, sizeof(state));
+    memset(state, 0, sizeof(*state));
 
     if ( restore_fd >= 0 ) {
-        ret = domain_restore(gc, &d_config->b_info, domid, restore_fd, &state);
+        ret = domain_restore(gc, &d_config->b_info, domid, restore_fd, state);
     } else {
-        ret = libxl__domain_build(gc, &d_config->b_info, domid, &state);
+        ret = libxl__domain_build(gc, &d_config->b_info, domid, state);
     }
 
     if (ret) {
@@ -649,7 +649,7 @@ static int do_domain_create(libxl__gc *g
         ret = init_console_info(&console, 0);
         if ( ret )
             goto error_out;
-        libxl__device_console_add(gc, domid, &console, &state);
+        libxl__device_console_add(gc, domid, &console, state);
         libxl__device_console_dispose(&console);
 
         libxl_device_vkb_init(&vkb);
@@ -657,7 +657,7 @@ static int do_domain_create(libxl__gc *g
         libxl_device_vkb_dispose(&vkb);
 
         ret = libxl__create_device_model(gc, domid, d_config,
-                                         &state, &dm_starting);
+                                         state, &dm_starting);
         if (ret < 0) {
             LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
                        "failed to create device model: %d", ret);
@@ -683,11 +683,11 @@ static int do_domain_create(libxl__gc *g
                 d_config->num_vfbs, d_config->vfbs,
                 d_config->num_disks, &d_config->disks[0]);
 
-        libxl__device_console_add(gc, domid, &console, &state);
+        libxl__device_console_add(gc, domid, &console, state);
         libxl__device_console_dispose(&console);
 
         if (need_qemu) {
-            libxl__create_xenpv_qemu(gc, domid, d_config, &state, 
&dm_starting);
+            libxl__create_xenpv_qemu(gc, domid, d_config, state, &dm_starting);
         }
         break;
     }
@@ -701,7 +701,7 @@ static int do_domain_create(libxl__gc *g
             == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) {
             libxl__qmp_initializations(gc, domid, d_config);
         }
-        ret = libxl__confirm_device_model_startup(gc, &state, dm_starting);
+        ret = libxl__confirm_device_model_startup(gc, state, dm_starting);
         if (ret < 0) {
             LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
                        "device model did not start: %d", ret);
diff -r 635eb1d6d433 -r 9524eb476e93 tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c    Fri May 11 18:59:02 2012 +0100
+++ b/tools/libxl/libxl_dm.c    Fri May 11 18:59:02 2012 +0100
@@ -678,10 +678,10 @@ static int libxl__create_stubdom(libxl__
     libxl_ctx *ctx = libxl__gc_owner(gc);
     int i, num_console = STUBDOM_SPECIAL_CONSOLES, ret;
     libxl__device_console *console;
-    libxl_domain_config dm_config;
+    libxl_domain_config dm_config[1];
     libxl_device_vfb vfb;
     libxl_device_vkb vkb;
-    libxl__domain_build_state stubdom_state;
+    libxl__domain_build_state stubdom_state[1];
     uint32_t dm_domid;
     char **args;
     struct xs_permissions perm[2];
@@ -694,58 +694,58 @@ static int libxl__create_stubdom(libxl__
         goto out;
     }
 
-    libxl_domain_create_info_init(&dm_config.c_info);
-    dm_config.c_info.type = LIBXL_DOMAIN_TYPE_PV;
-    dm_config.c_info.name = libxl__sprintf(gc, "%s-dm",
+    libxl_domain_create_info_init(&dm_config->c_info);
+    dm_config->c_info.type = LIBXL_DOMAIN_TYPE_PV;
+    dm_config->c_info.name = libxl__sprintf(gc, "%s-dm",
                                     libxl__domid_to_name(gc, guest_domid));
-    dm_config.c_info.ssidref = guest_config->b_info.device_model_ssidref;
+    dm_config->c_info.ssidref = guest_config->b_info.device_model_ssidref;
 
-    libxl_uuid_generate(&dm_config.c_info.uuid);
+    libxl_uuid_generate(&dm_config->c_info.uuid);
 
-    libxl_domain_build_info_init(&dm_config.b_info);
-    libxl_domain_build_info_init_type(&dm_config.b_info, LIBXL_DOMAIN_TYPE_PV);
+    libxl_domain_build_info_init(&dm_config->b_info);
+    libxl_domain_build_info_init_type(&dm_config->b_info, 
LIBXL_DOMAIN_TYPE_PV);
 
-    dm_config.b_info.max_vcpus = 1;
-    dm_config.b_info.max_memkb = 32 * 1024;
-    dm_config.b_info.target_memkb = dm_config.b_info.max_memkb;
+    dm_config->b_info.max_vcpus = 1;
+    dm_config->b_info.max_memkb = 32 * 1024;
+    dm_config->b_info.target_memkb = dm_config->b_info.max_memkb;
 
-    dm_config.b_info.u.pv.kernel.path = libxl__abs_path(gc, "ioemu-stubdom.gz",
+    dm_config->b_info.u.pv.kernel.path = libxl__abs_path(gc, 
"ioemu-stubdom.gz",
                                               libxl__xenfirmwaredir_path());
-    dm_config.b_info.u.pv.cmdline = libxl__sprintf(gc, " -d %d", guest_domid);
-    dm_config.b_info.u.pv.ramdisk.path = "";
-    dm_config.b_info.u.pv.features = "";
+    dm_config->b_info.u.pv.cmdline = libxl__sprintf(gc, " -d %d", guest_domid);
+    dm_config->b_info.u.pv.ramdisk.path = "";
+    dm_config->b_info.u.pv.features = "";
 
-    dm_config.b_info.device_model_version =
+    dm_config->b_info.device_model_version =
         guest_config->b_info.device_model_version;
-    dm_config.b_info.device_model =
+    dm_config->b_info.device_model =
         guest_config->b_info.device_model;
-    dm_config.b_info.extra = guest_config->b_info.extra;
-    dm_config.b_info.extra_pv = guest_config->b_info.extra_pv;
-    dm_config.b_info.extra_hvm = guest_config->b_info.extra_hvm;
+    dm_config->b_info.extra = guest_config->b_info.extra;
+    dm_config->b_info.extra_pv = guest_config->b_info.extra_pv;
+    dm_config->b_info.extra_hvm = guest_config->b_info.extra_hvm;
 
-    dm_config.disks = guest_config->disks;
-    dm_config.num_disks = guest_config->num_disks;
+    dm_config->disks = guest_config->disks;
+    dm_config->num_disks = guest_config->num_disks;
 
-    dm_config.vifs = guest_config->vifs;
-    dm_config.num_vifs = guest_config->num_vifs;
+    dm_config->vifs = guest_config->vifs;
+    dm_config->num_vifs = guest_config->num_vifs;
 
-    ret = libxl__domain_create_info_setdefault(gc, &dm_config.c_info);
+    ret = libxl__domain_create_info_setdefault(gc, &dm_config->c_info);
     if (ret) goto out;
-    ret = libxl__domain_build_info_setdefault(gc, &dm_config.b_info);
+    ret = libxl__domain_build_info_setdefault(gc, &dm_config->b_info);
     if (ret) goto out;
 
     libxl__vfb_and_vkb_from_hvm_guest_config(gc, guest_config, &vfb, &vkb);
-    dm_config.vfbs = &vfb;
-    dm_config.num_vfbs = 1;
-    dm_config.vkbs = &vkb;
-    dm_config.num_vkbs = 1;
+    dm_config->vfbs = &vfb;
+    dm_config->num_vfbs = 1;
+    dm_config->vkbs = &vkb;
+    dm_config->num_vkbs = 1;
 
     /* fixme: this function can leak the stubdom if it fails */
     dm_domid = 0;
-    ret = libxl__domain_make(gc, &dm_config.c_info, &dm_domid);
+    ret = libxl__domain_make(gc, &dm_config->c_info, &dm_domid);
     if (ret)
         goto out;
-    ret = libxl__domain_build(gc, &dm_config.b_info, dm_domid, &stubdom_state);
+    ret = libxl__domain_build(gc, &dm_config->b_info, dm_domid, stubdom_state);
     if (ret)
         goto out;
 
@@ -790,20 +790,20 @@ retry_transaction:
         if (errno == EAGAIN)
             goto retry_transaction;
 
-    for (i = 0; i < dm_config.num_disks; i++) {
-        ret = libxl_device_disk_add(ctx, dm_domid, &dm_config.disks[i]);
+    for (i = 0; i < dm_config->num_disks; i++) {
+        ret = libxl_device_disk_add(ctx, dm_domid, &dm_config->disks[i]);
         if (ret)
             goto out_free;
     }
-    for (i = 0; i < dm_config.num_vifs; i++) {
-        ret = libxl_device_nic_add(ctx, dm_domid, &dm_config.vifs[i]);
+    for (i = 0; i < dm_config->num_vifs; i++) {
+        ret = libxl_device_nic_add(ctx, dm_domid, &dm_config->vifs[i]);
         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]);
     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]);
     if (ret)
         goto out_free;
 
@@ -847,14 +847,14 @@ retry_transaction:
                 break;
         }
         ret = libxl__device_console_add(gc, dm_domid, &console[i],
-                        i == STUBDOM_CONSOLE_LOGGING ? &stubdom_state : NULL);
+                        i == STUBDOM_CONSOLE_LOGGING ? stubdom_state : NULL);
         if (ret)
             goto out_free;
     }
 
     if (libxl__create_xenpv_qemu(gc, dm_domid,
-                                 &dm_config,
-                                 &stubdom_state,
+                                 dm_config,
+                                 stubdom_state,
                                  &dm_starting) < 0) {
         ret = ERROR_FAIL;
         goto out_free;

_______________________________________________
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®.