mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-18 10:35:20 +00:00
qemu: Convert passing of 'vhostfd' to 'qemuFDPassDirect'
Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
bca9047906
commit
7869eb9b31
@ -4224,7 +4224,7 @@ qemuBuildHostNetProps(virDomainNetDef *net)
|
||||
|
||||
nfds = 0;
|
||||
for (n = netpriv->vhostfds; n; n = n->next) {
|
||||
virBufferAsprintf(&buf, "%s:", qemuFDPassGetPath(n->data));
|
||||
virBufferAsprintf(&buf, "%s:", qemuFDPassDirectGetPath(n->data));
|
||||
nfds++;
|
||||
}
|
||||
|
||||
@ -8886,10 +8886,8 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver,
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (n = netpriv->vhostfds; n; n = n->next) {
|
||||
if (qemuFDPassTransferCommand(n->data, cmd) < 0)
|
||||
return -1;
|
||||
}
|
||||
for (n = netpriv->vhostfds; n; n = n->next)
|
||||
qemuFDPassDirectTransferCommand(n->data, cmd);
|
||||
|
||||
if (qemuFDPassTransferCommand(netpriv->slirpfd, cmd) < 0 ||
|
||||
qemuFDPassTransferCommand(netpriv->vdpafd, cmd) < 0)
|
||||
|
@ -1053,7 +1053,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) qemuFDPassFree);
|
||||
g_slist_free_full(g_steal_pointer(&priv->vhostfds), (GDestroyNotify) qemuFDPassDirectFree);
|
||||
g_slist_free_full(g_steal_pointer(&priv->tapfds), (GDestroyNotify) qemuFDPassFree);
|
||||
}
|
||||
|
||||
|
@ -405,7 +405,7 @@ struct _qemuDomainNetworkPrivate {
|
||||
/* file descriptor transfer helpers */
|
||||
qemuFDPass *slirpfd;
|
||||
GSList *tapfds;
|
||||
GSList *vhostfds;
|
||||
GSList *vhostfds; /* qemuFDPassDirect */
|
||||
qemuFDPass *vdpafd;
|
||||
};
|
||||
|
||||
|
@ -1380,7 +1380,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver,
|
||||
}
|
||||
|
||||
for (n = netpriv->vhostfds; n; n = n->next) {
|
||||
if (qemuFDPassTransferMonitor(n->data, priv->mon) < 0) {
|
||||
if (qemuFDPassDirectTransferMonitor(n->data, priv->mon) < 0) {
|
||||
qemuDomainObjExitMonitor(vm);
|
||||
goto cleanup;
|
||||
}
|
||||
@ -1528,7 +1528,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver,
|
||||
qemuFDPassTransferMonitorRollback(n->data, priv->mon);
|
||||
|
||||
for (n = netpriv->vhostfds; n; n = n->next)
|
||||
qemuFDPassTransferMonitorRollback(n->data, priv->mon);
|
||||
qemuFDPassDirectTransferMonitorRollback(n->data, priv->mon);
|
||||
|
||||
qemuDomainObjExitMonitor(vm);
|
||||
virErrorRestore(&originalError);
|
||||
|
@ -700,12 +700,10 @@ int
|
||||
qemuInterfaceOpenVhostNet(virDomainObj *vm,
|
||||
virDomainNetDef *net)
|
||||
{
|
||||
qemuDomainObjPrivate *priv = vm->privateData;
|
||||
qemuDomainNetworkPrivate *netpriv = QEMU_DOMAIN_NETWORK_PRIVATE(net);
|
||||
size_t i;
|
||||
const char *vhostnet_path = net->backend.vhost;
|
||||
size_t vhostfdSize = net->driver.virtio.queues;
|
||||
g_autofree char *prefix = g_strdup_printf("vhostfd-%s", net->info.alias);
|
||||
|
||||
if (!vhostfdSize)
|
||||
vhostfdSize = 1;
|
||||
@ -743,8 +741,7 @@ qemuInterfaceOpenVhostNet(virDomainObj *vm,
|
||||
|
||||
for (i = 0; i < vhostfdSize; i++) {
|
||||
VIR_AUTOCLOSE fd = open(vhostnet_path, O_RDWR);
|
||||
g_autoptr(qemuFDPass) pass = qemuFDPassNewDirect(prefix, priv);
|
||||
g_autofree char *suffix = g_strdup_printf("%zu", i);
|
||||
g_autofree char *name = g_strdup_printf("vhostfd-%s%zu", net->info.alias, i);
|
||||
|
||||
/* If the config says explicitly to use vhost and we couldn't open it,
|
||||
* report an error.
|
||||
@ -761,8 +758,7 @@ qemuInterfaceOpenVhostNet(virDomainObj *vm,
|
||||
break;
|
||||
}
|
||||
|
||||
qemuFDPassAddFD(pass, &fd, suffix);
|
||||
netpriv->vhostfds = g_slist_prepend(netpriv->vhostfds, g_steal_pointer(&pass));
|
||||
netpriv->vhostfds = g_slist_prepend(netpriv->vhostfds, qemuFDPassDirectNew(name, &fd));
|
||||
}
|
||||
|
||||
netpriv->vhostfds = g_slist_reverse(netpriv->vhostfds);
|
||||
|
@ -226,12 +226,10 @@ virNetDevOpenvswitchGetVhostuserIfname(const char *path G_GNUC_UNUSED,
|
||||
}
|
||||
|
||||
int
|
||||
qemuInterfaceOpenVhostNet(virDomainObj *vm,
|
||||
qemuInterfaceOpenVhostNet(virDomainObj *vm G_GNUC_UNUSED,
|
||||
virDomainNetDef *net)
|
||||
{
|
||||
qemuDomainObjPrivate *priv = vm->privateData;
|
||||
qemuDomainNetworkPrivate *netpriv = QEMU_DOMAIN_NETWORK_PRIVATE(net);
|
||||
g_autofree char *prefix = g_strdup_printf("vhostfd-%s", net->info.alias);
|
||||
size_t vhostfdSize = net->driver.virtio.queues;
|
||||
size_t i;
|
||||
|
||||
@ -242,12 +240,10 @@ qemuInterfaceOpenVhostNet(virDomainObj *vm,
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < vhostfdSize; i++) {
|
||||
g_autoptr(qemuFDPass) pass = qemuFDPassNewDirect(prefix, priv);
|
||||
g_autofree char *suffix = g_strdup_printf("%zu", i);
|
||||
g_autofree char *name = g_strdup_printf("vhostfd-%s%zu", net->info.alias, i);
|
||||
int fd = STDERR_FILENO + 42 + i;
|
||||
|
||||
qemuFDPassAddFD(pass, &fd, suffix);
|
||||
netpriv->vhostfds = g_slist_prepend(netpriv->vhostfds, g_steal_pointer(&pass));
|
||||
netpriv->vhostfds = g_slist_prepend(netpriv->vhostfds, qemuFDPassDirectNew(name, &fd));
|
||||
}
|
||||
|
||||
netpriv->vhostfds = g_slist_reverse(netpriv->vhostfds);
|
||||
|
Loading…
x
Reference in New Issue
Block a user