mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
qemu: command: Introduce 'qemuBuildInterfaceConnect' helper
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@redhat.com> Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
ba9e1f629c
commit
29d022b1eb
@ -8674,6 +8674,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,
|
||||
@ -8709,6 +8749,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:
|
||||
|
@ -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,
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user