Commit Graph

65 Commits

Author SHA1 Message Date
Manohar Castelino
1ed52714c0 qmp: wait for POWERDOWN event in ExecuteSystemPowerdown()
ExecuteSystemPowerdown issues `system_powerdown` and waits
for `SHUTDOWN`. The event emitted is `POWERDOWN` per spec.

Without this we get an error even though the VM has shutdown
gracefully.

Per QEMU spec:

```

POWERDOWN (Event)

Emitted when the virtual machine is powered down through the power
control system, such as via ACPI.

Since

0.12

Example

<- { "event": "POWERDOWN",
     "timestamp": { "seconds": 1267040730, "microseconds": 682951 } }

SHUTDOWN (Event)

Emitted when the virtual machine has shut down, indicating that qemu is
about to exit.

Arguments

guest: boolean
If true, the shutdown was triggered by a guest request (such as a
guest-initiated ACPI shutdown request or other hardware-specific action)
rather than a host request (such as sending qemu a SIGINT). (since 2.10)
reason: ShutdownCause
The ShutdownCause which resulted in the SHUTDOWN. (since 4.0)
Note

If the command-line option “-no-shutdown” has been specified, qemu will
not exit, and a STOP event will eventually follow the SHUTDOWN event

Since

0.12

Example

<- { "event": "SHUTDOWN", "data": { "guest": true },
     "timestamp": { "seconds": 1267040730, "microseconds": 682951 } }

```

Signed-off-by: Manohar Castelino <mcastelino@apple.com>
2021-09-16 13:01:58 -07:00
David Gibson
d8cdf9aa2a qemu: Drop support for versions older than 5.0
Kata requires version 5.2 (or 5.1 on ARM) anyway.  Simplify code by
dropping support for older versions.  In any case explicit checks against
version number aren't necessarily reliable for patched qemu versions.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2021-08-04 13:42:41 +10:00
Marcel Apfelbaum
0e19ffb67e qemu: Allow hot-plugging memory devices on PCI bridges
Currently virtio-mem-pci devices can be hotplugged only on the root bus.
This doesn't work for PCIe machines like q35.

Extend the API to optionally support hotplugging on PCI bridges.

Fixes: #176

Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
2021-06-21 19:55:20 +03:00
Eric Ernst
e2eb549fcd qmp: Add ro argument for block-device hotplug funcs
We should allow users to specify if a block device should be hotplugged
as read-only.

Fixes: #157

Signed-off-by: Eric Ernst <eric.g.ernst@gmail.com>
2021-01-11 15:33:20 -08:00
bin liu
b8cd705901 qmp: add dump-guest-memory support
By adding `dump-guest-memory` command, user can get kernel
memory dump when guest panic occurred.

Fixes: #152

Signed-off-by: bin liu <bin@hyper.sh>
2020-10-19 17:09:12 +08:00
David Gibson
3d46d08a90 Add qom-get function
Add a function to access the qom-get QMP command so we can query
information from qemu.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-09-03 14:05:00 +10: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
Julio Montes
5378725f11 qemu: add pmem flag to memory-backend-file
According to QEMU's nvdimm documentation: When 'pmem' is 'on' and QEMU is
built with libpmem support, QEMU will take necessary operations to guarantee
the persistence of its own writes to the vNVDIMM backend.

Signed-off-by: Julio Montes <julio.montes@intel.com>
2020-03-03 14:28:59 +00:00
Julio Montes
cab4709376
Merge pull request #116 from Jimmy-Xu/add-pcie-root-port
qemu: Add pcie-root-port device support.
2020-01-31 08:07:07 -06:00
Jimmy Xu
f1252f6e17 qemu: Add pcie-root-port device support. 2020-01-26 21:44:11 +08:00
Hui Zhu
6667f4e90b qmp_test: Add TestExecMemdevAdd and TestExecQomSet
Add TestExecMemdevAdd and TestExecQomSet to qmp_test.go.
They can test ExecMemdevAdd and ExecQomSet.

Signed-off-by: Hui Zhu <teawater@antfin.com>
2020-01-21 10:26:59 +08:00
Liu Xiaodong
e04be2cc38 qmp: add ExecutePCIVhostUserDevAdd API
Caller can hotplug vhost-user device via qmp.
The Qemu vhost-user device, like vhost-user-blk-pci and
vhost-user-scsi-pci can be hotplugged by qmp API:
ExecuteCharDevUnixSocketAdd() together with
ExecutePCIVhostUserDevAdd()

Signed-off-by: Liu Xiaodong <xiaodong.liu@intel.com>
2020-01-14 00:41:53 -05:00
Liu Xiaodong
13aeba09d5 qmp: support command 'chardev-remove'
So that caller can remove hotremove chardev via qmp

Signed-off-by: Liu Xiaodong <xiaodong.liu@intel.com>
2020-01-14 00:12:04 -05:00
Peng Tao
164bd8cd22 test/fmt: drop extra newlines
They are unneeded.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2019-08-14 00:32:03 -07:00
Peng Tao
73555a409c qmp: add query-status API
So that caller can find out guest status via qmp.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2019-08-14 00:32:03 -07:00
Ning Bo
79e0d5333d qmp: support command 'query-qmp-schema'
The upper hyervisor manager application maybe need to wait some
QMP event to control boot sequence, but the event we wanted maybe
not exist in some older version, so we need query all QMP ABI and
check the event is supported or not.

related: kata-containers/runtime#1918

Signed-off-by: Ning Bo <ning.bo9@zte.com.cn>
2019-08-01 17:14:54 +08:00
Alice Frosi
68cdf64fe5 test: add cpu topology tests
Add cpu driver types in TestQMPCPUDeviceAdd

Signed-off-by: Alice Frosi <afrosi@de.ibm.com>
2019-07-26 14:27:25 +02:00
Julio Montes
a5c119086a qemu: support x86 SMP die
In QEMU 4.1 the CPU topology for x86 will change to:
`socket > die > core > thread`.
Add `die-id` field to `CPUProperties` and include it in CPU hotplugging

Signed-off-by: Julio Montes <julio.montes@intel.com>
2019-07-16 14:08:40 +00:00
Alice Frosi
65cc343f7b test: add devno in the tests for s390x
Add test with devno param

Signed-off-by: Alice Frosi <afrosi@de.ibm.com>
2019-07-05 08:08:25 +02:00
Ganesh Maharaj Mahalingam
0c900f596e Allow sharing of memory backend file
Hotplugged memory could be backed by a file on the host with sharing
turned on. This change allows qmp to pass that option to a govmm.

Signed-off-by: Ganesh Maharaj Mahalingam <ganesh.mahalingam@intel.com>
2019-06-18 08:07:17 -07: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
Peng Tao
f0f18dd0f2 qmp: add virtio-blk multiqueue
Hotplug virtio-blk with multiqueue support.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2019-05-27 20:40:12 -07:00
Julio Montes
694a7b1c61 qemu/qmp: re-implement mainLoop
In newer versions of QEMU, like 4.0-rc2, QMP events can be thrown even before
the QMP-version response, one example of this behaviour is when a virtio serial
is closed and a VSERPORT_CHANGE event is thrown.
Re-implement mainLoop to check the data received from the VM channel, since
it's not a guarantee that the first data read from the VM channel is the
QMP version.

fixes https://github.com/kata-containers/runtime/issues/1474

Signed-off-by: Julio Montes <julio.montes@intel.com>
2019-04-05 13:25:22 -06:00
Sebastien Boeuf
737f03de59
Merge pull request #76 from teawater/nvdimm
qmp: Add nvdimm support
2018-12-06 19:43:30 +00:00
Hui Zhu
c891f5f84b qmp: Add nvdimm support
ExecuteNVDIMMDeviceAdd can add a nvdimm disk to qemu.
Not implement NVDIMM device delete function because qemu doesn't support it.

Signed-off-by: Hui Zhu <teawater@hyper.sh>
2018-12-06 11:35:07 +08:00
Sebastien Boeuf
f9b31c0f80 qemu: Allow disable-modern option from QMP
For devices that actually support the option disable-modern, this
current commit provides a proper flag to the caller. This will allow
for better support when used in nested environment as virtio-pci
devices should rely on virtio 0.9 instead of 1.0 due to a bug in
KVM.

Fixes #80

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2018-12-05 09:16:41 -08:00
Mark Ryan
908b6aab14
Merge pull request #69 from BetaXOi/output-qmp-err
qmp: Output error detail when execute QMP command failed
2018-12-04 09:20:41 +01:00
NingBo
dab4cf1d70 qmp: Add tests
Test execute QMP command with error response.

Signed-off-by: NingBo <ning.bo9@zte.com.cn>
2018-12-03 14:40:26 +08: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
Hui Zhu
110d2fa049 qemu/qmp: add new function ExecuteBlockdevAddWithCache
ExecuteBlockdevAddWithCache has two more parameters direct and noFlush
than ExecuteBlockdevAdd.
They are cache-related options for block devices that are described in
https://github.com/qemu/qemu/blob/master/qapi/block-core.json.
direct denotes whether use of O_DIRECT (bypass the host page cache)
is enabled.  noFlush denotes whether flush requests for the device are
ignored.

Signed-off-by: Hui Zhu <teawater@hyper.sh>
2018-11-23 17:23:06 +08:00
Hui Zhu
a0b0c86e9c qmp_test: Change QMP version from 2.6 to 2.9
Also change TestQMPXBlockdevDel to TestQMPBlockdevDel because QMP verion
2.9 and older use blockdev-del but not x-blockdev-del.

Signed-off-by: Hui Zhu <teawater@hyper.sh>
2018-11-23 09:33:21 +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
Peng Tao
56f645eac6 qmp: add ExecuteQueryMigration
It sends query-migrate qmp command to check migration status.

Signed-off-by: Peng Tao <bergwolf@gmail.com>
2018-09-28 21:10:21 +08:00
Wei Zhang
1130aab85e qmp: add "query-cpus" support
Add "query-cpus" and "query-cpus-fast" to query CPU information from qemu

Signed-off-by: Wei Zhang <zhangwei555@huawei.com>
2018-09-21 10:14:25 +08:00
Ruidong Cao
1a1fee75e5 qemu/qmp: nic can works without vhost
If host doesn't support vhost_net, we won't pass vhost="on" in QMP.

Signed-off-by: Ruidong Cao <caoruidong@huawei.com>
2018-09-11 11:45:31 +08:00
Clare Chen
b16291cfab qemu/qmp: support query-memory-devices qmp command.
Implement query qemu memory devices function and testcase.

Signed-off-by: Clare Chen <clare.chenhui@huawei.com>
2018-08-28 23:19:52 -04:00
Julio Montes
cb112dba2c
Merge pull request #41 from caoruidong/support-mq
qemu/qmp: support hotplug a nic whose qdisc is mq
2018-08-23 12:01:44 -05:00
Ruidong Cao
0286ff9e6e qemu/qmp: support hotplug a nic whose qdisc is mq
If we hotplug a nic with args mq=on, its qdisc will be mq by default.
This aligns with cold plug nics.

Signed-off-by: Ruidong Cao <caoruidong@huawei.com>
2018-08-23 20:42:59 +08:00
Sebastien Boeuf
21504d31ff qemu/qmp: Add netdev_add with chardev support
In order to be able to hotplug network devices such as vhost user
net, we need to be able to define a previously declared chardev as
a parameter of this new network device.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2018-08-21 15:59:43 -07:00
Mark Ryan
ed34f61664 Add some negative test cases for qmp.go
This commit adds a couple of negative test cases for qmp.go, one
which checks that failed commands return errors and the other
checks that QMPStart exits gracefully when passed an invalid
socket path.

Signed-off-by: Mark Ryan <mark.d.ryan@intel.com>
2018-08-20 15:40:37 +01:00
Sebastien Boeuf
24ee4be532
Merge pull request #32 from amshinde/add-share-rw
disk: Add --share-rw option for hotplugging disks
2018-08-13 14:44:28 -07:00
Mark Ryan
c202f5d0ba
Merge pull request #30 from xindazhao/gpu-vfio-mdev
qemu/qmp: add vfio mediated device support
2018-08-13 22:07:21 +01:00
Zhao Xinda
fcaf61dcb1 qemu/qmp: add vfio mediated device support
In addition to normal VFIO device, this patch adds VFIO mediated device
as a supplement to do hot plug on PCI(E) bridges.

Signed-off-by: Zhao Xinda <xinda.zhao@intel.com>
2018-08-10 12:43:22 +08:00
Archana Shinde
4461c459a3 disk: Add --share-rw option for hotplugging disks
With qemu 2.10, a write lock was added for qcow images that
prevents the same image to be passed more than once.
This can be over-ridden using the --share-rw option which is
desired for raw images.

This solves an issue with running Kata with devicemapper
using the privileged mode as in this case all devices on the host
are passed to the container using the block device associated
with the rootfs, causing it to be passed twice to qemu.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2018-08-08 14:48:02 -07:00
Sebastien Boeuf
301ea5e989
Merge pull request #34 from devimc/topic/addrBusVsock
qemu/qmp: add addr and bus to hotplug vsock devices
2018-08-08 08:44:09 -07:00
Julio Montes
685199980d qemu/qmp: add addr and bus to hotplug vsock devices
For machines types based on PCIe like q35, device addr and bus must be specified.
For machines types based on PCI like pc, device addr must be specified and bus
is optional since devices can be hot plugged directly on the root bus.

Signed-off-by: Julio Montes <julio.montes@intel.com>
2018-08-08 09:53:09 -05:00
Ruidong Cao
10efa84132 qemu/qmp: add function for hotplug network by fds
Implement function to hotplug a network device to QEMU by fds.
Macvtap can only be hotplug by this way.

Signed-off-by: Ruidong Cao <caoruidong@huawei.com>
2018-08-08 11:12:47 +08:00
Julio Montes
80ed88edb1 qemu/qmp: implement function to hotplug serial ports
Implement function to hotplug virtio serial ports, the serial ports
are visible in the guest at the directory /dev/virtio-ports.

Signed-off-by: Julio Montes <julio.montes@intel.com>
2018-08-03 13:50:25 -05:00