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

Re: [libvirt] [PATCH] virsh: Increase device-detach intelligence



On 03/25/2011 09:09 AM, Michal Privoznik wrote:
> Up to now users have to give a full XML description on input when
> device-detaching. If they omited something it lead to unclear
> error messages (like generated MAC wasn't found, etc.).
> With this patch users can specify only those information which
> specify one device sufficiently precise. Remaining information is
> completed from domain.
> ---
>  tools/virsh.c |  260 +++++++++++++++++++++++++++++++++++++++++++++++++++++----
>  1 files changed, 245 insertions(+), 15 deletions(-)

Not forgotten, but not quite yet to the top of my queue, either :(  I
guess having too many patches to review is a good sign that there is a
lot of contribution going on.

> 
> diff --git a/tools/virsh.c b/tools/virsh.c
> index 50ca50f..95d27f7 100644
> --- a/tools/virsh.c
> +++ b/tools/virsh.c
> @@ -8702,6 +8702,224 @@ cmdAttachDevice(vshControl *ctl, const vshCmd *cmd)
>      return TRUE;
>  }
>  
> +/**
> + * Check if n1 is superset of n2, meaning n1 contains all elements and
> + * attributes as n2 at lest. Including children.
> + * @n1 first node
> + * @n2 second node
> + * return 1 in case n1 covers n2, 0 otherwise.
> + */
> +static int
> +vshNodeIsSuperset(xmlNodePtr n1, xmlNodePtr n2) {

Are there any xml library functions that can already do this without you
rewriting it from scratch?

> +/**
> + * To given domain and (probably incomplete) device XML specification try to
> + * find such device in domain and complete missing parts. This is however
> + * possible when given device XML is sufficiently precise so it addresses only
> + * one device.
> + * @ctl vshControl for error messages printing
> + * @dom domain
> + * @oldXML device XML before
> + * @newXML and after completion
> + * Returns -2 when no such device exists in domain, -3 when given XML selects many
> + *          (is too ambiguous), 0 in case of success. Otherwise returns -1. @newXML
> + *          is touched only in case of success.
> + */
> +static int
> +vshCompleteXMLFromDomain(vshControl *ctl, virDomainPtr dom, char *oldXML,
> +                         char **newXML) {

My quick glance of just the documentation says that this looks like a
nice helper, but I haven't reviewed it in depth.

-- 
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]