For hotplug, we will need to know how many disks use given pr-manager so that we know if to plug it too (for the first usage) or unlpug it (for the last one). Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- src/qemu/qemu_domain.c | 26 ++++++++++++++++++++++++++ src/qemu/qemu_domain.h | 4 ++++ 2 files changed, 30 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 4079165f9..c327dfc86 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -11236,6 +11236,32 @@ qemuDomainDiskPRObjectKillAll(qemuDomainObjPrivatePtr priv) priv->prHelpers = NULL; } +size_t +qemuDomainGetPRUsageCount(const virDomainDef *def, + const char *prAlias) +{ + size_t used = 0; + size_t i; + + for (i = 0; i < def->ndisks; i++) { + const virDomainDiskDef *disk = def->disks[i]; + qemuDomainStorageSourcePrivatePtr srcPriv; + + if (!disk->src || + !disk->src->pr) + continue; + + srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src); + + if (STRNEQ(srcPriv->prAlias, prAlias)) + continue; + + used++; + } + + return used; +} + static int qemuDomainPrepareDiskPR(qemuDomainObjPrivatePtr priv, diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 5fdb5b931..231583256 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -1011,4 +1011,8 @@ qemuDomainDiskPRObjectRegister(qemuDomainObjPrivatePtr priv, void qemuDomainDiskPRObjectKillAll(qemuDomainObjPrivatePtr priv); +size_t +qemuDomainGetPRUsageCount(const virDomainDef *def, + const char *prAlias); + #endif /* __QEMU_DOMAIN_H__ */ -- 2.13.6 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list