Commit Graph

84 Commits

Author SHA1 Message Date
Sandeep Gupta
a6cec2d38c qemu: add support for SevGuest object
Signed-off-by: Jim Cadden <jcadden@ibm.com>
2021-05-20 10:08:02 +02:00
Jakob Naucke
abd3c7ea03 qemu: VhostUserDevice CCW device numbers
Add CCW (s390x) device numbers to VhostUserDevices, as is with other
device types. Add them to VhostUserFS devices (the only type currently
supported on s390x) when building QEMU parameters.

Fixes: #170

Signed-off-by: Jakob Naucke <jakob.naucke@ibm.com>
2021-04-28 00:28:25 +02:00
Jakob Naucke
3eaeda7f6d qemu: Refactor vhostuserDev.QemuParams
by splitting out the respective functionality to QemuNetParams,
QemuSCSIParams, QemuBlkParams, and QemuFSParams. This allows adding
functionality to these functions without going beyond the cyclomatic
complexity of 15 mandated by the lint checks.

Signed-off-by: Jakob Naucke <jakob.naucke@ibm.com>
2021-04-28 00:28:11 +02:00
Michael Qiu
511cf58b0c Fix qemu commandline issue with empty romfile
Currently, if romfile field is empty, the commandline will
shows like below:
-device driver=virtio-net-pci,...,mq=on,vectors=4,romfile=

This does not make sense, just remove this field in commandline

Add unittest support.

Signed-off-by: Michael Qiu <qiudayu@huayun.com>
2021-04-22 04:09:16 -04:00
Julio Montes
3141894033 qemu: add support for tdx-guest object
support tdx-guest guest objects

Signed-off-by: Julio Montes <julio.montes@intel.com>
2021-03-30 16:18:11 -06:00
Fabiano Fidêncio
7fbc685865 Merge pull request #161 from Jakob-Naucke/memory-backend
qemu: Append memory backend for non-DIMM setups
2021-03-29 22:58:24 +02:00
GabyCT
4f6a403cde Merge pull request #162 from devimc/2021-03-24/deviceLoader
qemu: add support for device loaders
2021-03-29 10:22:21 -06:00
Jakob Naucke
4b136f3f1c qemu: Append memory backend for non-DIMM setups
Some architectures and setups do not support DIMM/NUMA. However, they
can still use memory backends, provided a memory backend of the same ID
is specified under -machine. This was introduced in QEMU 5.0. Enable
this functionality in appendMemoryKnobs.

Fixes: #160

Signed-off-by: Jakob Naucke <jakob.naucke@ibm.com>
2021-03-29 15:53:39 +02:00
Julio Montes
6213dea42a qemu: support QEMU 6
Use `on` and `off` to enable or disable features,
`no` prefix is deprecated

Signed-off-by: Julio Montes <julio.montes@intel.com>
2021-03-24 11:05:24 -06:00
Julio Montes
0d47025d05 qemu: add support for device loaders
Devices loaders can be used to load some firmwares.

Signed-off-by: Julio Montes <julio.montes@intel.com>
2021-03-24 10:35:45 -06:00
Jianyong Wu
0592c82536 qemu: add arm64 to support list of dimm
dimm is supported on arm64, so add is to check list.

Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
Fixes: #155
2020-11-19 16:44:16 +08:00
Edmond AK Dantes
2079c15c26 qemu: enable "-pflash"
flash image can store some critical data like firmware, enable it here.

Fixes: #140
Signed-off-by: Edmond AK Dantes <edmond.dantes.ak47@outlook.com>
2020-10-22 21:26:23 +08:00
Peng Tao
99f43ec188 Merge pull request #153 from liubin/feature/152-add-pvpanic-and-dump-guest-memory-support
qemu: add pvpanic and dump guest memory support
2020-10-20 13:20:39 +08:00
bin liu
d7836877e9 qemu: add pvpanic device to get GUEST_PANICKED event
Listening to the events channel from QEMU and a guest
panic event issued, then we can get the event and do some
work for the special event.

Fixes: #152

Signed-off-by: bin liu <bin@hyper.sh>
2020-10-19 16:59:37 +08:00
Julio Montes
11b6ac380d Merge pull request #151 from mazzy89/blk-device-serial
Add serial ID to blk device
2020-10-16 08:28:30 -05:00
Salvatore Mazzarino
43d774d27b Add serial to blk device
Signed-off-by: Salvatore Mazzarino <dev@mazzarino.cz>
2020-10-12 17:35:06 +02:00
Salvatore Mazzarino
8cb8b24c05 Make fw_cfg a slice
Signed-off-by: Salvatore Mazzarino <dev@mazzarino.cz>
2020-10-12 12:29:05 +02:00
Salvatore Mazzarino
29ba5a9012 qemu: add fw_cfg flag to config
Signed-off-by: Salvatore Mazzarino <dev@mazzarino.cz>
2020-10-09 10:17:58 +02:00
Jakob-Naucke
39c372a201 Add support for hot-plugging IBM VFIO-AP devices
Add ExecuteAPVFIOMediatedDeviceAdd to qmp.go, which executes a hotplug
for an IBM Adjunct processor (AP) VFIO device (see also
https://www.kernel.org/doc/html/latest/s390/vfio-ap.html )
Also includes the respective unittest and adds the VfioAP DeviceDriver
constant to qemu.go.

Pushing again due to incidental CI failure

Fixes: #133

Signed-off-by: Jakob-Naucke <jakob.naucke@ibm.com>
Reviewed-by: alicefr <afrosi@redhat.com>
2020-08-18 17:35:23 +02:00
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