mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-26 18:41:17 +00:00
qemuBuildInterfaceCommandLine: Use qemuFDPass for the vdpa fd
Use the new helpers for passing of the file descriptor needed for 'vdpa' interfaces. Apart from the simplification in this case it will allow further changes to unify all fdset handling. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
aac5899db9
commit
bfb79de3d3
@ -29,6 +29,7 @@
|
|||||||
#include "qemu_security.h"
|
#include "qemu_security.h"
|
||||||
#include "qemu_slirp.h"
|
#include "qemu_slirp.h"
|
||||||
#include "qemu_block.h"
|
#include "qemu_block.h"
|
||||||
|
#include "qemu_fd.h"
|
||||||
#include "viralloc.h"
|
#include "viralloc.h"
|
||||||
#include "virlog.h"
|
#include "virlog.h"
|
||||||
#include "virarch.h"
|
#include "virarch.h"
|
||||||
@ -8732,6 +8733,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver,
|
|||||||
size_t *nnicindexes,
|
size_t *nnicindexes,
|
||||||
int **nicindexes)
|
int **nicindexes)
|
||||||
{
|
{
|
||||||
|
qemuDomainObjPrivate *priv = vm->privateData;
|
||||||
virDomainDef *def = vm->def;
|
virDomainDef *def = vm->def;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
g_autoptr(virJSONValue) nicprops = NULL;
|
g_autoptr(virJSONValue) nicprops = NULL;
|
||||||
@ -8743,8 +8745,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver,
|
|||||||
char **tapfdName = NULL;
|
char **tapfdName = NULL;
|
||||||
char **vhostfdName = NULL;
|
char **vhostfdName = NULL;
|
||||||
g_autofree char *slirpfdName = NULL;
|
g_autofree char *slirpfdName = NULL;
|
||||||
g_autofree char *vdpafdName = NULL;
|
g_autoptr(qemuFDPass) vdpa = NULL;
|
||||||
int vdpafd = -1;
|
|
||||||
virDomainNetType actualType = virDomainNetGetActualType(net);
|
virDomainNetType actualType = virDomainNetGetActualType(net);
|
||||||
const virNetDevBandwidth *actualBandwidth;
|
const virNetDevBandwidth *actualBandwidth;
|
||||||
bool requireNicdev = false;
|
bool requireNicdev = false;
|
||||||
@ -8823,9 +8824,17 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver,
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_NET_TYPE_VDPA:
|
case VIR_DOMAIN_NET_TYPE_VDPA: {
|
||||||
|
VIR_AUTOCLOSE vdpafd = -1;
|
||||||
|
|
||||||
if ((vdpafd = qemuInterfaceVDPAConnect(net)) < 0)
|
if ((vdpafd = qemuInterfaceVDPAConnect(net)) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
vdpa = qemuFDPassNew(net->data.vdpa.devicepath, priv);
|
||||||
|
|
||||||
|
if (qemuFDPassAddFD(vdpa, &vdpafd, NULL) < 0)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_NET_TYPE_USER:
|
case VIR_DOMAIN_NET_TYPE_USER:
|
||||||
@ -8958,26 +8967,13 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver,
|
|||||||
vhostfd[i] = -1;
|
vhostfd[i] = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vdpafd > 0) {
|
qemuFDPassTransferCommand(vdpa, cmd);
|
||||||
g_autofree char *fdset = NULL;
|
|
||||||
g_autofree char *addfdarg = NULL;
|
|
||||||
size_t idx;
|
|
||||||
|
|
||||||
virCommandPassFDIndex(cmd, vdpafd, VIR_COMMAND_PASS_FD_CLOSE_PARENT, &idx);
|
|
||||||
fdset = qemuBuildFDSet(vdpafd, idx);
|
|
||||||
vdpafdName = g_strdup_printf("/dev/fdset/%zu", idx);
|
|
||||||
/* set opaque to the devicepath so that we can look up the fdset later
|
|
||||||
* if necessary */
|
|
||||||
addfdarg = g_strdup_printf("%s,opaque=%s", fdset,
|
|
||||||
net->data.vdpa.devicepath);
|
|
||||||
virCommandAddArgList(cmd, "-add-fd", addfdarg, NULL);
|
|
||||||
vdpafd = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(hostnetprops = qemuBuildHostNetProps(net,
|
if (!(hostnetprops = qemuBuildHostNetProps(net,
|
||||||
tapfdName, tapfdSize,
|
tapfdName, tapfdSize,
|
||||||
vhostfdName, vhostfdSize,
|
vhostfdName, vhostfdSize,
|
||||||
slirpfdName, vdpafdName)))
|
slirpfdName,
|
||||||
|
qemuFDPassGetPath(vdpa))))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (qemuBuildNetdevCommandlineFromJSON(cmd, hostnetprops, qemuCaps) < 0)
|
if (qemuBuildNetdevCommandlineFromJSON(cmd, hostnetprops, qemuCaps) < 0)
|
||||||
@ -9035,7 +9031,6 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver,
|
|||||||
VIR_FREE(tapfdName);
|
VIR_FREE(tapfdName);
|
||||||
VIR_FREE(vhostfd);
|
VIR_FREE(vhostfd);
|
||||||
VIR_FREE(tapfd);
|
VIR_FREE(tapfd);
|
||||||
VIR_FORCE_CLOSE(vdpafd);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user