[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] Merge
# HG changeset patch # User Keir Fraser <keir.fraser@xxxxxxxxxx> # Date 1279562162 -3600 # Node ID c1c6706e4162dfd05e007d8fe726bb04c0b6234a # Parent 785873d52123b6ab36ba5070a04ef01ac2760d9f # Parent 91c486918e020b3d7c15ac880734701bf0277dd2 Merge --- tools/console/daemon/io.c | 5 + tools/libxl/libxl.c | 130 +++++++++++++++++++++++++++++------------ tools/libxl/libxl.h | 11 +++ tools/libxl/libxl_bootloader.c | 4 - tools/libxl/libxl_dom.c | 21 +++--- tools/libxl/libxl_exec.c | 2 tools/libxl/libxl_internal.h | 3 tools/libxl/xl.h | 2 tools/libxl/xl_cmdimpl.c | 71 +++++++++++++++++----- tools/libxl/xl_cmdtable.c | 10 +++ tools/misc/xen-hvmctx.c | 2 tools/python/xen/xend/osdep.py | 16 +++-- 12 files changed, 207 insertions(+), 70 deletions(-) diff -r 785873d52123 -r c1c6706e4162 tools/console/daemon/io.c --- a/tools/console/daemon/io.c Mon Jul 19 15:10:20 2010 +0100 +++ b/tools/console/daemon/io.c Mon Jul 19 18:56:02 2010 +0100 @@ -747,6 +747,11 @@ static void cleanup_domain(struct domain { domain_close_tty(d); + if (d->log_fd != -1) { + close(d->log_fd); + d->log_fd = -1; + } + free(d->buffer.data); d->buffer.data = NULL; diff -r 785873d52123 -r c1c6706e4162 tools/libxl/libxl.c --- a/tools/libxl/libxl.c Mon Jul 19 15:10:20 2010 +0100 +++ b/tools/libxl/libxl.c Mon Jul 19 18:56:02 2010 +0100 @@ -37,6 +37,28 @@ #include "tap-ctl.h" #define PAGE_TO_MEMKB(pages) ((pages) * 4) + +int libxl_xc_error(int xc_err) +{ + int ret = ERROR_FAIL; + + switch(xc_err) { + case XC_ERROR_NONE: + return 0; + case XC_INVALID_PARAM: + ret = ERROR_INVAL; + break; + case XC_OUT_OF_MEMORY: + ret = ERROR_NOMEM; + break; + case XC_INTERNAL_ERROR: + case XC_INVALID_KERNEL: + default: + break; + } + + return ret; +} int libxl_ctx_init(struct libxl_ctx *ctx, int version, xentoollog_logger *lg) { @@ -519,14 +541,23 @@ int libxl_domain_suspend(struct libxl_ct int libxl_domain_pause(struct libxl_ctx *ctx, uint32_t domid) { - xc_domain_pause(ctx->xch, domid); - return 0; + int rc; + rc = xc_domain_pause(ctx->xch, domid); + return libxl_xc_error(rc); +} + +int libxl_domain_core_dump(struct libxl_ctx *ctx, uint32_t domid, const char *filename) +{ + int rc; + rc = xc_domain_dumpcore(ctx->xch, domid, filename); + return libxl_xc_error(rc); } int libxl_domain_unpause(struct libxl_ctx *ctx, uint32_t domid) { char *path; char *state; + int rc; if (is_hvm(ctx, domid)) { path = libxl_sprintf(ctx, "/local/domain/0/device-model/%d/state", domid); @@ -536,9 +567,8 @@ int libxl_domain_unpause(struct libxl_ct libxl_wait_for_device_model(ctx, domid, "running", NULL, NULL); } } - xc_domain_unpause(ctx->xch, domid); - - return 0; + rc = xc_domain_unpause(ctx->xch, domid); + return libxl_xc_error(rc); } static char *req_table[] = { @@ -553,6 +583,7 @@ int libxl_domain_shutdown(struct libxl_c { char *shutdown_path; char *dom_path; + int rc = 0; if (req > ARRAY_SIZE(req_table)) return ERROR_INVAL; @@ -570,9 +601,9 @@ int libxl_domain_shutdown(struct libxl_c xc_get_hvm_param(ctx->xch, domid, HVM_PARAM_ACPI_S_STATE, &acpi_s_state); xc_get_hvm_param(ctx->xch, domid, HVM_PARAM_CALLBACK_IRQ, &pvdriver); if (!pvdriver || acpi_s_state != 0) - xc_domain_shutdown(ctx->xch, domid, req); - } - return 0; + rc = xc_domain_shutdown(ctx->xch, domid, req); + } + return libxl_xc_error(rc); } int libxl_get_wait_fd(struct libxl_ctx *ctx, int *fd) @@ -617,7 +648,7 @@ int libxl_get_event(struct libxl_ctx *ct char **events = xs_read_watch(ctx->xsh, &num); if (num != 2) { free(events); - return -1; + return ERROR_FAIL; } event->path = strdup(events[XS_WATCH_PATH]); event->token = strdup(events[XS_WATCH_TOKEN]); @@ -629,7 +660,7 @@ int libxl_stop_waiting(struct libxl_ctx int libxl_stop_waiting(struct libxl_ctx *ctx, libxl_waiter *waiter) { if (!xs_unwatch(ctx->xsh, waiter->path, waiter->token)) - return -1; + return ERROR_FAIL; else return 0; } @@ -709,7 +740,7 @@ static int libxl_destroy_device_model(st int stubdomid = libxl_get_stubdom_id(ctx, domid); if (!stubdomid) { XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "Couldn't find device model's pid"); - return -1; + return ERROR_INVAL; } XL_LOG(ctx, XL_LOG_ERROR, "Device model is a stubdom, domid=%d\n", stubdomid); return libxl_domain_destroy(ctx, stubdomid, 0); @@ -747,7 +778,7 @@ int libxl_domain_destroy(struct libxl_ct dom_path = libxl_xs_get_dompath(ctx, domid); if (!dom_path) - return -1; + return ERROR_FAIL; if (libxl_device_pci_shutdown(ctx, domid) < 0) XL_LOG(ctx, XL_LOG_ERROR, "pci shutdown failed for domid %d", domid); @@ -759,7 +790,7 @@ int libxl_domain_destroy(struct libxl_ct rc = xc_domain_pause(ctx->xch, domid); if (rc < 0) { XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc, "xc_domain_pause failed for %d", domid); - return -1; + return libxl_xc_error(rc); } if (dm_present) { if (libxl_destroy_device_model(ctx, domid) < 0) @@ -790,7 +821,7 @@ int libxl_domain_destroy(struct libxl_ct rc = xc_domain_destroy(ctx->xch, domid); if (rc < 0) { XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc, "xc_domain_destroy failed for %d", domid); - return -1; + return libxl_xc_error(rc); } return 0; } @@ -801,6 +832,15 @@ int libxl_console_exec(struct libxl_ctx char *domid_s = libxl_sprintf(ctx, "%d", domid); char *cons_num_s = libxl_sprintf(ctx, "%d", cons_num); return execl(p, p, domid_s, "--num", cons_num_s, (void *)NULL) == 0 ? 0 : ERROR_FAIL; +} + +int libxl_primary_console_exec(struct libxl_ctx *ctx, uint32_t domid_vm) +{ + uint32_t stubdomid = libxl_get_stubdom_id(ctx, domid_vm); + if (stubdomid) + return libxl_console_exec(ctx, stubdomid, 1); + else + return libxl_console_exec(ctx, domid_vm, 0); } static char ** libxl_build_device_model_args(struct libxl_ctx *ctx, @@ -1136,11 +1176,11 @@ retry_transaction: } if (libxl_create_xenpv_qemu(ctx, vfb, num_console, console, &dm_starting) < 0) { free(args); - return -1; + return ERROR_FAIL; } if (libxl_confirm_device_model_startup(ctx, dm_starting) < 0) { free(args); - return -1; + return ERROR_FAIL; } libxl_domain_unpause(ctx, domid); @@ -1344,7 +1384,7 @@ int libxl_device_disk_add(struct libxl_c if (!dev) dev = make_blktap2_device(ctx, disk->physpath, type); if (!dev) - return -1; + return ERROR_FAIL; flexarray_set(back, boffset++, "tapdisk-params"); flexarray_set(back, boffset++, libxl_sprintf(ctx, "%s:%s", device_disk_string_of_phystype(disk->phystype), disk->physpath)); flexarray_set(back, boffset++, "params"); @@ -2044,7 +2084,7 @@ int libxl_cdrom_insert(struct libxl_ctx } if (i == num) { XL_LOG(ctx, XL_LOG_ERROR, "Virtual device not found"); - return -1; + return ERROR_FAIL; } libxl_device_disk_del(ctx, disks + i, 1); libxl_device_disk_add(ctx, domid, disk); @@ -2294,7 +2334,7 @@ static int libxl_device_pci_add_xenstore if (!is_hvm(ctx, domid)) { if (libxl_wait_for_backend(ctx, be_path, "4") < 0) - return -1; + return ERROR_FAIL; } back = flexarray_make(16, 1); @@ -2343,13 +2383,13 @@ static int libxl_device_pci_remove_xenst num_devs_path = libxl_sprintf(ctx, "%s/num_devs", be_path); num_devs = libxl_xs_read(ctx, XBT_NULL, num_devs_path); if (!num_devs) - return -1; + return ERROR_INVAL; num = atoi(num_devs); if (!is_hvm(ctx, domid)) { if (libxl_wait_for_backend(ctx, be_path, "4") < 0) { XL_LOG(ctx, XL_LOG_DEBUG, "pci backend at %s is not ready", be_path); - return -1; + return ERROR_FAIL; } } @@ -2363,7 +2403,7 @@ static int libxl_device_pci_remove_xenst } if (i == num) { XL_LOG(ctx, XL_LOG_ERROR, "Couldn't find the device on xenstore"); - return -1; + return ERROR_INVAL; } retry_transaction: @@ -2377,7 +2417,7 @@ retry_transaction: if (!is_hvm(ctx, domid)) { if (libxl_wait_for_backend(ctx, be_path, "4") < 0) { XL_LOG(ctx, XL_LOG_DEBUG, "pci backend at %s is not ready", be_path); - return -1; + return ERROR_FAIL; } } @@ -2457,7 +2497,7 @@ int libxl_device_pci_add(struct libxl_ct hvm = is_hvm(ctx, domid); if (hvm) { if (libxl_wait_for_device_model(ctx, domid, "running", NULL, NULL) < 0) { - return -1; + return ERROR_FAIL; } path = libxl_sprintf(ctx, "/local/domain/0/device-model/%d/state", domid); state = libxl_xs_read(ctx, XBT_NULL, path); @@ -2487,7 +2527,7 @@ int libxl_device_pci_add(struct libxl_ct if (f == NULL) { XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "Couldn't open %s", sysfs_path); - return -1; + return ERROR_FAIL; } for (i = 0; i < PROC_PCI_NUM_RESOURCES; i++) { if (fscanf(f, "0x%llx 0x%llx 0x%llx\n", &start, &end, &flags) != 3) @@ -2550,7 +2590,7 @@ int libxl_device_pci_remove(struct libxl hvm = is_hvm(ctx, domid); if (hvm) { if (libxl_wait_for_device_model(ctx, domid, "running", NULL, NULL) < 0) { - return -1; + return ERROR_FAIL; } path = libxl_sprintf(ctx, "/local/domain/0/device-model/%d/state", domid); state = libxl_xs_read(ctx, XBT_NULL, path); @@ -2561,7 +2601,7 @@ int libxl_device_pci_remove(struct libxl xs_write(ctx->xsh, XBT_NULL, path, "pci-rem", strlen("pci-rem")); if (libxl_wait_for_device_model(ctx, domid, "pci-removed", NULL, NULL) < 0) { XL_LOG(ctx, XL_LOG_ERROR, "Device Model didn't respond in time"); - return -1; + return ERROR_FAIL; } path = libxl_sprintf(ctx, "/local/domain/0/device-model/%d/state", domid); xs_write(ctx->xsh, XBT_NULL, path, state, strlen(state)); @@ -2685,7 +2725,7 @@ int libxl_device_pci_shutdown(struct lib pcidevs = libxl_device_pci_list(ctx, domid, &num); for (i = 0; i < num; i++) { if (libxl_device_pci_remove(ctx, domid, pcidevs + i) < 0) - return -1; + return ERROR_FAIL; } free(pcidevs); return 0; @@ -2971,14 +3011,14 @@ int libxl_sched_credit_domain_set(struct if (scinfo->weight < 1 || scinfo->weight > 65535) { XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc, "Cpu weight out of range, valid values are within range from 1 to 65535"); - return -1; + return ERROR_INVAL; } if (scinfo->cap < 0 || scinfo->cap > (domaininfo.max_vcpu_id + 1) * 100) { XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc, "Cpu cap out of range, valid range is from 0 to %d for specified number of vcpus", ((domaininfo.max_vcpu_id + 1) * 100)); - return -1; + return ERROR_INVAL; } sdom.weight = scinfo->weight; @@ -2986,7 +3026,7 @@ int libxl_sched_credit_domain_set(struct rc = xc_sched_credit_domain_set(ctx->xch, domid, &sdom); if (rc != 0) - return rc; + return libxl_xc_error(rc); return 0; } @@ -3015,7 +3055,7 @@ int libxl_send_trigger(struct libxl_ctx if (trigger_type == -1) { XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, -1, "Invalid trigger, valid triggers are <nmi|reset|init|power|sleep>"); - return -1; + return ERROR_INVAL; } rc = xc_domain_send_trigger(ctx->xch, domid, trigger_type, vcpuid); @@ -3023,7 +3063,7 @@ int libxl_send_trigger(struct libxl_ctx XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc, "Send trigger '%s' failed", trigger_name); - return rc; + return libxl_xc_error(rc); } int libxl_send_sysrq(struct libxl_ctx *ctx, uint32_t domid, char sysrq) @@ -3149,7 +3189,7 @@ int libxl_tmem_freeze(struct libxl_ctx * if (rc < 0) { XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc, "Can not freeze tmem pools"); - return -1; + return ERROR_FAIL; } return rc; @@ -3164,7 +3204,7 @@ int libxl_tmem_destroy(struct libxl_ctx if (rc < 0) { XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc, "Can not destroy tmem pools"); - return -1; + return ERROR_FAIL; } return rc; @@ -3179,7 +3219,7 @@ int libxl_tmem_thaw(struct libxl_ctx *ct if (rc < 0) { XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc, "Can not thaw tmem pools"); - return -1; + return ERROR_FAIL; } return rc; @@ -3205,13 +3245,13 @@ int libxl_tmem_set(struct libxl_ctx *ctx if (subop == -1) { XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, -1, "Invalid set, valid sets are <weight|cap|compress>"); - return -1; + return ERROR_INVAL; } rc = xc_tmem_control(ctx->xch, -1, subop, domid, set, 0, 0, NULL); if (rc < 0) { XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc, "Can not set tmem %s", name); - return -1; + return libxl_xc_error(rc); } return rc; @@ -3226,6 +3266,20 @@ int libxl_tmem_shared_auth(struct libxl_ if (rc < 0) { XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc, "Can not set tmem shared auth"); + return libxl_xc_error(rc); + } + + return rc; +} + +int libxl_tmem_freeable(struct libxl_ctx *ctx) +{ + int rc; + + rc = xc_tmem_control(ctx->xch, -1, TMEMC_QUERY_FREEABLE_MB, -1, 0, 0, 0, 0); + if (rc < 0) { + XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc, + "Can not get tmem freeable memory"); return -1; } diff -r 785873d52123 -r c1c6706e4162 tools/libxl/libxl.h --- a/tools/libxl/libxl.h Mon Jul 19 15:10:20 2010 +0100 +++ b/tools/libxl/libxl.h Mon Jul 19 18:56:02 2010 +0100 @@ -395,10 +395,20 @@ int libxl_domain_pause(struct libxl_ctx int libxl_domain_pause(struct libxl_ctx *ctx, uint32_t domid); int libxl_domain_unpause(struct libxl_ctx *ctx, uint32_t domid); +int libxl_domain_core_dump(struct libxl_ctx *ctx, uint32_t domid, const char *filename); + int libxl_domain_setmaxmem(struct libxl_ctx *ctx, uint32_t domid, uint32_t target_memkb); int libxl_set_memory_target(struct libxl_ctx *ctx, uint32_t domid, uint32_t target_memkb, int enforce); int libxl_console_exec(struct libxl_ctx *ctx, uint32_t domid, int cons_num); +/* 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 + * if the guest is using stubdoms). + * This function can be called after creating the device model, in + * case of HVM guests, and before libxl_run_bootloader in case of PV + * guests using pygrub. */ +int libxl_primary_console_exec(struct libxl_ctx *ctx, uint32_t domid_vm); int libxl_domain_info(struct libxl_ctx*, struct libxl_dominfo *info_r, uint32_t domid); @@ -602,6 +612,7 @@ int libxl_tmem_set(struct libxl_ctx *ctx uint32_t set); int libxl_tmem_shared_auth(struct libxl_ctx *ctx, uint32_t domid, char* uuid, int auth); +int libxl_tmem_freeable(struct libxl_ctx *ctx); typedef struct { char *backend; diff -r 785873d52123 -r c1c6706e4162 tools/libxl/libxl_bootloader.c --- a/tools/libxl/libxl_bootloader.c Mon Jul 19 15:10:20 2010 +0100 +++ b/tools/libxl/libxl_bootloader.c Mon Jul 19 18:56:02 2010 +0100 @@ -251,7 +251,7 @@ static char * bootloader_interact(struct if (temp == NULL) goto out_err; output = temp; - memset(output + size_out, new_size - size_out, 0); + memset(output + size_out, 0, new_size - size_out); size_out = new_size; } @@ -386,7 +386,7 @@ int libxl_run_bootloader(struct libxl_ct } dom_console_xs_path = libxl_sprintf(ctx, "%s/serial/0/tty", libxl_xs_get_dompath(ctx, domid)); - libxl_xs_write(ctx, XBT_NULL, dom_console_xs_path, dom_console_slave_tty_path); + libxl_xs_write(ctx, XBT_NULL, dom_console_xs_path, "%s", dom_console_slave_tty_path); pid = fork_exec_bootloader(&bootloader_fd, (char *)info->u.pv.bootloader, args); if (pid < 0) { diff -r 785873d52123 -r c1c6706e4162 tools/libxl/libxl_dom.c --- a/tools/libxl/libxl_dom.c Mon Jul 19 15:10:20 2010 +0100 +++ b/tools/libxl/libxl_dom.c Mon Jul 19 18:56:02 2010 +0100 @@ -212,7 +212,7 @@ int build_pv(struct libxl_ctx *ctx, uint ret = 0; out: xc_dom_release(dom); - return ret == 0 ? 0 : ERROR_FAIL; + return libxl_xc_error(ret); } int build_hvm(struct libxl_ctx *ctx, uint32_t domid, @@ -250,10 +250,12 @@ int restore_common(struct libxl_ctx *ctx int fd) { /* read signature */ - return xc_domain_restore(ctx->xch, fd, domid, + int rc; + rc = xc_domain_restore(ctx->xch, fd, domid, state->store_port, &state->store_mfn, state->console_port, &state->console_mfn, info->hvm, info->u.hvm.pae, 0); + return libxl_xc_error(rc); } struct suspendinfo { @@ -359,7 +361,7 @@ int core_suspend(struct libxl_ctx *ctx, si.xce = xc_evtchn_open(); if (si.xce < 0) - return -1; + return ERROR_FAIL; if (si.xce > 0) { port = xs_suspend_evtchn_port(si.domid); @@ -438,7 +440,7 @@ static const char *userdata_path(struct if (rc) { XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "unable to find domain info" " for domain %"PRIu32, domid); - return 0; + return NULL; } uuid_string = string_of_uuid(ctx, info.uuid); @@ -493,13 +495,13 @@ int libxl_userdata_store(struct libxl_ct size_t rs; filename = userdata_path(ctx, domid, userdata_userid, "d"); - if (!filename) return ENOMEM; + if (!filename) return ERROR_NOMEM; if (!datalen) return userdata_delete(ctx, filename); newfilename = userdata_path(ctx, domid, userdata_userid, "n"); - if (!newfilename) return ENOMEM; + if (!newfilename) return ERROR_NOMEM; fd= open(newfilename, O_RDWR|O_CREAT|O_TRUNC, 0600); if (fd<0) goto xe; @@ -523,9 +525,10 @@ int libxl_userdata_store(struct libxl_ct if (f) fclose(f); if (fd>=0) close(fd); + errno = e; XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "cannot write %s for %s", newfilename, filename); - return e; + return ERROR_FAIL; } int libxl_userdata_retrieve(struct libxl_ctx *ctx, uint32_t domid, @@ -537,14 +540,14 @@ int libxl_userdata_retrieve(struct libxl void *data = 0; filename = userdata_path(ctx, domid, userdata_userid, "d"); - if (!filename) return ENOMEM; + if (!filename) return ERROR_NOMEM; e = libxl_read_file_contents(ctx, filename, data_r ? &data : 0, &datalen); if (!e && !datalen) { XL_LOG(ctx, XL_LOG_ERROR, "userdata file %s is empty", filename); if (data_r) assert(!*data_r); - return EPROTO; + return ERROR_FAIL; } if (data_r) *data_r = data; diff -r 785873d52123 -r c1c6706e4162 tools/libxl/libxl_exec.c --- a/tools/libxl/libxl_exec.c Mon Jul 19 15:10:20 2010 +0100 +++ b/tools/libxl/libxl_exec.c Mon Jul 19 18:56:02 2010 +0100 @@ -53,7 +53,7 @@ void libxl_exec(int stdinfd, int stdoutf /* in case our caller set it to IGN. subprocesses are entitled * to assume they got DFL. */ - execv(arg0, args); + execvp(arg0, args); _exit(-1); } diff -r 785873d52123 -r c1c6706e4162 tools/libxl/libxl_internal.h --- a/tools/libxl/libxl_internal.h Mon Jul 19 15:10:20 2010 +0100 +++ b/tools/libxl/libxl_internal.h Mon Jul 19 18:56:02 2010 +0100 @@ -222,5 +222,8 @@ char *libxl_abs_path(struct libxl_ctx *c #define XL_LOG_WARNING XTL_WARN #define XL_LOG_ERROR XTL_ERROR +/* Error handling */ +int libxl_xc_error(int xc_err); + #endif diff -r 785873d52123 -r c1c6706e4162 tools/libxl/xl.h --- a/tools/libxl/xl.h Mon Jul 19 15:10:20 2010 +0100 +++ b/tools/libxl/xl.h Mon Jul 19 18:56:02 2010 +0100 @@ -37,6 +37,7 @@ int main_migrate_receive(int argc, char int main_migrate_receive(int argc, char **argv); int main_save(int argc, char **argv); int main_migrate(int argc, char **argv); +int main_dump_core(int argc, char **argv); int main_pause(int argc, char **argv); int main_unpause(int argc, char **argv); int main_destroy(int argc, char **argv); @@ -72,6 +73,7 @@ int main_tmem_thaw(int argc, char **argv int main_tmem_thaw(int argc, char **argv); int main_tmem_set(int argc, char **argv); int main_tmem_shared_auth(int argc, char **argv); +int main_tmem_freeable(int argc, char **argv); int main_network2attach(int argc, char **argv); int main_network2list(int argc, char **argv); int main_network2detach(int argc, char **argv); diff -r 785873d52123 -r c1c6706e4162 tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Mon Jul 19 15:10:20 2010 +0100 +++ b/tools/libxl/xl_cmdimpl.c Mon Jul 19 18:56:02 2010 +0100 @@ -947,9 +947,9 @@ static void *xrealloc(void *ptr, size_t return r; } -int autoconnect_console(int cons_num) -{ - int status; +int autoconnect_console(int hvm) +{ + int status, options; pid_t pid, r; /* @@ -966,14 +966,21 @@ int autoconnect_console(int cons_num) return 0; /* - * Catch failure of the create process. + * In the PV case we only catch failure of the create process, in + * the HVM case we also wait for the creation process to be + * completed so that the stubdom is already up and running and we + * can connect to it. */ + if (hvm) + options = 0; + else + options = WNOHANG; sleep(1); - r = waitpid(pid, &status, WNOHANG); + r = waitpid(pid, &status, options); if (r > 0 && WIFEXITED(status) && WEXITSTATUS(status) != 0) _exit(WEXITSTATUS(status)); - libxl_console_exec(&ctx, domid, cons_num); + libxl_primary_console_exec(&ctx, domid); /* Do not return. xl continued in child process */ fprintf(stderr, "Unable to attach console\n"); _exit(1); @@ -1170,7 +1177,7 @@ start: } if (dom_info->console_autoconnect) { - ret = autoconnect_console(0); + ret = autoconnect_console(info1.hvm); if (ret) goto error_out; } @@ -1624,18 +1631,13 @@ int main_cd_insert(int argc, char **argv int main_console(int argc, char **argv) { - int opt = 0, cons_num = 0; + int opt = 0; while ((opt = getopt(argc, argv, "hn:")) != -1) { switch (opt) { case 'h': help("console"); exit(0); - case 'n': - if (optarg) { - cons_num = strtol(optarg, NULL, 10); - } - break; default: fprintf(stderr, "option not supported\n"); break; @@ -1647,7 +1649,7 @@ int main_console(int argc, char **argv) } find_domain(argv[optind]); - libxl_console_exec(&ctx, domid, 0); + libxl_primary_console_exec(&ctx, domid); fprintf(stderr, "Unable to attach console\n"); return 1; } @@ -2262,6 +2264,14 @@ static void migrate_domain(char *domain_ exit(-ERROR_BADFAIL); } +static void core_dump_domain(const char *domain_spec, const char *filename) +{ + int rc; + find_domain(domain_spec); + rc=libxl_domain_core_dump(&ctx, domid, filename); + if (rc) { fprintf(stderr,"core dump failed (rc=%d)\n.",rc);exit(-1); } +} + static void migrate_receive(int debug, int daemonize) { int rc, rc2; @@ -2528,6 +2538,16 @@ int main_migrate(int argc, char **argv) } migrate_domain(p, rune, config_filename); + exit(0); +} + +int main_dump_core(int argc, char **argv) +{ + if ( argc-optind < 2 ) { + help("dump-core"); + exit(2); + } + core_dump_domain(argv[optind], argv[optind + 1]); exit(0); } @@ -4586,3 +4606,26 @@ int main_tmem_shared_auth(int argc, char exit(0); } +int main_tmem_freeable(int argc, char **argv) +{ + int opt; + int mb; + + while ((opt = getopt(argc, argv, "h")) != -1) { + switch (opt) { + case 'h': + help("tmem-freeable"); + exit(0); + default: + fprintf(stderr, "option `%c' not supported.\n", opt); + break; + } + } + + mb = libxl_tmem_freeable(&ctx); + if (mb == -1) + exit(-1); + + printf("%d\n", mb); + exit(0); +} diff -r 785873d52123 -r c1c6706e4162 tools/libxl/xl_cmdtable.c --- a/tools/libxl/xl_cmdtable.c Mon Jul 19 15:10:20 2010 +0100 +++ b/tools/libxl/xl_cmdtable.c Mon Jul 19 18:56:02 2010 +0100 @@ -102,6 +102,11 @@ struct cmd_spec cmd_table[] = { "-e Do not wait in the background (on <host>) for the death\n" " of the domain." }, + { "dump-core", + &main_dump_core, + "Core dump a domain", + "<Domain> <filename>" + }, { "restore", &main_restore, "Restore a domain from a saved state", @@ -294,6 +299,11 @@ struct cmd_spec cmd_table[] = { " -u UUID Specify uuid\n" " (abcdef01-2345-6789-1234-567890abcdef)\n" " -A AUTH 0=auth,1=deauth", + }, + { "tmem-freeable", + &main_tmem_freeable, + "Get information about how much freeable memory (MB) is in-use by tmem", + "", }, { "network2-attach", &main_network2attach, diff -r 785873d52123 -r c1c6706e4162 tools/misc/xen-hvmctx.c --- a/tools/misc/xen-hvmctx.c Mon Jul 19 15:10:20 2010 +0100 +++ b/tools/misc/xen-hvmctx.c Mon Jul 19 18:56:02 2010 +0100 @@ -156,7 +156,7 @@ static void dump_cpu(void) " ss 0x%8.8x (0x%16.16llx + 0x%8.8x / 0x%5.5x)\n" " tr 0x%8.8x (0x%16.16llx + 0x%8.8x / 0x%5.5x)\n" " ldtr 0x%8.8x (0x%16.16llx + 0x%8.8x / 0x%5.5x)\n" - " itdr (0x%16.16llx + 0x%8.8x)\n" + " idtr (0x%16.16llx + 0x%8.8x)\n" " gdtr (0x%16.16llx + 0x%8.8x)\n" " sysenter cs 0x%8.8llx eip 0x%16.16llx esp 0x%16.16llx\n" " shadow gs 0x%16.16llx\n" diff -r 785873d52123 -r c1c6706e4162 tools/python/xen/xend/osdep.py --- a/tools/python/xen/xend/osdep.py Mon Jul 19 15:10:20 2010 +0100 +++ b/tools/python/xen/xend/osdep.py Mon Jul 19 18:56:02 2010 +0100 @@ -83,13 +83,19 @@ def _netbsd_balloon_stat(label): import commands - if label != 'current': - return None - cmd = "/sbin/sysctl hw.physmem64" + xend2netbsd_labels = { 'current' : 'kern.xen.balloon.current', + 'target' : 'kern.xen.balloon.target', + 'low-balloon' : None, + 'high-balloon' : None, + 'limit' : None } + + cmdarg = xend2netbsd_labels[label] + if cmdarg is None: + return None + cmd = "/sbin/sysctl " + cmdarg sysctloutput = commands.getoutput(cmd) (name, value) = sysctloutput.split('=') - """Return value in KB.""" - return int(value) / 1024 + return int(value) def _solaris_balloon_stat(label): """Returns the value for the named label, or None if an error occurs.""" _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |