Ian Campbell
2011-Apr-20 16:15 UTC
[Xen-devel] [PATCH 00 of 32] [V2] tools: libxl IDL, SeaBIOS, ocaml binding autogeneration, misc
The following series is basically a flush of my current libxl and related patch queue. Most of this has been posted as separate series in the past but there is some interaction so it is easier to include everything in a single series. It contains: * xl API change to remove the need to specify hvmloader and device model by default (although users can still do so if they wish) * build and libxl support for using SeaBIOS with the upstream qemu instead of ROMBIOS. * Several improvements to the libxl IDL, including: * the addition of enumerations * the removal of some constructs which were either not very useful or semantically tricky for language bindings (e.g. References, BitFields) * read- and write-only types to save generating pointless marshaller functions for language bindings * simplification of the integer types, removed "unsigned long", "unsigned int" etc in favour of exclusively using uint{8,16,32,64}. The plain "integer" type is now limited to 24 (signed) bits for the benefit of higher-level languages which steal some bits from the native word size. * Autogeneration of the type marshallers for the ocaml bindings. The series incorporates much of Dave Scott''s ocaml interface cleanup series but excludes the network QoS bits (patches 13..14/14 in his series) since there were outstanding questions around that stuff. Not all of the datatypes are actually usable via the ocaml interfaces yet since the stub functions have not been implemented. I used -Wno-unused for now but this should go away as the set of stub functions is completed. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-20 16:15 UTC
[Xen-devel] [PATCH 01 of 32] tools: libxl: hide selection of hvmloader by default
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1303200984 -3600 # Node ID b7006e611860f6e600bb7dd7282d615d5bc94970 # Parent 58e0677597d673f706217ae2a149d051bcced9a5 tools: libxl: hide selection of hvmloader by default. This should never have been exposed to users as something they are required to think about, unless they want to. At the libxl API level: * Move libxl_domain_build_info.kernel into the PV side of the tagged union (using this field to specify both PV kernel and hvmloader is confusing) * Add hvmloader (a string) to the HVM side of the tagged union. This defaults to NULL and libxl will DTRT with that default but still allow libxl users to specify something explicit if they want. At the xl level: * WARN if an HVM guest cfg uses the "kernel" config option, and direct users to the "hvmloader_override" option if they really do not want the default hvmloader. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 58e0677597d6 -r b7006e611860 tools/libxl/libxl.idl --- a/tools/libxl/libxl.idl Tue Apr 19 09:16:24 2011 +0100 +++ b/tools/libxl/libxl.idl Tue Apr 19 09:16:24 2011 +0100 @@ -95,12 +95,12 @@ libxl_domain_build_info = Struct("domain ("video_memkb", uint32), ("shadow_memkb", uint32), ("disable_migrate", bool), - ("kernel", libxl_file_reference), ("cpuid", libxl_cpuid_policy_list), ("hvm", integer), ("u", KeyedUnion(None, "hvm", [("hvm", "%s", Struct(None, - [("pae", bool), + [("hvmloader", string), + ("pae", bool), ("apic", bool), ("acpi", bool), ("nx", bool), @@ -112,7 +112,8 @@ libxl_domain_build_info = Struct("domain ("nested_hvm", bool), ])), ("pv", "!%s", Struct(None, - [("slack_memkb", uint32), + [("kernel", libxl_file_reference), + ("slack_memkb", uint32), ("bootloader", string), ("bootloader_args", string), ("cmdline", string), diff -r 58e0677597d6 -r b7006e611860 tools/libxl/libxl_bootloader.c --- a/tools/libxl/libxl_bootloader.c Tue Apr 19 09:16:24 2011 +0100 +++ b/tools/libxl/libxl_bootloader.c Tue Apr 19 09:16:24 2011 +0100 @@ -44,8 +44,9 @@ static char **make_bootloader_args(libxl flexarray_set(args, nr++, (char *)info->u.pv.bootloader); - if (info->kernel.path) - flexarray_set(args, nr++, libxl__sprintf(gc, "--kernel=%s", info->kernel.path)); + if (info->u.pv.kernel.path) + flexarray_set(args, nr++, libxl__sprintf(gc, "--kernel=%s", + info->u.pv.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'') @@ -277,10 +278,10 @@ static void parse_bootloader_result(libx { while (*o != ''\0'') { if (strncmp("kernel ", o, strlen("kernel ")) == 0) { - free(info->kernel.path); - info->kernel.path = strdup(o + strlen("kernel ")); - libxl__file_reference_map(&info->kernel); - unlink(info->kernel.path); + free(info->u.pv.kernel.path); + info->u.pv.kernel.path = strdup(o + strlen("kernel ")); + libxl__file_reference_map(&info->u.pv.kernel); + unlink(info->u.pv.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 ")); diff -r 58e0677597d6 -r b7006e611860 tools/libxl/libxl_create.c --- a/tools/libxl/libxl_create.c Tue Apr 19 09:16:24 2011 +0100 +++ b/tools/libxl/libxl_create.c Tue Apr 19 09:16:24 2011 +0100 @@ -84,8 +84,8 @@ void libxl_init_build_info(libxl_domain_ b_info->shadow_memkb = 0; if (c_info->hvm) { b_info->video_memkb = 8 * 1024; - b_info->kernel.path = strdup("hvmloader"); b_info->hvm = 1; + b_info->u.hvm.hvmloader = NULL; b_info->u.hvm.pae = 1; b_info->u.hvm.apic = 1; b_info->u.hvm.acpi = 1; @@ -178,7 +178,7 @@ int libxl__domain_build(libxl__gc *gc, l vments[i++] = "image/ostype"; vments[i++] = "linux"; vments[i++] = "image/kernel"; - vments[i++] = (char*) info->kernel.path; + vments[i++] = (char*) info->u.pv.kernel.path; vments[i++] = "start_time"; vments[i++] = libxl__sprintf(gc, "%lu.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000); if (info->u.pv.ramdisk.path) { @@ -228,7 +228,7 @@ static int domain_restore(libxl__gc *gc, vments[i++] = "image/ostype"; vments[i++] = "linux"; vments[i++] = "image/kernel"; - vments[i++] = (char*) info->kernel.path; + vments[i++] = (char*) info->u.pv.kernel.path; vments[i++] = "start_time"; vments[i++] = libxl__sprintf(gc, "%lu.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000); if (info->u.pv.ramdisk.path) { @@ -252,9 +252,10 @@ static int domain_restore(libxl__gc *gc, } out: - libxl__file_reference_unmap(&info->kernel); - if (!info->hvm) - libxl__file_reference_unmap(&info->u.pv.ramdisk); + if (!info->hvm) { + libxl__file_reference_unmap(&info->u.pv.kernel); + libxl__file_reference_unmap(&info->u.pv.ramdisk); + } esave = errno; diff -r 58e0677597d6 -r b7006e611860 tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Tue Apr 19 09:16:24 2011 +0100 +++ b/tools/libxl/libxl_dm.c Tue Apr 19 09:16:24 2011 +0100 @@ -535,7 +535,8 @@ static int libxl__create_stubdom(libxl__ b_info.max_vcpus = 1; b_info.max_memkb = 32 * 1024; b_info.target_memkb = b_info.max_memkb; - b_info.kernel.path = libxl__abs_path(gc, "ioemu-stubdom.gz", libxl_xenfirmwaredir_path()); + 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 = ""; diff -r 58e0677597d6 -r b7006e611860 tools/libxl/libxl_dom.c --- a/tools/libxl/libxl_dom.c Tue Apr 19 09:16:24 2011 +0100 +++ b/tools/libxl/libxl_dom.c Tue Apr 19 09:16:24 2011 +0100 @@ -160,13 +160,17 @@ int libxl__build_pv(libxl__gc *gc, uint3 return ERROR_FAIL; } - if (info->kernel.mapped) { - if ( (ret = xc_dom_kernel_mem(dom, info->kernel.data, info->kernel.size)) != 0) { + if (info->u.pv.kernel.mapped) { + ret = xc_dom_kernel_mem(dom, + info->u.pv.kernel.data, + info->u.pv.kernel.size); + if ( ret != 0) { LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_kernel_mem failed"); goto out; } } else { - if ( (ret = xc_dom_kernel_file(dom, info->kernel.path)) != 0) { + ret = xc_dom_kernel_file(dom, info->u.pv.kernel.path); + if ( ret != 0) { LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_kernel_file failed"); goto out; } @@ -264,25 +268,27 @@ static int hvm_build_set_params(xc_inter return 0; } +static const char *libxl__domain_hvmloader(libxl__gc *gc, + libxl_domain_build_info *info) +{ + return libxl__abs_path(gc, + info->u.hvm.hvmloader ? : "hvmloader", + libxl_xenfirmwaredir_path()); +} + int libxl__build_hvm(libxl__gc *gc, uint32_t domid, libxl_domain_build_info *info, libxl_domain_build_state *state) { libxl_ctx *ctx = libxl__gc_owner(gc); int ret, rc = ERROR_INVAL; - if (info->kernel.mapped) { - LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "libxl__build_hvm kernel cannot be mmapped"); - goto out; - } - rc = ERROR_FAIL; ret = xc_hvm_build_target_mem( ctx->xch, domid, (info->max_memkb - info->video_memkb) / 1024, (info->target_memkb - info->video_memkb) / 1024, - libxl__abs_path(gc, (char *)info->kernel.path, - libxl_xenfirmwaredir_path())); + libxl__domain_hvmloader(gc, info)); if (ret) { LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, ret, "hvm building failed"); goto out; diff -r 58e0677597d6 -r b7006e611860 tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Tue Apr 19 09:16:24 2011 +0100 +++ b/tools/libxl/xl_cmdimpl.c Tue Apr 19 09:16:24 2011 +0100 @@ -337,7 +337,7 @@ static void printf_info(int domid, printf("\t(image\n"); if (c_info->hvm) { printf("\t\t(hvm\n"); - printf("\t\t\t(loader %s)\n", b_info->kernel.path); + printf("\t\t\t(loader %s)\n", b_info->u.hvm.hvmloader); printf("\t\t\t(video_memkb %d)\n", b_info->video_memkb); printf("\t\t\t(shadow_memkb %d)\n", b_info->shadow_memkb); printf("\t\t\t(pae %d)\n", b_info->u.hvm.pae); @@ -370,7 +370,7 @@ static void printf_info(int domid, printf("\t\t)\n"); } else { printf("\t\t(linux %d)\n", b_info->hvm); - printf("\t\t\t(kernel %s)\n", b_info->kernel.path); + printf("\t\t\t(kernel %s)\n", b_info->u.pv.kernel.path); printf("\t\t\t(cmdline %s)\n", b_info->u.pv.cmdline); printf("\t\t\t(ramdisk %s)\n", b_info->u.pv.ramdisk.path); printf("\t\t)\n"); @@ -740,12 +740,16 @@ static void parse_config_data(const char if (!xlu_cfg_get_long (config, "videoram", &l)) b_info->video_memkb = l * 1024; - xlu_cfg_replace_string (config, "kernel", &b_info->kernel.path); - if (!xlu_cfg_get_long (config, "gfx_passthru", &l)) dm_info->gfx_passthru = l; if (c_info->hvm == 1) { + if (!xlu_cfg_get_string (config, "kernel", &buf)) + fprintf(stderr, "WARNING: ignoring \"kernel\" directive for HVM guest. " + "Use \"hvmloader_override\" instead if you really want a non-default hvmloader\n"); + + xlu_cfg_replace_string (config, "hvmloader_override", + &b_info->u.hvm.hvmloader); if (!xlu_cfg_get_long (config, "pae", &l)) b_info->u.hvm.pae = l; if (!xlu_cfg_get_long (config, "apic", &l)) @@ -768,6 +772,8 @@ static void parse_config_data(const char char *cmdline = NULL; const char *root = NULL, *extra = ""; + xlu_cfg_replace_string (config, "kernel", &b_info->u.pv.kernel.path); + xlu_cfg_get_string (config, "root", &root); xlu_cfg_get_string (config, "extra", &extra); @@ -786,7 +792,7 @@ static void parse_config_data(const char xlu_cfg_replace_string (config, "bootloader", &b_info->u.pv.bootloader); xlu_cfg_replace_string (config, "bootloader_args", &b_info->u.pv.bootloader_args); - if (!b_info->u.pv.bootloader && !b_info->kernel.path) { + if (!b_info->u.pv.bootloader && !b_info->u.pv.kernel.path) { fprintf(stderr, "Neither kernel nor bootloader specified\n"); exit(1); } _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-20 16:15 UTC
[Xen-devel] [PATCH 02 of 32] tools: libxl: hide selection of device-model by default
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1303315980 -3600 # Node ID e8073053ef283658dd096f0846b0c438a29b6778 # Parent b7006e611860f6e600bb7dd7282d615d5bc94970 tools: libxl: hide selection of device-model by default. This should never have been exposed to users as something they are required to think about, unless they want to. At the libxl API level: * Add libxl_device_model_info.device_model_version allowing the user to say which qemu version (e.g. old qemu-xen or qemu upstream) they want for a domain. * Add libxl_device_model_info.device_model_stubdomain allowing the user to select stub or non-stub device model * Default both the device_model field to NULL and DTRT when building a domain with that value in those fields, but still allow libxl users to specify something explicit if they want. * Note that libxl_device_model_info.device_model, if specified, must now be a complete path. At the xl level: * Support a new "device_model_version" option which sets the new libxl_device_model_info.device_model_version field. This option is mandatory if device_model_override is used. * Support a new "device_model_stubdomain_override" option which allows the user to request stubdomain if desired. * WARN if an HVM guest cfg uses the "device_model" config option, and direct users to the "device_model_override" option if they really do not want the default. If the "device_model" directive contains "stubdom-db" then direct users to the "device_model_stubdomain_override" directive. The default qemu remains the existing qemu-xen based qemu-dm and stubdomain defaults to off. I chose the name "qemu-xen traditional" to refer to the existing Xen fork of qemu and simply "qemu-xen" to refer to the new device model based on qemu upstream. I suspect that the vast majority of users only have these config options because they''ve copied them from somewhere and they normally have no interest in which device model is used. Renaming the fields and warning when they are used makes these decisions internal. This will allow us to make decisions at a platform level regarding the preferred hvmloader, device model, stub domain etc without requiring everyone to change their configuration files. Adding a device model version to the API is intended to make it easy for users to select what they need without having to know about the paths to specific binaries etc. Most importantly it gets rid of the parsing of the output of qemu -h... It''s not clear where upstream qemu will eventually be installed, I went with /usr/bin/qemu for now. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r b7006e611860 -r e8073053ef28 tools/libxl/libxl.c --- a/tools/libxl/libxl.c Tue Apr 19 09:16:24 2011 +0100 +++ b/tools/libxl/libxl.c Wed Apr 20 17:13:00 2011 +0100 @@ -2070,15 +2070,17 @@ out: int libxl_domain_need_memory(libxl_ctx *ctx, libxl_domain_build_info *b_info, libxl_device_model_info *dm_info, uint32_t *need_memkb) { + libxl__gc gc = LIBXL_INIT_GC(ctx); *need_memkb = b_info->target_memkb; if (b_info->hvm) { *need_memkb += b_info->shadow_memkb + LIBXL_HVM_EXTRA_MEMORY; - if (strstr(dm_info->device_model, "stubdom-dm")) + if (dm_info->device_model_stubdomain) *need_memkb += 32 * 1024; } else *need_memkb += b_info->shadow_memkb + LIBXL_PV_EXTRA_MEMORY; if (*need_memkb % (2 * 1024)) *need_memkb += (2 * 1024) - (*need_memkb % (2 * 1024)); + libxl__free_all(&gc); return 0; } diff -r b7006e611860 -r e8073053ef28 tools/libxl/libxl.h --- a/tools/libxl/libxl.h Tue Apr 19 09:16:24 2011 +0100 +++ b/tools/libxl/libxl.h Wed Apr 20 17:13:00 2011 +0100 @@ -166,6 +166,13 @@ typedef enum { XENPV, } libxl_qemu_machine_type; +typedef enum libxl_device_model_version { + /* Historical qemu-xen device model (qemu-dm) */ + LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL = 1, + /* Upstream based qemu-xen device model */ + LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN = 2, +} libxl_device_model_version; + typedef enum { LIBXL_CONSTYPE_SERIAL = 1, LIBXL_CONSTYPE_PV, diff -r b7006e611860 -r e8073053ef28 tools/libxl/libxl.idl --- a/tools/libxl/libxl.idl Tue Apr 19 09:16:24 2011 +0100 +++ b/tools/libxl/libxl.idl Wed Apr 20 17:13:00 2011 +0100 @@ -9,6 +9,7 @@ libxl_mac = Builtin("mac") libxl_cpumap = Builtin("cpumap", destructor_fn="libxl_cpumap_destroy", passby=PASS_BY_REFERENCE) libxl_cpuarray = Builtin("cpuarray", destructor_fn="libxl_cpuarray_destroy", passby=PASS_BY_REFERENCE) libxl_qemu_machine_type = Number("qemu_machine_type", namespace="libxl_") +libxl_device_model_version = Number("device_model_version", namespace="libxl_") libxl_console_consback = Number("console_consback", namespace="libxl_") libxl_console_constype = Number("console_constype", namespace="libxl_") libxl_disk_format = Number("disk_format", namespace="libxl_") @@ -140,7 +141,9 @@ libxl_device_model_info = Struct("device ("domid", integer), ("uuid", libxl_uuid, False, "this is use only with stubdom, and must be different from the domain uuid"), ("dom_name", string), - ("device_model", string), + ("device_model_version", libxl_device_model_version), + ("device_model_stubdomain", bool), + ("device_model", string, False, "if you set this you must set device_model_version too"), ("saved_state", string), ("type", libxl_qemu_machine_type), ("target_ram", uint32), diff -r b7006e611860 -r e8073053ef28 tools/libxl/libxl_create.c --- a/tools/libxl/libxl_create.c Tue Apr 19 09:16:24 2011 +0100 +++ b/tools/libxl/libxl_create.c Wed Apr 20 17:13:00 2011 +0100 @@ -108,7 +108,9 @@ void libxl_init_dm_info(libxl_device_mod libxl_uuid_generate(&dm_info->uuid); dm_info->dom_name = strdup(c_info->name); - dm_info->device_model = strdup("qemu-dm"); + dm_info->device_model_version = LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL; + dm_info->device_model_stubdomain = false; + dm_info->device_model = NULL; dm_info->target_ram = libxl__sizekb_to_mb(b_info->target_memkb); dm_info->videoram = libxl__sizekb_to_mb(b_info->video_memkb); dm_info->apic = b_info->u.hvm.apic; diff -r b7006e611860 -r e8073053ef28 tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Tue Apr 19 09:16:24 2011 +0100 +++ b/tools/libxl/libxl_dm.c Wed Apr 20 17:13:00 2011 +0100 @@ -38,7 +38,39 @@ static const char *libxl_tapif_script(li #endif } +const char *libxl__domain_device_model(libxl__gc *gc, + libxl_device_model_info *info) +{ + libxl_ctx *ctx = libxl__gc_owner(gc); + const char *dm; + + if (info->device_model_stubdomain) + return NULL; + + if (info->device_model) { + dm = libxl__strdup(gc, info->device_model); + } else { + switch (info->device_model_version) { + case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: + dm = libxl__abs_path(gc, "qemu-dm", libxl_libexec_path()); + break; + case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN: + dm = libxl__strdup(gc, "/usr/bin/qemu"); + break; + default: + LIBXL__LOG(ctx, LIBXL__LOG_ERROR, + "invalid device model version %d\n", + info->device_model_version); + dm = NULL; + break; + } + } + + return dm; +} + 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) @@ -50,7 +82,8 @@ static char ** libxl__build_device_model if (!dm_args) return NULL; - flexarray_vappend(dm_args, "qemu-dm", "-d", libxl__sprintf(gc, "%d", info->domid), NULL); + flexarray_vappend(dm_args, dm, + "-d", libxl__sprintf(gc, "%d", info->domid), NULL); if (info->dom_name) flexarray_vappend(dm_args, "-domain-name", info->dom_name, NULL); @@ -183,6 +216,7 @@ 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) @@ -195,8 +229,8 @@ static char ** libxl__build_device_model if (!dm_args) return NULL; - flexarray_vappend(dm_args, libxl__strdup(gc, info->device_model), - "-xen-domid", libxl__sprintf(gc, "%d", info->domid), NULL); + flexarray_vappend(dm_args, dm, + "-xen-domid", libxl__sprintf(gc, "%d", info->domid), NULL); if (info->type == XENPV) { flexarray_append(dm_args, "-xen-attach"); @@ -385,19 +419,26 @@ 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) { libxl_ctx *ctx = libxl__gc_owner(gc); - int new_qemu; - new_qemu = libxl_check_device_model_version(ctx, info->device_model); - - if (new_qemu == 1) { - return libxl__build_device_model_args_new(gc, info, disks, num_disks, vifs, num_vifs); - } else { - return libxl__build_device_model_args_old(gc, info, disks, num_disks, vifs, num_vifs); + switch (info->device_model_version) { + case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: + return libxl__build_device_model_args_old(gc, dm, info, + disks, num_disks, + vifs, num_vifs); + case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN: + return libxl__build_device_model_args_new(gc, dm, info, + disks, num_disks, + vifs, num_vifs); + default: + LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "unknown device model version %d", + info->device_model_version); + return NULL; } } @@ -518,7 +559,13 @@ static int libxl__create_stubdom(libxl__ xs_transaction_t t; libxl__device_model_starting *dm_starting = 0; - args = libxl__build_device_model_args(gc, info, disks, num_disks, + if (info->device_model_version != LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL) { + ret = ERROR_INVAL; + goto out; + } + + args = libxl__build_device_model_args(gc, "stubdom-dm", info, + disks, num_disks, vifs, num_vifs); if (!args) { ret = ERROR_FAIL; @@ -676,20 +723,30 @@ int libxl__create_device_model(libxl__gc int rc; char **args; libxl__device_model_starting buf_starting, *p; - xs_transaction_t t; + xs_transaction_t t; char *vm_path; char **pass_stuff; + const char *dm; - if (strstr(info->device_model, "stubdom-dm")) { + if (info->device_model_stubdomain) { libxl_device_vfb vfb; libxl_device_vkb vkb; libxl__vfb_and_vkb_from_device_model_info(gc, info, &vfb, &vkb); - rc = libxl__create_stubdom(gc, info, disks, num_disks, vifs, num_vifs, &vfb, &vkb, starting_r); + rc = libxl__create_stubdom(gc, info, + disks, num_disks, + vifs, num_vifs, + &vfb, &vkb, starting_r); goto out; } - args = libxl__build_device_model_args(gc, info, disks, num_disks, + dm = libxl__domain_device_model(gc, info); + if (!dm) { + rc = ERROR_FAIL; + goto out; + } + + args = libxl__build_device_model_args(gc, dm, info, disks, num_disks, vifs, num_vifs); if (!args) { rc = ERROR_FAIL; @@ -747,8 +804,8 @@ retry_transaction: if (!rc) { /* inner child */ setsid(); libxl__exec(null, logfile_w, logfile_w, - libxl__abs_path(gc, info->device_model, libxl_libexec_path()), - args); + libxl__domain_device_model(gc, info), + args); } rc = 0; @@ -847,7 +904,8 @@ static int libxl__build_xenpv_qemu_args( info->nographic = 1; info->domid = domid; info->dom_name = libxl_domid_to_name(ctx, domid); - info->device_model = libxl__abs_path(gc, "qemu-dm", libxl_libexec_path()); + info->device_model_version = LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL; + info->device_model = NULL; info->type = XENPV; return 0; } diff -r b7006e611860 -r e8073053ef28 tools/libxl/libxl_internal.h --- a/tools/libxl/libxl_internal.h Tue Apr 19 09:16:24 2011 +0100 +++ b/tools/libxl/libxl_internal.h Wed Apr 20 17:13:00 2011 +0100 @@ -233,6 +233,8 @@ _hidden int libxl__domain_make(libxl__gc _hidden int libxl__domain_build(libxl__gc *gc, libxl_domain_build_info *info, uint32_t domid, /* out */ libxl_domain_build_state *state); /* for device model creation */ +_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_device_model_info *info, libxl_device_disk *disk, int num_disks, diff -r b7006e611860 -r e8073053ef28 tools/libxl/libxl_utils.c --- a/tools/libxl/libxl_utils.c Tue Apr 19 09:16:24 2011 +0100 +++ b/tools/libxl/libxl_utils.c Wed Apr 20 17:13:00 2011 +0100 @@ -568,89 +568,6 @@ out: return rc; } -#define QEMU_VERSION_STR "QEMU emulator version " - - -int libxl_check_device_model_version(libxl_ctx *ctx, char *path) -{ - libxl__gc gc = LIBXL_INIT_GC(ctx); - pid_t pid = -1; - int pipefd[2]; - char buf[100]; - ssize_t i, count = 0; - int status; - char *abs_path = NULL; - int rc = -1; - - abs_path = libxl__abs_path(&gc, path, libxl_private_bindir_path()); - - if (pipe(pipefd)) - goto out; - - pid = fork(); - if (pid == -1) { - goto out; - } - - if (!pid) { - close(pipefd[0]); - if (dup2(pipefd[1], STDOUT_FILENO) == -1) - exit(1); - execlp(abs_path, abs_path, "-h", NULL); - - close(pipefd[1]); - exit(127); - } - - close(pipefd[1]); - - /* attempt to get the first line of `qemu -h` */ - while ((i = read(pipefd[0], buf + count, 99 - count)) > 0) { - if (i + count > 90) - break; - for (int j = 0; j < i; j++) { - if (buf[j + count] == ''\n'') - break; - } - count += i; - } - count += i; - close(pipefd[0]); - waitpid(pid, &status, 0); - if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { - goto out; - } - - /* Check if we have the forked qemu-xen. */ - /* QEMU-DM emulator version 0.10.2, ... */ - if (strncmp("QEMU-DM ", buf, 7) == 0) { - rc = 0; - goto out; - } - - /* Check if the version is above 12.0 */ - /* The first line is : QEMU emulator version 0.12.50, ... */ - if (strncmp(QEMU_VERSION_STR, buf, strlen(QEMU_VERSION_STR)) == 0) { - int major, minor; - char *endptr = NULL; - char *v = buf + strlen(QEMU_VERSION_STR); - - major = strtol(v, &endptr, 10); - if (major == 0 && endptr && *endptr == ''.'') { - v = endptr + 1; - minor = strtol(v, &endptr, 10); - if (minor >= 12) { - rc = 1; - goto out; - } - } - } - rc = 0; -out: - libxl__free_all(&gc); - return rc; -} - int libxl_cpumap_alloc(libxl_ctx *ctx, libxl_cpumap *cpumap) { int max_cpus; diff -r b7006e611860 -r e8073053ef28 tools/libxl/libxl_utils.h --- a/tools/libxl/libxl_utils.h Tue Apr 19 09:16:24 2011 +0100 +++ b/tools/libxl/libxl_utils.h Wed Apr 20 17:13:00 2011 +0100 @@ -66,12 +66,6 @@ int libxl_devid_to_device_nic(libxl_ctx int libxl_devid_to_device_disk(libxl_ctx *ctx, uint32_t domid, const char *devid, libxl_device_disk *disk); -/* check the version of qemu - * return 1 if is the new one - * return 0 if is the old one - * return -1 if there are an error */ -int libxl_check_device_model_version(libxl_ctx *ctx, char *path); - int libxl_cpumap_alloc(libxl_ctx *ctx, libxl_cpumap *cpumap); int libxl_cpumap_test(libxl_cpumap *cpumap, int cpu); void libxl_cpumap_set(libxl_cpumap *cpumap, int cpu); diff -r b7006e611860 -r e8073053ef28 tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Tue Apr 19 09:16:24 2011 +0100 +++ b/tools/libxl/xl_cmdimpl.c Wed Apr 20 17:13:00 2011 +0100 @@ -350,7 +350,7 @@ static void printf_info(int domid, printf("\t\t\t(timer_mode %d)\n", b_info->u.hvm.timer_mode); printf("\t\t\t(nestedhvm %d)\n", b_info->u.hvm.nested_hvm); - printf("\t\t\t(device_model %s)\n", dm_info->device_model); + printf("\t\t\t(device_model %s)\n", dm_info->device_model ? : "default"); printf("\t\t\t(videoram %d)\n", dm_info->videoram); printf("\t\t\t(stdvga %d)\n", dm_info->stdvga); printf("\t\t\t(vnc %d)\n", dm_info->vnc); @@ -774,6 +774,8 @@ static void parse_config_data(const char xlu_cfg_replace_string (config, "kernel", &b_info->u.pv.kernel.path); + xlu_cfg_replace_string (config, "kernel", &b_info->u.pv.kernel.path); + xlu_cfg_get_string (config, "root", &root); xlu_cfg_get_string (config, "extra", &extra); @@ -1079,7 +1081,32 @@ skip_vfb: libxl_init_dm_info(dm_info, c_info, b_info); /* then process config related to dm */ - xlu_cfg_replace_string (config, "device_model", &dm_info->device_model); + if (!xlu_cfg_get_string (config, "device_model", &buf)) { + fprintf(stderr, + "WARNING: ignoring device_model directive.\n" + "WARNING: Use \"device_model_override\" instead if you really want a non-default device_model\n"); + if (strstr(buf, "stubdom-dm")) + fprintf(stderr, "WARNING: Or use \"device_model_stubdomain_override\" if you want to enable stubdomains\n"); + } + + xlu_cfg_replace_string (config, "device_model_override", + &dm_info->device_model); + if (!xlu_cfg_get_string (config, "device_model_version", &buf)) { + if (!strcmp(buf, "qemu-xen-traditional")) { + dm_info->device_model_version + = LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL; + } else if (!strcmp(buf, "qemu-xen")) { + dm_info->device_model_version + = LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN; + } else { + fprintf(stderr, + "Unknown device_model_version \"%s\" specified\n", buf); + exit(1); + } + } else if (dm_info->device_model) + fprintf(stderr, "WARNING: device model override given without specific DM version\n"); + if (!xlu_cfg_get_long (config, "device_model_stubdomain_override", &l)) + dm_info->device_model_stubdomain = l; if (!xlu_cfg_get_long (config, "stdvga", &l)) dm_info->stdvga = l; if (!xlu_cfg_get_long (config, "vnc", &l)) _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-20 16:15 UTC
[Xen-devel] [PATCH 03 of 32] tools: libxl: write selected BIOS to xenstore
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1303315986 -3600 # Node ID 8eb5c6ebc5c95791e8c129e75030a7979c1e7f5d # Parent e8073053ef283658dd096f0846b0c438a29b6778 tools: libxl: write selected BIOS to xenstore. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r e8073053ef28 -r 8eb5c6ebc5c9 tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Wed Apr 20 17:13:00 2011 +0100 +++ b/tools/libxl/libxl_dm.c Wed Apr 20 17:13:06 2011 +0100 @@ -69,6 +69,16 @@ const char *libxl__domain_device_model(l return dm; } +static char *libxl__domain_bios(libxl__gc *gc, + libxl_device_model_info *info) +{ + switch (info->device_model_version) { + case 1: return libxl__strdup(gc, "rombios"); + case 2: return libxl__strdup(gc, "rombios"); + default:return NULL; + } +} + static char ** libxl__build_device_model_args_old(libxl__gc *gc, const char *dm, libxl_device_model_info *info, @@ -753,6 +763,11 @@ int libxl__create_device_model(libxl__gc goto out; } + path = libxl__sprintf(gc, "/local/domain/%d/hvmloader", info->domid); + xs_mkdir(ctx->xsh, XBT_NULL, path); + libxl__xs_write(gc, XBT_NULL, libxl__sprintf(gc, "%s/bios", path), + libxl__domain_bios(gc, info)); + path = libxl__sprintf(gc, "/local/domain/0/device-model/%d", info->domid); xs_mkdir(ctx->xsh, XBT_NULL, path); libxl__xs_write(gc, XBT_NULL, libxl__sprintf(gc, "%s/disable_pf", path), "%d", !info->xen_platform_pci); @@ -875,6 +890,7 @@ int libxl__destroy_device_model(libxl__g } } xs_rm(ctx->xsh, XBT_NULL, libxl__sprintf(gc, "/local/domain/0/device-model/%d", domid)); + xs_rm(ctx->xsh, XBT_NULL, libxl__sprintf(gc, "/local/domain/%d/hvmloader", domid)); out: return ret; _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-20 16:15 UTC
[Xen-devel] [PATCH 04 of 32] tools: support SeaBIOS. Use by default when upstream qemu is configured
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1303315986 -3600 # Node ID 2b4be83bdc1aa1aaf13e0ff46c687802d77292dd # Parent 8eb5c6ebc5c95791e8c129e75030a7979c1e7f5d tools: support SeaBIOS. Use by default when upstream qemu is configured. The SeaBIOS integration here is only semi-complete and is targetted at developers and very early adopters who can be expected to cope with some rough edges. In particular the user must clone, patch as necessary and compile SeaBIOS themselves since this patchset does not cover any of that (in the same way we currently do not integrate upstream qemu clone+build). Include a big comment to that effect next to the Config.mk option. Many of the bios_config callback functions are not yet used by SeaBIOS. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 8eb5c6ebc5c9 -r 2b4be83bdc1a Config.mk --- a/Config.mk Wed Apr 20 17:13:06 2011 +0100 +++ b/Config.mk Wed Apr 20 17:13:06 2011 +0100 @@ -184,6 +184,18 @@ QEMU_TAG := xen-4.1.0-rc6 # Fri Feb 11 17:54:51 2011 +0000 # qemu-xen: fix segfault with empty cdroms +# Short answer -- do not enable this unless you know what you are +# doing and are prepared for some pain. + +# SeaBIOS integration is a work in progress. Before enabling this +# option you must clone git://git.qemu.org/seabios.git/, possibly add +# some development patches and then build it yourself before pointing +# this variable to it (using an absolute path). +# +# Note that using SeaBIOS requires the use the upstream qemu as the +# device model. +SEABIOS_DIR ?= + # Optional components XENSTAT_XENTOP ?= y VTPM_TOOLS ?= n diff -r 8eb5c6ebc5c9 -r 2b4be83bdc1a tools/firmware/hvmloader/Makefile --- a/tools/firmware/hvmloader/Makefile Wed Apr 20 17:13:06 2011 +0100 +++ b/tools/firmware/hvmloader/Makefile Wed Apr 20 17:13:06 2011 +0100 @@ -40,9 +40,16 @@ CIRRUSVGA_DEBUG ?= n ROMBIOS_DIR := ../rombios ifneq ($(ROMBIOS_DIR),) OBJS += rombios.o +CFLAGS += -DENABLE_ROMBIOS ROMBIOS_ROM := $(ROMBIOS_DIR)/BIOS-bochs-latest endif +ifneq ($(SEABIOS_DIR),) +OBJS += seabios.o +CFLAGS += -DENABLE_SEABIOS +SEABIOS_ROM := $(SEABIOS_DIR)/out/bios.bin +endif + STDVGA_ROM := ../vgabios/VGABIOS-lgpl-latest.bin ifeq ($(CIRRUSVGA_DEBUG),y) CIRRUSVGA_ROM := ../vgabios/VGABIOS-lgpl-latest.cirrus.debug.bin @@ -54,7 +61,7 @@ endif all: subdirs-all $(MAKE) hvmloader -rombios.o hvmloader.o: roms.inc +rombios.o seabios.o hvmloader.o: roms.inc smbios.o: CFLAGS += -D__SMBIOS_DATE__="\"$(shell date +%m/%d/%Y)\"" hvmloader: $(OBJS) acpi/acpi.a @@ -62,7 +69,7 @@ hvmloader: $(OBJS) acpi/acpi.a $(OBJCOPY) hvmloader.tmp hvmloader rm -f hvmloader.tmp -roms.inc: $(ROMBIOS_ROM) $(STDVGA_ROM) $(CIRRUSVGA_ROM) ../etherboot/eb-roms.h +roms.inc: $(ROMBIOS_ROM) $(SEABIOS_ROM) $(STDVGA_ROM) $(CIRRUSVGA_ROM) ../etherboot/eb-roms.h echo "/* Autogenerated file. DO NOT EDIT */" > $@.new ifneq ($(ROMBIOS_ROM),) @@ -71,6 +78,12 @@ ifneq ($(ROMBIOS_ROM),) echo "#endif" >> $@.new endif +ifneq ($(SEABIOS_ROM),) + echo "#ifdef ROM_INCLUDE_SEABIOS" >> $@.new + sh ./mkhex seabios $(SEABIOS_ROM) >> $@.new + echo "#endif" >> $@.new +endif + ifneq ($(STDVGA_ROM),) echo "#ifdef ROM_INCLUDE_VGABIOS" >> $@.new sh ./mkhex vgabios_stdvga $(STDVGA_ROM) >> $@.new diff -r 8eb5c6ebc5c9 -r 2b4be83bdc1a tools/firmware/hvmloader/config-seabios.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/firmware/hvmloader/config-seabios.h Wed Apr 20 17:13:06 2011 +0100 @@ -0,0 +1,9 @@ +#ifndef __HVMLOADER_CONFIG_SEABIOS_H__ +#define __HVMLOADER_CONFIG_SEABIOS_H__ + +#define OPTIONROM_PHYSICAL_ADDRESS 0x000C8000 +#define OPTIONROM_PHYSICAL_END 0x000E0000 + +#define SEABIOS_PHYSICAL_ADDRESS 0x000E0000 + +#endif /* __HVMLOADER_CONFIG_SEABIOS_H__ */ diff -r 8eb5c6ebc5c9 -r 2b4be83bdc1a tools/firmware/hvmloader/config.h --- a/tools/firmware/hvmloader/config.h Wed Apr 20 17:13:06 2011 +0100 +++ b/tools/firmware/hvmloader/config.h Wed Apr 20 17:13:06 2011 +0100 @@ -40,6 +40,7 @@ struct bios_config { }; extern struct bios_config rombios_config; +extern struct bios_config seabios_config; #define PAGE_SHIFT 12 #define PAGE_SIZE (1ul << PAGE_SHIFT) diff -r 8eb5c6ebc5c9 -r 2b4be83bdc1a tools/firmware/hvmloader/hvmloader.c --- a/tools/firmware/hvmloader/hvmloader.c Wed Apr 20 17:13:06 2011 +0100 +++ b/tools/firmware/hvmloader/hvmloader.c Wed Apr 20 17:13:06 2011 +0100 @@ -341,7 +341,12 @@ struct bios_info { const char *key; const struct bios_config *bios; } bios_configs[] = { +#ifdef ENABLE_ROMBIOS { "rombios", &rombios_config, }, +#endif +#ifdef ENABLE_SEABIOS + { "seabios", &seabios_config, }, +#endif { NULL, NULL } }; diff -r 8eb5c6ebc5c9 -r 2b4be83bdc1a tools/firmware/hvmloader/seabios.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/firmware/hvmloader/seabios.c Wed Apr 20 17:13:06 2011 +0100 @@ -0,0 +1,75 @@ +/* + * HVM SeaBIOS support. + * + * Leendert van Doorn, leendert@watson.ibm.com + * Copyright (c) 2005, International Business Machines Corporation. + * Copyright (c) 2006, Keir Fraser, XenSource Inc. + * Copyright (c) 2011, Citrix Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place - Suite 330, Boston, MA 02111-1307 USA. + */ + +#include "config.h" +#include "config-seabios.h" + +#include "util.h" + +#define ROM_INCLUDE_SEABIOS +#include "roms.inc" + +static void seabios_pci_setup(void) +{ + virtual_vga = VGA_cirrus; +} + +//BUILD_BUG_ON(sizeof(seabios) > (0x00100000U - SEABIOS_PHYSICAL_ADDRESS)); + +struct bios_config seabios_config = { + .name = "SeaBIOS", + + .image = seabios, + .image_size = sizeof(seabios), + + .bios_address = SEABIOS_PHYSICAL_ADDRESS, + + .smbios_start = 0, + .smbios_end = 0, + + .optionrom_start = OPTIONROM_PHYSICAL_ADDRESS, + .optionrom_end = OPTIONROM_PHYSICAL_END, + + .acpi_start = 0, + + .bios_info_setup = NULL, + + .apic_setup = NULL, + .pci_setup = seabios_pci_setup, + .smp_setup = NULL, + + .vm86_setup = NULL, + .e820_setup = NULL, + + .acpi_build_tables = NULL, + .create_mp_tables = NULL, +}; + +/* + * Local variables: + * mode: C + * c-set-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff -r 8eb5c6ebc5c9 -r 2b4be83bdc1a tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Wed Apr 20 17:13:06 2011 +0100 +++ b/tools/libxl/libxl_dm.c Wed Apr 20 17:13:06 2011 +0100 @@ -65,7 +65,6 @@ const char *libxl__domain_device_model(l break; } } - return dm; } @@ -74,7 +73,7 @@ static char *libxl__domain_bios(libxl__g { switch (info->device_model_version) { case 1: return libxl__strdup(gc, "rombios"); - case 2: return libxl__strdup(gc, "rombios"); + case 2: return libxl__strdup(gc, "seabios"); default:return NULL; } } _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-20 16:15 UTC
[Xen-devel] [PATCH 05 of 32] tools: libxl: move all enum values into the libxl namespace
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1303315987 -3600 # Node ID 34f797bacb7886641aa6f340356b915433d4a73b # Parent 2b4be83bdc1aa1aaf13e0ff46c687802d77292dd tools: libxl: move all enum values into the libxl namespace Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 2b4be83bdc1a -r 34f797bacb78 tools/libxl/libxl.c --- a/tools/libxl/libxl.c Wed Apr 20 17:13:06 2011 +0100 +++ b/tools/libxl/libxl.c Wed Apr 20 17:13:07 2011 +0100 @@ -695,15 +695,15 @@ int libxl_event_get_disk_eject_info(libx "/local/domain/%d/backend/%" TOSTRING(BACKEND_STRING_SIZE) "[a-z]/%*d/%*d", &disk->backend_domid, backend_type); if (!strcmp(backend_type, "tap") || !strcmp(backend_type, "vbd")) { - disk->backend = DISK_BACKEND_TAP; + disk->backend = LIBXL_DISK_BACKEND_TAP; } else if (!strcmp(backend_type, "qdisk")) { - disk->backend = DISK_BACKEND_QDISK; + disk->backend = LIBXL_DISK_BACKEND_QDISK; } else { - disk->backend = DISK_BACKEND_UNKNOWN; + disk->backend = LIBXL_DISK_BACKEND_UNKNOWN; } disk->pdev_path = strdup(""); - disk->format = DISK_FORMAT_EMPTY; + disk->format = LIBXL_DISK_FORMAT_EMPTY; /* this value is returned to the user: do not free right away */ disk->vdev = xs_read(ctx->xsh, XBT_NULL, libxl__sprintf(&gc, "%s/dev", backend), NULL); disk->unpluggable = 1; @@ -908,7 +908,7 @@ static int validate_virtual_disk(libxl__ struct stat stat_buf; char *delimiter; - if (disk->format == DISK_FORMAT_EMPTY) { + if (disk->format == LIBXL_DISK_FORMAT_EMPTY) { if (disk->is_cdrom) return 0; LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Empty disk %s is not a CDROM device\n", @@ -916,11 +916,11 @@ static int validate_virtual_disk(libxl__ return ERROR_INVAL; } - if (disk->format == DISK_FORMAT_RAW) { + if (disk->format == LIBXL_DISK_FORMAT_RAW) { delimiter = strchr(file_name, '':''); if (delimiter) { if (!strncmp(file_name, "vhd:", sizeof("vhd:")-1)) { - disk->format = DISK_FORMAT_VHD; + disk->format = LIBXL_DISK_FORMAT_VHD; file_name = ++delimiter; } } @@ -930,7 +930,7 @@ static int validate_virtual_disk(libxl__ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "failed to stat %s", file_name); return ERROR_INVAL; } - if (disk->backend == DISK_BACKEND_PHY) { + if (disk->backend == LIBXL_DISK_BACKEND_PHY) { if ( !(S_ISBLK(stat_buf.st_mode)) ) { LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Virtual disk %s is not a block device!\n", file_name); @@ -984,19 +984,20 @@ int libxl_device_disk_add(libxl_ctx *ctx device.kind = DEVICE_VBD; /* If blktap is not available then fallback to qdisk */ - if (disk->backend == DISK_BACKEND_TAP && !libxl__blktap_enabled(&gc)) - disk->backend = DISK_BACKEND_QDISK; + if (disk->backend == LIBXL_DISK_BACKEND_TAP && !libxl__blktap_enabled(&gc)) + disk->backend = LIBXL_DISK_BACKEND_QDISK; /* * blktap cannot handle empty disks (aka cdroms). Fall back to * qdisk because qemu-xen creates the disk based on the xenstore * entries. */ - if (disk->backend == DISK_BACKEND_TAP && disk->format == DISK_FORMAT_EMPTY) - disk->backend == DISK_BACKEND_QDISK; + if (disk->backend == LIBXL_DISK_BACKEND_TAP && + disk->format == LIBXL_DISK_FORMAT_EMPTY) + disk->backend == LIBXL_DISK_BACKEND_QDISK; switch (disk->backend) { - case DISK_BACKEND_PHY: + case LIBXL_DISK_BACKEND_PHY: dev = disk->pdev_path; do_backend_phy: libxl__device_physdisk_major_minor(dev, &major, &minor); @@ -1008,7 +1009,7 @@ int libxl_device_disk_add(libxl_ctx *ctx device.backend_kind = DEVICE_VBD; break; - case DISK_BACKEND_TAP: + case LIBXL_DISK_BACKEND_TAP: dev = libxl__blktap_devpath(&gc, disk->pdev_path, disk->format); if (!dev) { rc = ERROR_FAIL; @@ -1021,8 +1022,7 @@ int libxl_device_disk_add(libxl_ctx *ctx /* now create a phy device to export the device to the guest */ goto do_backend_phy; - - case DISK_BACKEND_QDISK: + case LIBXL_DISK_BACKEND_QDISK: flexarray_append(back, "params"); flexarray_append(back, libxl__sprintf(&gc, "%s:%s", libxl__device_disk_string_of_format(disk->format), disk->pdev_path)); @@ -1091,13 +1091,13 @@ int libxl_device_disk_del(libxl_ctx *ctx device.backend_devid = devid; switch (disk->backend) { - case DISK_BACKEND_PHY: + case LIBXL_DISK_BACKEND_PHY: device.backend_kind = DEVICE_VBD; break; - case DISK_BACKEND_TAP: + case LIBXL_DISK_BACKEND_TAP: device.backend_kind = DEVICE_VBD; break; - case DISK_BACKEND_QDISK: + case LIBXL_DISK_BACKEND_QDISK: device.backend_kind = DEVICE_QDISK; break; default: @@ -1124,8 +1124,8 @@ char * libxl_device_disk_local_attach(li char *ret = NULL; switch (disk->backend) { - case DISK_BACKEND_PHY: - if (disk->format != DISK_FORMAT_RAW) { + case LIBXL_DISK_BACKEND_PHY: + if (disk->format != LIBXL_DISK_FORMAT_RAW) { LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "physical block device must" " be raw"); break; @@ -1134,13 +1134,14 @@ char * libxl_device_disk_local_attach(li disk->pdev_path); dev = disk->pdev_path; break; - case DISK_BACKEND_TAP: - if (disk->format == DISK_FORMAT_VHD || disk->format == DISK_FORMAT_RAW) + case LIBXL_DISK_BACKEND_TAP: + if (disk->format == LIBXL_DISK_FORMAT_VHD || + disk->format == LIBXL_DISK_FORMAT_RAW) { if (libxl__blktap_enabled(&gc)) dev = libxl__blktap_devpath(&gc, disk->pdev_path, disk->format); else { - if (disk->format != DISK_FORMAT_RAW) { + if (disk->format != LIBXL_DISK_FORMAT_RAW) { LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "tapdisk2 is required" " to open a vhd disk"); break; @@ -1152,8 +1153,8 @@ char * libxl_device_disk_local_attach(li } } break; - } else if (disk->format == DISK_FORMAT_QCOW || - disk->format == DISK_FORMAT_QCOW2) { + } else if (disk->format == LIBXL_DISK_FORMAT_QCOW || + disk->format == LIBXL_DISK_FORMAT_QCOW2) { LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "cannot locally attach a qcow or qcow2 disk image"); break; } else { @@ -1161,8 +1162,8 @@ char * libxl_device_disk_local_attach(li "type: %d", disk->backend); break; } - case DISK_BACKEND_QDISK: - if (disk->format != DISK_FORMAT_RAW) { + case LIBXL_DISK_BACKEND_QDISK: + if (disk->format != LIBXL_DISK_FORMAT_RAW) { LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "cannot locally attach a qdisk " "image if the format is not raw"); break; @@ -1171,7 +1172,7 @@ char * libxl_device_disk_local_attach(li disk->pdev_path); dev = disk->pdev_path; break; - case DISK_BACKEND_UNKNOWN: + case LIBXL_DISK_BACKEND_UNKNOWN: default: LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "unrecognized disk backend " "type: %d", disk->backend); @@ -1222,7 +1223,7 @@ int libxl_device_nic_init(libxl_device_n if ( asprintf(&nic_info->script, "%s/vif-bridge", libxl_xen_script_dir_path()) < 0 ) return ERROR_FAIL; - nic_info->nictype = NICTYPE_IOEMU; + nic_info->nictype = LIBXL_NICTYPE_IOEMU; return 0; } @@ -1585,7 +1586,7 @@ static unsigned int libxl__append_disk_l pdisk->readwrite = 0; type = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/device-type", libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/%s/frontend", be_path, *dir)))); pdisk->is_cdrom = !strcmp(type, "cdrom"); - pdisk->format = DISK_FORMAT_UNKNOWN; + pdisk->format = LIBXL_DISK_FORMAT_UNKNOWN; } } @@ -1650,7 +1651,7 @@ int libxl_cdrom_insert(libxl_ctx *ctx, u if (!disk->pdev_path) { disk->pdev_path = strdup(""); - disk->format = DISK_FORMAT_EMPTY; + disk->format = LIBXL_DISK_FORMAT_EMPTY; } disks = libxl_device_disk_list(ctx, domid, &num); for (i = 0; i < num; i++) { @@ -2170,10 +2171,10 @@ int libxl_button_press(libxl_ctx *ctx, u int rc = -1; switch (button) { - case POWER_BUTTON: + case LIBXL_BUTTON_POWER: rc = xc_domain_send_trigger(ctx->xch, domid, XEN_DOMCTL_SENDTRIGGER_POWER, 0); break; - case SLEEP_BUTTON: + case LIBXL_BUTTON_SLEEP: rc = xc_domain_send_trigger(ctx->xch, domid, XEN_DOMCTL_SENDTRIGGER_SLEEP, 0); break; default: diff -r 2b4be83bdc1a -r 34f797bacb78 tools/libxl/libxl.h --- a/tools/libxl/libxl.h Wed Apr 20 17:13:06 2011 +0100 +++ b/tools/libxl/libxl.h Wed Apr 20 17:13:07 2011 +0100 @@ -162,8 +162,8 @@ typedef struct { void libxl_cpuarray_destroy(libxl_cpuarray *array); typedef enum { - XENFV = 1, - XENPV, + LIBXL_QEMU_MACHINE_TYPE_FV = 1, + LIBXL_QEMU_MACHINE_TYPE_PV, } libxl_qemu_machine_type; typedef enum libxl_device_model_version { @@ -184,24 +184,24 @@ typedef enum { } libxl_console_consback; typedef enum { - DISK_FORMAT_UNKNOWN = 0, - DISK_FORMAT_QCOW, - DISK_FORMAT_QCOW2, - DISK_FORMAT_VHD, - DISK_FORMAT_RAW, - DISK_FORMAT_EMPTY, + LIBXL_DISK_FORMAT_UNKNOWN = 0, + LIBXL_DISK_FORMAT_QCOW, + LIBXL_DISK_FORMAT_QCOW2, + LIBXL_DISK_FORMAT_VHD, + LIBXL_DISK_FORMAT_RAW, + LIBXL_DISK_FORMAT_EMPTY, } libxl_disk_format; typedef enum { - DISK_BACKEND_UNKNOWN = 0, - DISK_BACKEND_PHY, - DISK_BACKEND_TAP, - DISK_BACKEND_QDISK, + LIBXL_DISK_BACKEND_UNKNOWN = 0, + LIBXL_DISK_BACKEND_PHY, + LIBXL_DISK_BACKEND_TAP, + LIBXL_DISK_BACKEND_QDISK, } libxl_disk_backend; typedef enum { - NICTYPE_IOEMU = 1, - NICTYPE_VIF, + LIBXL_NICTYPE_IOEMU = 1, + LIBXL_NICTYPE_VIF, } libxl_nic_type; typedef struct { @@ -495,8 +495,8 @@ int libxl_userdata_retrieve(libxl_ctx *c */ typedef enum { - POWER_BUTTON, - SLEEP_BUTTON + LIBXL_BUTTON_POWER, + LIBXL_BUTTON_SLEEP } libxl_button; int libxl_button_press(libxl_ctx *ctx, uint32_t domid, libxl_button button); diff -r 2b4be83bdc1a -r 34f797bacb78 tools/libxl/libxl_device.c --- a/tools/libxl/libxl_device.c Wed Apr 20 17:13:06 2011 +0100 +++ b/tools/libxl/libxl_device.c Wed Apr 20 17:13:07 2011 +0100 @@ -121,11 +121,11 @@ out: char *libxl__device_disk_string_of_format(libxl_disk_format format) { switch (format) { - case DISK_FORMAT_QCOW: return "qcow"; - case DISK_FORMAT_QCOW2: return "qcow2"; - case DISK_FORMAT_VHD: return "vhd"; - case DISK_FORMAT_RAW: - case DISK_FORMAT_EMPTY: return "aio"; + case LIBXL_DISK_FORMAT_QCOW: return "qcow"; + case LIBXL_DISK_FORMAT_QCOW2: return "qcow2"; + case LIBXL_DISK_FORMAT_VHD: return "vhd"; + case LIBXL_DISK_FORMAT_RAW: + case LIBXL_DISK_FORMAT_EMPTY: return "aio"; default: return NULL; } } @@ -133,9 +133,9 @@ char *libxl__device_disk_string_of_forma char *libxl__device_disk_string_of_backend(libxl_disk_backend backend) { switch (backend) { - case DISK_BACKEND_QDISK: return "qdisk"; - case DISK_BACKEND_TAP: return "phy"; - case DISK_BACKEND_PHY: return "phy"; + case LIBXL_DISK_BACKEND_QDISK: return "qdisk"; + case LIBXL_DISK_BACKEND_TAP: return "phy"; + case LIBXL_DISK_BACKEND_PHY: return "phy"; default: return NULL; } } diff -r 2b4be83bdc1a -r 34f797bacb78 tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Wed Apr 20 17:13:06 2011 +0100 +++ b/tools/libxl/libxl_dm.c Wed Apr 20 17:13:07 2011 +0100 @@ -140,7 +140,7 @@ static char ** libxl__build_device_model if (info->serial) { flexarray_vappend(dm_args, "-serial", info->serial, NULL); } - if (info->type == XENFV) { + if (info->type == LIBXL_QEMU_MACHINE_TYPE_FV) { int ioemu_vifs = 0; if (info->videoram) { @@ -172,7 +172,7 @@ static char ** libxl__build_device_model flexarray_vappend(dm_args, "-vcpu_avail", libxl__sprintf(gc, "0x%x", info->vcpu_avail), NULL); } for (i = 0; i < num_vifs; i++) { - if (vifs[i].nictype == NICTYPE_IOEMU) { + if (vifs[i].nictype == LIBXL_NICTYPE_IOEMU) { char *smac = libxl__sprintf(gc, "%02x:%02x:%02x:%02x:%02x:%02x", vifs[i].mac[0], vifs[i].mac[1], vifs[i].mac[2], vifs[i].mac[3], vifs[i].mac[4], vifs[i].mac[5]); @@ -204,10 +204,14 @@ static char ** libxl__build_device_model for (i = 0; info->extra && info->extra[i] != NULL; i++) flexarray_append(dm_args, info->extra[i]); flexarray_append(dm_args, "-M"); - if (info->type == XENPV) + switch (info->type) { + case LIBXL_QEMU_MACHINE_TYPE_PV: flexarray_append(dm_args, "xenpv"); - else + break; + case LIBXL_QEMU_MACHINE_TYPE_FV: flexarray_append(dm_args, "xenfv"); + break; + } flexarray_append(dm_args, NULL); return (char **) flexarray_contents(dm_args); } @@ -215,11 +219,11 @@ static char ** libxl__build_device_model static const char *qemu_disk_format_string(libxl_disk_format format) { switch (format) { - case DISK_FORMAT_QCOW: return "qcow"; - case DISK_FORMAT_QCOW2: return "qcow2"; - case DISK_FORMAT_VHD: return "vpc"; - case DISK_FORMAT_RAW: return "raw"; - case DISK_FORMAT_EMPTY: return NULL; + case LIBXL_DISK_FORMAT_QCOW: return "qcow"; + case LIBXL_DISK_FORMAT_QCOW2: return "qcow2"; + case LIBXL_DISK_FORMAT_VHD: return "vpc"; + case LIBXL_DISK_FORMAT_RAW: return "raw"; + case LIBXL_DISK_FORMAT_EMPTY: return NULL; default: return NULL; } } @@ -241,7 +245,7 @@ static char ** libxl__build_device_model flexarray_vappend(dm_args, dm, "-xen-domid", libxl__sprintf(gc, "%d", info->domid), NULL); - if (info->type == XENPV) { + if (info->type == LIBXL_QEMU_MACHINE_TYPE_PV) { flexarray_append(dm_args, "-xen-attach"); } @@ -279,7 +283,7 @@ static char ** libxl__build_device_model flexarray_append(dm_args, "-sdl"); } - if (info->type == XENPV && !info->nographic) { + if (info->type == LIBXL_QEMU_MACHINE_TYPE_PV && !info->nographic) { flexarray_vappend(dm_args, "-vga", "xenfb", NULL); } @@ -292,7 +296,7 @@ static char ** libxl__build_device_model if (info->serial) { flexarray_vappend(dm_args, "-serial", info->serial, NULL); } - if (info->type == XENFV) { + if (info->type == LIBXL_QEMU_MACHINE_TYPE_FV) { int ioemu_vifs = 0; if (info->stdvga) { @@ -322,7 +326,7 @@ static char ** libxl__build_device_model flexarray_append(dm_args, libxl__sprintf(gc, "%d", info->vcpus)); } for (i = 0; i < num_vifs; i++) { - if (vifs[i].nictype == NICTYPE_IOEMU) { + if (vifs[i].nictype == LIBXL_NICTYPE_IOEMU) { char *smac = libxl__sprintf(gc, "%02x:%02x:%02x:%02x:%02x:%02x", vifs[i].mac[0], vifs[i].mac[1], vifs[i].mac[2], vifs[i].mac[3], vifs[i].mac[4], vifs[i].mac[5]); @@ -357,16 +361,20 @@ static char ** libxl__build_device_model for (i = 0; info->extra && info->extra[i] != NULL; i++) flexarray_append(dm_args, info->extra[i]); flexarray_append(dm_args, "-M"); - if (info->type == XENPV) + switch (info->type) { + case LIBXL_QEMU_MACHINE_TYPE_PV: flexarray_append(dm_args, "xenpv"); - else + break; + case LIBXL_QEMU_MACHINE_TYPE_FV: flexarray_append(dm_args, "xenfv"); + break; + } /* RAM Size */ flexarray_append(dm_args, "-m"); flexarray_append(dm_args, libxl__sprintf(gc, "%d", info->target_ram)); - if (info->type == XENFV) { + if (info->type == LIBXL_QEMU_MACHINE_TYPE_FV) { for (i; i < num_disks; i++) { int disk, part; int dev_number @@ -381,7 +389,7 @@ static char ** libxl__build_device_model } if (disks[i].is_cdrom) { - if (disks[i].format == DISK_FORMAT_EMPTY) + if (disks[i].format == LIBXL_DISK_FORMAT_EMPTY) drive = libxl__sprintf (gc, "if=ide,index=%d,media=cdrom", disk); else @@ -389,7 +397,7 @@ static char ** libxl__build_device_model (gc, "file=%s,if=ide,index=%d,media=cdrom,format=%s", disks[i].pdev_path, disk, format); } else { - if (disks[i].format == DISK_FORMAT_EMPTY) { + if (disks[i].format == LIBXL_DISK_FORMAT_EMPTY) { LIBXL__LOG(ctx, LIBXL__LOG_WARNING, "cannot support" " empty disk format for %s", disks[i].vdev); continue; @@ -921,7 +929,7 @@ static int libxl__build_xenpv_qemu_args( info->dom_name = libxl_domid_to_name(ctx, domid); info->device_model_version = LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL; info->device_model = NULL; - info->type = XENPV; + info->type = LIBXL_QEMU_MACHINE_TYPE_PV; return 0; } @@ -953,7 +961,7 @@ int libxl__need_xenpv_qemu(libxl__gc *gc int blktap_enabled = -1; for (i = 0; i < nr_disks; i++) { switch (disks[i].backend) { - case DISK_BACKEND_TAP: + case LIBXL_DISK_BACKEND_TAP: if (blktap_enabled == -1) blktap_enabled = libxl__blktap_enabled(gc); if (!blktap_enabled) { @@ -962,12 +970,12 @@ int libxl__need_xenpv_qemu(libxl__gc *gc } break; - case DISK_BACKEND_QDISK: + case LIBXL_DISK_BACKEND_QDISK: ret = 1; goto out; - case DISK_BACKEND_PHY: - case DISK_BACKEND_UNKNOWN: + case LIBXL_DISK_BACKEND_PHY: + case LIBXL_DISK_BACKEND_UNKNOWN: break; } } diff -r 2b4be83bdc1a -r 34f797bacb78 tools/libxl/libxl_utils.c --- a/tools/libxl/libxl_utils.c Wed Apr 20 17:13:06 2011 +0100 +++ b/tools/libxl/libxl_utils.c Wed Apr 20 17:13:07 2011 +0100 @@ -283,9 +283,9 @@ int libxl_string_to_backend(libxl_ctx *c int rc = 0; if (!strcmp(s, "phy")) { - *backend = DISK_BACKEND_PHY; + *backend = LIBXL_DISK_BACKEND_PHY; } else if (!strcmp(s, "file")) { - *backend = DISK_BACKEND_TAP; + *backend = LIBXL_DISK_BACKEND_TAP; } else if (!strcmp(s, "tap")) { p = strchr(s, '':''); if (!p) { @@ -294,11 +294,11 @@ int libxl_string_to_backend(libxl_ctx *c } p++; if (!strcmp(p, "vhd")) { - *backend = DISK_BACKEND_TAP; + *backend = LIBXL_DISK_BACKEND_TAP; } else if (!strcmp(p, "qcow")) { - *backend = DISK_BACKEND_QDISK; + *backend = LIBXL_DISK_BACKEND_QDISK; } else if (!strcmp(p, "qcow2")) { - *backend = DISK_BACKEND_QDISK; + *backend = LIBXL_DISK_BACKEND_QDISK; } } out: diff -r 2b4be83bdc1a -r 34f797bacb78 tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Wed Apr 20 17:13:06 2011 +0100 +++ b/tools/libxl/xl_cmdimpl.c Wed Apr 20 17:13:07 2011 +0100 @@ -481,12 +481,12 @@ static int parse_disk_config(libxl_devic *p = ''\0''; if ( !strcmp(tok, "phy") ) { state = DSTATE_PHYSPATH; - disk->format = DISK_FORMAT_RAW; - disk->backend = DISK_BACKEND_PHY; + disk->format = LIBXL_DISK_FORMAT_RAW; + disk->backend = LIBXL_DISK_BACKEND_PHY; }else if ( !strcmp(tok, "file") ) { state = DSTATE_PHYSPATH; - disk->format = DISK_FORMAT_RAW; - disk->backend = DISK_BACKEND_TAP; + disk->format = LIBXL_DISK_FORMAT_RAW; + disk->backend = LIBXL_DISK_BACKEND_TAP; }else if ((!strcmp(tok, "tap")) || (!strcmp(tok, "tap2"))) { state = DSTATE_TAP; @@ -497,16 +497,16 @@ static int parse_disk_config(libxl_devic tok = p + 1; } else if (*p == '','') { state = DSTATE_VIRTPATH; - disk->format = DISK_FORMAT_EMPTY; - disk->backend = DISK_BACKEND_TAP; + disk->format = LIBXL_DISK_FORMAT_EMPTY; + disk->backend = LIBXL_DISK_BACKEND_TAP; disk->pdev_path = strdup(""); tok = p + 1; } break; case DSTATE_TAP: if (*p == '','') { - disk->format = DISK_FORMAT_RAW; - disk->backend = DISK_BACKEND_TAP; + disk->format = LIBXL_DISK_FORMAT_RAW; + disk->backend = LIBXL_DISK_BACKEND_TAP; state = DSTATE_PHYSPATH; } else if ( *p == '':'' ) { *p = ''\0''; @@ -515,17 +515,17 @@ static int parse_disk_config(libxl_devic break; } if (!strcmp(tok, "vhd")) { - disk->format = DISK_FORMAT_VHD; - disk->backend = DISK_BACKEND_TAP; + disk->format = LIBXL_DISK_FORMAT_VHD; + disk->backend = LIBXL_DISK_BACKEND_TAP; }else if ( !strcmp(tok, "qcow") ) { - disk->format = DISK_FORMAT_QCOW; - disk->backend = DISK_BACKEND_QDISK; + disk->format = LIBXL_DISK_FORMAT_QCOW; + disk->backend = LIBXL_DISK_BACKEND_QDISK; }else if ( !strcmp(tok, "qcow2") ) { - disk->format = DISK_FORMAT_QCOW2; - disk->backend = DISK_BACKEND_QDISK; + disk->format = LIBXL_DISK_FORMAT_QCOW2; + disk->backend = LIBXL_DISK_BACKEND_QDISK; }else if (!strcmp(tok, "raw")) { - disk->format = DISK_FORMAT_RAW; - disk->backend = DISK_BACKEND_TAP; + disk->format = LIBXL_DISK_FORMAT_RAW; + disk->backend = LIBXL_DISK_BACKEND_TAP; } else { fprintf(stderr, "Unknown tapdisk type: %s\n", tok); @@ -874,9 +874,9 @@ static void parse_config_data(const char nic->bridge = strdup(p2 + 1); } else if (!strcmp(p, "type")) { if (!strcmp(p2 + 1, "ioemu")) - nic->nictype = NICTYPE_IOEMU; + nic->nictype = LIBXL_NICTYPE_IOEMU; else - nic->nictype = NICTYPE_VIF; + nic->nictype = LIBXL_NICTYPE_VIF; } else if (!strcmp(p, "ip")) { free(nic->ip); nic->ip = strdup(p2 + 1); @@ -1147,7 +1147,9 @@ skip_vfb: } } - dm_info->type = c_info->hvm ? XENFV : XENPV; + dm_info->type = c_info->hvm ? + LIBXL_QEMU_MACHINE_TYPE_FV : + LIBXL_QEMU_MACHINE_TYPE_PV; xlu_cfg_destroy(config); } @@ -3336,9 +3338,9 @@ static void button_press(const char *p, find_domain(p); if (!strcmp(b, "power")) { - button = POWER_BUTTON; + button = LIBXL_BUTTON_POWER; } else if (!strcmp(b, "sleep")) { - button = SLEEP_BUTTON; + button = LIBXL_BUTTON_SLEEP; } else { fprintf(stderr, "%s is an invalid button identifier\n", b); exit(2); @@ -4250,9 +4252,9 @@ int main_networkattach(int argc, char ** for (argv += optind+1, argc -= optind+1; argc > 0; ++argv, --argc) { if (!strncmp("type=", *argv, 5)) { if (!strncmp("vif", (*argv) + 5, 4)) { - nic.nictype = NICTYPE_VIF; + nic.nictype = LIBXL_NICTYPE_VIF; } else if (!strncmp("ioemu", (*argv) + 5, 5)) { - nic.nictype = NICTYPE_IOEMU; + nic.nictype = LIBXL_NICTYPE_IOEMU; } else { fprintf(stderr, "Invalid parameter `type''.\n"); return 1; @@ -4421,22 +4423,22 @@ int main_blockattach(int argc, char **ar tok = strtok(argv[optind+1], ":"); if (!strcmp(tok, "phy")) { - disk.backend = DISK_BACKEND_PHY; + disk.backend = LIBXL_DISK_BACKEND_PHY; } else if (!strcmp(tok, "file")) { - disk.backend = DISK_BACKEND_TAP; + disk.backend = LIBXL_DISK_BACKEND_TAP; } else if (!strcmp(tok, "tap")) { tok = strtok(NULL, ":"); if (!strcmp(tok, "aio")) { - disk.backend = DISK_BACKEND_TAP; + disk.backend = LIBXL_DISK_BACKEND_TAP; } else if (!strcmp(tok, "vhd")) { - disk.format = DISK_FORMAT_VHD; - disk.backend = DISK_BACKEND_TAP; + disk.format = LIBXL_DISK_FORMAT_VHD; + disk.backend = LIBXL_DISK_BACKEND_TAP; } else if (!strcmp(tok, "qcow")) { - disk.format = DISK_FORMAT_QCOW; - disk.backend = DISK_BACKEND_QDISK; + disk.format = LIBXL_DISK_FORMAT_QCOW; + disk.backend = LIBXL_DISK_BACKEND_QDISK; } else if (!strcmp(tok, "qcow2")) { - disk.format = DISK_FORMAT_QCOW2; - disk.backend = DISK_BACKEND_QDISK; + disk.format = LIBXL_DISK_FORMAT_QCOW2; + disk.backend = LIBXL_DISK_BACKEND_QDISK; } else { fprintf(stderr, "Error: `%s'' is not a valid disk image.\n", tok); return 1; diff -r 2b4be83bdc1a -r 34f797bacb78 tools/ocaml/libs/xl/xl_stubs.c --- a/tools/ocaml/libs/xl/xl_stubs.c Wed Apr 20 17:13:06 2011 +0100 +++ b/tools/ocaml/libs/xl/xl_stubs.c Wed Apr 20 17:13:07 2011 +0100 @@ -224,7 +224,7 @@ static int device_nic_val(caml_gc *gc, l c_val->bridge = dup_String_val(gc, Field(v, 5)); c_val->ifname = dup_String_val(gc, Field(v, 6)); c_val->script = dup_String_val(gc, Field(v, 7)); - c_val->nictype = (Int_val(Field(v, 8))) + NICTYPE_IOEMU; + c_val->nictype = (Int_val(Field(v, 8))) + LIBXL_NICTYPE_IOEMU; out: CAMLreturn(ret); @@ -610,7 +610,7 @@ value stub_xl_button_press(value domid, INIT_STRUCT(); INIT_CTX(); - ret = libxl_button_press(ctx, Int_val(domid), Int_val(button) + POWER_BUTTON); + ret = libxl_button_press(ctx, Int_val(domid), Int_val(button) + LIBXL_BUTTON_POWER); if (ret != 0) failwith_xl("button_press", &lg); FREE_CTX(); diff -r 2b4be83bdc1a -r 34f797bacb78 tools/python/xen/lowlevel/xl/xl.c --- a/tools/python/xen/lowlevel/xl/xl.c Wed Apr 20 17:13:06 2011 +0100 +++ b/tools/python/xen/lowlevel/xl/xl.c Wed Apr 20 17:13:07 2011 +0100 @@ -769,8 +769,8 @@ PyMODINIT_FUNC initxl(void) _INT_CONST(m, SHUTDOWN_crash); _INT_CONST(m, SHUTDOWN_watchdog); - _INT_CONST(m, XENFV); - _INT_CONST(m, XENPV); + _INT_CONST_LIBXL(m, QEMU_MACHINE_TYPE_FV); + _INT_CONST_LIBXL(m, QEMU_MACHINE_TYPE_PV); _INT_CONST_LIBXL(m, CONSTYPE_SERIAL); _INT_CONST_LIBXL(m, CONSTYPE_PV); @@ -778,26 +778,26 @@ PyMODINIT_FUNC initxl(void) _INT_CONST_LIBXL(m, CONSBACK_XENCONSOLED); _INT_CONST_LIBXL(m, CONSBACK_IOEMU); - _INT_CONST(m, DISK_FORMAT_UNKNOWN); - _INT_CONST(m, DISK_FORMAT_QCOW); - _INT_CONST(m, DISK_FORMAT_QCOW2); - _INT_CONST(m, DISK_FORMAT_VHD); - _INT_CONST(m, DISK_FORMAT_RAW); - _INT_CONST(m, DISK_FORMAT_EMPTY); + _INT_CONST_LIBXL(m, DISK_FORMAT_UNKNOWN); + _INT_CONST_LIBXL(m, DISK_FORMAT_QCOW); + _INT_CONST_LIBXL(m, DISK_FORMAT_QCOW2); + _INT_CONST_LIBXL(m, DISK_FORMAT_VHD); + _INT_CONST_LIBXL(m, DISK_FORMAT_RAW); + _INT_CONST_LIBXL(m, DISK_FORMAT_EMPTY); - _INT_CONST(m, DISK_BACKEND_UNKNOWN); - _INT_CONST(m, DISK_BACKEND_PHY); - _INT_CONST(m, DISK_BACKEND_TAP); - _INT_CONST(m, DISK_BACKEND_QDISK); + _INT_CONST_LIBXL(m, DISK_BACKEND_UNKNOWN); + _INT_CONST_LIBXL(m, DISK_BACKEND_PHY); + _INT_CONST_LIBXL(m, DISK_BACKEND_TAP); + _INT_CONST_LIBXL(m, DISK_BACKEND_QDISK); - _INT_CONST(m, NICTYPE_IOEMU); - _INT_CONST(m, NICTYPE_VIF); + _INT_CONST_LIBXL(m, NICTYPE_IOEMU); + _INT_CONST_LIBXL(m, NICTYPE_VIF); _INT_CONST_LIBXL(m, EVENT_DOMAIN_DEATH); _INT_CONST_LIBXL(m, EVENT_DISK_EJECT); - _INT_CONST(m, POWER_BUTTON); - _INT_CONST(m, SLEEP_BUTTON); + _INT_CONST_LIBXL(m, BUTTON_POWER); + _INT_CONST_LIBXL(m, BUTTON_SLEEP); genwrap__init(m); } _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-20 16:15 UTC
[Xen-devel] [PATCH 06 of 32] tools: libxl: generalize libxl_qemu_machine_type into libxl_domain_type
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1303315987 -3600 # Node ID 32ce16a8fd3aabee03118b965f0af1e6eb9b8d84 # Parent 34f797bacb7886641aa6f340356b915433d4a73b tools: libxl: generalize libxl_qemu_machine_type into libxl_domain_type The FV/PV distinction is not particular to the device model, although that remains the only user for now. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 34f797bacb78 -r 32ce16a8fd3a tools/libxl/libxl.h --- a/tools/libxl/libxl.h Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/libxl/libxl.h Wed Apr 20 17:13:07 2011 +0100 @@ -162,9 +162,9 @@ typedef struct { void libxl_cpuarray_destroy(libxl_cpuarray *array); typedef enum { - LIBXL_QEMU_MACHINE_TYPE_FV = 1, - LIBXL_QEMU_MACHINE_TYPE_PV, -} libxl_qemu_machine_type; + LIBXL_DOMAIN_TYPE_FV = 1, + LIBXL_DOMAIN_TYPE_PV, +} libxl_domain_type; typedef enum libxl_device_model_version { /* Historical qemu-xen device model (qemu-dm) */ diff -r 34f797bacb78 -r 32ce16a8fd3a tools/libxl/libxl.idl --- a/tools/libxl/libxl.idl Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/libxl/libxl.idl Wed Apr 20 17:13:07 2011 +0100 @@ -8,7 +8,7 @@ libxl_uuid = Builtin("uuid") libxl_mac = Builtin("mac") libxl_cpumap = Builtin("cpumap", destructor_fn="libxl_cpumap_destroy", passby=PASS_BY_REFERENCE) libxl_cpuarray = Builtin("cpuarray", destructor_fn="libxl_cpuarray_destroy", passby=PASS_BY_REFERENCE) -libxl_qemu_machine_type = Number("qemu_machine_type", namespace="libxl_") +libxl_domain_type = Number("domain_type", namespace="libxl_") libxl_device_model_version = Number("device_model_version", namespace="libxl_") libxl_console_consback = Number("console_consback", namespace="libxl_") libxl_console_constype = Number("console_constype", namespace="libxl_") @@ -145,7 +145,7 @@ libxl_device_model_info = Struct("device ("device_model_stubdomain", bool), ("device_model", string, False, "if you set this you must set device_model_version too"), ("saved_state", string), - ("type", libxl_qemu_machine_type), + ("type", libxl_domain_type), ("target_ram", uint32), ("videoram", integer, False, "size of the videoram in MB"), ("stdvga", bool, False, "stdvga enabled or disabled"), diff -r 34f797bacb78 -r 32ce16a8fd3a tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/libxl/libxl_dm.c Wed Apr 20 17:13:07 2011 +0100 @@ -140,7 +140,7 @@ static char ** libxl__build_device_model if (info->serial) { flexarray_vappend(dm_args, "-serial", info->serial, NULL); } - if (info->type == LIBXL_QEMU_MACHINE_TYPE_FV) { + if (info->type == LIBXL_DOMAIN_TYPE_FV) { int ioemu_vifs = 0; if (info->videoram) { @@ -205,10 +205,10 @@ static char ** libxl__build_device_model flexarray_append(dm_args, info->extra[i]); flexarray_append(dm_args, "-M"); switch (info->type) { - case LIBXL_QEMU_MACHINE_TYPE_PV: + case LIBXL_DOMAIN_TYPE_PV: flexarray_append(dm_args, "xenpv"); break; - case LIBXL_QEMU_MACHINE_TYPE_FV: + case LIBXL_DOMAIN_TYPE_FV: flexarray_append(dm_args, "xenfv"); break; } @@ -245,7 +245,7 @@ static char ** libxl__build_device_model flexarray_vappend(dm_args, dm, "-xen-domid", libxl__sprintf(gc, "%d", info->domid), NULL); - if (info->type == LIBXL_QEMU_MACHINE_TYPE_PV) { + if (info->type == LIBXL_DOMAIN_TYPE_PV) { flexarray_append(dm_args, "-xen-attach"); } @@ -283,7 +283,7 @@ static char ** libxl__build_device_model flexarray_append(dm_args, "-sdl"); } - if (info->type == LIBXL_QEMU_MACHINE_TYPE_PV && !info->nographic) { + if (info->type == LIBXL_DOMAIN_TYPE_PV && !info->nographic) { flexarray_vappend(dm_args, "-vga", "xenfb", NULL); } @@ -296,7 +296,7 @@ static char ** libxl__build_device_model if (info->serial) { flexarray_vappend(dm_args, "-serial", info->serial, NULL); } - if (info->type == LIBXL_QEMU_MACHINE_TYPE_FV) { + if (info->type == LIBXL_DOMAIN_TYPE_FV) { int ioemu_vifs = 0; if (info->stdvga) { @@ -362,10 +362,10 @@ static char ** libxl__build_device_model flexarray_append(dm_args, info->extra[i]); flexarray_append(dm_args, "-M"); switch (info->type) { - case LIBXL_QEMU_MACHINE_TYPE_PV: + case LIBXL_DOMAIN_TYPE_PV: flexarray_append(dm_args, "xenpv"); break; - case LIBXL_QEMU_MACHINE_TYPE_FV: + case LIBXL_DOMAIN_TYPE_FV: flexarray_append(dm_args, "xenfv"); break; } @@ -374,7 +374,7 @@ static char ** libxl__build_device_model flexarray_append(dm_args, "-m"); flexarray_append(dm_args, libxl__sprintf(gc, "%d", info->target_ram)); - if (info->type == LIBXL_QEMU_MACHINE_TYPE_FV) { + if (info->type == LIBXL_DOMAIN_TYPE_FV) { for (i; i < num_disks; i++) { int disk, part; int dev_number @@ -929,7 +929,7 @@ static int libxl__build_xenpv_qemu_args( info->dom_name = libxl_domid_to_name(ctx, domid); info->device_model_version = LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL; info->device_model = NULL; - info->type = LIBXL_QEMU_MACHINE_TYPE_PV; + info->type = LIBXL_DOMAIN_TYPE_PV; return 0; } diff -r 34f797bacb78 -r 32ce16a8fd3a tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/libxl/xl_cmdimpl.c Wed Apr 20 17:13:07 2011 +0100 @@ -1148,8 +1148,8 @@ skip_vfb: } dm_info->type = c_info->hvm ? - LIBXL_QEMU_MACHINE_TYPE_FV : - LIBXL_QEMU_MACHINE_TYPE_PV; + LIBXL_DOMAIN_TYPE_FV : + LIBXL_DOMAIN_TYPE_PV; xlu_cfg_destroy(config); } diff -r 34f797bacb78 -r 32ce16a8fd3a tools/python/xen/lowlevel/xl/xl.c --- a/tools/python/xen/lowlevel/xl/xl.c Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/python/xen/lowlevel/xl/xl.c Wed Apr 20 17:13:07 2011 +0100 @@ -769,8 +769,8 @@ PyMODINIT_FUNC initxl(void) _INT_CONST(m, SHUTDOWN_crash); _INT_CONST(m, SHUTDOWN_watchdog); - _INT_CONST_LIBXL(m, QEMU_MACHINE_TYPE_FV); - _INT_CONST_LIBXL(m, QEMU_MACHINE_TYPE_PV); + _INT_CONST_LIBXL(m, DOMAIN_TYPE_FV); + _INT_CONST_LIBXL(m, DOMAIN_TYPE_PV); _INT_CONST_LIBXL(m, CONSTYPE_SERIAL); _INT_CONST_LIBXL(m, CONSTYPE_PV); _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-20 16:15 UTC
[Xen-devel] [PATCH 07 of 32] tools: libxl: namespace enum values within their type
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1303315987 -3600 # Node ID de2e9214d8853529c82a02370ce99a0458a7a3eb # Parent 32ce16a8fd3aabee03118b965f0af1e6eb9b8d84 tools: libxl: namespace enum values within their type. In other words the values for an enum type libxl_foo always take the form LIBXL_FOO_VALUE. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 32ce16a8fd3a -r de2e9214d885 tools/libxl/libxl.c --- a/tools/libxl/libxl.c Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/libxl/libxl.c Wed Apr 20 17:13:07 2011 +0100 @@ -592,7 +592,7 @@ int libxl_get_wait_fd(libxl_ctx *ctx, in int libxl_wait_for_domain_death(libxl_ctx *ctx, uint32_t domid, libxl_waiter *waiter) { waiter->path = strdup("@releaseDomain"); - if (asprintf(&(waiter->token), "%d", LIBXL_EVENT_DOMAIN_DEATH) < 0) + if (asprintf(&(waiter->token), "%d", LIBXL_EVENT_TYPE_DOMAIN_DEATH) < 0) return -1; if (!xs_watch(ctx->xsh, waiter->path, waiter->token)) return -1; @@ -614,7 +614,7 @@ int libxl_wait_for_disk_ejects(libxl_ctx libxl__device_disk_dev_number(disks[i].vdev, NULL, NULL)) < 0) goto out; - if (asprintf(&(waiter[i].token), "%d", LIBXL_EVENT_DISK_EJECT) < 0) + if (asprintf(&(waiter[i].token), "%d", LIBXL_EVENT_TYPE_DISK_EJECT) < 0) goto out; xs_watch(ctx->xsh, waiter[i].path, waiter[i].token); } @@ -782,7 +782,7 @@ out: return 0; } -int libxl_console_exec(libxl_ctx *ctx, uint32_t domid, int cons_num, libxl_console_constype type) +int libxl_console_exec(libxl_ctx *ctx, uint32_t domid, int cons_num, libxl_console_type type) { libxl__gc gc = LIBXL_INIT_GC(ctx); char *p = libxl__sprintf(&gc, "%s/xenconsole", libxl_private_bindir_path()); @@ -791,10 +791,10 @@ int libxl_console_exec(libxl_ctx *ctx, u char *cons_type_s; switch (type) { - case LIBXL_CONSTYPE_PV: + case LIBXL_CONSOLE_TYPE_PV: cons_type_s = "pv"; break; - case LIBXL_CONSTYPE_SERIAL: + case LIBXL_CONSOLE_TYPE_SERIAL: cons_type_s = "serial"; break; default: @@ -815,12 +815,12 @@ int libxl_primary_console_exec(libxl_ctx int rc; if (stubdomid) rc = libxl_console_exec(ctx, stubdomid, - STUBDOM_CONSOLE_SERIAL, LIBXL_CONSTYPE_PV); + STUBDOM_CONSOLE_SERIAL, LIBXL_CONSOLE_TYPE_PV); else { if (libxl__domain_is_hvm(&gc, domid_vm)) - rc = libxl_console_exec(ctx, domid_vm, 0, LIBXL_CONSTYPE_SERIAL); + rc = libxl_console_exec(ctx, domid_vm, 0, LIBXL_CONSOLE_TYPE_SERIAL); else - rc = libxl_console_exec(ctx, domid_vm, 0, LIBXL_CONSTYPE_PV); + rc = libxl_console_exec(ctx, domid_vm, 0, LIBXL_CONSOLE_TYPE_PV); } libxl__free_all(&gc); return rc; @@ -1223,7 +1223,7 @@ int libxl_device_nic_init(libxl_device_n if ( asprintf(&nic_info->script, "%s/vif-bridge", libxl_xen_script_dir_path()) < 0 ) return ERROR_FAIL; - nic_info->nictype = LIBXL_NICTYPE_IOEMU; + nic_info->nictype = LIBXL_NIC_TYPE_IOEMU; return 0; } @@ -1441,7 +1441,7 @@ int libxl_device_console_add(libxl_ctx * flexarray_append(front, "limit"); flexarray_append(front, libxl__sprintf(&gc, "%d", LIBXL_XENCONSOLE_LIMIT)); flexarray_append(front, "type"); - if (console->consback == LIBXL_CONSBACK_XENCONSOLED) + if (console->consback == LIBXL_CONSOLE_BACKEND_XENCONSOLED) flexarray_append(front, "xenconsoled"); else flexarray_append(front, "ioemu"); diff -r 32ce16a8fd3a -r de2e9214d885 tools/libxl/libxl.h --- a/tools/libxl/libxl.h Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/libxl/libxl.h Wed Apr 20 17:13:07 2011 +0100 @@ -174,14 +174,14 @@ typedef enum libxl_device_model_version } libxl_device_model_version; typedef enum { - LIBXL_CONSTYPE_SERIAL = 1, - LIBXL_CONSTYPE_PV, -} libxl_console_constype; + LIBXL_CONSOLE_TYPE_SERIAL = 1, + LIBXL_CONSOLE_TYPE_PV, +} libxl_console_type; typedef enum { - LIBXL_CONSBACK_XENCONSOLED, - LIBXL_CONSBACK_IOEMU, -} libxl_console_consback; + LIBXL_CONSOLE_BACKEND_XENCONSOLED, + LIBXL_CONSOLE_BACKEND_IOEMU, +} libxl_console_backend; typedef enum { LIBXL_DISK_FORMAT_UNKNOWN = 0, @@ -200,8 +200,8 @@ typedef enum { } libxl_disk_backend; typedef enum { - LIBXL_NICTYPE_IOEMU = 1, - LIBXL_NICTYPE_VIF, + LIBXL_NIC_TYPE_IOEMU = 1, + LIBXL_NIC_TYPE_VIF, } libxl_nic_type; typedef struct { @@ -253,15 +253,15 @@ enum { #define LIBXL_VERSION 0 typedef enum libxl_action_on_shutdown { - LIBXL_ACTION_DESTROY, + LIBXL_ACTION_ON_SHUTDOWN_DESTROY, - LIBXL_ACTION_RESTART, - LIBXL_ACTION_RESTART_RENAME, + LIBXL_ACTION_ON_SHUTDOWN_RESTART, + LIBXL_ACTION_ON_SHUTDOWN_RESTART_RENAME, - LIBXL_ACTION_PRESERVE, + LIBXL_ACTION_ON_SHUTDOWN_PRESERVE, - LIBXL_ACTION_COREDUMP_DESTROY, - LIBXL_ACTION_COREDUMP_RESTART, + LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_DESTROY, + LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_RESTART, } libxl_action_on_shutdown; typedef struct { @@ -328,8 +328,8 @@ int libxl_run_bootloader(libxl_ctx *ctx, /* events handling */ typedef enum { - LIBXL_EVENT_DOMAIN_DEATH, - LIBXL_EVENT_DISK_EJECT, + LIBXL_EVENT_TYPE_DOMAIN_DEATH, + LIBXL_EVENT_TYPE_DISK_EJECT, } libxl_event_type; typedef struct { @@ -402,7 +402,7 @@ int libxl_wait_for_free_memory(libxl_ctx int libxl_wait_for_memory_target(libxl_ctx *ctx, uint32_t domid, int wait_secs); int libxl_vncviewer_exec(libxl_ctx *ctx, uint32_t domid, int autopass); -int libxl_console_exec(libxl_ctx *ctx, uint32_t domid, int cons_num, libxl_console_constype type); +int libxl_console_exec(libxl_ctx *ctx, uint32_t domid, int cons_num, libxl_console_type type); /* libxl_primary_console_exec finds the domid and console number * corresponding to the primary console of the given vm, then calls * libxl_console_exec with the right arguments (domid might be different diff -r 32ce16a8fd3a -r de2e9214d885 tools/libxl/libxl.idl --- a/tools/libxl/libxl.idl Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/libxl/libxl.idl Wed Apr 20 17:13:07 2011 +0100 @@ -10,8 +10,8 @@ libxl_cpumap = Builtin("cpumap", destruc libxl_cpuarray = Builtin("cpuarray", destructor_fn="libxl_cpuarray_destroy", passby=PASS_BY_REFERENCE) libxl_domain_type = Number("domain_type", namespace="libxl_") libxl_device_model_version = Number("device_model_version", namespace="libxl_") -libxl_console_consback = Number("console_consback", namespace="libxl_") -libxl_console_constype = Number("console_constype", namespace="libxl_") +libxl_console_backend = Number("console_backend", namespace="libxl_") +libxl_console_type = Number("console_type", namespace="libxl_") libxl_disk_format = Number("disk_format", namespace="libxl_") libxl_disk_backend = Number("disk_backend", namespace="libxl_") libxl_nic_type = Number("nic_type", namespace="libxl_") @@ -198,7 +198,7 @@ libxl_device_vkb = Struct("device_vkb", libxl_device_console = Struct("device_console", [ ("backend_domid", uint32), ("devid", integer), - ("consback", libxl_console_consback), + ("consback", libxl_console_backend), ("build_state", Reference(libxl_domain_build_state), True), ("output", string), ]) diff -r 32ce16a8fd3a -r de2e9214d885 tools/libxl/libxl_create.c --- a/tools/libxl/libxl_create.c Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/libxl/libxl_create.c Wed Apr 20 17:13:07 2011 +0100 @@ -137,7 +137,7 @@ static int init_console_info(libxl_devic { memset(console, 0x00, sizeof(libxl_device_console)); console->devid = dev_num; - console->consback = LIBXL_CONSBACK_XENCONSOLED; + console->consback = LIBXL_CONSOLE_BACKEND_XENCONSOLED; console->output = strdup("pty"); if ( NULL == console->output ) return ERROR_NOMEM; @@ -498,7 +498,7 @@ static int do_domain_create(libxl__gc *g d_config->num_disks, &d_config->disks[0]); if (need_qemu) - console.consback = LIBXL_CONSBACK_IOEMU; + console.consback = LIBXL_CONSOLE_BACKEND_IOEMU; libxl_device_console_add(ctx, domid, &console); libxl_device_console_destroy(&console); diff -r 32ce16a8fd3a -r de2e9214d885 tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/libxl/libxl_dm.c Wed Apr 20 17:13:07 2011 +0100 @@ -172,7 +172,7 @@ static char ** libxl__build_device_model flexarray_vappend(dm_args, "-vcpu_avail", libxl__sprintf(gc, "0x%x", info->vcpu_avail), NULL); } for (i = 0; i < num_vifs; i++) { - if (vifs[i].nictype == LIBXL_NICTYPE_IOEMU) { + if (vifs[i].nictype == LIBXL_NIC_TYPE_IOEMU) { char *smac = libxl__sprintf(gc, "%02x:%02x:%02x:%02x:%02x:%02x", vifs[i].mac[0], vifs[i].mac[1], vifs[i].mac[2], vifs[i].mac[3], vifs[i].mac[4], vifs[i].mac[5]); @@ -326,7 +326,7 @@ static char ** libxl__build_device_model flexarray_append(dm_args, libxl__sprintf(gc, "%d", info->vcpus)); } for (i = 0; i < num_vifs; i++) { - if (vifs[i].nictype == LIBXL_NICTYPE_IOEMU) { + if (vifs[i].nictype == LIBXL_NIC_TYPE_IOEMU) { char *smac = libxl__sprintf(gc, "%02x:%02x:%02x:%02x:%02x:%02x", vifs[i].mac[0], vifs[i].mac[1], vifs[i].mac[2], vifs[i].mac[3], vifs[i].mac[4], vifs[i].mac[5]); @@ -672,7 +672,7 @@ retry_transaction: for (i = 0; i < num_console; i++) { console[i].devid = i; - console[i].consback = LIBXL_CONSBACK_IOEMU; + console[i].consback = LIBXL_CONSOLE_BACKEND_IOEMU; /* STUBDOM_CONSOLE_LOGGING (console 0) is for minios logging * STUBDOM_CONSOLE_SAVE (console 1) is for writing the save file * STUBDOM_CONSOLE_RESTORE (console 2) is for reading the save file @@ -946,7 +946,7 @@ int libxl__need_xenpv_qemu(libxl__gc *gc } for (i = 0; i < nr_consoles; i++) { - if (consoles[i].consback == LIBXL_CONSBACK_IOEMU) { + if (consoles[i].consback == LIBXL_CONSOLE_BACKEND_IOEMU) { ret = 1; goto out; } diff -r 32ce16a8fd3a -r de2e9214d885 tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/libxl/xl_cmdimpl.c Wed Apr 20 17:13:07 2011 +0100 @@ -101,15 +101,15 @@ struct save_file_header { static const char *action_on_shutdown_names[] = { - [LIBXL_ACTION_DESTROY] = "destroy", - - [LIBXL_ACTION_RESTART] = "restart", - [LIBXL_ACTION_RESTART_RENAME] = "rename-restart", - - [LIBXL_ACTION_PRESERVE] = "preserve", - - [LIBXL_ACTION_COREDUMP_DESTROY] = "coredump-destroy", - [LIBXL_ACTION_COREDUMP_RESTART] = "coredump-restart", + [LIBXL_ACTION_ON_SHUTDOWN_DESTROY] = "destroy", + + [LIBXL_ACTION_ON_SHUTDOWN_RESTART] = "restart", + [LIBXL_ACTION_ON_SHUTDOWN_RESTART_RENAME] = "rename-restart", + + [LIBXL_ACTION_ON_SHUTDOWN_PRESERVE] = "preserve", + + [LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_DESTROY] = "coredump-destroy", + [LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_RESTART] = "coredump-restart", }; /* Optional data, in order: @@ -874,9 +874,9 @@ static void parse_config_data(const char nic->bridge = strdup(p2 + 1); } else if (!strcmp(p, "type")) { if (!strcmp(p2 + 1, "ioemu")) - nic->nictype = LIBXL_NICTYPE_IOEMU; + nic->nictype = LIBXL_NIC_TYPE_IOEMU; else - nic->nictype = LIBXL_NICTYPE_VIF; + nic->nictype = LIBXL_NIC_TYPE_VIF; } else if (!strcmp(p, "ip")) { free(nic->ip); nic->ip = strdup(p2 + 1); @@ -1178,12 +1178,12 @@ static int handle_domain_death(libxl_ctx break; default: LOG("Unknown shutdown reason code %d. Destroying domain.", info->shutdown_reason); - action = LIBXL_ACTION_DESTROY; + action = LIBXL_ACTION_ON_SHUTDOWN_DESTROY; } LOG("Action for shutdown reason code %d is %s", info->shutdown_reason, action_on_shutdown_names[action]); - if (action == LIBXL_ACTION_COREDUMP_DESTROY || action == LIBXL_ACTION_COREDUMP_RESTART) { + if (action == LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_DESTROY || action == LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_RESTART) { char *corefile; int rc; @@ -1196,30 +1196,30 @@ static int handle_domain_death(libxl_ctx } /* No point crying over spilled milk, continue on failure. */ - if (action == LIBXL_ACTION_COREDUMP_DESTROY) - action = LIBXL_ACTION_DESTROY; + if (action == LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_DESTROY) + action = LIBXL_ACTION_ON_SHUTDOWN_DESTROY; else - action = LIBXL_ACTION_RESTART; + action = LIBXL_ACTION_ON_SHUTDOWN_RESTART; } switch (action) { - case LIBXL_ACTION_PRESERVE: + case LIBXL_ACTION_ON_SHUTDOWN_PRESERVE: break; - case LIBXL_ACTION_RESTART_RENAME: + case LIBXL_ACTION_ON_SHUTDOWN_RESTART_RENAME: restart = 2; break; - case LIBXL_ACTION_RESTART: + case LIBXL_ACTION_ON_SHUTDOWN_RESTART: restart = 1; /* fall-through */ - case LIBXL_ACTION_DESTROY: + case LIBXL_ACTION_ON_SHUTDOWN_DESTROY: LOG("Domain %d needs to be cleaned up: destroying the domain", domid); libxl_domain_destroy(ctx, domid, 0); break; - case LIBXL_ACTION_COREDUMP_DESTROY: - case LIBXL_ACTION_COREDUMP_RESTART: + case LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_DESTROY: + case LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_RESTART: /* Already handled these above. */ abort(); } @@ -1617,7 +1617,7 @@ start: continue; libxl_get_event(ctx, &event); switch (event.type) { - case LIBXL_EVENT_DOMAIN_DEATH: + case LIBXL_EVENT_TYPE_DOMAIN_DEATH: ret = libxl_event_get_domain_death_info(ctx, domid, &event, &info); if (ret < 0) { @@ -1675,7 +1675,7 @@ start: goto out; } break; - case LIBXL_EVENT_DISK_EJECT: + case LIBXL_EVENT_TYPE_DISK_EJECT: if (libxl_event_get_disk_eject_info(ctx, domid, &event, &disk)) { libxl_cdrom_insert(ctx, domid, &disk); libxl_device_disk_destroy(&disk); @@ -1943,7 +1943,7 @@ int main_cd_insert(int argc, char **argv int main_console(int argc, char **argv) { int opt = 0, num = 0; - libxl_console_constype type = 0; + libxl_console_type type = 0; while ((opt = getopt(argc, argv, "hn:t:")) != -1) { switch (opt) { @@ -1952,9 +1952,9 @@ int main_console(int argc, char **argv) return 0; case ''t'': if (!strcmp(optarg, "pv")) - type = LIBXL_CONSTYPE_PV; + type = LIBXL_CONSOLE_TYPE_PV; else if (!strcmp(optarg, "serial")) - type = LIBXL_CONSTYPE_SERIAL; + type = LIBXL_CONSOLE_TYPE_SERIAL; else { fprintf(stderr, "console type supported are: pv, serial\n"); return 2; @@ -2249,7 +2249,7 @@ static void shutdown_domain(const char * libxl_get_event(ctx, &event); - if (event.type == LIBXL_EVENT_DOMAIN_DEATH) { + if (event.type == LIBXL_EVENT_TYPE_DOMAIN_DEATH) { if (libxl_event_get_domain_death_info(ctx, domid, &event, &info) < 0) continue; @@ -4252,9 +4252,9 @@ int main_networkattach(int argc, char ** for (argv += optind+1, argc -= optind+1; argc > 0; ++argv, --argc) { if (!strncmp("type=", *argv, 5)) { if (!strncmp("vif", (*argv) + 5, 4)) { - nic.nictype = LIBXL_NICTYPE_VIF; + nic.nictype = LIBXL_NIC_TYPE_VIF; } else if (!strncmp("ioemu", (*argv) + 5, 5)) { - nic.nictype = LIBXL_NICTYPE_IOEMU; + nic.nictype = LIBXL_NIC_TYPE_IOEMU; } else { fprintf(stderr, "Invalid parameter `type''.\n"); return 1; diff -r 32ce16a8fd3a -r de2e9214d885 tools/ocaml/libs/xl/xl_stubs.c --- a/tools/ocaml/libs/xl/xl_stubs.c Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/ocaml/libs/xl/xl_stubs.c Wed Apr 20 17:13:07 2011 +0100 @@ -224,7 +224,7 @@ static int device_nic_val(caml_gc *gc, l c_val->bridge = dup_String_val(gc, Field(v, 5)); c_val->ifname = dup_String_val(gc, Field(v, 6)); c_val->script = dup_String_val(gc, Field(v, 7)); - c_val->nictype = (Int_val(Field(v, 8))) + LIBXL_NICTYPE_IOEMU; + c_val->nictype = (Int_val(Field(v, 8))) + LIBXL_NIC_TYPE_IOEMU; out: CAMLreturn(ret); @@ -236,7 +236,7 @@ static int device_console_val(caml_gc *g c_val->backend_domid = Int_val(Field(v, 0)); c_val->devid = Int_val(Field(v, 1)); - c_val->consback = (Int_val(Field(v, 2))) + LIBXL_CONSBACK_XENCONSOLED; + c_val->consback = (Int_val(Field(v, 2))) + LIBXL_CONSOLE_BACKEND_XENCONSOLED; CAMLreturn(0); } diff -r 32ce16a8fd3a -r de2e9214d885 tools/python/xen/lowlevel/xl/xl.c --- a/tools/python/xen/lowlevel/xl/xl.c Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/python/xen/lowlevel/xl/xl.c Wed Apr 20 17:13:07 2011 +0100 @@ -772,11 +772,11 @@ PyMODINIT_FUNC initxl(void) _INT_CONST_LIBXL(m, DOMAIN_TYPE_FV); _INT_CONST_LIBXL(m, DOMAIN_TYPE_PV); - _INT_CONST_LIBXL(m, CONSTYPE_SERIAL); - _INT_CONST_LIBXL(m, CONSTYPE_PV); + _INT_CONST_LIBXL(m, CONSOLE_TYPE_SERIAL); + _INT_CONST_LIBXL(m, CONSOLE_TYPE_PV); - _INT_CONST_LIBXL(m, CONSBACK_XENCONSOLED); - _INT_CONST_LIBXL(m, CONSBACK_IOEMU); + _INT_CONST_LIBXL(m, CONSOLE_BACKEND_XENCONSOLED); + _INT_CONST_LIBXL(m, CONSOLE_BACKEND_IOEMU); _INT_CONST_LIBXL(m, DISK_FORMAT_UNKNOWN); _INT_CONST_LIBXL(m, DISK_FORMAT_QCOW); @@ -790,11 +790,11 @@ PyMODINIT_FUNC initxl(void) _INT_CONST_LIBXL(m, DISK_BACKEND_TAP); _INT_CONST_LIBXL(m, DISK_BACKEND_QDISK); - _INT_CONST_LIBXL(m, NICTYPE_IOEMU); - _INT_CONST_LIBXL(m, NICTYPE_VIF); + _INT_CONST_LIBXL(m, NIC_TYPE_IOEMU); + _INT_CONST_LIBXL(m, NIC_TYPE_VIF); - _INT_CONST_LIBXL(m, EVENT_DOMAIN_DEATH); - _INT_CONST_LIBXL(m, EVENT_DISK_EJECT); + _INT_CONST_LIBXL(m, EVENT_TYPE_DOMAIN_DEATH); + _INT_CONST_LIBXL(m, EVENT_TYPE_DISK_EJECT); _INT_CONST_LIBXL(m, BUTTON_POWER); _INT_CONST_LIBXL(m, BUTTON_SLEEP); _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-20 16:15 UTC
[Xen-devel] [PATCH 08 of 32] tools: libxl: add an Enumeration type to the IDL
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1303315987 -3600 # Node ID 7b8cf10806a14c913e659a5e8fe804b9c9b44f1a # Parent de2e9214d8853529c82a02370ce99a0458a7a3eb tools: libxl: add an Enumeration type to the IDL The IDL requires a specific value for each enumerate, this make it much easier to avoid (or at least track) ABI changes since they must now be explicit. I believe I have used the same values as would have been chosen previoulsy but have not confirmed. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r de2e9214d885 -r 7b8cf10806a1 tools/libxl/gentypes.py --- a/tools/libxl/gentypes.py Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/libxl/gentypes.py Wed Apr 20 17:13:07 2011 +0100 @@ -34,7 +34,28 @@ def libxl_C_instance_of(ty, instancename def libxl_C_type_define(ty, indent = ""): s = "" - if isinstance(ty, libxltypes.Aggregate): + + if isinstance(ty, libxltypes.Enumeration): + if ty.comment is not None: + s += format_comment(0, ty.comment) + + if ty.typename is None: + s += "enum {\n" + else: + s += "typedef enum %s {\n" % ty.typename + + for v in ty.values: + if v.comment is not None: + s += format_comment(4, v.comment) + x = "%s = %d" % (v.name, v.value) + x = x.replace("\n", "\n ") + s += " " + x + ",\n" + if ty.typename is None: + s += "}" + else: + s += "} %s" % ty.typename + + elif isinstance(ty, libxltypes.Aggregate): if ty.comment is not None: s += format_comment(0, ty.comment) diff -r de2e9214d885 -r 7b8cf10806a1 tools/libxl/idl.txt --- a/tools/libxl/idl.txt Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/libxl/idl.txt Wed Apr 20 17:13:07 2011 +0100 @@ -82,6 +82,30 @@ libxltype.Reference Complex type-Classes -------------------- +libxltype.Enumeration + + A class representing an enumeration (named integer values). + + The values are available in the list Enumeration.values. Each + element in the list is of type libxltype.EnumerationValue. + + Each EnumerationValue has the following properties: + + EnumerationValue.enum Reference to containing Enumeration + EnumerationValue.name The C name of this value, including + the namespace and typename of the + containing Enumeration (e.g. + "LIBXL_FOOENUM_VALUE") + EnumerationValue.rawname The C name of this value, excluding + the namespace but including the + typename of the containing + Enumeration (e.g. "FOOENUM_VALUE") + EnumerationValue.valuename The name of this value, excluding the + name of the containing Enumeration + and any namespace (e.g. "VALUE") + EnumerationValue.value The integer value associated with this name. + EnumerationValue.comment A free text comment which describes the member. + libxltype.Aggregate Base class for type-Classes which contain a number of other types diff -r de2e9214d885 -r 7b8cf10806a1 tools/libxl/libxl.h --- a/tools/libxl/libxl.h Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/libxl/libxl.h Wed Apr 20 17:13:07 2011 +0100 @@ -161,49 +161,6 @@ typedef struct { #define LIBXL_CPUARRAY_INVALID_ENTRY ~0 void libxl_cpuarray_destroy(libxl_cpuarray *array); -typedef enum { - LIBXL_DOMAIN_TYPE_FV = 1, - LIBXL_DOMAIN_TYPE_PV, -} libxl_domain_type; - -typedef enum libxl_device_model_version { - /* Historical qemu-xen device model (qemu-dm) */ - LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL = 1, - /* Upstream based qemu-xen device model */ - LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN = 2, -} libxl_device_model_version; - -typedef enum { - LIBXL_CONSOLE_TYPE_SERIAL = 1, - LIBXL_CONSOLE_TYPE_PV, -} libxl_console_type; - -typedef enum { - LIBXL_CONSOLE_BACKEND_XENCONSOLED, - LIBXL_CONSOLE_BACKEND_IOEMU, -} libxl_console_backend; - -typedef enum { - LIBXL_DISK_FORMAT_UNKNOWN = 0, - LIBXL_DISK_FORMAT_QCOW, - LIBXL_DISK_FORMAT_QCOW2, - LIBXL_DISK_FORMAT_VHD, - LIBXL_DISK_FORMAT_RAW, - LIBXL_DISK_FORMAT_EMPTY, -} libxl_disk_format; - -typedef enum { - LIBXL_DISK_BACKEND_UNKNOWN = 0, - LIBXL_DISK_BACKEND_PHY, - LIBXL_DISK_BACKEND_TAP, - LIBXL_DISK_BACKEND_QDISK, -} libxl_disk_backend; - -typedef enum { - LIBXL_NIC_TYPE_IOEMU = 1, - LIBXL_NIC_TYPE_VIF, -} libxl_nic_type; - typedef struct { /* * Path is always set if the file reference is valid. However if @@ -252,18 +209,6 @@ enum { #define LIBXL_VERSION 0 -typedef enum libxl_action_on_shutdown { - LIBXL_ACTION_ON_SHUTDOWN_DESTROY, - - LIBXL_ACTION_ON_SHUTDOWN_RESTART, - LIBXL_ACTION_ON_SHUTDOWN_RESTART_RENAME, - - LIBXL_ACTION_ON_SHUTDOWN_PRESERVE, - - LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_DESTROY, - LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_RESTART, -} libxl_action_on_shutdown; - typedef struct { libxl_domain_create_info c_info; libxl_domain_build_info b_info; @@ -327,11 +272,6 @@ int libxl_run_bootloader(libxl_ctx *ctx, /* events handling */ -typedef enum { - LIBXL_EVENT_TYPE_DOMAIN_DEATH, - LIBXL_EVENT_TYPE_DISK_EJECT, -} libxl_event_type; - typedef struct { /* event type */ libxl_event_type type; @@ -494,11 +434,6 @@ int libxl_userdata_retrieve(libxl_ctx *c * On error return, *data_r and *datalen_r are undefined. */ -typedef enum { - LIBXL_BUTTON_POWER, - LIBXL_BUTTON_SLEEP -} libxl_button; - int libxl_button_press(libxl_ctx *ctx, uint32_t domid, libxl_button button); int libxl_get_physinfo(libxl_ctx *ctx, libxl_physinfo *physinfo); diff -r de2e9214d885 -r 7b8cf10806a1 tools/libxl/libxl.idl --- a/tools/libxl/libxl.idl Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/libxl/libxl.idl Wed Apr 20 17:13:07 2011 +0100 @@ -8,13 +8,6 @@ libxl_uuid = Builtin("uuid") libxl_mac = Builtin("mac") libxl_cpumap = Builtin("cpumap", destructor_fn="libxl_cpumap_destroy", passby=PASS_BY_REFERENCE) libxl_cpuarray = Builtin("cpuarray", destructor_fn="libxl_cpuarray_destroy", passby=PASS_BY_REFERENCE) -libxl_domain_type = Number("domain_type", namespace="libxl_") -libxl_device_model_version = Number("device_model_version", namespace="libxl_") -libxl_console_backend = Number("console_backend", namespace="libxl_") -libxl_console_type = Number("console_type", namespace="libxl_") -libxl_disk_format = Number("disk_format", namespace="libxl_") -libxl_disk_backend = Number("disk_backend", namespace="libxl_") -libxl_nic_type = Number("nic_type", namespace="libxl_") libxl_cpuid_policy_list = Builtin("cpuid_policy_list", destructor_fn="libxl_cpuid_destroy", passby=PASS_BY_REFERENCE) libxl_string_list = Builtin("string_list", destructor_fn="libxl_string_list_destroy", passby=PASS_BY_REFERENCE) @@ -24,6 +17,73 @@ libxl_file_reference = Builtin("file_ref libxl_hwcap = Builtin("hwcap") # +# Constants / Enumerations +# + +libxl_domain_type = Enumeration("domain_type", [ + (1, "FV"), + (2, "PV"), + ]) + +libxl_device_model_version = Enumeration("device_model_version", [ + (1, "QEMU_XEN_TRADITIONAL", "Historical qemu-xen device model (qemu-dm)"), + (2, "QEMU_XEN", "Upstream based qemu-xen device model"), + ]) + +libxl_console_type = Enumeration("console_type", [ + (1, "SERIAL"), + (2, "PV"), + ]) + +libxl_console_backend = Enumeration("console_backend", [ + (1, "XENCONSOLED"), + (2, "IOEMU"), + ]) + +libxl_disk_format = Enumeration("disk_format", [ + (0, "UNKNOWN"), + (1, "QCOW"), + (2, "QCOW2"), + (3, "VHD"), + (4, "RAW"), + (5, "EMPTY"), + ]) + +libxl_disk_backend = Enumeration("disk_backend", [ + (0, "UNKNOWN"), + (1, "PHY"), + (2, "TAP"), + (3, "QDISK"), + ]) + +libxl_nic_type = Enumeration("nic_type", [ + (1, "IOEMU"), + (2, "VIF"), + ]) + +libxl_action_on_shutdown = Enumeration("action_on_shutdown", [ + (1, "DESTROY"), + + (2, "RESTART"), + (3, "RESTART_RENAME"), + + (4, "PRESERVE"), + + (5, "COREDUMP_DESTROY"), + (6, "COREDUMP_RESTART"), + ]) + +libxl_event_type = Enumeration("event_type", [ + (1, "DOMAIN_DEATH"), + (2, "DISK_EJECT"), + ]) + +libxl_button = Enumeration("button", [ + (1, "POWER"), + (2, "SLEEP"), + ]) + +# # Complex libxl types # libxl_dominfo = Struct("dominfo",[ diff -r de2e9214d885 -r 7b8cf10806a1 tools/libxl/libxltypes.py --- a/tools/libxl/libxltypes.py Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/libxl/libxltypes.py Wed Apr 20 17:13:07 2011 +0100 @@ -52,6 +52,35 @@ class UInt(Number): self.width = w +class EnumerationValue(object): + def __init__(self, enum, value, name, **kwargs): + self.enum = enum + + self.valuename = str.upper(name) + self.rawname = str.upper(enum.rawname) + "_" + self.valuename + self.name = str.upper(enum.namespace) + self.rawname + self.value = value + self.comment = kwargs.setdefault("comment", None) + +class Enumeration(Type): + def __init__(self, typename, values, **kwargs): + kwargs.setdefault(''destructor_fn'', None) + Type.__init__(self, typename, **kwargs) + + self.values = [] + for v in values: + # (value, name[, comment=None]) + if len(v) == 2: + (num,name) = v + comment = None + elif len(v) == 3: + num,name,comment = v + else: + raise "" + self.values.append(EnumerationValue(self, num, name, + comment=comment, + typename=self.rawname)) + class BitField(Type): def __init__(self, ty, w, **kwargs): kwargs.setdefault(''namespace'', None) diff -r de2e9214d885 -r 7b8cf10806a1 tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/libxl/xl_cmdimpl.c Wed Apr 20 17:13:07 2011 +0100 @@ -451,6 +451,8 @@ static int parse_action_on_shutdown(cons for (i = 0; i < sizeof(action_on_shutdown_names) / sizeof(action_on_shutdown_names[0]); i++) { n = action_on_shutdown_names[i]; + if (!n) continue; + if (strcmp(buf, n) == 0) { *a = i; return 1; diff -r de2e9214d885 -r 7b8cf10806a1 tools/python/genwrap.py --- a/tools/python/genwrap.py Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/python/genwrap.py Wed Apr 20 17:13:07 2011 +0100 @@ -9,6 +9,8 @@ import libxltypes def py_type(ty): if ty == libxltypes.bool or isinstance(ty, libxltypes.BitField) and ty.width == 1: return TYPE_BOOL + if isinstance(ty, libxltypes.Enumeration): + return TYPE_UINT if isinstance(ty, libxltypes.Number): if ty.signed: return TYPE_INT @@ -34,15 +36,16 @@ def fsanitize(name): def py_decls(ty): l = [] - l.append(''_hidden Py_%s *Py%s_New(void);\n''%(ty.rawname, ty.rawname)) - l.append(''_hidden int Py%s_Check(PyObject *self);\n''%ty.rawname) - for f in ty.fields: - if py_type(f.type) is not None: - continue - l.append(''_hidden PyObject *attrib__%s_get(%s *%s);''%(\ - fsanitize(f.type.typename), f.type.typename, f.name)) - l.append(''_hidden int attrib__%s_set(PyObject *v, %s *%s);''%(\ - fsanitize(f.type.typename), f.type.typename, f.name)) + if isinstance(ty, libxltypes.Aggregate): + l.append(''_hidden Py_%s *Py%s_New(void);\n''%(ty.rawname, ty.rawname)) + l.append(''_hidden int Py%s_Check(PyObject *self);\n''%ty.rawname) + for f in ty.fields: + if py_type(f.type) is not None: + continue + l.append(''_hidden PyObject *attrib__%s_get(%s *%s);''%(\ + fsanitize(f.type.typename), f.type.typename, f.name)) + l.append(''_hidden int attrib__%s_set(PyObject *v, %s *%s);''%(\ + fsanitize(f.type.typename), f.type.typename, f.name)) return ''\n''.join(l) + "\n" def py_attrib_get(ty, f): @@ -189,16 +192,23 @@ def py_initfuncs(types): l.append(''void genwrap__init(PyObject *m)'') l.append(''{'') for ty in types: - l.append('' if (PyType_Ready(&Py%s_Type) >= 0) {''%ty.rawname) - l.append('' Py_INCREF(&Py%s_Type);''%ty.rawname) - l.append('' PyModule_AddObject(m, "%s", (PyObject *)&Py%s_Type);''%(ty.rawname, ty.rawname)) - l.append('' }'') + if isinstance(ty, libxltypes.Enumeration): + for v in ty.values: + l.append('' PyModule_AddIntConstant(m, "%s", %s);'' % (v.rawname, v.name)) + elif isinstance(ty, libxltypes.Aggregate): + l.append('' if (PyType_Ready(&Py%s_Type) >= 0) {''%ty.rawname) + l.append('' Py_INCREF(&Py%s_Type);''%ty.rawname) + l.append('' PyModule_AddObject(m, "%s", (PyObject *)&Py%s_Type);''%(ty.rawname, ty.rawname)) + l.append('' }'') + else: + raise NotImplementedError("unknown type %s (%s)" % (ty.typename, type(ty))) + l.append(''}'') return ''\n''.join(l) + "\n\n" def tree_frob(types): ret = types[:] - for ty in ret: + for ty in [ty for ty in ret if isinstance(ty, libxltypes.Aggregate)]: ty.fields = filter(lambda f:f.name is not None and f.type.typename is not None, ty.fields) return ret @@ -249,8 +259,8 @@ _hidden PyObject *genwrap__ll_get(long l _hidden int genwrap__ll_set(PyObject *v, long long *val, long long mask); """ % " ".join(sys.argv)) - for ty in types: - f.write(''/* Internal APU for %s wrapper */\n''%ty.typename) + for ty in [ty for ty in types if isinstance(ty, libxltypes.Aggregate)]: + f.write(''/* Internal API for %s wrapper */\n''%ty.typename) f.write(py_wrapstruct(ty)) f.write(py_decls(ty)) f.write(''\n'') @@ -276,10 +286,11 @@ _hidden int genwrap__ll_set(PyObject *v, """ % tuple(('' ''.join(sys.argv),) + (os.path.split(decls)[-1:]),)) for ty in types: - f.write(''/* Attribute get/set functions for %s */\n''%ty.typename) - for a in ty.fields: - f.write(py_attrib_get(ty,a)) - f.write(py_attrib_set(ty,a)) - f.write(py_object_def(ty)) + if isinstance(ty, libxltypes.Aggregate): + f.write(''/* Attribute get/set functions for %s */\n''%ty.typename) + for a in ty.fields: + f.write(py_attrib_get(ty,a)) + f.write(py_attrib_set(ty,a)) + f.write(py_object_def(ty)) f.write(py_initfuncs(types)) f.close() diff -r de2e9214d885 -r 7b8cf10806a1 tools/python/xen/lowlevel/xl/xl.c --- a/tools/python/xen/lowlevel/xl/xl.c Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/python/xen/lowlevel/xl/xl.c Wed Apr 20 17:13:07 2011 +0100 @@ -769,35 +769,6 @@ PyMODINIT_FUNC initxl(void) _INT_CONST(m, SHUTDOWN_crash); _INT_CONST(m, SHUTDOWN_watchdog); - _INT_CONST_LIBXL(m, DOMAIN_TYPE_FV); - _INT_CONST_LIBXL(m, DOMAIN_TYPE_PV); - - _INT_CONST_LIBXL(m, CONSOLE_TYPE_SERIAL); - _INT_CONST_LIBXL(m, CONSOLE_TYPE_PV); - - _INT_CONST_LIBXL(m, CONSOLE_BACKEND_XENCONSOLED); - _INT_CONST_LIBXL(m, CONSOLE_BACKEND_IOEMU); - - _INT_CONST_LIBXL(m, DISK_FORMAT_UNKNOWN); - _INT_CONST_LIBXL(m, DISK_FORMAT_QCOW); - _INT_CONST_LIBXL(m, DISK_FORMAT_QCOW2); - _INT_CONST_LIBXL(m, DISK_FORMAT_VHD); - _INT_CONST_LIBXL(m, DISK_FORMAT_RAW); - _INT_CONST_LIBXL(m, DISK_FORMAT_EMPTY); - - _INT_CONST_LIBXL(m, DISK_BACKEND_UNKNOWN); - _INT_CONST_LIBXL(m, DISK_BACKEND_PHY); - _INT_CONST_LIBXL(m, DISK_BACKEND_TAP); - _INT_CONST_LIBXL(m, DISK_BACKEND_QDISK); - - _INT_CONST_LIBXL(m, NIC_TYPE_IOEMU); - _INT_CONST_LIBXL(m, NIC_TYPE_VIF); - - _INT_CONST_LIBXL(m, EVENT_TYPE_DOMAIN_DEATH); - _INT_CONST_LIBXL(m, EVENT_TYPE_DISK_EJECT); - - _INT_CONST_LIBXL(m, BUTTON_POWER); - _INT_CONST_LIBXL(m, BUTTON_SLEEP); genwrap__init(m); } _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-20 16:15 UTC
[Xen-devel] [PATCH 09 of 32] tools: libxl: add libxl_domid to IDL
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1303315987 -3600 # Node ID e19934c3d1c1c5daff74ea2f3b304fd873b3094c # Parent 7b8cf10806a14c913e659a5e8fe804b9c9b44f1a tools: libxl: add libxl_domid to IDL Language bindings would like to strongly type the domid as a separate type so make it a defined type. This patch only impacts the datatypes and autogenerated destructors, I didn''t think the churn of switching the uint32_t''s through the code was worth it. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 7b8cf10806a1 -r e19934c3d1c1 tools/libxl/libxl.h --- a/tools/libxl/libxl.h Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/libxl/libxl.h Wed Apr 20 17:13:07 2011 +0100 @@ -183,6 +183,8 @@ void libxl_cpuid_destroy(libxl_cpuid_pol #define LIBXL_PCI_FUNC_ALL (~0U) +typedef uint32_t libxl_domid; + #include "_libxl_types.h" typedef struct libxl__ctx libxl_ctx; diff -r 7b8cf10806a1 -r e19934c3d1c1 tools/libxl/libxl.idl --- a/tools/libxl/libxl.idl Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/libxl/libxl.idl Wed Apr 20 17:13:07 2011 +0100 @@ -3,7 +3,7 @@ # Builtin libxl types # -libxl_ctx = Builtin("ctx") +libxl_domid = Builtin("domid") libxl_uuid = Builtin("uuid") libxl_mac = Builtin("mac") libxl_cpumap = Builtin("cpumap", destructor_fn="libxl_cpumap_destroy", passby=PASS_BY_REFERENCE) @@ -88,7 +88,7 @@ libxl_button = Enumeration("button", [ # libxl_dominfo = Struct("dominfo",[ ("uuid", libxl_uuid), - ("domid", domid), + ("domid", libxl_domid), ("running", BitField(uint8, 1)), ("blocked", BitField(uint8, 1)), ("paused", BitField(uint8, 1)), @@ -116,7 +116,7 @@ libxl_cpupoolinfo = Struct("cpupoolinfo" libxl_vminfo = Struct("vminfo", [ ("uuid", libxl_uuid), - ("domid", domid), + ("domid", libxl_domid), ], destructor_fn=None) libxl_version_info = Struct("version_info", [ @@ -198,7 +198,7 @@ libxl_domain_build_state = Struct("domai ], destructor_fn=None) libxl_device_model_info = Struct("device_model_info",[ - ("domid", integer), + ("domid", libxl_domid), ("uuid", libxl_uuid, False, "this is use only with stubdom, and must be different from the domain uuid"), ("dom_name", string), ("device_model_version", libxl_device_model_version), @@ -236,7 +236,7 @@ libxl_device_model_info = Struct("device Network is missing""") libxl_device_vfb = Struct("device_vfb", [ - ("backend_domid", uint32), + ("backend_domid", libxl_domid), ("devid", integer), ("vnc", bool, False, "vnc enabled or disabled"), ("vnclisten", string, False, "address:port that should be listened on for the VNC server if vnc is set"), @@ -251,12 +251,12 @@ libxl_device_vfb = Struct("device_vfb", ]) libxl_device_vkb = Struct("device_vkb", [ - ("backend_domid", uint32), + ("backend_domid", libxl_domid), ("devid", integer), ]) libxl_device_console = Struct("device_console", [ - ("backend_domid", uint32), + ("backend_domid", libxl_domid), ("devid", integer), ("consback", libxl_console_backend), ("build_state", Reference(libxl_domain_build_state), True), @@ -264,7 +264,7 @@ libxl_device_console = Struct("device_co ]) libxl_device_disk = Struct("device_disk", [ - ("backend_domid", uint32), + ("backend_domid", libxl_domid), ("pdev_path", string), ("vdev", string), ("backend", libxl_disk_backend), @@ -275,7 +275,7 @@ libxl_device_disk = Struct("device_disk" ]) libxl_device_nic = Struct("device_nic", [ - ("backend_domid", uint32), + ("backend_domid", libxl_domid), ("devid", integer), ("mtu", integer), ("model", string), diff -r 7b8cf10806a1 -r e19934c3d1c1 tools/libxl/libxltypes.py --- a/tools/libxl/libxltypes.py Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/libxl/libxltypes.py Wed Apr 20 17:13:07 2011 +0100 @@ -184,8 +184,6 @@ uint16 = UInt(16) uint32 = UInt(32) uint64 = UInt(64) -domid = UInt(32) - string = Builtin("char *", namespace = None, destructor_fn = "free") class OrderedDict(dict): diff -r 7b8cf10806a1 -r e19934c3d1c1 tools/python/xen/lowlevel/xl/xl.c --- a/tools/python/xen/lowlevel/xl/xl.c Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/python/xen/lowlevel/xl/xl.c Wed Apr 20 17:13:07 2011 +0100 @@ -155,6 +155,7 @@ int genwrap__ll_set(PyObject *v, long lo *val = tmp; return 0; } + static int fixed_bytearray_set(PyObject *v, uint8_t *ptr, size_t len) { char *tmp; @@ -275,6 +276,11 @@ int attrib__libxl_uuid_set(PyObject *v, return fixed_bytearray_set(v, libxl_uuid_bytearray(pptr), 16); } +int attrib__libxl_domid_set(PyObject *v, libxl_domid *domid) { + *domid = PyInt_AsLong(v); + return 0; +} + int attrib__struct_in_addr_set(PyObject *v, struct in_addr *pptr) { PyErr_SetString(PyExc_NotImplementedError, "Setting in_addr"); @@ -362,6 +368,10 @@ PyObject *attrib__libxl_uuid_get(libxl_u return fixed_bytearray_get(libxl_uuid_bytearray(pptr), 16); } +PyObject *attrib__libxl_domid_get(libxl_domid *domid) { + return PyInt_FromLong(*domid); +} + PyObject *attrib__struct_in_addr_get(struct in_addr *pptr) { PyErr_SetString(PyExc_NotImplementedError, "Getting in_addr"); _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-20 16:15 UTC
[Xen-devel] [PATCH 10 of 32] tools: libxl: remove BitField type class from IDL
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1303315987 -3600 # Node ID 099e9d1f9a7dece291365b43d28291d8849afd2a # Parent e19934c3d1c1c5daff74ea2f3b304fd873b3094c tools: libxl: remove BitField type class from IDL All usages are single bit BitFields, AKA booleans. In general we prefer to use simple structures (e.g. without packing or specific layouts) in the libxl API and take care of any require structure by marshalling within the library instead of expecting users to do so (e.g. the PCI device BDF is unpacked in the libxl API). Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r e19934c3d1c1 -r 099e9d1f9a7d tools/libxl/gentypes.py --- a/tools/libxl/gentypes.py Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/libxl/gentypes.py Wed Apr 20 17:13:07 2011 +0100 @@ -22,9 +22,7 @@ def libxl_C_type_of(ty): return ty.typename def libxl_C_instance_of(ty, instancename): - if isinstance(ty, libxltypes.BitField): - return libxl_C_type_of(ty) + " " + instancename + ":%d" % ty.width - elif isinstance(ty, libxltypes.Aggregate) and ty.typename is None: + if isinstance(ty, libxltypes.Aggregate) and ty.typename is None: if instancename is None: return libxl_C_type_define(ty) else: diff -r e19934c3d1c1 -r 099e9d1f9a7d tools/libxl/idl.txt --- a/tools/libxl/idl.txt Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/libxl/idl.txt Wed Apr 20 17:13:07 2011 +0100 @@ -64,14 +64,6 @@ libxltype.UInt The <N> for a given instance must be passed to the constructor and is then available in UInt.width -libxltype.BitField - - Instances of this class represent bitfield type classes. - - The base type and desired width for a given instance must be passed - to the contructor. The base type becomes the type of the instance and - width is contained in BitField.width - libxltype.Reference Instances of this type represent a reference to another type diff -r e19934c3d1c1 -r 099e9d1f9a7d tools/libxl/libxl.idl --- a/tools/libxl/libxl.idl Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/libxl/libxl.idl Wed Apr 20 17:13:07 2011 +0100 @@ -89,11 +89,11 @@ libxl_button = Enumeration("button", [ libxl_dominfo = Struct("dominfo",[ ("uuid", libxl_uuid), ("domid", libxl_domid), - ("running", BitField(uint8, 1)), - ("blocked", BitField(uint8, 1)), - ("paused", BitField(uint8, 1)), - ("shutdown", BitField(uint8, 1)), - ("dying", BitField(uint8, 1)), + ("running", bool), + ("blocked", bool), + ("paused", bool), + ("shutdown", bool), + ("dying", bool), ("shutdown_reason", unsigned, False, """Valid SHUTDOWN_* value from xen/sched.h iff (shutdown||dying). @@ -326,9 +326,9 @@ libxl_nicinfo = Struct("nicinfo", [ libxl_vcpuinfo = Struct("vcpuinfo", [ ("vcpuid", uint32, False, "vcpu''s id"), ("cpu", uint32, False, "current mapping"), - ("online", BitField(uint8, 1), False, "currently online (not hotplugged)?"), - ("blocked", BitField(uint8, 1), False, "blocked waiting for an event?"), - ("running", BitField(uint8, 1), False, "currently scheduled on its CPU?"), + ("online", bool, False, "currently online (not hotplugged)?"), + ("blocked", bool, False, "blocked waiting for an event?"), + ("running", bool, False, "currently scheduled on its CPU?"), ("vcpu_time", uint64, False, "total vcpu time ran (ns)"), ("cpumap", libxl_cpumap, False, "current cpu''s affinities"), ]) diff -r e19934c3d1c1 -r 099e9d1f9a7d tools/libxl/libxltypes.py --- a/tools/libxl/libxltypes.py Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/libxl/libxltypes.py Wed Apr 20 17:13:07 2011 +0100 @@ -81,14 +81,6 @@ class Enumeration(Type): comment=comment, typename=self.rawname)) -class BitField(Type): - def __init__(self, ty, w, **kwargs): - kwargs.setdefault(''namespace'', None) - kwargs.setdefault(''destructor_fn'', None) - Type.__init__(self, ty.typename, **kwargs) - - self.width = w - class Field(object): """An element of an Aggregate type""" def __init__(self, type, name, **kwargs): diff -r e19934c3d1c1 -r 099e9d1f9a7d tools/python/genwrap.py --- a/tools/python/genwrap.py Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/python/genwrap.py Wed Apr 20 17:13:07 2011 +0100 @@ -7,7 +7,7 @@ import libxltypes (TYPE_BOOL, TYPE_INT, TYPE_UINT, TYPE_STRING) = range(4) def py_type(ty): - if ty == libxltypes.bool or isinstance(ty, libxltypes.BitField) and ty.width == 1: + if ty == libxltypes.bool: return TYPE_BOOL if isinstance(ty, libxltypes.Enumeration): return TYPE_UINT _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-20 16:15 UTC
[Xen-devel] [PATCH 11 of 32] tools: libxl: add concept of in- and out-put only data types to IDL
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1303315987 -3600 # Node ID d1a40e34829e71efe8819eead493a2243806efe5 # Parent 099e9d1f9a7dece291365b43d28291d8849afd2a tools: libxl: add concept of in- and out-put only data types to IDL This allow language bindings to only emit the relevant conversion functions. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 099e9d1f9a7d -r d1a40e34829e tools/libxl/libxl.idl --- a/tools/libxl/libxl.idl Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/libxl/libxl.idl Wed Apr 20 17:13:07 2011 +0100 @@ -348,7 +348,7 @@ libxl_physinfo = Struct("physinfo", [ ("nr_nodes", uint32), ("hw_cap", libxl_hwcap), ("phys_cap", uint32), - ], destructor_fn=None) + ], destructor_fn=None, dir=DIR_OUT) libxl_topologyinfo = Struct("topologyinfo", [ ("coremap", libxl_cpuarray, False, "cpu to core map"), diff -r 099e9d1f9a7d -r d1a40e34829e tools/libxl/libxltypes.py --- a/tools/libxl/libxltypes.py Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/libxl/libxltypes.py Wed Apr 20 17:13:07 2011 +0100 @@ -3,10 +3,18 @@ import sys PASS_BY_VALUE = 1 PASS_BY_REFERENCE = 2 +DIR_NONE = 0 +DIR_IN = 1 +DIR_OUT = 2 +DIR_BOTH = 3 + class Type(object): def __init__(self, typename, **kwargs): self.comment = kwargs.setdefault(''comment'', None) self.namespace = kwargs.setdefault(''namespace'', "libxl_") + self.dir = kwargs.setdefault(''dir'', DIR_BOTH) + if self.dir not in [DIR_NONE, DIR_IN, DIR_OUT, DIR_BOTH]: + raise ValueError self.passby = kwargs.setdefault(''passby'', PASS_BY_VALUE) if self.passby not in [PASS_BY_VALUE, PASS_BY_REFERENCE]: @@ -29,6 +37,11 @@ class Type(object): self.autogenerate_destructor = kwargs.setdefault(''autogenerate_destructor'', True) + def marshal_in(self): + return self.dir in [DIR_IN, DIR_BOTH] + def marshal_out(self): + return self.dir in [DIR_OUT, DIR_BOTH] + class Builtin(Type): """Builtin type""" def __init__(self, typename, **kwargs): @@ -214,7 +227,8 @@ def parse(f): globs[n] = t elif isinstance(t,type(object)) and issubclass(t, Type): globs[n] = t - elif n in [''PASS_BY_REFERENCE'', ''PASS_BY_VALUE'']: + elif n in [''PASS_BY_REFERENCE'', ''PASS_BY_VALUE'', + ''DIR_NONE'', ''DIR_IN'', ''DIR_OUT'', ''DIR_BOTH'']: globs[n] = t try: diff -r 099e9d1f9a7d -r d1a40e34829e tools/python/genwrap.py --- a/tools/python/genwrap.py Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/python/genwrap.py Wed Apr 20 17:13:07 2011 +0100 @@ -42,10 +42,12 @@ def py_decls(ty): for f in ty.fields: if py_type(f.type) is not None: continue - l.append(''_hidden PyObject *attrib__%s_get(%s *%s);''%(\ - fsanitize(f.type.typename), f.type.typename, f.name)) - l.append(''_hidden int attrib__%s_set(PyObject *v, %s *%s);''%(\ - fsanitize(f.type.typename), f.type.typename, f.name)) + if ty.marshal_out(): + l.append(''_hidden PyObject *attrib__%s_get(%s *%s);''%(\ + fsanitize(f.type.typename), f.type.typename, f.name)) + if ty.marshal_in(): + l.append(''_hidden int attrib__%s_set(PyObject *v, %s *%s);''%(\ + fsanitize(f.type.typename), f.type.typename, f.name)) return ''\n''.join(l) + "\n" def py_attrib_get(ty, f): @@ -128,8 +130,15 @@ static PyObject *Py%(rawname)s_new(PyTyp l.append(''static PyGetSetDef Py%s_getset[] = {''%ty.rawname) for f in ty.fields: l.append('' { .name = "%s", ''%f.name) - l.append('' .get = (getter)py_%s_%s_get, ''%(ty.rawname, f.name)) - l.append('' .set = (setter)py_%s_%s_set },''%(ty.rawname, f.name)) + if ty.marshal_out(): + l.append('' .get = (getter)py_%s_%s_get, ''%(ty.rawname, f.name)) + else: + l.append('' .get = (getter)NULL, '') + if ty.marshal_in(): + l.append('' .set = (setter)py_%s_%s_set,''%(ty.rawname, f.name)) + else: + l.append('' .set = (setter)NULL,'') + l.append('' },'') l.append('' { .name = NULL }'') l.append(''};'') struct=""" @@ -289,8 +298,10 @@ _hidden int genwrap__ll_set(PyObject *v, if isinstance(ty, libxltypes.Aggregate): f.write(''/* Attribute get/set functions for %s */\n''%ty.typename) for a in ty.fields: - f.write(py_attrib_get(ty,a)) - f.write(py_attrib_set(ty,a)) + if ty.marshal_out(): + f.write(py_attrib_get(ty,a)) + if ty.marshal_in(): + f.write(py_attrib_set(ty,a)) f.write(py_object_def(ty)) f.write(py_initfuncs(types)) f.close() _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-20 16:15 UTC
[Xen-devel] [PATCH 12 of 32] tools: libxl: do not specify protocol node for disk or net
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1303315987 -3600 # Node ID fe29a8881d30e5da198d191af2a79abf9fcb25bf # Parent d1a40e34829e71efe8819eead493a2243806efe5 tools: libxl: do not specify protocol node for disk or net This node is written by the front/backends as part of their negotiation about how to speak to each other. The toolstack has no part in this and it certainly shouldn''t be hardcoding the 32 bit protocol! Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r d1a40e34829e -r fe29a8881d30 tools/libxl/libxl.c --- a/tools/libxl/libxl.c Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/libxl/libxl.c Wed Apr 20 17:13:07 2011 +0100 @@ -1060,11 +1060,6 @@ int libxl_device_disk_add(libxl_ctx *ctx flexarray_append(front, "device-type"); flexarray_append(front, disk->is_cdrom ? "cdrom" : "disk"); - if (0 /* protocol != native*/) { - flexarray_append(front, "protocol"); - flexarray_append(front, "x86_32-abi"); /* hardcoded ! */ - } - libxl__device_generic_add(&gc, &device, libxl__xs_kvs_of_flexarray(&gc, back, back->count), libxl__xs_kvs_of_flexarray(&gc, front, front->count)); @@ -1304,11 +1299,6 @@ int libxl_device_nic_add(libxl_ctx *ctx, flexarray_append(front, libxl__sprintf(&gc, "%02x:%02x:%02x:%02x:%02x:%02x", nic->mac[0], nic->mac[1], nic->mac[2], nic->mac[3], nic->mac[4], nic->mac[5])); - if (0 /* protocol != native*/) { - flexarray_append(front, "protocol"); - flexarray_append(front, "x86_32-abi"); /* hardcoded ! */ - } - libxl__device_generic_add(&gc, &device, libxl__xs_kvs_of_flexarray(&gc, back, back->count), libxl__xs_kvs_of_flexarray(&gc, front, front->count)); _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-20 16:15 UTC
[Xen-devel] [PATCH 13 of 32] tools: ocaml: rename the device_nic types and functions
# HG changeset patch # User David Scott <dave.scott@eu.citrix.com> # Date 1301507668 -3600 # Node ID bdd0abc21941aa5fb0a5c726173f0e4f16246f00 # Parent fe29a8881d30e5da198d191af2a79abf9fcb25bf tools: ocaml: rename the device_nic types and functions The aims are: 1. make the records instantiable if they have field names in common; and 2. to make it easier to derive the names programatically from the IDL Signed-off-by: David Scott <dave.scott@eu.citrix.com> Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r fe29a8881d30 -r bdd0abc21941 tools/ocaml/libs/xl/xl.ml --- a/tools/ocaml/libs/xl/xl.ml Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100 @@ -1,5 +1,5 @@ (* - * Copyright (C) 2009-2010 Citrix Ltd. + * Copyright (C) 2009-2011 Citrix Ltd. * Author Vincent Hanquez <vincent.hanquez@eu.citrix.com> * * This program is free software; you can redistribute it and/or modify @@ -97,18 +97,22 @@ type nic_type | NICTYPE_IOEMU | NICTYPE_VIF -type nic_info -{ - backend_domid : domid; - devid : int; - mtu : int; - model : string; - mac : int array; - bridge : string; - ifname : string; - script : string; - nictype : nic_type; -} +module Device_nic = struct + type t + { + backend_domid : domid; + devid : int; + mtu : int; + model : string; + mac : int array; + bridge : string; + ifname : string; + script : string; + nictype : nic_type; + } + external add : t -> domid -> unit = "stub_xl_device_nic_add" + external del : t -> domid -> unit = "stub_xl_device_nic_del" +end type console_type | CONSOLETYPE_XENCONSOLED @@ -190,9 +194,6 @@ external domain_build : build_info -> do external disk_add : disk_info -> domid -> unit = "stub_xl_disk_add" external disk_remove : disk_info -> domid -> unit = "stub_xl_disk_remove" -external nic_add : nic_info -> domid -> unit = "stub_xl_nic_add" -external nic_remove : disk_info -> domid -> unit = "stub_xl_nic_remove" - external console_add : console_info -> build_state -> domid -> unit = "stub_xl_console_add" external vkb_add : vkb_info -> domid -> unit = "stub_xl_vkb_add" diff -r fe29a8881d30 -r bdd0abc21941 tools/ocaml/libs/xl/xl.mli --- a/tools/ocaml/libs/xl/xl.mli Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100 @@ -1,5 +1,5 @@ (* - * Copyright (C) 2009-2010 Citrix Ltd. + * Copyright (C) 2009-2011 Citrix Ltd. * Author Vincent Hanquez <vincent.hanquez@eu.citrix.com> * * This program is free software; you can redistribute it and/or modify @@ -97,18 +97,22 @@ type nic_type | NICTYPE_IOEMU | NICTYPE_VIF -type nic_info -{ - backend_domid : domid; - devid : int; - mtu : int; - model : string; - mac : int array; - bridge : string; - ifname : string; - script : string; - nictype : nic_type; -} +module Device_nic : sig + type t + { + backend_domid : domid; + devid : int; + mtu : int; + model : string; + mac : int array; + bridge : string; + ifname : string; + script : string; + nictype : nic_type; + } + external add : t -> domid -> unit = "stub_xl_device_nic_add" + external del : t -> domid -> unit = "stub_xl_device_nic_del" +end type console_type | CONSOLETYPE_XENCONSOLED @@ -190,9 +194,6 @@ external domain_build : build_info -> do external disk_add : disk_info -> domid -> unit = "stub_xl_disk_add" external disk_remove : disk_info -> domid -> unit = "stub_xl_disk_remove" -external nic_add : nic_info -> domid -> unit = "stub_xl_nic_add" -external nic_remove : disk_info -> domid -> unit = "stub_xl_nic_remove" - external console_add : console_info -> build_state -> domid -> unit = "stub_xl_console_add" external vkb_add : vkb_info -> domid -> unit = "stub_xl_vkb_add" diff -r fe29a8881d30 -r bdd0abc21941 tools/ocaml/libs/xl/xl_stubs.c --- a/tools/ocaml/libs/xl/xl_stubs.c Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/ocaml/libs/xl/xl_stubs.c Wed Mar 30 18:54:28 2011 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2010 Citrix Ltd. + * Copyright (C) 2009-2011 Citrix Ltd. * Author Vincent Hanquez <vincent.hanquez@eu.citrix.com> * * This program is free software; you can redistribute it and/or modify @@ -402,7 +402,7 @@ value stub_xl_disk_remove(value info, va CAMLreturn(Val_unit); } -value stub_xl_nic_add(value info, value domid) +value stub_xl_device_nic_add(value info, value domid) { CAMLparam2(info, domid); libxl_device_nic c_info; @@ -419,7 +419,7 @@ value stub_xl_nic_add(value info, value CAMLreturn(Val_unit); } -value stub_xl_nic_remove(value info, value domid) +value stub_xl_device_nic_del(value info, value domid) { CAMLparam2(info, domid); libxl_device_nic c_info; @@ -431,7 +431,7 @@ value stub_xl_nic_remove(value info, val INIT_CTX(); ret = libxl_device_nic_del(ctx, Int_val(domid), &c_info, 0); if (ret != 0) - failwith_xl("nic_remove", &lg); + failwith_xl("nic_del", &lg); FREE_CTX(); CAMLreturn(Val_unit); } _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-20 16:15 UTC
[Xen-devel] [PATCH 14 of 32] tools: ocaml: rename the disk_info types and functions
# HG changeset patch # User David Scott <dave.scott@eu.citrix.com> # Date 1301507668 -3600 # Node ID 3d4209b8a54a00c00acb414b8a706940c29d073e # Parent bdd0abc21941aa5fb0a5c726173f0e4f16246f00 tools: ocaml: rename the disk_info types and functions The aims are: 1. make the records instantiable if they have field names in common; and 2. to make it easier to derive the names programatically from the IDL Signed-off-by: David Scott <dave.scott@eu.citrix.com> Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r bdd0abc21941 -r 3d4209b8a54a tools/ocaml/libs/xl/xl.ml --- a/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100 +++ b/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100 @@ -82,16 +82,21 @@ type disk_phystype | PHYSTYPE_FILE | PHYSTYPE_PHY -type disk_info -{ - backend_domid : domid; - physpath : string; - phystype : disk_phystype; - virtpath : string; - unpluggable : bool; - readwrite : bool; - is_cdrom : bool; -} +module Device_disk = struct + type t + { + backend_domid : domid; + physpath : string; + phystype : disk_phystype; + virtpath : string; + unpluggable : bool; + readwrite : bool; + is_cdrom : bool; + } + + external add : t -> domid -> unit = "stub_xl_device_disk_add" + external del : t -> domid -> unit = "stub_xl_device_disk_del" +end type nic_type | NICTYPE_IOEMU @@ -191,9 +196,6 @@ type sched_credit external domain_make : create_info -> domid = "stub_xl_domain_make" external domain_build : build_info -> domid -> build_state = "stub_xl_domain_build" -external disk_add : disk_info -> domid -> unit = "stub_xl_disk_add" -external disk_remove : disk_info -> domid -> unit = "stub_xl_disk_remove" - external console_add : console_info -> build_state -> domid -> unit = "stub_xl_console_add" external vkb_add : vkb_info -> domid -> unit = "stub_xl_vkb_add" diff -r bdd0abc21941 -r 3d4209b8a54a tools/ocaml/libs/xl/xl.mli --- a/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100 +++ b/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100 @@ -82,16 +82,21 @@ type disk_phystype | PHYSTYPE_FILE | PHYSTYPE_PHY -type disk_info -{ - backend_domid : domid; - physpath : string; - phystype : disk_phystype; - virtpath : string; - unpluggable : bool; - readwrite : bool; - is_cdrom : bool; -} +module Device_disk : sig + type t + { + backend_domid : domid; + physpath : string; + phystype : disk_phystype; + virtpath : string; + unpluggable : bool; + readwrite : bool; + is_cdrom : bool; + } + + external add : t -> domid -> unit = "stub_xl_device_disk_add" + external del : t -> domid -> unit = "stub_xl_device_disk_del" +end type nic_type | NICTYPE_IOEMU @@ -191,9 +196,6 @@ type sched_credit external domain_make : create_info -> domid = "stub_xl_domain_make" external domain_build : build_info -> domid -> build_state = "stub_xl_domain_build" -external disk_add : disk_info -> domid -> unit = "stub_xl_disk_add" -external disk_remove : disk_info -> domid -> unit = "stub_xl_disk_remove" - external console_add : console_info -> build_state -> domid -> unit = "stub_xl_console_add" external vkb_add : vkb_info -> domid -> unit = "stub_xl_vkb_add" diff -r bdd0abc21941 -r 3d4209b8a54a tools/ocaml/libs/xl/xl_stubs.c --- a/tools/ocaml/libs/xl/xl_stubs.c Wed Mar 30 18:54:28 2011 +0100 +++ b/tools/ocaml/libs/xl/xl_stubs.c Wed Mar 30 18:54:28 2011 +0100 @@ -368,7 +368,7 @@ static value Val_topologyinfo(libxl_topo CAMLreturn(topologyinfo); } -value stub_xl_disk_add(value info, value domid) +value stub_xl_device_disk_add(value info, value domid) { CAMLparam2(info, domid); libxl_device_disk c_info; @@ -385,7 +385,7 @@ value stub_xl_disk_add(value info, value CAMLreturn(Val_unit); } -value stub_xl_disk_remove(value info, value domid) +value stub_xl_device_disk_del(value info, value domid) { CAMLparam2(info, domid); libxl_device_disk c_info; @@ -397,7 +397,7 @@ value stub_xl_disk_remove(value info, va INIT_CTX(); ret = libxl_device_disk_del(ctx, Int_val(domid), &c_info, 0); if (ret != 0) - failwith_xl("disk_remove", &lg); + failwith_xl("disk_del", &lg); FREE_CTX(); CAMLreturn(Val_unit); } _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-20 16:15 UTC
[Xen-devel] [PATCH 15 of 32] tools: ocaml: rename the console types and functions
# HG changeset patch # User David Scott <dave.scott@eu.citrix.com> # Date 1301507668 -3600 # Node ID b283510b15423d7d64dc0779835822bbfbf6ed94 # Parent 3d4209b8a54a00c00acb414b8a706940c29d073e tools: ocaml: rename the console types and functions The aims are: 1. make the records instantiable if they have field names in common; and 2. to make it easier to derive the names programatically from the IDL Signed-off-by: David Scott <dave.scott@eu.citrix.com> Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 3d4209b8a54a -r b283510b1542 tools/ocaml/libs/xl/xl.ml --- a/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100 +++ b/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100 @@ -123,12 +123,16 @@ type console_type | CONSOLETYPE_XENCONSOLED | CONSOLETYPE_IOEMU -type console_info -{ - backend_domid : domid; - devid : int; - consoletype : console_type; -} +module Device_console = struct + type t + { + backend_domid : domid; + devid : int; + consoletype : console_type; + } + + external add : t -> build_state -> domid -> unit = "stub_xl_device_console_add" +end type vkb_info { @@ -196,8 +200,6 @@ type sched_credit external domain_make : create_info -> domid = "stub_xl_domain_make" external domain_build : build_info -> domid -> build_state = "stub_xl_domain_build" -external console_add : console_info -> build_state -> domid -> unit = "stub_xl_console_add" - external vkb_add : vkb_info -> domid -> unit = "stub_xl_vkb_add" external vkb_clean_shutdown : domid -> unit = "stub_vkb_clean_shutdown" external vkb_hard_shutdown : domid -> unit = "stub_vkb_hard_shutdown" diff -r 3d4209b8a54a -r b283510b1542 tools/ocaml/libs/xl/xl.mli --- a/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100 +++ b/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100 @@ -123,12 +123,16 @@ type console_type | CONSOLETYPE_XENCONSOLED | CONSOLETYPE_IOEMU -type console_info -{ - backend_domid : domid; - devid : int; - consoletype : console_type; -} +module Device_console : sig + type t + { + backend_domid : domid; + devid : int; + consoletype : console_type; + } + + external add : t -> build_state -> domid -> unit = "stub_xl_device_console_add" +end type vkb_info { @@ -196,8 +200,6 @@ type sched_credit external domain_make : create_info -> domid = "stub_xl_domain_make" external domain_build : build_info -> domid -> build_state = "stub_xl_domain_build" -external console_add : console_info -> build_state -> domid -> unit = "stub_xl_console_add" - external vkb_add : vkb_info -> domid -> unit = "stub_xl_vkb_add" external vkb_clean_shutdown : domid -> unit = "stub_vkb_clean_shutdown" external vkb_hard_shutdown : domid -> unit = "stub_vkb_hard_shutdown" diff -r 3d4209b8a54a -r b283510b1542 tools/ocaml/libs/xl/xl_stubs.c --- a/tools/ocaml/libs/xl/xl_stubs.c Wed Mar 30 18:54:28 2011 +0100 +++ b/tools/ocaml/libs/xl/xl_stubs.c Wed Mar 30 18:54:28 2011 +0100 @@ -436,7 +436,7 @@ value stub_xl_device_nic_del(value info, CAMLreturn(Val_unit); } -value stub_xl_console_add(value info, value state, value domid) +value stub_xl_device_console_add(value info, value state, value domid) { CAMLparam3(info, state, domid); libxl_device_console c_info; _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-20 16:15 UTC
[Xen-devel] [PATCH 16 of 32] tools: ocaml: rename the vkb types and functions
# HG changeset patch # User David Scott <dave.scott@eu.citrix.com> # Date 1301507668 -3600 # Node ID 7a0a278c72290ea243a39792251df28a0f84e2fd # Parent b283510b15423d7d64dc0779835822bbfbf6ed94 tools: ocaml: rename the vkb types and functions The aims are: 1. make the records instantiable if they have field names in common; and 2. to make it easier to derive the names programatically from the IDL Signed-off-by: David Scott <dave.scott@eu.citrix.com> Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r b283510b1542 -r 7a0a278c7229 tools/ocaml/libs/xl/xl.ml --- a/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100 +++ b/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100 @@ -134,27 +134,39 @@ module Device_console = struct external add : t -> build_state -> domid -> unit = "stub_xl_device_console_add" end -type vkb_info -{ - backend_domid : domid; - devid : int; -} +module Device_vkb = struct + type t + { + backend_domid : domid; + devid : int; + } + + external add : t -> domid -> unit = "stub_xl_device_vkb_add" + external clean_shutdown : domid -> unit = "stub_xl_device_vkb_clean_shutdown" + external hard_shutdown : domid -> unit = "stub_xl_device_vkb_hard_shutdown" +end -type vfb_info -{ - backend_domid : domid; - devid : int; - vnc : bool; - vnclisten : string; - vncpasswd : string; - vncdisplay : int; - vncunused : bool; - keymap : string; - sdl : bool; - opengl : bool; - display : string; - xauthority : string; -} +module Device_vfb = struct + type t + { + backend_domid : domid; + devid : int; + vnc : bool; + vnclisten : string; + vncpasswd : string; + vncdisplay : int; + vncunused : bool; + keymap : string; + sdl : bool; + opengl : bool; + display : string; + xauthority : string; + } + external add : t -> domid -> unit = "stub_xl_device_vfb_add" + external clean_shutdown : domid -> unit = "stub_xl_device_vfb_clean_shutdown" + external hard_shutdown : domid -> unit = "stub_xl_device_vfb_hard_shutdown" +end + type pci_info { @@ -200,14 +212,6 @@ type sched_credit external domain_make : create_info -> domid = "stub_xl_domain_make" external domain_build : build_info -> domid -> build_state = "stub_xl_domain_build" -external vkb_add : vkb_info -> domid -> unit = "stub_xl_vkb_add" -external vkb_clean_shutdown : domid -> unit = "stub_vkb_clean_shutdown" -external vkb_hard_shutdown : domid -> unit = "stub_vkb_hard_shutdown" - -external vfb_add : vfb_info -> domid -> unit = "stub_xl_vfb_add" -external vfb_clean_shutdown : domid -> unit = "stub_vfb_clean_shutdown" -external vfb_hard_shutdown : domid -> unit = "stub_vfb_hard_shutdown" - external pci_add : pci_info -> domid -> unit = "stub_xl_pci_add" external pci_remove : pci_info -> domid -> unit = "stub_xl_pci_remove" external pci_shutdown : domid -> unit = "stub_xl_pci_shutdown" diff -r b283510b1542 -r 7a0a278c7229 tools/ocaml/libs/xl/xl.mli --- a/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100 +++ b/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100 @@ -134,27 +134,38 @@ module Device_console : sig external add : t -> build_state -> domid -> unit = "stub_xl_device_console_add" end -type vkb_info -{ - backend_domid : domid; - devid : int; -} +module Device_vkb : sig + type t + { + backend_domid : domid; + devid : int; + } + + external add : t -> domid -> unit = "stub_xl_device_vkb_add" + external clean_shutdown : domid -> unit = "stub_xl_device_vkb_clean_shutdown" + external hard_shutdown : domid -> unit = "stub_xl_device_vkb_hard_shutdown" +end -type vfb_info -{ - backend_domid : domid; - devid : int; - vnc : bool; - vnclisten : string; - vncpasswd : string; - vncdisplay : int; - vncunused : bool; - keymap : string; - sdl : bool; - opengl : bool; - display : string; - xauthority : string; -} +module Device_vfb : sig + type t + { + backend_domid : domid; + devid : int; + vnc : bool; + vnclisten : string; + vncpasswd : string; + vncdisplay : int; + vncunused : bool; + keymap : string; + sdl : bool; + opengl : bool; + display : string; + xauthority : string; + } + external add : t -> domid -> unit = "stub_xl_device_vfb_add" + external clean_shutdown : domid -> unit = "stub_xl_device_vfb_clean_shutdown" + external hard_shutdown : domid -> unit = "stub_xl_device_vfb_hard_shutdown" +end type pci_info { @@ -200,14 +211,6 @@ type sched_credit external domain_make : create_info -> domid = "stub_xl_domain_make" external domain_build : build_info -> domid -> build_state = "stub_xl_domain_build" -external vkb_add : vkb_info -> domid -> unit = "stub_xl_vkb_add" -external vkb_clean_shutdown : domid -> unit = "stub_vkb_clean_shutdown" -external vkb_hard_shutdown : domid -> unit = "stub_vkb_hard_shutdown" - -external vfb_add : vfb_info -> domid -> unit = "stub_xl_vfb_add" -external vfb_clean_shutdown : domid -> unit = "stub_vfb_clean_shutdown" -external vfb_hard_shutdown : domid -> unit = "stub_vfb_hard_shutdown" - external pci_add : pci_info -> domid -> unit = "stub_xl_pci_add" external pci_remove : pci_info -> domid -> unit = "stub_xl_pci_remove" external pci_shutdown : domid -> unit = "stub_xl_pci_shutdown" diff -r b283510b1542 -r 7a0a278c7229 tools/ocaml/libs/xl/xl_stubs.c --- a/tools/ocaml/libs/xl/xl_stubs.c Wed Mar 30 18:54:28 2011 +0100 +++ b/tools/ocaml/libs/xl/xl_stubs.c Wed Mar 30 18:54:28 2011 +0100 @@ -456,7 +456,7 @@ value stub_xl_device_console_add(value i CAMLreturn(Val_unit); } -value stub_xl_vkb_add(value info, value domid) +value stub_xl_device_vkb_add(value info, value domid) { CAMLparam2(info, domid); libxl_device_vkb c_info; @@ -474,7 +474,7 @@ value stub_xl_vkb_add(value info, value CAMLreturn(Val_unit); } -value stub_xl_vkb_clean_shutdown(value domid) +value stub_xl_device_vkb_clean_shutdown(value domid) { CAMLparam1(domid); int ret; @@ -489,7 +489,7 @@ value stub_xl_vkb_clean_shutdown(value d CAMLreturn(Val_unit); } -value stub_xl_vkb_hard_shutdown(value domid) +value stub_xl_device_vkb_hard_shutdown(value domid) { CAMLparam1(domid); int ret; @@ -504,7 +504,7 @@ value stub_xl_vkb_hard_shutdown(value do CAMLreturn(Val_unit); } -value stub_xl_vfb_add(value info, value domid) +value stub_xl_device_vfb_add(value info, value domid) { CAMLparam2(info, domid); libxl_device_vfb c_info; @@ -522,7 +522,7 @@ value stub_xl_vfb_add(value info, value CAMLreturn(Val_unit); } -value stub_xl_vfb_clean_shutdown(value domid) +value stub_xl_device_vfb_clean_shutdown(value domid) { CAMLparam1(domid); int ret; @@ -537,7 +537,7 @@ value stub_xl_vfb_clean_shutdown(value d CAMLreturn(Val_unit); } -value stub_xl_vfb_hard_shutdown(value domid) +value stub_xl_device_vfb_hard_shutdown(value domid) { CAMLparam1(domid); int ret; _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-20 16:15 UTC
[Xen-devel] [PATCH 17 of 32] tools: ocaml: rename the pci types and functions
# HG changeset patch # User David Scott <dave.scott@eu.citrix.com> # Date 1301507668 -3600 # Node ID 3a5022500b8206dd162f458d720917ba1ffdc1a7 # Parent 7a0a278c72290ea243a39792251df28a0f84e2fd tools: ocaml: rename the pci types and functions The aims are: 1. make the records instantiable if they have field names in common; and 2. to make it easier to derive the names programatically from the IDL Signed-off-by: David Scott <dave.scott@eu.citrix.com> Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 7a0a278c7229 -r 3a5022500b82 tools/ocaml/libs/xl/xl.ml --- a/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100 +++ b/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100 @@ -167,17 +167,22 @@ module Device_vfb = struct external hard_shutdown : domid -> unit = "stub_xl_device_vfb_hard_shutdown" end +module Device_pci = struct + type t + { + func : int; + dev : int; + bus : int; + domain : int; + vdevfn : int; + msitranslate : bool; + power_mgmt : bool; + } -type pci_info -{ - func : int; - dev : int; - bus : int; - domain : int; - vdevfn : int; - msitranslate : bool; - power_mgmt : bool; -} + external add : t -> domid -> unit = "stub_xl_device_pci_add" + external remove : t -> domid -> unit = "stub_xl_device_pci_remove" + external shutdown : domid -> unit = "stub_xl_device_pci_shutdown" +end type physinfo { @@ -212,10 +217,6 @@ type sched_credit external domain_make : create_info -> domid = "stub_xl_domain_make" external domain_build : build_info -> domid -> build_state = "stub_xl_domain_build" -external pci_add : pci_info -> domid -> unit = "stub_xl_pci_add" -external pci_remove : pci_info -> domid -> unit = "stub_xl_pci_remove" -external pci_shutdown : domid -> unit = "stub_xl_pci_shutdown" - type button | Button_Power | Button_Sleep diff -r 7a0a278c7229 -r 3a5022500b82 tools/ocaml/libs/xl/xl.mli --- a/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100 +++ b/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100 @@ -167,16 +167,22 @@ module Device_vfb : sig external hard_shutdown : domid -> unit = "stub_xl_device_vfb_hard_shutdown" end -type pci_info -{ - func : int; - dev : int; - bus : int; - domain : int; - vdevfn : int; - msitranslate : bool; - power_mgmt : bool; -} +module Device_pci : sig + type t + { + func : int; + dev : int; + bus : int; + domain : int; + vdevfn : int; + msitranslate : bool; + power_mgmt : bool; + } + + external add : t -> domid -> unit = "stub_xl_device_pci_add" + external remove : t -> domid -> unit = "stub_xl_device_pci_remove" + external shutdown : domid -> unit = "stub_xl_device_pci_shutdown" +end type physinfo { @@ -211,10 +217,6 @@ type sched_credit external domain_make : create_info -> domid = "stub_xl_domain_make" external domain_build : build_info -> domid -> build_state = "stub_xl_domain_build" -external pci_add : pci_info -> domid -> unit = "stub_xl_pci_add" -external pci_remove : pci_info -> domid -> unit = "stub_xl_pci_remove" -external pci_shutdown : domid -> unit = "stub_xl_pci_shutdown" - type button | Button_Power | Button_Sleep diff -r 7a0a278c7229 -r 3a5022500b82 tools/ocaml/libs/xl/xl_stubs.c --- a/tools/ocaml/libs/xl/xl_stubs.c Wed Mar 30 18:54:28 2011 +0100 +++ b/tools/ocaml/libs/xl/xl_stubs.c Wed Mar 30 18:54:28 2011 +0100 @@ -552,7 +552,7 @@ value stub_xl_device_vfb_hard_shutdown(v CAMLreturn(Val_unit); } -value stub_xl_pci_add(value info, value domid) +value stub_xl_device_pci_add(value info, value domid) { CAMLparam2(info, domid); libxl_device_pci c_info; @@ -570,7 +570,7 @@ value stub_xl_pci_add(value info, value CAMLreturn(Val_unit); } -value stub_xl_pci_remove(value info, value domid) +value stub_xl_device_pci_remove(value info, value domid) { CAMLparam2(info, domid); libxl_device_pci c_info; @@ -588,7 +588,7 @@ value stub_xl_pci_remove(value info, val CAMLreturn(Val_unit); } -value stub_xl_pci_shutdown(value domid) +value stub_xl_device_pci_shutdown(value domid) { CAMLparam1(domid); int ret; _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-20 16:15 UTC
[Xen-devel] [PATCH 18 of 32] tools: ocaml: remove the domain_make and domain_build functions since they don''t work
# HG changeset patch # User David Scott <dave.scott@eu.citrix.com> # Date 1301507668 -3600 # Node ID 6a224d7714c31b7eab5656a738ba08506c4d421e # Parent 3a5022500b8206dd162f458d720917ba1ffdc1a7 tools: ocaml: remove the domain_make and domain_build functions since they don''t work The actual stubs are missing so these are currently a trap for the unwary. Signed-off-by: David Scott <dave.scott@eu.citrix.com> Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 3a5022500b82 -r 6a224d7714c3 tools/ocaml/libs/xl/xl.ml --- a/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100 +++ b/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100 @@ -214,9 +214,6 @@ type sched_credit cap: int; } -external domain_make : create_info -> domid = "stub_xl_domain_make" -external domain_build : build_info -> domid -> build_state = "stub_xl_domain_build" - type button | Button_Power | Button_Sleep diff -r 3a5022500b82 -r 6a224d7714c3 tools/ocaml/libs/xl/xl.mli --- a/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100 +++ b/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100 @@ -214,9 +214,6 @@ type sched_credit cap: int; } -external domain_make : create_info -> domid = "stub_xl_domain_make" -external domain_build : build_info -> domid -> build_state = "stub_xl_domain_build" - type button | Button_Power | Button_Sleep _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-20 16:15 UTC
[Xen-devel] [PATCH 19 of 32] tools: ocaml: rename the create_info types and functions
# HG changeset patch # User David Scott <dave.scott@eu.citrix.com> # Date 1301507668 -3600 # Node ID 84f9158ee75907574edc2ce633c9c4bb31f661b6 # Parent 6a224d7714c31b7eab5656a738ba08506c4d421e tools: ocaml: rename the create_info types and functions The aims are: 1. make the records instantiable if they have field names in common; and 2. to make it easier to derive the names programatically from the IDL Signed-off-by: David Scott <dave.scott@eu.citrix.com> Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 6a224d7714c3 -r 84f9158ee759 tools/ocaml/libs/xl/xl.ml --- a/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100 +++ b/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100 @@ -15,19 +15,21 @@ exception Error of string -type create_info -{ - hvm : bool; - hap : bool; - oos : bool; - ssidref : int32; - name : string; - uuid : int array; - xsdata : (string * string) list; - platformdata : (string * string) list; - poolid : int32; - poolname : string; -} +module Domain_create_info = struct + type t + { + hvm : bool; + hap : bool; + oos : bool; + ssidref : int32; + name : string; + uuid : int array; + xsdata : (string * string) list; + platformdata : (string * string) list; + poolid : int32; + poolname : string; + } +end type build_pv_info { diff -r 6a224d7714c3 -r 84f9158ee759 tools/ocaml/libs/xl/xl.mli --- a/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100 +++ b/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100 @@ -15,19 +15,21 @@ exception Error of string -type create_info -{ - hvm : bool; - hap : bool; - oos : bool; - ssidref : int32; - name : string; - uuid : int array; - xsdata : (string * string) list; - platformdata : (string * string) list; - poolid : int32; - poolname : string; -} +module Domain_create_info : sig + type t + { + hvm : bool; + hap : bool; + oos : bool; + ssidref : int32; + name : string; + uuid : int array; + xsdata : (string * string) list; + platformdata : (string * string) list; + poolid : int32; + poolname : string; + } +end type build_pv_info { _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-20 16:15 UTC
[Xen-devel] [PATCH 20 of 32] tools: ocaml: rename the build_info types and functions
# HG changeset patch # User David Scott <dave.scott@eu.citrix.com> # Date 1301507668 -3600 # Node ID 099897496a90fc8720e9e7881b750d35b178fb4c # Parent 84f9158ee75907574edc2ce633c9c4bb31f661b6 tools: ocaml: rename the build_info types and functions The aims are: 1. make the records instantiable if they have field names in common; and 2. to make it easier to derive the names programatically from the IDL Signed-off-by: David Scott <dave.scott@eu.citrix.com> Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 84f9158ee759 -r 099897496a90 tools/ocaml/libs/xl/xl.ml --- a/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100 +++ b/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100 @@ -31,40 +31,44 @@ module Domain_create_info = struct } end -type build_pv_info -{ - slack_memkb : int64; - cmdline : string; - ramdisk : string; - features : string; -} +module Domain_build_info = struct + module Hvm = struct + type t + { + pae : bool; + apic : bool; + acpi : bool; + nx : bool; + viridian : bool; + timeoffset : string; + timer_mode : int; + hpet : int; + vpt_align : int; + } + end -type build_hvm_info -{ - pae : bool; - apic : bool; - acpi : bool; - nx : bool; - viridian : bool; - timeoffset : string; - timer_mode : int; - hpet : int; - vpt_align : int; -} + module Pv = struct + type t + { + slack_memkb : int64; + cmdline : string; + ramdisk : string; + features : string; + } + end -type build_spec = BuildHVM of build_hvm_info | BuildPV of build_pv_info - -type build_info -{ - max_vcpus : int; - cur_vcpus : int; - max_memkb : int64; - target_memkb : int64; - video_memkb : int64; - shadow_memkb : int64; - kernel : string; - priv: build_spec; -} + type t + { + max_vcpus : int; + cur_vcpus : int; + max_memkb : int64; + target_memkb : int64; + video_memkb : int64; + shadow_memkb : int64; + kernel : string; + u : [ `HVM of Hvm.t | `PV of Pv.t ]; + } +end type build_state { diff -r 84f9158ee759 -r 099897496a90 tools/ocaml/libs/xl/xl.mli --- a/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100 +++ b/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100 @@ -31,40 +31,44 @@ module Domain_create_info : sig } end -type build_pv_info -{ - slack_memkb : int64; - cmdline : string; - ramdisk : string; - features : string; -} +module Domain_build_info : sig + module Hvm : sig + type t + { + pae : bool; + apic : bool; + acpi : bool; + nx : bool; + viridian : bool; + timeoffset : string; + timer_mode : int; + hpet : int; + vpt_align : int; + } + end -type build_hvm_info -{ - pae : bool; - apic : bool; - acpi : bool; - nx : bool; - viridian : bool; - timeoffset : string; - timer_mode : int; - hpet : int; - vpt_align : int; -} + module Pv : sig + type t + { + slack_memkb : int64; + cmdline : string; + ramdisk : string; + features : string; + } + end -type build_spec = BuildHVM of build_hvm_info | BuildPV of build_pv_info - -type build_info -{ - max_vcpus : int; - cur_vcpus : int; - max_memkb : int64; - target_memkb : int64; - video_memkb : int64; - shadow_memkb : int64; - kernel : string; - priv: build_spec; -} + type t + { + max_vcpus : int; + cur_vcpus : int; + max_memkb : int64; + target_memkb : int64; + video_memkb : int64; + shadow_memkb : int64; + kernel : string; + u : [ `HVM of Hvm.t | `PV of Pv.t ]; + } +end type build_state { _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-20 16:15 UTC
[Xen-devel] [PATCH 21 of 32] tools: ocaml: rename the domain_build_state types and functions
# HG changeset patch # User David Scott <dave.scott@eu.citrix.com> # Date 1301507668 -3600 # Node ID 4d51775a57f71338e86f2752ad44462ba69d6ba6 # Parent 099897496a90fc8720e9e7881b750d35b178fb4c tools: ocaml: rename the domain_build_state types and functions The aims are: 1. make the records instantiable if they have field names in common; and 2. to make it easier to derive the names programatically from the IDL Signed-off-by: David Scott <dave.scott@eu.citrix.com> Signed-off-by: Ian Campbell <ian.campbell@citrix.com> [ijc: s/Device_build_state/Domain_build_state/g] diff -r 099897496a90 -r 4d51775a57f7 tools/ocaml/libs/xl/xl.ml --- a/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100 +++ b/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100 @@ -70,13 +70,15 @@ module Domain_build_info = struct } end -type build_state -{ - store_port : int; - store_mfn : int64; - console_port : int; - console_mfn : int64; -} +module Domain_build_state = struct + type t + { + store_port : int; + store_mfn : int64; + console_port : int; + console_mfn : int64; + } +end type domid = int @@ -137,7 +139,7 @@ module Device_console = struct consoletype : console_type; } - external add : t -> build_state -> domid -> unit = "stub_xl_device_console_add" + external add : t -> Domain_build_state.t -> domid -> unit = "stub_xl_device_console_add" end module Device_vkb = struct diff -r 099897496a90 -r 4d51775a57f7 tools/ocaml/libs/xl/xl.mli --- a/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100 +++ b/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100 @@ -70,13 +70,15 @@ module Domain_build_info : sig } end -type build_state -{ - store_port : int; - store_mfn : int64; - console_port : int; - console_mfn : int64; -} +module Domain_build_state : sig + type t + { + store_port : int; + store_mfn : int64; + console_port : int; + console_mfn : int64; + } +end type domid = int @@ -137,7 +139,7 @@ module Device_console : sig consoletype : console_type; } - external add : t -> build_state -> domid -> unit = "stub_xl_device_console_add" + external add : t -> Domain_build_state.t -> domid -> unit = "stub_xl_device_console_add" end module Device_vkb : sig _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-20 16:15 UTC
[Xen-devel] [PATCH 22 of 32] tools: ocaml: rename the physinfo types and functions
# HG changeset patch # User David Scott <dave.scott@eu.citrix.com> # Date 1301507668 -3600 # Node ID 2b51da680128e2da4527278e6e119434fc37e50c # Parent 4d51775a57f71338e86f2752ad44462ba69d6ba6 tools: ocaml: rename the physinfo types and functions The aims are: 1. make the records instantiable if they have field names in common; and 2. to make it easier to derive the names programatically from the IDL Signed-off-by: David Scott <dave.scott@eu.citrix.com> Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 4d51775a57f7 -r 2b51da680128 tools/ocaml/libs/xl/xl.ml --- a/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100 +++ b/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100 @@ -192,20 +192,24 @@ module Device_pci = struct external shutdown : domid -> unit = "stub_xl_device_pci_shutdown" end -type physinfo -{ - threads_per_core: int; - cores_per_socket: int; - max_cpu_id: int; - nr_cpus: int; - cpu_khz: int; - total_pages: int64; - free_pages: int64; - scrub_pages: int64; - nr_nodes: int; - hwcap: int32 array; - physcap: int32; -} +module Physinfo = struct + type t + { + threads_per_core: int; + cores_per_socket: int; + max_cpu_id: int; + nr_cpus: int; + cpu_khz: int; + total_pages: int64; + free_pages: int64; + scrub_pages: int64; + nr_nodes: int; + hwcap: int32 array; + physcap: int32; + } + external get : unit -> t = "stub_xl_physinfo" + +end type topology = { @@ -227,7 +231,6 @@ type button | Button_Sleep external button_press : domid -> button -> unit = "stub_xl_button_press" -external physinfo : unit -> physinfo = "stub_xl_physinfo" external topologyinfo: unit -> topologyinfo = "stub_xl_topologyinfo" diff -r 4d51775a57f7 -r 2b51da680128 tools/ocaml/libs/xl/xl.mli --- a/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100 +++ b/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100 @@ -192,20 +192,24 @@ module Device_pci : sig external shutdown : domid -> unit = "stub_xl_device_pci_shutdown" end -type physinfo -{ - threads_per_core: int; - cores_per_socket: int; - max_cpu_id: int; - nr_cpus: int; - cpu_khz: int; - total_pages: int64; - free_pages: int64; - scrub_pages: int64; - nr_nodes: int; - hwcap: int32 array; - physcap: int32; -} +module Physinfo : sig + type t + { + threads_per_core: int; + cores_per_socket: int; + max_cpu_id: int; + nr_cpus: int; + cpu_khz: int; + total_pages: int64; + free_pages: int64; + scrub_pages: int64; + nr_nodes: int; + hwcap: int32 array; + physcap: int32; + } + external get : unit -> t = "stub_xl_physinfo" + +end type topology = { @@ -227,7 +231,6 @@ type button | Button_Sleep external button_press : domid -> button -> unit = "stub_xl_button_press" -external physinfo : unit -> physinfo = "stub_xl_physinfo" external topologyinfo: unit -> topologyinfo = "stub_xl_topologyinfo" _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-20 16:15 UTC
[Xen-devel] [PATCH 23 of 32] tools: ocaml: rename the sched_credit types and functions
# HG changeset patch # User David Scott <dave.scott@eu.citrix.com> # Date 1301507668 -3600 # Node ID 505d103d8f6f0a62999d17e46e345faced1e1312 # Parent 2b51da680128e2da4527278e6e119434fc37e50c tools: ocaml: rename the sched_credit types and functions The aims are: 1. make the records instantiable if they have field names in common; and 2. to make it easier to derive the names programatically from the IDL Signed-off-by: David Scott <dave.scott@eu.citrix.com> Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 2b51da680128 -r 505d103d8f6f tools/ocaml/libs/xl/xl.ml --- a/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100 +++ b/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100 @@ -220,11 +220,15 @@ type topology type topologyinfo = topology option array -type sched_credit -{ - weight: int; - cap: int; -} +module Sched_credit = struct + type t + { + weight: int; + cap: int; + } + external domain_get : domid -> t = "stub_xl_sched_credit_domain_get" + external domain_set : domid -> t -> unit = "stub_xl_sched_credit_domain_set" +end type button | Button_Power @@ -234,9 +238,6 @@ external button_press : domid -> button external topologyinfo: unit -> topologyinfo = "stub_xl_topologyinfo" -external domain_sched_credit_get : domid -> sched_credit = "stub_xl_sched_credit_domain_get" -external domain_sched_credit_set : domid -> sched_credit -> unit = "stub_xl_sched_credit_domain_set" - external send_trigger : domid -> string -> int -> unit = "stub_xl_send_trigger" external send_sysrq : domid -> char -> unit = "stub_xl_send_sysrq" external send_debug_keys : domid -> string -> unit = "stub_xl_send_debug_keys" diff -r 2b51da680128 -r 505d103d8f6f tools/ocaml/libs/xl/xl.mli --- a/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100 +++ b/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100 @@ -220,11 +220,16 @@ type topology type topologyinfo = topology option array -type sched_credit -{ - weight: int; - cap: int; -} +module Sched_credit : sig + type t + { + weight: int; + cap: int; + } + + external domain_get : domid -> t = "stub_xl_sched_credit_domain_get" + external domain_set : domid -> t -> unit = "stub_xl_sched_credit_domain_set" +end type button | Button_Power @@ -234,9 +239,6 @@ external button_press : domid -> button external topologyinfo: unit -> topologyinfo = "stub_xl_topologyinfo" -external domain_sched_credit_get : domid -> sched_credit = "stub_xl_sched_credit_domain_get" -external domain_sched_credit_set : domid -> sched_credit -> unit = "stub_xl_sched_credit_domain_set" - external send_trigger : domid -> string -> int -> unit = "stub_xl_send_trigger" external send_sysrq : domid -> char -> unit = "stub_xl_send_sysrq" external send_debug_keys : domid -> string -> unit = "stub_xl_send_debug_keys" _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-20 16:15 UTC
[Xen-devel] [PATCH 24 of 32] tools: ocaml: rename the topology types and functions
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1303315987 -3600 # Node ID 369b10a8649aedc7ff68f74275b50d40bbe08bdb # Parent 505d103d8f6f0a62999d17e46e345faced1e1312 tools: ocaml: rename the topology types and functions The aims are: 1. make the records instantiable if they have field names in common; and 2. to make it easier to derive the names programatically from the IDL Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Cc: David Scott <dave.scott@eu.citrix.com> diff -r 505d103d8f6f -r 369b10a8649a tools/ocaml/libs/xl/xl.ml --- a/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100 +++ b/tools/ocaml/libs/xl/xl.ml Wed Apr 20 17:13:07 2011 +0100 @@ -211,14 +211,15 @@ module Physinfo = struct end -type topology = -{ - core: int; - socket: int; - node: int; -} - -type topologyinfo = topology option array +module Topologyinfo = struct + type t + { + core: int; + socket: int; + node: int; + } + external get: unit -> t = "stub_xl_topologyinfo" +end module Sched_credit = struct type t @@ -236,7 +237,6 @@ type button external button_press : domid -> button -> unit = "stub_xl_button_press" -external topologyinfo: unit -> topologyinfo = "stub_xl_topologyinfo" external send_trigger : domid -> string -> int -> unit = "stub_xl_send_trigger" external send_sysrq : domid -> char -> unit = "stub_xl_send_sysrq" diff -r 505d103d8f6f -r 369b10a8649a tools/ocaml/libs/xl/xl.mli --- a/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100 +++ b/tools/ocaml/libs/xl/xl.mli Wed Apr 20 17:13:07 2011 +0100 @@ -211,14 +211,15 @@ module Physinfo : sig end -type topology = -{ - core: int; - socket: int; - node: int; -} - -type topologyinfo = topology option array +module Topologyinfo : sig + type t + { + core: int; + socket: int; + node: int; + } + external get : unit -> t = "stub_xl_topologyinfo" +end module Sched_credit : sig type t @@ -237,8 +238,6 @@ type button external button_press : domid -> button -> unit = "stub_xl_button_press" -external topologyinfo: unit -> topologyinfo = "stub_xl_topologyinfo" - external send_trigger : domid -> string -> int -> unit = "stub_xl_send_trigger" external send_sysrq : domid -> char -> unit = "stub_xl_send_sysrq" external send_debug_keys : domid -> string -> unit = "stub_xl_send_debug_keys" _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-20 16:15 UTC
[Xen-devel] [PATCH 25 of 32] tools: libxl: remove libxl_domain_build_state from the IDL
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1303315987 -3600 # Node ID a560df9ad19d5b3ca409c325f0a498e31647efaa # Parent 369b10a8649aedc7ff68f74275b50d40bbe08bdb tools: libxl: remove libxl_domain_build_state from the IDL This datastructure is internal to the library. Remove the reference from libxl_device_console. This could never have been used from outside libxl and is only used internally to add the primary PV console to a guest. Make an internal variant of libxl_device_console_add which takes the build state as a parameter instead. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 369b10a8649a -r a560df9ad19d tools/libxl/libxl.c --- a/tools/libxl/libxl.c Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/libxl/libxl.c Wed Apr 20 17:13:07 2011 +0100 @@ -1389,14 +1389,20 @@ err: } /******************************************************************************/ -int libxl_device_console_add(libxl_ctx *ctx, uint32_t domid, libxl_device_console *console) +int libxl__device_console_add(libxl__gc *gc, uint32_t domid, + libxl_device_console *console, + libxl__domain_build_state *state) { - libxl__gc gc = LIBXL_INIT_GC(ctx); flexarray_t *front; flexarray_t *back; libxl__device device; int rc; + if (console->devid && state) { + rc = ERROR_INVAL; + goto out; + } + front = flexarray_make(16, 1); if (!front) { rc = ERROR_NOMEM; @@ -1416,20 +1422,20 @@ int libxl_device_console_add(libxl_ctx * device.kind = DEVICE_CONSOLE; flexarray_append(back, "frontend-id"); - flexarray_append(back, libxl__sprintf(&gc, "%d", domid)); + flexarray_append(back, libxl__sprintf(gc, "%d", domid)); flexarray_append(back, "online"); flexarray_append(back, "1"); flexarray_append(back, "state"); - flexarray_append(back, libxl__sprintf(&gc, "%d", 1)); + flexarray_append(back, libxl__sprintf(gc, "%d", 1)); flexarray_append(back, "domain"); - flexarray_append(back, libxl__domid_to_name(&gc, domid)); + flexarray_append(back, libxl__domid_to_name(gc, domid)); flexarray_append(back, "protocol"); flexarray_append(back, LIBXL_XENCONSOLE_PROTOCOL); flexarray_append(front, "backend-id"); - flexarray_append(front, libxl__sprintf(&gc, "%d", console->backend_domid)); + flexarray_append(front, libxl__sprintf(gc, "%d", console->backend_domid)); flexarray_append(front, "limit"); - flexarray_append(front, libxl__sprintf(&gc, "%d", LIBXL_XENCONSOLE_LIMIT)); + flexarray_append(front, libxl__sprintf(gc, "%d", LIBXL_XENCONSOLE_LIMIT)); flexarray_append(front, "type"); if (console->consback == LIBXL_CONSOLE_BACKEND_XENCONSOLED) flexarray_append(front, "xenconsoled"); @@ -1438,30 +1444,37 @@ int libxl_device_console_add(libxl_ctx * flexarray_append(front, "output"); flexarray_append(front, console->output); - if (device.devid == 0) { - if (console->build_state == NULL) { - rc = ERROR_INVAL; - goto out_free; - } + if (state) { flexarray_append(front, "port"); - flexarray_append(front, libxl__sprintf(&gc, "%"PRIu32, console->build_state->console_port)); + flexarray_append(front, libxl__sprintf(gc, "%"PRIu32, state->console_port)); flexarray_append(front, "ring-ref"); - flexarray_append(front, libxl__sprintf(&gc, "%lu", console->build_state->console_mfn)); + flexarray_append(front, libxl__sprintf(gc, "%lu", state->console_mfn)); } else { flexarray_append(front, "state"); - flexarray_append(front, libxl__sprintf(&gc, "%d", 1)); + flexarray_append(front, libxl__sprintf(gc, "%d", 1)); flexarray_append(front, "protocol"); flexarray_append(front, LIBXL_XENCONSOLE_PROTOCOL); } - libxl__device_generic_add(&gc, &device, - libxl__xs_kvs_of_flexarray(&gc, back, back->count), - libxl__xs_kvs_of_flexarray(&gc, front, front->count)); + libxl__device_generic_add(gc, &device, + libxl__xs_kvs_of_flexarray(gc, back, back->count), + libxl__xs_kvs_of_flexarray(gc, front, front->count)); rc = 0; out_free: flexarray_free(back); flexarray_free(front); out: + return rc; +} + +int libxl_device_console_add(libxl_ctx *ctx, uint32_t domid, + libxl_device_console *console) +{ + libxl__gc gc = LIBXL_INIT_GC(ctx); + int rc = ERROR_INVAL; + + rc = libxl__device_console_add(&gc, domid, console, NULL); + libxl__free_all(&gc); return rc; } diff -r 369b10a8649a -r a560df9ad19d tools/libxl/libxl.idl --- a/tools/libxl/libxl.idl Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/libxl/libxl.idl Wed Apr 20 17:13:07 2011 +0100 @@ -190,13 +190,6 @@ by libxl_domain_build/restore. If either then the user is responsible for calling libxl_file_reference_unmap.""") -libxl_domain_build_state = Struct("domain_build_state",[ - ("store_port", uint32), - ("store_mfn", unsigned_long), - ("console_port", uint32), - ("console_mfn", unsigned_long), - ], destructor_fn=None) - libxl_device_model_info = Struct("device_model_info",[ ("domid", libxl_domid), ("uuid", libxl_uuid, False, "this is use only with stubdom, and must be different from the domain uuid"), @@ -259,7 +252,6 @@ libxl_device_console = Struct("device_co ("backend_domid", libxl_domid), ("devid", integer), ("consback", libxl_console_backend), - ("build_state", Reference(libxl_domain_build_state), True), ("output", string), ]) diff -r 369b10a8649a -r a560df9ad19d tools/libxl/libxl_create.c --- a/tools/libxl/libxl_create.c Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/libxl/libxl_create.c Wed Apr 20 17:13:07 2011 +0100 @@ -133,7 +133,7 @@ void libxl_init_dm_info(libxl_device_mod dm_info->xen_platform_pci = 1; } -static int init_console_info(libxl_device_console *console, int dev_num, libxl_domain_build_state *state) +static int init_console_info(libxl_device_console *console, int dev_num) { memset(console, 0x00, sizeof(libxl_device_console)); console->devid = dev_num; @@ -141,12 +141,11 @@ static int init_console_info(libxl_devic console->output = strdup("pty"); if ( NULL == console->output ) return ERROR_NOMEM; - if (state) - console->build_state = state; return 0; } -int libxl__domain_build(libxl__gc *gc, libxl_domain_build_info *info, uint32_t domid, libxl_domain_build_state *state) +int libxl__domain_build(libxl__gc *gc, libxl_domain_build_info *info, + uint32_t domid, libxl__domain_build_state *state) { char **vments = NULL, **localents = NULL; struct timeval start_time; @@ -198,7 +197,8 @@ out: } static int domain_restore(libxl__gc *gc, libxl_domain_build_info *info, - uint32_t domid, int fd, libxl_domain_build_state *state, + uint32_t domid, int fd, + libxl__domain_build_state *state, libxl_device_model_info *dm_info) { libxl_ctx *ctx = libxl__gc_owner(gc); @@ -403,7 +403,7 @@ static int do_domain_create(libxl__gc *g libxl_ctx *ctx = libxl__gc_owner(gc); libxl__device_model_starting *dm_starting = 0; libxl_device_model_info *dm_info = &d_config->dm_info; - libxl_domain_build_state state; + libxl__domain_build_state state; uint32_t domid; int i, ret; @@ -464,10 +464,10 @@ static int do_domain_create(libxl__gc *g if (d_config->c_info.hvm) { libxl_device_console console; - ret = init_console_info(&console, 0, &state); + ret = init_console_info(&console, 0); if ( ret ) goto error_out; - libxl_device_console_add(ctx, domid, &console); + libxl__device_console_add(gc, domid, &console, &state); libxl_device_console_destroy(&console); dm_info->domid = domid; @@ -489,7 +489,7 @@ static int do_domain_create(libxl__gc *g libxl_device_vkb_add(ctx, domid, &d_config->vkbs[i]); } - ret = init_console_info(&console, 0, &state); + ret = init_console_info(&console, 0); if ( ret ) goto error_out; @@ -500,7 +500,7 @@ static int do_domain_create(libxl__gc *g if (need_qemu) console.consback = LIBXL_CONSOLE_BACKEND_IOEMU; - libxl_device_console_add(ctx, domid, &console); + libxl__device_console_add(gc, domid, &console, &state); libxl_device_console_destroy(&console); if (need_qemu) diff -r 369b10a8649a -r a560df9ad19d tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/libxl/libxl_dm.c Wed Apr 20 17:13:07 2011 +0100 @@ -569,7 +569,7 @@ static int libxl__create_stubdom(libxl__ libxl_device_console *console; libxl_domain_create_info c_info; libxl_domain_build_info b_info; - libxl_domain_build_state state; + libxl__domain_build_state state; uint32_t domid; char **args; struct xs_permissions perm[2]; @@ -684,7 +684,6 @@ retry_transaction: name = libxl__sprintf(gc, "qemu-dm-%s", libxl_domid_to_name(ctx, info->domid)); libxl_create_logfile(ctx, name, &filename); console[i].output = libxl__sprintf(gc, "file:%s", filename); - console[i].build_state = &state; free(filename); break; case STUBDOM_CONSOLE_SAVE: @@ -698,7 +697,8 @@ retry_transaction: console[i].output = "pty"; break; } - ret = libxl_device_console_add(ctx, domid, &console[i]); + ret = libxl__device_console_add(gc, domid, &console[i], + i == STUBDOM_CONSOLE_LOGGING ? &state : NULL); if (ret) goto out_free; } diff -r 369b10a8649a -r a560df9ad19d tools/libxl/libxl_dom.c --- a/tools/libxl/libxl_dom.c Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/libxl/libxl_dom.c Wed Apr 20 17:13:07 2011 +0100 @@ -67,7 +67,7 @@ int libxl__domain_shutdown_reason(libxl_ } int libxl__build_pre(libxl__gc *gc, uint32_t domid, - libxl_domain_build_info *info, libxl_domain_build_state *state) + libxl_domain_build_info *info, libxl__domain_build_state *state) { libxl_ctx *ctx = libxl__gc_owner(gc); xc_domain_max_vcpus(ctx->xch, domid, info->max_vcpus); @@ -91,8 +91,9 @@ int libxl__build_pre(libxl__gc *gc, uint } int libxl__build_post(libxl__gc *gc, uint32_t domid, - libxl_domain_build_info *info, libxl_domain_build_state *state, - char **vms_ents, char **local_ents) + libxl_domain_build_info *info, + libxl__domain_build_state *state, + char **vms_ents, char **local_ents) { libxl_ctx *ctx = libxl__gc_owner(gc); char *dom_path, *vm_path; @@ -145,7 +146,7 @@ retry_transaction: } int libxl__build_pv(libxl__gc *gc, uint32_t domid, - libxl_domain_build_info *info, libxl_domain_build_state *state) + libxl_domain_build_info *info, libxl__domain_build_state *state) { libxl_ctx *ctx = libxl__gc_owner(gc); struct xc_dom_image *dom; @@ -277,7 +278,7 @@ static const char *libxl__domain_hvmload } int libxl__build_hvm(libxl__gc *gc, uint32_t domid, - libxl_domain_build_info *info, libxl_domain_build_state *state) + libxl_domain_build_info *info, libxl__domain_build_state *state) { libxl_ctx *ctx = libxl__gc_owner(gc); int ret, rc = ERROR_INVAL; @@ -305,8 +306,9 @@ out: } int libxl__domain_restore_common(libxl__gc *gc, uint32_t domid, - libxl_domain_build_info *info, libxl_domain_build_state *state, - int fd) + libxl_domain_build_info *info, + libxl__domain_build_state *state, + int fd) { libxl_ctx *ctx = libxl__gc_owner(gc); /* read signature */ diff -r 369b10a8649a -r a560df9ad19d tools/libxl/libxl_internal.h --- a/tools/libxl/libxl_internal.h Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/libxl/libxl_internal.h Wed Apr 20 17:13:07 2011 +0100 @@ -169,23 +169,33 @@ _hidden char **libxl__xs_directory(libxl _hidden int libxl__domain_is_hvm(libxl__gc *gc, uint32_t domid); _hidden int libxl__domain_shutdown_reason(libxl__gc *gc, uint32_t domid); +typedef struct { + uint32_t store_port; + unsigned long store_mfn; + + uint32_t console_port; + unsigned long console_mfn; +} libxl__domain_build_state; + _hidden int libxl__build_pre(libxl__gc *gc, uint32_t domid, - libxl_domain_build_info *info, libxl_domain_build_state *state); + libxl_domain_build_info *info, libxl__domain_build_state *state); _hidden int libxl__build_post(libxl__gc *gc, uint32_t domid, - libxl_domain_build_info *info, libxl_domain_build_state *state, + libxl_domain_build_info *info, libxl__domain_build_state *state, char **vms_ents, char **local_ents); _hidden int libxl__build_pv(libxl__gc *gc, uint32_t domid, - libxl_domain_build_info *info, libxl_domain_build_state *state); + libxl_domain_build_info *info, libxl__domain_build_state *state); _hidden int libxl__build_hvm(libxl__gc *gc, uint32_t domid, - libxl_domain_build_info *info, libxl_domain_build_state *state); + libxl_domain_build_info *info, libxl__domain_build_state *state); _hidden int libxl__domain_rename(libxl__gc *gc, uint32_t domid, const char *old_name, const char *new_name, xs_transaction_t trans); _hidden int libxl__domain_restore_common(libxl__gc *gc, uint32_t domid, - libxl_domain_build_info *info, libxl_domain_build_state *state, int fd); + libxl_domain_build_info *info, + libxl__domain_build_state *state, + int fd); _hidden int libxl__domain_suspend_common(libxl__gc *gc, uint32_t domid, int fd, int hvm, int live, int debug); _hidden int libxl__domain_save_device_model(libxl__gc *gc, uint32_t domid, int fd); _hidden void libxl__userdata_destroyall(libxl__gc *gc, uint32_t domid); @@ -198,6 +208,10 @@ _hidden int libxl__device_physdisk_major _hidden int libxl__device_disk_dev_number(char *virtpath, int *pdisk, int *ppartition); +_hidden int libxl__device_console_add(libxl__gc *gc, uint32_t domid, + libxl_device_console *console, + libxl__domain_build_state *state); + _hidden int libxl__device_generic_add(libxl__gc *gc, libxl__device *device, char **bents, char **fents); _hidden char *libxl__device_backend_path(libxl__gc *gc, libxl__device *device); @@ -230,7 +244,9 @@ typedef struct { /* from xl_create */ _hidden int libxl__domain_make(libxl__gc *gc, libxl_domain_create_info *info, uint32_t *domid); -_hidden int libxl__domain_build(libxl__gc *gc, libxl_domain_build_info *info, uint32_t domid, /* out */ libxl_domain_build_state *state); +_hidden int libxl__domain_build(libxl__gc *gc, libxl_domain_build_info *info, + uint32_t domid, + libxl__domain_build_state *state); /* for device model creation */ _hidden const char *libxl__domain_device_model(libxl__gc *gc, diff -r 369b10a8649a -r a560df9ad19d tools/ocaml/libs/xl/xl.ml --- a/tools/ocaml/libs/xl/xl.ml Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/ocaml/libs/xl/xl.ml Wed Apr 20 17:13:07 2011 +0100 @@ -70,16 +70,6 @@ module Domain_build_info = struct } end -module Domain_build_state = struct - type t - { - store_port : int; - store_mfn : int64; - console_port : int; - console_mfn : int64; - } -end - type domid = int type disk_phystype @@ -139,7 +129,7 @@ module Device_console = struct consoletype : console_type; } - external add : t -> Domain_build_state.t -> domid -> unit = "stub_xl_device_console_add" + external add : t -> domid -> unit = "stub_xl_device_console_add" end module Device_vkb = struct diff -r 369b10a8649a -r a560df9ad19d tools/ocaml/libs/xl/xl.mli --- a/tools/ocaml/libs/xl/xl.mli Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/ocaml/libs/xl/xl.mli Wed Apr 20 17:13:07 2011 +0100 @@ -70,16 +70,6 @@ module Domain_build_info : sig } end -module Domain_build_state : sig - type t - { - store_port : int; - store_mfn : int64; - console_port : int; - console_mfn : int64; - } -end - type domid = int type disk_phystype @@ -139,7 +129,7 @@ module Device_console : sig consoletype : console_type; } - external add : t -> Domain_build_state.t -> domid -> unit = "stub_xl_device_console_add" + external add : t -> domid -> unit = "stub_xl_device_console_add" end module Device_vkb : sig diff -r 369b10a8649a -r a560df9ad19d tools/ocaml/libs/xl/xl_stubs.c --- a/tools/ocaml/libs/xl/xl_stubs.c Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/ocaml/libs/xl/xl_stubs.c Wed Apr 20 17:13:07 2011 +0100 @@ -294,18 +294,6 @@ static int sched_credit_val(caml_gc *gc, CAMLreturn(0); } -static int domain_build_state_val(caml_gc *gc, libxl_domain_build_state *c_val, value v) -{ - CAMLparam1(v); - - c_val->store_port = Int_val(Field(v, 0)); - c_val->store_mfn = Int64_val(Field(v, 1)); - c_val->console_port = Int_val(Field(v, 2)); - c_val->console_mfn = Int64_val(Field(v, 3)); - - CAMLreturn(0); -} - static value Val_sched_credit(libxl_sched_credit *c_val) { CAMLparam0(); @@ -436,17 +424,14 @@ value stub_xl_device_nic_del(value info, CAMLreturn(Val_unit); } -value stub_xl_device_console_add(value info, value state, value domid) +value stub_xl_device_console_add(value info, value domid) { - CAMLparam3(info, state, domid); + CAMLparam2(info, domid); libxl_device_console c_info; - libxl_domain_build_state c_state; int ret; INIT_STRUCT(); device_console_val(&gc, &c_info, info); - domain_build_state_val(&gc, &c_state, state); - c_info.build_state = &c_state; INIT_CTX(); ret = libxl_device_console_add(ctx, Int_val(domid), &c_info); diff -r 369b10a8649a -r a560df9ad19d tools/python/xen/lowlevel/xl/xl.c --- a/tools/python/xen/lowlevel/xl/xl.c Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/python/xen/lowlevel/xl/xl.c Wed Apr 20 17:13:07 2011 +0100 @@ -232,12 +232,6 @@ int attrib__libxl_cpuarray_set(PyObject return -1; } -int attrib__libxl_domain_build_state_ptr_set(PyObject *v, libxl_domain_build_state **pptr) -{ - PyErr_SetString(PyExc_NotImplementedError, "Setting domain_build_state_ptr"); - return -1; -} - int attrib__libxl_file_reference_set(PyObject *v, libxl_file_reference *pptr) { return genwrap__string_set(v, &pptr->path); @@ -329,12 +323,6 @@ PyObject *attrib__libxl_cpuarray_get(lib return list; } -PyObject *attrib__libxl_domain_build_state_ptr_get(libxl_domain_build_state **pptr) -{ - PyErr_SetString(PyExc_NotImplementedError, "Getting domain_build_state_ptr"); - return NULL; -} - PyObject *attrib__libxl_file_reference_get(libxl_file_reference *pptr) { return genwrap__string_get(&pptr->path); _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-20 16:15 UTC
[Xen-devel] [PATCH 26 of 32] tools: libxl: remove Reference meta-type from IDL
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1303315987 -3600 # Node ID 3c08d944bc2485f99b16c4e923e2731307cfa623 # Parent a560df9ad19d5b3ca409c325f0a498e31647efaa tools: libxl: remove Reference meta-type from IDL It is tricky to map to language bindings and is now unused in any case. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r a560df9ad19d -r 3c08d944bc24 tools/libxl/gentypes.py --- a/tools/libxl/gentypes.py Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/libxl/gentypes.py Wed Apr 20 17:13:07 2011 +0100 @@ -78,13 +78,13 @@ def libxl_C_type_define(ty, indent = "") raise NotImplementedError("%s" % type(ty)) return s.replace("\n", "\n%s" % indent) -def libxl_C_type_destroy(ty, v, reference, indent = " ", parent = None): - if reference: +def libxl_C_type_destroy(ty, v, indent = " ", parent = None): + if parent is None: deref = v + "->" else: deref = v + "." - if ty.passby == libxltypes.PASS_BY_REFERENCE and not reference: + if ty.passby == libxltypes.PASS_BY_REFERENCE and parent is not None: makeref = "&" else: makeref = "" @@ -96,19 +96,15 @@ def libxl_C_type_destroy(ty, v, referenc 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 += libxl_C_type_destroy(f.type, deref + f.name, indent + " ", deref) s += "}\n" - elif 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) elif isinstance(ty, libxltypes.Struct) and (parent is None or ty.destructor_fn is None): for f in [f for f in ty.fields if not f.const]: if f.name is None: # Anonynous struct - s += libxl_C_type_destroy(f.type, deref, False, "", deref) + s += libxl_C_type_destroy(f.type, deref, "", deref) else: - s += libxl_C_type_destroy(f.type, deref + f.name, False, "", deref) + s += libxl_C_type_destroy(f.type, deref + f.name, "", deref) else: if ty.destructor_fn is not None: s += "%s(%s);\n" % (ty.destructor_fn, makeref + v) @@ -177,7 +173,7 @@ if __name__ == ''__main__'': for ty in [t for t in types if t.destructor_fn is not None and t.autogenerate_destructor]: f.write("void %s(%s *p)\n" % (ty.destructor_fn, ty.typename)) f.write("{\n") - f.write(libxl_C_type_destroy(ty, "p", True)) + f.write(libxl_C_type_destroy(ty, "p")) f.write(" memset(p, LIBXL_DTOR_POISON, sizeof(*p));\n") f.write("}\n") f.write("\n") diff -r a560df9ad19d -r 3c08d944bc24 tools/libxl/idl.txt --- a/tools/libxl/idl.txt Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/libxl/idl.txt Wed Apr 20 17:13:07 2011 +0100 @@ -64,13 +64,6 @@ libxltype.UInt The <N> for a given instance must be passed to the constructor and is then available in UInt.width -libxltype.Reference - - Instances of this type represent a reference to another type - - The referant type must be passed to the constructor and is then - available in Reference.ref_type - Complex type-Classes -------------------- diff -r a560df9ad19d -r 3c08d944bc24 tools/libxl/libxltypes.py --- a/tools/libxl/libxltypes.py Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/libxl/libxltypes.py Wed Apr 20 17:13:07 2011 +0100 @@ -153,24 +153,6 @@ class KeyedUnion(Aggregate): 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): - self.ref_type = ty - - # Ugh - - kwargs.setdefault(''destructor_fn'', "free") - kwargs.setdefault(''autogenerate_destructor'', False) - kwargs.setdefault(''passby'', PASS_BY_VALUE) - - kwargs.setdefault(''namespace'', ty.namespace) - - typename = ty.typename - if ty.namespace: - typename = typename[len(kwargs[''namespace'']):] - Type.__init__(self, typename + " *", **kwargs) - # # Standard Types # _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-20 16:15 UTC
[Xen-devel] [PATCH 27 of 32] tools: libxl: reduce number of integer types in the IDL
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1303315987 -3600 # Node ID b142d87fd70402aeaf10c860bbb44339e2eafde2 # Parent 3c08d944bc2485f99b16c4e923e2731307cfa623 tools: libxl: reduce number of integer types in the IDL Remove unsigned_interger, unsigned and unsigned_long in favour of the uintX types. Retain the integer type as a 24 bit signed integer. This will benefit language bindings for higher-level languages which don''t support the full machine int size. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 3c08d944bc24 -r b142d87fd704 tools/libxl/idl.txt --- a/tools/libxl/idl.txt Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/libxl/idl.txt Wed Apr 20 17:13:07 2011 +0100 @@ -143,10 +143,7 @@ Several standard types a predefined. The void (void pointer type) bool size_t -integer (C int type) -unsigned_integer (C unsigned int type) -unsigned (C unsigned int type) -unsigned_long (C unsigned long type) +integer 24 bit signed integer. uint{8,16,32,64} uint{8,16,32,64}_t diff -r 3c08d944bc24 -r b142d87fd704 tools/libxl/libxl.idl --- a/tools/libxl/libxl.idl Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/libxl/libxl.idl Wed Apr 20 17:13:07 2011 +0100 @@ -95,7 +95,7 @@ libxl_dominfo = Struct("dominfo",[ ("shutdown", bool), ("dying", bool), - ("shutdown_reason", unsigned, False, + ("shutdown_reason", uint8, False, """Valid SHUTDOWN_* value from xen/sched.h iff (shutdown||dying). Otherwise set to a value guaranteed not to clash with any valid @@ -129,8 +129,8 @@ libxl_version_info = Struct("version_inf ("compile_date", string), ("capabilities", string), ("changeset", string), - ("virt_start", unsigned_long), - ("pagesize", unsigned_long), + ("virt_start", uint64), + ("pagesize", integer), ("commandline", string), ]) @@ -157,7 +157,7 @@ libxl_domain_build_info = Struct("domain ("shadow_memkb", uint32), ("disable_migrate", bool), ("cpuid", libxl_cpuid_policy_list), - ("hvm", integer), + ("hvm", bool), ("u", KeyedUnion(None, "hvm", [("hvm", "%s", Struct(None, [("hvmloader", string), @@ -220,7 +220,7 @@ libxl_device_model_info = Struct("device ("apic", bool, False, "apic enabled or disabled"), ("vcpus", integer, False, "max number of vcpus"), ("vcpu_avail", integer, False, "vcpus actually available"), - ("xen_platform_pci", integer, False, "enable/disable the xen platform pci device"), + ("xen_platform_pci", bool, False, "enable/disable the xen platform pci device"), ("extra", libxl_string_list, False, "extra parameters pass directly to qemu, NULL terminated"), ], comment@@ -283,9 +283,9 @@ libxl_device_pci = Struct("device_pci", ("func", uint8), ("dev", uint8), ("bus", uint8), - ("domain", unsigned_integer), - ("vdevfn", unsigned_integer), - ("vfunc_mask", unsigned_integer), + ("domain", integer), + ("vdevfn", uint32), + ("vfunc_mask", uint32), ("msitranslate", bool), ("power_mgmt", bool), ]) diff -r 3c08d944bc24 -r b142d87fd704 tools/libxl/libxltypes.py --- a/tools/libxl/libxltypes.py Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/libxl/libxltypes.py Wed Apr 20 17:13:07 2011 +0100 @@ -162,9 +162,6 @@ bool = Builtin("bool", namespace = None) size_t = Number("size_t", namespace = None) integer = Number("int", namespace = None, signed = True) -unsigned_integer = Number("unsigned int", namespace = None) -unsigned = Number("unsigned int", namespace = None) -unsigned_long = Number("unsigned long", namespace = None) uint8 = UInt(8) uint16 = UInt(16) diff -r 3c08d944bc24 -r b142d87fd704 tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/libxl/xl_cmdimpl.c Wed Apr 20 17:13:07 2011 +0100 @@ -3699,8 +3699,8 @@ static void output_xeninfo(void) printf("xen_extra : %s\n", info->xen_version_extra); printf("xen_caps : %s\n", info->capabilities); printf("xen_scheduler : %s\n", libxl_schedid_to_name(ctx, sched_id)); - printf("xen_pagesize : %lu\n", info->pagesize); - printf("platform_params : virt_start=0x%lx\n", info->virt_start); + printf("xen_pagesize : %u\n", info->pagesize); + printf("platform_params : virt_start=0x%"PRIx64"\n", info->virt_start); printf("xen_changeset : %s\n", info->changeset); printf("xen_commandline : %s\n", info->commandline); printf("cc_compiler : %s\n", info->compiler); _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-20 16:15 UTC
[Xen-devel] [PATCH 28 of 32] tools: ocaml: reorder xl bindings type and function definitions to match IDL
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1303315987 -3600 # Node ID 9efbf0a2ef1876ade982062e47af53d59abba93b # Parent b142d87fd70402aeaf10c860bbb44339e2eafde2 tools: ocaml: reorder xl bindings type and function definitions to match IDL Reduces the churn when comparing the before and after auto-generation versions of the patch. (in practice the ocaml pre-autogeneration bindings are so out of date that there isn''t all that much benefit to this though...) Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r b142d87fd704 -r 9efbf0a2ef18 tools/ocaml/libs/xl/xl.ml --- a/tools/ocaml/libs/xl/xl.ml Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/ocaml/libs/xl/xl.ml Wed Apr 20 17:13:07 2011 +0100 @@ -15,6 +15,28 @@ exception Error of string +type domid = int + +type console_type + | CONSOLETYPE_XENCONSOLED + | CONSOLETYPE_IOEMU + +type disk_phystype + | PHYSTYPE_QCOW + | PHYSTYPE_QCOW2 + | PHYSTYPE_VHD + | PHYSTYPE_AIO + | PHYSTYPE_FILE + | PHYSTYPE_PHY + +type nic_type + | NICTYPE_IOEMU + | NICTYPE_VIF + +type button + | Button_Power + | Button_Sleep + module Domain_create_info = struct type t { @@ -31,6 +53,129 @@ module Domain_create_info = struct } end +module Device_vfb = struct + type t + { + backend_domid : domid; + devid : int; + vnc : bool; + vnclisten : string; + vncpasswd : string; + vncdisplay : int; + vncunused : bool; + keymap : string; + sdl : bool; + opengl : bool; + display : string; + xauthority : string; + } + external add : t -> domid -> unit = "stub_xl_device_vfb_add" + external clean_shutdown : domid -> unit = "stub_xl_device_vfb_clean_shutdown" + external hard_shutdown : domid -> unit = "stub_xl_device_vfb_hard_shutdown" +end + +module Device_vkb = struct + type t + { + backend_domid : domid; + devid : int; + } + + external add : t -> domid -> unit = "stub_xl_device_vkb_add" + external clean_shutdown : domid -> unit = "stub_xl_device_vkb_clean_shutdown" + external hard_shutdown : domid -> unit = "stub_xl_device_vkb_hard_shutdown" +end + +module Device_console = struct + type t + { + backend_domid : domid; + devid : int; + consoletype : console_type; + } + + external add : t -> domid -> unit = "stub_xl_device_console_add" +end + +module Device_disk = struct + type t + { + backend_domid : domid; + physpath : string; + phystype : disk_phystype; + virtpath : string; + unpluggable : bool; + readwrite : bool; + is_cdrom : bool; + } + + external add : t -> domid -> unit = "stub_xl_device_disk_add" + external del : t -> domid -> unit = "stub_xl_device_disk_del" +end + +module Device_nic = struct + type t + { + backend_domid : domid; + devid : int; + mtu : int; + model : string; + mac : int array; + bridge : string; + ifname : string; + script : string; + nictype : nic_type; + } + external add : t -> domid -> unit = "stub_xl_device_nic_add" + external del : t -> domid -> unit = "stub_xl_device_nic_del" +end + +module Device_pci = struct + type t + { + func : int; + dev : int; + bus : int; + domain : int; + vdevfn : int; + msitranslate : bool; + power_mgmt : bool; + } + + external add : t -> domid -> unit = "stub_xl_device_pci_add" + external remove : t -> domid -> unit = "stub_xl_device_pci_remove" + external shutdown : domid -> unit = "stub_xl_device_pci_shutdown" +end + +module Physinfo = struct + type t + { + threads_per_core: int; + cores_per_socket: int; + max_cpu_id: int; + nr_cpus: int; + cpu_khz: int; + total_pages: int64; + free_pages: int64; + scrub_pages: int64; + nr_nodes: int; + hwcap: int32 array; + physcap: int32; + } + external get : unit -> t = "stub_xl_physinfo" + +end + +module Sched_credit = struct + type t + { + weight: int; + cap: int; + } + external domain_get : domid -> t = "stub_xl_sched_credit_domain_get" + external domain_set : domid -> t -> unit = "stub_xl_sched_credit_domain_set" +end + module Domain_build_info = struct module Hvm = struct type t @@ -70,137 +215,6 @@ module Domain_build_info = struct } end -type domid = int - -type disk_phystype - | PHYSTYPE_QCOW - | PHYSTYPE_QCOW2 - | PHYSTYPE_VHD - | PHYSTYPE_AIO - | PHYSTYPE_FILE - | PHYSTYPE_PHY - -module Device_disk = struct - type t - { - backend_domid : domid; - physpath : string; - phystype : disk_phystype; - virtpath : string; - unpluggable : bool; - readwrite : bool; - is_cdrom : bool; - } - - external add : t -> domid -> unit = "stub_xl_device_disk_add" - external del : t -> domid -> unit = "stub_xl_device_disk_del" -end - -type nic_type - | NICTYPE_IOEMU - | NICTYPE_VIF - -module Device_nic = struct - type t - { - backend_domid : domid; - devid : int; - mtu : int; - model : string; - mac : int array; - bridge : string; - ifname : string; - script : string; - nictype : nic_type; - } - external add : t -> domid -> unit = "stub_xl_device_nic_add" - external del : t -> domid -> unit = "stub_xl_device_nic_del" -end - -type console_type - | CONSOLETYPE_XENCONSOLED - | CONSOLETYPE_IOEMU - -module Device_console = struct - type t - { - backend_domid : domid; - devid : int; - consoletype : console_type; - } - - external add : t -> domid -> unit = "stub_xl_device_console_add" -end - -module Device_vkb = struct - type t - { - backend_domid : domid; - devid : int; - } - - external add : t -> domid -> unit = "stub_xl_device_vkb_add" - external clean_shutdown : domid -> unit = "stub_xl_device_vkb_clean_shutdown" - external hard_shutdown : domid -> unit = "stub_xl_device_vkb_hard_shutdown" -end - -module Device_vfb = struct - type t - { - backend_domid : domid; - devid : int; - vnc : bool; - vnclisten : string; - vncpasswd : string; - vncdisplay : int; - vncunused : bool; - keymap : string; - sdl : bool; - opengl : bool; - display : string; - xauthority : string; - } - external add : t -> domid -> unit = "stub_xl_device_vfb_add" - external clean_shutdown : domid -> unit = "stub_xl_device_vfb_clean_shutdown" - external hard_shutdown : domid -> unit = "stub_xl_device_vfb_hard_shutdown" -end - -module Device_pci = struct - type t - { - func : int; - dev : int; - bus : int; - domain : int; - vdevfn : int; - msitranslate : bool; - power_mgmt : bool; - } - - external add : t -> domid -> unit = "stub_xl_device_pci_add" - external remove : t -> domid -> unit = "stub_xl_device_pci_remove" - external shutdown : domid -> unit = "stub_xl_device_pci_shutdown" -end - -module Physinfo = struct - type t - { - threads_per_core: int; - cores_per_socket: int; - max_cpu_id: int; - nr_cpus: int; - cpu_khz: int; - total_pages: int64; - free_pages: int64; - scrub_pages: int64; - nr_nodes: int; - hwcap: int32 array; - physcap: int32; - } - external get : unit -> t = "stub_xl_physinfo" - -end - module Topologyinfo = struct type t { @@ -211,20 +225,6 @@ module Topologyinfo = struct external get: unit -> t = "stub_xl_topologyinfo" end -module Sched_credit = struct - type t - { - weight: int; - cap: int; - } - external domain_get : domid -> t = "stub_xl_sched_credit_domain_get" - external domain_set : domid -> t -> unit = "stub_xl_sched_credit_domain_set" -end - -type button - | Button_Power - | Button_Sleep - external button_press : domid -> button -> unit = "stub_xl_button_press" diff -r b142d87fd704 -r 9efbf0a2ef18 tools/ocaml/libs/xl/xl.mli --- a/tools/ocaml/libs/xl/xl.mli Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/ocaml/libs/xl/xl.mli Wed Apr 20 17:13:07 2011 +0100 @@ -15,6 +15,28 @@ exception Error of string +type domid = int + +type console_type + | CONSOLETYPE_XENCONSOLED + | CONSOLETYPE_IOEMU + +type disk_phystype + | PHYSTYPE_QCOW + | PHYSTYPE_QCOW2 + | PHYSTYPE_VHD + | PHYSTYPE_AIO + | PHYSTYPE_FILE + | PHYSTYPE_PHY + +type nic_type + | NICTYPE_IOEMU + | NICTYPE_VIF + +type button + | Button_Power + | Button_Sleep + module Domain_create_info : sig type t { @@ -31,6 +53,130 @@ module Domain_create_info : sig } end +module Device_vfb : sig + type t + { + backend_domid : domid; + devid : int; + vnc : bool; + vnclisten : string; + vncpasswd : string; + vncdisplay : int; + vncunused : bool; + keymap : string; + sdl : bool; + opengl : bool; + display : string; + xauthority : string; + } + external add : t -> domid -> unit = "stub_xl_device_vfb_add" + external clean_shutdown : domid -> unit = "stub_xl_device_vfb_clean_shutdown" + external hard_shutdown : domid -> unit = "stub_xl_device_vfb_hard_shutdown" +end + +module Device_vkb : sig + type t + { + backend_domid : domid; + devid : int; + } + + external add : t -> domid -> unit = "stub_xl_device_vkb_add" + external clean_shutdown : domid -> unit = "stub_xl_device_vkb_clean_shutdown" + external hard_shutdown : domid -> unit = "stub_xl_device_vkb_hard_shutdown" +end + +module Device_console : sig + type t + { + backend_domid : domid; + devid : int; + consoletype : console_type; + } + + external add : t -> domid -> unit = "stub_xl_device_console_add" +end + +module Device_disk : sig + type t + { + backend_domid : domid; + physpath : string; + phystype : disk_phystype; + virtpath : string; + unpluggable : bool; + readwrite : bool; + is_cdrom : bool; + } + + external add : t -> domid -> unit = "stub_xl_device_disk_add" + external del : t -> domid -> unit = "stub_xl_device_disk_del" +end + +module Device_nic : sig + type t + { + backend_domid : domid; + devid : int; + mtu : int; + model : string; + mac : int array; + bridge : string; + ifname : string; + script : string; + nictype : nic_type; + } + external add : t -> domid -> unit = "stub_xl_device_nic_add" + external del : t -> domid -> unit = "stub_xl_device_nic_del" +end + +module Device_pci : sig + type t + { + func : int; + dev : int; + bus : int; + domain : int; + vdevfn : int; + msitranslate : bool; + power_mgmt : bool; + } + + external add : t -> domid -> unit = "stub_xl_device_pci_add" + external remove : t -> domid -> unit = "stub_xl_device_pci_remove" + external shutdown : domid -> unit = "stub_xl_device_pci_shutdown" +end + +module Physinfo : sig + type t + { + threads_per_core: int; + cores_per_socket: int; + max_cpu_id: int; + nr_cpus: int; + cpu_khz: int; + total_pages: int64; + free_pages: int64; + scrub_pages: int64; + nr_nodes: int; + hwcap: int32 array; + physcap: int32; + } + external get : unit -> t = "stub_xl_physinfo" + +end + +module Sched_credit : sig + type t + { + weight: int; + cap: int; + } + + external domain_get : domid -> t = "stub_xl_sched_credit_domain_get" + external domain_set : domid -> t -> unit = "stub_xl_sched_credit_domain_set" +end + module Domain_build_info : sig module Hvm : sig type t @@ -70,137 +216,6 @@ module Domain_build_info : sig } end -type domid = int - -type disk_phystype - | PHYSTYPE_QCOW - | PHYSTYPE_QCOW2 - | PHYSTYPE_VHD - | PHYSTYPE_AIO - | PHYSTYPE_FILE - | PHYSTYPE_PHY - -module Device_disk : sig - type t - { - backend_domid : domid; - physpath : string; - phystype : disk_phystype; - virtpath : string; - unpluggable : bool; - readwrite : bool; - is_cdrom : bool; - } - - external add : t -> domid -> unit = "stub_xl_device_disk_add" - external del : t -> domid -> unit = "stub_xl_device_disk_del" -end - -type nic_type - | NICTYPE_IOEMU - | NICTYPE_VIF - -module Device_nic : sig - type t - { - backend_domid : domid; - devid : int; - mtu : int; - model : string; - mac : int array; - bridge : string; - ifname : string; - script : string; - nictype : nic_type; - } - external add : t -> domid -> unit = "stub_xl_device_nic_add" - external del : t -> domid -> unit = "stub_xl_device_nic_del" -end - -type console_type - | CONSOLETYPE_XENCONSOLED - | CONSOLETYPE_IOEMU - -module Device_console : sig - type t - { - backend_domid : domid; - devid : int; - consoletype : console_type; - } - - external add : t -> domid -> unit = "stub_xl_device_console_add" -end - -module Device_vkb : sig - type t - { - backend_domid : domid; - devid : int; - } - - external add : t -> domid -> unit = "stub_xl_device_vkb_add" - external clean_shutdown : domid -> unit = "stub_xl_device_vkb_clean_shutdown" - external hard_shutdown : domid -> unit = "stub_xl_device_vkb_hard_shutdown" -end - -module Device_vfb : sig - type t - { - backend_domid : domid; - devid : int; - vnc : bool; - vnclisten : string; - vncpasswd : string; - vncdisplay : int; - vncunused : bool; - keymap : string; - sdl : bool; - opengl : bool; - display : string; - xauthority : string; - } - external add : t -> domid -> unit = "stub_xl_device_vfb_add" - external clean_shutdown : domid -> unit = "stub_xl_device_vfb_clean_shutdown" - external hard_shutdown : domid -> unit = "stub_xl_device_vfb_hard_shutdown" -end - -module Device_pci : sig - type t - { - func : int; - dev : int; - bus : int; - domain : int; - vdevfn : int; - msitranslate : bool; - power_mgmt : bool; - } - - external add : t -> domid -> unit = "stub_xl_device_pci_add" - external remove : t -> domid -> unit = "stub_xl_device_pci_remove" - external shutdown : domid -> unit = "stub_xl_device_pci_shutdown" -end - -module Physinfo : sig - type t - { - threads_per_core: int; - cores_per_socket: int; - max_cpu_id: int; - nr_cpus: int; - cpu_khz: int; - total_pages: int64; - free_pages: int64; - scrub_pages: int64; - nr_nodes: int; - hwcap: int32 array; - physcap: int32; - } - external get : unit -> t = "stub_xl_physinfo" - -end - module Topologyinfo : sig type t { @@ -211,21 +226,6 @@ module Topologyinfo : sig external get : unit -> t = "stub_xl_topologyinfo" end -module Sched_credit : sig - type t - { - weight: int; - cap: int; - } - - external domain_get : domid -> t = "stub_xl_sched_credit_domain_get" - external domain_set : domid -> t -> unit = "stub_xl_sched_credit_domain_set" -end - -type button - | Button_Power - | Button_Sleep - external button_press : domid -> button -> unit = "stub_xl_button_press" external send_trigger : domid -> string -> int -> unit = "stub_xl_send_trigger" _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-20 16:15 UTC
[Xen-devel] [PATCH 29 of 32] tools: ocaml: remove create_info and build_info data types from xl bindings
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1303315987 -3600 # Node ID 9586790030d8221db24e78f5ca9f0b1a10a480d2 # Parent 9efbf0a2ef1876ade982062e47af53d59abba93b tools: ocaml: remove create_info and build_info data types from xl bindings There are currently no stub functions which use these datatypes. The existing definitions are out of date wrt the C API (and the conversion routines are commented out anyway) and are complex from the IDL point of view (and so will be skipped in the first round of autogeneration). Remove them to keep things simple for now. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 9efbf0a2ef18 -r 9586790030d8 tools/ocaml/libs/xl/xl.ml --- a/tools/ocaml/libs/xl/xl.ml Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/ocaml/libs/xl/xl.ml Wed Apr 20 17:13:07 2011 +0100 @@ -37,22 +37,6 @@ type button | Button_Power | Button_Sleep -module Domain_create_info = struct - type t - { - hvm : bool; - hap : bool; - oos : bool; - ssidref : int32; - name : string; - uuid : int array; - xsdata : (string * string) list; - platformdata : (string * string) list; - poolid : int32; - poolname : string; - } -end - module Device_vfb = struct type t { @@ -176,45 +160,6 @@ module Sched_credit = struct external domain_set : domid -> t -> unit = "stub_xl_sched_credit_domain_set" end -module Domain_build_info = struct - module Hvm = struct - type t - { - pae : bool; - apic : bool; - acpi : bool; - nx : bool; - viridian : bool; - timeoffset : string; - timer_mode : int; - hpet : int; - vpt_align : int; - } - end - - module Pv = struct - type t - { - slack_memkb : int64; - cmdline : string; - ramdisk : string; - features : string; - } - end - - type t - { - max_vcpus : int; - cur_vcpus : int; - max_memkb : int64; - target_memkb : int64; - video_memkb : int64; - shadow_memkb : int64; - kernel : string; - u : [ `HVM of Hvm.t | `PV of Pv.t ]; - } -end - module Topologyinfo = struct type t { diff -r 9efbf0a2ef18 -r 9586790030d8 tools/ocaml/libs/xl/xl.mli --- a/tools/ocaml/libs/xl/xl.mli Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/ocaml/libs/xl/xl.mli Wed Apr 20 17:13:07 2011 +0100 @@ -37,22 +37,6 @@ type button | Button_Power | Button_Sleep -module Domain_create_info : sig - type t - { - hvm : bool; - hap : bool; - oos : bool; - ssidref : int32; - name : string; - uuid : int array; - xsdata : (string * string) list; - platformdata : (string * string) list; - poolid : int32; - poolname : string; - } -end - module Device_vfb : sig type t { @@ -177,45 +161,6 @@ module Sched_credit : sig external domain_set : domid -> t -> unit = "stub_xl_sched_credit_domain_set" end -module Domain_build_info : sig - module Hvm : sig - type t - { - pae : bool; - apic : bool; - acpi : bool; - nx : bool; - viridian : bool; - timeoffset : string; - timer_mode : int; - hpet : int; - vpt_align : int; - } - end - - module Pv : sig - type t - { - slack_memkb : int64; - cmdline : string; - ramdisk : string; - features : string; - } - end - - type t - { - max_vcpus : int; - cur_vcpus : int; - max_memkb : int64; - target_memkb : int64; - video_memkb : int64; - shadow_memkb : int64; - kernel : string; - u : [ `HVM of Hvm.t | `PV of Pv.t ]; - } -end - module Topologyinfo : sig type t { diff -r 9efbf0a2ef18 -r 9586790030d8 tools/ocaml/libs/xl/xl_stubs.c --- a/tools/ocaml/libs/xl/xl_stubs.c Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/ocaml/libs/xl/xl_stubs.c Wed Apr 20 17:13:07 2011 +0100 @@ -128,63 +128,6 @@ static int string_string_tuple_array_val CAMLreturn(0); } -static int domain_create_info_val (caml_gc *gc, libxl_domain_create_info *c_val, value v) -{ - CAMLparam1(v); - CAMLlocal1(a); - uint8_t *uuid = libxl_uuid_bytearray(&c_val->uuid); - int i; - - c_val->hvm = Bool_val(Field(v, 0)); - c_val->hap = Bool_val(Field(v, 1)); - c_val->oos = Bool_val(Field(v, 2)); - c_val->ssidref = Int32_val(Field(v, 3)); - c_val->name = dup_String_val(gc, Field(v, 4)); - a = Field(v, 5); - for (i = 0; i < 16; i++) - uuid[i] = Int_val(Field(a, i)); - string_string_tuple_array_val(gc, &(c_val->xsdata), Field(v, 6)); - string_string_tuple_array_val(gc, &(c_val->platformdata), Field(v, 7)); - - c_val->poolid = Int32_val(Field(v, 8)); - c_val->poolname = dup_String_val(gc, Field(v, 9)); - - CAMLreturn(0); -} - -static int domain_build_info_val (caml_gc *gc, libxl_domain_build_info *c_val, value v) -{ - CAMLparam1(v); - CAMLlocal1(infopriv); - - c_val->max_vcpus = Int_val(Field(v, 0)); - c_val->cur_vcpus = Int_val(Field(v, 1)); - c_val->max_memkb = Int64_val(Field(v, 2)); - c_val->target_memkb = Int64_val(Field(v, 3)); - c_val->video_memkb = Int64_val(Field(v, 4)); - c_val->shadow_memkb = Int64_val(Field(v, 5)); - c_val->kernel.path = dup_String_val(gc, Field(v, 6)); - c_val->is_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)); - } 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)); - } - - CAMLreturn(0); -} #endif static int device_disk_val(caml_gc *gc, libxl_device_disk *c_val, value v) _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-20 16:15 UTC
[Xen-devel] [PATCH 30 of 32] tools: ocaml: tweak whitespace in preparation for autogenerating xl bindings
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1303315988 -3600 # Node ID 30e7e76df3ad5ca3b25d10dab25c10352fc2df68 # Parent 9586790030d8221db24e78f5ca9f0b1a10a480d2 tools: ocaml: tweak whitespace in preparation for autogenerating xl bindings Reduces the diff of existing vs auto-generated code. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 9586790030d8 -r 30e7e76df3ad tools/ocaml/libs/xl/xl.ml --- a/tools/ocaml/libs/xl/xl.ml Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/ocaml/libs/xl/xl.ml Wed Apr 20 17:13:08 2011 +0100 @@ -64,7 +64,6 @@ module Device_vkb = struct backend_domid : domid; devid : int; } - external add : t -> domid -> unit = "stub_xl_device_vkb_add" external clean_shutdown : domid -> unit = "stub_xl_device_vkb_clean_shutdown" external hard_shutdown : domid -> unit = "stub_xl_device_vkb_hard_shutdown" @@ -77,7 +76,6 @@ module Device_console = struct devid : int; consoletype : console_type; } - external add : t -> domid -> unit = "stub_xl_device_console_add" end @@ -92,7 +90,6 @@ module Device_disk = struct readwrite : bool; is_cdrom : bool; } - external add : t -> domid -> unit = "stub_xl_device_disk_add" external del : t -> domid -> unit = "stub_xl_device_disk_del" end @@ -125,7 +122,6 @@ module Device_pci = struct msitranslate : bool; power_mgmt : bool; } - external add : t -> domid -> unit = "stub_xl_device_pci_add" external remove : t -> domid -> unit = "stub_xl_device_pci_remove" external shutdown : domid -> unit = "stub_xl_device_pci_shutdown" @@ -134,17 +130,17 @@ end module Physinfo = struct type t { - threads_per_core: int; - cores_per_socket: int; - max_cpu_id: int; - nr_cpus: int; - cpu_khz: int; - total_pages: int64; - free_pages: int64; - scrub_pages: int64; - nr_nodes: int; - hwcap: int32 array; - physcap: int32; + threads_per_core : int; + cores_per_socket : int; + max_cpu_id : int; + nr_cpus : int; + cpu_khz : int; + total_pages : int64; + free_pages : int64; + scrub_pages : int64; + nr_nodes : int; + hwcap : int32 array; + physcap : int32; } external get : unit -> t = "stub_xl_physinfo" @@ -153,8 +149,8 @@ end module Sched_credit = struct type t { - weight: int; - cap: int; + weight : int; + cap : int; } external domain_get : domid -> t = "stub_xl_sched_credit_domain_get" external domain_set : domid -> t -> unit = "stub_xl_sched_credit_domain_set" @@ -163,11 +159,11 @@ end module Topologyinfo = struct type t { - core: int; - socket: int; - node: int; + core : int; + socket : int; + node : int; } - external get: unit -> t = "stub_xl_topologyinfo" + external get : unit -> t = "stub_xl_topologyinfo" end external button_press : domid -> button -> unit = "stub_xl_button_press" diff -r 9586790030d8 -r 30e7e76df3ad tools/ocaml/libs/xl/xl.mli --- a/tools/ocaml/libs/xl/xl.mli Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/ocaml/libs/xl/xl.mli Wed Apr 20 17:13:08 2011 +0100 @@ -64,7 +64,6 @@ module Device_vkb : sig backend_domid : domid; devid : int; } - external add : t -> domid -> unit = "stub_xl_device_vkb_add" external clean_shutdown : domid -> unit = "stub_xl_device_vkb_clean_shutdown" external hard_shutdown : domid -> unit = "stub_xl_device_vkb_hard_shutdown" @@ -92,7 +91,6 @@ module Device_disk : sig readwrite : bool; is_cdrom : bool; } - external add : t -> domid -> unit = "stub_xl_device_disk_add" external del : t -> domid -> unit = "stub_xl_device_disk_del" end @@ -125,7 +123,6 @@ module Device_pci : sig msitranslate : bool; power_mgmt : bool; } - external add : t -> domid -> unit = "stub_xl_device_pci_add" external remove : t -> domid -> unit = "stub_xl_device_pci_remove" external shutdown : domid -> unit = "stub_xl_device_pci_shutdown" @@ -134,29 +131,27 @@ end module Physinfo : sig type t { - threads_per_core: int; - cores_per_socket: int; - max_cpu_id: int; - nr_cpus: int; - cpu_khz: int; - total_pages: int64; - free_pages: int64; - scrub_pages: int64; - nr_nodes: int; - hwcap: int32 array; - physcap: int32; + threads_per_core : int; + cores_per_socket : int; + max_cpu_id : int; + nr_cpus : int; + cpu_khz : int; + total_pages : int64; + free_pages : int64; + scrub_pages : int64; + nr_nodes : int; + hwcap : int32 array; + physcap : int32; } external get : unit -> t = "stub_xl_physinfo" - end module Sched_credit : sig type t { - weight: int; - cap: int; + weight : int; + cap : int; } - external domain_get : domid -> t = "stub_xl_sched_credit_domain_get" external domain_set : domid -> t -> unit = "stub_xl_sched_credit_domain_set" end @@ -164,9 +159,9 @@ end module Topologyinfo : sig type t { - core: int; - socket: int; - node: int; + core : int; + socket : int; + node : int; } external get : unit -> t = "stub_xl_topologyinfo" end diff -r 9586790030d8 -r 30e7e76df3ad tools/ocaml/libs/xl/xl_stubs.c --- a/tools/ocaml/libs/xl/xl_stubs.c Wed Apr 20 17:13:07 2011 +0100 +++ b/tools/ocaml/libs/xl/xl_stubs.c Wed Apr 20 17:13:08 2011 +0100 @@ -283,7 +283,7 @@ static value Val_topologyinfo(libxl_topo int i; topologyinfo = caml_alloc_tuple(c_val->coremap.entries); - for (i = 0; i < c_val->coremap.entries; i++) { + for (i = 0; i < c_val->coremap.entries; i++) { v = Val_int(0); /* None */ if (c_val->coremap.array[i] != LIBXL_CPUARRAY_INVALID_ENTRY) { topology = caml_alloc_tuple(3); @@ -398,7 +398,7 @@ value stub_xl_device_vkb_add(value info, if (ret != 0) failwith_xl("vkb_add", &lg); FREE_CTX(); - + CAMLreturn(Val_unit); } @@ -413,7 +413,7 @@ value stub_xl_device_vkb_clean_shutdown( if (ret != 0) failwith_xl("vkb_clean_shutdown", &lg); FREE_CTX(); - + CAMLreturn(Val_unit); } @@ -428,7 +428,7 @@ value stub_xl_device_vkb_hard_shutdown(v if (ret != 0) failwith_xl("vkb_hard_shutdown", &lg); FREE_CTX(); - + CAMLreturn(Val_unit); } @@ -446,7 +446,7 @@ value stub_xl_device_vfb_add(value info, if (ret != 0) failwith_xl("vfb_add", &lg); FREE_CTX(); - + CAMLreturn(Val_unit); } @@ -461,7 +461,7 @@ value stub_xl_device_vfb_clean_shutdown( if (ret != 0) failwith_xl("vfb_clean_shutdown", &lg); FREE_CTX(); - + CAMLreturn(Val_unit); } @@ -476,7 +476,7 @@ value stub_xl_device_vfb_hard_shutdown(v if (ret != 0) failwith_xl("vfb_hard_shutdown", &lg); FREE_CTX(); - + CAMLreturn(Val_unit); } @@ -494,7 +494,7 @@ value stub_xl_device_pci_add(value info, if (ret != 0) failwith_xl("pci_add", &lg); FREE_CTX(); - + CAMLreturn(Val_unit); } @@ -512,7 +512,7 @@ value stub_xl_device_pci_remove(value in if (ret != 0) failwith_xl("pci_remove", &lg); FREE_CTX(); - + CAMLreturn(Val_unit); } @@ -527,7 +527,7 @@ value stub_xl_device_pci_shutdown(value if (ret != 0) failwith_xl("pci_shutdown", &lg); FREE_CTX(); - + CAMLreturn(Val_unit); } @@ -536,7 +536,7 @@ value stub_xl_button_press(value domid, CAMLparam2(domid, button); int ret; INIT_STRUCT(); - + INIT_CTX(); ret = libxl_button_press(ctx, Int_val(domid), Int_val(button) + LIBXL_BUTTON_POWER); if (ret != 0) _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-20 16:15 UTC
[Xen-devel] [PATCH 31 of 32] tools: ocaml: lay ground work for auto generating xl datatypes
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1303315988 -3600 # Node ID ed47a7438db2fa25a6e68cc7fbf7296f346c0537 # Parent 30e7e76df3ad5ca3b25d10dab25c10352fc2df68 tools: ocaml: lay ground work for auto generating xl datatypes. Doesn''t actually generate anything yet but puts all the moving parts into place. In particular sets up the xl.ml.in+_libxl_types.ml.in->xl.ml transformation using sed. This appears to be the only/best way to do this for ocaml due to the lack of a preprocessor and/or an include mechanism which has an inmpact on namespacing. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 30e7e76df3ad -r ed47a7438db2 .hgignore --- a/.hgignore Wed Apr 20 17:13:08 2011 +0100 +++ b/.hgignore Wed Apr 20 17:13:08 2011 +0100 @@ -295,6 +295,11 @@ ^tools/ocaml/.*/.*\.cmx?a$ ^tools/ocaml/.*/META$ ^tools/ocaml/.*/\.ocamldep\.make$ +^tools/ocaml/libs/xl/_libxl_types\.ml\.in$ +^tools/ocaml/libs/xl/_libxl_types\.mli\.in$ +^tools/ocaml/libs/xl/_libxl_types\.inc$ +^tools/ocaml/libs/xl/xl\.ml$ +^tools/ocaml/libs/xl/xl\.mli$ ^tools/ocaml/xenstored/oxenstored$ ^xen/\.banner.*$ ^xen/BLOG$ diff -r 30e7e76df3ad -r ed47a7438db2 tools/ocaml/libs/xl/Makefile --- a/tools/ocaml/libs/xl/Makefile Wed Apr 20 17:13:08 2011 +0100 +++ b/tools/ocaml/libs/xl/Makefile Wed Apr 20 17:13:08 2011 +0100 @@ -15,8 +15,36 @@ xl_C_OBJS = xl_stubs OCAML_LIBRARY = xl +GENERATED_FILES += xl.ml xl.mli +GENERATED_FILES += _libxl_types.ml.in _libxl_types.mli.in +GENERATED_FILES += _libxl_types.inc + all: $(INTF) $(LIBS) +xl.ml: xl.ml.in _libxl_types.ml.in + $(Q)sed -e ''1i(*\ + * AUTO-GENERATED FILE DO NOT EDIT\ + * Generated from xl.ml.in and _libxl_types.ml.in\ + *)\ +'' \ + -e ''/^(\* @@LIBXL_TYPES@@ \*)$$/r_libxl_types.ml.in'' \ + < xl.ml.in > xl.ml + +xl.mli: xl.mli.in _libxl_types.mli.in + $(Q)sed -e ''1i(*\ + * AUTO-GENERATED FILE DO NOT EDIT\ + * Generated from xl.mli.in and _libxl_types.mli.in\ + *)\ +'' \ + -e ''/^(\* @@LIBXL_TYPES@@ \*)$$/r_libxl_types.mli.in'' \ + < xl.mli.in > xl.mli + +_libxl_types.ml.in _libxl_types.mli.in _libxl_types.inc: genwrap.py $(XEN_ROOT)/tools/libxl/libxl.idl \ + $(XEN_ROOT)/tools/libxl/libxltypes.py + PYTHONPATH=$(XEN_ROOT)/tools/libxl $(PYTHON) genwrap.py \ + $(XEN_ROOT)/tools/libxl/libxl.idl \ + _libxl_types.mli.in _libxl_types.ml.in _libxl_types.inc + libs: $(LIBS) .PHONY: install diff -r 30e7e76df3ad -r ed47a7438db2 tools/ocaml/libs/xl/genwrap.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/ocaml/libs/xl/genwrap.py Wed Apr 20 17:13:08 2011 +0100 @@ -0,0 +1,42 @@ +#!/usr/bin/python + +import sys,os + +import libxltypes + +def autogen_header(open_comment, close_comment): + s = open_comment + " AUTO-GENERATED FILE DO NOT EDIT " + close_comment + "\n" + s += open_comment + " autogenerated by \n" + s += reduce(lambda x,y: x + " ", range(len(open_comment + " ")), "") + s += "%s" % " ".join(sys.argv) + s += "\n " + close_comment + "\n\n" + return s + +if __name__ == ''__main__'': + if len(sys.argv) < 4: + print >>sys.stderr, "Usage: genwrap.py <idl> <mli> <ml> <c-inc>" + sys.exit(1) + + idl = sys.argv[1] + (_,types) = libxltypes.parse(idl) + + + _ml = sys.argv[3] + ml = open(_ml, ''w'') + ml.write(autogen_header("(*", "*)")) + + _mli = sys.argv[2] + mli = open(_mli, ''w'') + mli.write(autogen_header("(*", "*)")) + + _cinc = sys.argv[4] + cinc = open(_cinc, ''w'') + cinc.write(autogen_header("/*", "*/")) + + # TODO: autogenerate something + + ml.write("(* END OF AUTO-GENERATED CODE *)\n") + ml.close() + mli.write("(* END OF AUTO-GENERATED CODE *)\n") + mli.close() + cinc.close() diff -r 30e7e76df3ad -r ed47a7438db2 tools/ocaml/libs/xl/xl.ml --- a/tools/ocaml/libs/xl/xl.ml Wed Apr 20 17:13:08 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,176 +0,0 @@ -(* - * Copyright (C) 2009-2011 Citrix Ltd. - * Author Vincent Hanquez <vincent.hanquez@eu.citrix.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; version 2.1 only. with the special - * exception on linking described in file LICENSE. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - *) - -exception Error of string - -type domid = int - -type console_type - | CONSOLETYPE_XENCONSOLED - | CONSOLETYPE_IOEMU - -type disk_phystype - | PHYSTYPE_QCOW - | PHYSTYPE_QCOW2 - | PHYSTYPE_VHD - | PHYSTYPE_AIO - | PHYSTYPE_FILE - | PHYSTYPE_PHY - -type nic_type - | NICTYPE_IOEMU - | NICTYPE_VIF - -type button - | Button_Power - | Button_Sleep - -module Device_vfb = struct - type t - { - backend_domid : domid; - devid : int; - vnc : bool; - vnclisten : string; - vncpasswd : string; - vncdisplay : int; - vncunused : bool; - keymap : string; - sdl : bool; - opengl : bool; - display : string; - xauthority : string; - } - external add : t -> domid -> unit = "stub_xl_device_vfb_add" - external clean_shutdown : domid -> unit = "stub_xl_device_vfb_clean_shutdown" - external hard_shutdown : domid -> unit = "stub_xl_device_vfb_hard_shutdown" -end - -module Device_vkb = struct - type t - { - backend_domid : domid; - devid : int; - } - external add : t -> domid -> unit = "stub_xl_device_vkb_add" - external clean_shutdown : domid -> unit = "stub_xl_device_vkb_clean_shutdown" - external hard_shutdown : domid -> unit = "stub_xl_device_vkb_hard_shutdown" -end - -module Device_console = struct - type t - { - backend_domid : domid; - devid : int; - consoletype : console_type; - } - external add : t -> domid -> unit = "stub_xl_device_console_add" -end - -module Device_disk = struct - type t - { - backend_domid : domid; - physpath : string; - phystype : disk_phystype; - virtpath : string; - unpluggable : bool; - readwrite : bool; - is_cdrom : bool; - } - external add : t -> domid -> unit = "stub_xl_device_disk_add" - external del : t -> domid -> unit = "stub_xl_device_disk_del" -end - -module Device_nic = struct - type t - { - backend_domid : domid; - devid : int; - mtu : int; - model : string; - mac : int array; - bridge : string; - ifname : string; - script : string; - nictype : nic_type; - } - external add : t -> domid -> unit = "stub_xl_device_nic_add" - external del : t -> domid -> unit = "stub_xl_device_nic_del" -end - -module Device_pci = struct - type t - { - func : int; - dev : int; - bus : int; - domain : int; - vdevfn : int; - msitranslate : bool; - power_mgmt : bool; - } - external add : t -> domid -> unit = "stub_xl_device_pci_add" - external remove : t -> domid -> unit = "stub_xl_device_pci_remove" - external shutdown : domid -> unit = "stub_xl_device_pci_shutdown" -end - -module Physinfo = struct - type t - { - threads_per_core : int; - cores_per_socket : int; - max_cpu_id : int; - nr_cpus : int; - cpu_khz : int; - total_pages : int64; - free_pages : int64; - scrub_pages : int64; - nr_nodes : int; - hwcap : int32 array; - physcap : int32; - } - external get : unit -> t = "stub_xl_physinfo" - -end - -module Sched_credit = struct - type t - { - weight : int; - cap : int; - } - external domain_get : domid -> t = "stub_xl_sched_credit_domain_get" - external domain_set : domid -> t -> unit = "stub_xl_sched_credit_domain_set" -end - -module Topologyinfo = struct - type t - { - core : int; - socket : int; - node : int; - } - external get : unit -> t = "stub_xl_topologyinfo" -end - -external button_press : domid -> button -> unit = "stub_xl_button_press" - - -external send_trigger : domid -> string -> int -> unit = "stub_xl_send_trigger" -external send_sysrq : domid -> char -> unit = "stub_xl_send_sysrq" -external send_debug_keys : domid -> string -> unit = "stub_xl_send_debug_keys" - -let _ = Callback.register_exception "xl.error" (Error "register_callback") diff -r 30e7e76df3ad -r ed47a7438db2 tools/ocaml/libs/xl/xl.ml.in --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/ocaml/libs/xl/xl.ml.in Wed Apr 20 17:13:08 2011 +0100 @@ -0,0 +1,178 @@ +(* + * Copyright (C) 2009-2011 Citrix Ltd. + * Author Vincent Hanquez <vincent.hanquez@eu.citrix.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; version 2.1 only. with the special + * exception on linking described in file LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + *) + +exception Error of string + +type domid = int + +(* @@LIBXL_TYPES@@ *) + +type console_type + | CONSOLETYPE_XENCONSOLED + | CONSOLETYPE_IOEMU + +type disk_phystype + | PHYSTYPE_QCOW + | PHYSTYPE_QCOW2 + | PHYSTYPE_VHD + | PHYSTYPE_AIO + | PHYSTYPE_FILE + | PHYSTYPE_PHY + +type nic_type + | NICTYPE_IOEMU + | NICTYPE_VIF + +type button + | Button_Power + | Button_Sleep + +module Device_vfb = struct + type t + { + backend_domid : domid; + devid : int; + vnc : bool; + vnclisten : string; + vncpasswd : string; + vncdisplay : int; + vncunused : bool; + keymap : string; + sdl : bool; + opengl : bool; + display : string; + xauthority : string; + } + external add : t -> domid -> unit = "stub_xl_device_vfb_add" + external clean_shutdown : domid -> unit = "stub_xl_device_vfb_clean_shutdown" + external hard_shutdown : domid -> unit = "stub_xl_device_vfb_hard_shutdown" +end + +module Device_vkb = struct + type t + { + backend_domid : domid; + devid : int; + } + external add : t -> domid -> unit = "stub_xl_device_vkb_add" + external clean_shutdown : domid -> unit = "stub_xl_device_vkb_clean_shutdown" + external hard_shutdown : domid -> unit = "stub_xl_device_vkb_hard_shutdown" +end + +module Device_console = struct + type t + { + backend_domid : domid; + devid : int; + consoletype : console_type; + } + external add : t -> domid -> unit = "stub_xl_device_console_add" +end + +module Device_disk = struct + type t + { + backend_domid : domid; + physpath : string; + phystype : disk_phystype; + virtpath : string; + unpluggable : bool; + readwrite : bool; + is_cdrom : bool; + } + external add : t -> domid -> unit = "stub_xl_device_disk_add" + external del : t -> domid -> unit = "stub_xl_device_disk_del" +end + +module Device_nic = struct + type t + { + backend_domid : domid; + devid : int; + mtu : int; + model : string; + mac : int array; + bridge : string; + ifname : string; + script : string; + nictype : nic_type; + } + external add : t -> domid -> unit = "stub_xl_device_nic_add" + external del : t -> domid -> unit = "stub_xl_device_nic_del" +end + +module Device_pci = struct + type t + { + func : int; + dev : int; + bus : int; + domain : int; + vdevfn : int; + msitranslate : bool; + power_mgmt : bool; + } + external add : t -> domid -> unit = "stub_xl_device_pci_add" + external remove : t -> domid -> unit = "stub_xl_device_pci_remove" + external shutdown : domid -> unit = "stub_xl_device_pci_shutdown" +end + +module Physinfo = struct + type t + { + threads_per_core : int; + cores_per_socket : int; + max_cpu_id : int; + nr_cpus : int; + cpu_khz : int; + total_pages : int64; + free_pages : int64; + scrub_pages : int64; + nr_nodes : int; + hwcap : int32 array; + physcap : int32; + } + external get : unit -> t = "stub_xl_physinfo" + +end + +module Sched_credit = struct + type t + { + weight : int; + cap : int; + } + external domain_get : domid -> t = "stub_xl_sched_credit_domain_get" + external domain_set : domid -> t -> unit = "stub_xl_sched_credit_domain_set" +end + +module Topologyinfo = struct + type t + { + core : int; + socket : int; + node : int; + } + external get : unit -> t = "stub_xl_topologyinfo" +end + +external button_press : domid -> button -> unit = "stub_xl_button_press" + + +external send_trigger : domid -> string -> int -> unit = "stub_xl_send_trigger" +external send_sysrq : domid -> char -> unit = "stub_xl_send_sysrq" +external send_debug_keys : domid -> string -> unit = "stub_xl_send_debug_keys" + +let _ = Callback.register_exception "xl.error" (Error "register_callback") diff -r 30e7e76df3ad -r ed47a7438db2 tools/ocaml/libs/xl/xl.mli --- a/tools/ocaml/libs/xl/xl.mli Wed Apr 20 17:13:08 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,173 +0,0 @@ -(* - * Copyright (C) 2009-2011 Citrix Ltd. - * Author Vincent Hanquez <vincent.hanquez@eu.citrix.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; version 2.1 only. with the special - * exception on linking described in file LICENSE. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - *) - -exception Error of string - -type domid = int - -type console_type - | CONSOLETYPE_XENCONSOLED - | CONSOLETYPE_IOEMU - -type disk_phystype - | PHYSTYPE_QCOW - | PHYSTYPE_QCOW2 - | PHYSTYPE_VHD - | PHYSTYPE_AIO - | PHYSTYPE_FILE - | PHYSTYPE_PHY - -type nic_type - | NICTYPE_IOEMU - | NICTYPE_VIF - -type button - | Button_Power - | Button_Sleep - -module Device_vfb : sig - type t - { - backend_domid : domid; - devid : int; - vnc : bool; - vnclisten : string; - vncpasswd : string; - vncdisplay : int; - vncunused : bool; - keymap : string; - sdl : bool; - opengl : bool; - display : string; - xauthority : string; - } - external add : t -> domid -> unit = "stub_xl_device_vfb_add" - external clean_shutdown : domid -> unit = "stub_xl_device_vfb_clean_shutdown" - external hard_shutdown : domid -> unit = "stub_xl_device_vfb_hard_shutdown" -end - -module Device_vkb : sig - type t - { - backend_domid : domid; - devid : int; - } - external add : t -> domid -> unit = "stub_xl_device_vkb_add" - external clean_shutdown : domid -> unit = "stub_xl_device_vkb_clean_shutdown" - external hard_shutdown : domid -> unit = "stub_xl_device_vkb_hard_shutdown" -end - -module Device_console : sig - type t - { - backend_domid : domid; - devid : int; - consoletype : console_type; - } - - external add : t -> domid -> unit = "stub_xl_device_console_add" -end - -module Device_disk : sig - type t - { - backend_domid : domid; - physpath : string; - phystype : disk_phystype; - virtpath : string; - unpluggable : bool; - readwrite : bool; - is_cdrom : bool; - } - external add : t -> domid -> unit = "stub_xl_device_disk_add" - external del : t -> domid -> unit = "stub_xl_device_disk_del" -end - -module Device_nic : sig - type t - { - backend_domid : domid; - devid : int; - mtu : int; - model : string; - mac : int array; - bridge : string; - ifname : string; - script : string; - nictype : nic_type; - } - external add : t -> domid -> unit = "stub_xl_device_nic_add" - external del : t -> domid -> unit = "stub_xl_device_nic_del" -end - -module Device_pci : sig - type t - { - func : int; - dev : int; - bus : int; - domain : int; - vdevfn : int; - msitranslate : bool; - power_mgmt : bool; - } - external add : t -> domid -> unit = "stub_xl_device_pci_add" - external remove : t -> domid -> unit = "stub_xl_device_pci_remove" - external shutdown : domid -> unit = "stub_xl_device_pci_shutdown" -end - -module Physinfo : sig - type t - { - threads_per_core : int; - cores_per_socket : int; - max_cpu_id : int; - nr_cpus : int; - cpu_khz : int; - total_pages : int64; - free_pages : int64; - scrub_pages : int64; - nr_nodes : int; - hwcap : int32 array; - physcap : int32; - } - external get : unit -> t = "stub_xl_physinfo" -end - -module Sched_credit : sig - type t - { - weight : int; - cap : int; - } - external domain_get : domid -> t = "stub_xl_sched_credit_domain_get" - external domain_set : domid -> t -> unit = "stub_xl_sched_credit_domain_set" -end - -module Topologyinfo : sig - type t - { - core : int; - socket : int; - node : int; - } - external get : unit -> t = "stub_xl_topologyinfo" -end - -external button_press : domid -> button -> unit = "stub_xl_button_press" - -external send_trigger : domid -> string -> int -> unit = "stub_xl_send_trigger" -external send_sysrq : domid -> char -> unit = "stub_xl_send_sysrq" -external send_debug_keys : domid -> string -> unit = "stub_xl_send_debug_keys" diff -r 30e7e76df3ad -r ed47a7438db2 tools/ocaml/libs/xl/xl.mli.in --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/ocaml/libs/xl/xl.mli.in Wed Apr 20 17:13:08 2011 +0100 @@ -0,0 +1,175 @@ +(* + * Copyright (C) 2009-2011 Citrix Ltd. + * Author Vincent Hanquez <vincent.hanquez@eu.citrix.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; version 2.1 only. with the special + * exception on linking described in file LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + *) + +exception Error of string + +type domid = int + +(* @@LIBXL_TYPES@@ *) + +type console_type + | CONSOLETYPE_XENCONSOLED + | CONSOLETYPE_IOEMU + +type disk_phystype + | PHYSTYPE_QCOW + | PHYSTYPE_QCOW2 + | PHYSTYPE_VHD + | PHYSTYPE_AIO + | PHYSTYPE_FILE + | PHYSTYPE_PHY + +type nic_type + | NICTYPE_IOEMU + | NICTYPE_VIF + +type button + | Button_Power + | Button_Sleep + +module Device_vfb : sig + type t + { + backend_domid : domid; + devid : int; + vnc : bool; + vnclisten : string; + vncpasswd : string; + vncdisplay : int; + vncunused : bool; + keymap : string; + sdl : bool; + opengl : bool; + display : string; + xauthority : string; + } + external add : t -> domid -> unit = "stub_xl_device_vfb_add" + external clean_shutdown : domid -> unit = "stub_xl_device_vfb_clean_shutdown" + external hard_shutdown : domid -> unit = "stub_xl_device_vfb_hard_shutdown" +end + +module Device_vkb : sig + type t + { + backend_domid : domid; + devid : int; + } + external add : t -> domid -> unit = "stub_xl_device_vkb_add" + external clean_shutdown : domid -> unit = "stub_xl_device_vkb_clean_shutdown" + external hard_shutdown : domid -> unit = "stub_xl_device_vkb_hard_shutdown" +end + +module Device_console : sig + type t + { + backend_domid : domid; + devid : int; + consoletype : console_type; + } + + external add : t -> domid -> unit = "stub_xl_device_console_add" +end + +module Device_disk : sig + type t + { + backend_domid : domid; + physpath : string; + phystype : disk_phystype; + virtpath : string; + unpluggable : bool; + readwrite : bool; + is_cdrom : bool; + } + external add : t -> domid -> unit = "stub_xl_device_disk_add" + external del : t -> domid -> unit = "stub_xl_device_disk_del" +end + +module Device_nic : sig + type t + { + backend_domid : domid; + devid : int; + mtu : int; + model : string; + mac : int array; + bridge : string; + ifname : string; + script : string; + nictype : nic_type; + } + external add : t -> domid -> unit = "stub_xl_device_nic_add" + external del : t -> domid -> unit = "stub_xl_device_nic_del" +end + +module Device_pci : sig + type t + { + func : int; + dev : int; + bus : int; + domain : int; + vdevfn : int; + msitranslate : bool; + power_mgmt : bool; + } + external add : t -> domid -> unit = "stub_xl_device_pci_add" + external remove : t -> domid -> unit = "stub_xl_device_pci_remove" + external shutdown : domid -> unit = "stub_xl_device_pci_shutdown" +end + +module Physinfo : sig + type t + { + threads_per_core : int; + cores_per_socket : int; + max_cpu_id : int; + nr_cpus : int; + cpu_khz : int; + total_pages : int64; + free_pages : int64; + scrub_pages : int64; + nr_nodes : int; + hwcap : int32 array; + physcap : int32; + } + external get : unit -> t = "stub_xl_physinfo" +end + +module Sched_credit : sig + type t + { + weight : int; + cap : int; + } + external domain_get : domid -> t = "stub_xl_sched_credit_domain_get" + external domain_set : domid -> t -> unit = "stub_xl_sched_credit_domain_set" +end + +module Topologyinfo : sig + type t + { + core : int; + socket : int; + node : int; + } + external get : unit -> t = "stub_xl_topologyinfo" +end + +external button_press : domid -> button -> unit = "stub_xl_button_press" + +external send_trigger : domid -> string -> int -> unit = "stub_xl_send_trigger" +external send_sysrq : domid -> char -> unit = "stub_xl_send_sysrq" +external send_debug_keys : domid -> string -> unit = "stub_xl_send_debug_keys" diff -r 30e7e76df3ad -r ed47a7438db2 tools/ocaml/libs/xl/xl_stubs.c --- a/tools/ocaml/libs/xl/xl_stubs.c Wed Apr 20 17:13:08 2011 +0100 +++ b/tools/ocaml/libs/xl/xl_stubs.c Wed Apr 20 17:13:08 2011 +0100 @@ -26,7 +26,7 @@ #include <stdint.h> #include <string.h> -#include "libxl.h" +#include <libxl.h> struct caml_logger { struct xentoollog_logger logger; @@ -130,6 +130,8 @@ static int string_string_tuple_array_val #endif +#include "_libxl_types.inc" + static int device_disk_val(caml_gc *gc, libxl_device_disk *c_val, value v) { CAMLparam1(v); _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-20 16:15 UTC
[Xen-devel] [PATCH 32 of 32] tools: ocaml: autogenerate xl datatype definitions and ocaml<->C conversion
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1303315988 -3600 # Node ID 750b91ed2540e66f179b825f101829eab39aeda0 # Parent ed47a7438db2fa25a6e68cc7fbf7296f346c0537 tools: ocaml: autogenerate xl datatype definitions and ocaml<->C conversion The method by which ocaml converts between ocaml types and C datastructures is based around explicit matching of field indexes within the ocaml data type to C structure members which is error prone to write and fragile to maintain (as evidenced by the difference between the existing hand coded support and the autogenerated code which shows how out of date the ocaml bindings have become). Autogenerating these types should reduce these problems. There is a short list of types which are blacklisted and not autogenerated because I expect them to change significantly in the future due to changes to the IDL type (fixing up the TaggedUnion class) so I didn''t want to spend the time to implement the necessary autogenerator features just yet.. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r ed47a7438db2 -r 750b91ed2540 tools/ocaml/libs/xl/Makefile --- a/tools/ocaml/libs/xl/Makefile Wed Apr 20 17:13:08 2011 +0100 +++ b/tools/ocaml/libs/xl/Makefile Wed Apr 20 17:13:08 2011 +0100 @@ -2,6 +2,8 @@ TOPLEVEL=$(CURDIR)/../.. XEN_ROOT=$(TOPLEVEL)/../.. include $(TOPLEVEL)/common.make +# ignore unused generated functions +CFLAGS += -Wno-unused CFLAGS += $(CFLAGS_libxenlight) OBJS = xl diff -r ed47a7438db2 -r 750b91ed2540 tools/ocaml/libs/xl/genwrap.py --- a/tools/ocaml/libs/xl/genwrap.py Wed Apr 20 17:13:08 2011 +0100 +++ b/tools/ocaml/libs/xl/genwrap.py Wed Apr 20 17:13:08 2011 +0100 @@ -4,6 +4,255 @@ import sys,os import libxltypes +# typename -> ( ocaml_type, c_from_ocaml, ocaml_from_c ) +builtins = { + "bool": ("bool", "%(c)s = Bool_val(%(o)s)", "Val_bool(%(c)s)" ), + "int": ("int", "%(c)s = Int_val(%(o)s)", "Val_int(%(c)s)" ), + "char *": ("string", "%(c)s = dup_String_val(gc, %(o)s)", "caml_copy_string(%(c)s)"), + "libxl_domid": ("domid", "%(c)s = Int_val(%(o)s)", "Val_int(%(c)s)" ), + "libxl_uuid": ("int array", "Uuid_val(gc, lg, &%(c)s, %(o)s)", "Val_uuid(&%(c)s)"), + "libxl_key_value_list": ("(string * string) list", None, None), + "libxl_mac": ("int array", "Mac_val(gc, lg, &%(c)s, %(o)s)", "Val_mac(&%(c)s)"), + "libxl_hwcap": ("int32 array", None, "Val_hwcap(&%(c)s)"), + } + +functions = { # ( name , [type1,type2,....] ) + "device_vfb": [ ("add", ["t", "domid", "unit"]), + ("clean_shutdown", ["domid", "unit"]), + ("hard_shutdown", ["domid", "unit"]), + ], + "device_vkb": [ ("add", ["t", "domid", "unit"]), + ("clean_shutdown", ["domid", "unit"]), + ("hard_shutdown", ["domid", "unit"]), + ], + "device_console": [ ("add", ["t", "domid", "unit"]), + ], + "device_disk": [ ("add", ["t", "domid", "unit"]), + ("del", ["t", "domid", "unit"]), + ], + "device_nic": [ ("add", ["t", "domid", "unit"]), + ("del", ["t", "domid", "unit"]), + ], + "device_pci": [ ("add", ["t", "domid", "unit"]), + ("remove", ["t", "domid", "unit"]), + ("shutdown", ["domid", "unit"]), + ], + "physinfo": [ ("get", ["unit", "t"]), + ], + "sched_credit": [ ("domain_get", ["domid", "t"]), + ("domain_set", ["domid", "t", "unit"]), + ], +} +def stub_fn_name(ty, name): + return "stub_xl_%s_%s" % (ty.rawname,name) + +def ocaml_type_of(ty): + if ty.rawname == "domid": + return "domid" + elif isinstance(ty,libxltypes.UInt): + if ty.width in [8, 16]: + # handle as ints + width = None + elif ty.width in [32, 64]: + width = ty.width + else: + raise NotImplementedError("Cannot handle %d-bit int" % ty.width) + if width: + return "int%d" % ty.width + else: + return "int" + + elif isinstance(ty,libxltypes.Builtin): + if not builtins.has_key(ty.typename): + raise NotImplementedError("Unknown Builtin %s (%s)" % (ty.typename, type(ty))) + typename,_,_ = builtins[ty.typename] + if not typename: + raise NotImplementedError("No typename for Builtin %s (%s)" % (ty.typename, type(ty))) + return typename + else: + return ty.rawname + +def ocaml_instance_of(type, name): + return "%s : %s" % (name, ocaml_type_of(type)) + +def gen_ocaml_ml(ty, interface, indent=""): + + if interface: + s = ("""(* %s interface *)\n""" % ty.typename) + else: + s = ("""(* %s implementation *)\n""" % ty.typename) + if isinstance(ty, libxltypes.Enumeration): + s = "type %s = \n" % ty.rawname + for v in ty.values: + s += "\t | %s\n" % v.rawname + elif isinstance(ty, libxltypes.Aggregate): + s = "" + if ty.typename is None: + raise NotImplementedError("%s has no typename" % type(ty)) + else: + + module_name = ty.rawname[0].upper() + ty.rawname[1:] + + if interface: + s += "module %s : sig\n" % module_name + else: + s += "module %s = struct\n" % module_name + s += "\ttype t =\n" + s += "\t{\n" + + for f in ty.fields: + x = ocaml_instance_of(f.type, f.name) + x = x.replace("\n", "\n\t\t") + s += "\t\t" + x + ";\n" + + s += "\t}\n" + + if functions.has_key(ty.rawname): + for name,args in functions[ty.rawname]: + s += "\texternal %s : " % name + s += " -> ".join(args) + s += " = \"%s\"\n" % stub_fn_name(ty,name) + + s += "end\n" + + else: + raise NotImplementedError("%s" % type(ty)) + return s.replace("\n", "\n%s" % indent) + +def c_val(ty, c, o, indent="", parent = None): + if ty.passby == libxltypes.PASS_BY_REFERENCE: + makeref = "" + else: + makeref = "&" + + s = indent + if isinstance(ty,libxltypes.UInt): + if ty.width in [8, 16]: + # handle as ints + width = None + elif ty.width in [32, 64]: + width = ty.width + else: + raise NotImplementedError("Cannot handle %d-bit int" % ty.width) + if width: + s += "%s = Int%d_val(%s);" % (c, width, o) + else: + s += "%s = Int_val(%s);" % (c, o) + elif isinstance(ty,libxltypes.Builtin): + if not builtins.has_key(ty.typename): + raise NotImplementedError("Unknown Builtin %s (%s)" % (ty.typename, type(ty))) + _,fn,_ = builtins[ty.typename] + if not fn: + raise NotImplementedError("No c_val fn for Builtin %s (%s)" % (ty.typename, type(ty))) + s += "%s;" % (fn % { "o": o, "c": c }) + elif isinstance(ty,libxltypes.Enumeration) and (parent is None): + n = 0 + s += "switch(Int_val(%s)) {\n" % o + for e in ty.values: + s += " case %d: *%s = %s; break;\n" % (n, c, e.name) + n += 1 + s += " default: failwith_xl(\"cannot convert value to %s\", lg); break;\n" % ty.typename + s += "}" + elif isinstance(ty, libxltypes.Aggregate) and (parent is None): + n = 0 + for f in ty.fields: + s += "%s\n" % c_val(f.type, "%s->%s" % (c, f.name), "Field(%s, %d)" % (o,n), parent="%s->" % (c)) + n = n + 1 + else: + s += "%s_val(gc, lg, %s, %s);" % (ty.rawname, makeref + c, o) + + return s.replace("\n", "\n%s" % indent) + +def gen_c_val(ty, indent=""): + s = "/* Convert caml value to %s */\n" % ty.rawname + + s += "static int %s_val (caml_gc *gc, struct caml_logger *lg, %s *c_val, value v)\n" % (ty.rawname, ty.typename) + s += "{\n" + s += "\tCAMLparam1(v);\n" + s += "\n" + + s += c_val(ty, "c_val", "v", indent="\t") + "\n" + + s += "\tCAMLreturn(0);\n" + s += "}\n" + + return s.replace("\n", "\n%s" % indent) + +def ocaml_Val(ty, o, c, indent="", parent = None): + if ty.passby == libxltypes.PASS_BY_REFERENCE: + makeref = "" + else: + makeref = "&" + + s = indent + if isinstance(ty,libxltypes.UInt): + if ty.width in [8, 16]: + # handle as ints + width = None + elif ty.width in [32, 64]: + width = ty.width + else: + raise NotImplementedError("Cannot handle %d-bit int" % ty.width) + if width: + s += "%s = caml_copy_int%d(%s);" % (o, width, c) + else: + s += "%s = Val_int(%s);" % (o, c) + elif isinstance(ty,libxltypes.Builtin): + if not builtins.has_key(ty.typename): + raise NotImplementedError("Unknown Builtin %s (%s)" % (ty.typename, type(ty))) + _,_,fn = builtins[ty.typename] + if not fn: + raise NotImplementedError("No ocaml Val fn for Builtin %s (%s)" % (ty.typename, type(ty))) + s += "%s = %s;" % (o, fn % { "c": c }) + elif isinstance(ty,libxltypes.Enumeration) and (parent is None): + n = 0 + s += "switch(*%s) {\n" % c + for e in ty.values: + s += " case %s: %s = Int_val(%d); break;\n" % (e.name, o, n) + n += 1 + s += " default: failwith_xl(\"cannot convert value from %s\", lg); break;\n" % ty.typename + s += "}" + elif isinstance(ty,libxltypes.Aggregate) and (parent is None): + s += "{\n" + s += "\tvalue %s_field;\n" % ty.rawname + s += "\n" + s += "\t%s = caml_alloc_tuple(%d);\n" % (o, len(ty.fields)) + + n = 0 + for f in ty.fields: + s += "\n" + s += "\t%s\n" % ocaml_Val(f.type, "%s_field" % ty.rawname, "%s->%s" % (c,f.name), parent="%s->" % c) + s += "\tStore_field(%s, %d, %s);\n" % (o, n, "%s_field" % ty.rawname) + n = n + 1 + s += "}" + else: + s += "%s = Val_%s(gc, lg, %s);" % (o, ty.rawname, makeref + c) + + return s.replace("\n", "\n%s" % indent).rstrip(indent) + +def gen_Val_ocaml(ty, indent=""): + s = "/* Convert %s to a caml value */\n" % ty.rawname + + s += "static value Val_%s (caml_gc *gc, struct caml_logger *lg, %s *%s_c)\n" % (ty.rawname, ty.typename, ty.rawname) + s += "{\n" + s += "\tCAMLparam0();\n" + s += "\tCAMLlocal1(%s_ocaml);\n" % ty.rawname + + s += ocaml_Val(ty, "%s_ocaml" % ty.rawname, "%s_c" % ty.rawname, indent="\t") + "\n" + + s += "\tCAMLreturn(%s_ocaml);\n" % ty.rawname + s += "}\n" + return s.replace("\n", "\n%s" % indent) + +def gen_c_stub_prototype(ty, fns): + s = "/* Stubs for %s */\n" % ty.rawname + for name,args in fns: + # For N args we return one value and take N-1 values as parameters + s += "value %s(" % stub_fn_name(ty, name) + s += ", ".join(["value v%d" % v for v in range(1,len(args))]) + s += ");\n" + return s + def autogen_header(open_comment, close_comment): s = open_comment + " AUTO-GENERATED FILE DO NOT EDIT " + close_comment + "\n" s += open_comment + " autogenerated by \n" @@ -20,6 +269,21 @@ if __name__ == ''__main__'': idl = sys.argv[1] (_,types) = libxltypes.parse(idl) + # Do not generate these yet. + blacklist = [ + "cpupoolinfo", + "domain_create_info", + "domain_build_info", + "device_model_info", + "vcpuinfo", + "topologyinfo", + ] + + for t in blacklist: + if t not in [ty.rawname for ty in types]: + print "unknown type %s in blacklist" % t + + types = [ty for ty in types if not ty.rawname in blacklist] _ml = sys.argv[3] ml = open(_ml, ''w'') @@ -33,8 +297,25 @@ if __name__ == ''__main__'': cinc = open(_cinc, ''w'') cinc.write(autogen_header("/*", "*/")) - # TODO: autogenerate something + for ty in types: + #sys.stdout.write(" TYPE %-20s " % ty.rawname) + ml.write(gen_ocaml_ml(ty, False)) + ml.write("\n") + mli.write(gen_ocaml_ml(ty, True)) + mli.write("\n") + + if ty.marshal_in(): + cinc.write(gen_c_val(ty)) + cinc.write("\n") + if ty.marshal_out(): + cinc.write(gen_Val_ocaml(ty)) + cinc.write("\n") + if functions.has_key(ty.rawname): + cinc.write(gen_c_stub_prototype(ty, functions[ty.rawname])) + cinc.write("\n") + #sys.stdout.write("\n") + ml.write("(* END OF AUTO-GENERATED CODE *)\n") ml.close() mli.write("(* END OF AUTO-GENERATED CODE *)\n") diff -r ed47a7438db2 -r 750b91ed2540 tools/ocaml/libs/xl/xl.ml.in --- a/tools/ocaml/libs/xl/xl.ml.in Wed Apr 20 17:13:08 2011 +0100 +++ b/tools/ocaml/libs/xl/xl.ml.in Wed Apr 20 17:13:08 2011 +0100 @@ -19,145 +19,6 @@ type domid = int (* @@LIBXL_TYPES@@ *) -type console_type - | CONSOLETYPE_XENCONSOLED - | CONSOLETYPE_IOEMU - -type disk_phystype - | PHYSTYPE_QCOW - | PHYSTYPE_QCOW2 - | PHYSTYPE_VHD - | PHYSTYPE_AIO - | PHYSTYPE_FILE - | PHYSTYPE_PHY - -type nic_type - | NICTYPE_IOEMU - | NICTYPE_VIF - -type button - | Button_Power - | Button_Sleep - -module Device_vfb = struct - type t - { - backend_domid : domid; - devid : int; - vnc : bool; - vnclisten : string; - vncpasswd : string; - vncdisplay : int; - vncunused : bool; - keymap : string; - sdl : bool; - opengl : bool; - display : string; - xauthority : string; - } - external add : t -> domid -> unit = "stub_xl_device_vfb_add" - external clean_shutdown : domid -> unit = "stub_xl_device_vfb_clean_shutdown" - external hard_shutdown : domid -> unit = "stub_xl_device_vfb_hard_shutdown" -end - -module Device_vkb = struct - type t - { - backend_domid : domid; - devid : int; - } - external add : t -> domid -> unit = "stub_xl_device_vkb_add" - external clean_shutdown : domid -> unit = "stub_xl_device_vkb_clean_shutdown" - external hard_shutdown : domid -> unit = "stub_xl_device_vkb_hard_shutdown" -end - -module Device_console = struct - type t - { - backend_domid : domid; - devid : int; - consoletype : console_type; - } - external add : t -> domid -> unit = "stub_xl_device_console_add" -end - -module Device_disk = struct - type t - { - backend_domid : domid; - physpath : string; - phystype : disk_phystype; - virtpath : string; - unpluggable : bool; - readwrite : bool; - is_cdrom : bool; - } - external add : t -> domid -> unit = "stub_xl_device_disk_add" - external del : t -> domid -> unit = "stub_xl_device_disk_del" -end - -module Device_nic = struct - type t - { - backend_domid : domid; - devid : int; - mtu : int; - model : string; - mac : int array; - bridge : string; - ifname : string; - script : string; - nictype : nic_type; - } - external add : t -> domid -> unit = "stub_xl_device_nic_add" - external del : t -> domid -> unit = "stub_xl_device_nic_del" -end - -module Device_pci = struct - type t - { - func : int; - dev : int; - bus : int; - domain : int; - vdevfn : int; - msitranslate : bool; - power_mgmt : bool; - } - external add : t -> domid -> unit = "stub_xl_device_pci_add" - external remove : t -> domid -> unit = "stub_xl_device_pci_remove" - external shutdown : domid -> unit = "stub_xl_device_pci_shutdown" -end - -module Physinfo = struct - type t - { - threads_per_core : int; - cores_per_socket : int; - max_cpu_id : int; - nr_cpus : int; - cpu_khz : int; - total_pages : int64; - free_pages : int64; - scrub_pages : int64; - nr_nodes : int; - hwcap : int32 array; - physcap : int32; - } - external get : unit -> t = "stub_xl_physinfo" - -end - -module Sched_credit = struct - type t - { - weight : int; - cap : int; - } - external domain_get : domid -> t = "stub_xl_sched_credit_domain_get" - external domain_set : domid -> t -> unit = "stub_xl_sched_credit_domain_set" -end - module Topologyinfo = struct type t { diff -r ed47a7438db2 -r 750b91ed2540 tools/ocaml/libs/xl/xl.mli.in --- a/tools/ocaml/libs/xl/xl.mli.in Wed Apr 20 17:13:08 2011 +0100 +++ b/tools/ocaml/libs/xl/xl.mli.in Wed Apr 20 17:13:08 2011 +0100 @@ -19,145 +19,6 @@ type domid = int (* @@LIBXL_TYPES@@ *) -type console_type - | CONSOLETYPE_XENCONSOLED - | CONSOLETYPE_IOEMU - -type disk_phystype - | PHYSTYPE_QCOW - | PHYSTYPE_QCOW2 - | PHYSTYPE_VHD - | PHYSTYPE_AIO - | PHYSTYPE_FILE - | PHYSTYPE_PHY - -type nic_type - | NICTYPE_IOEMU - | NICTYPE_VIF - -type button - | Button_Power - | Button_Sleep - -module Device_vfb : sig - type t - { - backend_domid : domid; - devid : int; - vnc : bool; - vnclisten : string; - vncpasswd : string; - vncdisplay : int; - vncunused : bool; - keymap : string; - sdl : bool; - opengl : bool; - display : string; - xauthority : string; - } - external add : t -> domid -> unit = "stub_xl_device_vfb_add" - external clean_shutdown : domid -> unit = "stub_xl_device_vfb_clean_shutdown" - external hard_shutdown : domid -> unit = "stub_xl_device_vfb_hard_shutdown" -end - -module Device_vkb : sig - type t - { - backend_domid : domid; - devid : int; - } - external add : t -> domid -> unit = "stub_xl_device_vkb_add" - external clean_shutdown : domid -> unit = "stub_xl_device_vkb_clean_shutdown" - external hard_shutdown : domid -> unit = "stub_xl_device_vkb_hard_shutdown" -end - -module Device_console : sig - type t - { - backend_domid : domid; - devid : int; - consoletype : console_type; - } - - external add : t -> domid -> unit = "stub_xl_device_console_add" -end - -module Device_disk : sig - type t - { - backend_domid : domid; - physpath : string; - phystype : disk_phystype; - virtpath : string; - unpluggable : bool; - readwrite : bool; - is_cdrom : bool; - } - external add : t -> domid -> unit = "stub_xl_device_disk_add" - external del : t -> domid -> unit = "stub_xl_device_disk_del" -end - -module Device_nic : sig - type t - { - backend_domid : domid; - devid : int; - mtu : int; - model : string; - mac : int array; - bridge : string; - ifname : string; - script : string; - nictype : nic_type; - } - external add : t -> domid -> unit = "stub_xl_device_nic_add" - external del : t -> domid -> unit = "stub_xl_device_nic_del" -end - -module Device_pci : sig - type t - { - func : int; - dev : int; - bus : int; - domain : int; - vdevfn : int; - msitranslate : bool; - power_mgmt : bool; - } - external add : t -> domid -> unit = "stub_xl_device_pci_add" - external remove : t -> domid -> unit = "stub_xl_device_pci_remove" - external shutdown : domid -> unit = "stub_xl_device_pci_shutdown" -end - -module Physinfo : sig - type t - { - threads_per_core : int; - cores_per_socket : int; - max_cpu_id : int; - nr_cpus : int; - cpu_khz : int; - total_pages : int64; - free_pages : int64; - scrub_pages : int64; - nr_nodes : int; - hwcap : int32 array; - physcap : int32; - } - external get : unit -> t = "stub_xl_physinfo" -end - -module Sched_credit : sig - type t - { - weight : int; - cap : int; - } - external domain_get : domid -> t = "stub_xl_sched_credit_domain_get" - external domain_set : domid -> t -> unit = "stub_xl_sched_credit_domain_set" -end - module Topologyinfo : sig type t { diff -r ed47a7438db2 -r 750b91ed2540 tools/ocaml/libs/xl/xl_stubs.c --- a/tools/ocaml/libs/xl/xl_stubs.c Wed Apr 20 17:13:08 2011 +0100 +++ b/tools/ocaml/libs/xl/xl_stubs.c Wed Apr 20 17:13:08 2011 +0100 @@ -39,7 +39,7 @@ typedef struct caml_gc { void *ptrs[64]; } caml_gc; -void log_vmessage(struct xentoollog_logger *logger, xentoollog_level level, +static void log_vmessage(struct xentoollog_logger *logger, xentoollog_level level, int errnoval, const char *context, const char *format, va_list al) { struct caml_logger *ologger = (struct caml_logger *) logger; @@ -48,7 +48,7 @@ void log_vmessage(struct xentoollog_logg 2048 - ologger->log_offset, format, al); } -void log_destroy(struct xentoollog_logger *logger) +static void log_destroy(struct xentoollog_logger *logger) { } @@ -89,7 +89,7 @@ static void gc_free(caml_gc *gc) } } -void failwith_xl(char *fname, struct caml_logger *lg) +static void failwith_xl(char *fname, struct caml_logger *lg) { char *s; s = (lg) ? lg->log_buf : fname; @@ -130,153 +130,72 @@ static int string_string_tuple_array_val #endif -#include "_libxl_types.inc" +static value Val_mac (libxl_mac *c_val) +{ + CAMLparam0(); + CAMLlocal1(v); + int i; -static int device_disk_val(caml_gc *gc, libxl_device_disk *c_val, value v) + v = caml_alloc_tuple(6); + + for(i=0; i<6; i++) + Store_field(v, i, Val_int((*c_val)[i])); + + CAMLreturn(v); +} + +static int Mac_val(caml_gc *gc, struct caml_logger *lg, libxl_mac *c_val, value v) { CAMLparam1(v); + int i; - c_val->backend_domid = Int_val(Field(v, 0)); - c_val->pdev_path = dup_String_val(gc, Field(v, 1)); - c_val->vdev = dup_String_val(gc, Field(v, 2)); - c_val->backend = (Int_val(Field(v, 3))); - c_val->format = (Int_val(Field(v, 4))); - c_val->unpluggable = Bool_val(Field(v, 5)); - c_val->readwrite = Bool_val(Field(v, 6)); - c_val->is_cdrom = Bool_val(Field(v, 7)); + for(i=0; i<6; i++) + (*c_val)[i] = Int_val(Field(v, i)); CAMLreturn(0); } -static int device_nic_val(caml_gc *gc, libxl_device_nic *c_val, value v) +static value Val_uuid (libxl_uuid *c_val) +{ + CAMLparam0(); + CAMLlocal1(v); + uint8_t *uuid = libxl_uuid_bytearray(c_val); + int i; + + v = caml_alloc_tuple(16); + + for(i=0; i<16; i++) + Store_field(v, i, Val_int(uuid[i])); + + CAMLreturn(v); +} + +static int Uuid_val(caml_gc *gc, struct caml_logger *lg, libxl_uuid *c_val, value v) { CAMLparam1(v); int i; - int ret = 0; - c_val->backend_domid = Int_val(Field(v, 0)); - c_val->devid = Int_val(Field(v, 1)); - c_val->mtu = Int_val(Field(v, 2)); - c_val->model = dup_String_val(gc, Field(v, 3)); + uint8_t *uuid = libxl_uuid_bytearray(c_val); - if (Wosize_val(Field(v, 4)) != 6) { - ret = 1; - goto out; - } - for (i = 0; i < 6; i++) - c_val->mac[i] = Int_val(Field(Field(v, 4), i)); - - /* not handling c_val->ip */ - c_val->bridge = dup_String_val(gc, Field(v, 5)); - c_val->ifname = dup_String_val(gc, Field(v, 6)); - c_val->script = dup_String_val(gc, Field(v, 7)); - c_val->nictype = (Int_val(Field(v, 8))) + LIBXL_NIC_TYPE_IOEMU; - -out: - CAMLreturn(ret); -} - -static int device_console_val(caml_gc *gc, libxl_device_console *c_val, value v) -{ - CAMLparam1(v); - - c_val->backend_domid = Int_val(Field(v, 0)); - c_val->devid = Int_val(Field(v, 1)); - c_val->consback = (Int_val(Field(v, 2))) + LIBXL_CONSOLE_BACKEND_XENCONSOLED; + for(i=0; i<16; i++) + uuid[i] = Int_val(Field(v, i)); CAMLreturn(0); } -static int device_vkb_val(caml_gc *gc, libxl_device_vkb *c_val, value v) -{ - CAMLparam1(v); - - c_val->backend_domid = Int_val(Field(v, 0)); - c_val->devid = Int_val(Field(v, 1)); - - CAMLreturn(0); -} - -static int device_vfb_val(caml_gc *gc, libxl_device_vfb *c_val, value v) -{ - CAMLparam1(v); - - c_val->backend_domid = Int_val(Field(v, 0)); - c_val->devid = Int_val(Field(v, 1)); - c_val->vnc = Bool_val(Field(v, 2)); - c_val->vnclisten = dup_String_val(gc, Field(v, 3)); - c_val->vncpasswd = dup_String_val(gc, Field(v, 4)); - c_val->vncdisplay = Int_val(Field(v, 5)); - c_val->keymap = dup_String_val(gc, Field(v, 6)); - c_val->sdl = Bool_val(Field(v, 7)); - c_val->opengl = Bool_val(Field(v, 8)); - c_val->display = dup_String_val(gc, Field(v, 9)); - c_val->xauthority = dup_String_val(gc, Field(v, 10)); - - CAMLreturn(0); -} - -static int device_pci_val(caml_gc *gc, libxl_device_pci *c_val, value v) -{ - CAMLparam1(v); - - c_val->func = Int_val(Field(v, 0)); - c_val->dev = Int_val(Field(v, 1)); - c_val->bus = Int_val(Field(v, 2)); - - c_val->domain = Int_val(Field(v, 3)); - c_val->vdevfn = Int_val(Field(v, 4)); - c_val->msitranslate = Bool_val(Field(v, 5)); - c_val->power_mgmt = Bool_val(Field(v, 6)); - - CAMLreturn(0); -} - -static int sched_credit_val(caml_gc *gc, libxl_sched_credit *c_val, value v) -{ - CAMLparam1(v); - c_val->weight = Int_val(Field(v, 0)); - c_val->cap = Int_val(Field(v, 1)); - CAMLreturn(0); -} - -static value Val_sched_credit(libxl_sched_credit *c_val) +static value Val_hwcap(libxl_hwcap *c_val) { CAMLparam0(); - CAMLlocal1(v); - - v = caml_alloc_tuple(2); - - Store_field(v, 0, Val_int(c_val->weight)); - Store_field(v, 1, Val_int(c_val->cap)); - - CAMLreturn(v); -} - -static value Val_physinfo(libxl_physinfo *c_val) -{ - CAMLparam0(); - CAMLlocal2(v, hwcap); + CAMLlocal1(hwcap); int i; hwcap = caml_alloc_tuple(8); for (i = 0; i < 8; i++) - Store_field(hwcap, i, caml_copy_int32(c_val->hw_cap[i])); + Store_field(hwcap, i, caml_copy_int32((*c_val)[i])); - v = caml_alloc_tuple(11); - Store_field(v, 0, Val_int(c_val->threads_per_core)); - Store_field(v, 1, Val_int(c_val->cores_per_socket)); - Store_field(v, 2, Val_int(c_val->max_cpu_id)); - Store_field(v, 3, Val_int(c_val->nr_cpus)); - Store_field(v, 4, Val_int(c_val->cpu_khz)); - Store_field(v, 5, caml_copy_int64(c_val->total_pages)); - Store_field(v, 6, caml_copy_int64(c_val->free_pages)); - Store_field(v, 7, caml_copy_int64(c_val->scrub_pages)); - Store_field(v, 8, Val_int(c_val->nr_nodes)); - Store_field(v, 9, hwcap); - Store_field(v, 10, caml_copy_int32(c_val->phys_cap)); + CAMLreturn(hwcap); +} - CAMLreturn(v); -} +#include "_libxl_types.inc" static value Val_topologyinfo(libxl_topologyinfo *c_val) { @@ -308,7 +227,7 @@ value stub_xl_device_disk_add(value info int ret; INIT_STRUCT(); - device_disk_val(&gc, &c_info, info); + device_disk_val(&gc, &lg, &c_info, info); INIT_CTX(); ret = libxl_device_disk_add(ctx, Int_val(domid), &c_info); @@ -325,7 +244,7 @@ value stub_xl_device_disk_del(value info int ret; INIT_STRUCT(); - device_disk_val(&gc, &c_info, info); + device_disk_val(&gc, &lg, &c_info, info); INIT_CTX(); ret = libxl_device_disk_del(ctx, Int_val(domid), &c_info, 0); @@ -342,7 +261,7 @@ value stub_xl_device_nic_add(value info, int ret; INIT_STRUCT(); - device_nic_val(&gc, &c_info, info); + device_nic_val(&gc, &lg, &c_info, info); INIT_CTX(); ret = libxl_device_nic_add(ctx, Int_val(domid), &c_info); @@ -359,7 +278,7 @@ value stub_xl_device_nic_del(value info, int ret; INIT_STRUCT(); - device_nic_val(&gc, &c_info, info); + device_nic_val(&gc, &lg, &c_info, info); INIT_CTX(); ret = libxl_device_nic_del(ctx, Int_val(domid), &c_info, 0); @@ -376,7 +295,7 @@ value stub_xl_device_console_add(value i int ret; INIT_STRUCT(); - device_console_val(&gc, &c_info, info); + device_console_val(&gc, &lg, &c_info, info); INIT_CTX(); ret = libxl_device_console_add(ctx, Int_val(domid), &c_info); @@ -393,7 +312,7 @@ value stub_xl_device_vkb_add(value info, int ret; INIT_STRUCT(); - device_vkb_val(&gc, &c_info, info); + device_vkb_val(&gc, &lg, &c_info, info); INIT_CTX(); ret = libxl_device_vkb_add(ctx, Int_val(domid), &c_info); @@ -441,7 +360,7 @@ value stub_xl_device_vfb_add(value info, int ret; INIT_STRUCT(); - device_vfb_val(&gc, &c_info, info); + device_vfb_val(&gc, &lg, &c_info, info); INIT_CTX(); ret = libxl_device_vfb_add(ctx, Int_val(domid), &c_info); @@ -489,7 +408,7 @@ value stub_xl_device_pci_add(value info, int ret; INIT_STRUCT(); - device_pci_val(&gc, &c_info, info); + device_pci_val(&gc, &lg, &c_info, info); INIT_CTX(); ret = libxl_device_pci_add(ctx, Int_val(domid), &c_info); @@ -507,7 +426,7 @@ value stub_xl_device_pci_remove(value in int ret; INIT_STRUCT(); - device_pci_val(&gc, &c_info, info); + device_pci_val(&gc, &lg, &c_info, info); INIT_CTX(); ret = libxl_device_pci_remove(ctx, Int_val(domid), &c_info, 0); @@ -548,7 +467,7 @@ value stub_xl_button_press(value domid, CAMLreturn(Val_unit); } -value stub_xl_physinfo(value unit) +value stub_xl_physinfo_get(value unit) { CAMLparam1(unit); CAMLlocal1(physinfo); @@ -561,8 +480,8 @@ value stub_xl_physinfo(value unit) if (ret != 0) failwith_xl("physinfo", &lg); FREE_CTX(); - - physinfo = Val_physinfo(&c_physinfo); + + physinfo = Val_physinfo(&gc, &lg, &c_physinfo); CAMLreturn(physinfo); } @@ -579,7 +498,7 @@ value stub_xl_topologyinfo(value unit) if (ret != 0) failwith_xl("topologyinfo", &lg); FREE_CTX(); - + topologyinfo = Val_topologyinfo(&c_topologyinfo); CAMLreturn(topologyinfo); } @@ -597,8 +516,8 @@ value stub_xl_sched_credit_domain_get(va if (ret != 0) failwith_xl("sched_credit_domain_get", &lg); FREE_CTX(); - - scinfo = Val_sched_credit(&c_scinfo); + + scinfo = Val_sched_credit(&gc, &lg, &c_scinfo); CAMLreturn(scinfo); } @@ -609,14 +528,14 @@ value stub_xl_sched_credit_domain_set(va int ret; INIT_STRUCT(); - sched_credit_val(&gc, &c_scinfo, scinfo); + sched_credit_val(&gc, &lg, &c_scinfo, scinfo); INIT_CTX(); ret = libxl_sched_credit_domain_set(ctx, Int_val(domid), &c_scinfo); if (ret != 0) failwith_xl("sched_credit_domain_set", &lg); FREE_CTX(); - + CAMLreturn(Val_unit); } _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel