qemu/hw/pci
Vladimir Sementsov-Ogievskiy 8eb85fb5ac pci: ROM preallocation for incoming migration
On incoming migration we have the following sequence to load option
ROM:

1. On device realize we do normal load ROM from the file

2. Than, on incoming migration we rewrite ROM from the incoming RAM
   block. If sizes mismatch we fail, like this:

    Size mismatch: 0000:00:03.0/virtio-net-pci.rom: 0x40000 != 0x80000: Invalid argument

This is not ideal when we migrate to updated distribution: we have to
keep old ROM files in new distribution and be careful around romfile
property to load correct ROM file. Which is loaded actually just to
allocate the ROM with correct length.

Note, that romsize property doesn't really help: if we try to specify
it when default romfile is larger, it fails with something like:

    romfile "efi-virtio.rom" (160768 bytes) is too large for ROM size 65536

Let's just ignore ROM file when romsize is specified and we are in
incoming migration state. In other words, we need only to preallocate
ROM of specified size, local ROM file is unrelated.

This way:

If romsize was specified on source, we just use same commandline as on
source, and migration will work independently of local ROM files on
target.

If romsize was not specified on source (and we have mismatching local
ROM file on target host), we have to specify romsize on target to match
source romsize. romfile parameter may be kept same as on source or may
be dropped, the file is not loaded anyway.

As a bonus we avoid extra reading from ROM file on target.

Note: when we don't have romsize parameter on source command line and
need it for target, it may be calculated as aligned up to power of two
size of ROM file on source (if we know, which file is it) or,
alternatively it may be retrieved from source QEMU by QMP qom-get
command, like

  { "execute": "qom-get",
    "arguments": {
      "path": "/machine/peripheral/CARD_ID/virtio-net-pci.rom[0]",
      "property": "size" } }

Note: we have extra initialization of size variable to zero in
      pci_add_option_rom to avoid false-positive
      "error: ‘size’ may be used uninitialized"

Suggested-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Message-Id: <20230522201740.88960-2-vsementsov@yandex-team.ru>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2023-06-23 02:54:44 -04:00
..
Kconfig
meson.build meson: Replace softmmu_ss -> system_ss 2023-06-20 10:01:30 +02:00
msi.c hw/xen: Support MSI mapping to PIRQ 2023-03-01 09:09:22 +00:00
msix.c
pci-hmp-cmds.c
pci-internal.h hw/pci/aer: Make PCIE AER error injection facility available for other emulation to use. 2023-03-07 12:39:00 -05:00
pci-qmp-cmds.c
pci-stub.c
pci.c pci: ROM preallocation for incoming migration 2023-06-23 02:54:44 -04:00
pci_bridge.c hw/pci-bridge: Fix release ordering by embedding PCIBridgeWindows within PCIBridge 2023-05-16 09:14:18 +02:00
pci_host.c
pcie.c pcie: set power indicator to off on reset by default 2023-03-02 19:13:41 -05:00
pcie_aer.c hw/pci: Disable PCI_ERR_UNCOR_MASK register for machine type < 8.0 2023-05-19 10:30:46 -04:00
pcie_doe.c
pcie_host.c
pcie_port.c hw/pci: Add pcie_count_ds_port() and pcie_find_port_first() helpers 2023-03-07 19:51:07 -05:00
pcie_sriov.c pcie: Introduce pcie_sriov_num_vfs 2023-03-10 15:35:38 +08:00
shpc.c pci/shpc: refactor shpc_device_plug_common() 2023-03-02 03:10:48 -05:00
slotid_cap.c
trace-events hw/pci: Trace IRQ routing on PCI topology 2023-03-02 19:13:52 -05:00
trace.h