[libvirt] [PATCH] qemu: Unlink managed state file when a domain is undefined

Eric Blake eblake at redhat.com
Wed Apr 20 13:17:04 UTC 2011


On 04/20/2011 01:30 AM, Osier Yang wrote:
> The managed state file is not useful anymore after the domain is
> undefined, and perhaps cause confusion. E.g. define & start a domain
> which has same name with previous undefined domain later.
> ---
>  src/qemu/qemu_driver.c |    8 ++++++++
>  1 files changed, 8 insertions(+), 0 deletions(-)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index f6e503a..874b455 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -3739,6 +3739,7 @@ static int qemudDomainUndefine(virDomainPtr dom) {
>      virDomainObjPtr vm;
>      virDomainEventPtr event = NULL;
>      int ret = -1;
> +    char *managed_save = NULL;
>  
>      qemuDriverLock(driver);
>      vm = virDomainFindByUUID(&driver->domains, dom->uuid);
> @@ -3766,6 +3767,13 @@ static int qemudDomainUndefine(virDomainPtr dom) {
>      if (virDomainDeleteConfig(driver->configDir, driver->autostartDir, vm) < 0)
>          goto cleanup;
>  
> +    if (!(managed_save = qemuDomainManagedSavePath(driver, vm)))
> +        goto cleanup;
> +
> +    if (virFileExists(managed_save) && (unlink(managed_save) < 0)) {
> +        VIR_WARN("Failed to remove the managed state %s", managed_save);
> +    }

Hmm, I'm wondering if we should instead swap this to occur before
virDomainDeleteConfig, and fail the undefine operation if unlink() fails
(doing it after the deletion and only doing a VIR_WARN while still
succeeding seems rather weak).

-- 
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: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110420/7aa978a5/attachment-0001.sig>


More information about the libvir-list mailing list