target-i386: return Error from cpu_x86_find_by_name()

it will allow to use property setters there later.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
target-i386: cpu_x86_register(): report error from property setter

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
target-i386: if x86_cpu_realize() failed report error and do cleanup

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
target-i386: filter out not TCG features if running without kvm at realize time

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
target-i386: move out CPU features initialization in separate func

later it could be used in cpu_x86_find_by_name() to init
CPU from found cpu_def

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
target-i386: xlevel should be more than 0x80000000, move fixup into setter

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
target-i386: convert cpuid features into properties

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
target-i386: convert 'hv_spinlocks' feature into property

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
target-i386: convert 'hv_relaxed' feature into property

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
target-i386: convert 'hv_vapic' feature into property

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
target-i386: convert 'check' and 'enforce' features into properties

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
add visitor for parsing hz[KMG] input string

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
target-i386: use visit_type_hz to parse tsc_freq property value

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
target-i386: introduce vendor-override property

currently 'cpuid_vendor_override' can be set only via cmd line cpu_model
string. But setting it in 'vendor' property prevents using 'vendor'
property on its own without setting cpuid_vendor_override.

So fix/remove enabling cpuid_vendor_override from "vendor" property setter.
It's up-to cpu_model string parser to maintain legacy behavior when user
overrides vendor on command line.

v2:
  - convert cpuid_vendor_override to bool to reflect its real usage

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
target-i386: use define for cpuid vendor string size

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
target-i386: replace uint32_t vendor fields by vendor string in x86_def_t

Vendor property setter takes string as vendor value but cpudefs
use uint32_t vendor[123] fields to define vendor value. It makes it
difficult to unify and use property setter for values from cpudefs.

To allow simplify code by using vendor property setter, vendor[123]
fields are converted into vendor[13] array to keep its value. And
vendor property setter is used to access/set value on CPU.

[ehabkost: change extra CPU model array items to use the .vendor field, too]

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
target-i386: parse cpu_model string into set of stringified properties

cpu_model string does represent features in following format:
 ([+-]feat)|(feat=foo)|(feat)
which makes it impossible directly use property infrastructure
to set features on CPU.
This patch introduces parser that splits CPU name from cpu_model and
converts legacy features string into canonized set of strings that
is compatible with property manipulation infrastructure.

PS:
  * later it could be used as a hook to convert legacy command line
    features to global properties. Then marked as deprecated and
    removed with -cpu option in the future.
  * compiler complains that it's unused function but I guess it is
    easier for review this way

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
target-i386: use properties to set/unset user specified features on CPU

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
target-i386: move init of "hypervisor" feature into CPU initializer from cpudef

"hypervisor" CPU feature is unconditionally enabled/overridden even if it's cleared
in cpudef. Moving it inside CPU initializer from cpudef will help to
split cpu_x86_find_by_name() into default init and user settable properties.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
target-i386: move default init of cpuid_kvm_features bitmap into CPU initializer from cpudef

Moving it inside CPU initializer from cpudef will help to split
cpu_x86_find_by_name() into default init and user settable properties.

PS:
  Is kvm_features field necessary in cpudef, what the point
  if it's almost imediately overwritten to ~0? Could it be removed
  from cpudef?

Signed-off-by: Igor Mammedov <imammedo@redhat.com>