[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] libxl: plumb libxl_domain_config down into device model creation.
# HG changeset patch # User Ian Campbell <ian.campbell@xxxxxxxxxx> # Date 1328020860 0 # Node ID 919ad96e3e2886bc5171bfed5205ad56a2390a5b # Parent 9f0c4da3cbef636e730280f6755f5968873b2344 libxl: plumb libxl_domain_config down into device model creation. Creating the device model derives lots of bits from the guest configuration. Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx> Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> Committed-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx> --- diff -r 9f0c4da3cbef -r 919ad96e3e28 tools/libxl/libxl_create.c --- a/tools/libxl/libxl_create.c Tue Jan 31 14:41:00 2012 +0000 +++ b/tools/libxl/libxl_create.c Tue Jan 31 14:41:00 2012 +0000 @@ -571,7 +571,7 @@ libxl_device_vkb_dispose(&vkb); dm_info->domid = domid; - ret = libxl__create_device_model(gc, dm_info, + ret = libxl__create_device_model(gc, d_config, dm_info, d_config->disks, d_config->num_disks, d_config->vifs, d_config->num_vifs, &dm_starting); @@ -618,7 +618,8 @@ xenpv_dm_info.extra_pv = d_config->dm_info.extra_pv; xenpv_dm_info.extra_hvm = d_config->dm_info.extra_hvm; - libxl__create_xenpv_qemu(gc, domid, &xenpv_dm_info, + libxl__create_xenpv_qemu(gc, domid, + d_config, &xenpv_dm_info, d_config->vfbs, &dm_starting); } break; diff -r 9f0c4da3cbef -r 919ad96e3e28 tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Tue Jan 31 14:41:00 2012 +0000 +++ b/tools/libxl/libxl_dm.c Tue Jan 31 14:41:00 2012 +0000 @@ -74,10 +74,11 @@ } static char ** libxl__build_device_model_args_old(libxl__gc *gc, - const char *dm, - libxl_device_model_info *info, - libxl_device_disk *disks, int num_disks, - libxl_device_nic *vifs, int num_vifs) + const char *dm, + const libxl_domain_config *guest_config, + const libxl_device_model_info *info, + const libxl_device_disk *disks, int num_disks, + const libxl_device_nic *vifs, int num_vifs) { int i; flexarray_t *dm_args; @@ -228,10 +229,11 @@ } static char ** libxl__build_device_model_args_new(libxl__gc *gc, - const char *dm, - libxl_device_model_info *info, - libxl_device_disk *disks, int num_disks, - libxl_device_nic *vifs, int num_vifs) + const char *dm, + const libxl_domain_config *guest_config, + const libxl_device_model_info *info, + const libxl_device_disk *disks, int num_disks, + const libxl_device_nic *vifs, int num_vifs) { libxl_ctx *ctx = libxl__gc_owner(gc); flexarray_t *dm_args; @@ -492,20 +494,21 @@ } static char ** libxl__build_device_model_args(libxl__gc *gc, - const char *dm, - libxl_device_model_info *info, - libxl_device_disk *disks, int num_disks, - libxl_device_nic *vifs, int num_vifs) + const char *dm, + const libxl_domain_config *guest_config, + const libxl_device_model_info *info, + const libxl_device_disk *disks, int num_disks, + const libxl_device_nic *vifs, int num_vifs) { libxl_ctx *ctx = libxl__gc_owner(gc); switch (info->device_model_version) { case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: - return libxl__build_device_model_args_old(gc, dm, info, + return libxl__build_device_model_args_old(gc, dm, guest_config, info, disks, num_disks, vifs, num_vifs); case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN: - return libxl__build_device_model_args_new(gc, dm, info, + return libxl__build_device_model_args_new(gc, dm, guest_config, info, disks, num_disks, vifs, num_vifs); default: @@ -516,9 +519,9 @@ } static int libxl__vfb_and_vkb_from_device_model_info(libxl__gc *gc, - libxl_device_model_info *info, - libxl_device_vfb *vfb, - libxl_device_vkb *vkb) + const libxl_device_model_info *info, + libxl_device_vfb *vfb, + libxl_device_vkb *vkb) { memset(vfb, 0x00, sizeof(libxl_device_vfb)); memset(vkb, 0x00, sizeof(libxl_device_vkb)); @@ -583,6 +586,7 @@ } static int libxl__create_stubdom(libxl__gc *gc, + libxl_domain_config *guest_config, libxl_device_model_info *info, libxl_device_disk *disks, int num_disks, libxl_device_nic *vifs, int num_vifs, @@ -593,8 +597,7 @@ libxl_ctx *ctx = libxl__gc_owner(gc); int i, num_console = STUBDOM_SPECIAL_CONSOLES, ret; libxl_device_console *console; - libxl_domain_create_info c_info; - libxl_domain_build_info b_info; + libxl_domain_config dm_config; libxl__domain_build_state state; uint32_t domid; char **args; @@ -608,7 +611,35 @@ goto out; } - args = libxl__build_device_model_args(gc, "stubdom-dm", info, + memset(&dm_config.c_info, 0x00, sizeof(libxl_domain_create_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, info->domid)); + + libxl_uuid_copy(&dm_config.c_info.uuid, &info->uuid); + + memset(&dm_config.b_info, 0x00, sizeof(libxl_domain_build_info)); + 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.type = LIBXL_DOMAIN_TYPE_PV; + 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", info->domid); + dm_config.b_info.u.pv.ramdisk.path = ""; + dm_config.b_info.u.pv.features = ""; + + /* fixme: this function can leak the stubdom if it fails */ + domid = 0; + ret = libxl__domain_make(gc, &dm_config.c_info, &domid); + if (ret) + goto out; + ret = libxl__domain_build(gc, &dm_config.b_info, info, domid, &state); + if (ret) + goto out; + + args = libxl__build_device_model_args(gc, "stubdom-dm", + guest_config, info, disks, num_disks, vifs, num_vifs); if (!args) { @@ -616,33 +647,6 @@ goto out; } - memset(&c_info, 0x00, sizeof(libxl_domain_create_info)); - c_info.type = LIBXL_DOMAIN_TYPE_PV; - c_info.name = libxl__sprintf(gc, "%s-dm", libxl__domid_to_name(gc, info->domid)); - - libxl_uuid_copy(&c_info.uuid, &info->uuid); - - memset(&b_info, 0x00, sizeof(libxl_domain_build_info)); - b_info.max_vcpus = 1; - b_info.max_memkb = 32 * 1024; - b_info.target_memkb = b_info.max_memkb; - - b_info.type = LIBXL_DOMAIN_TYPE_PV; - b_info.u.pv.kernel.path = libxl__abs_path(gc, "ioemu-stubdom.gz", - libxl_xenfirmwaredir_path()); - b_info.u.pv.cmdline = libxl__sprintf(gc, " -d %d", info->domid); - b_info.u.pv.ramdisk.path = ""; - b_info.u.pv.features = ""; - - /* fixme: this function can leak the stubdom if it fails */ - domid = 0; - ret = libxl__domain_make(gc, &c_info, &domid); - if (ret) - goto out_free; - ret = libxl__domain_build(gc, &b_info, info, domid, &state); - if (ret) - goto out_free; - libxl__write_dmargs(gc, domid, info->domid, args); libxl__xs_write(gc, XBT_NULL, libxl__sprintf(gc, "%s/image/device-model-domid", libxl__xs_get_dompath(gc, info->domid)), @@ -739,6 +743,7 @@ xenpv_dm_info.extra_hvm = info->extra_hvm; if (libxl__create_xenpv_qemu(gc, domid, + &dm_config, &xenpv_dm_info, vfb, &dm_starting) < 0) { ret = ERROR_FAIL; @@ -768,6 +773,7 @@ } int libxl__create_device_model(libxl__gc *gc, + libxl_domain_config *guest_config, libxl_device_model_info *info, libxl_device_disk *disks, int num_disks, libxl_device_nic *vifs, int num_vifs, @@ -789,7 +795,7 @@ libxl_device_vkb vkb; libxl__vfb_and_vkb_from_device_model_info(gc, info, &vfb, &vkb); - rc = libxl__create_stubdom(gc, info, + rc = libxl__create_stubdom(gc, guest_config, info, disks, num_disks, vifs, num_vifs, &vfb, &vkb, starting_r); @@ -807,7 +813,8 @@ rc = ERROR_FAIL; goto out; } - args = libxl__build_device_model_args(gc, dm, info, disks, num_disks, + args = libxl__build_device_model_args(gc, dm, guest_config, info, + disks, num_disks, vifs, num_vifs); if (!args) { rc = ERROR_FAIL; @@ -1027,12 +1034,13 @@ } int libxl__create_xenpv_qemu(libxl__gc *gc, uint32_t domid, + libxl_domain_config *guest_config, libxl_device_model_info *info, libxl_device_vfb *vfb, libxl__spawner_starting **starting_r) { libxl__build_xenpv_qemu_args(gc, domid, vfb, info); - libxl__create_device_model(gc, info, NULL, 0, NULL, 0, starting_r); + libxl__create_device_model(gc, guest_config, info, NULL, 0, NULL, 0, starting_r); return 0; } diff -r 9f0c4da3cbef -r 919ad96e3e28 tools/libxl/libxl_internal.h --- a/tools/libxl/libxl_internal.h Tue Jan 31 14:41:00 2012 +0000 +++ b/tools/libxl/libxl_internal.h Tue Jan 31 14:41:00 2012 +0000 @@ -866,11 +866,13 @@ _hidden const char *libxl__domain_device_model(libxl__gc *gc, libxl_device_model_info *info); _hidden int libxl__create_device_model(libxl__gc *gc, + libxl_domain_config *guest_config, libxl_device_model_info *info, - libxl_device_disk *disk, int num_disks, + libxl_device_disk *disks, int num_disks, libxl_device_nic *vifs, int num_vifs, libxl__spawner_starting **starting_r); _hidden int libxl__create_xenpv_qemu(libxl__gc *gc, uint32_t domid, + libxl_domain_config *guest_config, libxl_device_model_info *dm_info, libxl_device_vfb *vfb, libxl__spawner_starting **starting_r); diff -r 9f0c4da3cbef -r 919ad96e3e28 tools/libxl/libxl_uuid.c --- a/tools/libxl/libxl_uuid.c Tue Jan 31 14:41:00 2012 +0000 +++ b/tools/libxl/libxl_uuid.c Tue Jan 31 14:41:00 2012 +0000 @@ -35,7 +35,7 @@ return uuid_parse(in, uuid->uuid); } -void libxl_uuid_copy(libxl_uuid *dst, libxl_uuid *src) +void libxl_uuid_copy(libxl_uuid *dst, const libxl_uuid *src) { uuid_copy(dst->uuid, src->uuid); } @@ -82,7 +82,7 @@ } #undef LIBXL__UUID_PTRS -void libxl_uuid_copy(libxl_uuid *dst, libxl_uuid *src) +void libxl_uuid_copy(libxl_uuid *dst, const libxl_uuid *src) { memcpy(dst->uuid, src->uuid, sizeof(dst->uuid)); } diff -r 9f0c4da3cbef -r 919ad96e3e28 tools/libxl/libxl_uuid.h --- a/tools/libxl/libxl_uuid.h Tue Jan 31 14:41:00 2012 +0000 +++ b/tools/libxl/libxl_uuid.h Tue Jan 31 14:41:00 2012 +0000 @@ -56,7 +56,7 @@ int libxl_uuid_is_nil(libxl_uuid *uuid); void libxl_uuid_generate(libxl_uuid *uuid); int libxl_uuid_from_string(libxl_uuid *uuid, const char *in); -void libxl_uuid_copy(libxl_uuid *dst, libxl_uuid *src); +void libxl_uuid_copy(libxl_uuid *dst, const libxl_uuid *src); void libxl_uuid_clear(libxl_uuid *uuid); int libxl_uuid_compare(libxl_uuid *uuid1, libxl_uuid *uuid2); uint8_t *libxl_uuid_bytearray(libxl_uuid *uuid); _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |