-
-
Notifications
You must be signed in to change notification settings - Fork 52
/
0612-libxl-Add-a-utility-function-for-domain-resume.patch
90 lines (80 loc) · 2.92 KB
/
0612-libxl-Add-a-utility-function-for-domain-resume.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
83
84
85
86
87
88
89
From 10cdd589b0fa637bfd4eb41cc5157ea579e2f1a8 Mon Sep 17 00:00:00 2001
From: Demi Marie Obenour <[email protected]>
Date: Mon, 26 Sep 2022 10:48:26 -0400
Subject: [PATCH] libxl: Add a utility function for domain resume
It is necessary to all xs_resume_domain after any successful call to
xc_domain_resume, so that XenStore is notified of the resumption.
However, it is also very easy to forget to call this. This took me
several days to debug.
Fix this by adding a utility function to resume a domain and then notify
XenStore of the resumption. This function does not resume any device
model, so it is still internal to libxl, but it makes future changes to
libxl much less error-prone. It also makes libxl itself smaller.
Signed-off-by: Demi Marie Obenour <[email protected]>
---
tools/libs/light/libxl_dom_suspend.c | 41 +++++++++++++---------------
1 file changed, 19 insertions(+), 22 deletions(-)
diff --git a/tools/libs/light/libxl_dom_suspend.c b/tools/libs/light/libxl_dom_suspend.c
index 6091a5f3f695..ce501a932643 100644
--- a/tools/libs/light/libxl_dom_suspend.c
+++ b/tools/libs/light/libxl_dom_suspend.c
@@ -446,6 +446,22 @@ int libxl__domain_resume_device_model_deprecated(libxl__gc *gc, uint32_t domid)
return 0;
}
+/* Just resumes the domain. The device model must have been resumed already. */
+static int domain_resume_raw(libxl__gc *gc, uint32_t domid, int suspend_cancel)
+{
+ if (xc_domain_resume(CTX->xch, domid, suspend_cancel)) {
+ LOGED(ERROR, domid, "xc_domain_resume failed");
+ return ERROR_FAIL;
+ }
+
+ if (!xs_resume_domain(CTX->xsh, domid)) {
+ LOGED(ERROR, domid, "xs_resume_domain failed");
+ return ERROR_FAIL;
+ }
+
+ return 0;
+}
+
int libxl__domain_resume_deprecated(libxl__gc *gc, uint32_t domid, int suspend_cancel)
{
int rc = 0;
@@ -464,16 +480,7 @@ int libxl__domain_resume_deprecated(libxl__gc *gc, uint32_t domid, int suspend_c
}
}
- if (xc_domain_resume(CTX->xch, domid, suspend_cancel)) {
- LOGED(ERROR, domid, "xc_domain_resume failed");
- rc = ERROR_FAIL;
- goto out;
- }
-
- if (!xs_resume_domain(CTX->xsh, domid)) {
- LOGED(ERROR, domid, "xs_resume_domain failed");
- rc = ERROR_FAIL;
- }
+ rc = domain_resume_raw(gc, domid, suspend_cancel);
out:
return rc;
}
@@ -655,19 +662,9 @@ static void domain_resume_done(libxl__egc *egc,
/* Convenience aliases */
libxl_domid domid = dmrs->domid;
- if (rc) goto out;
-
- if (xc_domain_resume(CTX->xch, domid, dmrs->suspend_cancel)) {
- LOGED(ERROR, domid, "xc_domain_resume failed");
- rc = ERROR_FAIL;
- goto out;
- }
+ if (!rc)
+ rc = domain_resume_raw(gc, domid, dmrs->suspend_cancel);
- if (!xs_resume_domain(CTX->xsh, domid)) {
- LOGED(ERROR, domid, "xs_resume_domain failed");
- rc = ERROR_FAIL;
- }
-out:
dmrs->callback(egc, dmrs, rc);
}
--
2.44.0