[libvirt] [PATCH v2 2/8] undefine: Define the new API

Eric Blake eblake at redhat.com
Fri Jul 15 20:03:40 UTC 2011


On 07/15/2011 03:06 AM, Osier Yang wrote:
> This introduce a new API virDomainUndefineFlags to control the

s/introduce/introduces/

> domain undefine process, as the existed API virDomainUndefine

s/existed/existing/

> doesn't support flags.
> 
> Currently only flag VIR_DOMAIN_UNDEFINE_MANAGED_STATE is supported.
> If the domain has a managed state file, including
> VIR_DOMAIN_UNDEFINE_MANAGED_STATE in @flags will also remove that
> file, and omitting the flag will cause undefine process to fail.
> 
> This patch also changes the behavior of virDomainUndefine, if the
> domain has a managed state file, the undefine will be refused.

I also just realized that this is the right change, because by default,
libvirt should never allow data loss without explicit action.  If a
domain has managed state and libvirt were to silently delete the file,
then you have lost the data that was in memory at the time the managed
state file was created.  And undefining a domain while leaving the state
file behind opens the door for some other domain to be created and
clobber the state file, which is also data loss.  So even though it is a
semantic change to refuse to delete a domain with managed save data, it
fixes a data loss bug so it is the right thing to do.

> +++ b/src/libvirt.c
> @@ -6376,7 +6376,11 @@ error:
>   * virDomainUndefine:
>   * @domain: pointer to a defined domain
>   *
> - * Undefine a domain but does not stop it if it is running
> + * Undefine the configuration for an inactive domain.

Per the discussion in related threads, we want this to read more like:

Undefine a domain.  If the domain is running, this converts it to a
transient domain, without halting the guest.  If the domain is inactive,
this removes all traces of the domain.

> + *
> + * If the domain has a managed state file (see
> + * virDomainHasManagedSaveImage()), then the undefine will fail. See
> + * virDomainUndefineFlags() for more control.
>   *
>   * Returns 0 in case of success, -1 in case of error
>   */
> @@ -6415,6 +6419,56 @@ error:
>  }
>  
>  /**
> + * virDomainUndefineFlags:
> + * @domain: pointer to a defined domain
> + * @flags: bitwise-or of supported virDomainUndefineFlagsValues
> + *
> + * Undefine the configuration for an inactive domain.

Same paragraph change as for virDomainUndefine.

ACK with those paragraphs changed (and we'll have to fix qemu behavior
in a later patch).

-- 
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/20110715/b4ca7066/attachment-0001.sig>


More information about the libvir-list mailing list