mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-16 06:31:51 -06:00
qdev: Move global validation to a single function
Currently GlobalProperty.not_used=false has multiple meanings: * It may be a property for a hotpluggable device, which may or may not have been used by a device; * It may be a machine-type-provided property, which may or may not have been used by a device. * It may be a user-provided property that was actually not used by any device. Simplify the logic by having two separate fields: 'user_provided' and 'used'. This allows the entire global property validation logic to be contained in a single function, and allows more specific error messages. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
d828c430eb
commit
b3ce84fea4
4 changed files with 83 additions and 39 deletions
|
@ -388,28 +388,12 @@ void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd)
|
|||
static int qdev_add_one_global(QemuOpts *opts, void *opaque)
|
||||
{
|
||||
GlobalProperty *g;
|
||||
ObjectClass *oc;
|
||||
|
||||
g = g_malloc0(sizeof(*g));
|
||||
g->driver = qemu_opt_get(opts, "driver");
|
||||
g->property = qemu_opt_get(opts, "property");
|
||||
g->value = qemu_opt_get(opts, "value");
|
||||
oc = object_class_dynamic_cast(object_class_by_name(g->driver),
|
||||
TYPE_DEVICE);
|
||||
if (oc) {
|
||||
DeviceClass *dc = DEVICE_CLASS(oc);
|
||||
|
||||
if (dc->hotpluggable) {
|
||||
/* If hotpluggable then skip not_used checking. */
|
||||
g->not_used = false;
|
||||
} else {
|
||||
/* Maybe a typo. */
|
||||
g->not_used = true;
|
||||
}
|
||||
} else {
|
||||
/* Maybe a typo. */
|
||||
g->not_used = true;
|
||||
}
|
||||
g->user_provided = true;
|
||||
qdev_prop_register_global(g);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue