[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 3 of 4] libxl: namespace enum values within their type
# HG changeset patch # User Ian Campbell <ian.campbell@xxxxxxxxxx> # Date 1300969249 0 # Node ID dd172a4ee31058f1e108c8e5411ab7734bbddc6b # Parent 0af1e680ea5642c63e6467660190975d57f417e7 libxl: namespace enum values within their type. Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx> diff -r 0af1e680ea56 -r dd172a4ee310 tools/libxl/libxl.c --- a/tools/libxl/libxl.c Thu Mar 24 12:20:49 2011 +0000 +++ b/tools/libxl/libxl.c Thu Mar 24 12:20:49 2011 +0000 @@ -592,7 +592,7 @@ int libxl_wait_for_domain_death(libxl_ct 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; @@ -613,7 +613,7 @@ int libxl_wait_for_disk_ejects(libxl_ctx libxl__xs_get_dompath(&gc, domid), libxl__device_disk_dev_number(disks[i].vdev)) < 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; @@ -1202,7 +1202,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; } @@ -1641,7 +1641,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 0af1e680ea56 -r dd172a4ee310 tools/libxl/libxl.h --- a/tools/libxl/libxl.h Thu Mar 24 12:20:49 2011 +0000 +++ b/tools/libxl/libxl.h Thu Mar 24 12:20:49 2011 +0000 @@ -167,14 +167,14 @@ typedef enum { } libxl_qemu_machine_type; 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, @@ -193,8 +193,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 { @@ -246,15 +246,15 @@ enum { #define LIBXL_VERSION 0 typedef enum { - 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 { @@ -322,8 +322,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 { @@ -396,7 +396,7 @@ int libxl_wait_for_memory_target(libxl_c 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 0af1e680ea56 -r dd172a4ee310 tools/libxl/libxl.idl --- a/tools/libxl/libxl.idl Thu Mar 24 12:20:49 2011 +0000 +++ b/tools/libxl/libxl.idl Thu Mar 24 12:20:49 2011 +0000 @@ -9,8 +9,8 @@ libxl_cpumap = Builtin("cpumap", destruc 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_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_") @@ -196,7 +196,7 @@ libxl_device_console = Struct("device_co ("backend_domid", uint32), ("domid", domid), ("devid", integer), - ("consback", libxl_console_consback), + ("consback", libxl_console_backend), ("build_state", Reference(libxl_domain_build_state), True), ("output", string), ]) diff -r 0af1e680ea56 -r dd172a4ee310 tools/libxl/libxl_create.c --- a/tools/libxl/libxl_create.c Thu Mar 24 12:20:49 2011 +0000 +++ b/tools/libxl/libxl_create.c Thu Mar 24 12:20:49 2011 +0000 @@ -138,7 +138,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; @@ -515,7 +515,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 0af1e680ea56 -r dd172a4ee310 tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Thu Mar 24 12:20:49 2011 +0000 +++ b/tools/libxl/libxl_dm.c Thu Mar 24 12:20:49 2011 +0000 @@ -130,7 +130,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]); @@ -271,7 +271,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]); @@ -563,7 +563,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; console[i].domid = domid; /* STUBDOM_CONSOLE_LOGGING (console 0) is for minios logging * STUBDOM_CONSOLE_SAVE (console 1) is for writing the save file @@ -820,7 +820,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 0af1e680ea56 -r dd172a4ee310 tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Thu Mar 24 12:20:49 2011 +0000 +++ b/tools/libxl/xl_cmdimpl.c Thu Mar 24 12:20:49 2011 +0000 @@ -100,15 +100,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: @@ -862,9 +862,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); @@ -1184,12 +1184,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; @@ -1202,30 +1202,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: - break; - - case LIBXL_ACTION_RESTART_RENAME: + case LIBXL_ACTION_ON_SHUTDOWN_PRESERVE: + break; + + 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(); } @@ -1623,7 +1623,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) { @@ -1681,7 +1681,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); @@ -1950,7 +1950,7 @@ int main_console(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) { @@ -1959,9 +1959,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; @@ -2256,7 +2256,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; @@ -4259,9 +4259,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 0af1e680ea56 -r dd172a4ee310 tools/ocaml/libs/xl/xl_stubs.c --- a/tools/ocaml/libs/xl/xl_stubs.c Thu Mar 24 12:20:49 2011 +0000 +++ b/tools/ocaml/libs/xl/xl_stubs.c Thu Mar 24 12:20:49 2011 +0000 @@ -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 0af1e680ea56 -r dd172a4ee310 tools/python/xen/lowlevel/xl/xl.c --- a/tools/python/xen/lowlevel/xl/xl.c Thu Mar 24 12:20:49 2011 +0000 +++ b/tools/python/xen/lowlevel/xl/xl.c Thu Mar 24 12:20:49 2011 +0000 @@ -772,11 +772,11 @@ PyMODINIT_FUNC initxl(void) _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); + _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 |