add xl command to get hypervisor .config
v2 cover add xl command to get hypervisor .config
Add "xl get-hypervisor-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-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 | 34 ++++++++++++++++++++++++++++++ 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 | 17 +++++++++++++++ xen/include/public/sysctl.h | 18 +++++++++++++++- 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, 223 insertions(+), 8 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 v2 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.
---
V2:
- bump sysctl interface version
- check pad to be zero (Wei Liu)
- only copy data if buffer is large enough (Wei Liu)
- add .gitignore entry at correct position (Wei Liu)
- make xen_config_data_sz const (Jan Beulich)
--- .gitignore | 2 ++ tools/flask/policy/modules/dom0.te | 2 +- xen/common/Makefile | 7 +++++++ xen/common/sysctl.c | 17 +++++++++++++++++ xen/include/public/sysctl.h | 18 +++++++++++++++++- 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, 87 insertions(+), 4 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
@@ -326,6 +327,7 @@ xen/test/livepatch/xen_bye_world.livepatch xen/test/livepatch/xen_hello_world.livepatch xen/test/livepatch/xen_nop.livepatch xen/test/livepatch/xen_replace_world.livepatch +xen/tools/bin2c xen/tools/kconfig/.tmp_gtkcheck xen/tools/kconfig/.tmp_qtcheck xen/tools/symbols
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,6 +1,7 @@ obj-$(CONFIG_ARGO) += argo.o 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
@@ -84,3 +85,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 "const unsigned int xen_config_data_sz = sizeof(xen_config_data) - 1;" ) > $@
xen/common/sysctl.c +17 -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,22 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl)break ; } +case XEN_SYSCTL_get_config: + { +if ( op->u.get_config.pad ) + { + ret = -EINVAL ; +break ; + } +if ( xen_config_data_sz <= op->u.get_config.size && +copy_to_guest (op->u.get_config.buffer, xen_config_data, + xen_config_data_sz) ) + 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 +17 -1
@@ -36,7 +36,7 @@#include "physdev.h" #include "tmem.h" -#define XEN_SYSCTL_INTERFACE_VERSION 0x00000012 +#define XEN_SYSCTL_INTERFACE_VERSION 0x00000013/* * Read console content from Xen buffer ring.
@@ -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
@@ -830,6 +830,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 v2 1/2] xen: add interface for obtaining .config from hypervisor
Quoted 5 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]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v2 1/2] xen: add interface for obtaining .config from hypervisor
In reply to Juergen GrossQuoted 9 lines
Quoted 1 line
Quoted 1 line · On 14.03.19 at 12:59, <[email protected]> wrote:
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]>---
V2:
- bump sysctl interface version
Judging from the style you use for other entries here this wasn't a result of review feedback. Why did you do this? The change is a plain addition to the interface, which doesn't require caller awareness. My R-b does not hold with this in place.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v2 1/2] xen: add interface for obtaining .config from hypervisor
Quoted 4 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 14.03.19 at 12:59, <[email protected]> wrote:
Add a sysctl interface for obtaining the .config file used to build the hypervisor. The mechanism is inspired by the Linux kernel's one.
Quoted 8 lines
Quoted 5 lines
Signed-off-by Juergen Gross <[email protected]>---
V2:
- bump sysctl interface versionJudging from the style you use for other entries here this wasn't a result of review feedback. Why did you do this? The change is
V1 was posted before 4.12 was branched away, so bumping would have clearly be wrong at that time.
Quoted 2 lines
a plain addition to the interface, which doesn't require caller awareness. My R-b does not hold with this in place.
Ah, I wasn't aware of this rule. I'll remove the bumping in case this can't be done when committing.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v2 1/2] xen: add interface for obtaining .config from hypervisor
Quoted 15 lines
Quoted 1 line
Quoted 1 line · On 15.03.19 at 15:01, <[email protected]> wrote:
Quoted 4 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 14.03.19 at 12:59, <[email protected]> wrote:
Add a sysctl interface for obtaining the .config file used to build the hypervisor. The mechanism is inspired by the Linux kernel's one.
Quoted 8 lines
Quoted 5 lines
Signed-off-by Juergen Gross <[email protected]>---
V2:
- bump sysctl interface versionJudging from the style you use for other entries here this wasn't a result of review feedback. Why did you do this? The change is
Quoted 8 lines
V1 was posted before 4.12 was branched away, so bumping would have clearly be wrong at that time.
Quoted 2 lines
a plain addition to the interface, which doesn't require caller awareness. My R-b does not hold with this in place.
Ah, I wasn't aware of this rule. I'll remove the bumping in case this can't be done when committing.
It's pretty straightforward to drop this while committing.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v2 1/2] xen: add interface for obtaining .config from hypervisor
In reply to Juergen Grossxen/include/public/sysctl.h typedef struct xen_sysctl_cpu_policy xen_sysctl_cpu_policy_t; · line 1106
Quoted 8 lines · Juergen Gross
xen/include/public/sysctl.h +4
-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
I don't think it is wise to bake gzip into the API. These days, there really are better options than gzip both in terms of compression ratio and decompress speed.
I'd suggest just saying "file may be compressed" and leave it up to the packagers build system and xl choices to agree on which compression (if any) to use.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v2 1/2] xen: add interface for obtaining .config from hypervisor
Quoted 14 lines · Andrew Cooper
xen/include/public/sysctl.h typedef struct xen_sysctl_cpu_policy xen_sysctl_cpu_policy_t; · line 1106
Quoted 8 lines · Juergen Gross
xen/include/public/sysctl.h +4
-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 I don't think it is wise to bake gzip into the API. These days, there really are better options than gzip both in terms of compression ratio and decompress speed.
Quoted 3 lines
I'd suggest just saying "file may be compressed" and leave it up to the packagers build system and
xlchoices to agree on which compression (if any) to use.
I am not convinced this is a good idea. I think the data format should be specified.
And TBH: the difference in size for a rather "normal" .config is about 50 bytes (I tried gzip, xz and bzip2 with gzip producing the smallest result).
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v2 1/2] xen: add interface for obtaining .config from hypervisor
Quoted 19 lines · Juergen Gross
Quoted 14 lines · Andrew Cooper
xen/include/public/sysctl.h typedef struct xen_sysctl_cpu_policy xen_sysctl_cpu_policy_t; · line 1106
Quoted 8 lines · Juergen Gross
xen/include/public/sysctl.h +4
-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 I don't think it is wise to bake gzip into the API. These days, there really are better options than gzip both in terms of compression ratio and decompress speed.
Quoted 3 lines
I'd suggest just saying "file may be compressed" and leave it up to the packagers build system and
xlchoices to agree on which compression (if any) to use.
Quoted 6 lines
I am not convinced this is a good idea. I think the data format should be specified.
And TBH: the difference in size for a rather "normal" .config is about 50 bytes (I tried gzip, xz and bzip2 with gzip producing the smallest result).
Has this been resolved?
I don't really have an opinion on this.
Wei.
Quoted 3 lines
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v2 1/2] xen: add interface for obtaining .config from hypervisor
Quoted 23 lines · Wei Liu
Quoted 22 lines · Juergen Gross
Quoted 14 lines · Andrew Cooper
xen/include/public/sysctl.h typedef struct xen_sysctl_cpu_policy xen_sysctl_cpu_policy_t; · line 1106
Quoted 8 lines · Juergen Gross
xen/include/public/sysctl.h +4
-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 I don't think it is wise to bake gzip into the API. These days, there really are better options than gzip both in terms of compression ratio and decompress speed.
Quoted 3 lines
I'd suggest just saying "file may be compressed" and leave it up to the packagers build system and
xlchoices to agree on which compression (if any) to use.I am not convinced this is a good idea. I think the data format should be specified.
Quoted 7 lines
Quoted 3 lines
And TBH: the difference in size for a rather "normal" .config is about 50 bytes (I tried gzip, xz and bzip2 with gzip producing the smallest result).
Has this been resolved?
I don't really have an opinion on this.
I got no reply for that answer.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v2 1/2] xen: add interface for obtaining .config from hypervisor
Quoted 28 lines · Juergen Gross
Quoted 27 lines · Wei Liu
Quoted 25 lines · Juergen Gross
Quoted 14 lines · Andrew Cooper
xen/include/public/sysctl.h typedef struct xen_sysctl_cpu_policy xen_sysctl_cpu_policy_t; · line 1106
Quoted 8 lines · Juergen Gross
xen/include/public/sysctl.h +4
-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 I don't think it is wise to bake gzip into the API. These days, there really are better options than gzip both in terms of compression ratio and decompress speed.
Quoted 3 lines
I'd suggest just saying "file may be compressed" and leave it up to the packagers build system and
xlchoices to agree on which compression (if any) to use.I am not convinced this is a good idea. I think the data format should be specified.
And TBH: the difference in size for a rather "normal" .config is about 50 bytes (I tried gzip, xz and bzip2 with gzip producing the smallest result).
Quoted 5 lines
Quoted 3 lines
Has this been resolved?
I don't really have an opinion on this.
I got no reply for that answer.
You don't need a reply; if a suggestion is made, and you explain why you don't like it, then it's up to the other person to unabiguously Nack it if they don't like it; silence is interpreted as consent.
To move this forward, I'd suggest re-posting it, adding a comment about the choice of compression algorithm in the commit message.
-George
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v2 1/2] xen: add interface for obtaining .config from hypervisor
Quoted 33 lines · George Dunlap
Quoted 32 lines · Juergen Gross
Quoted 30 lines · Wei Liu
Quoted 19 lines · Juergen Gross
Quoted 14 lines · Andrew Cooper
xen/include/public/sysctl.h typedef struct xen_sysctl_cpu_policy xen_sysctl_cpu_policy_t; · line 1106
Quoted 8 lines · Juergen Gross
xen/include/public/sysctl.h +4
-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 I don't think it is wise to bake gzip into the API. These days, there really are better options than gzip both in terms of compression ratio and decompress speed.
Quoted 3 lines
I'd suggest just saying "file may be compressed" and leave it up to the packagers build system and
xlchoices to agree on which compression (if any) to use.Quoted 6 lines
I am not convinced this is a good idea. I think the data format should be specified.
And TBH: the difference in size for a rather "normal" .config is about 50 bytes (I tried gzip, xz and bzip2 with gzip producing the smallest result).
Has this been resolved?
I don't really have an opinion on this.
Quoted 8 lines
Quoted 1 line
I got no reply for that answer.
You don't need a reply; if a suggestion is made, and you explain why you don't like it, then it's up to the other person to unabiguously Nack it if they don't like it; silence is interpreted as consent.
To move this forward, I'd suggest re-posting it, adding a comment about the choice of compression algorithm in the commit message.
At the summit we had a discussion about a simple name-value store in the hypervisor for e.g. communicating mitigation settings or runtime param settings to at least dom0. The .config used for building Xen was agreed to be another candidate for that interface.
I wanted to have a look at that when I'm finished with other urgent work I'm actually doing.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v2 1/2] xen: add interface for obtaining .config from hypervisor
In reply to Juergen GrossQuoted 5 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]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 2/2 tools: add new xl command get-hypervisor-config
In reply to Juergen GrossAdd new subcommand "get-hypervisor-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.
---
V2:
- rename subcommand to get-hypervisor-config (Wei Liu)
- use goto style error handling (Wei Liu)
--- 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 | 34 ++++++++++++++++++++++++++++++++++ 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, 136 insertions(+), 4 deletions(-)
docs/man/xl.1.pod.in +5 -0
@@ -844,6 +844,11 @@ Clears Xen's message buffer. =back +=item B<get-hypervisor-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
@@ -2632,6 +2632,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 +34 -0
@@ -669,6 +669,40 @@ int libxl_set_parameters(libxl_ctx *ctx, char *params)return 0 ; } +int libxl_get_hypervisor_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" ); + ret =ERROR_FAIL ; + goto out; + } + + *buffer =xc_inflate_buffer (ctx->xch, gz_buffer, gz_size, &out_size); + +free (gz_buffer); + +if (!*buffer) { +LOGE (ERROR ,"decompressing config data failed" ); + ret =ERROR_FAIL ; + goto out; + } + + *buffer =libxl__realloc (NOGC , *buffer, out_size +1 ); + (*buffer)[out_size] =0 ; + + ret =0 ; + +out: +GC_FREE ; +return ret; +} +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_HYPERVISOR_CONFIG +* +* If this is defined getting hypervisor config is supported. +*/ +#define LIBXL_HAVE_GET_HYPERVISOR_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_hypervisor_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_hypervisor_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-hypervisor-config", + &main_get_hypervisor_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_hypervisor_config (int argc,char **argv) +{ +int opt; +char *conf; + + SWITCH_FOREACH_OPT(opt, "", NULL, "get-hypervisor-config", 0) { +/* No options */ + } + +if (libxl_get_hypervisor_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 v2 2/2] tools: add new xl command get-hypervisor-config
Quoted 7 lines · Juergen Gross
Add new subcommand "get-hypervisor-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 tolibxenguest.h.Signed-off-by Juergen Gross <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel