From 66a2174764a4e632f2eadc97cc06d7f1790db8db Mon Sep 17 00:00:00 2001 From: Jason Andryuk Date: Mon, 14 Mar 2022 13:45:11 -0400 Subject: [PATCH 1/6] blktap: Use blktap/control name We patch blktap to use blktap-control as the misc device name since upstream blktap uses blktap/control. Change our linux patch to use blktap/control and drop our blktap patching to align with upstream. refpolicy needs an additional fixup to label /dev/blktap/control properly. Signed-off-by: Jason Andryuk --- ...fix-run-time-errors-and-memory-leaks.patch | 22 ------------------- .../linux/6.1/patches/blktap2.patch | 2 +- .../policy/modules/services/blktap.fc | 1 + 3 files changed, 2 insertions(+), 23 deletions(-) diff --git a/recipes-extended/xen/blktap3/fix-run-time-errors-and-memory-leaks.patch b/recipes-extended/xen/blktap3/fix-run-time-errors-and-memory-leaks.patch index 1d96fa2719..9285c58ca1 100644 --- a/recipes-extended/xen/blktap3/fix-run-time-errors-and-memory-leaks.patch +++ b/recipes-extended/xen/blktap3/fix-run-time-errors-and-memory-leaks.patch @@ -83,28 +83,6 @@ PATCHES if (ret <= 0) { err = errno; break; ---- a/include/blktap.h -+++ b/include/blktap.h -@@ -32,7 +32,7 @@ - #define _TD_BLKTAP_H_ - - #define BLKTAP2_SYSFS_DIR "/sys/class/blktap2" --#define BLKTAP2_CONTROL_NAME "blktap/control" -+#define BLKTAP2_CONTROL_NAME "blktap-control" - #define BLKTAP2_CONTROL_DIR "/var/run/blktap-control" - #define BLKTAP2_CONTROL_SOCKET "ctl" - #define BLKTAP2_DIRECTORY "/dev/xen/blktap-2" ---- a/include/blktap2.h -+++ b/include/blktap2.h -@@ -50,7 +50,7 @@ - #define BLKTAP2_IOCTL_REMOVE_DEVICE 207 - - #define BLKTAP2_SYSFS_DIR "/sys/class/blktap2" --#define BLKTAP2_CONTROL_NAME "blktap/control" -+#define BLKTAP2_CONTROL_NAME "blktap-control" - #define BLKTAP2_CONTROL_DIR "/var/run/blktap-control" - #define BLKTAP2_CONTROL_SOCKET "ctl" - #define BLKTAP2_DIRECTORY "/dev/xen/blktap-2" --- a/tapback/frontend.c +++ b/tapback/frontend.c @@ -477,7 +477,7 @@ tapback_backend_handle_otherend_watch(ba diff --git a/recipes-kernel/linux/6.1/patches/blktap2.patch b/recipes-kernel/linux/6.1/patches/blktap2.patch index 46f2b7f2f9..8920d01db3 100644 --- a/recipes-kernel/linux/6.1/patches/blktap2.patch +++ b/recipes-kernel/linux/6.1/patches/blktap2.patch @@ -482,7 +482,7 @@ PATCHES + +static struct miscdevice blktap_control = { + .minor = MISC_DYNAMIC_MINOR, -+ .name = "blktap-control", ++ .name = "blktap/control", + .fops = &blktap_control_file_operations, +}; + diff --git a/recipes-security/refpolicy/refpolicy-mcs/policy/modules/services/blktap.fc b/recipes-security/refpolicy/refpolicy-mcs/policy/modules/services/blktap.fc index 18340ae98e..5cb3aa0048 100644 --- a/recipes-security/refpolicy/refpolicy-mcs/policy/modules/services/blktap.fc +++ b/recipes-security/refpolicy/refpolicy-mcs/policy/modules/services/blktap.fc @@ -24,6 +24,7 @@ /usr/sbin/tap-ctl -- gen_context(system_u:object_r:tapctl_exec_t,s0) /dev/xen/control -c gen_context(system_u:object_r:xen_device_t,s0) /dev/blktap-control -c gen_context(system_u:object_r:blktap_device_t,s0) +/dev/blktap/control -c gen_context(system_u:object_r:blktap_device_t,s0) /dev/shm/metrics(/.*)? gen_context(system_u:object_r:tapdisk_tmpfs_t,s0) /dev/shm/td3-[0-9]+-[0-9]+(/.*)? gen_context(system_u:object_r:tapdisk_tmpfs_t,s0) /dev/shm/vbd3-[0-9]+-[0-9]+(/.*)? gen_context(system_u:object_r:tapdisk_tmpfs_t,s0) From 90c474d4e8c45e3cc642c85b3fbeaec54581d2c5 Mon Sep 17 00:00:00 2001 From: Jason Andryuk Date: Wed, 6 Dec 2023 08:02:14 -0500 Subject: [PATCH 2/6] Revert "dom0-image: Remove tapback" tapback is making a comeback! We'll run it in dom0 to directly provide the tapdisk backends. This reverts commit 7151b14c45782901a9b31dc897228a4eb6be44ad. Signed-off-by: Jason Andryuk --- recipes-core/packagegroups/packagegroup-xenclient-dom0.bb | 1 + 1 file changed, 1 insertion(+) diff --git a/recipes-core/packagegroups/packagegroup-xenclient-dom0.bb b/recipes-core/packagegroups/packagegroup-xenclient-dom0.bb index d86e8c306c..a022d51378 100644 --- a/recipes-core/packagegroups/packagegroup-xenclient-dom0.bb +++ b/recipes-core/packagegroups/packagegroup-xenclient-dom0.bb @@ -105,6 +105,7 @@ RDEPENDS_${PN} = " \ tpm2-tss \ tpm2-tools \ blktap3 \ + tapback \ pesign \ ipxe \ udev-extraconf-dom0 \ From 1d8cee0e0023ca81af1239906f47a4eb92249610 Mon Sep 17 00:00:00 2001 From: Jason Andryuk Date: Thu, 4 Jan 2024 12:24:24 -0500 Subject: [PATCH 3/6] blktap3: Upstream libxl compatibility Add patches for libxl compatibility. Pass --libxl flag to tapback for compatibility mode. Signed-off-by: Jason Andryuk --- recipes-extended/xen/blktap3.bb | 3 + ...pback-Add-l-libxl-compatibility-mode.patch | 125 ++++++++++++++++++ ...ack-Move-backend-to-InitWait-earlier.patch | 86 ++++++++++++ ...emove-xenstore-backend-in-libxl-mode.patch | 52 ++++++++ ...fix-run-time-errors-and-memory-leaks.patch | 53 -------- .../xen/blktap3/tapback.initscript | 2 +- 6 files changed, 267 insertions(+), 54 deletions(-) create mode 100644 recipes-extended/xen/blktap3/0001-tapback-Add-l-libxl-compatibility-mode.patch create mode 100644 recipes-extended/xen/blktap3/0002-tapback-Move-backend-to-InitWait-earlier.patch create mode 100644 recipes-extended/xen/blktap3/0003-tapback-Don-t-remove-xenstore-backend-in-libxl-mode.patch diff --git a/recipes-extended/xen/blktap3.bb b/recipes-extended/xen/blktap3.bb index f21ca4095d..5fa400740e 100644 --- a/recipes-extended/xen/blktap3.bb +++ b/recipes-extended/xen/blktap3.bb @@ -26,6 +26,9 @@ SRC_URI = "git://github.com/xapi-project/blktap.git;protocol=https \ file://gcc9-compilation.patch \ file://openssl-1.1.x.patch \ file://0001-tap-ctl-Default-to-read-only-opening.patch \ + file://0001-tapback-Add-l-libxl-compatibility-mode.patch \ + file://0002-tapback-Move-backend-to-InitWait-earlier.patch \ + file://0003-tapback-Don-t-remove-xenstore-backend-in-libxl-mode.patch \ " S = "${WORKDIR}/git" diff --git a/recipes-extended/xen/blktap3/0001-tapback-Add-l-libxl-compatibility-mode.patch b/recipes-extended/xen/blktap3/0001-tapback-Add-l-libxl-compatibility-mode.patch new file mode 100644 index 0000000000..97e0576e26 --- /dev/null +++ b/recipes-extended/xen/blktap3/0001-tapback-Add-l-libxl-compatibility-mode.patch @@ -0,0 +1,125 @@ +From 63f3883abe1f94a85428e17e98fe0dbe15606b0b Mon Sep 17 00:00:00 2001 +From: Jason Andryuk +Date: Thu, 25 Jan 2024 08:22:55 -0500 +Subject: [PATCH 1/3] tapback: Add -l/--libxl compatibility mode + +libxl and xapi/xenopsd have different ordering requirements, and the +libxl required changes are not readily compatible with xapi. + +Add a flag to allow running in libxl compatibility mode to bodge around +the issue. The flag has to be passed from the parent tapback process +into the per-domain ones to ensure it is respected. + +Some nearby hard tabs are converted to spaces. + +Signed-off-by: Jason Andryuk +--- + tapback/backend.c | 8 +++++--- + tapback/tapback.c | 17 ++++++++++++++--- + tapback/tapback.h | 10 ++++++++++ + 3 files changed, 29 insertions(+), 6 deletions(-) + +diff --git a/tapback/backend.c b/tapback/backend.c +index facae9b..cb607b1 100644 +--- a/tapback/backend.c ++++ b/tapback/backend.c +@@ -1197,7 +1197,7 @@ tapback_backend_handle_backend_watch(backend_t *backend, + * FIXME Shall we watch the child process? + */ + } else { /* child */ +- char *args[7]; ++ char *args[8]; + int i = 0; + + args[i++] = (char*)tapback_name; +@@ -1211,8 +1211,10 @@ tapback_backend_handle_backend_watch(backend_t *backend, + } + if (log_level == LOG_DEBUG) + args[i++] = "-v"; +- if (!backend->barrier) +- args[i++] = "-b"; ++ if (!backend->barrier) ++ args[i++] = "-b"; ++ if (libxl_mode()) ++ args[i++] = "--libxl"; + args[i] = NULL; + /* + * TODO we're hard-coding the name of the binary, better let +diff --git a/tapback/tapback.c b/tapback/tapback.c +index fe04d17..6a3098f 100644 +--- a/tapback/tapback.c ++++ b/tapback/tapback.c +@@ -58,6 +58,7 @@ + const char tapback_name[] = "tapback"; + unsigned log_level; + int tapdev_major; ++static bool opt_libxl_mode; + + struct list_head backends = LIST_HEAD_INIT(backends); + +@@ -77,6 +78,12 @@ char *xenbus_strstate(const XenbusState xbs) + return str[xbs]; + } + ++bool ++libxl_mode(void) ++{ ++ return opt_libxl_mode; ++} ++ + /** + * Read changes that occurred on the "backend/" XenStore path + * or one of the front-end paths and act accordingly. +@@ -513,7 +520,8 @@ usage(FILE * const stream, const char * const prog) + "\t[-h|--help]\n" + "\t[-v|--verbose]\n" + "\t[-b]--nobarrier]\n" +- "\t[-n|--name]\n", prog); ++ "\t[-n|--name]\n" ++ "\t[-l|--libxl]\n", prog); + } + + extern char *optarg; +@@ -612,8 +620,8 @@ int main(int argc, char **argv) + {"name", 0, NULL, 'n'}, + {"pidfile", 0, NULL, 'p'}, + {"domain", 0, NULL, 'x'}, +- {"nobarrier", 0, NULL, 'b'}, +- ++ {"nobarrier", 0, NULL, 'b'}, ++ {"libxl", 0, NULL, 'l'}, + }; + int c; + +@@ -628,6 +636,9 @@ int main(int argc, char **argv) + case 'd': + opt_debug = true; + break; ++ case 'l': ++ opt_libxl_mode = true; ++ break; + case 'v': + opt_verbose = true; + break; +diff --git a/tapback/tapback.h b/tapback/tapback.h +index 9bde55d..f106f25 100644 +--- a/tapback/tapback.h ++++ b/tapback/tapback.h +@@ -524,4 +524,14 @@ tapback_backend_destroy(backend_t *backend); + + bool verbose(void); + ++/** ++ * Indicates when tapback is running in libxl compatibility mode. libxl needs ++ * backends to transition to InitWait earlier than xapi/xenopds. ++ * ++ * Returns true if tapback is running in libxl compatibility mode and false ++ * otherwise. ++ */ ++bool ++libxl_mode(void); ++ + #endif /* __TAPBACK_H__ */ +-- +2.43.0 + diff --git a/recipes-extended/xen/blktap3/0002-tapback-Move-backend-to-InitWait-earlier.patch b/recipes-extended/xen/blktap3/0002-tapback-Move-backend-to-InitWait-earlier.patch new file mode 100644 index 0000000000..fb48ac3976 --- /dev/null +++ b/recipes-extended/xen/blktap3/0002-tapback-Move-backend-to-InitWait-earlier.patch @@ -0,0 +1,86 @@ +From 726cdd1e45ed155af48b9b433492a0e427256b65 Mon Sep 17 00:00:00 2001 +From: Jason Andryuk +Date: Fri, 8 Dec 2023 13:17:20 -0500 +Subject: [PATCH 2/3] tapback: Move backend to InitWait earlier + +This is needed for libxl integration. + +tapdisk waits to transition to InitWait until after "hotplug-status" is +connected. However libxl doesn't run its hotplug scripts, which write +"hotplug-status", until the backend transitions to InitWait. With both +sides waiting, progress is not made and connecting the blktap device +times out and fails. + +Make tapback transition to InitWait earlier to resolve this issue under +libxl. Place the transition to InitWait in +tapback_backend_create_device() after the xenstore feature nodes have +been written. InitWait is a signal to the frontend that such nodes have +been written. This matches blkback's behaviour. It should also be fine +since tapback still won't advance to Connected without the other setup +like physical-device-path and hotplug-status. + +VBDs can be reconnected. When pv-grub is used, it connects the VBD, +loads the kernel, disconnects the VBD. It then re-sets the frontend +state to XenbusStateInitialising so that the new kernel will find and +connect the VBD. + +tapback and blkback handle this case differently. When blkback observes +the frontend transition to XenbusStateInitialising, and the backend is +XenbusStateClosed, the backend transitions to XenbusStateInitWait. + +When tapback observes the frontend transition to +XenbusStateInitialising, the backend checks for hotplug_status_connected +to be true before switching XenbusStateInitWait. For tapback, this +serves a second purpose for setting XenbusStateInitWait initially as +well. + +Use libxl_mode() to determine whether to transition to InitWait sooner. +Leave the hotplug_status_connected check since that should work fine for +either even through it may be an extra watch firing for libxl. + +Signed-off-by: Jason Andryuk +--- + tapback/backend.c | 11 +++++++++++ + tapback/frontend.c | 4 ++-- + 2 files changed, 13 insertions(+), 2 deletions(-) + +diff --git a/tapback/backend.c b/tapback/backend.c +index cb607b1..0494f15 100644 +--- a/tapback/backend.c ++++ b/tapback/backend.c +@@ -259,6 +259,17 @@ tapback_backend_create_device(backend_t *backend, + goto out; + } + ++ if (libxl_mode()) { ++ /* In libxl_mode, after tapback has written it's capabilities to ++ * XenStore, switch to InitWait. */ ++ err = xenbus_switch_state(device, XenbusStateInitWait); ++ if (unlikely(err)) { ++ WARN(device, "failed to switch to XenbusStateInitWait: %s\n", ++ strerror(-err)); ++ goto out; ++ } ++ } ++ + out: + if (err) { + WARN(NULL, "%s: error creating device: %s\n", name, strerror(-err)); +diff --git a/tapback/frontend.c b/tapback/frontend.c +index e086813..1b68d88 100644 +--- a/tapback/frontend.c ++++ b/tapback/frontend.c +@@ -439,8 +439,8 @@ frontend_changed(vbd_t * const device, const XenbusState state) + + switch (state) { + case XenbusStateInitialising: +- if (device->hotplug_status_connected) +- err = xenbus_switch_state(device, XenbusStateInitWait); ++ if (device->hotplug_status_connected) ++ err = xenbus_switch_state(device, XenbusStateInitWait); + break; + case XenbusStateInitialised: + case XenbusStateConnected: +-- +2.43.0 + diff --git a/recipes-extended/xen/blktap3/0003-tapback-Don-t-remove-xenstore-backend-in-libxl-mode.patch b/recipes-extended/xen/blktap3/0003-tapback-Don-t-remove-xenstore-backend-in-libxl-mode.patch new file mode 100644 index 0000000000..89ec0a0dd0 --- /dev/null +++ b/recipes-extended/xen/blktap3/0003-tapback-Don-t-remove-xenstore-backend-in-libxl-mode.patch @@ -0,0 +1,52 @@ +From adaffa0a7dab4984570e72c49366a08474bc6f2e Mon Sep 17 00:00:00 2001 +From: Jason Andryuk +Date: Thu, 25 Jan 2024 08:31:57 -0500 +Subject: [PATCH 3/3] tapback: Don't remove xenstore backend in libxl mode + +libxl doesn't clean up tapdisks because it doesn't call the hotplug +cleanup scripts: +libxl: debug: libxl_event.c:1043:devstate_callback: backend /local/domain/0/backend/vbd3/5/2048/state wanted state 6 but it was removed +libxl: debug: libxl_event.c:849:libxl__ev_xswatch_deregister: watch w=0xf82ba0 wpath=/local/domain/0/backend/vbd3/5/2048/state token=1/2: deregister slotnum=1 +libxl: debug: libxl_device.c:1156:device_backend_callback: Domain 5:calling device_backend_cleanup +libxl: debug: libxl_event.c:863:libxl__ev_xswatch_deregister: watch w=0xf82ba0: deregister unregistered +libxl: error: libxl_device.c:1169:device_backend_callback: Domain 5:unable to remove device with path /local/domain/0/backend/vbd3/5/2048 - rc -6 + +The backend state cannot be found because tapback deleted the entire +backend subtree. + +In libxl mode, tapback shouldn't remove the backend nodes when the +frontend is removed, because the nodes contain the information on how to +clean up. Leave the nodes and allowed them to be removed by the +toolstack. + +Signed-off-by: Jason Andryuk +--- + tapback/frontend.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/tapback/frontend.c b/tapback/frontend.c +index 1b68d88..d5db62b 100644 +--- a/tapback/frontend.c ++++ b/tapback/frontend.c +@@ -508,7 +508,7 @@ tapback_backend_handle_otherend_watch(backend_t *backend, + */ + s = tapback_xs_read(device->backend->xs, XBT_NULL, "%s", + device->frontend_state_path); +- if (!s) { ++ if (!s && !libxl_mode()) { + err = errno; + /* + * If the front-end XenBus node is missing, the XenBus device has been +@@ -531,6 +531,9 @@ tapback_backend_handle_otherend_watch(backend_t *backend, + } + } + } ++ } else if (!s && libxl_mode()) { ++ WARN(device, "frontend disappeared!"); ++ err = ENOENT; + } else { + state = strtol(s, &end, 0); + if (*end != 0 || end == s) { +-- +2.43.0 + diff --git a/recipes-extended/xen/blktap3/fix-run-time-errors-and-memory-leaks.patch b/recipes-extended/xen/blktap3/fix-run-time-errors-and-memory-leaks.patch index 9285c58ca1..38ed293d6f 100644 --- a/recipes-extended/xen/blktap3/fix-run-time-errors-and-memory-leaks.patch +++ b/recipes-extended/xen/blktap3/fix-run-time-errors-and-memory-leaks.patch @@ -83,59 +83,6 @@ PATCHES if (ret <= 0) { err = errno; break; ---- a/tapback/frontend.c -+++ b/tapback/frontend.c -@@ -477,7 +477,7 @@ tapback_backend_handle_otherend_watch(ba - { - vbd_t *device = NULL; - int err = 0, state = 0; -- char *s = NULL, *end = NULL, *_path = NULL; -+ char *s = NULL, *end = NULL; - - ASSERT(backend); - ASSERT(path); -@@ -508,30 +508,7 @@ tapback_backend_handle_otherend_watch(ba - */ - s = tapback_xs_read(device->backend->xs, XBT_NULL, "%s", - device->frontend_state_path); -- if (!s) { -- err = errno; -- /* -- * If the front-end XenBus node is missing, the XenBus device has been -- * removed: remove the XenBus back-end node. -- */ -- if (err == ENOENT) { -- err = asprintf(&_path, "%s/%s/%d/%d", XENSTORE_BACKEND, -- device->backend->name, device->domid, device->devid); -- if (err == -1) { -- err = errno; -- WARN(device, "failed to asprintf: %s\n", strerror(err)); -- goto out; -- } -- err = 0; -- if (!xs_rm(device->backend->xs, XBT_NULL, _path)) { -- if (errno != ENOENT) { -- err = errno; -- WARN(device, "failed to remove %s: %s\n", path, -- strerror(err)); -- } -- } -- } -- } else { -+ if(s) { - state = strtol(s, &end, 0); - if (*end != 0 || end == s) { - WARN(device, "invalid XenBus state '%s'\n", s); -@@ -540,9 +517,7 @@ tapback_backend_handle_otherend_watch(ba - err = frontend_changed(device, state); - } - --out: - free(s); -- free(_path); - return err; - } - --- a/tapback/tapback.c +++ b/tapback/tapback.c @@ -171,6 +171,7 @@ tapback_backend_destroy(backend_t *backe diff --git a/recipes-extended/xen/blktap3/tapback.initscript b/recipes-extended/xen/blktap3/tapback.initscript index 6e5437a07e..0b9e9a94ec 100644 --- a/recipes-extended/xen/blktap3/tapback.initscript +++ b/recipes-extended/xen/blktap3/tapback.initscript @@ -29,7 +29,7 @@ DESC="Tapback" EXEC=/usr/bin/tapback PIDFILE="/var/run/tapback.pid" -OPTS="-p $PIDFILE" +OPTS="-p $PIDFILE --libxl" do_start() { start-stop-daemon --start --quiet --oknodo --pidfile "$PIDFILE" \ From a00ddb2fb51c1fac2a249002a2b7181715a07c78 Mon Sep 17 00:00:00 2001 From: Jason Andryuk Date: Thu, 4 Jan 2024 12:26:04 -0500 Subject: [PATCH 4/6] xen-tools: libxl vbd3 support Add patches for libxl to directly support vbd3 without going through blkback. Signed-off-by: Jason Andryuk --- ...ck-common-Fix-same_vm-for-no-targets.patch | 56 +++++ ...02-libxl-Add-support-for-blktap-vbd3.patch | 189 +++++++++++++++ .../files/0003-hotplug-Update-block-tap.patch | 224 ++++++++++++++++++ ...Support-blktap-with-HVM-device-model.patch | 67 ++++++ ...0005-libxl-Switch-to-ndb-unix-format.patch | 29 +++ .../xen/files/libxl-vwif-support.patch | 16 +- recipes-extended/xen/xen-common.inc | 7 + 7 files changed, 580 insertions(+), 8 deletions(-) create mode 100644 recipes-extended/xen/files/0001-block-common-Fix-same_vm-for-no-targets.patch create mode 100644 recipes-extended/xen/files/0002-libxl-Add-support-for-blktap-vbd3.patch create mode 100644 recipes-extended/xen/files/0003-hotplug-Update-block-tap.patch create mode 100644 recipes-extended/xen/files/0004-libxl-Support-blktap-with-HVM-device-model.patch create mode 100644 recipes-extended/xen/files/0005-libxl-Switch-to-ndb-unix-format.patch diff --git a/recipes-extended/xen/files/0001-block-common-Fix-same_vm-for-no-targets.patch b/recipes-extended/xen/files/0001-block-common-Fix-same_vm-for-no-targets.patch new file mode 100644 index 0000000000..7a53f4ddf3 --- /dev/null +++ b/recipes-extended/xen/files/0001-block-common-Fix-same_vm-for-no-targets.patch @@ -0,0 +1,56 @@ +From 1eb266d3ac6df915a0fa2fb6e86d8f8cd1328ec9 Mon Sep 17 00:00:00 2001 +From: Jason Andryuk +Date: Thu, 21 Dec 2023 15:42:57 -0500 +Subject: [PATCH 1/5] block-common: Fix same_vm for no targets + +same_vm is broken when the two main domains do not have targets. otvm +and targetvm are both missing, which means they get set to -1 and then +converted to empty strings: + +++10697+ local targetvm=-1 +++10697+ local otvm=-1 +++10697+ otvm= +++10697+ othervm=/vm/cc97bc2f-3a91-43f7-8fbc-4cb92f90b4e4 +++10697+ targetvm= +++10697+ local frontend_uuid=/vm/844dea4e-44f8-4e3e-8145-325132a31ca5 + +The final comparison returns true since the two empty strings match: + +++10697+ '[' /vm/844dea4e-44f8-4e3e-8145-325132a31ca5 = /vm/cc97bc2f-3a91-43f7-8fbc-4cb92f90b4e4 -o '' = /vm/cc97bc2f-3a91-43f7-8fbc-4cb92f90b4e4 -o /vm/844dea4e-44f8-4e3e-8145-325132a31ca5 = '' -o '' = '' ']' + +Replace -1 with distinct strings indicating the lack of a value and +remove the collescing to empty stings. The strings themselves will no +longer match, and that is correct. + +++12364+ '[' /vm/844dea4e-44f8-4e3e-8145-325132a31ca5 = /vm/cc97bc2f-3a91-43f7-8fbc-4cb92f90b4e4 -o 'No target' = /vm/cc97bc2f-3a91-43f7-8fbc-4cb92f90b4e4 -o /vm/844dea4e-44f8-4e3e-8145-325132a31ca5 = 'No other target' -o 'No target' = 'No other target' ']' + +Signed-off-by: Jason Andryuk +--- + tools/hotplug/Linux/block-common.sh | 8 +++----- + 1 file changed, 3 insertions(+), 5 deletions(-) + +diff --git a/tools/hotplug/Linux/block-common.sh b/tools/hotplug/Linux/block-common.sh +index f86a88c4eb..5c80237d99 100644 +--- a/tools/hotplug/Linux/block-common.sh ++++ b/tools/hotplug/Linux/block-common.sh +@@ -112,14 +112,12 @@ same_vm() + "$FRONTEND_UUID") + local target=$(xenstore_read_default "/local/domain/$FRONTEND_ID/target" \ + "-1") +- local targetvm=$(xenstore_read_default "/local/domain/$target/vm" "-1") ++ local targetvm=$(xenstore_read_default "/local/domain/$target/vm" "No Target") + local otarget=$(xenstore_read_default "/local/domain/$otherdom/target" \ + "-1") + local otvm=$(xenstore_read_default "/local/domain/$otarget/vm" \ +- "-1") +- otvm=${otvm%-1} +- othervm=${othervm%-1} +- targetvm=${targetvm%-1} ++ "No Other Target") ++ + local frontend_uuid=${FRONTEND_UUID%-1} + + [ "$frontend_uuid" = "$othervm" -o "$targetvm" = "$othervm" -o \ +-- +2.43.0 + diff --git a/recipes-extended/xen/files/0002-libxl-Add-support-for-blktap-vbd3.patch b/recipes-extended/xen/files/0002-libxl-Add-support-for-blktap-vbd3.patch new file mode 100644 index 0000000000..1e69240da3 --- /dev/null +++ b/recipes-extended/xen/files/0002-libxl-Add-support-for-blktap-vbd3.patch @@ -0,0 +1,189 @@ +From ab11447309a175fbad3c38930e145a63001c8c9c Mon Sep 17 00:00:00 2001 +From: Jason Andryuk +Date: Fri, 21 Apr 2023 12:41:09 -0400 +Subject: [PATCH 2/5] libxl: Add support for blktap vbd3 + +This patch re-introduces blktap support to libxl. Unlike earlier +versions, it does not link against any blktap library. libxl changes +are needed to write to the vbd3 backend XenStore nodes. + +blktap has three components. tapdisk is a daemon implementing the disk +IO, NBD (Network Block Device), and Xen PV interfaces. tap-ctl is a +tool to control tapdisks - creating, starting, stopping and freeing. +tapback manages the XenStore operations and instructs tapdisk to +connect. + +It is notable that tapdisk performs the grant and event channel ops, but +doesn't interact with XenStore. tapback performs XenStore operations +and notifies tapdisks of values and changes. + +The flow is: libxl writes to the "vbd3" XenStore nodes and runs the +block-tap script. The block-tap script runs tap-ctl to create a tapdisk +instance as the physical device. tapback then sees the tapdisk and +instructs the tapdisk to connect up the PV blkif interface. + +This is expected to work without the kernel blktap driver, so the +block-tap script is modified accordingly to write the UNIX NBD path. + +backendtype=tap was not fully removed previously, but it would never +succeed since it would hit the hardcoded error in disk_try_backend(). +It is reused now. + +An example command to attach a vhd: +xl block-attach vm 'vdev=xvdf,backendtype=tap,format=vhd,target=/srv/target.vhd' + +Format raw also works to run an "aio:" tapdisk. + +Signed-off-by: Jason Andryuk +--- +VHD support is important for OpenXT since there are lots of existing +VHDs which still need supporting. tapdisk also supports encrypting VHDs +which is not available in QEMU. +--- + docs/man/xl-disk-configuration.5.pod.in | 4 +++- + tools/libs/light/libxl_device.c | 14 ++++++++++---- + tools/libs/light/libxl_disk.c | 20 +++++++++++++++----- + tools/libs/light/libxl_linux.c | 1 + + tools/libs/light/libxl_types_internal.idl | 1 + + tools/libs/light/libxl_utils.c | 2 ++ + 6 files changed, 32 insertions(+), 10 deletions(-) + +diff --git a/docs/man/xl-disk-configuration.5.pod.in b/docs/man/xl-disk-configuration.5.pod.in +index bc945cc517..cb442bd5b4 100644 +--- a/docs/man/xl-disk-configuration.5.pod.in ++++ b/docs/man/xl-disk-configuration.5.pod.in +@@ -232,7 +232,7 @@ Specifies the backend implementation to use + + =item Supported values + +-phy, qdisk, standalone ++phy, qdisk, standalone, tap + + =item Mandatory + +@@ -254,6 +254,8 @@ and "standalone" does not support specifications other than "virtio". + Normally this option should not be specified, in which case libxl will + automatically determine the most suitable backend. + ++"tap" needs blktap's tapback to be running. ++ + + =item B