提交 70a29b37 编写于 作者: L Laine Stump

qemu: call common NetDef validation for hotplug and device update

qemuDomainAttachNetDevice() (hotplug) previously had some of the
validation that is in qemuDomainValidateActualNetDef(), but it was
incomplete. qemuDomainChangeNet() had none of that validation, but it
is all appropriate in both cases.

This is the final piece of a previously partial resolution to
https://bugzilla.redhat.com/1502754Signed-off-by: NLaine Stump <laine@redhat.com>
Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
上级 3cff23f7
...@@ -1188,32 +1188,11 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, ...@@ -1188,32 +1188,11 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
goto cleanup; goto cleanup;
} }
actualType = virDomainNetGetActualType(net); /* final validation now that we have full info on the type */
if (qemuDomainValidateActualNetDef(net, priv->qemuCaps) < 0)
/* Currently only TAP/macvtap devices supports multiqueue. */
if (net->driver.virtio.queues > 0 &&
!(actualType == VIR_DOMAIN_NET_TYPE_NETWORK ||
actualType == VIR_DOMAIN_NET_TYPE_BRIDGE ||
actualType == VIR_DOMAIN_NET_TYPE_DIRECT ||
actualType == VIR_DOMAIN_NET_TYPE_ETHERNET ||
actualType == VIR_DOMAIN_NET_TYPE_VHOSTUSER)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Multiqueue network is not supported for: %s"),
virDomainNetTypeToString(actualType));
return -1; return -1;
}
/* and only TAP devices support nwfilter rules */ actualType = virDomainNetGetActualType(net);
if (net->filter &&
!(actualType == VIR_DOMAIN_NET_TYPE_NETWORK ||
actualType == VIR_DOMAIN_NET_TYPE_BRIDGE ||
actualType == VIR_DOMAIN_NET_TYPE_ETHERNET)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("filterref is not supported for "
"network interfaces of type %s"),
virDomainNetTypeToString(actualType));
return -1;
}
if (qemuAssignDeviceNetAlias(vm->def, net, -1) < 0) if (qemuAssignDeviceNetAlias(vm->def, net, -1) < 0)
goto cleanup; goto cleanup;
...@@ -3542,6 +3521,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, ...@@ -3542,6 +3521,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
virDomainObjPtr vm, virDomainObjPtr vm,
virDomainDeviceDefPtr dev) virDomainDeviceDefPtr dev)
{ {
qemuDomainObjPrivatePtr priv = vm->privateData;
virDomainNetDefPtr newdev = dev->data.net; virDomainNetDefPtr newdev = dev->data.net;
virDomainNetDefPtr *devslot = NULL; virDomainNetDefPtr *devslot = NULL;
virDomainNetDefPtr olddev; virDomainNetDefPtr olddev;
...@@ -3749,6 +3729,10 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, ...@@ -3749,6 +3729,10 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
goto cleanup; goto cleanup;
} }
/* final validation now that we have full info on the type */
if (qemuDomainValidateActualNetDef(newdev, priv->qemuCaps) < 0)
goto cleanup;
newType = virDomainNetGetActualType(newdev); newType = virDomainNetGetActualType(newdev);
if (newType == VIR_DOMAIN_NET_TYPE_HOSTDEV) { if (newType == VIR_DOMAIN_NET_TYPE_HOSTDEV) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册