Skip to contentSkip to conversation

fix '-cpu ?' Segfault

PATCH Applied Eduardo Habkost 6 participants 7 messages Mar 21, 2012 – Mar 23, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix '-cpu ?' Segfault

Fix stupid copy&paste mistake at commit ecf40beae7dcbb057d4f115207f9d8276832a774: I moved code around but kept "optarg" on the cpu_list() call.

---
 vl.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
vl.c +1 -1
index 112b0e0..0fccf50 100644
@@ -3196,7 +3196,7 @@ int main(int argc, char **argv, char **envp)
     cpudef_init();
 
     if (cpu_model && *cpu_model == '?') {
-        list_cpus(stdout, &fprintf, optarg);
+        list_cpus(stdout, &fprintf, cpu_model);
         exit(0);
     }
 
Signature · 1 line
1.7.3.2
#1 lore raw
Quoted 9 lines · Eduardo Habkost

Fix stupid copy&paste mistake at commit ecf40beae7dcbb057d4f115207f9d8276832a774: I moved code around but kept "optarg" on the cpu_list() call.

---
 vl.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Thanks, applied to the trivial patches tree:
https://github.com/stefanha/qemu/commits/trivial-patches

Stefan

#2 lore raw
In reply to Eduardo Habkost
Quoted 15 lines · Eduardo Habkost

Fix stupid copy&paste mistake at commit ecf40beae7dcbb057d4f115207f9d8276832a774: I moved code around but kept "optarg" on the cpu_list() call.

---
  vl.c |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
vl.c +0 -0
index 112b0e0..0fccf50 100644

vl.c int main(int argc, char **argv, char **envp) · line 3202

Quoted 8 lines
vl.c +1 -1
@@ -3196,7 +3196,7 @@ int main(int argc, char **argv, char **envp)
      cpudef_init();
 
      if (cpu_model&&  *cpu_model == '?') {
-        list_cpus(stdout,&fprintf, optarg);
+        list_cpus(stdout,&fprintf, cpu_model);
          exit(0);
      }
 

Does -cpu ? actually work then? I only see the list of cpus when using -cpu ?_ for example.

Stefan

#3 lore raw

Am 22.03.2012 14:28, schrieb Stefan Berger:

Quoted 18 lines · Eduardo Habkost
Quoted 17 lines

Fix stupid copy&paste mistake at commit ecf40beae7dcbb057d4f115207f9d8276832a774: I moved code around but kept "optarg" on the cpu_list() call.

---
  vl.c |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
vl.c +0 -0
index 112b0e0..0fccf50 100644
@@ -3196,7 +3196,7 @@ int main(int argc, char **argv, char **envp)
      cpudef_init();
 
Quoted 8 lines

vl.c int main(int argc, char **argv, char **envp) · line 3202

Quoted 6 lines
vl.c +1 -1
      if (cpu_model&&  *cpu_model == '?') {
-        list_cpus(stdout,&fprintf, optarg);
+        list_cpus(stdout,&fprintf, cpu_model);
          exit(0);
      }
 

Does -cpu ? actually work then? I only see the list of cpus when using -cpu ?_ for example.

You're right, it should be cpu_model + 1 from what I recall, i.e. just the optional argument, not the whole model string.

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#4 lore raw
Quoted 28 lines · Andreas Färber

Am 22.03.2012 14:28, schrieb Stefan Berger:

Quoted 18 lines · Eduardo Habkost
Quoted 17 lines

Fix stupid copy&paste mistake at commit ecf40beae7dcbb057d4f115207f9d8276832a774: I moved code around but kept "optarg" on the cpu_list() call.

---
  vl.c |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
vl.c +0 -0
index 112b0e0..0fccf50 100644
@@ -3196,7 +3196,7 @@ int main(int argc, char **argv, char **envp)
      cpudef_init();
 
Quoted 8 lines

vl.c int main(int argc, char **argv, char **envp) · line 3202

Quoted 6 lines
vl.c +1 -1
      if (cpu_model&&  *cpu_model == '?') {
-        list_cpus(stdout,&fprintf, optarg);
+        list_cpus(stdout,&fprintf, cpu_model);
          exit(0);
      }
 

Does -cpu ? actually work then? I only see the list of cpus when using -cpu ?_ for example.

Quoted 2 lines

You're right, it should be cpu_model + 1 from what I recall, i.e. just the optional argument, not the whole model string.

No, list_cpus() expects the whole argument string, including the leading "?":

void list_cpus(FILE *f, fprintf_function cpu_fprintf, const char *optarg)

{
    /* XXX: implement xxx_cpu_list for targets that still miss it */
#if defined(cpu_list_id)
    cpu_list_id(f, cpu_fprintf, optarg);

#elif defined(cpu_list)
cpu_list(f, cpu_fprintf); /* deprecated */
#endif
}

[...]

#define cpu_list_id x86_cpu_list

[...]

void x86_cpu_list(FILE *f, fprintf_function cpu_fprintf, const char *optarg)

{
    unsigned char model = !strcmp("?model", optarg);
    unsigned char dump = !strcmp("?dump", optarg);
    unsigned char cpuid = !strcmp("?cpuid", optarg);

[...]

Signature · 1 line
Eduardo
#5 lore raw
In reply to Stefan Berger
Quoted 18 lines · Stefan Berger
Quoted 17 lines · Eduardo Habkost

Fix stupid copy&paste mistake at commit ecf40beae7dcbb057d4f115207f9d8276832a774: I moved code around but kept "optarg" on the cpu_list() call.

---
 vl.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
vl.c +0 -0
index 112b0e0..0fccf50 100644
@@ -3196,7 +3196,7 @@ int main(int argc, char **argv, char **envp)
     cpudef_init();
 
Quoted 8 lines

vl.c int main(int argc, char **argv, char **envp) · line 3202

Quoted 6 lines
vl.c +1 -1
     if (cpu_model&&  *cpu_model == '?') {
-        list_cpus(stdout,&fprintf, optarg);
+        list_cpus(stdout,&fprintf, cpu_model);
         exit(0);
     }
 

Does -cpu ? actually work then? I only see the list of cpus when using -cpu ?_ for example.

I think this is actually just a shell issue:

mdroth@illuin:~/tmp/empty$ ls
mdroth@illuin:~/tmp/empty$ echo ?
?
mdroth@illuin:~/tmp/empty$ touch a
mdroth@illuin:~/tmp/empty$ echo ?
a
mdroth@illuin:~/tmp/empty$ echo ?_
?_
Quoted 4 lines

Stefan

#6 lore raw
Quoted 19 lines · Michael Roth
Quoted 18 lines · Stefan Berger
Quoted 17 lines · Eduardo Habkost

Fix stupid copy&paste mistake at commit ecf40beae7dcbb057d4f115207f9d8276832a774: I moved code around but kept "optarg" on the cpu_list() call.

---
 vl.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
vl.c +0 -0
index 112b0e0..0fccf50 100644
@@ -3196,7 +3196,7 @@ int main(int argc, char **argv, char **envp)
     cpudef_init();
 
Quoted 8 lines
Quoted 8 lines

vl.c int main(int argc, char **argv, char **envp) · line 3202

Quoted 6 lines
vl.c +1 -1
     if (cpu_model&&  *cpu_model == '?') {
-        list_cpus(stdout,&fprintf, optarg);
+        list_cpus(stdout,&fprintf, cpu_model);
         exit(0);
     }
 

Does -cpu ? actually work then? I only see the list of cpus when using -cpu ?_ for example.

use "-cpu \?"

Quoted 17 lines

I think this is actually just a shell issue:

mdroth@illuin:~/tmp/empty$ ls
mdroth@illuin:~/tmp/empty$ echo ?
?
mdroth@illuin:~/tmp/empty$ touch a
mdroth@illuin:~/tmp/empty$ echo ?
a
mdroth@illuin:~/tmp/empty$ echo ?_
?_
Quoted 4 lines

Stefan