[libvirt] PATCH: Fix crash attempting to shutdown inactive QEMU vm

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

 



If the virDomainShutdown() op was run on an active QEMu vm,
it would crash, since the def->monitor_chr was NULL.


Daniel

commit 49ec121fd806aaa07bbcba9668a8f9dd43dda9c4
Author: Daniel P. Berrange <berrange@xxxxxxxxxx>
Date:   Fri Jul 31 15:50:46 2009 +0100

    Fix crash when attempting to shutdown inactive QEMU vm
    
    * src/qemu_driver.c: Add check that QEMU is active before attemting
      to shutdown. Fix error code for check in destroy method

diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index 26897d3..cebbafb 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -2940,6 +2940,12 @@ static int qemudDomainShutdown(virDomainPtr dom) {
         goto cleanup;
     }
 
+    if (!virDomainIsActive(vm)) {
+        qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_INVALID,
+                         "%s", _("domain is not running"));
+        goto cleanup;
+    }
+
     if (qemudMonitorCommand(vm, "system_powerdown", &info) < 0) {
         qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
                          "%s", _("shutdown operation failed"));
@@ -2971,7 +2977,7 @@ static int qemudDomainDestroy(virDomainPtr dom) {
         goto cleanup;
     }
     if (!virDomainIsActive(vm)) {
-        qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
+        qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_INVALID,
                          "%s", _("domain is not running"));
         goto cleanup;
     }


-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
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]