On 07/09/2015 02:09 PM, Martin Kletzander wrote:
On Thu, Jul 09, 2015 at 11:44:30AM +0800, lhuang wrote:
On 07/08/2015 08:14 PM, Martin Kletzander wrote:
On Wed, Jun 17, 2015 at 11:56:17AM +0800, Luyao Huang wrote:
The helpers will be useful when implementing hotplug and coldplug of
shared memory devices.
Signed-off-by: Luyao Huang <lhuang@xxxxxxxxxx>
---
src/conf/domain_conf.c | 61
++++++++++++++++++++++++++++++++++++++++++++++++
src/conf/domain_conf.h | 7 ++++++
src/libvirt_private.syms | 3 +++
3 files changed, 71 insertions(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 306b718..8a8e4f7 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -13343,6 +13343,67 @@ 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)
+{
+ size_t i;
+
+ for (i = 0; i < def->nshmems; i++) {
+ virDomainShmemDefPtr tmpshmem = def->shmems[i];
+
+ if (STRNEQ_NULLABLE(shmem->name, tmpshmem->name))
+ continue;
+
I think that you shouldn't be able to have two <shmem/> elements in
the same domain, and since the name is mandatory, STREQ() should be
enough to check whether you need to return current 'i'.
Okay, i agree use STREQ() instead of STRNEQ_NULLABLE. BTW I think one
guest could have more than one <shmem/> element, maybe one is
non-server shmem and another is server shmem, it depends on how to use
it.
Maybe this function could have a bool parameter (something like a
'full_match') that would say whether everything must match or the name
is enough. And it the bool is false, streq is enough, but if it's
true, you could abstract the internals of this for body into
virDomainShmemEquals() or something and that would be called instead.
Good idea, this way is okay to me.
Thanks a lot for your opinion.
Luyao
--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list