Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx> --- data/org.libvirt.Connect.xml | 4 ++++ src/connect.c | 20 ++++++++++++++++++++ test/test_connect.py | 1 + 3 files changed, 25 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index e36b7f6..caf0a47 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -3,6 +3,10 @@ <node name="/org/libvirt/connect"> <interface name="org.libvirt.Connect"> + <property name="Capabilities" type="s" access="read"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-host.html#virConnectGetCapabilities"/> + </property> <property name="Version" type="t" access="read"> <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-host.html#virConnectGetVersion"/> diff --git a/src/connect.c b/src/connect.c index ce9055a..af61cc8 100644 --- a/src/connect.c +++ b/src/connect.c @@ -91,6 +91,25 @@ virtDBusConnectOpen(virtDBusConnect *connect, return TRUE; } +static void +virtDBusConnectGetCapabilities(const gchar *objectPath G_GNUC_UNUSED, + gpointer userData, + GVariant **value, + GError **error) +{ + virtDBusConnect *connect = userData; + g_autofree gchar *capabilities = NULL; + + if (!virtDBusConnectOpen(connect, error)) + return; + + capabilities = virConnectGetCapabilities(connect->connection); + if (!capabilities) + return virtDBusUtilSetLastVirtError(error); + + *value = g_variant_new("s", capabilities); +} + static void virtDBusConnectGetVersion(const gchar *objectPath G_GNUC_UNUSED, gpointer userData, @@ -443,6 +462,7 @@ virtDBusNetworkLookupByUUID(GVariant *inArgs, } static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] = { + { "Capabilities", virtDBusConnectGetCapabilities, NULL }, { "Version", virtDBusConnectGetVersion, NULL }, { 0 } }; diff --git a/test/test_connect.py b/test/test_connect.py index c411eeb..d7c1e20 100755 --- a/test/test_connect.py +++ b/test/test_connect.py @@ -81,6 +81,7 @@ class TestConnect(libvirttest.BaseTestClass): assert original_path == path @pytest.mark.parametrize("property_name,expected_type", [ + ("Capabilities", dbus.String), ("Version", dbus.UInt64), ]) def test_connect_properties_return_type(self, property_name, expected_type): -- 2.15.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list