mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
Make qemuBuildHostNetStr() take tapfd as a string
With hotplug, we're going to want to pass a tapfd name rather than an actual file descriptor, so prepare the way by passing a string tapfd to qemuBuildHostNetStr(). * src/qemu_conf.h: qemuBuildHostNetStr() takes a string tapfd now * src/qemu_conf.c: pass qemuBuildHostNetStr() a string rather than an actual file descriptor * src/qemu_driver.c: update qemudDomainAttachNetDevice() for change
This commit is contained in:
parent
a3f33b6531
commit
32db8dd75b
@ -1181,13 +1181,13 @@ qemuBuildHostNetStr(virConnectPtr conn,
|
||||
const char *prefix,
|
||||
char type_sep,
|
||||
int vlan,
|
||||
int tapfd,
|
||||
const char *tapfd,
|
||||
char **str)
|
||||
{
|
||||
switch (net->type) {
|
||||
case VIR_DOMAIN_NET_TYPE_NETWORK:
|
||||
case VIR_DOMAIN_NET_TYPE_BRIDGE:
|
||||
if (virAsprintf(str, "%stap%cfd=%d,vlan=%d%s%s",
|
||||
if (virAsprintf(str, "%stap%cfd=%s,vlan=%d%s%s",
|
||||
prefix ? prefix : "",
|
||||
type_sep, tapfd, vlan,
|
||||
(net->hostnet_name ? ",name=" : ""),
|
||||
@ -1805,7 +1805,7 @@ int qemudBuildCommandLine(virConnectPtr conn,
|
||||
for (i = 0 ; i < def->nnets ; i++) {
|
||||
virDomainNetDefPtr net = def->nets[i];
|
||||
char *nic, *host;
|
||||
int tapfd = -1;
|
||||
char *tapfd_name = NULL;
|
||||
|
||||
net->vlan = i;
|
||||
|
||||
@ -1821,7 +1821,7 @@ int qemudBuildCommandLine(virConnectPtr conn,
|
||||
|
||||
if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK ||
|
||||
net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) {
|
||||
tapfd = qemudNetworkIfaceConnect(conn, driver, net, qemuCmdFlags);
|
||||
int tapfd = qemudNetworkIfaceConnect(conn, driver, net, qemuCmdFlags);
|
||||
if (tapfd < 0)
|
||||
goto error;
|
||||
|
||||
@ -1831,14 +1831,21 @@ int qemudBuildCommandLine(virConnectPtr conn,
|
||||
}
|
||||
|
||||
(*tapfds)[(*ntapfds)++] = tapfd;
|
||||
|
||||
if (virAsprintf(&tapfd_name, "%d", tapfd) < 0)
|
||||
goto no_memory;
|
||||
}
|
||||
|
||||
if (qemuBuildHostNetStr(conn, net, NULL, ',',
|
||||
net->vlan, tapfd, &host) < 0)
|
||||
net->vlan, tapfd_name, &host) < 0) {
|
||||
VIR_FREE(tapfd_name);
|
||||
goto error;
|
||||
}
|
||||
|
||||
ADD_ARG_LIT("-net");
|
||||
ADD_ARG(host);
|
||||
|
||||
VIR_FREE(tapfd_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -155,7 +155,7 @@ int qemuBuildHostNetStr (virConnectPtr conn,
|
||||
const char *prefix,
|
||||
char type_sep,
|
||||
int vlan,
|
||||
int tapfd,
|
||||
const char *tapfd,
|
||||
char **str);
|
||||
|
||||
int qemuBuildNicStr (virConnectPtr conn,
|
||||
|
@ -4896,7 +4896,7 @@ static int qemudDomainAttachNetDevice(virConnectPtr conn,
|
||||
net->vlan = vm->def->nets[i]->vlan;
|
||||
|
||||
if (qemuBuildHostNetStr(conn, net,
|
||||
"host_net_add ", ' ', net->vlan, -1, &cmd) < 0)
|
||||
"host_net_add ", ' ', net->vlan, NULL, &cmd) < 0)
|
||||
return -1;
|
||||
|
||||
remove_cmd = NULL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user