diff mbox series

[14/24] Pass bridge name to qemu and set XEN_DOMAIN_ID

Message ID 20201214163623.2127-15-bouyer@netbsd.org (mailing list archive)
State New, archived
Headers show
Series NetBSD fixes | expand

Commit Message

Manuel Bouyer Dec. 14, 2020, 4:36 p.m. UTC
Pass bridge name to qemu
When starting qemu, set an environnement variable XEN_DOMAIN_ID,
to be used by qemu helper scripts

---
 tools/libs/light/libxl_dm.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Manuel Bouyer Dec. 15, 2020, 8:44 a.m. UTC | #1
On Mon, Dec 14, 2020 at 05:36:13PM +0100, Manuel Bouyer wrote:
> Pass bridge name to qemu
> When starting qemu, set an environnement variable XEN_DOMAIN_ID,
> to be used by qemu helper scripts

This one is not NetBSD related, I should have sent is as a separate
git mail ... I guess (i'm not familiar with git, sorry).

But I think it can be usefull for the comunity.
Roger Pau Monne Dec. 29, 2020, 3:19 p.m. UTC | #2
On Mon, Dec 14, 2020 at 05:36:13PM +0100, Manuel Bouyer wrote:
> Pass bridge name to qemu
> When starting qemu, set an environnement variable XEN_DOMAIN_ID,
> to be used by qemu helper scripts

NetBSD is the only one to use QEMU nic scripts, both FreeBSD and Linux
don't use up/down scripts with QEMU.

> ---
>  tools/libs/light/libxl_dm.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/tools/libs/light/libxl_dm.c b/tools/libs/light/libxl_dm.c
> index 3da83259c0..5948ace60d 100644
> --- a/tools/libs/light/libxl_dm.c
> +++ b/tools/libs/light/libxl_dm.c
> @@ -761,6 +761,10 @@ static int libxl__build_device_model_args_old(libxl__gc *gc,
>          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);

Indentation, here and below.

Also just use:

flexarray_append_pair(dm_envs, "XEN_DOMAIN_ID",
                      GCSPRINTF("%d", domid);

Here and below.

Thanks, Roger.
Manuel Bouyer Jan. 4, 2021, 10:36 a.m. UTC | #3
On Tue, Dec 29, 2020 at 04:19:58PM +0100, Roger Pau Monné wrote:
> On Mon, Dec 14, 2020 at 05:36:13PM +0100, Manuel Bouyer wrote:
> > Pass bridge name to qemu
> > When starting qemu, set an environnement variable XEN_DOMAIN_ID,
> > to be used by qemu helper scripts
> 
> NetBSD is the only one to use QEMU nic scripts, both FreeBSD and Linux
> don't use up/down scripts with QEMU.

I think the scripts are more flexible though; they can be hacked for
local needs ...

> 
> > ---
> >  tools/libs/light/libxl_dm.c | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
> > 
> > diff --git a/tools/libs/light/libxl_dm.c b/tools/libs/light/libxl_dm.c
> > index 3da83259c0..5948ace60d 100644
> > --- a/tools/libs/light/libxl_dm.c
> > +++ b/tools/libs/light/libxl_dm.c
> > @@ -761,6 +761,10 @@ static int libxl__build_device_model_args_old(libxl__gc *gc,
> >          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);
> 
> Indentation, here and below.
> 
> Also just use:
> 
> flexarray_append_pair(dm_envs, "XEN_DOMAIN_ID",
>                       GCSPRINTF("%d", domid);
> 
> Here and below.

fixed, thanks
diff mbox series

Patch

diff --git a/tools/libs/light/libxl_dm.c b/tools/libs/light/libxl_dm.c
index 3da83259c0..5948ace60d 100644
--- a/tools/libs/light/libxl_dm.c
+++ b/tools/libs/light/libxl_dm.c
@@ -761,6 +761,10 @@  static int libxl__build_device_model_args_old(libxl__gc *gc,
         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");
@@ -1547,8 +1551,10 @@  static int libxl__build_device_model_args_new(libxl__gc *gc,
                 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)));
 
@@ -1825,6 +1831,10 @@  static int libxl__build_device_model_args_new(libxl__gc *gc,
     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++) {