Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx> --- data/org.libvirt.Domain.xml | 8 ++++---- src/domain.c | 44 ++++++++++++++++++++++---------------------- test/test_domain.py | 2 +- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/data/org.libvirt.Domain.xml b/data/org.libvirt.Domain.xml index 7679018..1bbb383 100644 --- a/data/org.libvirt.Domain.xml +++ b/data/org.libvirt.Domain.xml @@ -3,6 +3,10 @@ <node name="/org/libvirt/domain"> <interface name="org.libvirt.Domain"> + <property name="Active" type="b" access="read"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainIsActive"/> + </property> <property name="Name" type="s" access="read"> <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetName"/> @@ -19,10 +23,6 @@ <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetOSType"/> </property> - <property name="Active" type="b" access="read"> - <annotation name="org.gtk.GDBus.DocString" - value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainIsActive"/> - </property> <property name="Persistent" type="b" access="read"> <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainIsPersistent"/> diff --git a/src/domain.c b/src/domain.c index 0066788..92cf21a 100644 --- a/src/domain.c +++ b/src/domain.c @@ -24,6 +24,27 @@ virtDBusDomainGetVirDomain(virtDBusConnect *connect, return domain; } +static void +virtDBusDomainGetActive(const gchar *objectPath, + gpointer userData, + GVariant **value, + GError **error) +{ + virtDBusConnect *connect = userData; + g_autoptr(virDomain) domain = NULL; + gint active; + + domain = virtDBusDomainGetVirDomain(connect, objectPath, error); + if (!domain) + return; + + active = virDomainIsActive(domain); + if (active < 0) + return virtDBusUtilSetLastVirtError(error); + + *value = g_variant_new("b", !!active); +} + static void virtDBusDomainGetName(const gchar *objectPath, gpointer userData, @@ -107,27 +128,6 @@ virtDBusDomainGetOsType(const gchar *objectPath, *value = g_variant_new("s", osType); } -static void -virtDBusDomainGetActive(const gchar *objectPath, - gpointer userData, - GVariant **value, - GError **error) -{ - virtDBusConnect *connect = userData; - g_autoptr(virDomain) domain = NULL; - gint active; - - domain = virtDBusDomainGetVirDomain(connect, objectPath, error); - if (!domain) - return; - - active = virDomainIsActive(domain); - if (active < 0) - return virtDBusUtilSetLastVirtError(error); - - *value = g_variant_new("b", !!active); -} - static void virtDBusDomainGetPersistent(const gchar *objectPath, gpointer userData, @@ -491,11 +491,11 @@ virtDBusDomainResume(GVariant *inArgs G_GNUC_UNUSED, } static virtDBusGDBusPropertyTable virtDBusDomainPropertyTable[] = { + { "Active", virtDBusDomainGetActive, NULL }, { "Name", virtDBusDomainGetName, NULL }, { "UUID", virtDBusDomainGetUUID, NULL }, { "Id", virtDBusDomainGetId, NULL }, { "OSType", virtDBusDomainGetOsType, NULL }, - { "Active", virtDBusDomainGetActive, NULL }, { "Persistent", virtDBusDomainGetPersistent, NULL }, { "State", virtDBusDomainGetState, NULL }, { "Autostart", virtDBusDomainGetAutostart, NULL }, diff --git a/test/test_domain.py b/test/test_domain.py index 7ec2318..58d389e 100755 --- a/test/test_domain.py +++ b/test/test_domain.py @@ -10,11 +10,11 @@ class TestDomain(libvirttest.BaseTestClass): obj, domain = self.domain() props = obj.GetAll('org.libvirt.Domain', dbus_interface=dbus.PROPERTIES_IFACE) + assert isinstance(props['Active'], dbus.Boolean) assert isinstance(props['Name'], dbus.String) assert isinstance(props['UUID'], dbus.String) assert isinstance(props['Id'], dbus.UInt32) assert isinstance(props['OSType'], dbus.String) - assert isinstance(props['Active'], dbus.Boolean) assert isinstance(props['Persistent'], dbus.Boolean) assert isinstance(props['State'], dbus.String) assert isinstance(props['Autostart'], dbus.Boolean) -- 2.15.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list