The current cleanup: in StartVMDaemon path is a poor duplication.
qemuShutdownVMDaemon can handle teardown for inactive VMs, so let's use it.
v2: Remove old abort: label, only use cleanup:
Signed-off-by: Cole Robinson <crobinso(a)redhat.com>
---
src/qemu/qemu_driver.c | 37 ++++++++++---------------------------
1 files changed, 10 insertions(+), 27 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d387e69..3823dbd 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3516,29 +3516,29 @@ static int qemudStartVMDaemon(virConnectPtr conn,
DEBUG0("Waiting for monitor to show up");
if (qemudWaitForMonitor(driver, vm, pos) < 0)
- goto abort;
+ goto cleanup;
DEBUG0("Detecting VCPU PIDs");
if (qemuDetectVcpuPIDs(driver, vm) < 0)
- goto abort;
+ goto cleanup;
DEBUG0("Setting any required VM passwords");
if (qemuInitPasswords(conn, driver, vm, qemuCmdFlags) < 0)
- goto abort;
+ goto cleanup;
/* If we have -device, then addresses are assigned explicitly.
* If not, then we have to detect dynamic ones here */
if (!(qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)) {
DEBUG0("Determining domain device PCI addresses");
if (qemuInitPCIAddresses(driver, vm) < 0)
- goto abort;
+ goto cleanup;
}
DEBUG0("Setting initial memory amount");
qemuDomainObjEnterMonitorWithDriver(driver, vm);
if (qemuMonitorSetBalloon(priv->mon, vm->def->memory) < 0) {
qemuDomainObjExitMonitorWithDriver(driver, vm);
- goto abort;
+ goto cleanup;
}
if (migrateFrom == NULL) {
@@ -3549,7 +3549,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
qemuReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("resume operation failed"));
qemuDomainObjExitMonitorWithDriver(driver, vm);
- goto abort;
+ goto cleanup;
}
}
qemuDomainObjExitMonitorWithDriver(driver, vm);
@@ -3557,7 +3557,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
DEBUG0("Writing domain status to disk");
if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0)
- goto abort;
+ goto cleanup;
if (logfile != -1)
close(logfile);
@@ -3565,26 +3565,9 @@ static int qemudStartVMDaemon(virConnectPtr conn,
return 0;
cleanup:
- /* We jump here if we failed to start the VM for any reason
- * XXX investigate if we can kill this block and safely call
- * qemudShutdownVMDaemon even though no PID is running */
- qemuDomainReAttachHostDevices(driver, vm->def);
-
- if (driver->securityDriver &&
- driver->securityDriver->domainRestoreSecurityAllLabel)
- driver->securityDriver->domainRestoreSecurityAllLabel(vm, 0);
- if (driver->securityDriver &&
- driver->securityDriver->domainReleaseSecurityLabel)
- driver->securityDriver->domainReleaseSecurityLabel(vm);
- qemuRemoveCgroup(driver, vm, 1);
- if (logfile != -1)
- close(logfile);
- vm->def->id = -1;
- return -1;
-
-abort:
- /* We jump here if we failed to initialize the now running VM
- * killing it off and pretend we never started it */
+ /* We jump here if we failed to start the VM for any reason, or
+ * if we failed to initialize the now running VM. kill it off and
+ * pretend we never started it */
qemudShutdownVMDaemon(driver, vm, 0);
if (logfile != -1)
--
1.6.6.1
Show replies by date
On 05/20/2010 09:54 AM, Cole Robinson wrote:
The current cleanup: in StartVMDaemon path is a poor duplication.
qemuShutdownVMDaemon can handle teardown for inactive VMs, so let's use it.
v2: Remove old abort: label, only use cleanup:
ACK; looks nicer.
--
Eric Blake eblake(a)redhat.com +1-801-349-2682
Libvirt virtualization library
http://libvirt.org
On 05/20/2010 03:01 PM, Eric Blake wrote:
On 05/20/2010 09:54 AM, Cole Robinson wrote:
> The current cleanup: in StartVMDaemon path is a poor duplication.
> qemuShutdownVMDaemon can handle teardown for inactive VMs, so let's use it.
>
> v2: Remove old abort: label, only use cleanup:
ACK; looks nicer.
Thanks, pushed.
- Cole