Accepting request 647056 from home:jfehlig:branches:Virtualization

- libxl: add support for soft reset
  14d03b27-libxl-rm-redundant-virObjectEventStateQueue.patch,
  82452a5d-libxl-rm-goto-libxlDomainShutdownThread.patch,
  da4b0fd9-libxl-support-soft-reset.patch
  bsc#1081516

OBS-URL: https://build.opensuse.org/request/show/647056
OBS-URL: https://build.opensuse.org/package/show/Virtualization/libvirt?expand=0&rev=716
This commit is contained in:
James Fehlig 2018-11-07 17:17:07 +00:00 committed by Git OBS Bridge
parent 7e651005e2
commit 0a997d39fb
5 changed files with 269 additions and 0 deletions

View File

@ -0,0 +1,36 @@
commit 14d03b27bf8f8a13da27a297e23e2b1b80688459
Author: Jim Fehlig <jfehlig@suse.com>
Date: Wed Oct 31 10:41:28 2018 -0600
libxl: remove redundant calls to virObjectEventStateQueue
In libxlDomainShutdownThread, virObjectEventStateQueue is needlessly
called in the destroy and restart labels. The cleanup label aready
queues whatever event was created based on libxl_shutdown_reason.
There is no need to handle destroy and restart differently.
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index 0032b9dd11..9ed6ee8fb3 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -538,8 +538,6 @@ libxlDomainShutdownThread(void *opaque)
}
destroy:
- virObjectEventStateQueue(driver->domainEventState, dom_event);
- dom_event = NULL;
libxlDomainDestroyInternal(driver, vm);
libxlDomainCleanup(driver, vm);
if (!vm->persistent)
@@ -548,8 +546,6 @@ libxlDomainShutdownThread(void *opaque)
goto endjob;
restart:
- virObjectEventStateQueue(driver->domainEventState, dom_event);
- dom_event = NULL;
libxlDomainDestroyInternal(driver, vm);
libxlDomainCleanup(driver, vm);
if (libxlDomainStartNew(driver, vm, false) < 0) {

View File

@ -0,0 +1,133 @@
commit 82452a5d7f55c7698459728a3ee071402f43bb4d
Author: Jim Fehlig <jfehlig@suse.com>
Date: Wed Oct 31 10:54:14 2018 -0600
libxl: Remove some goto labels in libxlDomainShutdownThread
There are too many goto labels in libxlDomainShutdownThread. Convert the
'destroy' and 'restart' labels to helper functions, leaving only the
commonly used pattern of 'endjob' and 'cleanup' labels.
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index 9ed6ee8fb3..4cdaee0e51 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -430,6 +430,30 @@ virDomainDefParserConfig libxlDomainDefParserConfig = {
};
+static void
+libxlDomainShutdownHandleDestroy(libxlDriverPrivatePtr driver,
+ virDomainObjPtr vm)
+{
+ libxlDomainDestroyInternal(driver, vm);
+ libxlDomainCleanup(driver, vm);
+ if (!vm->persistent)
+ virDomainObjListRemove(driver->domains, vm);
+}
+
+
+static void
+libxlDomainShutdownHandleRestart(libxlDriverPrivatePtr driver,
+ virDomainObjPtr vm)
+{
+ libxlDomainDestroyInternal(driver, vm);
+ libxlDomainCleanup(driver, vm);
+ if (libxlDomainStartNew(driver, vm, false) < 0) {
+ VIR_ERROR(_("Failed to restart VM '%s': %s"),
+ vm->def->name, virGetLastErrorMessage());
+ }
+}
+
+
struct libxlShutdownThreadInfo
{
libxlDriverPrivatePtr driver;
@@ -468,10 +492,12 @@ libxlDomainShutdownThread(void *opaque)
VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN);
switch ((virDomainLifecycleAction) vm->def->onPoweroff) {
case VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY:
- goto destroy;
+ libxlDomainShutdownHandleDestroy(driver, vm);
+ goto endjob;
case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART:
case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART_RENAME:
- goto restart;
+ libxlDomainShutdownHandleRestart(driver, vm);
+ goto endjob;
case VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE:
case VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_DESTROY:
case VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_RESTART:
@@ -487,19 +513,23 @@ libxlDomainShutdownThread(void *opaque)
VIR_DOMAIN_EVENT_STOPPED_CRASHED);
switch ((virDomainLifecycleAction) vm->def->onCrash) {
case VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY:
- goto destroy;
+ libxlDomainShutdownHandleDestroy(driver, vm);
+ goto endjob;
case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART:
case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART_RENAME:
- goto restart;
+ libxlDomainShutdownHandleRestart(driver, vm);
+ goto endjob;
case VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE:
case VIR_DOMAIN_LIFECYCLE_ACTION_LAST:
goto endjob;
case VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_DESTROY:
libxlDomainAutoCoreDump(driver, vm);
- goto destroy;
+ libxlDomainShutdownHandleDestroy(driver, vm);
+ goto endjob;
case VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_RESTART:
libxlDomainAutoCoreDump(driver, vm);
- goto restart;
+ libxlDomainShutdownHandleRestart(driver, vm);
+ goto endjob;
}
} else if (xl_reason == LIBXL_SHUTDOWN_REASON_REBOOT) {
virDomainObjSetState(vm, VIR_DOMAIN_SHUTOFF,
@@ -510,10 +540,12 @@ libxlDomainShutdownThread(void *opaque)
VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN);
switch ((virDomainLifecycleAction) vm->def->onReboot) {
case VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY:
- goto destroy;
+ libxlDomainShutdownHandleDestroy(driver, vm);
+ goto endjob;
case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART:
case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART_RENAME:
- goto restart;
+ libxlDomainShutdownHandleRestart(driver, vm);
+ goto endjob;
case VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE:
case VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_DESTROY:
case VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_RESTART:
@@ -531,26 +563,8 @@ libxlDomainShutdownThread(void *opaque)
* Similar to the xl implementation, ignore SUSPEND. Any actions needed
* after calling libxl_domain_suspend() are handled by it's callers.
*/
- goto endjob;
} else {
VIR_INFO("Unhandled shutdown_reason %d", xl_reason);
- goto endjob;
- }
-
- destroy:
- libxlDomainDestroyInternal(driver, vm);
- libxlDomainCleanup(driver, vm);
- if (!vm->persistent)
- virDomainObjListRemove(driver->domains, vm);
-
- goto endjob;
-
- restart:
- libxlDomainDestroyInternal(driver, vm);
- libxlDomainCleanup(driver, vm);
- if (libxlDomainStartNew(driver, vm, false) < 0) {
- VIR_ERROR(_("Failed to restart VM '%s': %s"),
- vm->def->name, virGetLastErrorMessage());
}
endjob:

View File

@ -0,0 +1,85 @@
commit da4b0fd9d3cdd117427e7e1981e8639bc859e844
Author: Jim Fehlig <jfehlig@suse.com>
Date: Wed Oct 31 11:03:37 2018 -0600
libxl: add support for soft reset
The pvops Linux kernel implements machine_ops.crash_shutdown as
static void xen_hvm_crash_shutdown(struct pt_regs *regs)
{
native_machine_crash_shutdown(regs);
xen_reboot(SHUTDOWN_soft_reset);
}
but currently the libxl driver does not handle the soft reset
shutdown event. As a result, the guest domain never proceeds
past xen_reboot(), making it impossible for HVM domains to save
a crash dump using kexec.
This patch adds support for handling the soft reset event by
calling libxl_domain_soft_reset() and re-enabling domain death
events, which is similar to the xl tool handling of soft reset
shutdown event.
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
Index: libvirt-4.9.0/src/libxl/libxl_domain.c
===================================================================
--- libvirt-4.9.0.orig/src/libxl/libxl_domain.c
+++ libvirt-4.9.0/src/libxl/libxl_domain.c
@@ -471,8 +471,10 @@ libxlDomainShutdownThread(void *opaque)
virObjectEventPtr dom_event = NULL;
libxl_shutdown_reason xl_reason = ev->u.domain_shutdown.shutdown_reason;
libxlDriverConfigPtr cfg;
+ libxl_domain_config d_config;
cfg = libxlDriverConfigGet(driver);
+ libxl_domain_config_init(&d_config);
vm = virDomainObjListFindByID(driver->domains, ev->domid);
if (!vm) {
@@ -563,6 +565,34 @@ libxlDomainShutdownThread(void *opaque)
* Similar to the xl implementation, ignore SUSPEND. Any actions needed
* after calling libxl_domain_suspend() are handled by it's callers.
*/
+#ifdef LIBXL_HAVE_SOFT_RESET
+ } else if (xl_reason == LIBXL_SHUTDOWN_REASON_SOFT_RESET) {
+ libxlDomainObjPrivatePtr priv = vm->privateData;
+
+ if (libxl_retrieve_domain_configuration(cfg->ctx, vm->def->id,
+ &d_config) != 0) {
+ VIR_ERROR(_("Failed to retrieve config for VM '%s'. "
+ "Unable to perform soft reset. Destroying VM"),
+ vm->def->name);
+ libxlDomainShutdownHandleDestroy(driver, vm);
+ goto endjob;
+ }
+
+ if (priv->deathW) {
+ libxl_evdisable_domain_death(cfg->ctx, priv->deathW);
+ priv->deathW = NULL;
+ }
+
+ if (libxl_domain_soft_reset(cfg->ctx, &d_config, vm->def->id,
+ NULL, NULL) != 0) {
+ VIR_ERROR(_("Failed to soft reset VM '%s'. Destroying VM"),
+ vm->def->name);
+ libxlDomainShutdownHandleDestroy(driver, vm);
+ goto endjob;
+ }
+ libxl_evenable_domain_death(cfg->ctx, vm->def->id, 0, &priv->deathW);
+ libxl_domain_unpause(cfg->ctx, vm->def->id);
+#endif
} else {
VIR_INFO("Unhandled shutdown_reason %d", xl_reason);
}
@@ -575,6 +605,7 @@ libxlDomainShutdownThread(void *opaque)
virObjectEventStateQueue(driver->domainEventState, dom_event);
libxl_event_free(cfg->ctx, ev);
VIR_FREE(shutdown_info);
+ libxl_domain_config_dispose(&d_config);
virObjectUnref(cfg);
}

View File

@ -1,3 +1,12 @@
-------------------------------------------------------------------
Tue Nov 6 18:33:26 UTC 2018 - James Fehlig <jfehlig@suse.com>
- libxl: add support for soft reset
14d03b27-libxl-rm-redundant-virObjectEventStateQueue.patch,
82452a5d-libxl-rm-goto-libxlDomainShutdownThread.patch,
da4b0fd9-libxl-support-soft-reset.patch
bsc#1081516
-------------------------------------------------------------------
Mon Nov 5 15:10:31 UTC 2018 - James Fehlig <jfehlig@suse.com>

View File

@ -339,6 +339,9 @@ Source6: libvirtd-relocation-server.xml
Source99: baselibs.conf
Source100: %{name}-rpmlintrc
# Upstream patches
Patch0: 14d03b27-libxl-rm-redundant-virObjectEventStateQueue.patch
Patch1: 82452a5d-libxl-rm-goto-libxlDomainShutdownThread.patch
Patch2: da4b0fd9-libxl-support-soft-reset.patch
# Patches pending upstream review
Patch100: libxl-dom-reset.patch
Patch101: network-don-t-use-dhcp-authoritative-on-static-netwo.patch
@ -901,6 +904,9 @@ libvirt plugin for NSS for translating domain names into IP addresses.
%prep
%setup -q
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch100 -p1
%patch101 -p1
%patch150 -p1