qdev: use object_property_help()
Use the common function introduced earlier, and report default value. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20200110153039.1379601-27-marcandre.lureau@redhat.com> [Sort the properties, following what is done for -object ...,help. - Paolo] Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
1bb3d7d92c
commit
e1043d674d
@ -37,6 +37,7 @@
|
|||||||
#include "sysemu/sysemu.h"
|
#include "sysemu/sysemu.h"
|
||||||
#include "migration/misc.h"
|
#include "migration/misc.h"
|
||||||
#include "migration/migration.h"
|
#include "migration/migration.h"
|
||||||
|
#include "qemu/cutils.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Aliases were a bad idea from the start. Let's keep them
|
* Aliases were a bad idea from the start. Let's keep them
|
||||||
@ -256,6 +257,8 @@ int qdev_device_help(QemuOpts *opts)
|
|||||||
const char *driver;
|
const char *driver;
|
||||||
ObjectPropertyInfoList *prop_list;
|
ObjectPropertyInfoList *prop_list;
|
||||||
ObjectPropertyInfoList *prop;
|
ObjectPropertyInfoList *prop;
|
||||||
|
GPtrArray *array;
|
||||||
|
int i;
|
||||||
|
|
||||||
driver = qemu_opt_get(opts, "driver");
|
driver = qemu_opt_get(opts, "driver");
|
||||||
if (driver && is_help_option(driver)) {
|
if (driver && is_help_option(driver)) {
|
||||||
@ -285,19 +288,20 @@ int qdev_device_help(QemuOpts *opts)
|
|||||||
} else {
|
} else {
|
||||||
qemu_printf("There are no options for %s.\n", driver);
|
qemu_printf("There are no options for %s.\n", driver);
|
||||||
}
|
}
|
||||||
|
array = g_ptr_array_new();
|
||||||
for (prop = prop_list; prop; prop = prop->next) {
|
for (prop = prop_list; prop; prop = prop->next) {
|
||||||
int len;
|
g_ptr_array_add(array,
|
||||||
qemu_printf(" %s=<%s>%n", prop->value->name, prop->value->type, &len);
|
object_property_help(prop->value->name,
|
||||||
if (prop->value->has_description) {
|
prop->value->type,
|
||||||
if (len < 24) {
|
prop->value->default_value,
|
||||||
qemu_printf("%*s", 24 - len, "");
|
prop->value->description));
|
||||||
}
|
}
|
||||||
qemu_printf(" - %s\n", prop->value->description);
|
g_ptr_array_sort(array, (GCompareFunc)qemu_pstrcmp0);
|
||||||
} else {
|
for (i = 0; i < array->len; i++) {
|
||||||
qemu_printf("\n");
|
printf("%s\n", (char *)array->pdata[i]);
|
||||||
}
|
}
|
||||||
}
|
g_ptr_array_set_free_func(array, g_free);
|
||||||
|
g_ptr_array_free(array, true);
|
||||||
qapi_free_ObjectPropertyInfoList(prop_list);
|
qapi_free_ObjectPropertyInfoList(prop_list);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user