Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

Commit

Permalink
qemu: add IOMMU Device
Browse files Browse the repository at this point in the history
The following options can be provided

Intremap: activates interrupt remapping
DeviceIotlb: enables device IOTLB support for the vIOMMU
CachingMode: enables Cahing Mode

See: https://wiki.qemu.org/Features/VT-d

Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
  • Loading branch information
amorenoz committed May 22, 2020
1 parent 10b22ac commit 1034c6d
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions qemu/qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -1861,6 +1861,51 @@ func (b BalloonDevice) deviceName(config *Config) string {
return BalloonDeviceTransport[b.Transport]
}

type IommuDev struct {
Intremap bool
DeviceIotlb bool
CachingMode bool
}

// Valid returns true if the IommuDev is valid
func (dev IommuDev) Valid() bool {
return true
}

// deviceName the qemu device name
func (dev IommuDev) deviceName() string {
return "intel-iommu"
}

// QemuParams returns the qemu parameters built out of the IommuDev.
func (dev IommuDev) QemuParams(_ *Config) []string {
var qemuParams []string
var deviceParams []string

deviceParams = append(deviceParams, dev.deviceName())
if dev.Intremap {
deviceParams = append(deviceParams, "intremap=on")
} else {
deviceParams = append(deviceParams, "intremap=off")
}

if dev.DeviceIotlb {
deviceParams = append(deviceParams, "device-iotlb=on")
} else {
deviceParams = append(deviceParams, "device-iotlb=off")
}

if dev.CachingMode {
deviceParams = append(deviceParams, "caching-mode=on")
} else {
deviceParams = append(deviceParams, "caching-mode=off")
}

qemuParams = append(qemuParams, "-device")
qemuParams = append(qemuParams, strings.Join(deviceParams, ","))
return qemuParams
}

// RTCBaseType is the qemu RTC base time type.
type RTCBaseType string

Expand Down

0 comments on commit 1034c6d

Please sign in to comment.