diff --git a/kvm-aarch64-Add-virt-rhel8.0.0-machine-type-for-ARM.patch b/kvm-aarch64-Add-virt-rhel8.0.0-machine-type-for-ARM.patch new file mode 100644 index 0000000..be3b71a --- /dev/null +++ b/kvm-aarch64-Add-virt-rhel8.0.0-machine-type-for-ARM.patch @@ -0,0 +1,70 @@ +From 7bfdb4cd2b490d6da5648b1bfeacf9078b4b3ecb Mon Sep 17 00:00:00 2001 +From: Wei Huang +Date: Thu, 17 Jan 2019 17:33:55 +0000 +Subject: [PATCH 5/7] aarch64: Add virt-rhel8.0.0 machine type for ARM + +RH-Author: Wei Huang +Message-id: <20190117173357.31514-2-wei@redhat.com> +Patchwork-id: 84037 +O-Subject: [RHEL8 qemu-kvm PATCH v3 1/3] aarch64: Add virt-rhel8.0.0 machine type for ARM +Bugzilla: 1656504 +RH-Acked-by: Andrew Jones +RH-Acked-by: Auger Eric +RH-Acked-by: Igor Mammedov +RH-Acked-by: Laszlo Ersek + +This patch adds a new machine type, virt-rhel8.0.0, for QEMU fast train +to replace old virt-rhel7.6.0 because virt-rhel7.6.0 was defined for +an unsupported preview product. Note that we explicitly disable +256MB ECAM region in virt-rhel8.0.0 to match what virt-rhel7.6.0 offered. + +Signed-off-by: Wei Huang +Signed-off-by: Danilo C. L. de Paula +--- + hw/arm/virt.c | 12 +++++++++--- + 1 file changed, 9 insertions(+), 3 deletions(-) + +diff --git a/hw/arm/virt.c b/hw/arm/virt.c +index 84a86c1..156721a 100644 +--- a/hw/arm/virt.c ++++ b/hw/arm/virt.c +@@ -2094,7 +2094,7 @@ static void rhel_machine_init(void) + } + type_init(rhel_machine_init); + +-static void rhel760_virt_instance_init(Object *obj) ++static void rhel800_virt_instance_init(Object *obj) + { + VirtMachineState *vms = VIRT_MACHINE(obj); + VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms); +@@ -2119,6 +2119,8 @@ static void rhel760_virt_instance_init(Object *obj) + "Set GIC version. " + "Valid values are 2, 3 and host", NULL); + ++ vms->highmem_ecam = !vmc->no_highmem_ecam; ++ + if (vmc->no_its) { + vms->its = false; + } else { +@@ -2132,12 +2134,16 @@ static void rhel760_virt_instance_init(Object *obj) + NULL); + } + ++ /* IOMMU is disabled by default and non-configurable for RHEL */ ++ vms->iommu = VIRT_IOMMU_NONE; ++ + vms->memmap=a15memmap; + vms->irqmap=a15irqmap; + } + +-static void rhel760_virt_options(MachineClass *mc) ++static void rhel800_virt_options(MachineClass *mc) + { + SET_MACHINE_COMPAT(mc, ARM_RHEL_COMPAT); ++ vmc->no_highmem_ecam = true; + } +-DEFINE_RHEL_MACHINE_AS_LATEST(7, 6, 0) ++DEFINE_RHEL_MACHINE_AS_LATEST(8, 0, 0) +-- +1.8.3.1 + diff --git a/kvm-aarch64-Set-virt-rhel8.0.0-max_cpus-to-512.patch b/kvm-aarch64-Set-virt-rhel8.0.0-max_cpus-to-512.patch new file mode 100644 index 0000000..76eae19 --- /dev/null +++ b/kvm-aarch64-Set-virt-rhel8.0.0-max_cpus-to-512.patch @@ -0,0 +1,50 @@ +From 3433e6920a4aaa2177f3503ef08256a58f866b33 Mon Sep 17 00:00:00 2001 +From: Wei Huang +Date: Thu, 17 Jan 2019 17:33:56 +0000 +Subject: [PATCH 6/7] aarch64: Set virt-rhel8.0.0 max_cpus to 512 + +RH-Author: Wei Huang +Message-id: <20190117173357.31514-3-wei@redhat.com> +Patchwork-id: 84038 +O-Subject: [RHEL8 qemu-kvm PATCH v3 2/3] aarch64: Set virt-rhel8.0.0 max_cpus to 512 +Bugzilla: 1656504 +RH-Acked-by: Andrew Jones +RH-Acked-by: Auger Eric +RH-Acked-by: Igor Mammedov +RH-Acked-by: Laszlo Ersek + +This patch increases max_cpus of virt-rhel8.0.0 from 255 to 512. +This decision is made due to a recent trend of ARM servers Red Hat +received. Currently Red Hat has HPE Apollo machines that contains 256 +cpu cores. It is reasonable to expect that we will see new machines +with > 256 cores very soon. We have verified this patch partially with a +256-vcpu VM on Apollo and expect 512 vcpus will work as well. + +Signed-off-by: Wei Huang +Signed-off-by: Danilo C. L. de Paula +--- + hw/arm/virt.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/hw/arm/virt.c b/hw/arm/virt.c +index 156721a..21965e4 100644 +--- a/hw/arm/virt.c ++++ b/hw/arm/virt.c +@@ -2063,11 +2063,11 @@ static void rhel_machine_class_init(ObjectClass *oc, void *data) + + mc->family = "virt-rhel-Z"; + mc->init = machvirt_init; +- /* Start max_cpus at the maximum QEMU supports. We'll further restrict +- * it later in machvirt_init, where we have more information about the ++ /* Start with max_cpus set to 512, which is the maximum supported by KVM. ++ * The value may be reduced later when we have more information about the + * configuration of the particular instance. + */ +- mc->max_cpus = 255; ++ mc->max_cpus = 512; + mc->block_default_type = IF_VIRTIO; + mc->no_cdrom = 1; + mc->pci_allow_0_address = true; +-- +1.8.3.1 + diff --git a/kvm-aarch64-Use-256MB-ECAM-region-by-default.patch b/kvm-aarch64-Use-256MB-ECAM-region-by-default.patch new file mode 100644 index 0000000..759adcc --- /dev/null +++ b/kvm-aarch64-Use-256MB-ECAM-region-by-default.patch @@ -0,0 +1,38 @@ +From 4d20863ae382c9ce2a8b7f88aee7a1d1228112a7 Mon Sep 17 00:00:00 2001 +From: Wei Huang +Date: Thu, 17 Jan 2019 17:33:57 +0000 +Subject: [PATCH 7/7] aarch64: Use 256MB ECAM region by default + +RH-Author: Wei Huang +Message-id: <20190117173357.31514-4-wei@redhat.com> +Patchwork-id: 84039 +O-Subject: [RHEL8 qemu-kvm PATCH v3 3/3] aarch64: Use 256MB ECAM region by default +Bugzilla: 1656504 +RH-Acked-by: Andrew Jones +RH-Acked-by: Auger Eric +RH-Acked-by: Igor Mammedov +RH-Acked-by: Laszlo Ersek + +This patch turns on 256MB ECAM region to support a larger number (up to +256) of PCIe buses on virt-rhel8.0.0. + +Signed-off-by: Wei Huang +Signed-off-by: Danilo C. L. de Paula +--- + hw/arm/virt.c | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/hw/arm/virt.c b/hw/arm/virt.c +index 21965e4..bee8f10 100644 +--- a/hw/arm/virt.c ++++ b/hw/arm/virt.c +@@ -2144,6 +2144,5 @@ static void rhel800_virt_instance_init(Object *obj) + static void rhel800_virt_options(MachineClass *mc) + { + SET_MACHINE_COMPAT(mc, ARM_RHEL_COMPAT); +- vmc->no_highmem_ecam = true; + } + DEFINE_RHEL_MACHINE_AS_LATEST(8, 0, 0) +-- +1.8.3.1 + diff --git a/kvm-globals-Allow-global-properties-to-be-optional.patch b/kvm-globals-Allow-global-properties-to-be-optional.patch new file mode 100644 index 0000000..b039c64 --- /dev/null +++ b/kvm-globals-Allow-global-properties-to-be-optional.patch @@ -0,0 +1,84 @@ +From c63a58b4e1d3db52301bec072ac8025216731f35 Mon Sep 17 00:00:00 2001 +From: Eduardo Habkost +Date: Wed, 16 Jan 2019 23:18:18 +0000 +Subject: [PATCH 3/7] globals: Allow global properties to be optional +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +RH-Author: Eduardo Habkost +Message-id: <20190116231819.29310-4-ehabkost@redhat.com> +Patchwork-id: 84029 +O-Subject: [RHEL-8.0/AV qemu-kvm PATCH 3/4] globals: Allow global properties to be optional +Bugzilla: 1648023 +RH-Acked-by: Cornelia Huck +RH-Acked-by: Thomas Huth +RH-Acked-by: Laurent Vivier +RH-Acked-by: Michael S. Tsirkin + +Upstream tree: git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git +Upstream commit: d7741743f4f3d2683d1bb6938f88dc0167c21afa + +Making some global properties optional will let us simplify +compat code when a given property works on most (but not all) +subclasses of a given type. + +Device types will be able to opt out from optional compat +properties by simply not registering those properties. + +Backport conflict notes: + Patching qdev_prop_set_globals(), because our downstream tree + still doesn't have object_apply_global_props() from commit + ea9ce8934c5d ("hw: apply accel compat properties without + touching globals") + +Signed-off-by: Eduardo Habkost +Reviewed-by: Cornelia Huck +Reviewed-by: Marc-André Lureau +Reviewed-by: Michael S. Tsirkin +Signed-off-by: Michael S. Tsirkin +Signed-off-by: Eduardo Habkost +Signed-off-by: Danilo C. L. de Paula +--- + hw/core/qdev-properties.c | 3 +++ + include/hw/qdev-core.h | 3 +++ + 2 files changed, 6 insertions(+) + +diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c +index 35072de..2023c1a 100644 +--- a/hw/core/qdev-properties.c ++++ b/hw/core/qdev-properties.c +@@ -1255,6 +1255,9 @@ void qdev_prop_set_globals(DeviceState *dev) + if (object_dynamic_cast(OBJECT(dev), prop->driver) == NULL) { + continue; + } ++ if (prop->optional && !object_property_find(OBJECT(dev), prop->property, NULL)) { ++ continue; ++ } + prop->used = true; + object_property_parse(OBJECT(dev), prop->value, prop->property, &err); + if (err != NULL) { +diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h +index a24d0dd..a10f60f 100644 +--- a/include/hw/qdev-core.h ++++ b/include/hw/qdev-core.h +@@ -252,6 +252,8 @@ struct PropertyInfo { + * @user_provided: Set to true if property comes from user-provided config + * (command-line or config file). + * @used: Set to true if property was used when initializing a device. ++ * @optional: If set to true, GlobalProperty will be skipped without errors ++ * if the property doesn't exist. + * @errp: Error destination, used like first argument of error_setg() + * in case property setting fails later. If @errp is NULL, we + * print warnings instead of ignoring errors silently. For +@@ -264,6 +266,7 @@ typedef struct GlobalProperty { + const char *value; + bool user_provided; + bool used; ++ bool optional; + Error **errp; + } GlobalProperty; + +-- +1.8.3.1 + diff --git a/kvm-virtio-Helper-for-registering-virtio-device-types.patch b/kvm-virtio-Helper-for-registering-virtio-device-types.patch new file mode 100644 index 0000000..c0dae87 --- /dev/null +++ b/kvm-virtio-Helper-for-registering-virtio-device-types.patch @@ -0,0 +1,553 @@ +From 8a7371fb25d2072d60b029eb092a083cfa064afb Mon Sep 17 00:00:00 2001 +From: Eduardo Habkost +Date: Wed, 16 Jan 2019 23:18:16 +0000 +Subject: [PATCH 1/7] virtio: Helper for registering virtio device types + +RH-Author: Eduardo Habkost +Message-id: <20190116231819.29310-2-ehabkost@redhat.com> +Patchwork-id: 84027 +O-Subject: [RHEL-8.0/AV qemu-kvm PATCH 1/4] virtio: Helper for registering virtio device types +Bugzilla: 1648023 +RH-Acked-by: Cornelia Huck +RH-Acked-by: Thomas Huth +RH-Acked-by: Laurent Vivier +RH-Acked-by: Michael S. Tsirkin + +Introduce a helper for registering different flavours of virtio +devices. Convert code to use the helper, but keep only the +existing generic types. Transitional and non-transitional device +types will be added by another patch. + +Backport conflicts: + hw/virtio/virtio-pci.c: because our downstream tree doesn't + have commit e6a74868d92f ("build-sys: add --disable-vhost-user") + +Acked-by: Andrea Bolognani +Reviewed-by: Cornelia Huck +Signed-off-by: Eduardo Habkost +Reviewed-by: Michael S. Tsirkin +Signed-off-by: Michael S. Tsirkin +(cherry picked from commit a4ee4c8baa37154f42b4dc6a13fee79268d15238) +Signed-off-by: Eduardo Habkost +Signed-off-by: Danilo C. L. de Paula +--- + hw/display/virtio-gpu-pci.c | 7 +- + hw/display/virtio-vga.c | 7 +- + hw/virtio/virtio-crypto-pci.c | 7 +- + hw/virtio/virtio-pci.c | 231 ++++++++++++++++++++++++++++++------------ + hw/virtio/virtio-pci.h | 54 ++++++++++ + 5 files changed, 228 insertions(+), 78 deletions(-) + +diff --git a/hw/display/virtio-gpu-pci.c b/hw/display/virtio-gpu-pci.c +index cece4aa..faf76a8 100644 +--- a/hw/display/virtio-gpu-pci.c ++++ b/hw/display/virtio-gpu-pci.c +@@ -69,9 +69,8 @@ static void virtio_gpu_initfn(Object *obj) + TYPE_VIRTIO_GPU); + } + +-static const TypeInfo virtio_gpu_pci_info = { +- .name = TYPE_VIRTIO_GPU_PCI, +- .parent = TYPE_VIRTIO_PCI, ++static const VirtioPCIDeviceTypeInfo virtio_gpu_pci_info = { ++ .generic_name = TYPE_VIRTIO_GPU_PCI, + .instance_size = sizeof(VirtIOGPUPCI), + .instance_init = virtio_gpu_initfn, + .class_init = virtio_gpu_pci_class_init, +@@ -79,6 +78,6 @@ static const TypeInfo virtio_gpu_pci_info = { + + static void virtio_gpu_pci_register_types(void) + { +- type_register_static(&virtio_gpu_pci_info); ++ virtio_pci_types_register(&virtio_gpu_pci_info); + } + type_init(virtio_gpu_pci_register_types) +diff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c +index ab2e369..8db4d91 100644 +--- a/hw/display/virtio-vga.c ++++ b/hw/display/virtio-vga.c +@@ -207,9 +207,8 @@ static void virtio_vga_inst_initfn(Object *obj) + TYPE_VIRTIO_GPU); + } + +-static TypeInfo virtio_vga_info = { +- .name = TYPE_VIRTIO_VGA, +- .parent = TYPE_VIRTIO_PCI, ++static VirtioPCIDeviceTypeInfo virtio_vga_info = { ++ .generic_name = TYPE_VIRTIO_VGA, + .instance_size = sizeof(struct VirtIOVGA), + .instance_init = virtio_vga_inst_initfn, + .class_init = virtio_vga_class_init, +@@ -217,7 +216,7 @@ static TypeInfo virtio_vga_info = { + + static void virtio_vga_register_types(void) + { +- type_register_static(&virtio_vga_info); ++ virtio_pci_types_register(&virtio_vga_info); + } + + type_init(virtio_vga_register_types) +diff --git a/hw/virtio/virtio-crypto-pci.c b/hw/virtio/virtio-crypto-pci.c +index bf64996..8cc3fa3 100644 +--- a/hw/virtio/virtio-crypto-pci.c ++++ b/hw/virtio/virtio-crypto-pci.c +@@ -64,9 +64,8 @@ static void virtio_crypto_initfn(Object *obj) + TYPE_VIRTIO_CRYPTO); + } + +-static const TypeInfo virtio_crypto_pci_info = { +- .name = TYPE_VIRTIO_CRYPTO_PCI, +- .parent = TYPE_VIRTIO_PCI, ++static const VirtioPCIDeviceTypeInfo virtio_crypto_pci_info = { ++ .generic_name = TYPE_VIRTIO_CRYPTO_PCI, + .instance_size = sizeof(VirtIOCryptoPCI), + .instance_init = virtio_crypto_initfn, + .class_init = virtio_crypto_pci_class_init, +@@ -74,6 +73,6 @@ static const TypeInfo virtio_crypto_pci_info = { + + static void virtio_crypto_pci_register_types(void) + { +- type_register_static(&virtio_crypto_pci_info); ++ virtio_pci_types_register(&virtio_crypto_pci_info); + } + type_init(virtio_crypto_pci_register_types) +diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c +index 9a987cb..bee3509 100644 +--- a/hw/virtio/virtio-pci.c ++++ b/hw/virtio/virtio-pci.c +@@ -1119,9 +1119,8 @@ static void virtio_9p_pci_instance_init(Object *obj) + TYPE_VIRTIO_9P); + } + +-static const TypeInfo virtio_9p_pci_info = { +- .name = TYPE_VIRTIO_9P_PCI, +- .parent = TYPE_VIRTIO_PCI, ++static const VirtioPCIDeviceTypeInfo virtio_9p_pci_info = { ++ .generic_name = TYPE_VIRTIO_9P_PCI, + .instance_size = sizeof(V9fsPCIState), + .instance_init = virtio_9p_pci_instance_init, + .class_init = virtio_9p_pci_class_init, +@@ -1877,9 +1876,6 @@ static void virtio_pci_reset(DeviceState *qdev) + static Property virtio_pci_properties[] = { + DEFINE_PROP_BIT("virtio-pci-bus-master-bug-migration", VirtIOPCIProxy, flags, + VIRTIO_PCI_FLAG_BUS_MASTER_BUG_MIGRATION_BIT, false), +- DEFINE_PROP_ON_OFF_AUTO("disable-legacy", VirtIOPCIProxy, disable_legacy, +- ON_OFF_AUTO_AUTO), +- DEFINE_PROP_BOOL("disable-modern", VirtIOPCIProxy, disable_modern, false), + DEFINE_PROP_BIT("migrate-extra", VirtIOPCIProxy, flags, + VIRTIO_PCI_FLAG_MIGRATE_EXTRA_BIT, true), + DEFINE_PROP_BIT("modern-pio-notify", VirtIOPCIProxy, flags, +@@ -1939,13 +1935,123 @@ static const TypeInfo virtio_pci_info = { + .class_init = virtio_pci_class_init, + .class_size = sizeof(VirtioPCIClass), + .abstract = true, +- .interfaces = (InterfaceInfo[]) { +- { INTERFACE_PCIE_DEVICE }, +- { INTERFACE_CONVENTIONAL_PCI_DEVICE }, +- { } +- }, + }; + ++static Property virtio_pci_generic_properties[] = { ++ DEFINE_PROP_ON_OFF_AUTO("disable-legacy", VirtIOPCIProxy, disable_legacy, ++ ON_OFF_AUTO_AUTO), ++ DEFINE_PROP_BOOL("disable-modern", VirtIOPCIProxy, disable_modern, false), ++ DEFINE_PROP_END_OF_LIST(), ++}; ++ ++static void virtio_pci_base_class_init(ObjectClass *klass, void *data) ++{ ++ const VirtioPCIDeviceTypeInfo *t = data; ++ if (t->class_init) { ++ t->class_init(klass, NULL); ++ } ++} ++ ++static void virtio_pci_generic_class_init(ObjectClass *klass, void *data) ++{ ++ DeviceClass *dc = DEVICE_CLASS(klass); ++ ++ dc->props = virtio_pci_generic_properties; ++} ++ ++/* Used when the generic type and the base type is the same */ ++static void virtio_pci_generic_base_class_init(ObjectClass *klass, void *data) ++{ ++ virtio_pci_base_class_init(klass, data); ++ virtio_pci_generic_class_init(klass, NULL); ++} ++ ++static void virtio_pci_transitional_instance_init(Object *obj) ++{ ++ VirtIOPCIProxy *proxy = VIRTIO_PCI(obj); ++ ++ proxy->disable_legacy = ON_OFF_AUTO_OFF; ++ proxy->disable_modern = false; ++} ++ ++static void virtio_pci_non_transitional_instance_init(Object *obj) ++{ ++ VirtIOPCIProxy *proxy = VIRTIO_PCI(obj); ++ ++ proxy->disable_legacy = ON_OFF_AUTO_ON; ++ proxy->disable_modern = false; ++} ++ ++void virtio_pci_types_register(const VirtioPCIDeviceTypeInfo *t) ++{ ++ TypeInfo base_type_info = { ++ .name = t->base_name, ++ .parent = t->parent ? t->parent : TYPE_VIRTIO_PCI, ++ .instance_size = t->instance_size, ++ .instance_init = t->instance_init, ++ .class_init = virtio_pci_base_class_init, ++ .class_data = (void *)t, ++ .abstract = true, ++ }; ++ TypeInfo generic_type_info = { ++ .name = t->generic_name, ++ .parent = base_type_info.name, ++ .class_init = virtio_pci_generic_class_init, ++ .interfaces = (InterfaceInfo[]) { ++ { INTERFACE_PCIE_DEVICE }, ++ { INTERFACE_CONVENTIONAL_PCI_DEVICE }, ++ { } ++ }, ++ }; ++ ++ if (!base_type_info.name) { ++ /* No base type -> register a single generic device type */ ++ base_type_info.name = t->generic_name; ++ base_type_info.class_init = virtio_pci_generic_base_class_init; ++ base_type_info.interfaces = generic_type_info.interfaces; ++ base_type_info.abstract = false; ++ generic_type_info.name = NULL; ++ assert(!t->non_transitional_name); ++ assert(!t->transitional_name); ++ } ++ ++ type_register(&base_type_info); ++ if (generic_type_info.name) { ++ type_register(&generic_type_info); ++ } ++ ++ if (t->non_transitional_name) { ++ const TypeInfo non_transitional_type_info = { ++ .name = t->non_transitional_name, ++ .parent = base_type_info.name, ++ .instance_init = virtio_pci_non_transitional_instance_init, ++ .interfaces = (InterfaceInfo[]) { ++ { INTERFACE_PCIE_DEVICE }, ++ { INTERFACE_CONVENTIONAL_PCI_DEVICE }, ++ { } ++ }, ++ }; ++ type_register(&non_transitional_type_info); ++ } ++ ++ if (t->transitional_name) { ++ const TypeInfo transitional_type_info = { ++ .name = t->transitional_name, ++ .parent = base_type_info.name, ++ .instance_init = virtio_pci_transitional_instance_init, ++ .interfaces = (InterfaceInfo[]) { ++ /* ++ * Transitional virtio devices work only as Conventional PCI ++ * devices because they require PIO ports. ++ */ ++ { INTERFACE_CONVENTIONAL_PCI_DEVICE }, ++ { } ++ }, ++ }; ++ type_register(&transitional_type_info); ++ } ++} ++ + /* virtio-blk-pci */ + + static Property virtio_blk_pci_properties[] = { +@@ -1995,9 +2101,8 @@ static void virtio_blk_pci_instance_init(Object *obj) + "bootindex", &error_abort); + } + +-static const TypeInfo virtio_blk_pci_info = { +- .name = TYPE_VIRTIO_BLK_PCI, +- .parent = TYPE_VIRTIO_PCI, ++static const VirtioPCIDeviceTypeInfo virtio_blk_pci_info = { ++ .generic_name = TYPE_VIRTIO_BLK_PCI, + .instance_size = sizeof(VirtIOBlkPCI), + .instance_init = virtio_blk_pci_instance_init, + .class_init = virtio_blk_pci_class_init, +@@ -2051,9 +2156,8 @@ static void vhost_user_blk_pci_instance_init(Object *obj) + "bootindex", &error_abort); + } + +-static const TypeInfo vhost_user_blk_pci_info = { +- .name = TYPE_VHOST_USER_BLK_PCI, +- .parent = TYPE_VIRTIO_PCI, ++static const VirtioPCIDeviceTypeInfo vhost_user_blk_pci_info = { ++ .generic_name = TYPE_VHOST_USER_BLK_PCI, + .instance_size = sizeof(VHostUserBlkPCI), + .instance_init = vhost_user_blk_pci_instance_init, + .class_init = vhost_user_blk_pci_class_init, +@@ -2119,9 +2223,8 @@ static void virtio_scsi_pci_instance_init(Object *obj) + TYPE_VIRTIO_SCSI); + } + +-static const TypeInfo virtio_scsi_pci_info = { +- .name = TYPE_VIRTIO_SCSI_PCI, +- .parent = TYPE_VIRTIO_PCI, ++static const VirtioPCIDeviceTypeInfo virtio_scsi_pci_info = { ++ .generic_name = TYPE_VIRTIO_SCSI_PCI, + .instance_size = sizeof(VirtIOSCSIPCI), + .instance_init = virtio_scsi_pci_instance_init, + .class_init = virtio_scsi_pci_class_init, +@@ -2174,9 +2277,8 @@ static void vhost_scsi_pci_instance_init(Object *obj) + "bootindex", &error_abort); + } + +-static const TypeInfo vhost_scsi_pci_info = { +- .name = TYPE_VHOST_SCSI_PCI, +- .parent = TYPE_VIRTIO_PCI, ++static const VirtioPCIDeviceTypeInfo vhost_scsi_pci_info = { ++ .generic_name = TYPE_VHOST_SCSI_PCI, + .instance_size = sizeof(VHostSCSIPCI), + .instance_init = vhost_scsi_pci_instance_init, + .class_init = vhost_scsi_pci_class_init, +@@ -2229,9 +2331,8 @@ static void vhost_user_scsi_pci_instance_init(Object *obj) + "bootindex", &error_abort); + } + +-static const TypeInfo vhost_user_scsi_pci_info = { +- .name = TYPE_VHOST_USER_SCSI_PCI, +- .parent = TYPE_VIRTIO_PCI, ++static const VirtioPCIDeviceTypeInfo vhost_user_scsi_pci_info = { ++ .generic_name = TYPE_VHOST_USER_SCSI_PCI, + .instance_size = sizeof(VHostUserSCSIPCI), + .instance_init = vhost_user_scsi_pci_instance_init, + .class_init = vhost_user_scsi_pci_class_init, +@@ -2277,9 +2378,8 @@ static void vhost_vsock_pci_instance_init(Object *obj) + TYPE_VHOST_VSOCK); + } + +-static const TypeInfo vhost_vsock_pci_info = { +- .name = TYPE_VHOST_VSOCK_PCI, +- .parent = TYPE_VIRTIO_PCI, ++static const VirtioPCIDeviceTypeInfo vhost_vsock_pci_info = { ++ .generic_name = TYPE_VHOST_VSOCK_PCI, + .instance_size = sizeof(VHostVSockPCI), + .instance_init = vhost_vsock_pci_instance_init, + .class_init = vhost_vsock_pci_class_init, +@@ -2334,9 +2434,8 @@ static void virtio_balloon_pci_instance_init(Object *obj) + "guest-stats-polling-interval", &error_abort); + } + +-static const TypeInfo virtio_balloon_pci_info = { +- .name = TYPE_VIRTIO_BALLOON_PCI, +- .parent = TYPE_VIRTIO_PCI, ++static const VirtioPCIDeviceTypeInfo virtio_balloon_pci_info = { ++ .generic_name = TYPE_VIRTIO_BALLOON_PCI, + .instance_size = sizeof(VirtIOBalloonPCI), + .instance_init = virtio_balloon_pci_instance_init, + .class_init = virtio_balloon_pci_class_init, +@@ -2407,9 +2506,8 @@ static void virtio_serial_pci_instance_init(Object *obj) + TYPE_VIRTIO_SERIAL); + } + +-static const TypeInfo virtio_serial_pci_info = { +- .name = TYPE_VIRTIO_SERIAL_PCI, +- .parent = TYPE_VIRTIO_PCI, ++static const VirtioPCIDeviceTypeInfo virtio_serial_pci_info = { ++ .generic_name = TYPE_VIRTIO_SERIAL_PCI, + .instance_size = sizeof(VirtIOSerialPCI), + .instance_init = virtio_serial_pci_instance_init, + .class_init = virtio_serial_pci_class_init, +@@ -2462,9 +2560,8 @@ static void virtio_net_pci_instance_init(Object *obj) + "bootindex", &error_abort); + } + +-static const TypeInfo virtio_net_pci_info = { +- .name = TYPE_VIRTIO_NET_PCI, +- .parent = TYPE_VIRTIO_PCI, ++static const VirtioPCIDeviceTypeInfo virtio_net_pci_info = { ++ .generic_name = TYPE_VIRTIO_NET_PCI, + .instance_size = sizeof(VirtIONetPCI), + .instance_init = virtio_net_pci_instance_init, + .class_init = virtio_net_pci_class_init, +@@ -2513,9 +2610,8 @@ static void virtio_rng_initfn(Object *obj) + TYPE_VIRTIO_RNG); + } + +-static const TypeInfo virtio_rng_pci_info = { +- .name = TYPE_VIRTIO_RNG_PCI, +- .parent = TYPE_VIRTIO_PCI, ++static const VirtioPCIDeviceTypeInfo virtio_rng_pci_info = { ++ .generic_name = TYPE_VIRTIO_RNG_PCI, + .instance_size = sizeof(VirtIORngPCI), + .instance_init = virtio_rng_initfn, + .class_init = virtio_rng_pci_class_init, +@@ -2605,24 +2701,24 @@ static const TypeInfo virtio_input_hid_pci_info = { + .abstract = true, + }; + +-static const TypeInfo virtio_keyboard_pci_info = { +- .name = TYPE_VIRTIO_KEYBOARD_PCI, ++static const VirtioPCIDeviceTypeInfo virtio_keyboard_pci_info = { ++ .generic_name = TYPE_VIRTIO_KEYBOARD_PCI, + .parent = TYPE_VIRTIO_INPUT_HID_PCI, + .class_init = virtio_input_hid_kbd_pci_class_init, + .instance_size = sizeof(VirtIOInputHIDPCI), + .instance_init = virtio_keyboard_initfn, + }; + +-static const TypeInfo virtio_mouse_pci_info = { +- .name = TYPE_VIRTIO_MOUSE_PCI, ++static const VirtioPCIDeviceTypeInfo virtio_mouse_pci_info = { ++ .generic_name = TYPE_VIRTIO_MOUSE_PCI, + .parent = TYPE_VIRTIO_INPUT_HID_PCI, + .class_init = virtio_input_hid_mouse_pci_class_init, + .instance_size = sizeof(VirtIOInputHIDPCI), + .instance_init = virtio_mouse_initfn, + }; + +-static const TypeInfo virtio_tablet_pci_info = { +- .name = TYPE_VIRTIO_TABLET_PCI, ++static const VirtioPCIDeviceTypeInfo virtio_tablet_pci_info = { ++ .generic_name = TYPE_VIRTIO_TABLET_PCI, + .parent = TYPE_VIRTIO_INPUT_HID_PCI, + .instance_size = sizeof(VirtIOInputHIDPCI), + .instance_init = virtio_tablet_initfn, +@@ -2637,8 +2733,8 @@ static void virtio_host_initfn(Object *obj) + TYPE_VIRTIO_INPUT_HOST); + } + +-static const TypeInfo virtio_host_pci_info = { +- .name = TYPE_VIRTIO_INPUT_HOST_PCI, ++static const VirtioPCIDeviceTypeInfo virtio_host_pci_info = { ++ .generic_name = TYPE_VIRTIO_INPUT_HOST_PCI, + .parent = TYPE_VIRTIO_INPUT_PCI, + .instance_size = sizeof(VirtIOInputHostPCI), + .instance_init = virtio_host_initfn, +@@ -2692,36 +2788,39 @@ static const TypeInfo virtio_pci_bus_info = { + + static void virtio_pci_register_types(void) + { +- type_register_static(&virtio_rng_pci_info); ++ /* Base types: */ ++ type_register_static(&virtio_pci_bus_info); ++ type_register_static(&virtio_pci_info); + type_register_static(&virtio_input_pci_info); + type_register_static(&virtio_input_hid_pci_info); +- type_register_static(&virtio_keyboard_pci_info); +- type_register_static(&virtio_mouse_pci_info); +- type_register_static(&virtio_tablet_pci_info); ++ ++ /* Implementations: */ ++ virtio_pci_types_register(&virtio_rng_pci_info); ++ virtio_pci_types_register(&virtio_keyboard_pci_info); ++ virtio_pci_types_register(&virtio_mouse_pci_info); ++ virtio_pci_types_register(&virtio_tablet_pci_info); + #ifdef CONFIG_LINUX +- type_register_static(&virtio_host_pci_info); ++ virtio_pci_types_register(&virtio_host_pci_info); + #endif +- type_register_static(&virtio_pci_bus_info); +- type_register_static(&virtio_pci_info); + #ifdef CONFIG_VIRTFS +- type_register_static(&virtio_9p_pci_info); ++ virtio_pci_types_register(&virtio_9p_pci_info); + #endif +- type_register_static(&virtio_blk_pci_info); ++ virtio_pci_types_register(&virtio_blk_pci_info); + #if defined(CONFIG_VHOST_USER_BLK) +- type_register_static(&vhost_user_blk_pci_info); ++ virtio_pci_types_register(&vhost_user_blk_pci_info); + #endif +- type_register_static(&virtio_scsi_pci_info); +- type_register_static(&virtio_balloon_pci_info); +- type_register_static(&virtio_serial_pci_info); +- type_register_static(&virtio_net_pci_info); ++ virtio_pci_types_register(&virtio_scsi_pci_info); ++ virtio_pci_types_register(&virtio_balloon_pci_info); ++ virtio_pci_types_register(&virtio_serial_pci_info); ++ virtio_pci_types_register(&virtio_net_pci_info); + #ifdef CONFIG_VHOST_SCSI +- type_register_static(&vhost_scsi_pci_info); ++ virtio_pci_types_register(&vhost_scsi_pci_info); + #endif + #if defined(CONFIG_VHOST_USER_SCSI) +- type_register_static(&vhost_user_scsi_pci_info); ++ virtio_pci_types_register(&vhost_user_scsi_pci_info); + #endif + #ifdef CONFIG_VHOST_VSOCK +- type_register_static(&vhost_vsock_pci_info); ++ virtio_pci_types_register(&vhost_vsock_pci_info); + #endif + } + +diff --git a/hw/virtio/virtio-pci.h b/hw/virtio/virtio-pci.h +index 813082b..8cd5466 100644 +--- a/hw/virtio/virtio-pci.h ++++ b/hw/virtio/virtio-pci.h +@@ -417,4 +417,58 @@ struct VirtIOCryptoPCI { + /* Virtio ABI version, if we increment this, we break the guest driver. */ + #define VIRTIO_PCI_ABI_VERSION 0 + ++/* Input for virtio_pci_types_register() */ ++typedef struct VirtioPCIDeviceTypeInfo { ++ /* ++ * Common base class for the subclasses below. ++ * ++ * Required only if transitional_name or non_transitional_name is set. ++ * ++ * We need a separate base type instead of making all types ++ * inherit from generic_name for two reasons: ++ * 1) generic_name implements INTERFACE_PCIE_DEVICE, but ++ * transitional_name does not. ++ * 2) generic_name has the "disable-legacy" and "disable-modern" ++ * properties, transitional_name and non_transitional name don't. ++ */ ++ const char *base_name; ++ /* ++ * Generic device type. Optional. ++ * ++ * Supports both transitional and non-transitional modes, ++ * using the disable-legacy and disable-modern properties. ++ * If disable-legacy=auto, (non-)transitional mode is selected ++ * depending on the bus where the device is plugged. ++ * ++ * Implements both INTERFACE_PCIE_DEVICE and INTERFACE_CONVENTIONAL_PCI_DEVICE, ++ * but PCI Express is supported only in non-transitional mode. ++ * ++ * The only type implemented by QEMU 3.1 and older. ++ */ ++ const char *generic_name; ++ /* ++ * The transitional device type. Optional. ++ * ++ * Implements both INTERFACE_PCIE_DEVICE and INTERFACE_CONVENTIONAL_PCI_DEVICE. ++ */ ++ const char *transitional_name; ++ /* ++ * The non-transitional device type. Optional. ++ * ++ * Implements INTERFACE_CONVENTIONAL_PCI_DEVICE only. ++ */ ++ const char *non_transitional_name; ++ ++ /* Parent type. If NULL, TYPE_VIRTIO_PCI is used */ ++ const char *parent; ++ ++ /* Same as TypeInfo fields: */ ++ size_t instance_size; ++ void (*instance_init)(Object *obj); ++ void (*class_init)(ObjectClass *klass, void *data); ++} VirtioPCIDeviceTypeInfo; ++ ++/* Register virtio-pci type(s). @t must be static. */ ++void virtio_pci_types_register(const VirtioPCIDeviceTypeInfo *t); ++ + #endif +-- +1.8.3.1 + diff --git a/kvm-virtio-Make-disable-legacy-disable-modern-compat-pro.patch b/kvm-virtio-Make-disable-legacy-disable-modern-compat-pro.patch new file mode 100644 index 0000000..c17fc0f --- /dev/null +++ b/kvm-virtio-Make-disable-legacy-disable-modern-compat-pro.patch @@ -0,0 +1,73 @@ +From cbac773c0218dc23f2c434f2d04e3e3cc1d081a9 Mon Sep 17 00:00:00 2001 +From: Eduardo Habkost +Date: Wed, 16 Jan 2019 23:18:19 +0000 +Subject: [PATCH 4/7] virtio: Make disable-legacy/disable-modern compat + properties optional + +RH-Author: Eduardo Habkost +Message-id: <20190116231819.29310-5-ehabkost@redhat.com> +Patchwork-id: 84030 +O-Subject: [RHEL-8.0/AV qemu-kvm PATCH 4/4] virtio: Make disable-legacy/disable-modern compat properties optional +Bugzilla: 1648023 +RH-Acked-by: Cornelia Huck +RH-Acked-by: Thomas Huth +RH-Acked-by: Laurent Vivier +RH-Acked-by: Michael S. Tsirkin + +Upstream tree: git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git +Upstream commit: 53921bfdce3f8fffcc22338633855247fb7b7a74 + +The disable-legacy and disable-modern properties apply only to +some virtio-pci devices. Make those properties optional. + +This fixes the crash introduced by commit f6e501a28ef9 ("virtio: Provide +version-specific variants of virtio PCI devices"): + + $ qemu-system-x86_64 -machine pc-i440fx-2.6 \ + -device virtio-net-pci-non-transitional + Unexpected error in object_property_find() at qom/object.c:1092: + qemu-system-x86_64: -device virtio-net-pci-non-transitional: can't apply \ + global virtio-pci.disable-modern=on: Property '.disable-modern' not found + Aborted (core dumped) + +Backport notes: + HW_COMPAT_RHEL7_2 (include/hw/compat.h) being patched instead + of hw_compat_2_6 (hw/core/machine.c). Our downstream tree + doesn't have the equivalent of commit ff8f261f113b ("compat: + replace PC_COMPAT_2_6 & HW_COMPAT_2_6 macros") + +Reported-by: Thomas Huth +Fixes: f6e501a28ef9 ("virtio: Provide version-specific variants of virtio PCI devices") +Signed-off-by: Eduardo Habkost +Reviewed-by: Cornelia Huck +Reviewed-by: Michael S. Tsirkin +Signed-off-by: Michael S. Tsirkin +(cherry picked from commit 1b0ba10643110f9590c0da0167d0cb1db48ca2e4) +Signed-off-by: Eduardo Habkost +Signed-off-by: Danilo C. L. de Paula +--- + include/hw/compat.h | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/include/hw/compat.h b/include/hw/compat.h +index 40db243..aeb2f73 100644 +--- a/include/hw/compat.h ++++ b/include/hw/compat.h +@@ -380,10 +380,14 @@ + .driver = "virtio-pci",\ + .property = "disable-modern",\ + .value = "on",\ ++ /* Optional because not all virtio-pci devices support legacy mode */ \ ++ .optional = true,\ + },{ /* HW_COMPAT_RHEL7_2 */ \ + .driver = "virtio-pci",\ + .property = "disable-legacy",\ + .value = "off",\ ++ /* Optional because not all virtio-pci devices support legacy mode */ \ ++ .optional = true,\ + },{ /* HW_COMPAT_RHEL7_2 */ \ + .driver = TYPE_PCI_DEVICE,\ + .property = "x-pcie-lnksta-dllla",\ +-- +1.8.3.1 + diff --git a/kvm-virtio-Provide-version-specific-variants-of-virtio-P.patch b/kvm-virtio-Provide-version-specific-variants-of-virtio-P.patch new file mode 100644 index 0000000..c093144 --- /dev/null +++ b/kvm-virtio-Provide-version-specific-variants-of-virtio-P.patch @@ -0,0 +1,519 @@ +From 14004eb28d1e573365ed21ed09afad85d239c769 Mon Sep 17 00:00:00 2001 +From: Eduardo Habkost +Date: Wed, 16 Jan 2019 23:18:17 +0000 +Subject: [PATCH 2/7] virtio: Provide version-specific variants of virtio PCI + devices + +RH-Author: Eduardo Habkost +Message-id: <20190116231819.29310-3-ehabkost@redhat.com> +Patchwork-id: 84028 +O-Subject: [RHEL-8.0/AV qemu-kvm PATCH 2/4] virtio: Provide version-specific variants of virtio PCI devices +Bugzilla: 1648023 +RH-Acked-by: Cornelia Huck +RH-Acked-by: Thomas Huth +RH-Acked-by: Laurent Vivier +RH-Acked-by: Michael S. Tsirkin + +Many of the current virtio-*-pci device types actually represent +3 different types of devices: +* virtio 1.0 non-transitional devices +* virtio 1.0 transitional devices +* virtio 0.9 ("legacy device" in virtio 1.0 terminology) + +That would be just an annoyance if it didn't break our device/bus +compatibility QMP interfaces. With these multi-purpose device +types, there's no way to tell management software that +transitional devices and legacy devices require a Conventional +PCI bus. + +The multi-purpose device types would also prevent us from telling +management software what's the PCI vendor/device ID for them, +because their PCI IDs change at runtime depending on the bus +where they were plugged. + +This patch adds separate device types for each of those virtio +device flavors: + +- virtio-*-pci: the existing multi-purpose device types + - Configurable using `disable-legacy` and `disable-modern` + properties + - Legacy driver support is automatically enabled/disabled + depending on the bus where it is plugged + - Supports Conventional PCI and PCI Express buses + (but Conventional PCI is incompatible with + disable-legacy=off) + - Changes PCI vendor/device IDs at runtime +- virtio-*-pci-transitional: virtio-1.0 device supporting legacy drivers + - Supports Conventional PCI buses only, because + it has a PIO BAR +- virtio-*-pci-non-transitional: modern-only + - Supports both Conventional PCI and PCI Express buses + +The existing TYPE_* macros for these types will point to an +abstract base type, so existing casts in the code will keep +working for all variants. + +A simple test script (tests/acceptance/virtio_version.py) is +included, to check if the new device types are equivalent to +using the `disable-legacy` and `disable-modern` options. + +Acked-by: Andrea Bolognani +Reviewed-by: Cornelia Huck +Signed-off-by: Eduardo Habkost +Reviewed-by: Michael S. Tsirkin +Signed-off-by: Michael S. Tsirkin +(cherry picked from commit f6e501a28ef9b69f6df6252160aa87876cc92a1a) +Signed-off-by: Eduardo Habkost +Signed-off-by: Danilo C. L. de Paula +--- + hw/virtio/virtio-pci.c | 60 ++++++++++--- + hw/virtio/virtio-pci.h | 24 ++--- + tests/acceptance/virtio_version.py | 176 +++++++++++++++++++++++++++++++++++++ + 3 files changed, 236 insertions(+), 24 deletions(-) + create mode 100644 tests/acceptance/virtio_version.py + +diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c +index bee3509..68cffcd 100644 +--- a/hw/virtio/virtio-pci.c ++++ b/hw/virtio/virtio-pci.c +@@ -1120,7 +1120,10 @@ static void virtio_9p_pci_instance_init(Object *obj) + } + + static const VirtioPCIDeviceTypeInfo virtio_9p_pci_info = { +- .generic_name = TYPE_VIRTIO_9P_PCI, ++ .base_name = TYPE_VIRTIO_9P_PCI, ++ .generic_name = "virtio-9p-pci", ++ .transitional_name = "virtio-9p-pci-transitional", ++ .non_transitional_name = "virtio-9p-pci-non-transitional", + .instance_size = sizeof(V9fsPCIState), + .instance_init = virtio_9p_pci_instance_init, + .class_init = virtio_9p_pci_class_init, +@@ -2102,7 +2105,10 @@ static void virtio_blk_pci_instance_init(Object *obj) + } + + static const VirtioPCIDeviceTypeInfo virtio_blk_pci_info = { +- .generic_name = TYPE_VIRTIO_BLK_PCI, ++ .base_name = TYPE_VIRTIO_BLK_PCI, ++ .generic_name = "virtio-blk-pci", ++ .transitional_name = "virtio-blk-pci-transitional", ++ .non_transitional_name = "virtio-blk-pci-non-transitional", + .instance_size = sizeof(VirtIOBlkPCI), + .instance_init = virtio_blk_pci_instance_init, + .class_init = virtio_blk_pci_class_init, +@@ -2157,7 +2163,10 @@ static void vhost_user_blk_pci_instance_init(Object *obj) + } + + static const VirtioPCIDeviceTypeInfo vhost_user_blk_pci_info = { +- .generic_name = TYPE_VHOST_USER_BLK_PCI, ++ .base_name = TYPE_VHOST_USER_BLK_PCI, ++ .generic_name = "vhost-user-blk-pci", ++ .transitional_name = "vhost-user-blk-pci-transitional", ++ .non_transitional_name = "vhost-user-blk-pci-non-transitional", + .instance_size = sizeof(VHostUserBlkPCI), + .instance_init = vhost_user_blk_pci_instance_init, + .class_init = vhost_user_blk_pci_class_init, +@@ -2224,7 +2233,10 @@ static void virtio_scsi_pci_instance_init(Object *obj) + } + + static const VirtioPCIDeviceTypeInfo virtio_scsi_pci_info = { +- .generic_name = TYPE_VIRTIO_SCSI_PCI, ++ .base_name = TYPE_VIRTIO_SCSI_PCI, ++ .generic_name = "virtio-scsi-pci", ++ .transitional_name = "virtio-scsi-pci-transitional", ++ .non_transitional_name = "virtio-scsi-pci-non-transitional", + .instance_size = sizeof(VirtIOSCSIPCI), + .instance_init = virtio_scsi_pci_instance_init, + .class_init = virtio_scsi_pci_class_init, +@@ -2278,7 +2290,10 @@ static void vhost_scsi_pci_instance_init(Object *obj) + } + + static const VirtioPCIDeviceTypeInfo vhost_scsi_pci_info = { +- .generic_name = TYPE_VHOST_SCSI_PCI, ++ .base_name = TYPE_VHOST_SCSI_PCI, ++ .generic_name = "vhost-scsi-pci", ++ .transitional_name = "vhost-scsi-pci-transitional", ++ .non_transitional_name = "vhost-scsi-pci-non-transitional", + .instance_size = sizeof(VHostSCSIPCI), + .instance_init = vhost_scsi_pci_instance_init, + .class_init = vhost_scsi_pci_class_init, +@@ -2332,7 +2347,10 @@ static void vhost_user_scsi_pci_instance_init(Object *obj) + } + + static const VirtioPCIDeviceTypeInfo vhost_user_scsi_pci_info = { +- .generic_name = TYPE_VHOST_USER_SCSI_PCI, ++ .base_name = TYPE_VHOST_USER_SCSI_PCI, ++ .generic_name = "vhost-user-scsi-pci", ++ .transitional_name = "vhost-user-scsi-pci-transitional", ++ .non_transitional_name = "vhost-user-scsi-pci-non-transitional", + .instance_size = sizeof(VHostUserSCSIPCI), + .instance_init = vhost_user_scsi_pci_instance_init, + .class_init = vhost_user_scsi_pci_class_init, +@@ -2379,7 +2397,10 @@ static void vhost_vsock_pci_instance_init(Object *obj) + } + + static const VirtioPCIDeviceTypeInfo vhost_vsock_pci_info = { +- .generic_name = TYPE_VHOST_VSOCK_PCI, ++ .base_name = TYPE_VHOST_VSOCK_PCI, ++ .generic_name = "vhost-vsock-pci", ++ .transitional_name = "vhost-vsock-pci-transitional", ++ .non_transitional_name = "vhost-vsock-pci-non-transitional", + .instance_size = sizeof(VHostVSockPCI), + .instance_init = vhost_vsock_pci_instance_init, + .class_init = vhost_vsock_pci_class_init, +@@ -2435,7 +2456,10 @@ static void virtio_balloon_pci_instance_init(Object *obj) + } + + static const VirtioPCIDeviceTypeInfo virtio_balloon_pci_info = { +- .generic_name = TYPE_VIRTIO_BALLOON_PCI, ++ .base_name = TYPE_VIRTIO_BALLOON_PCI, ++ .generic_name = "virtio-balloon-pci", ++ .transitional_name = "virtio-balloon-pci-transitional", ++ .non_transitional_name = "virtio-balloon-pci-non-transitional", + .instance_size = sizeof(VirtIOBalloonPCI), + .instance_init = virtio_balloon_pci_instance_init, + .class_init = virtio_balloon_pci_class_init, +@@ -2507,7 +2531,10 @@ static void virtio_serial_pci_instance_init(Object *obj) + } + + static const VirtioPCIDeviceTypeInfo virtio_serial_pci_info = { +- .generic_name = TYPE_VIRTIO_SERIAL_PCI, ++ .base_name = TYPE_VIRTIO_SERIAL_PCI, ++ .generic_name = "virtio-serial-pci", ++ .transitional_name = "virtio-serial-pci-transitional", ++ .non_transitional_name = "virtio-serial-pci-non-transitional", + .instance_size = sizeof(VirtIOSerialPCI), + .instance_init = virtio_serial_pci_instance_init, + .class_init = virtio_serial_pci_class_init, +@@ -2561,7 +2588,10 @@ static void virtio_net_pci_instance_init(Object *obj) + } + + static const VirtioPCIDeviceTypeInfo virtio_net_pci_info = { +- .generic_name = TYPE_VIRTIO_NET_PCI, ++ .base_name = TYPE_VIRTIO_NET_PCI, ++ .generic_name = "virtio-net-pci", ++ .transitional_name = "virtio-net-pci-transitional", ++ .non_transitional_name = "virtio-net-pci-non-transitional", + .instance_size = sizeof(VirtIONetPCI), + .instance_init = virtio_net_pci_instance_init, + .class_init = virtio_net_pci_class_init, +@@ -2611,7 +2641,10 @@ static void virtio_rng_initfn(Object *obj) + } + + static const VirtioPCIDeviceTypeInfo virtio_rng_pci_info = { +- .generic_name = TYPE_VIRTIO_RNG_PCI, ++ .base_name = TYPE_VIRTIO_RNG_PCI, ++ .generic_name = "virtio-rng-pci", ++ .transitional_name = "virtio-rng-pci-transitional", ++ .non_transitional_name = "virtio-rng-pci-non-transitional", + .instance_size = sizeof(VirtIORngPCI), + .instance_init = virtio_rng_initfn, + .class_init = virtio_rng_pci_class_init, +@@ -2734,7 +2767,10 @@ static void virtio_host_initfn(Object *obj) + } + + static const VirtioPCIDeviceTypeInfo virtio_host_pci_info = { +- .generic_name = TYPE_VIRTIO_INPUT_HOST_PCI, ++ .base_name = TYPE_VIRTIO_INPUT_HOST_PCI, ++ .generic_name = "virtio-input-host-pci", ++ .transitional_name = "virtio-input-host-pci-transitional", ++ .non_transitional_name = "virtio-input-host-pci-non-transitional", + .parent = TYPE_VIRTIO_INPUT_PCI, + .instance_size = sizeof(VirtIOInputHostPCI), + .instance_init = virtio_host_initfn, +diff --git a/hw/virtio/virtio-pci.h b/hw/virtio/virtio-pci.h +index 8cd5466..29b4216 100644 +--- a/hw/virtio/virtio-pci.h ++++ b/hw/virtio/virtio-pci.h +@@ -216,7 +216,7 @@ static inline void virtio_pci_disable_modern(VirtIOPCIProxy *proxy) + /* + * virtio-scsi-pci: This extends VirtioPCIProxy. + */ +-#define TYPE_VIRTIO_SCSI_PCI "virtio-scsi-pci" ++#define TYPE_VIRTIO_SCSI_PCI "virtio-scsi-pci-base" + #define VIRTIO_SCSI_PCI(obj) \ + OBJECT_CHECK(VirtIOSCSIPCI, (obj), TYPE_VIRTIO_SCSI_PCI) + +@@ -229,7 +229,7 @@ struct VirtIOSCSIPCI { + /* + * vhost-scsi-pci: This extends VirtioPCIProxy. + */ +-#define TYPE_VHOST_SCSI_PCI "vhost-scsi-pci" ++#define TYPE_VHOST_SCSI_PCI "vhost-scsi-pci-base" + #define VHOST_SCSI_PCI(obj) \ + OBJECT_CHECK(VHostSCSIPCI, (obj), TYPE_VHOST_SCSI_PCI) + +@@ -239,7 +239,7 @@ struct VHostSCSIPCI { + }; + #endif + +-#define TYPE_VHOST_USER_SCSI_PCI "vhost-user-scsi-pci" ++#define TYPE_VHOST_USER_SCSI_PCI "vhost-user-scsi-pci-base" + #define VHOST_USER_SCSI_PCI(obj) \ + OBJECT_CHECK(VHostUserSCSIPCI, (obj), TYPE_VHOST_USER_SCSI_PCI) + +@@ -252,7 +252,7 @@ struct VHostUserSCSIPCI { + /* + * vhost-user-blk-pci: This extends VirtioPCIProxy. + */ +-#define TYPE_VHOST_USER_BLK_PCI "vhost-user-blk-pci" ++#define TYPE_VHOST_USER_BLK_PCI "vhost-user-blk-pci-base" + #define VHOST_USER_BLK_PCI(obj) \ + OBJECT_CHECK(VHostUserBlkPCI, (obj), TYPE_VHOST_USER_BLK_PCI) + +@@ -265,7 +265,7 @@ struct VHostUserBlkPCI { + /* + * virtio-blk-pci: This extends VirtioPCIProxy. + */ +-#define TYPE_VIRTIO_BLK_PCI "virtio-blk-pci" ++#define TYPE_VIRTIO_BLK_PCI "virtio-blk-pci-base" + #define VIRTIO_BLK_PCI(obj) \ + OBJECT_CHECK(VirtIOBlkPCI, (obj), TYPE_VIRTIO_BLK_PCI) + +@@ -277,7 +277,7 @@ struct VirtIOBlkPCI { + /* + * virtio-balloon-pci: This extends VirtioPCIProxy. + */ +-#define TYPE_VIRTIO_BALLOON_PCI "virtio-balloon-pci" ++#define TYPE_VIRTIO_BALLOON_PCI "virtio-balloon-pci-base" + #define VIRTIO_BALLOON_PCI(obj) \ + OBJECT_CHECK(VirtIOBalloonPCI, (obj), TYPE_VIRTIO_BALLOON_PCI) + +@@ -289,7 +289,7 @@ struct VirtIOBalloonPCI { + /* + * virtio-serial-pci: This extends VirtioPCIProxy. + */ +-#define TYPE_VIRTIO_SERIAL_PCI "virtio-serial-pci" ++#define TYPE_VIRTIO_SERIAL_PCI "virtio-serial-pci-base" + #define VIRTIO_SERIAL_PCI(obj) \ + OBJECT_CHECK(VirtIOSerialPCI, (obj), TYPE_VIRTIO_SERIAL_PCI) + +@@ -301,7 +301,7 @@ struct VirtIOSerialPCI { + /* + * virtio-net-pci: This extends VirtioPCIProxy. + */ +-#define TYPE_VIRTIO_NET_PCI "virtio-net-pci" ++#define TYPE_VIRTIO_NET_PCI "virtio-net-pci-base" + #define VIRTIO_NET_PCI(obj) \ + OBJECT_CHECK(VirtIONetPCI, (obj), TYPE_VIRTIO_NET_PCI) + +@@ -316,7 +316,7 @@ struct VirtIONetPCI { + + #ifdef CONFIG_VIRTFS + +-#define TYPE_VIRTIO_9P_PCI "virtio-9p-pci" ++#define TYPE_VIRTIO_9P_PCI "virtio-9p-pci-base" + #define VIRTIO_9P_PCI(obj) \ + OBJECT_CHECK(V9fsPCIState, (obj), TYPE_VIRTIO_9P_PCI) + +@@ -330,7 +330,7 @@ typedef struct V9fsPCIState { + /* + * virtio-rng-pci: This extends VirtioPCIProxy. + */ +-#define TYPE_VIRTIO_RNG_PCI "virtio-rng-pci" ++#define TYPE_VIRTIO_RNG_PCI "virtio-rng-pci-base" + #define VIRTIO_RNG_PCI(obj) \ + OBJECT_CHECK(VirtIORngPCI, (obj), TYPE_VIRTIO_RNG_PCI) + +@@ -365,7 +365,7 @@ struct VirtIOInputHIDPCI { + + #ifdef CONFIG_LINUX + +-#define TYPE_VIRTIO_INPUT_HOST_PCI "virtio-input-host-pci" ++#define TYPE_VIRTIO_INPUT_HOST_PCI "virtio-input-host-pci-base" + #define VIRTIO_INPUT_HOST_PCI(obj) \ + OBJECT_CHECK(VirtIOInputHostPCI, (obj), TYPE_VIRTIO_INPUT_HOST_PCI) + +@@ -392,7 +392,7 @@ struct VirtIOGPUPCI { + /* + * vhost-vsock-pci: This extends VirtioPCIProxy. + */ +-#define TYPE_VHOST_VSOCK_PCI "vhost-vsock-pci" ++#define TYPE_VHOST_VSOCK_PCI "vhost-vsock-pci-base" + #define VHOST_VSOCK_PCI(obj) \ + OBJECT_CHECK(VHostVSockPCI, (obj), TYPE_VHOST_VSOCK_PCI) + +diff --git a/tests/acceptance/virtio_version.py b/tests/acceptance/virtio_version.py +new file mode 100644 +index 0000000..ce99025 +--- /dev/null ++++ b/tests/acceptance/virtio_version.py +@@ -0,0 +1,176 @@ ++""" ++Check compatibility of virtio device types ++""" ++# Copyright (c) 2018 Red Hat, Inc. ++# ++# Author: ++# Eduardo Habkost ++# ++# This work is licensed under the terms of the GNU GPL, version 2 or ++# later. See the COPYING file in the top-level directory. ++import sys ++import os ++ ++sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..", "scripts")) ++from qemu import QEMUMachine ++from avocado_qemu import Test ++ ++# Virtio Device IDs: ++VIRTIO_NET = 1 ++VIRTIO_BLOCK = 2 ++VIRTIO_CONSOLE = 3 ++VIRTIO_RNG = 4 ++VIRTIO_BALLOON = 5 ++VIRTIO_RPMSG = 7 ++VIRTIO_SCSI = 8 ++VIRTIO_9P = 9 ++VIRTIO_RPROC_SERIAL = 11 ++VIRTIO_CAIF = 12 ++VIRTIO_GPU = 16 ++VIRTIO_INPUT = 18 ++VIRTIO_VSOCK = 19 ++VIRTIO_CRYPTO = 20 ++ ++PCI_VENDOR_ID_REDHAT_QUMRANET = 0x1af4 ++ ++# Device IDs for legacy/transitional devices: ++PCI_LEGACY_DEVICE_IDS = { ++ VIRTIO_NET: 0x1000, ++ VIRTIO_BLOCK: 0x1001, ++ VIRTIO_BALLOON: 0x1002, ++ VIRTIO_CONSOLE: 0x1003, ++ VIRTIO_SCSI: 0x1004, ++ VIRTIO_RNG: 0x1005, ++ VIRTIO_9P: 0x1009, ++ VIRTIO_VSOCK: 0x1012, ++} ++ ++def pci_modern_device_id(virtio_devid): ++ return virtio_devid + 0x1040 ++ ++def devtype_implements(vm, devtype, implements): ++ return devtype in [d['name'] for d in vm.command('qom-list-types', implements=implements)] ++ ++def get_pci_interfaces(vm, devtype): ++ interfaces = ('pci-express-device', 'conventional-pci-device') ++ return [i for i in interfaces if devtype_implements(vm, devtype, i)] ++ ++class VirtioVersionCheck(Test): ++ """ ++ Check if virtio-version-specific device types result in the ++ same device tree created by `disable-modern` and ++ `disable-legacy`. ++ ++ :avocado: enable ++ :avocado: tags=x86_64 ++ """ ++ ++ # just in case there are failures, show larger diff: ++ maxDiff = 4096 ++ ++ def run_device(self, devtype, opts=None, machine='pc'): ++ """ ++ Run QEMU with `-device DEVTYPE`, return device info from `query-pci` ++ """ ++ with QEMUMachine(self.qemu_bin) as vm: ++ vm.set_machine(machine) ++ if opts: ++ devtype += ',' + opts ++ vm.add_args('-device', '%s,id=devfortest' % (devtype)) ++ vm.add_args('-S') ++ vm.launch() ++ ++ pcibuses = vm.command('query-pci') ++ alldevs = [dev for bus in pcibuses for dev in bus['devices']] ++ devfortest = [dev for dev in alldevs ++ if dev['qdev_id'] == 'devfortest'] ++ return devfortest[0], get_pci_interfaces(vm, devtype) ++ ++ ++ def assert_devids(self, dev, devid, non_transitional=False): ++ self.assertEqual(dev['id']['vendor'], PCI_VENDOR_ID_REDHAT_QUMRANET) ++ self.assertEqual(dev['id']['device'], devid) ++ if non_transitional: ++ self.assertTrue(0x1040 <= dev['id']['device'] <= 0x107f) ++ self.assertGreaterEqual(dev['id']['subsystem'], 0x40) ++ ++ def check_all_variants(self, qemu_devtype, virtio_devid): ++ """Check if a virtio device type and its variants behave as expected""" ++ # Force modern mode: ++ dev_modern, _ = self.run_device(qemu_devtype, ++ 'disable-modern=off,disable-legacy=on') ++ self.assert_devids(dev_modern, pci_modern_device_id(virtio_devid), ++ non_transitional=True) ++ ++ # -non-transitional device types should be 100% equivalent to ++ # ,disable-modern=off,disable-legacy=on ++ dev_1_0, nt_ifaces = self.run_device('%s-non-transitional' % (qemu_devtype)) ++ self.assertEqual(dev_modern, dev_1_0) ++ ++ # Force transitional mode: ++ dev_trans, _ = self.run_device(qemu_devtype, ++ 'disable-modern=off,disable-legacy=off') ++ self.assert_devids(dev_trans, PCI_LEGACY_DEVICE_IDS[virtio_devid]) ++ ++ # Force legacy mode: ++ dev_legacy, _ = self.run_device(qemu_devtype, ++ 'disable-modern=on,disable-legacy=off') ++ self.assert_devids(dev_legacy, PCI_LEGACY_DEVICE_IDS[virtio_devid]) ++ ++ # No options: default to transitional on PC machine-type: ++ no_opts_pc, generic_ifaces = self.run_device(qemu_devtype) ++ self.assertEqual(dev_trans, no_opts_pc) ++ ++ #TODO: check if plugging on a PCI Express bus will make the ++ # device non-transitional ++ #no_opts_q35 = self.run_device(qemu_devtype, machine='q35') ++ #self.assertEqual(dev_modern, no_opts_q35) ++ ++ # -transitional device types should be 100% equivalent to ++ # ,disable-modern=off,disable-legacy=off ++ dev_trans, trans_ifaces = self.run_device('%s-transitional' % (qemu_devtype)) ++ self.assertEqual(dev_trans, dev_trans) ++ ++ # ensure the interface information is correct: ++ self.assertIn('conventional-pci-device', generic_ifaces) ++ self.assertIn('pci-express-device', generic_ifaces) ++ ++ self.assertIn('conventional-pci-device', nt_ifaces) ++ self.assertIn('pci-express-device', nt_ifaces) ++ ++ self.assertIn('conventional-pci-device', trans_ifaces) ++ self.assertNotIn('pci-express-device', trans_ifaces) ++ ++ ++ def test_conventional_devs(self): ++ self.check_all_variants('virtio-net-pci', VIRTIO_NET) ++ # virtio-blk requires 'driver' parameter ++ #self.check_all_variants('virtio-blk-pci', VIRTIO_BLOCK) ++ self.check_all_variants('virtio-serial-pci', VIRTIO_CONSOLE) ++ self.check_all_variants('virtio-rng-pci', VIRTIO_RNG) ++ self.check_all_variants('virtio-balloon-pci', VIRTIO_BALLOON) ++ self.check_all_variants('virtio-scsi-pci', VIRTIO_SCSI) ++ # virtio-9p requires 'fsdev' parameter ++ #self.check_all_variants('virtio-9p-pci', VIRTIO_9P) ++ ++ def check_modern_only(self, qemu_devtype, virtio_devid): ++ """Check if a modern-only virtio device type behaves as expected""" ++ # Force modern mode: ++ dev_modern, _ = self.run_device(qemu_devtype, ++ 'disable-modern=off,disable-legacy=on') ++ self.assert_devids(dev_modern, pci_modern_device_id(virtio_devid), ++ non_transitional=True) ++ ++ # No options: should be modern anyway ++ dev_no_opts, ifaces = self.run_device(qemu_devtype) ++ self.assertEqual(dev_modern, dev_no_opts) ++ ++ self.assertIn('conventional-pci-device', ifaces) ++ self.assertIn('pci-express-device', ifaces) ++ ++ def test_modern_only_devs(self): ++ self.check_modern_only('virtio-vga', VIRTIO_GPU) ++ self.check_modern_only('virtio-gpu-pci', VIRTIO_GPU) ++ self.check_modern_only('virtio-mouse-pci', VIRTIO_INPUT) ++ self.check_modern_only('virtio-tablet-pci', VIRTIO_INPUT) ++ self.check_modern_only('virtio-keyboard-pci', VIRTIO_INPUT) +-- +1.8.3.1 + diff --git a/qemu-kvm.spec b/qemu-kvm.spec index cdc387b..f285fc6 100644 --- a/qemu-kvm.spec +++ b/qemu-kvm.spec @@ -68,7 +68,7 @@ Obsoletes: %1-rhev Summary: QEMU is a machine emulator and virtualizer Name: qemu-kvm Version: 3.1.0 -Release: 4%{?dist} +Release: 5%{?dist} # Epoch because we pushed a qemu-1.0 package. AIUI this can't ever be dropped Epoch: 15 License: GPLv2 and GPLv2+ and CC-BY @@ -140,6 +140,20 @@ Patch27: kvm-redhat-define-pseries-rhel8.0.0-machine-type.patch Patch28: kvm-hw-s390x-s390-virtio-ccw-Add-machine-types-for-RHEL8.patch # For bz#1661967 - Kernel prints the message "VPHN is not supported. Disabling polling..." Patch29: kvm-spapr-Add-H-Call-H_HOME_NODE_ASSOCIATIVITY.patch +# For bz#1648023 - Provide separate device types for transitional virtio PCI devices - Fast Train +Patch30: kvm-virtio-Helper-for-registering-virtio-device-types.patch +# For bz#1648023 - Provide separate device types for transitional virtio PCI devices - Fast Train +Patch31: kvm-virtio-Provide-version-specific-variants-of-virtio-P.patch +# For bz#1648023 - Provide separate device types for transitional virtio PCI devices - Fast Train +Patch32: kvm-globals-Allow-global-properties-to-be-optional.patch +# For bz#1648023 - Provide separate device types for transitional virtio PCI devices - Fast Train +Patch33: kvm-virtio-Make-disable-legacy-disable-modern-compat-pro.patch +# For bz#1656504 - Machine types for qemu-kvm based on rebase to qemu-3.1 (aarch64) +Patch34: kvm-aarch64-Add-virt-rhel8.0.0-machine-type-for-ARM.patch +# For bz#1656504 - Machine types for qemu-kvm based on rebase to qemu-3.1 (aarch64) +Patch35: kvm-aarch64-Set-virt-rhel8.0.0-max_cpus-to-512.patch +# For bz#1656504 - Machine types for qemu-kvm based on rebase to qemu-3.1 (aarch64) +Patch36: kvm-aarch64-Use-256MB-ECAM-region-by-default.patch BuildRequires: zlib-devel BuildRequires: glib2-devel @@ -987,6 +1001,19 @@ useradd -r -u 107 -g qemu -G kvm -d / -s /sbin/nologin \ %changelog +* Mon Jan 21 2019 Danilo Cesar Lemes de Paula - 3.1.0-5.el8 +- kvm-virtio-Helper-for-registering-virtio-device-types.patch [bz#1648023] +- kvm-virtio-Provide-version-specific-variants-of-virtio-P.patch [bz#1648023] +- kvm-globals-Allow-global-properties-to-be-optional.patch [bz#1648023] +- kvm-virtio-Make-disable-legacy-disable-modern-compat-pro.patch [bz#1648023] +- kvm-aarch64-Add-virt-rhel8.0.0-machine-type-for-ARM.patch [bz#1656504] +- kvm-aarch64-Set-virt-rhel8.0.0-max_cpus-to-512.patch [bz#1656504] +- kvm-aarch64-Use-256MB-ECAM-region-by-default.patch [bz#1656504] +- Resolves: bz#1648023 + (Provide separate device types for transitional virtio PCI devices - Fast Train) +- Resolves: bz#1656504 + (Machine types for qemu-kvm based on rebase to qemu-3.1 (aarch64)) + * Fri Jan 11 2019 Danilo Cesar Lemes de Paula - 3.1.0-4.el8 - kvm-hw-s390x-s390-virtio-ccw-Add-machine-types-for-RHEL8.patch [bz#1656510] - kvm-spapr-Add-H-Call-H_HOME_NODE_ASSOCIATIVITY.patch [bz#1661967]