Skip to contentSkip to conversation

tools: add some more configure options

PATCH Superseded Juergen Gross 3 participants 9 messages Aug 4, 2023 – Aug 8, 2023

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover tools: add some more configure options

Add two additional configure options for controlling the build of pygrub and libfsimage.

Juergen Gross (2):
tools: add configure option for disabling pygrub
tools: add configure option for libfsimage

 config/Tools.mk.in |  2 ++
 tools/Makefile     |  4 ++--
 tools/configure    | 54 ++++++++++++++++++++++++++++++++++++++++++++++
 tools/configure.ac | 14 ++++++++++++
 4 files changed, 72 insertions(+), 2 deletions(-)
Signature · 1 line
2.35.3
#1 lore raw

PATCH 1/2 tools: add configure option for disabling pygrub

Add a "--disable-pygrub" option for being able to disable the build and installation of pygrub.

There are two main reasons to do so:

- A main reason to use pygrub is to allow a PV guest to choose its bitness (32- or 64-bit). Pygrub allows that by looking into the boot image and to start the guest in the correct mode depending on the kernel selected. With 32-bit PV guests being deprecated and the possibility to even build a hypervisor without 32-bit PV support, this use case is gone for at least some configurations.

- Pygrub is running in dom0 with root privileges. As it is operating on guest controlled data (the boot image) and taking decisions based on this data, there is a possible security issue. Not being possible to use pygrub is thus a step towards more security.

Default is still to build and install pygrub.

---
 config/Tools.mk.in |  1 +
 tools/Makefile     |  2 +-
 tools/configure    | 26 ++++++++++++++++++++++++++
 tools/configure.ac |  1 +
 4 files changed, 29 insertions(+), 1 deletion(-)
config/Tools.mk.in +1 -0
index b7cc2961d8..432d7496f1 100644
@@ -48,6 +48,7 @@ CONFIG_QEMU_XEN     := @qemu_xen@
 CONFIG_QEMUU_EXTRA_ARGS:= @EXTRA_QEMUU_CONFIGURE_ARGS@
 CONFIG_LIBNL        := @libnl@
 CONFIG_GOLANG       := @golang@
+CONFIG_PYGRUB       := @pygrub@
 
 CONFIG_SYSTEMD      := @systemd@
 SYSTEMD_CFLAGS      := @SYSTEMD_CFLAGS@
tools/Makefile +1 -1
index 1ff90ddfa0..bbd75ebc1a 100644
@@ -36,7 +36,7 @@ SUBDIRS-$(CONFIG_X86) += debugger
 SUBDIRS-$(CONFIG_TESTS) += tests
 
 SUBDIRS-y += python
-SUBDIRS-y += pygrub
+SUBDIRS-$(CONFIG_PYGRUB) += pygrub
 SUBDIRS-$(OCAML_TOOLS) += ocaml
 
 ifeq ($(CONFIG_RUMP),y)
tools/configure +26 -0
index 52b4717d01..130e0d9abf 100755
@@ -707,6 +707,7 @@ AS86
 ipxe
 qemu_traditional
 LINUX_BACKEND_MODULES
+pygrub
 golang
 seabios
 ovmf
@@ -811,6 +812,7 @@ enable_xsmpolicy
 enable_ovmf
 enable_seabios
 enable_golang
+enable_pygrub
 with_linux_backend_modules
 enable_qemu_traditional
 enable_ipxe
@@ -1498,6 +1500,7 @@ Optional Features:
   --enable-ovmf           Enable OVMF (default is DISABLED)
   --disable-seabios       Disable SeaBIOS (default is ENABLED)
   --disable-golang        Disable Go tools (default is ENABLED)
+  --disable-pygrub        Disable pygrub (default is ENABLED)
   --enable-qemu-traditional
                           Enable qemu traditional device model, (DEFAULT is
                           off)
@@ -4287,6 +4290,29 @@ golang=$ax_cv_golang
 
 
 
+# Check whether --enable-pygrub was given.
+if test "${enable_pygrub+set}" = set; then :
+  enableval=$enable_pygrub;
+fi
+
+
+if test "x$enable_pygrub" = "xno"; then :
+
+    ax_cv_pygrub="n"
+
+elif test "x$enable_pygrub" = "xyes"; then :
+
+    ax_cv_pygrub="y"
+
+elif test -z $ax_cv_pygrub; then :
+
+    ax_cv_pygrub="y"
+
+fi
+pygrub=$ax_cv_pygrub
+
+
+
 
 # Check whether --with-linux-backend-modules was given.
 if test "${with_linux_backend_modules+set}" = set; then :
tools/configure.ac +1 -0
index 3cccf41960..9947bcefc6 100644
@@ -89,6 +89,7 @@ AX_ARG_DEFAULT_ENABLE([xsmpolicy], [Disable XSM policy compilation])
 AX_ARG_DEFAULT_DISABLE([ovmf], [Enable OVMF])
 AX_ARG_DEFAULT_ENABLE([seabios], [Disable SeaBIOS])
 AX_ARG_DEFAULT_ENABLE([golang], [Disable Go tools])
+AX_ARG_DEFAULT_ENABLE([pygrub], [Disable pygrub])
 
 AC_ARG_WITH([linux-backend-modules],
     AS_HELP_STRING([--with-linux-backend-modules="mod1 mod2"],
Signature · 1 line
2.35.3
Acked-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] tools: add configure option for disabling pygrub

Quoted 12 lines · Juergen Gross

Add a "--disable-pygrub" option for being able to disable the build and installation of pygrub.

There are two main reasons to do so:

- A main reason to use pygrub is to allow a PV guest to choose its bitness (32- or 64-bit). Pygrub allows that by looking into the boot image and to start the guest in the correct mode depending on the kernel selected. With 32-bit PV guests being deprecated and the possibility to even build a hypervisor without 32-bit PV support, this use case is gone for at least some configurations.

Quoted 8 lines

- Pygrub is running in dom0 with root privileges. As it is operating on guest controlled data (the boot image) and taking decisions based on this data, there is a possible security issue. Not being possible to use pygrub is thus a step towards more security.

Default is still to build and install pygrub.

Thanks,

Signature · 1 line
Anthony PERARD
#3 lore raw

Re: [PATCH 1/2] tools: add configure option for disabling pygrub

In reply to Juergen Gross
Quoted 12 lines · Juergen Gross

Add a "--disable-pygrub" option for being able to disable the build and installation of pygrub.

There are two main reasons to do so:

- A main reason to use pygrub is to allow a PV guest to choose its bitness (32- or 64-bit). Pygrub allows that by looking into the boot image and to start the guest in the correct mode depending on the kernel selected. With 32-bit PV guests being deprecated and the possibility to even build a hypervisor without 32-bit PV support, this use case is gone for at least some configurations.

Quoted 3 lines

- Pygrub is running in dom0 with root privileges. As it is operating on guest controlled data (the boot image) and taking decisions based on this data, there is a possible security issue.

This isn't really a possible security issue.  It's a high(er) security risk.

Pygrub is still security supported, so falls under the usual security process if an issue were to be found.

Quoted 2 lines

Not being possible
to use pygrub is thus a step towards more security.

IMO, the phrase you want to use here is "reduction in attack surface".

Quoted 9 lines

Default is still to build and install pygrub.

---
 config/Tools.mk.in |  1 +
 tools/Makefile     |  2 +-
 tools/configure    | 26 ++++++++++++++++++++++++++
 tools/configure.ac |  1 +
 4 files changed, 29 insertions(+), 1 deletion(-)

Shouldn't we have a patch to (lib)xl which provides a clean error message (rather than -ESRCH/etc) when the user selects bootloader=pygrub ?

Fine to be a separate patch, but not something which wants forgetting.

~Andrew

#4 lore raw

Re: [PATCH 1/2] tools: add configure option for disabling pygrub

Quoted 13 lines · Andrew Cooper
Quoted 12 lines · Juergen Gross

Add a "--disable-pygrub" option for being able to disable the build and installation of pygrub.

There are two main reasons to do so:

- A main reason to use pygrub is to allow a PV guest to choose its bitness (32- or 64-bit). Pygrub allows that by looking into the boot image and to start the guest in the correct mode depending on the kernel selected. With 32-bit PV guests being deprecated and the possibility to even build a hypervisor without 32-bit PV support, this use case is gone for at least some configurations.

Quoted 5 lines
Quoted 3 lines

- Pygrub is running in dom0 with root privileges. As it is operating on guest controlled data (the boot image) and taking decisions based on this data, there is a possible security issue.

This isn't really a possible security issue.  It's a high(er) security risk.

True. I'll s/possible security issue/higher security risk/.

Quoted 8 lines

Pygrub is still security supported, so falls under the usual security process if an issue were to be found.

Quoted 2 lines

Not being possible
to use pygrub is thus a step towards more security.

IMO, the phrase you want to use here is "reduction in attack surface".

Thanks. I'll use that.

Quoted 11 lines
Quoted 10 lines

Default is still to build and install pygrub.

---
  config/Tools.mk.in |  1 +
  tools/Makefile     |  2 +-
  tools/configure    | 26 ++++++++++++++++++++++++++
  tools/configure.ac |  1 +
  4 files changed, 29 insertions(+), 1 deletion(-)
Quoted 4 lines

Shouldn't we have a patch to (lib)xl which provides a clean error message (rather than -ESRCH/etc) when the user selects bootloader=pygrub ?

Fine to be a separate patch, but not something which wants forgetting.

I'll add it.

Juergen

#5 lore raw

PATCH 2/2 tools: add configure option for libfsimage

In reply to Juergen Gross

The only in-tree user of libfsimage is pygrub. Now that it is possible to disable the build of pygrub, the same should be possible for libfsimage.

Add an option for controlling the build of libfsimage. The default is on if pygrub is being built, and off if it isn't. Without pygrub the build of libfsimage can be enabled via --enable-libfsimage.

---
 config/Tools.mk.in |  1 +
 tools/Makefile     |  2 +-
 tools/configure    | 28 ++++++++++++++++++++++++++++
 tools/configure.ac | 13 +++++++++++++
 4 files changed, 43 insertions(+), 1 deletion(-)
config/Tools.mk.in +1 -0
index 432d7496f1..b54ab21f96 100644
@@ -49,6 +49,7 @@ CONFIG_QEMUU_EXTRA_ARGS:= @EXTRA_QEMUU_CONFIGURE_ARGS@
 CONFIG_LIBNL        := @libnl@
 CONFIG_GOLANG       := @golang@
 CONFIG_PYGRUB       := @pygrub@
+CONFIG_LIBFSIMAGE   := @libfsimage@
 
 CONFIG_SYSTEMD      := @systemd@
 SYSTEMD_CFLAGS      := @SYSTEMD_CFLAGS@
tools/Makefile +1 -1
index bbd75ebc1a..311a9098d7 100644
@@ -18,7 +18,7 @@ SUBDIRS-$(CONFIG_X86) += firmware
 SUBDIRS-y += console
 SUBDIRS-y += xenmon
 SUBDIRS-$(XENSTAT_XENTOP) += xentop
-SUBDIRS-y += libfsimage
+SUBDIRS-$(CONFIG_LIBFSIMAGE) += libfsimage
 SUBDIRS-$(CONFIG_Linux) += vchan
 
 # do not recurse in to a dir we are about to delete
tools/configure +28 -0
index 130e0d9abf..60dca366ca 100755
@@ -700,6 +700,7 @@ EXTRA_QEMUU_CONFIGURE_ARGS
 qemu_xen_systemd
 qemu_xen_path
 qemu_xen
+libfsimage
 rombios
 BCC
 LD86
@@ -818,6 +819,7 @@ enable_qemu_traditional
 enable_ipxe
 with_system_ipxe
 enable_rombios
+enable_libfsimage
 with_system_qemu
 with_stubdom_qmp_proxy
 with_system_seabios
@@ -1508,6 +1510,8 @@ Optional Features:
                           --with-system-ipxe)
   --enable-rombios        Enable ROMBIOS, (DEFAULT is on if qemu-traditional
                           or ipxe is enabled, otherwise off)
+  --enable-libfsimage     Enable libfsimage, (DEFAULT is on if pygrub is
+                          enabled, otherwise off)
   --enable-systemd        Enable systemd support (default is DISABLED)
   --enable-9pfs           Explicitly enable 9pfs support in QEMU build
                           (default is to defer to QEMU configure default)
@@ -4621,6 +4625,30 @@ else
 fi
 
 
+# Check whether --enable-libfsimage was given.
+if test "${enable_libfsimage+set}" = set; then :
+  enableval=$enable_libfsimage;
+else
+
+    if test "x$enable_pygrub" = "xno"; then :
+
+        enable_libfsimage="no"
+
+else
+
+        enable_libfsimage="yes"
+
+fi
+
+fi
+
+if test "x$enable_libfsimage" = "xyes"; then :
+  libfsimage=y
+else
+  libfsimage=n
+fi
+
+
 
 # Check whether --with-system-qemu was given.
 if test "${with_system_qemu+set}" = set; then :
tools/configure.ac +13 -0
index 9947bcefc6..aea24eb982 100644
@@ -185,6 +185,19 @@ AS_IF([test "x$enable_rombios" = "xyes"], [
 ])
 AC_SUBST(rombios)
 
+AC_ARG_ENABLE([libfsimage],
+    AS_HELP_STRING([--enable-libfsimage],
+                   [Enable libfsimage, (DEFAULT is on if pygrub is enabled,
+                    otherwise off)]),,[
+    AS_IF([test "x$enable_pygrub" = "xno"], [
+        enable_libfsimage="no"
+    ], [
+        enable_libfsimage="yes"
+    ])
+])
+AS_IF([test "x$enable_libfsimage" = "xyes"], [libfsimage=y], [libfsimage=n])
+AC_SUBST(libfsimage)
+
 AC_ARG_WITH([system-qemu],
     AS_HELP_STRING([--with-system-qemu@<:@=PATH@:>@],
        [Use system supplied qemu PATH or qemu (taken from $PATH) as qemu-xen
Signature · 1 line
2.35.3
#6 lore raw

Re: [PATCH 2/2] tools: add configure option for libfsimage

Quoted 21 lines · Juergen Gross

The only in-tree user of libfsimage is pygrub. Now that it is possible to disable the build of pygrub, the same should be possible for libfsimage.

Add an option for controlling the build of libfsimage. The default is on if pygrub is being built, and off if it isn't. Without pygrub the build of libfsimage can be enabled via --enable-libfsimage.

---

tools/configure.ac +3 -0
index 9947bcefc6..aea24eb982 100644
@@ -185,6 +185,19 @@ AS_IF([test "x$enable_rombios" = "xyes"], [
 ])
 AC_SUBST(rombios)
 
+AC_ARG_ENABLE([libfsimage],
+    AS_HELP_STRING([--enable-libfsimage],
+                   [Enable libfsimage, (DEFAULT is on if pygrub is enabled,

tools/configure.ac AS_IF([test "x$enable_rombios" = "xyes"], [ · line 200

Quoted 10 lines
tools/configure.ac +10 -0
+                    otherwise off)]),,[
+    AS_IF([test "x$enable_pygrub" = "xno"], [
+        enable_libfsimage="no"
+    ], [
+        enable_libfsimage="yes"
+    ])
+])
+AS_IF([test "x$enable_libfsimage" = "xyes"], [libfsimage=y], [libfsimage=n])
+AC_SUBST(libfsimage)
+

Should we issue an error if one does "--disable-libfsimage --enable-pygrub" ? Or just let the build of pygrub fails? Also, "--disable-libfsimage" alone will keep "pygrub" enabled, so we should probably check.

Thanks,

Signature · 1 line
Anthony PERARD
#7 lore raw

Re: [PATCH 2/2] tools: add configure option for libfsimage

Quoted 19 lines · Anthony PERARD
Quoted 18 lines · Juergen Gross

The only in-tree user of libfsimage is pygrub. Now that it is possible to disable the build of pygrub, the same should be possible for libfsimage.

Add an option for controlling the build of libfsimage. The default is on if pygrub is being built, and off if it isn't. Without pygrub the build of libfsimage can be enabled via --enable-libfsimage.

---

tools/configure.ac +0 -0
index 9947bcefc6..aea24eb982 100644
@@ -185,6 +185,19 @@ AS_IF([test "x$enable_rombios" = "xyes"], [
 ])
 AC_SUBST(rombios)
 
Quoted 15 lines

tools/configure.ac AS_IF([test "x$enable_rombios" = "xyes"], [ · line 200

Quoted 13 lines
tools/configure.ac +13 -0
+AC_ARG_ENABLE([libfsimage],
+    AS_HELP_STRING([--enable-libfsimage],
+                   [Enable libfsimage, (DEFAULT is on if pygrub is enabled,
+                    otherwise off)]),,[
+    AS_IF([test "x$enable_pygrub" = "xno"], [
+        enable_libfsimage="no"
+    ], [
+        enable_libfsimage="yes"
+    ])
+])
+AS_IF([test "x$enable_libfsimage" = "xyes"], [libfsimage=y], [libfsimage=n])
+AC_SUBST(libfsimage)
+

Should we issue an error if one does "--disable-libfsimage --enable-pygrub" ? Or just let the build of pygrub fails?

In such a case, it wouldn't be a build failure.  It would fail at runtime with an ImportError.

~Andrew

#8 lore raw

Re: [PATCH 2/2] tools: add configure option for libfsimage

Quoted 36 lines · Andrew Cooper
Quoted 19 lines · Anthony PERARD
Quoted 18 lines · Juergen Gross

The only in-tree user of libfsimage is pygrub. Now that it is possible to disable the build of pygrub, the same should be possible for libfsimage.

Add an option for controlling the build of libfsimage. The default is on if pygrub is being built, and off if it isn't. Without pygrub the build of libfsimage can be enabled via --enable-libfsimage.

---

tools/configure.ac +0 -0
index 9947bcefc6..aea24eb982 100644
@@ -185,6 +185,19 @@ AS_IF([test "x$enable_rombios" = "xyes"], [
  ])
  AC_SUBST(rombios)
 
Quoted 15 lines

tools/configure.ac AS_IF([test "x$enable_rombios" = "xyes"], [ · line 200

Quoted 13 lines
tools/configure.ac +13 -0
+AC_ARG_ENABLE([libfsimage],
+    AS_HELP_STRING([--enable-libfsimage],
+                   [Enable libfsimage, (DEFAULT is on if pygrub is enabled,
+                    otherwise off)]),,[
+    AS_IF([test "x$enable_pygrub" = "xno"], [
+        enable_libfsimage="no"
+    ], [
+        enable_libfsimage="yes"
+    ])
+])
+AS_IF([test "x$enable_libfsimage" = "xyes"], [libfsimage=y], [libfsimage=n])
+AC_SUBST(libfsimage)
+

Should we issue an error if one does "--disable-libfsimage --enable-pygrub" ? Or just let the build of pygrub fails?

Quoted 2 lines

In such a case, it wouldn't be a build failure.  It would fail at runtime with an ImportError.

Indeed.

I'll update the patch to fail configure in such a case.

Juergen