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:
Eduardo Habkost 2014-08-08 16:03:31 -03:00 committed by Michael S. Tsirkin
parent d828c430eb
commit b3ce84fea4
4 changed files with 83 additions and 39 deletions

View file

@ -242,16 +242,16 @@ struct PropertyInfo {
/**
* GlobalProperty:
* @not_used: Track use of a global property. Defaults to false in all C99
* struct initializations.
*
* This prevents reports of .compat_props when they are not used.
* @user_provided: Set to true if property comes from user-provided config
* (command-line or config file).
* @used: Set to true if property was used when initializing a device.
*/
typedef struct GlobalProperty {
const char *driver;
const char *property;
const char *value;
bool not_used;
bool user_provided;
bool used;
QTAILQ_ENTRY(GlobalProperty) next;
} GlobalProperty;