vl.c: Use qdev_prop_register_global() for single globals

Instead of using an array when registering a single global, simply call
qdev_prop_register().

Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
pc: Eliminate has_pci_info global variable

The variable is always set to false and never changed, so we simply
don't need it.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
piix: Add kvmclock_enabled, pci_enabled globals

This looks like a step backwards, but it will allow pc-0.1[0123] and
isapc to follow the same compat+init pattern used by the other
machine-types, making it easier to convert them to QOM and reduce
duplicated code.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
piix: Eliminate pc_init_pci()

Now we can use pc_init1() directly.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
piix: Move pc-0.14 qxl compat properties to PC_COMPAT_0_14

Those properties were introduced by commit
3827cdb1c3aa17a792d1658161195b9d7173c26b. They were not duplicated into
pc-0.13 and older because 0.14 was the first QEMU version supporting
qxl. The only problem is that this breaks the PC_COMPAT_* nesting
pattern we currently use.

So, move the properties to PC_COMPAT_0_14. This makes pc-0.13 and older
inherit them, but that shouldn't be an issue as QEMU 0.13 didn't support
qxl.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
piix: Move pc-0.13 virtio-9p-pci compat to PC_COMPAT_0_13

The compat property was added by commit
9dbcca5aa13cb9ab40788ac4c56bc227d94ca920, and the pc-0.12 and older
machine-types were not changed because virtio-9p-pci was introduced on QEMU
0.13 (commit 9f10751365b26b13b8a9b67e0e90536ae3d282df). The only problem is
that this breaks the PC_COMPAT_* nesting pattern we currently use.

So, move the property to PC_COMPAT_0_13. This make pc-0.12 and older inherit
it, but that shouldn't be an issue as QEMU 0.12 didn't have virtio-9p-pci.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
piix: Move pc-0.1[23] rombar compat props to PC_COMPAT_0_13

The VGA and vmware-svga rombar compat properties were added by commit
281a26b15b4adcecb8604216738975abd754bea8, but only to pc-0.13 and
pc-0.12. This breaks the PC_COMPAT_* nesting pattern we currently
follow.

The new variables will now be inherited by pc-0.11 and older, but
pc-0.11 and pc-0.10 already have PCI.rombar=0 on compat_props, so they
shouldn't be affected at all.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Cc: Stefan Weil <sw@weilnetz.de>
Cc: Gerd Hoffmann <kraxel@redhat.com>
piix: Move pc-0.11 drive version compat props TO PC_COMPAT_0_11

The current code setting ide-drive.ver and scsi-disk.ver on pc-0.11
breaks the PC_COMPAT_* nesting pattern we currently use.

As those variables are overwritten in pc-0.10 too, they can be inherited
by pc-0.10 with no side-effects at all.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
machine: Make compat_props a linked list

This will make it easier to write reusable class_init code which adds
properties to MachineClass.compat_props.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
pc: Register machine classes directly instead of using QEMUMachine

This is a (mostly) blind and mechanical conversion of the PC QEMUMachine
definitions to corresponding class registration code.

Existing duplication and unnecessary complexity on macro/function reuse
is being kept, to keep the conversion simple to review. The complexity
and duplication will be gradually removed by the next patches.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Cc: Igor Mammedov <imammedo@redhat.com>
---
Changes v1 -> v2:
 * Remove unused PC_DEFAULT_MACHINE_OPTIONS macro leftover
 * Use machine_class_register_global_props_array()
 * Rebase on top of Michael's pci tree
 * Eliminate qemu_register_pc_machine(), as it is not needed anymore
Changes v2 -> v3:
 * Make static TypeInfo structs const
   Suggested-by: Andreas Färber <afaerber@suse.de>
pc: Eliminate pc_common_machine_options()

The TYPE_PC_MACHINE parent class can initialize the common options for
all PC machines.

Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
pc: Eliminate pc_default_machine_options()

The only PC machines that didn't call pc_default_machine_options() were
isaps and xenfv. Both were already overwriting max_cpus, and only isapc
was not overwriting hot_add_cpu.

After making isapc set hot_add_cpu to NULL, we can move the
pc_default_machine_options() code the PC common class_init.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
piix: Eliminate pc_i440fx_machine_options()

Instead of calling it on every i440fx class_init function, just register
a common parent class for all i440fx machine-types.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
q35: Eliminate pc_q35_machine_options()

Instead of calling it on every q35 class_init function, just register a
common parent class for all q35 machine-types.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
q35: Eliminate pc_q35_1_4_machine_options()

The function was used only in a single place.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
pc: Eliminate all *_machine_options() functions

Finally eliminate all *_machine_options() functions, and make the
class_init functions for older machine-types simply reuse the class_init
functions from newer machine-types.

To allow compat_props reuse, the the PC_COMPAT_* macros were changed to
not nest within the older PC_COMPAT_* macros anymore.

We can now make all pc-{i440fx,q36}-* class_init functions call the previous
one.

For reference (to help ensure the reuse of previous class_init functions
won't change any behavior), these are the fields that are touched by the
class_init functions:

* name: All machine-types set it, class_init reuse won't affect it.
* hw_version: All machines older than pc*-1.0 already set it, class_init reuse
  won't affect it.
* desc: Only the base pc-{i440fx,q35} classes set it, so all classes already
  reused it.
* hot_add_cpu:
  * The base pc-{i440fx,q35} classes set it (so it was already reused by all
    subclasses).
  * pc-i440fx-1.4 was already overriding it inside
    pc_i440fx_1_4_machine_options() (and all older machine-types already
    reused it).
  * On pc_q35.c, only pc-q-35-1.4 (which is the oldest pc-q35 subclass) set it.
* alias: Only pc*-2.1 was setting it, pc*-2.0 was now changed to unset
  it, so only pc*-2.1 still have it set.
* is_default: Only pc-i440fx-2.1 was setting it, pc-i440fx-2.0 was now
  changed to unset it, so only pc-i440fx-2.1 still have it set.
* init: pc*-1.3 to pc*-2.1 were already setting it. The only ones that didn't
  set it were using the one set by previous *machine_options() functions.
* compat_props: All machine-types used PC_COMPAT_* macros that reused the
  previous one. Now they will simply append to the compat_props list added by
  the previous class_init function, and PC_COMPAT_* won't include the previous
  macros inside them.
* default_machine_opts: It was set by pc_*_2_1_machine_options() and is
  now set by pc-*-2.1 class_init(). pc*-1.7 and older didn't reuse
  pc_*_2_1_machine_options(), so now pc*-1.7 class_init() set
  default_machine_opts to NULL to ensure pc-*1.7 and older don't inherit
  it.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
machine: Eliminate QEMUMachine.compat_props

The only user of QEMUMachine.compat_props was the PC code, that was
already converted to QOM. We don't need that field anymore.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
pc: Rename pc_machine variable to pcms

"pcms" being the initials of "PCMachineState". The variable will be used
a lot, so it's better to make it short.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
pc: Pass PCMachineState argument to pc_cpus_init()

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
machine: Add MachineClass.default_cpu_model field

Instead of making the machine-specific init code set a default CPU
model, make the generic machine init code set cpu_model to a
class-specific default if it is not set.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>