[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 5/8] hw/xen: Use xs_node_read() from xen_netdev_get_name()
From: |
David Woodhouse |
Subject: |
[PULL 5/8] hw/xen: Use xs_node_read() from xen_netdev_get_name() |
Date: |
Thu, 16 Jan 2025 08:43:29 +0000 |
From: David Woodhouse <dwmw@amazon.co.uk>
Now that xs_node_read() can construct a node path, no need to open-code it.
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Anthony PERARD <anthony.perard@vates.tech>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
---
hw/net/xen_nic.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/hw/net/xen_nic.c b/hw/net/xen_nic.c
index 97ebd9fa30..5410039490 100644
--- a/hw/net/xen_nic.c
+++ b/hw/net/xen_nic.c
@@ -510,23 +510,22 @@ static char *xen_netdev_get_name(XenDevice *xendev, Error
**errp)
if (netdev->dev == -1) {
XenBus *xenbus = XEN_BUS(qdev_get_parent_bus(DEVICE(xendev)));
- char fe_path[XENSTORE_ABS_PATH_MAX + 1];
int idx = (xen_mode == XEN_EMULATE) ? 0 : 1;
+ Error *local_err = NULL;
char *value;
/* Theoretically we could go up to INT_MAX here but that's overkill */
while (idx < 100) {
- snprintf(fe_path, sizeof(fe_path),
- "/local/domain/%u/device/vif/%u",
- xendev->frontend_id, idx);
- value = qemu_xen_xs_read(xenbus->xsh, XBT_NULL, fe_path, NULL);
+ value = xs_node_read(xenbus->xsh, XBT_NULL, NULL, &local_err,
+ "/local/domain/%u/device/vif/%u",
+ xendev->frontend_id, idx);
if (!value) {
if (errno == ENOENT) {
netdev->dev = idx;
+ error_free(local_err);
goto found;
}
- error_setg(errp, "cannot read %s: %s", fe_path,
- strerror(errno));
+ error_propagate(errp, local_err);
return NULL;
}
free(value);
--
2.47.0
- [PULL 0/8] Xen regression fixes and cleanups, David Woodhouse, 2025/01/16
- [PULL 5/8] hw/xen: Use xs_node_read() from xen_netdev_get_name(),
David Woodhouse <=
- [PULL 7/8] hw/xen: Fix errp handling in xen_console, David Woodhouse, 2025/01/16
- [PULL 3/8] hw/xen: Use xs_node_read() from xs_node_vscanf(), David Woodhouse, 2025/01/16
- [PULL 8/8] system/runstate: Fix regression, clarify BQL status of exit notifiers, David Woodhouse, 2025/01/16
- [PULL 6/8] hw/xen: Use xs_node_read() from xenstore_read_str() instead of open-coding it, David Woodhouse, 2025/01/16
- [PULL 4/8] hw/xen: Use xs_node_read() from xen_console_get_name(), David Woodhouse, 2025/01/16
- [PULL 2/8] xen: do not use '%ms' scanf specifier, David Woodhouse, 2025/01/16
- [PULL 1/8] hw/xen: Add xs_node_read() helper function, David Woodhouse, 2025/01/16