]> xenbits.xensource.com Git - libvirt.git/commitdiff
test driver: error out when domain destroy twice
authorFélix Bouliane <felixbouliane@gmail.com>
Mon, 7 Nov 2016 20:09:26 +0000 (15:09 -0500)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 8 Nov 2016 08:34:25 +0000 (09:34 +0100)
Fixes the behavior when destroying a domain more than once.
VIR_ERR_OPERATION_INVALID should be raised when destroying an
already destroyed domain.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/test/test_driver.c

index 51fb7c8f3fa997ecf0d705224ba9a4feb703dc4e..c5e1a4591d0663fa0b5d6275f85cc47c6e53a433 100644 (file)
@@ -1731,10 +1731,15 @@ static int testDomainDestroy(virDomainPtr domain)
     virObjectEventPtr event = NULL;
     int ret = -1;
 
-
     if (!(privdom = testDomObjFromDomain(domain)))
         goto cleanup;
 
+    if (!virDomainObjIsActive(privdom)) {
+        virReportError(VIR_ERR_OPERATION_INVALID,
+                       "%s", _("domain is not running"));
+        goto cleanup;
+    }
+
     testDomainShutdownState(domain, privdom, VIR_DOMAIN_SHUTOFF_DESTROYED);
     event = virDomainEventLifecycleNewFromObj(privdom,
                                      VIR_DOMAIN_EVENT_STOPPED,