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

Eric Blake eblake at redhat.com
Mon Apr 25 14:45:20 UTC 2011


On 04/25/2011 08:29 AM, Eric Blake wrote:
> On 04/25/2011 03:41 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 but different UUID with previous undefined
>> domain later.
>>
>> v1 - v2:
>>    * Try to delete the managed state file before delete domain
>> config file, and goto fail if it failed to delete it.
>> ---
>>  src/qemu/qemu_driver.c |   10 ++++++++++
>>  1 files changed, 10 insertions(+), 0 deletions(-)
> 
> Ouch.  virDomainUndefine doesn't have a flags argument.  But this is
> changing behavior in a user-visible manner (arguably for the better, but
> any change is risky)
> 
> We have two options:
> 
> 1. Proceed with the change: virDomainUndefine removes all associated
> snapshot data; but this is a silent change in behavior
> 
> 2. Add a new API: virDomainUndefineFlags; flag 0 leaves snapshot data
> around (but warns), flag VIR_DOMAIN_UNDEFINE_ALL_ASSOCIATED_DATA (or
> some better name) guarantees that snapshots are also removed

Option 3: no silent deletion on undefine, and no new API, but make
virDomainUndefine fail if the managed state file exists.  The user is
then responsible for using virDomainHasManagedSaveImage and
virDomainManagedSaveRemove prior to undefining a domain.  But whereas
with option 1, people might complain that we removed the managed state
file, now with option 3 people might complain that we prevent the
undefine of a domain.  Which leads to:

Option 4: Add virDomainUndefineFlags().  virDomainUndefineFlags(,0)
refuses to undefine a domain if state exists, while
virDomainUndefineFlags(,VIR_DOMAIN_UNDEFINE_FORCE) proceeds to undefine
the domain even if a managed state file exists.  We'd still have to
decide whether virDomainUndefine maps to Flags(,0) or Flags(,FORCE), but
at least the default option is safer than in option 2 where you have to
use a flag to get the safe behavior.

At any rate, at the virsh level we can add a flag that maps into two API
calls as necessary to use virDomainManagedSaveRemove prior to
virDomainUndefine, regardless of what we do at the API level.

-- 
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/20110425/62783811/attachment-0001.sig>


More information about the libvir-list mailing list