[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 28 of 30] libxl: do not expose libxenctrl/libxenstore headers via libxl.h
# HG changeset patch # User Ian Campbell <ian.campbell@xxxxxxxxxx> # Date 1300718506 0 # Node ID dd0e1d4aae8f95979df38fe6ed9fadcfdda03b9d # Parent 8789166a014f43bf66ec4b2af51a4771fb56a5d5 libxl: do not expose libxenctrl/libxenstore headers via libxl.h This completely removes libxenstore from libxl users' view. xl still needs libxenctrl directly due to the direct use of the xentoollog functionality but it is not exposed to the indirect linkage anymore. Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx> diff -r 8789166a014f -r dd0e1d4aae8f tools/Rules.mk --- a/tools/Rules.mk Mon Mar 21 14:41:46 2011 +0000 +++ b/tools/Rules.mk Mon Mar 21 14:41:46 2011 +0000 @@ -49,7 +49,7 @@ SHLIB_libblktapctl = SHLIB_libblktapctl = endif -CFLAGS_libxenlight = -I$(XEN_XENLIGHT) $(CFLAGS_libxenctrl) $(CFLAGS_libxenstore) $(CFLAGS_xeninclude) +CFLAGS_libxenlight = -I$(XEN_XENLIGHT) $(CFLAGS_libxenctrl) $(CFLAGS_xeninclude) LDLIBS_libxenlight = -L$(XEN_XENLIGHT) $(SHLIB_libxenctrl) $(SHLIB_libxenstore) $(SHLIB_libblktapctl) -lxenlight SHLIB_libxenlight = -Wl,-rpath-link=$(XEN_XENLIGHT) diff -r 8789166a014f -r dd0e1d4aae8f tools/libxl/Makefile --- a/tools/libxl/Makefile Mon Mar 21 14:41:46 2011 +0000 +++ b/tools/libxl/Makefile Mon Mar 21 14:41:46 2011 +0000 @@ -13,7 +13,6 @@ XLUMINOR = 0 CFLAGS += -Werror -Wno-format-zero-length -Wmissing-declarations CFLAGS += -I. -fPIC -CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest) $(CFLAGS_libxenstore) $(CFLAGS_libblktapctl) ifeq ($(CONFIG_Linux),y) LIBUUID_LIBS += -luuid @@ -38,13 +37,18 @@ LIBXL_OBJS = flexarray.o libxl.o libxl_c libxl_internal.o libxl_utils.o $(LIBXL_OBJS-y) LIBXL_OBJS += _libxl_types.o +$(LIBXL_OBJS): CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest) $(CFLAGS_libxenstore) $(CFLAGS_libblktapctl) + AUTOINCS= libxlu_cfg_y.h libxlu_cfg_l.h AUTOSRCS= libxlu_cfg_y.c libxlu_cfg_l.c LIBXLU_OBJS = libxlu_cfg_y.o libxlu_cfg_l.o libxlu_cfg.o +$(LIBXLU_OBJS): CFLAGS += $(CFLAGS_libxenctrl) # For xentoollog.h CLIENTS = xl XL_OBJS = xl.o xl_cmdimpl.o xl_cmdtable.o +$(XL_OBJS): CFLAGS += $(CFLAGS_libxenctrl) # For xentoollog.h +$(XL_OBJS): CFLAGS += $(CFLAGS_libxenlight) .PHONY: all all: $(CLIENTS) libxenlight.so libxenlight.a libxlutil.so libxlutil.a \ diff -r 8789166a014f -r dd0e1d4aae8f tools/libxl/libxl.c --- a/tools/libxl/libxl.c Mon Mar 21 14:41:46 2011 +0000 +++ b/tools/libxl/libxl.c Mon Mar 21 14:41:46 2011 +0000 @@ -41,15 +41,22 @@ #define STRINGIFY(x) #x #define TOSTRING(x) STRINGIFY(x) -int libxl_ctx_init(libxl_ctx *ctx, int version, xentoollog_logger *lg) +int libxl_ctx_alloc(libxl_ctx **pctx, int version, xentoollog_logger * lg) { + libxl_ctx *ctx; struct stat stat_buf; if (version != LIBXL_VERSION) return ERROR_VERSION; + + ctx = malloc(sizeof(*ctx)); + if (!ctx) { + LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Failed to allocate context\n"); + return ERROR_NOMEM; + } + memset(ctx, 0, sizeof(libxl_ctx)); ctx->lg = lg; - memset(&ctx->version_info, 0, sizeof(libxl_version_info)); if ( stat(XENSTORE_PID_FILE, &stat_buf) != 0 ) { LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Is xenstore daemon running?\n" @@ -73,6 +80,8 @@ int libxl_ctx_init(libxl_ctx *ctx, int v xc_interface_close(ctx->xch); return ERROR_FAIL; } + + *pctx = ctx; return 0; } diff -r 8789166a014f -r dd0e1d4aae8f tools/libxl/libxl.h --- a/tools/libxl/libxl.h Mon Mar 21 14:41:46 2011 +0000 +++ b/tools/libxl/libxl.h Mon Mar 21 14:41:46 2011 +0000 @@ -124,12 +124,17 @@ #ifndef LIBXL_H #define LIBXL_H +#include <stdbool.h> #include <stdint.h> #include <stdarg.h> +#include <errno.h> #include <netinet/in.h> -#include <xenctrl.h> -#include <xs.h> #include <sys/wait.h> /* for pid_t */ + +#include <xentoollog.h> + +#include <xen/sched.h> +#include <xen/sysctl.h> #include "libxl_uuid.h" @@ -216,17 +221,7 @@ void libxl_cpuid_destroy(libxl_cpuid_pol #include "_libxl_types.h" -typedef struct { - xentoollog_logger *lg; - xc_interface *xch; - struct xs_handle *xsh; - - /* for callers who reap children willy-nilly; caller must only - * set this after libxl_init and before any other call - or - * may leave them untouched */ - int (*waitpid_instead)(pid_t pid, int *status, int flags); - libxl_version_info version_info; -} libxl_ctx; +typedef struct libxl__ctx libxl_ctx; const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx); @@ -283,7 +278,7 @@ typedef struct { } libxl_domain_config; /* context functions */ -int libxl_ctx_init(libxl_ctx *ctx, int version, xentoollog_logger*); +int libxl_ctx_alloc(libxl_ctx **pctx, int version, xentoollog_logger *lg); int libxl_ctx_free(libxl_ctx *ctx); int libxl_ctx_postfork(libxl_ctx *ctx); diff -r 8789166a014f -r dd0e1d4aae8f tools/libxl/libxl_internal.h --- a/tools/libxl/libxl_internal.h Mon Mar 21 14:41:46 2011 +0000 +++ b/tools/libxl/libxl_internal.h Mon Mar 21 14:41:46 2011 +0000 @@ -82,6 +82,17 @@ _hidden void libxl__log(libxl_ctx *ctx, /* these functions preserve errno (saving and restoring) */ +struct libxl__ctx { + xentoollog_logger *lg; + xc_interface *xch; + struct xs_handle *xsh; + + /* for callers who reap children willy-nilly; caller must only + * set this after libxl_init and before any other call - or + * may leave them untouched */ + int (*waitpid_instead)(pid_t pid, int *status, int flags); + libxl_version_info version_info; +}; typedef enum { DEVICE_VIF = 1, diff -r 8789166a014f -r dd0e1d4aae8f tools/libxl/xl.c --- a/tools/libxl/xl.c Mon Mar 21 14:41:46 2011 +0000 +++ b/tools/libxl/xl.c Mon Mar 21 14:41:46 2011 +0000 @@ -26,6 +26,7 @@ #include <fcntl.h> #include <ctype.h> #include <inttypes.h> +#include <xenctrl.h> #include "libxl.h" #include "libxl_utils.h" @@ -111,7 +112,7 @@ int main(int argc, char **argv) logger = xtl_createlogger_stdiostream(stderr, minmsglevel, 0); if (!logger) exit(1); - if (libxl_ctx_init(&ctx, LIBXL_VERSION, (xentoollog_logger*)logger)) { + if (libxl_ctx_alloc(&ctx, LIBXL_VERSION, (xentoollog_logger*)logger)) { fprintf(stderr, "cannot init xl context\n"); exit(1); } @@ -123,7 +124,7 @@ int main(int argc, char **argv) exit(1); } - ret = libxl_read_file_contents(&ctx, config_file, + ret = libxl_read_file_contents(ctx, config_file, &config_data, &config_len); if (ret) fprintf(stderr, "Failed to read config file: %s: %s\n", @@ -147,7 +148,7 @@ int main(int argc, char **argv) ret = 1; } - libxl_ctx_free(&ctx); + libxl_ctx_free(ctx); xtl_logger_destroy((xentoollog_logger*)logger); return ret; diff -r 8789166a014f -r dd0e1d4aae8f tools/libxl/xl.h --- a/tools/libxl/xl.h Mon Mar 21 14:41:46 2011 +0000 +++ b/tools/libxl/xl.h Mon Mar 21 14:41:46 2011 +0000 @@ -95,7 +95,7 @@ extern int cmdtable_len; /* Look up a command in the table, allowing unambiguous truncation */ struct cmd_spec *cmdtable_lookup(const char *s); -extern libxl_ctx ctx; +extern libxl_ctx *ctx; extern xentoollog_logger_stdiostream *logger; /* global options */ diff -r 8789166a014f -r dd0e1d4aae8f tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Mon Mar 21 14:41:46 2011 +0000 +++ b/tools/libxl/xl_cmdimpl.c Mon Mar 21 14:41:46 2011 +0000 @@ -31,7 +31,7 @@ #include <sys/socket.h> #include <sys/select.h> #include <sys/utsname.h> /* for utsname in xl info */ -#include <xenctrl.h> +#include <xentoollog.h> #include <ctype.h> #include <inttypes.h> @@ -62,7 +62,7 @@ int logfile = 2; int logfile = 2; /* every libxl action in xl uses this same libxl context */ -libxl_ctx ctx; +libxl_ctx *ctx; /* when we operate on a domain, it is this one: */ static uint32_t domid; @@ -150,11 +150,11 @@ static int domain_qualifier_to_domid(con *was_name_r = was_name; if (was_name) { - rc = libxl_name_to_domid(&ctx, p, domid_r); + rc = libxl_name_to_domid(ctx, p, domid_r); if (rc) return rc; } else { - rc = libxl_domain_info(&ctx, &dominfo, *domid_r); + rc = libxl_domain_info(ctx, &dominfo, *domid_r); /* error only if domain does not exist */ if (rc == ERROR_INVAL) return rc; @@ -170,7 +170,7 @@ static int cpupool_qualifier_to_cpupooli was_name = qualifier_to_id(p, poolid_r); if (was_name_r) *was_name_r = was_name; - return was_name ? libxl_name_to_cpupoolid(&ctx, p, poolid_r) : 0; + return was_name ? libxl_name_to_cpupoolid(ctx, p, poolid_r) : 0; } static void find_domain(const char *p) @@ -182,7 +182,7 @@ static void find_domain(const char *p) fprintf(stderr, "%s is an invalid domain identifier (rc=%d)\n", p, rc); exit(2); } - common_domname = was_name ? p : libxl_domid_to_name(&ctx, domid); + common_domname = was_name ? p : libxl_domid_to_name(ctx, domid); } static int acquire_lock(void) @@ -303,7 +303,7 @@ static void printf_info(int domid, /* retrieve the UUID from dominfo, since it is probably generated * during parsing and thus does not match the real one */ - if (libxl_domain_info(&ctx, &info, domid) == 0) { + if (libxl_domain_info(ctx, &info, domid) == 0) { printf("\t(uuid " LIBXL_UUID_FMT ")\n", LIBXL_UUID_BYTES(info.uuid)); } else { printf("\t(uuid <unknown>)\n"); @@ -667,7 +667,7 @@ static void parse_config_data(const char c_info->poolid = -1; cpupool_qualifier_to_cpupoolid(buf, &c_info->poolid, NULL); } - c_info->poolname = libxl_cpupoolid_to_name(&ctx, c_info->poolid); + c_info->poolname = libxl_cpupoolid_to_name(ctx, c_info->poolid); if (!c_info->poolname) { fprintf(stderr, "Illegal pool specified\n"); exit(1); @@ -875,7 +875,7 @@ static void parse_config_data(const char free(nic->ifname); nic->ifname = strdup(p2 + 1); } else if (!strcmp(p, "backend")) { - if(libxl_name_to_domid(&ctx, (p2 + 1), &(nic->backend_domid))) { + if(libxl_name_to_domid(ctx, (p2 + 1), &(nic->backend_domid))) { fprintf(stderr, "Specified backend domain does not exist, defaulting to Dom0\n"); nic->backend_domid = 0; } @@ -1022,7 +1022,7 @@ skip_vfb: pcidev->msitranslate = pci_msitranslate; pcidev->power_mgmt = pci_power_mgmt; - if (!libxl_device_pci_parse_bdf(&ctx, pcidev, buf)) + if (!libxl_device_pci_parse_bdf(ctx, pcidev, buf)) d_config->num_pcidevs++; } } @@ -1291,23 +1291,23 @@ static int freemem(libxl_domain_build_in if (!autoballoon) return 0; - rc = libxl_domain_need_memory(&ctx, b_info, dm_info, &need_memkb); + rc = libxl_domain_need_memory(ctx, b_info, dm_info, &need_memkb); if (rc < 0) return rc; do { - rc = libxl_get_free_memory(&ctx, &free_memkb); + rc = libxl_get_free_memory(ctx, &free_memkb); if (rc < 0) return rc; if (free_memkb >= need_memkb) return 0; - rc = libxl_set_memory_target(&ctx, 0, free_memkb - need_memkb, 1, 0); + rc = libxl_set_memory_target(ctx, 0, free_memkb - need_memkb, 1, 0); if (rc < 0) return rc; - rc = libxl_wait_for_free_memory(&ctx, domid, need_memkb, 10); + rc = libxl_wait_for_free_memory(ctx, domid, need_memkb, 10); if (!rc) return 0; else if (rc != ERROR_NOMEM) @@ -1315,7 +1315,7 @@ static int freemem(libxl_domain_build_in /* the memory target has been reached but the free memory is still * not enough: loop over again */ - rc = libxl_wait_for_memory_target(&ctx, 0, 1); + rc = libxl_wait_for_memory_target(ctx, 0, 1); if (rc < 0) return rc; @@ -1380,7 +1380,7 @@ static int create_domain(struct domain_c restore_fd = migrate_fd >= 0 ? migrate_fd : open(restore_file, O_RDONLY); - CHK_ERRNO( libxl_read_exactly(&ctx, restore_fd, &hdr, + CHK_ERRNO( libxl_read_exactly(ctx, restore_fd, &hdr, sizeof(hdr), restore_file, "header") ); if (memcmp(hdr.magic, savefileheader_magic, sizeof(hdr.magic))) { fprintf(stderr, "File has wrong magic number -" @@ -1406,7 +1406,7 @@ static int create_domain(struct domain_c } if (hdr.optional_data_len) { optdata_begin = xmalloc(hdr.optional_data_len); - CHK_ERRNO( libxl_read_exactly(&ctx, restore_fd, optdata_begin, + CHK_ERRNO( libxl_read_exactly(ctx, restore_fd, optdata_begin, hdr.optional_data_len, restore_file, "optdata") ); } @@ -1438,7 +1438,7 @@ static int create_domain(struct domain_c if (config_file) { free(config_data); config_data = 0; - ret = libxl_read_file_contents(&ctx, config_file, + ret = libxl_read_file_contents(ctx, config_file, &config_data, &config_len); if (ret) { fprintf(stderr, "Failed to read config file: %s: %s\n", config_file, strerror(errno)); return ERROR_FAIL; } @@ -1517,17 +1517,17 @@ start: } if ( restore_file ) { - ret = libxl_domain_create_restore(&ctx, &d_config, + ret = libxl_domain_create_restore(ctx, &d_config, cb, &child_console_pid, &domid, restore_fd); }else{ - ret = libxl_domain_create_new(&ctx, &d_config, + ret = libxl_domain_create_new(ctx, &d_config, cb, &child_console_pid, &domid); } if ( ret ) goto error_out; - ret = libxl_userdata_store(&ctx, domid, "xl", + ret = libxl_userdata_store(ctx, domid, "xl", config_data, config_len); if (ret) { perror("cannot save config file"); @@ -1538,7 +1538,7 @@ start: release_lock(); if (!paused) - libxl_domain_unpause(&ctx, domid); + libxl_domain_unpause(ctx, domid); ret = domid; /* caller gets success in parent */ if (!daemonize) @@ -1549,7 +1549,7 @@ start: pid_t child1, got_child; int nullfd; - child1 = libxl_fork(&ctx); + child1 = libxl_fork(ctx); if (child1) { printf("Daemon running with PID %d\n", child1); @@ -1564,7 +1564,7 @@ start: } } if (status) { - libxl_report_child_exitstatus(&ctx, XTL_ERROR, + libxl_report_child_exitstatus(ctx, XTL_ERROR, "daemonizing child", child1, status); ret = ERROR_FAIL; goto error_out; @@ -1573,7 +1573,7 @@ start: goto out; } - rc = libxl_ctx_postfork(&ctx); + rc = libxl_ctx_postfork(ctx); if (rc) { LOG("failed to reinitialise context after fork"); exit(-1); @@ -1583,7 +1583,7 @@ start: LOG("Failed to allocate memory in asprintf"); exit(1); } - rc = libxl_create_logfile(&ctx, name, &fullname); + rc = libxl_create_logfile(ctx, name, &fullname); if (rc) { LOG("failed to open logfile %s: %s",fullname,strerror(errno)); exit(-1); @@ -1605,9 +1605,9 @@ start: d_config.c_info.name, domid, (long)getpid()); w1 = (libxl_waiter*) xmalloc(sizeof(libxl_waiter) * d_config.num_disks); w2 = (libxl_waiter*) xmalloc(sizeof(libxl_waiter)); - libxl_wait_for_disk_ejects(&ctx, domid, d_config.disks, d_config.num_disks, w1); - libxl_wait_for_domain_death(&ctx, domid, w2); - libxl_get_wait_fd(&ctx, &fd); + libxl_wait_for_disk_ejects(ctx, domid, d_config.disks, d_config.num_disks, w1); + libxl_wait_for_domain_death(ctx, domid, w2); + libxl_get_wait_fd(ctx, &fd); while (1) { int ret; fd_set rfds; @@ -1621,10 +1621,10 @@ start: ret = select(fd + 1, &rfds, NULL, NULL, NULL); if (!ret) continue; - libxl_get_event(&ctx, &event); + libxl_get_event(ctx, &event); switch (event.type) { case LIBXL_EVENT_DOMAIN_DEATH: - ret = libxl_event_get_domain_death_info(&ctx, domid, &event, &info); + ret = libxl_event_get_domain_death_info(ctx, domid, &event, &info); if (ret < 0) { libxl_free_event(&event); @@ -1634,9 +1634,9 @@ start: LOG("Domain %d is dead", domid); if (ret) { - switch (handle_domain_death(&ctx, domid, &event, &d_config, &info)) { + switch (handle_domain_death(ctx, domid, &event, &d_config, &info)) { case 2: - if (!preserve_domain(&ctx, domid, &event, &d_config, &info)) { + if (!preserve_domain(ctx, domid, &event, &d_config, &info)) { /* If we fail then exit leaving the old domain in place. */ ret = -1; goto out; @@ -1682,8 +1682,8 @@ start: } break; case LIBXL_EVENT_DISK_EJECT: - if (libxl_event_get_disk_eject_info(&ctx, domid, &event, &disk)) { - libxl_cdrom_insert(&ctx, domid, &disk); + if (libxl_event_get_disk_eject_info(ctx, domid, &event, &disk)) { + libxl_cdrom_insert(ctx, domid, &disk); libxl_device_disk_destroy(&disk); } break; @@ -1694,7 +1694,7 @@ error_out: error_out: release_lock(); if (libxl_domid_valid_guest(domid)) - libxl_domain_destroy(&ctx, domid, 0); + libxl_domain_destroy(ctx, domid, 0); out: if (logfile != 2) @@ -1789,7 +1789,7 @@ static int set_memory_max(const char *p, exit(3); } - rc = libxl_domain_setmaxmem(&ctx, domid, memorykb); + rc = libxl_domain_setmaxmem(ctx, domid, memorykb); return rc; } @@ -1839,7 +1839,7 @@ static void set_memory_target(const char exit(3); } - libxl_set_memory_target(&ctx, domid, memorykb, 0, /* enforce */ 1); + libxl_set_memory_target(ctx, domid, memorykb, 0, /* enforce */ 1); } int main_memset(int argc, char **argv) @@ -1887,7 +1887,7 @@ static void cd_insert(const char *dom, c disk.backend_domid = 0; disk.domid = domid; - libxl_cdrom_insert(&ctx, domid, &disk); + libxl_cdrom_insert(ctx, domid, &disk); free(buf); } @@ -1982,9 +1982,9 @@ int main_console(int argc, char **argv) find_domain(argv[optind]); if (!type) - libxl_primary_console_exec(&ctx, domid); - else - libxl_console_exec(&ctx, domid, num, type); + libxl_primary_console_exec(ctx, domid); + else + libxl_console_exec(ctx, domid, num, type); fprintf(stderr, "Unable to attach console\n"); return 1; } @@ -1992,7 +1992,7 @@ static int vncviewer(const char *domain_ static int vncviewer(const char *domain_spec, int autopass) { find_domain(domain_spec); - libxl_vncviewer_exec(&ctx, domid, autopass); + libxl_vncviewer_exec(ctx, domid, autopass); fprintf(stderr, "Unable to execute vncviewer\n"); return 1; } @@ -2040,7 +2040,7 @@ static void pcilist_assignable(void) libxl_device_pci *pcidevs; int num, i; - if ( libxl_device_pci_list_assignable(&ctx, &pcidevs, &num) ) + if ( libxl_device_pci_list_assignable(ctx, &pcidevs, &num) ) return; for (i = 0; i < num; i++) { printf("%04x:%02x:%02x.%01x\n", @@ -2075,7 +2075,7 @@ static void pcilist(const char *dom) find_domain(dom); - if (libxl_device_pci_list_assigned(&ctx, &pcidevs, domid, &num)) + if (libxl_device_pci_list_assigned(ctx, &pcidevs, domid, &num)) return; printf("Vdev Device\n"); for (i = 0; i < num; i++) { @@ -2120,11 +2120,11 @@ static void pcidetach(const char *dom, c find_domain(dom); memset(&pcidev, 0x00, sizeof(pcidev)); - if (libxl_device_pci_parse_bdf(&ctx, &pcidev, bdf)) { + if (libxl_device_pci_parse_bdf(ctx, &pcidev, bdf)) { fprintf(stderr, "pci-detach: malformed BDF specification \"%s\"\n", bdf); exit(2); } - libxl_device_pci_remove(&ctx, domid, &pcidev, force); + libxl_device_pci_remove(ctx, domid, &pcidev, force); libxl_device_pci_destroy(&pcidev); } @@ -2165,11 +2165,11 @@ static void pciattach(const char *dom, c find_domain(dom); memset(&pcidev, 0x00, sizeof(pcidev)); - if (libxl_device_pci_parse_bdf(&ctx, &pcidev, bdf)) { + if (libxl_device_pci_parse_bdf(ctx, &pcidev, bdf)) { fprintf(stderr, "pci-attach: malformed BDF specification \"%s\"\n", bdf); exit(2); } - libxl_device_pci_add(&ctx, domid, &pcidev); + libxl_device_pci_add(ctx, domid, &pcidev); libxl_device_pci_destroy(&pcidev); } @@ -2206,13 +2206,13 @@ static void pause_domain(const char *p) static void pause_domain(const char *p) { find_domain(p); - libxl_domain_pause(&ctx, domid); + libxl_domain_pause(ctx, domid); } static void unpause_domain(const char *p) { find_domain(p); - libxl_domain_unpause(&ctx, domid); + libxl_domain_unpause(ctx, domid); } static void destroy_domain(const char *p) @@ -2223,7 +2223,7 @@ static void destroy_domain(const char *p fprintf(stderr, "Cannot destroy privileged domain 0.\n\n"); exit(-1); } - rc = libxl_domain_destroy(&ctx, domid, 0); + rc = libxl_domain_destroy(ctx, domid, 0); if (rc) { fprintf(stderr,"destroy failed (rc=%d)\n",rc); exit(-1); } } @@ -2232,16 +2232,16 @@ static void shutdown_domain(const char * int rc; find_domain(p); - rc=libxl_domain_shutdown(&ctx, domid, 0); + rc=libxl_domain_shutdown(ctx, domid, 0); if (rc) { fprintf(stderr,"shutdown failed (rc=%d)\n",rc);exit(-1); } if (wait) { libxl_waiter waiter; int fd; - libxl_wait_for_domain_death(&ctx, domid, &waiter); - - libxl_get_wait_fd(&ctx, &fd); + libxl_wait_for_domain_death(ctx, domid, &waiter); + + libxl_get_wait_fd(ctx, &fd); while (wait) { fd_set rfds; @@ -2254,10 +2254,10 @@ static void shutdown_domain(const char * if (!select(fd + 1, &rfds, NULL, NULL, NULL)) continue; - libxl_get_event(&ctx, &event); + libxl_get_event(ctx, &event); if (event.type == LIBXL_EVENT_DOMAIN_DEATH) { - if (libxl_event_get_domain_death_info(&ctx, domid, &event, &info) < 0) + if (libxl_event_get_domain_death_info(ctx, domid, &event, &info) < 0) continue; LOG("Domain %d is dead", domid); @@ -2274,7 +2274,7 @@ static void reboot_domain(const char *p) { int rc; find_domain(p); - rc=libxl_domain_shutdown(&ctx, domid, 1); + rc=libxl_domain_shutdown(ctx, domid, 1); if (rc) { fprintf(stderr,"reboot failed (rc=%d)\n",rc);exit(-1); } } @@ -2291,7 +2291,7 @@ static void list_domains_details(const l /* no detailed info available on dom0 */ if (info[i].domid == 0) continue; - rc = libxl_userdata_retrieve(&ctx, info[i].domid, "xl", &data, &len); + rc = libxl_userdata_retrieve(ctx, info[i].domid, "xl", &data, &len); if (rc) continue; CHK_ERRNO(asprintf(&config_file, "<domid %d data>", info[i].domid)); @@ -2315,7 +2315,7 @@ static void list_domains(int verbose, co for (i = 0; i < nb_domain; i++) { char *domname; unsigned shutdown_reason; - domname = libxl_domid_to_name(&ctx, info[i].domid); + domname = libxl_domid_to_name(ctx, info[i].domid); shutdown_reason = info[i].shutdown ? info[i].shutdown_reason : 0; printf("%-40s %5d %5lu %5d %c%c%c%c%c%c %8.1f", domname, @@ -2347,7 +2347,7 @@ static void list_vm(void) char *domname; int nb_vm, i; - info = libxl_list_vm(&ctx, &nb_vm); + info = libxl_list_vm(ctx, &nb_vm); if (info < 0) { fprintf(stderr, "libxl_domain_infolist failed.\n"); @@ -2355,7 +2355,7 @@ static void list_vm(void) } printf("UUID ID name\n"); for (i = 0; i < nb_vm; i++) { - domname = libxl_domid_to_name(&ctx, info[i].domid); + domname = libxl_domid_to_name(ctx, info[i].domid); printf(LIBXL_UUID_FMT " %d %-30s\n", LIBXL_UUID_BYTES(info[i].uuid), info[i].domid, domname); free(domname); @@ -2376,11 +2376,11 @@ static void save_domain_core_begin(const if (override_config_file) { void *config_v = 0; - rc = libxl_read_file_contents(&ctx, override_config_file, + rc = libxl_read_file_contents(ctx, override_config_file, &config_v, config_len_r); *config_data_r = config_v; } else { - rc = libxl_userdata_retrieve(&ctx, domid, "xl", + rc = libxl_userdata_retrieve(ctx, domid, "xl", config_data_r, config_len_r); } if (rc) { @@ -2417,9 +2417,9 @@ static void save_domain_core_writeconfig /* that's the optional data */ - CHK_ERRNO( libxl_write_exactly(&ctx, fd, + CHK_ERRNO( libxl_write_exactly(ctx, fd, &hdr, sizeof(hdr), filename, "header") ); - CHK_ERRNO( libxl_write_exactly(&ctx, fd, + CHK_ERRNO( libxl_write_exactly(ctx, fd, optdata_begin, hdr.optional_data_len, filename, "header") ); fprintf(stderr, "Saving to %s new xl format (info" @@ -2449,13 +2449,13 @@ static int save_domain(const char *p, co save_domain_core_writeconfig(fd, filename, config_data, config_len); - CHK_ERRNO(libxl_domain_suspend(&ctx, NULL, domid, fd)); + CHK_ERRNO(libxl_domain_suspend(ctx, NULL, domid, fd)); close(fd); if (checkpoint) - libxl_domain_unpause(&ctx, domid); - else - libxl_domain_destroy(&ctx, domid, 0); + libxl_domain_unpause(ctx, domid); + else + libxl_domain_destroy(ctx, domid, 0); exit(0); } @@ -2467,7 +2467,7 @@ static int migrate_read_fixedmessage(int int rc; stream = rune ? "migration receiver stream" : "migration stream"; - rc = libxl_read_exactly(&ctx, fd, buf, msgsz, stream, what); + rc = libxl_read_exactly(ctx, fd, buf, msgsz, stream, what); if (rc) return ERROR_FAIL; if (memcmp(buf, msg, msgsz)) { @@ -2496,7 +2496,7 @@ static void migration_child_report(pid_t if (child == migration_child) { if (status) - libxl_report_child_exitstatus(&ctx, XTL_INFO, + libxl_report_child_exitstatus(ctx, XTL_INFO, "migration target process", migration_child, status); break; @@ -2567,10 +2567,10 @@ static void migrate_domain(const char *d exit(1); } - MUST( libxl_pipe(&ctx, sendpipe) ); - MUST( libxl_pipe(&ctx, recvpipe) ); - - child = libxl_fork(&ctx); + MUST( libxl_pipe(ctx, sendpipe) ); + MUST( libxl_pipe(ctx, recvpipe) ); + + child = libxl_fork(ctx); if (child==-1) exit(1); if (!child) { @@ -2608,7 +2608,7 @@ static void migrate_domain(const char *d memset(&suspinfo, 0, sizeof(suspinfo)); suspinfo.flags |= XL_SUSPEND_LIVE; - rc = libxl_domain_suspend(&ctx, &suspinfo, domid, send_fd); + rc = libxl_domain_suspend(ctx, &suspinfo, domid, send_fd); if (rc) { fprintf(stderr, "migration sender: libxl_domain_suspend failed" " (rc=%d)\n", rc); @@ -2638,7 +2638,7 @@ static void migrate_domain(const char *d if (common_domname) { if (asprintf(&away_domname, "%s--migratedaway", common_domname) < 0) goto failed_resume; - rc = libxl_domain_rename(&ctx, domid, common_domname, away_domname); + rc = libxl_domain_rename(ctx, domid, common_domname, away_domname); if (rc) goto failed_resume; } @@ -2649,7 +2649,7 @@ static void migrate_domain(const char *d fprintf(stderr, "migration sender: Giving target permission to start.\n"); - rc = libxl_write_exactly(&ctx, send_fd, + rc = libxl_write_exactly(ctx, send_fd, migrate_permission_to_go, sizeof(migrate_permission_to_go), "migration stream", "GO message"); @@ -2660,7 +2660,7 @@ static void migrate_domain(const char *d "success/failure report message", rune); if (rc) goto failed_badly; - rc = libxl_read_exactly(&ctx, recv_fd, + rc = libxl_read_exactly(ctx, recv_fd, &rc_buf, 1, "migration ack stream", "success/failure status"); if (rc) goto failed_badly; @@ -2678,9 +2678,9 @@ static void migrate_domain(const char *d fprintf(stderr, "migration sender: Trying to resume at our end.\n"); if (common_domname) { - libxl_domain_rename(&ctx, domid, away_domname, common_domname); - } - rc = libxl_domain_resume(&ctx, domid); + libxl_domain_rename(ctx, domid, away_domname, common_domname); + } + rc = libxl_domain_resume(ctx, domid); if (!rc) fprintf(stderr, "migration sender: Resumed OK.\n"); fprintf(stderr, "Migration failed due to problems at target.\n"); @@ -2688,7 +2688,7 @@ static void migrate_domain(const char *d } fprintf(stderr, "migration sender: Target reports successful startup.\n"); - libxl_domain_destroy(&ctx, domid, 1); /* bang! */ + libxl_domain_destroy(ctx, domid, 1); /* bang! */ fprintf(stderr, "Migration successful.\n"); exit(0); @@ -2702,7 +2702,7 @@ static void migrate_domain(const char *d close(send_fd); migration_child_report(child, recv_fd); fprintf(stderr, "Migration failed, resuming at sender.\n"); - libxl_domain_resume(&ctx, domid); + libxl_domain_resume(ctx, domid); exit(-ERROR_FAIL); failed_badly: @@ -2723,7 +2723,7 @@ static void core_dump_domain(const char { int rc; find_domain(domain_spec); - rc=libxl_domain_core_dump(&ctx, domid, filename); + rc=libxl_domain_core_dump(ctx, domid, filename); if (rc) { fprintf(stderr,"core dump failed (rc=%d)\n",rc);exit(-1); } } @@ -2739,7 +2739,7 @@ static void migrate_receive(int debug, i fprintf(stderr, "migration target: Ready to receive domain.\n"); - CHK_ERRNO( libxl_write_exactly(&ctx, 1, + CHK_ERRNO( libxl_write_exactly(ctx, 1, migrate_receiver_banner, sizeof(migrate_receiver_banner)-1, "migration ack stream", @@ -2763,7 +2763,7 @@ static void migrate_receive(int debug, i fprintf(stderr, "migration target: Transfer complete," " requesting permission to start domain.\n"); - rc = libxl_write_exactly(&ctx, 1, + rc = libxl_write_exactly(ctx, 1, migrate_receiver_ready, sizeof(migrate_receiver_ready), "migration ack stream", "ready message"); @@ -2777,18 +2777,18 @@ static void migrate_receive(int debug, i fprintf(stderr, "migration target: Got permission, starting domain.\n"); if (migration_domname) { - rc = libxl_domain_rename(&ctx, domid, migration_domname, common_domname); + rc = libxl_domain_rename(ctx, domid, migration_domname, common_domname); if (rc) goto perhaps_destroy_notify_rc; } - rc = libxl_domain_unpause(&ctx, domid); + rc = libxl_domain_unpause(ctx, domid); if (rc) goto perhaps_destroy_notify_rc; fprintf(stderr, "migration target: Domain started successsfully.\n"); rc = 0; perhaps_destroy_notify_rc: - rc2 = libxl_write_exactly(&ctx, 1, + rc2 = libxl_write_exactly(ctx, 1, migrate_report, sizeof(migrate_report), "migration ack stream", "success/failure report"); @@ -2796,7 +2796,7 @@ static void migrate_receive(int debug, i rc_buf = -rc; assert(!!rc_buf == !!rc); - rc2 = libxl_write_exactly(&ctx, 1, &rc_buf, 1, + rc2 = libxl_write_exactly(ctx, 1, &rc_buf, 1, "migration ack stream", "success/failure code"); if (rc2) exit(-ERROR_BADFAIL); @@ -2804,7 +2804,7 @@ static void migrate_receive(int debug, i if (rc) { fprintf(stderr, "migration target: Failure, destroying our copy.\n"); - rc2 = libxl_domain_destroy(&ctx, domid, 1); + rc2 = libxl_domain_destroy(ctx, domid, 1); if (rc2) { fprintf(stderr, "migration target: Failed to destroy our copy" " (code %d).\n", rc2); @@ -2814,7 +2814,7 @@ static void migrate_receive(int debug, i fprintf(stderr, "migration target: Cleanup OK, granting sender" " permission to resume.\n"); - rc2 = libxl_write_exactly(&ctx, 1, + rc2 = libxl_write_exactly(ctx, 1, migrate_permission_to_go, sizeof(migrate_permission_to_go), "migration ack stream", @@ -3194,7 +3194,7 @@ int main_list(int argc, char **argv) } if (optind >= argc) { - info = libxl_list_domain(&ctx, &nb_domain); + info = libxl_list_domain(ctx, &nb_domain); if (!info) { fprintf(stderr, "libxl_domain_infolist failed.\n"); return 1; @@ -3202,7 +3202,7 @@ int main_list(int argc, char **argv) info_free = info; } else if (optind == argc-1) { find_domain(argv[optind]); - rc = libxl_domain_info(&ctx, &info_buf, domid); + rc = libxl_domain_info(ctx, &info_buf, domid); if (rc == ERROR_INVAL) { fprintf(stderr, "Error: Domain \'%s\' does not exist.\n", argv[optind]); @@ -3353,7 +3353,7 @@ static void button_press(const char *p, exit(2); } - libxl_button_press(&ctx, domid, button); + libxl_button_press(ctx, domid, button); } int main_button_press(int argc, char **argv) @@ -3441,7 +3441,7 @@ static void print_vcpuinfo(uint32_t tdom char *domname; /* NAME ID VCPU */ - domname = libxl_domid_to_name(&ctx, tdomid); + domname = libxl_domid_to_name(ctx, tdomid); printf("%-32s %5u %5u", domname, tdomid, vcpuinfo->vcpuid); free(domname); @@ -3466,7 +3466,7 @@ static void print_domain_vcpuinfo(uint32 libxl_vcpuinfo *vcpuinfo; int i, nb_vcpu, nrcpus; - vcpuinfo = libxl_list_vcpu(&ctx, domid, &nb_vcpu, &nrcpus); + vcpuinfo = libxl_list_vcpu(ctx, domid, &nb_vcpu, &nrcpus); if (!vcpuinfo) { fprintf(stderr, "libxl_list_vcpu failed.\n"); @@ -3487,7 +3487,7 @@ static void vcpulist(int argc, char **ar libxl_physinfo physinfo; int i, nb_domain; - if (libxl_get_physinfo(&ctx, &physinfo) != 0) { + if (libxl_get_physinfo(ctx, &physinfo) != 0) { fprintf(stderr, "libxl_physinfo failed.\n"); goto vcpulist_out; } @@ -3495,7 +3495,7 @@ static void vcpulist(int argc, char **ar printf("%-32s %5s %5s %5s %5s %9s %s\n", "Name", "ID", "VCPU", "CPU", "State", "Time(s)", "CPU Affinity"); if (!argc) { - if (!(dominfo = libxl_list_domain(&ctx, &nb_domain))) { + if (!(dominfo = libxl_list_domain(ctx, &nb_domain))) { fprintf(stderr, "libxl_list_domain failed.\n"); goto vcpulist_out; } @@ -3558,7 +3558,7 @@ static void vcpupin(const char *d, const find_domain(d); - if (libxl_cpumap_alloc(&ctx, &cpumap)) { + if (libxl_cpumap_alloc(ctx, &cpumap)) { goto vcpupin_out; } if (strcmp(cpu, "all")) { @@ -3589,17 +3589,17 @@ static void vcpupin(const char *d, const } if (vcpuid != -1) { - if (libxl_set_vcpuaffinity(&ctx, domid, vcpuid, &cpumap) == -1) { + if (libxl_set_vcpuaffinity(ctx, domid, vcpuid, &cpumap) == -1) { fprintf(stderr, "Could not set affinity for vcpu `%u'.\n", vcpuid); } } else { - if (!(vcpuinfo = libxl_list_vcpu(&ctx, domid, &nb_vcpu, &i))) { + if (!(vcpuinfo = libxl_list_vcpu(ctx, domid, &nb_vcpu, &i))) { fprintf(stderr, "libxl_list_vcpu failed.\n"); goto vcpupin_out1; } for (; nb_vcpu > 0; --nb_vcpu, ++vcpuinfo) { - if (libxl_set_vcpuaffinity(&ctx, domid, vcpuinfo->vcpuid, &cpumap) == -1) { + if (libxl_set_vcpuaffinity(ctx, domid, vcpuinfo->vcpuid, &cpumap) == -1) { fprintf(stderr, "libxl_set_vcpuaffinity failed on vcpu `%u'.\n", vcpuinfo->vcpuid); } } @@ -3648,14 +3648,14 @@ static void vcpuset(const char *d, const find_domain(d); - if (libxl_cpumap_alloc(&ctx, &cpumap)) { + if (libxl_cpumap_alloc(ctx, &cpumap)) { fprintf(stderr, "libxl_cpumap_alloc failed\n"); return; } for (i = 0; i < max_vcpus; i++) libxl_cpumap_set(&cpumap, i); - if (libxl_set_vcpuonline(&ctx, domid, &cpumap) < 0) + if (libxl_set_vcpuonline(ctx, domid, &cpumap) < 0) fprintf(stderr, "libxl_set_vcpuonline failed domid=%d max_vcpus=%d\n", domid, max_vcpus); libxl_cpumap_destroy(&cpumap); @@ -3689,12 +3689,12 @@ static void output_xeninfo(void) const libxl_version_info *info; int sched_id; - if (!(info = libxl_get_version_info(&ctx))) { + if (!(info = libxl_get_version_info(ctx))) { fprintf(stderr, "libxl_get_version_info failed.\n"); return; } - if ((sched_id = libxl_get_sched_id(&ctx)) < 0) { + if ((sched_id = libxl_get_sched_id(ctx)) < 0) { fprintf(stderr, "get_sched_id sysctl failed.\n"); return; } @@ -3703,7 +3703,7 @@ static void output_xeninfo(void) printf("xen_minor : %d\n", info->xen_version_minor); 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_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_changeset : %s\n", info->changeset); @@ -3737,7 +3737,7 @@ static void output_physinfo(void) libxl_cpumap cpumap; int n = 0; - if (libxl_get_physinfo(&ctx, &info) != 0) { + if (libxl_get_physinfo(ctx, &info) != 0) { fprintf(stderr, "libxl_physinfo failed.\n"); return; } @@ -3756,13 +3756,13 @@ static void output_physinfo(void) if (info.phys_cap & XEN_SYSCTL_PHYSCAP_hvm_directio) printf(" hvm_directio"); printf("\n"); - vinfo = libxl_get_version_info(&ctx); + vinfo = libxl_get_version_info(ctx); if (vinfo) { i = (1 << 20) / vinfo->pagesize; printf("total_memory : %"PRIu64"\n", info.total_pages / i); printf("free_memory : %"PRIu64"\n", info.free_pages / i); } - if (!libxl_get_freecpus(&ctx, &cpumap)) { + if (!libxl_get_freecpus(ctx, &cpumap)) { libxl_for_each_cpu(i, cpumap) if (libxl_cpumap_test(&cpumap, i)) n++; @@ -3778,7 +3778,7 @@ static void output_topologyinfo(void) libxl_topologyinfo info; int i; - if (libxl_get_topologyinfo(&ctx, &info)) { + if (libxl_get_topologyinfo(ctx, &info)) { fprintf(stderr, "libxl_get_topologyinfo failed.\n"); return; } @@ -3849,7 +3849,7 @@ static int sched_credit_domain_get( { int rc; - rc = libxl_sched_credit_domain_get(&ctx, domid, scinfo); + rc = libxl_sched_credit_domain_get(ctx, domid, scinfo); if (rc) fprintf(stderr, "libxl_sched_credit_domain_get failed.\n"); @@ -3861,7 +3861,7 @@ static int sched_credit_domain_set( { int rc; - rc = libxl_sched_credit_domain_set(&ctx, domid, scinfo); + rc = libxl_sched_credit_domain_set(ctx, domid, scinfo); if (rc) fprintf(stderr, "libxl_sched_credit_domain_set failed.\n"); @@ -3872,7 +3872,7 @@ static void sched_credit_domain_output( int domid, libxl_sched_credit *scinfo) { char *domname; - domname = libxl_domid_to_name(&ctx, domid); + domname = libxl_domid_to_name(ctx, domid); printf("%-33s %4d %6d %4d\n", domname, domid, @@ -3918,7 +3918,7 @@ int main_sched_credit(int argc, char **a } if (!dom) { /* list all domain's credit scheduler info */ - info = libxl_list_domain(&ctx, &nb_domain); + info = libxl_list_domain(ctx, &nb_domain); if (!info) { fprintf(stderr, "libxl_domain_infolist failed.\n"); return 1; @@ -3978,7 +3978,7 @@ int main_domid(int argc, char **argv) return 1; } - if (libxl_name_to_domid(&ctx, domname, &domid)) { + if (libxl_name_to_domid(ctx, domname, &domid)) { fprintf(stderr, "Can't get domid of domain name '%s', maybe this domain does not exist.\n", domname); return 1; } @@ -4017,7 +4017,7 @@ int main_domname(int argc, char **argv) return 1; } - domname = libxl_domid_to_name(&ctx, domid); + domname = libxl_domid_to_name(ctx, domid); if (!domname) { fprintf(stderr, "Can't get domain name of domain id '%d', maybe this domain does not exist.\n", domid); return 1; @@ -4056,7 +4056,7 @@ int main_rename(int argc, char **argv) find_domain(dom); new_name = argv[optind]; - if (libxl_domain_rename(&ctx, domid, common_domname, new_name)) { + if (libxl_domain_rename(ctx, domid, common_domname, new_name)) { fprintf(stderr, "Can't rename domain '%s'.\n", dom); return 1; } @@ -4101,7 +4101,7 @@ int main_trigger(int argc, char **argv) } } - libxl_send_trigger(&ctx, domid, trigger_name, vcpuid); + libxl_send_trigger(ctx, domid, trigger_name, vcpuid); return 0; } @@ -4141,7 +4141,7 @@ int main_sysrq(int argc, char **argv) return 1; } - libxl_send_sysrq(&ctx, domid, sysrq[0]); + libxl_send_sysrq(ctx, domid, sysrq[0]); return 0; } @@ -4168,7 +4168,7 @@ int main_debug_keys(int argc, char **arg keys = argv[optind]; - if (libxl_send_debug_keys(&ctx, keys)) { + if (libxl_send_debug_keys(ctx, keys)) { fprintf(stderr, "cannot send debug keys: %s\n", keys); return 1; } @@ -4197,15 +4197,15 @@ int main_dmesg(int argc, char **argv) } } - cr = libxl_xen_console_read_start(&ctx, clear); + cr = libxl_xen_console_read_start(ctx, clear); if (!cr) goto finish; - while ((ret = libxl_xen_console_read_line(&ctx, cr, &line)) > 0) + while ((ret = libxl_xen_console_read_line(ctx, cr, &line)) > 0) printf("%s", line); finish: - libxl_xen_console_read_finish(&ctx, cr); + libxl_xen_console_read_finish(ctx, cr); return ret; } @@ -4284,7 +4284,7 @@ int main_networkattach(int argc, char ** } else if (!strncmp("script=", *argv, 6)) { nic.script = (*argv) + 6; } else if (!strncmp("backend=", *argv, 8)) { - if(libxl_name_to_domid(&ctx, ((*argv) + 8), &val)) { + if(libxl_name_to_domid(ctx, ((*argv) + 8), &val)) { fprintf(stderr, "Specified backend domain does not exist, defaulting to Dom0\n"); val = 0; } @@ -4301,7 +4301,7 @@ int main_networkattach(int argc, char ** } } nic.domid = domid; - if (libxl_device_nic_add(&ctx, domid, &nic)) { + if (libxl_device_nic_add(ctx, domid, &nic)) { fprintf(stderr, "libxl_device_nic_add failed.\n"); return 1; } @@ -4338,7 +4338,7 @@ int main_networklist(int argc, char **ar fprintf(stderr, "%s is an invalid domain identifier\n", *argv); continue; } - if (!(nics = libxl_list_nics(&ctx, domid, &nb))) { + if (!(nics = libxl_list_nics(ctx, domid, &nb))) { continue; } for (i = 0; i < nb; ++i) { @@ -4385,17 +4385,17 @@ int main_networkdetach(int argc, char ** } if (!strchr(argv[optind+1], ':')) { - if (libxl_devid_to_device_nic(&ctx, domid, argv[optind+1], &nic)) { + if (libxl_devid_to_device_nic(ctx, domid, argv[optind+1], &nic)) { fprintf(stderr, "Unknown device %s.\n", argv[optind+1]); return 1; } } else { - if (libxl_mac_to_device_nic(&ctx, domid, argv[optind+1], &nic)) { + if (libxl_mac_to_device_nic(ctx, domid, argv[optind+1], &nic)) { fprintf(stderr, "Unknown device %s.\n", argv[optind+1]); return 1; } } - if (libxl_device_nic_del(&ctx, &nic, 1)) { + if (libxl_device_nic_del(ctx, &nic, 1)) { fprintf(stderr, "libxl_device_nic_del failed.\n"); return 1; } @@ -4473,7 +4473,7 @@ int main_blockattach(int argc, char **ar disk.domid = fe_domid; disk.backend_domid = be_domid; - if (libxl_device_disk_add(&ctx, fe_domid, &disk)) { + if (libxl_device_disk_add(ctx, fe_domid, &disk)) { fprintf(stderr, "libxl_device_disk_add failed.\n"); } return 0; @@ -4508,12 +4508,12 @@ int main_blocklist(int argc, char **argv fprintf(stderr, "%s is an invalid domain identifier\n", *argv); continue; } - disks = libxl_device_disk_list(&ctx, domid, &nb); + disks = libxl_device_disk_list(ctx, domid, &nb); if (!disks) { continue; } for (i=0; i<nb; i++) { - if (!libxl_device_disk_getinfo(&ctx, domid, &disks[i], &diskinfo)) { + if (!libxl_device_disk_getinfo(ctx, domid, &disks[i], &diskinfo)) { /* Vdev BE hdl st evch rref BE-path*/ printf("%-5d %-3d %-6d %-5d %-6d %-8d %-30s\n", diskinfo.devid, diskinfo.backend_id, diskinfo.frontend_id, @@ -4551,11 +4551,11 @@ int main_blockdetach(int argc, char **ar fprintf(stderr, "%s is an invalid domain identifier\n", argv[optind]); return 1; } - if (libxl_devid_to_device_disk(&ctx, domid, argv[optind+1], &disk)) { + if (libxl_devid_to_device_disk(ctx, domid, argv[optind+1], &disk)) { fprintf(stderr, "Error: Device %s not connected.\n", argv[optind+1]); return 1; } - if (libxl_device_disk_del(&ctx, &disk, 1)) { + if (libxl_device_disk_del(ctx, &disk, 1)) { fprintf(stderr, "libxl_device_disk_del failed.\n"); } return 0; @@ -4652,7 +4652,7 @@ int main_network2attach(int argc, char * } net2.domid = domid; net2.backend_domid = back_domid; - if (libxl_device_net2_add(&ctx, domid, &net2)) { + if (libxl_device_net2_add(ctx, domid, &net2)) { fprintf(stderr, "libxl_device_net2_add failed.\n"); } return 0; @@ -4687,7 +4687,7 @@ int main_network2list(int argc, char **a fprintf(stderr, "%s is an invalid domain identifier\n", *argv); continue; } - if ((net2s = libxl_device_net2_list(&ctx, domid, &nb))) { + if ((net2s = libxl_device_net2_list(ctx, domid, &nb))) { for (; nb > 0; --nb, ++net2s) { printf("%3d %2d %5d ", net2s->devid, net2s->backend_id, net2s->state); printf("%02x:%02x:%02x:%02x:%02x:%02x ", @@ -4727,11 +4727,11 @@ int main_network2detach(int argc, char * fprintf(stderr, "%s is an invalid domain identifier\n", argv[optind]); return 1; } - if (libxl_devid_to_device_net2(&ctx, domid, argv[optind+1], &net2)) { + if (libxl_devid_to_device_net2(ctx, domid, argv[optind+1], &net2)) { fprintf(stderr, "Error: Device %s not connected.\n", argv[optind+1]); return 1; } - if (libxl_device_net2_del(&ctx, &net2, 1)) { + if (libxl_device_net2_del(ctx, &net2, 1)) { fprintf(stderr, "libxl_device_net2_del failed.\n"); return 1; } @@ -4811,7 +4811,7 @@ static void print_dom0_uptime(int short_ strtok(buf, " "); uptime = strtoul(buf, NULL, 10); - domname = libxl_domid_to_name(&ctx, 0); + domname = libxl_domid_to_name(ctx, 0); if (short_mode) { now_str = current_time_to_string(now); @@ -4844,11 +4844,11 @@ static void print_domU_uptime(uint32_t d char *now_str = NULL; char *domname; - s_time = libxl_vm_get_start_time(&ctx, domuid); + s_time = libxl_vm_get_start_time(ctx, domuid); if (s_time == -1) return; uptime = now - s_time; - domname = libxl_domid_to_name(&ctx, domuid); + domname = libxl_domid_to_name(ctx, domuid); if (short_mode) { now_str = current_time_to_string(now); @@ -4883,7 +4883,7 @@ static void print_uptime(int short_mode, if (nb_doms == 0) { print_dom0_uptime(short_mode, now); - info = libxl_list_vm(&ctx, &nb_vm); + info = libxl_list_vm(ctx, &nb_vm); for (i = 0; i < nb_vm; i++) print_domU_uptime(info[i].domid, short_mode, now); } else { @@ -4965,7 +4965,7 @@ int main_tmem_list(int argc, char **argv else find_domain(dom); - buf = libxl_tmem_list(&ctx, domid, use_long); + buf = libxl_tmem_list(ctx, domid, use_long); if (buf == NULL) return -1; @@ -5006,7 +5006,7 @@ int main_tmem_freeze(int argc, char **ar else find_domain(dom); - libxl_tmem_freeze(&ctx, domid); + libxl_tmem_freeze(ctx, domid); return 0; } @@ -5042,7 +5042,7 @@ int main_tmem_destroy(int argc, char **a else find_domain(dom); - libxl_tmem_destroy(&ctx, domid); + libxl_tmem_destroy(ctx, domid); return 0; } @@ -5078,7 +5078,7 @@ int main_tmem_thaw(int argc, char **argv else find_domain(dom); - libxl_tmem_thaw(&ctx, domid); + libxl_tmem_thaw(ctx, domid); return 0; } @@ -5135,11 +5135,11 @@ int main_tmem_set(int argc, char **argv) } if (opt_w) - libxl_tmem_set(&ctx, domid, "weight", weight); + libxl_tmem_set(ctx, domid, "weight", weight); if (opt_c) - libxl_tmem_set(&ctx, domid, "cap", cap); + libxl_tmem_set(ctx, domid, "cap", cap); if (opt_p) - libxl_tmem_set(&ctx, domid, "compress", compress); + libxl_tmem_set(ctx, domid, "compress", compress); return 0; } @@ -5198,7 +5198,7 @@ int main_tmem_shared_auth(int argc, char return 1; } - libxl_tmem_shared_auth(&ctx, domid, uuid, auth); + libxl_tmem_shared_auth(ctx, domid, uuid, auth); return 0; } @@ -5219,7 +5219,7 @@ int main_tmem_freeable(int argc, char ** } } - mb = libxl_tmem_freeable(&ctx); + mb = libxl_tmem_freeable(ctx); if (mb == -1) return -1; @@ -5300,7 +5300,7 @@ int main_cpupoolcreate(int argc, char ** return -ERROR_FAIL; } - if (libxl_read_file_contents(&ctx, filename, (void **)&config_data, &config_len)) { + if (libxl_read_file_contents(ctx, filename, (void **)&config_data, &config_len)) { fprintf(stderr, "Failed to read config file: %s: %s\n", filename, strerror(errno)); return -ERROR_FAIL; @@ -5338,36 +5338,36 @@ int main_cpupoolcreate(int argc, char ** name = strdup(buf); else name = libxl_basename(filename); - if (!libxl_name_to_cpupoolid(&ctx, name, &poolid)) { + if (!libxl_name_to_cpupoolid(ctx, name, &poolid)) { fprintf(stderr, "Pool name \"%s\" already exists\n", name); return -ERROR_FAIL; } if (!xlu_cfg_get_string (config, "sched", &buf)) { - if ((schedid = libxl_name_to_schedid(&ctx, buf)) < 0) { + if ((schedid = libxl_name_to_schedid(ctx, buf)) < 0) { fprintf(stderr, "Unknown scheduler\n"); return -ERROR_FAIL; } } else { - if ((schedid = libxl_get_sched_id(&ctx)) < 0) { + if ((schedid = libxl_get_sched_id(ctx)) < 0) { fprintf(stderr, "get_sched_id sysctl failed.\n"); return -ERROR_FAIL; } } - sched = libxl_schedid_to_name(&ctx, schedid); - - if (libxl_get_freecpus(&ctx, &freemap)) { + sched = libxl_schedid_to_name(ctx, schedid); + + if (libxl_get_freecpus(ctx, &freemap)) { fprintf(stderr, "libxl_get_freecpus failed\n"); return -ERROR_FAIL; } - if (libxl_cpumap_alloc(&ctx, &cpumap)) { + if (libxl_cpumap_alloc(ctx, &cpumap)) { fprintf(stderr, "Failed to allocate cpumap\n"); return -ERROR_FAIL; } if (!xlu_cfg_get_list(config, "nodes", &nodes, 0, 0)) { n_cpus = 0; n_nodes = 0; - if (libxl_get_topologyinfo(&ctx, &topology)) { + if (libxl_get_topologyinfo(ctx, &topology)) { fprintf(stderr, "libxl_get_topologyinfo failed\n"); return -ERROR_FAIL; } @@ -5427,7 +5427,7 @@ int main_cpupoolcreate(int argc, char ** return 0; poolid = 0; - if (libxl_create_cpupool(&ctx, name, schedid, cpumap, &uuid, &poolid)) { + if (libxl_create_cpupool(ctx, name, schedid, cpumap, &uuid, &poolid)) { fprintf(stderr, "error on creating cpupool\n"); return -ERROR_FAIL; } @@ -5481,13 +5481,13 @@ int main_cpupoollist(int argc, char **ar } if (optind < argc) { pool = argv[optind]; - if (libxl_name_to_cpupoolid(&ctx, pool, &poolid)) { + if (libxl_name_to_cpupoolid(ctx, pool, &poolid)) { fprintf(stderr, "Pool \'%s\' does not exist\n", pool); return -ERROR_FAIL; } } - poolinfo = libxl_list_cpupool(&ctx, &n_pools); + poolinfo = libxl_list_cpupool(ctx, &n_pools); if (!poolinfo) { fprintf(stderr, "error getting cpupool info\n"); return -ERROR_NOMEM; @@ -5501,7 +5501,7 @@ int main_cpupoollist(int argc, char **ar for (p = 0; p < n_pools; p++) { if (!ret && (!pool || (poolinfo[p].poolid == poolid))) { - name = libxl_cpupoolid_to_name(&ctx, poolinfo[p].poolid); + name = libxl_cpupoolid_to_name(ctx, poolinfo[p].poolid); if (!name) { fprintf(stderr, "error getting cpupool info\n"); ret = -ERROR_NOMEM; @@ -5517,7 +5517,7 @@ int main_cpupoollist(int argc, char **ar } if (!opt_cpus) { printf("%3d %9s y %4d", n, - libxl_schedid_to_name(&ctx, poolinfo[p].sched_id), + libxl_schedid_to_name(ctx, poolinfo[p].sched_id), poolinfo[p].n_dom); } printf("\n"); @@ -5554,12 +5554,12 @@ int main_cpupooldestroy(int argc, char * } if (cpupool_qualifier_to_cpupoolid(pool, &poolid, NULL) || - !libxl_cpupoolid_to_name(&ctx, poolid)) { + !libxl_cpupoolid_to_name(ctx, poolid)) { fprintf(stderr, "unknown cpupool \'%s\'\n", pool); return -ERROR_FAIL; } - return -libxl_destroy_cpupool(&ctx, poolid); + return -libxl_destroy_cpupool(ctx, poolid); } int main_cpupoolrename(int argc, char **argv) @@ -5588,14 +5588,14 @@ int main_cpupoolrename(int argc, char ** } if (cpupool_qualifier_to_cpupoolid(pool, &poolid, NULL) || - !libxl_cpupoolid_to_name(&ctx, poolid)) { + !libxl_cpupoolid_to_name(ctx, poolid)) { fprintf(stderr, "unknown cpupool \'%s\'\n", pool); return -ERROR_FAIL; } new_name = argv[optind]; - if (libxl_cpupool_rename(&ctx, new_name, poolid)) { + if (libxl_cpupool_rename(ctx, new_name, poolid)) { fprintf(stderr, "Can't rename cpupool '%s'.\n", pool); return 1; } @@ -5644,16 +5644,16 @@ int main_cpupoolcpuadd(int argc, char ** } if (cpupool_qualifier_to_cpupoolid(pool, &poolid, NULL) || - !libxl_cpupoolid_to_name(&ctx, poolid)) { + !libxl_cpupoolid_to_name(ctx, poolid)) { fprintf(stderr, "unknown cpupool \'%s\'\n", pool); return -ERROR_FAIL; } if (cpu >= 0) { - return -libxl_cpupool_cpuadd(&ctx, poolid, cpu); - } - - if (libxl_cpupool_cpuadd_node(&ctx, poolid, node, &n)) { + return -libxl_cpupool_cpuadd(ctx, poolid, cpu); + } + + if (libxl_cpupool_cpuadd_node(ctx, poolid, node, &n)) { fprintf(stderr, "libxl_cpupool_cpuadd_node failed\n"); return -ERROR_FAIL; } @@ -5707,16 +5707,16 @@ int main_cpupoolcpuremove(int argc, char } if (cpupool_qualifier_to_cpupoolid(pool, &poolid, NULL) || - !libxl_cpupoolid_to_name(&ctx, poolid)) { + !libxl_cpupoolid_to_name(ctx, poolid)) { fprintf(stderr, "unknown cpupool \'%s\'\n", pool); return -ERROR_FAIL; } if (cpu >= 0) { - return -libxl_cpupool_cpuremove(&ctx, poolid, cpu); - } - - if (libxl_cpupool_cpuremove_node(&ctx, poolid, node, &n)) { + return -libxl_cpupool_cpuremove(ctx, poolid, cpu); + } + + if (libxl_cpupool_cpuremove_node(ctx, poolid, node, &n)) { fprintf(stderr, "libxl_cpupool_cpuremove_node failed\n"); return -ERROR_FAIL; } @@ -5763,18 +5763,18 @@ int main_cpupoolmigrate(int argc, char * } if (domain_qualifier_to_domid(dom, &domid, NULL) || - !libxl_domid_to_name(&ctx, domid)) { + !libxl_domid_to_name(ctx, domid)) { fprintf(stderr, "unknown domain \'%s\'\n", dom); return -ERROR_FAIL; } if (cpupool_qualifier_to_cpupoolid(pool, &poolid, NULL) || - !libxl_cpupoolid_to_name(&ctx, poolid)) { + !libxl_cpupoolid_to_name(ctx, poolid)) { fprintf(stderr, "unknown cpupool \'%s\'\n", pool); return -ERROR_FAIL; } - return -libxl_cpupool_movedomain(&ctx, poolid, domid); + return -libxl_cpupool_movedomain(ctx, poolid, domid); } int main_cpupoolnumasplit(int argc, char **argv) @@ -5807,7 +5807,7 @@ int main_cpupoolnumasplit(int argc, char } ret = 0; - poolinfo = libxl_list_cpupool(&ctx, &n_pools); + poolinfo = libxl_list_cpupool(ctx, &n_pools); if (!poolinfo) { fprintf(stderr, "error getting cpupool info\n"); return -ERROR_NOMEM; @@ -5822,12 +5822,12 @@ int main_cpupoolnumasplit(int argc, char return -ERROR_FAIL; } - if (libxl_get_topologyinfo(&ctx, &topology)) { + if (libxl_get_topologyinfo(ctx, &topology)) { fprintf(stderr, "libxl_get_topologyinfo failed\n"); return -ERROR_FAIL; } - if (libxl_cpumap_alloc(&ctx, &cpumap)) { + if (libxl_cpumap_alloc(ctx, &cpumap)) { fprintf(stderr, "Failed to allocate cpumap\n"); libxl_topologyinfo_destroy(&topology); return -ERROR_FAIL; @@ -5837,13 +5837,13 @@ int main_cpupoolnumasplit(int argc, char a cpupool without cpus in between */ node = topology.nodemap.array[0]; - if (libxl_cpupool_cpuadd_node(&ctx, 0, node, &n)) { + if (libxl_cpupool_cpuadd_node(ctx, 0, node, &n)) { fprintf(stderr, "error on adding cpu to Pool 0\n"); return -ERROR_FAIL; } snprintf(name, 15, "Pool-node%d", node); - ret = -libxl_cpupool_rename(&ctx, name, 0); + ret = -libxl_cpupool_rename(ctx, name, 0); if (ret) { fprintf(stderr, "error on renaming Pool 0\n"); goto out; @@ -5857,12 +5857,12 @@ int main_cpupoolnumasplit(int argc, char n++; } } - if (libxl_set_vcpuonline(&ctx, 0, &cpumap)) { + if (libxl_set_vcpuonline(ctx, 0, &cpumap)) { fprintf(stderr, "error on removing vcpus for Domain-0\n"); goto out; } for (c = 0; c < 10; c++) { - if (libxl_domain_info(&ctx, &info, 0)) { + if (libxl_domain_info(ctx, &info, 0)) { fprintf(stderr, "error on getting info for Domain-0\n"); goto out; } @@ -5883,7 +5883,7 @@ int main_cpupoolnumasplit(int argc, char } node = topology.nodemap.array[c]; - ret = -libxl_cpupool_cpuremove_node(&ctx, 0, node, &n); + ret = -libxl_cpupool_cpuremove_node(ctx, 0, node, &n); if (ret) { fprintf(stderr, "error on removing cpu from Pool 0\n"); goto out; @@ -5892,13 +5892,13 @@ int main_cpupoolnumasplit(int argc, char snprintf(name, 15, "Pool-node%d", node); libxl_uuid_generate(&uuid); poolid = 0; - ret = -libxl_create_cpupool(&ctx, name, schedid, cpumap, &uuid, &poolid); + ret = -libxl_create_cpupool(ctx, name, schedid, cpumap, &uuid, &poolid); if (ret) { fprintf(stderr, "error on creating cpupool\n"); goto out; } - ret = -libxl_cpupool_cpuadd_node(&ctx, poolid, node, &n); + ret = -libxl_cpupool_cpuadd_node(ctx, poolid, node, &n); if (ret) { fprintf(stderr, "error on adding cpus to cpupool\n"); goto out; diff -r 8789166a014f -r dd0e1d4aae8f tools/ocaml/libs/xl/xl_stubs.c --- a/tools/ocaml/libs/xl/xl_stubs.c Mon Mar 21 14:41:46 2011 +0000 +++ b/tools/ocaml/libs/xl/xl_stubs.c Mon Mar 21 14:41:46 2011 +0000 @@ -52,21 +52,21 @@ void log_destroy(struct xentoollog_logge { } -#define INIT_STRUCT() libxl_ctx ctx; struct caml_logger lg; struct caml_gc gc; gc.offset = 0; +#define INIT_STRUCT() libxl_ctx *ctx; struct caml_logger lg; struct caml_gc gc; gc.offset = 0; #define INIT_CTX() \ lg.logger.vmessage = log_vmessage; \ lg.logger.destroy = log_destroy; \ lg.logger.progress = NULL; \ caml_enter_blocking_section(); \ - ret = libxl_ctx_init(&ctx, LIBXL_VERSION, (struct xentoollog_logger *) &lg); \ + ret = libxl_ctx_alloc(&ctx, LIBXL_VERSION, (struct xentoollog_logger *) &lg); \ if (ret != 0) \ failwith_xl("cannot init context", &lg); #define FREE_CTX() \ gc_free(&gc); \ caml_leave_blocking_section(); \ - libxl_ctx_free(&ctx) + libxl_ctx_free(ctx) static char * dup_String_val(caml_gc *gc, value s) { @@ -372,7 +372,7 @@ value stub_xl_disk_add(value info, value c_info.domid = Int_val(domid); INIT_CTX(); - ret = libxl_device_disk_add(&ctx, Int_val(domid), &c_info); + ret = libxl_device_disk_add(ctx, Int_val(domid), &c_info); if (ret != 0) failwith_xl("disk_add", &lg); FREE_CTX(); @@ -390,7 +390,7 @@ value stub_xl_disk_remove(value info, va c_info.domid = Int_val(domid); INIT_CTX(); - ret = libxl_device_disk_del(&ctx, &c_info, 0); + ret = libxl_device_disk_del(ctx, &c_info, 0); if (ret != 0) failwith_xl("disk_remove", &lg); FREE_CTX(); @@ -408,7 +408,7 @@ value stub_xl_nic_add(value info, value c_info.domid = Int_val(domid); INIT_CTX(); - ret = libxl_device_nic_add(&ctx, Int_val(domid), &c_info); + ret = libxl_device_nic_add(ctx, Int_val(domid), &c_info); if (ret != 0) failwith_xl("nic_add", &lg); FREE_CTX(); @@ -426,7 +426,7 @@ value stub_xl_nic_remove(value info, val c_info.domid = Int_val(domid); INIT_CTX(); - ret = libxl_device_nic_del(&ctx, &c_info, 0); + ret = libxl_device_nic_del(ctx, &c_info, 0); if (ret != 0) failwith_xl("nic_remove", &lg); FREE_CTX(); @@ -447,7 +447,7 @@ value stub_xl_console_add(value info, va c_info.build_state = &c_state; INIT_CTX(); - ret = libxl_device_console_add(&ctx, Int_val(domid), &c_info); + ret = libxl_device_console_add(ctx, Int_val(domid), &c_info); if (ret != 0) failwith_xl("console_add", &lg); FREE_CTX(); @@ -465,7 +465,7 @@ value stub_xl_vkb_add(value info, value c_info.domid = Int_val(domid); INIT_CTX(); - ret = libxl_device_vkb_add(&ctx, Int_val(domid), &c_info); + ret = libxl_device_vkb_add(ctx, Int_val(domid), &c_info); if (ret != 0) failwith_xl("vkb_add", &lg); FREE_CTX(); @@ -480,7 +480,7 @@ value stub_xl_vkb_clean_shutdown(value d INIT_STRUCT(); INIT_CTX(); - ret = libxl_device_vkb_clean_shutdown(&ctx, Int_val(domid)); + ret = libxl_device_vkb_clean_shutdown(ctx, Int_val(domid)); if (ret != 0) failwith_xl("vkb_clean_shutdown", &lg); FREE_CTX(); @@ -495,7 +495,7 @@ value stub_xl_vkb_hard_shutdown(value do INIT_STRUCT(); INIT_CTX(); - ret = libxl_device_vkb_hard_shutdown(&ctx, Int_val(domid)); + ret = libxl_device_vkb_hard_shutdown(ctx, Int_val(domid)); if (ret != 0) failwith_xl("vkb_hard_shutdown", &lg); FREE_CTX(); @@ -514,7 +514,7 @@ value stub_xl_vfb_add(value info, value c_info.domid = Int_val(domid); INIT_CTX(); - ret = libxl_device_vfb_add(&ctx, Int_val(domid), &c_info); + ret = libxl_device_vfb_add(ctx, Int_val(domid), &c_info); if (ret != 0) failwith_xl("vfb_add", &lg); FREE_CTX(); @@ -529,7 +529,7 @@ value stub_xl_vfb_clean_shutdown(value d INIT_STRUCT(); INIT_CTX(); - ret = libxl_device_vfb_clean_shutdown(&ctx, Int_val(domid)); + ret = libxl_device_vfb_clean_shutdown(ctx, Int_val(domid)); if (ret != 0) failwith_xl("vfb_clean_shutdown", &lg); FREE_CTX(); @@ -544,7 +544,7 @@ value stub_xl_vfb_hard_shutdown(value do INIT_STRUCT(); INIT_CTX(); - ret = libxl_device_vfb_hard_shutdown(&ctx, Int_val(domid)); + ret = libxl_device_vfb_hard_shutdown(ctx, Int_val(domid)); if (ret != 0) failwith_xl("vfb_hard_shutdown", &lg); FREE_CTX(); @@ -562,7 +562,7 @@ value stub_xl_pci_add(value info, value device_pci_val(&gc, &c_info, info); INIT_CTX(); - ret = libxl_device_pci_add(&ctx, Int_val(domid), &c_info); + ret = libxl_device_pci_add(ctx, Int_val(domid), &c_info); if (ret != 0) failwith_xl("pci_add", &lg); FREE_CTX(); @@ -580,7 +580,7 @@ value stub_xl_pci_remove(value info, val device_pci_val(&gc, &c_info, info); INIT_CTX(); - ret = libxl_device_pci_remove(&ctx, Int_val(domid), &c_info, 0); + ret = libxl_device_pci_remove(ctx, Int_val(domid), &c_info, 0); if (ret != 0) failwith_xl("pci_remove", &lg); FREE_CTX(); @@ -595,7 +595,7 @@ value stub_xl_pci_shutdown(value domid) INIT_STRUCT(); INIT_CTX(); - ret = libxl_device_pci_shutdown(&ctx, Int_val(domid)); + ret = libxl_device_pci_shutdown(ctx, Int_val(domid)); if (ret != 0) failwith_xl("pci_shutdown", &lg); FREE_CTX(); @@ -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) + POWER_BUTTON); if (ret != 0) failwith_xl("button_press", &lg); FREE_CTX(); @@ -627,7 +627,7 @@ value stub_xl_physinfo(value unit) INIT_STRUCT(); INIT_CTX(); - ret = libxl_get_physinfo(&ctx, &c_physinfo); + ret = libxl_get_physinfo(ctx, &c_physinfo); if (ret != 0) failwith_xl("physinfo", &lg); FREE_CTX(); @@ -645,7 +645,7 @@ value stub_xl_sched_credit_domain_get(va INIT_STRUCT(); INIT_CTX(); - ret = libxl_sched_credit_domain_get(&ctx, Int_val(domid), &c_scinfo); + ret = libxl_sched_credit_domain_get(ctx, Int_val(domid), &c_scinfo); if (ret != 0) failwith_xl("sched_credit_domain_get", &lg); FREE_CTX(); @@ -664,7 +664,7 @@ value stub_xl_sched_credit_domain_set(va sched_credit_val(&gc, &c_scinfo, scinfo); INIT_CTX(); - ret = libxl_sched_credit_domain_set(&ctx, Int_val(domid), &c_scinfo); + ret = libxl_sched_credit_domain_set(ctx, Int_val(domid), &c_scinfo); if (ret != 0) failwith_xl("sched_credit_domain_set", &lg); FREE_CTX(); @@ -682,7 +682,7 @@ value stub_xl_send_trigger(value domid, c_trigger = dup_String_val(&gc, trigger); INIT_CTX(); - ret = libxl_send_trigger(&ctx, Int_val(domid), c_trigger, Int_val(vcpuid)); + ret = libxl_send_trigger(ctx, Int_val(domid), c_trigger, Int_val(vcpuid)); if (ret != 0) failwith_xl("send_trigger", &lg); FREE_CTX(); @@ -696,7 +696,7 @@ value stub_xl_send_sysrq(value domid, va INIT_STRUCT(); INIT_CTX(); - ret = libxl_send_sysrq(&ctx, Int_val(domid), Int_val(sysrq)); + ret = libxl_send_sysrq(ctx, Int_val(domid), Int_val(sysrq)); if (ret != 0) failwith_xl("send_sysrq", &lg); FREE_CTX(); @@ -713,7 +713,7 @@ value stub_xl_send_debug_keys(value keys c_keys = dup_String_val(&gc, keys); INIT_CTX(); - ret = libxl_send_debug_keys(&ctx, c_keys); + ret = libxl_send_debug_keys(ctx, c_keys); if (ret != 0) failwith_xl("send_debug_keys", &lg); FREE_CTX(); diff -r 8789166a014f -r dd0e1d4aae8f tools/python/setup.py --- a/tools/python/setup.py Mon Mar 21 14:41:46 2011 +0000 +++ b/tools/python/setup.py Mon Mar 21 14:41:46 2011 +0000 @@ -91,7 +91,7 @@ netlink = Extension("netlink", xl = Extension("xl", extra_compile_args = extra_compile_args, - include_dirs = [ PATH_XEN, PATH_LIBXL, PATH_LIBXC, PATH_XENSTORE, "xen/lowlevel/xl" ], + include_dirs = [ PATH_XEN, PATH_LIBXL, PATH_LIBXC, "xen/lowlevel/xl" ], library_dirs = [ PATH_LIBXL ], libraries = [ "xenlight" ], depends = [ PATH_LIBXL + "/libxenlight.so" ], diff -r 8789166a014f -r dd0e1d4aae8f tools/python/xen/lowlevel/xl/xl.c --- a/tools/python/xen/lowlevel/xl/xl.c Mon Mar 21 14:41:46 2011 +0000 +++ b/tools/python/xen/lowlevel/xl/xl.c Mon Mar 21 14:41:46 2011 +0000 @@ -370,7 +370,7 @@ PyObject *attrib__struct_in_addr_get(str typedef struct { PyObject_HEAD; - libxl_ctx ctx; + libxl_ctx *ctx; xentoollog_logger_stdiostream *logger; xentoollog_level minmsglevel; } XlObject; @@ -381,7 +381,7 @@ static PyObject *pyxl_list_domains(XlObj PyObject *list; int nr_dom, i; - info = libxl_list_domain(&self->ctx, &nr_dom); + info = libxl_list_domain(self->ctx, &nr_dom); if ( NULL == info ) return PyList_New(0); @@ -416,7 +416,7 @@ static PyObject *pyxl_domid_to_name(XlOb if ( !PyArg_ParseTuple(args, "i", &domid) ) return NULL; - domname = libxl_domid_to_name(&self->ctx, domid); + domname = libxl_domid_to_name(self->ctx, domid); ret = PyString_FromString(domname); free(domname); @@ -428,7 +428,7 @@ static PyObject *pyxl_domain_shutdown(Xl int domid, req = 0; if ( !PyArg_ParseTuple(args, "i|i", &domid, &req) ) return NULL; - if ( libxl_domain_shutdown(&self->ctx, domid, req) ) { + if ( libxl_domain_shutdown(self->ctx, domid, req) ) { PyErr_SetString(xl_error_obj, "cannot shutdown domain"); return NULL; } @@ -441,7 +441,7 @@ static PyObject *pyxl_domain_destroy(XlO int domid, force = 1; if ( !PyArg_ParseTuple(args, "i|i", &domid, &force) ) return NULL; - if ( libxl_domain_destroy(&self->ctx, domid, force) ) { + if ( libxl_domain_destroy(self->ctx, domid, force) ) { PyErr_SetString(xl_error_obj, "cannot destroy domain"); return NULL; } @@ -454,7 +454,7 @@ static PyObject *pyxl_domain_pause(XlObj int domid; if ( !PyArg_ParseTuple(args, "i", &domid) ) return NULL; - if ( libxl_domain_pause(&self->ctx, domid) ) { + if ( libxl_domain_pause(self->ctx, domid) ) { PyErr_SetString(xl_error_obj, "cannot pause domain"); return NULL; } @@ -467,7 +467,7 @@ static PyObject *pyxl_domain_unpause(XlO int domid; if ( !PyArg_ParseTuple(args, "i", &domid) ) return NULL; - if ( libxl_domain_unpause(&self->ctx, domid) ) { + if ( libxl_domain_unpause(self->ctx, domid) ) { PyErr_SetString(xl_error_obj, "cannot unpause domain"); return NULL; } @@ -481,7 +481,7 @@ static PyObject *pyxl_domain_rename(XlOb int domid; if ( !PyArg_ParseTuple(args, "is|s", &domid, &new_name, &old_name) ) return NULL; - if ( libxl_domain_rename(&self->ctx, domid, old_name, new_name) ) { + if ( libxl_domain_rename(self->ctx, domid, old_name, new_name) ) { PyErr_SetString(xl_error_obj, "cannot rename domain"); return NULL; } @@ -501,7 +501,7 @@ static PyObject *pyxl_pci_add(XlObject * return NULL; } pci = (Py_device_pci *)obj; - if ( libxl_device_pci_add(&self->ctx, domid, &pci->obj) ) { + if ( libxl_device_pci_add(self->ctx, domid, &pci->obj) ) { PyErr_SetString(xl_error_obj, "cannot add pci device"); return NULL; } @@ -522,7 +522,7 @@ static PyObject *pyxl_pci_del(XlObject * return NULL; } pci = (Py_device_pci *)obj; - if ( libxl_device_pci_remove(&self->ctx, domid, &pci->obj, force) ) { + if ( libxl_device_pci_remove(self->ctx, domid, &pci->obj, force) ) { PyErr_SetString(xl_error_obj, "cannot remove pci device"); return NULL; } @@ -544,7 +544,7 @@ static PyObject *pyxl_pci_parse(XlObject return NULL; } - if ( libxl_device_pci_parse_bdf(&self->ctx, &pci->obj, str) ) { + if ( libxl_device_pci_parse_bdf(self->ctx, &pci->obj, str) ) { PyErr_SetString(xl_error_obj, "cannot parse pci device spec (BDF)"); Py_DECREF(pci); return NULL; @@ -559,7 +559,7 @@ static PyObject *pyxl_pci_list_assignabl PyObject *list; int nr_dev, i; - if ( libxl_device_pci_list_assignable(&self->ctx, &dev, &nr_dev) ) { + if ( libxl_device_pci_list_assignable(self->ctx, &dev, &nr_dev) ) { PyErr_SetString(xl_error_obj, "Cannot list assignable devices"); return NULL; } @@ -595,7 +595,7 @@ static PyObject *pyxl_pci_list(XlObject if ( !PyArg_ParseTuple(args, "i", &domid) ) return NULL; - if ( libxl_device_pci_list_assigned(&self->ctx, &dev, domid, &nr_dev) ) { + if ( libxl_device_pci_list_assigned(self->ctx, &dev, domid, &nr_dev) ) { PyErr_SetString(xl_error_obj, "Cannot list assignable devices"); return NULL; } @@ -663,7 +663,7 @@ static PyObject *PyXl_new(PyTypeObject * if (self == NULL) return NULL; - memset(&self->ctx, 0, sizeof(self->ctx)); + self->ctx = NULL; self->logger = NULL; self->minmsglevel = XTL_PROGRESS; @@ -679,7 +679,7 @@ PyXl_init(XlObject *self, PyObject *args return -1; } - if ( libxl_ctx_init(&self->ctx, LIBXL_VERSION, + if ( libxl_ctx_alloc(&self->ctx, LIBXL_VERSION, (xentoollog_logger*)self->logger) ) { PyErr_SetString(xl_error_obj, "cannot init xl context"); return -1; @@ -690,7 +690,7 @@ PyXl_init(XlObject *self, PyObject *args static void PyXl_dealloc(XlObject *self) { - libxl_ctx_free(&self->ctx); + libxl_ctx_free(self->ctx); if ( self->logger ) xtl_logger_destroy((xentoollog_logger*)self->logger); _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |