From dffb4f96aedcbd5d412a562034f3854c48a6f9c8 Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Tue, 2 Oct 2018 12:13:18 -0700 Subject: [PATCH] virtcontainers: qemu: Add proper support for virt machine type The virt machine type provided by the NEMU project needs to be supported the same way we support pc and q35 machine types. First, this patch takes care of adding the hotpluggable block device capability to this machine type, this way when using devicemapper, we prevent the code from falling back on using 9pfs instead of SCSI. It also add one or several bridges to this machine type, as the code is tightly coupled to the fact that a bridge is required for PCI hotplug. At last, it changes the name of the PCI host bridge (main bus), to use "pcie.0". The default set up from pc machine type "pci.0" is not suitable for this machine type. Fixes #804 Signed-off-by: Sebastien Boeuf --- virtcontainers/qemu.go | 6 ++++-- virtcontainers/qemu_amd64.go | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/virtcontainers/qemu.go b/virtcontainers/qemu.go index 920ed9268b..fcaf70a838 100644 --- a/virtcontainers/qemu.go +++ b/virtcontainers/qemu.go @@ -1194,7 +1194,8 @@ func (q *qemu) disconnect() { // genericAppendBridges appends to devices the given bridges func genericAppendBridges(devices []govmmQemu.Device, bridges []Bridge, machineType string) []govmmQemu.Device { bus := defaultPCBridgeBus - if machineType == QemuQ35 { + switch machineType { + case QemuQ35, QemuVirt: bus = defaultBridgeBus } @@ -1227,13 +1228,14 @@ func genericBridges(number uint32, machineType string) []Bridge { var bt bridgeType switch machineType { - case QemuQ35: // currently only pci bridges are supported // qemu-2.10 will introduce pcie bridges fallthrough case QemuPC: bt = pciBridge + case QemuVirt: + bt = pcieBridge case QemuPseries: bt = pciBridge default: diff --git a/virtcontainers/qemu_amd64.go b/virtcontainers/qemu_amd64.go index 12089516d8..5eb002ff26 100644 --- a/virtcontainers/qemu_amd64.go +++ b/virtcontainers/qemu_amd64.go @@ -102,7 +102,9 @@ func newQemuArch(config HypervisorConfig) qemuArch { func (q *qemuAmd64) capabilities() capabilities { var caps capabilities - if q.machineType == QemuPC || q.machineType == QemuQ35 { + if q.machineType == QemuPC || + q.machineType == QemuQ35 || + q.machineType == QemuVirt { caps.setBlockDeviceHotplugSupport() }