qemu/hw
Markus Armbruster 9307d06da9 pci: Convert uses of pci_create() etc. with Coccinelle
Replace

    dev = pci_create(bus, type_name);
    ...
    qdev_init_nofail(dev);

by

    dev = pci_new(type_name);
    ...
    pci_realize_and_unref(dev, bus, &error_fatal);

and similarly for pci_create_multifunction().

Recent commit "qdev: New qdev_new(), qdev_realize(), etc." explains
why.

Coccinelle script:

    @@
    expression dev, bus, expr;
    expression list args;
    @@
    -    dev = pci_create(bus, args);
    +    dev = pci_new(args);
         ... when != dev = expr
    -    qdev_init_nofail(&dev->qdev);
    +    pci_realize_and_unref(dev, bus, &error_fatal);

    @@
    expression dev, bus, expr;
    expression list args;
    expression d;
    @@
    -    dev = pci_create(bus, args);
    +    dev = pci_new(args);
    (
         d = &dev->qdev;
    |
         d = DEVICE(dev);
    )
         ... when != dev = expr
    -    qdev_init_nofail(d);
    +    pci_realize_and_unref(dev, bus, &error_fatal);

    @@
    expression dev, bus, expr;
    expression list args;
    @@
    -    dev = pci_create(bus, args);
    +    dev = pci_new(args);
         ... when != dev = expr
    -    qdev_init_nofail(DEVICE(dev));
    +    pci_realize_and_unref(dev, bus, &error_fatal);

    @@
    expression dev, bus, expr;
    expression list args;
    @@
    -    dev = DEVICE(pci_create(bus, args));
    +    PCIDevice *pci_dev; // TODO move
    +    pci_dev = pci_new(args);
    +    dev = DEVICE(pci_dev);
         ... when != dev = expr
    -    qdev_init_nofail(dev);
    +    pci_realize_and_unref(pci_dev, bus, &error_fatal);

    @@
    expression dev, bus, expr;
    expression list args;
    @@
    -    dev = pci_create_multifunction(bus, args);
    +    dev = pci_new_multifunction(args);
         ... when != dev = expr
    -    qdev_init_nofail(&dev->qdev);
    +    pci_realize_and_unref(dev, bus, &error_fatal);

    @@
    expression bus, expr;
    expression list args;
    identifier dev;
    @@
    -    PCIDevice *dev = pci_create_multifunction(bus, args);
    +    PCIDevice *dev = pci_new_multifunction(args);
         ... when != dev = expr
    -    qdev_init_nofail(&dev->qdev);
    +    pci_realize_and_unref(dev, bus, &error_fatal);

    @@
    expression dev, bus, expr;
    expression list args;
    @@
    -    dev = pci_create_multifunction(bus, args);
    +    dev = pci_new_multifunction(args);
         ... when != dev = expr
    -    qdev_init_nofail(DEVICE(dev));
    +    pci_realize_and_unref(dev, bus, &error_fatal);

Missing #include "qapi/error.h" added manually, whitespace changes
minimized manually, @pci_dev declarations moved manually.

Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-16-armbru@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
2020-06-15 22:05:28 +02:00
..
9pfs xen/9pfs: increase max ring order to 9 2020-05-25 11:45:40 +02:00
acpi pci: Convert uses of pci_create() etc. with Coccinelle 2020-06-15 22:05:28 +02:00
adc hw/adc/stm32f2xx_adc: Correct memory region size and access size 2020-06-05 17:23:09 +01:00
alpha qdev: Convert uses of qdev_create() with Coccinelle 2020-06-15 22:00:10 +02:00
arm qdev: Convert uses of qdev_create() manually 2020-06-15 22:05:08 +02:00
audio qdev: Convert uses of qdev_create() with Coccinelle 2020-06-15 22:00:10 +02:00
block qdev: Convert uses of qdev_create() manually 2020-06-15 22:05:08 +02:00
char qdev: Convert uses of qdev_create() manually 2020-06-15 22:05:08 +02:00
core qdev: Convert uses of qdev_create() with Coccinelle 2020-06-15 22:00:10 +02:00
cpu qom: Drop parameter @errp of object_property_add() & friends 2020-05-15 07:07:58 +02:00
cris qdev: Convert uses of qdev_create() with Coccinelle 2020-06-15 22:00:10 +02:00
display qdev: Convert uses of qdev_set_parent_bus() with Coccinelle 2020-06-15 22:05:08 +02:00
dma qdev: Convert uses of qdev_create() with Coccinelle 2020-06-15 22:00:10 +02:00
gpio hw/unicore32/puv3: Use qemu_log_mask(ERROR) instead of debug printf() 2020-06-09 19:01:56 +02:00
hppa qdev: Convert uses of qdev_create() with Coccinelle 2020-06-15 22:00:10 +02:00
hyperv vmbus: add infrastructure to save/load vmbus requests 2020-06-10 12:09:41 -04:00
i2c qdev: Convert uses of qdev_create() with Coccinelle 2020-06-15 22:00:10 +02:00
i386 pci: Convert uses of pci_create() etc. with Coccinelle 2020-06-15 22:05:28 +02:00
ide qdev: Convert uses of qdev_create() with Coccinelle 2020-06-15 22:00:10 +02:00
input hw/input/pxa2xx_keypad: Replace hw_error() by qemu_log_mask() 2020-06-05 17:23:08 +01:00
intc qdev: Convert uses of qdev_create() with Coccinelle 2020-06-15 22:00:10 +02:00
ipack qdev: Unrealize must not fail 2020-05-15 07:08:14 +02:00
ipmi various: Remove unnecessary OBJECT() cast 2020-05-15 07:08:14 +02:00
isa pci: Convert uses of pci_create() etc. with Coccinelle 2020-06-15 22:05:28 +02:00
lm32 qdev: Convert uses of qdev_create() with Coccinelle 2020-06-15 22:00:10 +02:00
m68k qdev: Convert uses of qdev_create() with Coccinelle 2020-06-15 22:00:10 +02:00
mem nvdimm: Plug memory leak in uuid property setter 2020-05-27 07:44:59 +02:00
microblaze qdev: Convert uses of qdev_create() with Coccinelle 2020-06-15 22:00:10 +02:00
mips pci: Convert uses of pci_create() etc. with Coccinelle 2020-06-15 22:05:28 +02:00
misc qdev: Convert uses of qdev_set_parent_bus() with Coccinelle 2020-06-15 22:05:08 +02:00
moxie hw: Make MachineClass::is_default a boolean type 2020-02-28 14:57:19 -05:00
net qdev: Convert uses of qdev_create() with Coccinelle 2020-06-15 22:00:10 +02:00
nios2 qdev: Convert uses of qdev_create() with Coccinelle 2020-06-15 22:00:10 +02:00
nubus hw: Remove unnecessary DEVICE() cast 2020-05-15 07:08:52 +02:00
nvram qdev: Convert uses of qdev_create() with Coccinelle 2020-06-15 22:00:10 +02:00
openrisc qdev: Convert uses of qdev_create() with Coccinelle 2020-06-15 22:00:10 +02:00
pci pci: Convert uses of pci_create() etc. with Coccinelle 2020-06-15 22:05:28 +02:00
pci-bridge pci: Convert uses of pci_create() etc. with Coccinelle 2020-06-15 22:05:28 +02:00
pci-host pci: Convert uses of pci_create() etc. with Coccinelle 2020-06-15 22:05:28 +02:00
pcmcia qdev: Convert uses of qdev_create() with Coccinelle 2020-06-15 22:00:10 +02:00
ppc pci: Convert uses of pci_create() etc. with Coccinelle 2020-06-15 22:05:28 +02:00
rdma lockable: Replace locks with lock guard macros 2020-05-04 16:07:43 +01:00
riscv qdev: Convert uses of qdev_create() manually 2020-06-15 22:05:08 +02:00
rtc qdev: Convert uses of qdev_create() with Coccinelle 2020-06-15 22:00:10 +02:00
s390x qdev: Convert uses of qdev_set_parent_bus() manually 2020-06-15 22:05:28 +02:00
scsi qdev: Convert uses of qdev_create() with Coccinelle 2020-06-15 22:00:10 +02:00
sd qdev: Convert uses of qdev_create() with Coccinelle 2020-06-15 22:00:10 +02:00
semihosting semihosting: remove the pthread include which seems unused 2020-06-10 11:29:44 +02:00
sh4 qdev: Convert uses of qdev_create() with Coccinelle 2020-06-15 22:00:10 +02:00
smbios hw/smbios/smbios: Remove unused include 2020-02-06 10:38:57 +01:00
sparc qdev: Convert uses of qdev_create() manually 2020-06-15 22:05:08 +02:00
sparc64 pci: Convert uses of pci_create() etc. with Coccinelle 2020-06-15 22:05:28 +02:00
ssi hw/ssi/imx_spi: Removed unnecessary cast of rx data received from slave 2020-06-05 17:23:08 +01:00
timer Trivial branch pull request 20200610 2020-06-11 19:22:52 +01:00
tpm hw/tpm: fix usage of bool in tpm-tis.c 2020-05-12 11:47:24 -04:00
tricore hw: Do not initialize MachineClass::is_default to 0 2020-02-28 14:57:19 -05:00
unicore32 hw/unicore32/puv3: Use qemu_log_mask(ERROR) instead of debug printf() 2020-06-09 19:01:56 +02:00
usb qdev: Convert uses of qdev_create() manually 2020-06-15 22:05:08 +02:00
vfio * Miscellaneous fixes and feature enablement (many) 2020-06-12 23:06:22 +01:00
virtio qdev: Convert uses of qdev_set_parent_bus() with Coccinelle 2020-06-15 22:05:08 +02:00
watchdog hw/watchdog: Implement full i.MX watchdog support 2020-05-21 20:00:18 +01:00
xen qdev: Convert uses of qdev_set_parent_bus() with Coccinelle 2020-06-15 22:05:08 +02:00
xenpv trivial: Remove xenfb_enabled from sysemu.h 2020-02-04 09:00:57 +01:00
xtensa qdev: Convert uses of qdev_create() with Coccinelle 2020-06-15 22:00:10 +02:00
Kconfig Remove the core bluetooth code 2019-12-17 09:01:14 +01:00
Makefile.objs xen: fix build without pci passthrough 2020-06-12 11:20:12 -04:00