diff options
author | Ian Campbell <ian.campbell@citrix.com> | 2012-12-19 14:33:24 +0000 |
---|---|---|
committer | Ian Campbell <ian.campbell@citrix.com> | 2012-12-19 14:33:24 +0000 |
commit | f9e681d3d1b8fa4900acf5af588599d0892128d0 (patch) | |
tree | 455664168c27c8b079f7776ff6415be9fc802262 | |
parent | 3eab3e1de526c3fcf9ba1317de68d05812e1c623 (diff) | |
download | xen-f9e681d3d1b8fa4900acf5af588599d0892128d0.tar.gz xen-f9e681d3d1b8fa4900acf5af588599d0892128d0.tar.bz2 xen-f9e681d3d1b8fa4900acf5af588599d0892128d0.zip |
libxl: move definition of libxl_domain_config into the IDL
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
-rw-r--r-- | tools/libxl/libxl.h | 20 | ||||
-rw-r--r-- | tools/libxl/libxl_create.c | 37 | ||||
-rw-r--r-- | tools/libxl/libxl_json.c | 152 | ||||
-rw-r--r-- | tools/libxl/libxl_types.idl | 17 | ||||
-rw-r--r-- | tools/ocaml/libs/xl/genwrap.py | 1 |
5 files changed, 18 insertions, 209 deletions
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index e2ba5495d4..72e5efb6d1 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -474,26 +474,6 @@ typedef struct { #define LIBXL_VERSION 0 -typedef struct { - libxl_domain_create_info c_info; - libxl_domain_build_info b_info; - - int num_disks, num_nics, num_pcidevs, num_vfbs, num_vkbs, num_vtpms; - - libxl_device_disk *disks; - libxl_device_nic *nics; - libxl_device_pci *pcidevs; - libxl_device_vfb *vfbs; - libxl_device_vkb *vkbs; - libxl_device_vtpm *vtpms; - - libxl_action_on_shutdown on_poweroff; - libxl_action_on_shutdown on_reboot; - libxl_action_on_shutdown on_watchdog; - libxl_action_on_shutdown on_crash; -} libxl_domain_config; -char *libxl_domain_config_to_json(libxl_ctx *ctx, libxl_domain_config *p); - /* context functions */ int libxl_ctx_alloc(libxl_ctx **pctx, int version, unsigned flags /* none currently defined */, diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index b183255568..c6daec939f 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -24,43 +24,6 @@ #include <xenguest.h> #include <xen/hvm/hvm_info_table.h> -void libxl_domain_config_init(libxl_domain_config *d_config) -{ - memset(d_config, 0, sizeof(*d_config)); - libxl_domain_create_info_init(&d_config->c_info); - libxl_domain_build_info_init(&d_config->b_info); -} - -void libxl_domain_config_dispose(libxl_domain_config *d_config) -{ - int i; - - for (i=0; i<d_config->num_disks; i++) - libxl_device_disk_dispose(&d_config->disks[i]); - free(d_config->disks); - - for (i=0; i<d_config->num_nics; i++) - libxl_device_nic_dispose(&d_config->nics[i]); - free(d_config->nics); - - for (i=0; i<d_config->num_pcidevs; i++) - libxl_device_pci_dispose(&d_config->pcidevs[i]); - free(d_config->pcidevs); - - for (i=0; i<d_config->num_vfbs; i++) - libxl_device_vfb_dispose(&d_config->vfbs[i]); - free(d_config->vfbs); - - for (i=0; i<d_config->num_vkbs; i++) - libxl_device_vkb_dispose(&d_config->vkbs[i]); - free(d_config->vkbs); - - libxl_device_vtpm_list_free(d_config->vtpms, d_config->num_vtpms); - - libxl_domain_create_info_dispose(&d_config->c_info); - libxl_domain_build_info_dispose(&d_config->b_info); -} - int libxl__domain_create_info_setdefault(libxl__gc *gc, libxl_domain_create_info *c_info) { diff --git a/tools/libxl/libxl_json.c b/tools/libxl/libxl_json.c index 72bc4d5896..c6ffb528a7 100644 --- a/tools/libxl/libxl_json.c +++ b/tools/libxl/libxl_json.c @@ -786,158 +786,6 @@ out: return ret; } -yajl_gen_status libxl_domain_config_gen_json(yajl_gen hand, - libxl_domain_config *p) -{ - yajl_gen_status s; - int i; - - s = yajl_gen_map_open(hand); - if (s != yajl_gen_status_ok) - goto out; - - s = yajl_gen_string(hand, (const unsigned char *)"c_info", - sizeof("c_info")-1); - if (s != yajl_gen_status_ok) - goto out; - s = libxl_domain_create_info_gen_json(hand, &p->c_info); - if (s != yajl_gen_status_ok) - goto out; - - s = yajl_gen_string(hand, (const unsigned char *)"b_info", - sizeof("b_info")-1); - if (s != yajl_gen_status_ok) - goto out; - s = libxl_domain_build_info_gen_json(hand, &p->b_info); - if (s != yajl_gen_status_ok) - goto out; - - s = yajl_gen_string(hand, (const unsigned char *)"disks", - sizeof("disks")-1); - if (s != yajl_gen_status_ok) - goto out; - s = yajl_gen_array_open(hand); - if (s != yajl_gen_status_ok) - goto out; - for (i = 0; i < p->num_disks; i++) { - s = libxl_device_disk_gen_json(hand, &p->disks[i]); - if (s != yajl_gen_status_ok) - goto out; - } - s = yajl_gen_array_close(hand); - if (s != yajl_gen_status_ok) - goto out; - - s = yajl_gen_string(hand, (const unsigned char *)"nics", - sizeof("nics")-1); - if (s != yajl_gen_status_ok) - goto out; - s = yajl_gen_array_open(hand); - if (s != yajl_gen_status_ok) - goto out; - for (i = 0; i < p->num_nics; i++) { - s = libxl_device_nic_gen_json(hand, &p->nics[i]); - if (s != yajl_gen_status_ok) - goto out; - } - s = yajl_gen_array_close(hand); - if (s != yajl_gen_status_ok) - goto out; - - s = yajl_gen_string(hand, (const unsigned char *)"pcidevs", - sizeof("pcidevs")-1); - if (s != yajl_gen_status_ok) - goto out; - s = yajl_gen_array_open(hand); - if (s != yajl_gen_status_ok) - goto out; - for (i = 0; i < p->num_pcidevs; i++) { - s = libxl_device_pci_gen_json(hand, &p->pcidevs[i]); - if (s != yajl_gen_status_ok) - goto out; - } - s = yajl_gen_array_close(hand); - if (s != yajl_gen_status_ok) - goto out; - - s = yajl_gen_string(hand, (const unsigned char *)"vfbs", - sizeof("vfbs")-1); - if (s != yajl_gen_status_ok) - goto out; - s = yajl_gen_array_open(hand); - if (s != yajl_gen_status_ok) - goto out; - for (i = 0; i < p->num_vfbs; i++) { - s = libxl_device_vfb_gen_json(hand, &p->vfbs[i]); - if (s != yajl_gen_status_ok) - goto out; - } - s = yajl_gen_array_close(hand); - if (s != yajl_gen_status_ok) - goto out; - - s = yajl_gen_string(hand, (const unsigned char *)"vkbs", - sizeof("vkbs")-1); - if (s != yajl_gen_status_ok) - goto out; - s = yajl_gen_array_open(hand); - if (s != yajl_gen_status_ok) - goto out; - for (i = 0; i < p->num_vkbs; i++) { - s = libxl_device_vkb_gen_json(hand, &p->vkbs[i]); - if (s != yajl_gen_status_ok) - goto out; - } - s = yajl_gen_array_close(hand); - if (s != yajl_gen_status_ok) - goto out; - - s = yajl_gen_string(hand, (const unsigned char *)"on_poweroff", - sizeof("on_poweroff")-1); - if (s != yajl_gen_status_ok) - goto out; - s = libxl_action_on_shutdown_gen_json(hand, &p->on_poweroff); - if (s != yajl_gen_status_ok) - goto out; - - s = yajl_gen_string(hand, (const unsigned char *)"on_reboot", - sizeof("on_reboot")-1); - if (s != yajl_gen_status_ok) - goto out; - s = libxl_action_on_shutdown_gen_json(hand, &p->on_reboot); - if (s != yajl_gen_status_ok) - goto out; - - s = yajl_gen_string(hand, (const unsigned char *)"on_watchdog", - sizeof("on_watchdog")-1); - if (s != yajl_gen_status_ok) - goto out; - s = libxl_action_on_shutdown_gen_json(hand, &p->on_watchdog); - if (s != yajl_gen_status_ok) - goto out; - - s = yajl_gen_string(hand, (const unsigned char *)"on_crash", - sizeof("on_crash")-1); - if (s != yajl_gen_status_ok) - goto out; - s = libxl_action_on_shutdown_gen_json(hand, &p->on_crash); - if (s != yajl_gen_status_ok) - goto out; - - s = yajl_gen_map_close(hand); - if (s != yajl_gen_status_ok) - goto out; - out: - return s; -} - -char *libxl_domain_config_to_json(libxl_ctx *ctx, libxl_domain_config *p) -{ - return libxl__object_to_json(ctx, "libxl_domain_config", - (libxl__gen_json_callback)&libxl_domain_config_gen_json, - (void *)p); -} - /* * Local variables: * mode: C diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index 93524f0645..acc4bc9d9c 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -402,6 +402,23 @@ libxl_device_vtpm = Struct("device_vtpm", [ ("uuid", libxl_uuid), ]) +libxl_domain_config = Struct("domain_config", [ + ("c_info", libxl_domain_create_info), + ("b_info", libxl_domain_build_info), + + ("disks", Array(libxl_device_disk, "num_disks")), + ("nics", Array(libxl_device_nic, "num_nics")), + ("pcidevs", Array(libxl_device_pci, "num_pcidevs")), + ("vfbs", Array(libxl_device_vfb, "num_vfbs")), + ("vkbs", Array(libxl_device_vkb, "num_vkbs")), + ("vtpms", Array(libxl_device_vtpm, "num_vtpms")), + + ("on_poweroff", libxl_action_on_shutdown), + ("on_reboot", libxl_action_on_shutdown), + ("on_watchdog", libxl_action_on_shutdown), + ("on_crash", libxl_action_on_shutdown), + ]) + libxl_diskinfo = Struct("diskinfo", [ ("backend", string), ("backend_id", uint32), diff --git a/tools/ocaml/libs/xl/genwrap.py b/tools/ocaml/libs/xl/genwrap.py index 97d088ddf8..ea978bf697 100644 --- a/tools/ocaml/libs/xl/genwrap.py +++ b/tools/ocaml/libs/xl/genwrap.py @@ -283,6 +283,7 @@ if __name__ == '__main__': "cpupoolinfo", "domain_create_info", "domain_build_info", + "domain_config", "vcpuinfo", "event", ] |