qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

qdev-monitor: include QOM properties in -device FOO, help output

Update -device FOO,help to include QOM properties in addition to qdev
properties. Devices are gradually adding more QOM properties that are
not reflected as qdev properties.

It is important to report all device properties since management tools
like libvirt use this information (and device-list-properties QMP) to
detect the presence of QEMU features.

This patch reuses the device-list-properties QMP machinery to avoid code
duplication.

Reported-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Tested-by: Cole Robinson <crobinso@redhat.com>

authored by

Stefan Hajnoczi and committed by
Kevin Wolf
ef523587 4115dd65

+17 -23
+17 -23
qdev-monitor.c
··· 182 182 183 183 int qdev_device_help(QemuOpts *opts) 184 184 { 185 + Error *local_err = NULL; 185 186 const char *driver; 186 - Property *prop; 187 - ObjectClass *klass; 187 + DevicePropertyInfoList *prop_list; 188 + DevicePropertyInfoList *prop; 188 189 189 190 driver = qemu_opt_get(opts, "driver"); 190 191 if (driver && is_help_option(driver)) { ··· 196 197 return 0; 197 198 } 198 199 199 - klass = object_class_by_name(driver); 200 - if (!klass) { 200 + if (!object_class_by_name(driver)) { 201 201 const char *typename = find_typename_by_alias(driver); 202 202 203 203 if (typename) { 204 204 driver = typename; 205 - klass = object_class_by_name(driver); 206 205 } 207 206 } 208 207 209 - if (!object_class_dynamic_cast(klass, TYPE_DEVICE)) { 210 - return 0; 208 + prop_list = qmp_device_list_properties(driver, &local_err); 209 + if (!prop_list) { 210 + error_printf("%s\n", error_get_pretty(local_err)); 211 + error_free(local_err); 212 + return 1; 211 213 } 212 - do { 213 - for (prop = DEVICE_CLASS(klass)->props; prop && prop->name; prop++) { 214 - /* 215 - * TODO Properties without a parser are just for dirty hacks. 216 - * qdev_prop_ptr is the only such PropertyInfo. It's marked 217 - * for removal. This conditional should be removed along with 218 - * it. 219 - */ 220 - if (!prop->info->set) { 221 - continue; /* no way to set it, don't show */ 222 - } 223 - error_printf("%s.%s=%s\n", driver, prop->name, 224 - prop->info->legacy_name ?: prop->info->name); 225 - } 226 - klass = object_class_get_parent(klass); 227 - } while (klass != object_class_by_name(TYPE_DEVICE)); 214 + 215 + for (prop = prop_list; prop; prop = prop->next) { 216 + error_printf("%s.%s=%s\n", driver, 217 + prop->value->name, 218 + prop->value->type); 219 + } 220 + 221 + qapi_free_DevicePropertyInfoList(prop_list); 228 222 return 1; 229 223 } 230 224