From: Jim Fehlig Subject: Re: [PATCH V2] libxl: support domainReset Date: Fri, 26 Jun 2015 14:40:35 -0600 Message-ID: <558DB8C3.2040802__27417.6010433168$1435351380$gmane$org@suse.com> References: <1432755996-17332-1-git-send-email-jfehlig@suse.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1432755996-17332-1-git-send-email-jfehlig@suse.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: libvir-list@redhat.com Cc: ian.campbell@citrix.com, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org 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 > --- > > 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