[libvirt] [PATCH] Xen: Do not generate net ifname if domain is inactive

Eric Blake eblake at redhat.com
Thu Apr 28 20:00:09 UTC 2011


On 04/28/2011 11:53 AM, Jim Fehlig wrote:
> The xend driver will generate a virDomainNetDef ifname if one is not
> specified in xend sexpr, even if domain is inactive.  The result is
> network interface XML containing 'vif-1.Y' on dev attribute of target
> element, e.g.
> 
>   <interface type='bridge'>
>     <target dev='vif-1.0'/>
>     ...
> 
> This patch changes the behavior to only generate the ifname if not
> specified in xend sexpr *and* domain is not inactive (id != -1).

Makes sense for the rationale.  However...

> +            } else if (def->id != -1) {
>                  snprintf(buf, sizeof(buf), "vif%d.%d", def->id, vif_index);
> -                tmp = buf;
> +                if (!(net->ifname = strdup(buf)))

Rather than using snprintf and strdup, can't we just use:

if (virAsprintf(&net->ifname, "vif%d.%d", def->id, vif_index) < 0)
    goto no_memory;

-- 
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/20110428/c3eb82c3/attachment-0001.sig>


More information about the libvir-list mailing list