On 07.07.2015 01:27, Jim Fehlig wrote: > On 07/06/2015 03:46 PM, Jim Fehlig wrote: >> In Xen, dom0 is really just another domain that supports ballooning, >> adding/removing devices, changing vcpu configuration, etc. This patch >> adds support to the libxl driver for managing dom0. Note that the >> legacy xend driver has long supported managing dom0. >> >> Operations that are not supported on dom0 are filtered in libvirt >> where a sensible error is reported. Errors from libxl are not >> always helpful. E.g., attempting a save on dom0 results in >> >> 2015-06-23 15:25:05 MDT libxl: debug: >> libxl_dom.c:1570:libxl__toolstack_save: domain=0 toolstack data size=8 >> 2015-06-23 15:25:05 MDT libxl: debug: >> libxl.c:979:do_libxl_domain_suspend: ao 0x7f7e68000b70: inprogress: >> poller=0x7f7e68000930, flags=i >> 2015-06-23 15:25:05 MDT libxl-save-helper: debug: starting save: Success >> 2015-06-23 15:25:05 MDT xc: detail: xc_domain_save_suse: starting save >> of domid 0 >> 2015-06-23 15:25:05 MDT xc: error: Couldn't map live_shinfo (3 = No >> such process): Internal error >> 2015-06-23 15:25:05 MDT xc: detail: Save exit of domid 0 with errno=3 >> 2015-06-23 15:25:05 MDT libxl-save-helper: debug: complete r=1: No >> such process >> 2015-06-23 15:25:05 MDT libxl: error: >> libxl_dom.c:1876:libxl__xc_domain_save_done: saving domain: domain did >> not respond to suspend request: No such process >> 2015-06-23 15:25:05 MDT libxl: error: >> libxl_dom.c:2033:remus_teardown_done: Remus: failed to teardown device >> for guest with domid 0, rc -8 >> >> Signed-off-by: Jim Fehlig <jfeh...@suse.com> >> --- >> src/libxl/libxl_driver.c | 95 >> ++++++++++++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 95 insertions(+) >> >> diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c >> index 149ef70..d0b76ac 100644 >> --- a/src/libxl/libxl_driver.c >> +++ b/src/libxl/libxl_driver.c >> @@ -79,6 +79,15 @@ VIR_LOG_INIT("libxl.libxl_driver"); >> /* Number of Xen scheduler parameters */ >> #define XEN_SCHED_CREDIT_NPARAM 2 >> +#define LIBXL_CHECK_DOM0_GOTO(name, >> label) \ >> + do >> { \ >> + if (STREQ_NULLABLE(name, "Domain-0")) >> { \ >> + virReportError(VIR_ERR_OPERATION_INVALID, >> "%s", \ >> + _("Domain-0 does not support requested >> operation")); \ >> + goto >> label; \ >> + >> } \ >> + } while (0) >> + >> static libxlDriverPrivatePtr libxl_driver; >> @@ -501,6 +510,62 @@ const struct libxl_event_hooks ev_hooks = { >> }; >> static int >> +libxlAddDom0(libxlDriverPrivatePtr driver) >> +{ >> + libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver); >> + virDomainDefPtr def = NULL; >> + virDomainObjPtr vm = NULL; >> + virDomainDefPtr oldDef = NULL; >> + libxl_dominfo d_info; >> + int ret = -1; >> + >> + libxl_dominfo_init(&d_info); >> + >> + /* Ensure we have a dom0 */ >> + if (libxl_domain_info(cfg->ctx, &d_info, 0) != 0) { >> + virReportError(VIR_ERR_INTERNAL_ERROR, >> + "%s", _("unable to get Domain-0 information >> from libxenlight")); >> + goto cleanup; >> + } >> + >> + if (!(def = virDomainDefNew())) >> + goto cleanup; >> + >> + def->id = 0; >> + def->virtType = VIR_DOMAIN_VIRT_XEN; >> + if (VIR_STRDUP(def->name, "Domain-0") < 0) >> + goto cleanup; >> + >> + def->os.type = VIR_DOMAIN_OSTYPE_XEN; >> + >> + if (virUUIDParse("00000000-0000-0000-0000-000000000000", >> def->uuid) < 0) >> + goto cleanup; >> + >> + vm->def->vcpus = d_info.vcpu_online; >> + vm->def->maxvcpus = d_info.vcpu_max_id + 1; >> + vm->def->mem.cur_balloon = d_info.current_memkb; >> + vm->def->mem.max_balloon = d_info.max_memkb; > > Opps. Before sending the patch, but after testing it again, I moved the > call to libxl_domain_info to the beginning of this function. I also > moved setting the vcpu and memory info earlier, but > >> + >> + if (!(vm = virDomainObjListAdd(driver->domains, def, >> + driver->xmlopt, >> + 0, >> + &oldDef))) >> + goto cleanup; >> + >> + def = NULL; >> + ret = 0; > > before getting a virDomainObj - ouch. Consider the following obvious > fix squashed in > > diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c > index d0b76ac..c0dd00b 100644 > --- a/src/libxl/libxl_driver.c > +++ b/src/libxl/libxl_driver.c > @@ -541,18 +541,19 @@ libxlAddDom0(libxlDriverPrivatePtr driver) > if (virUUIDParse("00000000-0000-0000-0000-000000000000", def->uuid) > < 0) > goto cleanup; > > + if (!(vm = virDomainObjListAdd(driver->domains, def, > + driver->xmlopt, > + 0, > + &oldDef))) > + goto cleanup; > + > + def = NULL; > + > vm->def->vcpus = d_info.vcpu_online; > vm->def->maxvcpus = d_info.vcpu_max_id + 1; > vm->def->mem.cur_balloon = d_info.current_memkb; > vm->def->mem.max_balloon = d_info.max_memkb; > > - if (!(vm = virDomainObjListAdd(driver->domains, def, > - driver->xmlopt, > - 0, > - &oldDef))) > - goto cleanup; > - > - def = NULL; > ret = 0; > > cleanup: > > Regards, > Jim >
ACK with this squashed in. Michal -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list