Commit Graph

65 Commits

Author SHA1 Message Date
Qi Feng Huo
cf0f05d2e9 qemu: add iommu_platform knob for qemuParams
Signed-off-by: Qi Feng Huo <huoqif@cn.ibm.com>

fix typo

Signed-off-by: Qi Feng Huo <huoqif@cn.ibm.com>

qemu: remove useless fmt.Sprintf for qemuParams

Signed-off-by: Qi Feng Huo <huoqif@cn.ibm.com>

fix test cases for s390x

Signed-off-by: Qi Feng Huo <huoqif@cn.ibm.com>
2020-07-30 22:19:49 +08:00
Liam Merwick
6645baf249 qemu: Add NoReboot config Knob for qemuParams
The Kata architecture does not support rebooting VMs (the lifecycle
being start/exec/kill) and if a VM is killed (e.g. using sysrq-trigger),
the VM does not exit fully and other layers do not notice the state change.
Kata needs a way to tell QEMU to run with the '--no-reboot' option
so that the guest VM exits and does not attempt to reboot.

Add a NoReboot boolean Knob so when Knobs.NoReboot is set, the '--no-reboot'
command-line option will be passed to QEMU on startup.

Signed-off-by: Liam Merwick <liam.merwick@oracle.com>
2020-07-27 15:04:54 +01:00
Julio Montes
abca6f3ce9 Add multidevs option to fsdev
multidevs specifies how to deal with multiple devices being shared with a 9p
export. `multidevs=remap` fixes the following warning:

```
9p: Multiple devices detected in same VirtFS export, which might lead to file
ID collisions and severe misbehaviours on guest!
You should either use a separate export for each device shared from host or
use virtfs option 'multidevs=remap'!
```

Signed-off-by: Julio Montes <julio.montes@intel.com>
2020-07-23 10:56:22 -05:00
Adrian Moreno
e57e86e2ea qemu: add IOMMU Device
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>
2020-05-26 18:29:02 +02:00
Pradipta Kr. Banerjee
b2aa0225ac Enable Numa support for Power (ppc64le) architecture
Fixes #124
Signed-off-by: bpradipt@in.ibm.com
2020-05-13 01:21:00 +05:30
Julio Montes
ad66e4caf8 Merge pull request #122 from devimc/topic/qemu/maxPorts
qemu: Add max_ports option to virtio-serial device
2020-05-08 13:47:10 -05:00
Shuicheng Lin
29529a5d72 Add rt clock definition for rtc clock in qemu
There are three different types for the RTC clock: host, rt and vm.
Add `rt` to the list of RTC clocks.

Signed-off-by: Shuicheng Lin <shuicheng.lin@intel.com>
2020-05-06 08:43:40 +08:00
Julio Montes
0e98b613a8 qemu: Add max_ports option to virtio-serial device
Allow API consumers to change the maximum number of ports in the virtio-serial
devices, setting a lower number of ports can improve the boot time and
reduce the attack surface.

fixes #120

Signed-off-by: Julio Montes <julio.montes@intel.com>
2020-04-24 15:10:51 +00:00
Liam Merwick
787c86b7e5 qemu: Add microvm machine type support
Following on from #111 which added support for multiple virtio transports,
add code to use virtio-mmio as the transport when booting a guest with
the microvm machine type and add a microvm case when checking for
NUMA support. Also add a test case for machine string parsing.

Signed-off-by: Liam Merwick <liam.merwick@oracle.com>
2020-04-23 22:27:03 +01:00
Peng Tao
3700c55dd7 qemu: add block device readonly support
So that we can attach it readonly.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2020-02-21 08:58:53 +01:00
Mark Ryan
37b0d9c12f Merge pull request #111 from slp/multiple_transports
Refactor code to support multiple virtio transports at runtime
2020-02-18 13:51:07 +01:00
Sergio Lopez
88a25a2d68 Refactor code to support multiple virtio transports at runtime
Currently, virtio transports for each device are determined with
architecture dependent build time conditionals. This isn't the ideal
solution, as virtio transports aren't exactly tied to the host's
architecture.

For example, aarch64 VMs do support both PCI and MMIO devices, and
after the recent introduction of the microvm machine type, that's also
the case for x86_64.

This patch extends each device that supports multiple transports with
a VirtioTransport field, so users of the library can manually specify
a transport for each device. To avoid breaking the compatibility, if
VirtioTransport is empty a behavior equivalent to the legacy one is
achieved by checking runtime.GOARCH and Config.Machine.Type.

Keeping support for isVirtioPCI/isVirtioCCW in qmp.go is a bit
tricky. Eventually, the hot-plug API should be extended so callers
must manually specify the transport for the device.

Signed-off-by: Sergio Lopez <slp@redhat.com>
2020-02-07 18:17:12 +01:00
Fabiano Fidêncio
2ee53b00ca qemu: Don't set ".cache-size=" when CacheSize is 0
As there's no guarantee that ".cache-size" is a supported QEMU property,
let's not add it to the QEMU command line when the user explicitly set
virtio_fs_cache_size to zero.

By not always setting ".cache-size" property we avoid errors like:
```
$ sudo podman --runtime=/usr/bin/kata-runtime run --security-opt label=disable -it fedora:31 /bin/bash
Error: failed to launch qemu: exit status 1, error messages from qemu log: qemu-kvm: -device vhost-user-fs-pci,chardev=char-88c350403e95d3db,tag=kataShared,cache-size=0M: Property '.cache-size' not found: OCI runtime error
```

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
2020-02-07 09:56:36 +01:00
Jimmy Xu
f1252f6e17 qemu: Add pcie-root-port device support. 2020-01-26 21:44:11 +08:00
Jan Schintag
cb9f640b4e virtio-blk: Add support for share-rw flag
This allows multiple instances of qemu to share the same file for
virtio-blk device.

Fixes: #108
Signed-off-by: Jan Schintag <jan.schintag@de.ibm.com>
2019-09-13 08:58:23 +02:00
Alice Frosi
9463486d58 s390x: dimm not supported
Dimm is not supported on s390x

Fixes: #106
Signed-off-by: Alice Frosi <afrosi@de.ibm.com>
2019-08-27 08:37:21 +02:00
Peng Tao
234e0edfd7 qemu: fix memory prealloc handling
Memory preallocation is just a property of different memory backends.
We should treat it similar to memory sharing property. Also rename
FileBackedMemShared to MemShared as it is just another memory backend
property that works with different memory backends not just file backed
memory.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2019-08-14 00:32:00 -07:00
Peng Tao
30bfcaaa6d qemu: add debug logfile
When LogFile is specified, output debug log there.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2019-08-13 01:44:45 -07:00
Ace-Tang
8fd28e23ac Support x-pci-vendor-id and x-pci-device-id pass to qemu
since some vendor id like 1ded can not be identified by virtio-pci
driver, so upper level need to pass a specified vendor id to qemu.

the upper level will change unavailable id and pass it to qemu.

Signed-off-by: Ace-Tang <aceapril@126.com>
2019-07-09 12:19:51 +08:00
Alice Frosi
713d0d9406 s390x: add virtio-blk-ccw type
In order to hotplug virtio-blk, on s390x the CCW device drivers is used
instad of PCI.

Signed-off-by: Alice Frosi <afrosi@de.ibm.com>
2019-07-05 08:08:25 +02:00
Alice Frosi
9cf98da0be s390x: add devno support
DevNo is used to identify the ccw device for s390x systems

Signed-off-by: Alice Frosi <afrosi@de.ibm.com>
2019-07-05 08:08:25 +02:00
Peng Tao
f695ddf8f3 qemu: add migration incoming defer support
qemu commandline supports -incoming defer
and qmp supports migrate-incoming uri.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2019-06-14 00:24:26 -07:00
lifupan
7d3deea4fc qemu: Add a virtio-blk-pci device driver support
Add a pci bus based virtio block device driver support.

Fixes:#92

Signed-off-by: lifupan <lifupan@gmail.com>
2019-04-16 11:45:50 -04:00
Stefan Hajnoczi
058cda0603 qemu: use MiB instead of Gib for virtio-fs cache size
QEMU supports finer-grained units than GiB.  Change the cache size to
MiB so users have more control over the cache size.

Note that changing the semantics of the CacheSize field is fine because
there are no users of this API yet.  kata-runtime will be the first
users and prefers MiB instead of GiB.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2019-04-09 10:21:43 +01:00
Stefan Hajnoczi
3c84b1daa3 govmm: add VhostUserFS vhost-user device type
The QEMU vhost-user-fs-pci device provides virtio-fs host<->guest file
system sharing (https://virtio-fs.gitlab.io/).  The device is
instantiated like this:

  $ qemu -chardev socket,path=/tmp/vhost-fs.sock,id=chr0
         -device vhost-user-fs-pci,tag=myfs,chardev=chr0,cache-size=4G,versiontable=/dev/shm/fuse_shared_versions

This patch adds the VhostUserFS DeviceDriver and command-line generation
for this QEMU device.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2019-02-19 13:03:18 +00:00
Mark Ryan
cb2ce9339c Fix staticcheck S1008
static check was complaining about code that looked like

if x == "" {
  return false
}

return true

when what it wants to see is return x != "".  This commit fixes the issue.

Signed-off-by: Mark Ryan <mark.d.ryan@intel.com>
2019-01-28 16:17:24 +01:00
Mark Ryan
f0172cd2a6 Fix staticcheck (S1002)
staticcheck was complaining about code that looked like

if x == true {

}

rather than

if x {

}

This commit fixes the issue.

Signed-off-by: Mark Ryan <mark.d.ryan@intel.com>
2019-01-28 16:13:48 +01:00
Mark Ryan
5f2e630bda Fix staticcheck (S1025)
staticcheck was complaining as there were quite a lot of
fmt.Sprintf("%s",d) in the code where d was either a string or
had string as its underlying type.

Signed-off-by: Mark Ryan <mark.d.ryan@intel.com>
2019-01-28 16:06:49 +01:00
Alice Frosi
c80fc3b12f qemu: Add s390x support
The PR adds the s390x support. It sets the CCW devices and sets to false
all the devices in the mapping isVirtioPCI. It reimplements the functions
QemuNetdevParam and QemuDeviceParam to print an error message if the vhost-user
devices are used. It introduces a new function ExecuteNetCCWDeviceAdd for qmp
for the CCW devices.

Fixes: #37

Co-authored-by: Yash D Jain <ydjainopensource@gmail.com>
Signed-off-by: Alice Frosi <afrosi@de.ibm.com>
2018-11-30 10:13:28 +01:00
Mark Ryan
ca477a18b6 Update source file headers
This commit updates the headers in the Go source files to adhere
to the new guidelines in the CONTRIBUTING.md file.

Signed-off-by: Mark Ryan <mark.d.ryan@intel.com>
2018-11-30 09:34:21 +01:00
Alice Frosi
3becff5f4e qemu: change of ContextID from uint32 to uint64
The correct type used by qemu and in kernel is uint64 and this leads to
an endianess problem with ioctl system call. See the issue
https://github.com/kata-containers/runtime/issues/947

Fixes: #70

Signed-off-by: Alice Frosi <afrosi@de.ibm.com>
2018-11-29 12:29:29 +00:00
Sebastien Boeuf
60a5f7ca7f Merge pull request #64 from alicefr/preparation
qemu/qmp: preparation for s390x support
2018-11-27 19:23:58 +00:00
Alice Frosi
e4892e3396 qemu/qmp: preparation for s390x support
This PR prepares for the s390x support. It introduces:
 - a generalization of ccw and pci devices. The variables for the pci devices
   have been renamed by removing the Pci suffix. They have been moved to the
   qemu_arch_base.go
 - the mapping isVirtioPCI has been move to qemu_arch_base.go because in
   this way a different mapping can be added for other architecture (e.g
   s390x)
 - the functions QemuNetdevParam and QemuDeviceParam have been moved to
   qemu_arch_base.go. In this way, they could be reimplemented for other
   architecture for the case VHOSTUSER
 - a function disableModern has been introduced to check if the device is
   a pci device and then returns the right parameters. In the case of ccw
   devices, they don't have the disable-modern flag
 - a function mqParameter has been introduced to return the right
   parameters for the mq case. The virtio-net-ccw device doesn't have the
   vectors flag
 - in qemu_arch_base_test.go contains the test and strings that can be
   overwritten for other architectures (e.g s390). The devices names and
   the flags for the devices can be overwritten.
 - the string for the romfile has been replaced by a variable romfile
   that could be left empty if the devices doesn't support a romfile as
   for the ccw devices for s390.
 - clean-up: the disable-modern=on/off options have been changed to
   disable-modern=true/false. In the code there was a mixture of on/true
   off/false

Fixes: #61

Co-authored-by: Yash D Jain <ydjainopensource@gmail.com>
Signed-off-by: Alice Frosi <afrosi@de.ibm.com>
2018-11-23 10:15:09 +00:00
l00397676
10c36a13da qemu: add support for pidfile option
Add input for -pidfile option of qemu, so that we can get pid of
qemu main process, and apply resource limitations to it.

Fixes #62

Signed-off-by: l00397676 <lujingxiao@huawei.com>
2018-11-21 19:51:49 +08:00
Sebastien Boeuf
7fdfc6a4c9 qemu: Add support for romfile option
Any device inheriting from virtio-pci can specify a ROM file. This
option is provisioned by default with "efi-virtio.rom", but most
of the time, firmwares such as OVMF or seabios will already support
what is provided by this ROM file.

In order to reduce the "forced" dependency on such ROM file, govmm
should provide an empty path if the consumer of the library does not
provide one.

This patch reorganizes the list of devices, so that it gets easier to
list which devices inherit from virtio-pci, and then adds the romfile
option to every single device that support this option.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2018-10-10 17:17:36 -07:00
Jose Carlos Venegas Munoz
ec83abe69e qemu: Add virtio-balloon device suppport.
Add support for virtio-balloon.

- Add test
- Support disable-modern
- Support deflate-on-oom

Signed-off-by: Jose Carlos Venegas Munoz <jose.carlos.venegas.munoz@intel.com>
2018-10-05 11:18:31 -05:00
James O. D. Hunt
46970781fa qemu: Show full path to qemu binary at launch time
Rather than show the generic "qemu", log the full path to the
particular qemu binary being used.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2018-10-03 16:41:08 +01:00
Sebastien Boeuf
ef7250508c qemu: Fix the support of PCIe bridge
In case the type of bridge is PCIEBridge, which we expect as ending
up using pcie-pci-bridge device from Qemu, the properties chassis_nr
and shpc don't exist.

This commit simply fixes this use case by removing those parameters
from the command line.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2018-10-02 15:35:49 -07:00
Mark Ryan
c2d92fe208 Merge pull request #48 from bergwolf/memsize
qemu: skip setting system memory if it is set via dimm device
2018-09-26 08:53:24 +02:00
Peng Tao
a429677a0b govmm: fix memory prealloc
The memory-backend-ram should also be set to a numa node instead of
being inserted as a new device. Otherwise it becomes additional memory
and requires explicit online to be available, instead of just being a
backend of the memory specified by -m option.

Signed-off-by: Peng Tao <bergwolf@gmail.com>
2018-09-25 15:01:31 +08:00
Jose Carlos Venegas Munoz
6c3d84ea8c qemu: Add virtio RNG device.
Add support for virtio-rng divice.

Signed-off-by: Jose Carlos Venegas Munoz <jose.carlos.venegas.munoz@intel.com>
2018-09-07 15:11:02 -05:00
Rob Bradford
2706a07be5 qemu: Use the supplied context.Context for launching
This will kill the process when the context is cancelled. As using a nil
context is not permitted it is necessary to substitute with a real
context if it is not initialised in the Config struct.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2018-08-14 15:09:49 +01:00
Rob Bradford
e46092e03a qemu: Do not try and generate invalid RTC parameters
If no RTC is specified in the config then do not generate any RTC command line
options. RTC command line options are optional for QEMU so make Valid() return
false when presented with the empty version of the RTC struct containing empty
strings.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2018-08-10 14:54:22 +01:00
Sebastien Boeuf
131c8d0caa Merge branch 'master' into static-checks 2018-08-02 08:27:54 -07:00
Julio Montes
3830b4419f qemu: add vhostfd and disable-modern to vhost-vsock-pci
`vhostfd` is the vhost file descriptor that holds the socket context ID
`disable-modern` prevents qemu from relying on fast MMIO

Signed-off-by: Julio Montes <julio.montes@intel.com>
2018-07-24 15:24:43 -05:00
Julio Montes
f700a97bee qemu/qmp: implement function to hotplug vsock-pci
Implement function to hotplug vsocks, vsocks are needed
to communicate processes are running inside the VM
with processes are running on the host.

Signed-off-by: Julio Montes <julio.montes@intel.com>
2018-07-16 14:19:43 -05:00
Mark Ryan
430e72c63b qemu,qmp: Enable gas security checker
This commit enables the gas security checker on govmm builds.  The
security checker has signalled 4 issues all of which I've checked
and have determined to be non issues.  These issues are disabled
by this commit.

Signed-off-by: Mark Ryan <mark.d.ryan@intel.com>
2018-06-28 15:56:27 +01:00
Mark Ryan
ffc06e6bc4 qemu,qmp: Add staticcheck to travis and fix errors
This commit enables staticcheck in the travis builds and fixes the existing
errors detected by staticcheck.  There was one type of error repeated in
qemu.go in which the type of some constants was not explicitly specified.

Signed-off-by: Mark Ryan <mark.d.ryan@intel.com>
2018-06-28 15:11:13 +01:00
Peng Tao
e66a9b481b qemu: add appendMemoryKnobs helper
To fix travis failure about cyclomatic complexity in appendKnobs().

Signed-off-by: Peng Tao <bergwolf@gmail.com>
2018-06-23 11:39:28 +08:00
Peng Tao
0ace4176b4 qemu: allow to set migration incoming
It is useful when we want to specify migration incoming source.
Supported source are fd and exec right now.

Signed-off-by: Peng Tao <bergwolf@gmail.com>
2018-06-23 11:39:23 +08:00