From: Daniel P. Berrange Date: Fri, 31 Jul 2009 14:50:46 +0000 (+0100) Subject: Fix crash when attempting to shutdown inactive QEMU vm X-Git-Tag: v0.7.0~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5d3e02aaa21264bd516b4ad3724ec0ac8aabfcdd;p=thirdparty%2Flibvirt.git 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 26897d3421..cebbafb969 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; }