All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 4/7] cpu model bug fixes and definition corrections
@ 2011-05-23 21:47 john cooper
  2011-05-24 12:19 ` Jan Kiszka
  0 siblings, 1 reply; 2+ messages in thread
From: john cooper @ 2011-05-23 21:47 UTC (permalink / raw)
  To: qemu-devel; +Cc: john cooper, Anthony Liguori

Failure by qemu to open a default config file isn't cause to
error exit -- it just quietly continues on.   After puzzling
issues with otherwise opaque config file locations and
startup handling numerous times, some help from qemu seemed
justified.

In the case of a "?" pseudo filename arg to -readconfig,
verbose open of all config files will be enabled.  Normal
handling of config files is otherwise unaffected by this
option.

Note: other CLI flag schemes have been discussed at length
to accommodate this option.  However given the constraints
of the existing user interface, a solution which minimally
impacts the user is ultimately required.

Signed-off-by: john cooper <john.cooper@redhat.com>
---

diff --git a/qemu-config.c b/qemu-config.c
index 5d7ffa2..b39b8fe 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -666,21 +666,29 @@ out:
     return res;
 }
 
-int qemu_read_config_file(const char *filename)
+/* attempt to open and parse config file, report problems if vflag
+ */
+int qemu_read_config_file(const char *filename, int vflag)
 {
     FILE *f = fopen(filename, "r");
-    int ret;
+    int rv = 0;
+    const char *err;
 
     if (f == NULL) {
-        return -errno;
+        rv = -errno;
+        err = "open";
+    } else if (qemu_config_parse(f, vm_config_groups, filename) != 0) {
+        rv = -EINVAL;
+        err = "parse";
+    } else if (vflag) {
+        fprintf(stderr, "parsed config file %s\n", filename);
     }
-
-    ret = qemu_config_parse(f, vm_config_groups, filename);
-    fclose(f);
-
-    if (ret == 0) {
-        return 0;
-    } else {
-        return -EINVAL;
+    if (f) {
+        fclose(f);
+    }
+    if (rv && vflag) {
+        fprintf(stderr, "can't %s config file %s: %s\n",
+                err, filename, strerror(-rv));
     }
+    return rv;
 }
diff --git a/qemu-config.h b/qemu-config.h
index 20d707f..b90a7cc 100644
--- a/qemu-config.h
+++ b/qemu-config.h
@@ -14,6 +14,6 @@ void qemu_add_globals(void);
 void qemu_config_write(FILE *fp);
 int qemu_config_parse(FILE *fp, QemuOptsList **lists, const char *fname);
 
-int qemu_read_config_file(const char *filename);
+int qemu_read_config_file(const char *filename, int vflag);
 
 #endif /* QEMU_CONFIG_H */
diff --git a/vl.c b/vl.c
index b362871..65b0791 100644
--- a/vl.c
+++ b/vl.c
@@ -2059,6 +2059,7 @@ int main(int argc, char **argv, char **envp)
     int show_vnc_port = 0;
 #endif
     int defconfig = 1;
+    int defconfig_verbose = 0;
     const char *trace_file = NULL;
 
     atexit(qemu_run_exit_notifiers);
@@ -2108,6 +2109,12 @@ int main(int argc, char **argv, char **envp)
             case QEMU_OPTION_nodefconfig:
                 defconfig=0;
                 break;
+            case QEMU_OPTION_readconfig:
+                /* pseudo filename "?" enables verbose config file handling */
+                if (!strcmp(optarg, "?")) {
+                    defconfig_verbose = 1;
+                }
+                break;
             }
         }
     }
@@ -2115,12 +2122,13 @@ int main(int argc, char **argv, char **envp)
     if (defconfig) {
         int ret;
 
-        ret = qemu_read_config_file(CONFIG_QEMU_CONFDIR "/qemu.conf");
+        ret = qemu_read_config_file(CONFIG_QEMU_CONFDIR "/qemu.conf",
+                                    defconfig_verbose);
         if (ret < 0 && ret != -ENOENT) {
             exit(1);
         }
 
-        ret = qemu_read_config_file(arch_config_name);
+        ret = qemu_read_config_file(arch_config_name, defconfig_verbose);
         if (ret < 0 && ret != -ENOENT) {
             exit(1);
         }
@@ -2857,11 +2865,9 @@ int main(int argc, char **argv, char **envp)
 #endif
             case QEMU_OPTION_readconfig:
                 {
-                    int ret = qemu_read_config_file(optarg);
-                    if (ret < 0) {
-                        fprintf(stderr, "read config %s: %s\n", optarg,
-                            strerror(-ret));
-                        exit(1);
+                    if (strcmp(optarg, "?") &&
+                        qemu_read_config_file(optarg, defconfig_verbose) < 0) {
+                            exit(1);
                     }
                     break;
                 }
-- 
john.cooper@redhat.com

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH 4/7] cpu model bug fixes and definition corrections
  2011-05-23 21:47 [Qemu-devel] [PATCH 4/7] cpu model bug fixes and definition corrections john cooper
@ 2011-05-24 12:19 ` Jan Kiszka
  0 siblings, 0 replies; 2+ messages in thread
From: Jan Kiszka @ 2011-05-24 12:19 UTC (permalink / raw)
  To: john cooper; +Cc: Anthony Liguori, qemu-devel

Starting with this patch, the series lacks proper subjects. Please also
avoid such long subject lines. The background can be explained in the
introduction mail (threading your mails would be nice as well, check git
format-patch). Rather us short tags for the patches, describing the
subsystem/target-arch they touch.

On 2011-05-23 23:47, john cooper wrote:
> Failure by qemu to open a default config file isn't cause to
> error exit -- it just quietly continues on.   After puzzling
> issues with otherwise opaque config file locations and
> startup handling numerous times, some help from qemu seemed
> justified.
> 
> In the case of a "?" pseudo filename arg to -readconfig,
> verbose open of all config files will be enabled.  Normal
> handling of config files is otherwise unaffected by this
> option.
> 
> Note: other CLI flag schemes have been discussed at length
> to accommodate this option.  However given the constraints
> of the existing user interface, a solution which minimally
> impacts the user is ultimately required.

Does this patch also fix the loading of CPU configs when starting qemu
directly from the build folder? That would be warmly welcome!

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-05-24 12:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-23 21:47 [Qemu-devel] [PATCH 4/7] cpu model bug fixes and definition corrections john cooper
2011-05-24 12:19 ` Jan Kiszka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.