tools: libxl IDL, SeaBIOS, ocaml binding autogeneration, misc
PATCH v2 1/1 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.
PATCH 1/1 tools: libxl: hide selection of hvmloader by default
# HG changeset patch
# User Ian Campbell <[email protected]> # 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.
tools/libxl/libxl.idl +4 -3
@@ -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),
tools/libxl/libxl_bootloader.c +7 -6
@@ -44,8 +44,9 @@ static char **make_bootloader_args(libxlflexarray_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 " ));
tools/libxl/libxl_create.c +7 -6
@@ -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;
tools/libxl/libxl_dm.c +2 -1
@@ -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 ="" ;
tools/libxl/libxl_dom.c +16 -10
@@ -160,13 +160,17 @@ int libxl__build_pv(libxl__gc *gc, uint3return 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_interreturn 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;
tools/libxl/xl_cmdimpl.c +11 -5
@@ -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 charif (!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 charchar *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 charxlu_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 ); }
PATCH 1/1 tools: libxl: hide selection of device-model by default
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# 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.
tools/libxl/libxl.c +3 -1
@@ -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 ; }
tools/libxl/libxl.h +7 -0
@@ -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,
tools/libxl/libxl.idl +4 -1
@@ -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),
tools/libxl/libxl_create.c +3 -1
@@ -108,7 +108,9 @@ void libxl_init_dm_info(libxl_device_modlibxl_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;
tools/libxl/libxl_dm.c +76 -18
165 lines not on this page · raw message
tools/libxl/libxl_internal.h +2 -0
@@ -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,
tools/libxl/libxl_utils.c +0 -83
89 lines not on this page · raw message
tools/libxl/libxl_utils.h +0 -6
@@ -66,12 +66,6 @@ int libxl_devid_to_device_nic(libxl_ctxint 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);
tools/libxl/xl_cmdimpl.c +29 -2
@@ -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 charxlu_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))
PATCH 1/1 tools: libxl: write selected BIOS to xenstore
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1303315986 -3600
# Node ID 8eb5c6ebc5c95791e8c129e75030a7979c1e7f5d # Parent e8073053ef283658dd096f0846b0c438a29b6778
tools: libxl: write selected BIOS to xenstore.
tools/libxl/libxl_dm.c +16 -0
@@ -69,6 +69,16 @@ const char *libxl__domain_device_model(lreturn 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;
PATCH 1/1 tools: support SeaBIOS. Use by default when upstream qemu is configured
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# 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.
Config.mk +12 -0
@@ -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
tools/firmware/hvmloader/Makefile +15 -2
@@ -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 */" > [email protected] ifneq ($(ROMBIOS_ROM),)
@@ -71,6 +78,12 @@ ifneq ($(ROMBIOS_ROM),) echo "#endif" >> [email protected] endif +ifneq ($(SEABIOS_ROM),) + echo "#ifdef ROM_INCLUDE_SEABIOS" >> [email protected] + sh ./mkhex seabios $(SEABIOS_ROM) >> [email protected] + echo "#endif" >> [email protected] +endif + ifneq ($(STDVGA_ROM),) echo "#ifdef ROM_INCLUDE_VGABIOS" >> [email protected] sh ./mkhex vgabios_stdvga $(STDVGA_ROM) >> [email protected]
tools/firmware/hvmloader/config-seabios.h new file +9 -0
@@ -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__ */
tools/firmware/hvmloader/config.h +1 -0
@@ -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)
tools/firmware/hvmloader/hvmloader.c +5 -0
@@ -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 } };
tools/firmware/hvmloader/seabios.c new file +75 -0
75 lines not on this page · raw message
tools/libxl/libxl_dm.c +1 -2
@@ -65,7 +65,6 @@ const char *libxl__domain_device_model(lbreak ; } } -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 ; } }
PATCH 1/1 tools: libxl: move all enum values into the libxl namespace
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1303315987 -3600
# Node ID 34f797bacb7886641aa6f340356b915433d4a73b # Parent 2b4be83bdc1aa1aaf13e0ff46c687802d77292dd
tools: libxl: move all enum values into the libxl namespace
tools/libxl/libxl.c +35 -34
@@ -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(lichar *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_nif (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, uif (!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, uint 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 :
tools/libxl/libxl.h +16 -16
@@ -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);
tools/libxl/libxl_device.c +8 -8
@@ -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_formachar *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 ; } }
tools/libxl/libxl_dm.c +31 -23
150 lines not on this page · raw message
tools/libxl/libxl_utils.c +5 -5
@@ -283,9 +283,9 @@ int libxl_string_to_backend(libxl_ctx *cint 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:
tools/libxl/xl_cmdimpl.c +34 -32
135 lines not on this page · raw message
tools/ocaml/libs/xl/xl_stubs.c +2 -2
@@ -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 ();
tools/python/xen/lowlevel/xl/xl.c +16 -16
@@ -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); }
PATCH 1/1 tools: libxl: generalize libxl_qemu_machine_type into libxl_domain_type
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# 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.
tools/libxl/libxl.h +3 -3
@@ -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) */
tools/libxl/libxl.idl +2 -2
@@ -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"),
tools/libxl/libxl_dm.c +10 -10
@@ -140,7 +140,7 @@ static char ** libxl__build_device_modelif (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_modelflexarray_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_modelflexarray_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_modelflexarray_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_modelif (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_modelflexarray_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_modelflexarray_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 ; }
tools/libxl/xl_cmdimpl.c +2 -2
@@ -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); }
tools/python/xen/lowlevel/xl/xl.c +2 -2
@@ -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 );
PATCH 1/1 tools: libxl: namespace enum values within their type
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # 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.
tools/libxl/libxl.c +10 -10
@@ -592,7 +592,7 @@ int libxl_get_wait_fd(libxl_ctx *ctx, inint 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, uchar *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_ctxint 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_nif (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" );
tools/libxl/libxl.h +17 -17
@@ -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 0typedef 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_ctxint 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
tools/libxl/libxl.idl +3 -3
@@ -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), ])
tools/libxl/libxl_create.c +2 -2
@@ -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);
tools/libxl/libxl_dm.c +4 -4
@@ -172,7 +172,7 @@ static char ** libxl__build_device_modelflexarray_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_modelflexarray_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; }
tools/libxl/xl_cmdimpl.c +30 -30
142 lines not on this page · raw message
tools/ocaml/libs/xl/xl_stubs.c +2 -2
@@ -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 ); }
tools/python/xen/lowlevel/xl/xl.c +8 -8
@@ -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 );
PATCH 1/1 tools: libxl: add an Enumeration type to the IDL
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # 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.
tools/libxl/gentypes.py +22 -1
@@ -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)
tools/libxl/idl.txt +24 -0
@@ -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
tools/libxl/libxl.h +0 -65
89 lines not on this page · raw message
tools/libxl/libxl.idl +67 -7
86 lines not on this page · raw message
tools/libxl/libxltypes.py +29 -0
@@ -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)
tools/libxl/xl_cmdimpl.c +2 -0
@@ -451,6 +451,8 @@ static int parse_action_on_shutdown(consfor (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 ;
tools/python/genwrap.py +32 -21
87 lines not on this page · raw message
tools/python/xen/lowlevel/xl/xl.c +0 -29
@@ -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); }
PATCH 1/1 tools: libxl: add libxl_domid to IDL
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # 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.
tools/libxl/libxl.h +2 -0
@@ -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 ;
tools/libxl/libxl.idl +9 -9
@@ -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),
tools/libxl/libxltypes.py +0 -2
@@ -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):
tools/python/xen/lowlevel/xl/xl.c +10 -0
@@ -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_ureturn 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" );
PATCH 1/1 tools: libxl: remove BitField type class from IDL
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # 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).
tools/libxl/gentypes.py +1 -3
@@ -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:
tools/libxl/idl.txt +0 -8
@@ -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
tools/libxl/libxl.idl +8 -8
@@ -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"), ])
tools/libxl/libxltypes.py +0 -8
@@ -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):
tools/python/genwrap.py +1 -1
@@ -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
PATCH 1/1 tools: libxl: add concept of in- and out-put only data types to IDL
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# 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.
tools/libxl/libxl.idl +1 -1
@@ -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"),
tools/libxl/libxltypes.py +15 -1
@@ -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:
tools/python/genwrap.py +19 -8
@@ -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()
PATCH 1/1 tools: libxl: do not specify protocol node for disk or net
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# 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!
tools/libxl/libxl.c +0 -10
@@ -1060,11 +1060,6 @@ int libxl_device_disk_add(libxl_ctx *ctxflexarray_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));
PATCH 1/1 tools: ocaml: rename the device_nic types and functions
In reply to Ian Campbell# HG changeset patch
# User David Scott <[email protected]> # 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
tools/ocaml/libs/xl/xl.ml +17 -16
@@ -1,5 +1,5 @@ (* - * Copyright (C) 2009-2010 Citrix Ltd. + * Copyright (C) 2009-2011 Citrix Ltd. * Author Vincent Hanquez <[email protected]> * * 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"
tools/ocaml/libs/xl/xl.mli +17 -16
@@ -1,5 +1,5 @@ (* - * Copyright (C) 2009-2010 Citrix Ltd. + * Copyright (C) 2009-2011 Citrix Ltd. * Author Vincent Hanquez <[email protected]> * * 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"
tools/ocaml/libs/xl/xl_stubs.c +4 -4
@@ -1,5 +1,5 @@/* -* Copyright (C) 2009-2010 Citrix Ltd. +* Copyright (C) 2009-2011 Citrix Ltd. * Author Vincent Hanquez <[email protected]> * * This program is free software; you can redistribute it and/or modify
@@ -402,7 +402,7 @@ value stub_xl_disk_remove(value info, vaCAMLreturn (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, valueCAMLreturn (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, valINIT_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); }
PATCH 1/1 tools: ocaml: rename the disk_info types and functions
In reply to Ian Campbell# HG changeset patch
# User David Scott <[email protected]> # 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
tools/ocaml/libs/xl/xl.ml +15 -13
@@ -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"
tools/ocaml/libs/xl/xl.mli +15 -13
@@ -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"
tools/ocaml/libs/xl/xl_stubs.c +3 -3
@@ -368,7 +368,7 @@ static value Val_topologyinfo(libxl_topoCAMLreturn (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, valueCAMLreturn (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, vaINIT_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); }
PATCH 1/1 tools: ocaml: rename the console types and functions
In reply to Ian Campbell# HG changeset patch
# User David Scott <[email protected]> # 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
tools/ocaml/libs/xl/xl.ml +10 -8
@@ -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"
tools/ocaml/libs/xl/xl.mli +10 -8
@@ -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"
tools/ocaml/libs/xl/xl_stubs.c +1 -1
@@ -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;
PATCH 1/1 tools: ocaml: rename the vkb types and functions
In reply to Ian Campbell# HG changeset patch
# User David Scott <[email protected]> # 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
tools/ocaml/libs/xl/xl.ml +32 -28
@@ -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"
tools/ocaml/libs/xl/xl.mli +31 -28
72 lines not on this page · raw message
tools/ocaml/libs/xl/xl_stubs.c +6 -6
@@ -456,7 +456,7 @@ value stub_xl_device_console_add(value iCAMLreturn (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, valueCAMLreturn (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 dCAMLreturn (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 doCAMLreturn (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, valueCAMLreturn (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 dCAMLreturn (Val_unit); } -value stub_xl_vfb_hard_shutdown (value domid) +value stub_xl_device_vfb_hard_shutdown (value domid) {CAMLparam1 (domid);int ret;
PATCH 1/1 tools: ocaml: rename the pci types and functions
In reply to Ian Campbell# HG changeset patch
# User David Scott <[email protected]> # 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
tools/ocaml/libs/xl/xl.ml +15 -14
@@ -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
tools/ocaml/libs/xl/xl.mli +16 -14
@@ -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
tools/ocaml/libs/xl/xl_stubs.c +3 -3
@@ -552,7 +552,7 @@ value stub_xl_device_vfb_hard_shutdown(vCAMLreturn (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, valueCAMLreturn (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, valCAMLreturn (Val_unit); } -value stub_xl_pci_shutdown (value domid) +value stub_xl_device_pci_shutdown (value domid) {CAMLparam1 (domid);int ret;
PATCH 1/1 tools: ocaml: remove the domain_make and domain_build functions since they don't work
In reply to Ian Campbell# HG changeset patch
# User David Scott <[email protected]>
# 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.
tools/ocaml/libs/xl/xl.ml +0 -3
@@ -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
tools/ocaml/libs/xl/xl.mli +0 -3
@@ -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
PATCH 1/1 tools: ocaml: rename the create_info types and functions
In reply to Ian Campbell# HG changeset patch
# User David Scott <[email protected]>
# 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
tools/ocaml/libs/xl/xl.ml +15 -13
@@ -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 = {
tools/ocaml/libs/xl/xl.mli +15 -13
@@ -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 = {
PATCH 1/1 tools: ocaml: rename the build_info types and functions
In reply to Ian Campbell# HG changeset patch
# User David Scott <[email protected]> # 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
tools/ocaml/libs/xl/xl.ml +36 -32
@@ -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 = {
tools/ocaml/libs/xl/xl.mli +36 -32
76 lines not on this page · raw message
PATCH 1/1 tools: ocaml: rename the domain_build_state types and functions
In reply to Ian Campbell# HG changeset patch
# User David Scott <[email protected]>
# 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
tools/ocaml/libs/xl/xl.ml +10 -8
@@ -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
tools/ocaml/libs/xl/xl.mli +10 -8
@@ -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
PATCH 1/1 tools: ocaml: rename the physinfo types and functions
In reply to Ian Campbell# HG changeset patch
# User David Scott <[email protected]> # 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
tools/ocaml/libs/xl/xl.ml +18 -15
@@ -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"
tools/ocaml/libs/xl/xl.mli +18 -15
@@ -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"
PATCH 1/1 tools: ocaml: rename the sched_credit types and functions
In reply to Ian Campbell# HG changeset patch
# User David Scott <[email protected]>
# 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
tools/ocaml/libs/xl/xl.ml +9 -8
@@ -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"
tools/ocaml/libs/xl/xl.mli +10 -8
@@ -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"
PATCH 1/1 tools: ocaml: rename the topology types and functions
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # 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
tools/ocaml/libs/xl/xl.ml +9 -9
@@ -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"
tools/ocaml/libs/xl/xl.mli +9 -10
@@ -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"
PATCH 1/1 tools: libxl: remove libxl_domain_build_state from the IDL
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# 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.
tools/libxl/libxl.c +31 -18
@@ -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; }
tools/libxl/libxl.idl +0 -8
@@ -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), ])
tools/libxl/libxl_create.c +10 -10
@@ -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 *glibxl_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 *gif (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 *glibxl_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 *gif (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)
tools/libxl/libxl_dm.c +3 -3
@@ -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; }
tools/libxl/libxl_dom.c +9 -7
@@ -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 */
tools/libxl/libxl_internal.h +22 -6
@@ -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,
tools/ocaml/libs/xl/xl.ml +1 -11
@@ -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
tools/ocaml/libs/xl/xl.mli +1 -11
@@ -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
tools/ocaml/libs/xl/xl_stubs.c +2 -17
@@ -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);
tools/python/xen/lowlevel/xl/xl.c +0 -12
@@ -232,12 +232,6 @@ int attrib__libxl_cpuarray_set(PyObjectreturn -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(libreturn 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);
PATCH 1/1 tools: libxl: remove Reference meta-type from IDL
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # 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.
tools/libxl/gentypes.py +7 -11
@@ -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")
tools/libxl/idl.txt +0 -7
@@ -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 --------------------
tools/libxl/libxltypes.py +0 -18
@@ -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 #
PATCH 1/1 tools: libxl: reduce number of integer types in the IDL
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # 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.
tools/libxl/idl.txt +1 -4
@@ -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
tools/libxl/libxl.idl +8 -8
@@ -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), ])
tools/libxl/libxltypes.py +0 -3
@@ -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)
tools/libxl/xl_cmdimpl.c +2 -2
@@ -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);
PATCH 1/1 tools: ocaml: reorder xl bindings type and function definitions to match IDL
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# 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...)
tools/ocaml/libs/xl/xl.ml +145 -145
@@ -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"
tools/ocaml/libs/xl/xl.mli +146 -146
316 lines not on this page · raw message
PATCH 1/1 tools: ocaml: remove create_info and build_info data types from xl bindings
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# 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.
tools/ocaml/libs/xl/xl.ml +0 -55
@@ -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 = {
tools/ocaml/libs/xl/xl.mli +0 -55
67 lines not on this page · raw message
tools/ocaml/libs/xl/xl_stubs.c +0 -57
63 lines not on this page · raw message
PATCH 1/1 tools: ocaml: tweak whitespace in preparation for autogenerating xl bindings
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# 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.
tools/ocaml/libs/xl/xl.ml +17 -21
@@ -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"
tools/ocaml/libs/xl/xl.mli +16 -21
@@ -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
tools/ocaml/libs/xl/xl_stubs.c +11 -11
@@ -283,7 +283,7 @@ static value Val_topologyinfo(libxl_topoint 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(vif (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(vif (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 inif (ret !=0 )failwith_xl ("pci_remove" , &lg);FREE_CTX (); - +CAMLreturn (Val_unit); }
@@ -527,7 +527,7 @@ value stub_xl_device_pci_shutdown(valueif (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 )
PATCH 1/1 tools: ocaml: lay ground work for auto generating xl datatypes
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# 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.
.hgignore +5 -0
@@ -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$
tools/ocaml/libs/xl/Makefile +28 -0
@@ -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
tools/ocaml/libs/xl/genwrap.py new file +42 -0
42 lines not on this page · raw message
tools/ocaml/libs/xl/xl.ml deleted +0 -176
176 lines not on this page · raw message
tools/ocaml/libs/xl/xl.ml.in new file +178 -0
178 lines not on this page · raw message
tools/ocaml/libs/xl/xl.mli deleted +0 -173
173 lines not on this page · raw message
tools/ocaml/libs/xl/xl.mli.in new file +175 -0
175 lines not on this page · raw message
tools/ocaml/libs/xl/xl_stubs.c +3 -1
@@ -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);
PATCH 1/1 tools: ocaml: autogenerate xl datatype definitions and ocaml<->C conversion
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# 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..
tools/ocaml/libs/xl/Makefile +2 -0
@@ -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
tools/ocaml/libs/xl/genwrap.py +282 -1
302 lines not on this page · raw message
tools/ocaml/libs/xl/xl.ml.in +0 -139
145 lines not on this page · raw message
tools/ocaml/libs/xl/xl.mli.in +0 -139
145 lines not on this page · raw message
tools/ocaml/libs/xl/xl_stubs.c +62 -143
342 lines not on this page · raw message