Re: [PATCH 1/2] virsh: Introduce virshDomainDetachInterface function

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

 



On 05/04/2016 10:26 AM, Nitesh Konkar wrote:
> virshDomainDetachInterface handles virsh interface
> detach from the specified live/config domain xml.
> 
> Signed-off-by: Nitesh Konkar <nitkon12@xxxxxxxxxxxxxxxxxx>
> ---
>  tools/virsh-domain.c | 120 ++++++++++++++++++++++++++++-----------------------
>  1 file changed, 67 insertions(+), 53 deletions(-)
> 
> diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
> index 0a6caae..1b4e9f0 100644
> --- a/tools/virsh-domain.c
> +++ b/tools/virsh-domain.c
> @@ -11199,57 +11199,21 @@ static const vshCmdOptDef opts_detach_interface[] = {
>  };
>  

Thanks, I pushed with the following changes:

> +
> +
> +static bool
> +cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
> +{
> +    virDomainPtr dom = NULL;
> +    char *doc = NULL;
> +    const char *mac = NULL, *type = NULL;
> +    bool ret = false;
> +    unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
> +    bool current = vshCommandOptBool(cmd, "current");
> +    bool config = vshCommandOptBool(cmd, "config");
> +    bool live = vshCommandOptBool(cmd, "live");
> +    bool persistent = vshCommandOptBool(cmd, "persistent");
> +
> +    VSH_EXCLUSIVE_OPTIONS_VAR(persistent, current);
> +
> +    VSH_EXCLUSIVE_OPTIONS_VAR(current, live);
> +    VSH_EXCLUSIVE_OPTIONS_VAR(current, config);
> +
> +    if (vshCommandOptStringReq(ctl, cmd, "type", &type) < 0)
> +        goto cleanup;
> +
> +    if (vshCommandOptStringReq(ctl, cmd, "mac", &mac) < 0)
> +        goto cleanup;
> +

Moved these two checks below the 'dom' lookup, which is where they were originally

> +    if (config || persistent)
> +        flags |= VIR_DOMAIN_AFFECT_CONFIG;
> +    if (live)
> +        flags |= VIR_DOMAIN_AFFECT_LIVE;
> +
> +    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
> +        return false;
> +
> +    if (persistent &&
> +        virDomainIsActive(dom) == 1)
> +        flags |= VIR_DOMAIN_AFFECT_LIVE;
> +
> +    if (flags & VIR_DOMAIN_AFFECT_CONFIG)
> +        doc = virDomainGetXMLDesc(dom, VIR_DOMAIN_XML_INACTIVE);
> +    else
> +        doc = virDomainGetXMLDesc(dom, 0);
> +
> +    if (!doc)
> +        goto cleanup;
> +    else
> +        ret = virshDomainDetachInterface(doc, flags, dom, ctl, current, type, mac);
> +

Split this long line

Thanks,
Cole

> + cleanup:
> +    if (!ret) {
>          vshError(ctl, "%s", _("Failed to detach interface"));
>      } else {
>          vshPrint(ctl, "%s", _("Interface detached successfully\n"));
> -        functionReturn = true;
>      }
>  
> - cleanup:
>      VIR_FREE(doc);
> -    VIR_FREE(detach_xml);
>      virDomainFree(dom);
> -    xmlXPathFreeObject(obj);
> -    xmlXPathFreeContext(ctxt);
> -    xmlFreeDoc(xml);
> -    return functionReturn;
> +    return ret;
>  }
>  
>  typedef enum {
> 

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]