Skip to contentSkip to conversation

libxl: use preferred syntax for network device creation with upstream qemu

PATCH In review Ian Campbell 4 participants 8 messages May 25, 2011 – May 26, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxl: use preferred syntax for network device creation with upstream qemu

# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1306311631 -3600
# Node ID 6b1fe0cba8a2f0bcc1274c8e777da5b6c198b45d
# Parent 8258c5a0ba35de937597e2c516bc88f8ebe1be35
libxl: use preferred syntax for network device creation with upstream qemu

Markus Armbruster points out in <[email protected]> on qemu-devel that this is the prefered syntax going forward. Using it avoid needlessly instantiating a qemu "vlan" and instead creates a simply host end point and device.

Cc Markus Armbruster <[email protected]>
tools/libxl/libxl_dm.c +5 -5
diff -r 8258c5a0ba35 -r 6b1fe0cba8a2 tools/libxl/libxl_dm.c
@@ -336,11 +336,11 @@ static char ** libxl__build_device_model
                 } else {
                     ifname = vifs[i].ifname;
                 }
-                flexarray_append(dm_args, "-net");
-                flexarray_append(dm_args, libxl__sprintf(gc, "nic,vlan=%d,macaddr=%s,model=%s",
-                            vifs[i].devid, smac, vifs[i].model));
-                flexarray_append(dm_args, "-net");
-                flexarray_append(dm_args, libxl__sprintf(gc, "tap,vlan=%d,ifname=%s,script=%s",
+                flexarray_append(dm_args, "-device");
+                flexarray_append(dm_args, libxl__sprintf(gc, "%s,netdev=net%d,mac=%s",
+                                                         vifs[i].model, vifs[i].devid, smac));
+                flexarray_append(dm_args, "-netdev");
+                flexarray_append(dm_args, libxl__sprintf(gc, "type=tap,id=net%d,ifname=%s,script=%s",
                             vifs[i].devid, ifname, libxl_tapif_script(gc)));
                 ioemu_vifs++;
             }
#1 lore raw
Quoted 7 lines · Ian Campbell

# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1306311631 -3600
# Node ID 6b1fe0cba8a2f0bcc1274c8e777da5b6c198b45d
# Parent 8258c5a0ba35de937597e2c516bc88f8ebe1be35
libxl: use preferred syntax for network device creation with upstream qemu

Quoted 7 lines

Markus Armbruster points out in <[email protected]> on qemu-devel that this is the prefered syntax going forward. Using it avoid needlessly instantiating a qemu "vlan" and instead creates a simply host end point and device.

Cc Markus Armbruster <[email protected]>

I figure this is a good idea.

Important optimizations like GSO or vhost-net aren't feasible with -net's VLANs (no relation to IEEE 802.1Q) . That's why -netdev got added[*]. VLANs are still around for backward compatibility. I hope we can get rid of them eventually.

Quoted 5 lines

diff -r 8258c5a0ba35 -r 6b1fe0cba8a2 tools/libxl/libxl_dm.c

tools/libxl/libxl_dm.c +0 -0
@@ -336,11 +336,11 @@ static char ** libxl__build_device_model
                 } else {

tools/libxl/libxl_dm.c static char ** libxl__build_device_model · line 341

Quoted 10 lines
tools/libxl/libxl_dm.c +3 -5
                     ifname = vifs[i].ifname;
                 }
-                flexarray_append(dm_args, "-net");
-                flexarray_append(dm_args, libxl__sprintf(gc, "nic,vlan=%d,macaddr=%s,model=%s",
-                            vifs[i].devid, smac, vifs[i].model));
-                flexarray_append(dm_args, "-net");
-                flexarray_append(dm_args, libxl__sprintf(gc, "tap,vlan=%d,ifname=%s,script=%s",
+                flexarray_append(dm_args, "-device");
+                flexarray_append(dm_args, libxl__sprintf(gc, "%s,netdev=net%d,mac=%s",
+                                                         vifs[i].model, vifs[i].devid, smac));

You can name the device with "id=WHATEVER". IDs are handy when you need to refer to a device, e.g. for hot-unplug with device_del.

tools/libxl/libxl_dm.c static char ** libxl__build_device_model · line 346

Quoted 6 lines
tools/libxl/libxl_dm.c +2 -0
+                flexarray_append(dm_args, "-netdev");
+                flexarray_append(dm_args, libxl__sprintf(gc, "type=tap,id=net%d,ifname=%s,script=%s",
                             vifs[i].devid, ifname, libxl_tapif_script(gc)));
                 ioemu_vifs++;
             }

More info on conversion to -device syntax in docs/qdev-device-use.txt. It's a bit stale, patch for updating it is on qemu-devel.

[*] http://lists.gnu.org/archive/html/qemu-devel/2009-10/msg00858.html

#2 lore raw
Quoted 14 lines · Markus Armbruster
Quoted 12 lines · Ian Campbell

# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1306311631 -3600
# Node ID 6b1fe0cba8a2f0bcc1274c8e777da5b6c198b45d
# Parent 8258c5a0ba35de937597e2c516bc88f8ebe1be35
libxl: use preferred syntax for network device creation with upstream qemu

Markus Armbruster points out in <[email protected]> on qemu-devel that this is the prefered syntax going forward. Using it avoid needlessly instantiating a qemu "vlan" and instead creates a simply host end point and device.

Quoted 4 lines
Quoted 2 lines
Cc Markus Armbruster <[email protected]>

I figure this is a good idea.

Thanks for confirming.

Quoted 15 lines

Important optimizations like GSO or vhost-net aren't feasible with -net's VLANs (no relation to IEEE 802.1Q) . That's why -netdev got added[*]. VLANs are still around for backward compatibility. I hope we can get rid of them eventually.

Quoted 10 lines

diff -r 8258c5a0ba35 -r 6b1fe0cba8a2 tools/libxl/libxl_dm.c

tools/libxl/libxl_dm.c +0 -3
@@ -336,11 +336,11 @@ static char ** libxl__build_device_model
                 } else {
                     ifname = vifs[i].ifname;
                 }
-                flexarray_append(dm_args, "-net");
-                flexarray_append(dm_args, libxl__sprintf(gc, "nic,vlan=%d,macaddr=%s,model=%s",
-                            vifs[i].devid, smac, vifs[i].model));
Quoted 8 lines

tools/libxl/libxl_dm.c static char ** libxl__build_device_model · line 341

Quoted 5 lines
tools/libxl/libxl_dm.c +3 -2
-                flexarray_append(dm_args, "-net");
-                flexarray_append(dm_args, libxl__sprintf(gc, "tap,vlan=%d,ifname=%s,script=%s",
+                flexarray_append(dm_args, "-device");
+                flexarray_append(dm_args, libxl__sprintf(gc, "%s,netdev=net%d,mac=%s",
+                                                         vifs[i].model, vifs[i].devid, smac));

You can name the device with "id=WHATEVER". IDs are handy when you need to refer to a device, e.g. for hot-unplug with device_del.

Sure, I just couldn't think of a better name than net<n>.

Quoted 9 lines

tools/libxl/libxl_dm.c static char ** libxl__build_device_model · line 346

Quoted 6 lines
tools/libxl/libxl_dm.c +2 -0
+                flexarray_append(dm_args, "-netdev");
+                flexarray_append(dm_args, libxl__sprintf(gc, "type=tap,id=net%d,ifname=%s,script=%s",
                             vifs[i].devid, ifname, libxl_tapif_script(gc)));
                 ioemu_vifs++;
             }

More info on conversion to -device syntax in docs/qdev-device-use.txt. It's a bit stale, patch for updating it is on qemu-devel.

Thanks for the reference. Looks like I need to consider a similar update for disk devices too.

Quoted 2 lines

[*] http://lists.gnu.org/archive/html/qemu-devel/2009-10/msg00858.html

#3 lore raw
Quoted 46 lines · Ian Campbell
Quoted 14 lines · Markus Armbruster
Quoted 12 lines · Ian Campbell

# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1306311631 -3600
# Node ID 6b1fe0cba8a2f0bcc1274c8e777da5b6c198b45d
# Parent 8258c5a0ba35de937597e2c516bc88f8ebe1be35
libxl: use preferred syntax for network device creation with upstream qemu

Markus Armbruster points out in <[email protected]> on qemu-devel that this is the prefered syntax going forward. Using it avoid needlessly instantiating a qemu "vlan" and instead creates a simply host end point and device.

Quoted 4 lines
Quoted 2 lines
Cc Markus Armbruster <[email protected]>

I figure this is a good idea.

Thanks for confirming.

Quoted 15 lines

Important optimizations like GSO or vhost-net aren't feasible with -net's VLANs (no relation to IEEE 802.1Q) . That's why -netdev got added[*]. VLANs are still around for backward compatibility. I hope we can get rid of them eventually.

Quoted 10 lines

diff -r 8258c5a0ba35 -r 6b1fe0cba8a2 tools/libxl/libxl_dm.c

tools/libxl/libxl_dm.c +0 -3
@@ -336,11 +336,11 @@ static char ** libxl__build_device_model
                 } else {
                     ifname = vifs[i].ifname;
                 }
-                flexarray_append(dm_args, "-net");
-                flexarray_append(dm_args, libxl__sprintf(gc, "nic,vlan=%d,macaddr=%s,model=%s",
-                            vifs[i].devid, smac, vifs[i].model));
Quoted 8 lines

tools/libxl/libxl_dm.c static char ** libxl__build_device_model · line 341

Quoted 5 lines
tools/libxl/libxl_dm.c +3 -2
-                flexarray_append(dm_args, "-net");
-                flexarray_append(dm_args, libxl__sprintf(gc, "tap,vlan=%d,ifname=%s,script=%s",
+                flexarray_append(dm_args, "-device");
+                flexarray_append(dm_args, libxl__sprintf(gc, "%s,netdev=net%d,mac=%s",
+                                                         vifs[i].model, vifs[i].devid, smac));

You can name the device with "id=WHATEVER". IDs are handy when you need to refer to a device, e.g. for hot-unplug with device_del.

Quoted 1 line

Sure, I just couldn't think of a better name than net<n>.

Sorry, I wasn't writing clearly, let me retry. You're naming the host part of the NIC, created with -netdev. You can also name the guest part, created with -device.

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
tools/libxl/libxl_dm.c +2 -0
+                flexarray_append(dm_args, "-netdev");
+                flexarray_append(dm_args, libxl__sprintf(gc, "type=tap,id=net%d,ifname=%s,script=%s",
                             vifs[i].devid, ifname, libxl_tapif_script(gc)));
                 ioemu_vifs++;
             }
Quoted 5 lines
Quoted 2 lines

More info on conversion to -device syntax in docs/qdev-device-use.txt. It's a bit stale, patch for updating it is on qemu-devel.

Thanks for the reference. Looks like I need to consider a similar update for disk devices too.

There is no urgent need to convert, as the old syntax still works. There are no plans to retire the old syntax. However, the new syntax gives you more control. It's a bit more verbose in places, but non-human users tend not to mind that.

Quoted 1 line
Quoted 1 line

[*] http://lists.gnu.org/archive/html/qemu-devel/2009-10/msg00858.html

#4 lore raw
Quoted 29 lines · Markus Armbruster
Quoted 27 lines · Ian Campbell
Quoted 25 lines · Markus Armbruster

Ian Campbell <[email protected]> writes:

Important optimizations like GSO or vhost-net aren't feasible with -net's VLANs (no relation to IEEE 802.1Q) . That's why -netdev got added[*]. VLANs are still around for backward compatibility. I hope we can get rid of them eventually.

Quoted 5 lines

diff -r 8258c5a0ba35 -r 6b1fe0cba8a2 tools/libxl/libxl_dm.c

tools/libxl/libxl_dm.c +0 -0
@@ -336,11 +336,11 @@ static char ** libxl__build_device_model
                 } else {

tools/libxl/libxl_dm.c static char ** libxl__build_device_model · line 341

Quoted 10 lines
tools/libxl/libxl_dm.c +3 -5
                     ifname = vifs[i].ifname;
                 }
-                flexarray_append(dm_args, "-net");
-                flexarray_append(dm_args, libxl__sprintf(gc, "nic,vlan=%d,macaddr=%s,model=%s",
-                            vifs[i].devid, smac, vifs[i].model));
-                flexarray_append(dm_args, "-net");
-                flexarray_append(dm_args, libxl__sprintf(gc, "tap,vlan=%d,ifname=%s,script=%s",
+                flexarray_append(dm_args, "-device");
+                flexarray_append(dm_args, libxl__sprintf(gc, "%s,netdev=net%d,mac=%s",
+                                                         vifs[i].model, vifs[i].devid, smac));

You can name the device with "id=WHATEVER". IDs are handy when you need to refer to a device, e.g. for hot-unplug with device_del.

Quoted 5 lines
Quoted 1 line

Sure, I just couldn't think of a better name than net<n>.

Sorry, I wasn't writing clearly, let me retry. You're naming the host part of the NIC, created with -netdev. You can also name the guest part, created with -device.

Oh, I see, thanks. Make sense to call it nic<n> then I guess.

# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1306399775 -3600
# Node ID 7cb3b0b7f45d6272ef2c67dffd293aaf984c2ecc
# Parent 33cb7fe0d6d9f81292005e5671ebef7889c1d1ba
libxl: use preferred syntax for network device creation with upstream qemu

Markus Armbruster points out in <[email protected]> on qemu-devel that this is the prefered syntax going forward. Using it avoid needlessly instantiating a qemu "vlan" and instead creates a simply host end point and device.

Cc Markus Armbruster <[email protected]>
tools/libxl/libxl_dm.c +10 -6
diff -r 33cb7fe0d6d9 -r 7cb3b0b7f45d tools/libxl/libxl_dm.c
@@ -336,12 +336,16 @@ static char ** libxl__build_device_model
                 } else {
                     ifname = vifs[i].ifname;
                 }
-                flexarray_append(dm_args, "-net");
-                flexarray_append(dm_args, libxl__sprintf(gc, "nic,vlan=%d,macaddr=%s,model=%s",
-                            vifs[i].devid, smac, vifs[i].model));
-                flexarray_append(dm_args, "-net");
-                flexarray_append(dm_args, libxl__sprintf(gc, "tap,vlan=%d,ifname=%s,script=%s",
-                            vifs[i].devid, ifname, libxl_tapif_script(gc)));
+                flexarray_append(dm_args, "-device");
+                flexarray_append(dm_args,
+                                 libxl__sprintf(gc, "%s,id=nic%d,netdev=net%d,mac=%s",
+                                                vifs[i].model, vifs[i].devid,
+                                                vifs[i].devid, smac));
+                flexarray_append(dm_args, "-netdev");
+                flexarray_append(dm_args,
+                                 libxl__sprintf(gc, "type=tap,id=net%d,ifname=%s,script=%s",
+                                                vifs[i].devid, ifname,
+                                                libxl_tapif_script(gc)));
                 ioemu_vifs++;
             }
         }
#5 lore raw

Ian Campbell writes ("Re: [Xen-devel] [PATCH] libxl: use preferred syntax for network device creation with upstream qemu"):

Quoted 1 line

libxl: use preferred syntax for network device creation with upstream qemu

Applied (fixing up the formatting to stay within 80 columns).

Ian.

#6 lore raw

Re: [PATCH] libxl: use preferred syntax for network device creation with upstream qemu [and 1 more messages]

In reply to Ian Campbell

Markus Armbruster writes ("Re: [Xen-devel] [PATCH] libxl: use preferred syntax for network device creation with upstream qemu"):

Quoted 1 line

I figure this is a good idea.

Thanks, I'll take that as an ack.

However, sorry to nitpic, but:

Ian Campbell writes ("[Xen-devel] [PATCH] libxl: use preferred syntax for network device creation with upstream qemu"):

tools/libxl/libxl_dm.c static char ** libxl__build_device_model · line 343

Quoted 5 lines
tools/libxl/libxl_dm.c +3 -2
-                flexarray_append(dm_args, libxl__sprintf(gc, "nic,vlan=%d,macaddr=%s,model=%s",
-                flexarray_append(dm_args, libxl__sprintf(gc, "tap,vlan=%d,ifname=%s,script=%s",
+                flexarray_append(dm_args, libxl__sprintf(gc, "%s,netdev=net%d,mac=%s",
+                                                         vifs[i].model, vifs[i].devid, smac));
+                flexarray_append(dm_args, libxl__sprintf(gc, "type=tap,id=net%d,ifname=%s,script=%s",

This increases the number of overly-long lines. It's very hard to read on my screen:

Quoted 1 line

- flexarray_append(dm_args, libxl__sprintf(gc, "nic,vlan=%d,ma

caddr=%s,model=%s",

Quoted 1 line

- flexarray_append(dm_args, libxl__sprintf(gc, "tap,vlan=%d,if

name=%s,script=%s",

Quoted 1 line

+ flexarray_append(dm_args, libxl__sprintf(gc, "%s,netdev=net%

d,mac=%s",

Quoted 1 line

+ vifs[i].model, vifs

[i].devid, smac));

Quoted 1 line

+ flexarray_append(dm_args, libxl__sprintf(gc, "type=tap,id=ne

t%d,ifname=%s,script=%s",

Ian.

#7 lore raw

Re: [PATCH] libxl: use preferred syntax for network device creation with upstream qemu [and 1 more messages]

Quoted 8 lines · Ian Jackson

Markus Armbruster writes ("Re: [Xen-devel] [PATCH] libxl: use preferred syntax for network device creation with upstream qemu"):

Quoted 1 line

I figure this is a good idea.

Thanks, I'll take that as an ack.

However, sorry to nitpic, but:

Ian Campbell writes ("[Xen-devel] [PATCH] libxl: use preferred syntax for network device creation with upstream qemu"):

Quoted 8 lines

tools/libxl/libxl_dm.c static char ** libxl__build_device_model · line 343

Quoted 5 lines
tools/libxl/libxl_dm.c +3 -2
-                flexarray_append(dm_args, libxl__sprintf(gc, "nic,vlan=%d,macaddr=%s,model=%s",
-                flexarray_append(dm_args, libxl__sprintf(gc, "tap,vlan=%d,ifname=%s,script=%s",
+                flexarray_append(dm_args, libxl__sprintf(gc, "%s,netdev=net%d,mac=%s",
+                                                         vifs[i].model, vifs[i].devid, smac));
+                flexarray_append(dm_args, libxl__sprintf(gc, "type=tap,id=net%d,ifname=%s,script=%s",

This increases the number of overly-long lines. It's very hard to read on my screen:

I noticed that and fixed it in the replacement patch, see <[email protected]>

Quoted 14 lines
Quoted 2 lines

- flexarray_append(dm_args, libxl__sprintf(gc, "nic,vlan=%d,ma

caddr=%s,model=%s",

Quoted 1 line

- flexarray_append(dm_args, libxl__sprintf(gc, "tap,vlan=%d,if

name=%s,script=%s",

Quoted 1 line

+ flexarray_append(dm_args, libxl__sprintf(gc, "%s,netdev=net%

d,mac=%s",

Quoted 1 line

+ vifs[i].model, vifs

[i].devid, smac));

Quoted 1 line

+ flexarray_append(dm_args, libxl__sprintf(gc, "type=tap,id=ne

t%d,ifname=%s,script=%s",

Ian.