The helper will aggregate code that is used to connect the network
backend to the corresponding host portion.
This will be used to refactor the duplicated code between the cold-start
and hotplug helper functions.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_command.c | 43 +++++++++++++++++++++++++++++++++++++++++
src/qemu/qemu_command.h | 5 +++++
src/qemu/qemu_hotplug.c | 3 +++
3 files changed, 51 insertions(+)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 0d1517a5d6..2c4a1a582a 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -8652,6 +8652,46 @@ qemuInterfaceVhostuserConnect(virCommand *cmd,
return 0;
}
+
+int
+qemuBuildInterfaceConnect(virDomainObj *vm G_GNUC_UNUSED,
+ virDomainNetDef *net,
+ bool standalone G_GNUC_UNUSED)
+{
+ virDomainNetType actualType = virDomainNetGetActualType(net);
+
+ switch (actualType) {
+ case VIR_DOMAIN_NET_TYPE_NETWORK:
+ case VIR_DOMAIN_NET_TYPE_BRIDGE:
+ break;
+
+ case VIR_DOMAIN_NET_TYPE_DIRECT:
+ break;
+
+ case VIR_DOMAIN_NET_TYPE_ETHERNET:
+ break;
+
+ case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
+ break;
+
+ case VIR_DOMAIN_NET_TYPE_VDPA:
+ break;
+
+ case VIR_DOMAIN_NET_TYPE_HOSTDEV:
+ 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:
+ break;
+ }
+
+ return 0;
+}
+
+
static int
qemuBuildInterfaceCommandLine(virQEMUDriver *driver,
virDomainObj *vm,
@@ -8687,6 +8727,9 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver,
if (qemuDomainValidateActualNetDef(net, qemuCaps) < 0)
return -1;
+ if (qemuBuildInterfaceConnect(vm, net, standalone) < 0)
+ return -1;
+
switch (actualType) {
case VIR_DOMAIN_NET_TYPE_NETWORK:
case VIR_DOMAIN_NET_TYPE_BRIDGE:
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index a653ff7218..4b4e0bb456 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -94,6 +94,11 @@ qemuBuildHostNetProps(virDomainNetDef *net,
const char *slirpfd,
const char *vdpadev);
+int
+qemuBuildInterfaceConnect(virDomainObj *vm,
+ virDomainNetDef *net,
+ bool standalone);
+
/* Current, best practice */
virJSONValue *
qemuBuildNicDevProps(virDomainDef *def,
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 2923992759..221815568b 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1279,6 +1279,9 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver,
*/
VIR_APPEND_ELEMENT_COPY(vm->def->nets, vm->def->nnets, net);
+ if (qemuBuildInterfaceConnect(vm, net, false) < 0)
+ return -1;
+
switch (actualType) {
case VIR_DOMAIN_NET_TYPE_BRIDGE:
case VIR_DOMAIN_NET_TYPE_NETWORK:
--
2.35.1