[libvirt] [PATCH 3/4] Implement Public API of new virInterface functions

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

 



---
 src/libvirt.c |   89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 86 insertions(+), 3 deletions(-)

diff --git a/src/libvirt.c b/src/libvirt.c
index bf49018..c5c868d 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -5502,9 +5502,9 @@ virInterfaceGetConnect (virInterfacePtr iface)
  * virConnectNumOfInterfaces:
  * @conn: pointer to the hypervisor connection
  *
- * Provides the number of interfaces on the physical host.
+ * Provides the number of active interfaces on the physical host.
  *
- * Returns the number of interface found or -1 in case of error
+ * Returns the number of active interfaces found or -1 in case of error
  */
 int
 virConnectNumOfInterfaces(virConnectPtr conn)
@@ -5540,7 +5540,8 @@ error:
  * @names: array to collect the list of names of interfaces
  * @maxnames: size of @names
  *
- * Collect the list of physical host interfaces, and store their names in @names
+ * Collect the list of active physical host interfaces,
+ * and store their names in @names
  *
  * Returns the number of interfaces found or -1 in case of error
  */
@@ -5578,6 +5579,88 @@ error:
 }
 
 /**
+ * virConnectNumOfDefinedInterfaces:
+ * @conn: pointer to the hypervisor connection
+ *
+ * Provides the number of defined (inactive) interfaces on the physical host.
+ *
+ * Returns the number of defined interface found or -1 in case of error
+ */
+int
+virConnectNumOfDefinedInterfaces(virConnectPtr conn)
+{
+    DEBUG("conn=%p", conn);
+
+    virResetLastError();
+
+    if (!VIR_IS_CONNECT(conn)) {
+        virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+        return (-1);
+    }
+
+    if (conn->interfaceDriver && conn->interfaceDriver->numOfDefinedInterfaces) {
+        int ret;
+        ret = conn->interfaceDriver->numOfDefinedInterfaces (conn);
+        if (ret < 0)
+            goto error;
+        return ret;
+    }
+
+    virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+    /* Copy to connection error object for back compatability */
+    virSetConnError(conn);
+    return -1;
+}
+
+/**
+ * virConnectListDefinedInterfaces:
+ * @conn: pointer to the hypervisor connection
+ * @names: array to collect the list of names of interfaces
+ * @maxnames: size of @names
+ *
+ * Collect the list of defined (inactive) physical host interfaces,
+ * and store their names in @names.
+ *
+ * Returns the number of interfaces found or -1 in case of error
+ */
+int
+virConnectListDefinedInterfaces(virConnectPtr conn,
+                                char **const names,
+                                int maxnames)
+{
+    DEBUG("conn=%p, names=%p, maxnames=%d", conn, names, maxnames);
+
+    virResetLastError();
+
+    if (!VIR_IS_CONNECT(conn)) {
+        virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+        return (-1);
+    }
+
+    if ((names == NULL) || (maxnames < 0)) {
+        virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
+        goto error;
+    }
+
+    if (conn->interfaceDriver && conn->interfaceDriver->listDefinedInterfaces) {
+        int ret;
+        ret = conn->interfaceDriver->listDefinedInterfaces (conn, names, maxnames);
+        if (ret < 0)
+            goto error;
+        return ret;
+    }
+
+    virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+    /* Copy to connection error object for back compatability */
+    virSetConnError(conn);
+    return -1;
+}
+
+/**
  * virInterfaceLookupByName:
  * @conn: pointer to the hypervisor connection
  * @name: name for the interface
-- 
1.6.0.6

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