Patchwork [qemu,5/6] implement -no-user-config command-line option (v3)

login
register
mail settings
Submitter Eduardo Habkost
Date May 2, 2012, 4:07 p.m.
Message ID <1335974850-30180-6-git-send-email-ehabkost@redhat.com>
Download mbox | patch
Permalink /patch/156486/
State New
Headers show

Comments

Eduardo Habkost - May 2, 2012, 4:07 p.m.
Changes v2 -> v3:
 - Rebase against latest qemu.git

Changes v1 -> v2:
 - Change 'userconfig' field/variables to bool instead of int
 - Coding style change

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 arch_init.c     |   11 ++++++++---
 qemu-config.h   |    2 +-
 qemu-options.hx |   16 +++++++++++++---
 vl.c            |    6 +++++-
 4 files changed, 27 insertions(+), 8 deletions(-)
Andreas Färber - May 27, 2012, 2:02 p.m.
Am 02.05.2012 18:07, schrieb Eduardo Habkost:
> Changes v2 -> v3:
>  - Rebase against latest qemu.git
> 
> Changes v1 -> v2:
>  - Change 'userconfig' field/variables to bool instead of int
>  - Coding style change
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
>  arch_init.c     |   11 ++++++++---
>  qemu-config.h   |    2 +-
>  qemu-options.hx |   16 +++++++++++++---
>  vl.c            |    6 +++++-
>  4 files changed, 27 insertions(+), 8 deletions(-)
> 
> diff --git a/arch_init.c b/arch_init.c
> index 62332e9..996baba 100644
> --- a/arch_init.c
> +++ b/arch_init.c
> @@ -114,19 +114,24 @@ const uint32_t arch_type = QEMU_ARCH;
>  
>  static struct defconfig_file {
>      const char *filename;
> +    /* Indicates it is an user config file (disabled by -no-user-config) */
> +    bool userconfig;
>  } default_config_files[] = {
> -    { CONFIG_QEMU_CONFDIR "/qemu.conf" },
> -    { CONFIG_QEMU_CONFDIR "/target-" TARGET_ARCH ".conf" },
> +    { CONFIG_QEMU_CONFDIR "/qemu.conf",                   true },
> +    { CONFIG_QEMU_CONFDIR "/target-" TARGET_ARCH ".conf", true },
>      { NULL }, /* end of list */
>  };
>  
>  
> -int qemu_read_default_config_files(void)
> +int qemu_read_default_config_files(bool userconfig)

These changes broke the build on Darwin/ppc(64).

Just before this block there's an inclusion of altivec.h, which does
#define bool __bool
for powerpc-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5493).

  CC    i386-softmmu/arch_init.o
/Users/andreas/QEMU/qemu/arch_init.c:120: error: incompatible types in
initialization
/Users/andreas/QEMU/qemu/arch_init.c:121: error: incompatible types in
initialization
/Users/andreas/QEMU/qemu/arch_init.c:122: error: incompatible types in
initialization
/Users/andreas/QEMU/qemu/arch_init.c:128: error: conflicting types for
'qemu_read_default_config_files'
/Users/andreas/QEMU/qemu/qemu-config.h:21: error: previous declaration
of 'qemu_read_default_config_files' was here
/Users/andreas/QEMU/qemu/arch_init.c: In function
'qemu_read_default_config_files':
/Users/andreas/QEMU/qemu/arch_init.c:133: error: wrong type argument to
unary exclamation mark
/Users/andreas/QEMU/qemu/arch_init.c:133: error: invalid operands to
binary && (have 'int' and '__vector __bool int')
make[1]: *** [arch_init.o] Error 1
make: *** [subdir-i386-softmmu] Error 2

Any suggestion how to fix?

Andreas
Paolo Bonzini - May 28, 2012, 6:35 a.m.
Il 27/05/2012 16:02, Andreas Färber ha scritto:
> Any suggestion how to fix?

Does it work to "typedef _Bool __bool" before including altivec.h (and
in the same #ifdef)?

Paolo
Andreas Färber - May 28, 2012, 1:56 p.m.
Am 28.05.2012 08:35, schrieb Paolo Bonzini:
> Il 27/05/2012 16:02, Andreas Färber ha scritto:
>> Any suggestion how to fix?

Sorry, I forgot to reply here that I've sent a patch.

> Does it work to "typedef _Bool __bool" before including altivec.h (and
> in the same #ifdef)?

Haven't tried but I'm afraid of what side effects that may have...
I feel more comfortable sticking to the POSIX #define bool _Bool rule.

Andreas

Patch

diff --git a/arch_init.c b/arch_init.c
index 62332e9..996baba 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -114,19 +114,24 @@  const uint32_t arch_type = QEMU_ARCH;
 
 static struct defconfig_file {
     const char *filename;
+    /* Indicates it is an user config file (disabled by -no-user-config) */
+    bool userconfig;
 } default_config_files[] = {
-    { CONFIG_QEMU_CONFDIR "/qemu.conf" },
-    { CONFIG_QEMU_CONFDIR "/target-" TARGET_ARCH ".conf" },
+    { CONFIG_QEMU_CONFDIR "/qemu.conf",                   true },
+    { CONFIG_QEMU_CONFDIR "/target-" TARGET_ARCH ".conf", true },
     { NULL }, /* end of list */
 };
 
 
-int qemu_read_default_config_files(void)
+int qemu_read_default_config_files(bool userconfig)
 {
     int ret;
     struct defconfig_file *f;
 
     for (f = default_config_files; f->filename; f++) {
+        if (!userconfig && f->userconfig) {
+            continue;
+        }
         ret = qemu_read_config_file(f->filename);
         if (ret < 0 && ret != -ENOENT) {
             return ret;
diff --git a/qemu-config.h b/qemu-config.h
index ff934a1..6d7365d 100644
--- a/qemu-config.h
+++ b/qemu-config.h
@@ -18,6 +18,6 @@  int qemu_read_config_file(const char *filename);
 
 /* Read default Qemu config files
  */
-int qemu_read_default_config_files(void);
+int qemu_read_default_config_files(bool userconfig);
 
 #endif /* QEMU_CONFIG_H */
diff --git a/qemu-options.hx b/qemu-options.hx
index a169792..7d0b054 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -2685,9 +2685,19 @@  DEF("nodefconfig", 0, QEMU_OPTION_nodefconfig,
 STEXI
 @item -nodefconfig
 @findex -nodefconfig
-Normally QEMU loads a configuration file from @var{sysconfdir}/qemu.conf and
-@var{sysconfdir}/target-@var{ARCH}.conf on startup.  The @code{-nodefconfig}
-option will prevent QEMU from loading these configuration files at startup.
+Normally QEMU loads configuration files from @var{sysconfdir} and @var{datadir} at startup.
+The @code{-nodefconfig} option will prevent QEMU from loading any of those config files.
+ETEXI
+DEF("no-user-config", 0, QEMU_OPTION_nouserconfig,
+    "-no-user-config\n"
+    "                do not load user-provided config files at startup\n",
+    QEMU_ARCH_ALL)
+STEXI
+@item -no-user-config
+@findex -no-user-config
+The @code{-no-user-config} option makes QEMU not load any of the user-provided
+config files on @var{sysconfdir}, but won't make it skip the QEMU-provided config
+files from @var{datadir}.
 ETEXI
 DEF("trace", HAS_ARG, QEMU_OPTION_trace,
     "-trace [events=<file>][,file=<file>]\n"
diff --git a/vl.c b/vl.c
index eb3e088..87db855 100644
--- a/vl.c
+++ b/vl.c
@@ -2280,6 +2280,7 @@  int main(int argc, char **argv, char **envp)
     int show_vnc_port = 0;
 #endif
     bool defconfig = true;
+    bool userconfig = true;
     const char *log_mask = NULL;
     const char *log_file = NULL;
     GMemVTable mem_trace = {
@@ -2348,13 +2349,16 @@  int main(int argc, char **argv, char **envp)
             case QEMU_OPTION_nodefconfig:
                 defconfig = false;
                 break;
+            case QEMU_OPTION_nouserconfig:
+                userconfig = false;
+                break;
             }
         }
     }
 
     if (defconfig) {
         int ret;
-        ret = qemu_read_default_config_files();
+        ret = qemu_read_default_config_files(userconfig);
         if (ret < 0) {
             exit(1);
         }