[PATCH 19/20] conf: Add some shmem helpers for future use

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
---
 src/conf/domain_conf.c   | 75 ++++++++++++++++++++++++++++++++++++++++++++++++
 src/conf/domain_conf.h   |  9 ++++++
 src/libvirt_private.syms |  5 ++++
 3 files changed, 89 insertions(+)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index eeb8238c6b2f..11c7c5dd1f34 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -14803,6 +14803,81 @@ virDomainRedirdevDefRemove(virDomainDefPtr def, size_t idx)
 }


+int
+virDomainShmemDefInsert(virDomainDefPtr def,
+                        virDomainShmemDefPtr shmem)
+{
+    return VIR_APPEND_ELEMENT(def->shmems, def->nshmems, shmem);
+}
+
+
+bool
+virDomainShmemDefEquals(virDomainShmemDefPtr src,
+                        virDomainShmemDefPtr dst)
+{
+    if (STRNEQ_NULLABLE(src->name, dst->name))
+        return false;
+
+    if (src->size != dst->size)
+        return false;
+
+    if (src->server.enabled != dst->server.enabled)
+        return false;
+
+    if (src->server.enabled) {
+        if (STRNEQ_NULLABLE(src->server.chr.data.nix.path,
+                            dst->server.chr.data.nix.path))
+            return false;
+    }
+
+    if (src->msi.enabled != dst->msi.enabled)
+        return false;
+
+    if (src->msi.enabled) {
+        if (src->msi.vectors != dst->msi.vectors)
+            return false;
+        if (src->msi.ioeventfd != dst->msi.ioeventfd)
+            return false;
+    }
+
+    if (src->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
+        !virDomainDeviceInfoAddressIsEqual(&src->info, &dst->info))
+        return false;
+
+    return true;
+}
+
+
+ssize_t
+virDomainShmemDefFind(virDomainDefPtr def,
+                      virDomainShmemDefPtr shmem)
+{
+    size_t i;
+
+    for (i = 0; i < def->nshmems; i++) {
+         if (virDomainShmemDefEquals(def->shmems[i], shmem))
+             break;
+    }
+
+    if (i < def->nshmems)
+        return i;
+
+    return -1;
+}
+
+
+virDomainShmemDefPtr
+virDomainShmemDefRemove(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 3013278458d8..ec2cc09979cc 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2985,6 +2985,15 @@ int virDomainMemoryFindInactiveByDef(virDomainDefPtr def,
                                      virDomainMemoryDefPtr mem)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;

+int virDomainShmemDefInsert(virDomainDefPtr def, virDomainShmemDefPtr shmem)
+    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
+bool virDomainShmemDefEquals(virDomainShmemDefPtr src, virDomainShmemDefPtr dst)
+    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
+ssize_t virDomainShmemDefFind(virDomainDefPtr def, virDomainShmemDefPtr shmem)
+    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
+virDomainShmemDefPtr virDomainShmemDefRemove(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 31020e6dc207..e804d27e36b9 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -454,6 +454,11 @@ virDomainSaveStatus;
 virDomainSaveXML;
 virDomainSeclabelTypeFromString;
 virDomainSeclabelTypeToString;
+virDomainShmemDefEquals;
+virDomainShmemDefFind;
+virDomainShmemDefFree;
+virDomainShmemDefInsert;
+virDomainShmemDefRemove;
 virDomainShmemModelTypeFromString;
 virDomainShmemModelTypeToString;
 virDomainShmemRoleTypeFromString;
-- 
2.10.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]