|
@@ -367,28 +367,28 @@ static char *xen_console_get_name(XenDevice *xendev, Error **errp)
|
|
|
|
|
|
if (con->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) {
|
|
|
if (!idx) {
|
|
|
- snprintf(fe_path, sizeof(fe_path),
|
|
|
- "/local/domain/%u/console", xendev->frontend_id);
|
|
|
+ value = xs_node_read(xenbus->xsh, XBT_NULL, NULL, &local_err,
|
|
|
+ "/local/domain/%u/console",
|
|
|
+ xendev->frontend_id);
|
|
|
} else {
|
|
|
- snprintf(fe_path, sizeof(fe_path),
|
|
|
- "/local/domain/%u/device/console/%u",
|
|
|
- xendev->frontend_id, idx);
|
|
|
+ value = xs_node_read(xenbus->xsh, XBT_NULL, NULL, &local_err,
|
|
|
+ "/local/domain/%u/device/console/%u",
|
|
|
+ xendev->frontend_id, idx);
|
|
|
}
|
|
|
- value = qemu_xen_xs_read(xenbus->xsh, XBT_NULL, fe_path, NULL);
|
|
|
if (!value) {
|
|
|
if (errno == ENOENT) {
|
|
|
con->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);
|
|
@@ -550,7 +550,8 @@ static void xen_console_device_create(XenBackendInstance *backend,
|
|
|
goto fail;
|
|
|
}
|
|
|
|
|
|
- if (xs_node_scanf(xsh, XBT_NULL, fe, "type", errp, "%ms", &type) != 1) {
|
|
|
+ type = xs_node_read(xsh, XBT_NULL, NULL, errp, "%s/%s", fe, "type");
|
|
|
+ if (!type) {
|
|
|
error_prepend(errp, "failed to read console device type: ");
|
|
|
goto fail;
|
|
|
}
|
|
@@ -568,7 +569,8 @@ 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) {
|
|
|
+ output = xs_node_read(xsh, XBT_NULL, NULL, errp, "%s/%s", fe, "output");
|
|
|
+ if (output) {
|
|
|
/*
|
|
|
* FIXME: sure we want to support implicit
|
|
|
* muxed monitors here?
|
|
@@ -579,19 +581,27 @@ static void xen_console_device_create(XenBackendInstance *backend,
|
|
|
output);
|
|
|
goto fail;
|
|
|
}
|
|
|
- } else if (number) {
|
|
|
- cd = serial_hd(number);
|
|
|
- if (!cd) {
|
|
|
- error_prepend(errp, "console: No serial device #%ld found: ",
|
|
|
- number);
|
|
|
- goto fail;
|
|
|
- }
|
|
|
+ } else if (errno != ENOENT) {
|
|
|
+ error_prepend(errp, "console: No valid chardev found: ");
|
|
|
+ goto fail;
|
|
|
} else {
|
|
|
- /* No 'output' node on primary console: use null. */
|
|
|
- cd = qemu_chr_new(label, "null", NULL);
|
|
|
- if (!cd) {
|
|
|
- error_setg(errp, "console: failed to create null device");
|
|
|
- goto fail;
|
|
|
+ error_free(*errp);
|
|
|
+ *errp = NULL;
|
|
|
+
|
|
|
+ if (number) {
|
|
|
+ cd = serial_hd(number);
|
|
|
+ if (!cd) {
|
|
|
+ error_setg(errp, "console: No serial device #%ld found",
|
|
|
+ number);
|
|
|
+ goto fail;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ /* No 'output' node on primary console: use null. */
|
|
|
+ cd = qemu_chr_new(label, "null", NULL);
|
|
|
+ if (!cd) {
|
|
|
+ error_setg(errp, "console: failed to create null device");
|
|
|
+ goto fail;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|