forked from nrgaway/qubes-core-libvirt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
0006-libxl-pause-also-stubdomain-if-any-while-pausing-a-d.patch
83 lines (75 loc) · 3.36 KB
/
0006-libxl-pause-also-stubdomain-if-any-while-pausing-a-d.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
From b5e9e0269d58750929820e52879eccdf87442b6b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?=
<marmarek@invisiblethingslab.com>
Date: Wed, 25 Nov 2015 00:48:56 +0100
Subject: [PATCH] libxl: pause also stubdomain (if any) while pausing a domain
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Organization: Invisible Things Lab
Cc: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Otherwise stubdomain would crash, if host suspend was in effect in the
meantime.
Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
---
src/libxl/libxl_driver.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index a51836c1f5..0b62e90b99 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -1183,6 +1183,15 @@ libxlDomainSuspend(virDomainPtr dom)
goto endjob;
if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_PAUSED) {
+ int stubdom_domid = libxl_get_stubdom_id(cfg->ctx, vm->def->id);
+ if (stubdom_domid) {
+ if (libxl_domain_pause(cfg->ctx, stubdom_domid) != 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to suspend domain '%d' with libxenlight"),
+ stubdom_domid);
+ goto endjob;
+ }
+ }
if (libxl_domain_pause(cfg->ctx, vm->def->id) != 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to suspend domain '%d' with libxenlight"),
@@ -1219,6 +1228,8 @@ libxlDomainResume(virDomainPtr dom)
libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver);
virDomainObjPtr vm;
virObjectEventPtr event = NULL;
+ libxl_dominfo d_info;
+ int stubdom_domid;
int ret = -1;
if (!(vm = libxlDomObjFromDomain(dom)))
@@ -1236,12 +1247,31 @@ libxlDomainResume(virDomainPtr dom)
goto endjob;
if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_PAUSED) {
+ stubdom_domid = libxl_get_stubdom_id(cfg->ctx, vm->def->id);
if (libxl_domain_unpause(cfg->ctx, vm->def->id) != 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to resume domain '%d' with libxenlight"),
vm->def->id);
goto endjob;
}
+ if (stubdom_domid) {
+ /* stubdomain may not be paused, for example in case of
+ * virCreateWithFlags(..., VIR_DOMAIN_START_PAUSED), so first check
+ * for that
+ */
+ if (libxl_domain_info(cfg->ctx, &d_info, stubdom_domid) != 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to get '%d' stubdomain state with libxenlight"),
+ stubdom_domid);
+ goto endjob;
+ }
+ if (d_info.paused && libxl_domain_unpause(cfg->ctx, stubdom_domid) != 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to resume domain '%d' with libxenlight"),
+ stubdom_domid);
+ goto endjob;
+ }
+ }
virDomainObjSetState(vm, VIR_DOMAIN_RUNNING,
VIR_DOMAIN_RUNNING_UNPAUSED);
--
2.25.4