[PATCH v2 5/8] qemu: Validate virtio-mem-ccw

Michal Privoznik posted 8 patches 7 months, 1 week ago
[PATCH v2 5/8] qemu: Validate virtio-mem-ccw
Posted by Michal Privoznik 7 months, 1 week ago
There are basically two differences between virtio-mem-ccw and
virtio-mem-pci. s390 doesn't allow mixing different page sizes
and there's no NUMA support in QEMU.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
---
 src/qemu/qemu_validate.c | 35 ++++++++++++++++++++++++++++++++---
 1 file changed, 32 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index c8ea8b63d2..76f2eafe49 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -5224,7 +5224,8 @@ qemuValidateDomainDeviceDefHub(virDomainHubDef *hub,
 
 
 static int
-qemuValidateDomainDeviceDefMemory(virDomainMemoryDef *mem,
+qemuValidateDomainDeviceDefMemory(const virDomainMemoryDef *mem,
+                                  const virDomainDef *def,
                                   virQEMUCaps *qemuCaps)
 {
     virSGXCapability *sgxCaps;
@@ -5263,12 +5264,40 @@ qemuValidateDomainDeviceDefMemory(virDomainMemoryDef *mem,
         break;
 
     case VIR_DOMAIN_MEMORY_MODEL_VIRTIO_MEM:
-        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_MEM_PCI)) {
+        if ((mem->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI &&
+             !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_MEM_PCI)) ||
+            (mem->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW &&
+             !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_MEM_CCW))) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                            _("virtio-mem isn't supported by this QEMU binary"));
             return -1;
         }
 
+        if (mem->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
+            /* virtio-mem-ccw has a few differences compared to virtio-mem-pci:
+             *
+             * 1) corresponding memory-backing-* object can't have a different
+             *    page size than the boot memory (see s390_machine_device_plug()
+             *    in qemu sources).
+             * 2) Since its commit v2.12.0-rc0~41^2~6 QEMU doesn't allow NUMA
+             *    for s390.
+             */
+
+            if (mem->source.virtio_mem.pagesize != 0 &&
+                def->mem.nhugepages &&
+                mem->source.virtio_mem.pagesize != def->mem.hugepages[0].size) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                               _("virtio-mem-ccw can't use different page size than the boot memory"));
+                return -1;
+            }
+
+            if (mem->targetNode != 0 && mem->targetNode != -1) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                               _("NUMA nodes are not supported for virtio-mem-ccw"));
+                return -1;
+            }
+        }
+
         if (mem->target.virtio_mem.dynamicMemslots == VIR_TRISTATE_BOOL_YES &&
             !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_MEM_PCI_DYNAMIC_MEMSLOTS)) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
@@ -5455,7 +5484,7 @@ qemuValidateDomainDeviceDef(const virDomainDeviceDef *dev,
         return qemuValidateDomainDeviceDefSound(dev->data.sound, qemuCaps);
 
     case VIR_DOMAIN_DEVICE_MEMORY:
-        return qemuValidateDomainDeviceDefMemory(dev->data.memory, qemuCaps);
+        return qemuValidateDomainDeviceDefMemory(dev->data.memory, def, qemuCaps);
 
     case VIR_DOMAIN_DEVICE_SHMEM:
         return qemuValidateDomainDeviceDefShmem(dev->data.shmem, qemuCaps);
-- 
2.45.3
Re: [PATCH v2 5/8] qemu: Validate virtio-mem-ccw
Posted by David Hildenbrand 7 months ago
On 03.02.25 10:55, Michal Privoznik wrote:
> There are basically two differences between virtio-mem-ccw and
> virtio-mem-pci. s390 doesn't allow mixing different page sizes
> and there's no NUMA support in QEMU.
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
> ---
>   src/qemu/qemu_validate.c | 35 ++++++++++++++++++++++++++++++++---
>   1 file changed, 32 insertions(+), 3 deletions(-)
> 
> diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
> index c8ea8b63d2..76f2eafe49 100644
> --- a/src/qemu/qemu_validate.c
> +++ b/src/qemu/qemu_validate.c
> @@ -5224,7 +5224,8 @@ qemuValidateDomainDeviceDefHub(virDomainHubDef *hub,
>   
>   
>   static int
> -qemuValidateDomainDeviceDefMemory(virDomainMemoryDef *mem,
> +qemuValidateDomainDeviceDefMemory(const virDomainMemoryDef *mem,
> +                                  const virDomainDef *def,
>                                     virQEMUCaps *qemuCaps)
>   {
>       virSGXCapability *sgxCaps;
> @@ -5263,12 +5264,40 @@ qemuValidateDomainDeviceDefMemory(virDomainMemoryDef *mem,
>           break;
>   
>       case VIR_DOMAIN_MEMORY_MODEL_VIRTIO_MEM:
> -        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_MEM_PCI)) {
> +        if ((mem->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI &&
> +             !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_MEM_PCI)) ||
> +            (mem->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW &&
> +             !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_MEM_CCW))) {
>               virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
>                              _("virtio-mem isn't supported by this QEMU binary"));
>               return -1;
>           }
>   
> +        if (mem->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
> +            /* virtio-mem-ccw has a few differences compared to virtio-mem-pci:
> +             *
> +             * 1) corresponding memory-backing-* object can't have a different
> +             *    page size than the boot memory (see s390_machine_device_plug()
> +             *    in qemu sources).


Hm, but that also applies to virtio-mem-pci on s390x.

To be precise: this is a KVM limitation, but we currently check for it 
even under TCG. I should probably change that, to not apply for TCG, but 
I'll have to look into the details if my memory is correct.

So 1), in theory, applies with KVM, and independent of PCI vs. CCW.

> +             * 2) Since its commit v2.12.0-rc0~41^2~6 QEMU doesn't allow NUMA
> +             *    for s390.

Similar: this is also independent of PCI vs. CCW?


Thanks!

-- 
Cheers,

David / dhildenb
Re: [PATCH v2 5/8] qemu: Validate virtio-mem-ccw
Posted by David Hildenbrand 7 months ago
On 04.02.25 10:13, David Hildenbrand wrote:
> On 03.02.25 10:55, Michal Privoznik wrote:
>> There are basically two differences between virtio-mem-ccw and
>> virtio-mem-pci. s390 doesn't allow mixing different page sizes
>> and there's no NUMA support in QEMU.
>>
>> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
>> Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
>> ---
>>    src/qemu/qemu_validate.c | 35 ++++++++++++++++++++++++++++++++---
>>    1 file changed, 32 insertions(+), 3 deletions(-)
>>
>> diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
>> index c8ea8b63d2..76f2eafe49 100644
>> --- a/src/qemu/qemu_validate.c
>> +++ b/src/qemu/qemu_validate.c
>> @@ -5224,7 +5224,8 @@ qemuValidateDomainDeviceDefHub(virDomainHubDef *hub,
>>    
>>    
>>    static int
>> -qemuValidateDomainDeviceDefMemory(virDomainMemoryDef *mem,
>> +qemuValidateDomainDeviceDefMemory(const virDomainMemoryDef *mem,
>> +                                  const virDomainDef *def,
>>                                      virQEMUCaps *qemuCaps)
>>    {
>>        virSGXCapability *sgxCaps;
>> @@ -5263,12 +5264,40 @@ qemuValidateDomainDeviceDefMemory(virDomainMemoryDef *mem,
>>            break;
>>    
>>        case VIR_DOMAIN_MEMORY_MODEL_VIRTIO_MEM:
>> -        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_MEM_PCI)) {
>> +        if ((mem->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI &&
>> +             !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_MEM_PCI)) ||
>> +            (mem->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW &&
>> +             !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_MEM_CCW))) {
>>                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
>>                               _("virtio-mem isn't supported by this QEMU binary"));
>>                return -1;
>>            }
>>    
>> +        if (mem->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
>> +            /* virtio-mem-ccw has a few differences compared to virtio-mem-pci:
>> +             *
>> +             * 1) corresponding memory-backing-* object can't have a different
>> +             *    page size than the boot memory (see s390_machine_device_plug()
>> +             *    in qemu sources).
> 
> 
> Hm, but that also applies to virtio-mem-pci on s390x.
> 
> To be precise: this is a KVM limitation, but we currently check for it
> even under TCG. I should probably change that, to not apply for TCG, but
> I'll have to look into the details if my memory is correct.

Ah, and now I reread my own comment:

"While only relevant for KVM, there is not really any use case for this 
with TCG, so we'll unconditionally reject it."

So we can just assume that we cannot mix page sizes with a s390x 
machine, independent of KVM vs. TCG.

-- 
Cheers,

David / dhildenb