The helpers will be useful when implementing hotplug and coldplug of
shared memory devices.
Signed-off-by: Luyao Huang <lhuang(a)redhat.com>
---
src/conf/domain_conf.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++
src/conf/domain_conf.h | 7 +++++
src/libvirt_private.syms | 3 +++
3 files changed, 76 insertions(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 616bf80..cc2a767 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -13950,6 +13950,72 @@ virDomainMemoryRemove(virDomainDefPtr def,
}
+int
+virDomainShmemInsert(virDomainDefPtr def,
+ virDomainShmemDefPtr shmem)
+{
+ return VIR_APPEND_ELEMENT(def->shmems, def->nshmems, shmem);
+}
+
+
+ssize_t
+virDomainShmemFind(virDomainDefPtr def,
+ virDomainShmemDefPtr shmem,
+ bool fullmatch)
+{
+ size_t i;
+
+ for (i = 0; i < def->nshmems; i++) {
+ virDomainShmemDefPtr tmpshmem = def->shmems[i];
+
+ if (STREQ(shmem->name, tmpshmem->name)) {
+ if (!fullmatch)
+ return i;
+ } else {
+ continue;
+ }
+
+ if (shmem->size != tmpshmem->size)
+ continue;
+
+ if (shmem->server.enabled != tmpshmem->server.enabled ||
+ (shmem->server.enabled &&
+ STRNEQ_NULLABLE(shmem->server.chr.data.nix.path,
+ tmpshmem->server.chr.data.nix.path)))
+ continue;
+
+ if (shmem->msi.enabled != tmpshmem->msi.enabled ||
+ (shmem->msi.enabled &&
+ (shmem->msi.vectors != tmpshmem->msi.vectors ||
+ shmem->msi.ioeventfd != tmpshmem->msi.ioeventfd)))
+ continue;
+
+ if (shmem->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
+ !virDomainDeviceInfoAddressIsEqual(&shmem->info,
&tmpshmem->info))
+ continue;
+
+ break;
+ }
+
+ if (i < def->nshmems)
+ return i;
+
+ return -1;
+}
+
+
+virDomainShmemDefPtr
+virDomainShmemRemove(virDomainDefPtr def,
+ size_t idx)
+{
+ virDomainShmemDefPtr ret = def->shmems[idx];
+
+ VIR_DELETE_ELEMENT(def->shmems, idx, def->nshmems);
+
+ return ret;
+}
+
+
char *
virDomainDefGetDefaultEmulator(virDomainDefPtr def,
virCapsPtr caps)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 8d43ee6..ee76e3f 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -3012,6 +3012,13 @@ int virDomainMemoryFindInactiveByDef(virDomainDefPtr def,
virDomainMemoryDefPtr mem)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
+int virDomainShmemInsert(virDomainDefPtr def, virDomainShmemDefPtr shmem)
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
+ssize_t virDomainShmemFind(virDomainDefPtr def, virDomainShmemDefPtr shmem, bool
fullmatch)
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
+virDomainShmemDefPtr virDomainShmemRemove(virDomainDefPtr def, size_t idx)
+ ATTRIBUTE_NONNULL(1);
+
VIR_ENUM_DECL(virDomainTaint)
VIR_ENUM_DECL(virDomainVirt)
VIR_ENUM_DECL(virDomainBoot)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 7e60d87..88c2c53 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -451,6 +451,9 @@ virDomainSaveStatus;
virDomainSaveXML;
virDomainSeclabelTypeFromString;
virDomainSeclabelTypeToString;
+virDomainShmemFind;
+virDomainShmemInsert;
+virDomainShmemRemove;
virDomainShutdownReasonTypeFromString;
virDomainShutdownReasonTypeToString;
virDomainShutoffReasonTypeFromString;
--
1.8.3.1