[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 2/2] xen: do not use '%ms' scanf specifier
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 qemu_xen_xs_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@xxxxxxxxxx> --- Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx> Cc: Anthony PERARD <anthony@xxxxxxxxxxxxxx> Cc: Paul Durrant <paul@xxxxxxx> Cc: "Edgar E. Iglesias" <edgar.iglesias@xxxxxxxxx> Cc: "Marc-André Lureau" <marcandre.lureau@xxxxxxxxxx> Cc: Paolo Bonzini <pbonzini@xxxxxxxxxx> Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx --- hw/char/xen_console.c | 11 +++++++++-- hw/xen/xen-bus.c | 7 +++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/hw/char/xen_console.c b/hw/char/xen_console.c index af706c7ef440..18afd214c2f6 100644 --- a/hw/char/xen_console.c +++ b/hw/char/xen_console.c @@ -531,6 +531,7 @@ static void xen_console_device_create(XenBackendInstance *backend, const char *name = xen_backend_get_name(backend); unsigned long number; char *fe = NULL, *type = NULL, *output = NULL; + const char *node_path; char label[32]; XenDevice *xendev = NULL; XenConsole *con; @@ -550,7 +551,10 @@ static void xen_console_device_create(XenBackendInstance *backend, goto fail; } - if (xs_node_scanf(xsh, XBT_NULL, fe, "type", errp, "%ms", &type) != 1) { + node_path = g_strdup_printf("%s/type", fe); + type = qemu_xen_xs_read(xsh, XBT_NULL, node_path, NULL); + g_free(node_path); + if (!type) { error_setg(errp, "failed to read console device type: "); goto fail; } @@ -568,7 +572,10 @@ static void xen_console_device_create(XenBackendInstance *backend, snprintf(label, sizeof(label), "xencons%ld", number); - if (xs_node_scanf(xsh, XBT_NULL, fe, "output", NULL, "%ms", &output) == 1) { + node_path = g_strdup_printf("%s/output", fe); + output = qemu_xen_xs_read(xsh, XBT_NULL, node_path, NULL); + g_free(node_path); + if (!output) { /* * FIXME: sure we want to support implicit * muxed monitors here? diff --git a/hw/xen/xen-bus.c b/hw/xen/xen-bus.c index adfc4efad035..9be807649e77 100644 --- a/hw/xen/xen-bus.c +++ b/hw/xen/xen-bus.c @@ -142,6 +142,7 @@ again: opts = qdict_new(); for (i = 0; i < n; i++) { + const char *node_path; char *val; /* @@ -156,8 +157,10 @@ again: !strcmp(key[i], "hotplug-status")) continue; - if (xs_node_scanf(xenbus->xsh, tid, path, key[i], NULL, "%ms", - &val) == 1) { + node_path = g_strdup_printf("%s/%s", path, key[i]); + val = qemu_xen_xs_read(xenbus->xsh, tid, node_path, NULL); + g_free(node_path); + if (val) { qdict_put_str(opts, key[i], val); free(val); } -- 2.46.0
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |