qemu: Convert passing of 'tapfds' to 'qemuFDPassDirect'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2022-05-16 15:08:05 +02:00
parent 7869eb9b31
commit 1715dfce38
4 changed files with 9 additions and 14 deletions

View File

@ -4208,7 +4208,7 @@ qemuBuildHostNetProps(virDomainNetDef *net)
if (netpriv->tapfds) {
nfds = 0;
for (n = netpriv->tapfds; n; n = n->next) {
virBufferAsprintf(&buf, "%s:", qemuFDPassGetPath(n->data));
virBufferAsprintf(&buf, "%s:", qemuFDPassDirectGetPath(n->data));
nfds++;
}
@ -8709,16 +8709,13 @@ qemuBuildInterfaceConnect(virDomainObj *vm,
/* 'vhostfd' is set to true in all cases when we need to process tapfds */
if (vhostfd) {
g_autofree char *prefix = g_strdup_printf("tapfd-%s", net->info.alias);
size_t i;
for (i = 0; i < tapfdSize; i++) {
g_autoptr(qemuFDPass) pass = qemuFDPassNewDirect(prefix, priv);
g_autofree char *suffix = g_strdup_printf("%zu", i);
g_autofree char *name = g_strdup_printf("tapfd-%s%zu", net->info.alias, i);
int fd = tapfd[i]; /* we want to keep the array intact for security labeling*/
qemuFDPassAddFD(pass, &fd, suffix);
netpriv->tapfds = g_slist_prepend(netpriv->tapfds, g_steal_pointer(&pass));
netpriv->tapfds = g_slist_prepend(netpriv->tapfds, qemuFDPassDirectNew(name, &fd));
}
netpriv->tapfds = g_slist_reverse(netpriv->tapfds);
@ -8881,10 +8878,8 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver,
virNetDevSetMTU(net->ifname, net->mtu) < 0)
goto cleanup;
for (n = netpriv->tapfds; n; n = n->next) {
if (qemuFDPassTransferCommand(n->data, cmd) < 0)
return -1;
}
for (n = netpriv->tapfds; n; n = n->next)
qemuFDPassDirectTransferCommand(n->data, cmd);
for (n = netpriv->vhostfds; n; n = n->next)
qemuFDPassDirectTransferCommand(n->data, cmd);

View File

@ -1054,7 +1054,7 @@ qemuDomainNetworkPrivateClearFDs(qemuDomainNetworkPrivate *priv)
g_clear_pointer(&priv->slirpfd, qemuFDPassFree);
g_clear_pointer(&priv->vdpafd, qemuFDPassFree);
g_slist_free_full(g_steal_pointer(&priv->vhostfds), (GDestroyNotify) qemuFDPassDirectFree);
g_slist_free_full(g_steal_pointer(&priv->tapfds), (GDestroyNotify) qemuFDPassFree);
g_slist_free_full(g_steal_pointer(&priv->tapfds), (GDestroyNotify) qemuFDPassDirectFree);
}

View File

@ -404,7 +404,7 @@ struct _qemuDomainNetworkPrivate {
/* file descriptor transfer helpers */
qemuFDPass *slirpfd;
GSList *tapfds;
GSList *tapfds; /* qemuFDPassDirect */
GSList *vhostfds; /* qemuFDPassDirect */
qemuFDPass *vdpafd;
};

View File

@ -1373,7 +1373,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver,
qemuDomainObjEnterMonitor(driver, vm);
for (n = netpriv->tapfds; n; n = n->next) {
if (qemuFDPassTransferMonitor(n->data, priv->mon) < 0) {
if (qemuFDPassDirectTransferMonitor(n->data, priv->mon) < 0) {
qemuDomainObjExitMonitor(vm);
goto cleanup;
}
@ -1525,7 +1525,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver,
netdev_name);
for (n = netpriv->tapfds; n; n = n->next)
qemuFDPassTransferMonitorRollback(n->data, priv->mon);
qemuFDPassDirectTransferMonitorRollback(n->data, priv->mon);
for (n = netpriv->vhostfds; n; n = n->next)
qemuFDPassDirectTransferMonitorRollback(n->data, priv->mon);