aboutsummaryrefslogtreecommitdiff
path: root/hw/i386/x86-iommu.c
diff options
context:
space:
mode:
authorPeter Xu <peterx@redhat.com>2016-07-14 13:56:12 +0800
committerMichael S. Tsirkin <mst@redhat.com>2016-07-20 19:30:27 +0300
commit1cf5fd573f536de1eb601ed69127a324e940d37f (patch)
tree5d67a7261759a8159faec8cb8eb44c68ffe1b8ec /hw/i386/x86-iommu.c
parent04af0e18bc93c49faa94921b4326ef9261a2fa27 (diff)
downloadqemu-1cf5fd573f536de1eb601ed69127a324e940d37f.zip
qemu-1cf5fd573f536de1eb601ed69127a324e940d37f.tar.gz
qemu-1cf5fd573f536de1eb601ed69127a324e940d37f.tar.bz2
x86-iommu: provide x86_iommu_get_default
Instead of searching the device tree every time, one static variable is declared for the default system x86 IOMMU device. Signed-off-by: Peter Xu <peterx@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/i386/x86-iommu.c')
-rw-r--r--hw/i386/x86-iommu.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/hw/i386/x86-iommu.c b/hw/i386/x86-iommu.c
index d739afb..f395139 100644
--- a/hw/i386/x86-iommu.c
+++ b/hw/i386/x86-iommu.c
@@ -21,6 +21,28 @@
#include "hw/sysbus.h"
#include "hw/boards.h"
#include "hw/i386/x86-iommu.h"
+#include "qemu/error-report.h"
+
+/* Default X86 IOMMU device */
+static X86IOMMUState *x86_iommu_default = NULL;
+
+static void x86_iommu_set_default(X86IOMMUState *x86_iommu)
+{
+ assert(x86_iommu);
+
+ if (x86_iommu_default) {
+ error_report("QEMU does not support multiple vIOMMUs "
+ "for x86 yet.");
+ exit(1);
+ }
+
+ x86_iommu_default = x86_iommu;
+}
+
+X86IOMMUState *x86_iommu_get_default(void)
+{
+ return x86_iommu_default;
+}
static void x86_iommu_realize(DeviceState *dev, Error **errp)
{
@@ -28,6 +50,7 @@ static void x86_iommu_realize(DeviceState *dev, Error **errp)
if (x86_class->realize) {
x86_class->realize(dev, errp);
}
+ x86_iommu_set_default(X86_IOMMU_DEVICE(dev));
}
static void x86_iommu_class_init(ObjectClass *klass, void *data)