提交 0bce012d 编写于 作者: M Michal Privoznik

qemuBuildInterfaceCommandLine: Move from if-else forest to switch

Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
上级 4a74ccdb
...@@ -7915,8 +7915,9 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd, ...@@ -7915,8 +7915,9 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
cfg = virQEMUDriverGetConfig(driver); cfg = virQEMUDriverGetConfig(driver);
if (actualType == VIR_DOMAIN_NET_TYPE_NETWORK || switch (actualType) {
actualType == VIR_DOMAIN_NET_TYPE_BRIDGE) { case VIR_DOMAIN_NET_TYPE_NETWORK:
case VIR_DOMAIN_NET_TYPE_BRIDGE:
tapfdSize = net->driver.virtio.queues; tapfdSize = net->driver.virtio.queues;
if (!tapfdSize) if (!tapfdSize)
tapfdSize = 1; tapfdSize = 1;
...@@ -7930,7 +7931,9 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd, ...@@ -7930,7 +7931,9 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
if (qemuInterfaceBridgeConnect(def, driver, net, if (qemuInterfaceBridgeConnect(def, driver, net,
tapfd, &tapfdSize) < 0) tapfd, &tapfdSize) < 0)
goto cleanup; goto cleanup;
} else if (actualType == VIR_DOMAIN_NET_TYPE_DIRECT) { break;
case VIR_DOMAIN_NET_TYPE_DIRECT:
tapfdSize = net->driver.virtio.queues; tapfdSize = net->driver.virtio.queues;
if (!tapfdSize) if (!tapfdSize)
tapfdSize = 1; tapfdSize = 1;
...@@ -7944,7 +7947,9 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd, ...@@ -7944,7 +7947,9 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
if (qemuInterfaceDirectConnect(def, driver, net, if (qemuInterfaceDirectConnect(def, driver, net,
tapfd, tapfdSize, vmop) < 0) tapfd, tapfdSize, vmop) < 0)
goto cleanup; goto cleanup;
} else if (actualType == VIR_DOMAIN_NET_TYPE_ETHERNET) { break;
case VIR_DOMAIN_NET_TYPE_ETHERNET:
tapfdSize = net->driver.virtio.queues; tapfdSize = net->driver.virtio.queues;
if (!tapfdSize) if (!tapfdSize)
tapfdSize = 1; tapfdSize = 1;
...@@ -7956,17 +7961,32 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd, ...@@ -7956,17 +7961,32 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
memset(tapfd, -1, tapfdSize * sizeof(tapfd[0])); memset(tapfd, -1, tapfdSize * sizeof(tapfd[0]));
if (qemuInterfaceEthernetConnect(def, driver, net, if (qemuInterfaceEthernetConnect(def, driver, net,
tapfd, tapfdSize) < 0) tapfd, tapfdSize) < 0)
goto cleanup; goto cleanup;
} else if (actualType == VIR_DOMAIN_NET_TYPE_HOSTDEV) { break;
case VIR_DOMAIN_NET_TYPE_HOSTDEV:
/* NET_TYPE_HOSTDEV devices are really hostdev devices, so /* NET_TYPE_HOSTDEV devices are really hostdev devices, so
* their commandlines are constructed with other hostdevs. * their commandlines are constructed with other hostdevs.
*/ */
ret = 0; ret = 0;
goto cleanup; goto cleanup;
} else if (actualType == VIR_DOMAIN_NET_TYPE_VHOSTUSER) { break;
case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
ret = qemuBuildVhostuserCommandLine(cmd, def, net, qemuCaps, bootindex); ret = qemuBuildVhostuserCommandLine(cmd, def, net, qemuCaps, bootindex);
goto cleanup; goto cleanup;
break;
case VIR_DOMAIN_NET_TYPE_USER:
case VIR_DOMAIN_NET_TYPE_SERVER:
case VIR_DOMAIN_NET_TYPE_CLIENT:
case VIR_DOMAIN_NET_TYPE_MCAST:
case VIR_DOMAIN_NET_TYPE_INTERNAL:
case VIR_DOMAIN_NET_TYPE_UDP:
case VIR_DOMAIN_NET_TYPE_LAST:
/* nada */
break;
} }
/* For types whose implementations use a netdev on the host, add /* For types whose implementations use a netdev on the host, add
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册