qdev: Add help for property value
authorStefan Weil <weil@mail.berlios.de>
Wed, 20 Jan 2010 21:58:34 +0000 (22:58 +0100)
committerAnthony Liguori <aliguori@us.ibm.com>
Tue, 26 Jan 2010 21:42:01 +0000 (15:42 -0600)
When called with property value "?",
a help text will be printed (instead of an error message).

This is useful for command lines like
     qemu -device e1000,mac=?
and is already standard for other command line options.

A better help text could be provided by extending
the Property structure with a desc field.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
hw/qdev-properties.c

index 8547ad2..f5ca05f 100644 (file)
@@ -565,8 +565,13 @@ int qdev_prop_parse(DeviceState *dev, const char *name, const char *value)
         return -1;
     }
     if (prop->info->parse(dev, prop, value) != 0) {
-        fprintf(stderr, "property \"%s.%s\": failed to parse \"%s\"\n",
-                dev->info->name, name, value);
+        if (strcmp(value, "?") != 0) {
+            fprintf(stderr, "property \"%s.%s\": failed to parse \"%s\"\n",
+                    dev->info->name, name, value);
+        } else {
+            fprintf(stderr, "%s.%s=%s\n",
+                    dev->info->name, name, prop->info->name);
+        }
         return -1;
     }
     return 0;