xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Juergen Gross <jgross@suse.com>
To: xen-devel@lists.xenproject.org
Cc: Juergen Gross <jgross@suse.com>,
	Stefano Stabellini <sstabellini@kernel.org>, Wei Liu <wl@xen.org>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	George Dunlap <George.Dunlap@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>, Tim Deegan <tim@xen.org>,
	Julien Grall <julien.grall@arm.com>,
	Jan Beulich <jbeulich@suse.com>
Subject: [Xen-devel] [RFC PATCH 5/5] xen: add /buildinfo/config entry to hypervisor filesystem
Date: Wed, 11 Sep 2019 08:20:01 +0200	[thread overview]
Message-ID: <20190911062001.25931-6-jgross@suse.com> (raw)
In-Reply-To: <20190911062001.25931-1-jgross@suse.com>

Add the /buildinfo/config entry to the hypervisor filesystem. This
entry contains the .config file used to build the hypervisor.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 .gitignore               |  2 ++
 xen/common/Makefile      |  6 ++++++
 xen/common/filesystem.c  | 17 +++++++++++++++++
 xen/include/xen/kernel.h |  2 ++
 xen/tools/Makefile       |  9 +++++++--
 xen/tools/bin2c.c        | 28 ++++++++++++++++++++++++++++
 6 files changed, 62 insertions(+), 2 deletions(-)
 create mode 100644 xen/tools/bin2c.c

diff --git a/.gitignore b/.gitignore
index 3c947ac948..7150dd0548 100644
--- a/.gitignore
+++ b/.gitignore
@@ -295,6 +295,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
@@ -312,6 +313,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
diff --git a/xen/common/Makefile b/xen/common/Makefile
index be43757dff..9bce9db43b 100644
--- a/xen/common/Makefile
+++ b/xen/common/Makefile
@@ -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
@@ -79,3 +80,8 @@ 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[] ="; \
+	  ../tools/bin2c <$<; \
+	  echo ";" ) > $@
diff --git a/xen/common/filesystem.c b/xen/common/filesystem.c
index d833992ab1..4ab18eb82a 100644
--- a/xen/common/filesystem.c
+++ b/xen/common/filesystem.c
@@ -25,6 +25,10 @@ static struct fs_entry fs_root_entry = {
     .dir = &fs_root,
 };
 
+static struct fs_dir fs_buildinfo = {
+    .list = LIST_HEAD_INIT(fs_buildinfo.list),
+};
+
 static int fs_add_entry(struct fs_dir *parent, struct fs_entry *new)
 {
     int ret = -ENOENT;
@@ -268,3 +272,16 @@ long do_filesystem_op(unsigned int cmd,
 
     return ret;
 }
+
+static int __init fs_init(void)
+{
+    int ret;
+
+    ret = fs_new_dir(&fs_root, "buildinfo", &fs_buildinfo);
+    BUG_ON(ret);
+    ret = fs_new_entry(&fs_buildinfo, "config", xen_config_data);
+    BUG_ON(ret);
+
+    return 0;
+}
+__initcall(fs_init);
diff --git a/xen/include/xen/kernel.h b/xen/include/xen/kernel.h
index 548b64da9f..00817d06c8 100644
--- a/xen/include/xen/kernel.h
+++ b/xen/include/xen/kernel.h
@@ -100,5 +100,7 @@ extern enum system_state {
 
 bool_t is_active_kernel_text(unsigned long addr);
 
+extern const char xen_config_data[];
+
 #endif /* _LINUX_KERNEL_H */
 
diff --git a/xen/tools/Makefile b/xen/tools/Makefile
index e940939d61..cd2bbbf647 100644
--- a/xen/tools/Makefile
+++ b/xen/tools/Makefile
@@ -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 $@ $<
diff --git a/xen/tools/bin2c.c b/xen/tools/bin2c.c
new file mode 100644
index 0000000000..c332399b70
--- /dev/null
+++ b/xen/tools/bin2c.c
@@ -0,0 +1,28 @@
+/*
+ * Unloved program to convert a binary on stdin to a C include on stdout
+ *
+ * Jan 1999 Matt Mackall <mpm@selenic.com>
+ *
+ * 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;
+}
-- 
2.16.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2019-09-11  6:20 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-11  6:19 [Xen-devel] [RFC PATCH 0/5] Add hypervisor sysfs-like support Juergen Gross
2019-09-11  6:19 ` [Xen-devel] [RFC PATCH 1/5] docs: add feature document for Xen " Juergen Gross
2019-09-11  9:28   ` Jan Beulich
2019-09-11  9:29     ` Juergen Gross
2019-09-11  6:19 ` [Xen-devel] [RFC PATCH 2/5] xen: add basic hypervisor filesystem support Juergen Gross
2019-09-11  6:19 ` [Xen-devel] [RFC PATCH 3/5] libs: add libxenfs Juergen Gross
2019-09-11  6:20 ` [Xen-devel] [RFC PATCH 4/5] tools: add xenfs tool Juergen Gross
2019-09-11  9:30   ` Jan Beulich
2019-09-11  9:57     ` Juergen Gross
2019-09-11 10:07       ` Jan Beulich
2019-09-11 11:34         ` Juergen Gross
2019-09-11 11:50           ` Jan Beulich
2019-09-11 12:41             ` Juergen Gross
2019-09-11  6:20 ` Juergen Gross [this message]
2019-09-11  9:24 ` [Xen-devel] [RFC PATCH 0/5] Add hypervisor sysfs-like support Jan Beulich
2019-09-11 10:02   ` Juergen Gross
2019-09-11 11:17 ` Andrew Cooper
2019-09-11 11:29   ` Juergen Gross
2019-09-11 11:54     ` Jan Beulich
2019-09-11 13:01       ` Juergen Gross
2019-09-11 15:01         ` Jan Beulich
2019-09-11 15:06           ` Juergen Gross
2019-09-11 15:20             ` Jan Beulich
2019-09-11 15:26               ` Juergen Gross

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190911062001.25931-6-jgross@suse.com \
    --to=jgross@suse.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julien.grall@arm.com \
    --cc=konrad.wilk@oracle.com \
    --cc=sstabellini@kernel.org \
    --cc=tim@xen.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).