Mailing List Archive

[PATCH 17/27] 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@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
tools/libxl/libxl_create.c | 18 +++++-----
tools/libxl/libxl_dm.c | 84 ++++++++++++++++++++++----------------------
2 files changed, 51 insertions(+), 51 deletions(-)

diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index f7732aa..b137288 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -564,7 +564,7 @@ static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config,
{
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 *gc, libxl_domain_config *d_config,
}
}

- 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 *gc, libxl_domain_config *d_config,
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 *gc, libxl_domain_config *d_config,
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 *gc, libxl_domain_config *d_config,
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 *gc, libxl_domain_config *d_config,
== 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 --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index 36b0730..725c3c0 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -678,10 +678,10 @@ static int libxl__create_stubdom(libxl__gc *gc,
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__gc *gc,
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;
--
1.7.2.5


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel