Skip to contentSkip to conversation

qemu-xen and bridge (xen 4.11)

DISCUSSION Manuel Bouyer 2 participants 4 messages Aug 24, 2020 – Aug 27, 2020

lore
Share & tools
lore
#0 lore raw

Hello,
with the recent XSA about qemu, I'm trying to switch the NetBSD port from qemu-xen-traditional to qemu-xen (in Xen 4.11 for now, I'll look at 4.13 later).
One showstopper is that with qemu-xen, the bridge name is not passed any more to the qemu-ifup script. I tried adding a br= option to the qemu invocation, but qemu-system-i386 doesn't seem to use it (at last the script is still called with only one argument). I'm not about to pass to qemu the value of nics[i].script instead of libxl_tapif_script(), so that at last per-domain script can be specified.

How is this issue dealt with on other OSes ? I can't believe I'm the only one with multiple bridges in the dom0 ...

Signature · 3 lines
Manuel Bouyer <[email protected]>
     NetBSD: 26 ans d'experience feront toujours la difference
--
#1 lore raw
Quoted 13 lines · Manuel Bouyer

Hello,
with the recent XSA about qemu, I'm trying to switch the NetBSD port from qemu-xen-traditional to qemu-xen (in Xen 4.11 for now, I'll look at 4.13 later).
One showstopper is that with qemu-xen, the bridge name is not passed any more to the qemu-ifup script. I tried adding a br= option to the qemu invocation, but qemu-system-i386 doesn't seem to use it (at last the script is still called with only one argument). I'm not about to pass to qemu the value of nics[i].script instead of libxl_tapif_script(), so that at last per-domain script can be specified.

Quoted 2 lines

How is this issue dealt with on other OSes ? I can't believe I'm the only one with multiple bridges in the dom0 ...

You mean something like?
https://github.com/lf-edge/eve/blob/master/pkg/xen-tools/patches-4.14.0/10-bridge-helper-support.patch

Thanks,
Roman.

#2 lore raw
Quoted 14 lines · Roman Shaposhnik
Quoted 13 lines · Manuel Bouyer

Hello,
with the recent XSA about qemu, I'm trying to switch the NetBSD port from qemu-xen-traditional to qemu-xen (in Xen 4.11 for now, I'll look at 4.13 later).
One showstopper is that with qemu-xen, the bridge name is not passed any more to the qemu-ifup script. I tried adding a br= option to the qemu invocation, but qemu-system-i386 doesn't seem to use it (at last the script is still called with only one argument). I'm not about to pass to qemu the value of nics[i].script instead of libxl_tapif_script(), so that at last per-domain script can be specified.

Quoted 5 lines
Quoted 2 lines

How is this issue dealt with on other OSes ? I can't believe I'm the only one with multiple bridges in the dom0 ...

You mean something like?
https://github.com/lf-edge/eve/blob/master/pkg/xen-tools/patches-4.14.0/10-bridge-helper-support.patch

yes, that is going to help. I'll see if I can backport it to 4.11

thanks !

Signature · 3 lines
Manuel Bouyer <[email protected]>
     NetBSD: 26 ans d'experience feront toujours la difference
--
#3 lore raw
In reply to Roman Shaposhnik
Quoted 14 lines · Roman Shaposhnik
Quoted 13 lines · Manuel Bouyer

Hello,
with the recent XSA about qemu, I'm trying to switch the NetBSD port from qemu-xen-traditional to qemu-xen (in Xen 4.11 for now, I'll look at 4.13 later).
One showstopper is that with qemu-xen, the bridge name is not passed any more to the qemu-ifup script. I tried adding a br= option to the qemu invocation, but qemu-system-i386 doesn't seem to use it (at last the script is still called with only one argument). I'm not about to pass to qemu the value of nics[i].script instead of libxl_tapif_script(), so that at last per-domain script can be specified.

Quoted 5 lines
Quoted 2 lines

How is this issue dealt with on other OSes ? I can't believe I'm the only one with multiple bridges in the dom0 ...

You mean something like?
https://github.com/lf-edge/eve/blob/master/pkg/xen-tools/patches-4.14.0/10-bridge-helper-support.patch

Hello,
the attached patch is needed on Xen 4.13 in addition to the above patch, so that xl calls qemu with the br= argument properly set.

In addition to this, I also added an environnement variable XEN_DOMAIN_ID, which can be used from the qemu-ifup script if you need to query the xenstore (it's usefull for me).

Would such a patch be accepted ?

Signature · 3 lines
Manuel Bouyer <[email protected]>
     NetBSD: 26 ans d'experience feront toujours la difference
--

$NetBSD: $

libxl/libxl_dm.c renamed from libxl/libxl_dm.c.orig +10 -0
@@ -742,6 +742,10 @@
         int nr_set_cpus = 0;
         char *s;
 
+	static char buf[12];
+	snprintf(buf, sizeof(buf), "%d", domid);
+        flexarray_append_pair(dm_envs, "XEN_DOMAIN_ID", buf);
+
         if (b_info->kernel) {
             LOGD(ERROR, domid, "HVM direct kernel boot is not supported by "
                  "qemu-xen-traditional");
@@ -1503,8 +1507,10 @@
                 flexarray_append(dm_args, "-netdev");
                 flexarray_append(dm_args,
                                  GCSPRINTF("type=tap,id=net%d,ifname=%s,"
+					   "br=%s,"
                                            "script=%s,downscript=%s",
                                            nics[i].devid, ifname,
+					   nics[i].bridge,
                                            libxl_tapif_script(gc),
                                            libxl_tapif_script(gc)));
 
@@ -1772,6 +1778,10 @@
     flexarray_append(dm_args, GCSPRINTF("%"PRId64, ram_size));
 
     if (b_info->type == LIBXL_DOMAIN_TYPE_HVM) {
+	static char buf[12];
+	snprintf(buf, sizeof(buf), "%d", guest_domid);
+        flexarray_append_pair(dm_envs, "XEN_DOMAIN_ID", buf);
+
         if (b_info->u.hvm.hdtype == LIBXL_HDTYPE_AHCI)
             flexarray_append_pair(dm_args, "-device", "ahci,id=ahci0");
         for (i = 0; i < num_disks; i++) {