qdev: Add help for property value

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>
This commit is contained in:
Stefan Weil 2010-01-20 22:58:34 +01:00 committed by Anthony Liguori
parent 2ba6edf0dd
commit 922910ce42
1 changed files with 7 additions and 2 deletions

View 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;