[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

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



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 redhat com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]