On Tue, Mar 18, 2025 at 09:53:22AM +0100, Boris Fiuczynski wrote:
Since commit f23f8ff91a virtio-mem supports also CCW. When hotplugging
a
virtio-mem device with a CCW address results in a PCI device getting
attached. The method qemuDomainAssignMemoryDeviceSlot is only
considering PCI as address type and overwriting the CCW address. Adding
support for address type CCW.
Signed-off-by: Boris Fiuczynski <fiuczy(a)linux.ibm.com>
---
src/qemu/qemu_domain_address.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index d38983bf63..b0289c2337 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -3067,6 +3067,7 @@ qemuDomainAssignMemoryDeviceSlot(virDomainObj *vm,
virDomainMemoryDef *mem)
{
g_autoptr(virBitmap) slotmap = NULL;
+ virDomainCCWAddressSet *ccwaddrs = NULL;
virDomainDeviceDef dev = {.type = VIR_DOMAIN_DEVICE_MEMORY, .data.memory = mem};
switch (mem->model) {
@@ -3080,7 +3081,20 @@ qemuDomainAssignMemoryDeviceSlot(virDomainObj *vm,
case VIR_DOMAIN_MEMORY_MODEL_VIRTIO_PMEM:
case VIR_DOMAIN_MEMORY_MODEL_VIRTIO_MEM:
- return qemuDomainEnsurePCIAddress(vm, &dev);
+ if (mem->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
+ if (qemuDomainIsS390CCW(vm->def))
+ mem->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW;
+ }
+
+ if (mem->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE ||
+ mem->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
+ return qemuDomainEnsurePCIAddress(vm, &dev);
+ } else if (mem->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
+ if (!(ccwaddrs = virDomainCCWAddressSetCreateFromDomain(vm->def)))
+ return -1;
+ return virDomainCCWAddressAssign(&mem->info, ccwaddrs,
+ !mem->info.addr.ccw.assigned);
+ }
You leak ccwaddrs here, I'd suggest squashing something like this in:
diff --git i/src/conf/domain_addr.h w/src/conf/domain_addr.h
index e72fb4884758..d1c2539e7ea6 100644
--- i/src/conf/domain_addr.h
+++ w/src/conf/domain_addr.h
@@ -310,3 +310,5 @@ int
virDomainUSBAddressRelease(virDomainUSBAddressSet *addrs,
virDomainDeviceInfo *info)
ATTRIBUTE_NONNULL(2);
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainCCWAddressSet, virDomainCCWAddressSetFree);
diff --git i/src/qemu/qemu_domain_address.c w/src/qemu/qemu_domain_address.c
index b0289c2337ae..2dedff9c95d9 100644
--- i/src/qemu/qemu_domain_address.c
+++ w/src/qemu/qemu_domain_address.c
@@ -3067,7 +3067,7 @@ qemuDomainAssignMemoryDeviceSlot(virDomainObj *vm,
virDomainMemoryDef *mem)
{
g_autoptr(virBitmap) slotmap = NULL;
- virDomainCCWAddressSet *ccwaddrs = NULL;
+ g_autoptr(virDomainCCWAddressSet) ccwaddrs = NULL;
virDomainDeviceDef dev = {.type = VIR_DOMAIN_DEVICE_MEMORY, .data.memory = mem};
switch (mem->model) {
--
break;
case VIR_DOMAIN_MEMORY_MODEL_SGX_EPC:
--
2.47.0