[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH V2] libxl: support domainReset
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. 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 */ .domainDestroy = libxlDomainDestroy, /* 0.9.0 */ .domainDestroyFlags = libxlDomainDestroyFlags, /* 0.9.4 */ .domainGetOSType = libxlDomainGetOSType, /* 0.9.0 */ -- 2.3.7 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |