[libvirt] [dbus PATCH v2 00/17] Implement and Test Interface APIs

original patch series cover letter: https://www.redhat.com/archives/libvir-list/2018-July/msg00364.html changes since v1: * all commits "make" and "make check" * MACString property => MAC property * various corrections * add tests for all but virConnectListAllInterfaces, virInterfaceChangeBegin, virInterfaceChangeCommit, and virInterfaceChangeRollback * commits were reordered to introduce functions before they are needed by the test suite https://libvirt.org/html/libvirt-libvirt-interface.html The following functions have been implemented: - virConnectListAllInterfaces (connect method) - virInterfaceChangeBegin (connect method) - virInterfaceChangeCommit (connect method) - virInterfaceChangeRollback (connect method) - virInterfaceCreate (interface method) - virInterfaceDefineXML (connect method) - virInterfaceDestroy (interface method) - virInterfaceGetMACString (property) - virInterfaceGetName (property) - virInterfaceGetXMLDesc (interface method) - virInterfaceIsActive (property) - virInterfaceLookupByMACString (connect method) - virInterfaceLookupByName (connect method) - virInterfaceUndefine (interface method) Anya Harter (17): Introduce Interface Interface Implement InterfaceDefineXML method for Connect Interface Implement Create method for Interface Interface Implement Destroy method for Interface Interface Introduce Interface Tests & Test Create method for Interface Interface Test Destroy method for Interface Interface Implement Undefine method for Interface Interface Implement GetXMLDesc method for Interface Interface Implement Name property for Interface Interface Implement MAC property for Interface Interface Implement Active property for Interface Interface Implement ListInterfaces method for Connect Interface Implement InterfaceChangeBegin method for Connect Interface Implement InterfaceChangeCommit method for Connect Interface Implement InterfaceChangeRollback method for Connect Interface Implement InterfaceLookupByName method for Connect Interface Implement InterfaceLookupByMAC method for Connect Interface data/Makefile.am | 1 + data/org.libvirt.Connect.xml | 40 ++++++ data/org.libvirt.Interface.xml | 42 ++++++ src/Makefile.am | 2 + src/connect.c | 198 ++++++++++++++++++++++++++ src/connect.h | 1 + src/interface.c | 249 +++++++++++++++++++++++++++++++++ src/interface.h | 9 ++ src/util.c | 35 +++++ src/util.h | 15 ++ tests/Makefile.am | 1 + tests/libvirttest.py | 12 ++ tests/test_connect.py | 17 +++ tests/test_interface.py | 39 ++++++ tests/xmldata.py | 12 ++ 15 files changed, 673 insertions(+) create mode 100644 data/org.libvirt.Interface.xml create mode 100644 src/interface.c create mode 100644 src/interface.h create mode 100755 tests/test_interface.py -- 2.17.1

Signed-off-by: Anya Harter <aharter@redhat.com> --- data/Makefile.am | 1 + data/org.libvirt.Interface.xml | 7 ++++ src/Makefile.am | 2 ++ src/connect.c | 6 ++++ src/connect.h | 1 + src/interface.c | 65 ++++++++++++++++++++++++++++++++++ src/interface.h | 9 +++++ src/util.c | 35 ++++++++++++++++++ src/util.h | 15 ++++++++ 9 files changed, 141 insertions(+) create mode 100644 data/org.libvirt.Interface.xml create mode 100644 src/interface.c create mode 100644 src/interface.h diff --git a/data/Makefile.am b/data/Makefile.am index 7b523da..35a0bbd 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -33,6 +33,7 @@ polkit_DATA = \ interfaces_files = \ org.libvirt.Connect.xml \ org.libvirt.Domain.xml \ + org.libvirt.Interface.xml \ org.libvirt.Network.xml \ org.libvirt.NodeDevice.xml \ org.libvirt.NWFilter.xml \ diff --git a/data/org.libvirt.Interface.xml b/data/org.libvirt.Interface.xml new file mode 100644 index 0000000..93fa32f --- /dev/null +++ b/data/org.libvirt.Interface.xml @@ -0,0 +1,7 @@ +<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" +"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> + +<node name="/org/libvirt/interface"> + <interface name="org.libvirt.Interface"> + </interface> +</node> diff --git a/src/Makefile.am b/src/Makefile.am index b5bf129..d0e8f0d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -41,6 +41,8 @@ libvirt_dbus_SOURCES = \ events.h \ gdbus.c \ gdbus.h \ + interface.c \ + interface.h \ main.c \ network.c \ network.h \ diff --git a/src/connect.c b/src/connect.c index 9275121..3dc434d 100644 --- a/src/connect.c +++ b/src/connect.c @@ -1,6 +1,7 @@ #include "connect.h" #include "domain.h" #include "events.h" +#include "interface.h" #include "network.h" #include "nodedev.h" #include "nwfilter.h" @@ -1809,6 +1810,7 @@ virtDBusConnectFree(virtDBusConnect *connect) virtDBusConnectClose(connect, TRUE); g_free(connect->domainPath); + g_free(connect->interfacePath); g_free(connect->networkPath); g_free(connect->nodeDevPath); g_free(connect->nwfilterPath); @@ -1869,6 +1871,10 @@ virtDBusConnectNew(virtDBusConnect **connectp, if (error && *error) return; + virtDBusInterfaceRegister(connect, error); + if (error && *error) + return; + virtDBusNetworkRegister(connect, error); if (error && *error) return; diff --git a/src/connect.h b/src/connect.h index 0b9ae10..961b115 100644 --- a/src/connect.h +++ b/src/connect.h @@ -13,6 +13,7 @@ struct virtDBusConnect { const gchar *uri; const gchar *connectPath; gchar *domainPath; + gchar *interfacePath; gchar *networkPath; gchar *nodeDevPath; gchar *nwfilterPath; diff --git a/src/interface.c b/src/interface.c new file mode 100644 index 0000000..3c32f0f --- /dev/null +++ b/src/interface.c @@ -0,0 +1,65 @@ +#include "interface.h" +#include "util.h" + +#include <libvirt/libvirt.h> + +static virtDBusGDBusPropertyTable virtDBusInterfacePropertyTable[] = { + { 0 } +}; + +static virtDBusGDBusMethodTable virtDBusInterfaceMethodTable[] = { + { 0 } +}; + +static gchar ** +virtDBusInterfaceEnumerate(gpointer userData) +{ + virtDBusConnect *connect = userData; + g_autoptr(virInterfacePtr) interfaces = NULL; + gint num = 0; + gchar **ret = NULL; + + if (!virtDBusConnectOpen(connect, NULL)) + return NULL; + + num = virConnectListAllInterfaces(connect->connection, &interfaces, 0); + if (num < 0) + return NULL; + + if (num == 0) + return NULL; + + ret = g_new0(gchar *, num + 1); + + for (gint i = 0; i < num; i++) { + ret[i] = virtDBusUtilBusPathForVirInterface(interfaces[i], + connect->interfacePath); + } + + return ret; +} + +static GDBusInterfaceInfo *interfaceInfo; + +void +virtDBusInterfaceRegister(virtDBusConnect *connect, + GError **error) +{ + connect->interfacePath = g_strdup_printf("%s/interface", + connect->connectPath); + + if (!interfaceInfo) { + interfaceInfo = virtDBusGDBusLoadIntrospectData(VIRT_DBUS_INTERFACE_INTERFACE, + error); + if (!interfaceInfo) + return; + } + + virtDBusGDBusRegisterSubtree(connect->bus, + connect->interfacePath, + interfaceInfo, + virtDBusInterfaceEnumerate, + virtDBusInterfaceMethodTable, + virtDBusInterfacePropertyTable, + connect); +} diff --git a/src/interface.h b/src/interface.h new file mode 100644 index 0000000..8e5ee0a --- /dev/null +++ b/src/interface.h @@ -0,0 +1,9 @@ +#pragma once + +#include "connect.h" + +#define VIRT_DBUS_INTERFACE_INTERFACE "org.libvirt.Interface" + +void +virtDBusInterfaceRegister(virtDBusConnect *connect, + GError **error); diff --git a/src/util.c b/src/util.c index 8c822f2..9e11285 100644 --- a/src/util.c +++ b/src/util.c @@ -278,6 +278,41 @@ virtDBusUtilVirDomainListFree(virDomainPtr *domains) g_free(domains); } +virInterfacePtr +virtDBusUtilVirInterfaceFromBusPath(virConnectPtr connection, + const gchar *path, + const gchar *interfacePath) +{ + g_autofree gchar *macstr = NULL; + gsize prefixLen = strlen(interfacePath) + 1; + + macstr = virtDBusUtilDecodeStr(path + prefixLen); + + return virInterfaceLookupByMACString(connection, macstr); +} + +gchar * +virtDBusUtilBusPathForVirInterface(virInterfacePtr interface, + const gchar *interfacePath) +{ + const gchar *macstr = NULL; + g_autofree const gchar *encodedMACStr = NULL; + + macstr = virInterfaceGetMACString(interface); + encodedMACStr = virtDBusUtilEncodeStr(macstr); + + return g_strdup_printf("%s/%s", interfacePath, encodedMACStr); +} + +void +virtDBusUtilVirInterfaceListFree(virInterfacePtr *interfaces) +{ + for (gint i = 0; interfaces[i] != NULL; i++) + virInterfaceFree(interfaces[i]); + + g_free(interfaces); +} + virNetworkPtr virtDBusUtilVirNetworkFromBusPath(virConnectPtr connection, const gchar *path, diff --git a/src/util.h b/src/util.h index a688a3d..b05c2fc 100644 --- a/src/util.h +++ b/src/util.h @@ -65,6 +65,21 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainPtr, virtDBusUtilVirDomainListFree); G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainStatsRecordPtr, virDomainStatsRecordListFree); +virInterfacePtr +virtDBusUtilVirInterfaceFromBusPath(virConnectPtr connection, + const gchar *path, + const gchar *interfacePath); + +gchar * +virtDBusUtilBusPathForVirInterface(virInterfacePtr interface, + const gchar *interfacePath); + +void +virtDBusUtilVirInterfaceListFree(virInterfacePtr *interfaces); + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virInterface, virInterfaceFree); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virInterfacePtr, virtDBusUtilVirInterfaceListFree); + virNetworkPtr virtDBusUtilVirNetworkFromBusPath(virConnectPtr connection, const gchar *path, -- 2.17.1

On Fri, Jul 20, 2018 at 02:34:45PM -0400, Anya Harter wrote:
Signed-off-by: Anya Harter <aharter@redhat.com> --- data/Makefile.am | 1 + data/org.libvirt.Interface.xml | 7 ++++ src/Makefile.am | 2 ++ src/connect.c | 6 ++++ src/connect.h | 1 + src/interface.c | 65 ++++++++++++++++++++++++++++++++++ src/interface.h | 9 +++++ src/util.c | 35 ++++++++++++++++++ src/util.h | 15 ++++++++ 9 files changed, 141 insertions(+) create mode 100644 data/org.libvirt.Interface.xml create mode 100644 src/interface.c create mode 100644 src/interface.h
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Signed-off-by: Anya Harter <aharter@redhat.com> --- data/org.libvirt.Connect.xml | 7 +++++++ src/connect.c | 30 ++++++++++++++++++++++++++++++ tests/test_connect.py | 4 ++++ tests/xmldata.py | 12 ++++++++++++ 4 files changed, 53 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index 7014a09..f690bab 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -148,6 +148,13 @@ <arg name="flags" type="u" direction="in"/> <arg name="sysinfo" type="s" direction="out"/> </method> + <method name="InterfaceDefineXML"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceDefineXML"/> + <arg name="xml" type="s" direction="in"/> + <arg name="flags" type="u" direction="in"/> + <arg name="interface" type="o" direction="out"/> + </method> <method name="ListDomains"> <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectListAllDomains"/> diff --git a/src/connect.c b/src/connect.c index 3dc434d..304a56f 100644 --- a/src/connect.c +++ b/src/connect.c @@ -735,6 +735,35 @@ virtDBusConnectGetSysinfo(GVariant *inArgs, *outArgs = g_variant_new("(s)", sysinfo); } +static void +virtDBusConnectInterfaceDefineXML(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 *xml; + guint flags; + + g_variant_get(inArgs, "(&su)", &xml, &flags); + + if (!virtDBusConnectOpen(connect, error)) + return; + + interface = virInterfaceDefineXML(connect->connection, xml, flags); + if (!interface) + return virtDBusUtilSetLastVirtError(error); + + path = virtDBusUtilBusPathForVirInterface(interface, connect->interfacePath); + + *outArgs = g_variant_new("(o)", path); +} + static void virtDBusConnectListDomains(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -1766,6 +1795,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = { { "GetCPUModelNames", virtDBusConnectGetCPUModelNames }, { "GetDomainCapabilities", virtDBusConnectGetDomainCapabilities }, { "GetSysinfo", virtDBusConnectGetSysinfo }, + { "InterfaceDefineXML", virtDBusConnectInterfaceDefineXML }, { "ListDomains", virtDBusConnectListDomains }, { "ListNetworks", virtDBusConnectListNetworks }, { "ListNodeDevices", virtDBusConnectListNodeDevices }, diff --git a/tests/test_connect.py b/tests/test_connect.py index 2299b8a..d21b366 100755 --- a/tests/test_connect.py +++ b/tests/test_connect.py @@ -84,6 +84,10 @@ class TestConnect(libvirttest.BaseTestClass): sysinfo = self.connect.GetSysinfo(0) assert isinstance(sysinfo, dbus.String) + def test_connect_interface_define_xml(self): + path = self.connect.InterfaceDefineXML(xmldata.minimal_interface_xml, 0) + assert isinstance(path, dbus.ObjectPath) + def test_connect_list_networks(self): networks = self.connect.ListNetworks(0) assert isinstance(networks, dbus.Array) diff --git a/tests/xmldata.py b/tests/xmldata.py index 25bb089..a70bac1 100644 --- a/tests/xmldata.py +++ b/tests/xmldata.py @@ -12,6 +12,18 @@ minimal_domain_xml = ''' </domain> ''' +minimal_interface_xml = ''' +<interface type='ethernet' name='test-iface'> + <start mode='onboot'/> + <mac address='11:22:33:44:55:66'/> + <mtu size='1492'/> + <protocol family='ipv4'> + <ip address='192.168.15.5' prefix='24'/> + <route gateway='192.168.15.1'/> + </protocol> +</interface> +''' + minimal_network_xml = ''' <network> <name>bar</name> -- 2.17.1

On Fri, Jul 20, 2018 at 02:34:46PM -0400, Anya Harter wrote:
Signed-off-by: Anya Harter <aharter@redhat.com> --- data/org.libvirt.Connect.xml | 7 +++++++ src/connect.c | 30 ++++++++++++++++++++++++++++++ tests/test_connect.py | 4 ++++ tests/xmldata.py | 12 ++++++++++++ 4 files changed, 53 insertions(+)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Signed-off-by: Anya Harter <aharter@redhat.com> --- data/org.libvirt.Interface.xml | 5 ++++ src/interface.c | 45 ++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/data/org.libvirt.Interface.xml b/data/org.libvirt.Interface.xml index 93fa32f..d98a646 100644 --- a/data/org.libvirt.Interface.xml +++ b/data/org.libvirt.Interface.xml @@ -3,5 +3,10 @@ <node name="/org/libvirt/interface"> <interface name="org.libvirt.Interface"> + <method name="Create"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceCreate"/> + <arg name="flags" type="u" direction="in"/> + </method> </interface> </node> diff --git a/src/interface.c b/src/interface.c index 3c32f0f..4a5e431 100644 --- a/src/interface.c +++ b/src/interface.c @@ -3,11 +3,56 @@ #include <libvirt/libvirt.h> +static virInterfacePtr +virtDBusInterfaceGetVirInterface(virtDBusConnect *connect, + const gchar *objectPath, + GError **error) +{ + virInterfacePtr interface; + + if (virtDBusConnectOpen(connect, error) < 0) + return NULL; + + interface = virtDBusUtilVirInterfaceFromBusPath(connect->connection, + objectPath, + connect->interfacePath); + if (!interface) { + virtDBusUtilSetLastVirtError(error); + return NULL; + } + + return interface; +} + +static void +virtDBusInterfaceCreate(GVariant *inArgs, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath, + gpointer userData, + GVariant **outArgs G_GNUC_UNUSED, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ + virtDBusConnect *connect = userData; + g_autoptr(virInterface) interface = NULL; + guint flags; + + g_variant_get(inArgs, "(u)", &flags); + + interface = virtDBusInterfaceGetVirInterface(connect, objectPath, error); + if (!interface) + return; + + if (virInterfaceCreate(interface, flags) < 0) + virtDBusUtilSetLastVirtError(error); +} + static virtDBusGDBusPropertyTable virtDBusInterfacePropertyTable[] = { { 0 } }; static virtDBusGDBusMethodTable virtDBusInterfaceMethodTable[] = { + { "Create", virtDBusInterfaceCreate }, { 0 } }; -- 2.17.1

On Fri, Jul 20, 2018 at 02:34:47PM -0400, Anya Harter wrote:
Signed-off-by: Anya Harter <aharter@redhat.com> --- data/org.libvirt.Interface.xml | 5 ++++ src/interface.c | 45 ++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Signed-off-by: Anya Harter <aharter@redhat.com> --- data/org.libvirt.Interface.xml | 5 +++++ src/interface.c | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/data/org.libvirt.Interface.xml b/data/org.libvirt.Interface.xml index d98a646..f5ec281 100644 --- a/data/org.libvirt.Interface.xml +++ b/data/org.libvirt.Interface.xml @@ -8,5 +8,10 @@ value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceCreate"/> <arg name="flags" type="u" direction="in"/> </method> + <method name="Destroy"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceDestroy"/> + <arg name="flags" type="u" direction="in"/> + </method> </interface> </node> diff --git a/src/interface.c b/src/interface.c index 4a5e431..077b10d 100644 --- a/src/interface.c +++ b/src/interface.c @@ -47,12 +47,36 @@ virtDBusInterfaceCreate(GVariant *inArgs, virtDBusUtilSetLastVirtError(error); } +static void +virtDBusInterfaceDestroy(GVariant *inArgs, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath, + gpointer userData, + GVariant **outArgs G_GNUC_UNUSED, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ + virtDBusConnect *connect = userData; + g_autoptr(virInterface) interface = NULL; + guint flags; + + g_variant_get(inArgs, "(u)", &flags); + + interface = virtDBusInterfaceGetVirInterface(connect, objectPath, error); + if (!interface) + return; + + if (virInterfaceDestroy(interface, flags) < 0) + virtDBusUtilSetLastVirtError(error); +} + static virtDBusGDBusPropertyTable virtDBusInterfacePropertyTable[] = { { 0 } }; static virtDBusGDBusMethodTable virtDBusInterfaceMethodTable[] = { { "Create", virtDBusInterfaceCreate }, + { "Destroy", virtDBusInterfaceDestroy }, { 0 } }; -- 2.17.1

On Fri, Jul 20, 2018 at 02:34:48PM -0400, Anya Harter wrote:
Signed-off-by: Anya Harter <aharter@redhat.com> --- data/org.libvirt.Interface.xml | 5 +++++ src/interface.c | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Signed-off-by: Anya Harter <aharter@redhat.com> --- tests/Makefile.am | 1 + tests/libvirttest.py | 12 ++++++++++++ tests/test_interface.py | 16 ++++++++++++++++ 3 files changed, 29 insertions(+) create mode 100755 tests/test_interface.py diff --git a/tests/Makefile.am b/tests/Makefile.am index 09c3e2e..cd1fbd7 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -11,6 +11,7 @@ test_helpers = \ test_programs = \ test_connect.py \ test_domain.py \ + test_interface.py \ test_network.py \ test_nodedev.py \ test_storage.py \ diff --git a/tests/libvirttest.py b/tests/libvirttest.py index 3741abd..2a09182 100644 --- a/tests/libvirttest.py +++ b/tests/libvirttest.py @@ -71,6 +71,18 @@ class BaseTestClass(): if self.timeout: raise TimeoutError() + def interface_create(self): + """ Fixture to define dummy interface on the test driver + + This fixture should be used in the setup of every test manipulating + with interfaces. + """ + path = self.connect.InterfaceDefineXML(xmldata.minimal_interface_xml, 0) + obj = self.bus.get_object('org.libvirt', path) + interface_obj = dbus.Interface(obj, 'org.libvirt.Interface') + interface_obj.Create(0) + return path, interface_obj + @pytest.fixture def node_device_create(self): """ Fixture to create dummy node device on the test driver diff --git a/tests/test_interface.py b/tests/test_interface.py new file mode 100755 index 0000000..88be5dc --- /dev/null +++ b/tests/test_interface.py @@ -0,0 +1,16 @@ +#!/usr/bin/python3 + +import dbus +import libvirttest + +class TestInterface(libvirttest.BaseTestClass): + """ Tests for methods and properties of the Interface interface + """ + + def test_interface_create(self): + _,interface_obj = self.interface_create() + interface_obj.Destroy(0) + interface_obj.Create(0) + +if __name__ == '__main__': + libvirttest.run() -- 2.17.1

On Fri, Jul 20, 2018 at 02:34:49PM -0400, Anya Harter wrote:
Signed-off-by: Anya Harter <aharter@redhat.com> --- tests/Makefile.am | 1 + tests/libvirttest.py | 12 ++++++++++++ tests/test_interface.py | 16 ++++++++++++++++ 3 files changed, 29 insertions(+) create mode 100755 tests/test_interface.py
diff --git a/tests/Makefile.am b/tests/Makefile.am index 09c3e2e..cd1fbd7 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -11,6 +11,7 @@ test_helpers = \ test_programs = \ test_connect.py \ test_domain.py \ + test_interface.py \ test_network.py \ test_nodedev.py \ test_storage.py \ diff --git a/tests/libvirttest.py b/tests/libvirttest.py index 3741abd..2a09182 100644 --- a/tests/libvirttest.py +++ b/tests/libvirttest.py @@ -71,6 +71,18 @@ class BaseTestClass(): if self.timeout: raise TimeoutError()
This method is not a fixture unless you put the @pytest.fixture decorator. This code without the fixture decorator will actually work, but it does not do exactly what we want it to do. See explanation bellow.
+ def interface_create(self): + """ Fixture to define dummy interface on the test driver + + This fixture should be used in the setup of every test manipulating + with interfaces. + """ + path = self.connect.InterfaceDefineXML(xmldata.minimal_interface_xml, 0) + obj = self.bus.get_object('org.libvirt', path) + interface_obj = dbus.Interface(obj, 'org.libvirt.Interface') + interface_obj.Create(0) + return path, interface_obj + @pytest.fixture def node_device_create(self): """ Fixture to create dummy node device on the test driver diff --git a/tests/test_interface.py b/tests/test_interface.py new file mode 100755 index 0000000..88be5dc --- /dev/null +++ b/tests/test_interface.py @@ -0,0 +1,16 @@ +#!/usr/bin/python3 + +import dbus +import libvirttest + +class TestInterface(libvirttest.BaseTestClass): + """ Tests for methods and properties of the Interface interface + """
Here you are calling the interace_create function (! it's not a fixture without the decorator). It will create a dummy interface on the test driver so that your tests can use it. However, the interface_create functionality should not be tested in this test, this interface creation should be part of the test "setup". What is "setup"? pytest defines three test phases for each test, which are "setup", "call" and "teardown". The "setup" part should be used to prepare the environment for the test to run (for our case define an test Interface), and teardown to clean up after the test. Call is the actual test code itself. The way to run some code as a test setup is using pytest fuxtures. So the fixture definition you need to mark it with @pytest.fixture and the functions where the fixture should be applied to with @pytest.mark.usefixtures("interface_create") Then instead of calling the fixture we can use it's result by having the fixture name in the function arguments. So the following should look like: @pytest.mark.fixtures("interface_create") def test_interface_create(self, test_interface): _,interface_obj = test_interface interface_obj.Destroy(0) interface_obj.Create(0)
+ + def test_interface_create(self): + _,interface_obj = self.interface_create() + interface_obj.Destroy(0) + interface_obj.Create(0) + +if __name__ == '__main__': + libvirttest.run() -- 2.17.1
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Although the concept is not correct, similar mistake exist in the node_device tests, so I can fix it together in another patch set. Reviewed-by: Katerina Koukiou <kkoukiou@redhat.com> Note: If you 're still not sure what the setup fixture does see the code bellow: $ cat show-setup.py import pytest @pytest.mark.usefixtures("foo") def test_bar(foo): print("Here starts test CALL") print(foo) @pytest.fixture def foo(): print("Here starts test SETUP"); return "blabla" $ pytest show-setup.py -s ============================================================================ test session starts ============================================================================ platform linux2 -- Python 2.7.15, pytest-3.4.2, py-1.5.2, pluggy-0.6.0 rootdir: /home/kkoukiou/repos/libvirt-dbus, inifile: plugins: ordering-0.5, marker-bugzilla-0.7, jira-0.3.6, forked-0.2 collected 1 item show-setup.py Here starts test SETUP Here starts test CALL blabla . ========================================================================= 1 passed in 0.00 seconds ==========================================================================

On Tue, Jul 24, 2018 at 11:30:10AM +0200, Katerina Koukiou wrote:
On Fri, Jul 20, 2018 at 02:34:49PM -0400, Anya Harter wrote:
Signed-off-by: Anya Harter <aharter@redhat.com> --- tests/Makefile.am | 1 + tests/libvirttest.py | 12 ++++++++++++ tests/test_interface.py | 16 ++++++++++++++++ 3 files changed, 29 insertions(+) create mode 100755 tests/test_interface.py
diff --git a/tests/Makefile.am b/tests/Makefile.am index 09c3e2e..cd1fbd7 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -11,6 +11,7 @@ test_helpers = \ test_programs = \ test_connect.py \ test_domain.py \ + test_interface.py \ test_network.py \ test_nodedev.py \ test_storage.py \ diff --git a/tests/libvirttest.py b/tests/libvirttest.py index 3741abd..2a09182 100644 --- a/tests/libvirttest.py +++ b/tests/libvirttest.py @@ -71,6 +71,18 @@ class BaseTestClass(): if self.timeout: raise TimeoutError()
This method is not a fixture unless you put the @pytest.fixture decorator.
This code without the fixture decorator will actually work, but it does not do exactly what we want it to do.
See explanation bellow.
+ def interface_create(self): + """ Fixture to define dummy interface on the test driver + + This fixture should be used in the setup of every test manipulating + with interfaces. + """ + path = self.connect.InterfaceDefineXML(xmldata.minimal_interface_xml, 0) + obj = self.bus.get_object('org.libvirt', path) + interface_obj = dbus.Interface(obj, 'org.libvirt.Interface') + interface_obj.Create(0) + return path, interface_obj + @pytest.fixture def node_device_create(self): """ Fixture to create dummy node device on the test driver diff --git a/tests/test_interface.py b/tests/test_interface.py new file mode 100755 index 0000000..88be5dc --- /dev/null +++ b/tests/test_interface.py @@ -0,0 +1,16 @@ +#!/usr/bin/python3 + +import dbus +import libvirttest + +class TestInterface(libvirttest.BaseTestClass): + """ Tests for methods and properties of the Interface interface + """
Here you are calling the interace_create function (! it's not a fixture without the decorator). It will create a dummy interface on the test driver so that your tests can use it. However, the interface_create functionality should not be tested in this test, this interface creation should be part of the test "setup".
What is "setup"? pytest defines three test phases for each test, which are "setup", "call" and "teardown". The "setup" part should be used to prepare the environment for the test to run (for our case define an test Interface), and teardown to clean up after the test. Call is the actual test code itself. The way to run some code as a test setup is using pytest fuxtures.
So the fixture definition you need to mark it with @pytest.fixture and the functions where the fixture should be applied to with @pytest.mark.usefixtures("interface_create") Then instead of calling the fixture we can use it's result by having the fixture name in the function arguments. So the following should look like:
@pytest.mark.fixtures("interface_create") def test_interface_create(self, test_interface): _,interface_obj = test_interface interface_obj.Destroy(0) interface_obj.Create(0)
Nice, I didn't know that this is possible. I suggested not to use the fixture because we need the result as well and existing code was calling the fixture again as normal function which was failing for interfaces. Pavel

Signed-off-by: Anya Harter <aharter@redhat.com> --- tests/test_interface.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test_interface.py b/tests/test_interface.py index 88be5dc..62fd517 100755 --- a/tests/test_interface.py +++ b/tests/test_interface.py @@ -7,6 +7,10 @@ class TestInterface(libvirttest.BaseTestClass): """ Tests for methods and properties of the Interface interface """ + def test_interface_destroy(self): + _,interface_obj = self.interface_create() + interface_obj.Destroy(0) + def test_interface_create(self): _,interface_obj = self.interface_create() interface_obj.Destroy(0) -- 2.17.1

On Fri, Jul 20, 2018 at 02:34:50PM -0400, Anya Harter wrote:
Signed-off-by: Anya Harter <aharter@redhat.com> --- tests/test_interface.py | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/tests/test_interface.py b/tests/test_interface.py index 88be5dc..62fd517 100755 --- a/tests/test_interface.py +++ b/tests/test_interface.py @@ -7,6 +7,10 @@ class TestInterface(libvirttest.BaseTestClass): """ Tests for methods and properties of the Interface interface """
+ def test_interface_destroy(self): + _,interface_obj = self.interface_create()
Same as previous patch, interface_create should be fixture and ran at setup of the test. I 'll fix it in seperate patch.
+ interface_obj.Destroy(0) + def test_interface_create(self): _,interface_obj = self.interface_create() interface_obj.Destroy(0) -- 2.17.1
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Reviewed-by: Katerina Koukiou <kkoukiou@redhat.com>

Signed-off-by: Anya Harter <aharter@redhat.com> --- data/org.libvirt.Interface.xml | 4 ++++ src/interface.c | 21 +++++++++++++++++++++ tests/test_interface.py | 5 +++++ 3 files changed, 30 insertions(+) diff --git a/data/org.libvirt.Interface.xml b/data/org.libvirt.Interface.xml index f5ec281..4534b97 100644 --- a/data/org.libvirt.Interface.xml +++ b/data/org.libvirt.Interface.xml @@ -13,5 +13,9 @@ value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceDestroy"/> <arg name="flags" type="u" direction="in"/> </method> + <method name="Undefine"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceUndefine"/> + </method> </interface> </node> diff --git a/src/interface.c b/src/interface.c index 077b10d..a2d1cef 100644 --- a/src/interface.c +++ b/src/interface.c @@ -70,6 +70,26 @@ virtDBusInterfaceDestroy(GVariant *inArgs, virtDBusUtilSetLastVirtError(error); } +static void +virtDBusInterfaceUndefine(GVariant *inArgs G_GNUC_UNUSED, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath, + gpointer userData, + GVariant **outArgs G_GNUC_UNUSED, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ + virtDBusConnect *connect = userData; + g_autoptr(virInterface) interface = NULL; + + interface = virtDBusInterfaceGetVirInterface(connect, objectPath, error); + if (!interface) + return; + + if (virInterfaceUndefine(interface) < 0) + virtDBusUtilSetLastVirtError(error); +} + static virtDBusGDBusPropertyTable virtDBusInterfacePropertyTable[] = { { 0 } }; @@ -77,6 +97,7 @@ static virtDBusGDBusPropertyTable virtDBusInterfacePropertyTable[] = { static virtDBusGDBusMethodTable virtDBusInterfaceMethodTable[] = { { "Create", virtDBusInterfaceCreate }, { "Destroy", virtDBusInterfaceDestroy }, + { "Undefine", virtDBusInterfaceUndefine }, { 0 } }; diff --git a/tests/test_interface.py b/tests/test_interface.py index 62fd517..4a83672 100755 --- a/tests/test_interface.py +++ b/tests/test_interface.py @@ -7,6 +7,11 @@ class TestInterface(libvirttest.BaseTestClass): """ Tests for methods and properties of the Interface interface """ + def test_interface_undefine(self): + _,interface_obj = self.interface_create() + interface_obj.Destroy(0) + interface_obj.Undefine(0) + def test_interface_destroy(self): _,interface_obj = self.interface_create() interface_obj.Destroy(0) -- 2.17.1

On Fri, Jul 20, 2018 at 02:34:51PM -0400, Anya Harter wrote:
Signed-off-by: Anya Harter <aharter@redhat.com> --- data/org.libvirt.Interface.xml | 4 ++++ src/interface.c | 21 +++++++++++++++++++++ tests/test_interface.py | 5 +++++ 3 files changed, 30 insertions(+)
diff --git a/data/org.libvirt.Interface.xml b/data/org.libvirt.Interface.xml index f5ec281..4534b97 100644 --- a/data/org.libvirt.Interface.xml +++ b/data/org.libvirt.Interface.xml @@ -13,5 +13,9 @@ value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceDestroy"/> <arg name="flags" type="u" direction="in"/> </method> + <method name="Undefine"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceUndefine"/> + </method> </interface> </node> diff --git a/src/interface.c b/src/interface.c index 077b10d..a2d1cef 100644 --- a/src/interface.c +++ b/src/interface.c @@ -70,6 +70,26 @@ virtDBusInterfaceDestroy(GVariant *inArgs, virtDBusUtilSetLastVirtError(error); }
+static void +virtDBusInterfaceUndefine(GVariant *inArgs G_GNUC_UNUSED, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath, + gpointer userData, + GVariant **outArgs G_GNUC_UNUSED, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ + virtDBusConnect *connect = userData; + g_autoptr(virInterface) interface = NULL; + + interface = virtDBusInterfaceGetVirInterface(connect, objectPath, error); + if (!interface) + return; + + if (virInterfaceUndefine(interface) < 0) + virtDBusUtilSetLastVirtError(error); +} + static virtDBusGDBusPropertyTable virtDBusInterfacePropertyTable[] = { { 0 } }; @@ -77,6 +97,7 @@ static virtDBusGDBusPropertyTable virtDBusInterfacePropertyTable[] = { static virtDBusGDBusMethodTable virtDBusInterfaceMethodTable[] = { { "Create", virtDBusInterfaceCreate }, { "Destroy", virtDBusInterfaceDestroy }, + { "Undefine", virtDBusInterfaceUndefine }, { 0 } };
diff --git a/tests/test_interface.py b/tests/test_interface.py index 62fd517..4a83672 100755 --- a/tests/test_interface.py +++ b/tests/test_interface.py @@ -7,6 +7,11 @@ class TestInterface(libvirttest.BaseTestClass): """ Tests for methods and properties of the Interface interface """
+ def test_interface_undefine(self): + _,interface_obj = self.interface_create() + interface_obj.Destroy(0) + interface_obj.Undefine(0)
Undefine does not take any flags.
+ def test_interface_destroy(self): _,interface_obj = self.interface_create() interface_obj.Destroy(0) -- 2.17.1
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
With the flag argument removed: Reviewed-by: Katerina Koukiou <kkoukiou@redhat.com>

Signed-off-by: Anya Harter <aharter@redhat.com> --- data/org.libvirt.Interface.xml | 6 ++++++ src/interface.c | 28 ++++++++++++++++++++++++++++ tests/test_interface.py | 4 ++++ 3 files changed, 38 insertions(+) diff --git a/data/org.libvirt.Interface.xml b/data/org.libvirt.Interface.xml index 4534b97..dc03258 100644 --- a/data/org.libvirt.Interface.xml +++ b/data/org.libvirt.Interface.xml @@ -13,6 +13,12 @@ value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceDestroy"/> <arg name="flags" type="u" direction="in"/> </method> + <method name="GetXMLDesc"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceGetXMLDesc"/> + <arg name="flags" type="u" direction="in"/> + <arg name="xml" type="s" direction="out"/> + </method> <method name="Undefine"> <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceUndefine"/> diff --git a/src/interface.c b/src/interface.c index a2d1cef..fcec623 100644 --- a/src/interface.c +++ b/src/interface.c @@ -70,6 +70,33 @@ virtDBusInterfaceDestroy(GVariant *inArgs, virtDBusUtilSetLastVirtError(error); } +static void +virtDBusInterfaceGetXMLDesc(GVariant *inArgs, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath, + gpointer userData, + GVariant **outArgs, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ + virtDBusConnect *connect = userData; + g_autoptr(virInterface) interface = NULL; + g_autofree gchar *xml = NULL; + guint flags; + + g_variant_get(inArgs, "(u)", &flags); + + interface = virtDBusInterfaceGetVirInterface(connect, objectPath, error); + if (!interface) + return; + + xml = virInterfaceGetXMLDesc(interface, flags); + if (!xml) + return virtDBusUtilSetLastVirtError(error); + + *outArgs = g_variant_new("(s)", xml); +} + static void virtDBusInterfaceUndefine(GVariant *inArgs G_GNUC_UNUSED, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -97,6 +124,7 @@ static virtDBusGDBusPropertyTable virtDBusInterfacePropertyTable[] = { static virtDBusGDBusMethodTable virtDBusInterfaceMethodTable[] = { { "Create", virtDBusInterfaceCreate }, { "Destroy", virtDBusInterfaceDestroy }, + { "GetXMLDesc", virtDBusInterfaceGetXMLDesc }, { "Undefine", virtDBusInterfaceUndefine }, { 0 } }; diff --git a/tests/test_interface.py b/tests/test_interface.py index 4a83672..0b5a943 100755 --- a/tests/test_interface.py +++ b/tests/test_interface.py @@ -21,5 +21,9 @@ class TestInterface(libvirttest.BaseTestClass): interface_obj.Destroy(0) interface_obj.Create(0) + def test_interface_get_xml_description(self): + _,interface_obj = self.interface_create() + assert isinstance(interface_obj.GetXMLDesc(0), dbus.String) + if __name__ == '__main__': libvirttest.run() -- 2.17.1

On Fri, Jul 20, 2018 at 02:34:52PM -0400, Anya Harter wrote:
Signed-off-by: Anya Harter <aharter@redhat.com> --- data/org.libvirt.Interface.xml | 6 ++++++ src/interface.c | 28 ++++++++++++++++++++++++++++ tests/test_interface.py | 4 ++++ 3 files changed, 38 insertions(+)
Reviewed-by: Katerina Koukiou <kkoukiou@redhat.com>

Signed-off-by: Anya Harter <aharter@redhat.com> --- data/org.libvirt.Interface.xml | 5 +++++ src/interface.c | 22 ++++++++++++++++++++++ tests/test_interface.py | 8 ++++++++ 3 files changed, 35 insertions(+) diff --git a/data/org.libvirt.Interface.xml b/data/org.libvirt.Interface.xml index dc03258..c53c110 100644 --- a/data/org.libvirt.Interface.xml +++ b/data/org.libvirt.Interface.xml @@ -3,6 +3,11 @@ <node name="/org/libvirt/interface"> <interface name="org.libvirt.Interface"> + <property name="Name" type="s" access="read"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceGetName"/> + <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/> + </property> <method name="Create"> <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceCreate"/> diff --git a/src/interface.c b/src/interface.c index fcec623..a597fe5 100644 --- a/src/interface.c +++ b/src/interface.c @@ -70,6 +70,27 @@ virtDBusInterfaceDestroy(GVariant *inArgs, virtDBusUtilSetLastVirtError(error); } +static void +virtDBusInterfaceGetName(const gchar *objectPath, + gpointer userData, + GVariant **value, + GError **error) +{ + virtDBusConnect *connect = userData; + g_autoptr(virInterface) interface = NULL; + const gchar *name; + + interface = virtDBusInterfaceGetVirInterface(connect, objectPath, error); + if (!interface) + return; + + name = virInterfaceGetName(interface); + if (!name) + return virtDBusUtilSetLastVirtError(error); + + *value = g_variant_new("s", name); +} + static void virtDBusInterfaceGetXMLDesc(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -118,6 +139,7 @@ virtDBusInterfaceUndefine(GVariant *inArgs G_GNUC_UNUSED, } static virtDBusGDBusPropertyTable virtDBusInterfacePropertyTable[] = { + { "Name", virtDBusInterfaceGetName, NULL }, { 0 } }; diff --git a/tests/test_interface.py b/tests/test_interface.py index 0b5a943..c11a9be 100755 --- a/tests/test_interface.py +++ b/tests/test_interface.py @@ -25,5 +25,13 @@ class TestInterface(libvirttest.BaseTestClass): _,interface_obj = self.interface_create() assert isinstance(interface_obj.GetXMLDesc(0), dbus.String) + def test_interface_properties_type(self): + """ Ensure correct return type for Interface properties + """ + test_interface_path,_ = self.interface_create() + obj = self.bus.get_object('org.libvirt', test_interface_path) + props = obj.GetAll('org.libvirt.Interface', dbus_interface=dbus.PROPERTIES_IFACE) + assert isinstance(props['Name'], dbus.String) + if __name__ == '__main__': libvirttest.run() -- 2.17.1

On Fri, Jul 20, 2018 at 02:34:53PM -0400, Anya Harter wrote:
Signed-off-by: Anya Harter <aharter@redhat.com> --- data/org.libvirt.Interface.xml | 5 +++++ src/interface.c | 22 ++++++++++++++++++++++ tests/test_interface.py | 8 ++++++++ 3 files changed, 35 insertions(+)
Reviewed-by: Katerina Koukiou <kkoukiou@redhat.com>

Signed-off-by: Anya Harter <aharter@redhat.com> --- data/org.libvirt.Interface.xml | 5 +++++ src/interface.c | 22 ++++++++++++++++++++++ tests/test_interface.py | 1 + 3 files changed, 28 insertions(+) diff --git a/data/org.libvirt.Interface.xml b/data/org.libvirt.Interface.xml index c53c110..921e07f 100644 --- a/data/org.libvirt.Interface.xml +++ b/data/org.libvirt.Interface.xml @@ -3,6 +3,11 @@ <node name="/org/libvirt/interface"> <interface name="org.libvirt.Interface"> + <property name="MAC" type="s" access="read"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceGetMACString"/> + <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/> + </property> <property name="Name" type="s" access="read"> <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceGetName"/> diff --git a/src/interface.c b/src/interface.c index a597fe5..4caafcf 100644 --- a/src/interface.c +++ b/src/interface.c @@ -70,6 +70,27 @@ virtDBusInterfaceDestroy(GVariant *inArgs, virtDBusUtilSetLastVirtError(error); } +static void +virtDBusInterfaceGetMAC(const gchar *objectPath, + gpointer userData, + GVariant **value, + GError **error) +{ + virtDBusConnect *connect = userData; + g_autoptr(virInterface) interface = NULL; + const gchar *mac; + + interface = virtDBusInterfaceGetVirInterface(connect, objectPath, error); + if (!interface) + return; + + mac = virInterfaceGetMACString(interface); + if (!mac) + return virtDBusUtilSetLastVirtError(error); + + *value = g_variant_new("s", mac); +} + static void virtDBusInterfaceGetName(const gchar *objectPath, gpointer userData, @@ -139,6 +160,7 @@ virtDBusInterfaceUndefine(GVariant *inArgs G_GNUC_UNUSED, } static virtDBusGDBusPropertyTable virtDBusInterfacePropertyTable[] = { + { "MAC", virtDBusInterfaceGetMAC, NULL }, { "Name", virtDBusInterfaceGetName, NULL }, { 0 } }; diff --git a/tests/test_interface.py b/tests/test_interface.py index c11a9be..325f889 100755 --- a/tests/test_interface.py +++ b/tests/test_interface.py @@ -32,6 +32,7 @@ class TestInterface(libvirttest.BaseTestClass): obj = self.bus.get_object('org.libvirt', test_interface_path) props = obj.GetAll('org.libvirt.Interface', dbus_interface=dbus.PROPERTIES_IFACE) assert isinstance(props['Name'], dbus.String) + assert isinstance(props['MAC'], dbus.String) if __name__ == '__main__': libvirttest.run() -- 2.17.1

On Fri, Jul 20, 2018 at 02:34:54PM -0400, Anya Harter wrote:
Signed-off-by: Anya Harter <aharter@redhat.com> --- data/org.libvirt.Interface.xml | 5 +++++ src/interface.c | 22 ++++++++++++++++++++++ tests/test_interface.py | 1 + 3 files changed, 28 insertions(+)
Reviewed-by: Katerina Koukiou <kkoukiou@redhat.com>

Signed-off-by: Anya Harter <aharter@redhat.com> --- data/org.libvirt.Interface.xml | 5 +++++ src/interface.c | 22 ++++++++++++++++++++++ tests/test_interface.py | 1 + 3 files changed, 28 insertions(+) diff --git a/data/org.libvirt.Interface.xml b/data/org.libvirt.Interface.xml index 921e07f..6dd7c68 100644 --- a/data/org.libvirt.Interface.xml +++ b/data/org.libvirt.Interface.xml @@ -3,6 +3,11 @@ <node name="/org/libvirt/interface"> <interface name="org.libvirt.Interface"> + <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/> + <property name="Active" type="b" access="read"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceIsActive"/> + </property> <property name="MAC" type="s" access="read"> <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceGetMACString"/> diff --git a/src/interface.c b/src/interface.c index 4caafcf..191b8be 100644 --- a/src/interface.c +++ b/src/interface.c @@ -70,6 +70,27 @@ virtDBusInterfaceDestroy(GVariant *inArgs, virtDBusUtilSetLastVirtError(error); } +static void +virtDBusInterfaceGetActive(const gchar *objectPath, + gpointer userData, + GVariant **value, + GError **error) +{ + virtDBusConnect *connect = userData; + g_autoptr(virInterface) interface = NULL; + gint active; + + interface = virtDBusInterfaceGetVirInterface(connect, objectPath, error); + if (!interface) + return; + + active = virInterfaceIsActive(interface); + if (active < 0) + return virtDBusUtilSetLastVirtError(error); + + *value = g_variant_new("b", !!active); +} + static void virtDBusInterfaceGetMAC(const gchar *objectPath, gpointer userData, @@ -160,6 +181,7 @@ virtDBusInterfaceUndefine(GVariant *inArgs G_GNUC_UNUSED, } static virtDBusGDBusPropertyTable virtDBusInterfacePropertyTable[] = { + { "Active", virtDBusInterfaceGetActive, NULL }, { "MAC", virtDBusInterfaceGetMAC, NULL }, { "Name", virtDBusInterfaceGetName, NULL }, { 0 } diff --git a/tests/test_interface.py b/tests/test_interface.py index 325f889..4c7e3fb 100755 --- a/tests/test_interface.py +++ b/tests/test_interface.py @@ -33,6 +33,7 @@ class TestInterface(libvirttest.BaseTestClass): props = obj.GetAll('org.libvirt.Interface', dbus_interface=dbus.PROPERTIES_IFACE) assert isinstance(props['Name'], dbus.String) assert isinstance(props['MAC'], dbus.String) + assert isinstance(props['Active'], dbus.Boolean) if __name__ == '__main__': libvirttest.run() -- 2.17.1

On Fri, Jul 20, 2018 at 02:34:55PM -0400, Anya Harter wrote:
Signed-off-by: Anya Harter <aharter@redhat.com> --- data/org.libvirt.Interface.xml | 5 +++++ src/interface.c | 22 ++++++++++++++++++++++ tests/test_interface.py | 1 + 3 files changed, 28 insertions(+)
Reviewed-by: Katerina Koukiou <kkoukiou@redhat.com>

Signed-off-by: Anya Harter <aharter@redhat.com> --- data/org.libvirt.Connect.xml | 6 ++++++ src/connect.c | 38 ++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index f690bab..791e1f5 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -161,6 +161,12 @@ <arg name="flags" type="u" direction="in"/> <arg name="domains" type="ao" direction="out"/> </method> + <method name="ListInterfaces"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virConnectListAllInterfaces"/> + <arg name="flags" type="u" direction="in"/> + <arg name="interfaces" type="ao" direction="out"/> + </method> <method name="ListNetworks"> <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-network.html#virConnectListAllNetworks"/> diff --git a/src/connect.c b/src/connect.c index 304a56f..9be8264 100644 --- a/src/connect.c +++ b/src/connect.c @@ -801,6 +801,43 @@ virtDBusConnectListDomains(GVariant *inArgs, *outArgs = g_variant_new_tuple(&gdomains, 1); } +static void +virtDBusConnectListInterfaces(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(virInterfacePtr) interfaces = NULL; + guint flags; + GVariantBuilder builder; + GVariant *ginterfaces; + + g_variant_get(inArgs, "(u)", &flags); + + if (!virtDBusConnectOpen(connect, error)) + return; + + if (virConnectListAllInterfaces(connect->connection, &interfaces, flags) < 0) + return virtDBusUtilSetLastVirtError(error); + + g_variant_builder_init(&builder, G_VARIANT_TYPE("ao")); + + for (gint i = 0; interfaces[i]; i++) { + g_autofree gchar *path = NULL; + path = virtDBusUtilBusPathForVirInterface(interfaces[i], + connect->interfacePath); + + g_variant_builder_add(&builder, "o", path); + } + + ginterfaces = g_variant_builder_end(&builder); + *outArgs = g_variant_new_tuple(&ginterfaces, 1); +} + static void virtDBusConnectListNetworks(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -1797,6 +1834,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = { { "GetSysinfo", virtDBusConnectGetSysinfo }, { "InterfaceDefineXML", virtDBusConnectInterfaceDefineXML }, { "ListDomains", virtDBusConnectListDomains }, + { "ListInterfaces", virtDBusConnectListInterfaces }, { "ListNetworks", virtDBusConnectListNetworks }, { "ListNodeDevices", virtDBusConnectListNodeDevices }, { "ListNWFilters", virtDBusConnectListNWFilters }, -- 2.17.1

On Fri, Jul 20, 2018 at 02:34:56PM -0400, Anya Harter wrote:
Signed-off-by: Anya Harter <aharter@redhat.com> --- data/org.libvirt.Connect.xml | 6 ++++++ src/connect.c | 38 ++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+)
Reviewed-by: Katerina Koukiou <kkoukiou@redhat.com>

Signed-off-by: Anya Harter <aharter@redhat.com> --- data/org.libvirt.Connect.xml | 5 +++++ src/connect.c | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index 791e1f5..604afea 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -148,6 +148,11 @@ <arg name="flags" type="u" direction="in"/> <arg name="sysinfo" type="s" direction="out"/> </method> + <method name="InterfaceChangeBegin"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceChangeBegin"/> + <arg name="flags" type="u" direction="in"/> + </method> <method name="InterfaceDefineXML"> <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceDefineXML"/> diff --git a/src/connect.c b/src/connect.c index 9be8264..0e19e91 100644 --- a/src/connect.c +++ b/src/connect.c @@ -735,6 +735,27 @@ virtDBusConnectGetSysinfo(GVariant *inArgs, *outArgs = g_variant_new("(s)", sysinfo); } +static void +virtDBusConnectInterfaceChangeBegin(GVariant *inArgs, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath G_GNUC_UNUSED, + gpointer userData, + GVariant **outArgs G_GNUC_UNUSED, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ + virtDBusConnect *connect = userData; + guint flags; + + g_variant_get(inArgs, "(u)", &flags); + + if (!virtDBusConnectOpen(connect, error)) + return; + + if (virInterfaceChangeBegin(connect->connection, flags) < 0) + virtDBusUtilSetLastVirtError(error); +} + static void virtDBusConnectInterfaceDefineXML(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -1832,6 +1853,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = { { "GetCPUModelNames", virtDBusConnectGetCPUModelNames }, { "GetDomainCapabilities", virtDBusConnectGetDomainCapabilities }, { "GetSysinfo", virtDBusConnectGetSysinfo }, + { "InterfaceChangeBegin", virtDBusConnectInterfaceChangeBegin }, { "InterfaceDefineXML", virtDBusConnectInterfaceDefineXML }, { "ListDomains", virtDBusConnectListDomains }, { "ListInterfaces", virtDBusConnectListInterfaces }, -- 2.17.1

On Fri, Jul 20, 2018 at 02:34:57PM -0400, Anya Harter wrote:
Signed-off-by: Anya Harter <aharter@redhat.com> --- data/org.libvirt.Connect.xml | 5 +++++ src/connect.c | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+)
Reviewed-by: Katerina Koukiou <kkoukiou@redhat.com>

Signed-off-by: Anya Harter <aharter@redhat.com> --- data/org.libvirt.Connect.xml | 5 +++++ src/connect.c | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index 604afea..8c88cc8 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -153,6 +153,11 @@ value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceChangeBegin"/> <arg name="flags" type="u" direction="in"/> </method> + <method name="InterfaceChangeCommit"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceChangeCommit"/> + <arg name="flags" type="u" direction="in"/> + </method> <method name="InterfaceDefineXML"> <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceDefineXML"/> diff --git a/src/connect.c b/src/connect.c index 0e19e91..2acc657 100644 --- a/src/connect.c +++ b/src/connect.c @@ -756,6 +756,27 @@ virtDBusConnectInterfaceChangeBegin(GVariant *inArgs, virtDBusUtilSetLastVirtError(error); } +static void +virtDBusConnectInterfaceChangeCommit(GVariant *inArgs, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath G_GNUC_UNUSED, + gpointer userData, + GVariant **outArgs G_GNUC_UNUSED, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ + virtDBusConnect *connect = userData; + guint flags; + + g_variant_get(inArgs, "(u)", &flags); + + if (!virtDBusConnectOpen(connect, error)) + return; + + if (virInterfaceChangeCommit(connect->connection, flags) < 0) + virtDBusUtilSetLastVirtError(error); +} + static void virtDBusConnectInterfaceDefineXML(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -1854,6 +1875,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = { { "GetDomainCapabilities", virtDBusConnectGetDomainCapabilities }, { "GetSysinfo", virtDBusConnectGetSysinfo }, { "InterfaceChangeBegin", virtDBusConnectInterfaceChangeBegin }, + { "InterfaceChangeCommit", virtDBusConnectInterfaceChangeCommit }, { "InterfaceDefineXML", virtDBusConnectInterfaceDefineXML }, { "ListDomains", virtDBusConnectListDomains }, { "ListInterfaces", virtDBusConnectListInterfaces }, -- 2.17.1

On Fri, Jul 20, 2018 at 02:34:58PM -0400, Anya Harter wrote:
Signed-off-by: Anya Harter <aharter@redhat.com> --- data/org.libvirt.Connect.xml | 5 +++++ src/connect.c | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+)
Reviewed-by: Katerina Koukiou <kkoukiou@redhat.com>

Signed-off-by: Anya Harter <aharter@redhat.com> --- data/org.libvirt.Connect.xml | 5 +++++ src/connect.c | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index 8c88cc8..7c97117 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -158,6 +158,11 @@ value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceChangeCommit"/> <arg name="flags" type="u" direction="in"/> </method> + <method name="InterfaceChangeRollback"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceChangeRollback"/> + <arg name="flags" type="u" direction="in"/> + </method> <method name="InterfaceDefineXML"> <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceDefineXML"/> diff --git a/src/connect.c b/src/connect.c index 2acc657..ebcfa38 100644 --- a/src/connect.c +++ b/src/connect.c @@ -777,6 +777,27 @@ virtDBusConnectInterfaceChangeCommit(GVariant *inArgs, virtDBusUtilSetLastVirtError(error); } +static void +virtDBusConnectInterfaceChangeRollback(GVariant *inArgs, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath G_GNUC_UNUSED, + gpointer userData, + GVariant **outArgs G_GNUC_UNUSED, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ + virtDBusConnect *connect = userData; + guint flags; + + g_variant_get(inArgs, "(u)", &flags); + + if (!virtDBusConnectOpen(connect, error)) + return; + + if (virInterfaceChangeRollback(connect->connection, flags) < 0) + virtDBusUtilSetLastVirtError(error); +} + static void virtDBusConnectInterfaceDefineXML(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -1876,6 +1897,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = { { "GetSysinfo", virtDBusConnectGetSysinfo }, { "InterfaceChangeBegin", virtDBusConnectInterfaceChangeBegin }, { "InterfaceChangeCommit", virtDBusConnectInterfaceChangeCommit }, + { "InterfaceChangeRollback", virtDBusConnectInterfaceChangeRollback }, { "InterfaceDefineXML", virtDBusConnectInterfaceDefineXML }, { "ListDomains", virtDBusConnectListDomains }, { "ListInterfaces", virtDBusConnectListInterfaces }, -- 2.17.1

On Fri, Jul 20, 2018 at 02:34:59PM -0400, Anya Harter wrote:
Signed-off-by: Anya Harter <aharter@redhat.com> --- data/org.libvirt.Connect.xml | 5 +++++ src/connect.c | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+)
Reviewed-by: Katerina Koukiou <kkoukiou@redhat.com>

Signed-off-by: Anya Harter <aharter@redhat.com> --- data/org.libvirt.Connect.xml | 6 ++++++ src/connect.c | 29 +++++++++++++++++++++++++++++ tests/test_connect.py | 12 ++++++++++++ 3 files changed, 47 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index 7c97117..f99e205 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -170,6 +170,12 @@ <arg name="flags" type="u" direction="in"/> <arg name="interface" type="o" direction="out"/> </method> + <method name="InterfaceLookupByName"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceLookupByName"/> + <arg name="name" type="s" direction="in"/> + <arg name="interface" type="o" direction="out"/> + </method> <method name="ListDomains"> <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectListAllDomains"/> diff --git a/src/connect.c b/src/connect.c index ebcfa38..ae64d59 100644 --- a/src/connect.c +++ b/src/connect.c @@ -827,6 +827,34 @@ virtDBusConnectInterfaceDefineXML(GVariant *inArgs, *outArgs = g_variant_new("(o)", path); } +static void +virtDBusConnectInterfaceLookupByName(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 *name; + + g_variant_get(inArgs, "(&s)", &name); + + if (!virtDBusConnectOpen(connect, NULL)) + return; + + interface = virInterfaceLookupByName(connect->connection, name); + if (!interface) + return virtDBusUtilSetLastVirtError(error); + + path = virtDBusUtilBusPathForVirInterface(interface, connect->interfacePath); + + *outArgs = g_variant_new("(o)", path); +} + static void virtDBusConnectListDomains(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -1899,6 +1927,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = { { "InterfaceChangeCommit", virtDBusConnectInterfaceChangeCommit }, { "InterfaceChangeRollback", virtDBusConnectInterfaceChangeRollback }, { "InterfaceDefineXML", virtDBusConnectInterfaceDefineXML }, + { "InterfaceLookupByName", virtDBusConnectInterfaceLookupByName }, { "ListDomains", virtDBusConnectListDomains }, { "ListInterfaces", virtDBusConnectListInterfaces }, { "ListNetworks", virtDBusConnectListNetworks }, diff --git a/tests/test_connect.py b/tests/test_connect.py index d21b366..7e33b2a 100755 --- a/tests/test_connect.py +++ b/tests/test_connect.py @@ -88,6 +88,18 @@ class TestConnect(libvirttest.BaseTestClass): path = self.connect.InterfaceDefineXML(xmldata.minimal_interface_xml, 0) assert isinstance(path, dbus.ObjectPath) + @pytest.mark.parametrize("lookup_method_name,lookup_item", [ + ("InterfaceLookupByName", 'Name'), + ]) + def test_connect_interface_lookup_by_property(self, lookup_method_name, lookup_item): + """Parameterized test for all InterfaceLookupBy* API calls of Connect interface + """ + original_path,_ = self.interface_create() + obj = self.bus.get_object('org.libvirt', original_path) + prop = obj.Get('org.libvirt.Interface', lookup_item, dbus_interface=dbus.PROPERTIES_IFACE) + path = getattr(self.connect, lookup_method_name)(prop) + assert original_path == path + def test_connect_list_networks(self): networks = self.connect.ListNetworks(0) assert isinstance(networks, dbus.Array) -- 2.17.1

On Fri, Jul 20, 2018 at 02:35:00PM -0400, Anya Harter wrote:
Signed-off-by: Anya Harter <aharter@redhat.com> --- data/org.libvirt.Connect.xml | 6 ++++++ src/connect.c | 29 +++++++++++++++++++++++++++++ tests/test_connect.py | 12 ++++++++++++ 3 files changed, 47 insertions(+)
Fixture issues will be fixed in seperate patch. Reviewed-by: Katerina Koukiou <kkoukiou@redhat.com>

Signed-off-by: Anya Harter <aharter@redhat.com> --- 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 @@ <arg name="flags" type="u" direction="in"/> <arg name="interface" type="o" direction="out"/> </method> + <method name="InterfaceLookupByMAC"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceLookupByMACString"/> + <arg name="mac" type="s" direction="in"/> + <arg name="interface" type="o" direction="out"/> + </method> <method name="InterfaceLookupByName"> <annotation name="org.gtk.GDBus.DocString" value="See 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, "(&s)", &mac); + + 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

On Fri, Jul 20, 2018 at 02:35:01PM -0400, Anya Harter wrote:
Signed-off-by: Anya Harter <aharter@redhat.com> --- data/org.libvirt.Connect.xml | 6 ++++++ src/connect.c | 29 +++++++++++++++++++++++++++++ tests/test_connect.py | 1 + 3 files changed, 36 insertions(+)
Reviewed-by: Katerina Koukiou <kkoukiou@redhat.com>
participants (4)
-
Anya Harter
-
Ján Tomko
-
Katerina Koukiou
-
Pavel Hrdina