SHA256
1
0
forked from pool/libvirt
libvirt/libxl-dom-reset.patch
James Fehlig 4e3b0799c4 Accepting request 1068569 from home:jfehlig:branches:Virtualization
- Update to libvirt 9.1.0
  - Many incremental improvements and bug fixes, see
    https://libvirt.org/news.html#v9-1-0-2023-03-01
  - spec: Remove obsolete Groups tag
  - spec: Integrate upstream spec file changes that split the
    libvirt-daemon package, allowing more modular, customized
    installations
  - spec: New subpackages libvirt-daemon-common, libvirt-daemon-lock,
    libvirt-daemon-log, libvirt-daemon-proxy, and
    libvirt-daemon-plugin-lockd
  - spec: Renamed subpackage libvirt-lock-sanlock to
    libvirt-daemon-plugin-sanlock
  - Dropped patches:
    ef482951-apparmor-Allow-umount-dev.patch,
    d6a8b9ee-qemu-Fix-managed-no-when-creating-ethdev.patch,
    c3f16cea-qemu-cleanup-label-on-umount-failure.patch,
    697c16e3-qemu_process-better-debug-message.patch,
    5155ab4b-qemu_namespace-nested-mounts-when-umount.patch

OBS-URL: https://build.opensuse.org/request/show/1068569
OBS-URL: https://build.opensuse.org/package/show/Virtualization/libvirt?expand=0&rev=968
2023-03-02 00:49:27 +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-9.1.0/src/libxl/libxl_driver.c
===================================================================
--- libvirt-9.1.0.orig/src/libxl/libxl_driver.c
+++ libvirt-9.1.0/src/libxl/libxl_driver.c
@@ -1355,6 +1355,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 (virDomainObjBeginJob(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:
+ virDomainObjEndJob(vm);
+
+ cleanup:
+ virDomainObjEndAPI(&vm);
+ virObjectUnref(cfg);
+ return ret;
+}
+
+static int
libxlDomainDestroyFlags(virDomainPtr dom,
unsigned int flags)
{
@@ -6601,6 +6658,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