ports/sysutils/xen-tools/files/qemuu-0002-xen-do-not-use-ms-scanf-specifier.patch
Roger Pau Monné 049a2dcbdb {emulators,sysutils}/xen-{kernel,tools}: update to 4.19.1.20250217
Update Xen packages, include QEMU fix to avoid using %ms scanf directive
which is not supported by FreeBSD libc.

Link: https://lore.kernel.org/xen-devel/20250107093140.86180-1-roger.pau@citrix.com/
Link: https://lists.freebsd.org/archives/freebsd-xen/2025-February/000227.html
Approved by: bapt (implicit)
Sponsored by: Cloud Software Group
2025-02-18 15:29:31 +01:00

88 lines
3.4 KiB
Diff

From 677a577b625045c6d02210ac91ff452f54812513 Mon Sep 17 00:00:00 2001
From: Roger Pau Monne <roger.pau@citrix.com>
Date: Fri, 10 Jan 2025 10:35:31 +0100
Subject: [PATCH 2/2] xen: do not use '%ms' scanf specifier
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The 'm' parameter used to request auto-allocation of the destination variable
is not supported on FreeBSD, and as such leads to failures to parse.
What's more, the current usage of '%ms' with xs_node_scanf() is pointless, as
it just leads to a double allocation of the same string. Instead use
xs_node_read() to read the whole xenstore node.
Fixes: a783f8ad4ec9 ('xen: add a mechanism to automatically create XenDevice-s...')
Fixes: 9b7737469080 ('hw/xen: update Xen console to XenDevice model')
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Anthony PERARD <anthony.perard@vates.tech>
---
hw/block/xen-block.c | 4 ++--
hw/xen/xen-bus.c | 14 ++++++++++++--
include/hw/xen/xen-bus.h | 1 +
3 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c
index 6ccb8a4a3219..dc389578f454 100644
--- a/hw/block/xen-block.c
+++ b/hw/block/xen-block.c
@@ -115,8 +115,8 @@ static void xen_block_connect(XenDevice *xendev, Error **errp)
return;
}
- if (xen_device_frontend_scanf(xendev, "protocol", "%ms",
- &str) != 1) {
+ str = xen_device_frontend_read(xendev, "protocol");
+ if (!str) {
protocol = BLKIF_PROTOCOL_NATIVE;
} else {
if (strcmp(str, XEN_IO_PROTO_ABI_X86_32) == 0) {
diff --git a/hw/xen/xen-bus.c b/hw/xen/xen-bus.c
index c59850b1dee7..8ff083167f47 100644
--- a/hw/xen/xen-bus.c
+++ b/hw/xen/xen-bus.c
@@ -154,8 +154,8 @@ again:
!strcmp(key[i], "hotplug-status"))
continue;
- if (xs_node_scanf(xenbus->xsh, tid, path, key[i], NULL, "%ms",
- &val) == 1) {
+ val = xs_node_read(xenbus->xsh, tid, NULL, NULL, "%s/%s", path, key[i]);
+ if (val) {
qdict_put_str(opts, key[i], val);
free(val);
}
@@ -644,6 +644,16 @@ int xen_device_frontend_scanf(XenDevice *xendev, const char *key,
return rc;
}
+char *xen_device_frontend_read(XenDevice *xendev, const char *key)
+{
+ XenBus *xenbus = XEN_BUS(qdev_get_parent_bus(DEVICE(xendev)));
+
+ g_assert(xenbus->xsh);
+
+ return xs_node_read(xenbus->xsh, XBT_NULL, NULL, NULL, "%s/%s",
+ xendev->frontend_path, key);
+}
+
static void xen_device_frontend_set_state(XenDevice *xendev,
enum xenbus_state state,
bool publish)
diff --git a/include/hw/xen/xen-bus.h b/include/hw/xen/xen-bus.h
index f43589816495..6bb199704440 100644
--- a/include/hw/xen/xen-bus.h
+++ b/include/hw/xen/xen-bus.h
@@ -89,6 +89,7 @@ void xen_device_frontend_printf(XenDevice *xendev, const char *key,
int xen_device_frontend_scanf(XenDevice *xendev, const char *key,
const char *fmt, ...)
G_GNUC_SCANF(3, 4);
+char *xen_device_frontend_read(XenDevice *xendev, const char *key);
void xen_device_set_max_grant_refs(XenDevice *xendev, unsigned int nr_refs,
Error **errp);
--
2.46.0