1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-20 07:59:00 +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:
Mark McLoughlin 2009-07-22 20:17:14 +01:00
parent a3f33b6531
commit 32db8dd75b
3 changed files with 14 additions and 7 deletions

View File

@ -1181,13 +1181,13 @@ qemuBuildHostNetStr(virConnectPtr conn,
const char *prefix, const char *prefix,
char type_sep, char type_sep,
int vlan, int vlan,
int tapfd, const char *tapfd,
char **str) char **str)
{ {
switch (net->type) { switch (net->type) {
case VIR_DOMAIN_NET_TYPE_NETWORK: case VIR_DOMAIN_NET_TYPE_NETWORK:
case VIR_DOMAIN_NET_TYPE_BRIDGE: 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 : "", prefix ? prefix : "",
type_sep, tapfd, vlan, type_sep, tapfd, vlan,
(net->hostnet_name ? ",name=" : ""), (net->hostnet_name ? ",name=" : ""),
@ -1805,7 +1805,7 @@ int qemudBuildCommandLine(virConnectPtr conn,
for (i = 0 ; i < def->nnets ; i++) { for (i = 0 ; i < def->nnets ; i++) {
virDomainNetDefPtr net = def->nets[i]; virDomainNetDefPtr net = def->nets[i];
char *nic, *host; char *nic, *host;
int tapfd = -1; char *tapfd_name = NULL;
net->vlan = i; net->vlan = i;
@ -1821,7 +1821,7 @@ int qemudBuildCommandLine(virConnectPtr conn,
if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK || if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK ||
net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) { net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) {
tapfd = qemudNetworkIfaceConnect(conn, driver, net, qemuCmdFlags); int tapfd = qemudNetworkIfaceConnect(conn, driver, net, qemuCmdFlags);
if (tapfd < 0) if (tapfd < 0)
goto error; goto error;
@ -1831,14 +1831,21 @@ int qemudBuildCommandLine(virConnectPtr conn,
} }
(*tapfds)[(*ntapfds)++] = tapfd; (*tapfds)[(*ntapfds)++] = tapfd;
if (virAsprintf(&tapfd_name, "%d", tapfd) < 0)
goto no_memory;
} }
if (qemuBuildHostNetStr(conn, net, NULL, ',', if (qemuBuildHostNetStr(conn, net, NULL, ',',
net->vlan, tapfd, &host) < 0) net->vlan, tapfd_name, &host) < 0) {
VIR_FREE(tapfd_name);
goto error; goto error;
}
ADD_ARG_LIT("-net"); ADD_ARG_LIT("-net");
ADD_ARG(host); ADD_ARG(host);
VIR_FREE(tapfd_name);
} }
} }

View File

@ -155,7 +155,7 @@ int qemuBuildHostNetStr (virConnectPtr conn,
const char *prefix, const char *prefix,
char type_sep, char type_sep,
int vlan, int vlan,
int tapfd, const char *tapfd,
char **str); char **str);
int qemuBuildNicStr (virConnectPtr conn, int qemuBuildNicStr (virConnectPtr conn,

View File

@ -4896,7 +4896,7 @@ static int qemudDomainAttachNetDevice(virConnectPtr conn,
net->vlan = vm->def->nets[i]->vlan; net->vlan = vm->def->nets[i]->vlan;
if (qemuBuildHostNetStr(conn, net, if (qemuBuildHostNetStr(conn, net,
"host_net_add ", ' ', net->vlan, -1, &cmd) < 0) "host_net_add ", ' ', net->vlan, NULL, &cmd) < 0)
return -1; return -1;
remove_cmd = NULL; remove_cmd = NULL;