[libvirt] [dbus PATCH 0/8] Properties/Methods for Connect Interface

Plus some minor fixes. Katerina Koukiou (8): Implement Capabilities property for connect Interface Implement Hostname property for Connect Interface Implement LibVersion property for Connect Interface Implement Encrypted property for Connect Interface Implement Secure property for Connect Interface Implement GetSysinfo method for connect Interface All functions in src/connect.c should have virtDBusConnect prefix. Removing G_GNUC_UNUSED in cases where the parameter is used data/org.libvirt.Connect.xml | 26 ++++++ src/connect.c | 206 ++++++++++++++++++++++++++++++++++--------- src/domain.c | 10 +-- test/test_connect.py | 9 ++ 4 files changed, 206 insertions(+), 45 deletions(-) -- 2.15.0

Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com> --- 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

On Mon, Apr 09, 2018 at 01:47:32PM +0200, Katerina Koukiou wrote:
Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com> --- data/org.libvirt.Connect.xml | 4 ++++ src/connect.c | 20 ++++++++++++++++++++ test/test_connect.py | 1 + 3 files changed, 25 insertions(+)
Adding Dan to CC because I'm not that familiar with D-Bus conventions. This API can be exported as property, however it returns rather large string and not a simple value so I'm not sure whether method would be better in this case. Pavel
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@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

On Mon, Apr 09, 2018 at 02:25:04PM +0200, Pavel Hrdina wrote:
On Mon, Apr 09, 2018 at 01:47:32PM +0200, Katerina Koukiou wrote:
Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com> --- data/org.libvirt.Connect.xml | 4 ++++ src/connect.c | 20 ++++++++++++++++++++ test/test_connect.py | 1 + 3 files changed, 25 insertions(+)
Adding Dan to CC because I'm not that familiar with D-Bus conventions. This API can be exported as property, however it returns rather large string and not a simple value so I'm not sure whether method would be better in this case.
The concept of properties is essentially a convenience to make live easier for mapping into language bindings / higher level object systems. At the protocol level, the properties are handling via a standard interface with a handful of methods https://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces... So whether you have a "Capabilities" property, or a "GetCapabilities" method, you'll still have a method call on the wire protocol, with the full string transmitted. There is also a signal that servers should emit when a property value changes so that clients know that if they have cached the property value, they should refetch it. So potential issues are - If we don't emit PropertyChange signals, clients may cache out of date capabilities - If clients pre-fetch properties there'll be a small perf hit - If we have lots of properties, then the overall size of all properties combined might cause problems for GetAll The first item is the one that would concern me in this instance. The libvirt capabilities data can change between calls, and libvirt has no way to notify you of such changes. Thus IMHO it is better exposed as a dynamic method call than a property. Leave properties for libvirt things that are esentially static data, unless we're able to provide PropertyChange signals. Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

On Mon, 2018-04-09 at 13:45 +0100, Daniel P. Berrangé wrote:
On Mon, Apr 09, 2018 at 02:25:04PM +0200, Pavel Hrdina wrote:
On Mon, Apr 09, 2018 at 01:47:32PM +0200, Katerina Koukiou wrote:
Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com> --- data/org.libvirt.Connect.xml | 4 ++++ src/connect.c | 20 ++++++++++++++++++++ test/test_connect.py | 1 + 3 files changed, 25 insertions(+)
Adding Dan to CC because I'm not that familiar with D-Bus conventions. This API can be exported as property, however it returns rather large string and not a simple value so I'm not sure whether method would be better in this case.
The concept of properties is essentially a convenience to make live easier for mapping into language bindings / higher level object systems.
At the protocol level, the properties are handling via a standard interface with a handful of methods
https://dbus.freedesktop.org/doc/dbus-specification.html#standard-int erfaces-properties
So whether you have a "Capabilities" property, or a "GetCapabilities" method, you'll still have a method call on the wire protocol, with the full string transmitted. There is also a signal that servers should emit when a property value changes so that clients know that if they have cached the property value, they should refetch it.
So potential issues are
- If we don't emit PropertyChange signals, clients may cache out of date capabilities - If clients pre-fetch properties there'll be a small perf hit - If we have lots of properties, then the overall size of all properties combined might cause problems for GetAll
The first item is the one that would concern me in this instance. The libvirt capabilities data can change between calls, and libvirt has no way to notify you of such changes. Thus IMHO it is better exposed as a dynamic method call than a property. Leave properties for libvirt things that are esentially static data, unless we're able to provide PropertyChange signals.
Thanks for the detailed explanation. I will adjust it and repost.
Regards, Daniel
Regards, Katerina

Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com> --- 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 caf0a47..264f84c 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -7,6 +7,10 @@ <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-host.html#virConnectGetCapabilities"/> </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"/> + </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 af61cc8..b34cd95 100644 --- a/src/connect.c +++ b/src/connect.c @@ -110,6 +110,25 @@ virtDBusConnectGetCapabilities(const gchar *objectPath G_GNUC_UNUSED, *value = g_variant_new("s", capabilities); } +static void +virtDBusConnectGetHostname(const gchar *objectPath G_GNUC_UNUSED, + gpointer userData, + GVariant **value, + GError **error) +{ + virtDBusConnect *connect = userData; + g_autofree gchar * hostname = NULL; + + if (!virtDBusConnectOpen(connect, error)) + return; + + hostname = virConnectGetHostname(connect->connection); + if (!hostname) + return virtDBusUtilSetLastVirtError(error); + + *value = g_variant_new("s", hostname); +} + static void virtDBusConnectGetVersion(const gchar *objectPath G_GNUC_UNUSED, gpointer userData, @@ -463,6 +482,7 @@ virtDBusNetworkLookupByUUID(GVariant *inArgs, static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] = { { "Capabilities", virtDBusConnectGetCapabilities, NULL }, + { "Hostname", virtDBusConnectGetHostname, NULL }, { "Version", virtDBusConnectGetVersion, NULL }, { 0 } }; diff --git a/test/test_connect.py b/test/test_connect.py index d7c1e20..75a955e 100755 --- a/test/test_connect.py +++ b/test/test_connect.py @@ -82,6 +82,7 @@ class TestConnect(libvirttest.BaseTestClass): @pytest.mark.parametrize("property_name,expected_type", [ ("Capabilities", dbus.String), + ("Hostname", dbus.String), ("Version", dbus.UInt64), ]) def test_connect_properties_return_type(self, property_name, expected_type): -- 2.15.0

On Mon, Apr 09, 2018 at 01:47:33PM +0200, Katerina Koukiou wrote:
Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com> --- data/org.libvirt.Connect.xml | 4 ++++ src/connect.c | 20 ++++++++++++++++++++ test/test_connect.py | 1 + 3 files changed, 25 insertions(+)
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>

Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com> --- data/org.libvirt.Connect.xml | 4 ++++ src/connect.c | 19 +++++++++++++++++++ test/test_connect.py | 1 + 3 files changed, 24 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index 264f84c..5548820 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -11,6 +11,10 @@ <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-host.html#virConnectGetHostname"/> </property> + <property name="LibVersion" type="t" access="read"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-host.html#virConnectGetLibVersion"/> + </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 b34cd95..3fbb770 100644 --- a/src/connect.c +++ b/src/connect.c @@ -129,6 +129,24 @@ virtDBusConnectGetHostname(const gchar *objectPath G_GNUC_UNUSED, *value = g_variant_new("s", hostname); } +static void +virtDBusConnectGetLibVersion(const gchar *objectPath G_GNUC_UNUSED, + gpointer userData, + GVariant **value, + GError **error) +{ + virtDBusConnect *connect = userData; + gulong libVer; + + if (!virtDBusConnectOpen(connect, error)) + return; + + if (virConnectGetLibVersion(connect->connection, &libVer) < 0) + return virtDBusUtilSetLastVirtError(error); + + *value = g_variant_new("t", libVer); +} + static void virtDBusConnectGetVersion(const gchar *objectPath G_GNUC_UNUSED, gpointer userData, @@ -483,6 +501,7 @@ virtDBusNetworkLookupByUUID(GVariant *inArgs, static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] = { { "Capabilities", virtDBusConnectGetCapabilities, NULL }, { "Hostname", virtDBusConnectGetHostname, NULL }, + { "LibVersion", virtDBusConnectGetLibVersion, NULL }, { "Version", virtDBusConnectGetVersion, NULL }, { 0 } }; diff --git a/test/test_connect.py b/test/test_connect.py index 75a955e..f544f76 100755 --- a/test/test_connect.py +++ b/test/test_connect.py @@ -83,6 +83,7 @@ class TestConnect(libvirttest.BaseTestClass): @pytest.mark.parametrize("property_name,expected_type", [ ("Capabilities", dbus.String), ("Hostname", dbus.String), + ("LibVersion", dbus.UInt64), ("Version", dbus.UInt64), ]) def test_connect_properties_return_type(self, property_name, expected_type): -- 2.15.0

On Mon, Apr 09, 2018 at 01:47:34PM +0200, Katerina Koukiou wrote:
Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com> --- data/org.libvirt.Connect.xml | 4 ++++ src/connect.c | 19 +++++++++++++++++++ test/test_connect.py | 1 + 3 files changed, 24 insertions(+)
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>

Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com> --- 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 5548820..3791251 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -7,6 +7,10 @@ <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-host.html#virConnectGetCapabilities"/> </property> + <property name="Encrypted" type="b" access="read"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-host.html#virConnectIsEncrypted"/> + </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 3fbb770..4d90fc4 100644 --- a/src/connect.c +++ b/src/connect.c @@ -110,6 +110,25 @@ virtDBusConnectGetCapabilities(const gchar *objectPath G_GNUC_UNUSED, *value = g_variant_new("s", capabilities); } +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, @@ -500,6 +519,7 @@ virtDBusNetworkLookupByUUID(GVariant *inArgs, static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] = { { "Capabilities", virtDBusConnectGetCapabilities, NULL }, + { "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 f544f76..91c8bb6 100755 --- a/test/test_connect.py +++ b/test/test_connect.py @@ -82,6 +82,7 @@ class TestConnect(libvirttest.BaseTestClass): @pytest.mark.parametrize("property_name,expected_type", [ ("Capabilities", dbus.String), + ("Encrypted", dbus.Boolean), ("Hostname", dbus.String), ("LibVersion", dbus.UInt64), ("Version", dbus.UInt64), -- 2.15.0

On Mon, Apr 09, 2018 at 01:47:35PM +0200, Katerina Koukiou wrote:
Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com> --- data/org.libvirt.Connect.xml | 4 ++++ src/connect.c | 20 ++++++++++++++++++++ test/test_connect.py | 1 + 3 files changed, 25 insertions(+)
This and the Secure properties are not that simple to just export them. The reason is that the communication over D-Bus can be monitored even if the connection from libvirt-dbus to libvirt is secure. I would skip these two properties for now until we figure it out. Pavel

On Mon, Apr 09, 2018 at 02:40:27PM +0200, Pavel Hrdina wrote:
On Mon, Apr 09, 2018 at 01:47:35PM +0200, Katerina Koukiou wrote:
Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com> --- data/org.libvirt.Connect.xml | 4 ++++ src/connect.c | 20 ++++++++++++++++++++ test/test_connect.py | 1 + 3 files changed, 25 insertions(+)
This and the Secure properties are not that simple to just export them. The reason is that the communication over D-Bus can be monitored even if the connection from libvirt-dbus to libvirt is secure. I would skip these two properties for now until we figure it out.
I don't think that's a big problem - I think it is just a documentation task to say that monitoring of traffic on the dbus message bus is out of scope for these properties. IOW they just reflect the security properties of the libvirt-dbus <-> hypervisor paths, not the dbus client <-> hypervisor paths Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

On Mon, Apr 09, 2018 at 01:49:07PM +0100, Daniel P. Berrangé wrote:
On Mon, Apr 09, 2018 at 02:40:27PM +0200, Pavel Hrdina wrote:
On Mon, Apr 09, 2018 at 01:47:35PM +0200, Katerina Koukiou wrote:
Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com> --- data/org.libvirt.Connect.xml | 4 ++++ src/connect.c | 20 ++++++++++++++++++++ test/test_connect.py | 1 + 3 files changed, 25 insertions(+)
This and the Secure properties are not that simple to just export them. The reason is that the communication over D-Bus can be monitored even if the connection from libvirt-dbus to libvirt is secure. I would skip these two properties for now until we figure it out.
I don't think that's a big problem - I think it is just a documentation task to say that monitoring of traffic on the dbus message bus is out of scope for these properties. IOW they just reflect the security properties of the libvirt-dbus <-> hypervisor paths, not the dbus client <-> hypervisor paths
The only concern that I have is that it might be misleading to see the connection as secure but in fact the whole communication is not secure or encrypted. Currently every connection is secure and not encrypted since we use only local connections. In the future if we allow to configure remote connection it will have some value. I guess that user will have to trust to the system where the D-Bus communication is held on. Pavel

Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com> --- 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 3791251..8416339 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -19,6 +19,10 @@ <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-host.html#virConnectGetLibVersion"/> </property> + <property name="Secure" type="b" access="read"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-host.html#virConnectIsSecure"/> + </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 4d90fc4..9bf08c8 100644 --- a/src/connect.c +++ b/src/connect.c @@ -166,6 +166,25 @@ virtDBusConnectGetLibVersion(const gchar *objectPath G_GNUC_UNUSED, *value = g_variant_new("t", libVer); } +static void +virtDBusConnectGetSecure(const gchar *objectPath G_GNUC_UNUSED, + gpointer userData, + GVariant **value, + GError **error) +{ + virtDBusConnect *connect = userData; + gint secure; + + if (!virtDBusConnectOpen(connect, error)) + return; + + secure = virConnectIsEncrypted(connect->connection); + if (secure < 0) + return virtDBusUtilSetLastVirtError(error); + + *value = g_variant_new("b", !!secure); +} + static void virtDBusConnectGetVersion(const gchar *objectPath G_GNUC_UNUSED, gpointer userData, @@ -522,6 +541,7 @@ static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] = { { "Encrypted", virtDBusConnectGetEncrypted, NULL }, { "Hostname", virtDBusConnectGetHostname, NULL }, { "LibVersion", virtDBusConnectGetLibVersion, NULL }, + { "Secure", virtDBusConnectGetSecure, NULL }, { "Version", virtDBusConnectGetVersion, NULL }, { 0 } }; diff --git a/test/test_connect.py b/test/test_connect.py index 91c8bb6..d698a53 100755 --- a/test/test_connect.py +++ b/test/test_connect.py @@ -85,6 +85,7 @@ class TestConnect(libvirttest.BaseTestClass): ("Encrypted", dbus.Boolean), ("Hostname", dbus.String), ("LibVersion", dbus.UInt64), + ("Secure", dbus.Boolean), ("Version", dbus.UInt64), ]) def test_connect_properties_return_type(self, property_name, expected_type): -- 2.15.0

Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com> --- data/org.libvirt.Connect.xml | 6 ++++++ src/connect.c | 27 +++++++++++++++++++++++++++ test/test_connect.py | 4 ++++ 3 files changed, 37 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index 8416339..c58d3ce 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -64,6 +64,12 @@ <arg name="uuid" type="s" direction="in"/> <arg name="domain" type="o" direction="out"/> </method> + <method name="GetSysinfo"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-host.html#virConnectGetSysinfo"/> + <arg name="flags" type="u" direction="in"/> + <arg name="sysinfo" type="s" 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 9bf08c8..7f9344e 100644 --- a/src/connect.c +++ b/src/connect.c @@ -384,6 +384,32 @@ virtDBusDomainLookupByUUID(GVariant *inArgs, *outArgs = g_variant_new("(o)", path); } +static void +virtDBusConnectGetSysinfo(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; + guint flags; + g_autofree gchar *sysinfo = NULL; + + g_variant_get(inArgs, "(u)", &flags); + + if (!virtDBusConnectOpen(connect, error)) + return; + + sysinfo = virConnectGetSysinfo(connect->connection, flags); + if (!sysinfo) + return virtDBusUtilSetLastVirtError(error); + + *outArgs = g_variant_new("(s)", sysinfo); +} + static void virtDBusConnectListNetworks(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -553,6 +579,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = { { "DomainLookupByID", virtDBusDomainLookupByID }, { "DomainLookupByName", virtDBusDomainLookupByName }, { "DomainLookupByUUID", virtDBusDomainLookupByUUID }, + { "GetSysinfo", virtDBusConnectGetSysinfo }, { "ListNetworks", virtDBusConnectListNetworks }, { "NetworkCreateXML", virtDBusConnectNetworkCreateXML }, { "NetworkDefineXML", virtDBusConnectNetworkDefineXML }, diff --git a/test/test_connect.py b/test/test_connect.py index d698a53..aa30971 100755 --- a/test/test_connect.py +++ b/test/test_connect.py @@ -93,6 +93,10 @@ class TestConnect(libvirttest.BaseTestClass): props = obj.GetAll('org.libvirt.Connect', dbus_interface=dbus.PROPERTIES_IFACE) assert isinstance(props[property_name], expected_type) + def test_connect_get_sysinfo(self): + sysinfo = self.connect.GetSysinfo(0) + assert isinstance(sysinfo, dbus.String) + def test_list_networks(self): networks = self.connect.ListNetworks(0) assert isinstance(networks, dbus.Array) -- 2.15.0

On Mon, Apr 09, 2018 at 01:47:37PM +0200, Katerina Koukiou wrote:
Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com> --- data/org.libvirt.Connect.xml | 6 ++++++ src/connect.c | 27 +++++++++++++++++++++++++++ test/test_connect.py | 4 ++++ 3 files changed, 37 insertions(+)
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>

Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com> --- src/connect.c | 80 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/src/connect.c b/src/connect.c index 7f9344e..1ff3341 100644 --- a/src/connect.c +++ b/src/connect.c @@ -301,13 +301,13 @@ virtDBusConnectDomainDefineXML(GVariant *inArgs, } static void -virtDBusDomainLookupByID(GVariant *inArgs, - GUnixFDList *inFDs G_GNUC_UNUSED, - const gchar *objectPath G_GNUC_UNUSED, - gpointer userData, - GVariant **outArgs, - GUnixFDList **outFDs G_GNUC_UNUSED, - GError **error) +virtDBusConnectDomainLookupByID(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(virDomain) domain = NULL; @@ -329,13 +329,13 @@ virtDBusDomainLookupByID(GVariant *inArgs, } static void -virtDBusDomainLookupByName(GVariant *inArgs, - GUnixFDList *inFDs G_GNUC_UNUSED, - const gchar *objectPath G_GNUC_UNUSED, - gpointer userData, - GVariant **outArgs, - GUnixFDList **outFDs G_GNUC_UNUSED, - GError **error) +virtDBusConnectDomainLookupByName(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(virDomain) domain = NULL; @@ -357,13 +357,13 @@ virtDBusDomainLookupByName(GVariant *inArgs, } static void -virtDBusDomainLookupByUUID(GVariant *inArgs, - GUnixFDList *inFDs G_GNUC_UNUSED, - const gchar *objectPath G_GNUC_UNUSED, - gpointer userData, - GVariant **outArgs, - GUnixFDList **outFDs G_GNUC_UNUSED, - GError **error) +virtDBusConnectDomainLookupByUUID(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(virDomain) domain = NULL; @@ -507,13 +507,13 @@ virtDBusConnectNetworkDefineXML(GVariant *inArgs, } static void -virtDBusNetworkLookupByName(GVariant *inArgs, - GUnixFDList *inFDs G_GNUC_UNUSED, - const gchar *objectPath G_GNUC_UNUSED, - gpointer userData, - GVariant **outArgs, - GUnixFDList **outFDs G_GNUC_UNUSED, - GError **error) +virtDBusConnectNetworkLookupByName(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(virNetwork) network = NULL; @@ -535,13 +535,13 @@ virtDBusNetworkLookupByName(GVariant *inArgs, } static void -virtDBusNetworkLookupByUUID(GVariant *inArgs, - GUnixFDList *inFDs G_GNUC_UNUSED, - const gchar *objectPath G_GNUC_UNUSED, - gpointer userData, - GVariant **outArgs, - GUnixFDList **outFDs G_GNUC_UNUSED, - GError **error) +virtDBusConnectNetworkLookupByUUID(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(virNetwork) network = NULL; @@ -576,15 +576,15 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = { { "ListDomains", virtDBusConnectListDomains }, { "DomainCreateXML", virtDBusConnectDomainCreateXML }, { "DomainDefineXML", virtDBusConnectDomainDefineXML }, - { "DomainLookupByID", virtDBusDomainLookupByID }, - { "DomainLookupByName", virtDBusDomainLookupByName }, - { "DomainLookupByUUID", virtDBusDomainLookupByUUID }, + { "DomainLookupByID", virtDBusConnectDomainLookupByID }, + { "DomainLookupByName", virtDBusConnectDomainLookupByName }, + { "DomainLookupByUUID", virtDBusConnectDomainLookupByUUID }, { "GetSysinfo", virtDBusConnectGetSysinfo }, { "ListNetworks", virtDBusConnectListNetworks }, { "NetworkCreateXML", virtDBusConnectNetworkCreateXML }, { "NetworkDefineXML", virtDBusConnectNetworkDefineXML }, - { "NetworkLookupByName", virtDBusNetworkLookupByName }, - { "NetworkLookupByUUID", virtDBusNetworkLookupByUUID }, + { "NetworkLookupByName", virtDBusConnectNetworkLookupByName }, + { "NetworkLookupByUUID", virtDBusConnectNetworkLookupByUUID }, { 0 } }; -- 2.15.0

On Mon, Apr 09, 2018 at 01:47:38PM +0200, Katerina Koukiou wrote: s/.// in $subject
Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com> --- src/connect.c | 80 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 40 insertions(+), 40 deletions(-)
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>

Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com> --- src/domain.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/domain.c b/src/domain.c index a530987..0066788 100644 --- a/src/domain.c +++ b/src/domain.c @@ -311,7 +311,7 @@ virtDBusDomainGetStats(GVariant *inArgs, } static void -virtDBusDomainShutdown(GVariant *inArgs G_GNUC_UNUSED, +virtDBusDomainShutdown(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, const gchar *objectPath, gpointer userData, @@ -334,7 +334,7 @@ virtDBusDomainShutdown(GVariant *inArgs G_GNUC_UNUSED, } static void -virtDBusDomainDestroy(GVariant *inArgs G_GNUC_UNUSED, +virtDBusDomainDestroy(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, const gchar *objectPath, gpointer userData, @@ -359,7 +359,7 @@ virtDBusDomainDestroy(GVariant *inArgs G_GNUC_UNUSED, static void virtDBusDomainReboot(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, - const gchar *objectPath G_GNUC_UNUSED, + const gchar *objectPath, gpointer userData, GVariant **outArgs G_GNUC_UNUSED, GUnixFDList **outFDs G_GNUC_UNUSED, @@ -405,7 +405,7 @@ virtDBusDomainReset(GVariant *inArgs, } static void -virtDBusDomainCreate(GVariant *inArgs G_GNUC_UNUSED, +virtDBusDomainCreate(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, const gchar *objectPath, gpointer userData, @@ -428,7 +428,7 @@ virtDBusDomainCreate(GVariant *inArgs G_GNUC_UNUSED, } static void -virtDBusDomainUndefine(GVariant *inArgs G_GNUC_UNUSED, +virtDBusDomainUndefine(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, const gchar *objectPath, gpointer userData, -- 2.15.0

On Mon, Apr 09, 2018 at 01:47:39PM +0200, Katerina Koukiou wrote:
Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com> --- src/domain.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
participants (3)
-
Daniel P. Berrangé
-
Katerina Koukiou
-
Pavel Hrdina