Skip to contentSkip to conversation

vl.c: Output error on invalid machine type provided

PATCH Superseded Michal Novotny 2 participants 3 messages Jul 30, 2013

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vl.c: Output error on invalid machine type provided

Output error message when user provides the invalid machine type on the command line. This also saves time to find what issue is when you upgrade from one version of qemu to another version that doesn't support required machine type any longer.

Michal

---
 vl.c | 4 ++++
 1 file changed, 4 insertions(+)
vl.c +4 -0
index 25b8f2f..4455b26 100644
@@ -2671,6 +2671,10 @@ static QEMUMachine *machine_parse(const char *name)
     if (machine) {
         return machine;
     }
+
+    if (*name != '0')
+        printf("Error: Unsupported machine type '%s'\n", name);
+
     printf("Supported machines are:\n");
     for (m = first_machine; m != NULL; m = m->next) {
         if (m->alias) {
Signature · 1 line
1.7.11.7
#1 lore raw
Quoted 17 lines · Michal Novotny

Output error message when user provides the invalid machine type on the command line. This also saves time to find what issue is when you upgrade from one version of qemu to another version that doesn't support required machine type any longer.

Michal

---
 vl.c | 4 ++++
 1 file changed, 4 insertions(+)
vl.c +0 -0
index 25b8f2f..4455b26 100644

vl.c static QEMUMachine *machine_parse(const char *name) · line 2677

Quoted 7 lines
vl.c +4 -0
@@ -2671,6 +2671,10 @@ static QEMUMachine *machine_parse(const char *name)
     if (machine) {
         return machine;
     }
+
+    if (*name != '0')
+        printf("Error: Unsupported machine type '%s'\n", name);
+

Hi; thanks for the patch. I think the idea is a good one but there are some minor issues with the implementation:

This now causes "-M help" to print a spurious line "Error: Unsupported machine type 'help'".

You need braces around if statements, even one-liners. (scripts/checkpatch.pl may help with this kind of thing.)

This function can be called with name being NULL but you try to dereference it.

My suggestion is that your condition should be

    if (name && !is_help_option(name)) {
        ...
    }
Quoted 6 lines
vl.c +0 -1
     printf("Supported machines are:\n");
     for (m = first_machine; m != NULL; m = m->next) {
         if (m->alias) {
--

1.7.11.7

thanks
-- PMM

#2 lore raw
Quoted 34 lines · Peter Maydell
Quoted 17 lines · Michal Novotny

Output error message when user provides the invalid machine type on the command line. This also saves time to find what issue is when you upgrade from one version of qemu to another version that doesn't support required machine type any longer.

Michal

---
 vl.c | 4 ++++
 1 file changed, 4 insertions(+)
vl.c +0 -0
index 25b8f2f..4455b26 100644

vl.c static QEMUMachine *machine_parse(const char *name) · line 2677

Quoted 7 lines
vl.c +4 -0
@@ -2671,6 +2671,10 @@ static QEMUMachine *machine_parse(const char *name)
     if (machine) {
         return machine;
     }
+
+    if (*name != '0')
+        printf("Error: Unsupported machine type '%s'\n", name);
+

Hi; thanks for the patch. I think the idea is a good one but there are some minor issues with the implementation:

This now causes "-M help" to print a spurious line "Error: Unsupported machine type 'help'".

You need braces around if statements, even one-liners. (scripts/checkpatch.pl may help with this kind of thing.)

Quoted 7 lines

This function can be called with name being NULL but you try to dereference it.

My suggestion is that your condition should be

    if (name && !is_help_option(name)) {
        ...
    }

Hi Peter,
thanks a lot for your reply. I rewrote the patch and checked it using scripts/checkpatch.pl. It's already sent as v2 to the list.

Thanks a lot for your feedback,
Michal

Signature · 2 lines
Michal Novotny <[email protected]>, RHCE, Red Hat
Virtualization | libvirt-php bindings | php-virt-control.org