Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx> --- data/org.libvirt.Connect.xml | 5 +++++ src/connect.c | 20 ++++++++++++++++++++ test/test_connect.py | 1 + 3 files changed, 26 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index 0e5c7e2..84eadb0 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -3,6 +3,11 @@ <node name="/org/libvirt/connect"> <interface name="org.libvirt.Connect"> + <property name="Encrypted" type="b" access="read"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-host.html#virConnectIsEncrypted + Note that monitoring of traffic on the dbus message bus is out of the scope of this property"/> + </property> <property name="Hostname" type="s" access="read"> <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-host.html#virConnectGetHostname"/> diff --git a/src/connect.c b/src/connect.c index 78ed971..8335e51 100644 --- a/src/connect.c +++ b/src/connect.c @@ -91,6 +91,25 @@ virtDBusConnectOpen(virtDBusConnect *connect, return TRUE; } +static void +virtDBusConnectGetEncrypted(const gchar *objectPath G_GNUC_UNUSED, + gpointer userData, + GVariant **value, + GError **error) +{ + virtDBusConnect *connect = userData; + gint encrypted; + + if (!virtDBusConnectOpen(connect, error)) + return; + + encrypted = virConnectIsEncrypted(connect->connection); + if (encrypted < 0) + return virtDBusUtilSetLastVirtError(error); + + *value = g_variant_new("b", !!encrypted); +} + static void virtDBusConnectGetHostname(const gchar *objectPath G_GNUC_UNUSED, gpointer userData, @@ -502,6 +521,7 @@ virtDBusNetworkLookupByUUID(GVariant *inArgs, } static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] = { + { "Encrypted", virtDBusConnectGetEncrypted, NULL }, { "Hostname", virtDBusConnectGetHostname, NULL }, { "LibVersion", virtDBusConnectGetLibVersion, NULL }, { "Version", virtDBusConnectGetVersion, NULL }, diff --git a/test/test_connect.py b/test/test_connect.py index d24cba5..58bc267 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", [ + ("Encrypted", dbus.Boolean), ("Hostname", dbus.String), ("LibVersion", dbus.UInt64), ("Version", dbus.UInt64), -- 2.15.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list