File 23b51d7b-libxl-disable-death-event.patch of Package libvirt
xxxxxxxxxx
1
commit 23b51d7b8ec885e97a9277cf0a6c2833db4636e8
2
Author: Jim Fehlig <jfehlig@suse.com>
3
Date: Fri Oct 29 14:16:33 2021 -0600
4
5
libxl: Disable death events after receiving a shutdown event
6
7
The libxl driver will handle all domain destruction and cleanup
8
when receiving a domain shutdown event from libxl. Commit fa30ee04a2a
9
introduced the ignoreDeathEvent boolean in the DomainObjPrivate struct
10
to ignore subsequent death events from libxl. But libxl already provides
11
a mechanism to disable death events via libxl_evdisable_domain_death.
12
13
This patch partially reverts commit fa30ee04a2a and instead uses
14
libxl_evdisable_domain_death to disable subsequent death events when
15
processing a shutdown event.
16
17
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
18
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19
Reviewed-by: Ján Tomko <jtomko@redhat.com>
20
21
Index: libvirt-7.1.0/src/libxl/libxl_domain.c
22
===================================================================
23
--- libvirt-7.1.0.orig/src/libxl/libxl_domain.c
24
+++ libvirt-7.1.0/src/libxl/libxl_domain.c
25
26
libxlDomainHandleDeath(libxlDriverPrivatePtr driver, virDomainObjPtr vm)
27
{
28
virObjectEventPtr dom_event = NULL;
29
- libxlDomainObjPrivatePtr priv = vm->privateData;
30
-
31
- if (priv->ignoreDeathEvent) {
32
- priv->ignoreDeathEvent = false;
33
- return;
34
- }
35
36
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
37
return;
38
39
}
40
41
if (event->type == LIBXL_EVENT_TYPE_DOMAIN_SHUTDOWN) {
42
- libxlDomainObjPrivatePtr priv = vm->privateData;
43
struct libxlShutdownThreadInfo *shutdown_info = NULL;
44
virThread thread;
45
g_autofree char *name = NULL;
46
47
name = g_strdup_printf("ev-%d", event->domid);
48
/*
49
* Cleanup will be handled by the shutdown thread.
50
- * Ignore the forthcoming death event from libxl
51
*/
52
- priv->ignoreDeathEvent = true;
53
if (virThreadCreateFull(&thread, false, libxlDomainShutdownThread,
54
name, false, shutdown_info) < 0) {
55
- priv->ignoreDeathEvent = false;
56
/*
57
* Not much we can do on error here except log it.
58
*/
59
60
libxlDomainObjPrivatePtr priv = vm->privateData;
61
int ret = -1;
62
63
- /* Ignore next LIBXL_EVENT_TYPE_DOMAIN_DEATH as the caller will handle
64
- * domain death appropriately already (having more info, like the reason).
65
- */
66
- priv->ignoreDeathEvent = true;
67
+ if (priv->deathW) {
68
+ libxl_evdisable_domain_death(cfg->ctx, priv->deathW);
69
+ priv->deathW = NULL;
70
+ }
71
+
72
/* Unlock virDomainObj during destroy, which can take considerable
73
* time on large memory domains.
74
*/
75
virObjectUnlock(vm);
76
ret = libxl_domain_destroy(cfg->ctx, vm->def->id, NULL);
77
virObjectLock(vm);
78
- if (ret)
79
- priv->ignoreDeathEvent = false;
80
81
return ret;
82
}
83
84
priv->deathW = NULL;
85
}
86
87
- priv->ignoreDeathEvent = false;
88
-
89
if (!!g_atomic_int_dec_and_test(&driver->nactive) && driver->inhibitCallback)
90
driver->inhibitCallback(false, driver->inhibitOpaque);
91
92
Index: libvirt-7.1.0/src/libxl/libxl_domain.h
93
===================================================================
94
--- libvirt-7.1.0.orig/src/libxl/libxl_domain.h
95
+++ libvirt-7.1.0/src/libxl/libxl_domain.h
96
97
/* console */
98
virChrdevsPtr devs;
99
libxl_evgen_domain_death *deathW;
100
- /* Flag to indicate the upcoming LIBXL_EVENT_TYPE_DOMAIN_DEATH is caused
101
- * by libvirt and should not be handled separately */
102
- bool ignoreDeathEvent;
103
virThreadPtr migrationDstReceiveThr;
104
unsigned short migrationPort;
105
char *lockState;
106