From 4ed500c9eadccda8e96a95773e6751642b905b1a Mon Sep 17 00:00:00 2001 From: Joel Granados Date: Mon, 21 Jul 2025 21:46:03 +0200 Subject: [PATCH] iommu: add a new library call for intel iommu This is preferred to adding it with the global as it is valid regardles of what base is used Signed-off-by: Joel Granados --- lib/qemu/iommu | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 lib/qemu/iommu diff --git a/lib/qemu/iommu b/lib/qemu/iommu new file mode 100644 index 0000000..f7c42e1 --- /dev/null +++ b/lib/qemu/iommu @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: GPL-3.0-or-later +# Copyright (c) 2025 Samsung Electronics Co., Ltd. All Rights Reserved. +# +# Written by Joel Granados + +qemu_viommu_intel() { + local long="extra-args:" + + if ! tmp=$(getopt -o "" --long "$long" -n "${FUNCNAME[0]}" -- "$@"); then + exit 1 + fi + + eval set -- "$tmp" + unset tmp + + while true; do + case "$1" in + '--extra-args' ) + local extra_args="$2"; shift 2 + ;; + '--' ) + shift; break + ;; + * ) + _fatal 1 "unknown argument '$1'" + ;; + esac + done + + local iommu_arg="intel-iommu,intremap=on" + + if [[ -v extra_args ]]; then + iommu_arg="${iommu_arg},${extra_args}" + fi + + QEMU_PARAMS+=("-device" "${iommu_arg}") +}