Move CPU model config file to /usr/share
RFC PATCH 2/3 implement -readconfig help=defconfig option
In reply to Eduardo HabkostThis method will list the paths of all default config files.
This is where the placement of qemu_read_config_arg() on qemu-config-arch.c becomes necessary: we have to use the list of config files to implement the new help option.
--- qemu-config-arch.c | 27 ++++++++++++++++++++++++++- 1 files changed, 26 insertions(+), 1 deletions(-)
qemu-config-arch.c +26 -1
@@ -41,6 +41,10 @@ static QemuOptsList qemu_readconfig_opts = { .name = "fd", .type = QEMU_OPT_NUMBER, }, + { + .name = "help", + .type = QEMU_OPT_STRING, + }, {/*End of list */ } }, };
@@ -70,6 +74,22 @@ static struct DefaultConfigFile arch_default_configs[] = { {NULL, NULL}, }; +/* print -readconfig help information +*/ +static void readconfig_help (const char *arg) +{ +if (!strcmp (arg,"defconfig" )) { +const struct DefaultConfigFile *cfg; +printf ("Default config files:\n" ); +for (cfg = arch_default_configs; cfg->path; cfg++) { +printf ("\t%s:\t%s\n" , cfg->type, cfg->path); + } + }else { +fprintf (stderr,"Invalid readconfig help option: %s\n" , arg); +exit (1 ); + } +} +/* Read Qemu config file based on parsed QemuOpts object * * Returns 0 on success, -errno on failure.
@@ -79,12 +99,17 @@ static int qemu_read_config_opts(QemuOpts *opts)int fd =-1 ;uint64_t fd_arg =qemu_opt_get_number (opts,"fd" , (uint64_t )-1 );const char *path =qemu_opt_get (opts,"path" ); +const char *help =qemu_opt_get (opts,"help" ); +if (fd_arg != (uint64_t )-1 ) { fd = fd_arg; } -if (path) { +if (help) { +readconfig_help (help); +exit (0 ); + }else if (path) {return qemu_read_config_filename (path); }else if (fd >=0 ) {return qemu_read_config_fd (fd);
Signature · 1 line
1.7.3.2
cover Move CPU model config file to /usr/share
This is a RFC, but I really want to include this on Qemu 1.1.
This will allow libvirt to reuse our CPU defs starting on Qemu 1.1, and will give us some freedom to change the syntax and semantics of the cpudef sections, as long as we keep the config file at the same place.
Making this change earlier will benefit users that use Qemu directly but simply want to use the default CPU models (they won't have to update their config files on /etc once we change the way cpudefs work), and libvirt, that will finally be able to reuse the existing CPU models.
This series should be applied on top of both the "./configure --confdir" and the "-readconfig fd=<fd>" series I submitted earlier today.
Eduardo Habkost (3):
move list of default config files to qemu-config-arch.c implement -readconfig help=defconfig option
move cpudef config sections to /usr/share/qemu/cpudefs-x86_64.conf
Makefile | 2 + arch_init.c | 1 - arch_init.h | 2 - qemu-config-arch.c | 68 +++++++++++++++++- qemu-config-arch.h | 4 + sysconfigs/target/cpudefs-x86_64.conf | 127 ++++++++++++++++++++++++++++++++ sysconfigs/target/target-x86_64.conf | 128 --------------------------------- vl.c | 12 +--- 8 files changed, 203 insertions(+), 141 deletions(-) create mode 100644 sysconfigs/target/cpudefs-x86_64.conf
Signature · 1 line
1.7.3.2
RFC PATCH 3/3 move cpudef config sections to /usr/share/qemu/cpudefs-x86_64.conf
Motivations are:
1) Make the cpudefs reusable by the managment system if it wants to, so it doesn't need to write cpudefs from scratch. Putting them on /usr/share lets management reuse them without being affected by user configuration on /etc.
I expect libvirt to do something equivalent to:
$ cpuconf=$(qemu-system-x86_64 -readconfig help=defconfig | grep cpudefs: | cut -f3) $ qemu-system-x86_64 -nodefconfig -readconfig path=$cpuconf [...]
Note that '-readconfig help=defconfig' is just an example. A more machine-friendly querying mechanism may be provided later.
2) We need to be able to deploy fixes to existing CPU definitions if necessary, but to make that possible, the cpu definitions shouldn't be copied and edited directly, but extended on config files on /etc (or on the command-line) if necessary.
Note that the syntax or semantics of the cpudef section may change in the future. This patch will make sure management systems can reuse the cpudefs today using -readconfig, without worrying about how the cpudef config syntax works.
As agreed on previous discussions, -nodefconfig will disable the loading of this file, as expected.
--- Makefile | 2 + qemu-config-arch.c | 5 ++ sysconfigs/target/cpudefs-x86_64.conf | 127 ++++++++++++++++++++++++++++++++ sysconfigs/target/target-x86_64.conf | 128 --------------------------------- 4 files changed, 134 insertions(+), 128 deletions(-) create mode 100644 sysconfigs/target/cpudefs-x86_64.conf
Makefile +2 -0
@@ -281,6 +281,8 @@ endif install-sysconfig: $(INSTALL_DIR) "$(DESTDIR)$(confdir)" $(INSTALL_DATA) $(SRC_PATH)/sysconfigs/target/target-x86_64.conf "$(DESTDIR)$(confdir)" + $(INSTALL_DIR) "$(DESTDIR)$(datadir)" + $(INSTALL_DATA) "$(SRC_PATH)/sysconfigs/target/cpudefs-x86_64.conf" "$(DESTDIR)$(datadir)" install: all $(if $(BUILD_DOCS),install-doc) install-sysconfig $(INSTALL_DIR) "$(DESTDIR)$(bindir)"
qemu-config-arch.c +5 -0
@@ -51,6 +51,7 @@ static QemuOptsList qemu_readconfig_opts = {#define MAIN_CONFIG_NAME (CONFIG_QEMU_CONFDIR "/qemu.conf")#define ARCH_CONFIG_NAME (CONFIG_QEMU_CONFDIR "/target-" TARGET_ARCH ".conf") +#define CPUDEFS_CONFIG_NAME (CONFIG_QEMU_DATADIR "/cpudefs-" TARGET_ARCH ".conf")/* List of default config files */
@@ -64,6 +65,10 @@ struct DefaultConfigFile { };static struct DefaultConfigFile arch_default_configs[] = { +/* not commonly edited config files with defaults, from /usr/share: */ +/* CPU models: */ + {"cpudefs" ,CPUDEFS_CONFIG_NAME }, +/* user-editable config files from /etc: */ /* Main, generic config file: */ {"main" ,MAIN_CONFIG_NAME },
sysconfigs/target/cpudefs-x86_64.conf new file +127 -0
127 lines not on this page · raw message
sysconfigs/target/target-x86_64.conf +0 -128
128 lines not on this page · raw message
Signature · 1 line
1.7.3.2
RFC PATCH 1/3 move list of default config files to qemu-config-arch.c
In reply to Eduardo HabkostMove the list to an array, with a "type" field to identify the config file purpose/type.
--- arch_init.c | 1 - arch_init.h | 2 -- qemu-config-arch.c | 36 ++++++++++++++++++++++++++++++++++++ qemu-config-arch.h | 4 ++++ vl.c | 12 +++--------- 5 files changed, 43 insertions(+), 12 deletions(-)
arch_init.c +0 -1
@@ -54,7 +54,6 @@ int graphic_height = 600;int graphic_depth =15 ;#endif -const char arch_config_name[] =CONFIG_QEMU_CONFDIR "/target-" TARGET_ARCH ".conf" ;#if defined(TARGET_ALPHA )#define QEMU_ARCH QEMU_ARCH_ALPHA
arch_init.h +0 -2
@@ -1,8 +1,6 @@#ifndef QEMU_ARCH_INIT_H #define QEMU_ARCH_INIT_H -extern const char arch_config_name[]; -enum {QEMU_ARCH_ALL =-1 , QEMU_ARCH_ALPHA = 1,
qemu-config-arch.c +36 -0
@@ -45,6 +45,30 @@ static QemuOptsList qemu_readconfig_opts = { }, }; +#define MAIN_CONFIG_NAME (CONFIG_QEMU_CONFDIR "/qemu.conf") +#define ARCH_CONFIG_NAME (CONFIG_QEMU_CONFDIR "/target-" TARGET_ARCH ".conf") + +/* List of default config files +*/ +struct DefaultConfigFile { +/* Identifier to the default config file. +*/ +const char *type; +/* Config file path +*/ +const char *path; +}; + +static struct DefaultConfigFile arch_default_configs[] = { +/* user-editable config files from /etc: */ +/* Main, generic config file: */ + {"main" ,MAIN_CONFIG_NAME }, +/* Arch-specific config file: */ + {"arch" ,ARCH_CONFIG_NAME }, + +/* end of list */ + {NULL ,NULL }, +};/* Read Qemu config file based on parsed QemuOpts object *
@@ -84,3 +108,15 @@ int qemu_read_config_arg(const char *arg)qemu_opts_del (opts);return r; } + +int qemu_read_default_configs (void ) +{ +const struct DefaultConfigFile *cfg; +for (cfg = arch_default_configs; cfg->path; cfg++) { +int ret =qemu_read_config_filename (cfg->path); +if (ret <0 && ret != -ENOENT ) { +return ret; + } + } +return 0 ; +}
qemu-config-arch.h +4 -0
@@ -12,4 +12,8 @@*/ int qemu_read_config_arg (const char *arg); +/* Read default config files for the architecture +*/ +int qemu_read_default_configs (void ); +#endif /* QEMU_CONFIG_ARCH_H */
vl.c +3 -9
@@ -2350,15 +2350,9 @@ int main(int argc, char **argv, char **envp) }if (defconfig) { -int ret; - - ret =qemu_read_config_filename (CONFIG_QEMU_CONFDIR "/qemu.conf" ); -if (ret <0 && ret != -ENOENT ) { -exit (1 ); - } - - ret =qemu_read_config_filename (arch_config_name); -if (ret <0 && ret != -ENOENT ) { +int ret =qemu_read_default_configs (); +if (ret <0 ) { +fprintf (stderr,"error loading default config files: %s" ,strerror (ret));exit (1 ); } }
Signature · 1 line
1.7.3.2