mini-os: config related cleanups
cover mini-os: config related cleanups
While writing patch 2 I stumbled over CONFIG_TEST having no effect at the C source level, so I added patch 1 to avoid further similar problems.
The additionally fixed CONFIG_XC issue wasn't triggered in any known case, probably as FTYPE_XC hasn't been used in our code base.
Juergen Gross (2):
mini-os: make config handling more generic
mini-os: move test functions under CONFIG_TEST
Config.mk | 66 +++++++++++++++++++++---------------------------- xenbus/xenbus.c | 32 +++++++++++++----------- 2 files changed, 45 insertions(+), 53 deletions(-)
Signature · 1 line
2.26.2
PATCH 1/2 mini-os: make config handling more generic
When adding a new CONFIG_ variable this needs to be done in multiple places. Change the handling to be more generic.
This at once fixes a bug with CONFIG_XC which was not defined for the C preprocessor (it seems that this never resulted in any real issues, though).
--- Config.mk | 66 +++++++++++++++++++++++-------------------------------- 1 file changed, 28 insertions(+), 38 deletions(-)
Config.mk +28 -38
@@ -171,49 +171,39 @@ endif # CONFIG_ variables. # Configuration defaults +CONFIG-y += CONFIG_START_NETWORK +CONFIG-y += CONFIG_SPARSE_BSS +CONFIG-y += CONFIG_BLKFRONT +CONFIG-y += CONFIG_NETFRONT +CONFIG-y += CONFIG_FBFRONT +CONFIG-y += CONFIG_KBDFRONT +CONFIG-y += CONFIG_CONSFRONT +CONFIG-y += CONFIG_XENBUS +CONFIG-y += CONFIG_XC +CONFIG-n += CONFIG_QEMU_XS_ARGS +CONFIG-n += CONFIG_TEST +CONFIG-n += CONFIG_PCIFRONT +CONFIG-n += CONFIG_TPMFRONT +CONFIG-n += CONFIG_TPM_TIS +CONFIG-n += CONFIG_TPMBACK +CONFIG-n += CONFIG_BALLOON +# Setting CONFIG_USE_XEN_CONSOLE copies all print output to the Xen emergency +# console apart of standard dom0 handled console. +CONFIG-n += CONFIG_USE_XEN_CONSOLE ifeq ($(TARGET_ARCH_FAM),x86) -CONFIG_PARAVIRT ?= y +CONFIG-y += CONFIG_PARAVIRT else -CONFIG_PARAVIRT ?= n +CONFIG-n += CONFIG_PARAVIRT endif -CONFIG_START_NETWORK ?= y -CONFIG_SPARSE_BSS ?= y -CONFIG_QEMU_XS_ARGS ?= n -CONFIG_TEST ?= n -CONFIG_PCIFRONT ?= n -CONFIG_BLKFRONT ?= y -CONFIG_TPMFRONT ?= n -CONFIG_TPM_TIS ?= n -CONFIG_TPMBACK ?= n -CONFIG_NETFRONT ?= y -CONFIG_FBFRONT ?= y -CONFIG_KBDFRONT ?= y -CONFIG_CONSFRONT ?= y -CONFIG_XENBUS ?= y -CONFIG_XC ?=y -CONFIG_LWIP ?= $(lwip) -CONFIG_BALLOON ?= n -# Setting CONFIG_USE_XEN_CONSOLE copies all print output to the Xen emergency -# console apart of standard dom0 handled console. -CONFIG_USE_XEN_CONSOLE ?= n +CONFIG-$(lwip) += CONFIG_LWIP + +$(foreach i,$(CONFIG-y),$(eval $(i) ?= y)) +$(foreach i,$(CONFIG-n),$(eval $(i) ?= n)) + +CONFIG-all := $(CONFIG-y) $(CONFIG-n) # Export config items as compiler directives -DEFINES-$(CONFIG_PARAVIRT) += -DCONFIG_PARAVIRT -DEFINES-$(CONFIG_START_NETWORK) += -DCONFIG_START_NETWORK -DEFINES-$(CONFIG_SPARSE_BSS) += -DCONFIG_SPARSE_BSS -DEFINES-$(CONFIG_QEMU_XS_ARGS) += -DCONFIG_QEMU_XS_ARGS -DEFINES-$(CONFIG_PCIFRONT) += -DCONFIG_PCIFRONT -DEFINES-$(CONFIG_BLKFRONT) += -DCONFIG_BLKFRONT -DEFINES-$(CONFIG_TPMFRONT) += -DCONFIG_TPMFRONT -DEFINES-$(CONFIG_TPM_TIS) += -DCONFIG_TPM_TIS -DEFINES-$(CONFIG_TPMBACK) += -DCONFIG_TPMBACK -DEFINES-$(CONFIG_NETFRONT) += -DCONFIG_NETFRONT -DEFINES-$(CONFIG_KBDFRONT) += -DCONFIG_KBDFRONT -DEFINES-$(CONFIG_FBFRONT) += -DCONFIG_FBFRONT -DEFINES-$(CONFIG_CONSFRONT) += -DCONFIG_CONSFRONT -DEFINES-$(CONFIG_XENBUS) += -DCONFIG_XENBUS -DEFINES-$(CONFIG_BALLOON) += -DCONFIG_BALLOON -DEFINES-$(CONFIG_USE_XEN_CONSOLE) += -DCONFIG_USE_XEN_CONSOLE +$(foreach i,$(CONFIG-all),$(eval DEFINES-$($(i)) += -D$(i))) DEFINES-y += -D__XEN_INTERFACE_VERSION__=$(XEN_INTERFACE_VERSION)
Signature · 1 line
2.26.2
Re: [PATCH 1/2] mini-os: make config handling more generic
Juergen Gross, le mar. 17 août 2021 11:54:58 +0200, a ecrit:
Quoted 8 lines
When adding a new
CONFIG_variable this needs to be done in multiple places. Change the handling to be more generic.This at once fixes a bug with
CONFIG_XCwhich was not defined for the C preprocessor (it seems that this never resulted in any real issues, though).Signed-off-by Juergen Gross <[email protected]>
Quoted 85 lines
--- Config.mk | 66 +++++++++++++++++++++++-------------------------------- 1 file changed, 28 insertions(+), 38 deletions(-)Config.mk +28
-38@@ -171,49 +171,39 @@ endif # CONFIG_ variables. # Configuration defaults +CONFIG-y += CONFIG_START_NETWORK +CONFIG-y += CONFIG_SPARSE_BSS +CONFIG-y += CONFIG_BLKFRONT +CONFIG-y += CONFIG_NETFRONT +CONFIG-y += CONFIG_FBFRONT +CONFIG-y += CONFIG_KBDFRONT +CONFIG-y += CONFIG_CONSFRONT +CONFIG-y += CONFIG_XENBUS +CONFIG-y += CONFIG_XC +CONFIG-n += CONFIG_QEMU_XS_ARGS +CONFIG-n += CONFIG_TEST +CONFIG-n += CONFIG_PCIFRONT +CONFIG-n += CONFIG_TPMFRONT +CONFIG-n += CONFIG_TPM_TIS +CONFIG-n += CONFIG_TPMBACK +CONFIG-n += CONFIG_BALLOON +# Setting CONFIG_USE_XEN_CONSOLE copies all print output to the Xen emergency +# console apart of standard dom0 handled console. +CONFIG-n += CONFIG_USE_XEN_CONSOLE ifeq ($(TARGET_ARCH_FAM),x86) -CONFIG_PARAVIRT ?= y +CONFIG-y += CONFIG_PARAVIRT else -CONFIG_PARAVIRT ?= n +CONFIG-n += CONFIG_PARAVIRT endif -CONFIG_START_NETWORK ?= y -CONFIG_SPARSE_BSS ?= y -CONFIG_QEMU_XS_ARGS ?= n -CONFIG_TEST ?= n -CONFIG_PCIFRONT ?= n -CONFIG_BLKFRONT ?= y -CONFIG_TPMFRONT ?= n -CONFIG_TPM_TIS ?= n -CONFIG_TPMBACK ?= n -CONFIG_NETFRONT ?= y -CONFIG_FBFRONT ?= y -CONFIG_KBDFRONT ?= y -CONFIG_CONSFRONT ?= y -CONFIG_XENBUS ?= y -CONFIG_XC ?=y -CONFIG_LWIP ?= $(lwip) -CONFIG_BALLOON ?= n -# Setting CONFIG_USE_XEN_CONSOLE copies all print output to the Xen emergency -# console apart of standard dom0 handled console. -CONFIG_USE_XEN_CONSOLE ?= n +CONFIG-$(lwip) += CONFIG_LWIP + +$(foreach i,$(CONFIG-y),$(eval $(i) ?= y)) +$(foreach i,$(CONFIG-n),$(eval $(i) ?= n)) + +CONFIG-all := $(CONFIG-y) $(CONFIG-n) # Export config items as compiler directives -DEFINES-$(CONFIG_PARAVIRT) += -DCONFIG_PARAVIRT -DEFINES-$(CONFIG_START_NETWORK) += -DCONFIG_START_NETWORK -DEFINES-$(CONFIG_SPARSE_BSS) += -DCONFIG_SPARSE_BSS -DEFINES-$(CONFIG_QEMU_XS_ARGS) += -DCONFIG_QEMU_XS_ARGS -DEFINES-$(CONFIG_PCIFRONT) += -DCONFIG_PCIFRONT -DEFINES-$(CONFIG_BLKFRONT) += -DCONFIG_BLKFRONT -DEFINES-$(CONFIG_TPMFRONT) += -DCONFIG_TPMFRONT -DEFINES-$(CONFIG_TPM_TIS) += -DCONFIG_TPM_TIS -DEFINES-$(CONFIG_TPMBACK) += -DCONFIG_TPMBACK -DEFINES-$(CONFIG_NETFRONT) += -DCONFIG_NETFRONT -DEFINES-$(CONFIG_KBDFRONT) += -DCONFIG_KBDFRONT -DEFINES-$(CONFIG_FBFRONT) += -DCONFIG_FBFRONT -DEFINES-$(CONFIG_CONSFRONT) += -DCONFIG_CONSFRONT -DEFINES-$(CONFIG_XENBUS) += -DCONFIG_XENBUS -DEFINES-$(CONFIG_BALLOON) += -DCONFIG_BALLOON -DEFINES-$(CONFIG_USE_XEN_CONSOLE) += -DCONFIG_USE_XEN_CONSOLE +$(foreach i,$(CONFIG-all),$(eval DEFINES-$($(i)) += -D$(i))) DEFINES-y += -D__XEN_INTERFACE_VERSION__=$(XEN_INTERFACE_VERSION)
PATCH 2/2 mini-os: move test functions under CONFIG_TEST
In reply to Juergen GrossThere is no need to have the xenbus test support functions always included in Mini-OS. Move them inside #ifdef CONFIG_TEST.
--- xenbus/xenbus.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-)
xenbus/xenbus.c +17 -15
@@ -573,21 +573,6 @@ static char *errmsg(struct xsd_sockmsg *rep)return res; } -/* Send a debug message to xenbus. Can block. */ -static void xenbus_debug_msg (const char *msg) -{ -int len =strlen (msg); -struct write_req req[] = { - {"print" ,sizeof ("print" ) }, - { msg, len }, - {"" ,1 }}; -struct xsd_sockmsg *reply; - - reply =xenbus_msg_reply (XS_DEBUG ,0 , req,ARRAY_SIZE (req)); -printk ("Got a reply, type %d, id %d, len %d.\n" , - reply->type, reply->req_id, reply->len); -} -/* List the contents of a directory. Returns a malloc()ed array of pointers to malloc()ed strings. The array is NULL terminated. May block. */
@@ -882,6 +867,22 @@ domid_t xenbus_get_self_id(void)return ret; } +#ifdef CONFIG_TEST +/* Send a debug message to xenbus. Can block. */ +static void xenbus_debug_msg (const char *msg) +{ +int len =strlen (msg); +struct write_req req[] = { + {"print" ,sizeof ("print" ) }, + { msg, len }, + {"" ,1 }}; +struct xsd_sockmsg *reply; + + reply =xenbus_msg_reply (XS_DEBUG ,0 , req,ARRAY_SIZE (req)); +printk ("Got a reply, type %d, id %d, len %d.\n" , + reply->type, reply->req_id, reply->len); +} +static void do_ls_test (const char *pre) {char **dirs, *msg;
@@ -968,6 +969,7 @@ void test_xenbus(void)do_read_test ("device/vif/0/flibble" ); printk("(Should have said ENOENT)\n"); } +#endif /* CONFIG_TEST */ /* * Local variables:
Signature · 1 line
2.26.2
Re: [PATCH 2/2] mini-os: move test functions under CONFIG_TEST
Juergen Gross, le mar. 17 août 2021 11:54:59 +0200, a ecrit:
Quoted 4 lines
There is no need to have the xenbus test support functions always included in Mini-OS. Move them inside #ifdef
CONFIG_TEST.Signed-off-by Juergen Gross <[email protected]>
Quoted 64 lines
--- xenbus/xenbus.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-)xenbus/xenbus.c +17
-15@@ -573,21 +573,6 @@ static char *errmsg(struct xsd_sockmsg *rep)return res; } -/* Send a debug message to xenbus. Can block. */ -static void xenbus_debug_msg (const char *msg) -{ -int len =strlen (msg); -struct write_req req[] = { - {"print" ,sizeof ("print" ) }, - { msg, len }, - {"" ,1 }}; -struct xsd_sockmsg *reply; - - reply =xenbus_msg_reply (XS_DEBUG ,0 , req,ARRAY_SIZE (req)); -printk ("Got a reply, type %d, id %d, len %d.\n" , - reply->type, reply->req_id, reply->len); -} -/* List the contents of a directory. Returns a malloc()ed array of pointers to malloc()ed strings. The array is NULL terminated. May block. */ @@ -882,6 +867,22 @@ domid_t xenbus_get_self_id(void)return ret; } +#ifdef CONFIG_TEST +/* Send a debug message to xenbus. Can block. */ +static void xenbus_debug_msg (const char *msg) +{ +int len =strlen (msg); +struct write_req req[] = { + {"print" ,sizeof ("print" ) }, + { msg, len }, + {"" ,1 }}; +struct xsd_sockmsg *reply; + + reply =xenbus_msg_reply (XS_DEBUG ,0 , req,ARRAY_SIZE (req)); +printk ("Got a reply, type %d, id %d, len %d.\n" , + reply->type, reply->req_id, reply->len); +} +static void do_ls_test (const char *pre) {char **dirs, *msg;@@ -968,6 +969,7 @@ void test_xenbus(void)do_read_test ("device/vif/0/flibble" ); printk("(Should have said ENOENT)\n"); } +#endif /* CONFIG_TEST */ /* * Local variables: Signature · 1 line
2.26.2