diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 2a820af6f573d1bab9fe1111e7a787f2bbd07691..9528b4a49ffc902803ed8566929e1541b1da6062 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1342,7 +1342,7 @@ qemuDomainAssignS390Addresses(virDomainDefPtr def, virDomainCCWAddressSetPtr addrs = NULL; qemuDomainObjPrivatePtr priv = NULL; - if (STREQLEN(def->os.machine, "s390-ccw", 8) && + if (qemuDomainMachineIsS390CCW(def) && virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_CCW)) { qemuDomainPrimeVirtioDeviceAddresses( def, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW); @@ -1864,7 +1864,7 @@ qemuDomainReleaseDeviceAddress(virDomainObjPtr vm, devstr = info->alias; if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW && - STREQLEN(vm->def->os.machine, "s390-ccw", 8) && + qemuDomainMachineIsS390CCW(vm->def) && virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW) && virDomainCCWAddressReleaseAddr(priv->ccwaddrs, info) < 0) VIR_WARN("Unable to release CCW address on %s", diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 0a9ed6babb4cfb66dc31caf9aa9f37f53a2d6c4a..91c632ca27125f5d02875cc9dc66bb188e7b294d 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3323,6 +3323,12 @@ qemuDomainMachineNeedsFDC(const virDomainDef *def) } +bool +qemuDomainMachineIsS390CCW(const virDomainDef *def) +{ + return STRPREFIX(def->os.machine, "s390-ccw"); +} + /** * qemuDomainUpdateCurrentMemorySize: diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 2af7c5972abe2029d9834754fd422c83141c451c..91eaea174bbe0b7e228e8de17c371e961ce97ec8 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -469,6 +469,7 @@ virDomainChrSourceDefPtr qemuFindAgentConfig(virDomainDefPtr def); bool qemuDomainMachineIsQ35(const virDomainDef *def); bool qemuDomainMachineIsI440FX(const virDomainDef *def); bool qemuDomainMachineNeedsFDC(const virDomainDef *def); +bool qemuDomainMachineIsS390CCW(const virDomainDef *def); int qemuDomainUpdateCurrentMemorySize(virQEMUDriverPtr driver, virDomainObjPtr vm); diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index ac683adb36a75a8b8cfdc42d0197672812580a47..f46ec5e7035963315715cfad9395750d68222792 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -326,7 +326,7 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn, const char *src = virDomainDiskGetSource(disk); if (!disk->info.type) { - if (STREQLEN(vm->def->os.machine, "s390-ccw", 8) && + if (qemuDomainMachineIsS390CCW(vm->def) && virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW)) disk->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW; else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390)) @@ -443,7 +443,7 @@ int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver, if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) { if (controller->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) { - if (STRPREFIX(vm->def->os.machine, "s390-ccw") && + if (qemuDomainMachineIsS390CCW(vm->def) && virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW)) controller->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW; else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390)) @@ -991,7 +991,7 @@ int qemuDomainAttachNetDevice(virConnectPtr conn, goto cleanup; } - if (STREQLEN(vm->def->os.machine, "s390-ccw", 8) && + if (qemuDomainMachineIsS390CCW(vm->def) && virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW)) { net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW; if (virDomainCCWAddressAssign(&net->info, priv->ccwaddrs, @@ -1657,7 +1657,7 @@ qemuDomainAttachRNGDevice(virQEMUDriverPtr driver, return -1; if (rng->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) { - if (STRPREFIX(vm->def->os.machine, "s390-ccw") && + if (qemuDomainMachineIsS390CCW(vm->def) && virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW)) { rng->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW; } else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390)) { @@ -3412,7 +3412,7 @@ qemuDomainDetachVirtioDiskDevice(virQEMUDriverPtr driver, goto cleanup; } - if (STREQLEN(vm->def->os.machine, "s390-ccw", 8) && + if (qemuDomainMachineIsS390CCW(vm->def) && virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW)) { if (!virDomainDeviceAddressIsValid(&detach->info, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW)) { @@ -3942,7 +3942,7 @@ qemuDomainDetachNetDevice(virQEMUDriverPtr driver, virDomainNetGetActualHostdev(detach)); goto cleanup; } - if (STREQLEN(vm->def->os.machine, "s390-ccw", 8) && + if (qemuDomainMachineIsS390CCW(vm->def) && virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW)) { if (!virDomainDeviceAddressIsValid(&detach->info, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW)) {