Re: [dbus PATCH 1/2] Add 'Version' property for virConnectGetVersion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2018-03-26 at 16:58 +0200, Katerina Koukiou wrote:
> ---
>  data/org.libvirt.Connect.xml |  4 ++++
>  src/connect.c                | 25 ++++++++++++++++++++++++-
>  test/test_connect.py         |  8 ++++++++
>  3 files changed, 36 insertions(+), 1 deletion(-)
> 
> diff --git a/data/org.libvirt.Connect.xml
> b/data/org.libvirt.Connect.xml
> index e47c2f5..56a1126 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="Version" type="t" access="read">
> +      <annotation name="org.gtk.GDBus.DocString"
> +        value="See https://libvirt.org/html/libvirt-libvirt-domain.h
> tml#virConnectGetVersion"/>;
> +    </property>
>      <method name="ListDomains">
>        <annotation name="org.gtk.GDBus.DocString"
>          value="See https://libvirt.org/html/libvirt-libvirt-domain.h
> tml#virConnectListAllDomains"/>;
> diff --git a/src/connect.c b/src/connect.c
> index bf97cd5..8898e6d 100644
> --- a/src/connect.c
> +++ b/src/connect.c
> @@ -80,6 +80,24 @@ virtDBusConnectOpen(virtDBusConnect *connect,
>      return TRUE;
>  }
>  
> +static void
> +virtDBusConnectGetVersion(const gchar *objectPath G_GNUC_UNUSED,
> +                          gpointer userData,
> +                          GVariant **value,
> +                          GError **error)
> +{
> +    virtDBusConnect *connect = userData;
> +    gulong hvVer;
> +
> +    if (!virtDBusConnectOpen(connect, error))
> +        return;
> +
> +    if (virConnectGetVersion(connect->connection, &hvVer) < 0)
> +        return virtDBusUtilSetLastVirtError(error);
> +
> +    *value = g_variant_new("t", hvVer);
> +}
> +
>  static void
>  virtDBusConnectListDomains(GVariant *inArgs,
>                             GUnixFDList *inFDs G_GNUC_UNUSED,
> @@ -177,6 +195,11 @@ virtDBusConnectDefineXML(GVariant *inArgs,
>      *outArgs = g_variant_new("(o)", path);
>  }
>  
> +static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] = {
> +    { "Version", virtDBusConnectGetVersion, NULL },
> +    { NULL, NULL, NULL }
> +};
> +
>  static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = {
>      { "ListDomains", virtDBusConnectListDomains },
>      { "CreateXML", virtDBusConnectCreateXML },
> @@ -228,7 +251,7 @@ virtDBusConnectNew(virtDBusConnect **connectp,
>                                  connect->connectPath,
>                                  interfaceInfo,
>                                  virtDBusConnectMethodTable,
> -                                NULL,
> +                                virtDBusConnectPropertyTable,
>                                  connect);
>  
>      virtDBusDomainRegister(connect, error);
> diff --git a/test/test_connect.py b/test/test_connect.py
> index a52140c..02a7161 100755
> --- a/test/test_connect.py
> +++ b/test/test_connect.py
> @@ -2,6 +2,7 @@
>  
>  import dbus
>  import libvirttest
> +import pytest
>  
>  
>  class TestConnect(libvirttest.BaseTestClass):
> @@ -53,6 +54,13 @@ class TestConnect(libvirttest.BaseTestClass):
>  
>          self.main_loop()
>  
> +    @pytest.mark.parametrize("property_name,expected_type", [
> +    ("Version", dbus.UInt64),
Bad indentation. Will repost.
> +    ])
> +    def test_connect_properties_return_type(self, property_name,
> expected_type):
> +        obj = self.bus.get_object('org.libvirt',
> '/org/libvirt/Test')
> +        props = obj.GetAll('org.libvirt.Connect',
> dbus_interface=dbus.PROPERTIES_IFACE)
> +        assert isinstance(props[property_name], expected_type)
>  
Should be two blank lines here. 
>  if __name__ == '__main__':
>      libvirttest.run()

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux