Also test was renamed from test_list_domains to test_connect_list_domains to follow the naming convention. Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx> --- data/org.libvirt.Connect.xml | 12 +++---- src/connect.c | 82 ++++++++++++++++++++++---------------------- test/test_connect.py | 24 ++++++------- 3 files changed, 59 insertions(+), 59 deletions(-) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index 5b49ed9..55260cc 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -25,12 +25,6 @@ <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-host.html#virConnectGetVersion"/> </property> - <method name="ListDomains"> - <annotation name="org.gtk.GDBus.DocString" - value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectListAllDomains"/> - <arg name="flags" type="u" direction="in"/> - <arg name="domains" type="ao" direction="out"/> - </method> <method name="DomainCreateXML"> <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainCreateXML"/> @@ -73,6 +67,12 @@ <arg name="flags" type="u" direction="in"/> <arg name="sysinfo" type="s" direction="out"/> </method> + <method name="ListDomains"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectListAllDomains"/> + <arg name="flags" type="u" direction="in"/> + <arg name="domains" 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 9820de5..a8ff43c 100644 --- a/src/connect.c +++ b/src/connect.c @@ -206,46 +206,6 @@ virtDBusConnectGetCapabilities(GVariant *inArgs G_GNUC_UNUSED, *outArgs = g_variant_new("(s)", capabilities); } -static void -virtDBusConnectListDomains(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(virDomainPtr) domains = NULL; - guint flags; - GVariantBuilder builder; - GVariant *gdomains; - - g_variant_get(inArgs, "(u)", &flags); - - if (!virtDBusConnectOpen(connect, error)) - return; - - if (virConnectListAllDomains(connect->connection, &domains, flags) < 0) - return virtDBusUtilSetLastVirtError(error); - - if (!*domains) - return; - - g_variant_builder_init(&builder, G_VARIANT_TYPE("ao")); - - for (gint i = 0; domains[i]; i++) { - g_autofree gchar *path = NULL; - path = virtDBusUtilBusPathForVirDomain(domains[i], - connect->domainPath); - - g_variant_builder_add(&builder, "o", path); - } - - gdomains = g_variant_builder_end(&builder); - *outArgs = g_variant_new_tuple(&gdomains, 1); -} - static void virtDBusConnectDomainCreateXML(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -413,6 +373,46 @@ virtDBusConnectGetSysinfo(GVariant *inArgs, *outArgs = g_variant_new("(s)", sysinfo); } +static void +virtDBusConnectListDomains(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(virDomainPtr) domains = NULL; + guint flags; + GVariantBuilder builder; + GVariant *gdomains; + + g_variant_get(inArgs, "(u)", &flags); + + if (!virtDBusConnectOpen(connect, error)) + return; + + if (virConnectListAllDomains(connect->connection, &domains, flags) < 0) + return virtDBusUtilSetLastVirtError(error); + + if (!*domains) + return; + + g_variant_builder_init(&builder, G_VARIANT_TYPE("ao")); + + for (gint i = 0; domains[i]; i++) { + g_autofree gchar *path = NULL; + path = virtDBusUtilBusPathForVirDomain(domains[i], + connect->domainPath); + + g_variant_builder_add(&builder, "o", path); + } + + gdomains = g_variant_builder_end(&builder); + *outArgs = g_variant_new_tuple(&gdomains, 1); +} + static void virtDBusConnectListNetworks(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -575,7 +575,6 @@ static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] = { }; static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = { - { "ListDomains", virtDBusConnectListDomains }, { "DomainCreateXML", virtDBusConnectDomainCreateXML }, { "DomainDefineXML", virtDBusConnectDomainDefineXML }, { "DomainLookupByID", virtDBusConnectDomainLookupByID }, @@ -583,6 +582,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = { { "DomainLookupByUUID", virtDBusConnectDomainLookupByUUID }, { "GetCapabilities", virtDBusConnectGetCapabilities }, { "GetSysinfo", virtDBusConnectGetSysinfo }, + { "ListDomains", virtDBusConnectListDomains }, { "ListNetworks", virtDBusConnectListNetworks }, { "NetworkCreateXML", virtDBusConnectNetworkCreateXML }, { "NetworkDefineXML", virtDBusConnectNetworkDefineXML }, diff --git a/test/test_connect.py b/test/test_connect.py index 8948947..a7b7ad6 100755 --- a/test/test_connect.py +++ b/test/test_connect.py @@ -30,18 +30,6 @@ class TestConnect(libvirttest.BaseTestClass): </network> ''' - def test_list_domains(self): - domains = self.connect.ListDomains(0) - assert isinstance(domains, dbus.Array) - assert len(domains) == 1 - - for path in domains: - assert isinstance(path, dbus.ObjectPath) - domain = self.bus.get_object('org.libvirt', path) - - # ensure the path exists by calling Introspect on it - domain.Introspect(dbus_interface=dbus.INTROSPECTABLE_IFACE) - def test_connect_domain_create_xml(self): def domain_started(path, _event): assert isinstance(path, dbus.ObjectPath) @@ -80,6 +68,18 @@ class TestConnect(libvirttest.BaseTestClass): path = getattr(self.connect, lookup_method_name)(props[lookup_item]) assert original_path == path + def test_connect_list_domains(self): + domains = self.connect.ListDomains(0) + assert isinstance(domains, dbus.Array) + assert len(domains) == 1 + + for path in domains: + assert isinstance(path, dbus.ObjectPath) + domain = self.bus.get_object('org.libvirt', path) + + # ensure the path exists by calling Introspect on it + domain.Introspect(dbus_interface=dbus.INTROSPECTABLE_IFACE) + @pytest.mark.parametrize("property_name,expected_type", [ ("Encrypted", dbus.Boolean), ("Hostname", dbus.String), -- 2.15.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list