[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] xend deprecation
On Mon, 2013-10-21 at 15:09 +0100, Wei Liu wrote: > These issues are all connected in a way -- runtime info is not retrieved > / updated / preserved. What I have in mind is that we might need to > introduce a mechanism to pull info from Xenstore, serialize / > deserialize config info / update stored config file when necessary. > > Comments? I agree. I have long thought that we need a way to resynthesize a libxl_domain_config from a running domain directly instead of by reparsing the config, which is likely to be stale. This could also be used as part of migration which also suffers from issues where e.g. the migrated domain gets a new random mac or reverts to the original memory target. In this case instead of sending the config file over the migration wire we'd want to switch to using the JSON generation and add autogenerated JSON parsing for use on the other end. I started to hack on such a thing (see below, as you can see it is a bit WIP!). If you wanted to pick it up that would be awesome. Ian. commit 47a05fa3fa53761f889bec0bc2884fe927ac988f Author: Ian Campbell <ian.campbell@xxxxxxxxxx> Date: Mon Sep 23 12:52:07 2013 +0100 begin to implement libxl_domain_running_config diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 8dea15f..0ae145f 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -543,9 +543,9 @@ static void xcinfo2xlinfo(libxl__gc *gc, xlinfo->domain_type = (xcinfo->flags & XEN_DOMINF_hvm_guest) ? LIBXL_DOMAIN_TYPE_HVM : LIBXL_DOMAIN_TYPE_PV; - if (xcinfo->domaindomid && libxl_console_get_tty(CTX, xcinfo->domain, 0, - LIBXL_CONSOLE_TYPE_PV, - &xlinfo->console_tty) < 0) + if (xcinfo->domain && libxl_console_get_tty(CTX, xcinfo->domain, 0, + LIBXL_CONSOLE_TYPE_PV, + &xlinfo->console_tty) < 0) LOG(WARN, "unable to get dom%d pv console tty\n", xcinfo->domain); } diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index be19bf5..c824ad6 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -677,6 +677,17 @@ int libxl_primary_console_get_tty(libxl_ctx *ctx, uint32_t domid_vm, char **path int libxl_domain_info(libxl_ctx*, libxl_dominfo *info_r, uint32_t domid); +/* Returns the running configuration of a domain. If + * preserve_defaults is true then, where it makes sense, fields which + * were initially set to the default will be returned as defaults + * rather than presenting the actual value. e.g. this will be done for + * disk backend but not NIC MAC addresses. This can be useful if this + * call is to be used to recreate a domain, in which case you want to + * allow libxl to select the appropriate disk backend again but not + * change the MAC address. */ +int libxl_domain_running_config(libxl_ctx*, libxl_domain_config *dconfig_r, + uint32_t domid, bool preserve_defaults); + /* These functions each return (on success) an array of elements, * and the length via the int* out parameter. These arrays and * their contents come from malloc, and must be freed with the diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index 6e2252a..bf11b30 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -1668,6 +1668,153 @@ out: return rc; } +int libxl_domain_running_config(libxl_ctx *ctx, libxl_domain_config *dconfig_r, + uint32_t domid, bool preserve_defaults) +{ + GC_INIT(ctx); + int rc; + xc_domaininfo_t info; + int ret; + + /* Convenient aliases */ + libxl_domain_create_info *c_info = &dconfig_r->c_info; + libxl_domain_build_info *b_info = &dconfig_r->b_info; + + libxl_domain_config_init(dconfig_r); + + + ret = xc_domain_getinfolist(CTX->xch, domid, 1, &info); + if (ret != 1) + { + LOGE(ERROR, "getinfolist failed %d\n", ret); + rc = ERROR_FAIL; + goto out; + } + if (info.domain != domid) + { + LOGE(ERROR, "got info for dom%d, wanted dom%d\n", info.domain, domid); + rc = ERROR_FAIL; + goto out; + } + + c_info->type = libxl__domain_type(gc, domid); + if (c_info->type == LIBXL_DOMAIN_TYPE_INVALID) { + rc = ERROR_INVAL; + goto out; + } + + //c_info->hap + //c_info->oos + c_info->ssidref = info.ssidref; + //c_info->name + memcpy(&c_info->uuid, info.handle, sizeof(xen_domain_handle_t)); + //c_info->xsdata + //c_info->platformdata + c_info->poolid = info.cpupool; + //c_info->run_hotplug_scripts + + libxl_domain_build_info_init_type(b_info, c_info->type); + + b_info->max_vcpus = info.max_vcpu_id; + //b_info->avail_vcpus + //b_info->cpumap + //b_info->nodemap + //b_info->numa_placement + //b_info->tsc_mode + b_info->max_memkb = info.max_pages * XC_PAGE_SIZE / 1024; + //b_info->target_memkb + //b_info->video_memkb + //b_info->shadow_memkb + //b_info->rtc_timeoffset + //b_info->exec_ssidref + //b_info->localtime + //b_info->disable_migrate + //b_info->cpuid + //b_info->blkdev_start + + //b_info->device_model_version + //b_info->device_model_stubdomain + //b_info->device_model + //b_info->device_model_ssidref + + //b_info->extra + //b_info->extra_pv + //b_info->extra_hvm + //b_info->sched_params + + //b_info->ioports + //b_info->irqs + //b_info->iomem + //b_info->claim_mode + + switch (b_info->type) { + case LIBXL_DOMAIN_TYPE_HVM: + //b_info->firmware + //b_info->bios + //b_info->pae + //b_info->apic + //b_info->acpi + //b_info->acpi_s3 + //b_info->acpi_s4 + //b_info->nx + //b_info->viridian + //b_info->timeoffset + //b_info->hpet + //b_info->vpt_align + //b_info->timer_mode + //b_info->nested_hvm + //b_info->smbios_firmware + //b_info->acpi_firmware + //b_info->nographic + //b_info->vga + //b_info->vnc + //b_info->keymap + //b_info->sdl + //b_info->spice + //b_info->gfx_passthru + //b_info->serial + //b_info->boot + //b_info->usb + //b_info->usbdevice + //b_info->soundhw + //b_info->xen_platform_pci + //b_info->usbdevice_list + //b_info->vendor_device + break; + case LIBXL_DOMAIN_TYPE_PV: + //b_info->kernel + //b_info->slack_memkb + //b_info->bootloader + //b_info->bootloader_args + //b_info->cmdline + //b_info->ramdisk + //b_info->features + //b_info->e820_host + break; + case LIBXL_DOMAIN_TYPE_INVALID: abort(); + } + + dconfig_r->disks = libxl_device_disk_list(ctx, domid, + &dconfig_r->num_disks); + dconfig_r->nics = libxl_device_nic_list(ctx, domid, + &dconfig_r->num_nics); + dconfig_r->pcidevs = libxl_device_pci_list(ctx, domid, + &dconfig_r->num_pcidevs); + //dconfig_r->vfbs = libxl_device_vfb_list(ctx, domid, + // &dconfig_r->num_vfbs); + //dconfig_r->vkbs = libxl_device_vkb_list(ctx, domid, + // &dconfig_r->num_vkbs); + dconfig_r->vtpms = libxl_device_vtpm_list(ctx, domid, + &dconfig_r->num_vtpms); + + /* on_{poweroff,reboot,watchdog,crash} */ + rc = 0; + +out: + GC_FREE; + return rc; +} + /* * Local variables: * mode: C diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 9f051f8..48815f0 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -3007,9 +3007,9 @@ static void list_domains_details(libxl_dominfo *info, int nb_domain) { libxl_domain_config d_config; - char *config_source; - uint8_t *data; - int i, len, rc; + //char *config_source; + //uint8_t *data; + int i, rc; yajl_gen hand = NULL; yajl_gen_status s; @@ -3032,12 +3032,17 @@ static void list_domains_details(libxl_dominfo *info, int nb_domain) for (i = 0; i < nb_domain; i++) { if ( info[i].domid > 0 ) { - rc = libxl_userdata_retrieve(ctx, info[i].domid, "xl", &data, &len); + //int len; + //rc = libxl_userdata_retrieve(ctx, info[i].domid, "xl", &data, &len); + //if (rc) + // continue; + //CHK_ERRNO(asprintf(&config_source, "<domid %d data>", info[i].domid)); + //libxl_domain_config_init(&d_config); + //parse_config_data(config_source, (char *)data, len, &d_config, NULL); + rc = libxl_domain_running_config(ctx, &d_config, + info[i].domid, false); if (rc) continue; - CHK_ERRNO(asprintf(&config_source, "<domid %d data>", info[i].domid)); - libxl_domain_config_init(&d_config); - parse_config_data(config_source, (char *)data, len, &d_config, NULL); } if (default_output_format == OUTPUT_FORMAT_JSON) { s = printf_info_one_json(hand, info[i].domid, @@ -3049,8 +3054,8 @@ static void list_domains_details(libxl_dominfo *info, int nb_domain) if ( info[i].domid > 0 ) { libxl_domain_config_dispose(&d_config); - free(data); - free(config_source); + //free(data); + //free(config_source); } } if (default_output_format == OUTPUT_FORMAT_JSON) { _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |