[libvirt] [PATCH] to correct UML command line networking parameters

Eric Blake eblake at redhat.com
Thu Jun 2 19:55:31 UTC 2011


On 06/02/2011 10:23 AM, Heath Petersen wrote:
> I have been finding that some UML command line networking parameters are
> being generated incorrectly.  Attached is a patch that corrects the
> problem.
> 
> For more information, see
> https://bugzilla.redhat.com/show_bug.cgi?id=706295 .

Thanks for the patch.  I ended up rewriting your patch, but I'm still
pushing this in your name:

> 
> diff -Naur libvirt-0.9.1.orig/src/uml/uml_conf.c libvirt-0.9.1.new/src/uml/uml_conf.c
> --- libvirt-0.9.1.orig/src/uml/uml_conf.c	2011-03-01 01:03:32.000000000 -0600
> +++ libvirt-0.9.1.new/src/uml/uml_conf.c	2011-05-27 20:27:26.563772975 -0500
> @@ -208,6 +208,11 @@
>      case VIR_DOMAIN_NET_TYPE_ETHERNET:
>          /* ethNNN=tuntap,tapname,macaddr,gateway */
>          virBufferAddLit(&buf, "tuntap");
> +        if (def->ifname) {
> +            virBufferVSprintf(&buf, ",%s", def->ifname);

Your patch was based off of 0.9.1, but it is better to base off of
libvirt.git HEAD; there, we renamed virBufferVSprintf -> virBufferAsprintf.

> +        } else {
> +            virBufferAddLit(&buf, ",");

virBufferAddChar is more efficient here.

But after I made those two tweaks, I noticed that it is even more
efficient to always print the comma as part of the previous literal:

diff --git i/src/uml/uml_conf.c w/src/uml/uml_conf.c
index be902a6..0122472 100644
--- i/src/uml/uml_conf.c
+++ w/src/uml/uml_conf.c
@@ -207,11 +207,9 @@ umlBuildCommandLineNet(virConnectPtr conn,

     case VIR_DOMAIN_NET_TYPE_ETHERNET:
         /* ethNNN=tuntap,tapname,macaddr,gateway */
-        virBufferAddLit(&buf, "tuntap");
+        virBufferAddLit(&buf, "tuntap,");
         if (def->ifname) {
-            virBufferAsprintf(&buf, ",%s", def->ifname);
-        } else {
-            virBufferAddChar(&buf, ',');
+            virBufferAdd(&buf, def->ifname, -1);
         }
         if (def->data.ethernet.ipaddr) {
             umlReportError(VIR_ERR_INTERNAL_ERROR, "%s",


I also added you to AUTHORS; feel free to let me know if you prefer any
alternate spelling.

-- 
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/20110602/498fbb65/attachment-0001.sig>


More information about the libvir-list mailing list