mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-22 22:13:18 +00:00
qemu: Assign device addresses earlier in qemuDomainAttachNetDevice
If code in the @actualType switch needs to have/know which PCI Address is being used, then we must assign it earlier. In particular a vhost-user device needs to call qemuDomainSupportsNicdev which requires an address to be defined. Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn> Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
e6df863294
commit
01ca4010d8
@ -1369,6 +1369,25 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
|
|||||||
if (qemuAssignDeviceNetAlias(vm->def, net, -1) < 0)
|
if (qemuAssignDeviceNetAlias(vm->def, net, -1) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
if (qemuDomainIsS390CCW(vm->def) &&
|
||||||
|
net->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI &&
|
||||||
|
virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_CCW)) {
|
||||||
|
net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW;
|
||||||
|
if (!(ccwaddrs = virDomainCCWAddressSetCreateFromDomain(vm->def)))
|
||||||
|
goto cleanup;
|
||||||
|
if (virDomainCCWAddressAssign(&net->info, ccwaddrs,
|
||||||
|
!net->info.addr.ccw.assigned) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
} else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390)) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
_("virtio-s390 net device cannot be hotplugged."));
|
||||||
|
goto cleanup;
|
||||||
|
} else if (qemuDomainEnsurePCIAddress(vm, &dev, driver) < 0) {
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
releaseaddr = true;
|
||||||
|
|
||||||
switch (actualType) {
|
switch (actualType) {
|
||||||
case VIR_DOMAIN_NET_TYPE_BRIDGE:
|
case VIR_DOMAIN_NET_TYPE_BRIDGE:
|
||||||
case VIR_DOMAIN_NET_TYPE_NETWORK:
|
case VIR_DOMAIN_NET_TYPE_NETWORK:
|
||||||
@ -1503,25 +1522,6 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemuDomainIsS390CCW(vm->def) &&
|
|
||||||
net->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI &&
|
|
||||||
virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_CCW)) {
|
|
||||||
net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW;
|
|
||||||
if (!(ccwaddrs = virDomainCCWAddressSetCreateFromDomain(vm->def)))
|
|
||||||
goto cleanup;
|
|
||||||
if (virDomainCCWAddressAssign(&net->info, ccwaddrs,
|
|
||||||
!net->info.addr.ccw.assigned) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
} else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390)) {
|
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
||||||
_("virtio-s390 net device cannot be hotplugged."));
|
|
||||||
goto cleanup;
|
|
||||||
} else if (qemuDomainEnsurePCIAddress(vm, &dev, driver) < 0) {
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
releaseaddr = true;
|
|
||||||
|
|
||||||
if (VIR_ALLOC_N(tapfdName, tapfdSize) < 0 ||
|
if (VIR_ALLOC_N(tapfdName, tapfdSize) < 0 ||
|
||||||
VIR_ALLOC_N(vhostfdName, vhostfdSize) < 0)
|
VIR_ALLOC_N(vhostfdName, vhostfdSize) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
Loading…
Reference in New Issue
Block a user