Use the 'node-name' provided in the event if 'device' is empty to look
up the disk.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_monitor.c | 3 ++-
src/qemu/qemu_monitor.h | 2 ++
src/qemu/qemu_monitor_json.c | 5 ++++-
src/qemu/qemu_process.c | 12 +++++++++++-
4 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index cdfcbcea0b..49dc478f5b 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -1421,6 +1421,7 @@ qemuMonitorEmitWatchdog(qemuMonitorPtr mon, int action)
int
qemuMonitorEmitIOError(qemuMonitorPtr mon,
const char *diskAlias,
+ const char *nodename,
int action,
const char *reason)
{
@@ -1428,7 +1429,7 @@ qemuMonitorEmitIOError(qemuMonitorPtr mon,
VIR_DEBUG("mon=%p", mon);
QEMU_MONITOR_CALLBACK(mon, ret, domainIOError, mon->vm,
- diskAlias, action, reason);
+ diskAlias, nodename, action, reason);
return ret;
}
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 1c66459e69..70854497b2 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -155,6 +155,7 @@ typedef int (*qemuMonitorDomainWatchdogCallback)(qemuMonitorPtr mon,
typedef int (*qemuMonitorDomainIOErrorCallback)(qemuMonitorPtr mon,
virDomainObjPtr vm,
const char *diskAlias,
+ const char *nodename,
int action,
const char *reason,
void *opaque);
@@ -383,6 +384,7 @@ int qemuMonitorEmitRTCChange(qemuMonitorPtr mon, long long offset);
int qemuMonitorEmitWatchdog(qemuMonitorPtr mon, int action);
int qemuMonitorEmitIOError(qemuMonitorPtr mon,
const char *diskAlias,
+ const char *nodename,
int action,
const char *reason);
int qemuMonitorEmitGraphics(qemuMonitorPtr mon,
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 537cdfd19a..2b168d96c2 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -765,6 +765,7 @@ static void
qemuMonitorJSONHandleIOError(qemuMonitorPtr mon, virJSONValuePtr data)
{
const char *device;
+ const char *nodename;
const char *action;
const char *reason = "";
bool nospc = false;
@@ -782,6 +783,8 @@ qemuMonitorJSONHandleIOError(qemuMonitorPtr mon, virJSONValuePtr
data)
if ((device = virJSONValueObjectGetString(data, "device")) == NULL)
VIR_WARN("missing device in disk io error event");
+ nodename = virJSONValueObjectGetString(data, "node-name");
+
if (virJSONValueObjectGetBoolean(data, "nospace", &nospc) == 0
&& nospc)
reason = "enospc";
@@ -790,7 +793,7 @@ qemuMonitorJSONHandleIOError(qemuMonitorPtr mon, virJSONValuePtr
data)
actionID = VIR_DOMAIN_EVENT_IO_ERROR_NONE;
}
- qemuMonitorEmitIOError(mon, device, actionID, reason);
+ qemuMonitorEmitIOError(mon, device, nodename, actionID, reason);
}
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 40e2589b37..6e0b4b0027 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -855,6 +855,7 @@ static int
qemuProcessHandleIOError(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
virDomainObjPtr vm,
const char *diskAlias,
+ const char *nodename,
int action,
const char *reason,
void *opaque)
@@ -869,7 +870,16 @@ qemuProcessHandleIOError(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
virObjectLock(vm);
- disk = qemuProcessFindDomainDiskByAliasOrQOM(vm, diskAlias, NULL);
+
+ if (*diskAlias == '\0')
+ diskAlias = NULL;
+
+ if (diskAlias)
+ disk = qemuProcessFindDomainDiskByAliasOrQOM(vm, diskAlias, NULL);
+ else if (nodename)
+ disk = qemuDomainDiskLookupByNodename(vm->def, nodename, NULL, NULL);
+ else
+ disk = NULL;
if (disk) {
srcPath = virDomainDiskGetSource(disk);
--
2.16.2