diff options
-rw-r--r-- | accel/accel.c | 12 | ||||
-rw-r--r-- | backends/hostmem-file.c | 8 | ||||
-rw-r--r-- | backends/hostmem-memfd.c | 2 | ||||
-rw-r--r-- | backends/hostmem-ram.c | 9 | ||||
-rw-r--r-- | backends/hostmem.c | 36 | ||||
-rw-r--r-- | hw/arm/virt.c | 46 | ||||
-rw-r--r-- | hw/core/machine.c | 347 | ||||
-rw-r--r-- | hw/core/qdev-properties.c | 49 | ||||
-rw-r--r-- | hw/core/qdev.c | 15 | ||||
-rw-r--r-- | hw/i386/pc.c | 674 | ||||
-rw-r--r-- | hw/i386/pc_piix.c | 508 | ||||
-rw-r--r-- | hw/i386/pc_q35.c | 36 | ||||
-rw-r--r-- | hw/ppc/spapr.c | 207 | ||||
-rw-r--r-- | hw/s390x/s390-virtio-ccw.c | 196 | ||||
-rw-r--r-- | hw/xen/xen-common.c | 41 | ||||
-rw-r--r-- | include/hw/boards.h | 59 | ||||
-rw-r--r-- | include/hw/compat.h | 299 | ||||
-rw-r--r-- | include/hw/i386/pc.h | 689 | ||||
-rw-r--r-- | include/hw/qdev-core.h | 23 | ||||
-rw-r--r-- | include/qom/object.h | 3 | ||||
-rw-r--r-- | include/sysemu/accel.h | 4 | ||||
-rw-r--r-- | include/sysemu/hostmem.h | 3 | ||||
-rw-r--r-- | qom/cpu.c | 1 | ||||
-rw-r--r-- | qom/object.c | 35 | ||||
-rw-r--r-- | target/arm/cpu-qom.h | 3 | ||||
-rw-r--r-- | target/arm/cpu.c | 30 | ||||
-rw-r--r-- | target/arm/cpu.h | 2 | ||||
-rw-r--r-- | target/arm/cpu64.c | 24 | ||||
-rw-r--r-- | target/i386/cpu.c | 1 | ||||
-rw-r--r-- | target/sparc/cpu.c | 1 | ||||
-rw-r--r-- | tests/test-qdev-global-props.c | 57 | ||||
-rw-r--r-- | vl.c | 4 |
32 files changed, 1786 insertions, 1638 deletions
diff --git a/accel/accel.c b/accel/accel.c index 3da26eb90f..6db5d8f4df 100644 --- a/accel/accel.c +++ b/accel/accel.c @@ -119,18 +119,6 @@ void configure_accelerator(MachineState *ms) } } -void accel_register_compat_props(AccelState *accel) -{ - AccelClass *class = ACCEL_GET_CLASS(accel); - GlobalProperty *prop = class->global_props; - - for (; prop && prop->driver; prop++) { - /* Any compat_props must never cause error */ - prop->errp = &error_abort; - qdev_prop_register_global(prop); - } -} - void accel_setup_post(MachineState *ms) { AccelState *accel = ms->accelerator; diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c index 78f058dee2..7a34e25c43 100644 --- a/backends/hostmem-file.c +++ b/backends/hostmem-file.c @@ -43,7 +43,7 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) { HostMemoryBackendFile *fb = MEMORY_BACKEND_FILE(backend); #ifdef CONFIG_POSIX - gchar *path; + gchar *name; #endif if (!backend->size) { @@ -58,14 +58,14 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) error_setg(errp, "-mem-path not supported on this host"); #else backend->force_prealloc = mem_prealloc; - path = object_get_canonical_path(OBJECT(backend)); + name = host_memory_backend_get_name(backend); memory_region_init_ram_from_file(&backend->mr, OBJECT(backend), - path, + name, backend->size, fb->align, (backend->share ? RAM_SHARED : 0) | (fb->is_pmem ? RAM_PMEM : 0), fb->mem_path, errp); - g_free(path); + g_free(name); #endif } diff --git a/backends/hostmem-memfd.c b/backends/hostmem-memfd.c index 2eb9c827a5..98c9bf3240 100644 --- a/backends/hostmem-memfd.c +++ b/backends/hostmem-memfd.c @@ -53,7 +53,7 @@ memfd_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) return; } - name = object_get_canonical_path(OBJECT(backend)); + name = host_memory_backend_get_name(backend); memory_region_init_ram_from_fd(&backend->mr, OBJECT(backend), name, backend->size, backend->share, fd, errp); diff --git a/backends/hostmem-ram.c b/backends/hostmem-ram.c index 7ddd08d370..24b65d9ae3 100644 --- a/backends/hostmem-ram.c +++ b/backends/hostmem-ram.c @@ -16,21 +16,20 @@ #define TYPE_MEMORY_BACKEND_RAM "memory-backend-ram" - static void ram_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) { - char *path; + char *name; if (!backend->size) { error_setg(errp, "can't create backend with size 0"); return; } - path = object_get_canonical_path_component(OBJECT(backend)); - memory_region_init_ram_shared_nomigrate(&backend->mr, OBJECT(backend), path, + name = host_memory_backend_get_name(backend); + memory_region_init_ram_shared_nomigrate(&backend->mr, OBJECT(backend), name, backend->size, backend->share, errp); - g_free(path); + g_free(name); } static void diff --git a/backends/hostmem.c b/backends/hostmem.c index af800284e0..0c8ef17653 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -28,6 +28,16 @@ QEMU_BUILD_BUG_ON(HOST_MEM_POLICY_BIND != MPOL_BIND); QEMU_BUILD_BUG_ON(HOST_MEM_POLICY_INTERLEAVE != MPOL_INTERLEAVE); #endif +char * +host_memory_backend_get_name(HostMemoryBackend *backend) +{ + if (!backend->use_canonical_path) { + return object_get_canonical_path_component(OBJECT(backend)); + } + + return object_get_canonical_path(OBJECT(backend)); +} + static void host_memory_backend_get_size(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) @@ -247,6 +257,11 @@ static void host_memory_backend_init(Object *obj) backend->prealloc = mem_prealloc; } +static void host_memory_backend_post_init(Object *obj) +{ + object_apply_compat_props(obj); +} + bool host_memory_backend_mr_inited(HostMemoryBackend *backend) { /* @@ -395,6 +410,23 @@ static void host_memory_backend_set_share(Object *o, bool value, Error **errp) backend->share = value; } +static bool +host_memory_backend_get_use_canonical_path(Object *obj, Error **errp) +{ + HostMemoryBackend *backend = MEMORY_BACKEND(obj); + + return backend->use_canonical_path; +} + +static void +host_memory_backend_set_use_canonical_path(Object *obj, bool value, + Error **errp) +{ + HostMemoryBackend *backend = MEMORY_BACKEND(obj); + + backend->use_canonical_path = value; +} + static void host_memory_backend_class_init(ObjectClass *oc, void *data) { @@ -441,6 +473,9 @@ host_memory_backend_class_init(ObjectClass *oc, void *data) &error_abort); object_class_property_set_description(oc, "share", "Mark the memory as private to QEMU or shared", &error_abort); + object_class_property_add_bool(oc, "x-use-canonical-path-for-ramblock-id", + host_memory_backend_get_use_canonical_path, + host_memory_backend_set_use_canonical_path, &error_abort); } static const TypeInfo host_memory_backend_info = { @@ -451,6 +486,7 @@ static const TypeInfo host_memory_backend_info = { .class_init = host_memory_backend_class_init, .instance_size = sizeof(HostMemoryBackend), .instance_init = host_memory_backend_init, + .instance_post_init = host_memory_backend_post_init, .interfaces = (InterfaceInfo[]) { { TYPE_USER_CREATABLE }, { } diff --git a/hw/arm/virt.c b/hw/arm/virt.c index c2641e56ea..99c2b6e60d 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -43,7 +43,6 @@ #include "sysemu/numa.h" #include "sysemu/sysemu.h" #include "sysemu/kvm.h" -#include "hw/compat.h" #include "hw/loader.h" #include "exec/address-spaces.h" #include "qemu/bitops.h" @@ -1872,84 +1871,63 @@ static void virt_machine_4_0_options(MachineClass *mc) } DEFINE_VIRT_MACHINE_AS_LATEST(4, 0) -#define VIRT_COMPAT_3_1 \ - HW_COMPAT_3_1 - static void virt_machine_3_1_options(MachineClass *mc) { virt_machine_4_0_options(mc); - SET_MACHINE_COMPAT(mc, VIRT_COMPAT_3_1); + compat_props_add(mc->compat_props, hw_compat_3_1, hw_compat_3_1_len); } DEFINE_VIRT_MACHINE(3, 1) -#define VIRT_COMPAT_3_0 \ - HW_COMPAT_3_0 - static void virt_machine_3_0_options(MachineClass *mc) { virt_machine_3_1_options(mc); - SET_MACHINE_COMPAT(mc, VIRT_COMPAT_3_0); + compat_props_add(mc->compat_props, hw_compat_3_0, hw_compat_3_0_len); } DEFINE_VIRT_MACHINE(3, 0) -#define VIRT_COMPAT_2_12 \ - HW_COMPAT_2_12 - static void virt_machine_2_12_options(MachineClass *mc) { VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc)); virt_machine_3_0_options(mc); - SET_MACHINE_COMPAT(mc, VIRT_COMPAT_2_12); + compat_props_add(mc->compat_props, hw_compat_2_12, hw_compat_2_12_len); vmc->no_highmem_ecam = true; mc->max_cpus = 255; } DEFINE_VIRT_MACHINE(2, 12) -#define VIRT_COMPAT_2_11 \ - HW_COMPAT_2_11 - static void virt_machine_2_11_options(MachineClass *mc) { VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc)); virt_machine_2_12_options(mc); - SET_MACHINE_COMPAT(mc, VIRT_COMPAT_2_11); + compat_props_add(mc->compat_props, hw_compat_2_11, hw_compat_2_11_len); vmc->smbios_old_sys_ver = true; } DEFINE_VIRT_MACHINE(2, 11) -#define VIRT_COMPAT_2_10 \ - HW_COMPAT_2_10 - static void virt_machine_2_10_options(MachineClass *mc) { virt_machine_2_11_options(mc); - SET_MACHINE_COMPAT(mc, VIRT_COMPAT_2_10); + compat_props_add(mc->compat_props, hw_compat_2_10, hw_compat_2_10_len); /* before 2.11 we never faulted accesses to bad addresses */ mc->ignore_memory_transaction_failures = true; } DEFINE_VIRT_MACHINE(2, 10) -#define VIRT_COMPAT_2_9 \ - HW_COMPAT_2_9 - static void virt_machine_2_9_options(MachineClass *mc) { virt_machine_2_10_options(mc); - SET_MACHINE_COMPAT(mc, VIRT_COMPAT_2_9); + compat_props_add(mc->compat_props, hw_compat_2_9, hw_compat_2_9_len); } DEFINE_VIRT_MACHINE(2, 9) -#define VIRT_COMPAT_2_8 \ - HW_COMPAT_2_8 - static void virt_machine_2_8_options(MachineClass *mc) { VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc)); virt_machine_2_9_options(mc); - SET_MACHINE_COMPAT(mc, VIRT_COMPAT_2_8); + compat_props_add(mc->compat_props, hw_compat_2_8, hw_compat_2_8_len); /* For 2.8 and earlier we falsely claimed in the DT that * our timers were edge-triggered, not level-triggered. */ @@ -1957,15 +1935,12 @@ static void virt_machine_2_8_options(MachineClass *mc) } DEFINE_VIRT_MACHINE(2, 8) -#define VIRT_COMPAT_2_7 \ - HW_COMPAT_2_7 - static void virt_machine_2_7_options(MachineClass *mc) { VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc)); virt_machine_2_8_options(mc); - SET_MACHINE_COMPAT(mc, VIRT_COMPAT_2_7); + compat_props_add(mc->compat_props, hw_compat_2_7, hw_compat_2_7_len); /* ITS was introduced with 2.8 */ vmc->no_its = true; /* Stick with 1K pages for migration compatibility */ @@ -1973,15 +1948,12 @@ static void virt_machine_2_7_options(MachineClass *mc) } DEFINE_VIRT_MACHINE(2, 7) -#define VIRT_COMPAT_2_6 \ - HW_COMPAT_2_6 - static void virt_machine_2_6_options(MachineClass *mc) { VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc)); virt_machine_2_7_options(mc); - SET_MACHINE_COMPAT(mc, VIRT_COMPAT_2_6); + compat_props_add(mc->compat_props, hw_compat_2_6, hw_compat_2_6_len); vmc->disallow_affinity_adjustment = true; /* Disable PMU for 2.6 as PMU support was first introduced in 2.7 */ vmc->no_pmu = true; diff --git a/hw/core/machine.c b/hw/core/machine.c index 4439ea663f..f8563efb86 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -21,6 +21,334 @@ #include "sysemu/numa.h" #include "qemu/error-report.h" #include "sysemu/qtest.h" +#include "hw/pci/pci.h" + +GlobalProperty hw_compat_3_1[] = { + { + .driver = "pcie-root-port", + .property = "x-speed", + .value = "2_5", + },{ + .driver = "pcie-root-port", + .property = "x-width", + .value = "1", + },{ + .driver = "memory-backend-file", + .property = "x-use-canonical-path-for-ramblock-id", + .value = "true", + },{ + .driver = "memory-backend-memfd", + .property = "x-use-canonical-path-for-ramblock-id", + .value = "true", + }, +}; +const size_t hw_compat_3_1_len = G_N_ELEMENTS(hw_compat_3_1); + +GlobalProperty hw_compat_3_0[] = {}; +const size_t hw_compat_3_0_len = G_N_ELEMENTS(hw_compat_3_0); + +GlobalProperty hw_compat_2_12[] = { + { + .driver = "migration", + .property = "decompress-error-check", + .value = "off", + },{ + .driver = "hda-audio", + .property = "use-timer", + .value = "false", + },{ + .driver = "cirrus-vga", + .property = "global-vmstate", + .value = "true", + },{ + .driver = "VGA", + .property = "global-vmstate", + .value = "true", + },{ + .driver = "vmware-svga", + .property = "global-vmstate", + .value = "true", + },{ + .driver = "qxl-vga", + .property = "global-vmstate", + .value = "true", + }, +}; +const size_t hw_compat_2_12_len = G_N_ELEMENTS(hw_compat_2_12); + +GlobalProperty hw_compat_2_11[] = { + { + .driver = "hpet", + .property = "hpet-offset-saved", + .value = "false", + },{ + .driver = "virtio-blk-pci", + .property = "vectors", + .value = "2", + },{ + .driver = "vhost-user-blk-pci", + .property = "vectors", + .value = "2", + },{ + .driver = "e1000", + .property = "migrate_tso_props", + .value = "off", + }, +}; +const size_t hw_compat_2_11_len = G_N_ELEMENTS(hw_compat_2_11); + +GlobalProperty hw_compat_2_10[] = { + { + .driver = "virtio-mouse-device", + .property = "wheel-axis", + .value = "false", + },{ + .driver = "virtio-tablet-device", + .property = "wheel-axis", + .value = "false", + }, +}; +const size_t hw_compat_2_10_len = G_N_ELEMENTS(hw_compat_2_10); + +GlobalProperty hw_compat_2_9[] = { + { + .driver = "pci-bridge", + .property = "shpc", + .value = "off", + },{ + .driver = "intel-iommu", + .property = "pt", + .value = "off", + },{ + .driver = "virtio-net-device", + .property = "x-mtu-bypass-backend", + .value = "off", + },{ + .driver = "pcie-root-port", + .property = "x-migrate-msix", + .value = "false", + }, +}; +const size_t hw_compat_2_9_len = G_N_ELEMENTS(hw_compat_2_9); + +GlobalProperty hw_compat_2_8[] = { + { + .driver = "fw_cfg_mem", + .property = "x-file-slots", + .value = stringify(0x10), + },{ + .driver = "fw_cfg_io", + .property = "x-file-slots", + .value = stringify(0x10), + },{ + .driver = "pflash_cfi01", + .property = "old-multiple-chip-handling", + .value = "on", + },{ + .driver = "pci-bridge", + .property = "shpc", + .value = "on", + },{ + .driver = TYPE_PCI_DEVICE, + .property = "x-pcie-extcap-init", + .value = "off", + },{ + .driver = "virtio-pci", + .property = "x-pcie-deverr-init", + .value = "off", + },{ + .driver = "virtio-pci", + .property = "x-pcie-lnkctl-init", + .value = "off", + },{ + .driver = "virtio-pci", + .property = "x-pcie-pm-init", + .value = "off", + },{ + .driver = "cirrus-vga", + .property = "vgamem_mb", + .value = "8", + },{ + .driver = "isa-cirrus-vga", + .property = "vgamem_mb", + .value = "8", + }, +}; +const size_t hw_compat_2_8_len = G_N_ELEMENTS(hw_compat_2_8); + +GlobalProperty hw_compat_2_7[] = { + { + .driver = "virtio-pci", + .property = "page-per-vq", + .value = "on", + },{ + .driver = "virtio-serial-device", + .property = "emergency-write", + .value = "off", + },{ + .driver = "ioapic", + .property = "version", + .value = "0x11", + },{ + .driver = "intel-iommu", + .property = "x-buggy-eim", + .value = "true", + },{ + .driver = "virtio-pci", + .property = "x-ignore-backend-features", + .value = "on", + }, +}; +const size_t hw_compat_2_7_len = G_N_ELEMENTS(hw_compat_2_7); + +GlobalProperty hw_compat_2_6[] = { + { + .driver = "virtio-mmio", + .property = "format_transport_address", + .value = "off", + },{ + .driver = "virtio-pci", + .property = "disable-modern", + .value = "on", + },{ + .driver = "virtio-pci", + .property = "disable-legacy", + .value = "off", + }, +}; +const size_t hw_compat_2_6_len = G_N_ELEMENTS(hw_compat_2_6); + +GlobalProperty hw_compat_2_5[] = { + { + .driver = "isa-fdc", + .property = "fallback", + .value = "144", + },{ + .driver = "pvscsi", + .property = "x-old-pci-configuration", + .value = "on", + },{ + .driver = "pvscsi", + .property = "x-disable-pcie", + .value = "on", + }, + { + .driver = "vmxnet3", + .property = "x-old-msi-offsets", + .value = "on", + },{ + .driver = "vmxnet3", + .property = "x-disable-pcie", + .value = "on", + }, +}; +const size_t hw_compat_2_5_len = G_N_ELEMENTS(hw_compat_2_5); + +GlobalProperty hw_compat_2_4[] = { + { + .driver = "virtio-blk-device", + .property = "scsi", + .value = "true", + },{ + .driver = "e1000", + .property = "extra_mac_registers", + .value = "off", + },{ + .driver = "virtio-pci", + .property = "x-disable-pcie", + .value = "on", + },{ + .driver = "virtio-pci", + .property = "migrate-extra", + .value = "off", + },{ + .driver = "fw_cfg_mem", + .property = "dma_enabled", + .value = "off", + },{ + .driver = "fw_cfg_io", + .property = "dma_enabled", + .value = "off", + } +}; +const size_t hw_compat_2_4_len = G_N_ELEMENTS(hw_compat_2_4); + +GlobalProperty hw_compat_2_3[] = { + { + .driver = "virtio-blk-pci", + .property = "any_layout", + .value = "off", + },{ + .driver = "virtio-balloon-pci", + .property = "any_layout", + .value = "off", + },{ + .driver = "virtio-serial-pci", + .property = "any_layout", + .value = "off", + },{ + .driver = "virtio-9p-pci", + .property = "any_layout", + .value = "off", + },{ + .driver = "virtio-rng-pci", + .property = "any_layout", + .value = "off", + },{ + .driver = TYPE_PCI_DEVICE, + .property = "x-pcie-lnksta-dllla", + .value = "off", + },{ + .driver = "migration", + .property = "send-configuration", + .value = "off", + },{ + .driver = "migration", + .property = "send-section-footer", + .value = "off", + },{ + .driver = "migration", + .property = "store-global-state", + .value = "off", + }, +}; +const size_t hw_compat_2_3_len = G_N_ELEMENTS(hw_compat_2_3); + +GlobalProperty hw_compat_2_2[] = {}; +const size_t hw_compat_2_2_len = G_N_ELEMENTS(hw_compat_2_2); + +GlobalProperty hw_compat_2_1[] = { + { + .driver = "intel-hda", + .property = "old_msi_addr", + .value = "on", + },{ + .driver = "VGA", + .property = "qemu-extended-regs", + .value = "off", + },{ + .driver = "secondary-vga", + .property = "qemu-extended-regs", + .value = "off", + },{ + .driver = "virtio-scsi-pci", + .property = "any_layout", + .value = "off", + },{ + .driver = "usb-mouse", + .property = "usb_version", + .value = stringify(1), + },{ + .driver = "usb-kbd", + .property = "usb_version", + .value = stringify(1), + },{ + .driver = "virtio-pci", + .property = "virtio-pci-bus-master-bug-migration", + .value = "on", + }, +}; +const size_t hw_compat_2_1_len = G_N_ELEMENTS(hw_compat_2_1); static char *machine_get_accel(Object *obj, Error **errp) { @@ -647,6 +975,7 @@ static void machine_class_base_init(ObjectClass *oc, void *data) assert(g_str_has_suffix(cname, TYPE_MACHINE_SUFFIX)); mc->name = g_strndup(cname, strlen(cname) - strlen(TYPE_MACHINE_SUFFIX)); + mc->compat_props = g_ptr_array_new(); } } @@ -836,24 +1165,6 @@ void machine_run_board_init(MachineState *machine) machine_class->init(machine); } -void machine_register_compat_props(MachineState *machine) -{ - MachineClass *mc = MACHINE_GET_CLASS(machine); - int i; - GlobalProperty *p; - - if (!mc->compat_props) { - return; - } - - for (i = 0; i < mc->compat_props->len; i++) { - p = g_array_index(mc->compat_props, GlobalProperty *, i); - /* Machine compat_props must never cause errors: */ - p->errp = &error_abort; - qdev_prop_register_global(p); - } -} - static const TypeInfo machine_info = { .name = TYPE_MACHINE, .parent = TYPE_OBJECT, diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 943dc2654b..5da1439a8b 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -1173,28 +1173,35 @@ void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value) *ptr = value; } -static GList *global_props; +static GPtrArray *global_props(void) +{ + static GPtrArray *gp; + + if (!gp) { + gp = g_ptr_array_new(); + } + + return gp; +} void qdev_prop_register_global(GlobalProperty *prop) { - global_props = g_list_append(global_props, prop); + g_ptr_array_add(global_props(), prop); } int qdev_prop_check_globals(void) { - GList *l; - int ret = 0; + int i, ret = 0; - for (l = global_props; l; l = l->next) { - GlobalProperty *prop = l->data; + for (i = 0; i < global_props()->len; i++) { + GlobalProperty *prop; ObjectClass *oc; DeviceClass *dc; + + prop = g_ptr_array_index(global_props(), i); if (prop->used) { continue; } - if (!prop->user_provided) { - continue; - } oc = object_class_by_name(prop->driver); oc = object_class_dynamic_cast(oc, TYPE_DEVICE); if (!oc) { @@ -1216,28 +1223,8 @@ int qdev_prop_check_globals(void) void qdev_prop_set_globals(DeviceState *dev) { - GList *l; - - for (l = global_props; l; l = l->next) { - GlobalProperty *prop = l->data; - Error *err = NULL; - - if (object_dynamic_cast(OBJECT(dev), prop->driver) == NULL) { - continue; - } - prop->used = true; - object_property_parse(OBJECT(dev), prop->value, prop->property, &err); - if (err != NULL) { - error_prepend(&err, "can't apply global %s.%s=%s: ", - prop->driver, prop->property, prop->value); - if (!dev->hotplugged && prop->errp) { - error_propagate(prop->errp, err); - } else { - assert(prop->user_provided); - warn_report_err(err); - } - } - } + object_apply_global_props(OBJECT(dev), global_props(), + dev->hotplugged ? NULL : &error_fatal); } /* --- 64bit unsigned int 'size' type --- */ diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 6b3cc55b27..3769a2bccb 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -970,8 +970,23 @@ static void device_initfn(Object *obj) QLIST_INIT(&dev->gpios); } +void object_apply_compat_props(Object *obj) +{ + if (object_dynamic_cast(qdev_get_machine(), TYPE_MACHINE)) { + MachineState *m = MACHINE(qdev_get_machine()); + MachineClass *mc = MACHINE_GET_CLASS(m); + AccelClass *ac = ACCEL_GET_CLASS(m->accelerator); + + if (ac->compat_props) { + object_apply_global_props(obj, ac->compat_props, &error_abort); + } + object_apply_global_props(obj, mc->compat_props, &error_abort); + } +} + static void device_post_init(Object *obj) { + object_apply_compat_props(obj); qdev_prop_set_globals(DEVICE(obj)); } diff --git a/hw/i386/pc.c b/hw/i386/pc.c index f248662e97..4952feb476 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -72,6 +72,7 @@ #include "qapi/visitor.h" #include "qom/cpu.h" #include "hw/nmi.h" +#include "hw/usb.h" #include "hw/i386/intel_iommu.h" #include "hw/net/ne2000-isa.h" @@ -109,6 +110,679 @@ static struct e820_entry *e820_table; static unsigned e820_entries; struct hpet_fw_config hpet_cfg = {.count = UINT8_MAX}; +GlobalProperty pc_compat_3_1[] = { + { + .driver = "intel-iommu", + .property = "dma-drain", + .value = "off", + }, +}; +const size_t pc_compat_3_1_len = G_N_ELEMENTS(pc_compat_3_1); + +GlobalProperty pc_compat_3_0[] = { + { + .driver = TYPE_X86_CPU, + .property = "x-hv-synic-kvm-only", + .value = "on", + },{ + .driver = "Skylake-Server" "-" TYPE_X86_CPU, + .property = "pku", + .value = "off", + },{ + .driver = "Skylake-Server-IBRS" "-" TYPE_X86_CPU, + .property = "pku", + .value = "off", + }, +}; +const size_t pc_compat_3_0_len = G_N_ELEMENTS(pc_compat_3_0); + +GlobalProperty pc_compat_2_12[] = { + { + .driver = TYPE_X86_CPU, + .property = "legacy-cache", + .value = "on", + },{ + .driver = TYPE_X86_CPU, + .property = "topoext", + .value = "off", + },{ + .driver = "EPYC-" TYPE_X86_CPU, + .property = "xlevel", + .value = stringify(0x8000000a), + },{ + .driver = "EPYC-IBPB-" TYPE_X86_CPU, + .property = "xlevel", + .value = stringify(0x8000000a), + }, +}; +const size_t pc_compat_2_12_len = G_N_ELEMENTS(pc_compat_2_12); + +GlobalProperty pc_compat_2_11[] = { + { + .driver = TYPE_X86_CPU, + .property = "x-migrate-smi-count", + .value = "off", + },{ + .driver = "Skylake-Server" "-" TYPE_X86_CPU, + .property = "clflushopt", + .value = "off", + }, +}; +const size_t pc_compat_2_11_len = G_N_ELEMENTS(pc_compat_2_11); + +GlobalProperty pc_compat_2_10[] = { + { + .driver = TYPE_X86_CPU, + .property = "x-hv-max-vps", + .value = "0x40", + },{ + .driver = "i440FX-pcihost", + .property = "x-pci-hole64-fix", + .value = "off", + },{ + .driver = "q35-pcihost", + .property = "x-pci-hole64-fix", + .value = "off", + }, +}; +const size_t pc_compat_2_10_len = G_N_ELEMENTS(pc_compat_2_10); + +GlobalProperty pc_compat_2_9[] = { + { + .driver = "mch", + .property = "extended-tseg-mbytes", + .value = stringify(0), + }, +}; +const size_t pc_compat_2_9_len = G_N_ELEMENTS(pc_compat_2_9); + +GlobalProperty pc_compat_2_8[] = { + { + .driver = TYPE_X86_CPU, + .property = "tcg-cpuid", + .value = "off", + }, + { + .driver = "kvmclock", + .property = "x-mach-use-reliable-get-clock", + .value = "off", + }, + { + .driver = "ICH9-LPC", + .property = "x-smi-broadcast", + .value = "off", + }, + { + .driver = TYPE_X86_CPU, + .property = "vmware-cpuid-freq", + .value = "off", + }, + { + .driver = "Haswell-" TYPE_X86_CPU, + .property = "stepping", + .value = "1", + }, +}; +const size_t pc_compat_2_8_len = G_N_ELEMENTS(pc_compat_2_8); + +GlobalProperty pc_compat_2_7[] = { + { + .driver = TYPE_X86_CPU, + .property = "l3-cache", + .value = "off", + }, + { + .driver = TYPE_X86_CPU, + .property = "full-cpuid-auto-level", + .value = "off", + }, + { + .driver = "Opteron_G3" "-" TYPE_X86_CPU, + .property = "family", + .value = "15", + }, + { + .driver = "Opteron_G3" "-" TYPE_X86_CPU, + .property = "model", + .value = "6", + }, + { + .driver = "Opteron_G3" "-" TYPE_X86_CPU, + .property = "stepping", + .value = "1", + }, + { + .driver = "isa-pcspk", + .property = "migrate", + .value = "off", + }, +}; +const size_t pc_compat_2_7_len = G_N_ELEMENTS(pc_compat_2_7); + +GlobalProperty pc_compat_2_6[] = { + { + .driver = TYPE_X86_CPU, + .property = "cpuid-0xb", + .value = "off", + },{ + .driver = "vmxnet3", + .property = "romfile", + .value = "", + }, + { + .driver = TYPE_X86_CPU, + .property = "fill-mtrr-mask", + .value = "off", + }, + { + .driver = "apic-common", + .property = "legacy-instance-id", + .value = "on", + } +}; +const size_t pc_compat_2_6_len = G_N_ELEMENTS(pc_compat_2_6); + +GlobalProperty pc_compat_2_5[] = {}; +const size_t pc_compat_2_5_len = G_N_ELEMENTS(pc_compat_2_5); + +GlobalProperty pc_compat_2_4[] = { + PC_CPU_MODEL_IDS("2.4.0") + { + .driver = "Haswell-" TYPE_X86_CPU, + .property = "abm", + .value = "off", + }, + { + .driver = "Haswell-noTSX-" TYPE_X86_CPU, + .property = "abm", + .value = "off", + }, + { + .driver = "Broadwell-" TYPE_X86_CPU, + .property = "abm", + .value = "off", + }, + { + .driver = "Broadwell-noTSX-" TYPE_X86_CPU, + .property = "abm", + .value = "off", + }, + { + .driver = "host" "-" TYPE_X86_CPU, + .property = "host-cache-info", + .value = "on", + }, + { + .driver = TYPE_X86_CPU, + .property = "check", + .value = "off", + }, + { + .driver = "qemu64" "-" TYPE_X86_CPU, + .property = "sse4a", + .value = "on", + }, + { + .driver = "qemu64" "-" TYPE_X86_CPU, + .property = "abm", + .value = "on", + }, + { + .driver = "qemu64" "-" TYPE_X86_CPU, + .property = "popcnt", + .value = "on", + }, + { + .driver = "qemu32" "-" TYPE_X86_CPU, + .property = "popcnt", + .value = "on", + },{ + .driver = "Opteron_G2" "-" TYPE_X86_CPU, + .property = "rdtscp", + .value = "on", + },{ + .driver = "Opteron_G3" "-" TYPE_X86_CPU, + .property = "rdtscp", + .value = "on", + },{ + .driver = "Opteron_G4" "-" TYPE_X86_CPU, + .property = "rdtscp", + .value = "on", + },{ + .driver = "Opteron_G5" "-" TYPE_X86_CPU, + .property = "rdtscp", + .value = "on", + } +}; +const size_t pc_compat_2_4_len = G_N_ELEMENTS(pc_compat_2_4); + +GlobalProperty pc_compat_2_3[] = { + PC_CPU_MODEL_IDS("2.3.0") + { + .driver = TYPE_X86_CPU, + .property = "arat", + .value = "off", + },{ + .driver = "qemu64" "-" TYPE_X86_CPU, + .property = "min-level", + .value = stringify(4), + },{ + .driver = "kvm64" "-" TYPE_X86_CPU, + .property = "min-level", + .value = stringify(5), + },{ + .driver = "pentium3" "-" TYPE_X86_CPU, + .property = "min-level", + .value = stringify(2), + },{ + .driver = "n270" "-" TYPE_X86_CPU, + .property = "min-level", + .value = stringify(5), + },{ + .driver = "Conroe" "-" TYPE_X86_CPU, + .property = "min-level", + .value = stringify(4), + },{ + .driver = "Penryn" "-" TYPE_X86_CPU, + .property = "min-level", + .value = stringify(4), + },{ + .driver = "Nehalem" "-" TYPE_X86_CPU, + .property = "min-level", + .value = stringify(4), + },{ + .driver = "n270" "-" TYPE_X86_CPU, + .property = "min-xlevel", + .value = stringify(0x8000000a), + },{ + .driver = "Penryn" "-" TYPE_X86_CPU, + .property = "min-xlevel", + .value = stringify(0x8000000a), + },{ + .driver = "Conroe" "-" TYPE_X86_CPU, + .property = "min-xlevel", + .value = stringify(0x8000000a), + },{ + .driver = "Nehalem" "-" TYPE_X86_CPU, + .property = "min-xlevel", + .value = stringify(0x8000000a), + },{ + .driver = "Westmere" "-" TYPE_X86_CPU, + .property = "min-xlevel", + .value = stringify(0x8000000a), + },{ + .driver = "SandyBridge" "-" TYPE_X86_CPU, + .property = "min-xlevel", + .value = stringify(0x8000000a), + },{ + .driver = "IvyBridge" "-" TYPE_X86_CPU, + .property = "min-xlevel", + .value = stringify(0x8000000a), + },{ + .driver = "Haswell" "-" TYPE_X86_CPU, + .property = "min-xlevel", + .value = stringify(0x8000000a), + },{ + .driver = "Haswell-noTSX" "-" TYPE_X86_CPU, + .property = "min-xlevel", + .value = stringify(0x8000000a), + },{ + .driver = "Broadwell" "-" TYPE_X86_CPU, + .property = "min-xlevel", + .value = stringify(0x8000000a), + },{ + .driver = "Broadwell-noTSX" "-" TYPE_X86_CPU, + .property = "min-xlevel", + .value = stringify(0x8000000a), + },{ + .driver = TYPE_X86_CPU, + .property = "kvm-no-smi-migration", + .value = "on", + }, +}; +const size_t pc_compat_2_3_len = G_N_ELEMENTS(pc_compat_2_3); + +GlobalProperty pc_compat_2_2[] = { + PC_CPU_MODEL_IDS("2.2.0") + { + .driver = "kvm64" "-" TYPE_X86_CPU, + .property = "vme", + .value = "off", + }, + { + .driver = "kvm32" "-" TYPE_X86_CPU, + .property = "vme", + .value = "off", + }, + { + .driver = "Conroe" "-" TYPE_X86_CPU, + .property = "vme", + .value = "off", + }, + { + .driver = "Penryn" "-" TYPE_X86_CPU, + .property = "vme", + .value = "off", + }, + { + .driver = "Nehalem" "-" TYPE_X86_CPU, + .property = "vme", + .value = "off", + }, + { + .driver = "Westmere" "-" TYPE_X86_CPU, + .property = "vme", + .value = "off", + }, + { + .driver = "SandyBridge" "-" TYPE_X86_CPU, + .property = "vme", + .value = "off", + }, + { + .driver = "Haswell" "-" TYPE_X86_CPU, + .property = "vme", + .value = "off", + }, + { + .driver = "Broadwell" "-" TYPE_X86_CPU, + .property = "vme", + .value = "off", + }, + { + .driver = "Opteron_G1" "-" TYPE_X86_CPU, + .property = "vme", + .value = "off", + }, + { + .driver = "Opteron_G2" "-" TYPE_X86_CPU, + .property = "vme", + .value = "off", + }, + { + .driver = "Opteron_G3" "-" TYPE_X86_CPU, + .property = "vme", + .value = "off", + }, + { + .driver = "Opteron_G4" "-" TYPE_X86_CPU, + .property = "vme", + .value = "off", + }, + { + .driver = "Opteron_G5" "-" TYPE_X86_CPU, + .property = "vme", + .value = "off", + }, + { + .driver = "Haswell" "-" TYPE_X86_CPU, + .property = "f16c", + .value = "off", + }, + { + .driver = "Haswell" "-" TYPE_X86_CPU, + .property = "rdrand", + .value = "off", + }, + { + .driver = "Broadwell" "-" TYPE_X86_CPU, + .property = "f16c", + .value = "off", + }, + { + .driver = "Broadwell" "-" TYPE_X86_CPU, + .property = "rdrand", + .value = "off", + }, +}; +const size_t pc_compat_2_2_len = G_N_ELEMENTS(pc_compat_2_2); + +GlobalProperty pc_compat_2_1[] = { + PC_CPU_MODEL_IDS("2.1.0") + { + .driver = "coreduo" "-" TYPE_X86_CPU, + .property = "vmx", + .value = "on", + }, + { + .driver = "core2duo" "-" TYPE_X86_CPU, + .property = "vmx", + .value = "on", + }, +}; +const size_t pc_compat_2_1_len = G_N_ELEMENTS(pc_compat_2_1); + +GlobalProperty pc_compat_2_0[] = { + PC_CPU_MODEL_IDS("2.0.0") + { + .driver = "virtio-scsi-pci", + .property = "any_layout", + .value = "off", + },{ + .driver = "PIIX4_PM", + .property = "memory-hotplug-support", + .value = "off", + }, + { + .driver = "apic", + .property = "version", + .value = stringify(0x11), + }, + { + .driver = "nec-usb-xhci", + .property = "superspeed-ports-first", + .value = "off", + }, + { + .driver = "nec-usb-xhci", + .property = "force-pcie-endcap", + .value = "on", + }, + { + .driver = "pci-serial", + .property = "prog_if", + .value = stringify(0), + }, + { + .driver = "pci-serial-2x", + .property = "prog_if", + .value = stringify(0), + }, + { + .driver = "pci-serial-4x", + .property = "prog_if", + .value = stringify(0), + }, + { + .driver = "virtio-net-pci", + .property = "guest_announce", + .value = "off", + }, + { + .driver = "ICH9-LPC", + .property = "memory-hotplug-support", + .value = "off", + },{ + .driver = "xio3130-downstream", + .property = COMPAT_PROP_PCP, + .value = "off", + },{ + .driver = "ioh3420", + .property = COMPAT_PROP_PCP, + .value = "off", + }, +}; +const size_t pc_compat_2_0_len = G_N_ELEMENTS(pc_compat_2_0); + +GlobalProperty pc_compat_1_7[] = { + PC_CPU_MODEL_IDS("1.7.0") + { + .driver = TYPE_USB_DEVICE, + .property = "msos-desc", + .value = "no", + }, + { + .driver = "PIIX4_PM", + .property = "acpi-pci-hotplug-with-bridge-support", + .value = "off", + }, + { + .driver = "hpet", + .property = HPET_INTCAP, + .value = stringify(4), + }, +}; +const size_t pc_compat_1_7_len = G_N_ELEMENTS(pc_compat_1_7); + +GlobalProperty pc_compat_1_6[] = { + PC_CPU_MODEL_IDS("1.6.0") + { + .driver = "e1000", + .property = "mitigation", + .value = "off", + },{ + .driver = "qemu64-" TYPE_X86_CPU, + .property = "model", + .value = stringify(2), + },{ + .driver = "qemu32-" TYPE_X86_CPU, + .property = "model", + .value = stringify(3), + },{ + .driver = "i440FX-pcihost", + .property = "short_root_bus", + .value = stringify(1), + },{ + .driver = "q35-pcihost", + .property = "short_root_bus", + .value = stringify(1), + }, +}; +const size_t pc_compat_1_6_len = G_N_ELEMENTS(pc_compat_1_6); + +GlobalProperty pc_compat_1_5[] = { + PC_CPU_MODEL_IDS("1.5.0") + { + .driver = "Conroe-" TYPE_X86_CPU, + .property = "model", + .value = stringify(2), + },{ + .driver = "Conroe-" TYPE_X86_CPU, + .property = "min-level", + .value = stringify(2), + },{ + .driver = "Penryn-" TYPE_X86_CPU, + .property = "model", + .value = stringify(2), + },{ + .driver = "Penryn-" TYPE_X86_CPU, + .property = "min-level", + .value = stringify(2), + },{ + .driver = "Nehalem-" TYPE_X86_CPU, + .property = "model", + .value = stringify(2), + },{ + .driver = "Nehalem-" TYPE_X86_CPU, + .property = "min-level", + .value = stringify(2), + },{ + .driver = "virtio-net-pci", + .property = "any_layout", + .value = "off", + },{ + .driver = TYPE_X86_CPU, + .property = "pmu", + .value = "on", + },{ + .driver = "i440FX-pcihost", + .property = "short_root_bus", + .value = stringify(0), + },{ + .driver = "q35-pcihost", + .property = "short_root_bus", + .value = stringify(0), + }, +}; +const size_t pc_compat_1_5_len = G_N_ELEMENTS(pc_compat_1_5); + +GlobalProperty pc_compat_1_4[] = { + PC_CPU_MODEL_IDS("1.4.0") + { + .driver = "scsi-hd", + .property = "discard_granularity", + .value = stringify(0), + },{ + .driver = "scsi-cd", + .property = "discard_granularity", + .value = stringify(0), + },{ + .driver = "scsi-disk", + .property = "discard_granularity", + .value = stringify(0), + },{ + .driver = "ide-hd", + .property = "discard_granularity", + .value = stringify(0), + },{ + .driver = "ide-cd", + .property = "discard_granularity", + .value = stringify(0), + },{ + .driver = "ide-drive", + .property = "discard_granularity", + .value = stringify(0), + },{ + .driver = "virtio-blk-pci", + .property = "discard_granularity", + .value = stringify(0), + },{ + .driver = "virtio-serial-pci", + .property = "vectors", + /* DEV_NVECTORS_UNSPECIFIED as a uint32_t string */ + .value = stringify(0xFFFFFFFF), + },{ + .driver = "virtio-net-pci", + .property = "ctrl_guest_offloads", + .value = "off", + },{ + .driver = "e1000", + .property = "romfile", + .value = "pxe-e1000.rom", + },{ + .driver = "ne2k_pci", + .property = "romfile", + .value = "pxe-ne2k_pci.rom", + },{ + .driver = "pcnet", + .property = "romfile", + .value = "pxe-pcnet.rom", + },{ + .driver = "rtl8139", + .property = "romfile", + .value = "pxe-rtl8139.rom", + },{ + .driver = "virtio-net-pci", + .property = "romfile", + .value = "pxe-virtio.rom", + },{ + .driver = "486-" TYPE_X86_CPU, + .property = "model", + .value = stringify(0), + }, + { + .driver = "n270" "-" TYPE_X86_CPU, + .property = "movbe", + .value = "off", + }, + { + .driver = "Westmere" "-" TYPE_X86_CPU, + .property = "pclmulqdq", + .value = "off", + }, +}; +const size_t pc_compat_1_4_len = G_N_ELEMENTS(pc_compat_1_4); + void gsi_handler(void *opaque, int n, int level) { GSIState *s = opaque; diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 7f1cb527b5..ed6984638e 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -310,7 +310,7 @@ static void pc_init1(MachineState *machine, * HW_COMPAT_*, PC_COMPAT_*, or * pc_*_machine_options(). */ -static void pc_compat_2_3(MachineState *machine) +static void pc_compat_2_3_fn(MachineState *machine) { PCMachineState *pcms = PC_MACHINE(machine); if (kvm_enabled()) { @@ -318,46 +318,46 @@ static void pc_compat_2_3(MachineState *machine) } } -static void pc_compat_2_2(MachineState *machine) +static void pc_compat_2_2_fn(MachineState *machine) { - pc_compat_2_3(machine); + pc_compat_2_3_fn(machine); } -static void pc_compat_2_1(MachineState *machine) +static void pc_compat_2_1_fn(MachineState *machine) { - pc_compat_2_2(machine); + pc_compat_2_2_fn(machine); x86_cpu_change_kvm_default("svm", NULL); } -static void pc_compat_2_0(MachineState *machine) +static void pc_compat_2_0_fn(MachineState *machine) { - pc_compat_2_1(machine); + pc_compat_2_1_fn(machine); } -static void pc_compat_1_7(MachineState *machine) +static void pc_compat_1_7_fn(MachineState *machine) { - pc_compat_2_0(machine); + pc_compat_2_0_fn(machine); x86_cpu_change_kvm_default("x2apic", NULL); } -static void pc_compat_1_6(MachineState *machine) +static void pc_compat_1_6_fn(MachineState *machine) { - pc_compat_1_7(machine); + pc_compat_1_7_fn(machine); } -static void pc_compat_1_5(MachineState *machine) +static void pc_compat_1_5_fn(MachineState *machine) { - pc_compat_1_6(machine); + pc_compat_1_6_fn(machine); } -static void pc_compat_1_4(MachineState *machine) +static void pc_compat_1_4_fn(MachineState *machine) { - pc_compat_1_5(machine); + pc_compat_1_5_fn(machine); } static void pc_compat_1_3(MachineState *machine) { - pc_compat_1_4(machine); + pc_compat_1_4_fn(machine); enable_compat_apic_id_mode(); } @@ -443,7 +443,8 @@ static void pc_i440fx_3_1_machine_options(MachineClass *m) pc_i440fx_4_0_machine_options(m); m->is_default = 0; m->alias = NULL; - SET_MACHINE_COMPAT(m, PC_COMPAT_3_1); + compat_props_add(m->compat_props, hw_compat_3_1, hw_compat_3_1_len); + compat_props_add(m->compat_props, pc_compat_3_1, pc_compat_3_1_len); } DEFINE_I440FX_MACHINE(v3_1, "pc-i440fx-3.1", NULL, @@ -452,7 +453,8 @@ DEFINE_I440FX_MACHINE(v3_1, "pc-i440fx-3.1", NULL, static void pc_i440fx_3_0_machine_options(MachineClass *m) { pc_i440fx_3_1_machine_options(m); - SET_MACHINE_COMPAT(m, PC_COMPAT_3_0); + compat_props_add(m->compat_props, hw_compat_3_0, hw_compat_3_0_len); + compat_props_add(m->compat_props, pc_compat_3_0, pc_compat_3_0_len); } DEFINE_I440FX_MACHINE(v3_0, "pc-i440fx-3.0", NULL, @@ -461,7 +463,8 @@ DEFINE_I440FX_MACHINE(v3_0, "pc-i440fx-3.0", NULL, static void pc_i440fx_2_12_machine_options(MachineClass *m) { pc_i440fx_3_0_machine_options(m); - SET_MACHINE_COMPAT(m, PC_COMPAT_2_12); + compat_props_add(m->compat_props, hw_compat_2_12, hw_compat_2_12_len); + compat_props_add(m->compat_props, pc_compat_2_12, pc_compat_2_12_len); } DEFINE_I440FX_MACHINE(v2_12, "pc-i440fx-2.12", NULL, @@ -470,7 +473,8 @@ DEFINE_I440FX_MACHINE(v2_12, "pc-i440fx-2.12", NULL, static void pc_i440fx_2_11_machine_options(MachineClass *m) { pc_i440fx_2_12_machine_options(m); - SET_MACHINE_COMPAT(m, PC_COMPAT_2_11); + compat_props_add(m->compat_props, hw_compat_2_11, hw_compat_2_11_len); + compat_props_add(m->compat_props, pc_compat_2_11, pc_compat_2_11_len); } DEFINE_I440FX_MACHINE(v2_11, "pc-i440fx-2.11", NULL, @@ -479,7 +483,8 @@ DEFINE_I440FX_MACHINE(v2_11, "pc-i440fx-2.11", NULL, static void pc_i440fx_2_10_machine_options(MachineClass *m) { pc_i440fx_2_11_machine_options(m); - SET_MACHINE_COMPAT(m, PC_COMPAT_2_10); + compat_props_add(m->compat_props, hw_compat_2_10, hw_compat_2_10_len); + compat_props_add(m->compat_props, pc_compat_2_10, pc_compat_2_10_len); m->auto_enable_numa_with_memhp = false; } @@ -489,7 +494,8 @@ DEFINE_I440FX_MACHINE(v2_10, "pc-i440fx-2.10", NULL, static void pc_i440fx_2_9_machine_options(MachineClass *m) { pc_i440fx_2_10_machine_options(m); - SET_MACHINE_COMPAT(m, PC_COMPAT_2_9); + compat_props_add(m->compat_props, hw_compat_2_9, hw_compat_2_9_len); + compat_props_add(m->compat_props, pc_compat_2_9, pc_compat_2_9_len); m->numa_auto_assign_ram = numa_legacy_auto_assign_ram; } @@ -499,109 +505,114 @@ DEFINE_I440FX_MACHINE(v2_9, "pc-i440fx-2.9", NULL, static void pc_i440fx_2_8_machine_options(MachineClass *m) { pc_i440fx_2_9_machine_options(m); - SET_MACHINE_COMPAT(m, PC_COMPAT_2_8); + compat_props_add(m->compat_props, hw_compat_2_8, hw_compat_2_8_len); + compat_props_add(m->compat_props, pc_compat_2_8, pc_compat_2_8_len); } DEFINE_I440FX_MACHINE(v2_8, "pc-i440fx-2.8", NULL, pc_i440fx_2_8_machine_options); - static void pc_i440fx_2_7_machine_options(MachineClass *m) { pc_i440fx_2_8_machine_options(m); - SET_MACHINE_COMPAT(m, PC_COMPAT_2_7); + compat_props_add(m->compat_props, hw_compat_2_7, hw_compat_2_7_len); + compat_props_add(m->compat_props, pc_compat_2_7, pc_compat_2_7_len); } DEFINE_I440FX_MACHINE(v2_7, "pc-i440fx-2.7", NULL, pc_i440fx_2_7_machine_options); - static void pc_i440fx_2_6_machine_options(MachineClass *m) { PCMachineClass *pcmc = PC_MACHINE_CLASS(m); + pc_i440fx_2_7_machine_options(m); pcmc->legacy_cpu_hotplug = true; pcmc->linuxboot_dma_enabled = false; - SET_MACHINE_COMPAT(m, PC_COMPAT_2_6); + compat_props_add(m->compat_props, hw_compat_2_6, hw_compat_2_6_len); + compat_props_add(m->compat_props, pc_compat_2_6, pc_compat_2_6_len); } DEFINE_I440FX_MACHINE(v2_6, "pc-i440fx-2.6", NULL, pc_i440fx_2_6_machine_options); - static void pc_i440fx_2_5_machine_options(MachineClass *m) { PCMachineClass *pcmc = PC_MACHINE_CLASS(m); + pc_i440fx_2_6_machine_options(m); pcmc->save_tsc_khz = false; m->legacy_fw_cfg_order = 1; - SET_MACHINE_COMPAT(m, PC_COMPAT_2_5); + compat_props_add(m->compat_props, hw_compat_2_5, hw_compat_2_5_len); + compat_props_add(m->compat_props, pc_compat_2_5, pc_compat_2_5_len); } DEFINE_I440FX_MACHINE(v2_5, "pc-i440fx-2.5", NULL, pc_i440fx_2_5_machine_options); - static void pc_i440fx_2_4_machine_options(MachineClass *m) { PCMachineClass *pcmc = PC_MACHINE_CLASS(m); + pc_i440fx_2_5_machine_options(m); m->hw_version = "2.4.0"; pcmc->broken_reserved_end = true; - SET_MACHINE_COMPAT(m, PC_COMPAT_2_4); + compat_props_add(m->compat_props, hw_compat_2_4, hw_compat_2_4_len); + compat_props_add(m->compat_props, pc_compat_2_4, pc_compat_2_4_len); } DEFINE_I440FX_MACHINE(v2_4, "pc-i440fx-2.4", NULL, pc_i440fx_2_4_machine_options) - static void pc_i440fx_2_3_machine_options(MachineClass *m) { pc_i440fx_2_4_machine_options(m); m->hw_version = "2.3.0"; - SET_MACHINE_COMPAT(m, PC_COMPAT_2_3); + compat_props_add(m->compat_props, hw_compat_2_3, hw_compat_2_3_len); + compat_props_add(m->compat_props, pc_compat_2_3, pc_compat_2_3_len); } -DEFINE_I440FX_MACHINE(v2_3, "pc-i440fx-2.3", pc_compat_2_3, +DEFINE_I440FX_MACHINE(v2_3, "pc-i440fx-2.3", pc_compat_2_3_fn, pc_i440fx_2_3_machine_options); - static void pc_i440fx_2_2_machine_options(MachineClass *m) { PCMachineClass *pcmc = PC_MACHINE_CLASS(m); + pc_i440fx_2_3_machine_options(m); m->hw_version = "2.2.0"; m->default_machine_opts = "firmware=bios-256k.bin,suppress-vmdesc=on"; - SET_MACHINE_COMPAT(m, PC_COMPAT_2_2); + compat_props_add(m->compat_props, hw_compat_2_2, hw_compat_2_2_len); + compat_props_add(m->compat_props, pc_compat_2_2, pc_compat_2_2_len); pcmc->rsdp_in_ram = false; } -DEFINE_I440FX_MACHINE(v2_2, "pc-i440fx-2.2", pc_compat_2_2, +DEFINE_I440FX_MACHINE(v2_2, "pc-i440fx-2.2", pc_compat_2_2_fn, pc_i440fx_2_2_machine_options); - static void pc_i440fx_2_1_machine_options(MachineClass *m) { PCMachineClass *pcmc = PC_MACHINE_CLASS(m); + pc_i440fx_2_2_machine_options(m); m->hw_version = "2.1.0"; m->default_display = NULL; - SET_MACHINE_COMPAT(m, PC_COMPAT_2_1); + compat_props_add(m->compat_props, hw_compat_2_1, hw_compat_2_1_len); + compat_props_add(m->compat_props, pc_compat_2_1, pc_compat_2_1_len); pcmc->smbios_uuid_encoded = false; pcmc->enforce_aligned_dimm = false; } -DEFINE_I440FX_MACHINE(v2_1, "pc-i440fx-2.1", pc_compat_2_1, +DEFINE_I440FX_MACHINE(v2_1, "pc-i440fx-2.1", pc_compat_2_1_fn, pc_i440fx_2_1_machine_options); - - static void pc_i440fx_2_0_machine_options(MachineClass *m) { PCMachineClass *pcmc = PC_MACHINE_CLASS(m); + pc_i440fx_2_1_machine_options(m); m->hw_version = "2.0.0"; - SET_MACHINE_COMPAT(m, PC_COMPAT_2_0); + compat_props_add(m->compat_props, pc_compat_2_0, pc_compat_2_0_len); pcmc->smbios_legacy_mode = true; pcmc->has_reserved_memory = false; /* This value depends on the actual DSDT and SSDT compiled into @@ -624,329 +635,330 @@ static void pc_i440fx_2_0_machine_options(MachineClass *m) pcmc->acpi_data_size = 0x10000; } -DEFINE_I440FX_MACHINE(v2_0, "pc-i440fx-2.0", pc_compat_2_0, +DEFINE_I440FX_MACHINE(v2_0, "pc-i440fx-2.0", pc_compat_2_0_fn, pc_i440fx_2_0_machine_options); - static void pc_i440fx_1_7_machine_options(MachineClass *m) { PCMachineClass *pcmc = PC_MACHINE_CLASS(m); + pc_i440fx_2_0_machine_options(m); m->hw_version = "1.7.0"; m->default_machine_opts = NULL; m->option_rom_has_mr = true; - SET_MACHINE_COMPAT(m, PC_COMPAT_1_7); + compat_props_add(m->compat_props, pc_compat_1_7, pc_compat_1_7_len); pcmc->smbios_defaults = false; pcmc->gigabyte_align = false; pcmc->legacy_acpi_table_size = 6414; } -DEFINE_I440FX_MACHINE(v1_7, "pc-i440fx-1.7", pc_compat_1_7, +DEFINE_I440FX_MACHINE(v1_7, "pc-i440fx-1.7", pc_compat_1_7_fn, pc_i440fx_1_7_machine_options); - static void pc_i440fx_1_6_machine_options(MachineClass *m) { PCMachineClass *pcmc = PC_MACHINE_CLASS(m); + pc_i440fx_1_7_machine_options(m); m->hw_version = "1.6.0"; m->rom_file_has_mr = false; - SET_MACHINE_COMPAT(m, PC_COMPAT_1_6); + compat_props_add(m->compat_props, pc_compat_1_6, pc_compat_1_6_len); pcmc->has_acpi_build = false; } -DEFINE_I440FX_MACHINE(v1_6, "pc-i440fx-1.6", pc_compat_1_6, +DEFINE_I440FX_MACHINE(v1_6, "pc-i440fx-1.6", pc_compat_1_6_fn, pc_i440fx_1_6_machine_options); - static void pc_i440fx_1_5_machine_options(MachineClass *m) { pc_i440fx_1_6_machine_options(m); m->hw_version = "1.5.0"; - SET_MACHINE_COMPAT(m, PC_COMPAT_1_5); + compat_props_add(m->compat_props, pc_compat_1_5, pc_compat_1_5_len); } -DEFINE_I440FX_MACHINE(v1_5, "pc-i440fx-1.5", pc_compat_1_5, +DEFINE_I440FX_MACHINE(v1_5, "pc-i440fx-1.5", pc_compat_1_5_fn, pc_i440fx_1_5_machine_options); - static void pc_i440fx_1_4_machine_options(MachineClass *m) { pc_i440fx_1_5_machine_options(m); m->hw_version = "1.4.0"; m->hot_add_cpu = NULL; - SET_MACHINE_COMPAT(m, PC_COMPAT_1_4); + compat_props_add(m->compat_props, pc_compat_1_4, pc_compat_1_4_len); } -DEFINE_I440FX_MACHINE(v1_4, "pc-i440fx-1.4", pc_compat_1_4, +DEFINE_I440FX_MACHINE(v1_4, "pc-i440fx-1.4", pc_compat_1_4_fn, pc_i440fx_1_4_machine_options); - -#define PC_COMPAT_1_3 \ - PC_CPU_MODEL_IDS("1.3.0") \ - {\ - .driver = "usb-tablet",\ - .property = "usb_version",\ - .value = stringify(1),\ - },{\ - .driver = "virtio-net-pci",\ - .property = "ctrl_mac_addr",\ - .value = "off", \ - },{ \ - .driver = "virtio-net-pci", \ - .property = "mq", \ - .value = "off", \ - }, {\ - .driver = "e1000",\ - .property = "autonegotiation",\ - .value = "off",\ - }, - - static void pc_i440fx_1_3_machine_options(MachineClass *m) { + static GlobalProperty compat[] = { + PC_CPU_MODEL_IDS("1.3.0") + { + .driver = "usb-tablet", + .property = "usb_version", + .value = stringify(1), + },{ + .driver = "virtio-net-pci", + .property = "ctrl_mac_addr", + .value = "off", + },{ + .driver = "virtio-net-pci", + .property = "mq", + .value = "off", + }, { + .driver = "e1000", + .property = "autonegotiation", + .value = "off", + }, + }; + pc_i440fx_1_4_machine_options(m); m->hw_version = "1.3.0"; - SET_MACHINE_COMPAT(m, PC_COMPAT_1_3); + compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat)); } DEFINE_I440FX_MACHINE(v1_3, "pc-1.3", pc_compat_1_3, pc_i440fx_1_3_machine_options); -#define PC_COMPAT_1_2 \ - PC_CPU_MODEL_IDS("1.2.0") \ - {\ - .driver = "nec-usb-xhci",\ - .property = "msi",\ - .value = "off",\ - },{\ - .driver = "nec-usb-xhci",\ - .property = "msix",\ - .value = "off",\ - },{\ - .driver = "ivshmem",\ - .property = "use64",\ - .value = "0",\ - },{\ - .driver = "qxl",\ - .property = "revision",\ - .value = stringify(3),\ - },{\ - .driver = "qxl-vga",\ - .property = "revision",\ - .value = stringify(3),\ - },{\ - .driver = "VGA",\ - .property = "mmio",\ - .value = "off",\ - }, - static void pc_i440fx_1_2_machine_options(MachineClass *m) { + static GlobalProperty compat[] = { + PC_CPU_MODEL_IDS("1.2.0") + { + .driver = "nec-usb-xhci", + .property = "msi", + .value = "off", + },{ + .driver = "nec-usb-xhci", + .property = "msix", + .value = "off", + },{ + .driver = "ivshmem", + .property = "use64", + .value = "0", + },{ + .driver = "qxl", + .property = "revision", + .value = stringify(3), + },{ + .driver = "qxl-vga", + .property = "revision", + .value = stringify(3), + },{ + .driver = "VGA", + .property = "mmio", + .value = "off", + }, + }; + pc_i440fx_1_3_machine_options(m); m->hw_version = "1.2.0"; - SET_MACHINE_COMPAT(m, PC_COMPAT_1_2); + compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat)); } DEFINE_I440FX_MACHINE(v1_2, "pc-1.2", pc_compat_1_2, pc_i440fx_1_2_machine_options); -#define PC_COMPAT_1_1 \ - PC_CPU_MODEL_IDS("1.1.0") \ - {\ - .driver = "virtio-scsi-pci",\ - .property = "hotplug",\ - .value = "off",\ - },{\ - .driver = "virtio-scsi-pci",\ - .property = "param_change",\ - .value = "off",\ - },{\ - .driver = "VGA",\ - .property = "vgamem_mb",\ - .value = stringify(8),\ - },{\ - .driver = "vmware-svga",\ - .property = "vgamem_mb",\ - .value = stringify(8),\ - },{\ - .driver = "qxl-vga",\ - .property = "vgamem_mb",\ - .value = stringify(8),\ - },{\ - .driver = "qxl",\ - .property = "vgamem_mb",\ - .value = stringify(8),\ - },{\ - .driver = "virtio-blk-pci",\ - .property = "config-wce",\ - .value = "off",\ - }, - static void pc_i440fx_1_1_machine_options(MachineClass *m) { + static GlobalProperty compat[] = { + PC_CPU_MODEL_IDS("1.1.0") + { + .driver = "virtio-scsi-pci", + .property = "hotplug", + .value = "off", + },{ + .driver = "virtio-scsi-pci", + .property = "param_change", + .value = "off", + },{ + .driver = "VGA", + .property = "vgamem_mb", + .value = stringify(8), + },{ + .driver = "vmware-svga", + .property = "vgamem_mb", + .value = stringify(8), + },{ + .driver = "qxl-vga", + .property = "vgamem_mb", + .value = stringify(8), + },{ + .driver = "qxl", + .property = "vgamem_mb", + .value = stringify(8), + },{ + .driver = "virtio-blk-pci", + .property = "config-wce", + .value = "off", + }, + }; + pc_i440fx_1_2_machine_options(m); m->hw_version = "1.1.0"; - SET_MACHINE_COMPAT(m, PC_COMPAT_1_1); + compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat)); } DEFINE_I440FX_MACHINE(v1_1, "pc-1.1", pc_compat_1_2, pc_i440fx_1_1_machine_options); - -#define PC_COMPAT_1_0 \ - PC_CPU_MODEL_IDS("1.0") \ - {\ - .driver = TYPE_ISA_FDC,\ - .property = "check_media_rate",\ - .value = "off",\ - }, {\ - .driver = "virtio-balloon-pci",\ - .property = "class",\ - .value = stringify(PCI_CLASS_MEMORY_RAM),\ - },{\ - .driver = "apic-common",\ - .property = "vapic",\ - .value = "off",\ - },{\ - .driver = TYPE_USB_DEVICE,\ - .property = "full-path",\ - .value = "no",\ - }, - static void pc_i440fx_1_0_machine_options(MachineClass *m) { + static GlobalProperty compat[] = { + PC_CPU_MODEL_IDS("1.0") + { + .driver = TYPE_ISA_FDC, + .property = "check_media_rate", + .value = "off", + },{ + .driver = "virtio-balloon-pci", + .property = "class", + .value = stringify(PCI_CLASS_MEMORY_RAM), + },{ + .driver = "apic-common", + .property = "vapic", + .value = "off", + },{ + .driver = TYPE_USB_DEVICE, + .property = "full-path", + .value = "no", + }, + }; + pc_i440fx_1_1_machine_options(m); m->hw_version = "1.0"; - SET_MACHINE_COMPAT(m, PC_COMPAT_1_0); + compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat)); } DEFINE_I440FX_MACHINE(v1_0, "pc-1.0", pc_compat_1_2, pc_i440fx_1_0_machine_options); -#define PC_COMPAT_0_15 \ - PC_CPU_MODEL_IDS("0.15") - static void pc_i440fx_0_15_machine_options(MachineClass *m) { + static GlobalProperty compat[] = { + PC_CPU_MODEL_IDS("0.15") + }; + pc_i440fx_1_0_machine_options(m); m->hw_version = "0.15"; m->deprecation_reason = "use a newer machine type instead"; - SET_MACHINE_COMPAT(m, PC_COMPAT_0_15); + compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat)); } DEFINE_I440FX_MACHINE(v0_15, "pc-0.15", pc_compat_1_2, pc_i440fx_0_15_machine_options); -#define PC_COMPAT_0_14 \ - PC_CPU_MODEL_IDS("0.14") \ - {\ - .driver = "virtio-blk-pci",\ - .property = "event_idx",\ - .value = "off",\ - },{\ - .driver = "virtio-serial-pci",\ - .property = "event_idx",\ - .value = "off",\ - },{\ - .driver = "virtio-net-pci",\ - .property = "event_idx",\ - .value = "off",\ - },{\ - .driver = "virtio-balloon-pci",\ - .property = "event_idx",\ - .value = "off",\ - },{\ - .driver = "qxl",\ - .property = "revision",\ - .value = stringify(2),\ - },{\ - .driver = "qxl-vga",\ - .property = "revision",\ - .value = stringify(2),\ - }, - static void pc_i440fx_0_14_machine_options(MachineClass *m) { + static GlobalProperty compat[] = { + PC_CPU_MODEL_IDS("0.14") + { + .driver = "virtio-blk-pci", + .property = "event_idx", + .value = "off", + },{ + .driver = "virtio-serial-pci", + .property = "event_idx", + .value = "off", + },{ + .driver = "virtio-net-pci", + .property = "event_idx", + .value = "off", + },{ + .driver = "virtio-balloon-pci", + .property = "event_idx", + .value = "off", + },{ + .driver = "qxl", + .property = "revision", + .value = stringify(2), + },{ + .driver = "qxl-vga", + .property = "revision", + .value = stringify(2), + }, + }; + pc_i440fx_0_15_machine_options(m); m->hw_version = "0.14"; - SET_MACHINE_COMPAT(m, PC_COMPAT_0_14); + compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat)); } DEFINE_I440FX_MACHINE(v0_14, "pc-0.14", pc_compat_1_2, pc_i440fx_0_14_machine_options); - -#define PC_COMPAT_0_13 \ - PC_CPU_MODEL_IDS("0.13") \ - {\ - .driver = TYPE_PCI_DEVICE,\ - .property = "command_serr_enable",\ - .value = "off",\ - },{\ - .driver = "AC97",\ - .property = "use_broken_id",\ - .value = stringify(1),\ - },{\ - .driver = "virtio-9p-pci",\ - .property = "vectors",\ - .value = stringify(0),\ - },{\ - .driver = "VGA",\ - .property = "rombar",\ - .value = stringify(0),\ - },{\ - .driver = "vmware-svga",\ - .property = "rombar",\ - .value = stringify(0),\ - }, - static void pc_i440fx_0_13_machine_options(MachineClass *m) { PCMachineClass *pcmc = PC_MACHINE_CLASS(m); + static GlobalProperty compat[] = { + PC_CPU_MODEL_IDS("0.13") + { + .driver = TYPE_PCI_DEVICE, + .property = "command_serr_enable", + .value = "off", + },{ + .driver = "AC97", + .property = "use_broken_id", + .value = stringify(1), + },{ + .driver = "virtio-9p-pci", + .property = "vectors", + .value = stringify(0), + },{ + .driver = "VGA", + .property = "rombar", + .value = stringify(0), + },{ + .driver = "vmware-svga", + .property = "rombar", + .value = stringify(0), + }, + }; + pc_i440fx_0_14_machine_options(m); m->hw_version = "0.13"; - SET_MACHINE_COMPAT(m, PC_COMPAT_0_13); + compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat)); pcmc->kvmclock_enabled = false; } DEFINE_I440FX_MACHINE(v0_13, "pc-0.13", pc_compat_0_13, pc_i440fx_0_13_machine_options); - -#define PC_COMPAT_0_12 \ - PC_CPU_MODEL_IDS("0.12") \ - {\ - .driver = "virtio-serial-pci",\ - .property = "max_ports",\ - .value = stringify(1),\ - },{\ - .driver = "virtio-serial-pci",\ - .property = "vectors",\ - .value = stringify(0),\ - },{\ - .driver = "usb-mouse",\ - .property = "serial",\ - .value = "1",\ - },{\ - .driver = "usb-tablet",\ - .property = "serial",\ - .value = "1",\ - },{\ - .driver = "usb-kbd",\ - .property = "serial",\ - .value = "1",\ - }, - static void pc_i440fx_0_12_machine_options(MachineClass *m) { + static GlobalProperty compat[] = { + PC_CPU_MODEL_IDS("0.12") + { + .driver = "virtio-serial-pci", + .property = "max_ports", + .value = stringify(1), + },{ + .driver = "virtio-serial-pci", + .property = "vectors", + .value = stringify(0), + },{ + .driver = "usb-mouse", + .property = "serial", + .value = "1", + },{ + .driver = "usb-tablet", + .property = "serial", + .value = "1", + },{ + .driver = "usb-kbd", + .property = "serial", + .value = "1", + }, + }; + pc_i440fx_0_13_machine_options(m); m->hw_version = "0.12"; - SET_MACHINE_COMPAT(m, PC_COMPAT_0_12); + compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat)); } DEFINE_I440FX_MACHINE(v0_12, "pc-0.12", pc_compat_0_13, diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 0a3f3f18e4..94494e6441 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -326,7 +326,8 @@ static void pc_q35_3_1_machine_options(MachineClass *m) pc_q35_4_0_machine_options(m); m->default_kernel_irqchip_split = false; m->alias = NULL; - SET_MACHINE_COMPAT(m, PC_COMPAT_3_1); + compat_props_add(m->compat_props, hw_compat_3_1, hw_compat_3_1_len); + compat_props_add(m->compat_props, pc_compat_3_1, pc_compat_3_1_len); } DEFINE_Q35_MACHINE(v3_1, "pc-q35-3.1", NULL, @@ -335,7 +336,8 @@ DEFINE_Q35_MACHINE(v3_1, "pc-q35-3.1", NULL, static void pc_q35_3_0_machine_options(MachineClass *m) { pc_q35_3_1_machine_options(m); - SET_MACHINE_COMPAT(m, PC_COMPAT_3_0); + compat_props_add(m->compat_props, hw_compat_3_0, hw_compat_3_0_len); + compat_props_add(m->compat_props, pc_compat_3_0, pc_compat_3_0_len); } DEFINE_Q35_MACHINE(v3_0, "pc-q35-3.0", NULL, @@ -344,7 +346,8 @@ DEFINE_Q35_MACHINE(v3_0, "pc-q35-3.0", NULL, static void pc_q35_2_12_machine_options(MachineClass *m) { pc_q35_3_0_machine_options(m); - SET_MACHINE_COMPAT(m, PC_COMPAT_2_12); + compat_props_add(m->compat_props, hw_compat_2_12, hw_compat_2_12_len); + compat_props_add(m->compat_props, pc_compat_2_12, pc_compat_2_12_len); } DEFINE_Q35_MACHINE(v2_12, "pc-q35-2.12", NULL, @@ -356,7 +359,8 @@ static void pc_q35_2_11_machine_options(MachineClass *m) pc_q35_2_12_machine_options(m); pcmc->default_nic_model = "e1000"; - SET_MACHINE_COMPAT(m, PC_COMPAT_2_11); + compat_props_add(m->compat_props, hw_compat_2_11, hw_compat_2_11_len); + compat_props_add(m->compat_props, pc_compat_2_11, pc_compat_2_11_len); } DEFINE_Q35_MACHINE(v2_11, "pc-q35-2.11", NULL, @@ -365,7 +369,8 @@ DEFINE_Q35_MACHINE(v2_11, "pc-q35-2.11", NULL, static void pc_q35_2_10_machine_options(MachineClass *m) { pc_q35_2_11_machine_options(m); - SET_MACHINE_COMPAT(m, PC_COMPAT_2_10); + compat_props_add(m->compat_props, hw_compat_2_10, hw_compat_2_10_len); + compat_props_add(m->compat_props, pc_compat_2_10, pc_compat_2_10_len); m->numa_auto_assign_ram = numa_legacy_auto_assign_ram; m->auto_enable_numa_with_memhp = false; } @@ -376,7 +381,8 @@ DEFINE_Q35_MACHINE(v2_10, "pc-q35-2.10", NULL, static void pc_q35_2_9_machine_options(MachineClass *m) { pc_q35_2_10_machine_options(m); - SET_MACHINE_COMPAT(m, PC_COMPAT_2_9); + compat_props_add(m->compat_props, hw_compat_2_9, hw_compat_2_9_len); + compat_props_add(m->compat_props, pc_compat_2_9, pc_compat_2_9_len); } DEFINE_Q35_MACHINE(v2_9, "pc-q35-2.9", NULL, @@ -385,7 +391,8 @@ DEFINE_Q35_MACHINE(v2_9, "pc-q35-2.9", NULL, static void pc_q35_2_8_machine_options(MachineClass *m) { pc_q35_2_9_machine_options(m); - SET_MACHINE_COMPAT(m, PC_COMPAT_2_8); + compat_props_add(m->compat_props, hw_compat_2_8, hw_compat_2_8_len); + compat_props_add(m->compat_props, pc_compat_2_8, pc_compat_2_8_len); } DEFINE_Q35_MACHINE(v2_8, "pc-q35-2.8", NULL, @@ -395,7 +402,8 @@ static void pc_q35_2_7_machine_options(MachineClass *m) { pc_q35_2_8_machine_options(m); m->max_cpus = 255; - SET_MACHINE_COMPAT(m, PC_COMPAT_2_7); + compat_props_add(m->compat_props, hw_compat_2_7, hw_compat_2_7_len); + compat_props_add(m->compat_props, pc_compat_2_7, pc_compat_2_7_len); } DEFINE_Q35_MACHINE(v2_7, "pc-q35-2.7", NULL, @@ -404,10 +412,12 @@ DEFINE_Q35_MACHINE(v2_7, "pc-q35-2.7", NULL, static void pc_q35_2_6_machine_options(MachineClass *m) { PCMachineClass *pcmc = PC_MACHINE_CLASS(m); + pc_q35_2_7_machine_options(m); pcmc->legacy_cpu_hotplug = true; pcmc->linuxboot_dma_enabled = false; - SET_MACHINE_COMPAT(m, PC_COMPAT_2_6); + compat_props_add(m->compat_props, hw_compat_2_6, hw_compat_2_6_len); + compat_props_add(m->compat_props, pc_compat_2_6, pc_compat_2_6_len); } DEFINE_Q35_MACHINE(v2_6, "pc-q35-2.6", NULL, @@ -416,10 +426,12 @@ DEFINE_Q35_MACHINE(v2_6, "pc-q35-2.6", NULL, static void pc_q35_2_5_machine_options(MachineClass *m) { PCMachineClass *pcmc = PC_MACHINE_CLASS(m); + pc_q35_2_6_machine_options(m); pcmc->save_tsc_khz = false; m->legacy_fw_cfg_order = 1; - SET_MACHINE_COMPAT(m, PC_COMPAT_2_5); + compat_props_add(m->compat_props, hw_compat_2_5, hw_compat_2_5_len); + compat_props_add(m->compat_props, pc_compat_2_5, pc_compat_2_5_len); } DEFINE_Q35_MACHINE(v2_5, "pc-q35-2.5", NULL, @@ -428,10 +440,12 @@ DEFINE_Q35_MACHINE(v2_5, "pc-q35-2.5", NULL, static void pc_q35_2_4_machine_options(MachineClass *m) { PCMachineClass *pcmc = PC_MACHINE_CLASS(m); + pc_q35_2_5_machine_options(m); m->hw_version = "2.4.0"; pcmc->broken_reserved_end = true; - SET_MACHINE_COMPAT(m, PC_COMPAT_2_4); + compat_props_add(m->compat_props, hw_compat_2_4, hw_compat_2_4_len); + compat_props_add(m->compat_props, pc_compat_2_4, pc_compat_2_4_len); } DEFINE_Q35_MACHINE(v2_4, "pc-q35-2.4", NULL, diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 19a07c5c9d..5671608cea 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -70,7 +70,6 @@ #include "hw/nmi.h" #include "hw/intc/intc.h" -#include "hw/compat.h" #include "qemu/cutils.h" #include "hw/ppc/spapr_cpu_core.h" #include "hw/mem/memory-device.h" @@ -4021,13 +4020,10 @@ DEFINE_SPAPR_MACHINE(4_0, "4.0", true); /* * pseries-3.1 */ -#define SPAPR_COMPAT_3_1 \ - HW_COMPAT_3_1 - static void spapr_machine_3_1_class_options(MachineClass *mc) { spapr_machine_4_0_class_options(mc); - SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_3_1); + compat_props_add(mc->compat_props, hw_compat_3_1, hw_compat_3_1_len); mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("power8_v2.0"); } @@ -4036,15 +4032,13 @@ DEFINE_SPAPR_MACHINE(3_1, "3.1", false); /* * pseries-3.0 */ -#define SPAPR_COMPAT_3_0 \ - HW_COMPAT_3_0 static void spapr_machine_3_0_class_options(MachineClass *mc) { sPAPRMachineClass *smc = SPAPR_MACHINE_CLASS(mc); spapr_machine_3_1_class_options(mc); - SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_3_0); + compat_props_add(mc->compat_props, hw_compat_3_0, hw_compat_3_0_len); smc->legacy_irq_allocation = true; smc->irq = &spapr_irq_xics_legacy; @@ -4055,25 +4049,25 @@ DEFINE_SPAPR_MACHINE(3_0, "3.0", false); /* * pseries-2.12 */ -#define SPAPR_COMPAT_2_12 \ - HW_COMPAT_2_12 \ - { \ - .driver = TYPE_POWERPC_CPU, \ - .property = "pre-3.0-migration", \ - .value = "on", \ - }, \ - { \ - .driver = TYPE_SPAPR_CPU_CORE, \ - .property = "pre-3.0-migration", \ - .value = "on", \ - }, - static void spapr_machine_2_12_class_options(MachineClass *mc) { sPAPRMachineClass *smc = SPAPR_MACHINE_CLASS(mc); + static GlobalProperty compat[] = { + { + .driver = TYPE_POWERPC_CPU, + .property = "pre-3.0-migration", + .value = "on", + }, + { + .driver = TYPE_SPAPR_CPU_CORE, + .property = "pre-3.0-migration", + .value = "on", + }, + }; spapr_machine_3_0_class_options(mc); - SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_12); + compat_props_add(mc->compat_props, hw_compat_2_12, hw_compat_2_12_len); + compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat)); /* We depend on kvm_enabled() to choose a default value for the * hpt-max-page-size capability. Of course we can't do it here @@ -4100,8 +4094,6 @@ DEFINE_SPAPR_MACHINE(2_12_sxxm, "2.12-sxxm", false); /* * pseries-2.11 */ -#define SPAPR_COMPAT_2_11 \ - HW_COMPAT_2_11 static void spapr_machine_2_11_class_options(MachineClass *mc) { @@ -4109,7 +4101,7 @@ static void spapr_machine_2_11_class_options(MachineClass *mc) spapr_machine_2_12_class_options(mc); smc->default_caps.caps[SPAPR_CAP_HTM] = SPAPR_CAP_ON; - SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_11); + compat_props_add(mc->compat_props, hw_compat_2_11, hw_compat_2_11_len); } DEFINE_SPAPR_MACHINE(2_11, "2.11", false); @@ -4117,13 +4109,11 @@ DEFINE_SPAPR_MACHINE(2_11, "2.11", false); /* * pseries-2.10 */ -#define SPAPR_COMPAT_2_10 \ - HW_COMPAT_2_10 static void spapr_machine_2_10_class_options(MachineClass *mc) { spapr_machine_2_11_class_options(mc); - SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_10); + compat_props_add(mc->compat_props, hw_compat_2_10, hw_compat_2_10_len); } DEFINE_SPAPR_MACHINE(2_10, "2.10", false); @@ -4131,20 +4121,21 @@ DEFINE_SPAPR_MACHINE(2_10, "2.10", false); /* * pseries-2.9 */ -#define SPAPR_COMPAT_2_9 \ - HW_COMPAT_2_9 \ - { \ - .driver = TYPE_POWERPC_CPU, \ - .property = "pre-2.10-migration", \ - .value = "on", \ - }, \ static void spapr_machine_2_9_class_options(MachineClass *mc) { sPAPRMachineClass *smc = SPAPR_MACHINE_CLASS(mc); + static GlobalProperty compat[] = { + { + .driver = TYPE_POWERPC_CPU, + .property = "pre-2.10-migration", + .value = "on", + }, + }; spapr_machine_2_10_class_options(mc); - SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_9); + compat_props_add(mc->compat_props, hw_compat_2_9, hw_compat_2_9_len); + compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat)); mc->numa_auto_assign_ram = numa_legacy_auto_assign_ram; smc->pre_2_10_has_unused_icps = true; smc->resize_hpt_default = SPAPR_RESIZE_HPT_DISABLED; @@ -4155,18 +4146,20 @@ DEFINE_SPAPR_MACHINE(2_9, "2.9", false); /* * pseries-2.8 */ -#define SPAPR_COMPAT_2_8 \ - HW_COMPAT_2_8 \ - { \ - .driver = TYPE_SPAPR_PCI_HOST_BRIDGE, \ - .property = "pcie-extended-configuration-space", \ - .value = "off", \ - }, static void spapr_machine_2_8_class_options(MachineClass *mc) { + static GlobalProperty compat[] = { + { + .driver = TYPE_SPAPR_PCI_HOST_BRIDGE, + .property = "pcie-extended-configuration-space", + .value = "off", + }, + }; + spapr_machine_2_9_class_options(mc); - SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_8); + compat_props_add(mc->compat_props, hw_compat_2_8, hw_compat_2_8_len); + compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat)); mc->numa_mem_align_shift = 23; } @@ -4175,28 +4168,6 @@ DEFINE_SPAPR_MACHINE(2_8, "2.8", false); /* * pseries-2.7 */ -#define SPAPR_COMPAT_2_7 \ - HW_COMPAT_2_7 \ - { \ - .driver = TYPE_SPAPR_PCI_HOST_BRIDGE, \ - .property = "mem_win_size", \ - .value = stringify(SPAPR_PCI_2_7_MMIO_WIN_SIZE),\ - }, \ - { \ - .driver = TYPE_SPAPR_PCI_HOST_BRIDGE, \ - .property = "mem64_win_size", \ - .value = "0", \ - }, \ - { \ - .driver = TYPE_POWERPC_CPU, \ - .property = "pre-2.8-migration", \ - .value = "on", \ - }, \ - { \ - .driver = TYPE_SPAPR_PCI_HOST_BRIDGE, \ - .property = "pre-2.8-migration", \ - .value = "on", \ - }, static void phb_placement_2_7(sPAPRMachineState *spapr, uint32_t index, uint64_t *buid, hwaddr *pio, @@ -4250,11 +4221,34 @@ static void phb_placement_2_7(sPAPRMachineState *spapr, uint32_t index, static void spapr_machine_2_7_class_options(MachineClass *mc) { sPAPRMachineClass *smc = SPAPR_MACHINE_CLASS(mc); + static GlobalProperty compat[] = { + { + .driver = TYPE_SPAPR_PCI_HOST_BRIDGE, + .property = "mem_win_size", + .value = stringify(SPAPR_PCI_2_7_MMIO_WIN_SIZE), + }, + { + .driver = TYPE_SPAPR_PCI_HOST_BRIDGE, + .property = "mem64_win_size", + .value = "0", + }, + { + .driver = TYPE_POWERPC_CPU, + .property = "pre-2.8-migration", + .value = "on", + }, + { + .driver = TYPE_SPAPR_PCI_HOST_BRIDGE, + .property = "pre-2.8-migration", + .value = "on", + }, + }; spapr_machine_2_8_class_options(mc); mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("power7_v2.3"); mc->default_machine_opts = "modern-hotplug-events=off"; - SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_7); + compat_props_add(mc->compat_props, hw_compat_2_7, hw_compat_2_7_len); + compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat)); smc->phb_placement = phb_placement_2_7; } @@ -4263,19 +4257,21 @@ DEFINE_SPAPR_MACHINE(2_7, "2.7", false); /* * pseries-2.6 */ -#define SPAPR_COMPAT_2_6 \ - HW_COMPAT_2_6 \ - { \ - .driver = TYPE_SPAPR_PCI_HOST_BRIDGE,\ - .property = "ddw",\ - .value = stringify(off),\ - }, static void spapr_machine_2_6_class_options(MachineClass *mc) { + static GlobalProperty compat[] = { + { + .driver = TYPE_SPAPR_PCI_HOST_BRIDGE, + .property = "ddw", + .value = stringify(off), + }, + }; + spapr_machine_2_7_class_options(mc); mc->has_hotpluggable_cpus = false; - SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_6); + compat_props_add(mc->compat_props, hw_compat_2_6, hw_compat_2_6_len); + compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat)); } DEFINE_SPAPR_MACHINE(2_6, "2.6", false); @@ -4283,21 +4279,22 @@ DEFINE_SPAPR_MACHINE(2_6, "2.6", false); /* * pseries-2.5 */ -#define SPAPR_COMPAT_2_5 \ - HW_COMPAT_2_5 \ - { \ - .driver = "spapr-vlan", \ - .property = "use-rx-buffer-pools", \ - .value = "off", \ - }, static void spapr_machine_2_5_class_options(MachineClass *mc) { sPAPRMachineClass *smc = SPAPR_MACHINE_CLASS(mc); + static GlobalProperty compat[] = { + { + .driver = "spapr-vlan", + .property = "use-rx-buffer-pools", + .value = "off", + }, + }; spapr_machine_2_6_class_options(mc); smc->use_ohci_by_default = true; - SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_5); + compat_props_add(mc->compat_props, hw_compat_2_5, hw_compat_2_5_len); + compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat)); } DEFINE_SPAPR_MACHINE(2_5, "2.5", false); @@ -4305,8 +4302,6 @@ DEFINE_SPAPR_MACHINE(2_5, "2.5", false); /* * pseries-2.4 */ -#define SPAPR_COMPAT_2_4 \ - HW_COMPAT_2_4 static void spapr_machine_2_4_class_options(MachineClass *mc) { @@ -4314,7 +4309,7 @@ static void spapr_machine_2_4_class_options(MachineClass *mc) spapr_machine_2_5_class_options(mc); smc->dr_lmb_enabled = false; - SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_4); + compat_props_add(mc->compat_props, hw_compat_2_4, hw_compat_2_4_len); } DEFINE_SPAPR_MACHINE(2_4, "2.4", false); @@ -4322,18 +4317,19 @@ DEFINE_SPAPR_MACHINE(2_4, "2.4", false); /* * pseries-2.3 */ -#define SPAPR_COMPAT_2_3 \ - HW_COMPAT_2_3 \ - {\ - .driver = "spapr-pci-host-bridge",\ - .property = "dynamic-reconfiguration",\ - .value = "off",\ - }, static void spapr_machine_2_3_class_options(MachineClass *mc) { + static GlobalProperty compat[] = { + { + .driver = "spapr-pci-host-bridge", + .property = "dynamic-reconfiguration", + .value = "off", + }, + }; spapr_machine_2_4_class_options(mc); - SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_3); + compat_props_add(mc->compat_props, hw_compat_2_3, hw_compat_2_3_len); + compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat)); } DEFINE_SPAPR_MACHINE(2_3, "2.3", false); @@ -4341,18 +4337,19 @@ DEFINE_SPAPR_MACHINE(2_3, "2.3", false); * pseries-2.2 */ -#define SPAPR_COMPAT_2_2 \ - HW_COMPAT_2_2 \ - {\ - .driver = TYPE_SPAPR_PCI_HOST_BRIDGE,\ - .property = "mem_win_size",\ - .value = "0x20000000",\ - }, - static void spapr_machine_2_2_class_options(MachineClass *mc) { + static GlobalProperty compat[] = { + { + .driver = TYPE_SPAPR_PCI_HOST_BRIDGE, + .property = "mem_win_size", + .value = "0x20000000", + }, + }; + spapr_machine_2_3_class_options(mc); - SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_2); + compat_props_add(mc->compat_props, hw_compat_2_2, hw_compat_2_2_len); + compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat)); mc->default_machine_opts = "modern-hotplug-events=off,suppress-vmdesc=on"; } DEFINE_SPAPR_MACHINE(2_2, "2.2", false); @@ -4360,13 +4357,11 @@ DEFINE_SPAPR_MACHINE(2_2, "2.2", false); /* * pseries-2.1 */ -#define SPAPR_COMPAT_2_1 \ - HW_COMPAT_2_1 static void spapr_machine_2_1_class_options(MachineClass *mc) { spapr_machine_2_2_class_options(mc); - SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_1); + compat_props_add(mc->compat_props, hw_compat_2_1, hw_compat_2_1_len); } DEFINE_SPAPR_MACHINE(2_1, "2.1", false); diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index fd9d0b0542..c737507053 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -28,7 +28,6 @@ #include "hw/s390x/storage-keys.h" #include "hw/s390x/storage-attributes.h" #include "hw/s390x/event-facility.h" -#include "hw/compat.h" #include "ipl.h" #include "hw/s390x/s390-virtio-ccw.h" #include "hw/s390x/css-bridge.h" @@ -651,100 +650,6 @@ bool css_migration_enabled(void) } \ type_init(ccw_machine_register_##suffix) -#define CCW_COMPAT_3_1 \ - HW_COMPAT_3_1 - -#define CCW_COMPAT_3_0 \ - HW_COMPAT_3_0 - -#define CCW_COMPAT_2_12 \ - HW_COMPAT_2_12 - -#define CCW_COMPAT_2_11 \ - HW_COMPAT_2_11 \ - {\ - .driver = TYPE_SCLP_EVENT_FACILITY,\ - .property = "allow_all_mask_sizes",\ - .value = "off",\ - }, - -#define CCW_COMPAT_2_10 \ - HW_COMPAT_2_10 - -#define CCW_COMPAT_2_9 \ - HW_COMPAT_2_9 \ - {\ - .driver = TYPE_S390_STATTRIB,\ - .property = "migration-enabled",\ - .value = "off",\ - }, - -#define CCW_COMPAT_2_8 \ - HW_COMPAT_2_8 \ - {\ - .driver = TYPE_S390_FLIC_COMMON,\ - .property = "adapter_routes_max_batch",\ - .value = "64",\ - }, - -#define CCW_COMPAT_2_7 \ - HW_COMPAT_2_7 - -#define CCW_COMPAT_2_6 \ - HW_COMPAT_2_6 \ - {\ - .driver = TYPE_S390_IPL,\ - .property = "iplbext_migration",\ - .value = "off",\ - }, {\ - .driver = TYPE_VIRTUAL_CSS_BRIDGE,\ - .property = "css_dev_path",\ - .value = "off",\ - }, - -#define CCW_COMPAT_2_5 \ - HW_COMPAT_2_5 - -#define CCW_COMPAT_2_4 \ - HW_COMPAT_2_4 \ - {\ - .driver = TYPE_S390_SKEYS,\ - .property = "migration-enabled",\ - .value = "off",\ - },{\ - .driver = "virtio-blk-ccw",\ - .property = "max_revision",\ - .value = "0",\ - },{\ - .driver = "virtio-balloon-ccw",\ - .property = "max_revision",\ - .value = "0",\ - },{\ - .driver = "virtio-serial-ccw",\ - .property = "max_revision",\ - .value = "0",\ - },{\ - .driver = "virtio-9p-ccw",\ - .property = "max_revision",\ - .value = "0",\ - },{\ - .driver = "virtio-rng-ccw",\ - .property = "max_revision",\ - .value = "0",\ - },{\ - .driver = "virtio-net-ccw",\ - .property = "max_revision",\ - .value = "0",\ - },{\ - .driver = "virtio-scsi-ccw",\ - .property = "max_revision",\ - .value = "0",\ - },{\ - .driver = "vhost-scsi-ccw",\ - .property = "max_revision",\ - .value = "0",\ - }, - static void ccw_machine_4_0_instance_options(MachineState *machine) { } @@ -762,7 +667,7 @@ static void ccw_machine_3_1_instance_options(MachineState *machine) static void ccw_machine_3_1_class_options(MachineClass *mc) { ccw_machine_4_0_class_options(mc); - SET_MACHINE_COMPAT(mc, CCW_COMPAT_3_1); + compat_props_add(mc->compat_props, hw_compat_3_1, hw_compat_3_1_len); } DEFINE_CCW_MACHINE(3_1, "3.1", false); @@ -777,7 +682,7 @@ static void ccw_machine_3_0_class_options(MachineClass *mc) s390mc->hpage_1m_allowed = false; ccw_machine_3_1_class_options(mc); - SET_MACHINE_COMPAT(mc, CCW_COMPAT_3_0); + compat_props_add(mc->compat_props, hw_compat_3_0, hw_compat_3_0_len); } DEFINE_CCW_MACHINE(3_0, "3.0", false); @@ -791,7 +696,7 @@ static void ccw_machine_2_12_instance_options(MachineState *machine) static void ccw_machine_2_12_class_options(MachineClass *mc) { ccw_machine_3_0_class_options(mc); - SET_MACHINE_COMPAT(mc, CCW_COMPAT_2_12); + compat_props_add(mc->compat_props, hw_compat_2_12, hw_compat_2_12_len); } DEFINE_CCW_MACHINE(2_12, "2.12", false); @@ -806,8 +711,17 @@ static void ccw_machine_2_11_instance_options(MachineState *machine) static void ccw_machine_2_11_class_options(MachineClass *mc) { + static GlobalProperty compat[] = { + { + .driver = TYPE_SCLP_EVENT_FACILITY, + .property = "allow_all_mask_sizes", + .value = "off", + }, + }; + ccw_machine_2_12_class_options(mc); - SET_MACHINE_COMPAT(mc, CCW_COMPAT_2_11); + compat_props_add(mc->compat_props, hw_compat_2_11, hw_compat_2_11_len); + compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat)); } DEFINE_CCW_MACHINE(2_11, "2.11", false); @@ -819,7 +733,7 @@ static void ccw_machine_2_10_instance_options(MachineState *machine) static void ccw_machine_2_10_class_options(MachineClass *mc) { ccw_machine_2_11_class_options(mc); - SET_MACHINE_COMPAT(mc, CCW_COMPAT_2_10); + compat_props_add(mc->compat_props, hw_compat_2_10, hw_compat_2_10_len); } DEFINE_CCW_MACHINE(2_10, "2.10", false); @@ -836,9 +750,17 @@ static void ccw_machine_2_9_instance_options(MachineState *machine) static void ccw_machine_2_9_class_options(MachineClass *mc) { S390CcwMachineClass *s390mc = S390_MACHINE_CLASS(mc); + static GlobalProperty compat[] = { + { + .driver = TYPE_S390_STATTRIB, + .property = "migration-enabled", + .value = "off", + }, + }; ccw_machine_2_10_class_options(mc); - SET_MACHINE_COMPAT(mc, CCW_COMPAT_2_9); + compat_props_add(mc->compat_props, hw_compat_2_9, hw_compat_2_9_len); + compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat)); s390mc->css_migration_enabled = false; } DEFINE_CCW_MACHINE(2_9, "2.9", false); @@ -850,8 +772,17 @@ static void ccw_machine_2_8_instance_options(MachineState *machine) static void ccw_machine_2_8_class_options(MachineClass *mc) { + static GlobalProperty compat[] = { + { + .driver = TYPE_S390_FLIC_COMMON, + .property = "adapter_routes_max_batch", + .value = "64", + }, + }; + ccw_machine_2_9_class_options(mc); - SET_MACHINE_COMPAT(mc, CCW_COMPAT_2_8); + compat_props_add(mc->compat_props, hw_compat_2_8, hw_compat_2_8_len); + compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat)); } DEFINE_CCW_MACHINE(2_8, "2.8", false); @@ -866,7 +797,7 @@ static void ccw_machine_2_7_class_options(MachineClass *mc) s390mc->cpu_model_allowed = false; ccw_machine_2_8_class_options(mc); - SET_MACHINE_COMPAT(mc, CCW_COMPAT_2_7); + compat_props_add(mc->compat_props, hw_compat_2_7, hw_compat_2_7_len); } DEFINE_CCW_MACHINE(2_7, "2.7", false); @@ -878,10 +809,22 @@ static void ccw_machine_2_6_instance_options(MachineState *machine) static void ccw_machine_2_6_class_options(MachineClass *mc) { S390CcwMachineClass *s390mc = S390_MACHINE_CLASS(mc); + static GlobalProperty compat[] = { + { + .driver = TYPE_S390_IPL, + .property = "iplbext_migration", + .value = "off", + }, { + .driver = TYPE_VIRTUAL_CSS_BRIDGE, + .property = "css_dev_path", + .value = "off", + }, + }; s390mc->ri_allowed = false; ccw_machine_2_7_class_options(mc); - SET_MACHINE_COMPAT(mc, CCW_COMPAT_2_6); + compat_props_add(mc->compat_props, hw_compat_2_6, hw_compat_2_6_len); + compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat)); } DEFINE_CCW_MACHINE(2_6, "2.6", false); @@ -893,7 +836,7 @@ static void ccw_machine_2_5_instance_options(MachineState *machine) static void ccw_machine_2_5_class_options(MachineClass *mc) { ccw_machine_2_6_class_options(mc); - SET_MACHINE_COMPAT(mc, CCW_COMPAT_2_5); + compat_props_add(mc->compat_props, hw_compat_2_5, hw_compat_2_5_len); } DEFINE_CCW_MACHINE(2_5, "2.5", false); @@ -904,8 +847,49 @@ static void ccw_machine_2_4_instance_options(MachineState *machine) static void ccw_machine_2_4_class_options(MachineClass *mc) { + static GlobalProperty compat[] = { + { + .driver = TYPE_S390_SKEYS, + .property = "migration-enabled", + .value = "off", + },{ + .driver = "virtio-blk-ccw", + .property = "max_revision", + .value = "0", + },{ + .driver = "virtio-balloon-ccw", + .property = "max_revision", + .value = "0", + },{ + .driver = "virtio-serial-ccw", + .property = "max_revision", + .value = "0", + },{ + .driver = "virtio-9p-ccw", + .property = "max_revision", + .value = "0", + },{ + .driver = "virtio-rng-ccw", + .property = "max_revision", + .value = "0", + },{ + .driver = "virtio-net-ccw", + .property = "max_revision", + .value = "0", + },{ + .driver = "virtio-scsi-ccw", + .property = "max_revision", + .value = "0", + },{ + .driver = "vhost-scsi-ccw", + .property = "max_revision", + .value = "0", + }, + }; + ccw_machine_2_5_class_options(mc); - SET_MACHINE_COMPAT(mc, CCW_COMPAT_2_4); + compat_props_add(mc->compat_props, hw_compat_2_4, hw_compat_2_4_len); + compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat)); } DEFINE_CCW_MACHINE(2_4, "2.4", false); diff --git a/hw/xen/xen-common.c b/hw/xen/xen-common.c index 6ec14c73ca..d51148b6b3 100644 --- a/hw/xen/xen-common.c +++ b/hw/xen/xen-common.c @@ -159,33 +159,34 @@ static int xen_init(MachineState *ms) return 0; } -static GlobalProperty xen_compat_props[] = { - { - .driver = "migration", - .property = "store-global-state", - .value = "off", - }, - { - .driver = "migration", - .property = "send-configuration", - .value = "off", - }, - { - .driver = "migration", - .property = "send-section-footer", - .value = "off", - }, - { /* end of list */ }, -}; - static void xen_accel_class_init(ObjectClass *oc, void *data) { AccelClass *ac = ACCEL_CLASS(oc); + static GlobalProperty compat[] = { + { + .driver = "migration", + .property = "store-global-state", + .value = "off", + }, + { + .driver = "migration", + .property = "send-configuration", + .value = "off", + }, + { + .driver = "migration", + .property = "send-section-footer", + .value = "off", + } + }; + ac->name = "Xen"; ac->init_machine = xen_init; ac->setup_post = xen_setup_post; ac->allowed = &xen_allowed; - ac->global_props = xen_compat_props; + ac->compat_props = g_ptr_array_new(); + + compat_props_add(ac->compat_props, compat, G_N_ELEMENTS(compat)); } #define TYPE_XEN_ACCEL ACCEL_CLASS_NAME("xen") diff --git a/include/hw/boards.h b/include/hw/boards.h index 362384815e..02f114085f 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -69,7 +69,6 @@ int machine_kvm_shadow_mem(MachineState *machine); int machine_phandle_start(MachineState *machine); bool machine_dump_guest_core(MachineState *machine); bool machine_mem_merge(MachineState *machine); -void machine_register_compat_props(MachineState *machine); HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine); void machine_set_cpu_numa_node(MachineState *machine, const CpuInstanceProperties *props, @@ -191,7 +190,7 @@ struct MachineClass { const char *default_machine_opts; const char *default_boot_order; const char *default_display; - GArray *compat_props; + GPtrArray *compat_props; const char *hw_version; ram_addr_t default_ram_size; const char *default_cpu_type; @@ -289,20 +288,46 @@ struct MachineState { } \ type_init(machine_initfn##_register_types) -#define SET_MACHINE_COMPAT(m, COMPAT) \ - do { \ - int i; \ - static GlobalProperty props[] = { \ - COMPAT \ - { /* end of list */ } \ - }; \ - if (!m->compat_props) { \ - m->compat_props = g_array_new(false, false, sizeof(void *)); \ - } \ - for (i = 0; props[i].driver != NULL; i++) { \ - GlobalProperty *prop = &props[i]; \ - g_array_append_val(m->compat_props, prop); \ - } \ - } while (0) +extern GlobalProperty hw_compat_3_1[]; +extern const size_t hw_compat_3_1_len; + +extern GlobalProperty hw_compat_3_0[]; +extern const size_t hw_compat_3_0_len; + +extern GlobalProperty hw_compat_2_12[]; +extern const size_t hw_compat_2_12_len; + +extern GlobalProperty hw_compat_2_11[]; +extern const size_t hw_compat_2_11_len; + +extern GlobalProperty hw_compat_2_10[]; +extern const size_t hw_compat_2_10_len; + +extern GlobalProperty hw_compat_2_9[]; +extern const size_t hw_compat_2_9_len; + +extern GlobalProperty hw_compat_2_8[]; +extern const size_t hw_compat_2_8_len; + +extern GlobalProperty hw_compat_2_7[]; +extern const size_t hw_compat_2_7_len; + +extern GlobalProperty hw_compat_2_6[]; +extern const size_t hw_compat_2_6_len; + +extern GlobalProperty hw_compat_2_5[]; +extern const size_t hw_compat_2_5_len; + +extern GlobalProperty hw_compat_2_4[]; +extern const size_t hw_compat_2_4_len; + +extern GlobalProperty hw_compat_2_3[]; +extern const size_t hw_compat_2_3_len; + +extern GlobalProperty hw_compat_2_2[]; +extern const size_t hw_compat_2_2_len; + +extern GlobalProperty hw_compat_2_1[]; +extern const size_t hw_compat_2_1_len; #endif diff --git a/include/hw/compat.h b/include/hw/compat.h deleted file mode 100644 index 3ca85b037c..0000000000 --- a/include/hw/compat.h +++ /dev/null @@ -1,299 +0,0 @@ -#ifndef HW_COMPAT_H -#define HW_COMPAT_H - -#define HW_COMPAT_3_1 \ - {\ - .driver = "pcie-root-port",\ - .property = "x-speed",\ - .value = "2_5",\ - },{\ - .driver = "pcie-root-port",\ - .property = "x-width",\ - .value = "1",\ - }, - -#define HW_COMPAT_3_0 \ - /* empty */ - -#define HW_COMPAT_2_12 \ - {\ - .driver = "migration",\ - .property = "decompress-error-check",\ - .value = "off",\ - },{\ - .driver = "hda-audio",\ - .property = "use-timer",\ - .value = "false",\ - },{\ - .driver = "cirrus-vga",\ - .property = "global-vmstate",\ - .value = "true",\ - },{\ - .driver = "VGA",\ - .property = "global-vmstate",\ - .value = "true",\ - },{\ - .driver = "vmware-svga",\ - .property = "global-vmstate",\ - .value = "true",\ - },{\ - .driver = "qxl-vga",\ - .property = "global-vmstate",\ - .value = "true",\ - }, - -#define HW_COMPAT_2_11 \ - {\ - .driver = "hpet",\ - .property = "hpet-offset-saved",\ - .value = "false",\ - },{\ - .driver = "virtio-blk-pci",\ - .property = "vectors",\ - .value = "2",\ - },{\ - .driver = "vhost-user-blk-pci",\ - .property = "vectors",\ - .value = "2",\ - },{\ - .driver = "e1000",\ - .property = "migrate_tso_props",\ - .value = "off",\ - }, - -#define HW_COMPAT_2_10 \ - {\ - .driver = "virtio-mouse-device",\ - .property = "wheel-axis",\ - .value = "false",\ - },{\ - .driver = "virtio-tablet-device",\ - .property = "wheel-axis",\ - .value = "false",\ - }, - -#define HW_COMPAT_2_9 \ - {\ - .driver = "pci-bridge",\ - .property = "shpc",\ - .value = "off",\ - },{\ - .driver = "intel-iommu",\ - .property = "pt",\ - .value = "off",\ - },{\ - .driver = "virtio-net-device",\ - .property = "x-mtu-bypass-backend",\ - .value = "off",\ - },{\ - .driver = "pcie-root-port",\ - .property = "x-migrate-msix",\ - .value = "false",\ - }, - -#define HW_COMPAT_2_8 \ - {\ - .driver = "fw_cfg_mem",\ - .property = "x-file-slots",\ - .value = stringify(0x10),\ - },{\ - .driver = "fw_cfg_io",\ - .property = "x-file-slots",\ - .value = stringify(0x10),\ - },{\ - .driver = "pflash_cfi01",\ - .property = "old-multiple-chip-handling",\ - .value = "on",\ - },{\ - .driver = "pci-bridge",\ - .property = "shpc",\ - .value = "on",\ - },{\ - .driver = TYPE_PCI_DEVICE,\ - .property = "x-pcie-extcap-init",\ - .value = "off",\ - },{\ - .driver = "virtio-pci",\ - .property = "x-pcie-deverr-init",\ - .value = "off",\ - },{\ - .driver = "virtio-pci",\ - .property = "x-pcie-lnkctl-init",\ - .value = "off",\ - },{\ - .driver = "virtio-pci",\ - .property = "x-pcie-pm-init",\ - .value = "off",\ - },{\ - .driver = "cirrus-vga",\ - .property = "vgamem_mb",\ - .value = "8",\ - },{\ - .driver = "isa-cirrus-vga",\ - .property = "vgamem_mb",\ - .value = "8",\ - }, - -#define HW_COMPAT_2_7 \ - {\ - .driver = "virtio-pci",\ - .property = "page-per-vq",\ - .value = "on",\ - },{\ - .driver = "virtio-serial-device",\ - .property = "emergency-write",\ - .value = "off",\ - },{\ - .driver = "ioapic",\ - .property = "version",\ - .value = "0x11",\ - },{\ - .driver = "intel-iommu",\ - .property = "x-buggy-eim",\ - .value = "true",\ - },{\ - .driver = "virtio-pci",\ - .property = "x-ignore-backend-features",\ - .value = "on",\ - }, - -#define HW_COMPAT_2_6 \ - {\ - .driver = "virtio-mmio",\ - .property = "format_transport_address",\ - .value = "off",\ - },{\ - .driver = "virtio-pci",\ - .property = "disable-modern",\ - .value = "on",\ - },{\ - .driver = "virtio-pci",\ - .property = "disable-legacy",\ - .value = "off",\ - }, - -#define HW_COMPAT_2_5 \ - {\ - .driver = "isa-fdc",\ - .property = "fallback",\ - .value = "144",\ - },{\ - .driver = "pvscsi",\ - .property = "x-old-pci-configuration",\ - .value = "on",\ - },{\ - .driver = "pvscsi",\ - .property = "x-disable-pcie",\ - .value = "on",\ - },\ - {\ - .driver = "vmxnet3",\ - .property = "x-old-msi-offsets",\ - .value = "on",\ - },{\ - .driver = "vmxnet3",\ - .property = "x-disable-pcie",\ - .value = "on",\ - }, - -#define HW_COMPAT_2_4 \ - {\ - .driver = "virtio-blk-device",\ - .property = "scsi",\ - .value = "true",\ - },{\ - .driver = "e1000",\ - .property = "extra_mac_registers",\ - .value = "off",\ - },{\ - .driver = "virtio-pci",\ - .property = "x-disable-pcie",\ - .value = "on",\ - },{\ - .driver = "virtio-pci",\ - .property = "migrate-extra",\ - .value = "off",\ - },{\ - .driver = "fw_cfg_mem",\ - .property = "dma_enabled",\ - .value = "off",\ - },{\ - .driver = "fw_cfg_io",\ - .property = "dma_enabled",\ - .value = "off",\ - }, - -#define HW_COMPAT_2_3 \ - {\ - .driver = "virtio-blk-pci",\ - .property = "any_layout",\ - .value = "off",\ - },{\ - .driver = "virtio-balloon-pci",\ - .property = "any_layout",\ - .value = "off",\ - },{\ - .driver = "virtio-serial-pci",\ - .property = "any_layout",\ - .value = "off",\ - },{\ - .driver = "virtio-9p-pci",\ - .property = "any_layout",\ - .value = "off",\ - },{\ - .driver = "virtio-rng-pci",\ - .property = "any_layout",\ - .value = "off",\ - },{\ - .driver = TYPE_PCI_DEVICE,\ - .property = "x-pcie-lnksta-dllla",\ - .value = "off",\ - },{\ - .driver = "migration",\ - .property = "send-configuration",\ - .value = "off",\ - },{\ - .driver = "migration",\ - .property = "send-section-footer",\ - .value = "off",\ - },{\ - .driver = "migration",\ - .property = "store-global-state",\ - .value = "off",\ - }, - -#define HW_COMPAT_2_2 \ - /* empty */ - -#define HW_COMPAT_2_1 \ - {\ - .driver = "intel-hda",\ - .property = "old_msi_addr",\ - .value = "on",\ - },{\ - .driver = "VGA",\ - .property = "qemu-extended-regs",\ - .value = "off",\ - },{\ - .driver = "secondary-vga",\ - .property = "qemu-extended-regs",\ - .value = "off",\ - },{\ - .driver = "virtio-scsi-pci",\ - .property = "any_layout",\ - .value = "off",\ - },{\ - .driver = "usb-mouse",\ - .property = "usb_version",\ - .value = stringify(1),\ - },{\ - .driver = "usb-kbd",\ - .property = "usb_version",\ - .value = stringify(1),\ - },{\ - .driver = "virtio-pci",\ - .property = "virtio-pci-bus-master-bug-migration",\ - .value = "on",\ - }, - -#endif /* HW_COMPAT_H */ diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index c7c0c944e8..84720bede9 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -13,7 +13,6 @@ #include "qemu/bitmap.h" #include "sysemu/sysemu.h" #include "hw/pci/pci.h" -#include "hw/compat.h" #include "hw/mem/pc-dimm.h" #include "hw/mem/nvdimm.h" #include "hw/acpi/acpi_dev_interface.h" @@ -294,171 +293,62 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t); int e820_get_num_entries(void); bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *); -#define PC_COMPAT_3_1 \ - HW_COMPAT_3_1 \ - {\ - .driver = "intel-iommu",\ - .property = "dma-drain",\ - .value = "off",\ - }, +extern GlobalProperty pc_compat_3_1[]; +extern const size_t pc_compat_3_1_len; -#define PC_COMPAT_3_0 \ - HW_COMPAT_3_0 \ - {\ - .driver = TYPE_X86_CPU,\ - .property = "x-hv-synic-kvm-only",\ - .value = "on",\ - },{\ - .driver = "Skylake-Server" "-" TYPE_X86_CPU,\ - .property = "pku",\ - .value = "off",\ - },{\ - .driver = "Skylake-Server-IBRS" "-" TYPE_X86_CPU,\ - .property = "pku",\ - .value = "off",\ - }, +extern GlobalProperty pc_compat_3_0[]; +extern const size_t pc_compat_3_0_len; -#define PC_COMPAT_2_12 \ - HW_COMPAT_2_12 \ - {\ - .driver = TYPE_X86_CPU,\ - .property = "legacy-cache",\ - .value = "on",\ - },{\ - .driver = TYPE_X86_CPU,\ - .property = "topoext",\ - .value = "off",\ - },{\ - .driver = "EPYC-" TYPE_X86_CPU,\ - .property = "xlevel",\ - .value = stringify(0x8000000a),\ - },{\ - .driver = "EPYC-IBPB-" TYPE_X86_CPU,\ - .property = "xlevel",\ - .value = stringify(0x8000000a),\ - }, +extern GlobalProperty pc_compat_2_12[]; +extern const size_t pc_compat_2_12_len; -#define PC_COMPAT_2_11 \ - HW_COMPAT_2_11 \ - {\ - .driver = TYPE_X86_CPU,\ - .property = "x-migrate-smi-count",\ - .value = "off",\ - },{\ - .driver = "Skylake-Server" "-" TYPE_X86_CPU,\ - .property = "clflushopt",\ - .value = "off",\ - }, +extern GlobalProperty pc_compat_2_11[]; +extern const size_t pc_compat_2_11_len; -#define PC_COMPAT_2_10 \ - HW_COMPAT_2_10 \ - {\ - .driver = TYPE_X86_CPU,\ - .property = "x-hv-max-vps",\ - .value = "0x40",\ - },{\ - .driver = "i440FX-pcihost",\ - .property = "x-pci-hole64-fix",\ - .value = "off",\ - },{\ - .driver = "q35-pcihost",\ - .property = "x-pci-hole64-fix",\ - .value = "off",\ - }, +extern GlobalProperty pc_compat_2_10[]; +extern const size_t pc_compat_2_10_len; -#define PC_COMPAT_2_9 \ - HW_COMPAT_2_9 \ - {\ - .driver = "mch",\ - .property = "extended-tseg-mbytes",\ - .value = stringify(0),\ - },\ +extern GlobalProperty pc_compat_2_9[]; +extern const size_t pc_compat_2_9_len; -#define PC_COMPAT_2_8 \ - HW_COMPAT_2_8 \ - {\ - .driver = TYPE_X86_CPU,\ - .property = "tcg-cpuid",\ - .value = "off",\ - },\ - {\ - .driver = "kvmclock",\ - .property = "x-mach-use-reliable-get-clock",\ - .value = "off",\ - },\ - {\ - .driver = "ICH9-LPC",\ - .property = "x-smi-broadcast",\ - .value = "off",\ - },\ - {\ - .driver = TYPE_X86_CPU,\ - .property = "vmware-cpuid-freq",\ - .value = "off",\ - },\ - {\ - .driver = "Haswell-" TYPE_X86_CPU,\ - .property = "stepping",\ - .value = "1",\ - }, +extern GlobalProperty pc_compat_2_8[]; +extern const size_t pc_compat_2_8_len; -#define PC_COMPAT_2_7 \ - HW_COMPAT_2_7 \ - {\ - .driver = TYPE_X86_CPU,\ - .property = "l3-cache",\ - .value = "off",\ - },\ - {\ - .driver = TYPE_X86_CPU,\ - .property = "full-cpuid-auto-level",\ - .value = "off",\ - },\ - {\ - .driver = "Opteron_G3" "-" TYPE_X86_CPU,\ - .property = "family",\ - .value = "15",\ - },\ - {\ - .driver = "Opteron_G3" "-" TYPE_X86_CPU,\ - .property = "model",\ - .value = "6",\ - },\ - {\ - .driver = "Opteron_G3" "-" TYPE_X86_CPU,\ - .property = "stepping",\ - .value = "1",\ - },\ - {\ - .driver = "isa-pcspk",\ - .property = "migrate",\ - .value = "off",\ - }, +extern GlobalProperty pc_compat_2_7[]; +extern const size_t pc_compat_2_7_len; -#define PC_COMPAT_2_6 \ - HW_COMPAT_2_6 \ - {\ - .driver = TYPE_X86_CPU,\ - .property = "cpuid-0xb",\ - .value = "off",\ - },{\ - .driver = "vmxnet3",\ - .property = "romfile",\ - .value = "",\ - },\ - {\ - .driver = TYPE_X86_CPU,\ - .property = "fill-mtrr-mask",\ - .value = "off",\ - },\ - {\ - .driver = "apic-common",\ - .property = "legacy-instance-id",\ - .value = "on",\ - }, +extern GlobalProperty pc_compat_2_6[]; +extern const size_t pc_compat_2_6_len; -#define PC_COMPAT_2_5 \ - HW_COMPAT_2_5 +extern GlobalProperty pc_compat_2_5[]; +extern const size_t pc_compat_2_5_len; + +extern GlobalProperty pc_compat_2_4[]; +extern const size_t pc_compat_2_4_len; + +extern GlobalProperty pc_compat_2_3[]; +extern const size_t pc_compat_2_3_len; + +extern GlobalProperty pc_compat_2_2[]; +extern const size_t pc_compat_2_2_len; + +extern GlobalProperty pc_compat_2_1[]; +extern const size_t pc_compat_2_1_len; + +extern GlobalProperty pc_compat_2_0[]; +extern const size_t pc_compat_2_0_len; + +extern GlobalProperty pc_compat_1_7[]; +extern const size_t pc_compat_1_7_len; + +extern GlobalProperty pc_compat_1_6[]; +extern const size_t pc_compat_1_6_len; + +extern GlobalProperty pc_compat_1_5[]; +extern const size_t pc_compat_1_5_len; + +extern GlobalProperty pc_compat_1_4[]; +extern const size_t pc_compat_1_4_len; /* Helper for setting model-id for CPU models that changed model-id * depending on QEMU versions up to QEMU 2.4. @@ -480,491 +370,6 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *); .value = "QEMU Virtual CPU version " v,\ }, -#define PC_COMPAT_2_4 \ - HW_COMPAT_2_4 \ - PC_CPU_MODEL_IDS("2.4.0") \ - {\ - .driver = "Haswell-" TYPE_X86_CPU,\ - .property = "abm",\ - .value = "off",\ - },\ - {\ - .driver = "Haswell-noTSX-" TYPE_X86_CPU,\ - .property = "abm",\ - .value = "off",\ - },\ - {\ - .driver = "Broadwell-" TYPE_X86_CPU,\ - .property = "abm",\ - .value = "off",\ - },\ - {\ - .driver = "Broadwell-noTSX-" TYPE_X86_CPU,\ - .property = "abm",\ - .value = "off",\ - },\ - {\ - .driver = "host" "-" TYPE_X86_CPU,\ - .property = "host-cache-info",\ - .value = "on",\ - },\ - {\ - .driver = TYPE_X86_CPU,\ - .property = "check",\ - .value = "off",\ - },\ - {\ - .driver = "qemu64" "-" TYPE_X86_CPU,\ - .property = "sse4a",\ - .value = "on",\ - },\ - {\ - .driver = "qemu64" "-" TYPE_X86_CPU,\ - .property = "abm",\ - .value = "on",\ - },\ - {\ - .driver = "qemu64" "-" TYPE_X86_CPU,\ - .property = "popcnt",\ - .value = "on",\ - },\ - {\ - .driver = "qemu32" "-" TYPE_X86_CPU,\ - .property = "popcnt",\ - .value = "on",\ - },{\ - .driver = "Opteron_G2" "-" TYPE_X86_CPU,\ - .property = "rdtscp",\ - .value = "on",\ - },{\ - .driver = "Opteron_G3" "-" TYPE_X86_CPU,\ - .property = "rdtscp",\ - .value = "on",\ - },{\ - .driver = "Opteron_G4" "-" TYPE_X86_CPU,\ - .property = "rdtscp",\ - .value = "on",\ - },{\ - .driver = "Opteron_G5" "-" TYPE_X86_CPU,\ - .property = "rdtscp",\ - .value = "on",\ - }, - - -#define PC_COMPAT_2_3 \ - HW_COMPAT_2_3 \ - PC_CPU_MODEL_IDS("2.3.0") \ - {\ - .driver = TYPE_X86_CPU,\ - .property = "arat",\ - .value = "off",\ - },{\ - .driver = "qemu64" "-" TYPE_X86_CPU,\ - .property = "min-level",\ - .value = stringify(4),\ - },{\ - .driver = "kvm64" "-" TYPE_X86_CPU,\ - .property = "min-level",\ - .value = stringify(5),\ - },{\ - .driver = "pentium3" "-" TYPE_X86_CPU,\ - .property = "min-level",\ - .value = stringify(2),\ - },{\ - .driver = "n270" "-" TYPE_X86_CPU,\ - .property = "min-level",\ - .value = stringify(5),\ - },{\ - .driver = "Conroe" "-" TYPE_X86_CPU,\ - .property = "min-level",\ - .value = stringify(4),\ - },{\ - .driver = "Penryn" "-" TYPE_X86_CPU,\ - .property = "min-level",\ - .value = stringify(4),\ - },{\ - .driver = "Nehalem" "-" TYPE_X86_CPU,\ - .property = "min-level",\ - .value = stringify(4),\ - },{\ - .driver = "n270" "-" TYPE_X86_CPU,\ - .property = "min-xlevel",\ - .value = stringify(0x8000000a),\ - },{\ - .driver = "Penryn" "-" TYPE_X86_CPU,\ - .property = "min-xlevel",\ - .value = stringify(0x8000000a),\ - },{\ - .driver = "Conroe" "-" TYPE_X86_CPU,\ - .property = "min-xlevel",\ - .value = stringify(0x8000000a),\ - },{\ - .driver = "Nehalem" "-" TYPE_X86_CPU,\ - .property = "min-xlevel",\ - .value = stringify(0x8000000a),\ - },{\ - .driver = "Westmere" "-" TYPE_X86_CPU,\ - .property = "min-xlevel",\ - .value = stringify(0x8000000a),\ - },{\ - .driver = "SandyBridge" "-" TYPE_X86_CPU,\ - .property = "min-xlevel",\ - .value = stringify(0x8000000a),\ - },{\ - .driver = "IvyBridge" "-" TYPE_X86_CPU,\ - .property = "min-xlevel",\ - .value = stringify(0x8000000a),\ - },{\ - .driver = "Haswell" "-" TYPE_X86_CPU,\ - .property = "min-xlevel",\ - .value = stringify(0x8000000a),\ - },{\ - .driver = "Haswell-noTSX" "-" TYPE_X86_CPU,\ - .property = "min-xlevel",\ - .value = stringify(0x8000000a),\ - },{\ - .driver = "Broadwell" "-" TYPE_X86_CPU,\ - .property = "min-xlevel",\ - .value = stringify(0x8000000a),\ - },{\ - .driver = "Broadwell-noTSX" "-" TYPE_X86_CPU,\ - .property = "min-xlevel",\ - .value = stringify(0x8000000a),\ - },{\ - .driver = TYPE_X86_CPU,\ - .property = "kvm-no-smi-migration",\ - .value = "on",\ - }, - -#define PC_COMPAT_2_2 \ - HW_COMPAT_2_2 \ - PC_CPU_MODEL_IDS("2.2.0") \ - {\ - .driver = "kvm64" "-" TYPE_X86_CPU,\ - .property = "vme",\ - .value = "off",\ - },\ - {\ - .driver = "kvm32" "-" TYPE_X86_CPU,\ - .property = "vme",\ - .value = "off",\ - },\ - {\ - .driver = "Conroe" "-" TYPE_X86_CPU,\ - .property = "vme",\ - .value = "off",\ - },\ - {\ - .driver = "Penryn" "-" TYPE_X86_CPU,\ - .property = "vme",\ - .value = "off",\ - },\ - {\ - .driver = "Nehalem" "-" TYPE_X86_CPU,\ - .property = "vme",\ - .value = "off",\ - },\ - {\ - .driver = "Westmere" "-" TYPE_X86_CPU,\ - .property = "vme",\ - .value = "off",\ - },\ - {\ - .driver = "SandyBridge" "-" TYPE_X86_CPU,\ - .property = "vme",\ - .value = "off",\ - },\ - {\ - .driver = "Haswell" "-" TYPE_X86_CPU,\ - .property = "vme",\ - .value = "off",\ - },\ - {\ - .driver = "Broadwell" "-" TYPE_X86_CPU,\ - .property = "vme",\ - .value = "off",\ - },\ - {\ - .driver = "Opteron_G1" "-" TYPE_X86_CPU,\ - .property = "vme",\ - .value = "off",\ - },\ - {\ - .driver = "Opteron_G2" "-" TYPE_X86_CPU,\ - .property = "vme",\ - .value = "off",\ - },\ - {\ - .driver = "Opteron_G3" "-" TYPE_X86_CPU,\ - .property = "vme",\ - .value = "off",\ - },\ - {\ - .driver = "Opteron_G4" "-" TYPE_X86_CPU,\ - .property = "vme",\ - .value = "off",\ - },\ - {\ - .driver = "Opteron_G5" "-" TYPE_X86_CPU,\ - .property = "vme",\ - .value = "off",\ - },\ - {\ - .driver = "Haswell" "-" TYPE_X86_CPU,\ - .property = "f16c",\ - .value = "off",\ - },\ - {\ - .driver = "Haswell" "-" TYPE_X86_CPU,\ - .property = "rdrand",\ - .value = "off",\ - },\ - {\ - .driver = "Broadwell" "-" TYPE_X86_CPU,\ - .property = "f16c",\ - .value = "off",\ - },\ - {\ - .driver = "Broadwell" "-" TYPE_X86_CPU,\ - .property = "rdrand",\ - .value = "off",\ - }, - -#define PC_COMPAT_2_1 \ - HW_COMPAT_2_1 \ - PC_CPU_MODEL_IDS("2.1.0") \ - {\ - .driver = "coreduo" "-" TYPE_X86_CPU,\ - .property = "vmx",\ - .value = "on",\ - },\ - {\ - .driver = "core2duo" "-" TYPE_X86_CPU,\ - .property = "vmx",\ - .value = "on",\ - }, - -#define PC_COMPAT_2_0 \ - PC_CPU_MODEL_IDS("2.0.0") \ - {\ - .driver = "virtio-scsi-pci",\ - .property = "any_layout",\ - .value = "off",\ - },{\ - .driver = "PIIX4_PM",\ - .property = "memory-hotplug-support",\ - .value = "off",\ - },\ - {\ - .driver = "apic",\ - .property = "version",\ - .value = stringify(0x11),\ - },\ - {\ - .driver = "nec-usb-xhci",\ - .property = "superspeed-ports-first",\ - .value = "off",\ - },\ - {\ - .driver = "nec-usb-xhci",\ - .property = "force-pcie-endcap",\ - .value = "on",\ - },\ - {\ - .driver = "pci-serial",\ - .property = "prog_if",\ - .value = stringify(0),\ - },\ - {\ - .driver = "pci-serial-2x",\ - .property = "prog_if",\ - .value = stringify(0),\ - },\ - {\ - .driver = "pci-serial-4x",\ - .property = "prog_if",\ - .value = stringify(0),\ - },\ - {\ - .driver = "virtio-net-pci",\ - .property = "guest_announce",\ - .value = "off",\ - },\ - {\ - .driver = "ICH9-LPC",\ - .property = "memory-hotplug-support",\ - .value = "off",\ - },{\ - .driver = "xio3130-downstream",\ - .property = COMPAT_PROP_PCP,\ - .value = "off",\ - },{\ - .driver = "ioh3420",\ - .property = COMPAT_PROP_PCP,\ - .value = "off",\ - }, - -#define PC_COMPAT_1_7 \ - PC_CPU_MODEL_IDS("1.7.0") \ - {\ - .driver = TYPE_USB_DEVICE,\ - .property = "msos-desc",\ - .value = "no",\ - },\ - {\ - .driver = "PIIX4_PM",\ - .property = "acpi-pci-hotplug-with-bridge-support",\ - .value = "off",\ - },\ - {\ - .driver = "hpet",\ - .property = HPET_INTCAP,\ - .value = stringify(4),\ - }, - -#define PC_COMPAT_1_6 \ - PC_CPU_MODEL_IDS("1.6.0") \ - {\ - .driver = "e1000",\ - .property = "mitigation",\ - .value = "off",\ - },{\ - .driver = "qemu64-" TYPE_X86_CPU,\ - .property = "model",\ - .value = stringify(2),\ - },{\ - .driver = "qemu32-" TYPE_X86_CPU,\ - .property = "model",\ - .value = stringify(3),\ - },{\ - .driver = "i440FX-pcihost",\ - .property = "short_root_bus",\ - .value = stringify(1),\ - },{\ - .driver = "q35-pcihost",\ - .property = "short_root_bus",\ - .value = stringify(1),\ - }, - -#define PC_COMPAT_1_5 \ - PC_CPU_MODEL_IDS("1.5.0") \ - {\ - .driver = "Conroe-" TYPE_X86_CPU,\ - .property = "model",\ - .value = stringify(2),\ - },{\ - .driver = "Conroe-" TYPE_X86_CPU,\ - .property = "min-level",\ - .value = stringify(2),\ - },{\ - .driver = "Penryn-" TYPE_X86_CPU,\ - .property = "model",\ - .value = stringify(2),\ - },{\ - .driver = "Penryn-" TYPE_X86_CPU,\ - .property = "min-level",\ - .value = stringify(2),\ - },{\ - .driver = "Nehalem-" TYPE_X86_CPU,\ - .property = "model",\ - .value = stringify(2),\ - },{\ - .driver = "Nehalem-" TYPE_X86_CPU,\ - .property = "min-level",\ - .value = stringify(2),\ - },{\ - .driver = "virtio-net-pci",\ - .property = "any_layout",\ - .value = "off",\ - },{\ - .driver = TYPE_X86_CPU,\ - .property = "pmu",\ - .value = "on",\ - },{\ - .driver = "i440FX-pcihost",\ - .property = "short_root_bus",\ - .value = stringify(0),\ - },{\ - .driver = "q35-pcihost",\ - .property = "short_root_bus",\ - .value = stringify(0),\ - }, - -#define PC_COMPAT_1_4 \ - PC_CPU_MODEL_IDS("1.4.0") \ - {\ - .driver = "scsi-hd",\ - .property = "discard_granularity",\ - .value = stringify(0),\ - },{\ - .driver = "scsi-cd",\ - .property = "discard_granularity",\ - .value = stringify(0),\ - },{\ - .driver = "scsi-disk",\ - .property = "discard_granularity",\ - .value = stringify(0),\ - },{\ - .driver = "ide-hd",\ - .property = "discard_granularity",\ - .value = stringify(0),\ - },{\ - .driver = "ide-cd",\ - .property = "discard_granularity",\ - .value = stringify(0),\ - },{\ - .driver = "ide-drive",\ - .property = "discard_granularity",\ - .value = stringify(0),\ - },{\ - .driver = "virtio-blk-pci",\ - .property = "discard_granularity",\ - .value = stringify(0),\ - },{\ - .driver = "virtio-serial-pci",\ - .property = "vectors",\ - /* DEV_NVECTORS_UNSPECIFIED as a uint32_t string */\ - .value = stringify(0xFFFFFFFF),\ - },{ \ - .driver = "virtio-net-pci", \ - .property = "ctrl_guest_offloads", \ - .value = "off", \ - },{\ - .driver = "e1000",\ - .property = "romfile",\ - .value = "pxe-e1000.rom",\ - },{\ - .driver = "ne2k_pci",\ - .property = "romfile",\ - .value = "pxe-ne2k_pci.rom",\ - },{\ - .driver = "pcnet",\ - .property = "romfile",\ - .value = "pxe-pcnet.rom",\ - },{\ - .driver = "rtl8139",\ - .property = "romfile",\ - .value = "pxe-rtl8139.rom",\ - },{\ - .driver = "virtio-net-pci",\ - .property = "romfile",\ - .value = "pxe-virtio.rom",\ - },{\ - .driver = "486-" TYPE_X86_CPU,\ - .property = "model",\ - .value = stringify(0),\ - },\ - {\ - .driver = "n270" "-" TYPE_X86_CPU,\ - .property = "movbe",\ - .value = "off",\ - },\ - {\ - .driver = "Westmere" "-" TYPE_X86_CPU,\ - .property = "pclmulqdq",\ - .value = "off",\ - }, - #define DEFINE_PC_MACHINE(suffix, namestr, initfn, optsfn) \ static void pc_machine_##suffix##_class_init(ObjectClass *oc, void *data) \ { \ diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 92851e55df..bc014c1c9f 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -249,24 +249,27 @@ struct PropertyInfo { /** * GlobalProperty: - * @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. - * @errp: Error destination, used like first argument of error_setg() - * in case property setting fails later. If @errp is NULL, we - * print warnings instead of ignoring errors silently. For - * hotplugged devices, errp is always ignored and warnings are - * printed instead. + * + * An error is fatal for non-hotplugged devices, when the global is applied. */ typedef struct GlobalProperty { const char *driver; const char *property; const char *value; - bool user_provided; bool used; - Error **errp; } GlobalProperty; +static inline void +compat_props_add(GPtrArray *arr, + GlobalProperty props[], size_t nelem) +{ + int i; + for (i = 0; i < nelem; i++) { + g_ptr_array_add(arr, (void *)&props[i]); + } +} + /*** Board API. This should go away once we have a machine config file. ***/ DeviceState *qdev_create(BusState *bus, const char *name); @@ -412,6 +415,8 @@ const char *qdev_fw_name(DeviceState *dev); Object *qdev_get_machine(void); +void object_apply_compat_props(Object *obj); + /* FIXME: make this a link<> */ void qdev_set_parent_bus(DeviceState *dev, BusState *bus); diff --git a/include/qom/object.h b/include/qom/object.h index bcae3f4951..e0262962b5 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -675,6 +675,9 @@ Object *object_new_with_propv(const char *typename, Error **errp, va_list vargs); +void object_apply_global_props(Object *obj, const GPtrArray *props, + Error **errp); + /** * object_set_props: * @obj: the object instance to set properties on diff --git a/include/sysemu/accel.h b/include/sysemu/accel.h index 637358f430..f331d128e9 100644 --- a/include/sysemu/accel.h +++ b/include/sysemu/accel.h @@ -49,7 +49,7 @@ typedef struct AccelClass { * global properties may be overridden by machine-type * compat_props or user-provided global properties. */ - GlobalProperty *global_props; + GPtrArray *compat_props; } AccelClass; #define TYPE_ACCEL "accel" @@ -67,8 +67,6 @@ typedef struct AccelClass { extern unsigned long tcg_tb_size; void configure_accelerator(MachineState *ms); -/* Register accelerator specific global properties */ -void accel_register_compat_props(AccelState *accel); /* Called just before os_setup_post (ie just before drop OS privs) */ void accel_setup_post(MachineState *ms); diff --git a/include/sysemu/hostmem.h b/include/sysemu/hostmem.h index 6e6bd2c1cb..a023b372a4 100644 --- a/include/sysemu/hostmem.h +++ b/include/sysemu/hostmem.h @@ -53,7 +53,7 @@ struct HostMemoryBackend { /* protected */ uint64_t size; - bool merge, dump; + bool merge, dump, use_canonical_path; bool prealloc, force_prealloc, is_mapped, share; DECLARE_BITMAP(host_nodes, MAX_NODES + 1); HostMemPolicy policy; @@ -67,5 +67,6 @@ MemoryRegion *host_memory_backend_get_memory(HostMemoryBackend *backend); void host_memory_backend_set_mapped(HostMemoryBackend *backend, bool mapped); bool host_memory_backend_is_mapped(HostMemoryBackend *backend); size_t host_memory_backend_pagesize(HostMemoryBackend *memdev); +char *host_memory_backend_get_name(HostMemoryBackend *backend); #endif @@ -312,7 +312,6 @@ static void cpu_common_parse_features(const char *typename, char *features, prop->driver = typename; prop->property = g_strdup(featurestr); prop->value = g_strdup(val); - prop->errp = &error_fatal; qdev_prop_register_global(prop); } else { error_setg(errp, "Expected key=value format, found %s.", diff --git a/qom/object.c b/qom/object.c index 17921c0a71..aa6f3a2a71 100644 --- a/qom/object.c +++ b/qom/object.c @@ -370,6 +370,41 @@ static void object_post_init_with_type(Object *obj, TypeImpl *ti) } } +void object_apply_global_props(Object *obj, const GPtrArray *props, Error **errp) +{ + Error *err = NULL; + int i; + + if (!props) { + return; + } + + for (i = 0; i < props->len; i++) { + GlobalProperty *p = g_ptr_array_index(props, i); + + if (object_dynamic_cast(obj, p->driver) == NULL) { + continue; + } + p->used = true; + object_property_parse(obj, p->value, p->property, &err); + if (err != NULL) { + error_prepend(&err, "can't apply global %s.%s=%s: ", + p->driver, p->property, p->value); + /* + * If errp != NULL, propagate error and return. + * If errp == NULL, report a warning, but keep going + * with the remaining globals. + */ + if (errp) { + error_propagate(errp, err); + return; + } else { + warn_report_err(err); + } + } + } +} + static void object_initialize_with_type(void *data, size_t size, TypeImpl *type) { Object *obj = data; diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h index d135ff8e06..2049fa9612 100644 --- a/target/arm/cpu-qom.h +++ b/target/arm/cpu-qom.h @@ -35,6 +35,8 @@ struct arm_boot_info; #define TYPE_ARM_MAX_CPU "max-" TYPE_ARM_CPU +typedef struct ARMCPUInfo ARMCPUInfo; + /** * ARMCPUClass: * @parent_realize: The parent class' realize handler. @@ -47,6 +49,7 @@ typedef struct ARMCPUClass { CPUClass parent_class; /*< public >*/ + const ARMCPUInfo *info; DeviceRealize parent_realize; void (*parent_reset)(CPUState *cpu); } ARMCPUClass; diff --git a/target/arm/cpu.c b/target/arm/cpu.c index c8505eaaee..4c4e9e169e 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -740,7 +740,7 @@ static Property arm_cpu_pmsav7_dregion_property = static Property arm_cpu_initsvtor_property = DEFINE_PROP_UINT32("init-svtor", ARMCPU, init_svtor, 0); -static void arm_cpu_post_init(Object *obj) +void arm_cpu_post_init(Object *obj) { ARMCPU *cpu = ARM_CPU(obj); @@ -1457,8 +1457,10 @@ static void cortex_m33_initfn(Object *obj) static void arm_v7m_class_init(ObjectClass *oc, void *data) { + ARMCPUClass *acc = ARM_CPU_CLASS(oc); CPUClass *cc = CPU_CLASS(oc); + acc->info = data; #ifndef CONFIG_USER_ONLY cc->do_interrupt = arm_v7m_cpu_do_interrupt; #endif @@ -1959,11 +1961,11 @@ static void arm_max_initfn(Object *obj) #endif /* !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64) */ -typedef struct ARMCPUInfo { +struct ARMCPUInfo { const char *name; void (*initfn)(Object *obj); void (*class_init)(ObjectClass *oc, void *data); -} ARMCPUInfo; +}; static const ARMCPUInfo arm_cpus[] = { #if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64) @@ -2113,6 +2115,7 @@ static void arm_host_initfn(Object *obj) ARMCPU *cpu = ARM_CPU(obj); kvm_arm_set_cpu_features_from_host(cpu); + arm_cpu_post_init(obj); } static const TypeInfo host_arm_cpu_type_info = { @@ -2127,14 +2130,30 @@ static const TypeInfo host_arm_cpu_type_info = { #endif +static void arm_cpu_instance_init(Object *obj) +{ + ARMCPUClass *acc = ARM_CPU_GET_CLASS(obj); + + acc->info->initfn(obj); + arm_cpu_post_init(obj); +} + +static void cpu_register_class_init(ObjectClass *oc, void *data) +{ + ARMCPUClass *acc = ARM_CPU_CLASS(oc); + + acc->info = data; +} + static void cpu_register(const ARMCPUInfo *info) { TypeInfo type_info = { .parent = TYPE_ARM_CPU, .instance_size = sizeof(ARMCPU), - .instance_init = info->initfn, + .instance_init = arm_cpu_instance_init, .class_size = sizeof(ARMCPUClass), - .class_init = info->class_init, + .class_init = info->class_init ?: cpu_register_class_init, + .class_data = (void *)info, }; type_info.name = g_strdup_printf("%s-" TYPE_ARM_CPU, info->name); @@ -2147,7 +2166,6 @@ static const TypeInfo arm_cpu_type_info = { .parent = TYPE_CPU, .instance_size = sizeof(ARMCPU), .instance_init = arm_cpu_initfn, - .instance_post_init = arm_cpu_post_init, .instance_finalize = arm_cpu_finalizefn, .abstract = true, .class_size = sizeof(ARMCPUClass), diff --git a/target/arm/cpu.h b/target/arm/cpu.h index c943f35dd9..3aedfeeaf1 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -884,6 +884,8 @@ static inline ARMCPU *arm_env_get_cpu(CPUARMState *env) return container_of(env, ARMCPU, env); } +void arm_cpu_post_init(Object *obj); + uint64_t arm_cpu_mp_affinity(int idx, uint8_t clustersz); #define ENV_GET_CPU(e) CPU(arm_env_get_cpu(e)) diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 1d57be0c91..4b544a1c58 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -364,11 +364,11 @@ static void aarch64_max_initfn(Object *obj) } } -typedef struct ARMCPUInfo { +struct ARMCPUInfo { const char *name; void (*initfn)(Object *obj); void (*class_init)(ObjectClass *oc, void *data); -} ARMCPUInfo; +}; static const ARMCPUInfo aarch64_cpus[] = { { .name = "cortex-a57", .initfn = aarch64_a57_initfn }, @@ -452,14 +452,30 @@ static void aarch64_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_arch_name = aarch64_gdb_arch_name; } +static void aarch64_cpu_instance_init(Object *obj) +{ + ARMCPUClass *acc = ARM_CPU_GET_CLASS(obj); + + acc->info->initfn(obj); + arm_cpu_post_init(obj); +} + +static void cpu_register_class_init(ObjectClass *oc, void *data) +{ + ARMCPUClass *acc = ARM_CPU_CLASS(oc); + + acc->info = data; +} + static void aarch64_cpu_register(const ARMCPUInfo *info) { TypeInfo type_info = { .parent = TYPE_AARCH64_CPU, .instance_size = sizeof(ARMCPU), - .instance_init = info->initfn, + .instance_init = aarch64_cpu_instance_init, .class_size = sizeof(ARMCPUClass), - .class_init = info->class_init, + .class_init = info->class_init ?: cpu_register_class_init, + .class_data = (void *)info, }; type_info.name = g_strdup_printf("%s-" TYPE_ARM_CPU, info->name); diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 677a3bd5fb..fa37203d89 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -3568,7 +3568,6 @@ static void x86_cpu_parse_featurestr(const char *typename, char *features, prop->driver = typename; prop->property = g_strdup(name); prop->value = g_strdup(val); - prop->errp = &error_fatal; qdev_prop_register_global(prop); } diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index 0f090ece54..4a4445bdf5 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -111,7 +111,6 @@ cpu_add_feat_as_prop(const char *typename, const char *name, const char *val) prop->driver = typename; prop->property = g_strdup(name); prop->value = g_strdup(val); - prop->errp = &error_fatal; qdev_prop_register_global(prop); } diff --git a/tests/test-qdev-global-props.c b/tests/test-qdev-global-props.c index b1eb505442..60231b1372 100644 --- a/tests/test-qdev-global-props.c +++ b/tests/test-qdev-global-props.c @@ -216,12 +216,12 @@ static void test_dynamic_globalprop_subprocess(void) { MyType *mt; static GlobalProperty props[] = { - { TYPE_DYNAMIC_PROPS, "prop1", "101", true }, - { TYPE_DYNAMIC_PROPS, "prop2", "102", true }, - { TYPE_DYNAMIC_PROPS"-bad", "prop3", "103", true }, - { TYPE_UNUSED_HOTPLUG, "prop4", "104", true }, - { TYPE_UNUSED_NOHOTPLUG, "prop5", "105", true }, - { TYPE_NONDEVICE, "prop6", "106", true }, + { TYPE_DYNAMIC_PROPS, "prop1", "101", }, + { TYPE_DYNAMIC_PROPS, "prop2", "102", }, + { TYPE_DYNAMIC_PROPS"-bad", "prop3", "103", }, + { TYPE_UNUSED_HOTPLUG, "prop4", "104", }, + { TYPE_UNUSED_NOHOTPLUG, "prop5", "105", }, + { TYPE_NONDEVICE, "prop6", "106", }, {} }; int global_error; @@ -256,46 +256,6 @@ static void test_dynamic_globalprop(void) g_test_trap_assert_stdout(""); } -/* Test setting of dynamic properties using user_provided=false properties */ -static void test_dynamic_globalprop_nouser_subprocess(void) -{ - MyType *mt; - static GlobalProperty props[] = { - { TYPE_DYNAMIC_PROPS, "prop1", "101" }, - { TYPE_DYNAMIC_PROPS, "prop2", "102" }, - { TYPE_DYNAMIC_PROPS"-bad", "prop3", "103" }, - { TYPE_UNUSED_HOTPLUG, "prop4", "104" }, - { TYPE_UNUSED_NOHOTPLUG, "prop5", "105" }, - { TYPE_NONDEVICE, "prop6", "106" }, - {} - }; - int global_error; - - register_global_properties(props); - - mt = DYNAMIC_TYPE(object_new(TYPE_DYNAMIC_PROPS)); - qdev_init_nofail(DEVICE(mt)); - - g_assert_cmpuint(mt->prop1, ==, 101); - g_assert_cmpuint(mt->prop2, ==, 102); - global_error = qdev_prop_check_globals(); - g_assert_cmpuint(global_error, ==, 0); - g_assert(props[0].used); - g_assert(props[1].used); - g_assert(!props[2].used); - g_assert(!props[3].used); - g_assert(!props[4].used); - g_assert(!props[5].used); -} - -static void test_dynamic_globalprop_nouser(void) -{ - g_test_trap_subprocess("/qdev/properties/dynamic/global/nouser/subprocess", 0, 0); - g_test_trap_assert_passed(); - g_test_trap_assert_stderr(""); - g_test_trap_assert_stdout(""); -} - /* Test if global props affecting subclasses are applied in the right order */ static void test_subclass_global_props(void) { @@ -345,11 +305,6 @@ int main(int argc, char **argv) g_test_add_func("/qdev/properties/dynamic/global", test_dynamic_globalprop); - g_test_add_func("/qdev/properties/dynamic/global/nouser/subprocess", - test_dynamic_globalprop_nouser_subprocess); - g_test_add_func("/qdev/properties/dynamic/global/nouser", - test_dynamic_globalprop_nouser); - g_test_add_func("/qdev/properties/global/subclass", test_subclass_global_props); @@ -2964,8 +2964,6 @@ static int global_init_func(void *opaque, QemuOpts *opts, Error **errp) g->driver = qemu_opt_get(opts, "driver"); g->property = qemu_opt_get(opts, "property"); g->value = qemu_opt_get(opts, "value"); - g->user_provided = true; - g->errp = &error_fatal; qdev_prop_register_global(g); return 0; } @@ -2996,8 +2994,6 @@ static void user_register_global_props(void) */ static void register_global_properties(MachineState *ms) { - accel_register_compat_props(ms->accelerator); - machine_register_compat_props(ms); user_register_global_props(); } |