qemu_domain: Separate VFIO code

This piece of code will be re-used later.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
ACKed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Michal Privoznik 2019-06-24 10:01:16 +02:00
parent 84d11903e1
commit 610858d282
4 changed files with 23 additions and 11 deletions

View File

@ -31346,6 +31346,23 @@ virDomainDefHasManagedPR(const virDomainDef *def)
}
bool
virDomainDefHasVFIOHostdev(const virDomainDef *def)
{
size_t i;
for (i = 0; i < def->nhostdevs; i++) {
const virDomainHostdevDef *tmp = def->hostdevs[i];
if (tmp->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
tmp->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI &&
tmp->source.subsys.u.pci.backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO)
return true;
}
return false;
}
/**
* virDomainGraphicsDefHasOpenGL:
* @def: domain definition

View File

@ -3627,6 +3627,9 @@ virDomainDiskGetDetectZeroesMode(virDomainDiskDiscard discard,
bool
virDomainDefHasManagedPR(const virDomainDef *def);
bool
virDomainDefHasVFIOHostdev(const virDomainDef *def);
bool
virDomainGraphicsDefHasOpenGL(const virDomainDef *def);

View File

@ -298,6 +298,7 @@ virDomainDefHasMemballoon;
virDomainDefHasMemoryHotplug;
virDomainDefHasUSB;
virDomainDefHasVcpusOffline;
virDomainDefHasVFIOHostdev;
virDomainDefLifecycleActionAllowed;
virDomainDefMaybeAddController;
virDomainDefMaybeAddInput;

View File

@ -12359,7 +12359,7 @@ qemuDomainGetHostdevPath(virDomainDefPtr def,
bool includeVFIO = false;
char **tmpPaths = NULL;
int *tmpPerms = NULL;
size_t i, tmpNpaths = 0;
size_t tmpNpaths = 0;
int perm = 0;
*npaths = 0;
@ -12382,16 +12382,7 @@ qemuDomainGetHostdevPath(virDomainDefPtr def,
perm = VIR_CGROUP_DEVICE_RW;
if (teardown) {
size_t nvfios = 0;
for (i = 0; i < def->nhostdevs; i++) {
virDomainHostdevDefPtr tmp = def->hostdevs[i];
if (tmp->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
tmp->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI &&
tmp->source.subsys.u.pci.backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO)
nvfios++;
}
if (nvfios == 0)
if (!virDomainDefHasVFIOHostdev(def))
includeVFIO = true;
} else {
includeVFIO = true;