diff --git a/ChangeLog b/ChangeLog index 6b2f8967f8..40cdb705da 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Jul 24 10:24:11 EST 2007 Daniel P. Berrange + + * src/qemu_driver.c: Fixed crash when cleaning up after failed + attempt to start a VM. + Tue Jul 24 10:20:11 EST 2007 Daniel P. Berrange * qemud/remote.c: Always immediately free virDomainPtr objects diff --git a/src/qemu_driver.c b/src/qemu_driver.c index 0f0b7ea95e..0e3e658c20 100644 --- a/src/qemu_driver.c +++ b/src/qemu_driver.c @@ -92,9 +92,9 @@ static int qemudStartVMDaemon(virConnectPtr conn, struct qemud_driver *driver, struct qemud_vm *vm); -static int qemudShutdownVMDaemon(virConnectPtr conn, - struct qemud_driver *driver, - struct qemud_vm *vm); +static void qemudShutdownVMDaemon(virConnectPtr conn, + struct qemud_driver *driver, + struct qemud_vm *vm); static int qemudStartNetworkDaemon(virConnectPtr conn, struct qemud_driver *driver, @@ -277,6 +277,8 @@ qemudShutdown(void) { struct qemud_vm *next = vm->next; if (qemudIsActiveVM(vm)) qemudShutdownVMDaemon(NULL, qemu_driver, vm); + if (!vm->configFile[0]) + qemudRemoveInactiveVM(qemu_driver, vm); vm = next; } @@ -729,10 +731,10 @@ static int qemudVMData(struct qemud_driver *driver ATTRIBUTE_UNUSED, } -static int qemudShutdownVMDaemon(virConnectPtr conn ATTRIBUTE_UNUSED, - struct qemud_driver *driver, struct qemud_vm *vm) { +static void qemudShutdownVMDaemon(virConnectPtr conn ATTRIBUTE_UNUSED, + struct qemud_driver *driver, struct qemud_vm *vm) { if (!qemudIsActiveVM(vm)) - return 0; + return; qemudLog(QEMUD_INFO, "Shutting down VM '%s'", vm->def->name); @@ -774,24 +776,22 @@ static int qemudShutdownVMDaemon(virConnectPtr conn ATTRIBUTE_UNUSED, driver->nactivevms--; driver->ninactivevms++; - - if (!vm->configFile[0]) - qemudRemoveInactiveVM(driver, vm); - - return 0; } static int qemudDispatchVMLog(struct qemud_driver *driver, struct qemud_vm *vm, int fd) { - if (qemudVMData(driver, vm, fd) < 0) - if (qemudShutdownVMDaemon(NULL, driver, vm) < 0) - return -1; + if (qemudVMData(driver, vm, fd) < 0) { + qemudShutdownVMDaemon(NULL, driver, vm); + if (!vm->configFile[0]) + qemudRemoveInactiveVM(driver, vm); + } return 0; } static int qemudDispatchVMFailure(struct qemud_driver *driver, struct qemud_vm *vm, int fd ATTRIBUTE_UNUSED) { - if (qemudShutdownVMDaemon(NULL, driver, vm) < 0) - return -1; + qemudShutdownVMDaemon(NULL, driver, vm); + if (!vm->configFile[0]) + qemudRemoveInactiveVM(driver, vm); return 0; } @@ -1844,7 +1844,6 @@ static int qemudDomainResume(virDomainPtr dom) { static int qemudDomainDestroy(virDomainPtr dom) { struct qemud_driver *driver = (struct qemud_driver *)dom->conn->privateData; struct qemud_vm *vm = qemudFindVMByID(driver, dom->id); - int ret; if (!vm) { qemudReportError(dom->conn, dom, NULL, VIR_ERR_INVALID_DOMAIN, @@ -1852,9 +1851,11 @@ static int qemudDomainDestroy(virDomainPtr dom) { return -1; } - ret = qemudShutdownVMDaemon(dom->conn, driver, vm); + qemudShutdownVMDaemon(dom->conn, driver, vm); + if (!vm->configFile[0]) + qemudRemoveInactiveVM(driver, vm); virFreeDomain(dom->conn, dom); - return ret; + return 0; }