forked from QubesOS/qubes-vmm-xen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
1001-hotplug-store-block-params-for-cleanup.patch
70 lines (62 loc) · 2.09 KB
/
1001-hotplug-store-block-params-for-cleanup.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
From eaae036362dadc00a51441706239d47a170f8f97 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?=
<marmarek@invisiblethingslab.com>
Date: Wed, 16 Nov 2022 01:38:52 +0100
Subject: [PATCH] hotplug: store block params for cleanup
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Use /var/run/xen-hotplug for storing information needed to cleanup devices.
When called "remove" action - xenstore entriens can be already deleted.
Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
---
tools/hotplug/Linux/block | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/tools/hotplug/Linux/block b/tools/hotplug/Linux/block
index 2691b56951c9..dc4466906e70 100644
--- a/tools/hotplug/Linux/block
+++ b/tools/hotplug/Linux/block
@@ -3,6 +3,8 @@
dir=$(dirname "$0")
. "$dir/block-common.sh"
+HOTPLUG_STORE="/run/xen-hotplug/${XENBUS_PATH//\//-}"
+
expand_dev() {
local dev
case $1 in
@@ -256,6 +258,9 @@ case "$command" in
# script to be called twice, so just bail.
exit 0
fi
+ echo $p > "$HOTPLUG_STORE-params"
+ echo $mode > "$HOTPLUG_STORE-mode"
+ echo $truetype > "$HOTPLUG_STORE-type"
FRONTEND_ID=$(xenstore_read "$XENBUS_PATH/frontend-id")
FRONTEND_UUID=$(xenstore_read_default \
@@ -332,6 +337,7 @@ mount it read-write in a guest domain."
fi
do_or_die losetup $roflag "$loopdev" "$file"
xenstore_write "$XENBUS_PATH/node" "$loopdev"
+ echo $loopdev > "$HOTPLUG_STORE-node"
write_dev "$loopdev"
release_lock "block"
exit 0
@@ -346,6 +352,7 @@ mount it read-write in a guest domain."
;;
remove)
+ truetype=$(cat $HOTPLUG_STORE-type || echo $truetype)
case $truetype in
phy)
exit 0
@@ -353,8 +360,8 @@ mount it read-write in a guest domain."
file)
claim_lock "block"
- node=$(xenstore_read "$XENBUS_PATH/node")
- losetup -d "$node"
+ node=$(cat "$HOTPLUG_STORE-node")
+ losetup -d "$node"
release_lock "block"
exit 0
;;
--
2.44.0