[libvirt] [PATCH 4/4] qemu: Use ShutdownVMDaemon for all startup cleanup paths

Eric Blake eblake at redhat.com
Tue May 18 16:29:42 UTC 2010


On 05/17/2010 11:17 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.
> 
> Signed-off-by: Cole Robinson <crobinso at redhat.com>
> ---
>  src/qemu/qemu_driver.c |   18 +-----------------
>  1 files changed, 1 insertions(+), 17 deletions(-)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index d2f1a36..114917d 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -3569,23 +3569,7 @@ 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;
> -
> +    /* We jump here if we failed to start the VM for any reason */
>  abort:
>      /* We jump here if we failed to initialize the now running VM
>       * killing it off and pretend we never started it */

Agree with the proposed change being safe, but it is incomplete.  Now
that cleanup: has no code, but falls through immediately to abort:, I'd
rather see these merged into one label.  Probably cleanup: is the better
name, which means changing all the 'goto abort;'.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20100518/6ae41965/attachment-0001.sig>


More information about the libvir-list mailing list