[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH V2] libxl: support domainReset
On 05/27/2015 01:46 PM, Jim Fehlig wrote: Currently, libxl does not provide a reset function, but domainReset can be implemented in the libxl driver by forcibly destroying the domain and starting it again. Signed-off-by: Jim Fehlig <jfehlig@xxxxxxxx> --- This is essentially a V2 of a patch submitted quite some time ago https://www.redhat.com/archives/libvir-list/2014-August/msg00077.html The idea of implmenting domainReset in the libxl driver by forcibly destroying the domain and starting it again was ACK'ed in principle by Ian Campbell https://www.redhat.com/archives/libvir-list/2014-August/msg00109.html I never pushed the patch since it was not ACK'ed by a libvirt maintainer and stumbled across it while cleaning up some of my old branches. The only change here is rebase against current libvirt.git master. Any comments on this, beyond my self-comment below? src/libxl/libxl_driver.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 12be816..671d336 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -1237,6 +1237,64 @@ libxlDomainReboot(virDomainPtr dom, unsigned int flags) }static int+libxlDomainReset(virDomainPtr dom, unsigned int flags) +{ + libxlDriverPrivatePtr driver = dom->conn->privateData; + libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver); + virDomainObjPtr vm; + int ret = -1; + + virCheckFlags(0, -1); + + if (!(vm = libxlDomObjFromDomain(dom))) + goto cleanup; + + if (virDomainResetEnsureACL(dom->conn, vm->def) < 0) + goto cleanup; + + if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) + goto cleanup; + + if (!virDomainObjIsActive(vm)) { + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("Domain is not running")); + goto endjob; + } + + /* + * The semantics of reset can be achieved by forcibly destroying + * the domain and starting it again. + */ + if (libxl_domain_destroy(cfg->ctx, vm->def->id, NULL) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to destroy domain '%d' before reset"), + vm->def->id); + goto endjob; + } + + libxlDomainCleanup(driver, vm, VIR_DOMAIN_SHUTOFF_DESTROYED); + + if (libxlDomainStart(driver, vm, false, -1) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to start domain '%d' after reset"), + vm->def->id); + goto endjob; + } + + ret = 0; + + endjob: + if (!libxlDomainObjEndJob(driver, vm)) + vm = NULL; + + cleanup: + if (vm) + virObjectUnlock(vm); + virObjectUnref(cfg); + return ret; +} + +static int libxlDomainDestroyFlags(virDomainPtr dom, unsigned int flags) { @@ -5066,6 +5124,7 @@ static virHypervisorDriver libxlHypervisorDriver = { .domainShutdown = libxlDomainShutdown, /* 0.9.0 */ .domainShutdownFlags = libxlDomainShutdownFlags, /* 0.9.10 */ .domainReboot = libxlDomainReboot, /* 0.9.0 */ + .domainReset = libxlDomainReset, /* 1.2.8 */ Needs to be updated to 1.2.17? 1.3.0? (I'm behind on my libvirt mail and not sure about the outcome of the version discussion.) Regards, Jim _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |