summaryrefslogtreecommitdiff
path: root/hw/core
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2019-01-07 15:32:24 +0000
committerPeter Maydell <peter.maydell@linaro.org>2019-01-07 15:32:24 +0000
commit31ed41889e6e13699871040fe089a2884dca46cb (patch)
treec045cb2dfafade1ee80ae448f2ebaaf2a90d6cc8 /hw/core
parenta29644590f95166c8a13e5797f8e7701134b31d0 (diff)
parentfa0cb34d2210cc749b9a70db99bb41c56ad20831 (diff)
downloadqemu-31ed41889e6e13699871040fe089a2884dca46cb.zip
Merge remote-tracking branch 'remotes/elmarco/tags/machine-props-pull-request' into staging
Generalize machine compatibility properties During "[PATCH v2 05/10] qom/globals: generalize object_property_set_globals()" review, Eduardo suggested to rework the GlobalProperty handling, so that -global is limited to QDev only and we avoid mixing the machine compats and the user-provided -global properties (instead of generalizing -global to various object kinds, like I proposed in v2). "qdev: do not mix compat props with global props" patch decouples a bit user-provided -global from machine compat properties. This allows to get rid of "user_provided" and "errp" fields in following patches. A new compat property "x-use-canonical-path-for-ramblock-id" is added to hostmem for legacy canonical path names, set to true for -file and -memfd with qemu < 4.0. (this series was initially titled "[PATCH v2 00/10] hostmem: use object "id" for memory region name with >= 3.1", but its focus is more in refactoring the global and compatilibity properties handling now) # gpg: Signature made Mon 07 Jan 2019 12:22:43 GMT # gpg: using RSA key DAE8E10975969CE5 # gpg: Good signature from "Marc-André Lureau <marcandre.lureau@redhat.com>" # gpg: aka "Marc-André Lureau <marcandre.lureau@gmail.com>" # Primary key fingerprint: 87A9 BD93 3F87 C606 D276 F62D DAE8 E109 7596 9CE5 * remotes/elmarco/tags/machine-props-pull-request: (28 commits) hostmem: use object id for memory region name with >= 4.0 arm: replace instance_post_init() qdev-props: call object_apply_global_props() qdev-props: remove errp from GlobalProperty qdev-props: convert global_props to GPtrArray qdev: all globals are now user-provided qdev: make a separate helper function to apply compat properties compat: remove remaining PC_COMPAT macros include: remove compat.h compat: replace PC_COMPAT_2_1 & HW_COMPAT_2_1 macros compat: replace PC_COMPAT_2_2 & HW_COMPAT_2_2 macros compat: replace PC_COMPAT_2_3 & HW_COMPAT_2_3 macros compat: replace PC_COMPAT_2_4 & HW_COMPAT_2_4 macros compat: replace PC_COMPAT_2_5 & HW_COMPAT_2_5 macros compat: replace PC_COMPAT_2_6 & HW_COMPAT_2_6 macros compat: replace PC_COMPAT_2_7 & HW_COMPAT_2_7 macros compat: replace PC_COMPAT_2_8 & HW_COMPAT_2_8 macros compat: replace PC_COMPAT_2_9 & HW_COMPAT_2_9 macros compat: replace PC_COMPAT_2_10 & HW_COMPAT_2_10 macros compat: replace PC_COMPAT_2_11 & HW_COMPAT_2_11 macros ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/core')
-rw-r--r--hw/core/machine.c347
-rw-r--r--hw/core/qdev-properties.c49
-rw-r--r--hw/core/qdev.c15
3 files changed, 362 insertions, 49 deletions
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));
}