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>
action = "ignore";
}
- if ((device = virJSONValueObjectGetString(data, "device")) == NULL)
+ if ((device = virJSONValueObjectGetString(data, "device")) == NULL) {
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");
virObjectLock(vm);
priv = QEMU_DOMAIN_PRIVATE(vm);
- if (*diskAlias == '\0')
- diskAlias = NULL;
-
if (diskAlias)
disk = qemuProcessFindDomainDiskByAliasOrQOM(vm, diskAlias, NULL);
else if (nodename)