[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 07 of 32] tools: libxl: namespace enum values within their type
# HG changeset patch # User Ian Campbell <ian.campbell@xxxxxxxxxx> # Date 1303133925 -3600 # Node ID 383276163a6481c6c67713d8c58264f72721972f # Parent eb36ca823d375815e676edaf0b0f52c82adb37e5 tools: libxl: namespace enum values within their type. In other words the values for an enum type libxl_foo always take the form LIBXL_FOO_VALUE. Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx> diff -r eb36ca823d37 -r 383276163a64 tools/libxl/libxl.c --- a/tools/libxl/libxl.c Mon Apr 18 14:38:14 2011 +0100 +++ b/tools/libxl/libxl.c Mon Apr 18 14:38:45 2011 +0100 @@ -592,7 +592,7 @@ int libxl_get_wait_fd(libxl_ctx *ctx, in int libxl_wait_for_domain_death(libxl_ctx *ctx, uint32_t domid, libxl_waiter *waiter) { waiter->path = strdup("@releaseDomain"); - if (asprintf(&(waiter->token), "%d", LIBXL_EVENT_DOMAIN_DEATH) < 0) + if (asprintf(&(waiter->token), "%d", LIBXL_EVENT_TYPE_DOMAIN_DEATH) < 0) return -1; if (!xs_watch(ctx->xsh, waiter->path, waiter->token)) return -1; @@ -614,7 +614,7 @@ int libxl_wait_for_disk_ejects(libxl_ctx libxl__device_disk_dev_number(disks[i].vdev, NULL, NULL)) < 0) goto out; - if (asprintf(&(waiter[i].token), "%d", LIBXL_EVENT_DISK_EJECT) < 0) + if (asprintf(&(waiter[i].token), "%d", LIBXL_EVENT_TYPE_DISK_EJECT) < 0) goto out; xs_watch(ctx->xsh, waiter[i].path, waiter[i].token); } @@ -782,7 +782,7 @@ out: return 0; } -int libxl_console_exec(libxl_ctx *ctx, uint32_t domid, int cons_num, libxl_console_constype type) +int libxl_console_exec(libxl_ctx *ctx, uint32_t domid, int cons_num, libxl_console_type type) { libxl__gc gc = LIBXL_INIT_GC(ctx); char *p = libxl__sprintf(&gc, "%s/xenconsole", libxl_private_bindir_path()); @@ -791,10 +791,10 @@ int libxl_console_exec(libxl_ctx *ctx, u char *cons_type_s; switch (type) { - case LIBXL_CONSTYPE_PV: + case LIBXL_CONSOLE_TYPE_PV: cons_type_s = "pv"; break; - case LIBXL_CONSTYPE_SERIAL: + case LIBXL_CONSOLE_TYPE_SERIAL: cons_type_s = "serial"; break; default: @@ -815,12 +815,12 @@ int libxl_primary_console_exec(libxl_ctx int rc; if (stubdomid) rc = libxl_console_exec(ctx, stubdomid, - STUBDOM_CONSOLE_SERIAL, LIBXL_CONSTYPE_PV); + STUBDOM_CONSOLE_SERIAL, LIBXL_CONSOLE_TYPE_PV); else { if (libxl__domain_is_hvm(&gc, domid_vm)) - rc = libxl_console_exec(ctx, domid_vm, 0, LIBXL_CONSTYPE_SERIAL); + rc = libxl_console_exec(ctx, domid_vm, 0, LIBXL_CONSOLE_TYPE_SERIAL); else - rc = libxl_console_exec(ctx, domid_vm, 0, LIBXL_CONSTYPE_PV); + rc = libxl_console_exec(ctx, domid_vm, 0, LIBXL_CONSOLE_TYPE_PV); } libxl__free_all(&gc); return rc; @@ -1223,7 +1223,7 @@ int libxl_device_nic_init(libxl_device_n if ( asprintf(&nic_info->script, "%s/vif-bridge", libxl_xen_script_dir_path()) < 0 ) return ERROR_FAIL; - nic_info->nictype = LIBXL_NICTYPE_IOEMU; + nic_info->nictype = LIBXL_NIC_TYPE_IOEMU; return 0; } @@ -1441,7 +1441,7 @@ int libxl_device_console_add(libxl_ctx * flexarray_append(front, "limit"); flexarray_append(front, libxl__sprintf(&gc, "%d", LIBXL_XENCONSOLE_LIMIT)); flexarray_append(front, "type"); - if (console->consback == LIBXL_CONSBACK_XENCONSOLED) + if (console->consback == LIBXL_CONSOLE_BACKEND_XENCONSOLED) flexarray_append(front, "xenconsoled"); else flexarray_append(front, "ioemu"); diff -r eb36ca823d37 -r 383276163a64 tools/libxl/libxl.h --- a/tools/libxl/libxl.h Mon Apr 18 14:38:14 2011 +0100 +++ b/tools/libxl/libxl.h Mon Apr 18 14:38:45 2011 +0100 @@ -174,14 +174,14 @@ typedef enum libxl_device_model_version } libxl_device_model_version; typedef enum { - LIBXL_CONSTYPE_SERIAL = 1, - LIBXL_CONSTYPE_PV, -} libxl_console_constype; + LIBXL_CONSOLE_TYPE_SERIAL = 1, + LIBXL_CONSOLE_TYPE_PV, +} libxl_console_type; typedef enum { - LIBXL_CONSBACK_XENCONSOLED, - LIBXL_CONSBACK_IOEMU, -} libxl_console_consback; + LIBXL_CONSOLE_BACKEND_XENCONSOLED, + LIBXL_CONSOLE_BACKEND_IOEMU, +} libxl_console_backend; typedef enum { LIBXL_DISK_FORMAT_UNKNOWN = 0, @@ -200,8 +200,8 @@ typedef enum { } libxl_disk_backend; typedef enum { - LIBXL_NICTYPE_IOEMU = 1, - LIBXL_NICTYPE_VIF, + LIBXL_NIC_TYPE_IOEMU = 1, + LIBXL_NIC_TYPE_VIF, } libxl_nic_type; typedef struct { @@ -253,15 +253,15 @@ enum { #define LIBXL_VERSION 0 typedef enum libxl_action_on_shutdown { - LIBXL_ACTION_DESTROY, + LIBXL_ACTION_ON_SHUTDOWN_DESTROY, - LIBXL_ACTION_RESTART, - LIBXL_ACTION_RESTART_RENAME, + LIBXL_ACTION_ON_SHUTDOWN_RESTART, + LIBXL_ACTION_ON_SHUTDOWN_RESTART_RENAME, - LIBXL_ACTION_PRESERVE, + LIBXL_ACTION_ON_SHUTDOWN_PRESERVE, - LIBXL_ACTION_COREDUMP_DESTROY, - LIBXL_ACTION_COREDUMP_RESTART, + LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_DESTROY, + LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_RESTART, } libxl_action_on_shutdown; typedef struct { @@ -328,8 +328,8 @@ int libxl_run_bootloader(libxl_ctx *ctx, /* events handling */ typedef enum { - LIBXL_EVENT_DOMAIN_DEATH, - LIBXL_EVENT_DISK_EJECT, + LIBXL_EVENT_TYPE_DOMAIN_DEATH, + LIBXL_EVENT_TYPE_DISK_EJECT, } libxl_event_type; typedef struct { @@ -402,7 +402,7 @@ int libxl_wait_for_free_memory(libxl_ctx int libxl_wait_for_memory_target(libxl_ctx *ctx, uint32_t domid, int wait_secs); int libxl_vncviewer_exec(libxl_ctx *ctx, uint32_t domid, int autopass); -int libxl_console_exec(libxl_ctx *ctx, uint32_t domid, int cons_num, libxl_console_constype type); +int libxl_console_exec(libxl_ctx *ctx, uint32_t domid, int cons_num, libxl_console_type type); /* libxl_primary_console_exec finds the domid and console number * corresponding to the primary console of the given vm, then calls * libxl_console_exec with the right arguments (domid might be different diff -r eb36ca823d37 -r 383276163a64 tools/libxl/libxl.idl --- a/tools/libxl/libxl.idl Mon Apr 18 14:38:14 2011 +0100 +++ b/tools/libxl/libxl.idl Mon Apr 18 14:38:45 2011 +0100 @@ -10,8 +10,8 @@ libxl_cpumap = Builtin("cpumap", destruc libxl_cpuarray = Builtin("cpuarray", destructor_fn="libxl_cpuarray_destroy", passby=PASS_BY_REFERENCE) libxl_domain_type = Number("domain_type", namespace="libxl_") libxl_device_model_version = Number("device_model_version", namespace="libxl_") -libxl_console_consback = Number("console_consback", namespace="libxl_") -libxl_console_constype = Number("console_constype", namespace="libxl_") +libxl_console_backend = Number("console_backend", namespace="libxl_") +libxl_console_type = Number("console_type", namespace="libxl_") libxl_disk_format = Number("disk_format", namespace="libxl_") libxl_disk_backend = Number("disk_backend", namespace="libxl_") libxl_nic_type = Number("nic_type", namespace="libxl_") @@ -198,7 +198,7 @@ libxl_device_vkb = Struct("device_vkb", libxl_device_console = Struct("device_console", [ ("backend_domid", uint32), ("devid", integer), - ("consback", libxl_console_consback), + ("consback", libxl_console_backend), ("build_state", Reference(libxl_domain_build_state), True), ("output", string), ]) diff -r eb36ca823d37 -r 383276163a64 tools/libxl/libxl_create.c --- a/tools/libxl/libxl_create.c Mon Apr 18 14:38:14 2011 +0100 +++ b/tools/libxl/libxl_create.c Mon Apr 18 14:38:45 2011 +0100 @@ -137,7 +137,7 @@ static int init_console_info(libxl_devic { memset(console, 0x00, sizeof(libxl_device_console)); console->devid = dev_num; - console->consback = LIBXL_CONSBACK_XENCONSOLED; + console->consback = LIBXL_CONSOLE_BACKEND_XENCONSOLED; console->output = strdup("pty"); if ( NULL == console->output ) return ERROR_NOMEM; @@ -498,7 +498,7 @@ static int do_domain_create(libxl__gc *g d_config->num_disks, &d_config->disks[0]); if (need_qemu) - console.consback = LIBXL_CONSBACK_IOEMU; + console.consback = LIBXL_CONSOLE_BACKEND_IOEMU; libxl_device_console_add(ctx, domid, &console); libxl_device_console_destroy(&console); diff -r eb36ca823d37 -r 383276163a64 tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Mon Apr 18 14:38:14 2011 +0100 +++ b/tools/libxl/libxl_dm.c Mon Apr 18 14:38:45 2011 +0100 @@ -172,7 +172,7 @@ static char ** libxl__build_device_model flexarray_vappend(dm_args, "-vcpu_avail", libxl__sprintf(gc, "0x%x", info->vcpu_avail), NULL); } for (i = 0; i < num_vifs; i++) { - if (vifs[i].nictype == LIBXL_NICTYPE_IOEMU) { + if (vifs[i].nictype == LIBXL_NIC_TYPE_IOEMU) { char *smac = libxl__sprintf(gc, "%02x:%02x:%02x:%02x:%02x:%02x", vifs[i].mac[0], vifs[i].mac[1], vifs[i].mac[2], vifs[i].mac[3], vifs[i].mac[4], vifs[i].mac[5]); @@ -326,7 +326,7 @@ static char ** libxl__build_device_model flexarray_append(dm_args, libxl__sprintf(gc, "%d", info->vcpus)); } for (i = 0; i < num_vifs; i++) { - if (vifs[i].nictype == LIBXL_NICTYPE_IOEMU) { + if (vifs[i].nictype == LIBXL_NIC_TYPE_IOEMU) { char *smac = libxl__sprintf(gc, "%02x:%02x:%02x:%02x:%02x:%02x", vifs[i].mac[0], vifs[i].mac[1], vifs[i].mac[2], vifs[i].mac[3], vifs[i].mac[4], vifs[i].mac[5]); @@ -672,7 +672,7 @@ retry_transaction: for (i = 0; i < num_console; i++) { console[i].devid = i; - console[i].consback = LIBXL_CONSBACK_IOEMU; + console[i].consback = LIBXL_CONSOLE_BACKEND_IOEMU; /* STUBDOM_CONSOLE_LOGGING (console 0) is for minios logging * STUBDOM_CONSOLE_SAVE (console 1) is for writing the save file * STUBDOM_CONSOLE_RESTORE (console 2) is for reading the save file @@ -946,7 +946,7 @@ int libxl__need_xenpv_qemu(libxl__gc *gc } for (i = 0; i < nr_consoles; i++) { - if (consoles[i].consback == LIBXL_CONSBACK_IOEMU) { + if (consoles[i].consback == LIBXL_CONSOLE_BACKEND_IOEMU) { ret = 1; goto out; } diff -r eb36ca823d37 -r 383276163a64 tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Mon Apr 18 14:38:14 2011 +0100 +++ b/tools/libxl/xl_cmdimpl.c Mon Apr 18 14:38:45 2011 +0100 @@ -101,15 +101,15 @@ struct save_file_header { static const char *action_on_shutdown_names[] = { - [LIBXL_ACTION_DESTROY] = "destroy", - - [LIBXL_ACTION_RESTART] = "restart", - [LIBXL_ACTION_RESTART_RENAME] = "rename-restart", - - [LIBXL_ACTION_PRESERVE] = "preserve", - - [LIBXL_ACTION_COREDUMP_DESTROY] = "coredump-destroy", - [LIBXL_ACTION_COREDUMP_RESTART] = "coredump-restart", + [LIBXL_ACTION_ON_SHUTDOWN_DESTROY] = "destroy", + + [LIBXL_ACTION_ON_SHUTDOWN_RESTART] = "restart", + [LIBXL_ACTION_ON_SHUTDOWN_RESTART_RENAME] = "rename-restart", + + [LIBXL_ACTION_ON_SHUTDOWN_PRESERVE] = "preserve", + + [LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_DESTROY] = "coredump-destroy", + [LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_RESTART] = "coredump-restart", }; /* Optional data, in order: @@ -874,9 +874,9 @@ static void parse_config_data(const char nic->bridge = strdup(p2 + 1); } else if (!strcmp(p, "type")) { if (!strcmp(p2 + 1, "ioemu")) - nic->nictype = LIBXL_NICTYPE_IOEMU; + nic->nictype = LIBXL_NIC_TYPE_IOEMU; else - nic->nictype = LIBXL_NICTYPE_VIF; + nic->nictype = LIBXL_NIC_TYPE_VIF; } else if (!strcmp(p, "ip")) { free(nic->ip); nic->ip = strdup(p2 + 1); @@ -1178,12 +1178,12 @@ static int handle_domain_death(libxl_ctx break; default: LOG("Unknown shutdown reason code %d. Destroying domain.", info->shutdown_reason); - action = LIBXL_ACTION_DESTROY; + action = LIBXL_ACTION_ON_SHUTDOWN_DESTROY; } LOG("Action for shutdown reason code %d is %s", info->shutdown_reason, action_on_shutdown_names[action]); - if (action == LIBXL_ACTION_COREDUMP_DESTROY || action == LIBXL_ACTION_COREDUMP_RESTART) { + if (action == LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_DESTROY || action == LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_RESTART) { char *corefile; int rc; @@ -1196,30 +1196,30 @@ static int handle_domain_death(libxl_ctx } /* No point crying over spilled milk, continue on failure. */ - if (action == LIBXL_ACTION_COREDUMP_DESTROY) - action = LIBXL_ACTION_DESTROY; + if (action == LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_DESTROY) + action = LIBXL_ACTION_ON_SHUTDOWN_DESTROY; else - action = LIBXL_ACTION_RESTART; + action = LIBXL_ACTION_ON_SHUTDOWN_RESTART; } switch (action) { - case LIBXL_ACTION_PRESERVE: + case LIBXL_ACTION_ON_SHUTDOWN_PRESERVE: break; - case LIBXL_ACTION_RESTART_RENAME: + case LIBXL_ACTION_ON_SHUTDOWN_RESTART_RENAME: restart = 2; break; - case LIBXL_ACTION_RESTART: + case LIBXL_ACTION_ON_SHUTDOWN_RESTART: restart = 1; /* fall-through */ - case LIBXL_ACTION_DESTROY: + case LIBXL_ACTION_ON_SHUTDOWN_DESTROY: LOG("Domain %d needs to be cleaned up: destroying the domain", domid); libxl_domain_destroy(ctx, domid, 0); break; - case LIBXL_ACTION_COREDUMP_DESTROY: - case LIBXL_ACTION_COREDUMP_RESTART: + case LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_DESTROY: + case LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_RESTART: /* Already handled these above. */ abort(); } @@ -1617,7 +1617,7 @@ start: continue; libxl_get_event(ctx, &event); switch (event.type) { - case LIBXL_EVENT_DOMAIN_DEATH: + case LIBXL_EVENT_TYPE_DOMAIN_DEATH: ret = libxl_event_get_domain_death_info(ctx, domid, &event, &info); if (ret < 0) { @@ -1675,7 +1675,7 @@ start: goto out; } break; - case LIBXL_EVENT_DISK_EJECT: + case LIBXL_EVENT_TYPE_DISK_EJECT: if (libxl_event_get_disk_eject_info(ctx, domid, &event, &disk)) { libxl_cdrom_insert(ctx, domid, &disk); libxl_device_disk_destroy(&disk); @@ -1943,7 +1943,7 @@ int main_cd_insert(int argc, char **argv int main_console(int argc, char **argv) { int opt = 0, num = 0; - libxl_console_constype type = 0; + libxl_console_type type = 0; while ((opt = getopt(argc, argv, "hn:t:")) != -1) { switch (opt) { @@ -1952,9 +1952,9 @@ int main_console(int argc, char **argv) return 0; case 't': if (!strcmp(optarg, "pv")) - type = LIBXL_CONSTYPE_PV; + type = LIBXL_CONSOLE_TYPE_PV; else if (!strcmp(optarg, "serial")) - type = LIBXL_CONSTYPE_SERIAL; + type = LIBXL_CONSOLE_TYPE_SERIAL; else { fprintf(stderr, "console type supported are: pv, serial\n"); return 2; @@ -2249,7 +2249,7 @@ static void shutdown_domain(const char * libxl_get_event(ctx, &event); - if (event.type == LIBXL_EVENT_DOMAIN_DEATH) { + if (event.type == LIBXL_EVENT_TYPE_DOMAIN_DEATH) { if (libxl_event_get_domain_death_info(ctx, domid, &event, &info) < 0) continue; @@ -4252,9 +4252,9 @@ int main_networkattach(int argc, char ** for (argv += optind+1, argc -= optind+1; argc > 0; ++argv, --argc) { if (!strncmp("type=", *argv, 5)) { if (!strncmp("vif", (*argv) + 5, 4)) { - nic.nictype = LIBXL_NICTYPE_VIF; + nic.nictype = LIBXL_NIC_TYPE_VIF; } else if (!strncmp("ioemu", (*argv) + 5, 5)) { - nic.nictype = LIBXL_NICTYPE_IOEMU; + nic.nictype = LIBXL_NIC_TYPE_IOEMU; } else { fprintf(stderr, "Invalid parameter `type'.\n"); return 1; diff -r eb36ca823d37 -r 383276163a64 tools/ocaml/libs/xl/xl_stubs.c --- a/tools/ocaml/libs/xl/xl_stubs.c Mon Apr 18 14:38:14 2011 +0100 +++ b/tools/ocaml/libs/xl/xl_stubs.c Mon Apr 18 14:38:45 2011 +0100 @@ -224,7 +224,7 @@ static int device_nic_val(caml_gc *gc, l c_val->bridge = dup_String_val(gc, Field(v, 5)); c_val->ifname = dup_String_val(gc, Field(v, 6)); c_val->script = dup_String_val(gc, Field(v, 7)); - c_val->nictype = (Int_val(Field(v, 8))) + LIBXL_NICTYPE_IOEMU; + c_val->nictype = (Int_val(Field(v, 8))) + LIBXL_NIC_TYPE_IOEMU; out: CAMLreturn(ret); @@ -236,7 +236,7 @@ static int device_console_val(caml_gc *g c_val->backend_domid = Int_val(Field(v, 0)); c_val->devid = Int_val(Field(v, 1)); - c_val->consback = (Int_val(Field(v, 2))) + LIBXL_CONSBACK_XENCONSOLED; + c_val->consback = (Int_val(Field(v, 2))) + LIBXL_CONSOLE_BACKEND_XENCONSOLED; CAMLreturn(0); } diff -r eb36ca823d37 -r 383276163a64 tools/python/xen/lowlevel/xl/xl.c --- a/tools/python/xen/lowlevel/xl/xl.c Mon Apr 18 14:38:14 2011 +0100 +++ b/tools/python/xen/lowlevel/xl/xl.c Mon Apr 18 14:38:45 2011 +0100 @@ -772,11 +772,11 @@ PyMODINIT_FUNC initxl(void) _INT_CONST_LIBXL(m, DOMAIN_TYPE_FV); _INT_CONST_LIBXL(m, DOMAIN_TYPE_PV); - _INT_CONST_LIBXL(m, CONSTYPE_SERIAL); - _INT_CONST_LIBXL(m, CONSTYPE_PV); + _INT_CONST_LIBXL(m, CONSOLE_TYPE_SERIAL); + _INT_CONST_LIBXL(m, CONSOLE_TYPE_PV); - _INT_CONST_LIBXL(m, CONSBACK_XENCONSOLED); - _INT_CONST_LIBXL(m, CONSBACK_IOEMU); + _INT_CONST_LIBXL(m, CONSOLE_BACKEND_XENCONSOLED); + _INT_CONST_LIBXL(m, CONSOLE_BACKEND_IOEMU); _INT_CONST_LIBXL(m, DISK_FORMAT_UNKNOWN); _INT_CONST_LIBXL(m, DISK_FORMAT_QCOW); @@ -790,11 +790,11 @@ PyMODINIT_FUNC initxl(void) _INT_CONST_LIBXL(m, DISK_BACKEND_TAP); _INT_CONST_LIBXL(m, DISK_BACKEND_QDISK); - _INT_CONST_LIBXL(m, NICTYPE_IOEMU); - _INT_CONST_LIBXL(m, NICTYPE_VIF); + _INT_CONST_LIBXL(m, NIC_TYPE_IOEMU); + _INT_CONST_LIBXL(m, NIC_TYPE_VIF); - _INT_CONST_LIBXL(m, EVENT_DOMAIN_DEATH); - _INT_CONST_LIBXL(m, EVENT_DISK_EJECT); + _INT_CONST_LIBXL(m, EVENT_TYPE_DOMAIN_DEATH); + _INT_CONST_LIBXL(m, EVENT_TYPE_DISK_EJECT); _INT_CONST_LIBXL(m, BUTTON_POWER); _INT_CONST_LIBXL(m, BUTTON_SLEEP); _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |