[PATCH for-6.2 01/12] accel: Rename TYPE_ACCEL to TYPE_ACCEL_BASE

2021-08-06 Thread Eduardo Habkost
The ACCEL name conflicts with a Windows API typedef name, and it
is difficult to work around this because windows.h needs to be
included by osdep.h.  This prevents us from replacing the
existing ACCEL macro with an inline function generated by
OBJECT_DEFINE_TYPE.

Work around the conflict by renaming TYPE_ACCEL to TYPE_ACCEL_BASE.

Note that the actual QOM type name is still "accel", because QOM
type names are user-visible and I don't want to make any
user-visible change here.

Signed-off-by: Eduardo Habkost 
---
Notes about name alternatives:

I have considered using the name "CPU_ACCEL" as Daniel suggested,
but this would lead to a parent class named CPU_ACCEL, while
the subclasses would be still named KVM_ACCEL, HVF_ACCEL,
TCG_ACCEL, etc.  I that this would be confusing, because it
would look like CPU_ACCEL is just another type of accel, not the
parent type of all other *_ACCEL types.

Renaming KVM_ACCEL/HVF_ACCEL/TCG_ACCEL to
KVM_CPU_ACCEL/HVF_CPU_ACCEL/TCG_CPU_ACCEL would be clearer, but I
believe it would be too intrusive and the resulting type names
would be too long.

Renaming the base classe ACCEL_BASE sounds like a reasonable
alternative, as there are other examples in QEMU where abstract
base classes are called *_BASE: TYPE_VIRTIO_GPU_PCI_BASE,
TYPE_VIRTIO_GPU_BASE, TYPE_E1000_BASE, TYPE_RISCV_CPU_BASE,
TYPE_MEGASAS_BASE, TYPE_SCSI_DISK_BASE, etc.
---
Cc: Richard Henderson 
Cc: Paolo Bonzini 
Cc: Cameron Esfahani 
Cc: Roman Bolshakov 
Cc: Thomas Huth 
Cc: Laurent Vivier 
Cc: Stefano Stabellini 
Cc: Anthony Perard 
Cc: Paul Durrant 
Cc: Warner Losh 
Cc: Kyle Evans 
Cc: Eduardo Habkost 
Cc: Marcel Apfelbaum 
Cc: Peter Xu 
Cc: David Hildenbrand 
Cc: Wenchao Wang 
Cc: Colin Xu 
Cc: Kamil Rytarowski 
Cc: Reinoud Zandijk 
Cc: Sunil Muthuswamy 
Cc: qemu-de...@nongnu.org
Cc: k...@vger.kernel.org
Cc: xen-devel@lists.xenproject.org
Cc: haxm-t...@intel.com
---
 hw/core/machine.c   |  2 +-
 include/qemu/accel.h| 16 
 accel/accel-common.c|  4 ++--
 accel/accel-softmmu.c   |  4 ++--
 accel/accel-user.c  |  2 +-
 accel/hvf/hvf-accel-ops.c   |  4 ++--
 accel/kvm/kvm-all.c |  4 ++--
 accel/qtest/qtest.c |  4 ++--
 accel/tcg/tcg-all.c |  4 ++--
 accel/xen/xen-all.c |  4 ++--
 bsd-user/main.c |  2 +-
 linux-user/main.c   |  2 +-
 softmmu/memory.c|  2 +-
 softmmu/vl.c|  6 +++---
 target/i386/hax/hax-all.c   |  4 ++--
 target/i386/nvmm/nvmm-all.c |  4 ++--
 target/i386/whpx/whpx-all.c |  4 ++--
 17 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/hw/core/machine.c b/hw/core/machine.c
index 943974d411c..fdb1f886ce8 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -1268,7 +1268,7 @@ void machine_run_board_init(MachineState *machine)
"on", false);
 }
 
-accel_init_interfaces(ACCEL_GET_CLASS(machine->accelerator));
+accel_init_interfaces(ACCEL_BASE_GET_CLASS(machine->accelerator));
 machine_class->init(machine);
 phase_advance(PHASE_MACHINE_INITIALIZED);
 }
diff --git a/include/qemu/accel.h b/include/qemu/accel.h
index 4f4c283f6fc..cc915720494 100644
--- a/include/qemu/accel.h
+++ b/include/qemu/accel.h
@@ -54,17 +54,17 @@ typedef struct AccelClass {
 GPtrArray *compat_props;
 } AccelClass;
 
-#define TYPE_ACCEL "accel"
+#define TYPE_ACCEL_BASE "accel"
 
-#define ACCEL_CLASS_SUFFIX  "-" TYPE_ACCEL
+#define ACCEL_CLASS_SUFFIX  "-" TYPE_ACCEL_BASE
 #define ACCEL_CLASS_NAME(a) (a ACCEL_CLASS_SUFFIX)
 
-#define ACCEL_CLASS(klass) \
-OBJECT_CLASS_CHECK(AccelClass, (klass), TYPE_ACCEL)
-#define ACCEL(obj) \
-OBJECT_CHECK(AccelState, (obj), TYPE_ACCEL)
-#define ACCEL_GET_CLASS(obj) \
-OBJECT_GET_CLASS(AccelClass, (obj), TYPE_ACCEL)
+#define ACCEL_BASE_CLASS(klass) \
+OBJECT_CLASS_CHECK(AccelClass, (klass), TYPE_ACCEL_BASE)
+#define ACCEL_BASE(obj) \
+OBJECT_CHECK(AccelState, (obj), TYPE_ACCEL_BASE)
+#define ACCEL_BASE_GET_CLASS(obj) \
+OBJECT_GET_CLASS(AccelClass, (obj), TYPE_ACCEL_BASE)
 
 AccelClass *accel_find(const char *opt_name);
 AccelState *current_accel(void);
diff --git a/accel/accel-common.c b/accel/accel-common.c
index 7b8ec7e0f72..c4e268c8a74 100644
--- a/accel/accel-common.c
+++ b/accel/accel-common.c
@@ -34,7 +34,7 @@
 #endif /* !CONFIG_USER_ONLY */
 
 static const TypeInfo accel_type = {
-.name = TYPE_ACCEL,
+.name = TYPE_ACCEL_BASE,
 .parent = TYPE_OBJECT,
 .class_size = sizeof(AccelClass),
 .instance_size = sizeof(AccelState),
@@ -44,7 +44,7 @@ static const TypeInfo accel_type = {
 AccelClass *accel_find(const char *opt_name)
 {
 char *class_name = g_strdup_printf(ACCEL_CLASS_NAME("%s"), opt_name);
-AccelClass *ac = ACCEL_CLASS(module_object_class_by_name(class_name));
+AccelClass *ac = ACCEL_BASE_CLASS(module_object_class_by_name(class_name));
   

Re: [PATCH v4 23/32] qdev: Move dev->realized check to qdev_property_set()

2020-12-14 Thread Eduardo Habkost
On Mon, Dec 14, 2020 at 03:55:30PM +0100, Igor Mammedov wrote:
> On Fri, 11 Dec 2020 17:05:20 -0500
> Eduardo Habkost  wrote:
> 
> > Every single qdev property setter function manually checks
> > dev->realized.  We can just check dev->realized inside
> > qdev_property_set() instead.
> > 
> > The check is being added as a separate function
> > (qdev_prop_allow_set()) because it will become a callback later.
> 
> is callback added within this series?
> and I'd add here what's the purpose of it.

It will be added in part 2 of the series.  See v3:
https://lore.kernel.org/qemu-devel/20201112214350.872250-35-ehabk...@redhat.com/

I don't know what else I could say about its purpose, in addition
to what I wrote above, and the comment below[1].

If you are just curious about the callback and confused because
it is not anywhere in this series, I can just remove the
paragraph above from the commit message.  Would that be enough?

> 
[...]
> > +/* returns: true if property is allowed to be set, false otherwise */

[1] ^^^

> > +static bool qdev_prop_allow_set(Object *obj, const char *name,
> > +Error **errp)
> > +{
> > +DeviceState *dev = DEVICE(obj);
> > +
> > +if (dev->realized) {
> > +qdev_prop_set_after_realize(dev, name, errp);
> > +return false;
> > +}
> > +return true;
> > +}
> > +

-- 
Eduardo




[PATCH v4 30/32] qdev: Rename qdev_get_prop_ptr() to object_field_prop_ptr()

2020-12-11 Thread Eduardo Habkost
The function will be moved to common QOM code, as it is not
specific to TYPE_DEVICE anymore.

Reviewed-by: Stefan Berger 
Signed-off-by: Eduardo Habkost 
---
Changes v1 -> v2:
* Rename to object_field_prop_ptr() instead of object_static_prop_ptr()
---
Cc: Stefan Berger 
Cc: Stefano Stabellini 
Cc: Anthony Perard 
Cc: Paul Durrant 
Cc: Kevin Wolf 
Cc: Max Reitz 
Cc: Paolo Bonzini 
Cc: "Daniel P. Berrangé" 
Cc: Eduardo Habkost 
Cc: Cornelia Huck 
Cc: Halil Pasic 
Cc: Christian Borntraeger 
Cc: Richard Henderson 
Cc: David Hildenbrand 
Cc: Thomas Huth 
Cc: Matthew Rosato 
Cc: Alex Williamson 
Cc: qemu-de...@nongnu.org
Cc: xen-devel@lists.xenproject.org
Cc: qemu-bl...@nongnu.org
Cc: qemu-s3...@nongnu.org
---
 include/hw/qdev-properties.h |  2 +-
 backends/tpm/tpm_util.c  |  6 ++--
 hw/block/xen-block.c |  4 +--
 hw/core/qdev-properties-system.c | 50 +-
 hw/core/qdev-properties.c| 60 
 hw/s390x/css.c   |  4 +--
 hw/s390x/s390-pci-bus.c  |  4 +--
 hw/vfio/pci-quirks.c |  4 +--
 8 files changed, 67 insertions(+), 67 deletions(-)

diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
index 90222822f1..97bb9494ae 100644
--- a/include/hw/qdev-properties.h
+++ b/include/hw/qdev-properties.h
@@ -193,7 +193,7 @@ void qdev_prop_set_macaddr(DeviceState *dev, const char 
*name,
const uint8_t *value);
 void qdev_prop_set_enum(DeviceState *dev, const char *name, int value);
 
-void *qdev_get_prop_ptr(Object *obj, Property *prop);
+void *object_field_prop_ptr(Object *obj, Property *prop);
 
 void qdev_prop_register_global(GlobalProperty *prop);
 const GlobalProperty *qdev_find_global_prop(Object *obj,
diff --git a/backends/tpm/tpm_util.c b/backends/tpm/tpm_util.c
index 39b45fa46d..a6e6d3e72f 100644
--- a/backends/tpm/tpm_util.c
+++ b/backends/tpm/tpm_util.c
@@ -35,7 +35,7 @@
 static void get_tpm(Object *obj, Visitor *v, const char *name, void *opaque,
 Error **errp)
 {
-TPMBackend **be = qdev_get_prop_ptr(obj, opaque);
+TPMBackend **be = object_field_prop_ptr(obj, opaque);
 char *p;
 
 p = g_strdup(*be ? (*be)->id : "");
@@ -47,7 +47,7 @@ static void set_tpm(Object *obj, Visitor *v, const char 
*name, void *opaque,
 Error **errp)
 {
 Property *prop = opaque;
-TPMBackend *s, **be = qdev_get_prop_ptr(obj, prop);
+TPMBackend *s, **be = object_field_prop_ptr(obj, prop);
 char *str;
 
 if (!visit_type_str(v, name, , errp)) {
@@ -67,7 +67,7 @@ static void set_tpm(Object *obj, Visitor *v, const char 
*name, void *opaque,
 static void release_tpm(Object *obj, const char *name, void *opaque)
 {
 Property *prop = opaque;
-TPMBackend **be = qdev_get_prop_ptr(obj, prop);
+TPMBackend **be = object_field_prop_ptr(obj, prop);
 
 if (*be) {
 tpm_backend_reset(*be);
diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c
index bd1aef63a7..718d886e5c 100644
--- a/hw/block/xen-block.c
+++ b/hw/block/xen-block.c
@@ -336,7 +336,7 @@ static void xen_block_get_vdev(Object *obj, Visitor *v, 
const char *name,
void *opaque, Error **errp)
 {
 Property *prop = opaque;
-XenBlockVdev *vdev = qdev_get_prop_ptr(obj, prop);
+XenBlockVdev *vdev = object_field_prop_ptr(obj, prop);
 char *str;
 
 switch (vdev->type) {
@@ -396,7 +396,7 @@ static void xen_block_set_vdev(Object *obj, Visitor *v, 
const char *name,
void *opaque, Error **errp)
 {
 Property *prop = opaque;
-XenBlockVdev *vdev = qdev_get_prop_ptr(obj, prop);
+XenBlockVdev *vdev = object_field_prop_ptr(obj, prop);
 char *str, *p;
 const char *end;
 
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index 590c5f3d97..e6d378a34e 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -62,7 +62,7 @@ static void get_drive(Object *obj, Visitor *v, const char 
*name, void *opaque,
   Error **errp)
 {
 Property *prop = opaque;
-void **ptr = qdev_get_prop_ptr(obj, prop);
+void **ptr = object_field_prop_ptr(obj, prop);
 const char *value;
 char *p;
 
@@ -88,7 +88,7 @@ static void set_drive_helper(Object *obj, Visitor *v, const 
char *name,
 {
 DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
-void **ptr = qdev_get_prop_ptr(obj, prop);
+void **ptr = object_field_prop_ptr(obj, prop);
 char *str;
 BlockBackend *blk;
 bool blk_created = false;
@@ -181,7 +181,7 @@ static void release_drive(Object *obj, const char *name, 
void *opaque)
 {
 DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
-BlockBackend **ptr = qdev_get_prop_ptr(obj, prop);
+BlockBackend **ptr = object_field_prop_ptr(obj, prop);
 
 if (*ptr) {
 AioContext *ctx = blk_get_aio_co

[PATCH v4 23/32] qdev: Move dev->realized check to qdev_property_set()

2020-12-11 Thread Eduardo Habkost
Every single qdev property setter function manually checks
dev->realized.  We can just check dev->realized inside
qdev_property_set() instead.

The check is being added as a separate function
(qdev_prop_allow_set()) because it will become a callback later.

Reviewed-by: Stefan Berger 
Signed-off-by: Eduardo Habkost 
---
Changes v1 -> v2:
* Removed unused variable at xen_block_set_vdev()
* Redone patch after changes in the previous patches in the
  series
---
Cc: Stefan Berger 
Cc: Stefano Stabellini 
Cc: Anthony Perard 
Cc: Paul Durrant 
Cc: Kevin Wolf 
Cc: Max Reitz 
Cc: Paolo Bonzini 
Cc: "Daniel P. Berrangé" 
Cc: Eduardo Habkost 
Cc: Cornelia Huck 
Cc: Halil Pasic 
Cc: Christian Borntraeger 
Cc: Richard Henderson 
Cc: David Hildenbrand 
Cc: Thomas Huth 
Cc: Matthew Rosato 
Cc: Alex Williamson 
Cc: Mark Cave-Ayland 
Cc: Artyom Tarasenko 
Cc: qemu-de...@nongnu.org
Cc: xen-devel@lists.xenproject.org
Cc: qemu-bl...@nongnu.org
Cc: qemu-s3...@nongnu.org
---
 backends/tpm/tpm_util.c  |   6 --
 hw/block/xen-block.c |   6 --
 hw/core/qdev-properties-system.c |  70 --
 hw/core/qdev-properties.c| 100 ++-
 hw/s390x/css.c   |   6 --
 hw/s390x/s390-pci-bus.c  |   6 --
 hw/vfio/pci-quirks.c |   6 --
 target/sparc/cpu.c   |   6 --
 8 files changed, 18 insertions(+), 188 deletions(-)

diff --git a/backends/tpm/tpm_util.c b/backends/tpm/tpm_util.c
index a5d997e7dc..39b45fa46d 100644
--- a/backends/tpm/tpm_util.c
+++ b/backends/tpm/tpm_util.c
@@ -46,16 +46,10 @@ static void get_tpm(Object *obj, Visitor *v, const char 
*name, void *opaque,
 static void set_tpm(Object *obj, Visitor *v, const char *name, void *opaque,
 Error **errp)
 {
-DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
 TPMBackend *s, **be = qdev_get_prop_ptr(obj, prop);
 char *str;
 
-if (dev->realized) {
-qdev_prop_set_after_realize(dev, name, errp);
-return;
-}
-
 if (!visit_type_str(v, name, , errp)) {
 return;
 }
diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c
index 905e4acd97..bd1aef63a7 100644
--- a/hw/block/xen-block.c
+++ b/hw/block/xen-block.c
@@ -395,17 +395,11 @@ static int vbd_name_to_disk(const char *name, const char 
**endp,
 static void xen_block_set_vdev(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
 {
-DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
 XenBlockVdev *vdev = qdev_get_prop_ptr(obj, prop);
 char *str, *p;
 const char *end;
 
-if (dev->realized) {
-qdev_prop_set_after_realize(dev, name, errp);
-return;
-}
-
 if (!visit_type_str(v, name, , errp)) {
 return;
 }
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index 42529c3b65..f31aea3de1 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -94,11 +94,6 @@ static void set_drive_helper(Object *obj, Visitor *v, const 
char *name,
 bool blk_created = false;
 int ret;
 
-if (dev->realized) {
-qdev_prop_set_after_realize(dev, name, errp);
-return;
-}
-
 if (!visit_type_str(v, name, , errp)) {
 return;
 }
@@ -230,17 +225,11 @@ static void get_chr(Object *obj, Visitor *v, const char 
*name, void *opaque,
 static void set_chr(Object *obj, Visitor *v, const char *name, void *opaque,
 Error **errp)
 {
-DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
 CharBackend *be = qdev_get_prop_ptr(obj, prop);
 Chardev *s;
 char *str;
 
-if (dev->realized) {
-qdev_prop_set_after_realize(dev, name, errp);
-return;
-}
-
 if (!visit_type_str(v, name, , errp)) {
 return;
 }
@@ -311,18 +300,12 @@ static void get_mac(Object *obj, Visitor *v, const char 
*name, void *opaque,
 static void set_mac(Object *obj, Visitor *v, const char *name, void *opaque,
 Error **errp)
 {
-DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
 MACAddr *mac = qdev_get_prop_ptr(obj, prop);
 int i, pos;
 char *str;
 const char *p;
 
-if (dev->realized) {
-qdev_prop_set_after_realize(dev, name, errp);
-return;
-}
-
 if (!visit_type_str(v, name, , errp)) {
 return;
 }
@@ -390,7 +373,6 @@ static void get_netdev(Object *obj, Visitor *v, const char 
*name,
 static void set_netdev(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
 {
-DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
 NICPeers *peers_ptr = qdev_get_prop_ptr(obj, prop);
 NetClientState **ncs = peers_ptr->ncs;
@@ -398,11 +380,6 @@ static void set_netdev(Object *obj, Visitor *v, const char 
*name,
 int queues, err = 0, i = 0;
   

[PATCH v4 09/32] qdev: Make qdev_get_prop_ptr() get Object* arg

2020-12-11 Thread Eduardo Habkost
Make the code more generic and not specific to TYPE_DEVICE.

Reviewed-by: Marc-André Lureau 
Reviewed-by: Cornelia Huck  #s390 parts
Signed-off-by: Eduardo Habkost 
---
Changes v1 -> v2:
- Fix build error with CONFIG_XEN
  I took the liberty of keeping the Reviewed-by line from
  Marc-André as the build fix is a trivial one line change
---
Cc: Stefan Berger 
Cc: Stefano Stabellini 
Cc: Anthony Perard 
Cc: Paul Durrant 
Cc: Kevin Wolf 
Cc: Max Reitz 
Cc: Paolo Bonzini 
Cc: "Daniel P. Berrangé" 
Cc: Eduardo Habkost 
Cc: Cornelia Huck 
Cc: Thomas Huth 
Cc: Richard Henderson 
Cc: David Hildenbrand 
Cc: Halil Pasic 
Cc: Christian Borntraeger 
Cc: Matthew Rosato 
Cc: Alex Williamson 
Cc: qemu-de...@nongnu.org
Cc: xen-devel@lists.xenproject.org
Cc: qemu-bl...@nongnu.org
Cc: qemu-s3...@nongnu.org
---
 include/hw/qdev-properties.h |  2 +-
 backends/tpm/tpm_util.c  |  8 ++--
 hw/block/xen-block.c |  5 +-
 hw/core/qdev-properties-system.c | 57 +-
 hw/core/qdev-properties.c| 82 +---
 hw/s390x/css.c   |  5 +-
 hw/s390x/s390-pci-bus.c  |  4 +-
 hw/vfio/pci-quirks.c |  5 +-
 8 files changed, 68 insertions(+), 100 deletions(-)

diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
index 0ea822e6a7..0b92cfc761 100644
--- a/include/hw/qdev-properties.h
+++ b/include/hw/qdev-properties.h
@@ -302,7 +302,7 @@ void qdev_prop_set_macaddr(DeviceState *dev, const char 
*name,
const uint8_t *value);
 void qdev_prop_set_enum(DeviceState *dev, const char *name, int value);
 
-void *qdev_get_prop_ptr(DeviceState *dev, Property *prop);
+void *qdev_get_prop_ptr(Object *obj, Property *prop);
 
 void qdev_prop_register_global(GlobalProperty *prop);
 const GlobalProperty *qdev_find_global_prop(DeviceState *dev,
diff --git a/backends/tpm/tpm_util.c b/backends/tpm/tpm_util.c
index e6aeb63587..3973105658 100644
--- a/backends/tpm/tpm_util.c
+++ b/backends/tpm/tpm_util.c
@@ -35,8 +35,7 @@
 static void get_tpm(Object *obj, Visitor *v, const char *name, void *opaque,
 Error **errp)
 {
-DeviceState *dev = DEVICE(obj);
-TPMBackend **be = qdev_get_prop_ptr(dev, opaque);
+TPMBackend **be = qdev_get_prop_ptr(obj, opaque);
 char *p;
 
 p = g_strdup(*be ? (*be)->id : "");
@@ -49,7 +48,7 @@ static void set_tpm(Object *obj, Visitor *v, const char 
*name, void *opaque,
 {
 DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
-TPMBackend *s, **be = qdev_get_prop_ptr(dev, prop);
+TPMBackend *s, **be = qdev_get_prop_ptr(obj, prop);
 char *str;
 
 if (dev->realized) {
@@ -73,9 +72,8 @@ static void set_tpm(Object *obj, Visitor *v, const char 
*name, void *opaque,
 
 static void release_tpm(Object *obj, const char *name, void *opaque)
 {
-DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
-TPMBackend **be = qdev_get_prop_ptr(dev, prop);
+TPMBackend **be = qdev_get_prop_ptr(obj, prop);
 
 if (*be) {
 tpm_backend_reset(*be);
diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c
index 8a7a3f5452..905e4acd97 100644
--- a/hw/block/xen-block.c
+++ b/hw/block/xen-block.c
@@ -335,9 +335,8 @@ static char *disk_to_vbd_name(unsigned int disk)
 static void xen_block_get_vdev(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
 {
-DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
-XenBlockVdev *vdev = qdev_get_prop_ptr(dev, prop);
+XenBlockVdev *vdev = qdev_get_prop_ptr(obj, prop);
 char *str;
 
 switch (vdev->type) {
@@ -398,7 +397,7 @@ static void xen_block_set_vdev(Object *obj, Visitor *v, 
const char *name,
 {
 DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
-XenBlockVdev *vdev = qdev_get_prop_ptr(dev, prop);
+XenBlockVdev *vdev = qdev_get_prop_ptr(obj, prop);
 char *str, *p;
 const char *end;
 
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index 77b31eb9dc..9ac9b95852 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -59,9 +59,8 @@ static bool check_prop_still_unset(DeviceState *dev, const 
char *name,
 static void get_drive(Object *obj, Visitor *v, const char *name, void *opaque,
   Error **errp)
 {
-DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
-void **ptr = qdev_get_prop_ptr(dev, prop);
+void **ptr = qdev_get_prop_ptr(obj, prop);
 const char *value;
 char *p;
 
@@ -87,7 +86,7 @@ static void set_drive_helper(Object *obj, Visitor *v, const 
char *name,
 {
 DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
-void **ptr = qdev_get_prop_ptr(dev, prop);
+void **ptr = qdev_get_prop_ptr(obj, prop);
 char *str;
 BlockBackend *blk;
 bool blk_created = false;
@@ -185,7 +184,7 @@ static void release_dri

Re: [PATCH-for-6.0 v4 15/17] gitlab-ci: Add test for Xen (on CentOS 7)

2020-11-26 Thread Eduardo Habkost
On Thu, Nov 26, 2020 at 05:38:24PM +, Anthony PERARD wrote:
> On Sun, Nov 08, 2020 at 09:45:33PM +0100, Philippe Mathieu-Daudé wrote:
> > Xen packages are available in CentOS 7, but have been
> > removed from CentOS 8. Use the CentOS 7 container.
> 
> Technically Xen has never been in CentOS 8, I'm working on it, slowly.
> 
> > Signed-off-by: Philippe Mathieu-Daudé 
> > ---
> > Cc: Eduardo Habkost 
> > Cc: Stefano Stabellini 
> > Cc: Anthony Perard 
> > Cc: Paul Durrant 
> > Cc: xen-devel@lists.xenproject.org
> > ---
> >  .gitlab-ci.yml | 21 +
> >  1 file changed, 21 insertions(+)
> > 
> > diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
> > index 2f0da7b3dc1..8e15266c277 100644
> > --- a/.gitlab-ci.yml
> > +++ b/.gitlab-ci.yml
> > @@ -557,6 +557,27 @@ check-crypto-only-gnutls:
> >  IMAGE: centos7
> >  MAKE_CHECK_ARGS: check
> >  
> > +build-xen-centos:
> > +  <<: *native_build_job_definition
> > +  variables:
> > +IMAGE: centos7
> > +TARGETS: i386-softmmu x86_64-softmmu
> > +CONFIGURE_ARGS: --enable-xen
> > +MAKE_CHECK_ARGS: check-build
> > +  artifacts:
> > +paths:
> > +  - build
> > +
> > +check-xen-centos:
> > +  <<: *native_test_job_definition
> > +  needs:
> > +- job: build-xen-centos
> > +  artifacts: true
> > +  variables:
> > +IMAGE: centos7
> > +MAKE_CHECK_ARGS: check
> 
> Is `make check` going to do something useful with the Xen support? Or is
> it going to need more work in order to test the Xen support of QEMU?
> (Like starting an actual Xen guest.)

I don't think it will test Xen support, but we still want to at
least check if --enable-xen doesn't break anything else.

Is there any public CI system anywhere where Xen support is
tested today?

-- 
Eduardo




[PATCH v2 4/6] xen: Delete xen_available() function

2020-11-25 Thread Eduardo Habkost
The function can be replaced with accel_available("xen").

Signed-off-by: Eduardo Habkost 
---
Cc: Paolo Bonzini 
Cc: qemu-de...@nongnu.org
Cc: Stefano Stabellini 
Cc: Anthony Perard 
Cc: Paul Durrant 
Cc: xen-devel@lists.xenproject.org
Cc: Richard Henderson 
Cc: Claudio Fontana 
Cc: Roman Bolshakov 
---
 include/sysemu/arch_init.h | 2 --
 softmmu/arch_init.c| 9 -
 softmmu/vl.c   | 6 +++---
 3 files changed, 3 insertions(+), 14 deletions(-)

diff --git a/include/sysemu/arch_init.h b/include/sysemu/arch_init.h
index b32ce1afa9..40ac8052b7 100644
--- a/include/sysemu/arch_init.h
+++ b/include/sysemu/arch_init.h
@@ -32,6 +32,4 @@ enum {
 
 extern const uint32_t arch_type;
 
-int xen_available(void);
-
 #endif
diff --git a/softmmu/arch_init.c b/softmmu/arch_init.c
index 79383c8db8..f4770931f5 100644
--- a/softmmu/arch_init.c
+++ b/softmmu/arch_init.c
@@ -49,12 +49,3 @@ int graphic_depth = 32;
 
 
 const uint32_t arch_type = QEMU_ARCH;
-
-int xen_available(void)
-{
-#ifdef CONFIG_XEN
-return 1;
-#else
-return 0;
-#endif
-}
diff --git a/softmmu/vl.c b/softmmu/vl.c
index e6e0ad5a92..74b6ebf1e4 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -3667,21 +3667,21 @@ void qemu_init(int argc, char **argv, char **envp)
 has_defaults = 0;
 break;
 case QEMU_OPTION_xen_domid:
-if (!(xen_available())) {
+if (!(accel_available("xen"))) {
 error_report("Option not supported for this target");
 exit(1);
 }
 xen_domid = atoi(optarg);
 break;
 case QEMU_OPTION_xen_attach:
-if (!(xen_available())) {
+if (!(accel_available("xen"))) {
 error_report("Option not supported for this target");
 exit(1);
 }
 xen_mode = XEN_ATTACH;
 break;
 case QEMU_OPTION_xen_domid_restrict:
-if (!(xen_available())) {
+if (!(accel_available("xen"))) {
 error_report("Option not supported for this target");
 exit(1);
 }
-- 
2.28.0




[PATCH v3 30/53] qdev: Rename qdev_get_prop_ptr() to object_field_prop_ptr()

2020-11-12 Thread Eduardo Habkost
The function will be moved to common QOM code, as it is not
specific to TYPE_DEVICE anymore.

Reviewed-by: Stefan Berger 
Signed-off-by: Eduardo Habkost 
---
Changes v1 -> v2:
* Rename to object_field_prop_ptr() instead of object_static_prop_ptr()
---
Cc: Stefan Berger 
Cc: Stefano Stabellini 
Cc: Anthony Perard 
Cc: Paul Durrant 
Cc: Kevin Wolf 
Cc: Max Reitz 
Cc: Paolo Bonzini 
Cc: "Daniel P. Berrangé" 
Cc: Eduardo Habkost 
Cc: Cornelia Huck 
Cc: Halil Pasic 
Cc: Christian Borntraeger 
Cc: Richard Henderson 
Cc: David Hildenbrand 
Cc: Thomas Huth 
Cc: Matthew Rosato 
Cc: Alex Williamson 
Cc: qemu-de...@nongnu.org
Cc: xen-devel@lists.xenproject.org
Cc: qemu-bl...@nongnu.org
Cc: qemu-s3...@nongnu.org
---
 include/hw/qdev-properties.h |  2 +-
 backends/tpm/tpm_util.c  |  6 ++--
 hw/block/xen-block.c |  4 +--
 hw/core/qdev-properties-system.c | 50 +-
 hw/core/qdev-properties.c| 60 
 hw/s390x/css.c   |  4 +--
 hw/s390x/s390-pci-bus.c  |  4 +--
 hw/vfio/pci-quirks.c |  4 +--
 8 files changed, 67 insertions(+), 67 deletions(-)

diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
index 90222822f1..97bb9494ae 100644
--- a/include/hw/qdev-properties.h
+++ b/include/hw/qdev-properties.h
@@ -193,7 +193,7 @@ void qdev_prop_set_macaddr(DeviceState *dev, const char 
*name,
const uint8_t *value);
 void qdev_prop_set_enum(DeviceState *dev, const char *name, int value);
 
-void *qdev_get_prop_ptr(Object *obj, Property *prop);
+void *object_field_prop_ptr(Object *obj, Property *prop);
 
 void qdev_prop_register_global(GlobalProperty *prop);
 const GlobalProperty *qdev_find_global_prop(Object *obj,
diff --git a/backends/tpm/tpm_util.c b/backends/tpm/tpm_util.c
index 0b07cf55ea..bb1ab34a75 100644
--- a/backends/tpm/tpm_util.c
+++ b/backends/tpm/tpm_util.c
@@ -35,7 +35,7 @@
 static void get_tpm(Object *obj, Visitor *v, const char *name, void *opaque,
 Error **errp)
 {
-TPMBackend **be = qdev_get_prop_ptr(obj, opaque);
+TPMBackend **be = object_field_prop_ptr(obj, opaque);
 char *p;
 
 p = g_strdup(*be ? (*be)->id : "");
@@ -47,7 +47,7 @@ static void set_tpm(Object *obj, Visitor *v, const char 
*name, void *opaque,
 Error **errp)
 {
 Property *prop = opaque;
-TPMBackend *s, **be = qdev_get_prop_ptr(obj, prop);
+TPMBackend *s, **be = object_field_prop_ptr(obj, prop);
 char *str;
 
 if (!visit_type_str(v, name, , errp)) {
@@ -67,7 +67,7 @@ static void set_tpm(Object *obj, Visitor *v, const char 
*name, void *opaque,
 static void release_tpm(Object *obj, const char *name, void *opaque)
 {
 Property *prop = opaque;
-TPMBackend **be = qdev_get_prop_ptr(obj, prop);
+TPMBackend **be = object_field_prop_ptr(obj, prop);
 
 if (*be) {
 tpm_backend_reset(*be);
diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c
index bd1aef63a7..718d886e5c 100644
--- a/hw/block/xen-block.c
+++ b/hw/block/xen-block.c
@@ -336,7 +336,7 @@ static void xen_block_get_vdev(Object *obj, Visitor *v, 
const char *name,
void *opaque, Error **errp)
 {
 Property *prop = opaque;
-XenBlockVdev *vdev = qdev_get_prop_ptr(obj, prop);
+XenBlockVdev *vdev = object_field_prop_ptr(obj, prop);
 char *str;
 
 switch (vdev->type) {
@@ -396,7 +396,7 @@ static void xen_block_set_vdev(Object *obj, Visitor *v, 
const char *name,
void *opaque, Error **errp)
 {
 Property *prop = opaque;
-XenBlockVdev *vdev = qdev_get_prop_ptr(obj, prop);
+XenBlockVdev *vdev = object_field_prop_ptr(obj, prop);
 char *str, *p;
 const char *end;
 
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index 96a0bc5109..8781b856d3 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -62,7 +62,7 @@ static void get_drive(Object *obj, Visitor *v, const char 
*name, void *opaque,
   Error **errp)
 {
 Property *prop = opaque;
-void **ptr = qdev_get_prop_ptr(obj, prop);
+void **ptr = object_field_prop_ptr(obj, prop);
 const char *value;
 char *p;
 
@@ -88,7 +88,7 @@ static void set_drive_helper(Object *obj, Visitor *v, const 
char *name,
 {
 DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
-void **ptr = qdev_get_prop_ptr(obj, prop);
+void **ptr = object_field_prop_ptr(obj, prop);
 char *str;
 BlockBackend *blk;
 bool blk_created = false;
@@ -181,7 +181,7 @@ static void release_drive(Object *obj, const char *name, 
void *opaque)
 {
 DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
-BlockBackend **ptr = qdev_get_prop_ptr(obj, prop);
+BlockBackend **ptr = object_field_prop_ptr(obj, prop);
 
 if (*ptr) {
 AioContext *ctx = blk_get_aio_co

[PATCH v3 23/53] qdev: Move dev->realized check to qdev_property_set()

2020-11-12 Thread Eduardo Habkost
Every single qdev property setter function manually checks
dev->realized.  We can just check dev->realized inside
qdev_property_set() instead.

The check is being added as a separate function
(qdev_prop_allow_set()) because it will become a callback later.

Reviewed-by: Stefan Berger 
Signed-off-by: Eduardo Habkost 
---
Changes v1 -> v2:
* Removed unused variable at xen_block_set_vdev()
* Redone patch after changes in the previous patches in the
  series
---
Cc: Stefan Berger 
Cc: Stefano Stabellini 
Cc: Anthony Perard 
Cc: Paul Durrant 
Cc: Kevin Wolf 
Cc: Max Reitz 
Cc: Paolo Bonzini 
Cc: "Daniel P. Berrangé" 
Cc: Eduardo Habkost 
Cc: Cornelia Huck 
Cc: Halil Pasic 
Cc: Christian Borntraeger 
Cc: Richard Henderson 
Cc: David Hildenbrand 
Cc: Thomas Huth 
Cc: Matthew Rosato 
Cc: Alex Williamson 
Cc: Mark Cave-Ayland 
Cc: Artyom Tarasenko 
Cc: qemu-de...@nongnu.org
Cc: xen-devel@lists.xenproject.org
Cc: qemu-bl...@nongnu.org
Cc: qemu-s3...@nongnu.org
---
 backends/tpm/tpm_util.c  |   6 --
 hw/block/xen-block.c |   6 --
 hw/core/qdev-properties-system.c |  70 --
 hw/core/qdev-properties.c| 100 ++-
 hw/s390x/css.c   |   6 --
 hw/s390x/s390-pci-bus.c  |   6 --
 hw/vfio/pci-quirks.c |   6 --
 target/sparc/cpu.c   |   6 --
 8 files changed, 18 insertions(+), 188 deletions(-)

diff --git a/backends/tpm/tpm_util.c b/backends/tpm/tpm_util.c
index dba2f6b04a..0b07cf55ea 100644
--- a/backends/tpm/tpm_util.c
+++ b/backends/tpm/tpm_util.c
@@ -46,16 +46,10 @@ static void get_tpm(Object *obj, Visitor *v, const char 
*name, void *opaque,
 static void set_tpm(Object *obj, Visitor *v, const char *name, void *opaque,
 Error **errp)
 {
-DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
 TPMBackend *s, **be = qdev_get_prop_ptr(obj, prop);
 char *str;
 
-if (dev->realized) {
-qdev_prop_set_after_realize(dev, name, errp);
-return;
-}
-
 if (!visit_type_str(v, name, , errp)) {
 return;
 }
diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c
index 905e4acd97..bd1aef63a7 100644
--- a/hw/block/xen-block.c
+++ b/hw/block/xen-block.c
@@ -395,17 +395,11 @@ static int vbd_name_to_disk(const char *name, const char 
**endp,
 static void xen_block_set_vdev(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
 {
-DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
 XenBlockVdev *vdev = qdev_get_prop_ptr(obj, prop);
 char *str, *p;
 const char *end;
 
-if (dev->realized) {
-qdev_prop_set_after_realize(dev, name, errp);
-return;
-}
-
 if (!visit_type_str(v, name, , errp)) {
 return;
 }
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index 202abd0e4b..0d3e57bba0 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -94,11 +94,6 @@ static void set_drive_helper(Object *obj, Visitor *v, const 
char *name,
 bool blk_created = false;
 int ret;
 
-if (dev->realized) {
-qdev_prop_set_after_realize(dev, name, errp);
-return;
-}
-
 if (!visit_type_str(v, name, , errp)) {
 return;
 }
@@ -230,17 +225,11 @@ static void get_chr(Object *obj, Visitor *v, const char 
*name, void *opaque,
 static void set_chr(Object *obj, Visitor *v, const char *name, void *opaque,
 Error **errp)
 {
-DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
 CharBackend *be = qdev_get_prop_ptr(obj, prop);
 Chardev *s;
 char *str;
 
-if (dev->realized) {
-qdev_prop_set_after_realize(dev, name, errp);
-return;
-}
-
 if (!visit_type_str(v, name, , errp)) {
 return;
 }
@@ -311,18 +300,12 @@ static void get_mac(Object *obj, Visitor *v, const char 
*name, void *opaque,
 static void set_mac(Object *obj, Visitor *v, const char *name, void *opaque,
 Error **errp)
 {
-DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
 MACAddr *mac = qdev_get_prop_ptr(obj, prop);
 int i, pos;
 char *str;
 const char *p;
 
-if (dev->realized) {
-qdev_prop_set_after_realize(dev, name, errp);
-return;
-}
-
 if (!visit_type_str(v, name, , errp)) {
 return;
 }
@@ -390,7 +373,6 @@ static void get_netdev(Object *obj, Visitor *v, const char 
*name,
 static void set_netdev(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
 {
-DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
 NICPeers *peers_ptr = qdev_get_prop_ptr(obj, prop);
 NetClientState **ncs = peers_ptr->ncs;
@@ -398,11 +380,6 @@ static void set_netdev(Object *obj, Visitor *v, const char 
*name,
 int queues, err = 0, i = 0;
   

[PATCH v3 09/53] qdev: Make qdev_get_prop_ptr() get Object* arg

2020-11-12 Thread Eduardo Habkost
Make the code more generic and not specific to TYPE_DEVICE.

Reviewed-by: Marc-André Lureau 
Signed-off-by: Eduardo Habkost 
---
Changes v1 -> v2:
- Fix build error with CONFIG_XEN
  I took the liberty of keeping the Reviewed-by line from
  Marc-André as the build fix is a trivial one line change
---
Cc: Stefan Berger 
Cc: Stefano Stabellini 
Cc: Anthony Perard 
Cc: Paul Durrant 
Cc: Kevin Wolf 
Cc: Max Reitz 
Cc: Paolo Bonzini 
Cc: "Daniel P. Berrangé" 
Cc: Eduardo Habkost 
Cc: Cornelia Huck 
Cc: Thomas Huth 
Cc: Richard Henderson 
Cc: David Hildenbrand 
Cc: Halil Pasic 
Cc: Christian Borntraeger 
Cc: Matthew Rosato 
Cc: Alex Williamson 
Cc: qemu-de...@nongnu.org
Cc: xen-devel@lists.xenproject.org
Cc: qemu-bl...@nongnu.org
Cc: qemu-s3...@nongnu.org
---
 include/hw/qdev-properties.h |  2 +-
 backends/tpm/tpm_util.c  |  8 ++--
 hw/block/xen-block.c |  5 +-
 hw/core/qdev-properties-system.c | 57 +-
 hw/core/qdev-properties.c| 82 +---
 hw/s390x/css.c   |  5 +-
 hw/s390x/s390-pci-bus.c  |  4 +-
 hw/vfio/pci-quirks.c |  5 +-
 8 files changed, 68 insertions(+), 100 deletions(-)

diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
index 0ea822e6a7..0b92cfc761 100644
--- a/include/hw/qdev-properties.h
+++ b/include/hw/qdev-properties.h
@@ -302,7 +302,7 @@ void qdev_prop_set_macaddr(DeviceState *dev, const char 
*name,
const uint8_t *value);
 void qdev_prop_set_enum(DeviceState *dev, const char *name, int value);
 
-void *qdev_get_prop_ptr(DeviceState *dev, Property *prop);
+void *qdev_get_prop_ptr(Object *obj, Property *prop);
 
 void qdev_prop_register_global(GlobalProperty *prop);
 const GlobalProperty *qdev_find_global_prop(DeviceState *dev,
diff --git a/backends/tpm/tpm_util.c b/backends/tpm/tpm_util.c
index b58d298c1a..e91c21dd4a 100644
--- a/backends/tpm/tpm_util.c
+++ b/backends/tpm/tpm_util.c
@@ -35,8 +35,7 @@
 static void get_tpm(Object *obj, Visitor *v, const char *name, void *opaque,
 Error **errp)
 {
-DeviceState *dev = DEVICE(obj);
-TPMBackend **be = qdev_get_prop_ptr(dev, opaque);
+TPMBackend **be = qdev_get_prop_ptr(obj, opaque);
 char *p;
 
 p = g_strdup(*be ? (*be)->id : "");
@@ -49,7 +48,7 @@ static void set_tpm(Object *obj, Visitor *v, const char 
*name, void *opaque,
 {
 DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
-TPMBackend *s, **be = qdev_get_prop_ptr(dev, prop);
+TPMBackend *s, **be = qdev_get_prop_ptr(obj, prop);
 char *str;
 
 if (dev->realized) {
@@ -73,9 +72,8 @@ static void set_tpm(Object *obj, Visitor *v, const char 
*name, void *opaque,
 
 static void release_tpm(Object *obj, const char *name, void *opaque)
 {
-DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
-TPMBackend **be = qdev_get_prop_ptr(dev, prop);
+TPMBackend **be = qdev_get_prop_ptr(obj, prop);
 
 if (*be) {
 tpm_backend_reset(*be);
diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c
index 8a7a3f5452..905e4acd97 100644
--- a/hw/block/xen-block.c
+++ b/hw/block/xen-block.c
@@ -335,9 +335,8 @@ static char *disk_to_vbd_name(unsigned int disk)
 static void xen_block_get_vdev(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
 {
-DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
-XenBlockVdev *vdev = qdev_get_prop_ptr(dev, prop);
+XenBlockVdev *vdev = qdev_get_prop_ptr(obj, prop);
 char *str;
 
 switch (vdev->type) {
@@ -398,7 +397,7 @@ static void xen_block_set_vdev(Object *obj, Visitor *v, 
const char *name,
 {
 DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
-XenBlockVdev *vdev = qdev_get_prop_ptr(dev, prop);
+XenBlockVdev *vdev = qdev_get_prop_ptr(obj, prop);
 char *str, *p;
 const char *end;
 
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index d0fb063a49..c8c73c371b 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -59,9 +59,8 @@ static bool check_prop_still_unset(DeviceState *dev, const 
char *name,
 static void get_drive(Object *obj, Visitor *v, const char *name, void *opaque,
   Error **errp)
 {
-DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
-void **ptr = qdev_get_prop_ptr(dev, prop);
+void **ptr = qdev_get_prop_ptr(obj, prop);
 const char *value;
 char *p;
 
@@ -87,7 +86,7 @@ static void set_drive_helper(Object *obj, Visitor *v, const 
char *name,
 {
 DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
-void **ptr = qdev_get_prop_ptr(dev, prop);
+void **ptr = qdev_get_prop_ptr(obj, prop);
 char *str;
 BlockBackend *blk;
 bool blk_created = false;
@@ -185,7 +184,7 @@ static void release_drive(Object *obj, const char *name, 
void *

[PATCH 4/7] qom: Replace void* parameter with Property* on field getters/setters

2020-11-04 Thread Eduardo Habkost
All field property getters and setters must interpret the fourth
argument as Property*.  Change the function signature of field
property getters and setters to indicate that.

Signed-off-by: Eduardo Habkost 
---
Cc: Stefan Berger 
Cc: Stefano Stabellini 
Cc: Anthony Perard 
Cc: Paul Durrant 
Cc: Kevin Wolf 
Cc: Max Reitz 
Cc: Paolo Bonzini 
Cc: "Daniel P. Berrangé" 
Cc: Eduardo Habkost 
Cc: Richard Henderson 
Cc: David Hildenbrand 
Cc: Cornelia Huck 
Cc: Thomas Huth 
Cc: Halil Pasic 
Cc: Christian Borntraeger 
Cc: Matthew Rosato 
Cc: Alex Williamson 
Cc: Mark Cave-Ayland 
Cc: Artyom Tarasenko 
Cc: qemu-de...@nongnu.org
Cc: xen-devel@lists.xenproject.org
Cc: qemu-bl...@nongnu.org
Cc: qemu-s3...@nongnu.org
---
 include/qom/field-property-internal.h |   8 +-
 include/qom/field-property.h  |  26 ---
 backends/tpm/tpm_util.c   |  11 ++-
 hw/block/xen-block.c  |   6 +-
 hw/core/qdev-properties-system.c  |  86 +-
 hw/s390x/css.c|   6 +-
 hw/s390x/s390-pci-bus.c   |   6 +-
 hw/vfio/pci-quirks.c  |  10 +--
 qom/property-types.c  | 102 +-
 target/sparc/cpu.c|   4 +-
 10 files changed, 105 insertions(+), 160 deletions(-)

diff --git a/include/qom/field-property-internal.h 
b/include/qom/field-property-internal.h
index 7aa27ce836..bc7d25033d 100644
--- a/include/qom/field-property-internal.h
+++ b/include/qom/field-property-internal.h
@@ -9,9 +9,9 @@
 #define QOM_STATIC_PROPERTY_INTERNAL_H
 
 void field_prop_get_enum(Object *obj, Visitor *v, const char *name,
- void *opaque, Error **errp);
+ Property *prop, Error **errp);
 void field_prop_set_enum(Object *obj, Visitor *v, const char *name,
- void *opaque, Error **errp);
+ Property *prop, Error **errp);
 
 void field_prop_set_default_value_enum(ObjectProperty *op,
const Property *prop);
@@ -21,9 +21,9 @@ void field_prop_set_default_value_uint(ObjectProperty *op,
const Property *prop);
 
 void field_prop_get_int32(Object *obj, Visitor *v, const char *name,
-  void *opaque, Error **errp);
+  Property *prop, Error **errp);
 void field_prop_get_size32(Object *obj, Visitor *v, const char *name,
-   void *opaque, Error **errp);
+   Property *prop, Error **errp);
 
 /**
  * object_property_add_field: Add a field property to an object instance
diff --git a/include/qom/field-property.h b/include/qom/field-property.h
index e64a2b3c07..438bb25896 100644
--- a/include/qom/field-property.h
+++ b/include/qom/field-property.h
@@ -54,6 +54,18 @@ struct Property {
 const char   *link_type;
 };
 
+/**
+ * typedef FieldAccessor: a field property getter or setter function
+ * @obj: the object instance
+ * @v: the visitor that contains the property data
+ * @name: the name of the property
+ * @prop: Field property definition
+ * @errp: pointer to error information
+ */
+typedef void FieldAccessor(Object *obj, Visitor *v,
+   const char *name, Property *prop,
+   Error **errp);
+
 /**
  * struct PropertyInfo: information on a specific QOM property type
  */
@@ -71,16 +83,10 @@ struct PropertyInfo {
 /** @create: Optional callback for creation of property */
 ObjectProperty *(*create)(ObjectClass *oc, const char *name,
   Property *prop);
-/**
- * @get: Property getter.  The opaque parameter will point to
- *the  struct for the property.
- */
-ObjectPropertyAccessor *get;
-/**
- * @set: Property setter.  The opaque parameter will point to
- *the  struct for the property.
- */
-ObjectPropertyAccessor *set;
+/** @get: Property getter */
+FieldAccessor *get;
+/** @set: Property setter */
+FieldAccessor *set;
 /**
  * @release: Optional release function, called when the object
  * is destroyed
diff --git a/backends/tpm/tpm_util.c b/backends/tpm/tpm_util.c
index bb1ab34a75..e8837938e5 100644
--- a/backends/tpm/tpm_util.c
+++ b/backends/tpm/tpm_util.c
@@ -32,10 +32,10 @@
 
 /* tpm backend property */
 
-static void get_tpm(Object *obj, Visitor *v, const char *name, void *opaque,
-Error **errp)
+static void get_tpm(Object *obj, Visitor *v, const char *name,
+Property *prop, Error **errp)
 {
-TPMBackend **be = object_field_prop_ptr(obj, opaque);
+TPMBackend **be = object_field_prop_ptr(obj, prop);
 char *p;
 
 p = g_strdup(*be ? (*be)->id : "");
@@ -43,10 +43,9 @@ static void get_tpm(Object *obj, Visitor *v, const char 
*name, void *opaque,
 g_free(p);
 }
 
-static void set_tpm(Object *obj, Visitor *v,

[PATCH 6/7] qom: Add FIELD_PTR, a type-safe wrapper for object_field_prop_ptr()

2020-11-04 Thread Eduardo Habkost
Introduce a FIELD_PTR macro that will ensure the size of the area
we are accessing has the correct size, and will return a pointer
of the correct type.

Signed-off-by: Eduardo Habkost 
---
Cc: Stefan Berger 
Cc: Stefano Stabellini 
Cc: Anthony Perard 
Cc: Paul Durrant 
Cc: Kevin Wolf 
Cc: Max Reitz 
Cc: Paolo Bonzini 
Cc: "Daniel P. Berrangé" 
Cc: Eduardo Habkost 
Cc: Cornelia Huck 
Cc: Thomas Huth 
Cc: Halil Pasic 
Cc: Christian Borntraeger 
Cc: Richard Henderson 
Cc: David Hildenbrand 
Cc: Matthew Rosato 
Cc: Alex Williamson 
Cc: qemu-de...@nongnu.org
Cc: xen-devel@lists.xenproject.org
Cc: qemu-bl...@nongnu.org
Cc: qemu-s3...@nongnu.org
---
 include/qom/field-property.h | 21 ++-
 backends/tpm/tpm_util.c  |  6 ++--
 hw/block/xen-block.c |  4 +--
 hw/core/qdev-properties-system.c | 50 +-
 hw/s390x/css.c   |  4 +--
 hw/s390x/s390-pci-bus.c  |  4 +--
 hw/vfio/pci-quirks.c |  4 +--
 qom/field-property.c |  3 +-
 qom/property-types.c | 60 +---
 9 files changed, 89 insertions(+), 67 deletions(-)

diff --git a/include/qom/field-property.h b/include/qom/field-property.h
index 1d3bf9699b..58baaca160 100644
--- a/include/qom/field-property.h
+++ b/include/qom/field-property.h
@@ -125,6 +125,25 @@ object_class_property_add_field(ObjectClass *oc, const 
char *name,
 Property *prop,
 ObjectPropertyAllowSet allow_set);
 
-void *object_field_prop_ptr(Object *obj, Property *prop);
+/**
+ * object_field_prop_ptr: Get pointer to property field
+ * @obj: the object instance
+ * @prop: field property definition
+ * @expected_size: expected size of struct field
+ *
+ * Don't use this function directly, use the FIELD_PTR() macro instead.
+ */
+void *object_field_prop_ptr(Object *obj, Property *prop, size_t expected_size);
+
+/**
+ * FIELD_PTR: Get pointer to struct field for property
+ *
+ * This returns a pointer to type @type, pointing to the struct
+ * field containing the property value.
+ *
+ * @type must match the expected type for the property.
+ */
+#define FIELD_PTR(obj, prop, type) \
+((type *)object_field_prop_ptr((obj), (prop), sizeof(type)))
 
 #endif
diff --git a/backends/tpm/tpm_util.c b/backends/tpm/tpm_util.c
index 556e21388c..da80379404 100644
--- a/backends/tpm/tpm_util.c
+++ b/backends/tpm/tpm_util.c
@@ -35,7 +35,7 @@
 static void get_tpm(Object *obj, Visitor *v, const char *name,
 Property *prop, Error **errp)
 {
-TPMBackend **be = object_field_prop_ptr(obj, prop);
+TPMBackend **be = FIELD_PTR(obj, prop, TPMBackend *);
 char *p;
 
 p = g_strdup(*be ? (*be)->id : "");
@@ -46,7 +46,7 @@ static void get_tpm(Object *obj, Visitor *v, const char *name,
 static void set_tpm(Object *obj, Visitor *v, const char *name,
 Property *prop, Error **errp)
 {
-TPMBackend *s, **be = object_field_prop_ptr(obj, prop);
+TPMBackend *s, **be = FIELD_PTR(obj, prop, TPMBackend *);
 char *str;
 
 if (!visit_type_str(v, name, , errp)) {
@@ -65,7 +65,7 @@ static void set_tpm(Object *obj, Visitor *v, const char *name,
 
 static void release_tpm(Object *obj, const char *name, Property *prop)
 {
-TPMBackend **be = object_field_prop_ptr(obj, prop);
+TPMBackend **be = FIELD_PTR(obj, prop, TPMBackend *);
 
 if (*be) {
 tpm_backend_reset(*be);
diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c
index c1ee634639..390bf417ab 100644
--- a/hw/block/xen-block.c
+++ b/hw/block/xen-block.c
@@ -335,7 +335,7 @@ static char *disk_to_vbd_name(unsigned int disk)
 static void xen_block_get_vdev(Object *obj, Visitor *v, const char *name,
 Property *prop, Error **errp)
 {
-XenBlockVdev *vdev = object_field_prop_ptr(obj, prop);
+XenBlockVdev *vdev = FIELD_PTR(obj, prop, XenBlockVdev);
 char *str;
 
 switch (vdev->type) {
@@ -394,7 +394,7 @@ static int vbd_name_to_disk(const char *name, const char 
**endp,
 static void xen_block_set_vdev(Object *obj, Visitor *v, const char *name,
 Property *prop, Error **errp)
 {
-XenBlockVdev *vdev = object_field_prop_ptr(obj, prop);
+XenBlockVdev *vdev = FIELD_PTR(obj, prop, XenBlockVdev);
 char *str, *p;
 const char *end;
 
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index 2fdd5863bb..1ec64514b9 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -61,7 +61,7 @@ static bool check_prop_still_unset(Object *obj, const char 
*name,
 static void get_drive(Object *obj, Visitor *v, const char *name,
   Property *prop, Error **errp)
 {
-void **ptr = object_field_prop_ptr(obj, prop);
+void **ptr = FIELD_PTR(obj, prop, void *);
 const char *value;
 char *p;
 
@@ -87,7 +87,7 @@ static void set_drive_h

[PATCH v2 36/44] qdev: Rename qdev_get_prop_ptr() to object_field_prop_ptr()

2020-11-04 Thread Eduardo Habkost
The function will be moved to common QOM code, as it is not
specific to TYPE_DEVICE anymore.

Signed-off-by: Eduardo Habkost 
---
Changes v1 -> v2:
* Rename to object_field_prop_ptr() instead of object_static_prop_ptr()
---
Cc: Stefan Berger 
Cc: Stefano Stabellini 
Cc: Anthony Perard 
Cc: Paul Durrant 
Cc: Kevin Wolf 
Cc: Max Reitz 
Cc: Paolo Bonzini 
Cc: "Daniel P. Berrangé" 
Cc: Eduardo Habkost 
Cc: Cornelia Huck 
Cc: Halil Pasic 
Cc: Christian Borntraeger 
Cc: Richard Henderson 
Cc: David Hildenbrand 
Cc: Thomas Huth 
Cc: Matthew Rosato 
Cc: Alex Williamson 
Cc: qemu-de...@nongnu.org
Cc: xen-devel@lists.xenproject.org
Cc: qemu-bl...@nongnu.org
Cc: qemu-s3...@nongnu.org
---
 include/hw/qdev-properties.h |  2 +-
 backends/tpm/tpm_util.c  |  6 ++--
 hw/block/xen-block.c |  4 +--
 hw/core/qdev-properties-system.c | 50 +-
 hw/core/qdev-properties.c| 60 
 hw/s390x/css.c   |  4 +--
 hw/s390x/s390-pci-bus.c  |  4 +--
 hw/vfio/pci-quirks.c |  4 +--
 8 files changed, 67 insertions(+), 67 deletions(-)

diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
index 7f8d5fc206..2bec65c8e5 100644
--- a/include/hw/qdev-properties.h
+++ b/include/hw/qdev-properties.h
@@ -223,7 +223,7 @@ void qdev_prop_set_macaddr(DeviceState *dev, const char 
*name,
const uint8_t *value);
 void qdev_prop_set_enum(DeviceState *dev, const char *name, int value);
 
-void *qdev_get_prop_ptr(Object *obj, Property *prop);
+void *object_field_prop_ptr(Object *obj, Property *prop);
 
 void qdev_prop_register_global(GlobalProperty *prop);
 const GlobalProperty *qdev_find_global_prop(Object *obj,
diff --git a/backends/tpm/tpm_util.c b/backends/tpm/tpm_util.c
index 0b07cf55ea..bb1ab34a75 100644
--- a/backends/tpm/tpm_util.c
+++ b/backends/tpm/tpm_util.c
@@ -35,7 +35,7 @@
 static void get_tpm(Object *obj, Visitor *v, const char *name, void *opaque,
 Error **errp)
 {
-TPMBackend **be = qdev_get_prop_ptr(obj, opaque);
+TPMBackend **be = object_field_prop_ptr(obj, opaque);
 char *p;
 
 p = g_strdup(*be ? (*be)->id : "");
@@ -47,7 +47,7 @@ static void set_tpm(Object *obj, Visitor *v, const char 
*name, void *opaque,
 Error **errp)
 {
 Property *prop = opaque;
-TPMBackend *s, **be = qdev_get_prop_ptr(obj, prop);
+TPMBackend *s, **be = object_field_prop_ptr(obj, prop);
 char *str;
 
 if (!visit_type_str(v, name, , errp)) {
@@ -67,7 +67,7 @@ static void set_tpm(Object *obj, Visitor *v, const char 
*name, void *opaque,
 static void release_tpm(Object *obj, const char *name, void *opaque)
 {
 Property *prop = opaque;
-TPMBackend **be = qdev_get_prop_ptr(obj, prop);
+TPMBackend **be = object_field_prop_ptr(obj, prop);
 
 if (*be) {
 tpm_backend_reset(*be);
diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c
index bd1aef63a7..718d886e5c 100644
--- a/hw/block/xen-block.c
+++ b/hw/block/xen-block.c
@@ -336,7 +336,7 @@ static void xen_block_get_vdev(Object *obj, Visitor *v, 
const char *name,
void *opaque, Error **errp)
 {
 Property *prop = opaque;
-XenBlockVdev *vdev = qdev_get_prop_ptr(obj, prop);
+XenBlockVdev *vdev = object_field_prop_ptr(obj, prop);
 char *str;
 
 switch (vdev->type) {
@@ -396,7 +396,7 @@ static void xen_block_set_vdev(Object *obj, Visitor *v, 
const char *name,
void *opaque, Error **errp)
 {
 Property *prop = opaque;
-XenBlockVdev *vdev = qdev_get_prop_ptr(obj, prop);
+XenBlockVdev *vdev = object_field_prop_ptr(obj, prop);
 char *str, *p;
 const char *end;
 
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index 96a0bc5109..8781b856d3 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -62,7 +62,7 @@ static void get_drive(Object *obj, Visitor *v, const char 
*name, void *opaque,
   Error **errp)
 {
 Property *prop = opaque;
-void **ptr = qdev_get_prop_ptr(obj, prop);
+void **ptr = object_field_prop_ptr(obj, prop);
 const char *value;
 char *p;
 
@@ -88,7 +88,7 @@ static void set_drive_helper(Object *obj, Visitor *v, const 
char *name,
 {
 DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
-void **ptr = qdev_get_prop_ptr(obj, prop);
+void **ptr = object_field_prop_ptr(obj, prop);
 char *str;
 BlockBackend *blk;
 bool blk_created = false;
@@ -181,7 +181,7 @@ static void release_drive(Object *obj, const char *name, 
void *opaque)
 {
 DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
-BlockBackend **ptr = qdev_get_prop_ptr(obj, prop);
+BlockBackend **ptr = object_field_prop_ptr(obj, prop);
 
 if (*ptr) {
 AioContext *ctx = blk_get_aio_context(*ptr);
@@ -214,7

[PATCH v2 22/44] qdev: Move dev->realized check to qdev_property_set()

2020-11-04 Thread Eduardo Habkost
Every single qdev property setter function manually checks
dev->realized.  We can just check dev->realized inside
qdev_property_set() instead.

The check is being added as a separate function
(qdev_prop_allow_set()) because it will become a callback later.

Signed-off-by: Eduardo Habkost 
---
Changes v1 -> v2:
* Removed unused variable at xen_block_set_vdev()
* Redone patch after changes in the previous patches in the
  series
---
Cc: Stefan Berger 
Cc: Stefano Stabellini 
Cc: Anthony Perard 
Cc: Paul Durrant 
Cc: Kevin Wolf 
Cc: Max Reitz 
Cc: Paolo Bonzini 
Cc: "Daniel P. Berrangé" 
Cc: Eduardo Habkost 
Cc: Cornelia Huck 
Cc: Halil Pasic 
Cc: Christian Borntraeger 
Cc: Richard Henderson 
Cc: David Hildenbrand 
Cc: Thomas Huth 
Cc: Matthew Rosato 
Cc: Alex Williamson 
Cc: Mark Cave-Ayland 
Cc: Artyom Tarasenko 
Cc: qemu-de...@nongnu.org
Cc: xen-devel@lists.xenproject.org
Cc: qemu-bl...@nongnu.org
Cc: qemu-s3...@nongnu.org
---
 backends/tpm/tpm_util.c  |   6 --
 hw/block/xen-block.c |   6 --
 hw/core/qdev-properties-system.c |  70 --
 hw/core/qdev-properties.c| 100 ++-
 hw/s390x/css.c   |   6 --
 hw/s390x/s390-pci-bus.c  |   6 --
 hw/vfio/pci-quirks.c |   6 --
 target/sparc/cpu.c   |   6 --
 8 files changed, 18 insertions(+), 188 deletions(-)

diff --git a/backends/tpm/tpm_util.c b/backends/tpm/tpm_util.c
index dba2f6b04a..0b07cf55ea 100644
--- a/backends/tpm/tpm_util.c
+++ b/backends/tpm/tpm_util.c
@@ -46,16 +46,10 @@ static void get_tpm(Object *obj, Visitor *v, const char 
*name, void *opaque,
 static void set_tpm(Object *obj, Visitor *v, const char *name, void *opaque,
 Error **errp)
 {
-DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
 TPMBackend *s, **be = qdev_get_prop_ptr(obj, prop);
 char *str;
 
-if (dev->realized) {
-qdev_prop_set_after_realize(dev, name, errp);
-return;
-}
-
 if (!visit_type_str(v, name, , errp)) {
 return;
 }
diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c
index 905e4acd97..bd1aef63a7 100644
--- a/hw/block/xen-block.c
+++ b/hw/block/xen-block.c
@@ -395,17 +395,11 @@ static int vbd_name_to_disk(const char *name, const char 
**endp,
 static void xen_block_set_vdev(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
 {
-DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
 XenBlockVdev *vdev = qdev_get_prop_ptr(obj, prop);
 char *str, *p;
 const char *end;
 
-if (dev->realized) {
-qdev_prop_set_after_realize(dev, name, errp);
-return;
-}
-
 if (!visit_type_str(v, name, , errp)) {
 return;
 }
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index 202abd0e4b..0d3e57bba0 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -94,11 +94,6 @@ static void set_drive_helper(Object *obj, Visitor *v, const 
char *name,
 bool blk_created = false;
 int ret;
 
-if (dev->realized) {
-qdev_prop_set_after_realize(dev, name, errp);
-return;
-}
-
 if (!visit_type_str(v, name, , errp)) {
 return;
 }
@@ -230,17 +225,11 @@ static void get_chr(Object *obj, Visitor *v, const char 
*name, void *opaque,
 static void set_chr(Object *obj, Visitor *v, const char *name, void *opaque,
 Error **errp)
 {
-DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
 CharBackend *be = qdev_get_prop_ptr(obj, prop);
 Chardev *s;
 char *str;
 
-if (dev->realized) {
-qdev_prop_set_after_realize(dev, name, errp);
-return;
-}
-
 if (!visit_type_str(v, name, , errp)) {
 return;
 }
@@ -311,18 +300,12 @@ static void get_mac(Object *obj, Visitor *v, const char 
*name, void *opaque,
 static void set_mac(Object *obj, Visitor *v, const char *name, void *opaque,
 Error **errp)
 {
-DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
 MACAddr *mac = qdev_get_prop_ptr(obj, prop);
 int i, pos;
 char *str;
 const char *p;
 
-if (dev->realized) {
-qdev_prop_set_after_realize(dev, name, errp);
-return;
-}
-
 if (!visit_type_str(v, name, , errp)) {
 return;
 }
@@ -390,7 +373,6 @@ static void get_netdev(Object *obj, Visitor *v, const char 
*name,
 static void set_netdev(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
 {
-DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
 NICPeers *peers_ptr = qdev_get_prop_ptr(obj, prop);
 NetClientState **ncs = peers_ptr->ncs;
@@ -398,11 +380,6 @@ static void set_netdev(Object *obj, Visitor *v, const char 
*name,
 int queues, err = 0, i = 0;
 char *str;
 
-if (dev->realized) {

[PATCH v2 09/44] qdev: Make qdev_get_prop_ptr() get Object* arg

2020-11-04 Thread Eduardo Habkost
Make the code more generic and not specific to TYPE_DEVICE.

Reviewed-by: Marc-André Lureau 
Signed-off-by: Eduardo Habkost 
---
Changes v1 -> v2:
- Fix build error with CONFIG_XEN
  I took the liberty of keeping the Reviewed-by line from
  Marc-André as the build fix is a trivial one line change
---
Cc: Stefan Berger 
Cc: Stefano Stabellini 
Cc: Anthony Perard 
Cc: Paul Durrant 
Cc: Kevin Wolf 
Cc: Max Reitz 
Cc: Paolo Bonzini 
Cc: "Daniel P. Berrangé" 
Cc: Eduardo Habkost 
Cc: Cornelia Huck 
Cc: Thomas Huth 
Cc: Richard Henderson 
Cc: David Hildenbrand 
Cc: Halil Pasic 
Cc: Christian Borntraeger 
Cc: Matthew Rosato 
Cc: Alex Williamson 
Cc: qemu-de...@nongnu.org
Cc: xen-devel@lists.xenproject.org
Cc: qemu-bl...@nongnu.org
Cc: qemu-s3...@nongnu.org
---
 include/hw/qdev-properties.h |  2 +-
 backends/tpm/tpm_util.c  |  8 ++--
 hw/block/xen-block.c |  5 +-
 hw/core/qdev-properties-system.c | 57 +-
 hw/core/qdev-properties.c| 82 +---
 hw/s390x/css.c   |  5 +-
 hw/s390x/s390-pci-bus.c  |  4 +-
 hw/vfio/pci-quirks.c |  5 +-
 8 files changed, 68 insertions(+), 100 deletions(-)

diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
index 0ea822e6a7..0b92cfc761 100644
--- a/include/hw/qdev-properties.h
+++ b/include/hw/qdev-properties.h
@@ -302,7 +302,7 @@ void qdev_prop_set_macaddr(DeviceState *dev, const char 
*name,
const uint8_t *value);
 void qdev_prop_set_enum(DeviceState *dev, const char *name, int value);
 
-void *qdev_get_prop_ptr(DeviceState *dev, Property *prop);
+void *qdev_get_prop_ptr(Object *obj, Property *prop);
 
 void qdev_prop_register_global(GlobalProperty *prop);
 const GlobalProperty *qdev_find_global_prop(DeviceState *dev,
diff --git a/backends/tpm/tpm_util.c b/backends/tpm/tpm_util.c
index b58d298c1a..e91c21dd4a 100644
--- a/backends/tpm/tpm_util.c
+++ b/backends/tpm/tpm_util.c
@@ -35,8 +35,7 @@
 static void get_tpm(Object *obj, Visitor *v, const char *name, void *opaque,
 Error **errp)
 {
-DeviceState *dev = DEVICE(obj);
-TPMBackend **be = qdev_get_prop_ptr(dev, opaque);
+TPMBackend **be = qdev_get_prop_ptr(obj, opaque);
 char *p;
 
 p = g_strdup(*be ? (*be)->id : "");
@@ -49,7 +48,7 @@ static void set_tpm(Object *obj, Visitor *v, const char 
*name, void *opaque,
 {
 DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
-TPMBackend *s, **be = qdev_get_prop_ptr(dev, prop);
+TPMBackend *s, **be = qdev_get_prop_ptr(obj, prop);
 char *str;
 
 if (dev->realized) {
@@ -73,9 +72,8 @@ static void set_tpm(Object *obj, Visitor *v, const char 
*name, void *opaque,
 
 static void release_tpm(Object *obj, const char *name, void *opaque)
 {
-DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
-TPMBackend **be = qdev_get_prop_ptr(dev, prop);
+TPMBackend **be = qdev_get_prop_ptr(obj, prop);
 
 if (*be) {
 tpm_backend_reset(*be);
diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c
index 8a7a3f5452..905e4acd97 100644
--- a/hw/block/xen-block.c
+++ b/hw/block/xen-block.c
@@ -335,9 +335,8 @@ static char *disk_to_vbd_name(unsigned int disk)
 static void xen_block_get_vdev(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
 {
-DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
-XenBlockVdev *vdev = qdev_get_prop_ptr(dev, prop);
+XenBlockVdev *vdev = qdev_get_prop_ptr(obj, prop);
 char *str;
 
 switch (vdev->type) {
@@ -398,7 +397,7 @@ static void xen_block_set_vdev(Object *obj, Visitor *v, 
const char *name,
 {
 DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
-XenBlockVdev *vdev = qdev_get_prop_ptr(dev, prop);
+XenBlockVdev *vdev = qdev_get_prop_ptr(obj, prop);
 char *str, *p;
 const char *end;
 
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index d0fb063a49..c8c73c371b 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -59,9 +59,8 @@ static bool check_prop_still_unset(DeviceState *dev, const 
char *name,
 static void get_drive(Object *obj, Visitor *v, const char *name, void *opaque,
   Error **errp)
 {
-DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
-void **ptr = qdev_get_prop_ptr(dev, prop);
+void **ptr = qdev_get_prop_ptr(obj, prop);
 const char *value;
 char *p;
 
@@ -87,7 +86,7 @@ static void set_drive_helper(Object *obj, Visitor *v, const 
char *name,
 {
 DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
-void **ptr = qdev_get_prop_ptr(dev, prop);
+void **ptr = qdev_get_prop_ptr(obj, prop);
 char *str;
 BlockBackend *blk;
 bool blk_created = false;
@@ -185,7 +184,7 @@ static void release_drive(Object *obj, const char *name, 
void *

--enable-xen on gitlab CI? (was Re: [PATCH 09/36] qdev: Make qdev_get_prop_ptr() get Object* arg)

2020-10-30 Thread Eduardo Habkost
On Fri, Oct 30, 2020 at 11:29:25AM +0400, Marc-André Lureau wrote:
> On Fri, Oct 30, 2020 at 2:07 AM Eduardo Habkost  wrote:
> 
> > Make the code more generic and not specific to TYPE_DEVICE.
> >
> > Signed-off-by: Eduardo Habkost 
> >
> 
> Nice cleanup!, but fails to build atm
> 
> ../hw/block/xen-block.c:403:9: error: ‘dev’ undeclared (first use in this
> function); did you mean ‘vdev’?
>   403 | if (dev->realized) {

Thanks for catching it!

What is necessary to make sure we have a CONFIG_XEN=y job in
gitlab CI?  Maybe just including xen-devel in some of the
container images is enough?

-- 
Eduardo




[PATCH 09/36] qdev: Make qdev_get_prop_ptr() get Object* arg

2020-10-29 Thread Eduardo Habkost
Make the code more generic and not specific to TYPE_DEVICE.

Signed-off-by: Eduardo Habkost 
---
Cc: Stefan Berger 
Cc: Stefano Stabellini 
Cc: Anthony Perard 
Cc: Paul Durrant 
Cc: Kevin Wolf 
Cc: Max Reitz 
Cc: Paolo Bonzini 
Cc: "Daniel P. Berrangé" 
Cc: Eduardo Habkost 
Cc: Richard Henderson 
Cc: David Hildenbrand 
Cc: Cornelia Huck 
Cc: Halil Pasic 
Cc: Christian Borntraeger 
Cc: Thomas Huth 
Cc: Matthew Rosato 
Cc: Alex Williamson 
Cc: qemu-de...@nongnu.org
Cc: xen-devel@lists.xenproject.org
Cc: qemu-bl...@nongnu.org
Cc: qemu-s3...@nongnu.org
---
 include/hw/qdev-properties.h |  2 +-
 backends/tpm/tpm_util.c  |  8 ++--
 hw/block/xen-block.c |  6 +--
 hw/core/qdev-properties-system.c | 57 +-
 hw/core/qdev-properties.c| 82 +---
 hw/s390x/css.c   |  5 +-
 hw/s390x/s390-pci-bus.c  |  4 +-
 hw/vfio/pci-quirks.c |  5 +-
 8 files changed, 68 insertions(+), 101 deletions(-)

diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
index 0ea822e6a7..0b92cfc761 100644
--- a/include/hw/qdev-properties.h
+++ b/include/hw/qdev-properties.h
@@ -302,7 +302,7 @@ void qdev_prop_set_macaddr(DeviceState *dev, const char 
*name,
const uint8_t *value);
 void qdev_prop_set_enum(DeviceState *dev, const char *name, int value);
 
-void *qdev_get_prop_ptr(DeviceState *dev, Property *prop);
+void *qdev_get_prop_ptr(Object *obj, Property *prop);
 
 void qdev_prop_register_global(GlobalProperty *prop);
 const GlobalProperty *qdev_find_global_prop(DeviceState *dev,
diff --git a/backends/tpm/tpm_util.c b/backends/tpm/tpm_util.c
index b58d298c1a..e91c21dd4a 100644
--- a/backends/tpm/tpm_util.c
+++ b/backends/tpm/tpm_util.c
@@ -35,8 +35,7 @@
 static void get_tpm(Object *obj, Visitor *v, const char *name, void *opaque,
 Error **errp)
 {
-DeviceState *dev = DEVICE(obj);
-TPMBackend **be = qdev_get_prop_ptr(dev, opaque);
+TPMBackend **be = qdev_get_prop_ptr(obj, opaque);
 char *p;
 
 p = g_strdup(*be ? (*be)->id : "");
@@ -49,7 +48,7 @@ static void set_tpm(Object *obj, Visitor *v, const char 
*name, void *opaque,
 {
 DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
-TPMBackend *s, **be = qdev_get_prop_ptr(dev, prop);
+TPMBackend *s, **be = qdev_get_prop_ptr(obj, prop);
 char *str;
 
 if (dev->realized) {
@@ -73,9 +72,8 @@ static void set_tpm(Object *obj, Visitor *v, const char 
*name, void *opaque,
 
 static void release_tpm(Object *obj, const char *name, void *opaque)
 {
-DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
-TPMBackend **be = qdev_get_prop_ptr(dev, prop);
+TPMBackend **be = qdev_get_prop_ptr(obj, prop);
 
 if (*be) {
 tpm_backend_reset(*be);
diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c
index 8a7a3f5452..1ba9981c08 100644
--- a/hw/block/xen-block.c
+++ b/hw/block/xen-block.c
@@ -335,9 +335,8 @@ static char *disk_to_vbd_name(unsigned int disk)
 static void xen_block_get_vdev(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
 {
-DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
-XenBlockVdev *vdev = qdev_get_prop_ptr(dev, prop);
+XenBlockVdev *vdev = qdev_get_prop_ptr(obj, prop);
 char *str;
 
 switch (vdev->type) {
@@ -396,9 +395,8 @@ static int vbd_name_to_disk(const char *name, const char 
**endp,
 static void xen_block_set_vdev(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
 {
-DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
-XenBlockVdev *vdev = qdev_get_prop_ptr(dev, prop);
+XenBlockVdev *vdev = qdev_get_prop_ptr(obj, prop);
 char *str, *p;
 const char *end;
 
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index d0fb063a49..c8c73c371b 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -59,9 +59,8 @@ static bool check_prop_still_unset(DeviceState *dev, const 
char *name,
 static void get_drive(Object *obj, Visitor *v, const char *name, void *opaque,
   Error **errp)
 {
-DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
-void **ptr = qdev_get_prop_ptr(dev, prop);
+void **ptr = qdev_get_prop_ptr(obj, prop);
 const char *value;
 char *p;
 
@@ -87,7 +86,7 @@ static void set_drive_helper(Object *obj, Visitor *v, const 
char *name,
 {
 DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
-void **ptr = qdev_get_prop_ptr(dev, prop);
+void **ptr = qdev_get_prop_ptr(obj, prop);
 char *str;
 BlockBackend *blk;
 bool blk_created = false;
@@ -185,7 +184,7 @@ static void release_drive(Object *obj, const char *name, 
void *opaque)
 {
 DeviceState *dev = DEVICE(obj);
 Property *prop = op

[PATCH 14/36] qdev: Move dev->realized check to qdev_property_set()

2020-10-29 Thread Eduardo Habkost
Every single qdev property setter function manually checks
dev->realized.  We can just check dev->realized inside
qdev_property_set() instead.

The check is being added as a separate function
(qdev_prop_allow_set()) because it will become a callback later.

Signed-off-by: Eduardo Habkost 
---
Cc: Stefan Berger 
Cc: Stefano Stabellini 
Cc: Anthony Perard 
Cc: Paul Durrant 
Cc: Kevin Wolf 
Cc: Max Reitz 
Cc: Paolo Bonzini 
Cc: "Daniel P. Berrangé" 
Cc: Eduardo Habkost 
Cc: Cornelia Huck 
Cc: Halil Pasic 
Cc: Christian Borntraeger 
Cc: Thomas Huth 
Cc: Richard Henderson 
Cc: David Hildenbrand 
Cc: Matthew Rosato 
Cc: Alex Williamson 
Cc: Mark Cave-Ayland 
Cc: Artyom Tarasenko 
Cc: qemu-de...@nongnu.org
Cc: xen-devel@lists.xenproject.org
Cc: qemu-bl...@nongnu.org
Cc: qemu-s3...@nongnu.org
---
 backends/tpm/tpm_util.c  |   6 --
 hw/block/xen-block.c |   5 --
 hw/core/qdev-properties-system.c |  64 ---
 hw/core/qdev-properties.c| 106 ++-
 hw/s390x/css.c   |   6 --
 hw/s390x/s390-pci-bus.c  |   6 --
 hw/vfio/pci-quirks.c |   6 --
 target/sparc/cpu.c   |   6 --
 8 files changed, 18 insertions(+), 187 deletions(-)

diff --git a/backends/tpm/tpm_util.c b/backends/tpm/tpm_util.c
index e91c21dd4a..042cacfcca 100644
--- a/backends/tpm/tpm_util.c
+++ b/backends/tpm/tpm_util.c
@@ -46,16 +46,10 @@ static void get_tpm(Object *obj, Visitor *v, const char 
*name, void *opaque,
 static void set_tpm(Object *obj, Visitor *v, const char *name, void *opaque,
 Error **errp)
 {
-DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
 TPMBackend *s, **be = qdev_get_prop_ptr(obj, prop);
 char *str;
 
-if (dev->realized) {
-qdev_prop_set_after_realize(dev, name, errp);
-return;
-}
-
 if (!visit_type_str(v, name, , errp)) {
 return;
 }
diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c
index 1ba9981c08..bd1aef63a7 100644
--- a/hw/block/xen-block.c
+++ b/hw/block/xen-block.c
@@ -400,11 +400,6 @@ static void xen_block_set_vdev(Object *obj, Visitor *v, 
const char *name,
 char *str, *p;
 const char *end;
 
-if (dev->realized) {
-qdev_prop_set_after_realize(dev, name, errp);
-return;
-}
-
 if (!visit_type_str(v, name, , errp)) {
 return;
 }
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index fca1b694ca..60a45f5620 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -92,11 +92,6 @@ static void set_drive_helper(Object *obj, Visitor *v, const 
char *name,
 bool blk_created = false;
 int ret;
 
-if (dev->realized) {
-qdev_prop_set_after_realize(dev, name, errp);
-return;
-}
-
 if (!visit_type_str(v, name, , errp)) {
 return;
 }
@@ -228,17 +223,11 @@ static void get_chr(Object *obj, Visitor *v, const char 
*name, void *opaque,
 static void set_chr(Object *obj, Visitor *v, const char *name, void *opaque,
 Error **errp)
 {
-DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
 CharBackend *be = qdev_get_prop_ptr(obj, prop);
 Chardev *s;
 char *str;
 
-if (dev->realized) {
-qdev_prop_set_after_realize(dev, name, errp);
-return;
-}
-
 if (!visit_type_str(v, name, , errp)) {
 return;
 }
@@ -309,18 +298,12 @@ static void get_mac(Object *obj, Visitor *v, const char 
*name, void *opaque,
 static void set_mac(Object *obj, Visitor *v, const char *name, void *opaque,
 Error **errp)
 {
-DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
 MACAddr *mac = qdev_get_prop_ptr(obj, prop);
 int i, pos;
 char *str;
 const char *p;
 
-if (dev->realized) {
-qdev_prop_set_after_realize(dev, name, errp);
-return;
-}
-
 if (!visit_type_str(v, name, , errp)) {
 return;
 }
@@ -388,7 +371,6 @@ static void get_netdev(Object *obj, Visitor *v, const char 
*name,
 static void set_netdev(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
 {
-DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
 NICPeers *peers_ptr = qdev_get_prop_ptr(obj, prop);
 NetClientState **ncs = peers_ptr->ncs;
@@ -396,11 +378,6 @@ static void set_netdev(Object *obj, Visitor *v, const char 
*name,
 int queues, err = 0, i = 0;
 char *str;
 
-if (dev->realized) {
-qdev_prop_set_after_realize(dev, name, errp);
-return;
-}
-
 if (!visit_type_str(v, name, , errp)) {
 return;
 }
@@ -467,18 +444,12 @@ static void get_audiodev(Object *obj, Visitor *v, const 
char* name,
 static void set_audiodev(Object *obj, Visitor *v, const char* name,
  void *opaque, Error **errp)
 {
-DeviceState *dev = DEVI

[PATCH 25/36] qdev: Rename qdev_get_prop_ptr() to object_static_prop_ptr()

2020-10-29 Thread Eduardo Habkost
The function will be moved to common QOM code, as it is not
specific to TYPE_DEVICE anymore.

Signed-off-by: Eduardo Habkost 
---
Cc: Stefan Berger 
Cc: Stefano Stabellini 
Cc: Anthony Perard 
Cc: Paul Durrant 
Cc: Kevin Wolf 
Cc: Max Reitz 
Cc: Paolo Bonzini 
Cc: "Daniel P. Berrangé" 
Cc: Eduardo Habkost 
Cc: Cornelia Huck 
Cc: Halil Pasic 
Cc: Christian Borntraeger 
Cc: Richard Henderson 
Cc: David Hildenbrand 
Cc: Thomas Huth 
Cc: Matthew Rosato 
Cc: Alex Williamson 
Cc: qemu-de...@nongnu.org
Cc: xen-devel@lists.xenproject.org
Cc: qemu-bl...@nongnu.org
Cc: qemu-s3...@nongnu.org
---
 include/hw/qdev-properties.h |  2 +-
 backends/tpm/tpm_util.c  |  6 +--
 hw/block/xen-block.c |  4 +-
 hw/core/qdev-properties-system.c | 46 +++
 hw/core/qdev-properties.c| 64 
 hw/s390x/css.c   |  4 +-
 hw/s390x/s390-pci-bus.c  |  4 +-
 hw/vfio/pci-quirks.c |  4 +-
 8 files changed, 67 insertions(+), 67 deletions(-)

diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
index 0acc92ae2b..4146dac281 100644
--- a/include/hw/qdev-properties.h
+++ b/include/hw/qdev-properties.h
@@ -332,7 +332,7 @@ void qdev_prop_set_macaddr(DeviceState *dev, const char 
*name,
const uint8_t *value);
 void qdev_prop_set_enum(DeviceState *dev, const char *name, int value);
 
-void *qdev_get_prop_ptr(Object *obj, Property *prop);
+void *object_static_prop_ptr(Object *obj, Property *prop);
 
 void qdev_prop_register_global(GlobalProperty *prop);
 const GlobalProperty *qdev_find_global_prop(Object *obj,
diff --git a/backends/tpm/tpm_util.c b/backends/tpm/tpm_util.c
index 042cacfcca..2b5f788861 100644
--- a/backends/tpm/tpm_util.c
+++ b/backends/tpm/tpm_util.c
@@ -35,7 +35,7 @@
 static void get_tpm(Object *obj, Visitor *v, const char *name, void *opaque,
 Error **errp)
 {
-TPMBackend **be = qdev_get_prop_ptr(obj, opaque);
+TPMBackend **be = object_static_prop_ptr(obj, opaque);
 char *p;
 
 p = g_strdup(*be ? (*be)->id : "");
@@ -47,7 +47,7 @@ static void set_tpm(Object *obj, Visitor *v, const char 
*name, void *opaque,
 Error **errp)
 {
 Property *prop = opaque;
-TPMBackend *s, **be = qdev_get_prop_ptr(obj, prop);
+TPMBackend *s, **be = object_static_prop_ptr(obj, prop);
 char *str;
 
 if (!visit_type_str(v, name, , errp)) {
@@ -67,7 +67,7 @@ static void set_tpm(Object *obj, Visitor *v, const char 
*name, void *opaque,
 static void release_tpm(Object *obj, const char *name, void *opaque)
 {
 Property *prop = opaque;
-TPMBackend **be = qdev_get_prop_ptr(obj, prop);
+TPMBackend **be = object_static_prop_ptr(obj, prop);
 
 if (*be) {
 tpm_backend_reset(*be);
diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c
index bd1aef63a7..20985c465a 100644
--- a/hw/block/xen-block.c
+++ b/hw/block/xen-block.c
@@ -336,7 +336,7 @@ static void xen_block_get_vdev(Object *obj, Visitor *v, 
const char *name,
void *opaque, Error **errp)
 {
 Property *prop = opaque;
-XenBlockVdev *vdev = qdev_get_prop_ptr(obj, prop);
+XenBlockVdev *vdev = object_static_prop_ptr(obj, prop);
 char *str;
 
 switch (vdev->type) {
@@ -396,7 +396,7 @@ static void xen_block_set_vdev(Object *obj, Visitor *v, 
const char *name,
void *opaque, Error **errp)
 {
 Property *prop = opaque;
-XenBlockVdev *vdev = qdev_get_prop_ptr(obj, prop);
+XenBlockVdev *vdev = object_static_prop_ptr(obj, prop);
 char *str, *p;
 const char *end;
 
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index d9355053d2..448d77ecab 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -60,7 +60,7 @@ static void get_drive(Object *obj, Visitor *v, const char 
*name, void *opaque,
   Error **errp)
 {
 Property *prop = opaque;
-void **ptr = qdev_get_prop_ptr(obj, prop);
+void **ptr = object_static_prop_ptr(obj, prop);
 const char *value;
 char *p;
 
@@ -86,7 +86,7 @@ static void set_drive_helper(Object *obj, Visitor *v, const 
char *name,
 {
 DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
-void **ptr = qdev_get_prop_ptr(obj, prop);
+void **ptr = object_static_prop_ptr(obj, prop);
 char *str;
 BlockBackend *blk;
 bool blk_created = false;
@@ -179,7 +179,7 @@ static void release_drive(Object *obj, const char *name, 
void *opaque)
 {
 DeviceState *dev = DEVICE(obj);
 Property *prop = opaque;
-BlockBackend **ptr = qdev_get_prop_ptr(obj, prop);
+BlockBackend **ptr = object_static_prop_ptr(obj, prop);
 
 if (*ptr) {
 AioContext *ctx = blk_get_aio_context(*ptr);
@@ -212,7 +212,7 @@ const PropertyInfo qdev_prop_drive_iothread = {
 static void get_chr(Object *obj, Visitor 

Re: [PATCH 0/5] qom: Convert more declarations to OBJECT_DECLARE*

2020-09-18 Thread Eduardo Habkost
On Wed, Sep 16, 2020 at 02:25:14PM -0400, Eduardo Habkost wrote:
> This converts many QOM types to use OBJECT_DECLARE* instead of
> manually using DECLARE*_CHECKER*.
> 
> Before doing that, I'm simplifying the OBJECT_DECLARE* API to
> make it easier to use and more difficult to misuse.  The
> module_obj_name and ParentClassType parameters were removed
> because they are not needed.

I'm queueing this on machine-next.

> 
> Eduardo Habkost (5):
>   scripts/codeconverter: Update to latest version
>   qom: Remove ParentClassType argument from OBJECT_DECLARE_SIMPLE_TYPE
>   qom: Remove module_obj_name parameter from OBJECT_DECLARE* macros
>   [automated] Use OBJECT_DECLARE_TYPE when possible
>   [automated] Use OBJECT_DECLARE_SIMPLE_TYPE when possible
> 
>  hw/9pfs/virtio-9p.h   |   4 +-
>  hw/audio/intel-hda.h  |   6 +-
>  hw/display/ati_int.h  |   4 +-
>  hw/display/qxl.h  |   4 +-
>  hw/display/virtio-vga.h   |   2 +-
>  hw/i386/amd_iommu.h   |   4 +-
>  hw/misc/tmp105.h  |   4 +-
>  hw/net/fsl_etsec/etsec.h  |   3 +-
>  hw/net/tulip.h|   4 +-
>  hw/ppc/e500-ccsr.h|   4 +-
>  hw/ppc/e500.h |   5 +-
>  hw/ppc/mac.h  |   4 +-
>  hw/s390x/ccw-device.h |   4 +-
>  hw/s390x/ipl.h|   4 +-
>  hw/s390x/s390-pci-bus.h   |  16 +-
>  hw/s390x/virtio-ccw.h |  57 +-
>  hw/usb/ccid.h |   5 +-
>  hw/usb/hcd-dwc2.h |   3 +-
>  hw/usb/hcd-ehci.h |  13 +-
>  hw/usb/hcd-ohci.h |   4 +-
>  hw/usb/hcd-xhci.h |   4 +-
>  hw/vfio/pci.h |   4 +-
>  hw/virtio/virtio-pci.h|   5 +-
>  hw/xen/xen_pt.h   |   4 +-
>  include/authz/base.h  |   2 +-
>  include/authz/list.h  |   4 +-
>  include/authz/listfile.h  |   4 +-
>  include/authz/pamacct.h   |   4 +-
>  include/authz/simple.h|   4 +-
>  include/block/throttle-groups.h   |   4 +-
>  include/chardev/char.h|   4 +-
>  include/crypto/secret_common.h|   2 +-
>  include/crypto/secret_keyring.h   |   4 +-
>  include/hw/acpi/generic_event_device.h|   4 +-
>  include/hw/acpi/vmgenid.h |   4 +-
>  include/hw/adc/stm32f2xx_adc.h|   4 +-
>  include/hw/arm/allwinner-a10.h|   4 +-
>  include/hw/arm/allwinner-h3.h |   4 +-
>  include/hw/arm/armsse.h   |   2 +-
>  include/hw/arm/armv7m.h   |   8 +-
>  include/hw/arm/aspeed_soc.h   |   5 +-
>  include/hw/arm/bcm2835_peripherals.h  |   4 +-
>  include/hw/arm/bcm2836.h  |   5 +-
>  include/hw/arm/digic.h|   4 +-
>  include/hw/arm/exynos4210.h   |   4 +-
>  include/hw/arm/fsl-imx25.h|   4 +-
>  include/hw/arm/fsl-imx31.h|   4 +-
>  include/hw/arm/fsl-imx6.h |   4 +-
>  include/hw/arm/fsl-imx6ul.h   |   4 +-
>  include/hw/arm/fsl-imx7.h |   4 +-
>  include/hw/arm/msf2-soc.h |   4 +-
>  include/hw/arm/nrf51_soc.h|   4 +-
>  include/hw/arm/omap.h |   4 +-
>  include/hw/arm/pxa.h  |  15 +-
>  include/hw/arm/smmu-common.h  |   5 +-
>  include/hw/arm/smmuv3.h   |   5 +-
>  include/hw/arm/stm32f205_soc.h|   4 +-
>  include/hw/arm/stm32f405_soc.h|   4 +-
>  include/hw/arm/virt.h |   5 +-
>  include/hw/arm/xlnx-versal.h  |   4 +-
>  include/hw/arm/xlnx-zynqmp.h  |   4 +-
>  include/hw/block/flash.h  |   8 +-
>  include/hw/block/swim.h   |  12 +-
>  include/hw/boards.h   |   3 +-
>  include/hw/char/avr_usart.h   |   4 +-
>  include/hw/char/bcm2835_aux.h |   4 +-
>  include/hw/char/cadence_uart.h|   4 +-
>  include/hw/char/cmsdk-apb-uart.h  |   4 +-
>  include/hw/char/digic-uart.h   

[PATCH 3/5] qom: Remove module_obj_name parameter from OBJECT_DECLARE* macros

2020-09-16 Thread Eduardo Habkost
One of the goals of having less boilerplate on QOM declarations
is to avoid human error.  Requiring an extra argument that is
never used is an opportunity for mistakes.

Remove the unused argument from OBJECT_DECLARE_TYPE and
OBJECT_DECLARE_SIMPLE_TYPE.

Coccinelle patch used to convert all users of the macros:

  @@
  declarer name OBJECT_DECLARE_TYPE;
  identifier InstanceType, ClassType, lowercase, UPPERCASE;
  @@
   OBJECT_DECLARE_TYPE(InstanceType, ClassType,
  -lowercase,
   UPPERCASE);

  @@
  declarer name OBJECT_DECLARE_SIMPLE_TYPE;
  identifier InstanceType, lowercase, UPPERCASE;
  @@
   OBJECT_DECLARE_SIMPLE_TYPE(InstanceType,
  -lowercase,
   UPPERCASE);

Signed-off-by: Eduardo Habkost 
---
Cc: "Marc-André Lureau" 
Cc: Gerd Hoffmann 
Cc: "Michael S. Tsirkin" 
Cc: "Daniel P. Berrangé" 
Cc: Peter Maydell 
Cc: Corey Minyard 
Cc: "Cédric Le Goater" 
Cc: David Gibson 
Cc: Cornelia Huck 
Cc: Thomas Huth 
Cc: Halil Pasic 
Cc: Christian Borntraeger 
Cc: "Philippe Mathieu-Daudé" 
Cc: Alistair Francis 
Cc: David Hildenbrand 
Cc: Laurent Vivier 
Cc: Amit Shah 
Cc: Stefano Stabellini 
Cc: Anthony Perard 
Cc: Paul Durrant 
Cc: Paolo Bonzini 
Cc: Eduardo Habkost 
Cc: Fam Zheng 
Cc: "Gonglei (Arei)" 
Cc: Igor Mammedov 
Cc: Stefan Berger 
Cc: Richard Henderson 
Cc: Michael Rolnik 
Cc: Sarah Harris 
Cc: "Edgar E. Iglesias" 
Cc: Michael Walle 
Cc: Aleksandar Markovic 
Cc: Aurelien Jarno 
Cc: Jiaxun Yang 
Cc: Aleksandar Rikalo 
Cc: Anthony Green 
Cc: Chris Wulff 
Cc: Marek Vasut 
Cc: Stafford Horne 
Cc: Palmer Dabbelt 
Cc: Sagar Karandikar 
Cc: Bastian Koppelmann 
Cc: Yoshinori Sato 
Cc: Mark Cave-Ayland 
Cc: Artyom Tarasenko 
Cc: Guan Xuetao 
Cc: Max Filippov 
Cc: qemu-de...@nongnu.org
Cc: qemu-...@nongnu.org
Cc: qemu-...@nongnu.org
Cc: qemu-s3...@nongnu.org
Cc: qemu-bl...@nongnu.org
Cc: xen-devel@lists.xenproject.org
Cc: qemu-ri...@nongnu.org
---
 hw/audio/intel-hda.h| 2 +-
 hw/display/virtio-vga.h | 2 +-
 include/authz/base.h| 2 +-
 include/authz/list.h| 2 +-
 include/authz/listfile.h| 2 +-
 include/authz/pamacct.h | 2 +-
 include/authz/simple.h  | 2 +-
 include/crypto/secret_common.h  | 2 +-
 include/crypto/secret_keyring.h | 2 +-
 include/hw/arm/armsse.h | 2 +-
 include/hw/hyperv/vmbus.h   | 2 +-
 include/hw/i2c/i2c.h| 2 +-
 include/hw/i2c/smbus_slave.h| 2 +-
 include/hw/ipack/ipack.h| 2 +-
 include/hw/ipmi/ipmi.h  | 2 +-
 include/hw/mem/pc-dimm.h| 2 +-
 include/hw/ppc/pnv.h| 2 +-
 include/hw/ppc/pnv_core.h   | 2 +-
 include/hw/ppc/pnv_homer.h  | 2 +-
 include/hw/ppc/pnv_occ.h| 2 +-
 include/hw/ppc/pnv_psi.h| 2 +-
 include/hw/ppc/pnv_xive.h   | 2 +-
 include/hw/ppc/spapr_cpu_core.h | 2 +-
 include/hw/ppc/spapr_vio.h  | 2 +-
 include/hw/ppc/xics.h   | 2 +-
 include/hw/ppc/xive.h   | 2 +-
 include/hw/s390x/event-facility.h   | 2 +-
 include/hw/s390x/s390_flic.h| 2 +-
 include/hw/s390x/sclp.h | 2 +-
 include/hw/sd/sd.h  | 2 +-
 include/hw/ssi/ssi.h| 2 +-
 include/hw/sysbus.h | 2 +-
 include/hw/virtio/virtio-gpu.h  | 2 +-
 include/hw/virtio/virtio-input.h| 2 +-
 include/hw/virtio/virtio-mem.h  | 2 +-
 include/hw/virtio/virtio-pmem.h | 2 +-
 include/hw/virtio/virtio-serial.h   | 2 +-
 include/hw/xen/xen-bus.h| 2 +-
 include/io/channel.h| 2 +-
 include/io/dns-resolver.h   | 2 +-
 include/io/net-listener.h   | 2 +-
 include/qom/object.h| 6 ++
 include/scsi/pr-manager.h   | 2 +-
 include/sysemu/cryptodev.h  | 2 +-
 include/sysemu/hostmem.h| 2 +-
 include/sysemu/rng.h| 2 +-
 include/sysemu/tpm_backend.h| 2 +-
 include/sysemu/vhost-user-backend.h | 2 +-
 target/alpha/cpu-qom.h  | 2 +-
 target/arm/cpu-qom.h| 2 +-
 target/avr/cpu-qom.h| 2 +-
 target/cris/cpu-qom.h   | 2 +-
 target/hppa/cpu-qom.h   | 2 +-
 target/i386/cpu-qom.h   | 2 +-
 target/lm32/cpu-qom.h   | 2 +-
 target/m68k/cpu-qom.h   | 2 +-
 target/microblaze/cpu-qom.h | 2 +-
 target/mips/cpu-qom.h   | 2 +-
 target/moxie/cpu.h  | 2 +-
 target/nios2/cpu.h  | 2 +-
 target/openrisc/cpu.h   | 2 +-
 target/ppc/cpu-qom.h| 2 +-
 target/riscv/cpu.h  | 2 +-
 target/rx/cpu-qom.h | 2 +-
 target/s390x/cpu-qom.h  | 2 +-
 target/sh4/cpu-qom.h| 2 +-
 target/sparc/cpu-qom.h  | 2 +-
 target/tilegx

[PATCH 4/5] [automated] Use OBJECT_DECLARE_TYPE when possible

2020-09-16 Thread Eduardo Habkost
This converts existing DECLARE_OBJ_CHECKERS usage to
OBJECT_DECLARE_TYPE when possible.

 $ ./scripts/codeconverter/converter.py -i \
   --pattern=AddObjectDeclareType $(git grep -l '' -- '*.[ch]')

Signed-off-by: Eduardo Habkost 
---
Cc: Peter Maydell 
Cc: Andrzej Zaborowski 
Cc: Alistair Francis 
Cc: Kevin Wolf 
Cc: Max Reitz 
Cc: Mark Cave-Ayland 
Cc: David Gibson 
Cc: Richard Henderson 
Cc: David Hildenbrand 
Cc: Cornelia Huck 
Cc: Thomas Huth 
Cc: Halil Pasic 
Cc: Christian Borntraeger 
Cc: "Michael S. Tsirkin" 
Cc: Paolo Bonzini 
Cc: Fam Zheng 
Cc: Dmitry Fleytman 
Cc: Gerd Hoffmann 
Cc: "Marc-André Lureau" 
Cc: "Cédric Le Goater" 
Cc: Andrew Jeffery 
Cc: Joel Stanley 
Cc: Andrew Baumann 
Cc: "Philippe Mathieu-Daudé" 
Cc: Eric Auger 
Cc: Eduardo Habkost 
Cc: Marcel Apfelbaum 
Cc: Laurent Vivier 
Cc: Sergio Lopez 
Cc: John Snow 
Cc: Xiao Guangrong 
Cc: Peter Chubb 
Cc: "Daniel P. Berrangé" 
Cc: Beniamino Galvani 
Cc: "Edgar E. Iglesias" 
Cc: Stefano Stabellini 
Cc: Anthony Perard 
Cc: Paul Durrant 
Cc: Jason Wang 
Cc: qemu-...@nongnu.org
Cc: qemu-de...@nongnu.org
Cc: qemu-bl...@nongnu.org
Cc: qemu-...@nongnu.org
Cc: qemu-s3...@nongnu.org
Cc: xen-devel@lists.xenproject.org
---
 hw/ppc/e500.h | 5 +
 hw/s390x/ccw-device.h | 4 +---
 hw/s390x/virtio-ccw.h | 5 +
 hw/usb/ccid.h | 5 +
 hw/usb/hcd-dwc2.h | 3 +--
 hw/usb/hcd-ehci.h | 5 +
 hw/virtio/virtio-pci.h| 5 +
 include/chardev/char.h| 4 +---
 include/hw/arm/aspeed_soc.h   | 5 +
 include/hw/arm/bcm2836.h  | 5 +
 include/hw/arm/smmu-common.h  | 5 +
 include/hw/arm/smmuv3.h   | 5 +
 include/hw/arm/virt.h | 5 +
 include/hw/boards.h   | 3 +--
 include/hw/display/macfb.h| 5 +
 include/hw/gpio/aspeed_gpio.h | 5 +
 include/hw/i2c/aspeed_i2c.h   | 5 +
 include/hw/i386/ioapic_internal.h | 5 +
 include/hw/i386/microvm.h | 5 +
 include/hw/i386/pc.h  | 4 +---
 include/hw/i386/x86-iommu.h   | 5 +
 include/hw/i386/x86.h | 5 +
 include/hw/ide/internal.h | 4 +---
 include/hw/input/adb.h| 4 +---
 include/hw/isa/i8259_internal.h   | 5 +
 include/hw/isa/isa.h  | 4 +---
 include/hw/mem/nvdimm.h   | 5 +
 include/hw/misc/aspeed_scu.h  | 5 +
 include/hw/misc/aspeed_sdmc.h | 5 +
 include/hw/misc/imx_ccm.h | 5 +
 include/hw/misc/mos6522.h | 5 +
 include/hw/pci-host/pnv_phb4.h| 5 +
 include/hw/pci/pci.h  | 4 +---
 include/hw/pci/pci_host.h | 4 +---
 include/hw/pcmcia.h   | 5 +
 include/hw/ppc/spapr.h| 5 +
 include/hw/qdev-core.h| 4 +---
 include/hw/rtc/allwinner-rtc.h| 5 +
 include/hw/s390x/3270-ccw.h   | 5 +
 include/hw/s390x/s390-virtio-ccw.h| 5 +
 include/hw/s390x/storage-attributes.h | 5 +
 include/hw/s390x/storage-keys.h   | 5 +
 include/hw/s390x/tod.h| 5 +
 include/hw/scsi/scsi.h| 4 +---
 include/hw/sd/allwinner-sdhost.h  | 5 +
 include/hw/sd/sd.h| 5 +
 include/hw/ssi/aspeed_smc.h   | 5 +
 include/hw/ssi/xilinx_spips.h | 4 +---
 include/hw/timer/aspeed_timer.h   | 5 +
 include/hw/timer/i8254.h  | 5 +
 include/hw/usb.h  | 4 +---
 include/hw/virtio/virtio.h| 4 +---
 include/hw/watchdog/wdt_aspeed.h  | 5 +
 include/hw/xen/xen-block.h| 4 +---
 include/hw/xen/xen-bus.h  | 4 +---
 include/net/can_host.h| 5 +
 include/net/filter.h  | 4 +---
 include/ui/console.h  | 4 +---
 hw/arm/mps2-tz.c  | 5 +
 hw/arm/mps2.c | 5 +
 hw/arm/musca.c| 5 +
 hw/arm/spitz.c| 5 +
 hw/arm/vexpress.c | 5 +
 hw/block/m25p80.c | 5 +
 hw/input/adb-kbd.c| 5 +
 hw/input/adb-mouse.c  | 5 +
 hw/misc/tmp421.c  | 5 +
 hw/scsi/scsi-disk.c   | 5 +
 hw/scsi/vmw_pvscsi.c  | 5 +
 69 files changed, 69 insertions(+), 255 deletions(-)

diff --git a/hw/ppc/e500.h b/hw/ppc/e500.h
index 63870751ff..1e5853b032 100644
--- a/hw/ppc/e500.h
+++ b/hw/ppc/e500.h
@@ -14,7 +14,6 @@ struct PPCE500MachineState {
  */
 PlatformBusDevice *pbus_dev;
 };
-typedef struct PPCE500MachineState PPCE500MachineState;
 
 struct PPCE500MachineClass {
 /*< private &

Re: [PATCH v4 00/18] qom: Automated conversion of type checking boilerplate

2020-09-03 Thread Eduardo Habkost
On Mon, Aug 31, 2020 at 05:07:22PM -0400, Eduardo Habkost wrote:
> Latest version of this series can be found at the branch:
> https://github.com/ehabkost/qemu-hacks/tree/work/qom-macros-autoconvert
> 
> This is an extension of the series previously submitted by
> Daniel[1], including a script that will convert existing type
> checker macros automatically.
> 
> [1] https://lore.kernel.org/qemu-devel/20200723181410.3145233-1-berrange@redh=
> at.com/
> 
> Link to series v4:
> https://github.com/ehabkost/qemu-hacks/tree/work/qom-macros-autoconvert-v4

I'm queueing this on machine-next.

-- 
Eduardo




[PATCH 57/63] xen: Rename XENBACKEND_DEVICE to XENBACKEND

2020-09-02 Thread Eduardo Habkost
Make the type checking macro name consistent with the TYPE_*
constant.

Signed-off-by: Eduardo Habkost 
---
Cc: Stefano Stabellini 
Cc: Anthony Perard 
Cc: Paul Durrant 
Cc: xen-devel@lists.xenproject.org
Cc: qemu-de...@nongnu.org
---
 include/hw/xen/xen-legacy-backend.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/hw/xen/xen-legacy-backend.h 
b/include/hw/xen/xen-legacy-backend.h
index ba7a3c59bb..be281e1f38 100644
--- a/include/hw/xen/xen-legacy-backend.h
+++ b/include/hw/xen/xen-legacy-backend.h
@@ -11,7 +11,7 @@
 #define TYPE_XENBACKEND "xen-backend"
 
 typedef struct XenLegacyDevice XenLegacyDevice;
-DECLARE_INSTANCE_CHECKER(XenLegacyDevice, XENBACKEND_DEVICE,
+DECLARE_INSTANCE_CHECKER(XenLegacyDevice, XENBACKEND,
  TYPE_XENBACKEND)
 
 /* variables */
-- 
2.26.2




[PATCH v4 15/18] [automated] Use OBJECT_DECLARE_TYPE where possible

2020-08-31 Thread Eduardo Habkost
Replace DECLARE_OBJ_CHECKERS with OBJECT_DECLARE_TYPE where the
typedefs can be safely removed.

Generated running:

$ ./scripts/codeconverter/converter.py -i \
  --pattern=DeclareObjCheckers $(git grep -l '' -- '*.[ch]')

Reviewed-by: Daniel P. Berrangé 
Signed-off-by: Eduardo Habkost 
---
Changes v3 -> v4: none

Changes v2 -> v3:
* Removed hunks due to rebase conflict: include/hw/ppc/xive.h
  include/hw/arm/armsse.h
* Reviewed-by line from Daniel was kept, as no additional hunks
  are introduced in this version

Changes v1 -> v2:
* Script re-run after typedefs and macros were moved, and now the
  patch also touches:
  - TYPE_ARM_SSE
  - TYPE_SD_BUS

Signed-off-by: Eduardo Habkost 

---
Cc: "Marc-André Lureau" 
Cc: Gerd Hoffmann 
Cc: "Michael S. Tsirkin" 
Cc: "Daniel P. Berrangé" 
Cc: Peter Maydell 
Cc: Corey Minyard 
Cc: "Cédric Le Goater" 
Cc: David Gibson 
Cc: Cornelia Huck 
Cc: Thomas Huth 
Cc: Halil Pasic 
Cc: Christian Borntraeger 
Cc: "Philippe Mathieu-Daudé" 
Cc: Alistair Francis 
Cc: David Hildenbrand 
Cc: Laurent Vivier 
Cc: Amit Shah 
Cc: Stefano Stabellini 
Cc: Anthony Perard 
Cc: Paul Durrant 
Cc: Paolo Bonzini 
Cc: Fam Zheng 
Cc: "Gonglei (Arei)" 
Cc: Eduardo Habkost 
Cc: Igor Mammedov 
Cc: Stefan Berger 
Cc: Richard Henderson 
Cc: Michael Rolnik 
Cc: Sarah Harris 
Cc: "Edgar E. Iglesias" 
Cc: Michael Walle 
Cc: Aleksandar Markovic 
Cc: Aurelien Jarno 
Cc: Jiaxun Yang 
Cc: Aleksandar Rikalo 
Cc: Anthony Green 
Cc: Chris Wulff 
Cc: Marek Vasut 
Cc: Stafford Horne 
Cc: Palmer Dabbelt 
Cc: Sagar Karandikar 
Cc: Bastian Koppelmann 
Cc: Yoshinori Sato 
Cc: Mark Cave-Ayland 
Cc: Artyom Tarasenko 
Cc: Guan Xuetao 
Cc: Max Filippov 
Cc: qemu-de...@nongnu.org
Cc: qemu-...@nongnu.org
Cc: qemu-...@nongnu.org
Cc: qemu-s3...@nongnu.org
Cc: qemu-bl...@nongnu.org
Cc: xen-devel@lists.xenproject.org
Cc: qemu-ri...@nongnu.org

Signed-off-by: Eduardo Habkost 
---
 hw/audio/intel-hda.h| 6 ++
 hw/display/virtio-vga.h | 6 ++
 include/authz/base.h| 6 ++
 include/authz/list.h| 6 ++
 include/authz/listfile.h| 6 ++
 include/authz/pamacct.h | 6 ++
 include/authz/simple.h  | 6 ++
 include/crypto/secret_common.h  | 6 ++
 include/crypto/secret_keyring.h | 6 ++
 include/hw/hyperv/vmbus.h   | 6 ++
 include/hw/i2c/i2c.h| 6 ++
 include/hw/i2c/smbus_slave.h| 6 ++
 include/hw/ipack/ipack.h| 6 ++
 include/hw/ipmi/ipmi.h  | 6 ++
 include/hw/mem/pc-dimm.h| 6 ++
 include/hw/ppc/pnv.h| 6 ++
 include/hw/ppc/pnv_core.h   | 6 ++
 include/hw/ppc/pnv_homer.h  | 6 ++
 include/hw/ppc/pnv_occ.h| 6 ++
 include/hw/ppc/pnv_psi.h| 6 ++
 include/hw/ppc/pnv_xive.h   | 6 ++
 include/hw/ppc/spapr_cpu_core.h | 6 ++
 include/hw/ppc/spapr_drc.h  | 6 ++
 include/hw/ppc/spapr_vio.h  | 6 ++
 include/hw/ppc/spapr_xive.h | 6 ++
 include/hw/ppc/xics.h   | 6 ++
 include/hw/s390x/event-facility.h   | 6 ++
 include/hw/s390x/s390_flic.h| 6 ++
 include/hw/s390x/sclp.h | 6 ++
 include/hw/sd/sd.h  | 6 ++
 include/hw/ssi/ssi.h| 6 ++
 include/hw/sysbus.h | 6 ++
 include/hw/virtio/virtio-gpu.h  | 6 ++
 include/hw/virtio/virtio-input.h| 6 ++
 include/hw/virtio/virtio-mem.h  | 6 ++
 include/hw/virtio/virtio-pmem.h | 6 ++
 include/hw/virtio/virtio-serial.h   | 6 ++
 include/hw/xen/xen-bus.h| 6 ++
 include/io/channel.h| 6 ++
 include/io/dns-resolver.h   | 6 ++
 include/io/net-listener.h   | 6 ++
 include/scsi/pr-manager.h   | 6 ++
 include/sysemu/cryptodev.h  | 6 ++
 include/sysemu/hostmem.h| 6 ++
 include/sysemu/rng.h| 6 ++
 include/sysemu/tpm_backend.h| 6 ++
 include/sysemu/vhost-user-backend.h | 6 ++
 target/alpha/cpu-qom.h  | 6 ++
 target/arm/cpu-qom.h| 6 ++
 target/avr/cpu-qom.h| 6 ++
 target/cris/cpu-qom.h   | 6 ++
 target/hppa/cpu-qom.h   | 6 ++
 target/i386/cpu-qom.h   | 6 ++
 target/lm32/cpu-qom.h   | 6 ++
 target/m68k/cpu-qom.h   | 6 ++
 target/microblaze/cpu-qom.h | 6 ++
 target/mips/cpu-qom.h   | 6 ++
 target/moxie/cpu.h  | 6 ++
 target/nios2/cpu.h  | 6 ++
 target/openrisc/cpu.h   | 6 ++
 target/ppc/cpu-qom.h| 6 ++
 target/riscv/cpu.h  | 6 ++
 target/s390x/cpu-qom.h  | 6

Re: [PATCH v3 00/74] qom: Automated conversion of type checking boilerplate

2020-08-27 Thread Eduardo Habkost
On Tue, Aug 25, 2020 at 03:19:56PM -0400, Eduardo Habkost wrote:
> git tree for this series:
> https://github.com/ehabkost/qemu-hacks/tree/work/qom-macros-autoconvert
> 
> This is an extension of the series previously submitted by
> Daniel[1], including a script that will convert existing type
> checker macros automatically.
> 
> [1] https://lore.kernel.org/qemu-devel/20200723181410.3145233-1-berrange@redh=
> at.com/

I'm queueing the following patches on machine-next:

[PATCH v3 01/74] e1000: Rename QOM class cast macros
[PATCH v3 02/74] megasas: Rename QOM class cast macros
[PATCH v3 03/74] vmw_pvscsi: Rename QOM class cast macros
[PATCH v3 04/74] pl110: Rename pl110_version enum values
[PATCH v3 05/74] allwinner-h3: Rename memmap enum constants
[PATCH v3 06/74] aspeed_soc: Rename memmap/irqmap enum constants
[PATCH v3 07/74] opentitan: Rename memmap enum constants
[PATCH v3 10/74] aspeed_timer: Fix ASPEED_TIMER macro definition
[PATCH v3 11/74] versatile: Fix typo in PCI_VPB_HOST definition
[PATCH v3 12/74] virtio-ccw: Fix definition of VIRTIO_CCW_BUS_GET_CLASS
[PATCH v3 13/74] hvf: Add missing include
[PATCH v3 14/74] hcd-dwc2: Rename USB_*CLASS macros for consistency
[PATCH v3 15/74] tulip: Move TulipState typedef to header
[PATCH v3 16/74] throttle-groups: Move ThrottleGroup typedef to header
[PATCH v3 17/74] pci: Move PCIBusClass typedef to pci.h
[PATCH v3 18/74] i8254: Move PITCommonState/PITCommonClass typedefs to i8254.h
[PATCH v3 19/74] hvf: Move HVFState typedef to hvf.h
[PATCH v3 20/74] mcf_fec: Move mcf_fec_state typedef to header
[PATCH v3 21/74] s390_flic: Move KVMS390FLICState typedef to header
[PATCH v3 22/74] can_emu: Delete macros for non-existing typedef
[PATCH v3 23/74] nubus: Delete unused NUBUS_BRIDGE macro
[PATCH v3 24/74] platform-bus: Delete macros for non-existing typedef
[PATCH v3 25/74] armsse: Rename QOM macros to avoid conflicts
[PATCH v3 26/74] xen-legacy-backend: Add missing typedef XenLegacyDevice
[PATCH v3 27/74] spapr: Move typedef SpaprMachineState to spapr.h
[PATCH v3 28/74] s390x: Move typedef SCLPEventFacility to event-facility.h
[PATCH v3 29/74] vhost-user-gpu: Move QOM macro to header
[PATCH v3 30/74] ahci: Move QOM macros to header
[PATCH v3 31/74] i8257: Move QOM macro to header
[PATCH v3 32/74] ahci: Move QOM macro to header
[PATCH v3 33/74] pckbd: Move QOM macro to header
[PATCH v3 34/74] vmbus: Move QOM macros to vmbus.h
[PATCH v3 35/74] virtio-serial-bus: Move QOM macros to header
[PATCH v3 36/74] piix: Move QOM macros to header
[PATCH v3 37/74] auxbus: Move QOM macros to header
[PATCH v3 38/74] rocker: Move QOM macros to header
[PATCH v3 39/74] pxa2xx: Move QOM macros to header
[PATCH v3 40/74] mptsas: Move QOM macros to header
[PATCH v3 41/74] kvm: Move QOM macros to kvm.h
[PATCH v3 42/74] vfio/pci: Move QOM macros to header
[PATCH v3 43/74] nubus: Rename class type checking macros
[PATCH v3 48/74] s390-virtio-ccw: Rename S390_MACHINE_CLASS macro
[PATCH v3 49/74] swim: Rename struct SWIM to Swim
[PATCH v3 50/74] migration: Rename class type checking macros

-- 
Eduardo




Re: [PATCH v3 72/74] [automated] Remove redundant instance_size/class_size fields

2020-08-26 Thread Eduardo Habkost
On Tue, Aug 25, 2020 at 03:21:08PM -0400, Eduardo Habkost wrote:
> This will remove instance_size/class_size fields from TypeInfo
> variables when the value is exactly the same as the one in the
> parent class.
> 
> Generated by:
> 
>  $ ./scripts/codeconverter/converter.py -i \
>--pattern=RedundantTypeSizes $(git grep -l TypeInfo -- '*.[ch]')
> 
> Signed-off-by: Eduardo Habkost 

This patch triggers an assert due to code outside QOM core using
TypeInfo.instance_size directly.  Please ignore it by now.

Thanks to Roman Bolshakov for reporting the problem.

-- 
Eduardo




[PATCH v3 72/74] [automated] Remove redundant instance_size/class_size fields

2020-08-25 Thread Eduardo Habkost
This will remove instance_size/class_size fields from TypeInfo
variables when the value is exactly the same as the one in the
parent class.

Generated by:

 $ ./scripts/codeconverter/converter.py -i \
   --pattern=RedundantTypeSizes $(git grep -l TypeInfo -- '*.[ch]')

Signed-off-by: Eduardo Habkost 
---
Changes series v2 -> v3: this is a new patch in series v3

---
Cc: "Marc-André Lureau" 
Cc: Paolo Bonzini 
Cc: "Daniel P. Berrangé" 
Cc: "Cédric Le Goater" 
Cc: Peter Maydell 
Cc: Andrew Jeffery 
Cc: Joel Stanley 
Cc: Jan Kiszka 
Cc: Eduardo Habkost 
Cc: "Michael S. Tsirkin" 
Cc: Marcel Apfelbaum 
Cc: Richard Henderson 
Cc: Stefano Stabellini 
Cc: Anthony Perard 
Cc: Paul Durrant 
Cc: Gerd Hoffmann 
Cc: Aleksandar Markovic 
Cc: "Philippe Mathieu-Daudé" 
Cc: Aurelien Jarno 
Cc: Jiaxun Yang 
Cc: Aleksandar Rikalo 
Cc: Laurent Vivier 
Cc: Mark Cave-Ayland 
Cc: David Gibson 
Cc: Cornelia Huck 
Cc: Thomas Huth 
Cc: David Hildenbrand 
Cc: Halil Pasic 
Cc: Christian Borntraeger 
Cc: Fam Zheng 
Cc: Beniamino Galvani 
Cc: Andrew Baumann 
Cc: Michael Walle 
Cc: Andrzej Zaborowski 
Cc: Yoshinori Sato 
Cc: Alex Williamson 
Cc: qemu-de...@nongnu.org
Cc: qemu-...@nongnu.org
Cc: xen-devel@lists.xenproject.org
Cc: qemu-...@nongnu.org
Cc: qemu-s3...@nongnu.org
Cc: qemu-bl...@nongnu.org

---
Cc: "Marc-André Lureau" 
Cc: Paolo Bonzini 
Cc: "Daniel P. Berrangé" 
Cc: "Cédric Le Goater" 
Cc: Peter Maydell 
Cc: Andrew Jeffery 
Cc: Joel Stanley 
Cc: Jan Kiszka 
Cc: Eduardo Habkost 
Cc: "Michael S. Tsirkin" 
Cc: Marcel Apfelbaum 
Cc: Richard Henderson 
Cc: Stefano Stabellini 
Cc: Anthony Perard 
Cc: Paul Durrant 
Cc: Gerd Hoffmann 
Cc: Aleksandar Markovic 
Cc: "Philippe Mathieu-Daudé" 
Cc: Aurelien Jarno 
Cc: Jiaxun Yang 
Cc: Aleksandar Rikalo 
Cc: Laurent Vivier 
Cc: Mark Cave-Ayland 
Cc: David Gibson 
Cc: Cornelia Huck 
Cc: Halil Pasic 
Cc: Christian Borntraeger 
Cc: Thomas Huth 
Cc: David Hildenbrand 
Cc: Fam Zheng 
Cc: Beniamino Galvani 
Cc: Andrew Baumann 
Cc: Michael Walle 
Cc: Andrzej Zaborowski 
Cc: Yoshinori Sato 
Cc: Alex Williamson 
Cc: qemu-de...@nongnu.org
Cc: qemu-...@nongnu.org
Cc: xen-devel@lists.xenproject.org
Cc: qemu-...@nongnu.org
Cc: qemu-s3...@nongnu.org
Cc: qemu-bl...@nongnu.org
---
 chardev/char-null.c| 1 -
 crypto/tls-cipher-suites.c | 2 --
 hw/arm/aspeed_ast2600.c| 2 --
 hw/arm/aspeed_soc.c| 2 --
 hw/arm/musicpal.c  | 1 -
 hw/core/sysbus.c   | 1 -
 hw/i386/kvm/apic.c | 1 -
 hw/i386/pc_piix.c  | 1 -
 hw/i386/xen/xen_apic.c | 1 -
 hw/input/virtio-input-hid.c| 3 ---
 hw/intc/apic.c | 1 -
 hw/intc/ioapic.c   | 1 -
 hw/isa/isa-bus.c   | 1 -
 hw/mips/gt64xxx_pci.c  | 1 -
 hw/misc/aspeed_scu.c   | 3 ---
 hw/misc/ivshmem.c  | 2 --
 hw/nubus/nubus-bridge.c| 1 -
 hw/pci-bridge/dec.c| 2 --
 hw/pci-bridge/pci_bridge_dev.c | 1 -
 hw/pci-host/grackle.c  | 1 -
 hw/pci-host/uninorth.c | 4 
 hw/pci-host/versatile.c| 1 -
 hw/pci-host/xen_igd_pt.c   | 1 -
 hw/ppc/pnv_homer.c | 2 --
 hw/ppc/pnv_occ.c   | 2 --
 hw/ppc/ppc4xx_pci.c| 1 -
 hw/s390x/s390-skeys-kvm.c  | 2 --
 hw/s390x/sclpcpu.c | 2 --
 hw/s390x/sclpquiesce.c | 2 --
 hw/s390x/tod-kvm.c | 2 --
 hw/s390x/tod-qemu.c| 2 --
 hw/s390x/virtio-ccw-input.c| 3 ---
 hw/scsi/scsi-generic.c | 1 -
 hw/sd/allwinner-sdhost.c   | 1 -
 hw/sd/bcm2835_sdhost.c | 1 -
 hw/sd/milkymist-memcard.c  | 1 -
 hw/sd/pl181.c  | 1 -
 hw/sd/pxa2xx_mmci.c| 1 -
 hw/sd/sdhci.c  | 1 -
 hw/sh4/sh_pci.c| 1 -
 hw/timer/pxa2xx_timer.c| 2 --
 hw/vfio/pci.c  | 1 -
 hw/virtio/virtio-mmio.c| 1 -
 hw/watchdog/wdt_aspeed.c   | 3 ---
 hw/xen/xen-legacy-backend.c| 1 -
 45 files changed, 69 deletions(-)

diff --git a/chardev/char-null.c b/chardev/char-null.c
index ce43ccdda6..2736b2ff2b 100644
--- a/chardev/char-null.c
+++ b/chardev/char-null.c
@@ -44,7 +44,6 @@ static void char_null_class_init(ObjectClass *oc, void *data)
 static const TypeInfo char_null_type_info = {
 .name = TYPE_CHARDEV_NULL,
 .parent = TYPE_CHARDEV,
-.instance_size = sizeof(Chardev),
 .class_init = char_null_class_init,
 };
 TYPE_INFO(char_null_type_info)
diff --git a/crypto/tls-cipher-suites.c b/crypto/tls-cipher-suites.c
index e92a380a24..0c9713d301 100644
--- a/crypto/tls-cipher-suites.c
+++ b/crypto/tls-cipher-suites.c
@@ -108,8 +108,6 @@ static void 
qcrypto_tls_cipher_suites_class_init(ObjectClass *oc, void *data)
 static const TypeInfo qcrypto_tls_cipher_suites_info = {
 .parent = TYPE_QCRYPTO_TLS_CREDS,
 .name = TYPE_QCRYPTO_TLS_CIPHER_SUITES,
-.ins

[PATCH v3 69/74] [automated] Use OBJECT_DECLARE_TYPE where possible

2020-08-25 Thread Eduardo Habkost
Replace DECLARE_OBJ_CHECKERS with OBJECT_DECLARE_TYPE where the
typedefs can be safely removed.

Generated running:

$ ./scripts/codeconverter/converter.py -i \
  --pattern=DeclareObjCheckers $(git grep -l '' -- '*.[ch]')

Reviewed-by: Daniel P. Berrangé 
Signed-off-by: Eduardo Habkost 
---
Changes v2 -> v3:
* Removed hunk due to rebase conflict: include/hw/ppc/xive.h
* Reviewed-by line from Daniel was kept, as no additional hunks
  are introduced in this version

Changes v1 -> v2:
* Script re-run after typedefs and macros were moved, and now the
  patch also touches:
  - TYPE_ARM_SSE
  - TYPE_SD_BUS

Signed-off-by: Eduardo Habkost 

---
Cc: "Marc-André Lureau" 
Cc: Gerd Hoffmann 
Cc: "Michael S. Tsirkin" 
Cc: "Daniel P. Berrangé" 
Cc: Peter Maydell 
Cc: Corey Minyard 
Cc: "Cédric Le Goater" 
Cc: David Gibson 
Cc: Cornelia Huck 
Cc: Thomas Huth 
Cc: Halil Pasic 
Cc: Christian Borntraeger 
Cc: "Philippe Mathieu-Daudé" 
Cc: Alistair Francis 
Cc: David Hildenbrand 
Cc: Laurent Vivier 
Cc: Amit Shah 
Cc: Stefano Stabellini 
Cc: Anthony Perard 
Cc: Paul Durrant 
Cc: Paolo Bonzini 
Cc: Fam Zheng 
Cc: "Gonglei (Arei)" 
Cc: Eduardo Habkost 
Cc: Igor Mammedov 
Cc: Stefan Berger 
Cc: Richard Henderson 
Cc: Michael Rolnik 
Cc: Sarah Harris 
Cc: "Edgar E. Iglesias" 
Cc: Michael Walle 
Cc: Aleksandar Markovic 
Cc: Aurelien Jarno 
Cc: Jiaxun Yang 
Cc: Aleksandar Rikalo 
Cc: Anthony Green 
Cc: Chris Wulff 
Cc: Marek Vasut 
Cc: Stafford Horne 
Cc: Palmer Dabbelt 
Cc: Sagar Karandikar 
Cc: Bastian Koppelmann 
Cc: Yoshinori Sato 
Cc: Mark Cave-Ayland 
Cc: Artyom Tarasenko 
Cc: Guan Xuetao 
Cc: Max Filippov 
Cc: qemu-de...@nongnu.org
Cc: qemu-...@nongnu.org
Cc: qemu-...@nongnu.org
Cc: qemu-s3...@nongnu.org
Cc: qemu-bl...@nongnu.org
Cc: xen-devel@lists.xenproject.org
Cc: qemu-ri...@nongnu.org
---
 hw/audio/intel-hda.h| 6 ++
 hw/display/virtio-vga.h | 6 ++
 include/authz/base.h| 6 ++
 include/authz/list.h| 6 ++
 include/authz/listfile.h| 6 ++
 include/authz/pamacct.h | 6 ++
 include/authz/simple.h  | 6 ++
 include/crypto/secret_common.h  | 6 ++
 include/crypto/secret_keyring.h | 6 ++
 include/hw/arm/armsse.h | 6 ++
 include/hw/hyperv/vmbus.h   | 6 ++
 include/hw/i2c/i2c.h| 6 ++
 include/hw/i2c/smbus_slave.h| 6 ++
 include/hw/ipack/ipack.h| 6 ++
 include/hw/ipmi/ipmi.h  | 6 ++
 include/hw/mem/pc-dimm.h| 6 ++
 include/hw/ppc/pnv.h| 6 ++
 include/hw/ppc/pnv_core.h   | 6 ++
 include/hw/ppc/pnv_homer.h  | 6 ++
 include/hw/ppc/pnv_occ.h| 6 ++
 include/hw/ppc/pnv_psi.h| 6 ++
 include/hw/ppc/pnv_xive.h   | 6 ++
 include/hw/ppc/spapr_cpu_core.h | 6 ++
 include/hw/ppc/spapr_drc.h  | 6 ++
 include/hw/ppc/spapr_vio.h  | 6 ++
 include/hw/ppc/spapr_xive.h | 6 ++
 include/hw/ppc/xics.h   | 6 ++
 include/hw/s390x/event-facility.h   | 6 ++
 include/hw/s390x/s390_flic.h| 6 ++
 include/hw/s390x/sclp.h | 6 ++
 include/hw/sd/sd.h  | 6 ++
 include/hw/ssi/ssi.h| 6 ++
 include/hw/sysbus.h | 6 ++
 include/hw/virtio/virtio-gpu.h  | 6 ++
 include/hw/virtio/virtio-input.h| 6 ++
 include/hw/virtio/virtio-mem.h  | 6 ++
 include/hw/virtio/virtio-pmem.h | 6 ++
 include/hw/virtio/virtio-serial.h   | 6 ++
 include/hw/xen/xen-bus.h| 6 ++
 include/io/channel.h| 6 ++
 include/io/dns-resolver.h   | 6 ++
 include/io/net-listener.h   | 6 ++
 include/scsi/pr-manager.h   | 6 ++
 include/sysemu/cryptodev.h  | 6 ++
 include/sysemu/hostmem.h| 6 ++
 include/sysemu/rng.h| 6 ++
 include/sysemu/tpm_backend.h| 6 ++
 include/sysemu/vhost-user-backend.h | 6 ++
 target/alpha/cpu-qom.h  | 6 ++
 target/arm/cpu-qom.h| 6 ++
 target/avr/cpu-qom.h| 6 ++
 target/cris/cpu-qom.h   | 6 ++
 target/hppa/cpu-qom.h   | 6 ++
 target/i386/cpu-qom.h   | 6 ++
 target/lm32/cpu-qom.h   | 6 ++
 target/m68k/cpu-qom.h   | 6 ++
 target/microblaze/cpu-qom.h | 6 ++
 target/mips/cpu-qom.h   | 6 ++
 target/moxie/cpu.h  | 6 ++
 target/nios2/cpu.h  | 6 ++
 target/openrisc/cpu.h   | 6 ++
 target/ppc/cpu-qom.h| 6 ++
 target/riscv/cpu.h  | 6 ++
 target/s390x/cpu-qom.h  | 6 ++
 target/sh4/cpu-qom.h| 6

[PATCH v3 26/74] xen-legacy-backend: Add missing typedef XenLegacyDevice

2020-08-25 Thread Eduardo Habkost
The typedef was used in the XENBACKEND_DEVICE macro, but it was
never defined.  Define the typedef close to the type checking
macro.

Acked-by: Anthony PERARD 
Reviewed-by: Daniel P. Berrangé 
Signed-off-by: Eduardo Habkost 
---
Changes v2 -> v3: none

Changes series v1 -> v2: new patch in series v2

---
Cc: Stefano Stabellini 
Cc: Anthony Perard 
Cc: Paul Durrant 
Cc: xen-devel@lists.xenproject.org
Cc: qemu-de...@nongnu.org
---
 include/hw/xen/xen-legacy-backend.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/hw/xen/xen-legacy-backend.h 
b/include/hw/xen/xen-legacy-backend.h
index 5e6c56c4d6..704bc7852b 100644
--- a/include/hw/xen/xen-legacy-backend.h
+++ b/include/hw/xen/xen-legacy-backend.h
@@ -9,6 +9,7 @@
 #define TYPE_XENSYSBUS "xen-sysbus"
 #define TYPE_XENBACKEND "xen-backend"
 
+typedef struct XenLegacyDevice XenLegacyDevice;
 #define XENBACKEND_DEVICE(obj) \
 OBJECT_CHECK(XenLegacyDevice, (obj), TYPE_XENBACKEND)
 
-- 
2.26.2




[PATCH v2 26/58] xen-legacy-backend: Add missing typedef XenLegacyDevice

2020-08-19 Thread Eduardo Habkost
The typedef was used in the XENBACKEND_DEVICE macro, but it was
never defined.  Define the typedef close to the type checking
macro.

Signed-off-by: Eduardo Habkost 
---
Changes series v1 -> v2: new patch in series v2

---
Cc: Stefano Stabellini 
Cc: Anthony Perard 
Cc: Paul Durrant 
Cc: xen-devel@lists.xenproject.org
Cc: qemu-de...@nongnu.org
---
 include/hw/xen/xen-legacy-backend.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/hw/xen/xen-legacy-backend.h 
b/include/hw/xen/xen-legacy-backend.h
index 5e6c56c4d6..704bc7852b 100644
--- a/include/hw/xen/xen-legacy-backend.h
+++ b/include/hw/xen/xen-legacy-backend.h
@@ -9,6 +9,7 @@
 #define TYPE_XENSYSBUS "xen-sysbus"
 #define TYPE_XENBACKEND "xen-backend"
 
+typedef struct XenLegacyDevice XenLegacyDevice;
 #define XENBACKEND_DEVICE(obj) \
 OBJECT_CHECK(XenLegacyDevice, (obj), TYPE_XENBACKEND)
 
-- 
2.26.2




Re: [Xen-devel] [Qemu-devel] [PATCH 3/3] machine: Use shorter format for GlobalProperty arrays

2019-01-09 Thread Eduardo Habkost
On Tue, Jan 08, 2019 at 11:20:12AM +0100, Cornelia Huck wrote:
> On Tue, 8 Jan 2019 07:45:43 +0100
> Gerd Hoffmann  wrote:
> 
> >   Hi,
> > 
> > > +{ "migration", "decompress-error-check", "off" },
> > > +{ "hda-audio", "use-timer", "false" },
> > > +{ "cirrus-vga", "global-vmstate", "true" },
> > > +{ "VGA", "global-vmstate", "true" },
> > > +{ "vmware-svga", "global-vmstate", "true" },
> > > +{ "qxl-vga", "global-vmstate", "true" },  
> > 
> > I'd like to have the fields aligned.  Especially in cases like this one
> > where multiple devices get the same value assigned it makes things more
> > readable:
> > 
> > { "migration",   "decompress-error-check", "off"   },
> > { "hda-audio",   "use-timer",  "false" },
> > { "cirrus-vga",  "global-vmstate", "true"  },
> > { "VGA", "global-vmstate", "true"  },
> > { "vmware-svga", "global-vmstate", "true"  },
> > { "qxl-vga", "global-vmstate", "true"  },
> > 
> > thanks,
> >   Gerd
> > 
> 
> I'm a bit on the fence here. It does make things more readable (at
> least in your example), but I find editing aligned tables a bit
> annoying. OTOH, that won't happen often, anyway.

I'm unsure, too.  Also, not merging this series is increasing the
likelihood of conflicts with other patches.  I'm queueing this
version, and we can discuss alignment alternatives later.

(I'm less worried about conflicts caused by future alignment
patches because alignment conflicts are easier to sort out than
redoing the .driver/.property/.value conversion).

-- 
Eduardo

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

[Xen-devel] [PATCH 3/3] machine: Use shorter format for GlobalProperty arrays

2019-01-07 Thread Eduardo Habkost
Instead of verbose arrays with 4 lines for each entry, make each
entry take only one line.  This makes long arrays that couldn't
fit in the screen become short and readable.

Signed-off-by: Eduardo Habkost 
---
 include/hw/i386/pc.h   |  18 +-
 hw/core/machine.c  | 338 -
 hw/i386/pc.c   | 720 +++--
 hw/i386/pc_piix.c  | 192 ++
 hw/ppc/spapr.c |  72 +---
 hw/s390x/s390-virtio-ccw.c |  75 +---
 hw/xen/xen-common.c|  18 +-
 7 files changed, 265 insertions(+), 1168 deletions(-)

diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 84720bede9..0abbe45637 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -354,21 +354,9 @@ extern const size_t pc_compat_1_4_len;
  * depending on QEMU versions up to QEMU 2.4.
  */
 #define PC_CPU_MODEL_IDS(v) \
-{\
-.driver   = "qemu32-" TYPE_X86_CPU,\
-.property = "model-id",\
-.value= "QEMU Virtual CPU version " v,\
-},\
-{\
-.driver   = "qemu64-" TYPE_X86_CPU,\
-.property = "model-id",\
-.value= "QEMU Virtual CPU version " v,\
-},\
-{\
-.driver   = "athlon-" TYPE_X86_CPU,\
-.property = "model-id",\
-.value= "QEMU Virtual CPU version " v,\
-},
+{ "qemu32-" TYPE_X86_CPU, "model-id", "QEMU Virtual CPU version " v, },\
+{ "qemu64-" TYPE_X86_CPU, "model-id", "QEMU Virtual CPU version " v, },\
+{ "athlon-" TYPE_X86_CPU, "model-id", "QEMU Virtual CPU version " v, },
 
 #define DEFINE_PC_MACHINE(suffix, namestr, initfn, optsfn) \
 static void pc_machine_##suffix##_class_init(ObjectClass *oc, void *data) \
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 4b4d6c23de..5530b71981 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -24,23 +24,10 @@
 #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",
-},
+{ "pcie-root-port", "x-speed", "2_5" },
+{ "pcie-root-port", "x-width", "1" },
+{ "memory-backend-file", "x-use-canonical-path-for-ramblock-id", "true" },
+{ "memory-backend-memfd", "x-use-canonical-path-for-ramblock-id", "true" },
 };
 const size_t hw_compat_3_1_len = G_N_ELEMENTS(hw_compat_3_1);
 
@@ -48,269 +35,96 @@ 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",
-},
+{ "migration", "decompress-error-check", "off" },
+{ "hda-audio", "use-timer", "false" },
+{ "cirrus-vga", "global-vmstate", "true" },
+{ "VGA", "global-vmstate", "true" },
+{ "vmware-svga", "global-vmstate", "true" },
+{ "qxl-vga", "global-vmstate", "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"

[Xen-devel] [PATCH 2/3] machine: Eliminate unnecessary stringify() usage

2019-01-07 Thread Eduardo Habkost
stringify() is useful when we need to use macros in compat_props
(like when we set virtio-baloon-pci.class=PCI_CLASS_MEMORY_RAM at
pc_i440fx_1_0_machine_options()), but it is pointless when we are
already providing a number literal.

Replace stringify() with string literals when appropriate.

Signed-off-by: Eduardo Habkost 
---
 hw/core/machine.c |  8 ++--
 hw/i386/pc.c  | 94 +++
 hw/i386/pc_piix.c | 30 +++
 hw/ppc/spapr.c|  2 +-
 4 files changed, 67 insertions(+), 67 deletions(-)

diff --git a/hw/core/machine.c b/hw/core/machine.c
index f8563efb86..4b4d6c23de 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -135,11 +135,11 @@ GlobalProperty hw_compat_2_8[] = {
 {
 .driver   = "fw_cfg_mem",
 .property = "x-file-slots",
-.value= stringify(0x10),
+.value= "0x10",
 },{
 .driver   = "fw_cfg_io",
 .property = "x-file-slots",
-.value= stringify(0x10),
+.value= "0x10",
 },{
 .driver   = "pflash_cfi01",
 .property = "old-multiple-chip-handling",
@@ -337,11 +337,11 @@ GlobalProperty hw_compat_2_1[] = {
 },{
 .driver   = "usb-mouse",
 .property = "usb_version",
-.value= stringify(1),
+.value= "1",
 },{
 .driver   = "usb-kbd",
 .property = "usb_version",
-.value= stringify(1),
+.value= "1",
 },{
 .driver   = "virtio-pci",
 .property = "virtio-pci-bus-master-bug-migration",
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 4952feb476..ff14b6d4df 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -148,11 +148,11 @@ GlobalProperty pc_compat_2_12[] = {
 },{
 .driver   = "EPYC-" TYPE_X86_CPU,
 .property = "xlevel",
-.value= stringify(0x800a),
+.value= "0x800a",
 },{
 .driver   = "EPYC-IBPB-" TYPE_X86_CPU,
 .property = "xlevel",
-.value= stringify(0x800a),
+.value= "0x800a",
 },
 };
 const size_t pc_compat_2_12_len = G_N_ELEMENTS(pc_compat_2_12);
@@ -191,7 +191,7 @@ GlobalProperty pc_compat_2_9[] = {
 {
 .driver   = "mch",
 .property = "extended-tseg-mbytes",
-.value= stringify(0),
+.value= "0",
 },
 };
 const size_t pc_compat_2_9_len = G_N_ELEMENTS(pc_compat_2_9);
@@ -365,75 +365,75 @@ GlobalProperty pc_compat_2_3[] = {
 },{
 .driver   = "qemu64" "-" TYPE_X86_CPU,
 .property = "min-level",
-.value= stringify(4),
+.value= "4",
 },{
 .driver   = "kvm64" "-" TYPE_X86_CPU,
 .property = "min-level",
-.value= stringify(5),
+.value= "5",
 },{
 .driver   = "pentium3" "-" TYPE_X86_CPU,
 .property = "min-level",
-.value= stringify(2),
+.value= "2",
 },{
 .driver   = "n270" "-" TYPE_X86_CPU,
 .property = "min-level",
-.value= stringify(5),
+.value= "5",
 },{
 .driver   = "Conroe" "-" TYPE_X86_CPU,
 .property = "min-level",
-.value= stringify(4),
+.value= "4",
 },{
 .driver   = "Penryn" "-" TYPE_X86_CPU,
 .property = "min-level",
-.value= stringify(4),
+.value= "4",
 },{
 .driver   = "Nehalem" "-" TYPE_X86_CPU,
 .property = "min-level",
-.value= stringify(4),
+.value= "4",
 },{
 .driver   = "n270" "-" TYPE_X86_CPU,
 .property = "min-xlevel",
-.value= stringify(0x800a),
+.value= "0x800a",
 },{
 .driver   = "Penryn" "-" TYPE_X86_CPU,
 .property = "min-xlevel",
-.value= stringify(0x800a),
+.value= "0x800a",
 },{
 .driver   = "Conroe" "-" TYPE_X86_CPU,
 .property = "min-xlevel",
-.value= stringify(0x800a),
+.value= "0x800a",
 },{
 .driver   = "Nehalem" "-" TYPE_X86_CPU,
 .property = "min-xlevel",
-.value= stringify(0x800a),
+.value= "0x800a",
 },{
 .driver   = "Westmere" "-" TY

[Xen-devel] [PATCH 1/3] spapr: Eliminate SPAPR_PCI_2_7_MMIO_WIN_SIZE macro

2019-01-07 Thread Eduardo Habkost
The macro is only used in one place, where the purpose of the
value is obvious.  Eliminate the macro so we don't need to rely
on stringify().

Signed-off-by: Eduardo Habkost 
---
 include/hw/pci-host/spapr.h | 1 -
 hw/ppc/spapr.c  | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/include/hw/pci-host/spapr.h b/include/hw/pci-host/spapr.h
index 7c66c3872f..a85a995b6c 100644
--- a/include/hw/pci-host/spapr.h
+++ b/include/hw/pci-host/spapr.h
@@ -99,7 +99,6 @@ struct sPAPRPHBState {
 #define SPAPR_PCI_BASE   (1ULL << 45) /* 32 TiB */
 #define SPAPR_PCI_LIMIT  (1ULL << 46) /* 64 TiB */
 
-#define SPAPR_PCI_2_7_MMIO_WIN_SIZE  0xf8000
 #define SPAPR_PCI_IO_WIN_SIZE0x1
 
 #define SPAPR_PCI_MSI_WINDOW 0x400ULL
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 5671608cea..bff42f0adb 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -4225,7 +4225,7 @@ static void spapr_machine_2_7_class_options(MachineClass 
*mc)
 {
 .driver   = TYPE_SPAPR_PCI_HOST_BRIDGE,
 .property = "mem_win_size",
-.value= stringify(SPAPR_PCI_2_7_MMIO_WIN_SIZE),
+.value= "0xf8000",
 },
 {
 .driver   = TYPE_SPAPR_PCI_HOST_BRIDGE,
-- 
2.18.0.rc1.1.g3f1ff2140


___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

[Xen-devel] [PATCH 0/3] machine: Make compat_props arrays shorter and more readable

2019-01-07 Thread Eduardo Habkost
Current declarations of compat_props arrays are very verbose,
with each entry taking 4 lines of code.  By omitting the field
designators, we can make each array entry fit a single line of
code and be more readable.

Eduardo Habkost (3):
  spapr: Eliminate SPAPR_PCI_2_7_MMIO_WIN_SIZE macro
  machine: Eliminate unnecessary stringify() usage
  machine: Use shorter format for GlobalProperty arrays

 include/hw/i386/pc.h|  18 +-
 include/hw/pci-host/spapr.h |   1 -
 hw/core/machine.c   | 338 -
 hw/i386/pc.c| 720 +++-
 hw/i386/pc_piix.c   | 192 ++
 hw/ppc/spapr.c  |  72 +---
 hw/s390x/s390-virtio-ccw.c  |  75 +---
 hw/xen/xen-common.c |  18 +-
 8 files changed, 265 insertions(+), 1169 deletions(-)

-- 
2.18.0.rc1.1.g3f1ff2140


___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [Qemu-devel] [PATCH for-3.2 v4 15/28] hw: apply accel compat properties without touching globals

2018-11-29 Thread Eduardo Habkost
On Wed, Nov 28, 2018 at 12:02:21AM +0400, Marc-André Lureau wrote:
> Hi
> 
> On Tue, Nov 27, 2018 at 11:40 PM Eduardo Habkost  wrote:
> >
> > On Tue, Nov 27, 2018 at 01:27:48PM +0400, Marc-André Lureau wrote:
> > > Introduce object_apply_global_props() function, to apply compatibility
> > > properties from a GPtrArray.
> > >
> > > For accel compatibility properties, apply them during
> > > device_post_init(), after accel_register_compat_props() has set them.
> > >
> > > To populate the compatibility properties, introduce SET_COMPAT(), a
> > > more generic version of SET_MACHINE_COMPAT() that can set compat
> > > properties on other objects than Machine, and using GPtrArray.
> > >
> > > Signed-off-by: Marc-André Lureau 
> > > ---
> > >  include/hw/qdev-core.h | 13 +
> > >  include/qom/object.h   |  3 +++
> > >  include/sysemu/accel.h |  4 +---
> > >  accel/accel.c  | 12 
> > >  hw/core/qdev.c | 11 +++
> > >  hw/xen/xen-common.c| 38 +++---
> > >  qom/object.c   | 25 +
> > >  vl.c   |  2 +-
> > >  8 files changed, 73 insertions(+), 35 deletions(-)
> > >
> > > diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
> > > index a24d0dd566..82afd3c50d 100644
> > > --- a/include/hw/qdev-core.h
> > > +++ b/include/hw/qdev-core.h
> > > @@ -267,6 +267,19 @@ typedef struct GlobalProperty {
> > >  Error **errp;
> > >  } GlobalProperty;
> > >
> > > +#define SET_COMPAT(S, COMPAT)   \
> > > +do {\
> > > +int i;  \
> > > +static GlobalProperty props[] = {   \
> > > +COMPAT  \
> > > +};  \
> > > +for (i = 0; i < G_N_ELEMENTS(props); i++) { \
> > > +g_ptr_array_add((S)->compat_props, (void *)[i]);  \
> > > +}   \
> > > +} while (0)
> >
> > I think this macro would be an acceptable alternative to the
> > existing SET_MACHINE_COMPAT macro trickery, but:
> >
> > > +
> > > +void accel_register_compat_props(const GPtrArray *props);
> > [...]
> > > @@ -185,7 +183,9 @@ static void xen_accel_class_init(ObjectClass *oc, 
> > > void *data)
> > >  ac->init_machine = xen_init;
> > >  ac->setup_post = xen_setup_post;
> > >  ac->allowed = _allowed;
> > > -ac->global_props = xen_compat_props;
> > > +ac->compat_props = g_ptr_array_new();
> > > +
> > > +SET_COMPAT(ac, XEN_COMPAT);
> >
> > I think this is a step backwards.  I like us to be able to
> > register compat properties without macro magic.  The existence of
> > SET_MACHINE_COMPAT is a bug and not a feature.
> >
> > If you really want to use GPtrArray instead of a simple
> > GlobalProperty* field (I'm not sure I understand the reasoning
> > behind the choice to use GPtrArray), what about:
> 
> Except in the Xen case, It needs to register multiple GlobalProperty*,
> not necessarily from contiguous in memory. That's why we have an array
> of ptr.

If you also need to register multiple properties not from a
contiguous array, would a simple wrapper that does a single
g_ptr_array_add() call be enough?


> 
> >
> > static GPtrArray *build_compat_props_array(GlobalProperty *props)
> > {
> > GlobalProperty *p = props;
> > GPtrArray *array = g_ptr_array_new();
> > while (p->driver) {
> > g_ptr_array_add(array, (void *)p);
> > }
> > return array;
> > }
> >
> >
> > static void xen_accel_class_init(ObjectClass *oc, void *data)
> > {
> > ...
> > ac->compat_props = build_compat_props_array(xen_compat_props);
> 
> If we would register from one place, that would be fine.
> 
> We could replace the macro by a function, then we would have to
> declare the GlobalProperty arrays manually basically.

I would prefer to replace the macro with a function, if possible.
What do you mean by declaring the GlobalProperty arrays manually?


> 
> > }
> >
> >
> >
> >

Re: [Xen-devel] [Qemu-devel] [PATCH for-3.2 v4 15/28] hw: apply accel compat properties without touching globals

2018-11-27 Thread Eduardo Habkost
On Tue, Nov 27, 2018 at 01:27:48PM +0400, Marc-André Lureau wrote:
> Introduce object_apply_global_props() function, to apply compatibility
> properties from a GPtrArray.
> 
> For accel compatibility properties, apply them during
> device_post_init(), after accel_register_compat_props() has set them.
> 
> To populate the compatibility properties, introduce SET_COMPAT(), a
> more generic version of SET_MACHINE_COMPAT() that can set compat
> properties on other objects than Machine, and using GPtrArray.
> 
> Signed-off-by: Marc-André Lureau 
> ---
>  include/hw/qdev-core.h | 13 +
>  include/qom/object.h   |  3 +++
>  include/sysemu/accel.h |  4 +---
>  accel/accel.c  | 12 
>  hw/core/qdev.c | 11 +++
>  hw/xen/xen-common.c| 38 +++---
>  qom/object.c   | 25 +
>  vl.c   |  2 +-
>  8 files changed, 73 insertions(+), 35 deletions(-)
> 
> diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
> index a24d0dd566..82afd3c50d 100644
> --- a/include/hw/qdev-core.h
> +++ b/include/hw/qdev-core.h
> @@ -267,6 +267,19 @@ typedef struct GlobalProperty {
>  Error **errp;
>  } GlobalProperty;
>  
> +#define SET_COMPAT(S, COMPAT)   \
> +do {\
> +int i;  \
> +static GlobalProperty props[] = {   \
> +COMPAT  \
> +};  \
> +for (i = 0; i < G_N_ELEMENTS(props); i++) { \
> +g_ptr_array_add((S)->compat_props, (void *)[i]);  \
> +}   \
> +} while (0)

I think this macro would be an acceptable alternative to the
existing SET_MACHINE_COMPAT macro trickery, but:

> +
> +void accel_register_compat_props(const GPtrArray *props);
[...]
> @@ -185,7 +183,9 @@ static void xen_accel_class_init(ObjectClass *oc, void 
> *data)
>  ac->init_machine = xen_init;
>  ac->setup_post = xen_setup_post;
>  ac->allowed = _allowed;
> -ac->global_props = xen_compat_props;
> +ac->compat_props = g_ptr_array_new();
> +
> +SET_COMPAT(ac, XEN_COMPAT);

I think this is a step backwards.  I like us to be able to
register compat properties without macro magic.  The existence of
SET_MACHINE_COMPAT is a bug and not a feature.

If you really want to use GPtrArray instead of a simple
GlobalProperty* field (I'm not sure I understand the reasoning
behind the choice to use GPtrArray), what about:

static GPtrArray *build_compat_props_array(GlobalProperty *props)
{
GlobalProperty *p = props;
GPtrArray *array = g_ptr_array_new();
while (p->driver) {
g_ptr_array_add(array, (void *)p);
}
return array;
}


static void xen_accel_class_init(ObjectClass *oc, void *data)
{
...
ac->compat_props = build_compat_props_array(xen_compat_props);
}



>  }
>  
>  #define TYPE_XEN_ACCEL ACCEL_CLASS_NAME("xen")
> diff --git a/qom/object.c b/qom/object.c
> index 17921c0a71..dbdab0aead 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -370,6 +370,31 @@ 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, );
> +if (err != NULL) {
> +error_prepend(, "can't apply global %s.%s=%s: ",
> +  p->driver, p->property, p->value);
> +error_propagate(errp, err);
> +}
> +}
> +}
> +
>  static void object_initialize_with_type(void *data, size_t size, TypeImpl 
> *type)
>  {
>  Object *obj = data;
> diff --git a/vl.c b/vl.c
> index fa25d1ae2d..c06e94271c 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2963,7 +2963,7 @@ static void user_register_global_props(void)
>   */
>  static void register_global_properties(MachineState *ms)
>  {
> -accel_register_compat_props(ms->accelerator);
> +
> accel_register_compat_props(ACCEL_GET_CLASS(ms->accelerator)->compat_props);
>  machine_register_compat_props(ms);
>  user_register_global_props();
>  }
> -- 
> 2.20.0.rc1
> 
> 

-- 
Eduardo

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [Qemu-devel] [PATCH for-3.2 v3 02/14] qom: make interface types abstract

2018-11-20 Thread Eduardo Habkost
On Tue, Nov 20, 2018 at 05:33:24PM +0100, Igor Mammedov wrote:
> On Wed,  7 Nov 2018 16:36:40 +0400
> Marc-André Lureau  wrote:
> 
> > Interfaces don't have instance, let's make the interface type really
> > abstract to avoid confusion.
> > 
> > Signed-off-by: Marc-André Lureau 
> > ---
> >  include/hw/acpi/acpi_dev_interface.h | 6 +-
> >  include/hw/arm/linux-boot-if.h   | 5 +
> >  include/hw/fw-path-provider.h| 4 +---
> >  include/hw/hotplug.h | 6 +-
> >  include/hw/intc/intc.h   | 4 +---
> >  include/hw/ipmi/ipmi.h   | 4 +---
> >  include/hw/isa/isa.h | 4 
> >  include/hw/mem/memory-device.h   | 4 +---
> >  include/hw/nmi.h | 4 +---
> >  include/hw/stream.h  | 4 +---
> >  include/hw/timer/m48t59.h| 4 +---
> >  include/qom/object_interfaces.h  | 6 +-
> >  include/sysemu/tpm.h | 4 +---
> >  target/arm/idau.h| 4 +---
> >  tests/check-qom-interface.c  | 4 +---
> >  15 files changed, 14 insertions(+), 53 deletions(-)
> > 
> > diff --git a/include/hw/acpi/acpi_dev_interface.h 
> > b/include/hw/acpi/acpi_dev_interface.h
> > index dabf4c4fc9..43ff119179 100644
> > --- a/include/hw/acpi/acpi_dev_interface.h
> > +++ b/include/hw/acpi/acpi_dev_interface.h
> > @@ -25,11 +25,7 @@ typedef enum {
> >   INTERFACE_CHECK(AcpiDeviceIf, (obj), \
> >   TYPE_ACPI_DEVICE_IF)
> >  
> > -
> > -typedef struct AcpiDeviceIf {
> > -/*  */
> > -Object Parent;
> > -} AcpiDeviceIf;
> > +typedef struct AcpiDeviceIf AcpiDeviceIf;
> >  
> >  void acpi_send_event(DeviceState *dev, AcpiEventStatusBits event);
> >  
> > diff --git a/include/hw/arm/linux-boot-if.h b/include/hw/arm/linux-boot-if.h
> > index aba4479a14..7bbdfd1cc6 100644
> > --- a/include/hw/arm/linux-boot-if.h
> > +++ b/include/hw/arm/linux-boot-if.h
> > @@ -16,10 +16,7 @@
> >  #define ARM_LINUX_BOOT_IF(obj) \
> >  INTERFACE_CHECK(ARMLinuxBootIf, (obj), TYPE_ARM_LINUX_BOOT_IF)
> >  
> > -typedef struct ARMLinuxBootIf {
> > -/*< private >*/
> > -Object parent_obj;
> > -} ARMLinuxBootIf;
> > +typedef struct ARMLinuxBootIf ARMLinuxBootIf;
> I like how it makes interface truly opaque and removes the need for
> structure declaration but:
> 
>  1: I'm not sure if it's acceptable thing to do from language point of view
> 
>  2: For a reader not aware of a trick, it's sort of confusing to have forward 
> declaration but without structure itself. So if #1 is acceptable we probably 
> should document interface trick in object.h

I'm not sure what's the question here.  We do this all the time
on typedefs.h, don't we?

-- 
Eduardo

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [Qemu-devel] [PATCH for-3.2 v3 13/14] hw/i386: add pc-i440fx-3.2 & pc-q35-3.2

2018-11-07 Thread Eduardo Habkost
On Wed, Nov 07, 2018 at 07:49:54PM +0400, Marc-André Lureau wrote:
> Hi
> 
> On Wed, Nov 7, 2018 at 4:49 PM Marc-André Lureau
>  wrote:
> >
> > The following patch is going to add compatiblity parameters for
> > qemu <= 3.1.
> >
> 
> I realize this may be good enough for x86 i440/q35 machines, but what
> about other machines & architectures?
> 
> What do we officially support, for migration, across different versions?
> 
> It seems we have versionized:
> - arm "virt" machines
> - "s390-ccw-virtio" machines
> - ppc "pseries" machines
> - x86 piix/q35 machines
> 
> At least, I think I should update this patch to add new 3.2 machines for 
> those.

This QEMU release seems to be unusual: normally we add features
that require adding new machine-types long before soft freeze.
If we didn't add new machine-types until now, this means we
didn't introduce any guest ABI changes that require them.

Now, this is an interesting case: we probably don't _need_ the
new machine-types, but users might be confused if they don't see
new machine-types.  Should we add them anyway?


> 
> Is there any way to check compat properties are handled properly for
> those various machines? It looks like it is generally lacking. For
> example, if there is a new HW_COMPAT, it would be nice if something
> failed if a corresponding machine hasn't been added.
> 
> It also looks like there is a bit of code duplication and a bit too
> much macros :) unfortunately, I don't yet have a good idea how to
> improve things...

I dream with the day all this compatibility data will be treated
like what it is: just data.  The ugly macro trickery needs to go
away eventually, but this requires making the QOM/machine-type
APIs more practical.

Removing very old machine-types will probably make this task
easier, because they are the main source of compatibility code
that is not represented as  tuples (grep
for "static void pc_compat_" and you'll see them).

-- 
Eduardo

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [RFC PATCH 16/30] q35/xen: Add Xen platform device support for Q35

2018-03-12 Thread Eduardo Habkost
On Tue, Mar 13, 2018 at 06:56:37AM +1000, Alexey G wrote:
> On Mon, 12 Mar 2018 16:44:06 -0300
> Eduardo Habkost <ehabk...@redhat.com> wrote:
> 
> >On Tue, Mar 13, 2018 at 04:34:01AM +1000, Alexey Gerasimenko wrote:
> >> Current Xen/QEMU method to control Xen Platform device on i440 is a
> >> bit odd -- enabling/disabling Xen platform device actually modifies
> >> the QEMU emulated machine type, namely xenfv <--> pc.
> >> 
> >> In order to avoid multiplying machine types, use a new way to
> >> control Xen Platform device for QEMU -- "xen-platform-dev" machine
> >> property (bool). To maintain backward compatibility with existing
> >> Xen/QEMU setups, this is only applicable to q35 machine currently.
> >> i440 emulation still uses the old method (i.e. xenfv/pc machine
> >> selection) to control Xen Platform device, this may be changed later
> >> to xen-platform-dev property as well.
> >> 
> >> This way we can use a single machine type (q35) and change just
> >> xen-platform-dev value to on/off to control Xen platform device.
> >> 
> >> Signed-off-by: Alexey Gerasimenko <x19...@gmail.com>
> >> ---  
> >[...]
> >> diff --git a/qemu-options.hx b/qemu-options.hx
> >> index 6585058c6c..cee0b92028 100644
> >> --- a/qemu-options.hx
> >> +++ b/qemu-options.hx
> >> @@ -38,6 +38,7 @@ DEF("machine", HAS_ARG, QEMU_OPTION_machine, \
> >>  "dump-guest-core=on|off include guest memory in
> >> a core dump (default=on)\n" "mem-merge=on|off
> >> controls memory merge support (default: on)\n" "
> >> igd-passthru=on|off controls IGD GFX passthrough support
> >> (default=off)\n"
> >> +"xen-platform-dev=on|off controls Xen Platform
> >> device (default=off)\n" "aes-key-wrap=on|off
> >> controls support for AES key wrapping (default=on)\n"
> >> "dea-key-wrap=on|off controls support for DEA key
> >> wrapping (default=on)\n" "suppress-vmdesc=on|off
> >> disables self-describing migration (default=off)\n"  
> >
> >What are the obstacles preventing "-device xen-platform" from
> >working?  It would be better than adding a new boolean option to
> >-machine.
> 
> I guess the initial assumption was that changing the
> xen_platform_device value in Xen's options may cause some additional
> changes in platform configuration besides adding (or not) the Xen
> Platform device, hence a completely different machine type was chosen
> (xenfv).
> 
> At the moment pc,accel=xen/xenfv selection mostly governs
> only the Xen Platform device presence. Also setting max_cpus to
> HVM_MAX_VCPUS depends on it, but this doesn't applicable to a
> 'pc,accel=xen' machine for some reason.
> 
> If applying HVM_MAX_VCPUS to max_cpus is really necessary I think it's
> better to set it unconditionally for all 'accel=xen' HVM machine
> types inside xen_enabled() block. Right now it's missing for
> pc,accel=xen and q35,accel=xen.

If you are talking about MachineClass::max_cpus, note that it is
returned by query-machines, so it's supposed to be a static
value.  Changing it a runtime would mean the query-machines value
is incorrect.

Is HVM_MAX_CPUS higher or lower than 255?  If it's higher, does
it mean the current value on pc and q35 isn't accurate?


> 
> I'll check if supplying the Xen platform device via the '-device' option
> will be ok for all usage cases.

Is HVM_MAX_CPUS something that needs to be enabled because of
accel=xen or because or the xen-platform device?

If it's just because of accel=xen, we could introduce a
AccelClass::max_cpus() method (we also have KVM-imposed CPU count
limits, currently implemented inside kvm_init()).

-- 
Eduardo

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [RFC PATCH 16/30] q35/xen: Add Xen platform device support for Q35

2018-03-12 Thread Eduardo Habkost
On Tue, Mar 13, 2018 at 04:34:01AM +1000, Alexey Gerasimenko wrote:
> Current Xen/QEMU method to control Xen Platform device on i440 is a bit
> odd -- enabling/disabling Xen platform device actually modifies the QEMU
> emulated machine type, namely xenfv <--> pc.
> 
> In order to avoid multiplying machine types, use a new way to control Xen
> Platform device for QEMU -- "xen-platform-dev" machine property (bool).
> To maintain backward compatibility with existing Xen/QEMU setups, this
> is only applicable to q35 machine currently. i440 emulation still uses the
> old method (i.e. xenfv/pc machine selection) to control Xen Platform
> device, this may be changed later to xen-platform-dev property as well.
> 
> This way we can use a single machine type (q35) and change just
> xen-platform-dev value to on/off to control Xen platform device.
> 
> Signed-off-by: Alexey Gerasimenko 
> ---
[...]
> diff --git a/qemu-options.hx b/qemu-options.hx
> index 6585058c6c..cee0b92028 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -38,6 +38,7 @@ DEF("machine", HAS_ARG, QEMU_OPTION_machine, \
>  "dump-guest-core=on|off include guest memory in a core 
> dump (default=on)\n"
>  "mem-merge=on|off controls memory merge support 
> (default: on)\n"
>  "igd-passthru=on|off controls IGD GFX passthrough 
> support (default=off)\n"
> +"xen-platform-dev=on|off controls Xen Platform device 
> (default=off)\n"
>  "aes-key-wrap=on|off controls support for AES key 
> wrapping (default=on)\n"
>  "dea-key-wrap=on|off controls support for DEA key 
> wrapping (default=on)\n"
>  "suppress-vmdesc=on|off disables self-describing 
> migration (default=off)\n"

What are the obstacles preventing "-device xen-platform" from
working?  It would be better than adding a new boolean option to
-machine.

-- 
Eduardo

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH 03/11] xen: defer call to xen_restrict until just before os_setup_post

2018-03-09 Thread Eduardo Habkost
On Fri, Mar 09, 2018 at 12:07:21PM +, Ian Jackson wrote:
> Ian Jackson writes ("Re: [PATCH 03/11] xen: defer call to xen_restrict until 
> just before os_setup_post"):
> > Eduardo Habkost writes ("Re: [PATCH 03/11] xen: defer call to xen_restrict 
> > until just before os_setup_post"):
> > > I don't think we should have accelerator-specific code in main(),
> > > if we already have accelerator classes that can abstract that
> > > out.  I suggest adding a AccelClass;:setup_post() method that can
> > > be called here.
> > 
> > I think I can do that.
> 
> How about this ?
> 
> From 61f11221afaa29e10021599420238e03836ba413 Mon Sep 17 00:00:00 2001
> From: Ian Jackson <ian.jack...@eu.citrix.com>
> Date: Fri, 9 Mar 2018 12:02:50 +
> Subject: [PATCH v6.2 12/11] AccelClass: Introduce accel_setup_post
> 
> This is called just before os_setup_post.  Currently none of the
> accelerators provide this hook, but the Xen one is going to provide
> one in a moment.
> 
> Signed-off-by: Ian Jackson <ian.jack...@eu.citrix.com>

Looks good to me.

Reviewed-by: Eduardo Habkost <ehabk...@redhat.com>

That said, I don't think this should block the inclusion of the
previous patch in 2.12, if the Xen maintainers were already going
to merge it.

-- 
Eduardo

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH 03/11] xen: defer call to xen_restrict until just before os_setup_post

2018-03-09 Thread Eduardo Habkost
On Fri, Mar 09, 2018 at 11:33:35AM +, Ian Jackson wrote:
> Eduardo Habkost writes ("Re: [PATCH 03/11] xen: defer call to xen_restrict 
> until just before os_setup_post"):
> > On Thu, Mar 08, 2018 at 05:39:09PM +, Ian Jackson wrote:
> > [...]
> > > diff --git a/vl.c b/vl.c
> > > +xen_setup_post();
> > 
> > I don't think we should have accelerator-specific code in main(),
> > if we already have accelerator classes that can abstract that
> > out.  I suggest adding a AccelClass;:setup_post() method that can
> > be called here.
> 
> I think I can do that.
> 
> Although, it is a bit disappointing to be given this feedback in v6 of
> this series.  Did the right people not get CC'd on v5 in October ?

That is entirely my fault, for not paying attention to the patch
back in october (I was CCed on it).  Sorry for that.

-- 
Eduardo

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH 03/11] xen: defer call to xen_restrict until just before os_setup_post

2018-03-08 Thread Eduardo Habkost
On Thu, Mar 08, 2018 at 05:39:09PM +, Ian Jackson wrote:
[...]
> diff --git a/vl.c b/vl.c
> index dae986b..e6e8e1e 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -4719,6 +4719,7 @@ int main(int argc, char **argv, char **envp)
>  vm_start();
>  }
>  
> +xen_setup_post();

I don't think we should have accelerator-specific code in main(),
if we already have accelerator classes that can abstract that
out.  I suggest adding a AccelClass;:setup_post() method that can
be called here.

-- 
Eduardo

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

[Xen-devel] [PULL v2 10/19] xen: Add only xen-sysdev to dynamic sysbus device list

2018-01-19 Thread Eduardo Habkost
There's no need to make the machine allow every possible sysbus
device.  We can now just add xen-sysdev to the allowed list.

Cc: Stefano Stabellini <sstabell...@kernel.org>
Cc: Anthony Perard <anthony.per...@citrix.com>
Cc: xen-devel@lists.xenproject.org
Cc: Juergen Gross <jgr...@suse.com>
Signed-off-by: Eduardo Habkost <ehabk...@redhat.com>
Message-Id: <20171125151610.20547-6-ehabk...@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lur...@redhat.com>
Acked-by: Anthony PERARD <anthony.per...@citrix.com>
Signed-off-by: Eduardo Habkost <ehabk...@redhat.com>
---
 hw/xen/xen_backend.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/hw/xen/xen_backend.c b/hw/xen/xen_backend.c
index 82380ea9ee..7445b506ac 100644
--- a/hw/xen/xen_backend.c
+++ b/hw/xen/xen_backend.c
@@ -564,12 +564,7 @@ static void xen_set_dynamic_sysbus(void)
 ObjectClass *oc = object_get_class(machine);
 MachineClass *mc = MACHINE_CLASS(oc);
 
-/*
- * Emulate old mc->has_dynamic_sysbus=true assignment
- *
- *TODO: add only Xen devices to the list
- */
-machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE);
+machine_class_allow_dynamic_sysbus_dev(mc, TYPE_XENSYSDEV);
 }
 
 int xen_be_register(const char *type, struct XenDevOps *ops)
-- 
2.14.3


___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

[Xen-devel] [PULL v2 06/19] machine: Replace has_dynamic_sysbus with list of allowed devices

2018-01-19 Thread Eduardo Habkost
The existing has_dynamic_sysbus flag makes the machine accept
every user-creatable sysbus device type on the command-line.
Replace it with a list of allowed device types, so machines can
easily accept some sysbus devices while rejecting others.

To keep exactly the same behavior as before, the existing
has_dynamic_sysbus=true assignments are replaced with a
TYPE_SYS_BUS_DEVICE entry on the allowed list.  Other patches
will replace the TYPE_SYS_BUS_DEVICE entries with more specific
lists of devices.

Cc: Peter Maydell <peter.mayd...@linaro.org>
Cc: Marcel Apfelbaum <mar...@redhat.com>
Cc: "Michael S. Tsirkin" <m...@redhat.com>
Cc: Alexander Graf <ag...@suse.de>
Cc: David Gibson <da...@gibson.dropbear.id.au>
Cc: Stefano Stabellini <sstabell...@kernel.org>
Cc: Anthony Perard <anthony.per...@citrix.com>
Cc: qemu-...@nongnu.org
Cc: qemu-...@nongnu.org
Cc: xen-devel@lists.xenproject.org
Signed-off-by: Eduardo Habkost <ehabk...@redhat.com>
Message-Id: <20171125151610.20547-2-ehabk...@redhat.com>
Reviewed-by: Greg Kurz <gr...@kaod.org>
Reviewed-by: David Gibson <da...@gibson.dropbear.id.au>
Reviewed-by: Marc-André Lureau <marcandre.lur...@redhat.com>
Reviewed-by: Marcel Apfelbaum <mar...@redhat.com>
Signed-off-by: Eduardo Habkost <ehabk...@redhat.com>
---
 include/hw/boards.h  |  5 -
 hw/arm/virt.c|  3 ++-
 hw/core/machine.c| 43 +--
 hw/i386/pc_q35.c |  3 ++-
 hw/ppc/e500plat.c|  4 +++-
 hw/ppc/spapr.c   |  3 ++-
 hw/xen/xen_backend.c |  7 ++-
 7 files changed, 48 insertions(+), 20 deletions(-)

diff --git a/include/hw/boards.h b/include/hw/boards.h
index 156b16f7a6..041bc08971 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -76,6 +76,9 @@ void machine_set_cpu_numa_node(MachineState *machine,
const CpuInstanceProperties *props,
Error **errp);
 
+void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char 
*type);
+
+
 /**
  * CPUArchId:
  * @arch_id - architecture-dependent CPU ID of present or possible CPU
@@ -179,7 +182,6 @@ struct MachineClass {
 no_floppy:1,
 no_cdrom:1,
 no_sdcard:1,
-has_dynamic_sysbus:1,
 pci_allow_0_address:1,
 legacy_fw_cfg_order:1;
 int is_default;
@@ -197,6 +199,7 @@ struct MachineClass {
 bool ignore_memory_transaction_failures;
 int numa_mem_align_shift;
 const char **valid_cpu_types;
+strList *allowed_dynamic_sysbus_devices;
 bool auto_enable_numa_with_memhp;
 void (*numa_auto_assign_ram)(MachineClass *mc, NodeInfo *nodes,
  int nb_nodes, ram_addr_t size);
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 543f9bd6cc..7549895fd2 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -1591,7 +1591,8 @@ static void virt_machine_class_init(ObjectClass *oc, void 
*data)
  * configuration of the particular instance.
  */
 mc->max_cpus = 255;
-mc->has_dynamic_sysbus = true;
+/*TODO: allow only sysbus devices that really work with this machine */
+machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE);
 mc->block_default_type = IF_VIRTIO;
 mc->no_cdrom = 1;
 mc->pci_allow_0_address = true;
diff --git a/hw/core/machine.c b/hw/core/machine.c
index c857f3f934..0320a8efa1 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -334,29 +334,44 @@ static bool machine_get_enforce_config_section(Object 
*obj, Error **errp)
 return ms->enforce_config_section;
 }
 
-static void error_on_sysbus_device(SysBusDevice *sbdev, void *opaque)
+void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *type)
 {
-error_report("Option '-device %s' cannot be handled by this machine",
- object_class_get_name(object_get_class(OBJECT(sbdev;
-exit(1);
+strList *item = g_new0(strList, 1);
+
+item->value = g_strdup(type);
+item->next = mc->allowed_dynamic_sysbus_devices;
+mc->allowed_dynamic_sysbus_devices = item;
 }
 
-static void machine_init_notify(Notifier *notifier, void *data)
+static void validate_sysbus_device(SysBusDevice *sbdev, void *opaque)
 {
-Object *machine = qdev_get_machine();
-ObjectClass *oc = object_get_class(machine);
-MachineClass *mc = MACHINE_CLASS(oc);
+MachineState *machine = opaque;
+MachineClass *mc = MACHINE_GET_CLASS(machine);
+bool allowed = false;
+strList *wl;
 
-if (mc->has_dynamic_sysbus) {
-/* Our machine can handle dynamic sysbus devices, we're all good */
-return;
+for (wl = mc->allowed_dynamic_sysbus_devices;
+ !allowed && wl;
+ wl = wl->next) {
+allowed |= !!object_dynamic_cast(OBJECT(sbdev), wl->value);
 }
 
+if (!allowed) {
+error_report("Option '-device %s

[Xen-devel] [PULL 06/19] machine: Replace has_dynamic_sysbus with list of allowed devices

2018-01-17 Thread Eduardo Habkost
The existing has_dynamic_sysbus flag makes the machine accept
every user-creatable sysbus device type on the command-line.
Replace it with a list of allowed device types, so machines can
easily accept some sysbus devices while rejecting others.

To keep exactly the same behavior as before, the existing
has_dynamic_sysbus=true assignments are replaced with a
TYPE_SYS_BUS_DEVICE entry on the allowed list.  Other patches
will replace the TYPE_SYS_BUS_DEVICE entries with more specific
lists of devices.

Cc: Peter Maydell <peter.mayd...@linaro.org>
Cc: Marcel Apfelbaum <mar...@redhat.com>
Cc: "Michael S. Tsirkin" <m...@redhat.com>
Cc: Alexander Graf <ag...@suse.de>
Cc: David Gibson <da...@gibson.dropbear.id.au>
Cc: Stefano Stabellini <sstabell...@kernel.org>
Cc: Anthony Perard <anthony.per...@citrix.com>
Cc: qemu-...@nongnu.org
Cc: qemu-...@nongnu.org
Cc: xen-devel@lists.xenproject.org
Signed-off-by: Eduardo Habkost <ehabk...@redhat.com>
Message-Id: <20171125151610.20547-2-ehabk...@redhat.com>
Reviewed-by: Greg Kurz <gr...@kaod.org>
Reviewed-by: David Gibson <da...@gibson.dropbear.id.au>
Reviewed-by: Marc-André Lureau <marcandre.lur...@redhat.com>
Reviewed-by: Marcel Apfelbaum <mar...@redhat.com>
Signed-off-by: Eduardo Habkost <ehabk...@redhat.com>
---
 include/hw/boards.h  |  5 -
 hw/arm/virt.c|  3 ++-
 hw/core/machine.c| 43 +--
 hw/i386/pc_q35.c |  3 ++-
 hw/ppc/e500plat.c|  4 +++-
 hw/ppc/spapr.c   |  3 ++-
 hw/xen/xen_backend.c |  7 ++-
 7 files changed, 48 insertions(+), 20 deletions(-)

diff --git a/include/hw/boards.h b/include/hw/boards.h
index 156b16f7a6..041bc08971 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -76,6 +76,9 @@ void machine_set_cpu_numa_node(MachineState *machine,
const CpuInstanceProperties *props,
Error **errp);
 
+void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char 
*type);
+
+
 /**
  * CPUArchId:
  * @arch_id - architecture-dependent CPU ID of present or possible CPU
@@ -179,7 +182,6 @@ struct MachineClass {
 no_floppy:1,
 no_cdrom:1,
 no_sdcard:1,
-has_dynamic_sysbus:1,
 pci_allow_0_address:1,
 legacy_fw_cfg_order:1;
 int is_default;
@@ -197,6 +199,7 @@ struct MachineClass {
 bool ignore_memory_transaction_failures;
 int numa_mem_align_shift;
 const char **valid_cpu_types;
+strList *allowed_dynamic_sysbus_devices;
 bool auto_enable_numa_with_memhp;
 void (*numa_auto_assign_ram)(MachineClass *mc, NodeInfo *nodes,
  int nb_nodes, ram_addr_t size);
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 543f9bd6cc..7549895fd2 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -1591,7 +1591,8 @@ static void virt_machine_class_init(ObjectClass *oc, void 
*data)
  * configuration of the particular instance.
  */
 mc->max_cpus = 255;
-mc->has_dynamic_sysbus = true;
+/*TODO: allow only sysbus devices that really work with this machine */
+machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE);
 mc->block_default_type = IF_VIRTIO;
 mc->no_cdrom = 1;
 mc->pci_allow_0_address = true;
diff --git a/hw/core/machine.c b/hw/core/machine.c
index c857f3f934..0320a8efa1 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -334,29 +334,44 @@ static bool machine_get_enforce_config_section(Object 
*obj, Error **errp)
 return ms->enforce_config_section;
 }
 
-static void error_on_sysbus_device(SysBusDevice *sbdev, void *opaque)
+void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *type)
 {
-error_report("Option '-device %s' cannot be handled by this machine",
- object_class_get_name(object_get_class(OBJECT(sbdev;
-exit(1);
+strList *item = g_new0(strList, 1);
+
+item->value = g_strdup(type);
+item->next = mc->allowed_dynamic_sysbus_devices;
+mc->allowed_dynamic_sysbus_devices = item;
 }
 
-static void machine_init_notify(Notifier *notifier, void *data)
+static void validate_sysbus_device(SysBusDevice *sbdev, void *opaque)
 {
-Object *machine = qdev_get_machine();
-ObjectClass *oc = object_get_class(machine);
-MachineClass *mc = MACHINE_CLASS(oc);
+MachineState *machine = opaque;
+MachineClass *mc = MACHINE_GET_CLASS(machine);
+bool allowed = false;
+strList *wl;
 
-if (mc->has_dynamic_sysbus) {
-/* Our machine can handle dynamic sysbus devices, we're all good */
-return;
+for (wl = mc->allowed_dynamic_sysbus_devices;
+ !allowed && wl;
+ wl = wl->next) {
+allowed |= !!object_dynamic_cast(OBJECT(sbdev), wl->value);
 }
 
+if (!allowed) {
+error_report("Option '-device %s

[Xen-devel] [PULL 10/19] xen: Add only xen-sysdev to dynamic sysbus device list

2018-01-17 Thread Eduardo Habkost
There's no need to make the machine allow every possible sysbus
device.  We can now just add xen-sysdev to the allowed list.

Cc: Stefano Stabellini <sstabell...@kernel.org>
Cc: Anthony Perard <anthony.per...@citrix.com>
Cc: xen-devel@lists.xenproject.org
Cc: Juergen Gross <jgr...@suse.com>
Signed-off-by: Eduardo Habkost <ehabk...@redhat.com>
Message-Id: <20171125151610.20547-6-ehabk...@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lur...@redhat.com>
Acked-by: Anthony PERARD <anthony.per...@citrix.com>
Signed-off-by: Eduardo Habkost <ehabk...@redhat.com>
---
 hw/xen/xen_backend.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/hw/xen/xen_backend.c b/hw/xen/xen_backend.c
index 82380ea9ee..7445b506ac 100644
--- a/hw/xen/xen_backend.c
+++ b/hw/xen/xen_backend.c
@@ -564,12 +564,7 @@ static void xen_set_dynamic_sysbus(void)
 ObjectClass *oc = object_get_class(machine);
 MachineClass *mc = MACHINE_CLASS(oc);
 
-/*
- * Emulate old mc->has_dynamic_sysbus=true assignment
- *
- *TODO: add only Xen devices to the list
- */
-machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE);
+machine_class_allow_dynamic_sysbus_dev(mc, TYPE_XENSYSDEV);
 }
 
 int xen_be_register(const char *type, struct XenDevOps *ops)
-- 
2.14.3


___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [Qemu-devel] [PATCH V5] pci: removed the is_express field since a uniform interface was inserted

2017-12-19 Thread Eduardo Habkost
On Mon, Dec 18, 2017 at 05:21:40PM +0200, Yoni Bettan wrote:
> according to Eduardo Habkost's commit fd3b02c889 all PCIEs now implement
> INTERFACE_PCIE_DEVICE so we don't need is_express field anymore.
> 
> Devices that implements only INTERFACE_PCIE_DEVICE (is_express == 1)
> or
> devices that implements only INTERFACE_CONVENTIONAL_PCI_DEVICE (is_express == 
> 0)
> where not affected by the change.
> 
> The only devices that were affected are those that are hybrid and also
> had (is_express == 1) - therefor only:
>   - hw/vfio/pci.c
>   - hw/usb/hcd-xhci.c
>   - hw/xen/xen_pt.c
> 
> For those 3 I made sure that QEMU_PCI_CAP_EXPRESS is on in instance_init()
> 
> Signed-off-by: Yoni Bettan <ybet...@redhat.com>

Reviewed-by: Eduardo Habkost <ehabk...@redhat.com>

-- 
Eduardo

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel