Nodename may be asociated to a disk backup job, add support to looking
up in that chain too. This is specifically useful for the
BLOCK_WRITE_THRESHOLD event which can be registered for any nodename.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_domain.c | 12 ++++++++++++
src/qemu/qemu_domain.h | 1 +
src/qemu/qemu_process.c | 7 +++++--
3 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 44abe0ce93..7232b6131f 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -9896,6 +9896,7 @@ qemuDomainGetHostdevPath(virDomainHostdevDefPtr dev,
/**
* qemuDomainDiskLookupByNodename:
* @def: domain definition to look for the disk
+ * @backupdef: definition of the backup job of the domain (optional)
* @nodename: block backend node name to find
* @src: filled with the specific backing store element if provided
*
@@ -9905,6 +9906,7 @@ qemuDomainGetHostdevPath(virDomainHostdevDefPtr dev,
*/
virDomainDiskDefPtr
qemuDomainDiskLookupByNodename(virDomainDefPtr def,
+ virDomainBackupDefPtr backupdef,
const char *nodename,
virStorageSourcePtr *src)
{
@@ -9925,6 +9927,16 @@ qemuDomainDiskLookupByNodename(virDomainDefPtr def,
return domdisk;
}
+ if (backupdef) {
+ for (i = 0; i < backupdef->ndisks; i++) {
+ virDomainBackupDiskDefPtr backupdisk = backupdef->disks + i;
+
+ if (backupdisk->store &&
+ (*src = virStorageSourceFindByNodeName(backupdisk->store, nodename)))
+ return virDomainDiskByTarget(def, backupdisk->name);
+ }
+ }
+
return NULL;
}
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 9e870ff1e2..32f3586882 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -912,6 +912,7 @@ int qemuDomainGetHostdevPath(virDomainHostdevDefPtr dev,
int *perms);
virDomainDiskDefPtr qemuDomainDiskLookupByNodename(virDomainDefPtr def,
+ virDomainBackupDefPtr backupdef,
const char *nodename,
virStorageSourcePtr *src);
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 9d83825190..db77d8f1de 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -879,7 +879,7 @@ qemuProcessHandleIOError(qemuMonitorPtr mon G_GNUC_UNUSED,
if (diskAlias)
disk = qemuProcessFindDomainDiskByAliasOrQOM(vm, diskAlias, NULL);
else if (nodename)
- disk = qemuDomainDiskLookupByNodename(vm->def, nodename, NULL);
+ disk = qemuDomainDiskLookupByNodename(vm->def, NULL, nodename, NULL);
else
disk = NULL;
@@ -1483,6 +1483,7 @@ qemuProcessHandleBlockThreshold(qemuMonitorPtr mon G_GNUC_UNUSED,
unsigned long long excess,
void *opaque)
{
+ qemuDomainObjPrivatePtr priv;
virQEMUDriverPtr driver = opaque;
virObjectEventPtr eventSource = NULL;
virObjectEventPtr eventDevice = NULL;
@@ -1492,11 +1493,13 @@ qemuProcessHandleBlockThreshold(qemuMonitorPtr mon G_GNUC_UNUSED,
virObjectLock(vm);
+ priv = vm->privateData;
+
VIR_DEBUG("BLOCK_WRITE_THRESHOLD event for block node '%s' in domain %p
%s:"
"threshold '%llu' exceeded by '%llu'",
nodename, vm, vm->def->name, threshold, excess);
- if ((disk = qemuDomainDiskLookupByNodename(vm->def, nodename, &src))) {
+ if ((disk = qemuDomainDiskLookupByNodename(vm->def, priv->backup, nodename,
&src))) {
if (virStorageSourceIsLocalStorage(src))
path = src->path;
--
2.28.0