tools: add some more configure options
v2 cover tools: add some more configure options
Add two additional configure options for controlling the build of pygrub and libfsimage.
Changes in V2:
- add check for --enable-pygrub --disable-libfsimage
- new patch 3
Juergen Gross (3):
tools: add configure option for disabling pygrub
tools: add configure option for libfsimage tools/xl: reject bootloader=pygrub in case pygrub is disabled
config/Tools.mk.in | 2 ++ tools/Makefile | 4 +-- tools/config.h.in | 3 ++ tools/configure | 74 +++++++++++++++++++++++++++++++++++++++++++++ tools/configure.ac | 26 ++++++++++++++++ tools/xl/xl_parse.c | 9 ++++++ 6 files changed, 116 insertions(+), 2 deletions(-)
Signature · 1 line
2.35.3
PATCH v2 1/3 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 higher security risk. Not being possible to use pygrub is thus a step towards a reduction of attack surface.
Default is still to build and install pygrub.
---
V2:
- better wording regarding security aspects (Andrew Cooper)
- add HAVE_PYGRUB to tools/config.h
--- config/Tools.mk.in | 1 + tools/Makefile | 2 +- tools/config.h.in | 3 +++ tools/configure | 34 ++++++++++++++++++++++++++++++++++ tools/configure.ac | 5 +++++ 5 files changed, 44 insertions(+), 1 deletion(-)
config/Tools.mk.in +1 -0
@@ -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
@@ -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/config.h.in +3 -0
@@ -45,6 +45,9 @@ /* ROMBIOS enabled */ #undef HAVE_ROMBIOS +/* pygrub enabled */ +#undef HAVE_PYGRUB + /* Define to 1 if you have the <stdint.h> header file. */ #undef HAVE_STDINT_H
tools/configure +34 -0
@@ -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 :
@@ -4595,6 +4621,14 @@ else fi +if test "x$pygrub" = "xy"; then : + + +$as_echo "#define HAVE_PYGRUB 1" >>confdefs.h + + +fi + # Check whether --with-system-qemu was given. if test "${with_system_qemu+set}" = set; then :
tools/configure.ac +5 -0
@@ -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"],
@@ -184,6 +185,10 @@ AS_IF([test "x$enable_rombios" = "xyes"], [ ]) AC_SUBST(rombios) +AS_IF([test "x$pygrub" = "xy"], [ + AC_DEFINE([HAVE_PYGRUB], [1], [pygrub enabled]) +]) + 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
Re: [PATCH v2 1/3] 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 higher security risk. Not being possible to use pygrub is thus a step towards a reduction of attack surface.
Default is still to build and install pygrub.
Signed-off-by Juergen Gross <[email protected]>
Thanks,
Signature · 1 line
Anthony PERARD
PATCH v2 2/3 tools: add configure option for libfsimage
In reply to Juergen GrossThe 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.
---
V2:
- add check for pygrub enabled and libfsimage disabled (Andrew Cooper)
--- config/Tools.mk.in | 1 + tools/Makefile | 2 +- tools/configure | 40 ++++++++++++++++++++++++++++++++++++++++ tools/configure.ac | 21 +++++++++++++++++++++ 4 files changed, 63 insertions(+), 1 deletion(-)
config/Tools.mk.in +1 -0
@@ -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
@@ -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 +40 -0
@@ -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)
@@ -4629,6 +4633,42 @@ $as_echo "#define HAVE_PYGRUB 1" >>confdefs.h fi +# Check whether --enable-libfsimage was given. +if test "${enable_libfsimage+set}" = set; then : + enableval=$enable_libfsimage; +else + + if test "x$pygrub" = "xn"; then : + + enable_libfsimage="no" + +else + + enable_libfsimage="yes" + +fi + +fi + +if test "x$enable_libfsimage" = "xyes"; then : + + libfsimage=y + +else + + if test "x$pygrub" = "xy"; then : + + as_fn_error $? "pygrub needs libfsimage" "$LINENO" 5 + +else + + libfsimage=n + +fi + +fi + + # Check whether --with-system-qemu was given. if test "${with_system_qemu+set}" = set; then :
tools/configure.ac +21 -0
@@ -189,6 +189,27 @@ AS_IF([test "x$pygrub" = "xy"], [ AC_DEFINE([HAVE_PYGRUB], [1], [pygrub enabled]) ]) +AC_ARG_ENABLE([libfsimage], + AS_HELP_STRING([--enable-libfsimage], + [Enable libfsimage, (DEFAULT is on if pygrub is enabled, + otherwise off)]),,[ + AS_IF([test "x$pygrub" = "xn"], [ + enable_libfsimage="no" + ], [ + enable_libfsimage="yes" + ]) +]) +AS_IF([test "x$enable_libfsimage" = "xyes"], [ + libfsimage=y +], [ + AS_IF([test "x$pygrub" = "xy"], [ + AC_MSG_ERROR([pygrub needs libfsimage]) + ], [ + 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
Re: [PATCH v2 2/3] tools: add configure option for libfsimage
Quoted 9 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.
Signed-off-by Juergen Gross <[email protected]>
Thanks,
Signature · 1 line
Anthony PERARD
PATCH v2 3/3 tools/xl: reject bootloader=pygrub in case pygrub is disabled
In reply to Juergen GrossIn case Xen has been configured with "--disable-pygrub", don't accept the domain config option "bootloader=pygrub".
---
V2:
- new patch
--- tools/xl/xl_parse.c | 9 +++++++++ 1 file changed, 9 insertions(+)
tools/xl/xl_parse.c +9 -0
@@ -1692,6 +1692,15 @@ void parse_config_data(const char *config_source,xlu_cfg_get_defbool (config,"acpi" , &b_info->acpi,0 );xlu_cfg_replace_string (config,"bootloader" , &b_info->bootloader,0 ); +#ifndef HAVE_PYGRUB +if (b_info->bootloader && + (!strcmp (b_info->bootloader,"pygrub" ) || + !strcmp (b_info->bootloader,"/usr/bin/pygrub" ))) { +fprintf (stderr,"ERROR: this instance of Xen has been built without support of \"pygrub\".\n" ); +exit (-ERROR_FAIL ); + } +#endif +switch (xlu_cfg_get_list_as_string_list (config,"bootloader_args" , &b_info->bootloader_args,1 )) {case 0 :
Signature · 1 line
2.35.3
Re: [PATCH v2 3/3] tools/xl: reject bootloader=pygrub in case pygrub is disabled
tools/xl/xl_parse.c void parse_config_data(const char *config_source, · line 1698
Quoted 10 lines · Juergen Gross
tools/xl/xl_parse.c +4
-0@@ -1692,6 +1692,15 @@ void parse_config_data(const char *config_source,xlu_cfg_get_defbool (config,"acpi" , &b_info->acpi,0 );xlu_cfg_replace_string (config,"bootloader" , &b_info->bootloader,0 ); +#ifndef HAVE_PYGRUB +if (b_info->bootloader && + (!strcmp (b_info->bootloader,"pygrub" ) || + !strcmp (b_info->bootloader,"/usr/bin/pygrub" ))) {
And no other path combinations can occur? strstr() is perhaps too lax, but what about finding the last slash (if any) and comparing the rest of the string (the full string when there's no slash) against "pygrub"?
tools/xl/xl_parse.c void parse_config_data(const char *config_source, · line 1699
Quoted 1 line
tools/xl/xl_parse.c +1
-0+fprintf (stderr,"ERROR: this instance of Xen has been built without support of \"pygrub\".\n" );
The other question (I'm sorry for my ignorance here) is whether pygrub could come from anywhere else.
Jan
Re: [PATCH v2 3/3] tools/xl: reject bootloader=pygrub in case pygrub is disabled
Quoted 6 lines · Jan Beulich
Quoted 5 lines · Juergen Gross
tools/xl/xl_parse.c +0
-0@@ -1692,6 +1692,15 @@ void parse_config_data(const char *config_source,xlu_cfg_get_defbool (config,"acpi" , &b_info->acpi,0 );
Quoted 9 lines
tools/xl/xl_parse.c void parse_config_data(const char *config_source, · line 1698
Quoted 5 lines
tools/xl/xl_parse.c +4
-0xlu_cfg_replace_string (config,"bootloader" , &b_info->bootloader,0 ); +#ifndef HAVE_PYGRUB +if (b_info->bootloader && + (!strcmp (b_info->bootloader,"pygrub" ) || + !strcmp (b_info->bootloader,"/usr/bin/pygrub" ))) {And no other path combinations can occur?
strstr()is perhaps too lax, but what about finding the last slash (if any) and comparing the rest of the string (the full string when there's no slash) against "pygrub"?
"pygrub" is the preferred variant, "/usr/bin/pygrub" seems to be the legacy variant, which will result in a warning to use "pygrub" only (in case pygrub is enabled, of course).
I don't think we should test for other non-standard paths.
Quoted 5 lines
tools/xl/xl_parse.c void parse_config_data(const char *config_source, · line 1699
Quoted 2 lines
tools/xl/xl_parse.c +1
-0+fprintf (stderr,"ERROR: this instance of Xen has been built without support of \"pygrub\".\n" );The other question (I'm sorry for my ignorance here) is whether pygrub could come from anywhere else.
It would be possible to use that in case it is e.g. installed in /usr/local/bin/pygrub (assuming the check above isn't modified).
Juergen
Re: [PATCH v2 3/3] tools/xl: reject bootloader=pygrub in case pygrub is disabled
Quoted 24 lines · Juergen Gross
Quoted 6 lines · Jan Beulich
Quoted 5 lines · Juergen Gross
tools/xl/xl_parse.c +0
-0@@ -1692,6 +1692,15 @@ void parse_config_data(const char *config_source,xlu_cfg_get_defbool (config,"acpi" , &b_info->acpi,0 );Quoted 9 lines
tools/xl/xl_parse.c void parse_config_data(const char *config_source, · line 1698
Quoted 5 lines
tools/xl/xl_parse.c +4
-0xlu_cfg_replace_string (config,"bootloader" , &b_info->bootloader,0 ); +#ifndef HAVE_PYGRUB +if (b_info->bootloader && + (!strcmp (b_info->bootloader,"pygrub" ) || + !strcmp (b_info->bootloader,"/usr/bin/pygrub" ))) {And no other path combinations can occur?
strstr()is perhaps too lax, but what about finding the last slash (if any) and comparing the rest of the string (the full string when there's no slash) against "pygrub"?"pygrub" is the preferred variant, "
/usr/bin/pygrub" seems to be the legacy variant, which will result in a warning to use "pygrub" only (in case pygrub is enabled, of course).I don't think we should test for other non-standard paths.
Quoted 1 line
Quoted 7 lines
Quoted 4 lines
tools/xl/xl_parse.c void parse_config_data(const char *config_source, · line 1699
Quoted 1 line
tools/xl/xl_parse.c +1
-0+fprintf (stderr,"ERROR: this instance of Xen has been built without support of \"pygrub\".\n" );The other question (I'm sorry for my ignorance here) is whether pygrub could come from anywhere else.
It would be possible to use that in case it is e.g. installed in
/usr/local/bin/pygrub(assuming the check above isn't modified).
Well, okay, I'll leave this to Anthony then.
Jan
Re: [PATCH v2 3/3] tools/xl: reject bootloader=pygrub in case pygrub is disabled
In reply to Juergen GrossQuoted 5 lines · Juergen Gross
In case Xen has been configured with "--disable-pygrub", don't accept the domain config option "bootloader=pygrub".
Suggested-by Andrew Cooper <[email protected]>Signed-off-by Juergen Gross <[email protected]>
I'm unsure about this patch, but I guess we kind of expect pygrub to be built at the same time as `xl'. And it still allow to use "pygrub" if one specify the full path to it. So,
Thanks,
Signature · 1 line
Anthony PERARD