We need to catch Exceptions when testing this API call, since virDomainDestroyFlags will be supported in test-driver in 4.2.0 libvirt release. Better version checks for unsupported API calls need to be done in all tests, but it's not relevant to this commit. When virConnectGetVersion will be supported we can move to better implementation, and python logging should be used to provide proper warnings for skipped tests. Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx> --- data/org.libvirt.Domain.xml | 4 +++- src/domain.c | 5 ++++- test/test_domain.py | 7 ++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/data/org.libvirt.Domain.xml b/data/org.libvirt.Domain.xml index 4b1a650..dcaca5e 100644 --- a/data/org.libvirt.Domain.xml +++ b/data/org.libvirt.Domain.xml @@ -27,7 +27,9 @@ <method name="ShutdownFlags"> <arg name="flags" type="u" direction="in"/> </method> - <method name="Destroy"/> + <method name="Destroy"> + <arg name="flags" type="u" direction="in"/> + </method> <method name="Reboot"> <arg name="flags" type="u" direction="in"/> </method> diff --git a/src/domain.c b/src/domain.c index cc4e692..9e13862 100644 --- a/src/domain.c +++ b/src/domain.c @@ -343,12 +343,15 @@ virtDBusDomainDestroy(GVariant *inArgs G_GNUC_UNUSED, { virtDBusConnect *connect = userData; g_autoptr(virDomain) domain = NULL; + guint flags; + + g_variant_get(inArgs, "(u)", &flags); domain = virtDBusDomainGetVirDomain(connect, objectPath, error); if (!domain) return; - if (virDomainDestroy(domain) < 0) + if (virDomainDestroyFlags(domain, flags) < 0) virtDBusUtilSetLastVirtError(error); } diff --git a/test/test_domain.py b/test/test_domain.py index e3f32ca..409633a 100755 --- a/test/test_domain.py +++ b/test/test_domain.py @@ -3,6 +3,7 @@ import dbus import libvirttest +DBUS_EXCEPTION_MISSING_FUNCTION = 'this function is not supported by the connection driver' class TestDomain(libvirttest.BaseTestClass): def domain(self): @@ -34,7 +35,11 @@ class TestDomain(libvirttest.BaseTestClass): domain.Reboot(0) domain.ShutdownFlags(0) domain.CreateWithFlags(0) - domain.Destroy() + try: + domain.Destroy(0) + except dbus.exceptions.DBusException as e: + if not any(DBUS_EXCEPTION_MISSING_FUNCTION in arg for arg in e.args): + raise e domain.UndefineFlags(0) def test_shutdown(self): -- 2.15.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list