Signed-off-by: Anya Harter
---
data/org.libvirt.Connect.xml | 6 ++
src/connect.c| 29 +
tests/test_connect.py| 1 +
3 files changed, 36 insertions(+)
diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
index f99e205..3447538 100644
--- a/data/org.libvirt.Connect.xml
+++ b/data/org.libvirt.Connect.xml
@@ -170,6 +170,12 @@
+
+ https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceLookupByMACString"/>
+
+
+
https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceLookupByName"/>
diff --git a/src/connect.c b/src/connect.c
index ae64d59..f0da1dd 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -827,6 +827,34 @@ virtDBusConnectInterfaceDefineXML(GVariant *inArgs,
*outArgs = g_variant_new("(o)", path);
}
+static void
+virtDBusConnectInterfaceLookupByMAC(GVariant *inArgs,
+GUnixFDList *inFDs G_GNUC_UNUSED,
+const gchar *objectPath G_GNUC_UNUSED,
+gpointer userData,
+GVariant **outArgs,
+GUnixFDList **outFDs G_GNUC_UNUSED,
+GError **error)
+{
+virtDBusConnect *connect = userData;
+g_autoptr(virInterface) interface = NULL;
+g_autofree gchar *path = NULL;
+const gchar *mac;
+
+g_variant_get(inArgs, "()", );
+
+if (!virtDBusConnectOpen(connect, NULL))
+return;
+
+interface = virInterfaceLookupByMACString(connect->connection, mac);
+if (!interface)
+return virtDBusUtilSetLastVirtError(error);
+
+path = virtDBusUtilBusPathForVirInterface(interface,
connect->interfacePath);
+
+*outArgs = g_variant_new("(o)", path);
+}
+
static void
virtDBusConnectInterfaceLookupByName(GVariant *inArgs,
GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -1927,6 +1955,7 @@ static virtDBusGDBusMethodTable
virtDBusConnectMethodTable[] = {
{ "InterfaceChangeCommit", virtDBusConnectInterfaceChangeCommit },
{ "InterfaceChangeRollback", virtDBusConnectInterfaceChangeRollback },
{ "InterfaceDefineXML", virtDBusConnectInterfaceDefineXML },
+{ "InterfaceLookupByMAC", virtDBusConnectInterfaceLookupByMAC },
{ "InterfaceLookupByName", virtDBusConnectInterfaceLookupByName },
{ "ListDomains", virtDBusConnectListDomains },
{ "ListInterfaces", virtDBusConnectListInterfaces },
diff --git a/tests/test_connect.py b/tests/test_connect.py
index 7e33b2a..042c568 100755
--- a/tests/test_connect.py
+++ b/tests/test_connect.py
@@ -90,6 +90,7 @@ class TestConnect(libvirttest.BaseTestClass):
@pytest.mark.parametrize("lookup_method_name,lookup_item", [
("InterfaceLookupByName", 'Name'),
+("InterfaceLookupByMAC", 'MAC'),
])
def test_connect_interface_lookup_by_property(self, lookup_method_name,
lookup_item):
"""Parameterized test for all InterfaceLookupBy* API calls of Connect
interface
--
2.17.1
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list