qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 11/58] qdev: Convert uses of qdev_set_parent_bus() with Co


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH v2 11/58] qdev: Convert uses of qdev_set_parent_bus() with Coccinelle
Date: Tue, 9 Jun 2020 10:08:24 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0

On 5/29/20 3:44 PM, Markus Armbruster wrote:
> In addition to the qdev_create() patterns converted so far, we have a
> qdev_set_parent_bus() pattern.  Mostly when we embed a device in a
> parent device rather than allocating it on the heap.
> 
> This pattern also puts devices in the dangerous "no QOM parent, but
> plugged into bus" state I explained in recent commit "qdev: New
> qdev_new(), qdev_realize(), etc."
> 
> Apply same solution: convert to qdev_realize().  Coccinelle script:
> 
>     @@
>     expression dev, bus, errp;
>     symbol true;
>     @@
>     -    qdev_set_parent_bus(DEVICE(dev), bus);
>          ...
>     -    object_property_set_bool(OBJECT(dev), true, "realized", errp);
>     +    qdev_realize(DEVICE(dev), bus, errp);
> 
>     @ depends on !(file in "qdev-monitor.c") && !(file in "hw/core/qdev.c")@
>     expression dev, bus, errp;
>     symbol true;
>     @@
>     -    qdev_set_parent_bus(dev, bus);
>          ...
>     -    object_property_set_bool(OBJECT(dev), true, "realized", errp);
>     +    qdev_realize(dev, bus, errp);
> 
>     @@
>     expression dev, bus;
>     symbol true;
>     @@
>     -    qdev_set_parent_bus(DEVICE(dev), bus);
>          ...
>     -    qdev_init_nofail(DEVICE(dev));
>     +    qdev_realize(DEVICE(dev), bus, &error_fatal);

I insist the qdev_realize() name is confusing me - all these calls work
on SysBusDevice - but the API change is very good.

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> 
> Unconverted uses of qdev_set_parent_bus() remain.  They'll be
> converted later in this series.
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  hw/display/virtio-gpu-pci.c     | 3 +--
>  hw/display/virtio-vga.c         | 3 +--
>  hw/i386/amd_iommu.c             | 3 +--
>  hw/isa/piix4.c                  | 3 +--
>  hw/misc/macio/macio.c           | 7 ++-----
>  hw/pci-host/designware.c        | 3 +--
>  hw/pci-host/gpex.c              | 3 +--
>  hw/pci-host/pnv_phb3.c          | 3 +--
>  hw/pci-host/pnv_phb4.c          | 3 +--
>  hw/pci-host/q35.c               | 3 +--
>  hw/pci-host/versatile.c         | 3 +--
>  hw/pci-host/xilinx-pcie.c       | 3 +--
>  hw/s390x/vhost-vsock-ccw.c      | 3 +--
>  hw/s390x/virtio-ccw-9p.c        | 3 +--
>  hw/s390x/virtio-ccw-balloon.c   | 3 +--
>  hw/s390x/virtio-ccw-blk.c       | 3 +--
>  hw/s390x/virtio-ccw-crypto.c    | 3 +--
>  hw/s390x/virtio-ccw-gpu.c       | 3 +--
>  hw/s390x/virtio-ccw-input.c     | 3 +--
>  hw/s390x/virtio-ccw-net.c       | 3 +--
>  hw/s390x/virtio-ccw-rng.c       | 3 +--
>  hw/s390x/virtio-ccw-scsi.c      | 6 ++----
>  hw/s390x/virtio-ccw-serial.c    | 3 +--
>  hw/virtio/vhost-scsi-pci.c      | 3 +--
>  hw/virtio/vhost-user-blk-pci.c  | 3 +--
>  hw/virtio/vhost-user-fs-pci.c   | 3 +--
>  hw/virtio/vhost-user-scsi-pci.c | 3 +--
>  hw/virtio/vhost-vsock-pci.c     | 3 +--
>  hw/virtio/virtio-9p-pci.c       | 3 +--
>  hw/virtio/virtio-balloon-pci.c  | 3 +--
>  hw/virtio/virtio-blk-pci.c      | 3 +--
>  hw/virtio/virtio-crypto-pci.c   | 3 +--
>  hw/virtio/virtio-input-pci.c    | 3 +--
>  hw/virtio/virtio-iommu-pci.c    | 3 +--
>  hw/virtio/virtio-net-pci.c      | 3 +--
>  hw/virtio/virtio-pmem-pci.c     | 3 +--
>  hw/virtio/virtio-rng-pci.c      | 3 +--
>  hw/virtio/virtio-scsi-pci.c     | 3 +--
>  hw/virtio/virtio-serial-pci.c   | 3 +--
>  hw/xen/xen-legacy-backend.c     | 3 +--
>  40 files changed, 42 insertions(+), 85 deletions(-)
[...]




reply via email to

[Prev in Thread] Current Thread [Next in Thread]