mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemu: monitor: Unify and refactor 'PTY' case in qemuMonitorJSONAttachCharDev
Use qemuMonitorJSONGetReply and unify the two blocks with the same condition. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
80f1b8a5b0
commit
962ce78175
@ -6578,24 +6578,19 @@ qemuMonitorJSONAttachCharDev(qemuMonitor *mon,
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (chr->type == VIR_DOMAIN_CHR_TYPE_PTY) {
|
if (chr->type == VIR_DOMAIN_CHR_TYPE_PTY) {
|
||||||
if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0)
|
virJSONValue *data;
|
||||||
return -1;
|
|
||||||
} else {
|
|
||||||
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (chr->type == VIR_DOMAIN_CHR_TYPE_PTY) {
|
if (!(data = qemuMonitorJSONGetReply(cmd, reply, VIR_JSON_TYPE_OBJECT)))
|
||||||
virJSONValue *data = virJSONValueObjectGetObject(reply, "return");
|
return -1;
|
||||||
const char *path;
|
|
||||||
|
|
||||||
if (!(path = virJSONValueObjectGetString(data, "pty"))) {
|
if (!(chr->data.file.path = g_strdup(virJSONValueObjectGetString(data, "pty")))) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("chardev-add reply was missing pty path"));
|
_("chardev-add reply was missing pty path"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
chr->data.file.path = g_strdup(path);
|
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user