qemuDomainAttachNetDevice: Use 'qemuFDPass' for the vdpa file descriptor

We use the qemuFDPass infrastructure when building the command line,
refactor the monitor too.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2022-05-06 09:45:08 +02:00
parent 5077263ecb
commit 1d3e955938

View File

@ -1184,8 +1184,8 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver,
virErrorPtr originalError = NULL;
g_autofree char *slirpfdName = NULL;
int slirpfd = -1;
g_autofree char *vdpafdName = NULL;
int vdpafd = -1;
g_autoptr(qemuFDPass) vdpa = NULL;
char **tapfdName = NULL;
int *tapfd = NULL;
size_t tapfdSize = 0;
@ -1394,6 +1394,10 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver,
if ((vdpafd = qemuInterfaceVDPAConnect(net)) < 0)
goto cleanup;
vdpa = qemuFDPassNew(net->info.alias, priv);
qemuFDPassAddFD(vdpa, &vdpafd, "-vdpa");
break;
case VIR_DOMAIN_NET_TYPE_SERVER:
@ -1455,24 +1459,15 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver,
qemuDomainObjEnterMonitor(driver, vm);
if (vdpafd > 0) {
/* vhost-vdpa only accepts a filename. We can pass an open fd by
* filename if we add the fd to an fdset and then pass a filename of
* /dev/fdset/$FDSETID. */
qemuMonitorAddFdInfo fdinfo;
if (qemuMonitorAddFileHandleToSet(priv->mon, vdpafd, -1,
net->data.vdpa.devicepath,
&fdinfo) < 0) {
qemuDomainObjExitMonitor(vm);
goto cleanup;
}
vdpafdName = g_strdup_printf("/dev/fdset/%d", fdinfo.fdset);
if (qemuFDPassTransferMonitor(vdpa, priv->mon) < 0) {
qemuDomainObjExitMonitor(vm);
goto cleanup;
}
if (!(netprops = qemuBuildHostNetProps(net,
tapfdName, tapfdSize,
vhostfdName, vhostfdSize,
slirpfdName, vdpafdName))) {
slirpfdName, qemuFDPassGetPath(vdpa)))) {
qemuDomainObjExitMonitor(vm);
goto cleanup;
}