From 378bfb59a59c8b029c95f538fee46262a2c72116 Mon Sep 17 00:00:00 2001
Message-Id: <378bfb59a59c8b029c95f538fee46262a2c72116@dist-git>
From: Martin Kletzander <mkletzan@redhat.com>
Date: Fri, 4 Nov 2016 10:29:44 +0100
Subject: [PATCH] conf: Add some shmem helpers for future use
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
(cherry picked from commit e5568193f4d663f6a9edebcf9044d527f90a031f)
https://bugzilla.redhat.com/show_bug.cgi?id=1392031
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
---
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 415ab1c..57d5ec8 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -14831,6 +14831,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 c674796..594982e 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2955,6 +2955,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 5878360..9b7c26c 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -455,6 +455,11 @@ virDomainSaveStatus;
virDomainSaveXML;
virDomainSeclabelTypeFromString;
virDomainSeclabelTypeToString;
+virDomainShmemDefEquals;
+virDomainShmemDefFind;
+virDomainShmemDefFree;
+virDomainShmemDefInsert;
+virDomainShmemDefRemove;
virDomainShutdownReasonTypeFromString;
virDomainShutdownReasonTypeToString;
virDomainShutoffReasonTypeFromString;
--
2.10.2