@@ -531,6 +531,10 @@ static QEMUMachine pc_i440fx_machine_v2_2 = {
PC_I440FX_2_2_MACHINE_OPTIONS,
.name = "pc-i440fx-2.2",
.init = pc_init_pci_2_2,
+ .compat_props = (GlobalProperty[]) {
+ HW_COMPAT_2_2,
+ { /* end of list */ }
+ },
};
#define PC_I440FX_2_1_MACHINE_OPTIONS \
@@ -428,6 +428,10 @@ static QEMUMachine pc_q35_machine_v2_2 = {
PC_Q35_2_2_MACHINE_OPTIONS,
.name = "pc-q35-2.2",
.init = pc_q35_init_2_2,
+ .compat_props = (GlobalProperty[]) {
+ HW_COMPAT_2_2,
+ { /* end of list */ }
+ },
};
#define PC_Q35_2_1_MACHINE_OPTIONS \
@@ -1777,11 +1777,16 @@ static const TypeInfo spapr_machine_2_1_info = {
static void spapr_machine_2_2_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
+ HW_COMPAT_2_2,
+ { /* end of list */ }
+ };
mc->name = "pseries-2.2";
mc->desc = "pSeries Logical Partition (PAPR compliant) v2.2";
mc->alias = "pseries";
mc->is_default = 1;
+ mc->compat_props = compat_props;
}
static const TypeInfo spapr_machine_2_2_info = {
@@ -961,7 +961,7 @@ static void virtio_pci_device_plugged(DeviceState *d)
VirtIOPCIProxy *proxy = VIRTIO_PCI(d);
VirtioBusState *bus = &proxy->bus;
uint8_t *config;
- uint32_t size;
+ uint32_t size, bar_size;
config = proxy->pci_dev.config;
if (proxy->class_code) {
@@ -972,8 +972,19 @@ static void virtio_pci_device_plugged(DeviceState *d)
pci_set_word(config + PCI_SUBSYSTEM_ID, virtio_bus_get_vdev_id(bus));
config[PCI_INTERRUPT_PIN] = 1;
+ if (proxy->flags & VIRTIO_PCI_FLAG_AUTO_MSIX_SIZE) {
+ bar_size = proxy->nvectors * PCI_MSIX_ENTRY_SIZE * 2;
+ if (bar_size & (bar_size - 1)) {
+ bar_size = 1 << qemu_fls(bar_size);
+ }
+ } else {
+ /* For migration compatibility */
+ bar_size = 4096;
+ }
+
if (proxy->nvectors &&
- msix_init_exclusive_bar(&proxy->pci_dev, proxy->nvectors, 1, 4096)) {
+ msix_init_exclusive_bar(&proxy->pci_dev, proxy->nvectors, 1,
+ bar_size)) {
error_report("unable to init msix vectors to %" PRIu32,
proxy->nvectors);
proxy->nvectors = 0;
@@ -1418,6 +1429,8 @@ static const TypeInfo virtio_serial_pci_info = {
static Property virtio_net_properties[] = {
DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags,
VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, false),
+ DEFINE_PROP_BIT("auto_msix_bar_size", VirtIOPCIProxy, flags,
+ VIRTIO_PCI_FLAG_AUTO_MSIX_SIZE_BIT, true),
DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 3),
DEFINE_VIRTIO_NET_FEATURES(VirtIOPCIProxy, host_features),
DEFINE_PROP_END_OF_LIST(),
@@ -62,6 +62,9 @@ typedef struct VirtioBusClass VirtioPCIBusClass;
* vcpu thread using ioeventfd for some devices. */
#define VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT 1
#define VIRTIO_PCI_FLAG_USE_IOEVENTFD (1 << VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT)
+#define VIRTIO_PCI_FLAG_AUTO_MSIX_SIZE_BIT 2
+#define VIRTIO_PCI_FLAG_AUTO_MSIX_SIZE \
+ (1 << VIRTIO_PCI_FLAG_AUTO_MSIX_SIZE_BIT)
typedef struct {
MSIMessage msg;
@@ -1,7 +1,15 @@
#ifndef HW_COMPAT_H
#define HW_COMPAT_H
+#define HW_COMPAT_2_2 \
+ {\
+ .driver = "virtio-net-pci",\
+ .property = "auto_msix_bar_size",\
+ .value = "off",\
+ }
+
#define HW_COMPAT_2_1 \
+ HW_COMPAT_2_2, \
{\
.driver = "intel-hda",\
.property = "old_msi_addr",\
This patch introduces boolean auto_msix_bar_size property for virito-pci devices. Enable this will let the device calculate the msix bar size based on the number of MSI-X entries instead of previous 4096 hard-coded limit. This is a must to let virtio-net can up to 256 queues and each queue were associated with a specific MSI-X entry. Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Richard Henderson <rth@twiddle.net> Cc: Anthony Liguori <aliguori@amazon.com> Cc: Michael S. Tsirkin <mst@redhat.com> Cc: Alexander Graf <agraf@suse.de> Cc: qemu-ppc@nongnu.org Signed-off-by: Jason Wang <jasowang@redhat.com> --- hw/i386/pc_piix.c | 4 ++++ hw/i386/pc_q35.c | 4 ++++ hw/ppc/spapr.c | 5 +++++ hw/virtio/virtio-pci.c | 17 +++++++++++++++-- hw/virtio/virtio-pci.h | 3 +++ include/hw/compat.h | 8 ++++++++ 6 files changed, 39 insertions(+), 2 deletions(-)