[PATCH 04/12] conf: introduce 3 functions for RNG device

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

 



the 3 functions are:
virDomainRNGInsert: Insert a RNG device to vm->def.
virDomainRNGRemove: remove a RNG device in vm->def.
virDomainRNGFind: find a RNG device in vm->def.

Signed-off-by: Luyao Huang <lhuang@xxxxxxxxxx>
---
 src/conf/domain_conf.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 src/conf/domain_conf.h |  9 +++++++++
 2 files changed, 53 insertions(+)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 91c114e..37c4569 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -11956,6 +11956,50 @@ virDomainRNGEquals(virDomainRNGDefPtr src,
     return false;
 }
 
+int
+virDomainRNGInsert(virDomainDefPtr vmdef,
+                   virDomainRNGDefPtr rng)
+{
+    return VIR_APPEND_ELEMENT(vmdef->rngs, vmdef->nrngs, rng);
+}
+
+virDomainRNGDefPtr
+virDomainRNGRemove(virDomainDefPtr vmdef,
+                   virDomainRNGDefPtr rng)
+{
+    virDomainRNGDefPtr ret;
+    size_t i;
+
+    for (i = 0; i < vmdef->nrngs; i++) {
+        ret = vmdef->rngs[i];
+
+        if (virDomainRNGEquals(ret, rng))
+            break;
+    }
+
+    if (i == vmdef->nrngs)
+        return NULL;
+
+    VIR_DELETE_ELEMENT(vmdef->rngs, i, vmdef->nrngs);
+    return ret;
+}
+
+virDomainRNGDefPtr
+virDomainRNGFind(virDomainDefPtr vmdef,
+                 virDomainRNGDefPtr rng)
+{
+    virDomainRNGDefPtr ret;
+    size_t i;
+
+    for (i = 0; i < vmdef->nrngs; i++) {
+        ret = vmdef->rngs[i];
+
+        if (virDomainRNGEquals(ret, rng))
+            return ret;
+    }
+    return NULL;
+}
+
 char *
 virDomainDefGetDefaultEmulator(virDomainDefPtr def,
                                virCapsPtr caps)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index c197095..cb87fad 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2600,6 +2600,15 @@ virDomainChrRemove(virDomainDefPtr vmdef,
 bool
 virDomainRNGEquals(virDomainRNGDefPtr src,
                    virDomainRNGDefPtr tgt);
+int
+virDomainRNGInsert(virDomainDefPtr vmdef,
+                   virDomainRNGDefPtr rng);
+virDomainRNGDefPtr
+virDomainRNGRemove(virDomainDefPtr vmdef,
+                   virDomainRNGDefPtr rng);
+virDomainRNGDefPtr
+virDomainRNGFind(virDomainDefPtr vmdef,
+                 virDomainRNGDefPtr rng);
 
 int virDomainSaveXML(const char *configDir,
                      virDomainDefPtr def,
-- 
1.8.3.1

--
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]