[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 08 of 32 RFC] libxl: plumb libxl_domain_config down into device model creation
# HG changeset patch # User Ian Campbell <ian.campbell@xxxxxxxxxx> # Date 1326296799 0 # Node ID 14605ae17bd9d8a3e2a5111ae6f06ffda0ddc441 # Parent 2cf31bf780380c42d859bb0b8f7c701cbf424180 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> diff -r 2cf31bf78038 -r 14605ae17bd9 tools/libxl/libxl_create.c --- a/tools/libxl/libxl_create.c Wed Jan 11 15:42:33 2012 +0000 +++ b/tools/libxl/libxl_create.c Wed Jan 11 15:46:39 2012 +0000 @@ -558,7 +558,7 @@ static int do_domain_create(libxl__gc *g 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); @@ -605,7 +605,8 @@ static int do_domain_create(libxl__gc *g 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 2cf31bf78038 -r 14605ae17bd9 tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Wed Jan 11 15:42:33 2012 +0000 +++ b/tools/libxl/libxl_dm.c Wed Jan 11 15:46:39 2012 +0000 @@ -82,10 +82,11 @@ static const char *libxl__domain_bios(li } 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; @@ -236,10 +237,11 @@ static const char *qemu_disk_format_stri } 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; @@ -500,20 +502,21 @@ static char ** libxl__build_device_model } 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: @@ -524,9 +527,9 @@ static char ** libxl__build_device_model } 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)); @@ -591,6 +594,7 @@ retry_transaction: } 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, @@ -601,8 +605,7 @@ 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_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; @@ -616,7 +619,35 @@ static int libxl__create_stubdom(libxl__ 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) { @@ -624,33 +655,6 @@ static int libxl__create_stubdom(libxl__ 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)), @@ -749,6 +753,7 @@ retry_transaction: 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; @@ -778,6 +783,7 @@ out: } 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, @@ -799,7 +805,7 @@ int libxl__create_device_model(libxl__gc 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); @@ -817,7 +823,8 @@ int libxl__create_device_model(libxl__gc 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; @@ -1037,12 +1044,13 @@ out: } 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 2cf31bf78038 -r 14605ae17bd9 tools/libxl/libxl_internal.h --- a/tools/libxl/libxl_internal.h Wed Jan 11 15:42:33 2012 +0000 +++ b/tools/libxl/libxl_internal.h Wed Jan 11 15:46:39 2012 +0000 @@ -465,11 +465,13 @@ _hidden int libxl__domain_build(libxl__g _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 2cf31bf78038 -r 14605ae17bd9 tools/libxl/libxl_uuid.c --- a/tools/libxl/libxl_uuid.c Wed Jan 11 15:42:33 2012 +0000 +++ b/tools/libxl/libxl_uuid.c Wed Jan 11 15:46:39 2012 +0000 @@ -35,7 +35,7 @@ int libxl_uuid_from_string(libxl_uuid *u 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 @@ int libxl_uuid_from_string(libxl_uuid *u } #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 2cf31bf78038 -r 14605ae17bd9 tools/libxl/libxl_uuid.h --- a/tools/libxl/libxl_uuid.h Wed Jan 11 15:42:33 2012 +0000 +++ b/tools/libxl/libxl_uuid.h Wed Jan 11 15:46:39 2012 +0000 @@ -56,7 +56,7 @@ typedef struct { 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-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |