[PATCH v2 2/7] virDomainRedirdevDef: Introduce find & remove routines

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

 



Basically, there are just two functions introduced here:
virDomainRedirdevDefFind which looks up given redirdev in domain
definition, and virDomainRedirdevDefRemove which removes the
device at given index in the array of devices.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/conf/domain_conf.c   | 42 ++++++++++++++++++++++++++++++++++++++++++
 src/conf/domain_conf.h   |  4 ++++
 src/libvirt_private.syms |  2 ++
 3 files changed, 48 insertions(+)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c75279d..e0d10e9 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -14603,6 +14603,48 @@ virDomainMemoryRemove(virDomainDefPtr def,
 }
 
 
+ssize_t
+virDomainRedirdevDefFind(virDomainDefPtr def,
+                         virDomainRedirdevDefPtr redirdev)
+{
+    size_t i;
+
+    for (i = 0; i < def->nredirdevs; i++) {
+        virDomainRedirdevDefPtr tmp = def->redirdevs[i];
+
+        if (redirdev->bus != tmp->bus)
+            continue;
+
+        if (!virDomainChrSourceDefIsEqual(&redirdev->source.chr,
+                                          &tmp->source.chr))
+            continue;
+
+        if (redirdev->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
+            !virDomainDeviceInfoAddressIsEqual(&redirdev->info, &tmp->info))
+            continue;
+
+        if (redirdev->info.alias &&
+            STRNEQ_NULLABLE(redirdev->info.alias, tmp->info.alias))
+            continue;
+
+        return i;
+    }
+
+    return -1;
+}
+
+
+virDomainRedirdevDefPtr
+virDomainRedirdevDefRemove(virDomainDefPtr def, size_t idx)
+{
+    virDomainRedirdevDefPtr ret = def->redirdevs[idx];
+
+    VIR_DELETE_ELEMENT(def->redirdevs, idx, def->nredirdevs);
+
+    return ret;
+}
+
+
 char *
 virDomainDefGetDefaultEmulator(virDomainDefPtr def,
                                virCapsPtr caps)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 3792562..c1b002a 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2827,6 +2827,10 @@ virDomainChrRemove(virDomainDefPtr vmdef,
 ssize_t virDomainRNGFind(virDomainDefPtr def, virDomainRNGDefPtr rng);
 virDomainRNGDefPtr virDomainRNGRemove(virDomainDefPtr def, size_t idx);
 
+ssize_t virDomainRedirdevDefFind(virDomainDefPtr def,
+                                 virDomainRedirdevDefPtr redirdev);
+virDomainRedirdevDefPtr virDomainRedirdevDefRemove(virDomainDefPtr def, size_t idx);
+
 int virDomainSaveXML(const char *configDir,
                      virDomainDefPtr def,
                      const char *xml);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 85b9cd1..4625886 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -424,7 +424,9 @@ virDomainPMSuspendedReasonTypeFromString;
 virDomainPMSuspendedReasonTypeToString;
 virDomainRedirdevBusTypeFromString;
 virDomainRedirdevBusTypeToString;
+virDomainRedirdevDefFind;
 virDomainRedirdevDefFree;
+virDomainRedirdevDefRemove;
 virDomainRNGBackendTypeToString;
 virDomainRNGDefFree;
 virDomainRNGFind;
-- 
2.8.4

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