mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-06 11:49:29 +00:00
qemu: Handle quirks of 'device' field of BLOCK_IO_ERROR event in monitor code
BLOCK_IO_ERROR's 'device' field is an empty string in case when it isn't applicable as it was originally mandatory in the qemu API docs. Move the logic that convert's empty string back to NULL from 'qemuProcessHandleIOError()' to 'qemuMonitorJSONHandleIOError()' This also fixes a hypothetical NULL-dereference if qemu would indeed report an IO error without the 'device' field present. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
22e90a3b17
commit
2f8359f827
@ -708,8 +708,15 @@ qemuMonitorJSONHandleIOError(qemuMonitor *mon, virJSONValue *data)
|
|||||||
action = "ignore";
|
action = "ignore";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((device = virJSONValueObjectGetString(data, "device")) == NULL)
|
if ((device = virJSONValueObjectGetString(data, "device")) == NULL) {
|
||||||
VIR_WARN("missing device in disk io error event");
|
VIR_WARN("missing device in disk io error event");
|
||||||
|
} else {
|
||||||
|
/* 'device' was documented as mandatory in the qemu event, but later became
|
||||||
|
* optional, in which case an empty string is sent by qemu. Convert it back
|
||||||
|
* to NULL */
|
||||||
|
if (*device == '\0')
|
||||||
|
device = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
nodename = virJSONValueObjectGetString(data, "node-name");
|
nodename = virJSONValueObjectGetString(data, "node-name");
|
||||||
|
|
||||||
|
@ -840,9 +840,6 @@ qemuProcessHandleIOError(qemuMonitor *mon G_GNUC_UNUSED,
|
|||||||
virObjectLock(vm);
|
virObjectLock(vm);
|
||||||
priv = QEMU_DOMAIN_PRIVATE(vm);
|
priv = QEMU_DOMAIN_PRIVATE(vm);
|
||||||
|
|
||||||
if (*diskAlias == '\0')
|
|
||||||
diskAlias = NULL;
|
|
||||||
|
|
||||||
if (diskAlias)
|
if (diskAlias)
|
||||||
disk = qemuProcessFindDomainDiskByAliasOrQOM(vm, diskAlias, NULL);
|
disk = qemuProcessFindDomainDiskByAliasOrQOM(vm, diskAlias, NULL);
|
||||||
else if (nodename)
|
else if (nodename)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user