On Mon, Aug 24, 2020 at 11:24:06AM -0700, Roman Shaposhnik wrote:
> On Mon, Aug 24, 2020 at 11:12 AM Manuel Bouyer <[email protected]> wrote:
> >
> > 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 ...
> 
> 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 ?

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

--- tools/libxl/libxl_dm.c.orig	2020-05-14 14:19:32.000000000 +0200
+++ tools/libxl/libxl_dm.c	2020-08-27 14:12:38.150082263 +0200
@@ -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++) {

Reply via email to