[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 8/8] x86-iommu: Fail early if vIOMMU specified after vfio-pci
From: |
Peter Xu |
Subject: |
Re: [PATCH 8/8] x86-iommu: Fail early if vIOMMU specified after vfio-pci |
Date: |
Fri, 22 Oct 2021 10:37:30 +0800 |
On Thu, Oct 21, 2021 at 02:38:54PM +0200, Eric Auger wrote:
> Hi Peter,
>
> On 10/21/21 12:42 PM, Peter Xu wrote:
> > Scan the pci bus to make sure there's no vfio-pci device attached before
> > vIOMMU
> > is realized.
> >
> > Suggested-by: Igor Mammedov <imammedo@redhat.com>
> > Signed-off-by: Peter Xu <peterx@redhat.com>
> > ---
> > hw/i386/x86-iommu.c | 18 ++++++++++++++++++
> > 1 file changed, 18 insertions(+)
> >
> > diff --git a/hw/i386/x86-iommu.c b/hw/i386/x86-iommu.c
> > index 86ad03972e..58abce7edc 100644
> > --- a/hw/i386/x86-iommu.c
> > +++ b/hw/i386/x86-iommu.c
> > @@ -21,6 +21,7 @@
> > #include "hw/sysbus.h"
> > #include "hw/i386/x86-iommu.h"
> > #include "hw/qdev-properties.h"
> > +#include "hw/vfio/pci.h"
> > #include "hw/i386/pc.h"
> > #include "qapi/error.h"
> > #include "qemu/error-report.h"
> > @@ -103,6 +104,16 @@ IommuType x86_iommu_get_type(void)
> > return x86_iommu_default->type;
> > }
> >
> > +static void x86_iommu_pci_dev_hook(PCIBus *bus, PCIDevice *dev, void
> > *opaque)
> > +{
> > + Error **errp = (Error **)opaque;
> > +
> > + if (object_dynamic_cast(OBJECT(dev), TYPE_VFIO_PCI)) {
> > + error_setg(errp, "Device '%s' must be specified before vIOMMUs",
> > + TYPE_VFIO_PCI);
> if there are several VFIO-PCI devices set before the IOMMU, errp may be
> overriden
> as we do not exit the loop as soon as there is an error I think
Hmm, good point. I won't worry too much about overriding yet as if there're
more devices violating the rule then reporting any of them should work - then
as the user tune the qemu cmdline it'll finally go right.
But I do see that error_setv() has an assertion on *errp being NULL.. I'll at
least make sure it won't trigger that assert by accident.
Thanks for spotting it!
--
Peter Xu
- Re: [PATCH 6/8] pci: Use pci_for_each_root_bus() in current code, (continued)
- [PATCH 7/8] pci: Add pci_for_each_device_all(), Peter Xu, 2021/10/21
- [PATCH 8/8] x86-iommu: Fail early if vIOMMU specified after vfio-pci, Peter Xu, 2021/10/21
- Re: [PATCH 8/8] x86-iommu: Fail early if vIOMMU specified after vfio-pci, Michael S. Tsirkin, 2021/10/21
- Re: [PATCH 8/8] x86-iommu: Fail early if vIOMMU specified after vfio-pci, Eric Auger, 2021/10/21
- Re: [PATCH 8/8] x86-iommu: Fail early if vIOMMU specified after vfio-pci,
Peter Xu <=
- Re: [PATCH 8/8] x86-iommu: Fail early if vIOMMU specified after vfio-pci, Alex Williamson, 2021/10/21
- Re: [PATCH 8/8] x86-iommu: Fail early if vIOMMU specified after vfio-pci, Peter Xu, 2021/10/21
- Re: [PATCH 8/8] x86-iommu: Fail early if vIOMMU specified after vfio-pci, Igor Mammedov, 2021/10/26
- Re: [PATCH 8/8] x86-iommu: Fail early if vIOMMU specified after vfio-pci, Alex Williamson, 2021/10/26
- Re: [PATCH 8/8] x86-iommu: Fail early if vIOMMU specified after vfio-pci, Peter Xu, 2021/10/27
- Re: [PATCH 8/8] x86-iommu: Fail early if vIOMMU specified after vfio-pci, Peter Xu, 2021/10/27