* [Qemu-devel] [PATCH 0/4] Introduce global config and default devices
@ 2010-01-21 18:48 Anthony Liguori
2010-01-21 18:48 ` [Qemu-devel] [PATCH 1/4] Support --confdir in configure to specify path to configuration files Anthony Liguori
` (3 more replies)
0 siblings, 4 replies; 12+ messages in thread
From: Anthony Liguori @ 2010-01-21 18:48 UTC (permalink / raw)
To: qemu-devel; +Cc: John Cooper, Gerd Hoffman
This series introduces global config files stored in /etc/qemu. There is both
a common config (qemu.conf) and a per-target config (target-<TARGET_NAME>.conf).
To demonstrate what can be done with global config, I've also made some
enhancements to the default device code that allows many of the builtin qemu
defaults to be overridden. For instance, the following config file would always
disable the monitor on stdio and use virtio-net with tun/tap instead of
slirp.
/etc/qemu/qemu.conf:
[default]
monitor = "stdio"
[net]
type = "nic"
default = "on"
model = "virtio"
[net]
type = "tap"
default = "on"
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Qemu-devel] [PATCH 1/4] Support --confdir in configure to specify path to configuration files
2010-01-21 18:48 [Qemu-devel] [PATCH 0/4] Introduce global config and default devices Anthony Liguori
@ 2010-01-21 18:48 ` Anthony Liguori
2010-01-22 12:43 ` [Qemu-devel] " Paolo Bonzini
2010-01-21 18:48 ` [Qemu-devel] [PATCH 2/4] Load global config files by default Anthony Liguori
` (2 subsequent siblings)
3 siblings, 1 reply; 12+ messages in thread
From: Anthony Liguori @ 2010-01-21 18:48 UTC (permalink / raw)
To: qemu-devel; +Cc: John Cooper, Anthony Liguori, Gerd Hoffman
The default value is ${prefix}/etc/qemu. --confdir can be used to override the
default to an absolute path. The expectation is that when installed to /usr,
--confdir=/etc/qemu will be used.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
configure | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/configure b/configure
index 5631bbb..e86b27e 100755
--- a/configure
+++ b/configure
@@ -32,6 +32,7 @@ cpu=""
prefix=""
interp_prefix="/usr/gnemul/qemu-%M"
static="no"
+confdir=""
sparc_cpu=""
cross_prefix=""
cc="gcc"
@@ -453,6 +454,8 @@ for opt do
;;
--static) static="yes"
;;
+ --confdir) confdir="$optarg"
+ ;;
--disable-sdl) sdl="no"
;;
--enable-sdl) sdl="yes"
@@ -686,6 +689,7 @@ echo " --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS"
echo " --make=MAKE use specified make [$make]"
echo " --install=INSTALL use specified install [$install]"
echo " --static enable static build [$static]"
+echo " --confdir=PATH install config in PATH"
echo " --enable-debug-tcg enable TCG debugging"
echo " --disable-debug-tcg disable TCG debugging (default)"
echo " --enable-debug enable common debug build options"
@@ -1828,6 +1832,7 @@ if test "$mingw32" = "yes" ; then
fi
mansuffix=""
datasuffix=""
+ confsuffix=""
docsuffix=""
binsuffix=""
else
@@ -1838,6 +1843,9 @@ else
datasuffix="/share/qemu"
docsuffix="/share/doc/qemu"
binsuffix="/bin"
+ if test -z "$confdir" ; then
+ confdir="${prefix}/etc/qemu"
+ fi
fi
echo "Install prefix $prefix"
@@ -1914,6 +1922,7 @@ printf " '%s'" "$0" "$@" >> $config_host_mak
echo >> $config_host_mak
echo "CONFIG_QEMU_SHAREDIR=\"$prefix$datasuffix\"" >> $config_host_mak
+echo "CONFIG_QEMU_CONFDIR=\"$confdir\"" >> $config_host_mak
case "$cpu" in
i386|x86_64|alpha|cris|hppa|ia64|m68k|microblaze|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
@@ -2159,6 +2168,7 @@ echo "prefix=$prefix" >> $config_host_mak
echo "bindir=\${prefix}$binsuffix" >> $config_host_mak
echo "mandir=\${prefix}$mansuffix" >> $config_host_mak
echo "datadir=\${prefix}$datasuffix" >> $config_host_mak
+echo "confdir=$confdir" >> $config_host_mak
echo "docdir=\${prefix}$docsuffix" >> $config_host_mak
echo "MAKE=$make" >> $config_host_mak
echo "INSTALL=$install" >> $config_host_mak
--
1.6.5.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Qemu-devel] [PATCH 2/4] Load global config files by default
2010-01-21 18:48 [Qemu-devel] [PATCH 0/4] Introduce global config and default devices Anthony Liguori
2010-01-21 18:48 ` [Qemu-devel] [PATCH 1/4] Support --confdir in configure to specify path to configuration files Anthony Liguori
@ 2010-01-21 18:48 ` Anthony Liguori
2010-01-22 10:33 ` [Qemu-devel] " Gerd Hoffmann
2010-01-21 18:48 ` [Qemu-devel] [PATCH 3/4] Add -defaults option to allow default devices to be overridden Anthony Liguori
2010-01-21 18:48 ` [Qemu-devel] [PATCH 4/4] Allow default network type " Anthony Liguori
3 siblings, 1 reply; 12+ messages in thread
From: Anthony Liguori @ 2010-01-21 18:48 UTC (permalink / raw)
To: qemu-devel; +Cc: John Cooper, Anthony Liguori, Gerd Hoffman
A new option, -nodefconfig is introduced to prevent loading from the default
config location. Otherwise, two configuration files will be searched for,
qemu.conf and target-<TARGET_NAME>.conf.
The ordering is a little troubling. Command line options are parsed before
loading the default configs which means that the command line configs will be
loaded before the default config. The effect is that the default config will
override -readconfig directives.
It's unclear the best way to handle this.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
qemu-options.hx | 7 +++++++
vl.c | 23 +++++++++++++++++++++++
2 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/qemu-options.hx b/qemu-options.hx
index ee60d8a..57f453d 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1965,6 +1965,13 @@ STEXI
@item -writeconfig @var{file}
Write device configuration to @var{file}.
ETEXI
+DEF("nodefconfig", 0, QEMU_OPTION_nodefconfig,
+ "-nodefconfig\n"
+ " do not load default config file\n")
+STEXI
+@item -nodefconfig
+Do not load default config files.
+ETEXI
HXCOMM This is the last statement. Insert new options before this line!
STEXI
diff --git a/vl.c b/vl.c
index e070ec9..cf12ab0 100644
--- a/vl.c
+++ b/vl.c
@@ -4690,6 +4690,7 @@ int main(int argc, char **argv, char **envp)
#endif
CPUState *env;
int show_vnc_port = 0;
+ int defconfig = 1;
init_clocks();
@@ -5457,6 +5458,9 @@ int main(int argc, char **argv, char **envp)
fclose(fp);
break;
}
+ case QEMU_OPTION_nodefconfig:
+ defconfig=0;
+ break;
}
}
}
@@ -5471,6 +5475,25 @@ int main(int argc, char **argv, char **envp)
data_dir = CONFIG_QEMU_SHAREDIR;
}
+ if (defconfig) {
+ FILE *fp;
+ fp = fopen(CONFIG_QEMU_CONFDIR "/qemu.conf", "r");
+ if (fp) {
+ if (qemu_config_parse(fp) != 0) {
+ exit(1);
+ }
+ fclose(fp);
+ }
+
+ fp = fopen(CONFIG_QEMU_CONFDIR "/target-" TARGET_ARCH ".conf", "r");
+ if (fp) {
+ if (qemu_config_parse(fp) != 0) {
+ exit(1);
+ }
+ fclose(fp);
+ }
+ }
+
/*
* Default to max_cpus = smp_cpus, in case the user doesn't
* specify a max_cpus value.
--
1.6.5.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Qemu-devel] [PATCH 3/4] Add -defaults option to allow default devices to be overridden
2010-01-21 18:48 [Qemu-devel] [PATCH 0/4] Introduce global config and default devices Anthony Liguori
2010-01-21 18:48 ` [Qemu-devel] [PATCH 1/4] Support --confdir in configure to specify path to configuration files Anthony Liguori
2010-01-21 18:48 ` [Qemu-devel] [PATCH 2/4] Load global config files by default Anthony Liguori
@ 2010-01-21 18:48 ` Anthony Liguori
2010-01-22 10:15 ` Markus Armbruster
2010-01-21 18:48 ` [Qemu-devel] [PATCH 4/4] Allow default network type " Anthony Liguori
3 siblings, 1 reply; 12+ messages in thread
From: Anthony Liguori @ 2010-01-21 18:48 UTC (permalink / raw)
To: qemu-devel; +Cc: John Cooper, Anthony Liguori, Gerd Hoffman
This option can be used to toggle whether each default device is enabled or
disabled. For character devices, the default backend can also be overridden.
For devices, we'll have to take a different approach to changing the defaults
which will be covered in the next patch.
N.B. I took special care with -nographic. Now -nographic pretty clearly acts
as a mechanism to override the default backend devices.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
qemu-config.c | 45 +++++++++++++++++++++++++++++++++
qemu-config.h | 1 +
qemu-options.hx | 7 +++++
vl.c | 75 +++++++++++++++++++++++++++++++++++++++++--------------
4 files changed, 109 insertions(+), 19 deletions(-)
diff --git a/qemu-config.c b/qemu-config.c
index c3203c8..82ca399 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -242,6 +242,50 @@ QemuOptsList qemu_mon_opts = {
},
};
+QemuOptsList qemu_default_opts = {
+ .name = "default",
+ .head = QTAILQ_HEAD_INITIALIZER(qemu_default_opts.head),
+ .desc = {
+ {
+ .name = "serial",
+ .type = QEMU_OPT_STRING,
+ },
+ {
+ .name = "parallel",
+ .type = QEMU_OPT_STRING,
+ },
+ {
+ .name = "virtcon",
+ .type = QEMU_OPT_STRING,
+ },
+ {
+ .name = "monitor",
+ .type = QEMU_OPT_STRING,
+ },
+ {
+ .name = "vga",
+ .type = QEMU_OPT_BOOL,
+ },
+ {
+ .name = "net",
+ .type = QEMU_OPT_BOOL,
+ },
+ {
+ .name = "floppy",
+ .type = QEMU_OPT_BOOL,
+ },
+ {
+ .name = "cdrom",
+ .type = QEMU_OPT_BOOL,
+ },
+ {
+ .name = "sdcard",
+ .type = QEMU_OPT_BOOL,
+ },
+ { /* end if list */ }
+ },
+};
+
static QemuOptsList *lists[] = {
&qemu_drive_opts,
&qemu_chardev_opts,
@@ -250,6 +294,7 @@ static QemuOptsList *lists[] = {
&qemu_net_opts,
&qemu_rtc_opts,
&qemu_global_opts,
+ &qemu_default_opts,
&qemu_mon_opts,
NULL,
};
diff --git a/qemu-config.h b/qemu-config.h
index dd89ae4..14ed67b 100644
--- a/qemu-config.h
+++ b/qemu-config.h
@@ -9,6 +9,7 @@ extern QemuOptsList qemu_net_opts;
extern QemuOptsList qemu_rtc_opts;
extern QemuOptsList qemu_global_opts;
extern QemuOptsList qemu_mon_opts;
+extern QemuOptsList qemu_default_opts;
int qemu_set_option(const char *str);
int qemu_global_option(const char *str);
diff --git a/qemu-options.hx b/qemu-options.hx
index 57f453d..e81ecb5 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1919,6 +1919,13 @@ STEXI
Don't create default devices.
ETEXI
+DEF("default", HAS_ARG, QEMU_OPTION_default, \
+ "-default arg specify default devices\n")
+STEXI
+@item -defaults
+Override builtin default devices
+ETEXI
+
#ifndef _WIN32
DEF("chroot", HAS_ARG, QEMU_OPTION_chroot, \
"-chroot dir chroot to dir just before starting the VM\n")
diff --git a/vl.c b/vl.c
index cf12ab0..6a3529e 100644
--- a/vl.c
+++ b/vl.c
@@ -280,6 +280,11 @@ static int default_floppy = 1;
static int default_cdrom = 1;
static int default_sdcard = 1;
+static const char *default_serial_opt = "vc:80Cx24C";
+static const char *default_parallel_opt = "vc:80Cx24C";
+static const char *default_monitor_opt = "vc:80Cx24C";
+static const char *default_virtcon_opt = "vc:80Cx24C";
+
static struct {
const char *driver;
int *flag;
@@ -4658,6 +4663,32 @@ static int debugcon_parse(const char *devname)
return 0;
}
+static int default_opt_init(QemuOpts *opts, void *dummy)
+{
+ const char *opt;
+
+ if ((opt = qemu_opt_get(opts, "serial"))) {
+ default_serial_opt = opt;
+ }
+ if ((opt = qemu_opt_get(opts, "parallel"))) {
+ default_parallel_opt = opt;
+ }
+ if ((opt = qemu_opt_get(opts, "virtcon"))) {
+ default_virtcon_opt = opt;
+ }
+ if ((opt = qemu_opt_get(opts, "monitor"))) {
+ default_monitor_opt = opt;
+ }
+
+ default_vga = qemu_opt_get_bool(opts, "vga", default_vga);
+ default_net = qemu_opt_get_bool(opts, "net", default_net);
+ default_floppy = qemu_opt_get_bool(opts, "floppy", default_floppy);
+ default_cdrom = qemu_opt_get_bool(opts, "cdrom", default_cdrom);
+ default_sdcard = qemu_opt_get_bool(opts, "sdcard", default_sdcard);
+
+ return 0;
+}
+
int main(int argc, char **argv, char **envp)
{
const char *gdbstub_dev = NULL;
@@ -5409,6 +5440,13 @@ int main(int argc, char **argv, char **envp)
default_cdrom = 0;
default_sdcard = 0;
break;
+ case QEMU_OPTION_default:
+ opts = qemu_opts_parse(&qemu_default_opts, optarg, NULL);
+ if (!opts) {
+ fprintf(stderr, "parse error: %s\n", optarg);
+ exit(1);
+ }
+ break;
#ifndef _WIN32
case QEMU_OPTION_chroot:
chroot_dir = optarg;
@@ -5509,6 +5547,7 @@ int main(int argc, char **argv, char **envp)
exit(1);
}
+ qemu_opts_foreach(&qemu_default_opts, default_opt_init, NULL, 0);
qemu_opts_foreach(&qemu_device_opts, default_driver_check, NULL, 0);
qemu_opts_foreach(&qemu_global_opts, default_driver_check, NULL, 0);
@@ -5535,30 +5574,28 @@ int main(int argc, char **argv, char **envp)
}
if (display_type == DT_NOGRAPHIC) {
- if (default_parallel)
- add_device_config(DEV_PARALLEL, "null");
+ default_parallel_opt = "null";
+
if (default_serial && default_monitor) {
- add_device_config(DEV_SERIAL, "mon:stdio");
+ default_serial_opt = "mon:stdio";
} else if (default_virtcon && default_monitor) {
- add_device_config(DEV_VIRTCON, "mon:stdio");
+ default_virtcon_opt = "mon:stdio";
} else {
- if (default_serial)
- add_device_config(DEV_SERIAL, "stdio");
- if (default_virtcon)
- add_device_config(DEV_VIRTCON, "stdio");
- if (default_monitor)
- monitor_parse("stdio", "readline");
+ default_serial_opt = "stdio";
+ default_virtcon_opt = "stdio";
+ default_monitor_opt = "stdio";
}
- } else {
- if (default_serial)
- add_device_config(DEV_SERIAL, "vc:80Cx24C");
- if (default_parallel)
- add_device_config(DEV_PARALLEL, "vc:80Cx24C");
- if (default_monitor)
- monitor_parse("vc:80Cx24C", "readline");
- if (default_virtcon)
- add_device_config(DEV_VIRTCON, "vc:80Cx24C");
}
+
+ if (default_serial)
+ add_device_config(DEV_SERIAL, default_serial_opt);
+ if (default_parallel)
+ add_device_config(DEV_PARALLEL, default_parallel_opt);
+ if (default_monitor)
+ monitor_parse(default_monitor_opt, "readline");
+ if (default_virtcon)
+ add_device_config(DEV_VIRTCON, default_virtcon_opt);
+
if (default_vga)
vga_interface_type = VGA_CIRRUS;
--
1.6.5.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Qemu-devel] [PATCH 4/4] Allow default network type to be overridden
2010-01-21 18:48 [Qemu-devel] [PATCH 0/4] Introduce global config and default devices Anthony Liguori
` (2 preceding siblings ...)
2010-01-21 18:48 ` [Qemu-devel] [PATCH 3/4] Add -defaults option to allow default devices to be overridden Anthony Liguori
@ 2010-01-21 18:48 ` Anthony Liguori
2010-01-22 11:00 ` [Qemu-devel] " Gerd Hoffmann
3 siblings, 1 reply; 12+ messages in thread
From: Anthony Liguori @ 2010-01-21 18:48 UTC (permalink / raw)
To: qemu-devel; +Cc: John Cooper, Anthony Liguori, Gerd Hoffman
Introduce a default option to the network device which specifies that this is
a default network device. This approach should generalize to any other device.
The meaning of a default device is as follows: a default device is added to a
machine IIF defaults aren't disable (via -default or -nodefaults) and a
non-default device of this type hasn't been added.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
net.c | 42 +++++++++++++++++++++++++++++++++++++-----
1 files changed, 37 insertions(+), 5 deletions(-)
diff --git a/net.c b/net.c
index 6ef93e6..1aa3c77 100644
--- a/net.c
+++ b/net.c
@@ -833,6 +833,10 @@ static int net_init_nic(QemuOpts *opts,
.name = "name", \
.type = QEMU_OPT_STRING, \
.help = "identifier for monitor commands", \
+ }, { \
+ .name = "default", \
+ .type = QEMU_OPT_BOOL, \
+ .help = "act as default network device", \
}
typedef int (*net_client_init_func)(QemuOpts *opts,
@@ -1056,6 +1060,15 @@ int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev)
const char *type;
int i;
+ /* Do not create default network devices if no defaults */
+ if (!default_net) {
+ const char *opt = qemu_opt_get(opts, "default");
+
+ if (opt && strcmp(opt, "on") == 0) {
+ return 0;
+ }
+ }
+
type = qemu_opt_get(opts, "type");
if (!is_netdev) {
@@ -1320,10 +1333,22 @@ static int net_init_netdev(QemuOpts *opts, void *dummy)
int net_init_clients(void)
{
if (default_net) {
- /* if no clients, we use a default config */
- qemu_opts_set(&qemu_net_opts, NULL, "type", "nic");
+ QemuOpts *opts;
+
+ opts = qemu_opts_create(&qemu_net_opts, NULL, 1);
+ if (opts == NULL) {
+ return -1;
+ }
+ qemu_opt_set(opts, "type", "nic");
+ qemu_opt_set(opts, "default", "on");
+
#ifdef CONFIG_SLIRP
- qemu_opts_set(&qemu_net_opts, NULL, "type", "user");
+ opts = qemu_opts_create(&qemu_net_opts, NULL, 1);
+ if (opts == NULL) {
+ return -1;
+ }
+ qemu_opt_set(opts, "type", "user");
+ qemu_opt_set(opts, "default", "on");
#endif
}
@@ -1344,6 +1369,8 @@ int net_init_clients(void)
int net_client_parse(QemuOptsList *opts_list, const char *optarg)
{
+ QemuOpts *opts;
+ const char *opt;
#if defined(CONFIG_SLIRP)
int ret;
if (net_slirp_parse_legacy(opts_list, optarg, &ret)) {
@@ -1351,10 +1378,15 @@ int net_client_parse(QemuOptsList *opts_list, const char *optarg)
}
#endif
- if (!qemu_opts_parse(opts_list, optarg, "type")) {
+ opts = qemu_opts_parse(opts_list, optarg, "type");
+ if (opts == NULL) {
return -1;
}
- default_net = 0;
+ opt = qemu_opt_get(opts, "default");
+ if (!opt || strcmp(opt, "off") == 0) {
+ default_net = 0;
+ }
+
return 0;
}
--
1.6.5.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [Qemu-devel] [PATCH 3/4] Add -defaults option to allow default devices to be overridden
2010-01-21 18:48 ` [Qemu-devel] [PATCH 3/4] Add -defaults option to allow default devices to be overridden Anthony Liguori
@ 2010-01-22 10:15 ` Markus Armbruster
2010-01-22 15:45 ` Anthony Liguori
0 siblings, 1 reply; 12+ messages in thread
From: Markus Armbruster @ 2010-01-22 10:15 UTC (permalink / raw)
To: Anthony Liguori; +Cc: John Cooper, qemu-devel, Gerd Hoffman
Anthony Liguori <aliguori@us.ibm.com> writes:
> This option can be used to toggle whether each default device is enabled or
> disabled. For character devices, the default backend can also be overridden.
>
> For devices, we'll have to take a different approach to changing the defaults
> which will be covered in the next patch.
>
> N.B. I took special care with -nographic. Now -nographic pretty clearly acts
> as a mechanism to override the default backend devices.
>
> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
> ---
> qemu-config.c | 45 +++++++++++++++++++++++++++++++++
> qemu-config.h | 1 +
> qemu-options.hx | 7 +++++
> vl.c | 75 +++++++++++++++++++++++++++++++++++++++++--------------
> 4 files changed, 109 insertions(+), 19 deletions(-)
>
> diff --git a/qemu-config.c b/qemu-config.c
> index c3203c8..82ca399 100644
> --- a/qemu-config.c
> +++ b/qemu-config.c
> @@ -242,6 +242,50 @@ QemuOptsList qemu_mon_opts = {
> },
> };
>
> +QemuOptsList qemu_default_opts = {
> + .name = "default",
> + .head = QTAILQ_HEAD_INITIALIZER(qemu_default_opts.head),
> + .desc = {
> + {
> + .name = "serial",
> + .type = QEMU_OPT_STRING,
> + },
[...]
> diff --git a/qemu-options.hx b/qemu-options.hx
> index 57f453d..e81ecb5 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -1919,6 +1919,13 @@ STEXI
> Don't create default devices.
> ETEXI
>
> +DEF("default", HAS_ARG, QEMU_OPTION_default, \
> + "-default arg specify default devices\n")
Isn't this too terse?
> +STEXI
> +@item -defaults
> +Override builtin default devices
> +ETEXI
This *is* too terse :)
Oh, and it's -default (sans 's'). Same typo in subject.
While we're talking about naming: isn't -default a bit too generic a
name for something that manipulates devices? Not sure we care, as
-nodefaults is much worse, already.
[...]
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Qemu-devel] Re: [PATCH 2/4] Load global config files by default
2010-01-21 18:48 ` [Qemu-devel] [PATCH 2/4] Load global config files by default Anthony Liguori
@ 2010-01-22 10:33 ` Gerd Hoffmann
0 siblings, 0 replies; 12+ messages in thread
From: Gerd Hoffmann @ 2010-01-22 10:33 UTC (permalink / raw)
To: Anthony Liguori; +Cc: John Cooper, qemu-devel
On 01/21/10 19:48, Anthony Liguori wrote:
> The ordering is a little troubling. Command line options are parsed before
> loading the default configs which means that the command line configs will be
> loaded before the default config. The effect is that the default config will
> override -readconfig directives.
>
> It's unclear the best way to handle this.
Maybe we need two passes over the command line options?
-confdir and -nodefconfig switches would be handled in the first pass,
then read the global config files (unless disabled), then the second pass.
I think we could also make the default device handling less messy that
way by checking -nographic and -nodefaults in the first pass too.
Having the machine type (-M) read in the first pass could allow some
cleanups too.
cheers,
Gerd
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Qemu-devel] Re: [PATCH 4/4] Allow default network type to be overridden
2010-01-21 18:48 ` [Qemu-devel] [PATCH 4/4] Allow default network type " Anthony Liguori
@ 2010-01-22 11:00 ` Gerd Hoffmann
2010-01-22 14:44 ` Anthony Liguori
0 siblings, 1 reply; 12+ messages in thread
From: Gerd Hoffmann @ 2010-01-22 11:00 UTC (permalink / raw)
To: Anthony Liguori; +Cc: John Cooper, qemu-devel
On 01/21/10 19:48, Anthony Liguori wrote:
> Introduce a default option to the network device which specifies that this is
> a default network device. This approach should generalize to any other device.
> The meaning of a default device is as follows: a default device is added to a
> machine IIF defaults aren't disable (via -default or -nodefaults) and a
> non-default device of this type hasn't been added.
I don't like the idea to have two different mechanisms for configuring
defaults ([default] section + default = "on"). I'd suggest to pick one
and apply it everythere.
cheers,
Gerd
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Qemu-devel] Re: [PATCH 1/4] Support --confdir in configure to specify path to configuration files
2010-01-21 18:48 ` [Qemu-devel] [PATCH 1/4] Support --confdir in configure to specify path to configuration files Anthony Liguori
@ 2010-01-22 12:43 ` Paolo Bonzini
2010-01-22 14:39 ` Anthony Liguori
0 siblings, 1 reply; 12+ messages in thread
From: Paolo Bonzini @ 2010-01-22 12:43 UTC (permalink / raw)
To: Anthony Liguori; +Cc: John Cooper, qemu-devel, Gerd Hoffman
On 01/21/2010 07:48 PM, Anthony Liguori wrote:
> --confdir can be used to override the
> default to an absolute path. The expectation is that when installed to /usr,
> --confdir=/etc/qemu will be used.
Why not --sysconfdir? There are already several differences between
Autoconf options and QEMU configure options, however unlike the others
this one would be used by basically all distros.
Paolo
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Qemu-devel] Re: [PATCH 1/4] Support --confdir in configure to specify path to configuration files
2010-01-22 12:43 ` [Qemu-devel] " Paolo Bonzini
@ 2010-01-22 14:39 ` Anthony Liguori
0 siblings, 0 replies; 12+ messages in thread
From: Anthony Liguori @ 2010-01-22 14:39 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: John Cooper, Anthony Liguori, qemu-devel, Gerd Hoffman
On 01/22/2010 06:43 AM, Paolo Bonzini wrote:
> On 01/21/2010 07:48 PM, Anthony Liguori wrote:
>> --confdir can be used to override the
>> default to an absolute path. The expectation is that when installed
>> to /usr,
>> --confdir=/etc/qemu will be used.
>
> Why not --sysconfdir? There are already several differences between
> Autoconf options and QEMU configure options, however unlike the others
> this one would be used by basically all distros.
Wasn't 100% sure on the proper naming. sysconfdir works for me.
Regards,
Anthony Liguori
> Paolo
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Qemu-devel] Re: [PATCH 4/4] Allow default network type to be overridden
2010-01-22 11:00 ` [Qemu-devel] " Gerd Hoffmann
@ 2010-01-22 14:44 ` Anthony Liguori
0 siblings, 0 replies; 12+ messages in thread
From: Anthony Liguori @ 2010-01-22 14:44 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: John Cooper, qemu-devel
On 01/22/2010 05:00 AM, Gerd Hoffmann wrote:
> On 01/21/10 19:48, Anthony Liguori wrote:
>> Introduce a default option to the network device which specifies that
>> this is
>> a default network device. This approach should generalize to any
>> other device.
>
>> The meaning of a default device is as follows: a default device is
>> added to a
>> machine IIF defaults aren't disable (via -default or -nodefaults) and a
>> non-default device of this type hasn't been added.
>
> I don't like the idea to have two different mechanisms for configuring
> defaults ([default] section + default = "on"). I'd suggest to pick
> one and apply it everythere.
I agree that it's awkward. Need to think a bit about it.
Regards,
Anthony Liguori
> cheers,
> Gerd
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Qemu-devel] [PATCH 3/4] Add -defaults option to allow default devices to be overridden
2010-01-22 10:15 ` Markus Armbruster
@ 2010-01-22 15:45 ` Anthony Liguori
0 siblings, 0 replies; 12+ messages in thread
From: Anthony Liguori @ 2010-01-22 15:45 UTC (permalink / raw)
To: Markus Armbruster; +Cc: John Cooper, qemu-devel, Gerd Hoffman
On 01/22/2010 04:15 AM, Markus Armbruster wrote:
> Anthony Liguori<aliguori@us.ibm.com> writes:
>
>
>> This option can be used to toggle whether each default device is enabled or
>> disabled. For character devices, the default backend can also be overridden.
>>
>> For devices, we'll have to take a different approach to changing the defaults
>> which will be covered in the next patch.
>>
>> N.B. I took special care with -nographic. Now -nographic pretty clearly acts
>> as a mechanism to override the default backend devices.
>>
>> Signed-off-by: Anthony Liguori<aliguori@us.ibm.com>
>> ---
>> qemu-config.c | 45 +++++++++++++++++++++++++++++++++
>> qemu-config.h | 1 +
>> qemu-options.hx | 7 +++++
>> vl.c | 75 +++++++++++++++++++++++++++++++++++++++++--------------
>> 4 files changed, 109 insertions(+), 19 deletions(-)
>>
>> diff --git a/qemu-config.c b/qemu-config.c
>> index c3203c8..82ca399 100644
>> --- a/qemu-config.c
>> +++ b/qemu-config.c
>> @@ -242,6 +242,50 @@ QemuOptsList qemu_mon_opts = {
>> },
>> };
>>
>> +QemuOptsList qemu_default_opts = {
>> + .name = "default",
>> + .head = QTAILQ_HEAD_INITIALIZER(qemu_default_opts.head),
>> + .desc = {
>> + {
>> + .name = "serial",
>> + .type = QEMU_OPT_STRING,
>> + },
>>
> [...]
>
>> diff --git a/qemu-options.hx b/qemu-options.hx
>> index 57f453d..e81ecb5 100644
>> --- a/qemu-options.hx
>> +++ b/qemu-options.hx
>> @@ -1919,6 +1919,13 @@ STEXI
>> Don't create default devices.
>> ETEXI
>>
>> +DEF("default", HAS_ARG, QEMU_OPTION_default, \
>> + "-default arg specify default devices\n")
>>
> Isn't this too terse?
>
Yes. Thanks for pointing that out.
>> +STEXI
>> +@item -defaults
>> +Override builtin default devices
>> +ETEXI
>>
> This *is* too terse :)
>
> Oh, and it's -default (sans 's'). Same typo in subject.
>
> While we're talking about naming: isn't -default a bit too generic a
> name for something that manipulates devices? Not sure we care, as
> -nodefaults is much worse, already.
>
Absolutely. I'm going to split out the config loading bits because they
should be easy to commit. How to best handle defaults could use some
more thought. I think this is a key bit of functionality to get right
though because it solves a whole class of problems relating to upstream
policy vs. downstream policy.
I very much like the idea of having a qdev property 'default' to signify
that this is a default device. It means we could easily allow a user to
universally enable usb devices, etc without baking a default_usb concept
into qemu. Ideally, we could eliminate the whole default mess we have
today by doing this, provided that we can implement the right semantics.
Today, those semantics are, if we specify any device of the same
"class", do not load default devices of that class. It's unclear how to
specify the concept of a "class" though. I know Gerd brought this up
ages ago and both Paul and I were very opposed to it but I certainly
appreciate the fact that it would simplify default device handling.
It's definitely clear that each device needs to be able to be part of
multiple default-class's. We could potentially introduce a qdev
property and label every device with a class array but that's a lot of
ugliness just to support defaults. I still would prefer that there was
a more discoverable way to determine the class of a device as opposed to
explicitly labelling it.
If we need to do class tagging, I guess it's not the end of the world...
Regards,
Anthony Liguori
> [...]
>
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2010-01-22 15:46 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-21 18:48 [Qemu-devel] [PATCH 0/4] Introduce global config and default devices Anthony Liguori
2010-01-21 18:48 ` [Qemu-devel] [PATCH 1/4] Support --confdir in configure to specify path to configuration files Anthony Liguori
2010-01-22 12:43 ` [Qemu-devel] " Paolo Bonzini
2010-01-22 14:39 ` Anthony Liguori
2010-01-21 18:48 ` [Qemu-devel] [PATCH 2/4] Load global config files by default Anthony Liguori
2010-01-22 10:33 ` [Qemu-devel] " Gerd Hoffmann
2010-01-21 18:48 ` [Qemu-devel] [PATCH 3/4] Add -defaults option to allow default devices to be overridden Anthony Liguori
2010-01-22 10:15 ` Markus Armbruster
2010-01-22 15:45 ` Anthony Liguori
2010-01-21 18:48 ` [Qemu-devel] [PATCH 4/4] Allow default network type " Anthony Liguori
2010-01-22 11:00 ` [Qemu-devel] " Gerd Hoffmann
2010-01-22 14:44 ` Anthony Liguori
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).