xen: xen-domid-restrict improvements
v5 cover xen: xen-domid-restrict improvements
I have been working on trying to get qemu, when running as a Xen device model, to _actually_ not have power equivalent to root.
I think I have achieved this, with some limitations (which are discussed in my series against xen.git.
However, there are changes to qemu needed. In particular
* The -xen-domid-restrict option does not work properly right now. It only restricts a small subset of the descriptors qemu has open. I am introducing a new library call in the Xen libraries for this, xentoolcore_restrict_all.
* We need to call a different function on domain shutdown.
* The restriction operation needs to be done at a slightly different time, necessitating a new hook.
* Additionally, we want to be able to set aside a uid range for these qemus to run in, and that involves being able to tell qemu to drop privilege by numeric uid and gid.
Thanks to Anthony Perard, Ross Lagerwall, Peter Maydell, Markus Armbruster and Daniel P. Berrange for assistance, review and testing.
m 1/8 xen: link against xentoolcore
r 2/8 xen: restrict: use xentoolcore_restrict_all
rm 3/8 xen: defer call to xen_restrict until just before
r 4/8 xen: destroy_hvm_domain: Move reason into a variable
a 5/8 xen: move xc_interface compatibility fallback further up
r 6/8 xen: destroy_hvm_domain: Try xendevicemodel_shutdown
* 7/8 os-posix: Provide new -runas <uid>.<gid> facility
8/8 configure: do_compiler: Dump some extra info under bash m = commit message (only) changed in v5 of the series
* = patch changed in v5 of the series
r = reviewed
a = acked
Thanks,
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v5 1/8 xen: link against xentoolcore
From: Anthony PERARD <[email protected]>
Xen libraries 4.10 will include a new xentoolcore library, without which xendevicemodel et al will not work.
--- configure | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
configure +5 -3
@@ -2072,7 +2072,7 @@ if test "$xen" != "no" ; then $($pkg_config --modversion xencontrol | sed 's/\./ /g') )" xen=yes xen_pc="xencontrol xenstore xenguest xenforeignmemory xengnttab" - xen_pc="$xen_pc xenevtchn xendevicemodel" + xen_pc="$xen_pc xenevtchn xendevicemodel xentoolcore" QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags $xen_pc)" libs_softmmu="$($pkg_config --libs $xen_pc) $libs_softmmu" LDFLAGS="$($pkg_config --libs $xen_pc) $LDFLAGS"
@@ -2104,18 +2104,20 @@ EOF cat > $TMPC <<EOF && #undef XC_WANT_COMPAT_MAP_FOREIGN_API #include <xenforeignmemory.h> +#include <xentoolcore.h> int main(void) { xenforeignmemory_handle *xfmem; xfmem = xenforeignmemory_open(0, 0); xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0); + xentoolcore_restrict_all(0); return 0; } EOF - compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs" + compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore" then - xen_stable_libs="-lxendevicemodel $xen_stable_libs" + xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore" xen_ctrl_version=41000 xen=yes elif
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v5 2/8 xen: restrict: use xentoolcore_restrict_all
In reply to Ian JacksonAnd insist that it works.
Drop individual use of xendevicemodel_restrict and xenforeignmemory_restrict. These are not actually effective in this version of qemu, because qemu has a large number of fds open onto various Xen control devices.
The restriction arrangements are still not right, because the restriction needs to be done very late - after qemu has opened all of its control fds.
xentoolcore_restrict_all and xentoolcore.h are available in Xen 4.10 and later, only. Provide a compatibility stub. And drop the compatibility stubs for the old functions.
---
v2: Modify the compatibility code, too.
Bump this patch ahead of "defer call to xen_restrict until running" Retain call to xentoolcore_restrict_all
--- include/hw/xen/xen_common.h | 46 +++++++++++---------------------------------- 1 file changed, 11 insertions(+), 35 deletions(-)
include/hw/xen/xen_common.h +11 -35
@@ -91,6 +91,16 @@ static inline void *xenforeignmemory_map2(xenforeignmemory_handle *h, return xenforeignmemory_map(h, dom, prot, pages, arr, err); } +static inline int xentoolcore_restrict_all (domid_t domid) +{ + errno =ENOTTY ; +return -1 ; +} + +#else /* CONFIG_XEN_CTRL_INTERFACE_VERSION >= 41000 */ + +#include <xentoolcore.h> +#endif #if CONFIG_XEN_CTRL_INTERFACE_VERSION <40900
@@ -218,20 +228,6 @@ static inline int xendevicemodel_set_mem_type( return xc_hvm_set_mem_type(dmod, domid, mem_type, first_pfn, nr); } -static inline int xendevicemodel_restrict ( -xendevicemodel_handle *dmod,domid_t domid) -{ - errno =ENOTTY ; -return -1 ; -} - -static inline int xenforeignmemory_restrict ( -xenforeignmemory_handle *fmem,domid_t domid) -{ - errno =ENOTTY ; -return -1 ; -} -#else /* CONFIG_XEN_CTRL_INTERFACE_VERSION >= 40900 */ #undef XC_WANT_COMPAT_DEVICEMODEL_API
@@ -290,28 +286,8 @@ static inline int xen_modified_memory(domid_t domid, uint64_t first_pfn,static inline int xen_restrict (domid_t domid) {int rc; - -/* Attempt to restrict devicemodel operations */ - rc =xendevicemodel_restrict (xen_dmod, domid); + rc =xentoolcore_restrict_all (domid);trace_xen_domid_restrict (rc ? errno :0 ); - -if (rc <0 ) { -/* -* If errno is ENOTTY then restriction is not implemented so -* there's no point in trying to restrict other types of -* operation, but it should not be treated as a failure. -*/ -if (errno ==ENOTTY ) { -return 0 ; - } - -return rc; - } - -/* Restrict foreignmemory operations */ - rc =xenforeignmemory_restrict (xen_fmem, domid); -trace_xen_domid_restrict (rc ? errno :0 ); -return rc; }
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v5 3/8 xen: defer call to xen_restrict until just before os_setup_post
In reply to Ian JacksonWe need to restrict *all* the control fds that qemu opens. Looking in /proc/PID/fd shows there are many; their allocation seems scattered throughout Xen support code in qemu.
We must postpone the restrict call until roughly the same time as qemu changes its uid, chroots (if applicable), and so on.
There doesn't seem to be an appropriate hook already. The RunState change hook fires at different times depending on exactly what mode qemu is operating in.
And it appears that no-one but the Xen code wants a hook at this phase of execution. So, introduce a bare call to a new function xen_setup_post, just before os_setup_post. Also provide the appropriate stub for when Xen compilation is disabled.
We do the restriction before rather than after os_setup_post, because xen_restrict may need to open /dev/null, and os_setup_post might have called chroot.
---
v3: Do xen_setup_post just before, not just after, os_setup_post,
to improve interaction with chroot. Thanks to Ross Lagerwall.
--- hw/i386/xen/xen-hvm.c | 8 -------- hw/xen/xen-common.c | 13 +++++++++++++ include/sysemu/sysemu.h | 2 ++ stubs/xen-hvm.c | 5 +++++ vl.c | 1 + 5 files changed, 21 insertions(+), 8 deletions(-)
hw/i386/xen/xen-hvm.c +0 -8
@@ -1254,14 +1254,6 @@ void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory) goto err; } -if (xen_domid_restrict) { - rc =xen_restrict (xen_domid); -if (rc <0 ) { -error_report ("failed to restrict: error %d" , errno); - goto err; - } - } -xen_create_ioreq_server (xen_domid, &state->ioservid); state->exit.notify = xen_exit_notifier;
hw/xen/xen-common.c +13 -0
@@ -117,6 +117,19 @@ static void xen_change_state_handler(void *opaque, int running, } } +void xen_setup_post (void ) +{ +int rc; + +if (xen_domid_restrict) { + rc =xen_restrict (xen_domid); +if (rc <0 ) { +perror ("xen: failed to restrict" ); +exit (1 ); + } + } +} +static int xen_init (MachineState *ms) { xen_xc =xc_interface_open (0 ,0 ,0 );
include/sysemu/sysemu.h +2 -0
@@ -93,6 +93,8 @@ void qemu_remove_machine_init_done_notifier(Notifier *notify);void qemu_announce_self (void ); +void xen_setup_post (void ); +extern int autostart; typedef enum {
stubs/xen-hvm.c +5 -0
@@ -13,6 +13,7 @@#include "hw/xen/xen.h" #include "exec/memory.h" #include "qmp-commands.h" +#include "sysemu/sysemu.h" int xen_pci_slot_get_pirq (PCIDevice *pci_dev,int irq_num) {
@@ -61,3 +62,7 @@ void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory)void qmp_xen_set_global_dirty_log (bool enable,Error **errp) { } + +void xen_setup_post (void ) +{ +}
vl.c +1 -0
@@ -4792,6 +4792,7 @@ int main(int argc, char **argv, char **envp)vm_start (); } +xen_setup_post ();os_setup_post ();main_loop ();
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v5 4/8 xen: destroy_hvm_domain: Move reason into a variable
In reply to Ian JacksonWe are going to want to reuse this.
No functional change.
--- hw/i386/xen/xen-hvm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
hw/i386/xen/xen-hvm.c +3 -2
@@ -1387,12 +1387,13 @@ void destroy_hvm_domain(bool reboot)xc_interface *xc_handle;int sts; +unsigned int reason = reboot ? SHUTDOWN_reboot : SHUTDOWN_poweroff; + xc_handle =xc_interface_open (0 ,0 ,0 );if (xc_handle ==NULL ) {fprintf (stderr,"Cannot acquire xenctrl handle\n" ); }else { - sts =xc_domain_shutdown (xc_handle, xen_domid, - reboot ? SHUTDOWN_reboot : SHUTDOWN_poweroff); + sts =xc_domain_shutdown (xc_handle, xen_domid, reason);if (sts !=0 ) { fprintf(stderr, "xc_domain_shutdown failed to issue %s, " "sts %d, %s\n", reboot ? "reboot" : "poweroff",
Signature · 1 line
2.1.4
PATCH v5 5/8 xen: move xc_interface compatibility fallback further up the file
In reply to Ian JacksonWe are going to want to use the dummy xendevicemodel_handle type in new stub functions in the CONFIG_XEN_CTRL_INTERFACE_VERSION < 41000 section. So we need to provide that definition, or (as applicable) include the appropriate header, earlier in the file.
(Ideally the newer compatibility layers would be at the bottom of the file, so that they can naturally benefit from the compatibility layers for earlier version. But that's rather too much for this series.)
No functional change.
---
v2: New patch in v2 of the series
--- include/hw/xen/xen_common.h | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
include/hw/xen/xen_common.h +11 -7
@@ -78,6 +78,17 @@ static inline void *xenforeignmemory_map(xc_interface *h, uint32_t dom,extern xenforeignmemory_handle *xen_fmem; +#if CONFIG_XEN_CTRL_INTERFACE_VERSION <40900 + +typedef xc_interface xendevicemodel_handle ; + +#else /* CONFIG_XEN_CTRL_INTERFACE_VERSION >= 40900 */ + +#undef XC_WANT_COMPAT_DEVICEMODEL_API +#include <xendevicemodel.h> + +#endif +#if CONFIG_XEN_CTRL_INTERFACE_VERSION <41000 #define XEN_COMPAT_PHYSMAP
@@ -105,8 +116,6 @@ static inline int xentoolcore_restrict_all(domid_t domid)#if CONFIG_XEN_CTRL_INTERFACE_VERSION <40900 -typedef xc_interface xendevicemodel_handle ; -static inline xendevicemodel_handle *xendevicemodel_open (struct xentoollog_logger *logger,unsigned int open_flags) {
@@ -228,11 +237,6 @@ static inline int xendevicemodel_set_mem_type( return xc_hvm_set_mem_type(dmod, domid, mem_type, first_pfn, nr); } -#else /* CONFIG_XEN_CTRL_INTERFACE_VERSION >= 40900 */ - -#undef XC_WANT_COMPAT_DEVICEMODEL_API -#include <xendevicemodel.h> -#endif extern xendevicemodel_handle *xen_dmod;
Signature · 1 line
2.1.4
PATCH v5 6/8 xen: destroy_hvm_domain: Try xendevicemodel_shutdown
In reply to Ian Jacksonxc_interface_open etc. is not going to work if we have dropped privilege, but xendevicemodel_shutdown will if everything is new enough.
xendevicemodel_shutdown is only availabe in Xen 4.10 and later, so provide a stub for earlier versions.
---
v2: Add compatibility stub for Xen < 4.10.
Fix coding style.
--- hw/i386/xen/xen-hvm.c | 10 ++++++++++ include/hw/xen/xen_common.h | 7 +++++++ 2 files changed, 17 insertions(+)
hw/i386/xen/xen-hvm.c +10 -0
@@ -1386,9 +1386,19 @@ void destroy_hvm_domain(bool reboot) {xc_interface *xc_handle;int sts; +int rc;unsigned int reason = reboot ? SHUTDOWN_reboot : SHUTDOWN_poweroff; +if (xen_dmod) { + rc =xendevicemodel_shutdown (xen_dmod, xen_domid, reason); +if (!rc) { +return ; + } +perror ("xendevicemodel_shutdown failed" ); +/* well, try the old thing then */ + } + xc_handle =xc_interface_open (0 ,0 ,0 );if (xc_handle ==NULL ) {fprintf (stderr,"Cannot acquire xenctrl handle\n" );
include/hw/xen/xen_common.h +7 -0
@@ -108,6 +108,13 @@ static inline int xentoolcore_restrict_all(domid_t domid) return -1; } +static inline int xendevicemodel_shutdown (xendevicemodel_handle *dmod, +domid_t domid,unsigned int reason) +{ + errno =ENOTTY ; +return -1 ; +} +#else /* CONFIG_XEN_CTRL_INTERFACE_VERSION >= 41000 */ #include <xentoolcore.h>
Signature · 1 line
2.1.4
PATCH v5 7/8 os-posix: Provide new -runas <uid>.<gid> facility
In reply to Ian JacksonThis allows the caller to specify a uid and gid to use, even if there is no corresponding password entry. This will be useful in certain Xen configurations.
We don't support just -runas <uid> because: (i) deprivileging without calling setgroups would be ineffective (ii) given only a uid we don't know what gid we ought to use (since uids may eppear in multiple passwd file entries with different gids).
---
v4: Changed to reuse option -runas
v3: Error messages fixed. Thanks to Peter Maydell and Ross Lagerwall.
v2: Coding style fixes.
--- os-posix.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++---------- qemu-options.hx | 3 ++- 2 files changed, 55 insertions(+), 12 deletions(-)
os-posix.c +53 -11
@@ -43,6 +43,8 @@#endif static struct passwd *user_pwd; +static uid_t user_uid = (uid_t)-1 ; +static gid_t user_gid = (gid_t)-1 ;static const char *chroot_dir;static int daemonize;static int daemon_pipe;
@@ -128,6 +130,34 @@ void os_set_proc_name(const char *s)#endif } + +static bool os_parse_runas_uid_gid (const char *optarg) +{ +unsigned long lv; +char *ep; +uid_t got_uid; +gid_t got_gid; +int rc; + + errno =0 ; + lv =strtoul (optarg, &ep,0 );/* can't qemu_strtoul, want *ep=='.' */ + got_uid = lv;/* overflow here is ID in C99 */ +if (errno || *ep !='.' || got_uid != lv || got_uid == (uid_t)-1 ) { +return false; + } + + lv =0 ; + rc =qemu_strtoul (ep +1 ,0 ,0 , &lv); + got_gid = lv;/* overflow here is ID in C99 */ +if (rc || got_gid != lv || got_gid == (gid_t)-1 ) { +return false; + } + + user_uid = got_uid; + user_gid = got_gid; +return true; +} +/* * Parse OS specific command line options. * return 0 if option handled, -1 otherwise
@@ -145,8 +175,10 @@ void os_parse_cmd_args(int index, const char *optarg)#endif case QEMU_OPTION_runas: user_pwd =getpwnam (optarg); -if (!user_pwd) { -fprintf (stderr,"User \"%s\" doesn't exist\n" , optarg); +if (!user_pwd && !os_parse_runas_uid_gid (optarg)) { +fprintf (stderr, +"User \"%s\" doesn't exist (and is not <uid>.<gid>)\n" , + optarg);exit (1 ); }break ;
@@ -166,18 +198,28 @@ void os_parse_cmd_args(int index, const char *optarg)static void change_process_uid (void ) { -if (user_pwd) { -if (setgid (user_pwd->pw_gid) <0 ) { -fprintf (stderr,"Failed to setgid(%d)\n" , user_pwd->pw_gid); +if (user_pwd || user_uid != (uid_t)-1 ) { +gid_t intended_gid = user_pwd ? user_pwd->pw_gid : user_gid; +uid_t intended_uid = user_pwd ? user_pwd->pw_uid : user_uid; +if (setgid (intended_gid) <0 ) { +fprintf (stderr,"Failed to setgid(%d)\n" , intended_gid);exit (1 ); } -if (initgroups (user_pwd->pw_name, user_pwd->pw_gid) <0 ) { -fprintf (stderr,"Failed to initgroups(\"%s\", %d)\n" , - user_pwd->pw_name, user_pwd->pw_gid); -exit (1 ); +if (user_pwd) { +if (initgroups (user_pwd->pw_name, user_pwd->pw_gid) <0 ) { +fprintf (stderr,"Failed to initgroups(\"%s\", %d)\n" , + user_pwd->pw_name, user_pwd->pw_gid); +exit (1 ); + } + }else { +if (setgroups (1 , &user_gid) <0 ) { +fprintf (stderr,"Failed to setgroups(1, [%d])" , + user_gid); +exit (1 ); + } } -if (setuid (user_pwd->pw_uid) <0 ) { -fprintf (stderr,"Failed to setuid(%d)\n" , user_pwd->pw_uid); +if (setuid (intended_uid) <0 ) { +fprintf (stderr,"Failed to setuid(%d)\n" , intended_uid);exit (1 ); }if (setuid (0 ) !=-1 ) {
qemu-options.hx +2 -1
@@ -3958,7 +3958,8 @@ ETEXI #ifndef _WIN32 DEF("runas", HAS_ARG, QEMU_OPTION_runas, \ - "-runas user change to user id user just before starting the VM\n", + "-runas user change to user id user just before starting the VM\n" \ + " user can be numeric uid.gid instead\n", QEMU_ARCH_ALL) #endif STEXI
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v5 8/8 configure: do_compiler: Dump some extra info under bash
In reply to Ian JacksonThis makes it much easier to find a particular thing in config.log.
The information may be lacking in other shells, resulting in harmless empty output. (This is why we don't use the proper ${FUNCNAME[*]} array syntax - other shells will choke on that.)
The extra output is only printed if configure is run with bash. The
something), it is necessary to say bash ./configure to get the extra
debug info in the log.
---
v4: No longer tag this patch RFC.
--- configure | 4 ++++ 1 file changed, 4 insertions(+)
configure +4 -0
@@ -60,6 +60,10 @@ do_compiler() { # is compiler binary to execute. local compiler="$1" shift + echo >>config.log " +funcs: ${FUNCNAME} +lines: ${BASH_LINENO} +files: ${BASH_SOURCE}" echo $compiler "$@" >> config.log $compiler "$@" >> config.log 2>&1 || return $? # Test passed. If this is an --enable-werror build, rerun
Signature · 1 line
2.1.4
This series seems to have some coding style problems. See output below for more information:
Hi,
This series seems to have some coding style problems. See output below for more information:
Type: series
Message-id: [email protected]
Subject: [Qemu-devel] [PATCH v5 0/8] xen: xen-domid-restrict improvements
=== TEST SCRIPT BEGIN ===
#!/bin/bash
BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0
git config --local diff.renamelimit 0
git config --local diff.renames True
commits="$(git log --format=%H --reverse $BASE..)" for c in $commits; do
echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
failed=1
echo
fi
n=$((n+1))done
exit $failed
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'b9f9672c4d configure: do_compiler: Dump some extra info under bash 74f2dc4a81 os-posix: Provide new -runas <uid>.<gid> facility 34bf5bf2fa xen: destroy_hvm_domain: Try xendevicemodel_shutdown baa9207819 xen: move xc_interface compatibility fallback further up the file f3cb5e6890 xen: destroy_hvm_domain: Move reason into a variable 4d0d91ed91 xen: defer call to xen_restrict until just before os_setup_post 4deada5196 xen: restrict: use xentoolcore_restrict_all 13836ce7d9 xen: link against xentoolcore
=== OUTPUT BEGIN ===
Checking PATCH 1/8: xen: link against xentoolcore...
Checking PATCH 2/8: xen: restrict: use xentoolcore_restrict_all... Checking PATCH 3/8: xen: defer call to xen_restrict until just before os_setup_post... Checking PATCH 4/8: xen: destroy_hvm_domain: Move reason into a variable... Checking PATCH 5/8: xen: move xc_interface compatibility fallback further up the file... Checking PATCH 6/8: xen: destroy_hvm_domain: Try xendevicemodel_shutdown... Checking PATCH 7/8: os-posix: Provide new -runas <uid>.<gid> facility...
ERROR: consider using qemu_strtoul in preference to strtoul
#45: FILE: os-posix.c:142:
+ lv = strtoul(optarg, &ep, 0); /* can't qemu_strtoul, want *ep=='.' */
total: 1 errors, 0 warnings, 100 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
Checking PATCH 8/8: configure: do_compiler: Dump some extra info under bash... === OUTPUT END ===
Test command exited with code: 1
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
[email protected] writes ("Re: [Qemu-devel] [PATCH v5 0/8] xen: xen-domid-restrict improvements"):
Quoted 2 lines
This series seems to have some coding style problems. See output below for more information:
No, it doesn't have coding style problems. At least, this mail contains only one complaint which is this:
Quoted 4 lines
Checking PATCH 7/8: os-posix: Provide new -runas <uid>.<gid> facility...
ERROR: consider usingqemu_strtoulin preference to strtoul #45: FILE: os-posix.c:142:
+ lv =strtoul(optarg, &ep, 0); /* can'tqemu_strtoul, want *ep=='.' */
This is a false positive as you can see from the comment.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Hi Ian,
The patches in this v5 appear to be the same the one from the patch series v4.
Signature · 6 lines
Anthony PERARD _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Anthony PERARD writes ("Re: [PATCH v5 0/8] xen: xen-domid-restrict improvements"):
Quoted 2 lines
The patches in this v5 appear to be the same the one from the patch series v4.
Erk, so they are.
I'll post a v5.1 in reply to this email.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v5 1/8 xen: link against xentoolcore
From: Anthony PERARD <[email protected]>
Xen libraries in 4.10 include a new xentoolcore library. This contains the xentoolcore_restrict_all function which we are about to want to use.
---
v5: More truthful commit message.
--- configure | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
configure +5 -3
@@ -2072,7 +2072,7 @@ if test "$xen" != "no" ; then $($pkg_config --modversion xencontrol | sed 's/\./ /g') )" xen=yes xen_pc="xencontrol xenstore xenguest xenforeignmemory xengnttab" - xen_pc="$xen_pc xenevtchn xendevicemodel" + xen_pc="$xen_pc xenevtchn xendevicemodel xentoolcore" QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags $xen_pc)" libs_softmmu="$($pkg_config --libs $xen_pc) $libs_softmmu" LDFLAGS="$($pkg_config --libs $xen_pc) $LDFLAGS"
@@ -2104,18 +2104,20 @@ EOF cat > $TMPC <<EOF && #undef XC_WANT_COMPAT_MAP_FOREIGN_API #include <xenforeignmemory.h> +#include <xentoolcore.h> int main(void) { xenforeignmemory_handle *xfmem; xfmem = xenforeignmemory_open(0, 0); xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0); + xentoolcore_restrict_all(0); return 0; } EOF - compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs" + compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore" then - xen_stable_libs="-lxendevicemodel $xen_stable_libs" + xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore" xen_ctrl_version=41000 xen=yes elif
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v5 2/8 xen: restrict: use xentoolcore_restrict_all
And insist that it works.
Drop individual use of xendevicemodel_restrict and xenforeignmemory_restrict. These are not actually effective in this version of qemu, because qemu has a large number of fds open onto various Xen control devices.
The restriction arrangements are still not right, because the restriction needs to be done very late - after qemu has opened all of its control fds.
xentoolcore_restrict_all and xentoolcore.h are available in Xen 4.10 and later, only. Provide a compatibility stub. And drop the compatibility stubs for the old functions.
---
v2: Modify the compatibility code, too.
Bump this patch ahead of "defer call to xen_restrict until running" Retain call to xentoolcore_restrict_all
--- include/hw/xen/xen_common.h | 46 +++++++++++---------------------------------- 1 file changed, 11 insertions(+), 35 deletions(-)
include/hw/xen/xen_common.h +11 -35
@@ -91,6 +91,16 @@ static inline void *xenforeignmemory_map2(xenforeignmemory_handle *h, return xenforeignmemory_map(h, dom, prot, pages, arr, err); } +static inline int xentoolcore_restrict_all (domid_t domid) +{ + errno =ENOTTY ; +return -1 ; +} + +#else /* CONFIG_XEN_CTRL_INTERFACE_VERSION >= 41000 */ + +#include <xentoolcore.h> +#endif #if CONFIG_XEN_CTRL_INTERFACE_VERSION <40900
@@ -218,20 +228,6 @@ static inline int xendevicemodel_set_mem_type( return xc_hvm_set_mem_type(dmod, domid, mem_type, first_pfn, nr); } -static inline int xendevicemodel_restrict ( -xendevicemodel_handle *dmod,domid_t domid) -{ - errno =ENOTTY ; -return -1 ; -} - -static inline int xenforeignmemory_restrict ( -xenforeignmemory_handle *fmem,domid_t domid) -{ - errno =ENOTTY ; -return -1 ; -} -#else /* CONFIG_XEN_CTRL_INTERFACE_VERSION >= 40900 */ #undef XC_WANT_COMPAT_DEVICEMODEL_API
@@ -290,28 +286,8 @@ static inline int xen_modified_memory(domid_t domid, uint64_t first_pfn,static inline int xen_restrict (domid_t domid) {int rc; - -/* Attempt to restrict devicemodel operations */ - rc =xendevicemodel_restrict (xen_dmod, domid); + rc =xentoolcore_restrict_all (domid);trace_xen_domid_restrict (rc ? errno :0 ); - -if (rc <0 ) { -/* -* If errno is ENOTTY then restriction is not implemented so -* there's no point in trying to restrict other types of -* operation, but it should not be treated as a failure. -*/ -if (errno ==ENOTTY ) { -return 0 ; - } - -return rc; - } - -/* Restrict foreignmemory operations */ - rc =xenforeignmemory_restrict (xen_fmem, domid); -trace_xen_domid_restrict (rc ? errno :0 ); -return rc; }
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [Qemu-devel] [PATCH v5.1 2/8] xen: restrict: use xentoolcore_restrict_all
Quoted 30 lines · Ian Jackson
And insist that it works.
Drop individual use of
xendevicemodel_restrictandxenforeignmemory_restrict. These are not actually effective in this version of qemu, because qemu has a large number of fds open onto various Xen control devices.The restriction arrangements are still not right, because the restriction needs to be done very late - after qemu has opened all of its control fds.
xentoolcore_restrict_allandxentoolcore.hare available in Xen 4.10 and later, only. Provide a compatibility stub. And drop the compatibility stubs for the old functions.Signed-off-by Ian Jackson <[email protected]>Reviewed-by Anthony PERARD <[email protected]>---
v2: Modify the compatibility code, too.
Bump this patch ahead of "defer call toxen_restrictuntil running" Retain call toxentoolcore_restrict_all--- include/hw/xen/xen_common.h | 46 +++++++++++---------------------------------- 1 file changed, 11 insertions(+), 35 deletions(-)include/hw/xen/xen_common.h +0
-0
include/hw/xen/xen_common.h static inline void *xenforeignmemory_map2(xenforeignmemory_handle *h, · line 97
Quoted 7 lines
include/hw/xen/xen_common.h +4
-0@@ -91,6 +91,16 @@ static inline void *xenforeignmemory_map2(xenforeignmemory_handle *h,return xenforeignmemory_map (h, dom, prot, pages, arr, err); } +static inline int xentoolcore_restrict_all (domid_t domid) +{ + errno =ENOTTY ; +return -1 ;
Wait, if the compat stub returns error, and this patch removed the code to check for ENOTTY, doesn't it prevent any QEMU compiled against older Xen from working?
Or am I missing something?
Quoted 63 lines
include/hw/xen/xen_common.h +7
-35+} + +#else /* CONFIG_XEN_CTRL_INTERFACE_VERSION >= 41000 */ + +#include <xentoolcore.h> +#endif #if CONFIG_XEN_CTRL_INTERFACE_VERSION <40900 @@ -218,20 +228,6 @@ static inline int xendevicemodel_set_mem_type( return xc_hvm_set_mem_type(dmod, domid, mem_type, first_pfn, nr); } -static inline int xendevicemodel_restrict ( -xendevicemodel_handle *dmod,domid_t domid) -{ - errno =ENOTTY ; -return -1 ; -} - -static inline int xenforeignmemory_restrict ( -xenforeignmemory_handle *fmem,domid_t domid) -{ - errno =ENOTTY ; -return -1 ; -} -#else /* CONFIG_XEN_CTRL_INTERFACE_VERSION >= 40900 */ #undef XC_WANT_COMPAT_DEVICEMODEL_API@@ -290,28 +286,8 @@ static inline int xen_modified_memory(domid_t domid, uint64_t first_pfn,static inline int xen_restrict (domid_t domid) {int rc; - -/* Attempt to restrict devicemodel operations */ - rc =xendevicemodel_restrict (xen_dmod, domid); + rc =xentoolcore_restrict_all (domid);trace_xen_domid_restrict (rc ? errno :0 ); - -if (rc <0 ) { -/* -* If errno is ENOTTY then restriction is not implemented so -* there's no point in trying to restrict other types of -* operation, but it should not be treated as a failure. -*/ -if (errno ==ENOTTY ) { -return 0 ; - } - -return rc; - } - -/* Restrict foreignmemory operations */ - rc =xenforeignmemory_restrict (xen_fmem, domid); -trace_xen_domid_restrict (rc ? errno :0 ); -return rc; }Signature · 1 line
2.1.4
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [Qemu-devel] [PATCH v5.1 2/8] xen: restrict: use xentoolcore_restrict_all
Stefano Stabellini writes ("Re: [PATCH v5.1 2/8] xen: restrict: use xentoolcore_restrict_all"):
Quoted 1 line · Ian Jackson
...
Quoted 4 lines
Quoted 4 lines
Drop individual use of
xendevicemodel_restrictandxenforeignmemory_restrict. These are not actually effective in this version of qemu, because qemu has a large number of fds open onto various Xen control devices.
...
Quoted 5 lines
Wait, if the compat stub returns error, and this patch removed the code to check for ENOTTY, doesn't it prevent any QEMU compiled against older Xen from working?
Or am I missing something?
You are right, but this is intended. The paragraph I quote in the commit message above is intended to explain.
That is: without xentoolcore_restrict_all, -xen-domid-restrict is a booby-trap. It does not actually prevent a compromised qemu from doing anything. So there is no reason to pass it in such a configuration. If you do pass it it is better for the domain startup to fail, than for it to carry on without the restriction.
The only reason I am not saying someone should be issuing an advisory is that this feature was never supported by any of the Xen toolstacks.
Thanks,
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Stefano Stabellini
Acked-byRe: [Qemu-devel] [PATCH v5.1 2/8] xen: restrict: use xentoolcore_restrict_all
Quoted 17 lines · Ian Jackson
Stefano Stabellini writes ("Re: [PATCH v5.1 2/8] xen: restrict: use
xentoolcore_restrict_all"):Quoted 1 line · Ian Jackson
...
Quoted 4 lines
Quoted 4 lines
Drop individual use of
xendevicemodel_restrictandxenforeignmemory_restrict. These are not actually effective in this version of qemu, because qemu has a large number of fds open onto various Xen control devices....
Quoted 5 lines
Wait, if the compat stub returns error, and this patch removed the code to check for ENOTTY, doesn't it prevent any QEMU compiled against older Xen from working?
Or am I missing something?
You are right, but this is intended. The paragraph I quote in the commit message above is intended to explain.
Quoted 8 lines
That is: without
xentoolcore_restrict_all, -xen-domid-restrict is a booby-trap. It does not actually prevent a compromised qemu from doing anything. So there is no reason to pass it in such a configuration. If you do pass it it is better for the domain startup to fail, than for it to carry on without the restriction.The only reason I am not saying someone should be issuing an advisory is that this feature was never supported by any of the Xen toolstacks.
Ah, right. And libxl has never passed -xen-domid-restrict in previous releases, so we are OK.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v5 3/8 xen: defer call to xen_restrict until just before os_setup_post
In reply to Ian JacksonWe need to restrict *all* the control fds that qemu opens. Looking in /proc/PID/fd shows there are many; their allocation seems scattered throughout Xen support code in qemu.
We must postpone the restrict call until roughly the same time as qemu changes its uid, chroots (if applicable), and so on.
There doesn't seem to be an appropriate hook already. The RunState change hook fires at different times depending on exactly what mode qemu is operating in.
And it appears that no-one but the Xen code wants a hook at this phase of execution. So, introduce a bare call to a new function xen_setup_post, just before os_setup_post. Also provide the appropriate stub for when Xen compilation is disabled.
We do the restriction before rather than after os_setup_post, because xen_restrict may need to open /dev/null, and os_setup_post might have called chroot.
Currently this does not work with migration, because when running as the Xen device model qemu needs to signal to the toolstack that it is ready. It currently does this using xenstore, and for incoming migration (but not for ordinary startup) that happens after os_setup_post.
It is correct that this happens late: we want the incoming migration stream to be processed by a restricted qemu. The fix for this will be to do the startup notification a different way, without using xenstore. (QMP is probably a reasonable choice.)
So for now this restriction feature cannot be used in conjunction with migration. (Note that this is not a regression in this patch, because previously the -xen-restrict-domid call was, in fact, simply ineffective!) We will revisit this in the Xen 4.11 release cycle.
---
v5: Discuss problems with migration startup notification
in the commit message.
v3: Do xen_setup_post just before, not just after, os_setup_post,
to improve interaction with chroot. Thanks to Ross Lagerwall.
--- hw/i386/xen/xen-hvm.c | 8 -------- hw/xen/xen-common.c | 13 +++++++++++++ include/sysemu/sysemu.h | 2 ++ stubs/xen-hvm.c | 5 +++++ vl.c | 1 + 5 files changed, 21 insertions(+), 8 deletions(-)
hw/i386/xen/xen-hvm.c +0 -8
@@ -1254,14 +1254,6 @@ void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory) goto err; } -if (xen_domid_restrict) { - rc =xen_restrict (xen_domid); -if (rc <0 ) { -error_report ("failed to restrict: error %d" , errno); - goto err; - } - } -xen_create_ioreq_server (xen_domid, &state->ioservid); state->exit.notify = xen_exit_notifier;
hw/xen/xen-common.c +13 -0
@@ -117,6 +117,19 @@ static void xen_change_state_handler(void *opaque, int running, } } +void xen_setup_post (void ) +{ +int rc; + +if (xen_domid_restrict) { + rc =xen_restrict (xen_domid); +if (rc <0 ) { +perror ("xen: failed to restrict" ); +exit (1 ); + } + } +} +static int xen_init (MachineState *ms) { xen_xc =xc_interface_open (0 ,0 ,0 );
include/sysemu/sysemu.h +2 -0
@@ -93,6 +93,8 @@ void qemu_remove_machine_init_done_notifier(Notifier *notify);void qemu_announce_self (void ); +void xen_setup_post (void ); +extern int autostart; typedef enum {
stubs/xen-hvm.c +5 -0
@@ -13,6 +13,7 @@#include "hw/xen/xen.h" #include "exec/memory.h" #include "qmp-commands.h" +#include "sysemu/sysemu.h" int xen_pci_slot_get_pirq (PCIDevice *pci_dev,int irq_num) {
@@ -61,3 +62,7 @@ void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory)void qmp_xen_set_global_dirty_log (bool enable,Error **errp) { } + +void xen_setup_post (void ) +{ +}
vl.c +1 -0
@@ -4792,6 +4792,7 @@ int main(int argc, char **argv, char **envp)vm_start (); } +xen_setup_post ();os_setup_post ();main_loop ();
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [Qemu-devel] [PATCH v5.1 3/8] xen: defer call to xen_restrict until just before os_setup_post
This patch affects non-Xen components. CC'ing the relevant maintainers.
Quoted 142 lines · Ian Jackson
We need to restrict *all* the control fds that qemu opens. Looking in
/proc/PID/fdshows there are many; their allocation seems scattered throughout Xen support code in qemu.We must postpone the restrict call until roughly the same time as qemu changes its uid, chroots (if applicable), and so on.
There doesn't seem to be an appropriate hook already. The RunState change hook fires at different times depending on exactly what mode qemu is operating in.
And it appears that no-one but the Xen code wants a hook at this phase of execution. So, introduce a bare call to a new function
xen_setup_post, just beforeos_setup_post. Also provide the appropriate stub for when Xen compilation is disabled.We do the restriction before rather than after
os_setup_post, becausexen_restrictmay need to open/dev/null, andos_setup_postmight have called chroot.Currently this does not work with migration, because when running as the Xen device model qemu needs to signal to the toolstack that it is ready. It currently does this using xenstore, and for incoming migration (but not for ordinary startup) that happens after
os_setup_post.It is correct that this happens late: we want the incoming migration stream to be processed by a restricted qemu. The fix for this will be to do the startup notification a different way, without using xenstore. (QMP is probably a reasonable choice.)
So for now this restriction feature cannot be used in conjunction with migration. (Note that this is not a regression in this patch, because previously the -xen-restrict-domid call was, in fact, simply ineffective!) We will revisit this in the Xen 4.11 release cycle.
Signed-off-by Ian Jackson <[email protected]>Reviewed-by Anthony PERARD <[email protected]>---
v5: Discuss problems with migration startup notification
in the commit message.
v3: Doxen_setup_postjust before, not just after,os_setup_post,
to improve interaction with chroot. Thanks to Ross Lagerwall.--- hw/i386/xen/xen-hvm.c | 8 -------- hw/xen/xen-common.c | 13 +++++++++++++ include/sysemu/sysemu.h | 2 ++ stubs/xen-hvm.c | 5 +++++ vl.c | 1 + 5 files changed, 21 insertions(+), 8 deletions(-)hw/i386/xen/xen-hvm.c +0
-8@@ -1254,14 +1254,6 @@ void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory) goto err; } -if (xen_domid_restrict) { - rc =xen_restrict (xen_domid); -if (rc <0 ) { -error_report ("failed to restrict: error %d" , errno); - goto err; - } - } -xen_create_ioreq_server (xen_domid, &state->ioservid); state->exit.notify = xen_exit_notifier;hw/xen/xen-common.c +13
-0@@ -117,6 +117,19 @@ static void xen_change_state_handler(void *opaque, int running, } } +void xen_setup_post (void ) +{ +int rc; + +if (xen_domid_restrict) { + rc =xen_restrict (xen_domid); +if (rc <0 ) { +perror ("xen: failed to restrict" ); +exit (1 ); + } + } +} +static int xen_init (MachineState *ms) { xen_xc =xc_interface_open (0 ,0 ,0 );include/sysemu/sysemu.h +2
-0@@ -93,6 +93,8 @@ void qemu_remove_machine_init_done_notifier(Notifier *notify);void qemu_announce_self (void ); +void xen_setup_post (void ); +extern int autostart; typedef enum {stubs/xen-hvm.c +5
-0@@ -13,6 +13,7 @@#include "hw/xen/xen.h" #include "exec/memory.h" #include "qmp-commands.h" +#include "sysemu/sysemu.h" int xen_pci_slot_get_pirq (PCIDevice *pci_dev,int irq_num) {@@ -61,3 +62,7 @@ void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory)void qmp_xen_set_global_dirty_log (bool enable,Error **errp) { } + +void xen_setup_post (void ) +{ +}vl.c +1
-0@@ -4792,6 +4792,7 @@ int main(int argc, char **argv, char **envp)vm_start (); } +xen_setup_post ();os_setup_post ();main_loop ();Signature · 1 line
2.1.4
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v5 4/8 xen: destroy_hvm_domain: Move reason into a variable
In reply to Ian JacksonWe are going to want to reuse this.
No functional change.
--- hw/i386/xen/xen-hvm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
hw/i386/xen/xen-hvm.c +3 -2
@@ -1387,12 +1387,13 @@ void destroy_hvm_domain(bool reboot)xc_interface *xc_handle;int sts; +unsigned int reason = reboot ? SHUTDOWN_reboot : SHUTDOWN_poweroff; + xc_handle =xc_interface_open (0 ,0 ,0 );if (xc_handle ==NULL ) {fprintf (stderr,"Cannot acquire xenctrl handle\n" ); }else { - sts =xc_domain_shutdown (xc_handle, xen_domid, - reboot ? SHUTDOWN_reboot : SHUTDOWN_poweroff); + sts =xc_domain_shutdown (xc_handle, xen_domid, reason);if (sts !=0 ) { fprintf(stderr, "xc_domain_shutdown failed to issue %s, " "sts %d, %s\n", reboot ? "reboot" : "poweroff",
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [Qemu-devel] [PATCH v5.1 4/8] xen: destroy_hvm_domain: Move reason into a variable
Quoted 6 lines · Ian Jackson
We are going to want to reuse this.
No functional change.
Signed-off-by Ian Jackson <[email protected]>Reviewed-by Anthony PERARD <[email protected]>
Quoted 27 lines
--- hw/i386/xen/xen-hvm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)hw/i386/xen/xen-hvm.c +3
-2@@ -1387,12 +1387,13 @@ void destroy_hvm_domain(bool reboot)xc_interface *xc_handle;int sts; +unsigned int reason = reboot ? SHUTDOWN_reboot : SHUTDOWN_poweroff; + xc_handle =xc_interface_open (0 ,0 ,0 );if (xc_handle ==NULL ) {fprintf (stderr,"Cannot acquire xenctrl handle\n" ); }else { - sts =xc_domain_shutdown (xc_handle, xen_domid, - reboot ? SHUTDOWN_reboot : SHUTDOWN_poweroff); + sts =xc_domain_shutdown (xc_handle, xen_domid, reason);if (sts !=0 ) { fprintf(stderr, "xc_domain_shutdown failed to issue %s, " "sts %d, %s\n", reboot ? "reboot" : "poweroff",Signature · 1 line
2.1.4
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v5 5/8 xen: move xc_interface compatibility fallback further up the file
In reply to Ian JacksonWe are going to want to use the dummy xendevicemodel_handle type in new stub functions in the CONFIG_XEN_CTRL_INTERFACE_VERSION < 41000 section. So we need to provide that definition, or (as applicable) include the appropriate header, earlier in the file.
(Ideally the newer compatibility layers would be at the bottom of the file, so that they can naturally benefit from the compatibility layers for earlier version. But that's rather too much for this series.)
No functional change.
---
v2: New patch in v2 of the series
--- include/hw/xen/xen_common.h | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
include/hw/xen/xen_common.h +11 -7
@@ -78,6 +78,17 @@ static inline void *xenforeignmemory_map(xc_interface *h, uint32_t dom,extern xenforeignmemory_handle *xen_fmem; +#if CONFIG_XEN_CTRL_INTERFACE_VERSION <40900 + +typedef xc_interface xendevicemodel_handle ; + +#else /* CONFIG_XEN_CTRL_INTERFACE_VERSION >= 40900 */ + +#undef XC_WANT_COMPAT_DEVICEMODEL_API +#include <xendevicemodel.h> + +#endif +#if CONFIG_XEN_CTRL_INTERFACE_VERSION <41000 #define XEN_COMPAT_PHYSMAP
@@ -105,8 +116,6 @@ static inline int xentoolcore_restrict_all(domid_t domid)#if CONFIG_XEN_CTRL_INTERFACE_VERSION <40900 -typedef xc_interface xendevicemodel_handle ; -static inline xendevicemodel_handle *xendevicemodel_open (struct xentoollog_logger *logger,unsigned int open_flags) {
@@ -228,11 +237,6 @@ static inline int xendevicemodel_set_mem_type( return xc_hvm_set_mem_type(dmod, domid, mem_type, first_pfn, nr); } -#else /* CONFIG_XEN_CTRL_INTERFACE_VERSION >= 40900 */ - -#undef XC_WANT_COMPAT_DEVICEMODEL_API -#include <xendevicemodel.h> -#endif extern xendevicemodel_handle *xen_dmod;
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [Qemu-devel] [PATCH v5.1 5/8] xen: move xc_interface compatibility fallback further up the file
Quoted 5 lines · Ian Jackson
We are going to want to use the dummy
xendevicemodel_handletype in new stub functions in theCONFIG_XEN_CTRL_INTERFACE_VERSION< 41000 section. So we need to provide that definition, or (as applicable) include the appropriate header, earlier in the file.
Quoted 8 lines
(Ideally the newer compatibility layers would be at the bottom of the file, so that they can naturally benefit from the compatibility layers for earlier version. But that's rather too much for this series.)
No functional change.
Signed-off-by Ian Jackson <[email protected]>Acked-by Anthony PERARD <[email protected]>
Quoted 52 lines
---
v2: New patch in v2 of the series--- include/hw/xen/xen_common.h | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)include/hw/xen/xen_common.h +11
-7@@ -78,6 +78,17 @@ static inline void *xenforeignmemory_map(xc_interface *h, uint32_t dom,extern xenforeignmemory_handle *xen_fmem; +#if CONFIG_XEN_CTRL_INTERFACE_VERSION <40900 + +typedef xc_interface xendevicemodel_handle ; + +#else /* CONFIG_XEN_CTRL_INTERFACE_VERSION >= 40900 */ + +#undef XC_WANT_COMPAT_DEVICEMODEL_API +#include <xendevicemodel.h> + +#endif +#if CONFIG_XEN_CTRL_INTERFACE_VERSION <41000 #define XEN_COMPAT_PHYSMAP @@ -105,8 +116,6 @@ static inline int xentoolcore_restrict_all(domid_t domid)#if CONFIG_XEN_CTRL_INTERFACE_VERSION <40900 -typedef xc_interface xendevicemodel_handle ; -static inline xendevicemodel_handle *xendevicemodel_open (struct xentoollog_logger *logger,unsigned int open_flags) {@@ -228,11 +237,6 @@ static inline int xendevicemodel_set_mem_type( return xc_hvm_set_mem_type(dmod, domid, mem_type, first_pfn, nr); } -#else /* CONFIG_XEN_CTRL_INTERFACE_VERSION >= 40900 */ - -#undef XC_WANT_COMPAT_DEVICEMODEL_API -#include <xendevicemodel.h> -#endif extern xendevicemodel_handle *xen_dmod;Signature · 1 line
2.1.4
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v5 6/8 xen: destroy_hvm_domain: Try xendevicemodel_shutdown
In reply to Ian Jacksonxc_interface_open etc. is not going to work if we have dropped privilege, but xendevicemodel_shutdown will if everything is new enough.
xendevicemodel_shutdown is only availabe in Xen 4.10 and later, so provide a stub for earlier versions.
---
v2: Add compatibility stub for Xen < 4.10.
Fix coding style.
--- hw/i386/xen/xen-hvm.c | 10 ++++++++++ include/hw/xen/xen_common.h | 7 +++++++ 2 files changed, 17 insertions(+)
hw/i386/xen/xen-hvm.c +10 -0
@@ -1386,9 +1386,19 @@ void destroy_hvm_domain(bool reboot) {xc_interface *xc_handle;int sts; +int rc;unsigned int reason = reboot ? SHUTDOWN_reboot : SHUTDOWN_poweroff; +if (xen_dmod) { + rc =xendevicemodel_shutdown (xen_dmod, xen_domid, reason); +if (!rc) { +return ; + } +perror ("xendevicemodel_shutdown failed" ); +/* well, try the old thing then */ + } + xc_handle =xc_interface_open (0 ,0 ,0 );if (xc_handle ==NULL ) {fprintf (stderr,"Cannot acquire xenctrl handle\n" );
include/hw/xen/xen_common.h +7 -0
@@ -108,6 +108,13 @@ static inline int xentoolcore_restrict_all(domid_t domid) return -1; } +static inline int xendevicemodel_shutdown (xendevicemodel_handle *dmod, +domid_t domid,unsigned int reason) +{ + errno =ENOTTY ; +return -1 ; +} +#else /* CONFIG_XEN_CTRL_INTERFACE_VERSION >= 41000 */ #include <xentoolcore.h>
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [Qemu-devel] [PATCH v5.1 6/8] xen: destroy_hvm_domain: Try xendevicemodel_shutdown
Quoted 25 lines · Ian Jackson
xc_interface_openetc. is not going to work if we have dropped privilege, butxendevicemodel_shutdownwill if everything is new enough.
xendevicemodel_shutdownis only availabe in Xen 4.10 and later, so provide a stub for earlier versions.Signed-off-by Ian Jackson <[email protected]>Reviewed-by Anthony PERARD <[email protected]>---
v2: Add compatibility stub for Xen < 4.10.
Fix coding style.--- hw/i386/xen/xen-hvm.c | 10 ++++++++++ include/hw/xen/xen_common.h | 7 +++++++ 2 files changed, 17 insertions(+)hw/i386/xen/xen-hvm.c +0
-0@@ -1386,9 +1386,19 @@ void destroy_hvm_domain(bool reboot) {xc_interface *xc_handle;int sts;
hw/i386/xen/xen-hvm.c void destroy_hvm_domain(bool reboot) · line 1398
Quoted 10 lines
hw/i386/xen/xen-hvm.c +7
-0+int rc;unsigned int reason = reboot ? SHUTDOWN_reboot : SHUTDOWN_poweroff; +if (xen_dmod) { + rc =xendevicemodel_shutdown (xen_dmod, xen_domid, reason); +if (!rc) { +return ; + } +perror ("xendevicemodel_shutdown failed" );
I don't think is a good idea to print an error because this is actually a normal condition when QEMU is build and run against an older Xen. Users might get confused when looking at the logs.
But it would be correct to print an error if errno != ENOTTY.
Quoted 27 lines
hw/i386/xen/xen-hvm.c +3
-0+/* well, try the old thing then */ + } + xc_handle =xc_interface_open (0 ,0 ,0 );if (xc_handle ==NULL ) {fprintf (stderr,"Cannot acquire xenctrl handle\n" );include/hw/xen/xen_common.h +7
-0@@ -108,6 +108,13 @@ static inline int xentoolcore_restrict_all(domid_t domid) return -1; } +static inline int xendevicemodel_shutdown (xendevicemodel_handle *dmod, +domid_t domid,unsigned int reason) +{ + errno =ENOTTY ; +return -1 ; +} +#else /* CONFIG_XEN_CTRL_INTERFACE_VERSION >= 41000 */ #include <xentoolcore.h> Signature · 1 line
2.1.4
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [Qemu-devel] [PATCH v5.1 6/8] xen: destroy_hvm_domain: Try xendevicemodel_shutdown
Stefano Stabellini writes ("Re: [PATCH v5.1 6/8] xen: destroy_hvm_domain: Try xendevicemodel_shutdown"):
Quoted 7 lines · Ian Jackson
Quoted 6 lines
xc_interface_openetc. is not going to work if we have dropped privilege, butxendevicemodel_shutdownwill if everything is new enough.
xendevicemodel_shutdownis only availabe in Xen 4.10 and later, so provide a stub for earlier versions.
...
Quoted 10 lines
hw/i386/xen/xen-hvm.c void destroy_hvm_domain(bool reboot) · line 1398
Quoted 6 lines
hw/i386/xen/xen-hvm.c +6
-0+if (xen_dmod) { + rc =xendevicemodel_shutdown (xen_dmod, xen_domid, reason); +if (!rc) { +return ; + } +perror ("xendevicemodel_shutdown failed" );I don't think is a good idea to print an error because this is actually a normal condition when QEMU is build and run against an older Xen. Users might get confused when looking at the logs.
Oh. Yes. I wrote this before I provided the fallback stub in xen_common.h, and therefore before I properly understood the approach taken to fallbacks. The fallback logic here is not correct.
Quoted 1 line
But it would be correct to print an error if errno != ENOTTY.
Indeed.
I have changed it to read like this:
if (xen_dmod) {
rc = xendevicemodel_shutdown(xen_dmod, xen_domid, reason);
if (!rc) {
return;
}
if (errno != ENOTTY /* old Xen */)
perror("xendevicemodel_shutdown failed");
/* well, try the old thing then */
}Thanks,
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v5 7/8 os-posix: Provide new -runas <uid>:<gid> facility
In reply to Ian JacksonThis allows the caller to specify a uid and gid to use, even if there is no corresponding password entry. This will be useful in certain Xen configurations.
We don't support just -runas <uid> because: (i) deprivileging without calling setgroups would be ineffective (ii) given only a uid we don't know what gid we ought to use (since uids may eppear in multiple passwd file entries with different gids).
---
v5: Use : rather than . to separate uid from gid
v4: Changed to reuse option -runas
v3: Error messages fixed. Thanks to Peter Maydell and Ross Lagerwall.
v2: Coding style fixes.
squash! os-posix: Provide new -runas <uid>.<gid> facility
--- os-posix.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++---------- qemu-options.hx | 3 ++- 2 files changed, 55 insertions(+), 12 deletions(-)
os-posix.c +53 -11
@@ -43,6 +43,8 @@#endif static struct passwd *user_pwd; +static uid_t user_uid = (uid_t)-1 ; +static gid_t user_gid = (gid_t)-1 ;static const char *chroot_dir;static int daemonize;static int daemon_pipe;
@@ -128,6 +130,34 @@ void os_set_proc_name(const char *s)#endif } + +static bool os_parse_runas_uid_gid (const char *optarg) +{ +unsigned long lv; +char *ep; +uid_t got_uid; +gid_t got_gid; +int rc; + + errno =0 ; + lv =strtoul (optarg, &ep,0 );/* can't qemu_strtoul, want *ep==':' */ + got_uid = lv;/* overflow here is ID in C99 */ +if (errno || *ep !=':' || got_uid != lv || got_uid == (uid_t)-1 ) { +return false; + } + + lv =0 ; + rc =qemu_strtoul (ep +1 ,0 ,0 , &lv); + got_gid = lv;/* overflow here is ID in C99 */ +if (rc || got_gid != lv || got_gid == (gid_t)-1 ) { +return false; + } + + user_uid = got_uid; + user_gid = got_gid; +return true; +} +/* * Parse OS specific command line options. * return 0 if option handled, -1 otherwise
@@ -145,8 +175,10 @@ void os_parse_cmd_args(int index, const char *optarg)#endif case QEMU_OPTION_runas: user_pwd =getpwnam (optarg); -if (!user_pwd) { -fprintf (stderr,"User \"%s\" doesn't exist\n" , optarg); +if (!user_pwd && !os_parse_runas_uid_gid (optarg)) { +fprintf (stderr, +"User \"%s\" doesn't exist (and is not <uid>.<gid>)\n" , + optarg);exit (1 ); }break ;
@@ -166,18 +198,28 @@ void os_parse_cmd_args(int index, const char *optarg)static void change_process_uid (void ) { -if (user_pwd) { -if (setgid (user_pwd->pw_gid) <0 ) { -fprintf (stderr,"Failed to setgid(%d)\n" , user_pwd->pw_gid); +if (user_pwd || user_uid != (uid_t)-1 ) { +gid_t intended_gid = user_pwd ? user_pwd->pw_gid : user_gid; +uid_t intended_uid = user_pwd ? user_pwd->pw_uid : user_uid; +if (setgid (intended_gid) <0 ) { +fprintf (stderr,"Failed to setgid(%d)\n" , intended_gid);exit (1 ); } -if (initgroups (user_pwd->pw_name, user_pwd->pw_gid) <0 ) { -fprintf (stderr,"Failed to initgroups(\"%s\", %d)\n" , - user_pwd->pw_name, user_pwd->pw_gid); -exit (1 ); +if (user_pwd) { +if (initgroups (user_pwd->pw_name, user_pwd->pw_gid) <0 ) { +fprintf (stderr,"Failed to initgroups(\"%s\", %d)\n" , + user_pwd->pw_name, user_pwd->pw_gid); +exit (1 ); + } + }else { +if (setgroups (1 , &user_gid) <0 ) { +fprintf (stderr,"Failed to setgroups(1, [%d])" , + user_gid); +exit (1 ); + } } -if (setuid (user_pwd->pw_uid) <0 ) { -fprintf (stderr,"Failed to setuid(%d)\n" , user_pwd->pw_uid); +if (setuid (intended_uid) <0 ) { +fprintf (stderr,"Failed to setuid(%d)\n" , intended_uid);exit (1 ); }if (setuid (0 ) !=-1 ) {
qemu-options.hx +2 -1
@@ -3958,7 +3958,8 @@ ETEXI #ifndef _WIN32 DEF("runas", HAS_ARG, QEMU_OPTION_runas, \ - "-runas user change to user id user just before starting the VM\n", + "-runas user change to user id user just before starting the VM\n" \ + " user can be numeric uid:gid instead\n", QEMU_ARCH_ALL) #endif STEXI
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [Qemu-devel] [PATCH v5.1 7/8] os-posix: Provide new -runas <uid>:<gid> facility
os-posix.c void os_set_proc_name(const char *s) · line 143
Quoted 10 lines · Ian Jackson
os-posix.c +10
-0+static bool os_parse_runas_uid_gid (const char *optarg) +{ +unsigned long lv; +char *ep; +uid_t got_uid; +gid_t got_gid; +int rc; + + errno =0 ; + lv =strtoul (optarg, &ep,0 );/* can't qemu_strtoul, want *ep==':' */
Should strtoul base be 10? If that matter.
Quoted 21 lines
os-posix.c +17
-0+ got_uid = lv;/* overflow here is ID in C99 */ +if (errno || *ep !=':' || got_uid != lv || got_uid == (uid_t)-1 ) { +return false; + } + + lv =0 ; + rc =qemu_strtoul (ep +1 ,0 ,0 , &lv); + got_gid = lv;/* overflow here is ID in C99 */ +if (rc || got_gid != lv || got_gid == (gid_t)-1 ) { +return false; + } + + user_uid = got_uid; + user_gid = got_gid; +return true; +} +/* * Parse OS specific command line options. * return 0 if option handled, -1 otherwise
os-posix.c void os_parse_cmd_args(int index, const char *optarg) · line 180
Quoted 8 lines
os-posix.c +3
-2@@ -145,8 +175,10 @@ void os_parse_cmd_args(int index, const char *optarg)#endif case QEMU_OPTION_runas: user_pwd =getpwnam (optarg); -if (!user_pwd) { -fprintf (stderr,"User \"%s\" doesn't exist\n" , optarg); +if (!user_pwd && !os_parse_runas_uid_gid (optarg)) { + fprintf(stderr, + "User \"%s\" doesn't exist (and is not <uid>.<gid>)\n",
The error message have not been update, I think it should be <uid>:<gid>
os-posix.c void os_parse_cmd_args(int index, const char *optarg) · line 184
Quoted 4 lines
os-posix.c +1
-0+ optarg);exit (1 ); }break ;
With the error message fix:
Signature · 6 lines
Anthony PERARD _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [Qemu-devel] [PATCH v5.1 7/8] os-posix: Provide new -runas <uid>:<gid> facility
Anthony PERARD writes ("Re: [PATCH v5.1 7/8] os-posix: Provide new -runas <uid>:<gid> facility"):
Quoted 2 lines · Ian Jackson
Quoted 1 line
+static bool
os_parse_runas_uid_gid(const char *optarg)
...
Quoted 4 lines
os-posix.c void os_set_proc_name(const char *s) · line 143
Quoted 2 lines
os-posix.c +2
-0+ errno =0 ; + lv =strtoul (optarg, &ep,0 );/* can't qemu_strtoul, want *ep==':' */ Should strtoul base be 10? If that matter.
If someone wants to write uids in hex then I don't see a reason to stop them...
Quoted 7 lines
os-posix.c void os_parse_cmd_args(int index, const char *optarg) · line 180
Quoted 5 lines
os-posix.c +3
-2-if (!user_pwd) { -fprintf (stderr,"User \"%s\" doesn't exist\n" , optarg); +if (!user_pwd && !os_parse_runas_uid_gid (optarg)) { + fprintf(stderr, + "User \"%s\" doesn't exist (and is not <uid>.<gid>)\n",The error message have not been update, I think it should be <uid>:<gid>
Oops.
Quoted 2 lines
With the error message fix:
Reviewed-by Anthony PERARD <[email protected]>
Thanks,
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [Qemu-devel] [PATCH v5.1 7/8] os-posix: Provide new -runas <uid>:<gid> facility
In reply to Ian JacksonCC'ing the maintainers (scripts/get_maintainer.pl is your friend)
Quoted 138 lines · Ian Jackson
This allows the caller to specify a uid and gid to use, even if there is no corresponding password entry. This will be useful in certain Xen configurations.
We don't support just -runas <uid> because: (i) deprivileging without calling setgroups would be ineffective (ii) given only a uid we don't know what gid we ought to use (since uids may eppear in multiple passwd file entries with different gids).
Signed-off-by Ian Jackson <[email protected]>---
v5: Use : rather than . to separate uid from gid
v4: Changed to reuse option -runas
v3: Error messages fixed. Thanks to Peter Maydell and Ross Lagerwall.
v2: Coding style fixes.squash! os-posix: Provide new -runas <uid>.<gid> facility
--- os-posix.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++---------- qemu-options.hx | 3 ++- 2 files changed, 55 insertions(+), 12 deletions(-)os-posix.c +53
-11@@ -43,6 +43,8 @@#endif static struct passwd *user_pwd; +static uid_t user_uid = (uid_t)-1 ; +static gid_t user_gid = (gid_t)-1 ;static const char *chroot_dir;static int daemonize;static int daemon_pipe;@@ -128,6 +130,34 @@ void os_set_proc_name(const char *s)#endif } + +static bool os_parse_runas_uid_gid (const char *optarg) +{ +unsigned long lv; +char *ep; +uid_t got_uid; +gid_t got_gid; +int rc; + + errno =0 ; + lv =strtoul (optarg, &ep,0 );/* can't qemu_strtoul, want *ep==':' */ + got_uid = lv;/* overflow here is ID in C99 */ +if (errno || *ep !=':' || got_uid != lv || got_uid == (uid_t)-1 ) { +return false; + } + + lv =0 ; + rc =qemu_strtoul (ep +1 ,0 ,0 , &lv); + got_gid = lv;/* overflow here is ID in C99 */ +if (rc || got_gid != lv || got_gid == (gid_t)-1 ) { +return false; + } + + user_uid = got_uid; + user_gid = got_gid; +return true; +} +/* * Parse OS specific command line options. * return 0 if option handled, -1 otherwise @@ -145,8 +175,10 @@ void os_parse_cmd_args(int index, const char *optarg)#endif case QEMU_OPTION_runas: user_pwd =getpwnam (optarg); -if (!user_pwd) { -fprintf (stderr,"User \"%s\" doesn't exist\n" , optarg); +if (!user_pwd && !os_parse_runas_uid_gid (optarg)) { +fprintf (stderr, +"User \"%s\" doesn't exist (and is not <uid>.<gid>)\n" , + optarg);exit (1 ); }break ;@@ -166,18 +198,28 @@ void os_parse_cmd_args(int index, const char *optarg)static void change_process_uid (void ) { -if (user_pwd) { -if (setgid (user_pwd->pw_gid) <0 ) { -fprintf (stderr,"Failed to setgid(%d)\n" , user_pwd->pw_gid); +if (user_pwd || user_uid != (uid_t)-1 ) { +gid_t intended_gid = user_pwd ? user_pwd->pw_gid : user_gid; +uid_t intended_uid = user_pwd ? user_pwd->pw_uid : user_uid; +if (setgid (intended_gid) <0 ) { +fprintf (stderr,"Failed to setgid(%d)\n" , intended_gid);exit (1 ); } -if (initgroups (user_pwd->pw_name, user_pwd->pw_gid) <0 ) { -fprintf (stderr,"Failed to initgroups(\"%s\", %d)\n" , - user_pwd->pw_name, user_pwd->pw_gid); -exit (1 ); +if (user_pwd) { +if (initgroups (user_pwd->pw_name, user_pwd->pw_gid) <0 ) { +fprintf (stderr,"Failed to initgroups(\"%s\", %d)\n" , + user_pwd->pw_name, user_pwd->pw_gid); +exit (1 ); + } + }else { +if (setgroups (1 , &user_gid) <0 ) { +fprintf (stderr,"Failed to setgroups(1, [%d])" , + user_gid); +exit (1 ); + } } -if (setuid (user_pwd->pw_uid) <0 ) { -fprintf (stderr,"Failed to setuid(%d)\n" , user_pwd->pw_uid); +if (setuid (intended_uid) <0 ) { +fprintf (stderr,"Failed to setuid(%d)\n" , intended_uid);exit (1 ); }if (setuid (0 ) !=-1 ) {qemu-options.hx +2
-1@@ -3958,7 +3958,8 @@ ETEXI #ifndef _WIN32 DEF("runas", HAS_ARG, QEMU_OPTION_runas, \ - "-runas user change to user id user just before starting the VM\n", + "-runas user change to user id user just before starting the VM\n" \ + " user can be numeric uid:gid instead\n", QEMU_ARCH_ALL) #endif STEXISignature · 1 line
2.1.4
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [Qemu-devel] [PATCH v5.1 7/8] os-posix: Provide new -runas <uid>:<gid> facility
Stefano Stabellini writes ("Re: [PATCH v5.1 7/8] os-posix: Provide new -runas <uid>:<gid> facility"):
Quoted 1 line
CC'ing the maintainers (
scripts/get_maintainer.plis your friend)
I don't know what your scripts/get_maintainer.pl does, but mine says:
get_maintainer.pl: No maintainers found, printing recent contributors. get_maintainer.pl: Do not blindly cc: them on patches! Use common sense.
Anthony PERARD <[email protected]> (commit_signer:1/2=50%) Paolo Bonzini <[email protected]> (commit_signer:1/2=50%,commit_signer:11/57=19%) Ian Jackson <[email protected]> (commit_signer:1/2=50%) Michael Tokarev <[email protected]> (commit_signer:12/57=21%)
Eric Blake <[email protected]> (commit_signer:10/57=18%)
Thomas Huth <[email protected]> (commit_signer:8/57=14%)
Markus Armbruster <[email protected]> (commit_signer:8/57=14%) [email protected] (open list:POSIX)
I have added Paolo, Markus and Daniel Berrange to the CCs of my patch on the basis that they have commented already...
Thanks,
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v5 8/8 configure: do_compiler: Dump some extra info under bash
In reply to Ian JacksonThis makes it much easier to find a particular thing in config.log.
The information may be lacking in other shells, resulting in harmless empty output. (This is why we don't use the proper ${FUNCNAME[*]} array syntax - other shells will choke on that.)
The extra output is only printed if configure is run with bash. The
something), it is necessary to say bash ./configure to get the extra
debug info in the log.
---
v4: No longer tag this patch RFC.
--- configure | 4 ++++ 1 file changed, 4 insertions(+)
configure +4 -0
@@ -60,6 +60,10 @@ do_compiler() { # is compiler binary to execute. local compiler="$1" shift + echo >>config.log " +funcs: ${FUNCNAME} +lines: ${BASH_LINENO} +files: ${BASH_SOURCE}" echo $compiler "$@" >> config.log $compiler "$@" >> config.log 2>&1 || return $? # Test passed. If this is an --enable-werror build, rerun
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v5 8/8 configure: do_compiler: Dump some extra info under bash [and 1 more messages]
Ian Jackson writes ("[PATCH v5.1 8/8] configure: do_compiler: Dump some extra info under bash"):
Quoted 9 lines
This makes it much easier to find a particular thing in config.log.
The information may be lacking in other shells, resulting in harmless empty output. (This is why we don't use the proper ${FUNCNAME[*]} array syntax - other shells will choke on that.)
The extra output is only printed if configure is run with bash. The
something), it is necessary to say bash ./configure to get the extra
debug info in the log.
Kent Spillner points out that this last sentence is garbled. The paragraph should read:
The extra output is only printed if configure is run with bash. On systems where /bin/sh is not bash, it is necessary to say bash ./configure to get the extra debug info in the log.
I have updated it in my branch.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [Qemu-devel] [PATCH v5.1 8/8] configure: do_compiler: Dump some extra info under bash
In reply to Ian JacksonCC'ing the maintainers for this.
Quoted 35 lines · Ian Jackson
This makes it much easier to find a particular thing in config.log.
The information may be lacking in other shells, resulting in harmless empty output. (This is why we don't use the proper ${FUNCNAME[*]} array syntax - other shells will choke on that.)
The extra output is only printed if configure is run with bash. The
something), it is necessary to say bash ./configure to get the extra
debug info in the log.Signed-off-by Ian Jackson <[email protected]>---
v4: No longer tag this patch RFC.--- configure | 4 ++++ 1 file changed, 4 insertions(+)configure +4
-0@@ -60,6 +60,10 @@ do_compiler() { # is compiler binary to execute. local compiler="$1" shift + echo >>config.log " +funcs: ${FUNCNAME} +lines: ${BASH_LINENO} +files: ${BASH_SOURCE}" echo $compiler "$@" >> config.log $compiler "$@" >> config.log 2>&1 || return $? # Test passed. If this is an --enable-werror build, rerunSignature · 1 line
2.1.4
Re: [Qemu-devel] [PATCH v5.1 8/8] configure: do_compiler: Dump some extra info under bash
Stefano Stabellini writes ("Re: [PATCH v5.1 8/8] configure: do_compiler: Dump some extra info under bash"):
Quoted 1 line
CC'ing the maintainers for this.
Thanks, but scripts/get_maintainer.pl seems to print different information for me... (see my other mail)
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [Qemu-devel] [PATCH v5.1 1/8] xen: link against xentoolcore
In reply to Ian JacksonQuoted 36 lines · Ian Jackson
From: Anthony PERARD <[email protected]>
Xen libraries in 4.10 include a new xentoolcore library. This contains the
xentoolcore_restrict_allfunction which we are about to want to use.Signed-off-by Ian Jackson <[email protected]>---
v5: More truthful commit message.--- configure | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)configure +2
-1@@ -2072,7 +2072,7 @@ if test "$xen" != "no" ; then $($pkg_config --modversion xencontrol | sed 's/\./ /g') )" xen=yes xen_pc="xencontrol xenstore xenguest xenforeignmemory xengnttab" - xen_pc="$xen_pc xenevtchn xendevicemodel" + xen_pc="$xen_pc xenevtchn xendevicemodel xentoolcore" QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags $xen_pc)" libs_softmmu="$($pkg_config --libs $xen_pc) $libs_softmmu" LDFLAGS="$($pkg_config --libs $xen_pc) $LDFLAGS"@@ -2104,18 +2104,20 @@ EOF cat > $TMPC <<EOF && #undef XC_WANT_COMPAT_MAP_FOREIGN_API #include <xenforeignmemory.h> +#include <xentoolcore.h> int main(void) { xenforeignmemory_handle *xfmem; xfmem = xenforeignmemory_open(0, 0); xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
configure EOF · line 2120
Quoted 10 lines
configure +3
-2+ xentoolcore_restrict_all(0); return 0; } EOF - compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs" + compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore" then - xen_stable_libs="-lxendevicemodel $xen_stable_libs" + xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
Is it on purpose that -lxentoolcore is at the end of this string rather than before $xen_stable_libs?
In any case
Quoted 6 lines
configure +0
-0xen_ctrl_version=41000 xen=yes elifSignature · 1 line
2.1.4
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [Qemu-devel] [PATCH v5.1 1/8] xen: link against xentoolcore
Stefano Stabellini writes ("Re: [PATCH v5.1 1/8] xen: link against xentoolcore"):
Quoted 7 lines · Ian Jackson
configure EOF · line 2120
Quoted 3 lines
then
configure +1
-1- xen_stable_libs="-lxendevicemodel $xen_stable_libs" + xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"Is it on purpose that -lxentoolcore is at the end of this string rather than before $xen_stable_libs?
Yes. xentoolcore is required by the other libraries, and this is therefore the correct ordering for situations where the link order matters.
Quoted 3 lines
In any case
Thanks,
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 8 lines · Ian Jackson
Anthony PERARD writes ("Re: [PATCH v5 0/8] xen: xen-domid-restrict improvements"):
Quoted 2 lines
The patches in this v5 appear to be the same the one from the patch series v4.
Erk, so they are.
I'll post a v5.1 in reply to this email.
What's the status of this patch series? There don't seem to be many outstanding complaints but they haven't been pushed into master. At least the Xen changes have all been reviewed by Anthony (except for configure changes) so they could probably go in.
Thanks,
Signature · 6 lines
Ross Lagerwall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Ross Lagerwall writes ("Re: [PATCH v5 0/8] xen: xen-domid-restrict improvements"):
Quoted 4 lines
What's the status of this patch series? There don't seem to be many outstanding complaints but they haven't been pushed into master. At least the Xen changes have all been reviewed by Anthony (except for configure changes) so they could probably go in.
The short answer is I don't really know; my brain was eaten by meltdown/spectre. I'll hope to get back to this RSN.
Thanks,
Ian.