add xl command to get hypervisor .config
cover add xl command to get hypervisor .config
Add "xl get-config" printing the .config used to build the currently running hypervisor.
Juergen Gross (2):
xen: add interface for obtaining .config from hypervisor
tools: add new xl command get-config for getting hypervisor config
.gitignore | 2 ++ docs/man/xl.1.pod.in | 5 +++++ tools/flask/policy/modules/dom0.te | 2 +- tools/libxc/include/xenctrl.h | 8 +++++++ tools/libxc/include/xenguest.h | 13 ++++++++++++ tools/libxc/xc_misc.c | 42 +++++++++++++++++++++++++++++++++++++ tools/libxc/xg_private.h | 4 ---- tools/libxl/libxl.c | 30 ++++++++++++++++++++++++++ tools/libxl/libxl.h | 8 +++++++ tools/xl/xl.h | 1 + tools/xl/xl_cmdtable.c | 5 +++++ tools/xl/xl_misc.c | 20 ++++++++++++++++++ xen/common/Makefile | 7 +++++++ xen/common/sysctl.c | 13 ++++++++++++ xen/include/public/sysctl.h | 16 ++++++++++++++ xen/include/xen/kernel.h | 3 +++ xen/tools/Makefile | 9 ++++++-- xen/tools/bin2c.c | 28 +++++++++++++++++++++++++ xen/xsm/flask/hooks.c | 3 +++ xen/xsm/flask/policy/access_vectors | 2 ++ 20 files changed, 214 insertions(+), 7 deletions(-) create mode 100644 xen/tools/bin2c.c
Signature · 7 lines
2.16.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 1/2 xen: add interface for obtaining .config from hypervisor
Add a sysctl interface for obtaining the .config file used to build the hypervisor. The mechanism is inspired by the Linux kernel's one.
--- .gitignore | 2 ++ tools/flask/policy/modules/dom0.te | 2 +- xen/common/Makefile | 7 +++++++ xen/common/sysctl.c | 13 +++++++++++++ xen/include/public/sysctl.h | 16 ++++++++++++++++ xen/include/xen/kernel.h | 3 +++ xen/tools/Makefile | 9 +++++++-- xen/tools/bin2c.c | 28 ++++++++++++++++++++++++++++ xen/xsm/flask/hooks.c | 3 +++ xen/xsm/flask/policy/access_vectors | 2 ++ 10 files changed, 82 insertions(+), 3 deletions(-) create mode 100644 xen/tools/bin2c.c
.gitignore +2 -0
@@ -309,6 +309,7 @@ xen/arch/*/efi/boot.c xen/arch/*/efi/compat.c xen/arch/*/efi/efi.h xen/arch/*/efi/runtime.c +xen/common/config_data.c xen/include/headers*.chk xen/include/asm xen/include/asm-*/asm-offsets.h
@@ -328,6 +329,7 @@ xen/test/livepatch/xen_nop.livepatch xen/test/livepatch/xen_replace_world.livepatch xen/tools/kconfig/.tmp_gtkcheck xen/tools/kconfig/.tmp_qtcheck +xen/tools/bin2c xen/tools/symbols xen/xsm/flask/include/av_perm_to_string.h xen/xsm/flask/include/av_permissions.h
tools/flask/policy/modules/dom0.te +1 -1
@@ -16,7 +16,7 @@ allow dom0_t xen_t:xen { allow dom0_t xen_t:xen2 { resource_op psr_cmt_op psr_alloc pmu_ctrl get_symbol get_cpu_levelling_caps get_cpu_featureset livepatch_op - coverage_op set_parameter + coverage_op set_parameter get_config }; # Allow dom0 to use all XENVER_ subops that have checks.
xen/common/Makefile +7 -0
@@ -1,5 +1,6 @@ obj-y += bitmap.o obj-y += bsearch.o +obj-y += config_data.o obj-$(CONFIG_CORE_PARKING) += core_parking.o obj-y += cpu.o obj-y += cpupool.o
@@ -83,3 +84,9 @@ subdir-$(CONFIG_UBSAN) += ubsan subdir-$(CONFIG_NEEDS_LIBELF) += libelf subdir-$(CONFIG_HAS_DEVICE_TREE) += libfdt + +config_data.c: ../.config + ( echo "const char xen_config_data[] ="; \ + cat $< | gzip | ../tools/bin2c; \ + echo ";"; \ + echo "unsigned int xen_config_data_sz = sizeof(xen_config_data) - 1;" ) > $@
xen/common/sysctl.c +13 -0
@@ -13,6 +13,7 @@#include <xen/domain.h> #include <xen/event.h> #include <xen/domain_page.h> +#include <xen/kernel.h> #include <xen/tmem.h> #include <xen/trace.h> #include <xen/console.h>
@@ -502,6 +503,18 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl)break ; } +case XEN_SYSCTL_get_config: + { +unsigned int size =min (op->u.get_config.size, xen_config_data_sz); + +if ( size && +copy_to_guest (op->u.get_config.buffer, xen_config_data, size) ) + ret = -EFAULT ; + op->u.get_config.size = xen_config_data_sz; + +break ; + } +default : ret =arch_do_sysctl (op, u_sysctl); copyback =0 ;
xen/include/public/sysctl.h +16 -0
@@ -1100,6 +1100,20 @@ typedef struct xen_sysctl_cpu_policy xen_sysctl_cpu_policy_t;DEFINE_XEN_GUEST_HANDLE (xen_sysctl_cpu_policy_t);#endif +/* +* XEN_SYSCTL_get_config +* +* Return gzip-ed .config file +*/ +struct xen_sysctl_get_config { +XEN_GUEST_HANDLE_64 (char ) buffer;/* IN: pointer to buffer. */ +uint32_t size;/* IN: size of buffer. */ +/* OUT: size of config data. */ +uint32_t pad;/* IN: MUST be zero. */ +}; +typedef struct xen_sysctl_get_config xen_sysctl_get_config_t ; +DEFINE_XEN_GUEST_HANDLE (xen_sysctl_get_config_t); +struct xen_sysctl {uint32_t cmd;#define XEN_SYSCTL_readconsole 1
@@ -1130,6 +1144,7 @@ struct xen_sysctl {#define XEN_SYSCTL_livepatch_op 27#define XEN_SYSCTL_set_parameter 28#define XEN_SYSCTL_get_cpu_policy 29 +#define XEN_SYSCTL_get_config 30uint32_t interface_version;/* XEN_SYSCTL_INTERFACE_VERSION */ union {struct xen_sysctl_readconsole readconsole;
@@ -1162,6 +1177,7 @@ struct xen_sysctl {#if defined(__i386__) || defined(__x86_64__)struct xen_sysctl_cpu_policy cpu_policy;#endif +struct xen_sysctl_get_config get_config;uint8_t pad[128 ]; } u; };
xen/include/xen/kernel.h +3 -0
@@ -100,5 +100,8 @@ extern enum system_state {bool_t is_active_kernel_text (unsigned long addr); +extern const char xen_config_data[]; +extern unsigned int xen_config_data_sz; +#endif /* _LINUX_KERNEL_H */
xen/tools/Makefile +7 -2
@@ -1,13 +1,18 @@ include $(XEN_ROOT)/Config.mk +PROGS = symbols bin2c + .PHONY: default default: - $(MAKE) symbols + $(MAKE) $(PROGS) .PHONY: clean clean: - rm -f *.o symbols + rm -f *.o $(PROGS) symbols: symbols.c $(HOSTCC) $(HOSTCFLAGS) -o $@ $< + +bin2c: bin2c.c + $(HOSTCC) $(HOSTCFLAGS) -o $@ $<
xen/tools/bin2c.c new file +28 -0
@@ -0,0 +1,28 @@ +/* +* Unloved program to convert a binary on stdin to a C include on stdout +* +* Jan 1999 Matt Mackall <[email protected]> +* +* This software may be used and distributed according to the terms +* of the GNU General Public License, incorporated herein by reference. +*/ + +#include <stdio.h> + +int main (int argc,char *argv[]) +{ +int ch, total =0 ; + +do { +printf ("\t\"" ); +while ((ch =getchar ()) !=EOF ) { + total++; +printf ("\\x%02x" , ch); +if (total %16 ==0 ) +break ; + } +printf ("\"\n" ); + }while (ch !=EOF ); + +return 0 ; +}
xen/xsm/flask/hooks.c +3 -0
@@ -828,6 +828,9 @@ static int flask_sysctl(int cmd)case XEN_SYSCTL_set_parameter:return avc_current_has_perm (SECINITSID_XEN ,SECCLASS_XEN2 ,XEN2__SET_PARAMETER ,NULL ); +case XEN_SYSCTL_get_config: +return avc_current_has_perm (SECINITSID_XEN ,SECCLASS_XEN2 , +XEN2__GET_CONFIG ,NULL );default :return avc_unknown_permission ("sysctl" , cmd);
xen/xsm/flask/policy/access_vectors +2 -0
@@ -103,6 +103,8 @@ class xen2 coverage_op # XEN_SYSCTL_set_parameter set_parameter +# XEN_SYSCTL_get_config + get_config } # Classes domain and domain2 consist of operations that a domain performs on
Signature · 7 lines
2.16.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 1/2] xen: add interface for obtaining .config from hypervisor
Quoted 31 lines · Juergen Gross
Add a sysctl interface for obtaining the .config file used to build the hypervisor. The mechanism is inspired by the Linux kernel's one.
Signed-off-by Juergen Gross <[email protected]>--- .gitignore | 2 ++ tools/flask/policy/modules/dom0.te | 2 +- xen/common/Makefile | 7 +++++++ xen/common/sysctl.c | 13 +++++++++++++ xen/include/public/sysctl.h | 16 ++++++++++++++++ xen/include/xen/kernel.h | 3 +++ xen/tools/Makefile | 9 +++++++-- xen/tools/bin2c.c | 28 ++++++++++++++++++++++++++++ xen/xsm/flask/hooks.c | 3 +++ xen/xsm/flask/policy/access_vectors | 2 ++ 10 files changed, 82 insertions(+), 3 deletions(-) create mode 100644 xen/tools/bin2c.c.gitignore +1
-0@@ -309,6 +309,7 @@ xen/arch/*/efi/boot.c xen/arch/*/efi/compat.c xen/arch/*/efi/efi.h xen/arch/*/efi/runtime.c +xen/common/config_data.c xen/include/headers*.chk xen/include/asm xen/include/asm-*/asm-offsets.h
.gitignore xen/test/livepatch/xen_nop.livepatch · line 332
Quoted 4 lines
.gitignore +1
-0@@ -328,6 +329,7 @@ xen/test/livepatch/xen_nop.livepatch xen/test/livepatch/xen_replace_world.livepatch xen/tools/kconfig/.tmp_gtkcheck xen/tools/kconfig/.tmp_qtcheck +xen/tools/bin2c
Move this ahead before kconfig?
Quoted 50 lines
.gitignore +0
-0xen/tools/symbols xen/xsm/flask/include/av_perm_to_string.h xen/xsm/flask/include/av_permissions.htools/flask/policy/modules/dom0.te +1
-1@@ -16,7 +16,7 @@ allow dom0_t xen_t:xen { allow dom0_t xen_t:xen2 { resource_op psr_cmt_op psr_alloc pmu_ctrl get_symbol get_cpu_levelling_caps get_cpu_featureset livepatch_op - coverage_op set_parameter + coverage_op set_parameter get_config }; # Allow dom0 to use all XENVER_ subops that have checks.xen/common/Makefile +7
-0@@ -1,5 +1,6 @@ obj-y += bitmap.o obj-y += bsearch.o +obj-y += config_data.o obj-$(CONFIG_CORE_PARKING) += core_parking.o obj-y += cpu.o obj-y += cpupool.o@@ -83,3 +84,9 @@ subdir-$(CONFIG_UBSAN) += ubsan subdir-$(CONFIG_NEEDS_LIBELF) += libelf subdir-$(CONFIG_HAS_DEVICE_TREE) += libfdt + +config_data.c: ../.config + ( echo "const char xen_config_data[] ="; \ + cat $< | gzip | ../tools/bin2c; \ + echo ";"; \ + echo "unsigned int xen_config_data_sz = sizeof(xen_config_data) - 1;" ) > $@xen/common/sysctl.c +1
-0@@ -13,6 +13,7 @@#include <xen/domain.h> #include <xen/event.h> #include <xen/domain_page.h> +#include <xen/kernel.h> #include <xen/tmem.h> #include <xen/trace.h> #include <xen/console.h>
xen/common/sysctl.c long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) · line 512
Quoted 10 lines
xen/common/sysctl.c +7
-0@@ -502,6 +503,18 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl)break ; } +case XEN_SYSCTL_get_config: + { +unsigned int size =min (op->u.get_config.size, xen_config_data_sz); + +if ( size && +copy_to_guest (op->u.get_config.buffer, xen_config_data, size) ) + ret = -EFAULT ;
What's the point of copying when user supplied buffer is not big enough? They can't continue from where they left off anyway.
Quoted 16 lines
xen/common/sysctl.c +5
-0+ op->u.get_config.size = xen_config_data_sz; + +break ; + } +default : ret =arch_do_sysctl (op, u_sysctl); copyback =0 ;xen/include/public/sysctl.h +0
-0@@ -1100,6 +1100,20 @@ typedef struct xen_sysctl_cpu_policy xen_sysctl_cpu_policy_t;DEFINE_XEN_GUEST_HANDLE (xen_sysctl_cpu_policy_t);#endif
xen/include/public/sysctl.h typedef struct xen_sysctl_cpu_policy xen_sysctl_cpu_policy_t; · line 1112
Quoted 10 lines
xen/include/public/sysctl.h +10
-0+/* +* XEN_SYSCTL_get_config +* +* Return gzip-ed .config file +*/ +struct xen_sysctl_get_config { +XEN_GUEST_HANDLE_64 (char ) buffer;/* IN: pointer to buffer. */ +uint32_t size;/* IN: size of buffer. */ +/* OUT: size of config data. */ +uint32_t pad;/* IN: MUST be zero. */
Please check pad is really zero in code.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 1/2] xen: add interface for obtaining .config from hypervisor
Quoted 30 lines · Wei Liu
Quoted 29 lines · Juergen Gross
Add a sysctl interface for obtaining the .config file used to build the hypervisor. The mechanism is inspired by the Linux kernel's one.
Signed-off-by Juergen Gross <[email protected]>--- .gitignore | 2 ++ tools/flask/policy/modules/dom0.te | 2 +- xen/common/Makefile | 7 +++++++ xen/common/sysctl.c | 13 +++++++++++++ xen/include/public/sysctl.h | 16 ++++++++++++++++ xen/include/xen/kernel.h | 3 +++ xen/tools/Makefile | 9 +++++++-- xen/tools/bin2c.c | 28 ++++++++++++++++++++++++++++ xen/xsm/flask/hooks.c | 3 +++ xen/xsm/flask/policy/access_vectors | 2 ++ 10 files changed, 82 insertions(+), 3 deletions(-) create mode 100644 xen/tools/bin2c.c.gitignore +1
-0@@ -309,6 +309,7 @@ xen/arch/*/efi/boot.c xen/arch/*/efi/compat.c xen/arch/*/efi/efi.h xen/arch/*/efi/runtime.c +xen/common/config_data.c xen/include/headers*.chk xen/include/asm
Quoted 8 lines
.gitignore xen/test/livepatch/xen_nop.livepatch · line 332
Quoted 6 lines
.gitignore +1
-0xen/include/asm-*/asm-offsets.h@@ -328,6 +329,7 @@ xen/test/livepatch/xen_nop.livepatch xen/test/livepatch/xen_replace_world.livepatch xen/tools/kconfig/.tmp_gtkcheck xen/tools/kconfig/.tmp_qtcheck +xen/tools/bin2cMove this ahead before kconfig?
Sorry, of course!
Quoted 54 lines
Quoted 54 lines
.gitignore +0
-0xen/tools/symbols xen/xsm/flask/include/av_perm_to_string.h xen/xsm/flask/include/av_permissions.htools/flask/policy/modules/dom0.te +1
-1@@ -16,7 +16,7 @@ allow dom0_t xen_t:xen { allow dom0_t xen_t:xen2 { resource_op psr_cmt_op psr_alloc pmu_ctrl get_symbol get_cpu_levelling_caps get_cpu_featureset livepatch_op - coverage_op set_parameter + coverage_op set_parameter get_config }; # Allow dom0 to use all XENVER_ subops that have checks.xen/common/Makefile +7
-0@@ -1,5 +1,6 @@ obj-y += bitmap.o obj-y += bsearch.o +obj-y += config_data.o obj-$(CONFIG_CORE_PARKING) += core_parking.o obj-y += cpu.o obj-y += cpupool.o@@ -83,3 +84,9 @@ subdir-$(CONFIG_UBSAN) += ubsan subdir-$(CONFIG_NEEDS_LIBELF) += libelf subdir-$(CONFIG_HAS_DEVICE_TREE) += libfdt + +config_data.c: ../.config + ( echo "const char xen_config_data[] ="; \ + cat $< | gzip | ../tools/bin2c; \ + echo ";"; \ + echo "unsigned int xen_config_data_sz = sizeof(xen_config_data) - 1;" ) > $@xen/common/sysctl.c +1
-0@@ -13,6 +13,7 @@#include <xen/domain.h> #include <xen/event.h> #include <xen/domain_page.h> +#include <xen/kernel.h> #include <xen/tmem.h> #include <xen/trace.h> #include <xen/console.h> @@ -502,6 +503,18 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl)break ; }
Quoted 10 lines
xen/common/sysctl.c long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) · line 512
Quoted 7 lines
xen/common/sysctl.c +7
-0+case XEN_SYSCTL_get_config: + { +unsigned int size =min (op->u.get_config.size, xen_config_data_sz); + +if ( size && +copy_to_guest (op->u.get_config.buffer, xen_config_data, size) ) + ret = -EFAULT ;What's the point of copying when user supplied buffer is not big enough? They can't continue from where they left off anyway.
Hmm, true. Will change.
Quoted 17 lines
Quoted 17 lines
xen/common/sysctl.c +5
-0+ op->u.get_config.size = xen_config_data_sz; + +break ; + } +default : ret =arch_do_sysctl (op, u_sysctl); copyback =0 ;xen/include/public/sysctl.h +0
-0@@ -1100,6 +1100,20 @@ typedef struct xen_sysctl_cpu_policy xen_sysctl_cpu_policy_t;DEFINE_XEN_GUEST_HANDLE (xen_sysctl_cpu_policy_t);#endif
Quoted 12 lines
xen/include/public/sysctl.h typedef struct xen_sysctl_cpu_policy xen_sysctl_cpu_policy_t; · line 1112
Quoted 10 lines
xen/include/public/sysctl.h +10
-0+/* +* XEN_SYSCTL_get_config +* +* Return gzip-ed .config file +*/ +struct xen_sysctl_get_config { +XEN_GUEST_HANDLE_64 (char ) buffer;/* IN: pointer to buffer. */ +uint32_t size;/* IN: size of buffer. */ +/* OUT: size of config data. */ +uint32_t pad;/* IN: MUST be zero. */ Please check pad is really zero in code.
Yes.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 1/2] xen: add interface for obtaining .config from hypervisor
In reply to Juergen Grossxen/common/Makefile subdir-$(CONFIG_UBSAN) += ubsan · line 92
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 17.01.19 at 15:57, <[email protected]> wrote:
xen/common/Makefile +6
-0@@ -83,3 +84,9 @@ subdir-$(CONFIG_UBSAN) += ubsan subdir-$(CONFIG_NEEDS_LIBELF) += libelf subdir-$(CONFIG_HAS_DEVICE_TREE) += libfdt + +config_data.c: ../.config + ( echo "const char xen_config_data[] ="; \ + cat $< | gzip | ../tools/bin2c; \ + echo ";"; \ + echo "unsigned int xen_config_data_sz = sizeof(xen_config_data) - 1;" ) > $@
const here as well please. With this adjusted
(apart from the XSM changes)
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 1/2] xen: add interface for obtaining .config from hypervisor
Quoted 14 lines
xen/common/Makefile subdir-$(CONFIG_UBSAN) += ubsan · line 92
Quoted 12 lines
Quoted 2 lines · On 28.01.19 at 12:40, <[email protected]> wrote:
Quoted 1 line · On 17.01.19 at 15:57, <[email protected]> wrote:
xen/common/Makefile +6
-0@@ -83,3 +84,9 @@ subdir-$(CONFIG_UBSAN) += ubsan subdir-$(CONFIG_NEEDS_LIBELF) += libelf subdir-$(CONFIG_HAS_DEVICE_TREE) += libfdt + +config_data.c: ../.config + ( echo "const char xen_config_data[] ="; \ + cat $< | gzip | ../tools/bin2c; \ + echo ";"; \ + echo "unsigned int xen_config_data_sz = sizeof(xen_config_data) - 1;" ) >$@
Quoted 3 lines
const here as well please. With this adjusted
Reviewed-by Jan Beulich <[email protected]>(apart from the XSM changes)
And I should have added "with Wei's comments also taken care of".
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 2/2 tools: add new xl command get-config for getting hypervisor config
In reply to Juergen GrossAdd new subcommand "get-config" to xl config to print the hypervisor
.config file.
To be able to reuse already existing decompressing code in libxenguest xc_inflate_buffer() has to be moved to libxenguest.h.
--- docs/man/xl.1.pod.in | 5 +++++ tools/libxc/include/xenctrl.h | 8 ++++++++ tools/libxc/include/xenguest.h | 13 +++++++++++++ tools/libxc/xc_misc.c | 42 ++++++++++++++++++++++++++++++++++++++++++ tools/libxc/xg_private.h | 4 ---- tools/libxl/libxl.c | 30 ++++++++++++++++++++++++++++++ tools/libxl/libxl.h | 8 ++++++++ tools/xl/xl.h | 1 + tools/xl/xl_cmdtable.c | 5 +++++ tools/xl/xl_misc.c | 20 ++++++++++++++++++++ 10 files changed, 132 insertions(+), 4 deletions(-)
docs/man/xl.1.pod.in +5 -0
@@ -844,6 +844,11 @@ Clears Xen's message buffer. =back +=item B<get-config> + +Print the software configuration file (.config) used to build the +hypervisor. + =item B<info> [I<OPTIONS>] Print information about the Xen host in I<name : value> format. When
tools/libxc/include/xenctrl.h +8 -0
@@ -2627,6 +2627,14 @@ int xc_livepatch_replace(xc_interface *xch, char *name, uint32_t timeout);int xc_domain_cacheflush (xc_interface *xch,uint32_t domid,xen_pfn_t start_pfn,xen_pfn_t nr_pfns); +/* +* Get gzip-ed .config from hypervisor. +* *buffer must be free()-ed by caller. +* data size is returned in `size`. +* Returns 0 on success. +*/ +int xc_get_config (xc_interface *xch,char **buffer,unsigned long *size); +/* Compat shims */ #include "xenctrl_compat.h"
tools/libxc/include/xenguest.h +13 -0
@@ -310,4 +310,17 @@ xen_pfn_t *xc_map_m2p(xc_interface *xch,unsigned long max_mfn, int prot, unsigned long *mfn0); + +/** +* Decompress a gzip-ed stream. +* @parm xch a handle to an open hypervisor interface +* @parm in_buf buffer holding the gzip-ed data +* @parm in_size size in bytes of the gzip-ed data +* @parm out_size where to store the gunzip-ed data length +* @return new allocated buffer holding the gunzip-ed data +*/ +char *xc_inflate_buffer (xc_interface *xch, +const char *in_buf, +unsigned long in_size, +unsigned long *out_size);#endif /* XENGUEST_H */
tools/libxc/xc_misc.c +42 -0
48 lines not on this page · raw message
tools/libxc/xg_private.h +0 -4
@@ -43,10 +43,6 @@char *xc_read_image (xc_interface *xch,const char *filename,unsigned long *size); -char *xc_inflate_buffer (xc_interface *xch, -const char *in_buf, -unsigned long in_size, -unsigned long *out_size);unsigned long csum_page (void * page);
tools/libxl/libxl.c +30 -0
@@ -669,6 +669,36 @@ int libxl_set_parameters(libxl_ctx *ctx, char *params)return 0 ; } +int libxl_get_config (libxl_ctx *ctx,char **buffer) +{ +int ret; +unsigned long gz_size, out_size; +char *gz_buffer; +GC_INIT (ctx); + + ret =xc_get_config (ctx->xch, &gz_buffer, &gz_size); +if (ret <0 ) { +LOGEV (ERROR , ret,"getting config" ); +GC_FREE ; +return ERROR_FAIL ; + } + + *buffer =xc_inflate_buffer (ctx->xch, gz_buffer, gz_size, &out_size); + +GC_FREE ; +free (gz_buffer); + +if (!*buffer) { +LOGE (ERROR ,"decompressing config data failed" ); +return ERROR_FAIL ; + } + + *buffer =libxl__realloc (NOGC , *buffer, out_size +1 ); + (*buffer)[out_size] =0 ; + +return 0 ; +} +static int fd_set_flags (libxl_ctx *ctx,int fd,int fcntlgetop,int fcntlsetop,const char *fl,int flagmask,int set_p)
tools/libxl/libxl.h +8 -0
@@ -1149,6 +1149,13 @@ void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, const libxl_mac *src);*/ #define LIBXL_HAVE_SET_PARAMETERS 1 +/* +* LIBXL_HAVE_GET_CONFIG +* +* If this is defined getting hypervisor config is supported. +*/ +#define LIBXL_HAVE_GET_CONFIG 1 +/* * LIBXL_HAVE_PV_SHIM *
@@ -2307,6 +2314,7 @@ int libxl_send_trigger(libxl_ctx *ctx, uint32_t domid,int libxl_send_sysrq (libxl_ctx *ctx,uint32_t domid,char sysrq);int libxl_send_debug_keys (libxl_ctx *ctx,char *keys);int libxl_set_parameters (libxl_ctx *ctx,char *params); +int libxl_get_config (libxl_ctx *ctx,char **buffer);typedef struct libxl__xen_console_reader libxl_xen_console_reader ;
tools/xl/xl.h +1 -0
@@ -156,6 +156,7 @@ int main_trigger(int argc, char **argv);int main_sysrq (int argc,char **argv);int main_debug_keys (int argc,char **argv);int main_set_parameters (int argc,char **argv); +int main_get_config (int argc,char **argv);int main_dmesg (int argc,char **argv);int main_top (int argc,char **argv);int main_networkattach (int argc,char **argv);
tools/xl/xl_cmdtable.c +5 -0
@@ -320,6 +320,11 @@ struct cmd_spec cmd_table[] = {"Set hypervisor parameters" ,"<Params>" , }, + { "get-config", + &main_get_config,0 ,0 , +"Get hypervisor build config" , +"" , + }, { "dmesg", &main_dmesg,0 ,0 , "Read and/or clear dmesg buffer",
tools/xl/xl_misc.c +20 -0
@@ -175,6 +175,26 @@ int main_set_parameters(int argc, char **argv)return EXIT_SUCCESS ; } +int main_get_config (int argc,char **argv) +{ +int opt; +char *conf; + + SWITCH_FOREACH_OPT(opt, "", NULL, "get-config", 0) { +/* No options */ + } + +if (libxl_get_config (ctx, &conf)) { +fprintf (stderr,"cannot get config\n" ); +return EXIT_FAILURE ; + } + +printf ("%s\n" , conf); +free (conf); + +return EXIT_SUCCESS ; +} +int main_devd (int argc,char **argv) {int ret =0 , opt =0 , daemonize =1 ;
Signature · 7 lines
2.16.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 2/2] tools: add new xl command get-config for getting hypervisor config
Quoted 2 lines · Juergen Gross
Add new subcommand "get-config" to xl config to print the hypervisor
.config file.
I slight prefer get-xen-config or get-hypervisor-config.
Quoted 5 lines
To be able to reuse already existing decompressing code in libxenguest
xc_inflate_buffer()has to be moved tolibxenguest.h.Signed-off-by Juergen Gross <[email protected]>
[...]
Quoted 8 lines
tools/libxl/libxl.c +7
-0+int libxl_get_config (libxl_ctx *ctx,char **buffer) +{ +int ret; +unsigned long gz_size, out_size; +char *gz_buffer; +GC_INIT (ctx); +
tools/libxl/libxl.c int libxl_set_parameters(libxl_ctx *ctx, char *params) · line 688
Quoted 10 lines
tools/libxl/libxl.c +10
-0+ ret =xc_get_config (ctx->xch, &gz_buffer, &gz_size); +if (ret <0 ) { +LOGEV (ERROR , ret,"getting config" ); +GC_FREE ; +return ERROR_FAIL ; + } + + *buffer =xc_inflate_buffer (ctx->xch, gz_buffer, gz_size, &out_size); + +GC_FREE ;
Please move this to the end of the function and ...
tools/libxl/libxl.c int libxl_set_parameters(libxl_ctx *ctx, char *params) · line 693
Quoted 5 lines
tools/libxl/libxl.c +5
-0+free (gz_buffer); + +if (!*buffer) { +LOGE (ERROR ,"decompressing config data failed" ); +return ERROR_FAIL ;
... use goto style instead.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 2/2] tools: add new xl command get-config for getting hypervisor config
Quoted 5 lines · Wei Liu
Quoted 2 lines · Juergen Gross
Add new subcommand "get-config" to xl config to print the hypervisor
.config file.I slight prefer get-xen-config or get-hypervisor-config.
I'd be happy with either.
Anybody else got a special preference?
Quoted 28 lines
Quoted 6 lines
To be able to reuse already existing decompressing code in libxenguest
xc_inflate_buffer()has to be moved tolibxenguest.h.Signed-off-by Juergen Gross <[email protected]>[...]
Quoted 8 lines
tools/libxl/libxl.c +7
-0+int libxl_get_config (libxl_ctx *ctx,char **buffer) +{ +int ret; +unsigned long gz_size, out_size; +char *gz_buffer; +GC_INIT (ctx); +tools/libxl/libxl.c int libxl_set_parameters(libxl_ctx *ctx, char *params) · line 688
Quoted 10 lines
tools/libxl/libxl.c +10
-0+ ret =xc_get_config (ctx->xch, &gz_buffer, &gz_size); +if (ret <0 ) { +LOGEV (ERROR , ret,"getting config" ); +GC_FREE ; +return ERROR_FAIL ; + } + + *buffer =xc_inflate_buffer (ctx->xch, gz_buffer, gz_size, &out_size); + +GC_FREE ;Please move this to the end of the function and ...
Quoted 7 lines
tools/libxl/libxl.c int libxl_set_parameters(libxl_ctx *ctx, char *params) · line 693
Quoted 5 lines
tools/libxl/libxl.c +5
-0+free (gz_buffer); + +if (!*buffer) { +LOGE (ERROR ,"decompressing config data failed" ); +return ERROR_FAIL ;... use goto style instead.
Okay.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 2/2] tools: add new xl command get-config for getting hypervisor config
Juergen Gross writes ("Re: [PATCH 2/2] tools: add new xl command get-config for getting hypervisor config"):
Quoted 10 lines · Wei Liu
Quoted 5 lines · Juergen Gross
Quoted 2 lines
Add new subcommand "get-config" to xl config to print the hypervisor
.config file.I slight prefer get-xen-config or get-hypervisor-config.
I'd be happy with either.
Anybody else got a special preference?
I prefer
get-hypervisor-config
Thanks to Wei for the reviews.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 2 lines · Juergen Gross
Add "xl get-config" printing the .config used to build the currently running hypervisor.
BTW: I'd like to have feedback especially if someone thinks this series should by any means be part of 4.12. If not I'll send out V2 with bumping the sysctl interface version.
Juergen
Quoted 19 lines
Juergen Gross (2):
xen: add interface for obtaining .config from hypervisor
tools: add new xl command get-config for getting hypervisor config.gitignore | 2 ++ docs/man/xl.1.pod.in | 5 +++++ tools/flask/policy/modules/dom0.te | 2 +- tools/libxc/include/xenctrl.h | 8 +++++++ tools/libxc/include/xenguest.h | 13 ++++++++++++ tools/libxc/xc_misc.c | 42 +++++++++++++++++++++++++++++++++++++ tools/libxc/xg_private.h | 4 ---- tools/libxl/libxl.c | 30 ++++++++++++++++++++++++++ tools/libxl/libxl.h | 8 +++++++ tools/xl/xl.h | 1 + tools/xl/xl_cmdtable.c | 5 +++++ tools/xl/xl_misc.c | 20 ++++++++++++++++++ xen/common/Makefile | 7 +++++++ xen/common/sysctl.c | 13 ++++++++++++
Quoted 9 lines
xen/include/public/sysctl.h | 16 ++++++++++++++ xen/include/xen/kernel.h | 3 +++ xen/tools/Makefile | 9 ++++++-- xen/tools/bin2c.c | 28 +++++++++++++++++++++++++ xen/xsm/flask/hooks.c | 3 +++ xen/xsm/flask/policy/access_vectors | 2 ++ 20 files changed, 214 insertions(+), 7 deletions(-) create mode 100644 xen/tools/bin2c.c
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 6 lines · Juergen Gross
Quoted 2 lines · Juergen Gross
Add "xl get-config" printing the .config used to build the currently running hypervisor.
BTW: I'd like to have feedback especially if someone thinks this series should by any means be part of 4.12. If not I'll send out V2 with bumping the sysctl interface version.
LGTM for 4.12
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 7 lines · Juergen Gross
Quoted 2 lines · Juergen Gross
Add "xl get-config" printing the .config used to build the currently running hypervisor.
BTW: I'd like to have feedback especially if someone thinks this series should by any means be part of 4.12. If not I'll send out V2 with bumping the sysctl interface version.
I certainly won't have objection for it to go into 4.12.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 7 lines · Juergen Gross
Quoted 2 lines · Juergen Gross
Add "xl get-config" printing the .config used to build the currently running hypervisor.
BTW: I'd like to have feedback especially if someone thinks this series should by any means be part of 4.12. If not I'll send out V2 with bumping the sysctl interface version.
If someone *else* would have send this instead of you, would you have considered including it, or would you have said that this is way past the "feature freeze" in mid-December, it will be just fine to wait until 4.13?
If the answer is "yes", then it begs the question what the point of the feature freeze is, if new features can be introduced after the *code freeze*.
If the answer is "no", then you're basically abusing your position as release manager to get your own code in.
*Everyone* thinks that their own patch is super-important to get in before the next release, and basically perfect and not going to cause any regressions. It's the job of a release manager to be the "bad guy" and tell them no; and a release manager should be stricter with themselves than with anybody else.
-George
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 5 lines · George Dunlap
Quoted 4 lines · Juergen Gross
Quoted 2 lines · Juergen Gross
Add "xl get-config" printing the .config used to build the currently running hypervisor.
Quoted 8 lines
Quoted 3 lines
BTW: I'd like to have feedback especially if someone thinks this series should by any means be part of 4.12. If not I'll send out V2 with bumping the sysctl interface version.
If someone *else* would have send this instead of you, would you have considered including it, or would you have said that this is way past the "feature freeze" in mid-December, it will be just fine to wait until 4.13?
It would need a rather strong reason to be accepted.
Quoted 6 lines
If the answer is "yes", then it begs the question what the point of the feature freeze is, if new features can be introduced after the *code freeze*.
If the answer is "no", then you're basically abusing your position as release manager to get your own code in.
That's exactly why I asked for that feedback.
Someone saying "I don't mind this going in" is not enough. I said:
"... should by any means be part of 4.12".
So there would need to be a strong reason for that request, and up to now I haven't seen that reason.
Quoted 5 lines
*Everyone* thinks that their own patch is super-important to get in before the next release, and basically perfect and not going to cause any regressions. It's the job of a release manager to be the "bad guy" and tell them no; and a release manager should be stricter with themselves than with anybody else.
I completely agree with you here.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel