Skip to content

Commit e4e113e

Browse files
committed
hw/xen: Use xs_node_read() from xen_netdev_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 b34729a commit e4e113e

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

hw/net/xen_nic.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -510,23 +510,22 @@ static char *xen_netdev_get_name(XenDevice *xendev, Error **errp)
510510

511511
if (netdev->dev == -1) {
512512
XenBus *xenbus = XEN_BUS(qdev_get_parent_bus(DEVICE(xendev)));
513-
char fe_path[XENSTORE_ABS_PATH_MAX + 1];
514513
int idx = (xen_mode == XEN_EMULATE) ? 0 : 1;
514+
Error *local_err = NULL;
515515
char *value;
516516

517517
/* Theoretically we could go up to INT_MAX here but that's overkill */
518518
while (idx < 100) {
519-
snprintf(fe_path, sizeof(fe_path),
520-
"/local/domain/%u/device/vif/%u",
521-
xendev->frontend_id, idx);
522-
value = qemu_xen_xs_read(xenbus->xsh, XBT_NULL, fe_path, NULL);
519+
value = xs_node_read(xenbus->xsh, XBT_NULL, NULL, &local_err,
520+
"/local/domain/%u/device/vif/%u",
521+
xendev->frontend_id, idx);
523522
if (!value) {
524523
if (errno == ENOENT) {
525524
netdev->dev = idx;
525+
error_free(local_err);
526526
goto found;
527527
}
528-
error_setg(errp, "cannot read %s: %s", fe_path,
529-
strerror(errno));
528+
error_propagate(errp, local_err);
530529
return NULL;
531530
}
532531
free(value);

0 commit comments

Comments
 (0)