forked from QubesOS/qubes-vmm-xen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
patch-pvcontrol-0001-libxl-workaround-for-Windows-PV-drivers-removing-con.patch
70 lines (63 loc) · 2.39 KB
/
patch-pvcontrol-0001-libxl-workaround-for-Windows-PV-drivers-removing-con.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
From cefbb54594aa90b1e8cdcf85b44e5d6a23dc6762 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?=
<marmarek@invisiblethingslab.com>
Date: Thu, 27 Oct 2022 21:16:18 +0200
Subject: [PATCH 1/2] libxl: workaround for Windows PV drivers removing
control/shutdown node
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
win-pv-drivers 8.x remove control/shutdown node as an acknowledgement,
instead of just clearing the content. This means the subsequent write
will create it anew, with default permissions (dom0 write, guest read).
Such permissions won't allow the guest to acknowledge subsequent
requests.
Workaround the issue by explicitly setting permissions after the write.
Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
-----------
diff --git a/tools/libs/light/libxl_domain.c b/tools/libs/light/libxl_domain.c
index f1f83b8d..bf951db3 100644
--- a/tools/libs/light/libxl_domain.c
+++ b/tools/libs/light/libxl_domain.c
@@ -771,7 +771,12 @@ int libxl__domain_pvcontrol(libxl__egc *egc, libxl__xswait_state *pvcontrol,
domid_t domid, const char *cmd)
{
STATE_AO_GC(pvcontrol->ao);
+ libxl_ctx *ctx = libxl__gc_owner(gc);
const char *shutdown_path;
+ xs_transaction_t t;
+ struct xs_permissions perms[] = {
+ { .id = domid, .perms = XS_PERM_NONE },
+ };
int rc;
rc = libxl__domain_pvcontrol_available(gc, domid);
@@ -785,9 +790,28 @@ int libxl__domain_pvcontrol(libxl__egc *egc, libxl__xswait_state *pvcontrol,
if (!shutdown_path)
return ERROR_FAIL;
- rc = libxl__xs_printf(gc, XBT_NULL, shutdown_path, "%s", cmd);
- if (rc)
+ retry_transaction:
+ t = xs_transaction_start(ctx->xsh);
+ if (!t)
+ return ERROR_FAIL;
+
+ rc = libxl__xs_printf(gc, t, shutdown_path, "%s", cmd);
+ if (rc) {
+ xs_transaction_end(ctx->xsh, t, 1);
return rc;
+ }
+
+ if (!xs_set_permissions(ctx->xsh, t, shutdown_path, perms, ARRAY_SIZE(perms))) {
+ xs_transaction_end(ctx->xsh, t, 1);
+ return ERROR_FAIL;
+ }
+
+ if (!xs_transaction_end(ctx->xsh, t, 0)) {
+ if (errno == EAGAIN)
+ goto retry_transaction;
+ else
+ return ERROR_FAIL;
+ }
pvcontrol->path = shutdown_path;
pvcontrol->what = GCSPRINTF("guest acknowledgement of %s request", cmd);
-----------------