mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
qemu: make vdpa connect function more generic
qemuInterfaceVDPAConnect() was a helper function for connecting to the vdpa device file. But in order to support other vdpa devices besides network interfaces (e.g. vdpa block devices) make this function a bit more generic. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
6cf7dbeff8
commit
0ebb416d7e
@ -8533,7 +8533,7 @@ qemuBuildInterfaceConnect(virDomainObj *vm,
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_NET_TYPE_VDPA:
|
||||
if ((vdpafd = qemuInterfaceVDPAConnect(net)) < 0)
|
||||
if ((vdpafd = qemuVDPAConnect(net->data.vdpa.devicepath)) < 0)
|
||||
return -1;
|
||||
|
||||
netpriv->vdpafd = qemuFDPassNew(net->info.alias, priv);
|
||||
@ -10993,3 +10993,24 @@ qemuBuildStorageSourceChainAttachPrepareBlockdevTop(virStorageSource *top,
|
||||
|
||||
return g_steal_pointer(&data);
|
||||
}
|
||||
|
||||
|
||||
/* qemuVDPAConnect:
|
||||
* @devicepath: the path to the vdpa device
|
||||
*
|
||||
* returns: file descriptor of the vdpa device
|
||||
*/
|
||||
int
|
||||
qemuVDPAConnect(const char *devicepath)
|
||||
{
|
||||
int fd;
|
||||
|
||||
if ((fd = open(devicepath, O_RDWR)) < 0) {
|
||||
virReportSystemError(errno,
|
||||
_("Unable to open '%1$s' for vdpa device"),
|
||||
devicepath);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
@ -248,3 +248,4 @@ qemuBuildTPMOpenBackendFDs(const char *tpmdev,
|
||||
|
||||
const char * qemuAudioDriverTypeToString(virDomainAudioType type);
|
||||
virDomainAudioType qemuAudioDriverTypeFromString(const char *str);
|
||||
int qemuVDPAConnect(const char *devicepath) G_NO_INLINE;
|
||||
|
@ -648,29 +648,6 @@ qemuInterfaceBridgeConnect(virDomainDef *def,
|
||||
}
|
||||
|
||||
|
||||
/* qemuInterfaceVDPAConnect:
|
||||
* @net: pointer to the VM's interface description
|
||||
*
|
||||
* returns: file descriptor of the vdpa device
|
||||
*
|
||||
* Called *only* called if actualType is VIR_DOMAIN_NET_TYPE_VDPA
|
||||
*/
|
||||
int
|
||||
qemuInterfaceVDPAConnect(virDomainNetDef *net)
|
||||
{
|
||||
int fd;
|
||||
|
||||
if ((fd = open(net->data.vdpa.devicepath, O_RDWR)) < 0) {
|
||||
virReportSystemError(errno,
|
||||
_("Unable to open '%1$s' for vdpa device"),
|
||||
net->data.vdpa.devicepath);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Returns: -1 on error, 0 on success. Populates net->privateData->slirp if
|
||||
* the slirp helper is needed.
|
||||
|
@ -55,5 +55,3 @@ int qemuInterfaceOpenVhostNet(virDomainObj *def,
|
||||
|
||||
int qemuInterfacePrepareSlirp(virQEMUDriver *driver,
|
||||
virDomainNetDef *net);
|
||||
|
||||
int qemuInterfaceVDPAConnect(virDomainNetDef *net) G_NO_INLINE;
|
||||
|
@ -18,8 +18,8 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "qemu/qemu_command.h"
|
||||
#include "qemu/qemu_hotplug.h"
|
||||
#include "qemu/qemu_interface.h"
|
||||
#include "qemu/qemu_process.h"
|
||||
#include "testutilsqemu.h"
|
||||
#include "conf/domain_conf.h"
|
||||
@ -94,7 +94,7 @@ qemuProcessKillManagedPRDaemon(virDomainObj *vm G_GNUC_UNUSED)
|
||||
}
|
||||
|
||||
int
|
||||
qemuInterfaceVDPAConnect(virDomainNetDef *net G_GNUC_UNUSED)
|
||||
qemuVDPAConnect(const char *devicepath G_GNUC_UNUSED)
|
||||
{
|
||||
/* need a valid fd or sendmsg won't work. Just open /dev/null */
|
||||
return open("/dev/null", O_RDONLY);
|
||||
|
@ -255,7 +255,7 @@ virNetDevBandwidthSetRootQDisc(const char *ifname G_GNUC_UNUSED,
|
||||
|
||||
|
||||
int
|
||||
qemuInterfaceVDPAConnect(virDomainNetDef *net G_GNUC_UNUSED)
|
||||
qemuVDPAConnect(const char *devicepath G_GNUC_UNUSED)
|
||||
{
|
||||
if (fcntl(1732, F_GETFD) != -1)
|
||||
abort();
|
||||
|
Loading…
Reference in New Issue
Block a user