提交 d334c917 编写于 作者: J John Ferlan

qemu: Introduce qemuDomainMachineIsS390CCW

Rather than have different usages of STR function in order to determine
whether the domain is s390-ccw or s390-ccw-virtio, make a single API
which will check the machine.os prefix. Then use the function.
上级 682775fb
...@@ -1342,7 +1342,7 @@ qemuDomainAssignS390Addresses(virDomainDefPtr def, ...@@ -1342,7 +1342,7 @@ qemuDomainAssignS390Addresses(virDomainDefPtr def,
virDomainCCWAddressSetPtr addrs = NULL; virDomainCCWAddressSetPtr addrs = NULL;
qemuDomainObjPrivatePtr priv = NULL; qemuDomainObjPrivatePtr priv = NULL;
if (STREQLEN(def->os.machine, "s390-ccw", 8) && if (qemuDomainMachineIsS390CCW(def) &&
virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_CCW)) { virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_CCW)) {
qemuDomainPrimeVirtioDeviceAddresses( qemuDomainPrimeVirtioDeviceAddresses(
def, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW); def, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW);
...@@ -1864,7 +1864,7 @@ qemuDomainReleaseDeviceAddress(virDomainObjPtr vm, ...@@ -1864,7 +1864,7 @@ qemuDomainReleaseDeviceAddress(virDomainObjPtr vm,
devstr = info->alias; devstr = info->alias;
if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW && 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) && virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW) &&
virDomainCCWAddressReleaseAddr(priv->ccwaddrs, info) < 0) virDomainCCWAddressReleaseAddr(priv->ccwaddrs, info) < 0)
VIR_WARN("Unable to release CCW address on %s", VIR_WARN("Unable to release CCW address on %s",
......
...@@ -3323,6 +3323,12 @@ qemuDomainMachineNeedsFDC(const virDomainDef *def) ...@@ -3323,6 +3323,12 @@ qemuDomainMachineNeedsFDC(const virDomainDef *def)
} }
bool
qemuDomainMachineIsS390CCW(const virDomainDef *def)
{
return STRPREFIX(def->os.machine, "s390-ccw");
}
/** /**
* qemuDomainUpdateCurrentMemorySize: * qemuDomainUpdateCurrentMemorySize:
......
...@@ -469,6 +469,7 @@ virDomainChrSourceDefPtr qemuFindAgentConfig(virDomainDefPtr def); ...@@ -469,6 +469,7 @@ virDomainChrSourceDefPtr qemuFindAgentConfig(virDomainDefPtr def);
bool qemuDomainMachineIsQ35(const virDomainDef *def); bool qemuDomainMachineIsQ35(const virDomainDef *def);
bool qemuDomainMachineIsI440FX(const virDomainDef *def); bool qemuDomainMachineIsI440FX(const virDomainDef *def);
bool qemuDomainMachineNeedsFDC(const virDomainDef *def); bool qemuDomainMachineNeedsFDC(const virDomainDef *def);
bool qemuDomainMachineIsS390CCW(const virDomainDef *def);
int qemuDomainUpdateCurrentMemorySize(virQEMUDriverPtr driver, int qemuDomainUpdateCurrentMemorySize(virQEMUDriverPtr driver,
virDomainObjPtr vm); virDomainObjPtr vm);
......
...@@ -326,7 +326,7 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn, ...@@ -326,7 +326,7 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn,
const char *src = virDomainDiskGetSource(disk); const char *src = virDomainDiskGetSource(disk);
if (!disk->info.type) { if (!disk->info.type) {
if (STREQLEN(vm->def->os.machine, "s390-ccw", 8) && if (qemuDomainMachineIsS390CCW(vm->def) &&
virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW)) virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW))
disk->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW; disk->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW;
else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390)) else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390))
...@@ -443,7 +443,7 @@ int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver, ...@@ -443,7 +443,7 @@ int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver,
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) { if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
if (controller->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) { 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)) virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW))
controller->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW; controller->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW;
else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390)) else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390))
...@@ -991,7 +991,7 @@ int qemuDomainAttachNetDevice(virConnectPtr conn, ...@@ -991,7 +991,7 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
goto cleanup; goto cleanup;
} }
if (STREQLEN(vm->def->os.machine, "s390-ccw", 8) && if (qemuDomainMachineIsS390CCW(vm->def) &&
virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW)) { virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW)) {
net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW; net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW;
if (virDomainCCWAddressAssign(&net->info, priv->ccwaddrs, if (virDomainCCWAddressAssign(&net->info, priv->ccwaddrs,
...@@ -1657,7 +1657,7 @@ qemuDomainAttachRNGDevice(virQEMUDriverPtr driver, ...@@ -1657,7 +1657,7 @@ qemuDomainAttachRNGDevice(virQEMUDriverPtr driver,
return -1; return -1;
if (rng->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) { 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)) { virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW)) {
rng->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW; rng->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW;
} else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390)) { } else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390)) {
...@@ -3412,7 +3412,7 @@ qemuDomainDetachVirtioDiskDevice(virQEMUDriverPtr driver, ...@@ -3412,7 +3412,7 @@ qemuDomainDetachVirtioDiskDevice(virQEMUDriverPtr driver,
goto cleanup; goto cleanup;
} }
if (STREQLEN(vm->def->os.machine, "s390-ccw", 8) && if (qemuDomainMachineIsS390CCW(vm->def) &&
virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW)) { virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW)) {
if (!virDomainDeviceAddressIsValid(&detach->info, if (!virDomainDeviceAddressIsValid(&detach->info,
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW)) { VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW)) {
...@@ -3942,7 +3942,7 @@ qemuDomainDetachNetDevice(virQEMUDriverPtr driver, ...@@ -3942,7 +3942,7 @@ qemuDomainDetachNetDevice(virQEMUDriverPtr driver,
virDomainNetGetActualHostdev(detach)); virDomainNetGetActualHostdev(detach));
goto cleanup; goto cleanup;
} }
if (STREQLEN(vm->def->os.machine, "s390-ccw", 8) && if (qemuDomainMachineIsS390CCW(vm->def) &&
virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW)) { virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW)) {
if (!virDomainDeviceAddressIsValid(&detach->info, if (!virDomainDeviceAddressIsValid(&detach->info,
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW)) { VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册