[libvirt] [PATCH v6 04/17] qemu: set/use proper pciConnectFlags during hotplug

Andrea Bolognani abologna at redhat.com
Tue Nov 8 11:00:58 UTC 2016


On Mon, 2016-11-07 at 14:50 -0500, Laine Stump wrote:
> Before now, all the qemu hotplug functions assumed that all devices to
> be hotplugged were legacy PCI endpoint devices
> (VIR_PCI_CONNECT_TYPE_PCI_DEVICE). This worked out "okay", because all
> devices *are* legacy PCI endpoint devices on x86/440fx machinetypes,
> and hotplug didn't work properly on machinetypes using PCIe anyway
> (hotplugging onto a legacy PCI slot doesn't work, and until commit
> b87703cf any attempt to manually specify a PCIe address for a
> hotplugged device would be erroneously rejected).
> 
> This patch makes all qemu hotplug operations honor the pciConnectFlags
> set by the single all-knowing function
> qemuDomainDeviceCalculatePCIConnectFlags(). This is done in 3 steps,
> but in a single commit since we would have to touch the other points
> at each step anyway:
> 
> 1) add a flags argument to the hypervisor-agnostic
> virDomainPCIAddressEnsureAddr() (previously it hardcoded
> ..._PCI_DEVICE)
> 
> 2) add a new qemu-specific function qemuDomainEnsurePCIAddress() which
> gets the correct pciConnectFlags for the device from
> qemuDomainDeviceConnectFlags(), then calls
> virDomainPCIAddressEnsureAddr().
> 
> 3) in qemu_hotplug.c replace all calls to
> virDomainPCIAddressEnsureAddr() with calls to
> qemuDomainEnsurePCIAddress()
> 
> So in effect, we're putting a "shim" on top of all calls to
> virDomainPCIAddressEnsureAddr() that sets the right pciConnectFlags.
> ---
>  src/conf/domain_addr.c         | 10 ++--------
>  src/conf/domain_addr.h         |  3 ++-
>  src/qemu/qemu_domain_address.c | 27 +++++++++++++++++++++++++++
>  src/qemu/qemu_domain_address.h |  4 ++++
>  src/qemu/qemu_hotplug.c        | 23 ++++++++++++++++-------
>  5 files changed, 51 insertions(+), 16 deletions(-)

Oh, just one more tiny detail:

[...]
> @@ -2512,7 +2521,7 @@ qemuDomainAttachShmemDevice(virQEMUDriverPtr driver,
>  
>      if ((shmem->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE ||
>           shmem->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) &&
> -         (virDomainPCIAddressEnsureAddr(priv->pciaddrs, &shmem->info) < 0))
> +        (qemuDomainEnsurePCIAddress(vm, &dev) < 0))
>          return -1;

This branch should have had curly braces even before, but
since you're changing the condition anyway you might as well
slip them in now. And thanks for fixing the indentation :)

-- 
Andrea Bolognani / Red Hat / Virtualization




More information about the libvir-list mailing list