SHA256
1
0
forked from pool/libvirt
libvirt/libxl-dom-reset.patch
James Fehlig 58112c5e1b Accepting request 1000754 from home:jfehlig:branches:Virtualization
- Update to libvirt 8.7.0
  - jsc#PED-620, jsc#PED-1540
  - Many incremental improvements and bug fixes, see
    https://libvirt.org/news.html#v8-7-0-2022-09-01
  - Dropped patches:
    9493c9b7-lxc-containter-fix-build-with-glibc-2.36.patch,
    c0d9adf2-virfile-Fix-build-with-glibc-2.36.patch

- spec: Suppress error messages about nonexistent or unreadable
  files from grep

OBS-URL: https://build.opensuse.org/request/show/1000754
OBS-URL: https://build.opensuse.org/package/show/Virtualization/libvirt?expand=0&rev=943
2022-09-01 22:07:34 +00:00

91 lines
2.8 KiB
Diff

From 02cd96b46167b2b9c27a388ec25d4ffdae6508ba Mon Sep 17 00:00:00 2001
From: Jim Fehlig <jfehlig@suse.com>
Date: Tue, 5 Jul 2022 11:07:05 -0600
Subject: libxl: support domainReset
Currently, libxl_send_trigger() does not implement the LIBXL_TRIGGER_RESET
option, but domainReset can be implemented in the libxl driver by
forcibly destroying the domain and starting it again.
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
---
src/libxl/libxl_driver.c | 58 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 58 insertions(+)
Index: libvirt-8.7.0/src/libxl/libxl_driver.c
===================================================================
--- libvirt-8.7.0.orig/src/libxl/libxl_driver.c
+++ libvirt-8.7.0/src/libxl/libxl_driver.c
@@ -1354,6 +1354,63 @@ libxlDomainReboot(virDomainPtr dom, unsi
}
static int
+libxlDomainReset(virDomainPtr dom, unsigned int flags)
+{
+ libxlDriverPrivate *driver = dom->conn->privateData;
+ libxlDriverConfig *cfg = libxlDriverConfigGet(driver);
+ virDomainObj *vm;
+ int ret = -1;
+
+ virCheckFlags(0, -1);
+
+ if (!(vm = libxlDomObjFromDomain(dom)))
+ goto cleanup;
+
+ LIBXL_CHECK_DOM0_GOTO(vm->def->name, cleanup);
+
+ if (virDomainResetEnsureACL(dom->conn, vm->def) < 0)
+ goto cleanup;
+
+ if (libxlDomainObjBeginJob(driver, vm, VIR_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 reset domain '%d'"), vm->def->id);
+ goto endjob;
+ }
+
+ libxlDomainCleanup(driver, vm);
+
+ if (libxlDomainStartNew(driver, vm, false) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to start domain '%d' after reset"),
+ vm->def->id);
+ goto endjob;
+ }
+
+ ret = 0;
+
+ endjob:
+ libxlDomainObjEndJob(driver, vm);
+
+ cleanup:
+ virDomainObjEndAPI(&vm);
+ virObjectUnref(cfg);
+ return ret;
+}
+
+static int
libxlDomainDestroyFlags(virDomainPtr dom,
unsigned int flags)
{
@@ -6461,6 +6518,7 @@ static virHypervisorDriver libxlHypervis
.domainShutdown = libxlDomainShutdown, /* 0.9.0 */
.domainShutdownFlags = libxlDomainShutdownFlags, /* 0.9.10 */
.domainReboot = libxlDomainReboot, /* 0.9.0 */
+ .domainReset = libxlDomainReset, /* 1.2.16 */
.domainDestroy = libxlDomainDestroy, /* 0.9.0 */
.domainDestroyFlags = libxlDomainDestroyFlags, /* 0.9.4 */
#ifdef LIBXL_HAVE_DOMAIN_SUSPEND_ONLY