Skip to content

Commit b34729a

Browse files
committed
hw/xen: Use xs_node_read() from xen_console_get_name()
Now that xs_node_read() can construct a node path, no need to open-code it. Signed-off-by: David Woodhouse <[email protected]> Reviewed-by: Anthony PERARD <[email protected]> Acked-by: Roger Pau Monné <[email protected]>
1 parent 76f26e4 commit b34729a

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

hw/char/xen_console.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -367,28 +367,28 @@ static char *xen_console_get_name(XenDevice *xendev, Error **errp)
367367

368368
if (con->dev == -1) {
369369
XenBus *xenbus = XEN_BUS(qdev_get_parent_bus(DEVICE(xendev)));
370-
char fe_path[XENSTORE_ABS_PATH_MAX + 1];
371370
int idx = (xen_mode == XEN_EMULATE) ? 0 : 1;
371+
Error *local_err = NULL;
372372
char *value;
373373

374374
/* Theoretically we could go up to INT_MAX here but that's overkill */
375375
while (idx < 100) {
376376
if (!idx) {
377-
snprintf(fe_path, sizeof(fe_path),
378-
"/local/domain/%u/console", xendev->frontend_id);
377+
value = xs_node_read(xenbus->xsh, XBT_NULL, NULL, &local_err,
378+
"/local/domain/%u/console",
379+
xendev->frontend_id);
379380
} else {
380-
snprintf(fe_path, sizeof(fe_path),
381-
"/local/domain/%u/device/console/%u",
382-
xendev->frontend_id, idx);
381+
value = xs_node_read(xenbus->xsh, XBT_NULL, NULL, &local_err,
382+
"/local/domain/%u/device/console/%u",
383+
xendev->frontend_id, idx);
383384
}
384-
value = qemu_xen_xs_read(xenbus->xsh, XBT_NULL, fe_path, NULL);
385385
if (!value) {
386386
if (errno == ENOENT) {
387387
con->dev = idx;
388+
error_free(local_err);
388389
goto found;
389390
}
390-
error_setg(errp, "cannot read %s: %s", fe_path,
391-
strerror(errno));
391+
error_propagate(errp, local_err);
392392
return NULL;
393393
}
394394
free(value);

0 commit comments

Comments
 (0)