[libvirt] [PATCH v2 04/39] qemu_hostdev: Introduce qemuHostdevNeedsVFIO()

Michal Privoznik posted 39 patches 6 years, 4 months ago
There is a newer version of this series
[libvirt] [PATCH v2 04/39] qemu_hostdev: Introduce qemuHostdevNeedsVFIO()
Posted by Michal Privoznik 6 years, 4 months ago
There are two types of host devices that require /dev/vfio/vfio
access:

  1) PCI devices with VFIO backend
  2) Mediated devices

Introduce a simple helper that returns true if passed @hostdev
falls in either of the categories.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/qemu/qemu_hostdev.c | 9 +++++++++
 src/qemu/qemu_hostdev.h | 2 ++
 2 files changed, 11 insertions(+)

diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c
index af41c32679..ebbca817b8 100644
--- a/src/qemu/qemu_hostdev.c
+++ b/src/qemu/qemu_hostdev.c
@@ -118,6 +118,15 @@ qemuHostdevUpdateActiveDomainDevices(virQEMUDriverPtr driver,
     return 0;
 }
 
+
+bool
+qemuHostdevNeedsVFIO(const virDomainHostdevDef *hostdev)
+{
+    return virHostdevIsVFIODevice(hostdev) ||
+        virHostdevIsMdevDevice(hostdev);
+}
+
+
 bool
 qemuHostdevHostSupportsPassthroughVFIO(void)
 {
diff --git a/src/qemu/qemu_hostdev.h b/src/qemu/qemu_hostdev.h
index e99c204961..536069fe8a 100644
--- a/src/qemu/qemu_hostdev.h
+++ b/src/qemu/qemu_hostdev.h
@@ -24,6 +24,8 @@
 #include "qemu_conf.h"
 #include "domain_conf.h"
 
+bool qemuHostdevNeedsVFIO(const virDomainHostdevDef *hostdev);
+
 bool qemuHostdevHostSupportsPassthroughVFIO(void);
 
 int qemuHostdevUpdateActiveMediatedDevices(virQEMUDriverPtr driver,
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 04/39] qemu_hostdev: Introduce qemuHostdevNeedsVFIO()
Posted by Cole Robinson 6 years, 3 months ago
On 9/26/19 12:12 PM, Michal Privoznik wrote:
> There are two types of host devices that require /dev/vfio/vfio
> access:
> 
>   1) PCI devices with VFIO backend
>   2) Mediated devices
> 
> Introduce a simple helper that returns true if passed @hostdev
> falls in either of the categories.
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  src/qemu/qemu_hostdev.c | 9 +++++++++
>  src/qemu/qemu_hostdev.h | 2 ++
>  2 files changed, 11 insertions(+)
> 
> diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c
> index af41c32679..ebbca817b8 100644
> --- a/src/qemu/qemu_hostdev.c
> +++ b/src/qemu/qemu_hostdev.c
> @@ -118,6 +118,15 @@ qemuHostdevUpdateActiveDomainDevices(virQEMUDriverPtr driver,
>      return 0;
>  }
>  
> +
> +bool
> +qemuHostdevNeedsVFIO(const virDomainHostdevDef *hostdev)
> +{
> +    return virHostdevIsVFIODevice(hostdev) ||
> +        virHostdevIsMdevDevice(hostdev);
> +}
> +
> +
>  bool
>  qemuHostdevHostSupportsPassthroughVFIO(void)
>  {

Converts from single to double spacing between functions, but I see this
file is inconsistent anyways so no objection from me. Would be nice to
standardize the codebase on double spacing IMO. I don't know if we have
a guidelines for that one way or the other though? Anyways...

Reviewed-by: Cole Robinson <crobinso@redhat.com>

- Cole

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list