2010-12-16 15:07:07 +00:00
|
|
|
/*
|
|
|
|
* qemu_capabilities.c: QEMU capabilities generation
|
|
|
|
*
|
2016-01-08 10:45:06 +00:00
|
|
|
* Copyright (C) 2006-2016 Red Hat, Inc.
|
2010-12-16 15:07:07 +00:00
|
|
|
* Copyright (C) 2006 Daniel P. Berrange
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-09-20 22:30:55 +00:00
|
|
|
* License along with this library. If not, see
|
2012-07-21 10:06:23 +00:00
|
|
|
* <http://www.gnu.org/licenses/>.
|
2010-12-16 15:07:07 +00:00
|
|
|
*
|
|
|
|
* Author: Daniel P. Berrange <berrange@redhat.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "qemu_capabilities.h"
|
2012-12-12 18:06:53 +00:00
|
|
|
#include "viralloc.h"
|
2014-03-05 16:51:59 +00:00
|
|
|
#include "vircrypto.h"
|
2012-12-12 17:59:27 +00:00
|
|
|
#include "virlog.h"
|
2012-12-13 18:21:53 +00:00
|
|
|
#include "virerror.h"
|
2011-07-19 18:32:58 +00:00
|
|
|
#include "virfile.h"
|
2017-07-19 15:01:56 +00:00
|
|
|
#include "virfilecache.h"
|
2012-10-02 08:59:56 +00:00
|
|
|
#include "virpidfile.h"
|
|
|
|
#include "virprocess.h"
|
2010-12-16 15:07:07 +00:00
|
|
|
#include "cpu/cpu.h"
|
2017-01-11 13:36:34 +00:00
|
|
|
#include "cpu/cpu_x86.h"
|
2010-12-16 15:07:07 +00:00
|
|
|
#include "domain_conf.h"
|
2012-12-12 16:27:01 +00:00
|
|
|
#include "vircommand.h"
|
2012-12-04 11:56:32 +00:00
|
|
|
#include "virbitmap.h"
|
2011-11-29 14:42:58 +00:00
|
|
|
#include "virnodesuspend.h"
|
2014-06-06 14:50:39 +00:00
|
|
|
#include "virnuma.h"
|
2016-06-24 15:04:13 +00:00
|
|
|
#include "virhostcpu.h"
|
2012-08-22 17:05:08 +00:00
|
|
|
#include "qemu_monitor.h"
|
2013-04-12 20:55:45 +00:00
|
|
|
#include "virstring.h"
|
2014-06-25 16:39:29 +00:00
|
|
|
#include "qemu_hostdev.h"
|
2015-03-10 13:23:43 +00:00
|
|
|
#include "qemu_domain.h"
|
2017-03-22 15:22:15 +00:00
|
|
|
#define __QEMU_CAPSPRIV_H_ALLOW__
|
2015-09-09 14:03:14 +00:00
|
|
|
#include "qemu_capspriv.h"
|
2018-03-20 07:44:11 +00:00
|
|
|
#include "qemu_qapi.h"
|
2010-12-16 15:07:07 +00:00
|
|
|
|
2013-01-29 16:52:17 +00:00
|
|
|
#include <fcntl.h>
|
2010-12-16 15:07:07 +00:00
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/wait.h>
|
2011-02-08 14:22:39 +00:00
|
|
|
#include <stdarg.h>
|
2018-01-22 10:37:04 +00:00
|
|
|
#include <sys/utsname.h>
|
2010-12-16 15:07:07 +00:00
|
|
|
|
|
|
|
#define VIR_FROM_THIS VIR_FROM_QEMU
|
|
|
|
|
2014-02-28 12:16:17 +00:00
|
|
|
VIR_LOG_INIT("qemu.qemu_capabilities");
|
|
|
|
|
2011-05-04 11:55:38 +00:00
|
|
|
/* While not public, these strings must not change. They
|
|
|
|
* are used in domain status files which are read on
|
|
|
|
* daemon restarts
|
|
|
|
*/
|
2013-02-01 13:48:58 +00:00
|
|
|
VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 0 */
|
|
|
|
"kqemu",
|
2011-05-04 11:55:38 +00:00
|
|
|
"vnc-colon",
|
|
|
|
"no-reboot",
|
|
|
|
"drive",
|
|
|
|
"drive-boot",
|
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 5 */
|
|
|
|
"name",
|
2011-05-04 11:55:38 +00:00
|
|
|
"uuid",
|
|
|
|
"domid",
|
|
|
|
"vnet-hdr",
|
|
|
|
"migrate-kvm-stdio",
|
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 10 */
|
|
|
|
"migrate-qemu-tcp",
|
2011-05-04 11:55:38 +00:00
|
|
|
"migrate-qemu-exec",
|
|
|
|
"drive-cache-v2",
|
|
|
|
"kvm",
|
|
|
|
"drive-format",
|
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 15 */
|
|
|
|
"vga",
|
2011-05-04 11:55:38 +00:00
|
|
|
"0.10",
|
|
|
|
"pci-device",
|
|
|
|
"mem-path",
|
|
|
|
"drive-serial",
|
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 20 */
|
|
|
|
"xen-domid",
|
2011-05-04 11:55:38 +00:00
|
|
|
"migrate-qemu-unix",
|
|
|
|
"chardev",
|
|
|
|
"enable-kvm",
|
|
|
|
"monitor-json",
|
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 25 */
|
|
|
|
"balloon",
|
2011-05-04 11:55:38 +00:00
|
|
|
"device",
|
|
|
|
"sdl",
|
|
|
|
"smp-topology",
|
|
|
|
"netdev",
|
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 30 */
|
|
|
|
"rtc",
|
2011-05-23 17:38:32 +00:00
|
|
|
"vhost-net",
|
2011-05-04 11:55:38 +00:00
|
|
|
"rtc-td-hack",
|
|
|
|
"no-hpet",
|
|
|
|
"no-kvm-pit",
|
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 35 */
|
|
|
|
"tdf",
|
2011-05-04 11:55:38 +00:00
|
|
|
"pci-configfd",
|
|
|
|
"nodefconfig",
|
|
|
|
"boot-menu",
|
|
|
|
"enable-kqemu",
|
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 40 */
|
|
|
|
"fsdev",
|
2011-05-04 11:55:38 +00:00
|
|
|
"nesting",
|
|
|
|
"name-process",
|
|
|
|
"drive-readonly",
|
|
|
|
"smbios-type",
|
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 45 */
|
|
|
|
"vga-qxl",
|
2011-05-04 11:55:38 +00:00
|
|
|
"spice",
|
|
|
|
"vga-none",
|
|
|
|
"migrate-qemu-fd",
|
|
|
|
"boot-index",
|
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 50 */
|
|
|
|
"hda-duplex",
|
2011-05-04 11:55:38 +00:00
|
|
|
"drive-aio",
|
|
|
|
"pci-multibus",
|
|
|
|
"pci-bootindex",
|
|
|
|
"ccid-emulated",
|
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 55 */
|
|
|
|
"ccid-passthru",
|
2011-05-04 11:55:38 +00:00
|
|
|
"chardev-spicevmc",
|
|
|
|
"device-spicevmc",
|
|
|
|
"virtio-tx-alg",
|
|
|
|
"device-qxl-vga",
|
2011-05-09 06:59:16 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 60 */
|
|
|
|
"pci-multifunction",
|
2011-06-20 08:26:47 +00:00
|
|
|
"virtio-blk-pci.ioeventfd",
|
2011-07-08 07:56:17 +00:00
|
|
|
"sga",
|
2011-08-13 06:32:45 +00:00
|
|
|
"virtio-blk-pci.event_idx",
|
|
|
|
"virtio-net-pci.event_idx",
|
2011-09-02 12:56:50 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 65 */
|
|
|
|
"cache-directsync",
|
2011-09-02 12:56:50 +00:00
|
|
|
"piix3-usb-uhci",
|
|
|
|
"piix4-usb-uhci",
|
|
|
|
"usb-ehci",
|
|
|
|
"ich9-usb-ehci1",
|
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 70 */
|
|
|
|
"vt82c686b-usb-uhci",
|
2011-09-02 12:56:50 +00:00
|
|
|
"pci-ohci",
|
|
|
|
"usb-redir",
|
2011-09-02 14:20:40 +00:00
|
|
|
"usb-hub",
|
2011-09-21 08:25:29 +00:00
|
|
|
"no-shutdown",
|
2011-09-22 19:33:47 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 75 */
|
|
|
|
"cache-unsafe",
|
2011-09-20 17:31:52 +00:00
|
|
|
"rombar",
|
2011-09-28 03:46:08 +00:00
|
|
|
"ich9-ahci",
|
2011-12-20 01:08:29 +00:00
|
|
|
"no-acpi",
|
2011-12-21 15:51:29 +00:00
|
|
|
"fsdev-readonly",
|
2011-11-29 18:37:27 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 80 */
|
|
|
|
"virtio-blk-pci.scsi",
|
2011-11-29 18:37:27 +00:00
|
|
|
"blk-sg-io",
|
2012-01-12 09:31:14 +00:00
|
|
|
"drive-copy-on-read",
|
2011-12-21 12:47:17 +00:00
|
|
|
"cpu-host",
|
2012-01-17 12:44:18 +00:00
|
|
|
"fsdev-writeout",
|
2012-01-18 16:42:33 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 85 */
|
|
|
|
"drive-iotune",
|
2012-02-13 11:19:24 +00:00
|
|
|
"system_wakeup",
|
2012-02-27 10:20:21 +00:00
|
|
|
"scsi-disk.channel",
|
2012-03-12 14:19:56 +00:00
|
|
|
"scsi-block",
|
2012-03-14 22:29:21 +00:00
|
|
|
"transaction",
|
2012-04-11 21:40:16 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 90 */
|
|
|
|
"block-job-sync",
|
2012-04-11 21:40:16 +00:00
|
|
|
"block-job-async",
|
2012-04-17 09:08:05 +00:00
|
|
|
"scsi-cd",
|
2012-04-17 09:16:52 +00:00
|
|
|
"ide-cd",
|
2012-04-26 10:11:49 +00:00
|
|
|
"no-user-config",
|
2012-05-15 22:55:08 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 95 */
|
|
|
|
"hda-micro",
|
2012-06-12 03:06:33 +00:00
|
|
|
"dump-guest-memory",
|
2012-06-21 13:45:25 +00:00
|
|
|
"nec-usb-xhci",
|
2012-06-29 15:02:05 +00:00
|
|
|
"virtio-s390",
|
2012-07-12 15:45:57 +00:00
|
|
|
"balloon-event",
|
2012-05-15 22:55:08 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 100 */
|
|
|
|
"bridge",
|
2012-08-08 06:25:24 +00:00
|
|
|
"lsi",
|
|
|
|
"virtio-scsi-pci",
|
2012-09-04 14:30:55 +00:00
|
|
|
"blockio",
|
2012-08-02 10:14:39 +00:00
|
|
|
"disable-s3",
|
2012-08-03 20:33:05 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 105 */
|
|
|
|
"disable-s4",
|
2012-08-19 15:42:44 +00:00
|
|
|
"usb-redir.filter",
|
2012-09-18 02:12:11 +00:00
|
|
|
"ide-drive.wwn",
|
|
|
|
"scsi-disk.wwn",
|
2012-09-18 07:24:51 +00:00
|
|
|
"seccomp-sandbox",
|
2012-09-18 10:31:30 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 110 */
|
|
|
|
"reboot-timeout",
|
2012-08-15 07:59:24 +00:00
|
|
|
"dump-guest-core",
|
2012-09-20 09:15:31 +00:00
|
|
|
"seamless-migration",
|
2012-10-03 21:13:21 +00:00
|
|
|
"block-commit",
|
2012-10-19 19:40:52 +00:00
|
|
|
"vnc",
|
blockjob: add qemu capabilities related to block jobs
Upstream qemu 1.3 is adding two new monitor commands, 'drive-mirror'
and 'block-job-complete'[1], which can drive live block copy and
storage migration. [Additionally, RHEL 6.3 had backported an earlier
version of most of the same functionality, but under the names
'__com.redhat_drive-mirror' and '__com.redhat_drive-reopen' and with
slightly different JSON arguments, and has been using patches similar
to these upstream patches for several months now.]
The libvirt API virDomainBlockRebase as already committed for 0.9.12
is flexible enough to expose the basics of block copy, but some
additional features in the 'drive-mirror' qemu command, such as
setting error policy, setting granularity, or using a persistent
bitmap, may later require a new libvirt API virDomainBlockCopy. I
will wait to add that API until we know more about what qemu 1.3
will finally provide.
This patch caters only to the upstream qemu 1.3 interface, although
I have proven that the changes for RHEL 6.3 can be isolated to
just qemu_monitor_json.c, and the rest of this series will
gracefully handle either interface once the JSON differences are
papered over in a downstream patch.
For consistency with other block job commands, libvirt must handle
the bandwidth argument as MiB/sec from the user, even though qemu
exposes the speed argument as bytes/sec; then again, qemu rounds
up to cluster size internally, so using MiB hides the worst effects
of that rounding if you pass small numbers.
[1]https://lists.gnu.org/archive/html/qemu-devel/2012-10/msg04123.html
* src/qemu/qemu_capabilities.h (QEMU_CAPS_DRIVE_MIRROR)
(QEMU_CAPS_DRIVE_REOPEN): New bits.
* src/qemu/qemu_capabilities.c (qemuCaps): Name them.
* src/qemu/qemu_monitor_json.c (qemuMonitorJSONCheckCommands): Set
them.
(qemuMonitorJSONDriveMirror, qemuMonitorDrivePivot): New functions.
* src/qemu/qemu_monitor_json.h (qemuMonitorJSONDriveMirror)
(qemuMonitorDrivePivot): Declare them.
* src/qemu/qemu_monitor.c (qemuMonitorDriveMirror)
(qemuMonitorDrivePivot): New passthroughs.
* src/qemu/qemu_monitor.h (qemuMonitorDriveMirror)
(qemuMonitorDrivePivot): Declare them.
2012-09-28 23:29:53 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 115 */
|
|
|
|
"drive-mirror",
|
2012-11-14 14:51:30 +00:00
|
|
|
"usb-redir.bootindex",
|
|
|
|
"usb-host.bootindex",
|
2012-12-03 21:25:30 +00:00
|
|
|
"blockdev-snapshot-sync",
|
2012-12-14 07:06:31 +00:00
|
|
|
"qxl",
|
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 120 */
|
|
|
|
"VGA",
|
2012-12-14 07:06:31 +00:00
|
|
|
"cirrus-vga",
|
|
|
|
"vmware-svga",
|
|
|
|
"device-video-primary",
|
2013-01-07 17:17:15 +00:00
|
|
|
"s390-sclp",
|
2013-01-11 16:43:49 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 125 */
|
|
|
|
"usb-serial",
|
2013-01-03 07:13:05 +00:00
|
|
|
"usb-net",
|
2013-01-29 16:52:17 +00:00
|
|
|
"add-fd",
|
2012-11-21 13:28:44 +00:00
|
|
|
"nbd-server",
|
2013-01-11 16:48:21 +00:00
|
|
|
"virtio-rng",
|
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 130 */
|
|
|
|
"rng-random",
|
2013-02-13 10:22:23 +00:00
|
|
|
"rng-egd",
|
2013-03-14 04:49:43 +00:00
|
|
|
"virtio-ccw",
|
|
|
|
"dtb",
|
2013-03-21 14:11:39 +00:00
|
|
|
"megasas",
|
2013-03-22 13:52:25 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 135 */
|
|
|
|
"ipv6-migration",
|
2013-03-29 05:22:46 +00:00
|
|
|
"machine-opt",
|
2013-04-07 08:31:57 +00:00
|
|
|
"machine-usb-opt",
|
2013-04-12 20:55:45 +00:00
|
|
|
"tpm-passthrough",
|
|
|
|
"tpm-tis",
|
2013-04-25 08:46:04 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 140 */
|
|
|
|
"nvram",
|
2013-05-03 18:07:21 +00:00
|
|
|
"pci-bridge",
|
|
|
|
"vfio-pci",
|
|
|
|
"vfio-pci.bootindex",
|
|
|
|
"scsi-generic",
|
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 145 */
|
|
|
|
"scsi-generic.bootindex",
|
2013-05-14 05:25:49 +00:00
|
|
|
"mem-merge",
|
2013-04-30 14:26:43 +00:00
|
|
|
"vnc-websocket",
|
2013-05-14 12:44:54 +00:00
|
|
|
"drive-discard",
|
2013-05-16 20:01:05 +00:00
|
|
|
"mlock",
|
2013-05-21 14:31:47 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 150 */
|
|
|
|
"vnc-share-policy",
|
2013-07-11 15:07:26 +00:00
|
|
|
"device-del-event",
|
qemu: add dmi-to-pci-bridge controller
This PCI controller, named "dmi-to-pci-bridge" in the libvirt config,
and implemented with qemu's "i82801b11-bridge" device, connects to a
PCI Express slot (e.g. one of the slots provided by the pcie-root
controller, aka "pcie.0" on the qemu commandline), and provides 31
*non-hot-pluggable* PCI (*not* PCIe) slots, numbered 1-31.
Any time a machine is defined which has a pcie-root controller
(i.e. any q35-based machinetype), libvirt will automatically add a
dmi-to-pci-bridge controller if one doesn't exist, and also add a
pci-bridge controller. The reasoning here is that any useful domain
will have either an immediate (startup time) or eventual (subsequent
hot-plug) need for a standard PCI slot; since the pcie-root controller
only provides PCIe slots, we need to connect a dmi-to-pci-bridge
controller to it in order to get a non-hot-plug PCI slot that we can
then use to connect a pci-bridge - the slots provided by the
pci-bridge will be both standard PCI and hot-pluggable.
Since pci-bridge devices themselves can not be hot-plugged into a
running system (although you can hot-plug other devices into a
pci-bridge's slots), any new pci-bridge controller that is added can
(and will) be plugged into the dmi-to-pci-bridge as long as it has
empty slots available.
This patch is also changing the qemuxml2xml-pcie test from a "DO_TEST"
to a "DO_DIFFERENT_TEST". This is so that the "before" xml can omit
the automatically added dmi-to-pci-bridge and pci-bridge devices, and
the "after" xml can include it - this way we are testing if libvirt is
properly adding these devices.
2013-07-31 01:37:32 +00:00
|
|
|
"dmi-to-pci-bridge",
|
2013-08-12 11:48:34 +00:00
|
|
|
"i440fx-pci-hole64-size",
|
|
|
|
"q35-pci-hole64-size",
|
2013-08-23 10:38:10 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 155 */
|
|
|
|
"usb-storage",
|
2013-08-23 10:38:11 +00:00
|
|
|
"usb-storage.removable",
|
2013-08-01 01:40:35 +00:00
|
|
|
"virtio-mmio",
|
2013-09-24 14:17:38 +00:00
|
|
|
"ich9-intel-hda",
|
2013-07-01 16:28:50 +00:00
|
|
|
"kvm-pit-lost-tick-policy",
|
qemu: add "-boot strict" to commandline whenever possible
This resolves:
https://bugzilla.redhat.com/show_bug.cgi?id=888635
(which was already closed as CANTFIX because the qemu "-boot strict"
commandline option wasn't available at the time).
Problem: you couldn't have a domain that used PXE to boot, but also
had an un-bootable disk device *even if that disk wasn't listed in the
boot order*, because if PXE timed out (e.g. due to the bridge
forwarding delay), the BIOS would move on to the next target, which
would be the unbootable disk device (again - even though it wasn't
given a boot order), and get stuck at a "BOOT DISK FAILURE, PRESS ANY
KEY" message until a user intervened.
The solution available since sometime around QEMU 1.5, is to add
"-boot strict=on" to *every* qemu command. When this is done, if any
devices have a boot order specified, then QEMU will *only* attempt to
boot from those devices that have an explicit boot order, ignoring the
rest.
2013-12-02 12:07:12 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 160 */
|
|
|
|
"boot-strict",
|
qemu: ask for -enable-fips when FIPS is required
On a system that is enforcing FIPS, most libraries honor the
current mode by default. Qemu, on the other hand, refused to
honor FIPS mode unless you add the '-enable-fips' command
line option; worse, this option is not discoverable via QMP,
and is only present on binaries built for Linux. So, if we
detect FIPS mode, then we unconditionally ask for FIPS; either
qemu is new enough to have the option and then correctly
cripple insecure VNC passwords, or it is so old that we are
correctly avoiding a FIPS violation by preventing qemu from
starting. Meanwhile, if we don't detect FIPS mode, then
omitting the argument is safe whether the qemu has the option
(but it would do nothing because FIPS is disabled) or whether
qemu lacks the option (including in the case where we are not
running on Linux).
The testsuite was a bit interesting: we don't want our test
to depend on whether it is being run in FIPS mode, so I had
to tweak things to set the capability bit outside of our
normal interaction with capability parsing.
This fixes https://bugzilla.redhat.com/show_bug.cgi?id=1035474
* src/qemu/qemu_capabilities.h (QEMU_CAPS_ENABLE_FIPS): New bit.
* src/qemu/qemu_capabilities.c (virQEMUCapsInitQMP): Conditionally
set capability according to detection of FIPS mode.
* src/qemu/qemu_command.c (qemuBuildCommandLine): Use it.
* tests/qemucapabilitiestest.c (testQemuCaps): Conditionally set
capability to test expected output.
* tests/qemucapabilitiesdata/caps_1.2.2-1.caps: Update list.
* tests/qemucapabilitiesdata/caps_1.6.0-1.caps: Likewise.
Signed-off-by: Eric Blake <eblake@redhat.com>
2013-12-05 21:47:09 +00:00
|
|
|
"pvpanic",
|
|
|
|
"enable-fips",
|
2014-01-30 11:19:12 +00:00
|
|
|
"spice-file-xfer-disable",
|
|
|
|
"spiceport",
|
2014-02-17 10:17:55 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 165 */
|
|
|
|
"usb-kbd",
|
qemu: add host-pci-multidomain capability
Quite a long time ago, (apparently between qemu 0.12 and 0.13) qemu
quietly began supporting the optional specification of a domain in the
host-side address of all pci passthrough commands (by simply
prepending it to the bus:slot.function format, as
"dddd:bb:ss.f"). Since machines with multiple PCI domains are very
rare, this never came up in practice, so libvirt was never updated to
support it.
This patch takes the first step to supporting specification of a non-0
domain in the host-side address of PCI devices being assigned to a
domain, by adding a capability bit to indicate support
"QEMU_CAPS_HOST_PCI_MULTIDOMAIN", and detect it. Since this support
was added in a version prior to the minimum version required for
QMP-style capabilities detection, the capability is always enabled for
any qemu that uses QMP for capabilities detection. For older qemus,
the only clue that a domain can be specified in the host pci address
is the presence of the string "[seg:]" in the help string for
-pcidevice. (Ironically, libvirt will not be modified to support
specification of domain for -pcidevice, since any qemu new enough for
us to care about also supports "-device pci-assign" or "-device
vfio-pci", which are greatly preferred).
2014-04-29 15:11:45 +00:00
|
|
|
"host-pci-multidomain",
|
2014-04-09 13:23:45 +00:00
|
|
|
"msg-timestamp",
|
2014-06-17 03:42:49 +00:00
|
|
|
"active-commit",
|
2014-05-26 12:09:22 +00:00
|
|
|
"change-backing-file",
|
2014-05-07 15:20:15 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 170 */
|
|
|
|
"memory-backend-ram",
|
2014-06-17 11:43:19 +00:00
|
|
|
"numa",
|
2014-07-23 15:37:21 +00:00
|
|
|
"memory-backend-file",
|
2014-07-24 15:32:31 +00:00
|
|
|
"usb-audio",
|
2014-08-13 12:28:24 +00:00
|
|
|
"rtc-reset-reinjection",
|
2014-08-22 11:42:46 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 175 */
|
|
|
|
"splash-timeout",
|
2014-08-22 22:15:30 +00:00
|
|
|
"iothread",
|
2014-09-11 12:11:54 +00:00
|
|
|
"migrate-rdma",
|
2014-08-22 10:47:02 +00:00
|
|
|
"ivshmem",
|
2014-10-29 12:16:01 +00:00
|
|
|
"drive-iotune-max",
|
2014-11-12 12:58:33 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 180 */
|
|
|
|
"VGA.vgamem_mb",
|
2014-11-12 12:58:33 +00:00
|
|
|
"vmware-svga.vgamem_mb",
|
|
|
|
"qxl.vgamem_mb",
|
|
|
|
"qxl-vga.vgamem_mb",
|
2014-10-06 12:16:47 +00:00
|
|
|
"pc-dimm",
|
2015-04-02 16:43:47 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 185 */
|
|
|
|
"machine-vmport-opt",
|
2015-04-27 21:57:29 +00:00
|
|
|
"aes-key-wrap",
|
|
|
|
"dea-key-wrap",
|
2015-05-06 15:50:03 +00:00
|
|
|
"pci-serial",
|
2015-05-21 22:18:20 +00:00
|
|
|
"aarch64-off",
|
2015-06-04 09:37:37 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 190 */
|
|
|
|
"vhost-user-multiqueue",
|
2015-05-28 11:35:52 +00:00
|
|
|
"migration-event",
|
2015-07-17 11:27:44 +00:00
|
|
|
"gpex-pcihost",
|
2015-06-17 17:13:28 +00:00
|
|
|
"ioh3420",
|
2015-06-16 18:54:21 +00:00
|
|
|
"x3130-upstream",
|
2015-09-04 14:23:46 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 195 */
|
|
|
|
"xio3130-downstream",
|
2015-09-04 14:23:46 +00:00
|
|
|
"rtl8139",
|
2015-09-04 14:40:37 +00:00
|
|
|
"e1000",
|
2015-09-01 12:38:19 +00:00
|
|
|
"virtio-net",
|
2015-09-30 11:04:09 +00:00
|
|
|
"gic-version",
|
2015-11-11 17:02:23 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 200 */
|
|
|
|
"incoming-defer",
|
2015-11-25 08:42:32 +00:00
|
|
|
"virtio-gpu",
|
2015-11-25 08:42:33 +00:00
|
|
|
"virtio-gpu.virgl",
|
2015-11-13 10:26:37 +00:00
|
|
|
"virtio-keyboard",
|
|
|
|
"virtio-mouse",
|
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 205 */
|
|
|
|
"virtio-tablet",
|
2015-11-13 14:41:20 +00:00
|
|
|
"virtio-input-host",
|
2015-12-24 14:27:55 +00:00
|
|
|
"chardev-file-append",
|
2016-01-09 20:58:50 +00:00
|
|
|
"ich9-disable-s3",
|
|
|
|
"ich9-disable-s4",
|
2016-01-05 13:05:15 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 210 */
|
|
|
|
"vserport-change-event",
|
2016-01-08 10:45:06 +00:00
|
|
|
"virtio-balloon-pci.deflate-on-oom",
|
2016-02-11 10:48:20 +00:00
|
|
|
"mptsas1068",
|
2016-02-19 14:30:15 +00:00
|
|
|
"spice-gl",
|
2016-03-01 12:46:37 +00:00
|
|
|
"qxl.vram64_size_mb",
|
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 215 */
|
|
|
|
"qxl-vga.vram64_size_mb",
|
2016-02-23 11:56:34 +00:00
|
|
|
"chardev-logfile",
|
2016-03-10 19:46:38 +00:00
|
|
|
"debug-threads",
|
2016-03-21 15:49:12 +00:00
|
|
|
"secret",
|
2016-02-24 21:40:49 +00:00
|
|
|
"pxb",
|
2016-03-08 21:25:22 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 220 */
|
|
|
|
"pxb-pcie",
|
2016-04-29 11:49:13 +00:00
|
|
|
"device-tray-moved-event",
|
2016-04-24 14:52:38 +00:00
|
|
|
"nec-usb-xhci-ports",
|
2016-04-20 18:43:04 +00:00
|
|
|
"virtio-scsi-pci.iothread",
|
2016-04-22 22:39:09 +00:00
|
|
|
"name-guest",
|
2015-12-11 13:26:24 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 225 */
|
|
|
|
"qxl.max_outputs",
|
2015-12-11 13:26:24 +00:00
|
|
|
"qxl-vga.max_outputs",
|
2016-06-07 22:21:29 +00:00
|
|
|
"spice-unix",
|
2015-12-14 08:35:20 +00:00
|
|
|
"drive-detect-zeroes",
|
2016-08-04 15:13:48 +00:00
|
|
|
"tls-creds-x509",
|
2016-06-07 15:28:20 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 230 */
|
|
|
|
"display",
|
2016-06-22 15:24:24 +00:00
|
|
|
"intel-iommu",
|
2016-07-13 12:09:20 +00:00
|
|
|
"smm",
|
2016-08-08 14:05:27 +00:00
|
|
|
"virtio-pci-disable-legacy",
|
2016-06-23 11:56:12 +00:00
|
|
|
"query-hotpluggable-cpus",
|
2016-08-19 06:39:08 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 235 */
|
|
|
|
"virtio-net.rx_queue_size",
|
2016-10-03 12:31:12 +00:00
|
|
|
"machine-iommu",
|
2016-10-11 12:07:58 +00:00
|
|
|
"virtio-vga",
|
2016-09-19 10:47:19 +00:00
|
|
|
"drive-iotune-max-length",
|
2016-08-02 06:48:45 +00:00
|
|
|
"ivshmem-plain",
|
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 240 */
|
|
|
|
"ivshmem-doorbell",
|
2016-10-19 12:40:53 +00:00
|
|
|
"query-qmp-schema",
|
2016-11-10 14:47:50 +00:00
|
|
|
"gluster.debug_level",
|
2016-11-22 03:58:15 +00:00
|
|
|
"vhost-scsi",
|
2016-11-07 11:19:50 +00:00
|
|
|
"drive-iotune-group",
|
2016-12-18 19:22:26 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 245 */
|
|
|
|
"query-cpu-model-expansion",
|
2017-01-23 13:33:20 +00:00
|
|
|
"virtio-net.host_mtu",
|
2017-02-14 21:04:13 +00:00
|
|
|
"spice-rendernode",
|
2016-07-29 06:17:42 +00:00
|
|
|
"nvdimm",
|
2017-01-16 12:28:20 +00:00
|
|
|
"pcie-root-port",
|
2017-03-16 08:19:02 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 250 */
|
|
|
|
"query-cpu-definitions",
|
2017-02-22 15:52:22 +00:00
|
|
|
"block-write-threshold",
|
2017-03-15 16:21:48 +00:00
|
|
|
"query-named-block-nodes",
|
2017-04-25 17:07:19 +00:00
|
|
|
"cpu-cache",
|
2017-04-28 08:44:03 +00:00
|
|
|
"qemu-xhci",
|
2017-03-17 07:26:49 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 255 */
|
|
|
|
"kernel-irqchip",
|
2017-03-17 07:26:49 +00:00
|
|
|
"kernel-irqchip.split",
|
2017-05-03 13:23:12 +00:00
|
|
|
"intel-iommu.intremap",
|
2017-03-17 07:28:04 +00:00
|
|
|
"intel-iommu.caching-mode",
|
2017-05-18 08:48:03 +00:00
|
|
|
"intel-iommu.eim",
|
2017-05-03 15:18:47 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 260 */
|
|
|
|
"intel-iommu.device-iotlb",
|
2017-05-24 15:09:12 +00:00
|
|
|
"virtio.iommu_platform",
|
|
|
|
"virtio.ats",
|
2017-06-01 16:36:26 +00:00
|
|
|
"loadparm",
|
2017-02-20 14:34:51 +00:00
|
|
|
"spapr-pci-host-bridge",
|
2017-07-22 08:30:19 +00:00
|
|
|
|
|
|
|
/* 265 */
|
2017-07-21 08:02:32 +00:00
|
|
|
"spapr-pci-host-bridge.numa_node",
|
2017-07-12 12:19:26 +00:00
|
|
|
"vnc-multi-servers",
|
|
|
|
"virtio-net.tx_queue_size",
|
2017-08-09 13:06:40 +00:00
|
|
|
"chardev-reconnect",
|
2017-08-23 12:06:17 +00:00
|
|
|
"virtio-gpu.max_outputs",
|
2017-08-29 22:44:19 +00:00
|
|
|
|
|
|
|
/* 270 */
|
|
|
|
"vxhs",
|
2017-09-30 17:15:35 +00:00
|
|
|
"virtio-blk.num-queues",
|
2017-11-06 15:39:40 +00:00
|
|
|
"machine.pseries.resize-hpt",
|
2017-11-16 16:49:38 +00:00
|
|
|
"vmcoreinfo",
|
2017-11-08 18:13:28 +00:00
|
|
|
"spapr-vty",
|
2017-11-15 17:08:44 +00:00
|
|
|
|
|
|
|
/* 275 */
|
|
|
|
"sclplmconsole",
|
2017-11-14 13:29:20 +00:00
|
|
|
"numa.dist",
|
2017-11-15 14:02:58 +00:00
|
|
|
"disk-share-rw",
|
2017-09-01 19:09:29 +00:00
|
|
|
"iscsi.password-secret",
|
2017-11-26 16:19:46 +00:00
|
|
|
"isa-serial",
|
2017-11-28 10:23:26 +00:00
|
|
|
|
|
|
|
/* 280 */
|
|
|
|
"pl011",
|
2018-01-05 13:47:46 +00:00
|
|
|
"machine.pseries.max-cpu-compat",
|
2017-11-17 13:46:27 +00:00
|
|
|
"dump-completed",
|
2018-03-23 17:22:38 +00:00
|
|
|
"virtio-gpu-ccw",
|
2018-03-23 17:22:41 +00:00
|
|
|
"virtio-keyboard-ccw",
|
|
|
|
|
|
|
|
/* 285 */
|
|
|
|
"virtio-mouse-ccw",
|
|
|
|
"virtio-tablet-ccw",
|
2018-03-28 11:29:11 +00:00
|
|
|
"qcow2-luks",
|
2018-01-09 17:05:30 +00:00
|
|
|
"pcie-pci-bridge",
|
2018-03-31 20:15:02 +00:00
|
|
|
"seccomp-blacklist",
|
2018-03-05 11:44:24 +00:00
|
|
|
|
|
|
|
/* 290 */
|
|
|
|
"query-cpus-fast",
|
2018-04-03 17:11:22 +00:00
|
|
|
"disk-write-cache",
|
2018-04-26 11:11:05 +00:00
|
|
|
"nbd-tls",
|
2018-04-26 17:42:17 +00:00
|
|
|
"tpm-crb",
|
2011-05-04 11:55:38 +00:00
|
|
|
);
|
|
|
|
|
2014-03-05 16:51:59 +00:00
|
|
|
|
2016-07-29 08:13:46 +00:00
|
|
|
struct virQEMUCapsMachineType {
|
|
|
|
char *name;
|
|
|
|
char *alias;
|
|
|
|
unsigned int maxCpus;
|
2016-07-29 07:45:19 +00:00
|
|
|
bool hotplugCpus;
|
2016-07-29 08:13:46 +00:00
|
|
|
};
|
2017-04-07 16:15:26 +00:00
|
|
|
|
|
|
|
typedef struct _virQEMUCapsHostCPUData virQEMUCapsHostCPUData;
|
|
|
|
typedef virQEMUCapsHostCPUData *virQEMUCapsHostCPUDataPtr;
|
|
|
|
struct _virQEMUCapsHostCPUData {
|
|
|
|
/* Only the "info" part is stored in the capabilities cache, the rest is
|
|
|
|
* re-computed from other fields and external data sources everytime we
|
|
|
|
* probe QEMU or load the cache.
|
|
|
|
*/
|
|
|
|
qemuMonitorCPUModelInfoPtr info;
|
|
|
|
/* Host CPU definition reported in domain capabilities. */
|
|
|
|
virCPUDefPtr reported;
|
2017-03-29 13:31:17 +00:00
|
|
|
/* Migratable host CPU definition used for updating guest CPU. */
|
|
|
|
virCPUDefPtr migratable;
|
2017-04-11 18:46:05 +00:00
|
|
|
/* CPU definition with features detected by libvirt using virCPUGetHost
|
|
|
|
* combined with features reported by QEMU. This is used for backward
|
|
|
|
* compatible comparison between a guest CPU and a host CPU. */
|
|
|
|
virCPUDefPtr full;
|
2017-04-07 16:15:26 +00:00
|
|
|
};
|
|
|
|
|
2014-03-05 16:51:59 +00:00
|
|
|
/*
|
|
|
|
* Update the XML parser/formatter when adding more
|
|
|
|
* information to this struct so that it gets cached
|
|
|
|
* correctly. It does not have to be ABI-stable, as
|
|
|
|
* the cache will be discarded & repopulated if the
|
|
|
|
* timestamp on the libvirtd binary changes.
|
2016-08-04 14:48:40 +00:00
|
|
|
*
|
|
|
|
* And don't forget to update virQEMUCapsNewCopy.
|
2014-03-05 16:51:59 +00:00
|
|
|
*/
|
2013-02-01 13:48:58 +00:00
|
|
|
struct _virQEMUCaps {
|
2018-04-13 11:51:23 +00:00
|
|
|
virObject parent;
|
2012-08-20 16:44:14 +00:00
|
|
|
|
2012-08-22 17:05:08 +00:00
|
|
|
bool usedQMP;
|
|
|
|
|
2012-09-10 10:47:56 +00:00
|
|
|
char *binary;
|
2014-03-10 15:50:19 +00:00
|
|
|
time_t ctime;
|
2017-06-13 15:55:45 +00:00
|
|
|
time_t libvirtCtime;
|
2012-09-10 10:47:56 +00:00
|
|
|
|
2012-08-20 16:44:14 +00:00
|
|
|
virBitmapPtr flags;
|
2012-08-22 10:11:28 +00:00
|
|
|
|
|
|
|
unsigned int version;
|
|
|
|
unsigned int kvmVersion;
|
2017-06-13 15:55:45 +00:00
|
|
|
unsigned int libvirtVersion;
|
2017-12-12 15:23:41 +00:00
|
|
|
unsigned int microcodeVersion;
|
2015-02-02 10:28:30 +00:00
|
|
|
char *package;
|
2018-01-22 10:37:04 +00:00
|
|
|
char *kernelVersion;
|
2012-08-22 10:11:28 +00:00
|
|
|
|
2012-12-11 13:06:45 +00:00
|
|
|
virArch arch;
|
2012-08-22 10:11:28 +00:00
|
|
|
|
2016-11-14 16:21:30 +00:00
|
|
|
virDomainCapsCPUModelsPtr kvmCPUModels;
|
|
|
|
virDomainCapsCPUModelsPtr tcgCPUModels;
|
2012-08-22 10:11:28 +00:00
|
|
|
|
|
|
|
size_t nmachineTypes;
|
2016-07-29 08:13:46 +00:00
|
|
|
struct virQEMUCapsMachineType *machineTypes;
|
2016-03-08 17:24:18 +00:00
|
|
|
|
|
|
|
size_t ngicCapabilities;
|
|
|
|
virGICCapability *gicCapabilities;
|
2016-06-15 12:35:18 +00:00
|
|
|
|
2017-04-07 16:15:26 +00:00
|
|
|
virQEMUCapsHostCPUData kvmCPU;
|
|
|
|
virQEMUCapsHostCPUData tcgCPU;
|
2012-08-20 16:44:14 +00:00
|
|
|
};
|
|
|
|
|
2014-06-30 14:12:07 +00:00
|
|
|
struct virQEMUCapsSearchData {
|
|
|
|
virArch arch;
|
|
|
|
};
|
|
|
|
|
2012-08-20 16:44:14 +00:00
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
static virClassPtr virQEMUCapsClass;
|
|
|
|
static void virQEMUCapsDispose(void *obj);
|
2012-08-20 16:44:14 +00:00
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
static int virQEMUCapsOnceInit(void)
|
2012-08-20 16:44:14 +00:00
|
|
|
{
|
2018-04-17 15:42:33 +00:00
|
|
|
if (!VIR_CLASS_NEW(virQEMUCaps, virClassForObject()))
|
2012-08-20 16:44:14 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
VIR_ONCE_GLOBAL_INIT(virQEMUCaps)
|
2012-08-20 16:44:14 +00:00
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
static virArch virQEMUCapsArchFromString(const char *arch)
|
2012-12-11 13:06:45 +00:00
|
|
|
{
|
|
|
|
if (STREQ(arch, "i386"))
|
|
|
|
return VIR_ARCH_I686;
|
|
|
|
if (STREQ(arch, "arm"))
|
|
|
|
return VIR_ARCH_ARMV7L;
|
2015-06-11 14:26:45 +00:00
|
|
|
if (STREQ(arch, "or32"))
|
|
|
|
return VIR_ARCH_OR32;
|
2012-12-11 13:06:45 +00:00
|
|
|
|
|
|
|
return virArchFromString(arch);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
static const char *virQEMUCapsArchToString(virArch arch)
|
2012-12-11 13:06:45 +00:00
|
|
|
{
|
|
|
|
if (arch == VIR_ARCH_I686)
|
|
|
|
return "i386";
|
|
|
|
else if (arch == VIR_ARCH_ARMV7L)
|
|
|
|
return "arm";
|
2015-06-11 14:26:45 +00:00
|
|
|
else if (arch == VIR_ARCH_OR32)
|
|
|
|
return "or32";
|
2012-12-11 13:06:45 +00:00
|
|
|
|
|
|
|
return virArchToString(arch);
|
|
|
|
}
|
|
|
|
|
2016-06-14 15:25:58 +00:00
|
|
|
|
|
|
|
/* Checks whether a domain with @guest arch can run natively on @host.
|
|
|
|
*/
|
2017-07-11 13:15:01 +00:00
|
|
|
bool
|
2016-06-14 15:25:58 +00:00
|
|
|
virQEMUCapsGuestIsNative(virArch host,
|
|
|
|
virArch guest)
|
|
|
|
{
|
|
|
|
if (host == guest)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (host == VIR_ARCH_X86_64 && guest == VIR_ARCH_I686)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (host == VIR_ARCH_AARCH64 && guest == VIR_ARCH_ARMV7L)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (ARCH_IS_PPC64(host) && ARCH_IS_PPC64(guest))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-09-15 13:58:09 +00:00
|
|
|
/* Given a host and guest architectures, find a suitable QEMU target.
|
|
|
|
*
|
|
|
|
* This is meant to be used as a second attempt if qemu-system-$guestarch
|
|
|
|
* can't be found, eg. on a x86_64 host you want to use qemu-system-i386,
|
|
|
|
* if available, instead of qemu-system-x86_64 to run i686 guests */
|
|
|
|
static virArch
|
|
|
|
virQEMUCapsFindTarget(virArch hostarch,
|
|
|
|
virArch guestarch)
|
|
|
|
{
|
2016-12-13 15:58:41 +00:00
|
|
|
if (virQEMUCapsGuestIsNative(hostarch, guestarch))
|
|
|
|
guestarch = hostarch;
|
|
|
|
|
2015-09-15 13:58:09 +00:00
|
|
|
/* Both ppc64 and ppc64le guests can use the ppc64 target */
|
|
|
|
if (ARCH_IS_PPC64(guestarch))
|
|
|
|
guestarch = VIR_ARCH_PPC64;
|
|
|
|
|
|
|
|
return guestarch;
|
|
|
|
}
|
2012-12-11 13:06:45 +00:00
|
|
|
|
2012-08-20 15:05:45 +00:00
|
|
|
|
2012-11-30 18:22:42 +00:00
|
|
|
static void
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsSetDefaultMachine(virQEMUCapsPtr qemuCaps,
|
|
|
|
size_t defIdx)
|
2012-11-30 18:22:42 +00:00
|
|
|
{
|
2016-07-29 08:13:46 +00:00
|
|
|
struct virQEMUCapsMachineType tmp = qemuCaps->machineTypes[defIdx];
|
2013-02-01 13:48:58 +00:00
|
|
|
|
|
|
|
memmove(qemuCaps->machineTypes + 1,
|
|
|
|
qemuCaps->machineTypes,
|
|
|
|
sizeof(qemuCaps->machineTypes[0]) * defIdx);
|
2016-07-29 08:13:46 +00:00
|
|
|
|
|
|
|
qemuCaps->machineTypes[0] = tmp;
|
2012-11-30 18:22:42 +00:00
|
|
|
}
|
|
|
|
|
2010-12-16 15:07:07 +00:00
|
|
|
|
2012-08-22 16:59:39 +00:00
|
|
|
static char *
|
2015-09-15 13:58:09 +00:00
|
|
|
virQEMUCapsFindBinary(const char *format,
|
|
|
|
const char *archstr)
|
2012-08-22 16:59:39 +00:00
|
|
|
{
|
2015-09-15 13:58:09 +00:00
|
|
|
char *ret = NULL;
|
|
|
|
char *binary = NULL;
|
2015-02-15 04:18:00 +00:00
|
|
|
|
2015-09-15 13:58:09 +00:00
|
|
|
if (virAsprintf(&binary, format, archstr) < 0)
|
2018-04-13 06:01:45 +00:00
|
|
|
return NULL;
|
2012-12-11 13:06:45 +00:00
|
|
|
|
|
|
|
ret = virFindFileInPath(binary);
|
|
|
|
VIR_FREE(binary);
|
2015-09-15 13:58:09 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
virQEMUCapsFindBinaryForArch(virArch hostarch,
|
|
|
|
virArch guestarch)
|
|
|
|
{
|
|
|
|
char *ret = NULL;
|
|
|
|
const char *archstr;
|
|
|
|
virArch target;
|
|
|
|
|
|
|
|
/* First attempt: try the guest architecture as it is */
|
|
|
|
archstr = virQEMUCapsArchToString(guestarch);
|
|
|
|
if ((ret = virQEMUCapsFindBinary("qemu-system-%s", archstr)) != NULL)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/* Second attempt: try looking up by target instead */
|
|
|
|
target = virQEMUCapsFindTarget(hostarch, guestarch);
|
|
|
|
if (target != guestarch) {
|
|
|
|
archstr = virQEMUCapsArchToString(target);
|
|
|
|
if ((ret = virQEMUCapsFindBinary("qemu-system-%s", archstr)) != NULL)
|
|
|
|
goto out;
|
2012-12-11 13:06:45 +00:00
|
|
|
}
|
2012-08-22 16:59:39 +00:00
|
|
|
|
2015-09-15 13:58:09 +00:00
|
|
|
/* Third attempt, i686 only: try 'qemu' */
|
|
|
|
if (guestarch == VIR_ARCH_I686) {
|
|
|
|
if ((ret = virQEMUCapsFindBinary("%s", "qemu")) != NULL)
|
|
|
|
goto out;
|
2012-08-22 16:59:39 +00:00
|
|
|
}
|
2012-12-11 13:06:45 +00:00
|
|
|
|
2015-09-15 13:58:09 +00:00
|
|
|
out:
|
2012-08-22 16:59:39 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-12-16 15:07:07 +00:00
|
|
|
static int
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsInitGuest(virCapsPtr caps,
|
2017-07-19 15:01:56 +00:00
|
|
|
virFileCachePtr cache,
|
2013-02-01 13:48:58 +00:00
|
|
|
virArch hostarch,
|
|
|
|
virArch guestarch)
|
2010-12-16 15:07:07 +00:00
|
|
|
{
|
Convert 'int i' to 'size_t i' in src/qemu files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 14:09:33 +00:00
|
|
|
size_t i;
|
2010-12-16 15:07:07 +00:00
|
|
|
char *kvmbin = NULL;
|
|
|
|
char *binary = NULL;
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsPtr qemubinCaps = NULL;
|
|
|
|
virQEMUCapsPtr kvmbinCaps = NULL;
|
2010-12-16 15:07:07 +00:00
|
|
|
int ret = -1;
|
|
|
|
|
2012-10-11 16:31:20 +00:00
|
|
|
/* Check for existence of base emulator, or alternate base
|
2010-12-16 15:07:07 +00:00
|
|
|
* which can be used with magic cpu choice
|
|
|
|
*/
|
2013-02-01 13:48:58 +00:00
|
|
|
binary = virQEMUCapsFindBinaryForArch(hostarch, guestarch);
|
2010-12-16 15:07:07 +00:00
|
|
|
|
2012-07-13 14:30:55 +00:00
|
|
|
/* Ignore binary if extracting version info fails */
|
2012-08-22 13:37:05 +00:00
|
|
|
if (binary) {
|
2017-07-21 13:09:54 +00:00
|
|
|
if (!(qemubinCaps = virQEMUCapsCacheLookup(cache, binary))) {
|
2012-08-22 13:37:05 +00:00
|
|
|
virResetLastError();
|
|
|
|
VIR_FREE(binary);
|
|
|
|
}
|
|
|
|
}
|
2012-07-13 14:30:55 +00:00
|
|
|
|
|
|
|
/* qemu-kvm/kvm binaries can only be used if
|
2010-12-16 15:07:07 +00:00
|
|
|
* - host & guest arches match
|
2015-05-21 22:18:30 +00:00
|
|
|
* - hostarch is x86_64 and guest arch is i686 (needs -cpu qemu32)
|
|
|
|
* - hostarch is aarch64 and guest arch is armv7l (needs -cpu aarch64=off)
|
2015-09-30 15:58:58 +00:00
|
|
|
* - hostarch and guestarch are both ppc64*
|
2010-12-16 15:07:07 +00:00
|
|
|
*/
|
2016-06-14 15:25:58 +00:00
|
|
|
if (virQEMUCapsGuestIsNative(hostarch, guestarch)) {
|
2015-05-21 22:18:30 +00:00
|
|
|
const char *kvmbins[] = {
|
|
|
|
"/usr/libexec/qemu-kvm", /* RHEL */
|
|
|
|
"qemu-kvm", /* Fedora */
|
|
|
|
"kvm", /* Debian/Ubuntu */
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* x86 32-on-64 can be used with qemu-system-i386 and
|
|
|
|
* qemu-system-x86_64, so if we don't find a specific kvm binary,
|
|
|
|
* we can just fall back to the host arch native binary and
|
|
|
|
* everything works fine.
|
|
|
|
*
|
|
|
|
* arm is different in that 32-on-64 _only_ works with
|
|
|
|
* qemu-system-aarch64. So we have to add it to the kvmbins list
|
|
|
|
*/
|
2016-06-14 15:25:58 +00:00
|
|
|
if (hostarch == VIR_ARCH_AARCH64 && guestarch == VIR_ARCH_ARMV7L)
|
2015-05-21 22:18:30 +00:00
|
|
|
kvmbins[3] = "qemu-system-aarch64";
|
2010-12-16 15:07:07 +00:00
|
|
|
|
2012-07-13 14:30:55 +00:00
|
|
|
for (i = 0; i < ARRAY_CARDINALITY(kvmbins); ++i) {
|
2015-05-21 22:18:30 +00:00
|
|
|
if (!kvmbins[i])
|
|
|
|
continue;
|
|
|
|
|
2012-07-13 14:30:55 +00:00
|
|
|
kvmbin = virFindFileInPath(kvmbins[i]);
|
2010-12-16 15:07:07 +00:00
|
|
|
|
2012-07-13 14:30:55 +00:00
|
|
|
if (!kvmbin)
|
|
|
|
continue;
|
2010-12-16 15:07:07 +00:00
|
|
|
|
2017-07-21 13:09:54 +00:00
|
|
|
if (!(kvmbinCaps = virQEMUCapsCacheLookup(cache, kvmbin))) {
|
2012-08-22 13:37:05 +00:00
|
|
|
virResetLastError();
|
2012-07-13 14:30:55 +00:00
|
|
|
VIR_FREE(kvmbin);
|
|
|
|
continue;
|
|
|
|
}
|
2010-12-16 15:07:07 +00:00
|
|
|
|
2012-07-13 14:30:55 +00:00
|
|
|
if (!binary) {
|
|
|
|
binary = kvmbin;
|
2012-08-20 16:44:14 +00:00
|
|
|
qemubinCaps = kvmbinCaps;
|
2012-07-13 14:30:55 +00:00
|
|
|
kvmbin = NULL;
|
2012-08-20 16:44:14 +00:00
|
|
|
kvmbinCaps = NULL;
|
2010-12-16 15:07:07 +00:00
|
|
|
}
|
2012-07-13 14:30:55 +00:00
|
|
|
break;
|
2010-12-16 15:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-17 15:19:45 +00:00
|
|
|
ret = virQEMUCapsInitGuestFromBinary(caps,
|
|
|
|
binary, qemubinCaps,
|
|
|
|
kvmbin, kvmbinCaps,
|
|
|
|
guestarch);
|
|
|
|
|
|
|
|
VIR_FREE(binary);
|
|
|
|
VIR_FREE(kvmbin);
|
|
|
|
virObjectUnref(qemubinCaps);
|
|
|
|
virObjectUnref(kvmbinCaps);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
virQEMUCapsInitGuestFromBinary(virCapsPtr caps,
|
|
|
|
const char *binary,
|
|
|
|
virQEMUCapsPtr qemubinCaps,
|
|
|
|
const char *kvmbin,
|
|
|
|
virQEMUCapsPtr kvmbinCaps,
|
|
|
|
virArch guestarch)
|
|
|
|
{
|
|
|
|
virCapsGuestPtr guest;
|
|
|
|
bool haskvm = false;
|
|
|
|
virCapsGuestMachinePtr *machines = NULL;
|
|
|
|
size_t nmachines = 0;
|
|
|
|
int ret = -1;
|
|
|
|
bool hasdisksnapshot = false;
|
|
|
|
|
2010-12-16 15:07:07 +00:00
|
|
|
if (!binary)
|
|
|
|
return 0;
|
|
|
|
|
2013-09-13 13:32:43 +00:00
|
|
|
if (virFileExists("/dev/kvm") &&
|
2013-02-01 13:48:58 +00:00
|
|
|
(virQEMUCapsGet(qemubinCaps, QEMU_CAPS_KVM) ||
|
|
|
|
virQEMUCapsGet(qemubinCaps, QEMU_CAPS_ENABLE_KVM) ||
|
2012-07-13 14:30:55 +00:00
|
|
|
kvmbin))
|
2013-05-24 10:14:02 +00:00
|
|
|
haskvm = true;
|
2012-07-13 14:30:55 +00:00
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
if (virQEMUCapsGetMachineTypesCaps(qemubinCaps, &nmachines, &machines) < 0)
|
2014-03-17 15:19:45 +00:00
|
|
|
goto cleanup;
|
2010-12-16 15:07:07 +00:00
|
|
|
|
|
|
|
/* We register kvm as the base emulator too, since we can
|
|
|
|
* just give -no-kvm to disable acceleration if required */
|
|
|
|
if ((guest = virCapabilitiesAddGuest(caps,
|
2015-04-17 22:09:16 +00:00
|
|
|
VIR_DOMAIN_OSTYPE_HVM,
|
2012-08-22 16:59:39 +00:00
|
|
|
guestarch,
|
2010-12-16 15:07:07 +00:00
|
|
|
binary,
|
|
|
|
NULL,
|
|
|
|
nmachines,
|
|
|
|
machines)) == NULL)
|
2014-03-17 15:19:45 +00:00
|
|
|
goto cleanup;
|
2010-12-16 15:07:07 +00:00
|
|
|
|
|
|
|
machines = NULL;
|
|
|
|
nmachines = 0;
|
|
|
|
|
2016-05-16 08:08:29 +00:00
|
|
|
/* CPU selection is always available, because all QEMU versions
|
|
|
|
* we support can use at least '-cpu host' */
|
|
|
|
if (!virCapabilitiesAddGuestFeature(guest, "cpuselection", true, false))
|
2014-03-17 15:19:45 +00:00
|
|
|
goto cleanup;
|
2010-12-16 15:07:07 +00:00
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
if (virQEMUCapsGet(qemubinCaps, QEMU_CAPS_BOOTINDEX) &&
|
2014-07-14 12:56:13 +00:00
|
|
|
!virCapabilitiesAddGuestFeature(guest, "deviceboot", true, false))
|
2014-03-17 15:19:45 +00:00
|
|
|
goto cleanup;
|
2011-01-12 10:33:34 +00:00
|
|
|
|
2014-03-17 15:19:44 +00:00
|
|
|
if (virQEMUCapsGet(qemubinCaps, QEMU_CAPS_DISK_SNAPSHOT))
|
|
|
|
hasdisksnapshot = true;
|
|
|
|
|
2014-07-14 12:56:13 +00:00
|
|
|
if (!virCapabilitiesAddGuestFeature(guest, "disksnapshot", hasdisksnapshot,
|
|
|
|
false))
|
2014-03-17 15:19:45 +00:00
|
|
|
goto cleanup;
|
2014-03-17 15:19:44 +00:00
|
|
|
|
2012-08-22 16:29:01 +00:00
|
|
|
if (virCapabilitiesAddGuestDomain(guest,
|
2015-04-17 22:38:10 +00:00
|
|
|
VIR_DOMAIN_VIRT_QEMU,
|
2012-08-22 16:29:01 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
NULL) == NULL)
|
2014-03-17 15:19:45 +00:00
|
|
|
goto cleanup;
|
2010-12-16 15:07:07 +00:00
|
|
|
|
2012-08-22 16:29:01 +00:00
|
|
|
if (haskvm) {
|
|
|
|
virCapsGuestDomainPtr dom;
|
2010-12-16 15:07:07 +00:00
|
|
|
|
2012-08-22 16:29:01 +00:00
|
|
|
if (kvmbin &&
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsGetMachineTypesCaps(kvmbinCaps, &nmachines, &machines) < 0)
|
2014-03-17 15:19:45 +00:00
|
|
|
goto cleanup;
|
2010-12-16 15:07:07 +00:00
|
|
|
|
2012-08-22 16:29:01 +00:00
|
|
|
if ((dom = virCapabilitiesAddGuestDomain(guest,
|
2015-04-17 22:38:10 +00:00
|
|
|
VIR_DOMAIN_VIRT_KVM,
|
2012-08-22 16:29:01 +00:00
|
|
|
kvmbin ? kvmbin : binary,
|
|
|
|
NULL,
|
|
|
|
nmachines,
|
|
|
|
machines)) == NULL) {
|
2014-03-17 15:19:45 +00:00
|
|
|
goto cleanup;
|
2012-08-22 16:29:01 +00:00
|
|
|
}
|
2010-12-16 15:07:07 +00:00
|
|
|
|
2012-08-22 16:29:01 +00:00
|
|
|
machines = NULL;
|
|
|
|
nmachines = 0;
|
2017-03-02 17:57:51 +00:00
|
|
|
}
|
2010-12-16 15:07:07 +00:00
|
|
|
|
2017-03-02 17:57:51 +00:00
|
|
|
if ((ARCH_IS_X86(guestarch) || guestarch == VIR_ARCH_AARCH64) &&
|
|
|
|
virCapabilitiesAddGuestFeature(guest, "acpi", true, true) == NULL) {
|
|
|
|
goto cleanup;
|
2010-12-16 15:07:07 +00:00
|
|
|
}
|
|
|
|
|
2017-03-02 17:00:05 +00:00
|
|
|
if (ARCH_IS_X86(guestarch) &&
|
2017-03-02 17:57:51 +00:00
|
|
|
virCapabilitiesAddGuestFeature(guest, "apic", true, false) == NULL) {
|
2014-03-17 15:19:45 +00:00
|
|
|
goto cleanup;
|
2017-03-02 17:57:51 +00:00
|
|
|
}
|
2012-08-22 16:59:39 +00:00
|
|
|
|
2012-12-10 22:28:09 +00:00
|
|
|
if ((guestarch == VIR_ARCH_I686) &&
|
2014-07-14 12:56:13 +00:00
|
|
|
(virCapabilitiesAddGuestFeature(guest, "pae", true, false) == NULL ||
|
|
|
|
virCapabilitiesAddGuestFeature(guest, "nonpae", true, false) == NULL))
|
2014-03-17 15:19:45 +00:00
|
|
|
goto cleanup;
|
2010-12-16 15:07:07 +00:00
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
|
2014-03-25 06:49:44 +00:00
|
|
|
cleanup:
|
2010-12-16 15:07:07 +00:00
|
|
|
|
|
|
|
virCapabilitiesFreeMachines(machines, nmachines);
|
|
|
|
|
2014-03-17 15:19:45 +00:00
|
|
|
return ret;
|
2010-12-16 15:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-03-08 12:32:46 +00:00
|
|
|
virCPUDefPtr
|
2017-07-21 13:09:54 +00:00
|
|
|
virQEMUCapsProbeHostCPUForEmulator(virArch hostArch,
|
2017-03-08 12:32:46 +00:00
|
|
|
virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainVirtType type)
|
|
|
|
{
|
2017-09-22 13:51:33 +00:00
|
|
|
return virCPUGetHost(hostArch, VIR_CPU_TYPE_GUEST, NULL,
|
|
|
|
virQEMUCapsGetCPUDefinitions(qemuCaps, type));
|
2017-03-08 12:32:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-19 15:01:56 +00:00
|
|
|
virCapsPtr
|
|
|
|
virQEMUCapsInit(virFileCachePtr cache)
|
2010-12-16 15:07:07 +00:00
|
|
|
{
|
|
|
|
virCapsPtr caps;
|
Convert 'int i' to 'size_t i' in src/qemu files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 14:09:33 +00:00
|
|
|
size_t i;
|
2013-04-08 12:33:07 +00:00
|
|
|
virArch hostarch = virArchFromHost();
|
2012-12-10 22:28:09 +00:00
|
|
|
|
2013-04-08 12:33:07 +00:00
|
|
|
if ((caps = virCapabilitiesNew(hostarch,
|
2014-07-14 12:56:13 +00:00
|
|
|
true, true)) == NULL)
|
2012-08-22 16:59:39 +00:00
|
|
|
goto error;
|
2010-12-16 15:07:07 +00:00
|
|
|
|
|
|
|
/* Some machines have problematic NUMA toplogy causing
|
|
|
|
* unexpected failures. We don't want to break the QEMU
|
|
|
|
* driver in this scenario, so log errors & carry on
|
|
|
|
*/
|
2017-03-07 09:40:15 +00:00
|
|
|
if (virCapabilitiesInitNUMA(caps) < 0) {
|
2010-12-16 15:07:07 +00:00
|
|
|
virCapabilitiesFreeNUMAInfo(caps);
|
2011-05-09 09:24:09 +00:00
|
|
|
VIR_WARN("Failed to query host NUMA topology, disabling NUMA capabilities");
|
2010-12-16 15:07:07 +00:00
|
|
|
}
|
|
|
|
|
2017-03-29 13:52:31 +00:00
|
|
|
if (virCapabilitiesInitCaches(caps) < 0)
|
|
|
|
VIR_WARN("Failed to get host CPU cache info");
|
|
|
|
|
2017-03-15 08:07:38 +00:00
|
|
|
if (!(caps->host.cpu = virCPUProbeHost(caps->host.arch)))
|
2012-08-22 13:37:05 +00:00
|
|
|
VIR_WARN("Failed to get host CPU");
|
2010-12-16 15:07:07 +00:00
|
|
|
|
2011-11-22 03:31:22 +00:00
|
|
|
/* Add the power management features of the host */
|
2011-11-29 14:50:04 +00:00
|
|
|
if (virNodeSuspendGetTargetMask(&caps->host.powerMgmt) < 0)
|
2011-11-22 03:31:22 +00:00
|
|
|
VIR_WARN("Failed to get host power management capabilities");
|
|
|
|
|
2014-06-06 16:12:51 +00:00
|
|
|
/* Add huge pages info */
|
2017-03-11 15:32:13 +00:00
|
|
|
if (virCapabilitiesInitPages(caps) < 0)
|
2014-06-06 16:12:51 +00:00
|
|
|
VIR_WARN("Failed to get pages info");
|
|
|
|
|
2014-09-11 12:11:54 +00:00
|
|
|
/* Add domain migration transport URIs */
|
|
|
|
virCapabilitiesAddHostMigrateTransport(caps, "tcp");
|
|
|
|
virCapabilitiesAddHostMigrateTransport(caps, "rdma");
|
2010-12-16 15:07:07 +00:00
|
|
|
|
2012-12-10 22:28:09 +00:00
|
|
|
/* QEMU can support pretty much every arch that exists,
|
|
|
|
* so just probe for them all - we gracefully fail
|
|
|
|
* if a qemu-system-$ARCH binary can't be found
|
|
|
|
*/
|
2013-05-21 07:21:20 +00:00
|
|
|
for (i = 0; i < VIR_ARCH_LAST; i++)
|
2013-02-01 13:48:58 +00:00
|
|
|
if (virQEMUCapsInitGuest(caps, cache,
|
2013-04-08 12:33:07 +00:00
|
|
|
hostarch,
|
2013-02-01 13:48:58 +00:00
|
|
|
i) < 0)
|
2012-08-22 16:59:39 +00:00
|
|
|
goto error;
|
2010-12-16 15:07:07 +00:00
|
|
|
|
|
|
|
return caps;
|
|
|
|
|
2014-03-25 06:49:44 +00:00
|
|
|
error:
|
2013-02-01 12:26:18 +00:00
|
|
|
virObjectUnref(caps);
|
2010-12-16 15:07:07 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
struct virQEMUCapsStringFlags {
|
2012-09-13 17:04:24 +00:00
|
|
|
const char *value;
|
|
|
|
int flag;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-06-19 08:00:10 +00:00
|
|
|
struct virQEMUCapsStringFlags virQEMUCapsCommands[] = {
|
|
|
|
{ "transaction", QEMU_CAPS_TRANSACTION },
|
qemu: better error message when block job can't succeed
https://bugzilla.redhat.com/show_bug.cgi?id=1140981 reports that
the qemu-kvm shipped as part of RHEL 7.0 intentionally[1] cripples
block jobs by removing the 'block-stream' QMP command, while still
leaving 'block-job-cancel' as an unusable no-op. Meanwhile, we
already had existing code that checked whether block jobs were
completely missing (such as qemu 0.15), old style (cancel is
synchronous, and all commands spelled with '_'), or new style
(cancel is asynchronous, and all commands spelled with '-'), and
used that three-way probe to give decent error messages. At the
time that code was added, all existing qemu versions fell in one
of three buckets, and the code was using the presence of
'block-job-cancel' as the witness of which of the three buckets.
But now that RHEL qemu has shipped with intentionally crippled
'block-stream', we have a fourth bucket, which results in ugly
error messages when trying 'virsh blockpull':
error: Requested operation is not valid: Command 'block-stream' is not found
In reality, the fourth bucket should be treated the same as the
first bucket (no block job support); we can do that by realizing
that no existing build of qemu has working block-stream while
lacking block-job-cancel, so it is easiest to change our witness
to the command that starts a job rather than ends one. We still
act correctly regarding command spelling and whether cancel is
asynchronous. And on crippled RHEL builds, we now get the desired:
error: unsupported configuration: block jobs not supported with this qemu binary
[1] The intentional cripple is limited to qemu-kvm of RHEL; when using
qemu-kvm-rhev of RHEV, block job functionality is supported. Don't ask
me to explain the "why" behind it all - I'm just dealing with fallout
from someone else's decision.
* src/qemu/qemu_capabilities.h (QEMU_CAPS_BLOCKJOB_SYNC): Tweak comment.
* src/qemu/qemu_capabilities.c (virQEMUCapsCommands): Look for stream
rather than cancel when determining the flavor of block jobs supported.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-10-24 20:49:13 +00:00
|
|
|
{ "block-stream", QEMU_CAPS_BLOCKJOB_ASYNC },
|
2013-06-19 08:00:10 +00:00
|
|
|
{ "dump-guest-memory", QEMU_CAPS_DUMP_GUEST_MEMORY },
|
|
|
|
{ "query-spice", QEMU_CAPS_SPICE },
|
|
|
|
{ "query-kvm", QEMU_CAPS_KVM },
|
|
|
|
{ "block-commit", QEMU_CAPS_BLOCK_COMMIT },
|
|
|
|
{ "query-vnc", QEMU_CAPS_VNC },
|
|
|
|
{ "drive-mirror", QEMU_CAPS_DRIVE_MIRROR },
|
|
|
|
{ "blockdev-snapshot-sync", QEMU_CAPS_DISK_SNAPSHOT },
|
|
|
|
{ "add-fd", QEMU_CAPS_ADD_FD },
|
|
|
|
{ "nbd-server-start", QEMU_CAPS_NBD_SERVER },
|
2014-05-26 12:09:22 +00:00
|
|
|
{ "change-backing-file", QEMU_CAPS_CHANGE_BACKING_FILE },
|
2014-08-13 12:28:24 +00:00
|
|
|
{ "rtc-reset-reinjection", QEMU_CAPS_RTC_RESET_REINJECTION },
|
2015-11-11 17:02:23 +00:00
|
|
|
{ "migrate-incoming", QEMU_CAPS_INCOMING_DEFER },
|
2016-06-23 11:56:12 +00:00
|
|
|
{ "query-hotpluggable-cpus", QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS },
|
2016-12-18 19:22:26 +00:00
|
|
|
{ "query-qmp-schema", QEMU_CAPS_QUERY_QMP_SCHEMA },
|
2018-03-20 15:45:15 +00:00
|
|
|
{ "query-cpu-model-expansion", QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION },
|
|
|
|
{ "query-cpu-definitions", QEMU_CAPS_QUERY_CPU_DEFINITIONS },
|
|
|
|
{ "query-named-block-nodes", QEMU_CAPS_QUERY_NAMED_BLOCK_NODES },
|
2018-03-05 11:44:24 +00:00
|
|
|
{ "query-cpus-fast", QEMU_CAPS_QUERY_CPUS_FAST },
|
2013-06-19 08:00:10 +00:00
|
|
|
};
|
|
|
|
|
2014-09-11 12:11:54 +00:00
|
|
|
struct virQEMUCapsStringFlags virQEMUCapsMigration[] = {
|
|
|
|
{ "rdma-pin-all", QEMU_CAPS_MIGRATE_RDMA },
|
|
|
|
};
|
|
|
|
|
2013-06-19 07:24:54 +00:00
|
|
|
struct virQEMUCapsStringFlags virQEMUCapsEvents[] = {
|
|
|
|
{ "BALLOON_CHANGE", QEMU_CAPS_BALLOON_EVENT },
|
|
|
|
{ "SPICE_MIGRATE_COMPLETED", QEMU_CAPS_SEAMLESS_MIGRATION },
|
2013-07-11 15:07:26 +00:00
|
|
|
{ "DEVICE_DELETED", QEMU_CAPS_DEVICE_DEL_EVENT },
|
2015-05-28 11:35:52 +00:00
|
|
|
{ "MIGRATION", QEMU_CAPS_MIGRATION_EVENT },
|
2016-01-05 13:05:15 +00:00
|
|
|
{ "VSERPORT_CHANGE", QEMU_CAPS_VSERPORT_CHANGE },
|
2016-04-29 11:49:13 +00:00
|
|
|
{ "DEVICE_TRAY_MOVED", QEMU_CAPS_DEVICE_TRAY_MOVED },
|
2017-02-22 15:52:22 +00:00
|
|
|
{ "BLOCK_WRITE_THRESHOLD", QEMU_CAPS_BLOCK_WRITE_THRESHOLD },
|
2017-11-17 13:46:27 +00:00
|
|
|
{ "DUMP_COMPLETED", QEMU_CAPS_DUMP_COMPLETED },
|
2013-06-19 07:24:54 +00:00
|
|
|
};
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
|
2012-09-13 17:04:24 +00:00
|
|
|
{ "hda-duplex", QEMU_CAPS_HDA_DUPLEX },
|
|
|
|
{ "hda-micro", QEMU_CAPS_HDA_MICRO },
|
|
|
|
{ "ccid-card-emulated", QEMU_CAPS_CCID_EMULATED },
|
|
|
|
{ "ccid-card-passthru", QEMU_CAPS_CCID_PASSTHRU },
|
|
|
|
{ "piix3-usb-uhci", QEMU_CAPS_PIIX3_USB_UHCI },
|
|
|
|
{ "piix4-usb-uhci", QEMU_CAPS_PIIX4_USB_UHCI },
|
|
|
|
{ "usb-ehci", QEMU_CAPS_USB_EHCI },
|
|
|
|
{ "ich9-usb-ehci1", QEMU_CAPS_ICH9_USB_EHCI1 },
|
|
|
|
{ "vt82c686b-usb-uhci", QEMU_CAPS_VT82C686B_USB_UHCI },
|
|
|
|
{ "pci-ohci", QEMU_CAPS_PCI_OHCI },
|
|
|
|
{ "nec-usb-xhci", QEMU_CAPS_NEC_USB_XHCI },
|
|
|
|
{ "usb-redir", QEMU_CAPS_USB_REDIR },
|
|
|
|
{ "usb-hub", QEMU_CAPS_USB_HUB },
|
|
|
|
{ "ich9-ahci", QEMU_CAPS_ICH9_AHCI },
|
|
|
|
{ "virtio-blk-s390", QEMU_CAPS_VIRTIO_S390 },
|
2013-03-05 15:44:21 +00:00
|
|
|
{ "virtio-blk-ccw", QEMU_CAPS_VIRTIO_CCW },
|
2017-11-15 17:05:44 +00:00
|
|
|
{ "sclpconsole", QEMU_CAPS_DEVICE_SCLPCONSOLE },
|
2012-09-13 17:04:24 +00:00
|
|
|
{ "lsi53c895a", QEMU_CAPS_SCSI_LSI },
|
2013-03-14 18:32:24 +00:00
|
|
|
{ "virtio-scsi-pci", QEMU_CAPS_VIRTIO_SCSI },
|
2013-03-14 18:32:25 +00:00
|
|
|
{ "virtio-scsi-s390", QEMU_CAPS_VIRTIO_SCSI },
|
|
|
|
{ "virtio-scsi-ccw", QEMU_CAPS_VIRTIO_SCSI },
|
2015-04-10 09:22:05 +00:00
|
|
|
{ "virtio-scsi-device", QEMU_CAPS_VIRTIO_SCSI },
|
2013-03-21 14:11:39 +00:00
|
|
|
{ "megasas", QEMU_CAPS_SCSI_MEGASAS },
|
2012-12-14 07:06:31 +00:00
|
|
|
{ "qxl", QEMU_CAPS_DEVICE_QXL },
|
2012-09-13 17:04:24 +00:00
|
|
|
{ "sga", QEMU_CAPS_SGA },
|
|
|
|
{ "scsi-block", QEMU_CAPS_SCSI_BLOCK },
|
|
|
|
{ "scsi-cd", QEMU_CAPS_SCSI_CD },
|
|
|
|
{ "ide-cd", QEMU_CAPS_IDE_CD },
|
2012-12-14 07:06:31 +00:00
|
|
|
{ "VGA", QEMU_CAPS_DEVICE_VGA },
|
|
|
|
{ "cirrus-vga", QEMU_CAPS_DEVICE_CIRRUS_VGA },
|
|
|
|
{ "vmware-svga", QEMU_CAPS_DEVICE_VMWARE_SVGA },
|
2013-05-03 18:07:21 +00:00
|
|
|
{ "usb-serial", QEMU_CAPS_DEVICE_USB_SERIAL },
|
|
|
|
{ "usb-net", QEMU_CAPS_DEVICE_USB_NET },
|
2013-01-11 16:48:21 +00:00
|
|
|
{ "virtio-rng-pci", QEMU_CAPS_DEVICE_VIRTIO_RNG },
|
2013-03-14 18:32:25 +00:00
|
|
|
{ "virtio-rng-s390", QEMU_CAPS_DEVICE_VIRTIO_RNG },
|
|
|
|
{ "virtio-rng-ccw", QEMU_CAPS_DEVICE_VIRTIO_RNG },
|
2015-04-10 09:22:05 +00:00
|
|
|
{ "virtio-rng-device", QEMU_CAPS_DEVICE_VIRTIO_RNG },
|
2013-01-11 16:48:21 +00:00
|
|
|
{ "rng-random", QEMU_CAPS_OBJECT_RNG_RANDOM },
|
2013-02-13 10:22:23 +00:00
|
|
|
{ "rng-egd", QEMU_CAPS_OBJECT_RNG_EGD },
|
2013-04-25 08:46:04 +00:00
|
|
|
{ "spapr-nvram", QEMU_CAPS_DEVICE_NVRAM },
|
2013-03-07 11:03:41 +00:00
|
|
|
{ "pci-bridge", QEMU_CAPS_DEVICE_PCI_BRIDGE },
|
2013-04-17 18:16:28 +00:00
|
|
|
{ "vfio-pci", QEMU_CAPS_DEVICE_VFIO_PCI },
|
2013-05-03 18:07:21 +00:00
|
|
|
{ "scsi-generic", QEMU_CAPS_DEVICE_SCSI_GENERIC },
|
qemu: add dmi-to-pci-bridge controller
This PCI controller, named "dmi-to-pci-bridge" in the libvirt config,
and implemented with qemu's "i82801b11-bridge" device, connects to a
PCI Express slot (e.g. one of the slots provided by the pcie-root
controller, aka "pcie.0" on the qemu commandline), and provides 31
*non-hot-pluggable* PCI (*not* PCIe) slots, numbered 1-31.
Any time a machine is defined which has a pcie-root controller
(i.e. any q35-based machinetype), libvirt will automatically add a
dmi-to-pci-bridge controller if one doesn't exist, and also add a
pci-bridge controller. The reasoning here is that any useful domain
will have either an immediate (startup time) or eventual (subsequent
hot-plug) need for a standard PCI slot; since the pcie-root controller
only provides PCIe slots, we need to connect a dmi-to-pci-bridge
controller to it in order to get a non-hot-plug PCI slot that we can
then use to connect a pci-bridge - the slots provided by the
pci-bridge will be both standard PCI and hot-pluggable.
Since pci-bridge devices themselves can not be hot-plugged into a
running system (although you can hot-plug other devices into a
pci-bridge's slots), any new pci-bridge controller that is added can
(and will) be plugged into the dmi-to-pci-bridge as long as it has
empty slots available.
This patch is also changing the qemuxml2xml-pcie test from a "DO_TEST"
to a "DO_DIFFERENT_TEST". This is so that the "before" xml can omit
the automatically added dmi-to-pci-bridge and pci-bridge devices, and
the "after" xml can include it - this way we are testing if libvirt is
properly adding these devices.
2013-07-31 01:37:32 +00:00
|
|
|
{ "i82801b11-bridge", QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE },
|
2013-08-23 10:38:10 +00:00
|
|
|
{ "usb-storage", QEMU_CAPS_DEVICE_USB_STORAGE },
|
2013-08-01 01:40:35 +00:00
|
|
|
{ "virtio-mmio", QEMU_CAPS_DEVICE_VIRTIO_MMIO },
|
2013-09-24 14:17:38 +00:00
|
|
|
{ "ich9-intel-hda", QEMU_CAPS_DEVICE_ICH9_INTEL_HDA },
|
2013-12-09 09:11:15 +00:00
|
|
|
{ "pvpanic", QEMU_CAPS_DEVICE_PANIC },
|
2014-02-17 10:17:55 +00:00
|
|
|
{ "usb-kbd", QEMU_CAPS_DEVICE_USB_KBD },
|
2014-05-07 15:20:15 +00:00
|
|
|
{ "memory-backend-ram", QEMU_CAPS_OBJECT_MEMORY_RAM },
|
2014-07-23 15:37:21 +00:00
|
|
|
{ "memory-backend-file", QEMU_CAPS_OBJECT_MEMORY_FILE },
|
2014-07-24 15:32:31 +00:00
|
|
|
{ "usb-audio", QEMU_CAPS_OBJECT_USB_AUDIO },
|
2014-08-22 22:15:30 +00:00
|
|
|
{ "iothread", QEMU_CAPS_OBJECT_IOTHREAD},
|
2014-08-22 10:47:02 +00:00
|
|
|
{ "ivshmem", QEMU_CAPS_DEVICE_IVSHMEM },
|
2014-10-06 12:16:47 +00:00
|
|
|
{ "pc-dimm", QEMU_CAPS_DEVICE_PC_DIMM },
|
2015-05-06 15:50:03 +00:00
|
|
|
{ "pci-serial", QEMU_CAPS_DEVICE_PCI_SERIAL },
|
2015-07-17 11:27:44 +00:00
|
|
|
{ "gpex-pcihost", QEMU_CAPS_OBJECT_GPEX},
|
2015-06-17 17:13:28 +00:00
|
|
|
{ "ioh3420", QEMU_CAPS_DEVICE_IOH3420 },
|
2015-06-16 18:54:21 +00:00
|
|
|
{ "x3130-upstream", QEMU_CAPS_DEVICE_X3130_UPSTREAM },
|
2015-06-17 18:24:29 +00:00
|
|
|
{ "xio3130-downstream", QEMU_CAPS_DEVICE_XIO3130_DOWNSTREAM },
|
2015-09-04 14:23:46 +00:00
|
|
|
{ "rtl8139", QEMU_CAPS_DEVICE_RTL8139 },
|
2015-09-04 14:40:37 +00:00
|
|
|
{ "e1000", QEMU_CAPS_DEVICE_E1000 },
|
2015-09-01 12:38:19 +00:00
|
|
|
{ "virtio-net-pci", QEMU_CAPS_DEVICE_VIRTIO_NET },
|
|
|
|
{ "virtio-net-ccw", QEMU_CAPS_DEVICE_VIRTIO_NET },
|
|
|
|
{ "virtio-net-s390", QEMU_CAPS_DEVICE_VIRTIO_NET },
|
|
|
|
{ "virtio-net-device", QEMU_CAPS_DEVICE_VIRTIO_NET },
|
2015-11-25 08:42:32 +00:00
|
|
|
{ "virtio-gpu-pci", QEMU_CAPS_DEVICE_VIRTIO_GPU },
|
|
|
|
{ "virtio-gpu-device", QEMU_CAPS_DEVICE_VIRTIO_GPU },
|
2016-10-11 12:07:58 +00:00
|
|
|
{ "virtio-vga", QEMU_CAPS_DEVICE_VIRTIO_VGA },
|
2015-11-13 10:26:37 +00:00
|
|
|
{ "virtio-keyboard-device", QEMU_CAPS_VIRTIO_KEYBOARD },
|
|
|
|
{ "virtio-keyboard-pci", QEMU_CAPS_VIRTIO_KEYBOARD },
|
|
|
|
{ "virtio-mouse-device", QEMU_CAPS_VIRTIO_MOUSE },
|
|
|
|
{ "virtio-mouse-pci", QEMU_CAPS_VIRTIO_MOUSE },
|
|
|
|
{ "virtio-tablet-device", QEMU_CAPS_VIRTIO_TABLET },
|
|
|
|
{ "virtio-tablet-pci", QEMU_CAPS_VIRTIO_TABLET },
|
2015-11-13 14:41:20 +00:00
|
|
|
{ "virtio-input-host-device", QEMU_CAPS_VIRTIO_INPUT_HOST },
|
|
|
|
{ "virtio-input-host-pci", QEMU_CAPS_VIRTIO_INPUT_HOST },
|
2016-02-11 10:48:20 +00:00
|
|
|
{ "mptsas1068", QEMU_CAPS_SCSI_MPTSAS1068 },
|
2016-03-21 15:49:12 +00:00
|
|
|
{ "secret", QEMU_CAPS_OBJECT_SECRET },
|
2016-02-24 21:40:49 +00:00
|
|
|
{ "pxb", QEMU_CAPS_DEVICE_PXB },
|
2016-03-08 21:25:22 +00:00
|
|
|
{ "pxb-pcie", QEMU_CAPS_DEVICE_PXB_PCIE },
|
2016-06-07 15:28:20 +00:00
|
|
|
{ "tls-creds-x509", QEMU_CAPS_OBJECT_TLS_CREDS_X509 },
|
2016-06-22 15:24:24 +00:00
|
|
|
{ "intel-iommu", QEMU_CAPS_DEVICE_INTEL_IOMMU },
|
2016-08-02 06:48:45 +00:00
|
|
|
{ "ivshmem-plain", QEMU_CAPS_DEVICE_IVSHMEM_PLAIN },
|
|
|
|
{ "ivshmem-doorbell", QEMU_CAPS_DEVICE_IVSHMEM_DOORBELL },
|
2016-11-22 03:58:15 +00:00
|
|
|
{ "vhost-scsi", QEMU_CAPS_DEVICE_VHOST_SCSI },
|
2016-07-29 06:17:42 +00:00
|
|
|
{ "nvdimm", QEMU_CAPS_DEVICE_NVDIMM },
|
2017-01-16 12:28:20 +00:00
|
|
|
{ "pcie-root-port", QEMU_CAPS_DEVICE_PCIE_ROOT_PORT },
|
2017-04-28 08:44:03 +00:00
|
|
|
{ "qemu-xhci", QEMU_CAPS_DEVICE_QEMU_XHCI },
|
2017-02-20 14:34:51 +00:00
|
|
|
{ "spapr-pci-host-bridge", QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE },
|
2017-11-16 16:49:38 +00:00
|
|
|
{ "vmcoreinfo", QEMU_CAPS_DEVICE_VMCOREINFO },
|
2017-11-08 18:13:28 +00:00
|
|
|
{ "spapr-vty", QEMU_CAPS_DEVICE_SPAPR_VTY },
|
2017-11-15 17:08:44 +00:00
|
|
|
{ "sclplmconsole", QEMU_CAPS_DEVICE_SCLPLMCONSOLE },
|
2017-11-26 16:19:46 +00:00
|
|
|
{ "isa-serial", QEMU_CAPS_DEVICE_ISA_SERIAL },
|
2017-11-28 10:23:26 +00:00
|
|
|
{ "pl011", QEMU_CAPS_DEVICE_PL011 },
|
2018-03-23 17:22:38 +00:00
|
|
|
{ "virtio-gpu-ccw", QEMU_CAPS_DEVICE_VIRTIO_GPU_CCW },
|
2018-03-23 17:22:41 +00:00
|
|
|
{ "virtio-keyboard-ccw", QEMU_CAPS_DEVICE_VIRTIO_KEYBOARD_CCW },
|
|
|
|
{ "virtio-mouse-ccw", QEMU_CAPS_DEVICE_VIRTIO_MOUSE_CCW },
|
|
|
|
{ "virtio-tablet-ccw", QEMU_CAPS_DEVICE_VIRTIO_TABLET_CCW },
|
2018-01-09 17:05:30 +00:00
|
|
|
{ "pcie-pci-bridge", QEMU_CAPS_DEVICE_PCIE_PCI_BRIDGE },
|
2012-09-13 17:04:24 +00:00
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVirtioBalloon[] = {
|
2016-01-08 10:45:06 +00:00
|
|
|
{ "deflate-on-oom", QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE },
|
2018-03-06 13:44:49 +00:00
|
|
|
{ "disable-legacy", QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY },
|
|
|
|
{ "iommu_platform", QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM },
|
|
|
|
{ "ats", QEMU_CAPS_VIRTIO_PCI_ATS },
|
2016-01-08 10:45:06 +00:00
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVirtioBlk[] = {
|
2012-09-13 17:04:24 +00:00
|
|
|
{ "bootindex", QEMU_CAPS_BOOTINDEX },
|
|
|
|
{ "ioeventfd", QEMU_CAPS_VIRTIO_IOEVENTFD },
|
|
|
|
{ "event_idx", QEMU_CAPS_VIRTIO_BLK_EVENT_IDX },
|
|
|
|
{ "scsi", QEMU_CAPS_VIRTIO_BLK_SCSI },
|
|
|
|
{ "logical_block_size", QEMU_CAPS_BLOCKIO },
|
2017-09-30 17:15:35 +00:00
|
|
|
{ "num-queues", QEMU_CAPS_VIRTIO_BLK_NUM_QUEUES },
|
2017-11-15 14:02:58 +00:00
|
|
|
{ "share-rw", QEMU_CAPS_DISK_SHARE_RW },
|
2018-03-06 13:44:49 +00:00
|
|
|
{ "disable-legacy", QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY },
|
|
|
|
{ "iommu_platform", QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM },
|
|
|
|
{ "ats", QEMU_CAPS_VIRTIO_PCI_ATS },
|
2018-04-03 17:11:22 +00:00
|
|
|
{ "write-cache", QEMU_CAPS_DISK_WRITE_CACHE },
|
2012-09-13 17:04:24 +00:00
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVirtioNet[] = {
|
2012-09-13 17:04:24 +00:00
|
|
|
{ "tx", QEMU_CAPS_VIRTIO_TX_ALG },
|
|
|
|
{ "event_idx", QEMU_CAPS_VIRTIO_NET_EVENT_IDX },
|
2016-08-19 06:39:08 +00:00
|
|
|
{ "rx_queue_size", QEMU_CAPS_VIRTIO_NET_RX_QUEUE_SIZE },
|
2017-07-12 12:19:26 +00:00
|
|
|
{ "tx_queue_size", QEMU_CAPS_VIRTIO_NET_TX_QUEUE_SIZE },
|
2017-01-23 13:33:20 +00:00
|
|
|
{ "host_mtu", QEMU_CAPS_VIRTIO_NET_HOST_MTU },
|
2018-03-06 13:44:49 +00:00
|
|
|
{ "disable-legacy", QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY },
|
|
|
|
{ "iommu_platform", QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM },
|
|
|
|
{ "ats", QEMU_CAPS_VIRTIO_PCI_ATS },
|
2012-09-13 17:04:24 +00:00
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsSpaprPCIHostBridge[] = {
|
2017-07-21 08:02:32 +00:00
|
|
|
{ "numa_node", QEMU_CAPS_SPAPR_PCI_HOST_BRIDGE_NUMA_NODE },
|
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVirtioSCSI[] = {
|
2016-04-20 18:43:04 +00:00
|
|
|
{ "iothread", QEMU_CAPS_VIRTIO_SCSI_IOTHREAD },
|
2018-03-06 13:44:49 +00:00
|
|
|
{ "disable-legacy", QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY },
|
|
|
|
{ "iommu_platform", QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM },
|
|
|
|
{ "ats", QEMU_CAPS_VIRTIO_PCI_ATS },
|
2016-04-20 18:43:04 +00:00
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsPCIAssign[] = {
|
2012-09-13 17:04:24 +00:00
|
|
|
{ "configfd", QEMU_CAPS_PCI_CONFIGFD },
|
|
|
|
{ "bootindex", QEMU_CAPS_PCI_BOOTINDEX },
|
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVfioPCI[] = {
|
2013-04-17 18:16:28 +00:00
|
|
|
{ "bootindex", QEMU_CAPS_VFIO_PCI_BOOTINDEX },
|
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsSCSIDisk[] = {
|
2012-09-13 17:04:24 +00:00
|
|
|
{ "channel", QEMU_CAPS_SCSI_DISK_CHANNEL },
|
|
|
|
{ "wwn", QEMU_CAPS_SCSI_DISK_WWN },
|
2017-11-15 14:02:58 +00:00
|
|
|
{ "share-rw", QEMU_CAPS_DISK_SHARE_RW },
|
2018-04-03 17:11:22 +00:00
|
|
|
{ "write-cache", QEMU_CAPS_DISK_WRITE_CACHE },
|
2012-09-13 17:04:24 +00:00
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsIDEDrive[] = {
|
2012-09-13 17:04:24 +00:00
|
|
|
{ "wwn", QEMU_CAPS_IDE_DRIVE_WWN },
|
2017-11-15 14:02:58 +00:00
|
|
|
{ "share-rw", QEMU_CAPS_DISK_SHARE_RW },
|
2018-04-03 17:11:22 +00:00
|
|
|
{ "write-cache", QEMU_CAPS_DISK_WRITE_CACHE },
|
2012-09-13 17:04:24 +00:00
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsPiix4PM[] = {
|
2016-01-04 22:57:06 +00:00
|
|
|
{ "disable_s3", QEMU_CAPS_PIIX_DISABLE_S3 },
|
|
|
|
{ "disable_s4", QEMU_CAPS_PIIX_DISABLE_S4 },
|
2012-09-13 17:04:24 +00:00
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsUSBRedir[] = {
|
2012-09-13 17:04:24 +00:00
|
|
|
{ "filter", QEMU_CAPS_USB_REDIR_FILTER },
|
2012-11-14 14:51:30 +00:00
|
|
|
{ "bootindex", QEMU_CAPS_USB_REDIR_BOOTINDEX },
|
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsUSBHost[] = {
|
2012-11-14 14:51:30 +00:00
|
|
|
{ "bootindex", QEMU_CAPS_USB_HOST_BOOTINDEX },
|
2012-09-13 17:04:24 +00:00
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsSCSIGeneric[] = {
|
2013-05-03 18:07:21 +00:00
|
|
|
{ "bootindex", QEMU_CAPS_DEVICE_SCSI_GENERIC_BOOTINDEX },
|
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsI440FXPCIHost[] = {
|
2013-08-12 11:48:34 +00:00
|
|
|
{ "pci-hole64-size", QEMU_CAPS_I440FX_PCI_HOLE64_SIZE },
|
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsQ35PCIHost[] = {
|
2013-08-12 11:48:34 +00:00
|
|
|
{ "pci-hole64-size", QEMU_CAPS_Q35_PCI_HOLE64_SIZE },
|
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsUSBStorage[] = {
|
2013-08-23 10:38:11 +00:00
|
|
|
{ "removable", QEMU_CAPS_USB_STORAGE_REMOVABLE },
|
2017-11-15 14:02:58 +00:00
|
|
|
{ "share-rw", QEMU_CAPS_DISK_SHARE_RW },
|
2018-04-03 17:11:22 +00:00
|
|
|
{ "write-cache", QEMU_CAPS_DISK_WRITE_CACHE },
|
2013-08-23 10:38:11 +00:00
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsKVMPit[] = {
|
2013-07-01 16:28:50 +00:00
|
|
|
{ "lost_tick_policy", QEMU_CAPS_KVM_PIT_TICK_POLICY },
|
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVGA[] = {
|
2014-11-12 12:58:33 +00:00
|
|
|
{ "vgamem_mb", QEMU_CAPS_VGA_VGAMEM },
|
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVmwareSvga[] = {
|
2014-11-12 12:58:33 +00:00
|
|
|
{ "vgamem_mb", QEMU_CAPS_VMWARE_SVGA_VGAMEM },
|
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsQxl[] = {
|
2014-11-12 12:58:33 +00:00
|
|
|
{ "vgamem_mb", QEMU_CAPS_QXL_VGAMEM },
|
2016-03-01 12:46:37 +00:00
|
|
|
{ "vram64_size_mb", QEMU_CAPS_QXL_VRAM64 },
|
2015-12-11 13:26:24 +00:00
|
|
|
{ "max_outputs", QEMU_CAPS_QXL_MAX_OUTPUTS },
|
2014-11-12 12:58:33 +00:00
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVirtioGpu[] = {
|
2016-10-11 12:06:53 +00:00
|
|
|
{ "virgl", QEMU_CAPS_VIRTIO_GPU_VIRGL },
|
2017-08-23 12:06:17 +00:00
|
|
|
{ "max_outputs", QEMU_CAPS_VIRTIO_GPU_MAX_OUTPUTS },
|
2018-03-06 13:44:49 +00:00
|
|
|
{ "disable-legacy", QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY },
|
|
|
|
{ "iommu_platform", QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM },
|
|
|
|
{ "ats", QEMU_CAPS_VIRTIO_PCI_ATS },
|
2015-11-25 08:42:33 +00:00
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsICH9[] = {
|
2016-01-09 20:58:50 +00:00
|
|
|
{ "disable_s3", QEMU_CAPS_ICH9_DISABLE_S3 },
|
|
|
|
{ "disable_s4", QEMU_CAPS_ICH9_DISABLE_S4 },
|
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsUSBNECXHCI[] = {
|
2016-04-24 14:52:38 +00:00
|
|
|
{ "p3", QEMU_CAPS_NEC_USB_XHCI_PORTS },
|
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsIntelIOMMU[] = {
|
2017-05-03 13:23:12 +00:00
|
|
|
{ "intremap", QEMU_CAPS_INTEL_IOMMU_INTREMAP },
|
2017-03-17 07:28:04 +00:00
|
|
|
{ "caching-mode", QEMU_CAPS_INTEL_IOMMU_CACHING_MODE },
|
2017-05-18 08:48:03 +00:00
|
|
|
{ "eim", QEMU_CAPS_INTEL_IOMMU_EIM },
|
2017-05-03 15:18:47 +00:00
|
|
|
{ "device-iotlb", QEMU_CAPS_INTEL_IOMMU_DEVICE_IOTLB },
|
2017-05-03 13:23:12 +00:00
|
|
|
};
|
|
|
|
|
2018-03-20 07:57:44 +00:00
|
|
|
/* see documentation for virQEMUQAPISchemaPathGet for the query format */
|
2016-10-19 12:40:53 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsQMPSchemaQueries[] = {
|
2016-09-21 19:34:19 +00:00
|
|
|
{ "blockdev-add/arg-type/options/+gluster/debug-level", QEMU_CAPS_GLUSTER_DEBUG_LEVEL},
|
2016-12-06 15:59:18 +00:00
|
|
|
{ "blockdev-add/arg-type/+gluster/debug", QEMU_CAPS_GLUSTER_DEBUG_LEVEL},
|
2017-08-29 22:44:19 +00:00
|
|
|
{ "blockdev-add/arg-type/+vxhs", QEMU_CAPS_VXHS},
|
2017-09-01 19:09:29 +00:00
|
|
|
{ "blockdev-add/arg-type/+iscsi/password-secret", QEMU_CAPS_ISCSI_PASSWORD_SECRET },
|
2018-03-28 11:29:11 +00:00
|
|
|
{ "blockdev-add/arg-type/+qcow2/encrypt/+luks/key-secret", QEMU_CAPS_QCOW2_LUKS },
|
2018-04-26 11:11:05 +00:00
|
|
|
{ "nbd-server-start/arg-type/tls-creds", QEMU_CAPS_NBD_TLS },
|
2016-10-19 12:40:53 +00:00
|
|
|
};
|
|
|
|
|
2018-04-12 12:39:43 +00:00
|
|
|
typedef struct _virQEMUCapsObjectTypeProps virQEMUCapsObjectTypeProps;
|
|
|
|
struct _virQEMUCapsObjectTypeProps {
|
2012-09-13 17:04:24 +00:00
|
|
|
const char *type;
|
2013-02-01 13:48:58 +00:00
|
|
|
struct virQEMUCapsStringFlags *props;
|
2012-09-13 17:04:24 +00:00
|
|
|
size_t nprops;
|
2017-03-20 15:08:48 +00:00
|
|
|
int capsCondition;
|
2012-09-13 17:04:24 +00:00
|
|
|
};
|
|
|
|
|
2018-04-12 12:39:43 +00:00
|
|
|
typedef int (*virQEMUCapsObjectTypePropsCB)(qemuMonitorPtr mon,
|
|
|
|
const char *type,
|
|
|
|
char ***props);
|
|
|
|
|
|
|
|
static virQEMUCapsObjectTypeProps virQEMUCapsDeviceProps[] = {
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "virtio-blk-pci", virQEMUCapsDevicePropsVirtioBlk,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioBlk),
|
2017-03-20 15:08:48 +00:00
|
|
|
-1 },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "virtio-net-pci", virQEMUCapsDevicePropsVirtioNet,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioNet),
|
2018-03-06 12:49:39 +00:00
|
|
|
QEMU_CAPS_DEVICE_VIRTIO_NET },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "virtio-scsi-pci", virQEMUCapsDevicePropsVirtioSCSI,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioSCSI),
|
2018-03-06 12:49:39 +00:00
|
|
|
QEMU_CAPS_VIRTIO_SCSI },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "virtio-blk-ccw", virQEMUCapsDevicePropsVirtioBlk,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioBlk),
|
2018-03-06 12:49:39 +00:00
|
|
|
QEMU_CAPS_VIRTIO_CCW },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "virtio-net-ccw", virQEMUCapsDevicePropsVirtioNet,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioNet),
|
2018-03-06 12:49:39 +00:00
|
|
|
QEMU_CAPS_DEVICE_VIRTIO_NET },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "virtio-scsi-ccw", virQEMUCapsDevicePropsVirtioSCSI,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioSCSI),
|
2018-03-06 12:49:39 +00:00
|
|
|
QEMU_CAPS_VIRTIO_SCSI },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "virtio-blk-s390", virQEMUCapsDevicePropsVirtioBlk,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioBlk),
|
2018-03-06 12:49:39 +00:00
|
|
|
QEMU_CAPS_VIRTIO_S390 },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "virtio-net-s390", virQEMUCapsDevicePropsVirtioNet,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioNet),
|
2018-03-06 12:49:39 +00:00
|
|
|
QEMU_CAPS_DEVICE_VIRTIO_NET },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "pci-assign", virQEMUCapsDevicePropsPCIAssign,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsPCIAssign),
|
2017-03-20 15:08:48 +00:00
|
|
|
-1 },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "kvm-pci-assign", virQEMUCapsDevicePropsPCIAssign,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsPCIAssign),
|
2017-03-20 15:08:48 +00:00
|
|
|
-1 },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "vfio-pci", virQEMUCapsDevicePropsVfioPCI,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVfioPCI),
|
2018-03-06 12:49:39 +00:00
|
|
|
QEMU_CAPS_DEVICE_VFIO_PCI },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "scsi-disk", virQEMUCapsDevicePropsSCSIDisk,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsSCSIDisk),
|
2017-03-20 15:08:48 +00:00
|
|
|
-1 },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "ide-drive", virQEMUCapsDevicePropsIDEDrive,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsIDEDrive),
|
2017-03-20 15:08:48 +00:00
|
|
|
-1 },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "PIIX4_PM", virQEMUCapsDevicePropsPiix4PM,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsPiix4PM),
|
2017-03-20 15:08:48 +00:00
|
|
|
-1 },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "usb-redir", virQEMUCapsDevicePropsUSBRedir,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsUSBRedir),
|
2018-03-06 12:49:39 +00:00
|
|
|
QEMU_CAPS_USB_REDIR },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "usb-host", virQEMUCapsDevicePropsUSBHost,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsUSBHost),
|
2017-03-20 15:08:48 +00:00
|
|
|
-1 },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "scsi-generic", virQEMUCapsDevicePropsSCSIGeneric,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsSCSIGeneric),
|
2018-03-06 12:49:39 +00:00
|
|
|
QEMU_CAPS_DEVICE_SCSI_GENERIC },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "i440FX-pcihost", virQEMUCapsDevicePropsI440FXPCIHost,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsI440FXPCIHost),
|
2017-03-20 15:08:48 +00:00
|
|
|
-1 },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "q35-pcihost", virQEMUCapsDevicePropsQ35PCIHost,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsQ35PCIHost),
|
2017-03-20 15:08:48 +00:00
|
|
|
-1 },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "usb-storage", virQEMUCapsDevicePropsUSBStorage,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsUSBStorage),
|
2018-03-06 12:49:39 +00:00
|
|
|
QEMU_CAPS_DEVICE_USB_STORAGE },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "kvm-pit", virQEMUCapsDevicePropsKVMPit,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsKVMPit),
|
2017-03-20 15:08:48 +00:00
|
|
|
-1 },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "VGA", virQEMUCapsDevicePropsVGA,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVGA),
|
2018-03-06 12:49:39 +00:00
|
|
|
QEMU_CAPS_DEVICE_VGA },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "vmware-svga", virQEMUCapsDevicePropsVmwareSvga,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVmwareSvga),
|
2018-03-06 12:49:39 +00:00
|
|
|
QEMU_CAPS_DEVICE_VMWARE_SVGA },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "qxl", virQEMUCapsDevicePropsQxl,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsQxl),
|
2018-03-06 12:49:39 +00:00
|
|
|
QEMU_CAPS_DEVICE_QXL },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "virtio-gpu-pci", virQEMUCapsDevicePropsVirtioGpu,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioGpu),
|
2018-03-06 12:49:39 +00:00
|
|
|
QEMU_CAPS_DEVICE_VIRTIO_GPU },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "virtio-gpu-device", virQEMUCapsDevicePropsVirtioGpu,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioGpu),
|
2018-03-06 12:49:39 +00:00
|
|
|
QEMU_CAPS_DEVICE_VIRTIO_GPU },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "ICH9-LPC", virQEMUCapsDevicePropsICH9,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsICH9),
|
2017-03-20 15:08:48 +00:00
|
|
|
-1 },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "virtio-balloon-pci", virQEMUCapsDevicePropsVirtioBalloon,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioBalloon),
|
2017-03-20 15:08:48 +00:00
|
|
|
-1 },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "virtio-balloon-ccw", virQEMUCapsDevicePropsVirtioBalloon,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioBalloon),
|
2017-03-20 15:08:48 +00:00
|
|
|
-1 },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "virtio-balloon-device", virQEMUCapsDevicePropsVirtioBalloon,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioBalloon),
|
2017-03-20 15:08:48 +00:00
|
|
|
-1 },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "nec-usb-xhci", virQEMUCapsDevicePropsUSBNECXHCI,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsUSBNECXHCI),
|
2018-03-06 12:49:39 +00:00
|
|
|
QEMU_CAPS_NEC_USB_XHCI },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "intel-iommu", virQEMUCapsDevicePropsIntelIOMMU,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsIntelIOMMU),
|
2017-07-24 05:55:16 +00:00
|
|
|
QEMU_CAPS_DEVICE_INTEL_IOMMU },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "spapr-pci-host-bridge", virQEMUCapsDevicePropsSpaprPCIHostBridge,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsSpaprPCIHostBridge),
|
2017-07-21 08:02:32 +00:00
|
|
|
QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "virtio-gpu-ccw", virQEMUCapsDevicePropsVirtioGpu,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioGpu),
|
2018-03-23 17:22:38 +00:00
|
|
|
QEMU_CAPS_DEVICE_VIRTIO_GPU_CCW },
|
2012-09-13 17:04:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsProcessStringFlags(virQEMUCapsPtr qemuCaps,
|
|
|
|
size_t nflags,
|
|
|
|
struct virQEMUCapsStringFlags *flags,
|
|
|
|
size_t nvalues,
|
|
|
|
char *const*values)
|
2012-09-13 17:04:24 +00:00
|
|
|
{
|
|
|
|
size_t i, j;
|
2013-05-21 07:21:20 +00:00
|
|
|
for (i = 0; i < nflags; i++) {
|
2018-03-06 12:43:26 +00:00
|
|
|
if (virQEMUCapsGet(qemuCaps, flags[i].flag))
|
|
|
|
continue;
|
|
|
|
|
2013-05-21 07:21:20 +00:00
|
|
|
for (j = 0; j < nvalues; j++) {
|
2012-09-13 17:04:24 +00:00
|
|
|
if (STREQ(values[j], flags[i].value)) {
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsSet(qemuCaps, flags[i].flag);
|
2012-09-13 17:04:24 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
int virQEMUCapsGetDefaultVersion(virCapsPtr caps,
|
2017-07-19 15:01:56 +00:00
|
|
|
virFileCachePtr capsCache,
|
2013-02-01 13:48:58 +00:00
|
|
|
unsigned int *version)
|
2010-12-16 15:07:07 +00:00
|
|
|
{
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsPtr qemucaps;
|
2013-04-08 12:33:07 +00:00
|
|
|
virArch hostarch;
|
2015-04-18 00:15:25 +00:00
|
|
|
virCapsDomainDataPtr capsdata;
|
2010-12-16 15:07:07 +00:00
|
|
|
|
|
|
|
if (*version > 0)
|
|
|
|
return 0;
|
|
|
|
|
2013-04-08 12:33:07 +00:00
|
|
|
hostarch = virArchFromHost();
|
2015-04-18 00:15:25 +00:00
|
|
|
if (!(capsdata = virCapabilitiesDomainDataLookup(caps,
|
|
|
|
VIR_DOMAIN_OSTYPE_HVM, hostarch, VIR_DOMAIN_VIRT_QEMU,
|
|
|
|
NULL, NULL))) {
|
2012-07-18 15:22:03 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
2012-12-10 22:28:09 +00:00
|
|
|
_("Cannot find suitable emulator for %s"),
|
2013-04-08 12:33:07 +00:00
|
|
|
virArchToString(hostarch));
|
2010-12-16 15:07:07 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2017-07-21 13:09:54 +00:00
|
|
|
qemucaps = virQEMUCapsCacheLookup(capsCache, capsdata->emulator);
|
2015-04-18 00:15:25 +00:00
|
|
|
VIR_FREE(capsdata);
|
|
|
|
if (!qemucaps)
|
2010-12-16 15:07:07 +00:00
|
|
|
return -1;
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
*version = virQEMUCapsGetVersion(qemucaps);
|
2012-08-22 14:39:54 +00:00
|
|
|
virObjectUnref(qemucaps);
|
2010-12-16 15:07:07 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2011-02-08 14:08:12 +00:00
|
|
|
|
|
|
|
|
2012-08-20 16:44:14 +00:00
|
|
|
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsPtr
|
|
|
|
virQEMUCapsNew(void)
|
2011-02-08 14:22:39 +00:00
|
|
|
{
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsPtr qemuCaps;
|
2011-02-08 14:22:39 +00:00
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
if (virQEMUCapsInitialize() < 0)
|
2012-08-20 16:44:14 +00:00
|
|
|
return NULL;
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
if (!(qemuCaps = virObjectNew(virQEMUCapsClass)))
|
2012-08-20 16:44:14 +00:00
|
|
|
return NULL;
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
if (!(qemuCaps->flags = virBitmapNew(QEMU_CAPS_LAST)))
|
2013-07-04 10:14:12 +00:00
|
|
|
goto error;
|
2011-02-08 14:22:39 +00:00
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
return qemuCaps;
|
2012-08-20 16:44:14 +00:00
|
|
|
|
2014-03-25 06:49:44 +00:00
|
|
|
error:
|
2013-02-01 13:48:58 +00:00
|
|
|
virObjectUnref(qemuCaps);
|
2012-08-20 16:44:14 +00:00
|
|
|
return NULL;
|
2011-02-08 14:22:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-04-07 15:40:31 +00:00
|
|
|
static int
|
2017-04-07 16:15:26 +00:00
|
|
|
virQEMUCapsHostCPUDataCopy(virQEMUCapsHostCPUDataPtr dst,
|
|
|
|
virQEMUCapsHostCPUDataPtr src)
|
2017-04-07 15:40:31 +00:00
|
|
|
{
|
2017-04-07 16:15:26 +00:00
|
|
|
if (src->info &&
|
|
|
|
!(dst->info = qemuMonitorCPUModelInfoCopy(src->info)))
|
2017-04-07 15:40:31 +00:00
|
|
|
return -1;
|
|
|
|
|
2017-04-07 16:15:26 +00:00
|
|
|
if (src->reported &&
|
|
|
|
!(dst->reported = virCPUDefCopy(src->reported)))
|
2017-04-07 15:40:31 +00:00
|
|
|
return -1;
|
|
|
|
|
2017-03-29 13:31:17 +00:00
|
|
|
if (src->migratable &&
|
|
|
|
!(dst->migratable = virCPUDefCopy(src->migratable)))
|
|
|
|
return -1;
|
|
|
|
|
2017-04-11 18:46:05 +00:00
|
|
|
if (src->full &&
|
|
|
|
!(dst->full = virCPUDefCopy(src->full)))
|
|
|
|
return -1;
|
|
|
|
|
2017-04-07 15:40:31 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-04-07 15:43:59 +00:00
|
|
|
static void
|
2017-04-07 16:15:26 +00:00
|
|
|
virQEMUCapsHostCPUDataClear(virQEMUCapsHostCPUDataPtr cpuData)
|
2017-04-07 15:43:59 +00:00
|
|
|
{
|
2017-04-07 16:15:26 +00:00
|
|
|
qemuMonitorCPUModelInfoFree(cpuData->info);
|
|
|
|
virCPUDefFree(cpuData->reported);
|
2017-03-29 13:31:17 +00:00
|
|
|
virCPUDefFree(cpuData->migratable);
|
2017-04-11 18:46:05 +00:00
|
|
|
virCPUDefFree(cpuData->full);
|
2017-04-07 16:15:26 +00:00
|
|
|
|
|
|
|
memset(cpuData, 0, sizeof(*cpuData));
|
2017-04-07 15:43:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsPtr virQEMUCapsNewCopy(virQEMUCapsPtr qemuCaps)
|
2012-09-11 12:42:20 +00:00
|
|
|
{
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsPtr ret = virQEMUCapsNew();
|
2012-09-11 12:42:20 +00:00
|
|
|
size_t i;
|
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
return NULL;
|
|
|
|
|
2016-08-04 14:45:53 +00:00
|
|
|
ret->usedQMP = qemuCaps->usedQMP;
|
|
|
|
|
2016-08-04 14:48:40 +00:00
|
|
|
if (VIR_STRDUP(ret->binary, qemuCaps->binary) < 0)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
ret->ctime = qemuCaps->ctime;
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
virBitmapCopy(ret->flags, qemuCaps->flags);
|
2012-09-11 12:42:20 +00:00
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
ret->version = qemuCaps->version;
|
|
|
|
ret->kvmVersion = qemuCaps->kvmVersion;
|
2017-12-12 15:23:41 +00:00
|
|
|
ret->microcodeVersion = qemuCaps->microcodeVersion;
|
2015-02-02 10:28:30 +00:00
|
|
|
|
|
|
|
if (VIR_STRDUP(ret->package, qemuCaps->package) < 0)
|
|
|
|
goto error;
|
|
|
|
|
2018-01-22 10:37:04 +00:00
|
|
|
if (VIR_STRDUP(ret->kernelVersion, qemuCaps->kernelVersion) < 0)
|
|
|
|
goto error;
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
ret->arch = qemuCaps->arch;
|
2012-09-11 12:42:20 +00:00
|
|
|
|
2016-11-14 16:21:30 +00:00
|
|
|
if (qemuCaps->kvmCPUModels) {
|
|
|
|
ret->kvmCPUModels = virDomainCapsCPUModelsCopy(qemuCaps->kvmCPUModels);
|
|
|
|
if (!ret->kvmCPUModels)
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (qemuCaps->tcgCPUModels) {
|
|
|
|
ret->tcgCPUModels = virDomainCapsCPUModelsCopy(qemuCaps->tcgCPUModels);
|
|
|
|
if (!ret->tcgCPUModels)
|
2013-05-20 09:23:13 +00:00
|
|
|
goto error;
|
2012-09-11 12:42:20 +00:00
|
|
|
}
|
|
|
|
|
2017-04-07 16:15:26 +00:00
|
|
|
if (virQEMUCapsHostCPUDataCopy(&ret->kvmCPU, &qemuCaps->kvmCPU) < 0 ||
|
|
|
|
virQEMUCapsHostCPUDataCopy(&ret->tcgCPU, &qemuCaps->tcgCPU) < 0)
|
2017-01-06 07:52:22 +00:00
|
|
|
goto error;
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
if (VIR_ALLOC_N(ret->machineTypes, qemuCaps->nmachineTypes) < 0)
|
2013-07-04 10:14:12 +00:00
|
|
|
goto error;
|
2013-02-01 13:48:58 +00:00
|
|
|
ret->nmachineTypes = qemuCaps->nmachineTypes;
|
2013-05-21 07:21:20 +00:00
|
|
|
for (i = 0; i < qemuCaps->nmachineTypes; i++) {
|
2016-07-29 08:13:46 +00:00
|
|
|
if (VIR_STRDUP(ret->machineTypes[i].name, qemuCaps->machineTypes[i].name) < 0 ||
|
|
|
|
VIR_STRDUP(ret->machineTypes[i].alias, qemuCaps->machineTypes[i].alias) < 0)
|
2013-05-20 09:23:13 +00:00
|
|
|
goto error;
|
2016-07-29 08:13:46 +00:00
|
|
|
ret->machineTypes[i].maxCpus = qemuCaps->machineTypes[i].maxCpus;
|
2016-07-29 07:45:19 +00:00
|
|
|
ret->machineTypes[i].hotplugCpus = qemuCaps->machineTypes[i].hotplugCpus;
|
2012-09-11 12:42:20 +00:00
|
|
|
}
|
|
|
|
|
2016-08-04 14:48:40 +00:00
|
|
|
if (VIR_ALLOC_N(ret->gicCapabilities, qemuCaps->ngicCapabilities) < 0)
|
|
|
|
goto error;
|
|
|
|
ret->ngicCapabilities = qemuCaps->ngicCapabilities;
|
|
|
|
for (i = 0; i < qemuCaps->ngicCapabilities; i++)
|
|
|
|
ret->gicCapabilities[i] = qemuCaps->gicCapabilities[i];
|
|
|
|
|
2012-09-11 12:42:20 +00:00
|
|
|
return ret;
|
|
|
|
|
2014-03-25 06:49:44 +00:00
|
|
|
error:
|
2012-09-11 12:42:20 +00:00
|
|
|
virObjectUnref(ret);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
void virQEMUCapsDispose(void *obj)
|
2012-08-20 16:44:14 +00:00
|
|
|
{
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsPtr qemuCaps = obj;
|
2012-08-22 10:11:28 +00:00
|
|
|
size_t i;
|
|
|
|
|
2013-05-21 07:21:20 +00:00
|
|
|
for (i = 0; i < qemuCaps->nmachineTypes; i++) {
|
2016-07-29 08:13:46 +00:00
|
|
|
VIR_FREE(qemuCaps->machineTypes[i].name);
|
|
|
|
VIR_FREE(qemuCaps->machineTypes[i].alias);
|
2012-08-22 10:11:28 +00:00
|
|
|
}
|
2013-02-01 13:48:58 +00:00
|
|
|
VIR_FREE(qemuCaps->machineTypes);
|
2012-08-22 10:11:28 +00:00
|
|
|
|
2016-11-14 16:21:30 +00:00
|
|
|
virObjectUnref(qemuCaps->kvmCPUModels);
|
|
|
|
virObjectUnref(qemuCaps->tcgCPUModels);
|
2012-08-20 16:44:14 +00:00
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
virBitmapFree(qemuCaps->flags);
|
2012-09-10 10:47:56 +00:00
|
|
|
|
2015-02-02 10:28:30 +00:00
|
|
|
VIR_FREE(qemuCaps->package);
|
2018-01-22 10:37:04 +00:00
|
|
|
VIR_FREE(qemuCaps->kernelVersion);
|
2013-02-01 13:48:58 +00:00
|
|
|
VIR_FREE(qemuCaps->binary);
|
2016-03-08 17:24:18 +00:00
|
|
|
|
|
|
|
VIR_FREE(qemuCaps->gicCapabilities);
|
2016-06-15 12:35:18 +00:00
|
|
|
|
2017-04-07 16:15:26 +00:00
|
|
|
virQEMUCapsHostCPUDataClear(&qemuCaps->kvmCPU);
|
|
|
|
virQEMUCapsHostCPUDataClear(&qemuCaps->tcgCPU);
|
2012-08-20 16:44:14 +00:00
|
|
|
}
|
|
|
|
|
2011-02-08 14:08:12 +00:00
|
|
|
void
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsSet(virQEMUCapsPtr qemuCaps,
|
2014-06-15 16:32:56 +00:00
|
|
|
virQEMUCapsFlags flag)
|
2011-02-08 14:08:12 +00:00
|
|
|
{
|
2013-02-01 13:48:58 +00:00
|
|
|
ignore_value(virBitmapSetBit(qemuCaps->flags, flag));
|
2011-02-08 14:22:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsSetList(virQEMUCapsPtr qemuCaps, ...)
|
2011-02-08 14:22:39 +00:00
|
|
|
{
|
|
|
|
va_list list;
|
|
|
|
int flag;
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
va_start(list, qemuCaps);
|
2011-02-08 14:22:39 +00:00
|
|
|
while ((flag = va_arg(list, int)) < QEMU_CAPS_LAST)
|
2013-02-01 13:48:58 +00:00
|
|
|
ignore_value(virBitmapSetBit(qemuCaps->flags, flag));
|
2011-02-08 14:22:39 +00:00
|
|
|
va_end(list);
|
2011-02-08 14:08:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsClear(virQEMUCapsPtr qemuCaps,
|
2014-06-15 16:32:56 +00:00
|
|
|
virQEMUCapsFlags flag)
|
2011-02-08 14:08:12 +00:00
|
|
|
{
|
2013-02-01 13:48:58 +00:00
|
|
|
ignore_value(virBitmapClearBit(qemuCaps->flags, flag));
|
2012-08-20 16:44:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
char *virQEMUCapsFlagsString(virQEMUCapsPtr qemuCaps)
|
2012-08-20 16:44:14 +00:00
|
|
|
{
|
2017-08-23 07:09:17 +00:00
|
|
|
return virBitmapToString(qemuCaps->flags, true, false);
|
2011-02-08 14:08:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsGet(virQEMUCapsPtr qemuCaps,
|
2014-06-15 16:32:56 +00:00
|
|
|
virQEMUCapsFlags flag)
|
2011-02-08 14:08:12 +00:00
|
|
|
{
|
2015-03-11 15:41:57 +00:00
|
|
|
return qemuCaps && virBitmapIsBitSet(qemuCaps->flags, flag);
|
2011-02-08 14:08:12 +00:00
|
|
|
}
|
2012-08-22 10:11:28 +00:00
|
|
|
|
|
|
|
|
2014-04-23 15:35:37 +00:00
|
|
|
bool virQEMUCapsHasPCIMultiBus(virQEMUCapsPtr qemuCaps,
|
2017-11-15 14:17:39 +00:00
|
|
|
const virDomainDef *def)
|
2014-04-23 15:35:37 +00:00
|
|
|
{
|
2017-03-02 14:40:29 +00:00
|
|
|
/* x86_64 and i686 support PCI-multibus on all machine types
|
|
|
|
* since forever */
|
2017-11-29 13:51:22 +00:00
|
|
|
if (ARCH_IS_X86(def->os.arch))
|
2014-04-23 15:35:37 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
if (def->os.arch == VIR_ARCH_PPC ||
|
2014-11-04 17:21:26 +00:00
|
|
|
ARCH_IS_PPC64(def->os.arch)) {
|
2014-04-23 15:35:37 +00:00
|
|
|
/*
|
|
|
|
* Usage of pci.0 naming:
|
|
|
|
*
|
|
|
|
* ref405ep: no pci
|
|
|
|
* taihu: no pci
|
|
|
|
* bamboo: 1.1.0
|
|
|
|
* mac99: 2.0.0
|
|
|
|
* g3beige: 2.0.0
|
|
|
|
* prep: 1.4.0
|
|
|
|
* pseries: 2.0.0
|
|
|
|
* mpc8544ds: forever
|
|
|
|
* virtex-m507: no pci
|
|
|
|
* ppce500: 1.6.0
|
|
|
|
*/
|
|
|
|
|
2017-11-29 14:05:23 +00:00
|
|
|
/* We do not store the qemu version in domain status XML.
|
|
|
|
* Hope the user is using a QEMU new enough to use 'pci.0',
|
|
|
|
* otherwise the results of this function will be wrong
|
|
|
|
* for domains already running at the time of daemon
|
|
|
|
* restart */
|
|
|
|
if (qemuCaps->version == 0)
|
|
|
|
return true;
|
|
|
|
|
2014-04-23 15:35:37 +00:00
|
|
|
if (qemuCaps->version >= 2000000)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (qemuCaps->version >= 1006000 &&
|
|
|
|
STREQ(def->os.machine, "ppce500"))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (qemuCaps->version >= 1004000 &&
|
|
|
|
STREQ(def->os.machine, "prep"))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (qemuCaps->version >= 1001000 &&
|
|
|
|
STREQ(def->os.machine, "bamboo"))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (STREQ(def->os.machine, "mpc8544ds"))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-06-22 16:55:37 +00:00
|
|
|
/* If 'virt' supports PCI, it supports multibus.
|
|
|
|
* No extra conditions here for simplicity.
|
|
|
|
*/
|
2017-04-18 10:43:58 +00:00
|
|
|
if (qemuDomainIsVirt(def))
|
2016-06-22 16:55:37 +00:00
|
|
|
return true;
|
2015-07-17 11:27:45 +00:00
|
|
|
|
2014-04-23 15:35:37 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
const char *virQEMUCapsGetBinary(virQEMUCapsPtr qemuCaps)
|
2012-08-22 13:37:05 +00:00
|
|
|
{
|
2013-02-01 13:48:58 +00:00
|
|
|
return qemuCaps->binary;
|
2012-08-22 13:37:05 +00:00
|
|
|
}
|
|
|
|
|
2016-08-03 10:26:41 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
virQEMUCapsSetArch(virQEMUCapsPtr qemuCaps,
|
|
|
|
virArch arch)
|
|
|
|
{
|
|
|
|
qemuCaps->arch = arch;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
virArch virQEMUCapsGetArch(virQEMUCapsPtr qemuCaps)
|
2012-08-22 10:11:28 +00:00
|
|
|
{
|
2013-02-01 13:48:58 +00:00
|
|
|
return qemuCaps->arch;
|
2012-08-22 10:11:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
unsigned int virQEMUCapsGetVersion(virQEMUCapsPtr qemuCaps)
|
2012-08-22 10:11:28 +00:00
|
|
|
{
|
2013-02-01 13:48:58 +00:00
|
|
|
return qemuCaps->version;
|
2012-08-22 10:11:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
unsigned int virQEMUCapsGetKVMVersion(virQEMUCapsPtr qemuCaps)
|
2012-08-22 10:11:28 +00:00
|
|
|
{
|
2013-02-01 13:48:58 +00:00
|
|
|
return qemuCaps->kvmVersion;
|
2012-08-22 10:11:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-02 10:28:30 +00:00
|
|
|
const char *virQEMUCapsGetPackage(virQEMUCapsPtr qemuCaps)
|
|
|
|
{
|
|
|
|
return qemuCaps->package;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-21 10:51:01 +00:00
|
|
|
int
|
|
|
|
virQEMUCapsAddCPUDefinitions(virQEMUCapsPtr qemuCaps,
|
2016-11-14 16:21:30 +00:00
|
|
|
virDomainVirtType type,
|
2016-04-21 10:51:01 +00:00
|
|
|
const char **name,
|
2016-04-21 11:08:12 +00:00
|
|
|
size_t count,
|
|
|
|
virDomainCapsCPUUsable usable)
|
2012-08-22 15:28:55 +00:00
|
|
|
{
|
2016-04-21 10:51:01 +00:00
|
|
|
size_t i;
|
2016-11-14 16:21:30 +00:00
|
|
|
virDomainCapsCPUModelsPtr cpus = NULL;
|
2013-05-20 09:23:13 +00:00
|
|
|
|
2016-11-14 16:21:30 +00:00
|
|
|
if (type == VIR_DOMAIN_VIRT_KVM && qemuCaps->kvmCPUModels)
|
|
|
|
cpus = qemuCaps->kvmCPUModels;
|
|
|
|
else if (type == VIR_DOMAIN_VIRT_QEMU && qemuCaps->tcgCPUModels)
|
|
|
|
cpus = qemuCaps->tcgCPUModels;
|
|
|
|
|
|
|
|
if (!cpus) {
|
|
|
|
if (!(cpus = virDomainCapsCPUModelsNew(count)))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (type == VIR_DOMAIN_VIRT_KVM)
|
|
|
|
qemuCaps->kvmCPUModels = cpus;
|
|
|
|
else
|
|
|
|
qemuCaps->tcgCPUModels = cpus;
|
|
|
|
}
|
2016-04-21 10:51:01 +00:00
|
|
|
|
|
|
|
for (i = 0; i < count; i++) {
|
2017-09-19 16:35:08 +00:00
|
|
|
if (virDomainCapsCPUModelsAdd(cpus, name[i], -1, usable, NULL) < 0)
|
2016-04-21 10:51:01 +00:00
|
|
|
return -1;
|
2012-08-22 15:28:55 +00:00
|
|
|
}
|
2016-04-21 10:51:01 +00:00
|
|
|
|
2012-08-22 15:28:55 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-22 13:51:33 +00:00
|
|
|
virDomainCapsCPUModelsPtr
|
2016-04-21 10:51:01 +00:00
|
|
|
virQEMUCapsGetCPUDefinitions(virQEMUCapsPtr qemuCaps,
|
2017-09-22 13:51:33 +00:00
|
|
|
virDomainVirtType type)
|
2012-08-22 10:11:28 +00:00
|
|
|
{
|
2016-11-14 16:21:30 +00:00
|
|
|
if (type == VIR_DOMAIN_VIRT_KVM)
|
2017-09-22 13:51:33 +00:00
|
|
|
return qemuCaps->kvmCPUModels;
|
2016-11-14 16:21:30 +00:00
|
|
|
else
|
2017-09-22 13:51:33 +00:00
|
|
|
return qemuCaps->tcgCPUModels;
|
2012-08-22 10:11:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-04-07 16:15:26 +00:00
|
|
|
static virQEMUCapsHostCPUDataPtr
|
|
|
|
virQEMUCapsGetHostCPUData(virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainVirtType type)
|
|
|
|
{
|
|
|
|
if (type == VIR_DOMAIN_VIRT_KVM)
|
|
|
|
return &qemuCaps->kvmCPU;
|
|
|
|
else
|
|
|
|
return &qemuCaps->tcgCPU;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-06-22 10:34:07 +00:00
|
|
|
virCPUDefPtr
|
2017-02-22 15:51:50 +00:00
|
|
|
virQEMUCapsGetHostModel(virQEMUCapsPtr qemuCaps,
|
2017-04-11 09:14:30 +00:00
|
|
|
virDomainVirtType type,
|
|
|
|
virQEMUCapsHostCPUType cpuType)
|
2016-06-22 10:34:07 +00:00
|
|
|
{
|
2017-04-07 16:15:26 +00:00
|
|
|
virQEMUCapsHostCPUDataPtr cpuData = virQEMUCapsGetHostCPUData(qemuCaps, type);
|
|
|
|
|
2017-04-11 09:14:30 +00:00
|
|
|
switch (cpuType) {
|
|
|
|
case VIR_QEMU_CAPS_HOST_CPU_REPORTED:
|
|
|
|
return cpuData->reported;
|
2017-03-29 13:31:17 +00:00
|
|
|
|
|
|
|
case VIR_QEMU_CAPS_HOST_CPU_MIGRATABLE:
|
|
|
|
return cpuData->migratable;
|
2017-04-11 18:46:05 +00:00
|
|
|
|
|
|
|
case VIR_QEMU_CAPS_HOST_CPU_FULL:
|
|
|
|
/* 'full' is non-NULL only if we have data from both QEMU and
|
|
|
|
* virCPUGetHost */
|
|
|
|
return cpuData->full ? cpuData->full : cpuData->reported;
|
2017-04-11 09:14:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
2016-06-22 10:34:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-04-07 15:03:38 +00:00
|
|
|
static void
|
|
|
|
virQEMUCapsSetHostModel(virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainVirtType type,
|
2017-03-29 13:31:17 +00:00
|
|
|
virCPUDefPtr reported,
|
2017-04-11 18:46:05 +00:00
|
|
|
virCPUDefPtr migratable,
|
|
|
|
virCPUDefPtr full)
|
2017-04-07 15:03:38 +00:00
|
|
|
{
|
2017-04-07 16:15:26 +00:00
|
|
|
virQEMUCapsHostCPUDataPtr cpuData = virQEMUCapsGetHostCPUData(qemuCaps, type);
|
|
|
|
|
2017-03-29 13:31:17 +00:00
|
|
|
cpuData->reported = reported;
|
|
|
|
cpuData->migratable = migratable;
|
2017-04-11 18:46:05 +00:00
|
|
|
cpuData->full = full;
|
2017-04-07 15:03:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-03 14:22:30 +00:00
|
|
|
bool
|
|
|
|
virQEMUCapsIsCPUModeSupported(virQEMUCapsPtr qemuCaps,
|
|
|
|
virCapsPtr caps,
|
|
|
|
virDomainVirtType type,
|
|
|
|
virCPUMode mode)
|
|
|
|
{
|
2016-11-14 16:21:30 +00:00
|
|
|
virDomainCapsCPUModelsPtr cpus;
|
|
|
|
|
2016-08-03 14:22:30 +00:00
|
|
|
switch (mode) {
|
|
|
|
case VIR_CPU_MODE_HOST_PASSTHROUGH:
|
|
|
|
return type == VIR_DOMAIN_VIRT_KVM &&
|
|
|
|
virQEMUCapsGuestIsNative(caps->host.arch, qemuCaps->arch);
|
|
|
|
|
|
|
|
case VIR_CPU_MODE_HOST_MODEL:
|
2017-04-11 09:14:30 +00:00
|
|
|
return !!virQEMUCapsGetHostModel(qemuCaps, type,
|
|
|
|
VIR_QEMU_CAPS_HOST_CPU_REPORTED);
|
2016-08-03 14:22:30 +00:00
|
|
|
|
|
|
|
case VIR_CPU_MODE_CUSTOM:
|
2016-11-14 16:21:30 +00:00
|
|
|
if (type == VIR_DOMAIN_VIRT_KVM)
|
|
|
|
cpus = qemuCaps->kvmCPUModels;
|
|
|
|
else
|
|
|
|
cpus = qemuCaps->tcgCPUModels;
|
|
|
|
return cpus && cpus->nmodels > 0;
|
2016-08-03 14:22:30 +00:00
|
|
|
|
|
|
|
case VIR_CPU_MODE_LAST:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
int virQEMUCapsGetMachineTypesCaps(virQEMUCapsPtr qemuCaps,
|
|
|
|
size_t *nmachines,
|
|
|
|
virCapsGuestMachinePtr **machines)
|
2012-08-22 13:37:05 +00:00
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
*machines = NULL;
|
2013-02-01 13:48:58 +00:00
|
|
|
*nmachines = qemuCaps->nmachineTypes;
|
2012-08-22 13:37:05 +00:00
|
|
|
|
2014-03-27 11:38:56 +00:00
|
|
|
if (*nmachines &&
|
|
|
|
VIR_ALLOC_N(*machines, qemuCaps->nmachineTypes) < 0)
|
|
|
|
goto error;
|
|
|
|
|
2013-05-21 07:21:20 +00:00
|
|
|
for (i = 0; i < qemuCaps->nmachineTypes; i++) {
|
2012-08-22 13:37:05 +00:00
|
|
|
virCapsGuestMachinePtr mach;
|
|
|
|
if (VIR_ALLOC(mach) < 0)
|
2013-05-20 09:23:13 +00:00
|
|
|
goto error;
|
2014-08-27 18:57:08 +00:00
|
|
|
(*machines)[i] = mach;
|
2016-07-29 08:13:46 +00:00
|
|
|
if (qemuCaps->machineTypes[i].alias) {
|
|
|
|
if (VIR_STRDUP(mach->name, qemuCaps->machineTypes[i].alias) < 0 ||
|
|
|
|
VIR_STRDUP(mach->canonical, qemuCaps->machineTypes[i].name) < 0)
|
2013-05-20 09:23:13 +00:00
|
|
|
goto error;
|
2012-08-22 13:37:05 +00:00
|
|
|
} else {
|
2016-07-29 08:13:46 +00:00
|
|
|
if (VIR_STRDUP(mach->name, qemuCaps->machineTypes[i].name) < 0)
|
2013-05-20 09:23:13 +00:00
|
|
|
goto error;
|
2012-08-22 13:37:05 +00:00
|
|
|
}
|
2016-07-29 08:13:46 +00:00
|
|
|
mach->maxCpus = qemuCaps->machineTypes[i].maxCpus;
|
2012-08-22 13:37:05 +00:00
|
|
|
}
|
|
|
|
|
qemu: Report all supported machine types in capabilities
Some machine types are only reported as canonical names for other
machine types, which make it a bit harder to find what machine types are
supported by a specific QEMU binary. Ideally, one would just use
/capabilities/guest/arch[@name='...']/machine/text() XPath to get a list
of all supported machine types, but it doesn't work right now.
For example, we report
<machine canonical='pc-i440fx-2.3' maxCpus='255'>pc</machine>
in guest capabilities, but the corresponding
<machine maxCpus='255'>pc-i440fx-2.3</machine>
is missing.
This is a result of QMP probing. With "-machine ?" parsing QEMU sends
us two lines:
pc Standard PC (i440FX + PIIX, 1996) (alias of pc-i440fx-2.3)
pc-i440fx-2.3 Standard PC (i440FX + PIIX, 1996) (default)
while query-machines QMP command reports both in the same entry:
{"name": "pc-i440fx-2.3", "is-default": true, "cpu-max": 255, "alias": "pc"}
Let's make sure we always report separate <machine/> for both the
canonical name and its alias and using the canonical name as the default
machine type (i.e., inserting it before its alias) in case is-default is
true.
https://bugzilla.redhat.com/show_bug.cgi?id=1229666
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-06-12 12:36:51 +00:00
|
|
|
/* Make sure all canonical machine types also have their own entry so that
|
|
|
|
* /capabilities/guest/arch[@name='...']/machine/text() XPath selects all
|
|
|
|
* supported machine types.
|
|
|
|
*/
|
|
|
|
i = 0;
|
|
|
|
while (i < *nmachines) {
|
|
|
|
size_t j;
|
|
|
|
bool found = false;
|
|
|
|
virCapsGuestMachinePtr machine = (*machines)[i];
|
|
|
|
|
|
|
|
if (!machine->canonical) {
|
|
|
|
i++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (j = 0; j < *nmachines; j++) {
|
|
|
|
if (STREQ(machine->canonical, (*machines)[j]->name)) {
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!found) {
|
|
|
|
virCapsGuestMachinePtr mach;
|
|
|
|
if (VIR_ALLOC(mach) < 0)
|
|
|
|
goto error;
|
|
|
|
if (VIR_INSERT_ELEMENT_COPY(*machines, i, *nmachines, mach) < 0) {
|
|
|
|
VIR_FREE(mach);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
if (VIR_STRDUP(mach->name, machine->canonical) < 0)
|
|
|
|
goto error;
|
|
|
|
mach->maxCpus = machine->maxCpus;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2012-08-22 13:37:05 +00:00
|
|
|
return 0;
|
|
|
|
|
2014-03-25 06:49:44 +00:00
|
|
|
error:
|
2012-08-22 13:37:05 +00:00
|
|
|
virCapabilitiesFreeMachines(*machines, *nmachines);
|
|
|
|
*nmachines = 0;
|
|
|
|
*machines = NULL;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-08-16 13:37:18 +00:00
|
|
|
/**
|
|
|
|
* virQEMUCapsGetCanonicalMachine:
|
|
|
|
* @qemuCaps: qemu capabilities object
|
|
|
|
* @name: machine name
|
|
|
|
*
|
|
|
|
* Resolves aliased machine names to the actual machine name. If qemuCaps isn't
|
|
|
|
* present @name is returned.
|
|
|
|
*/
|
2013-02-01 13:48:58 +00:00
|
|
|
const char *virQEMUCapsGetCanonicalMachine(virQEMUCapsPtr qemuCaps,
|
|
|
|
const char *name)
|
2012-08-22 10:11:28 +00:00
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
2017-08-16 13:37:18 +00:00
|
|
|
if (!name || !qemuCaps)
|
|
|
|
return name;
|
2012-11-01 11:43:03 +00:00
|
|
|
|
2013-05-21 07:21:20 +00:00
|
|
|
for (i = 0; i < qemuCaps->nmachineTypes; i++) {
|
2016-07-29 08:13:46 +00:00
|
|
|
if (!qemuCaps->machineTypes[i].alias)
|
2012-08-22 10:11:28 +00:00
|
|
|
continue;
|
2016-07-29 08:13:46 +00:00
|
|
|
if (STREQ(qemuCaps->machineTypes[i].alias, name))
|
|
|
|
return qemuCaps->machineTypes[i].name;
|
2012-08-22 10:11:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return name;
|
|
|
|
}
|
2012-09-10 10:47:56 +00:00
|
|
|
|
|
|
|
|
2013-06-26 15:46:35 +00:00
|
|
|
int virQEMUCapsGetMachineMaxCpus(virQEMUCapsPtr qemuCaps,
|
|
|
|
const char *name)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
if (!name)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
for (i = 0; i < qemuCaps->nmachineTypes; i++) {
|
2016-07-29 08:13:46 +00:00
|
|
|
if (!qemuCaps->machineTypes[i].maxCpus)
|
2013-06-26 15:46:35 +00:00
|
|
|
continue;
|
2016-07-29 08:13:46 +00:00
|
|
|
if (STREQ(qemuCaps->machineTypes[i].name, name))
|
|
|
|
return qemuCaps->machineTypes[i].maxCpus;
|
2013-06-26 15:46:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-07-29 07:45:19 +00:00
|
|
|
bool virQEMUCapsGetMachineHotplugCpus(virQEMUCapsPtr qemuCaps,
|
|
|
|
const char *name)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
for (i = 0; i < qemuCaps->nmachineTypes; i++) {
|
|
|
|
if (STREQ_NULLABLE(qemuCaps->machineTypes[i].name, name))
|
|
|
|
return qemuCaps->machineTypes[i].hotplugCpus;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-05-10 08:50:34 +00:00
|
|
|
/**
|
|
|
|
* virQEMUCapsSetGICCapabilities:
|
|
|
|
* @qemuCaps: QEMU capabilities
|
|
|
|
* @capabilities: GIC capabilities
|
|
|
|
* @ncapabilities: number of GIC capabilities
|
|
|
|
*
|
|
|
|
* Set the GIC capabilities for @qemuCaps.
|
|
|
|
*
|
|
|
|
* The ownership of @capabilities is taken away from the caller, ie. this
|
|
|
|
* function will not make a copy of @capabilities, so releasing that memory
|
|
|
|
* after it's been called is a bug.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
virQEMUCapsSetGICCapabilities(virQEMUCapsPtr qemuCaps,
|
|
|
|
virGICCapability *capabilities,
|
|
|
|
size_t ncapabilities)
|
|
|
|
{
|
|
|
|
VIR_FREE(qemuCaps->gicCapabilities);
|
|
|
|
|
|
|
|
qemuCaps->gicCapabilities = capabilities;
|
|
|
|
qemuCaps->ngicCapabilities = ncapabilities;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-09-13 14:54:02 +00:00
|
|
|
static int
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsProbeQMPCommands(virQEMUCapsPtr qemuCaps,
|
|
|
|
qemuMonitorPtr mon)
|
2012-09-13 14:54:02 +00:00
|
|
|
{
|
|
|
|
char **commands = NULL;
|
|
|
|
int ncommands;
|
|
|
|
|
|
|
|
if ((ncommands = qemuMonitorGetCommands(mon, &commands)) < 0)
|
|
|
|
return -1;
|
|
|
|
|
2013-06-19 08:00:10 +00:00
|
|
|
virQEMUCapsProcessStringFlags(qemuCaps,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsCommands),
|
|
|
|
virQEMUCapsCommands,
|
|
|
|
ncommands, commands);
|
2017-03-03 20:31:26 +00:00
|
|
|
virStringListFreeCount(commands, ncommands);
|
2012-09-13 14:54:02 +00:00
|
|
|
|
2013-01-29 16:52:17 +00:00
|
|
|
/* QMP add-fd was introduced in 1.2, but did not support
|
|
|
|
* management control of set numbering, and did not have a
|
|
|
|
* counterpart -add-fd command line option. We require the
|
|
|
|
* add-fd features from 1.3 or later. */
|
2013-02-01 13:48:58 +00:00
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_ADD_FD)) {
|
2013-01-29 16:52:17 +00:00
|
|
|
int fd = open("/dev/null", O_RDONLY);
|
|
|
|
if (fd < 0) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("unable to probe for add-fd"));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (qemuMonitorAddFd(mon, 0, fd, "/dev/null") < 0)
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsClear(qemuCaps, QEMU_CAPS_ADD_FD);
|
2013-01-29 16:52:17 +00:00
|
|
|
VIR_FORCE_CLOSE(fd);
|
|
|
|
}
|
|
|
|
|
2014-06-17 03:42:49 +00:00
|
|
|
/* Probe for active commit of qemu 2.1 (for now, we are choosing
|
|
|
|
* to ignore the fact that qemu 2.0 can also do active commit) */
|
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCK_COMMIT) &&
|
|
|
|
qemuMonitorSupportsActiveCommit(mon))
|
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_ACTIVE_COMMIT);
|
|
|
|
|
2012-09-13 14:54:02 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsProbeQMPEvents(virQEMUCapsPtr qemuCaps,
|
|
|
|
qemuMonitorPtr mon)
|
2012-09-13 14:54:02 +00:00
|
|
|
{
|
|
|
|
char **events = NULL;
|
|
|
|
int nevents;
|
|
|
|
|
|
|
|
if ((nevents = qemuMonitorGetEvents(mon, &events)) < 0)
|
|
|
|
return -1;
|
|
|
|
|
2013-06-19 07:24:54 +00:00
|
|
|
virQEMUCapsProcessStringFlags(qemuCaps,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsEvents),
|
|
|
|
virQEMUCapsEvents,
|
|
|
|
nevents, events);
|
2017-03-03 20:31:26 +00:00
|
|
|
virStringListFreeCount(events, nevents);
|
2012-09-13 14:54:02 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-04-12 12:39:43 +00:00
|
|
|
static int
|
|
|
|
virQEMUCapsProbeQMPGenericProps(virQEMUCapsPtr qemuCaps,
|
|
|
|
qemuMonitorPtr mon,
|
|
|
|
virQEMUCapsObjectTypeProps *props,
|
|
|
|
size_t nprops,
|
|
|
|
virQEMUCapsObjectTypePropsCB propsGetCB)
|
|
|
|
{
|
|
|
|
int nvalues;
|
|
|
|
char **values;
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
for (i = 0; i < nprops; i++) {
|
|
|
|
const char *type = props[i].type;
|
|
|
|
int cap = props[i].capsCondition;
|
|
|
|
|
|
|
|
if (cap >= 0 && !virQEMUCapsGet(qemuCaps, cap))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if ((nvalues = propsGetCB(mon, type, &values)) < 0)
|
|
|
|
return -1;
|
|
|
|
virQEMUCapsProcessStringFlags(qemuCaps,
|
|
|
|
props[i].nprops,
|
|
|
|
props[i].props,
|
|
|
|
nvalues, values);
|
|
|
|
virStringListFreeCount(values, nvalues);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2012-09-13 14:54:02 +00:00
|
|
|
|
2012-08-22 17:05:08 +00:00
|
|
|
static int
|
2018-04-12 11:31:03 +00:00
|
|
|
virQEMUCapsProbeQMPDevices(virQEMUCapsPtr qemuCaps,
|
2013-02-01 13:48:58 +00:00
|
|
|
qemuMonitorPtr mon)
|
2012-08-22 17:05:08 +00:00
|
|
|
{
|
|
|
|
int nvalues;
|
|
|
|
char **values;
|
|
|
|
|
|
|
|
if ((nvalues = qemuMonitorGetObjectTypes(mon, &values)) < 0)
|
|
|
|
return -1;
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsProcessStringFlags(qemuCaps,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsObjectTypes),
|
|
|
|
virQEMUCapsObjectTypes,
|
|
|
|
nvalues, values);
|
2017-03-03 20:31:26 +00:00
|
|
|
virStringListFreeCount(values, nvalues);
|
2013-02-01 13:48:58 +00:00
|
|
|
|
2018-04-12 12:39:43 +00:00
|
|
|
if (virQEMUCapsProbeQMPGenericProps(qemuCaps,
|
|
|
|
mon,
|
|
|
|
virQEMUCapsDeviceProps,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDeviceProps),
|
|
|
|
qemuMonitorGetDeviceProps) < 0)
|
|
|
|
return -1;
|
2012-08-22 17:05:08 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsProbeQMPMachineTypes(virQEMUCapsPtr qemuCaps,
|
|
|
|
qemuMonitorPtr mon)
|
2012-08-22 17:05:08 +00:00
|
|
|
{
|
|
|
|
qemuMonitorMachineInfoPtr *machines = NULL;
|
|
|
|
int nmachines = 0;
|
|
|
|
int ret = -1;
|
|
|
|
size_t i;
|
2012-11-30 18:22:42 +00:00
|
|
|
size_t defIdx = 0;
|
2012-08-22 17:05:08 +00:00
|
|
|
|
|
|
|
if ((nmachines = qemuMonitorGetMachines(mon, &machines)) < 0)
|
2014-09-04 21:15:51 +00:00
|
|
|
return -1;
|
2012-08-22 17:05:08 +00:00
|
|
|
|
2013-07-04 10:14:12 +00:00
|
|
|
if (VIR_ALLOC_N(qemuCaps->machineTypes, nmachines) < 0)
|
2012-08-22 17:05:08 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2013-05-21 07:21:20 +00:00
|
|
|
for (i = 0; i < nmachines; i++) {
|
2016-07-29 08:35:48 +00:00
|
|
|
struct virQEMUCapsMachineType *mach;
|
2013-11-06 07:31:24 +00:00
|
|
|
if (STREQ(machines[i]->name, "none"))
|
|
|
|
continue;
|
2016-07-29 08:35:48 +00:00
|
|
|
|
|
|
|
mach = &(qemuCaps->machineTypes[qemuCaps->nmachineTypes++]);
|
|
|
|
|
|
|
|
if (VIR_STRDUP(mach->alias, machines[i]->alias) < 0 ||
|
|
|
|
VIR_STRDUP(mach->name, machines[i]->name) < 0)
|
2012-12-07 16:30:34 +00:00
|
|
|
goto cleanup;
|
2016-07-29 08:35:48 +00:00
|
|
|
|
|
|
|
mach->maxCpus = machines[i]->maxCpus;
|
2016-07-29 07:45:19 +00:00
|
|
|
mach->hotplugCpus = machines[i]->hotplugCpus;
|
2016-07-29 08:35:48 +00:00
|
|
|
|
2012-11-30 18:22:42 +00:00
|
|
|
if (machines[i]->isDefault)
|
2013-12-17 08:33:19 +00:00
|
|
|
defIdx = qemuCaps->nmachineTypes - 1;
|
2012-08-22 17:05:08 +00:00
|
|
|
}
|
2012-11-30 18:22:42 +00:00
|
|
|
|
|
|
|
if (defIdx)
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsSetDefaultMachine(qemuCaps, defIdx);
|
2012-08-22 17:05:08 +00:00
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
|
2014-03-25 06:49:44 +00:00
|
|
|
cleanup:
|
2013-05-21 07:21:20 +00:00
|
|
|
for (i = 0; i < nmachines; i++)
|
2012-08-22 17:05:08 +00:00
|
|
|
qemuMonitorMachineInfoFree(machines[i]);
|
|
|
|
VIR_FREE(machines);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-07 10:21:48 +00:00
|
|
|
virDomainCapsCPUModelsPtr
|
|
|
|
virQEMUCapsFetchCPUDefinitions(qemuMonitorPtr mon)
|
2012-08-22 17:05:08 +00:00
|
|
|
{
|
2017-12-07 10:21:48 +00:00
|
|
|
virDomainCapsCPUModelsPtr models = NULL;
|
|
|
|
qemuMonitorCPUDefInfoPtr *cpus = NULL;
|
|
|
|
int ncpus = 0;
|
2016-04-21 10:51:01 +00:00
|
|
|
size_t i;
|
2012-08-22 17:05:08 +00:00
|
|
|
|
2016-04-21 10:51:01 +00:00
|
|
|
if ((ncpus = qemuMonitorGetCPUDefinitions(mon, &cpus)) < 0)
|
2017-12-11 13:34:20 +00:00
|
|
|
return NULL;
|
2012-08-22 17:05:08 +00:00
|
|
|
|
2016-11-14 16:21:30 +00:00
|
|
|
if (!(models = virDomainCapsCPUModelsNew(ncpus)))
|
2017-12-07 10:21:48 +00:00
|
|
|
goto error;
|
2016-11-14 16:21:30 +00:00
|
|
|
|
2016-04-21 10:51:01 +00:00
|
|
|
for (i = 0; i < ncpus; i++) {
|
2016-04-21 11:08:12 +00:00
|
|
|
virDomainCapsCPUUsable usable = VIR_DOMCAPS_CPU_USABLE_UNKNOWN;
|
|
|
|
|
|
|
|
if (cpus[i]->usable == VIR_TRISTATE_BOOL_YES)
|
|
|
|
usable = VIR_DOMCAPS_CPU_USABLE_YES;
|
|
|
|
else if (cpus[i]->usable == VIR_TRISTATE_BOOL_NO)
|
|
|
|
usable = VIR_DOMCAPS_CPU_USABLE_NO;
|
|
|
|
|
2017-09-19 16:35:08 +00:00
|
|
|
if (virDomainCapsCPUModelsAddSteal(models, &cpus[i]->name, usable,
|
2017-09-20 08:45:49 +00:00
|
|
|
&cpus[i]->blockers) < 0)
|
2017-12-07 10:21:48 +00:00
|
|
|
goto error;
|
2016-04-21 10:51:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
for (i = 0; i < ncpus; i++)
|
|
|
|
qemuMonitorCPUDefInfoFree(cpus[i]);
|
|
|
|
VIR_FREE(cpus);
|
2017-12-07 10:21:48 +00:00
|
|
|
return models;
|
|
|
|
|
|
|
|
error:
|
|
|
|
virObjectUnref(models);
|
|
|
|
models = NULL;
|
|
|
|
goto cleanup;
|
2012-08-22 17:05:08 +00:00
|
|
|
}
|
|
|
|
|
2017-12-07 10:21:48 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
virQEMUCapsProbeQMPCPUDefinitions(virQEMUCapsPtr qemuCaps,
|
|
|
|
qemuMonitorPtr mon,
|
|
|
|
bool tcg)
|
|
|
|
{
|
|
|
|
virDomainCapsCPUModelsPtr models = NULL;
|
|
|
|
|
|
|
|
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_DEFINITIONS))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (!(models = virQEMUCapsFetchCPUDefinitions(mon)))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (tcg || !virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM))
|
|
|
|
qemuCaps->tcgCPUModels = models;
|
|
|
|
else
|
|
|
|
qemuCaps->kvmCPUModels = models;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-06 07:52:22 +00:00
|
|
|
static int
|
|
|
|
virQEMUCapsProbeQMPHostCPU(virQEMUCapsPtr qemuCaps,
|
2017-02-22 15:51:50 +00:00
|
|
|
qemuMonitorPtr mon,
|
|
|
|
bool tcg)
|
2017-01-06 07:52:22 +00:00
|
|
|
{
|
2017-04-07 16:15:26 +00:00
|
|
|
qemuMonitorCPUModelInfoPtr modelInfo = NULL;
|
2017-03-29 08:58:41 +00:00
|
|
|
qemuMonitorCPUModelInfoPtr nonMigratable = NULL;
|
|
|
|
virHashTablePtr hash = NULL;
|
2017-02-22 15:51:50 +00:00
|
|
|
const char *model;
|
2017-02-23 12:53:51 +00:00
|
|
|
qemuMonitorCPUModelExpansionType type;
|
2017-04-07 16:15:26 +00:00
|
|
|
virDomainVirtType virtType;
|
|
|
|
virQEMUCapsHostCPUDataPtr cpuData;
|
2017-03-29 08:58:41 +00:00
|
|
|
int ret = -1;
|
2017-02-22 15:51:50 +00:00
|
|
|
|
|
|
|
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION))
|
2017-01-06 07:52:22 +00:00
|
|
|
return 0;
|
|
|
|
|
2017-02-22 15:51:50 +00:00
|
|
|
if (tcg || !virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) {
|
2017-04-07 16:15:26 +00:00
|
|
|
virtType = VIR_DOMAIN_VIRT_QEMU;
|
2017-02-22 15:51:50 +00:00
|
|
|
model = "max";
|
|
|
|
} else {
|
2017-04-07 16:15:26 +00:00
|
|
|
virtType = VIR_DOMAIN_VIRT_KVM;
|
2017-02-22 15:51:50 +00:00
|
|
|
model = "host";
|
|
|
|
}
|
|
|
|
|
2017-04-07 16:15:26 +00:00
|
|
|
cpuData = virQEMUCapsGetHostCPUData(qemuCaps, virtType);
|
|
|
|
|
2017-02-23 12:53:51 +00:00
|
|
|
/* Some x86_64 features defined in cpu_map.xml use spelling which differ
|
|
|
|
* from the one preferred by QEMU. Static expansion would give us only the
|
|
|
|
* preferred spelling, thus we need to do a full expansion on the result of
|
|
|
|
* the initial static expansion to get all variants of all features.
|
|
|
|
*/
|
|
|
|
if (ARCH_IS_X86(qemuCaps->arch))
|
|
|
|
type = QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC_FULL;
|
|
|
|
else
|
|
|
|
type = QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC;
|
|
|
|
|
2017-04-07 16:15:26 +00:00
|
|
|
if (qemuMonitorGetCPUModelExpansion(mon, type, model, true, &modelInfo) < 0)
|
|
|
|
goto cleanup;
|
2017-03-29 08:58:41 +00:00
|
|
|
|
|
|
|
/* Try to check migratability of each feature. */
|
2017-04-07 16:15:26 +00:00
|
|
|
if (modelInfo &&
|
2017-03-29 08:58:41 +00:00
|
|
|
qemuMonitorGetCPUModelExpansion(mon, type, model, false,
|
|
|
|
&nonMigratable) < 0)
|
2017-04-07 16:15:26 +00:00
|
|
|
goto cleanup;
|
2017-03-29 08:58:41 +00:00
|
|
|
|
|
|
|
if (nonMigratable) {
|
|
|
|
qemuMonitorCPUPropertyPtr prop;
|
|
|
|
qemuMonitorCPUPropertyPtr nmProp;
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
if (!(hash = virHashCreate(0, NULL)))
|
2017-04-07 16:15:26 +00:00
|
|
|
goto cleanup;
|
2017-03-29 08:58:41 +00:00
|
|
|
|
2017-04-07 16:15:26 +00:00
|
|
|
for (i = 0; i < modelInfo->nprops; i++) {
|
|
|
|
prop = modelInfo->props + i;
|
2017-03-29 08:58:41 +00:00
|
|
|
if (virHashAddEntry(hash, prop->name, prop) < 0)
|
2017-04-07 16:15:26 +00:00
|
|
|
goto cleanup;
|
2017-03-29 08:58:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < nonMigratable->nprops; i++) {
|
|
|
|
nmProp = nonMigratable->props + i;
|
|
|
|
if (!(prop = virHashLookup(hash, nmProp->name)) ||
|
|
|
|
prop->type != QEMU_MONITOR_CPU_PROPERTY_BOOLEAN ||
|
|
|
|
prop->type != nmProp->type)
|
|
|
|
continue;
|
|
|
|
|
2017-03-29 09:00:32 +00:00
|
|
|
if (prop->value.boolean) {
|
2017-03-29 08:58:41 +00:00
|
|
|
prop->migratable = VIR_TRISTATE_BOOL_YES;
|
2017-03-29 09:00:32 +00:00
|
|
|
} else if (nmProp->value.boolean) {
|
|
|
|
prop->value.boolean = true;
|
|
|
|
prop->migratable = VIR_TRISTATE_BOOL_NO;
|
|
|
|
}
|
2017-03-29 08:58:41 +00:00
|
|
|
}
|
|
|
|
|
2017-04-07 16:15:26 +00:00
|
|
|
modelInfo->migratability = true;
|
2017-03-29 08:58:41 +00:00
|
|
|
}
|
|
|
|
|
2017-04-07 16:15:26 +00:00
|
|
|
VIR_STEAL_PTR(cpuData->info, modelInfo);
|
2017-03-29 08:58:41 +00:00
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virHashFree(hash);
|
|
|
|
qemuMonitorCPUModelInfoFree(nonMigratable);
|
2017-04-07 16:15:26 +00:00
|
|
|
qemuMonitorCPUModelInfoFree(modelInfo);
|
2017-03-29 08:58:41 +00:00
|
|
|
|
|
|
|
return ret;
|
2017-01-06 07:52:22 +00:00
|
|
|
}
|
|
|
|
|
2013-04-12 20:55:45 +00:00
|
|
|
struct tpmTypeToCaps {
|
|
|
|
int type;
|
2014-06-15 16:32:56 +00:00
|
|
|
virQEMUCapsFlags caps;
|
2013-04-12 20:55:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct tpmTypeToCaps virQEMUCapsTPMTypesToCaps[] = {
|
|
|
|
{
|
|
|
|
.type = VIR_DOMAIN_TPM_TYPE_PASSTHROUGH,
|
|
|
|
.caps = QEMU_CAPS_DEVICE_TPM_PASSTHROUGH,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct tpmTypeToCaps virQEMUCapsTPMModelsToCaps[] = {
|
|
|
|
{
|
|
|
|
.type = VIR_DOMAIN_TPM_MODEL_TIS,
|
|
|
|
.caps = QEMU_CAPS_DEVICE_TPM_TIS,
|
|
|
|
},
|
2018-04-26 17:42:17 +00:00
|
|
|
{
|
|
|
|
.type = VIR_DOMAIN_TPM_MODEL_CRB,
|
|
|
|
.caps = QEMU_CAPS_DEVICE_TPM_CRB,
|
|
|
|
},
|
2013-04-12 20:55:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
virQEMUCapsProbeQMPTPM(virQEMUCapsPtr qemuCaps,
|
|
|
|
qemuMonitorPtr mon)
|
|
|
|
{
|
Convert 'int i' to 'size_t i' in src/qemu files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 14:09:33 +00:00
|
|
|
int nentries;
|
|
|
|
size_t i;
|
2013-04-12 20:55:45 +00:00
|
|
|
char **entries = NULL;
|
2013-04-15 20:46:53 +00:00
|
|
|
|
2013-04-12 20:55:45 +00:00
|
|
|
if ((nentries = qemuMonitorGetTPMModels(mon, &entries)) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (nentries > 0) {
|
|
|
|
for (i = 0; i < ARRAY_CARDINALITY(virQEMUCapsTPMModelsToCaps); i++) {
|
|
|
|
const char *needle = virDomainTPMModelTypeToString(
|
|
|
|
virQEMUCapsTPMModelsToCaps[i].type);
|
2018-04-25 12:42:34 +00:00
|
|
|
if (virStringListHasString((const char **)entries, needle))
|
2013-04-12 20:55:45 +00:00
|
|
|
virQEMUCapsSet(qemuCaps,
|
|
|
|
virQEMUCapsTPMModelsToCaps[i].caps);
|
|
|
|
}
|
|
|
|
}
|
2016-11-25 08:18:35 +00:00
|
|
|
virStringListFree(entries);
|
2013-04-12 20:55:45 +00:00
|
|
|
|
|
|
|
if ((nentries = qemuMonitorGetTPMTypes(mon, &entries)) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (nentries > 0) {
|
|
|
|
for (i = 0; i < ARRAY_CARDINALITY(virQEMUCapsTPMTypesToCaps); i++) {
|
|
|
|
const char *needle = virDomainTPMBackendTypeToString(
|
|
|
|
virQEMUCapsTPMTypesToCaps[i].type);
|
2018-04-25 12:42:34 +00:00
|
|
|
if (virStringListHasString((const char **)entries, needle))
|
2013-04-12 20:55:45 +00:00
|
|
|
virQEMUCapsSet(qemuCaps, virQEMUCapsTPMTypesToCaps[i].caps);
|
|
|
|
}
|
|
|
|
}
|
2016-11-25 08:18:35 +00:00
|
|
|
virStringListFree(entries);
|
2013-04-12 20:55:45 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-08-22 17:05:08 +00:00
|
|
|
|
Make non-KVM machines work with QMP probing
When there is no 'qemu-kvm' binary and the emulator used for a machine
is, for example, 'qemu-system-x86_64' that, by default, runs without
kvm enabled, libvirt still supplies '-no-kvm' option to this process,
even though it does not recognize such option (making the start of a
domain fail in that case).
This patch fixes building a command-line for QEMU machines without KVM
acceleration and is based on following assumptions:
- QEMU_CAPS_KVM flag means that QEMU is running KVM accelerated
machines by default (without explicitly requesting that using a
command-line option). It is the closest to the truth according to
the code with the only exception being the comment next to the
flag, so it's fixed in this patch as well.
- QEMU_CAPS_ENABLE_KVM flag means that QEMU is, by default, running
without KVM acceleration and in case we need KVM acceleration it
needs to be explicitly instructed to do so. This is partially
true for the past (this option essentially means that QEMU
recognizes the '-enable-kvm' option, even though it's almost the
same).
2012-10-31 07:31:49 +00:00
|
|
|
static int
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsProbeQMPKVMState(virQEMUCapsPtr qemuCaps,
|
|
|
|
qemuMonitorPtr mon)
|
Make non-KVM machines work with QMP probing
When there is no 'qemu-kvm' binary and the emulator used for a machine
is, for example, 'qemu-system-x86_64' that, by default, runs without
kvm enabled, libvirt still supplies '-no-kvm' option to this process,
even though it does not recognize such option (making the start of a
domain fail in that case).
This patch fixes building a command-line for QEMU machines without KVM
acceleration and is based on following assumptions:
- QEMU_CAPS_KVM flag means that QEMU is running KVM accelerated
machines by default (without explicitly requesting that using a
command-line option). It is the closest to the truth according to
the code with the only exception being the comment next to the
flag, so it's fixed in this patch as well.
- QEMU_CAPS_ENABLE_KVM flag means that QEMU is, by default, running
without KVM acceleration and in case we need KVM acceleration it
needs to be explicitly instructed to do so. This is partially
true for the past (this option essentially means that QEMU
recognizes the '-enable-kvm' option, even though it's almost the
same).
2012-10-31 07:31:49 +00:00
|
|
|
{
|
|
|
|
bool enabled = false;
|
|
|
|
bool present = false;
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM))
|
Make non-KVM machines work with QMP probing
When there is no 'qemu-kvm' binary and the emulator used for a machine
is, for example, 'qemu-system-x86_64' that, by default, runs without
kvm enabled, libvirt still supplies '-no-kvm' option to this process,
even though it does not recognize such option (making the start of a
domain fail in that case).
This patch fixes building a command-line for QEMU machines without KVM
acceleration and is based on following assumptions:
- QEMU_CAPS_KVM flag means that QEMU is running KVM accelerated
machines by default (without explicitly requesting that using a
command-line option). It is the closest to the truth according to
the code with the only exception being the comment next to the
flag, so it's fixed in this patch as well.
- QEMU_CAPS_ENABLE_KVM flag means that QEMU is, by default, running
without KVM acceleration and in case we need KVM acceleration it
needs to be explicitly instructed to do so. This is partially
true for the past (this option essentially means that QEMU
recognizes the '-enable-kvm' option, even though it's almost the
same).
2012-10-31 07:31:49 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (qemuMonitorGetKVMState(mon, &enabled, &present) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
/* The QEMU_CAPS_KVM flag was initially set according to the QEMU
|
2013-01-25 10:46:49 +00:00
|
|
|
* reporting the recognition of 'query-kvm' QMP command. That merely
|
2014-04-20 20:07:46 +00:00
|
|
|
* indicates existence of the command though, not whether KVM support
|
2013-01-25 10:46:49 +00:00
|
|
|
* is actually available, nor whether it is enabled by default.
|
|
|
|
*
|
|
|
|
* If it is not present we need to clear the flag, and if it is
|
|
|
|
* not enabled by default we need to change the flag.
|
|
|
|
*/
|
|
|
|
if (!present) {
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsClear(qemuCaps, QEMU_CAPS_KVM);
|
2013-01-25 10:46:49 +00:00
|
|
|
} else if (!enabled) {
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsClear(qemuCaps, QEMU_CAPS_KVM);
|
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_ENABLE_KVM);
|
Make non-KVM machines work with QMP probing
When there is no 'qemu-kvm' binary and the emulator used for a machine
is, for example, 'qemu-system-x86_64' that, by default, runs without
kvm enabled, libvirt still supplies '-no-kvm' option to this process,
even though it does not recognize such option (making the start of a
domain fail in that case).
This patch fixes building a command-line for QEMU machines without KVM
acceleration and is based on following assumptions:
- QEMU_CAPS_KVM flag means that QEMU is running KVM accelerated
machines by default (without explicitly requesting that using a
command-line option). It is the closest to the truth according to
the code with the only exception being the comment next to the
flag, so it's fixed in this patch as well.
- QEMU_CAPS_ENABLE_KVM flag means that QEMU is, by default, running
without KVM acceleration and in case we need KVM acceleration it
needs to be explicitly instructed to do so. This is partially
true for the past (this option essentially means that QEMU
recognizes the '-enable-kvm' option, even though it's almost the
same).
2012-10-31 07:31:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-05-14 05:25:49 +00:00
|
|
|
struct virQEMUCapsCommandLineProps {
|
|
|
|
const char *option;
|
|
|
|
const char *param;
|
|
|
|
int flag;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct virQEMUCapsCommandLineProps virQEMUCapsCommandLine[] = {
|
|
|
|
{ "machine", "mem-merge", QEMU_CAPS_MEM_MERGE },
|
2015-04-02 16:43:47 +00:00
|
|
|
{ "machine", "vmport", QEMU_CAPS_MACHINE_VMPORT_OPT },
|
2013-05-14 12:44:54 +00:00
|
|
|
{ "drive", "discard", QEMU_CAPS_DRIVE_DISCARD },
|
2015-12-14 08:35:20 +00:00
|
|
|
{ "drive", "detect-zeroes", QEMU_CAPS_DRIVE_DETECT_ZEROES },
|
2016-07-25 12:44:16 +00:00
|
|
|
{ "realtime", "mlock", QEMU_CAPS_REALTIME_MLOCK },
|
qemu: add "-boot strict" to commandline whenever possible
This resolves:
https://bugzilla.redhat.com/show_bug.cgi?id=888635
(which was already closed as CANTFIX because the qemu "-boot strict"
commandline option wasn't available at the time).
Problem: you couldn't have a domain that used PXE to boot, but also
had an un-bootable disk device *even if that disk wasn't listed in the
boot order*, because if PXE timed out (e.g. due to the bridge
forwarding delay), the BIOS would move on to the next target, which
would be the unbootable disk device (again - even though it wasn't
given a boot order), and get stuck at a "BOOT DISK FAILURE, PRESS ANY
KEY" message until a user intervened.
The solution available since sometime around QEMU 1.5, is to add
"-boot strict=on" to *every* qemu command. When this is done, if any
devices have a boot order specified, then QEMU will *only* attempt to
boot from those devices that have an explicit boot order, ignoring the
rest.
2013-12-02 12:07:12 +00:00
|
|
|
{ "boot-opts", "strict", QEMU_CAPS_BOOT_STRICT },
|
2013-12-13 13:51:24 +00:00
|
|
|
{ "boot-opts", "reboot-timeout", QEMU_CAPS_REBOOT_TIMEOUT },
|
2014-08-22 11:42:46 +00:00
|
|
|
{ "boot-opts", "splash-time", QEMU_CAPS_SPLASH_TIMEOUT },
|
2014-01-16 16:11:14 +00:00
|
|
|
{ "spice", "disable-agent-file-xfer", QEMU_CAPS_SPICE_FILE_XFER_DISABLE },
|
2014-04-09 13:23:45 +00:00
|
|
|
{ "msg", "timestamp", QEMU_CAPS_MSG_TIMESTAMP },
|
2014-06-17 11:43:19 +00:00
|
|
|
{ "numa", NULL, QEMU_CAPS_NUMA },
|
2014-10-29 12:16:01 +00:00
|
|
|
{ "drive", "throttling.bps-total-max", QEMU_CAPS_DRIVE_IOTUNE_MAX},
|
2015-04-27 21:57:29 +00:00
|
|
|
{ "machine", "aes-key-wrap", QEMU_CAPS_AES_KEY_WRAP },
|
|
|
|
{ "machine", "dea-key-wrap", QEMU_CAPS_DEA_KEY_WRAP },
|
2015-12-24 14:27:55 +00:00
|
|
|
{ "chardev", "append", QEMU_CAPS_CHARDEV_FILE_APPEND },
|
2016-02-19 14:30:15 +00:00
|
|
|
{ "spice", "gl", QEMU_CAPS_SPICE_GL },
|
2016-02-23 11:56:34 +00:00
|
|
|
{ "chardev", "logfile", QEMU_CAPS_CHARDEV_LOGFILE },
|
2016-03-10 19:46:38 +00:00
|
|
|
{ "name", "debug-threads", QEMU_CAPS_NAME_DEBUG_THREADS },
|
2016-04-22 22:39:09 +00:00
|
|
|
{ "name", "guest", QEMU_CAPS_NAME_GUEST },
|
2016-06-07 22:21:29 +00:00
|
|
|
{ "spice", "unix", QEMU_CAPS_SPICE_UNIX },
|
2016-09-19 10:47:19 +00:00
|
|
|
{ "drive", "throttling.bps-total-max-length", QEMU_CAPS_DRIVE_IOTUNE_MAX_LENGTH },
|
2016-11-07 11:19:50 +00:00
|
|
|
{ "drive", "throttling.group", QEMU_CAPS_DRIVE_IOTUNE_GROUP },
|
2017-02-14 21:04:13 +00:00
|
|
|
{ "spice", "rendernode", QEMU_CAPS_SPICE_RENDERNODE },
|
2017-03-17 07:26:49 +00:00
|
|
|
{ "machine", "kernel_irqchip", QEMU_CAPS_MACHINE_KERNEL_IRQCHIP },
|
2017-06-01 16:36:26 +00:00
|
|
|
{ "machine", "loadparm", QEMU_CAPS_LOADPARM },
|
2017-07-21 16:44:14 +00:00
|
|
|
{ "vnc", "vnc", QEMU_CAPS_VNC_MULTI_SERVERS },
|
2017-08-09 13:06:40 +00:00
|
|
|
{ "chardev", "reconnect", QEMU_CAPS_CHARDEV_RECONNECT },
|
2018-03-31 20:15:02 +00:00
|
|
|
{ "sandbox", "elevateprivileges", QEMU_CAPS_SECCOMP_BLACKLIST },
|
2013-05-14 05:25:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
virQEMUCapsProbeQMPCommandLine(virQEMUCapsPtr qemuCaps,
|
|
|
|
qemuMonitorPtr mon)
|
|
|
|
{
|
2014-06-17 11:41:16 +00:00
|
|
|
bool found = false;
|
2013-05-14 05:25:49 +00:00
|
|
|
int nvalues;
|
|
|
|
char **values;
|
|
|
|
size_t i, j;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_CARDINALITY(virQEMUCapsCommandLine); i++) {
|
|
|
|
if ((nvalues = qemuMonitorGetCommandLineOptionParameters(mon,
|
|
|
|
virQEMUCapsCommandLine[i].option,
|
2014-06-17 11:41:16 +00:00
|
|
|
&values,
|
|
|
|
&found)) < 0)
|
2013-05-14 05:25:49 +00:00
|
|
|
return -1;
|
2014-06-17 11:41:16 +00:00
|
|
|
|
|
|
|
if (found && !virQEMUCapsCommandLine[i].param)
|
|
|
|
virQEMUCapsSet(qemuCaps, virQEMUCapsCommandLine[i].flag);
|
|
|
|
|
2013-05-14 05:25:49 +00:00
|
|
|
for (j = 0; j < nvalues; j++) {
|
2014-06-17 11:41:16 +00:00
|
|
|
if (STREQ_NULLABLE(virQEMUCapsCommandLine[i].param, values[j])) {
|
2013-05-14 05:25:49 +00:00
|
|
|
virQEMUCapsSet(qemuCaps, virQEMUCapsCommandLine[i].flag);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-11-25 08:18:35 +00:00
|
|
|
virStringListFree(values);
|
2013-05-14 05:25:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
Make non-KVM machines work with QMP probing
When there is no 'qemu-kvm' binary and the emulator used for a machine
is, for example, 'qemu-system-x86_64' that, by default, runs without
kvm enabled, libvirt still supplies '-no-kvm' option to this process,
even though it does not recognize such option (making the start of a
domain fail in that case).
This patch fixes building a command-line for QEMU machines without KVM
acceleration and is based on following assumptions:
- QEMU_CAPS_KVM flag means that QEMU is running KVM accelerated
machines by default (without explicitly requesting that using a
command-line option). It is the closest to the truth according to
the code with the only exception being the comment next to the
flag, so it's fixed in this patch as well.
- QEMU_CAPS_ENABLE_KVM flag means that QEMU is, by default, running
without KVM acceleration and in case we need KVM acceleration it
needs to be explicitly instructed to do so. This is partially
true for the past (this option essentially means that QEMU
recognizes the '-enable-kvm' option, even though it's almost the
same).
2012-10-31 07:31:49 +00:00
|
|
|
|
2014-09-11 12:11:54 +00:00
|
|
|
static int
|
|
|
|
virQEMUCapsProbeQMPMigrationCapabilities(virQEMUCapsPtr qemuCaps,
|
|
|
|
qemuMonitorPtr mon)
|
|
|
|
{
|
|
|
|
char **caps = NULL;
|
|
|
|
int ncaps;
|
|
|
|
|
|
|
|
if ((ncaps = qemuMonitorGetMigrationCapabilities(mon, &caps)) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
virQEMUCapsProcessStringFlags(qemuCaps,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsMigration),
|
|
|
|
virQEMUCapsMigration,
|
|
|
|
ncaps, caps);
|
2017-03-03 20:31:26 +00:00
|
|
|
virStringListFreeCount(caps, ncaps);
|
2014-09-11 12:11:54 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-03-08 17:24:18 +00:00
|
|
|
/**
|
|
|
|
* virQEMUCapsProbeQMPGICCapabilities:
|
|
|
|
* @qemuCaps: QEMU binary capabilities
|
|
|
|
* @mon: QEMU monitor
|
|
|
|
*
|
|
|
|
* Use @mon to obtain information about the GIC capabilities for the
|
|
|
|
* corresponding QEMU binary, and store them in @qemuCaps.
|
|
|
|
*
|
|
|
|
* Returns: 0 on success, <0 on failure
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
virQEMUCapsProbeQMPGICCapabilities(virQEMUCapsPtr qemuCaps,
|
|
|
|
qemuMonitorPtr mon)
|
|
|
|
{
|
|
|
|
virGICCapability *caps = NULL;
|
|
|
|
int ncaps;
|
|
|
|
|
|
|
|
if ((ncaps = qemuMonitorGetGICCapabilities(mon, &caps)) < 0)
|
|
|
|
return -1;
|
|
|
|
|
2016-05-10 08:50:34 +00:00
|
|
|
virQEMUCapsSetGICCapabilities(qemuCaps, caps, ncaps);
|
2016-03-08 17:24:18 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-09-13 14:54:02 +00:00
|
|
|
|
2017-09-13 15:28:13 +00:00
|
|
|
bool
|
2016-07-21 15:02:37 +00:00
|
|
|
virQEMUCapsCPUFilterFeatures(const char *name,
|
2017-01-18 13:05:26 +00:00
|
|
|
void *opaque)
|
2016-07-21 15:02:37 +00:00
|
|
|
{
|
2017-09-13 15:26:07 +00:00
|
|
|
virArch *arch = opaque;
|
2017-01-18 13:05:26 +00:00
|
|
|
|
2017-09-13 15:26:07 +00:00
|
|
|
if (!ARCH_IS_X86(*arch))
|
2017-01-18 13:05:26 +00:00
|
|
|
return true;
|
|
|
|
|
2016-07-21 15:02:37 +00:00
|
|
|
if (STREQ(name, "cmt") ||
|
|
|
|
STREQ(name, "mbm_total") ||
|
|
|
|
STREQ(name, "mbm_local"))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-10 18:16:24 +00:00
|
|
|
/**
|
|
|
|
* Returns 0 when host CPU model provided by QEMU was filled in qemuCaps,
|
|
|
|
* 1 when the caller should fall back to using virCapsPtr->host.cpu,
|
2017-11-27 12:12:17 +00:00
|
|
|
* 2 when cpu model info is not supported for this configuration,
|
2017-01-10 18:16:24 +00:00
|
|
|
* -1 on error.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
virQEMUCapsInitCPUModelS390(virQEMUCapsPtr qemuCaps,
|
2017-11-24 08:02:02 +00:00
|
|
|
virDomainVirtType type,
|
2017-03-30 11:50:44 +00:00
|
|
|
qemuMonitorCPUModelInfoPtr modelInfo,
|
2017-03-29 11:33:50 +00:00
|
|
|
virCPUDefPtr cpu,
|
|
|
|
bool migratable)
|
2016-06-15 12:35:18 +00:00
|
|
|
{
|
2017-01-06 07:52:22 +00:00
|
|
|
size_t i;
|
2016-06-15 12:35:18 +00:00
|
|
|
|
2017-01-10 18:16:24 +00:00
|
|
|
if (!modelInfo) {
|
2017-11-24 08:02:02 +00:00
|
|
|
if (type == VIR_DOMAIN_VIRT_KVM) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("missing host CPU model info from QEMU "
|
|
|
|
"capabilities for binary %s"),
|
|
|
|
qemuCaps->binary);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 2;
|
2017-01-06 07:52:22 +00:00
|
|
|
}
|
qemu: Fix crash in qemucapsprobe
The qemucapsprobe helper calls virQEMUCapsNewForBinaryInternal with
caps == NULL, causing the following crash:
Program received signal SIGSEGV, Segmentation fault.
#0 0x00007ffff788775f in virQEMUCapsInitHostCPUModel
(qemuCaps=qemuCaps@entry=0x649680, host=host@entry=0x10) at
src/qemu/qemu_capabilities.c:2969
#1 0x00007ffff7889dbf in virQEMUCapsNewForBinaryInternal
(caps=caps@entry=0x0, binary=<optimized out>,
libDir=libDir@entry=0x4033f6 "/tmp", cacheDir=cacheDir@entry=0x0,
runUid=runUid@entry=4294967295, runGid=runGid@entry=4294967295,
qmpOnly=true) at src/qemu/qemu_capabilities.c:4039
#2 0x0000000000401702 in main (argc=2, argv=0x7fffffffd968) at
tests/qemucapsprobe.c:73
Caused by v2.2.0-182-g68c7011.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-09-27 11:39:51 +00:00
|
|
|
|
2017-01-06 07:52:22 +00:00
|
|
|
if (VIR_STRDUP(cpu->model, modelInfo->name) < 0 ||
|
|
|
|
VIR_ALLOC_N(cpu->features, modelInfo->nprops) < 0)
|
2017-01-10 18:16:24 +00:00
|
|
|
return -1;
|
2017-01-06 07:52:22 +00:00
|
|
|
|
|
|
|
cpu->nfeatures_max = modelInfo->nprops;
|
|
|
|
cpu->nfeatures = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < modelInfo->nprops; i++) {
|
2017-02-22 15:01:30 +00:00
|
|
|
virCPUFeatureDefPtr feature = cpu->features + cpu->nfeatures;
|
|
|
|
qemuMonitorCPUPropertyPtr prop = modelInfo->props + i;
|
2017-01-06 07:52:22 +00:00
|
|
|
|
2017-02-22 15:01:30 +00:00
|
|
|
if (prop->type != QEMU_MONITOR_CPU_PROPERTY_BOOLEAN)
|
|
|
|
continue;
|
2017-01-06 07:52:22 +00:00
|
|
|
|
2017-02-22 15:01:30 +00:00
|
|
|
if (VIR_STRDUP(feature->name, prop->name) < 0)
|
|
|
|
return -1;
|
2017-03-29 11:33:50 +00:00
|
|
|
|
|
|
|
if (!prop->value.boolean ||
|
|
|
|
(migratable && prop->migratable == VIR_TRISTATE_BOOL_NO))
|
|
|
|
feature->policy = VIR_CPU_FEATURE_DISABLE;
|
|
|
|
else
|
|
|
|
feature->policy = VIR_CPU_FEATURE_REQUIRE;
|
2017-01-06 07:52:22 +00:00
|
|
|
cpu->nfeatures++;
|
|
|
|
}
|
|
|
|
|
2017-01-10 18:16:24 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2017-01-06 07:52:22 +00:00
|
|
|
|
2017-01-10 18:16:24 +00:00
|
|
|
|
2017-01-11 13:36:34 +00:00
|
|
|
/**
|
|
|
|
* Returns 0 when host CPU model provided by QEMU was filled in qemuCaps,
|
|
|
|
* 1 when the caller should fall back to using virCapsPtr->host.cpu,
|
|
|
|
* -1 on error.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
virQEMUCapsInitCPUModelX86(virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainVirtType type,
|
2017-03-30 11:50:44 +00:00
|
|
|
qemuMonitorCPUModelInfoPtr model,
|
2017-03-29 11:33:50 +00:00
|
|
|
virCPUDefPtr cpu,
|
|
|
|
bool migratable)
|
2017-01-11 13:36:34 +00:00
|
|
|
{
|
|
|
|
virCPUDataPtr data = NULL;
|
|
|
|
unsigned long long sigFamily = 0;
|
|
|
|
unsigned long long sigModel = 0;
|
2017-10-10 11:34:28 +00:00
|
|
|
unsigned long long sigStepping = 0;
|
2017-01-11 13:36:34 +00:00
|
|
|
int ret = -1;
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
if (!model)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
if (!(data = virCPUDataNew(VIR_ARCH_X86_64)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
for (i = 0; i < model->nprops; i++) {
|
|
|
|
qemuMonitorCPUPropertyPtr prop = model->props + i;
|
|
|
|
|
|
|
|
switch (prop->type) {
|
|
|
|
case QEMU_MONITOR_CPU_PROPERTY_BOOLEAN:
|
2017-03-29 11:33:50 +00:00
|
|
|
if (!prop->value.boolean ||
|
|
|
|
(migratable && prop->migratable == VIR_TRISTATE_BOOL_NO))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (virCPUx86DataAddFeature(data, prop->name) < 0)
|
2017-01-11 13:36:34 +00:00
|
|
|
goto cleanup;
|
2017-03-29 11:33:50 +00:00
|
|
|
|
2017-01-11 13:36:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case QEMU_MONITOR_CPU_PROPERTY_STRING:
|
|
|
|
if (STREQ(prop->name, "vendor") &&
|
|
|
|
virCPUx86DataSetVendor(data, prop->value.string) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case QEMU_MONITOR_CPU_PROPERTY_NUMBER:
|
|
|
|
if (STREQ(prop->name, "family"))
|
|
|
|
sigFamily = prop->value.number;
|
|
|
|
else if (STREQ(prop->name, "model"))
|
|
|
|
sigModel = prop->value.number;
|
2017-10-10 11:34:28 +00:00
|
|
|
else if (STREQ(prop->name, "stepping"))
|
|
|
|
sigStepping = prop->value.number;
|
2017-01-11 13:36:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case QEMU_MONITOR_CPU_PROPERTY_LAST:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-10 11:34:28 +00:00
|
|
|
if (virCPUx86DataSetSignature(data, sigFamily, sigModel, sigStepping) < 0)
|
2017-01-11 13:36:34 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2017-09-26 08:24:05 +00:00
|
|
|
if (cpuDecode(cpu, data, virQEMUCapsGetCPUDefinitions(qemuCaps, type)) < 0)
|
2017-01-11 13:36:34 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virCPUDataFree(data);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-10 18:16:24 +00:00
|
|
|
/**
|
|
|
|
* Returns 0 when host CPU model provided by QEMU was filled in qemuCaps,
|
2017-11-27 12:12:17 +00:00
|
|
|
* 1 when the caller should fall back to other methods,
|
|
|
|
* 2 when cpu model info is not supported for this configuration,
|
2017-01-10 18:16:24 +00:00
|
|
|
* -1 on error.
|
|
|
|
*/
|
2017-02-23 13:31:23 +00:00
|
|
|
int
|
2017-01-10 18:16:24 +00:00
|
|
|
virQEMUCapsInitCPUModel(virQEMUCapsPtr qemuCaps,
|
2017-02-22 15:51:50 +00:00
|
|
|
virDomainVirtType type,
|
2017-03-29 11:33:50 +00:00
|
|
|
virCPUDefPtr cpu,
|
|
|
|
bool migratable)
|
2017-01-10 18:16:24 +00:00
|
|
|
{
|
2017-04-07 16:15:26 +00:00
|
|
|
virQEMUCapsHostCPUDataPtr cpuData = virQEMUCapsGetHostCPUData(qemuCaps, type);
|
2017-01-10 18:16:24 +00:00
|
|
|
int ret = 1;
|
|
|
|
|
2017-04-07 16:15:26 +00:00
|
|
|
if (migratable && cpuData->info && !cpuData->info->migratability)
|
2017-03-29 11:33:50 +00:00
|
|
|
return 1;
|
|
|
|
|
2017-04-07 16:15:26 +00:00
|
|
|
if (ARCH_IS_S390(qemuCaps->arch)) {
|
2017-11-24 08:02:02 +00:00
|
|
|
ret = virQEMUCapsInitCPUModelS390(qemuCaps, type, cpuData->info,
|
2017-04-07 16:15:26 +00:00
|
|
|
cpu, migratable);
|
|
|
|
} else if (ARCH_IS_X86(qemuCaps->arch)) {
|
|
|
|
ret = virQEMUCapsInitCPUModelX86(qemuCaps, type, cpuData->info,
|
|
|
|
cpu, migratable);
|
|
|
|
}
|
2017-01-10 18:16:24 +00:00
|
|
|
|
2017-01-10 20:07:23 +00:00
|
|
|
if (ret == 0)
|
|
|
|
cpu->fallback = VIR_CPU_FALLBACK_FORBID;
|
|
|
|
|
2017-01-10 18:16:24 +00:00
|
|
|
return ret;
|
2017-01-06 07:52:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-03-29 13:31:17 +00:00
|
|
|
static virCPUDefPtr
|
|
|
|
virQEMUCapsNewHostCPUModel(void)
|
|
|
|
{
|
|
|
|
virCPUDefPtr cpu;
|
|
|
|
|
|
|
|
if (VIR_ALLOC(cpu) < 0)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
cpu->type = VIR_CPU_TYPE_GUEST;
|
|
|
|
cpu->mode = VIR_CPU_MODE_CUSTOM;
|
|
|
|
cpu->match = VIR_CPU_MATCH_EXACT;
|
|
|
|
cpu->fallback = VIR_CPU_FALLBACK_ALLOW;
|
|
|
|
|
|
|
|
return cpu;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-10 18:16:24 +00:00
|
|
|
void
|
|
|
|
virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps,
|
2017-07-21 13:09:54 +00:00
|
|
|
virArch hostArch,
|
2017-02-22 15:51:50 +00:00
|
|
|
virDomainVirtType type)
|
2017-01-06 07:52:22 +00:00
|
|
|
{
|
|
|
|
virCPUDefPtr cpu = NULL;
|
2018-04-11 08:57:32 +00:00
|
|
|
virCPUDefPtr cpuExpanded = NULL;
|
2017-03-29 13:31:17 +00:00
|
|
|
virCPUDefPtr migCPU = NULL;
|
2017-03-08 12:32:46 +00:00
|
|
|
virCPUDefPtr hostCPU = NULL;
|
2017-04-11 18:46:05 +00:00
|
|
|
virCPUDefPtr fullCPU = NULL;
|
|
|
|
size_t i;
|
2017-01-10 18:16:24 +00:00
|
|
|
int rc;
|
2017-01-06 07:52:22 +00:00
|
|
|
|
2017-07-21 13:09:54 +00:00
|
|
|
if (!virQEMUCapsGuestIsNative(hostArch, qemuCaps->arch))
|
2017-01-10 18:16:24 +00:00
|
|
|
return;
|
|
|
|
|
2017-03-29 13:31:17 +00:00
|
|
|
if (!(cpu = virQEMUCapsNewHostCPUModel()))
|
2017-01-10 18:16:24 +00:00
|
|
|
goto error;
|
|
|
|
|
2017-03-29 11:33:50 +00:00
|
|
|
if ((rc = virQEMUCapsInitCPUModel(qemuCaps, type, cpu, false)) < 0) {
|
2017-01-10 18:16:24 +00:00
|
|
|
goto error;
|
|
|
|
} else if (rc == 1) {
|
2017-03-08 12:32:46 +00:00
|
|
|
VIR_DEBUG("No host CPU model info from QEMU; probing host CPU directly");
|
2016-06-15 12:35:18 +00:00
|
|
|
|
2017-07-21 13:09:54 +00:00
|
|
|
hostCPU = virQEMUCapsProbeHostCPUForEmulator(hostArch, qemuCaps, type);
|
2017-03-08 12:32:46 +00:00
|
|
|
if (!hostCPU ||
|
|
|
|
virCPUDefCopyModelFilter(cpu, hostCPU, true,
|
2017-01-18 13:05:26 +00:00
|
|
|
virQEMUCapsCPUFilterFeatures,
|
2017-09-13 15:26:07 +00:00
|
|
|
&qemuCaps->arch) < 0)
|
2016-06-15 12:35:18 +00:00
|
|
|
goto error;
|
2017-11-24 08:02:02 +00:00
|
|
|
} else if (rc == 2) {
|
|
|
|
VIR_DEBUG("QEMU does not provide CPU model for arch=%s virttype=%s",
|
|
|
|
virArchToString(qemuCaps->arch),
|
|
|
|
virDomainVirtTypeToString(type));
|
|
|
|
goto error;
|
2017-04-11 18:46:05 +00:00
|
|
|
} else if (type == VIR_DOMAIN_VIRT_KVM &&
|
|
|
|
virCPUGetHostIsSupported(qemuCaps->arch)) {
|
|
|
|
if (!(fullCPU = virCPUGetHost(qemuCaps->arch, VIR_CPU_TYPE_GUEST,
|
2017-09-22 13:51:33 +00:00
|
|
|
NULL, NULL)))
|
2017-04-11 18:46:05 +00:00
|
|
|
goto error;
|
|
|
|
|
2018-04-11 08:57:32 +00:00
|
|
|
if (!(cpuExpanded = virCPUDefCopy(cpu)) ||
|
|
|
|
virCPUExpandFeatures(qemuCaps->arch, cpuExpanded) < 0)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
for (i = 0; i < cpuExpanded->nfeatures; i++) {
|
|
|
|
if (cpuExpanded->features[i].policy == VIR_CPU_FEATURE_REQUIRE &&
|
|
|
|
virCPUDefUpdateFeature(fullCPU, cpuExpanded->features[i].name,
|
2017-04-11 18:46:05 +00:00
|
|
|
VIR_CPU_FEATURE_REQUIRE) < 0)
|
|
|
|
goto error;
|
|
|
|
}
|
2016-06-15 12:35:18 +00:00
|
|
|
}
|
|
|
|
|
2017-03-29 13:31:17 +00:00
|
|
|
if (!(migCPU = virQEMUCapsNewHostCPUModel()))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
if ((rc = virQEMUCapsInitCPUModel(qemuCaps, type, migCPU, true)) < 0) {
|
|
|
|
goto error;
|
|
|
|
} else if (rc == 1) {
|
|
|
|
VIR_DEBUG("CPU migratability not provided by QEMU");
|
|
|
|
|
|
|
|
virCPUDefFree(migCPU);
|
|
|
|
if (!(migCPU = virCPUCopyMigratable(qemuCaps->arch, cpu)))
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2017-04-11 18:46:05 +00:00
|
|
|
virQEMUCapsSetHostModel(qemuCaps, type, cpu, migCPU, fullCPU);
|
2017-02-22 15:51:50 +00:00
|
|
|
|
2017-03-08 12:32:46 +00:00
|
|
|
cleanup:
|
2018-04-11 08:57:32 +00:00
|
|
|
virCPUDefFree(cpuExpanded);
|
2017-03-08 12:32:46 +00:00
|
|
|
virCPUDefFree(hostCPU);
|
2016-06-15 12:35:18 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
error:
|
|
|
|
virCPUDefFree(cpu);
|
2017-03-29 13:31:17 +00:00
|
|
|
virCPUDefFree(migCPU);
|
2017-04-11 18:46:05 +00:00
|
|
|
virCPUDefFree(fullCPU);
|
2016-06-15 12:35:18 +00:00
|
|
|
virResetLastError();
|
2017-03-08 12:32:46 +00:00
|
|
|
goto cleanup;
|
2016-06-15 12:35:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-23 13:31:23 +00:00
|
|
|
void
|
|
|
|
virQEMUCapsSetCPUModelInfo(virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainVirtType type,
|
|
|
|
qemuMonitorCPUModelInfoPtr modelInfo)
|
|
|
|
{
|
2017-04-07 16:15:26 +00:00
|
|
|
virQEMUCapsHostCPUDataPtr cpuData = virQEMUCapsGetHostCPUData(qemuCaps, type);
|
|
|
|
|
|
|
|
cpuData->info = modelInfo;
|
2017-02-23 13:31:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-06 07:52:22 +00:00
|
|
|
static int
|
|
|
|
virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsPtr qemuCaps,
|
2017-02-22 15:51:50 +00:00
|
|
|
xmlXPathContextPtr ctxt,
|
|
|
|
virDomainVirtType virtType)
|
2017-01-06 07:52:22 +00:00
|
|
|
{
|
|
|
|
char *str = NULL;
|
|
|
|
xmlNodePtr hostCPUNode;
|
2017-01-30 15:30:13 +00:00
|
|
|
xmlNodePtr *nodes = NULL;
|
2017-01-06 07:52:22 +00:00
|
|
|
xmlNodePtr oldnode = ctxt->node;
|
|
|
|
qemuMonitorCPUModelInfoPtr hostCPU = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
size_t i;
|
|
|
|
int n;
|
2017-03-29 08:33:08 +00:00
|
|
|
int val;
|
2017-01-06 07:52:22 +00:00
|
|
|
|
2017-02-22 15:51:50 +00:00
|
|
|
if (virtType == VIR_DOMAIN_VIRT_KVM)
|
|
|
|
hostCPUNode = virXPathNode("./hostCPU[@type='kvm']", ctxt);
|
|
|
|
else
|
|
|
|
hostCPUNode = virXPathNode("./hostCPU[@type='tcg']", ctxt);
|
|
|
|
|
|
|
|
if (!hostCPUNode) {
|
2017-01-06 07:52:22 +00:00
|
|
|
ret = 0;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (VIR_ALLOC(hostCPU) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (!(hostCPU->name = virXMLPropString(hostCPUNode, "model"))) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("missing host CPU model name in QEMU "
|
|
|
|
"capabilities cache"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2017-03-29 08:33:08 +00:00
|
|
|
if (!(str = virXMLPropString(hostCPUNode, "migratability")) ||
|
|
|
|
(val = virTristateBoolTypeFromString(str)) <= 0) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("invalid migratability value for host CPU model"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
hostCPU->migratability = val == VIR_TRISTATE_BOOL_YES;
|
|
|
|
VIR_FREE(str);
|
|
|
|
|
2017-01-06 07:52:22 +00:00
|
|
|
ctxt->node = hostCPUNode;
|
|
|
|
|
2017-01-30 15:30:13 +00:00
|
|
|
if ((n = virXPathNodeSet("./property", ctxt, &nodes)) > 0) {
|
2017-01-06 07:52:22 +00:00
|
|
|
if (VIR_ALLOC_N(hostCPU->props, n) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
hostCPU->nprops = n;
|
|
|
|
|
|
|
|
for (i = 0; i < n; i++) {
|
2017-02-22 15:01:30 +00:00
|
|
|
qemuMonitorCPUPropertyPtr prop = hostCPU->props + i;
|
|
|
|
|
|
|
|
ctxt->node = nodes[i];
|
|
|
|
|
|
|
|
if (!(prop->name = virXMLPropString(ctxt->node, "name"))) {
|
2017-01-06 07:52:22 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("missing 'name' attribute for a host CPU"
|
2017-01-30 15:30:13 +00:00
|
|
|
" model property in QEMU capabilities cache"));
|
2017-01-06 07:52:22 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2017-02-22 15:01:30 +00:00
|
|
|
if (!(str = virXMLPropString(ctxt->node, "type")) ||
|
2017-03-29 08:33:08 +00:00
|
|
|
(val = qemuMonitorCPUPropertyTypeFromString(str)) < 0) {
|
2017-01-06 07:52:22 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
2017-02-22 15:01:30 +00:00
|
|
|
_("missing or invalid CPU model property type "
|
|
|
|
"in QEMU capabilities cache"));
|
2017-01-06 07:52:22 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
VIR_FREE(str);
|
2017-02-22 15:01:30 +00:00
|
|
|
|
2017-03-29 08:33:08 +00:00
|
|
|
prop->type = val;
|
2017-02-22 15:01:30 +00:00
|
|
|
switch (prop->type) {
|
|
|
|
case QEMU_MONITOR_CPU_PROPERTY_BOOLEAN:
|
|
|
|
if (virXPathBoolean("./@value='true'", ctxt))
|
|
|
|
prop->value.boolean = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case QEMU_MONITOR_CPU_PROPERTY_STRING:
|
|
|
|
prop->value.string = virXMLPropString(ctxt->node, "value");
|
|
|
|
if (!prop->value.string) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("invalid string value for '%s' host CPU "
|
|
|
|
"model property in QEMU capabilities cache"),
|
|
|
|
prop->name);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case QEMU_MONITOR_CPU_PROPERTY_NUMBER:
|
|
|
|
if (virXPathLongLong("string(./@value)", ctxt,
|
|
|
|
&prop->value.number) < 0) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("invalid number value for '%s' host CPU "
|
|
|
|
"model property in QEMU capabilities cache"),
|
|
|
|
prop->name);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case QEMU_MONITOR_CPU_PROPERTY_LAST:
|
|
|
|
break;
|
|
|
|
}
|
2017-03-29 08:33:08 +00:00
|
|
|
|
|
|
|
if ((str = virXMLPropString(ctxt->node, "migratable"))) {
|
|
|
|
if ((val = virTristateBoolTypeFromString(str)) <= 0) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("unknown migratable value for '%s' host "
|
|
|
|
"CPU model property"),
|
|
|
|
prop->name);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
prop->migratable = val;
|
|
|
|
VIR_FREE(str);
|
|
|
|
}
|
2017-01-06 07:52:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-23 13:31:23 +00:00
|
|
|
virQEMUCapsSetCPUModelInfo(qemuCaps, virtType, hostCPU);
|
2017-01-06 07:52:22 +00:00
|
|
|
hostCPU = NULL;
|
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
ctxt->node = oldnode;
|
|
|
|
VIR_FREE(str);
|
2017-01-30 15:30:13 +00:00
|
|
|
VIR_FREE(nodes);
|
2017-01-06 07:52:22 +00:00
|
|
|
qemuMonitorCPUModelInfoFree(hostCPU);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-11-14 20:51:19 +00:00
|
|
|
static int
|
|
|
|
virQEMUCapsLoadCPUModels(virQEMUCapsPtr qemuCaps,
|
2016-11-14 16:21:30 +00:00
|
|
|
xmlXPathContextPtr ctxt,
|
|
|
|
virDomainVirtType type)
|
2016-11-14 20:51:19 +00:00
|
|
|
{
|
2016-11-14 16:21:30 +00:00
|
|
|
virDomainCapsCPUModelsPtr cpus = NULL;
|
2016-11-14 20:51:19 +00:00
|
|
|
xmlNodePtr *nodes = NULL;
|
|
|
|
char *str = NULL;
|
|
|
|
size_t i;
|
|
|
|
int n;
|
|
|
|
int ret = -1;
|
2017-09-21 14:11:14 +00:00
|
|
|
xmlNodePtr node;
|
|
|
|
xmlNodePtr *blockerNodes = NULL;
|
|
|
|
char **blockers = NULL;
|
|
|
|
int nblockers;
|
2016-11-14 20:51:19 +00:00
|
|
|
|
2016-11-14 16:21:30 +00:00
|
|
|
if (type == VIR_DOMAIN_VIRT_KVM)
|
|
|
|
n = virXPathNodeSet("./cpu[@type='kvm']", ctxt, &nodes);
|
|
|
|
else
|
|
|
|
n = virXPathNodeSet("./cpu[@type='tcg']", ctxt, &nodes);
|
|
|
|
|
|
|
|
if (n < 0) {
|
2016-11-14 20:51:19 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("failed to parse qemu capabilities cpus"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (n == 0) {
|
|
|
|
ret = 0;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2016-11-14 16:21:30 +00:00
|
|
|
if (!(cpus = virDomainCapsCPUModelsNew(n)))
|
2016-11-14 20:51:19 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2016-11-14 16:21:30 +00:00
|
|
|
if (type == VIR_DOMAIN_VIRT_KVM)
|
|
|
|
qemuCaps->kvmCPUModels = cpus;
|
|
|
|
else
|
|
|
|
qemuCaps->tcgCPUModels = cpus;
|
|
|
|
|
2016-11-14 20:51:19 +00:00
|
|
|
for (i = 0; i < n; i++) {
|
2016-04-21 11:08:12 +00:00
|
|
|
int usable = VIR_DOMCAPS_CPU_USABLE_UNKNOWN;
|
|
|
|
|
|
|
|
if ((str = virXMLPropString(nodes[i], "usable")) &&
|
|
|
|
(usable = virDomainCapsCPUUsableTypeFromString(str)) < 0) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("unknown value '%s' in attribute 'usable'"), str);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
VIR_FREE(str);
|
|
|
|
|
2016-11-14 20:51:19 +00:00
|
|
|
if (!(str = virXMLPropString(nodes[i], "name"))) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("missing cpu name in QEMU capabilities cache"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2017-09-21 14:11:14 +00:00
|
|
|
node = ctxt->node;
|
|
|
|
ctxt->node = nodes[i];
|
|
|
|
nblockers = virXPathNodeSet("./blocker", ctxt, &blockerNodes);
|
|
|
|
ctxt->node = node;
|
|
|
|
|
|
|
|
if (nblockers < 0) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("failed to parse CPU blockers in QEMU capabilities"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nblockers > 0) {
|
|
|
|
size_t j;
|
|
|
|
|
|
|
|
if (VIR_ALLOC_N(blockers, nblockers + 1) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
for (j = 0; j < nblockers; j++) {
|
|
|
|
if (!(blockers[j] = virXMLPropString(blockerNodes[j], "name"))) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("missing blocker name in QEMU "
|
|
|
|
"capabilities cache"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
}
|
2017-10-27 07:53:03 +00:00
|
|
|
VIR_FREE(blockerNodes);
|
2017-09-21 14:11:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (virDomainCapsCPUModelsAddSteal(cpus, &str, usable, &blockers) < 0)
|
2016-11-14 20:51:19 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
VIR_FREE(nodes);
|
|
|
|
VIR_FREE(str);
|
2017-09-21 14:11:14 +00:00
|
|
|
VIR_FREE(blockerNodes);
|
|
|
|
virStringListFree(blockers);
|
2016-11-14 20:51:19 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-19 15:02:40 +00:00
|
|
|
struct _virQEMUCapsCachePriv {
|
|
|
|
char *libDir;
|
|
|
|
uid_t runUid;
|
|
|
|
gid_t runGid;
|
|
|
|
virArch hostArch;
|
2017-12-12 15:23:41 +00:00
|
|
|
unsigned int microcodeVersion;
|
2018-01-22 10:37:04 +00:00
|
|
|
char *kernelVersion;
|
2017-07-19 15:02:40 +00:00
|
|
|
};
|
|
|
|
typedef struct _virQEMUCapsCachePriv virQEMUCapsCachePriv;
|
|
|
|
typedef virQEMUCapsCachePriv *virQEMUCapsCachePrivPtr;
|
|
|
|
|
|
|
|
|
2017-06-20 14:17:23 +00:00
|
|
|
static void
|
2017-07-19 15:01:56 +00:00
|
|
|
virQEMUCapsCachePrivFree(void *privData)
|
2017-06-20 14:17:23 +00:00
|
|
|
{
|
2017-07-19 15:01:56 +00:00
|
|
|
virQEMUCapsCachePrivPtr priv = privData;
|
|
|
|
|
2017-06-20 14:17:23 +00:00
|
|
|
VIR_FREE(priv->libDir);
|
2018-01-22 10:37:04 +00:00
|
|
|
VIR_FREE(priv->kernelVersion);
|
2017-06-20 14:17:23 +00:00
|
|
|
VIR_FREE(priv);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-05 16:51:59 +00:00
|
|
|
/*
|
|
|
|
* Parsing a doc that looks like
|
|
|
|
*
|
|
|
|
* <qemuCaps>
|
|
|
|
* <qemuctime>234235253</qemuctime>
|
|
|
|
* <selfctime>234235253</selfctime>
|
2015-05-23 14:19:20 +00:00
|
|
|
* <selfvers>1002016</selfvers>
|
2014-03-05 16:51:59 +00:00
|
|
|
* <usedQMP/>
|
|
|
|
* <flag name='foo'/>
|
|
|
|
* <flag name='bar'/>
|
|
|
|
* ...
|
|
|
|
* <cpu name="pentium3"/>
|
|
|
|
* ...
|
2016-07-29 07:45:19 +00:00
|
|
|
* <machine name="pc-1.0" alias="pc" hotplugCpus='yes' maxCpus="4"/>
|
2014-03-05 16:51:59 +00:00
|
|
|
* ...
|
|
|
|
* </qemuCaps>
|
|
|
|
*/
|
2016-04-28 13:01:02 +00:00
|
|
|
int
|
2017-07-21 13:09:54 +00:00
|
|
|
virQEMUCapsLoadCache(virArch hostArch,
|
2016-06-15 12:35:18 +00:00
|
|
|
virQEMUCapsPtr qemuCaps,
|
2017-06-13 15:55:45 +00:00
|
|
|
const char *filename)
|
2014-03-05 16:51:59 +00:00
|
|
|
{
|
|
|
|
xmlDocPtr doc = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
size_t i;
|
|
|
|
int n;
|
|
|
|
xmlNodePtr *nodes = NULL;
|
|
|
|
xmlXPathContextPtr ctxt = NULL;
|
2014-03-19 16:13:19 +00:00
|
|
|
char *str = NULL;
|
2014-03-05 16:51:59 +00:00
|
|
|
long long int l;
|
2015-05-23 14:19:20 +00:00
|
|
|
unsigned long lu;
|
2014-03-05 16:51:59 +00:00
|
|
|
|
|
|
|
if (!(doc = virXMLParseFile(filename)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (!(ctxt = xmlXPathNewContext(doc))) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
ctxt->node = xmlDocGetRootElement(doc);
|
|
|
|
|
|
|
|
if (STRNEQ((const char *)ctxt->node->name, "qemuCaps")) {
|
|
|
|
virReportError(VIR_ERR_XML_ERROR,
|
|
|
|
_("unexpected root element <%s>, "
|
|
|
|
"expecting <qemuCaps>"),
|
|
|
|
ctxt->node->name);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (virXPathLongLong("string(./qemuctime)", ctxt, &l) < 0) {
|
|
|
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
|
|
_("missing qemuctime in QEMU capabilities XML"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2016-10-27 08:54:13 +00:00
|
|
|
qemuCaps->ctime = (time_t)l;
|
2014-03-05 16:51:59 +00:00
|
|
|
|
|
|
|
if (virXPathLongLong("string(./selfctime)", ctxt, &l) < 0) {
|
|
|
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
|
|
_("missing selfctime in QEMU capabilities XML"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2017-06-13 15:55:45 +00:00
|
|
|
qemuCaps->libvirtCtime = (time_t)l;
|
2014-03-05 16:51:59 +00:00
|
|
|
|
2017-06-13 15:55:45 +00:00
|
|
|
qemuCaps->libvirtVersion = 0;
|
2015-05-23 14:19:20 +00:00
|
|
|
if (virXPathULong("string(./selfvers)", ctxt, &lu) == 0)
|
2017-06-13 15:55:45 +00:00
|
|
|
qemuCaps->libvirtVersion = lu;
|
2015-05-23 14:19:20 +00:00
|
|
|
|
2014-03-05 16:51:59 +00:00
|
|
|
qemuCaps->usedQMP = virXPathBoolean("count(./usedQMP) > 0",
|
|
|
|
ctxt) > 0;
|
|
|
|
|
|
|
|
if ((n = virXPathNodeSet("./flag", ctxt, &nodes)) < 0) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("failed to parse qemu capabilities flags"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
VIR_DEBUG("Got flags %d", n);
|
2016-02-22 10:04:38 +00:00
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
int flag;
|
|
|
|
if (!(str = virXMLPropString(nodes[i], "name"))) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("missing flag name in QEMU capabilities cache"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
flag = virQEMUCapsTypeFromString(str);
|
|
|
|
if (flag < 0) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Unknown qemu capabilities flag %s"), str);
|
|
|
|
goto cleanup;
|
2014-03-05 16:51:59 +00:00
|
|
|
}
|
2016-02-22 10:04:38 +00:00
|
|
|
VIR_FREE(str);
|
|
|
|
virQEMUCapsSet(qemuCaps, flag);
|
2014-03-05 16:51:59 +00:00
|
|
|
}
|
|
|
|
VIR_FREE(nodes);
|
|
|
|
|
|
|
|
if (virXPathUInt("string(./version)", ctxt, &qemuCaps->version) < 0) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("missing version in QEMU capabilities cache"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (virXPathUInt("string(./kvmVersion)", ctxt, &qemuCaps->kvmVersion) < 0) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("missing version in QEMU capabilities cache"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2017-12-12 15:23:41 +00:00
|
|
|
if (virXPathUInt("string(./microcodeVersion)", ctxt,
|
|
|
|
&qemuCaps->microcodeVersion) < 0) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("missing microcode version in QEMU capabilities cache"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2016-08-04 20:43:22 +00:00
|
|
|
if (virXPathBoolean("boolean(./package)", ctxt) > 0) {
|
|
|
|
qemuCaps->package = virXPathString("string(./package)", ctxt);
|
|
|
|
if (!qemuCaps->package &&
|
|
|
|
VIR_STRDUP(qemuCaps->package, "") < 0)
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2015-02-02 10:28:30 +00:00
|
|
|
|
2018-01-22 10:37:04 +00:00
|
|
|
if (virXPathBoolean("boolean(./kernelVersion)", ctxt) > 0) {
|
|
|
|
qemuCaps->kernelVersion = virXPathString("string(./kernelVersion)", ctxt);
|
|
|
|
if (!qemuCaps->kernelVersion)
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2014-03-05 16:51:59 +00:00
|
|
|
if (!(str = virXPathString("string(./arch)", ctxt))) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("missing arch in QEMU capabilities cache"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
if (!(qemuCaps->arch = virArchFromString(str))) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("unknown arch %s in QEMU capabilities cache"), str);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2014-03-19 16:13:19 +00:00
|
|
|
VIR_FREE(str);
|
2014-03-05 16:51:59 +00:00
|
|
|
|
2017-02-22 15:51:50 +00:00
|
|
|
if (virQEMUCapsLoadHostCPUModelInfo(qemuCaps, ctxt, VIR_DOMAIN_VIRT_KVM) < 0 ||
|
|
|
|
virQEMUCapsLoadHostCPUModelInfo(qemuCaps, ctxt, VIR_DOMAIN_VIRT_QEMU) < 0)
|
2017-01-06 07:52:22 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2016-11-14 16:21:30 +00:00
|
|
|
if (virQEMUCapsLoadCPUModels(qemuCaps, ctxt, VIR_DOMAIN_VIRT_KVM) < 0 ||
|
|
|
|
virQEMUCapsLoadCPUModels(qemuCaps, ctxt, VIR_DOMAIN_VIRT_QEMU) < 0)
|
2014-03-05 16:51:59 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if ((n = virXPathNodeSet("./machine", ctxt, &nodes)) < 0) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("failed to parse qemu capabilities machines"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
if (n > 0) {
|
|
|
|
qemuCaps->nmachineTypes = n;
|
2016-07-29 08:13:46 +00:00
|
|
|
if (VIR_ALLOC_N(qemuCaps->machineTypes, qemuCaps->nmachineTypes) < 0)
|
2014-03-05 16:51:59 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
for (i = 0; i < n; i++) {
|
2016-07-29 08:13:46 +00:00
|
|
|
if (!(qemuCaps->machineTypes[i].name = virXMLPropString(nodes[i], "name"))) {
|
2014-03-05 16:51:59 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("missing machine name in QEMU capabilities cache"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2016-07-29 08:13:46 +00:00
|
|
|
qemuCaps->machineTypes[i].alias = virXMLPropString(nodes[i], "alias");
|
2014-03-05 16:51:59 +00:00
|
|
|
|
|
|
|
str = virXMLPropString(nodes[i], "maxCpus");
|
|
|
|
if (str &&
|
2016-07-29 08:13:46 +00:00
|
|
|
virStrToLong_ui(str, NULL, 10, &(qemuCaps->machineTypes[i].maxCpus)) < 0) {
|
2014-03-05 16:51:59 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("malformed machine cpu count in QEMU capabilities cache"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2014-03-19 16:13:19 +00:00
|
|
|
VIR_FREE(str);
|
2016-07-29 07:45:19 +00:00
|
|
|
|
|
|
|
str = virXMLPropString(nodes[i], "hotplugCpus");
|
|
|
|
if (STREQ_NULLABLE(str, "yes"))
|
|
|
|
qemuCaps->machineTypes[i].hotplugCpus = true;
|
|
|
|
VIR_FREE(str);
|
2014-03-05 16:51:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
VIR_FREE(nodes);
|
|
|
|
|
2016-03-10 16:59:51 +00:00
|
|
|
if ((n = virXPathNodeSet("./gic", ctxt, &nodes)) < 0) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("failed to parse qemu capabilities gic"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
if (n > 0) {
|
|
|
|
unsigned int uintValue;
|
|
|
|
bool boolValue;
|
|
|
|
|
|
|
|
qemuCaps->ngicCapabilities = n;
|
|
|
|
if (VIR_ALLOC_N(qemuCaps->gicCapabilities, n) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
virGICCapabilityPtr cap = &qemuCaps->gicCapabilities[i];
|
|
|
|
|
|
|
|
if (!(str = virXMLPropString(nodes[i], "version"))) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("missing GIC version "
|
|
|
|
"in QEMU capabilities cache"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
if (virStrToLong_ui(str, NULL, 10, &uintValue) < 0) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("malformed GIC version "
|
|
|
|
"in QEMU capabilities cache"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
cap->version = uintValue;
|
|
|
|
VIR_FREE(str);
|
|
|
|
|
|
|
|
if (!(str = virXMLPropString(nodes[i], "kernel"))) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("missing in-kernel GIC information "
|
|
|
|
"in QEMU capabilities cache"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
if (!(boolValue = STREQ(str, "yes")) && STRNEQ(str, "no")) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("malformed in-kernel GIC information "
|
|
|
|
"in QEMU capabilities cache"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
if (boolValue)
|
|
|
|
cap->implementation |= VIR_GIC_IMPLEMENTATION_KERNEL;
|
|
|
|
VIR_FREE(str);
|
|
|
|
|
|
|
|
if (!(str = virXMLPropString(nodes[i], "emulated"))) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("missing emulated GIC information "
|
|
|
|
"in QEMU capabilities cache"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
if (!(boolValue = STREQ(str, "yes")) && STRNEQ(str, "no")) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("malformed emulated GIC information "
|
|
|
|
"in QEMU capabilities cache"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
if (boolValue)
|
|
|
|
cap->implementation |= VIR_GIC_IMPLEMENTATION_EMULATED;
|
|
|
|
VIR_FREE(str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
VIR_FREE(nodes);
|
|
|
|
|
2017-07-21 13:09:54 +00:00
|
|
|
virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_KVM);
|
|
|
|
virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_QEMU);
|
2016-06-15 12:35:18 +00:00
|
|
|
|
2014-03-05 16:51:59 +00:00
|
|
|
ret = 0;
|
2014-03-25 06:49:44 +00:00
|
|
|
cleanup:
|
2014-03-19 16:13:19 +00:00
|
|
|
VIR_FREE(str);
|
2014-03-05 16:51:59 +00:00
|
|
|
VIR_FREE(nodes);
|
|
|
|
xmlXPathFreeContext(ctxt);
|
|
|
|
xmlFreeDoc(doc);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-13 17:42:57 +00:00
|
|
|
static void
|
|
|
|
virQEMUCapsFormatHostCPUModelInfo(virQEMUCapsPtr qemuCaps,
|
2017-02-22 15:51:50 +00:00
|
|
|
virBufferPtr buf,
|
|
|
|
virDomainVirtType type)
|
2017-01-13 17:42:57 +00:00
|
|
|
{
|
2017-04-07 16:15:26 +00:00
|
|
|
virQEMUCapsHostCPUDataPtr cpuData = virQEMUCapsGetHostCPUData(qemuCaps, type);
|
|
|
|
qemuMonitorCPUModelInfoPtr model = cpuData->info;
|
|
|
|
const char *typeStr = type == VIR_DOMAIN_VIRT_KVM ? "kvm" : "tcg";
|
2017-01-13 17:42:57 +00:00
|
|
|
size_t i;
|
|
|
|
|
2017-02-22 15:51:50 +00:00
|
|
|
if (!model)
|
|
|
|
return;
|
|
|
|
|
2017-03-29 08:33:08 +00:00
|
|
|
virBufferAsprintf(buf,
|
|
|
|
"<hostCPU type='%s' model='%s' migratability='%s'>\n",
|
|
|
|
typeStr, model->name,
|
|
|
|
model->migratability ? "yes" : "no");
|
2017-01-13 17:42:57 +00:00
|
|
|
virBufferAdjustIndent(buf, 2);
|
|
|
|
|
|
|
|
for (i = 0; i < model->nprops; i++) {
|
2017-02-22 15:01:30 +00:00
|
|
|
qemuMonitorCPUPropertyPtr prop = model->props + i;
|
|
|
|
|
|
|
|
virBufferAsprintf(buf, "<property name='%s' type='%s' ",
|
|
|
|
prop->name,
|
|
|
|
qemuMonitorCPUPropertyTypeToString(prop->type));
|
|
|
|
|
|
|
|
switch (prop->type) {
|
|
|
|
case QEMU_MONITOR_CPU_PROPERTY_BOOLEAN:
|
|
|
|
virBufferAsprintf(buf, "value='%s'",
|
|
|
|
prop->value.boolean ? "true" : "false");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case QEMU_MONITOR_CPU_PROPERTY_STRING:
|
|
|
|
virBufferEscapeString(buf, "value='%s'", prop->value.string);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case QEMU_MONITOR_CPU_PROPERTY_NUMBER:
|
|
|
|
virBufferAsprintf(buf, "value='%lld'", prop->value.number);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case QEMU_MONITOR_CPU_PROPERTY_LAST:
|
|
|
|
break;
|
|
|
|
}
|
2017-03-29 08:33:08 +00:00
|
|
|
|
|
|
|
if (prop->migratable > 0)
|
|
|
|
virBufferAsprintf(buf, " migratable='%s'",
|
|
|
|
virTristateBoolTypeToString(prop->migratable));
|
|
|
|
|
2017-02-22 15:01:30 +00:00
|
|
|
virBufferAddLit(buf, "/>\n");
|
2017-01-13 17:42:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virBufferAdjustIndent(buf, -2);
|
|
|
|
virBufferAddLit(buf, "</hostCPU>\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-11-14 20:51:31 +00:00
|
|
|
static void
|
|
|
|
virQEMUCapsFormatCPUModels(virQEMUCapsPtr qemuCaps,
|
2016-11-14 16:21:30 +00:00
|
|
|
virBufferPtr buf,
|
|
|
|
virDomainVirtType type)
|
2016-11-14 20:51:31 +00:00
|
|
|
{
|
2016-11-14 16:21:30 +00:00
|
|
|
virDomainCapsCPUModelsPtr cpus;
|
|
|
|
const char *typeStr;
|
2016-11-14 20:51:31 +00:00
|
|
|
size_t i;
|
|
|
|
|
2016-11-14 16:21:30 +00:00
|
|
|
if (type == VIR_DOMAIN_VIRT_KVM) {
|
|
|
|
typeStr = "kvm";
|
|
|
|
cpus = qemuCaps->kvmCPUModels;
|
|
|
|
} else {
|
|
|
|
typeStr = "tcg";
|
|
|
|
cpus = qemuCaps->tcgCPUModels;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!cpus)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < cpus->nmodels; i++) {
|
2016-04-21 11:08:12 +00:00
|
|
|
virDomainCapsCPUModelPtr cpu = cpus->models + i;
|
|
|
|
|
2016-11-14 16:21:30 +00:00
|
|
|
virBufferAsprintf(buf, "<cpu type='%s' ", typeStr);
|
2016-04-21 11:08:12 +00:00
|
|
|
virBufferEscapeString(buf, "name='%s'", cpu->name);
|
|
|
|
if (cpu->usable) {
|
|
|
|
virBufferAsprintf(buf, " usable='%s'",
|
|
|
|
virDomainCapsCPUUsableTypeToString(cpu->usable));
|
|
|
|
}
|
2017-09-21 14:11:14 +00:00
|
|
|
|
|
|
|
if (cpu->blockers) {
|
|
|
|
size_t j;
|
|
|
|
|
|
|
|
virBufferAddLit(buf, ">\n");
|
|
|
|
virBufferAdjustIndent(buf, 2);
|
|
|
|
|
|
|
|
for (j = 0; cpu->blockers[j]; j++)
|
|
|
|
virBufferAsprintf(buf, "<blocker name='%s'/>\n", cpu->blockers[j]);
|
|
|
|
|
|
|
|
virBufferAdjustIndent(buf, -2);
|
|
|
|
virBufferAddLit(buf, "</cpu>\n");
|
|
|
|
} else {
|
|
|
|
virBufferAddLit(buf, "/>\n");
|
|
|
|
}
|
2016-11-14 20:51:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-28 13:01:02 +00:00
|
|
|
char *
|
2017-06-13 15:55:45 +00:00
|
|
|
virQEMUCapsFormatCache(virQEMUCapsPtr qemuCaps)
|
2014-03-05 16:51:59 +00:00
|
|
|
{
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
2016-04-28 12:59:15 +00:00
|
|
|
char *ret = NULL;
|
2014-03-05 16:51:59 +00:00
|
|
|
size_t i;
|
|
|
|
|
|
|
|
virBufferAddLit(&buf, "<qemuCaps>\n");
|
2014-03-13 00:35:01 +00:00
|
|
|
virBufferAdjustIndent(&buf, 2);
|
2014-03-05 16:51:59 +00:00
|
|
|
|
2014-03-13 00:35:01 +00:00
|
|
|
virBufferAsprintf(&buf, "<qemuctime>%llu</qemuctime>\n",
|
2018-04-25 12:42:34 +00:00
|
|
|
(long long)qemuCaps->ctime);
|
2014-03-13 00:35:01 +00:00
|
|
|
virBufferAsprintf(&buf, "<selfctime>%llu</selfctime>\n",
|
2018-04-25 12:42:34 +00:00
|
|
|
(long long)qemuCaps->libvirtCtime);
|
2015-05-23 14:19:20 +00:00
|
|
|
virBufferAsprintf(&buf, "<selfvers>%lu</selfvers>\n",
|
2018-04-25 12:42:34 +00:00
|
|
|
(unsigned long)qemuCaps->libvirtVersion);
|
2014-03-05 16:51:59 +00:00
|
|
|
|
|
|
|
if (qemuCaps->usedQMP)
|
2014-03-13 00:35:01 +00:00
|
|
|
virBufferAddLit(&buf, "<usedQMP/>\n");
|
2014-03-05 16:51:59 +00:00
|
|
|
|
|
|
|
for (i = 0; i < QEMU_CAPS_LAST; i++) {
|
|
|
|
if (virQEMUCapsGet(qemuCaps, i)) {
|
2014-03-13 00:35:01 +00:00
|
|
|
virBufferAsprintf(&buf, "<flag name='%s'/>\n",
|
2014-03-05 16:51:59 +00:00
|
|
|
virQEMUCapsTypeToString(i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-13 00:35:01 +00:00
|
|
|
virBufferAsprintf(&buf, "<version>%d</version>\n",
|
2014-03-05 16:51:59 +00:00
|
|
|
qemuCaps->version);
|
|
|
|
|
2014-03-13 00:35:01 +00:00
|
|
|
virBufferAsprintf(&buf, "<kvmVersion>%d</kvmVersion>\n",
|
2014-03-05 16:51:59 +00:00
|
|
|
qemuCaps->kvmVersion);
|
|
|
|
|
2017-12-12 15:23:41 +00:00
|
|
|
virBufferAsprintf(&buf, "<microcodeVersion>%u</microcodeVersion>\n",
|
|
|
|
qemuCaps->microcodeVersion);
|
|
|
|
|
2015-02-02 10:28:30 +00:00
|
|
|
if (qemuCaps->package)
|
|
|
|
virBufferAsprintf(&buf, "<package>%s</package>\n",
|
|
|
|
qemuCaps->package);
|
|
|
|
|
2018-01-22 10:37:04 +00:00
|
|
|
if (qemuCaps->kernelVersion)
|
|
|
|
virBufferAsprintf(&buf, "<kernelVersion>%s</kernelVersion>\n",
|
|
|
|
qemuCaps->kernelVersion);
|
|
|
|
|
2014-03-13 00:35:01 +00:00
|
|
|
virBufferAsprintf(&buf, "<arch>%s</arch>\n",
|
2014-03-05 16:51:59 +00:00
|
|
|
virArchToString(qemuCaps->arch));
|
|
|
|
|
2017-02-22 15:51:50 +00:00
|
|
|
virQEMUCapsFormatHostCPUModelInfo(qemuCaps, &buf, VIR_DOMAIN_VIRT_KVM);
|
|
|
|
virQEMUCapsFormatHostCPUModelInfo(qemuCaps, &buf, VIR_DOMAIN_VIRT_QEMU);
|
2017-01-06 07:52:22 +00:00
|
|
|
|
2016-11-14 16:21:30 +00:00
|
|
|
virQEMUCapsFormatCPUModels(qemuCaps, &buf, VIR_DOMAIN_VIRT_KVM);
|
|
|
|
virQEMUCapsFormatCPUModels(qemuCaps, &buf, VIR_DOMAIN_VIRT_QEMU);
|
2014-03-05 16:51:59 +00:00
|
|
|
|
|
|
|
for (i = 0; i < qemuCaps->nmachineTypes; i++) {
|
2014-03-13 00:35:01 +00:00
|
|
|
virBufferEscapeString(&buf, "<machine name='%s'",
|
2016-07-29 08:13:46 +00:00
|
|
|
qemuCaps->machineTypes[i].name);
|
|
|
|
if (qemuCaps->machineTypes[i].alias)
|
2014-03-05 16:51:59 +00:00
|
|
|
virBufferEscapeString(&buf, " alias='%s'",
|
2016-07-29 08:13:46 +00:00
|
|
|
qemuCaps->machineTypes[i].alias);
|
2016-07-29 07:45:19 +00:00
|
|
|
if (qemuCaps->machineTypes[i].hotplugCpus)
|
|
|
|
virBufferAddLit(&buf, " hotplugCpus='yes'");
|
2014-03-05 16:51:59 +00:00
|
|
|
virBufferAsprintf(&buf, " maxCpus='%u'/>\n",
|
2016-07-29 08:13:46 +00:00
|
|
|
qemuCaps->machineTypes[i].maxCpus);
|
2014-03-05 16:51:59 +00:00
|
|
|
}
|
|
|
|
|
2016-03-10 16:59:51 +00:00
|
|
|
for (i = 0; i < qemuCaps->ngicCapabilities; i++) {
|
|
|
|
virGICCapabilityPtr cap;
|
|
|
|
bool kernel;
|
|
|
|
bool emulated;
|
|
|
|
|
|
|
|
cap = &qemuCaps->gicCapabilities[i];
|
|
|
|
kernel = (cap->implementation & VIR_GIC_IMPLEMENTATION_KERNEL);
|
|
|
|
emulated = (cap->implementation & VIR_GIC_IMPLEMENTATION_EMULATED);
|
|
|
|
|
|
|
|
virBufferAsprintf(&buf,
|
|
|
|
"<gic version='%d' kernel='%s' emulated='%s'/>\n",
|
|
|
|
cap->version,
|
|
|
|
kernel ? "yes" : "no",
|
|
|
|
emulated ? "yes" : "no");
|
|
|
|
}
|
|
|
|
|
2014-03-13 00:35:01 +00:00
|
|
|
virBufferAdjustIndent(&buf, -2);
|
2014-03-05 16:51:59 +00:00
|
|
|
virBufferAddLit(&buf, "</qemuCaps>\n");
|
|
|
|
|
2016-04-28 12:59:15 +00:00
|
|
|
if (virBufferCheckError(&buf) == 0)
|
|
|
|
ret = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2017-07-19 15:01:56 +00:00
|
|
|
virQEMUCapsSaveFile(void *data,
|
|
|
|
const char *filename,
|
|
|
|
void *privData ATTRIBUTE_UNUSED)
|
2016-04-28 12:59:15 +00:00
|
|
|
{
|
2017-07-19 15:01:56 +00:00
|
|
|
virQEMUCapsPtr qemuCaps = data;
|
2016-04-28 12:59:15 +00:00
|
|
|
char *xml = NULL;
|
|
|
|
int ret = -1;
|
2014-03-05 16:51:59 +00:00
|
|
|
|
2017-06-13 15:55:45 +00:00
|
|
|
xml = virQEMUCapsFormatCache(qemuCaps);
|
2014-03-05 16:51:59 +00:00
|
|
|
|
|
|
|
if (virFileWriteStr(filename, xml, 0600) < 0) {
|
|
|
|
virReportSystemError(errno,
|
|
|
|
_("Failed to save '%s' for '%s'"),
|
|
|
|
filename, qemuCaps->binary);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
VIR_DEBUG("Saved caps '%s' for '%s' with (%lld, %lld)",
|
|
|
|
filename, qemuCaps->binary,
|
|
|
|
(long long)qemuCaps->ctime,
|
2017-06-13 15:55:45 +00:00
|
|
|
(long long)qemuCaps->libvirtCtime);
|
2014-03-05 16:51:59 +00:00
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
cleanup:
|
|
|
|
VIR_FREE(xml);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-06-19 12:03:06 +00:00
|
|
|
static bool
|
2017-07-19 15:01:56 +00:00
|
|
|
virQEMUCapsIsValid(void *data,
|
|
|
|
void *privData)
|
2017-06-19 12:03:06 +00:00
|
|
|
{
|
2017-07-19 15:01:56 +00:00
|
|
|
virQEMUCapsPtr qemuCaps = data;
|
|
|
|
virQEMUCapsCachePrivPtr priv = privData;
|
2017-06-19 12:03:06 +00:00
|
|
|
bool kvmUsable;
|
2017-06-22 10:53:26 +00:00
|
|
|
struct stat sb;
|
2017-06-19 12:03:06 +00:00
|
|
|
|
|
|
|
if (!qemuCaps->binary)
|
|
|
|
return true;
|
|
|
|
|
2017-06-22 10:52:35 +00:00
|
|
|
if (qemuCaps->libvirtCtime != virGetSelfLastChanged() ||
|
|
|
|
qemuCaps->libvirtVersion != LIBVIR_VERSION_NUMBER) {
|
|
|
|
VIR_DEBUG("Outdated capabilities for '%s': libvirt changed "
|
|
|
|
"(%lld vs %lld, %lu vs %lu)",
|
|
|
|
qemuCaps->binary,
|
|
|
|
(long long)qemuCaps->libvirtCtime,
|
|
|
|
(long long)virGetSelfLastChanged(),
|
|
|
|
(unsigned long)qemuCaps->libvirtVersion,
|
|
|
|
(unsigned long)LIBVIR_VERSION_NUMBER);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-06-22 10:53:26 +00:00
|
|
|
if (stat(qemuCaps->binary, &sb) < 0) {
|
|
|
|
char ebuf[1024];
|
|
|
|
VIR_DEBUG("Failed to stat QEMU binary '%s': %s",
|
|
|
|
qemuCaps->binary,
|
|
|
|
virStrerror(errno, ebuf, sizeof(ebuf)));
|
|
|
|
return false;
|
2017-06-19 12:03:06 +00:00
|
|
|
}
|
|
|
|
|
2017-06-22 10:53:26 +00:00
|
|
|
if (sb.st_ctime != qemuCaps->ctime) {
|
2017-06-19 12:03:06 +00:00
|
|
|
VIR_DEBUG("Outdated capabilities for '%s': QEMU binary changed "
|
|
|
|
"(%lld vs %lld)",
|
|
|
|
qemuCaps->binary,
|
2018-04-25 12:42:34 +00:00
|
|
|
(long long)sb.st_ctime, (long long)qemuCaps->ctime);
|
2017-06-19 12:03:06 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
kvmUsable = virFileAccessibleAs("/dev/kvm", R_OK | W_OK,
|
2017-06-20 14:17:23 +00:00
|
|
|
priv->runUid, priv->runGid) == 0;
|
2017-06-19 12:03:06 +00:00
|
|
|
|
|
|
|
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM) &&
|
|
|
|
virQEMUCapsGet(qemuCaps, QEMU_CAPS_ENABLE_KVM) &&
|
|
|
|
kvmUsable) {
|
|
|
|
VIR_DEBUG("KVM was not enabled when probing '%s', "
|
|
|
|
"but it should be usable now",
|
|
|
|
qemuCaps->binary);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM) &&
|
|
|
|
!kvmUsable) {
|
|
|
|
VIR_DEBUG("KVM was enabled when probing '%s', "
|
|
|
|
"but it is not available now",
|
|
|
|
qemuCaps->binary);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-01-22 10:37:04 +00:00
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) {
|
|
|
|
if (priv->microcodeVersion != qemuCaps->microcodeVersion) {
|
|
|
|
VIR_DEBUG("Outdated capabilities for '%s': microcode version "
|
|
|
|
"changed (%u vs %u)",
|
|
|
|
qemuCaps->binary,
|
|
|
|
priv->microcodeVersion,
|
|
|
|
qemuCaps->microcodeVersion);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (STRNEQ_NULLABLE(priv->kernelVersion, qemuCaps->kernelVersion)) {
|
|
|
|
VIR_DEBUG("Outdated capabilities for '%s': kernel version changed "
|
|
|
|
"('%s' vs '%s')",
|
|
|
|
qemuCaps->binary,
|
|
|
|
priv->kernelVersion,
|
|
|
|
qemuCaps->kernelVersion);
|
|
|
|
return false;
|
|
|
|
}
|
2017-12-12 15:23:41 +00:00
|
|
|
}
|
|
|
|
|
2017-06-19 12:03:06 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
static void virQEMUCapsMonitorNotify(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
2013-07-25 17:26:15 +00:00
|
|
|
virDomainObjPtr vm ATTRIBUTE_UNUSED,
|
|
|
|
void *opaque ATTRIBUTE_UNUSED)
|
2012-08-22 17:05:08 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static qemuMonitorCallbacks callbacks = {
|
2013-02-01 13:48:58 +00:00
|
|
|
.eofNotify = virQEMUCapsMonitorNotify,
|
|
|
|
.errorNotify = virQEMUCapsMonitorNotify,
|
2012-08-22 17:05:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2017-03-27 14:42:17 +00:00
|
|
|
/**
|
|
|
|
* virQEMUCapsInitQMPArch:
|
|
|
|
* @qemuCaps: QEMU capabilities
|
|
|
|
* @mon: QEMU monitor
|
|
|
|
*
|
|
|
|
* Initialize the architecture for @qemuCaps by asking @mon.
|
|
|
|
*
|
|
|
|
* Returns: 0 on success, <0 on failure
|
2013-05-07 11:34:27 +00:00
|
|
|
*/
|
|
|
|
static int
|
2017-03-27 14:42:17 +00:00
|
|
|
virQEMUCapsInitQMPArch(virQEMUCapsPtr qemuCaps,
|
2013-05-07 11:34:27 +00:00
|
|
|
qemuMonitorPtr mon)
|
|
|
|
{
|
|
|
|
char *archstr = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
if (!(archstr = qemuMonitorGetTargetArch(mon)))
|
2017-03-27 14:42:17 +00:00
|
|
|
goto cleanup;
|
2013-05-07 11:34:27 +00:00
|
|
|
|
|
|
|
if ((qemuCaps->arch = virQEMUCapsArchFromString(archstr)) == VIR_ARCH_NONE) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Unknown QEMU arch %s"), archstr);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2017-03-27 14:42:17 +00:00
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
VIR_FREE(archstr);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* virQEMUCapsInitQMPBasicArch:
|
|
|
|
* @qemuCaps: QEMU capabilities
|
|
|
|
*
|
|
|
|
* Initialize @qemuCaps with basic architecture-dependent capabilities.
|
|
|
|
*/
|
2017-03-02 18:24:22 +00:00
|
|
|
void
|
2017-03-27 14:42:17 +00:00
|
|
|
virQEMUCapsInitQMPBasicArch(virQEMUCapsPtr qemuCaps)
|
|
|
|
{
|
2017-03-02 17:57:51 +00:00
|
|
|
/* ACPI only works on x86 and aarch64 */
|
|
|
|
if (ARCH_IS_X86(qemuCaps->arch) ||
|
|
|
|
qemuCaps->arch == VIR_ARCH_AARCH64) {
|
2013-05-07 11:34:27 +00:00
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_NO_ACPI);
|
2017-03-02 17:57:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* HPET and KVM PIT are x86 specific */
|
|
|
|
if (ARCH_IS_X86(qemuCaps->arch)) {
|
2014-04-17 14:50:43 +00:00
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_NO_HPET);
|
2013-05-07 11:34:27 +00:00
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_NO_KVM_PIT);
|
|
|
|
}
|
|
|
|
}
|
2012-08-22 17:05:08 +00:00
|
|
|
|
2016-10-19 12:40:53 +00:00
|
|
|
|
|
|
|
static int
|
|
|
|
virQEMUCapsProbeQMPSchemaCapabilities(virQEMUCapsPtr qemuCaps,
|
|
|
|
qemuMonitorPtr mon)
|
|
|
|
{
|
|
|
|
struct virQEMUCapsStringFlags *entry;
|
2018-03-20 08:29:30 +00:00
|
|
|
virJSONValuePtr schemareply;
|
|
|
|
virHashTablePtr schema = NULL;
|
2016-10-19 12:40:53 +00:00
|
|
|
size_t i;
|
|
|
|
|
2018-03-20 08:29:30 +00:00
|
|
|
if (!(schemareply = qemuMonitorQueryQMPSchema(mon)))
|
2016-10-19 12:40:53 +00:00
|
|
|
return -1;
|
|
|
|
|
2018-03-20 08:29:30 +00:00
|
|
|
if (!(schema = virQEMUQAPISchemaConvert(schemareply)))
|
|
|
|
return -1;
|
|
|
|
schemareply = NULL;
|
|
|
|
|
2016-10-19 12:40:53 +00:00
|
|
|
for (i = 0; i < ARRAY_CARDINALITY(virQEMUCapsQMPSchemaQueries); i++) {
|
|
|
|
entry = virQEMUCapsQMPSchemaQueries + i;
|
|
|
|
|
2018-03-20 07:57:44 +00:00
|
|
|
if (virQEMUQAPISchemaPathExists(entry->value, schema))
|
2016-10-19 12:40:53 +00:00
|
|
|
virQEMUCapsSet(qemuCaps, entry->flag);
|
|
|
|
}
|
|
|
|
|
|
|
|
virHashFree(schema);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-03-28 20:46:41 +00:00
|
|
|
#define QEMU_MIN_MAJOR 1
|
2018-04-10 12:52:47 +00:00
|
|
|
#define QEMU_MIN_MINOR 5
|
2018-03-28 20:46:41 +00:00
|
|
|
#define QEMU_MIN_MICRO 0
|
2016-10-19 12:40:53 +00:00
|
|
|
|
2013-09-19 11:14:25 +00:00
|
|
|
int
|
|
|
|
virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps,
|
|
|
|
qemuMonitorPtr mon)
|
|
|
|
{
|
|
|
|
int ret = -1;
|
|
|
|
int major, minor, micro;
|
|
|
|
char *package = NULL;
|
|
|
|
|
|
|
|
/* @mon is supposed to be locked by callee */
|
|
|
|
|
|
|
|
if (qemuMonitorSetCapabilities(mon) < 0) {
|
|
|
|
VIR_DEBUG("Failed to set monitor capabilities %s",
|
2016-03-23 18:31:50 +00:00
|
|
|
virGetLastErrorMessage());
|
2013-09-19 11:14:25 +00:00
|
|
|
ret = 0;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (qemuMonitorGetVersion(mon,
|
|
|
|
&major, &minor, µ,
|
|
|
|
&package) < 0) {
|
|
|
|
VIR_DEBUG("Failed to query monitor version %s",
|
2016-03-23 18:31:50 +00:00
|
|
|
virGetLastErrorMessage());
|
2013-09-19 11:14:25 +00:00
|
|
|
ret = 0;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
VIR_DEBUG("Got version %d.%d.%d (%s)",
|
|
|
|
major, minor, micro, NULLSTR(package));
|
|
|
|
|
2018-03-28 20:46:41 +00:00
|
|
|
if (major < QEMU_MIN_MAJOR ||
|
|
|
|
(major == QEMU_MIN_MAJOR && minor < QEMU_MIN_MINOR)) {
|
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
|
|
_("QEMU version >= %d.%d.%d is required, but %d.%d.%d found"),
|
|
|
|
QEMU_MIN_MAJOR, QEMU_MIN_MINOR, QEMU_MIN_MICRO,
|
|
|
|
major, minor, micro);
|
2013-09-19 11:14:25 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
qemuCaps->version = major * 1000000 + minor * 1000 + micro;
|
2015-02-02 10:28:30 +00:00
|
|
|
qemuCaps->package = package;
|
2013-09-19 11:14:25 +00:00
|
|
|
qemuCaps->usedQMP = true;
|
|
|
|
|
2017-03-27 14:42:17 +00:00
|
|
|
if (virQEMUCapsInitQMPArch(qemuCaps, mon) < 0)
|
2013-09-19 11:14:25 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2017-03-27 14:42:17 +00:00
|
|
|
virQEMUCapsInitQMPBasicArch(qemuCaps);
|
|
|
|
|
2013-09-19 11:14:25 +00:00
|
|
|
/* WebSockets were introduced between 1.3.0 and 1.3.1 */
|
|
|
|
if (qemuCaps->version >= 1003001)
|
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_VNC_WEBSOCKET);
|
|
|
|
|
2014-01-30 11:19:12 +00:00
|
|
|
/* -chardev spiceport is supported from 1.4.0, but usable through
|
|
|
|
* qapi only since 1.5.0, however, it still cannot be queried
|
|
|
|
* for as a capability */
|
|
|
|
if (qemuCaps->version >= 1005000)
|
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_CHARDEV_SPICEPORT);
|
|
|
|
|
2013-09-19 11:14:25 +00:00
|
|
|
if (qemuCaps->version >= 1006000)
|
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
|
|
|
|
|
2015-04-02 16:43:47 +00:00
|
|
|
/* vmport option is supported v2.2.0 onwards */
|
|
|
|
if (qemuCaps->version >= 2002000)
|
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_VMPORT_OPT);
|
|
|
|
|
2015-05-21 22:18:20 +00:00
|
|
|
/* -cpu ...,aarch64=off supported in v2.3.0 and onwards. But it
|
|
|
|
isn't detectable via qmp at this point */
|
|
|
|
if (qemuCaps->arch == VIR_ARCH_AARCH64 &&
|
|
|
|
qemuCaps->version >= 2003000)
|
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_CPU_AARCH64_OFF);
|
|
|
|
|
2015-06-04 09:37:37 +00:00
|
|
|
/* vhost-user supports multi-queue from v2.4.0 onwards,
|
|
|
|
* but there is no way to query for that capability */
|
|
|
|
if (qemuCaps->version >= 2004000)
|
2015-06-15 08:38:21 +00:00
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_VHOSTUSER_MULTIQUEUE);
|
2015-06-04 09:37:37 +00:00
|
|
|
|
2016-07-13 12:09:20 +00:00
|
|
|
/* smm option is supported from v2.4.0 */
|
|
|
|
if (qemuCaps->version >= 2004000)
|
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_SMM_OPT);
|
|
|
|
|
2015-09-30 11:04:09 +00:00
|
|
|
/* Since 2.4.50 ARM virt machine supports gic-version option */
|
|
|
|
if (qemuCaps->version >= 2004050)
|
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACH_VIRT_GIC_VERSION);
|
|
|
|
|
2017-03-17 07:26:49 +00:00
|
|
|
/* no way to query if -machine kernel_irqchip supports split */
|
|
|
|
if (qemuCaps->version >= 2006000)
|
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_KERNEL_IRQCHIP_SPLIT);
|
|
|
|
|
2017-11-06 15:39:40 +00:00
|
|
|
/* HPT resizing is supported since QEMU 2.10 on ppc64; unfortunately
|
|
|
|
* there's no sane way to probe for it */
|
|
|
|
if (qemuCaps->version >= 2010000 &&
|
|
|
|
ARCH_IS_PPC64(qemuCaps->arch)) {
|
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
|
|
|
|
}
|
|
|
|
|
2017-11-14 13:29:20 +00:00
|
|
|
/* no way to query for -numa dist */
|
|
|
|
if (qemuCaps->version >= 2010000)
|
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_NUMA_DIST);
|
|
|
|
|
2018-01-05 13:47:46 +00:00
|
|
|
/* no way to query max-cpu-compat */
|
|
|
|
if (qemuCaps->version >= 2010000 &&
|
|
|
|
ARCH_IS_PPC64(qemuCaps->arch)) {
|
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_PSERIES_MAX_CPU_COMPAT);
|
|
|
|
}
|
|
|
|
|
2013-09-19 11:14:25 +00:00
|
|
|
if (virQEMUCapsProbeQMPCommands(qemuCaps, mon) < 0)
|
|
|
|
goto cleanup;
|
2016-06-10 17:14:52 +00:00
|
|
|
|
|
|
|
/* Some capabilities may differ depending on KVM state */
|
|
|
|
if (virQEMUCapsProbeQMPKVMState(qemuCaps, mon) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2013-09-19 11:14:25 +00:00
|
|
|
if (virQEMUCapsProbeQMPEvents(qemuCaps, mon) < 0)
|
|
|
|
goto cleanup;
|
2018-04-12 11:31:03 +00:00
|
|
|
if (virQEMUCapsProbeQMPDevices(qemuCaps, mon) < 0)
|
2013-09-19 11:14:25 +00:00
|
|
|
goto cleanup;
|
|
|
|
if (virQEMUCapsProbeQMPMachineTypes(qemuCaps, mon) < 0)
|
|
|
|
goto cleanup;
|
2016-11-14 16:21:30 +00:00
|
|
|
if (virQEMUCapsProbeQMPCPUDefinitions(qemuCaps, mon, false) < 0)
|
2013-09-19 11:14:25 +00:00
|
|
|
goto cleanup;
|
|
|
|
if (virQEMUCapsProbeQMPTPM(qemuCaps, mon) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
if (virQEMUCapsProbeQMPCommandLine(qemuCaps, mon) < 0)
|
|
|
|
goto cleanup;
|
2014-09-11 12:11:54 +00:00
|
|
|
if (virQEMUCapsProbeQMPMigrationCapabilities(qemuCaps, mon) < 0)
|
|
|
|
goto cleanup;
|
2016-10-19 12:40:53 +00:00
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_QMP_SCHEMA) &&
|
|
|
|
virQEMUCapsProbeQMPSchemaCapabilities(qemuCaps, mon) < 0)
|
|
|
|
goto cleanup;
|
2017-02-22 15:51:50 +00:00
|
|
|
if (virQEMUCapsProbeQMPHostCPU(qemuCaps, mon, false) < 0)
|
2017-01-06 07:52:22 +00:00
|
|
|
goto cleanup;
|
2013-09-19 11:14:25 +00:00
|
|
|
|
2016-10-03 12:31:12 +00:00
|
|
|
/* 'intel-iommu' shows up as a device since 2.2.0, but can
|
|
|
|
* not be used with -device until 2.7.0. Before that it
|
|
|
|
* requires -machine iommu=on. So we must clear the device
|
|
|
|
* capability we detected on older QEMUs
|
|
|
|
*/
|
|
|
|
if (qemuCaps->version < 2007000 &&
|
|
|
|
virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_INTEL_IOMMU)) {
|
|
|
|
virQEMUCapsClear(qemuCaps, QEMU_CAPS_DEVICE_INTEL_IOMMU);
|
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_IOMMU);
|
|
|
|
}
|
|
|
|
|
2016-03-08 17:24:18 +00:00
|
|
|
/* GIC capabilities, eg. available GIC versions */
|
|
|
|
if ((qemuCaps->arch == VIR_ARCH_AARCH64 ||
|
|
|
|
qemuCaps->arch == VIR_ARCH_ARMV7L) &&
|
|
|
|
virQEMUCapsProbeQMPGICCapabilities(qemuCaps, mon) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2016-07-29 06:17:42 +00:00
|
|
|
/* Prealloc on NVDIMMs is broken on older QEMUs leading to
|
|
|
|
* user data corruption. If we are dealing with such version
|
|
|
|
* of QEMU pretend we don't know how to NVDIMM. */
|
|
|
|
if (qemuCaps->version < 2009000 &&
|
|
|
|
virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_NVDIMM))
|
|
|
|
virQEMUCapsClear(qemuCaps, QEMU_CAPS_DEVICE_NVDIMM);
|
|
|
|
|
2017-04-25 17:07:19 +00:00
|
|
|
if (ARCH_IS_X86(qemuCaps->arch) &&
|
|
|
|
virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION))
|
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_CPU_CACHE);
|
|
|
|
|
2013-09-19 11:14:25 +00:00
|
|
|
ret = 0;
|
2014-03-25 06:49:44 +00:00
|
|
|
cleanup:
|
2013-09-19 11:14:25 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-07-22 17:38:37 +00:00
|
|
|
|
2016-06-10 15:16:21 +00:00
|
|
|
int
|
|
|
|
virQEMUCapsInitQMPMonitorTCG(virQEMUCapsPtr qemuCaps ATTRIBUTE_UNUSED,
|
|
|
|
qemuMonitorPtr mon)
|
|
|
|
{
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
if (qemuMonitorSetCapabilities(mon) < 0) {
|
|
|
|
VIR_DEBUG("Failed to set monitor capabilities %s",
|
|
|
|
virGetLastErrorMessage());
|
|
|
|
ret = 0;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2016-11-14 16:21:30 +00:00
|
|
|
if (virQEMUCapsProbeQMPCPUDefinitions(qemuCaps, mon, true) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2017-02-22 15:51:50 +00:00
|
|
|
if (virQEMUCapsProbeQMPHostCPU(qemuCaps, mon, true) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2016-06-10 15:16:21 +00:00
|
|
|
ret = 0;
|
|
|
|
cleanup:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-22 17:38:37 +00:00
|
|
|
typedef struct _virQEMUCapsInitQMPCommand virQEMUCapsInitQMPCommand;
|
|
|
|
typedef virQEMUCapsInitQMPCommand *virQEMUCapsInitQMPCommandPtr;
|
|
|
|
struct _virQEMUCapsInitQMPCommand {
|
|
|
|
char *binary;
|
|
|
|
uid_t runUid;
|
|
|
|
gid_t runGid;
|
|
|
|
char **qmperr;
|
|
|
|
char *monarg;
|
|
|
|
char *monpath;
|
|
|
|
char *pidfile;
|
|
|
|
virCommandPtr cmd;
|
|
|
|
qemuMonitorPtr mon;
|
2012-08-22 17:05:08 +00:00
|
|
|
virDomainChrSourceDef config;
|
2013-07-22 17:38:37 +00:00
|
|
|
pid_t pid;
|
|
|
|
virDomainObjPtr vm;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
virQEMUCapsInitQMPCommandAbort(virQEMUCapsInitQMPCommandPtr cmd)
|
|
|
|
{
|
|
|
|
if (cmd->mon)
|
|
|
|
virObjectUnlock(cmd->mon);
|
|
|
|
qemuMonitorClose(cmd->mon);
|
|
|
|
cmd->mon = NULL;
|
|
|
|
|
|
|
|
virCommandAbort(cmd->cmd);
|
|
|
|
virCommandFree(cmd->cmd);
|
|
|
|
cmd->cmd = NULL;
|
|
|
|
|
|
|
|
if (cmd->monpath)
|
|
|
|
ignore_value(unlink(cmd->monpath));
|
|
|
|
|
|
|
|
virDomainObjEndAPI(&cmd->vm);
|
|
|
|
|
|
|
|
if (cmd->pid != 0) {
|
|
|
|
char ebuf[1024];
|
|
|
|
|
2018-04-25 12:42:34 +00:00
|
|
|
VIR_DEBUG("Killing QMP caps process %lld", (long long)cmd->pid);
|
2013-07-22 17:38:37 +00:00
|
|
|
if (virProcessKill(cmd->pid, SIGKILL) < 0 && errno != ESRCH)
|
|
|
|
VIR_ERROR(_("Failed to kill process %lld: %s"),
|
2018-04-25 12:42:34 +00:00
|
|
|
(long long)cmd->pid,
|
2013-07-22 17:38:37 +00:00
|
|
|
virStrerror(errno, ebuf, sizeof(ebuf)));
|
|
|
|
|
|
|
|
VIR_FREE(*cmd->qmperr);
|
|
|
|
}
|
|
|
|
if (cmd->pidfile)
|
|
|
|
unlink(cmd->pidfile);
|
|
|
|
cmd->pid = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
virQEMUCapsInitQMPCommandFree(virQEMUCapsInitQMPCommandPtr cmd)
|
|
|
|
{
|
|
|
|
if (!cmd)
|
|
|
|
return;
|
|
|
|
|
|
|
|
virQEMUCapsInitQMPCommandAbort(cmd);
|
|
|
|
VIR_FREE(cmd->binary);
|
|
|
|
VIR_FREE(cmd->monpath);
|
|
|
|
VIR_FREE(cmd->monarg);
|
|
|
|
VIR_FREE(cmd->pidfile);
|
|
|
|
VIR_FREE(cmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static virQEMUCapsInitQMPCommandPtr
|
|
|
|
virQEMUCapsInitQMPCommandNew(char *binary,
|
|
|
|
const char *libDir,
|
|
|
|
uid_t runUid,
|
|
|
|
gid_t runGid,
|
|
|
|
char **qmperr)
|
|
|
|
{
|
|
|
|
virQEMUCapsInitQMPCommandPtr cmd = NULL;
|
|
|
|
|
|
|
|
if (VIR_ALLOC(cmd) < 0)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
if (VIR_STRDUP(cmd->binary, binary) < 0)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
cmd->runUid = runUid;
|
|
|
|
cmd->runGid = runGid;
|
|
|
|
cmd->qmperr = qmperr;
|
2012-08-22 17:05:08 +00:00
|
|
|
|
2012-10-02 08:59:56 +00:00
|
|
|
/* the ".sock" sufix is important to avoid a possible clash with a qemu
|
|
|
|
* domain called "capabilities"
|
|
|
|
*/
|
2013-07-22 17:38:37 +00:00
|
|
|
if (virAsprintf(&cmd->monpath, "%s/%s", libDir,
|
|
|
|
"capabilities.monitor.sock") < 0)
|
|
|
|
goto error;
|
|
|
|
if (virAsprintf(&cmd->monarg, "unix:%s,server,nowait", cmd->monpath) < 0)
|
|
|
|
goto error;
|
2012-08-22 17:05:08 +00:00
|
|
|
|
2012-10-02 08:59:56 +00:00
|
|
|
/* ".pidfile" suffix is used rather than ".pid" to avoid a possible clash
|
|
|
|
* with a qemu domain called "capabilities"
|
2013-01-24 18:21:23 +00:00
|
|
|
* Normally we'd use runDir for pid files, but because we're using
|
|
|
|
* -daemonize we need QEMU to be allowed to create them, rather
|
|
|
|
* than libvirtd. So we're using libDir which QEMU can write to
|
2012-10-02 08:59:56 +00:00
|
|
|
*/
|
2013-07-22 17:38:37 +00:00
|
|
|
if (virAsprintf(&cmd->pidfile, "%s/%s", libDir, "capabilities.pidfile") < 0)
|
|
|
|
goto error;
|
2012-10-02 08:59:56 +00:00
|
|
|
|
2013-07-22 17:38:37 +00:00
|
|
|
virPidFileForceCleanupPath(cmd->pidfile);
|
2012-08-22 17:05:08 +00:00
|
|
|
|
2013-07-22 17:38:37 +00:00
|
|
|
cmd->config.type = VIR_DOMAIN_CHR_TYPE_UNIX;
|
|
|
|
cmd->config.data.nix.path = cmd->monpath;
|
|
|
|
cmd->config.data.nix.listen = false;
|
2014-10-09 06:18:33 +00:00
|
|
|
|
2013-07-22 17:38:37 +00:00
|
|
|
return cmd;
|
|
|
|
|
|
|
|
error:
|
|
|
|
virQEMUCapsInitQMPCommandFree(cmd);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Returns -1 on fatal error,
|
|
|
|
* 0 on success,
|
|
|
|
* 1 when probing QEMU failed
|
|
|
|
*/
|
|
|
|
static int
|
2016-06-10 15:16:21 +00:00
|
|
|
virQEMUCapsInitQMPCommandRun(virQEMUCapsInitQMPCommandPtr cmd,
|
|
|
|
bool forceTCG)
|
2013-07-22 17:38:37 +00:00
|
|
|
{
|
|
|
|
virDomainXMLOptionPtr xmlopt = NULL;
|
2016-06-10 15:16:21 +00:00
|
|
|
const char *machine;
|
2013-07-22 17:38:37 +00:00
|
|
|
int status = 0;
|
|
|
|
int ret = -1;
|
|
|
|
|
2016-06-10 15:16:21 +00:00
|
|
|
if (forceTCG)
|
|
|
|
machine = "none,accel=tcg";
|
|
|
|
else
|
|
|
|
machine = "none,accel=kvm:tcg";
|
|
|
|
|
|
|
|
VIR_DEBUG("Try to probe capabilities of '%s' via QMP, machine %s",
|
|
|
|
cmd->binary, machine);
|
2012-08-22 17:05:08 +00:00
|
|
|
|
2013-01-24 18:21:23 +00:00
|
|
|
/*
|
|
|
|
* We explicitly need to use -daemonize here, rather than
|
|
|
|
* virCommandDaemonize, because we need to synchronize
|
|
|
|
* with QEMU creating its monitor socket API. Using
|
|
|
|
* daemonize guarantees control won't return to libvirt
|
|
|
|
* until the socket is present.
|
|
|
|
*/
|
2013-07-22 17:38:37 +00:00
|
|
|
cmd->cmd = virCommandNewArgList(cmd->binary,
|
|
|
|
"-S",
|
|
|
|
"-no-user-config",
|
|
|
|
"-nodefaults",
|
|
|
|
"-nographic",
|
2016-06-10 15:16:21 +00:00
|
|
|
"-machine", machine,
|
2013-07-22 17:38:37 +00:00
|
|
|
"-qmp", cmd->monarg,
|
|
|
|
"-pidfile", cmd->pidfile,
|
|
|
|
"-daemonize",
|
|
|
|
NULL);
|
|
|
|
virCommandAddEnvPassCommon(cmd->cmd);
|
|
|
|
virCommandClearCaps(cmd->cmd);
|
|
|
|
virCommandSetGID(cmd->cmd, cmd->runGid);
|
|
|
|
virCommandSetUID(cmd->cmd, cmd->runUid);
|
|
|
|
|
|
|
|
virCommandSetErrorBuffer(cmd->cmd, cmd->qmperr);
|
2014-12-04 15:26:41 +00:00
|
|
|
|
2014-02-20 00:32:19 +00:00
|
|
|
/* Log, but otherwise ignore, non-zero status. */
|
2013-07-22 17:38:37 +00:00
|
|
|
if (virCommandRun(cmd->cmd, &status) < 0)
|
2012-08-22 17:05:08 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (status != 0) {
|
2014-12-04 15:26:41 +00:00
|
|
|
VIR_DEBUG("QEMU %s exited with status %d: %s",
|
2013-07-22 17:38:37 +00:00
|
|
|
cmd->binary, status, *cmd->qmperr);
|
|
|
|
goto ignore;
|
2012-08-22 17:05:08 +00:00
|
|
|
}
|
|
|
|
|
2013-07-22 17:38:37 +00:00
|
|
|
if (virPidFileReadPath(cmd->pidfile, &cmd->pid) < 0) {
|
|
|
|
VIR_DEBUG("Failed to read pidfile %s", cmd->pidfile);
|
|
|
|
goto ignore;
|
2013-01-07 16:19:36 +00:00
|
|
|
}
|
|
|
|
|
2017-06-01 22:44:46 +00:00
|
|
|
if (!(xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL, NULL, NULL)) ||
|
2013-07-22 17:38:37 +00:00
|
|
|
!(cmd->vm = virDomainObjNew(xmlopt)))
|
2013-10-08 14:50:33 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2013-07-22 17:38:37 +00:00
|
|
|
cmd->vm->pid = cmd->pid;
|
2013-01-07 16:19:36 +00:00
|
|
|
|
2013-07-22 17:38:37 +00:00
|
|
|
if (!(cmd->mon = qemuMonitorOpen(cmd->vm, &cmd->config, true,
|
2017-03-11 06:23:42 +00:00
|
|
|
0, &callbacks, NULL)))
|
2013-07-22 17:38:37 +00:00
|
|
|
goto ignore;
|
2012-08-22 17:05:08 +00:00
|
|
|
|
2013-07-22 17:38:37 +00:00
|
|
|
virObjectLock(cmd->mon);
|
2012-08-22 17:05:08 +00:00
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
|
2014-03-25 06:49:44 +00:00
|
|
|
cleanup:
|
2013-07-22 17:38:37 +00:00
|
|
|
if (!cmd->mon)
|
|
|
|
virQEMUCapsInitQMPCommandAbort(cmd);
|
2013-10-08 14:50:33 +00:00
|
|
|
virObjectUnref(xmlopt);
|
2012-10-02 08:59:56 +00:00
|
|
|
|
2013-07-22 17:38:37 +00:00
|
|
|
return ret;
|
2012-10-02 08:59:56 +00:00
|
|
|
|
2013-07-22 17:38:37 +00:00
|
|
|
ignore:
|
|
|
|
ret = 1;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2014-12-04 15:26:41 +00:00
|
|
|
|
2013-07-22 17:38:37 +00:00
|
|
|
|
|
|
|
static int
|
|
|
|
virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps,
|
|
|
|
const char *libDir,
|
|
|
|
uid_t runUid,
|
|
|
|
gid_t runGid,
|
|
|
|
char **qmperr)
|
|
|
|
{
|
|
|
|
virQEMUCapsInitQMPCommandPtr cmd = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (!(cmd = virQEMUCapsInitQMPCommandNew(qemuCaps->binary, libDir,
|
|
|
|
runUid, runGid, qmperr)))
|
|
|
|
goto cleanup;
|
|
|
|
|
2016-06-10 15:16:21 +00:00
|
|
|
if ((rc = virQEMUCapsInitQMPCommandRun(cmd, false)) != 0) {
|
2013-07-22 17:38:37 +00:00
|
|
|
if (rc == 1)
|
|
|
|
ret = 0;
|
|
|
|
goto cleanup;
|
2012-10-02 08:59:56 +00:00
|
|
|
}
|
2013-07-22 17:38:37 +00:00
|
|
|
|
|
|
|
if (virQEMUCapsInitQMPMonitor(qemuCaps, cmd->mon) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2016-06-10 15:16:21 +00:00
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) {
|
|
|
|
virQEMUCapsInitQMPCommandAbort(cmd);
|
|
|
|
if ((rc = virQEMUCapsInitQMPCommandRun(cmd, true)) != 0) {
|
|
|
|
if (rc == 1)
|
|
|
|
ret = 0;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (virQEMUCapsInitQMPMonitorTCG(qemuCaps, cmd->mon) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2013-07-22 17:38:37 +00:00
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virQEMUCapsInitQMPCommandFree(cmd);
|
2012-08-22 17:05:08 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-02-21 17:16:07 +00:00
|
|
|
#define MESSAGE_ID_CAPS_PROBE_FAILURE "8ae2f3fb-2dbe-498e-8fbd-012d40afa361"
|
|
|
|
|
|
|
|
static void
|
|
|
|
virQEMUCapsLogProbeFailure(const char *binary)
|
|
|
|
{
|
|
|
|
virLogMetadata meta[] = {
|
|
|
|
{ .key = "MESSAGE_ID", .s = MESSAGE_ID_CAPS_PROBE_FAILURE, .iv = 0 },
|
|
|
|
{ .key = "LIBVIRT_QEMU_BINARY", .s = binary, .iv = 0 },
|
|
|
|
{ .key = NULL },
|
|
|
|
};
|
|
|
|
|
2014-02-27 17:44:53 +00:00
|
|
|
virLogMessage(&virLogSelf,
|
2014-02-21 17:16:07 +00:00
|
|
|
VIR_LOG_WARN,
|
|
|
|
__FILE__, __LINE__, __func__,
|
|
|
|
meta,
|
|
|
|
_("Failed to probe capabilities for %s: %s"),
|
2016-03-23 18:31:50 +00:00
|
|
|
binary, virGetLastErrorMessage());
|
2014-02-21 17:16:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-26 13:03:06 +00:00
|
|
|
virQEMUCapsPtr
|
2017-07-21 13:09:54 +00:00
|
|
|
virQEMUCapsNewForBinaryInternal(virArch hostArch,
|
2016-06-15 11:48:19 +00:00
|
|
|
const char *binary,
|
2016-04-26 13:03:06 +00:00
|
|
|
const char *libDir,
|
|
|
|
uid_t runUid,
|
|
|
|
gid_t runGid,
|
2017-12-12 15:23:41 +00:00
|
|
|
unsigned int microcodeVersion,
|
2018-03-28 20:46:41 +00:00
|
|
|
const char *kernelVersion)
|
2012-08-22 17:05:08 +00:00
|
|
|
{
|
2014-08-27 13:43:52 +00:00
|
|
|
virQEMUCapsPtr qemuCaps;
|
2012-08-22 17:05:08 +00:00
|
|
|
struct stat sb;
|
2014-12-04 15:26:41 +00:00
|
|
|
char *qmperr = NULL;
|
2012-08-22 17:05:08 +00:00
|
|
|
|
2014-08-27 13:43:52 +00:00
|
|
|
if (!(qemuCaps = virQEMUCapsNew()))
|
|
|
|
goto error;
|
|
|
|
|
2013-05-20 09:23:13 +00:00
|
|
|
if (VIR_STRDUP(qemuCaps->binary, binary) < 0)
|
|
|
|
goto error;
|
2012-08-22 17:05:08 +00:00
|
|
|
|
|
|
|
/* We would also want to check faccessat if we cared about ACLs,
|
|
|
|
* but we don't. */
|
|
|
|
if (stat(binary, &sb) < 0) {
|
|
|
|
virReportSystemError(errno, _("Cannot check QEMU binary %s"),
|
|
|
|
binary);
|
|
|
|
goto error;
|
|
|
|
}
|
2014-03-10 15:50:19 +00:00
|
|
|
qemuCaps->ctime = sb.st_ctime;
|
2012-08-22 17:05:08 +00:00
|
|
|
|
|
|
|
/* Make sure the binary we are about to try exec'ing exists.
|
|
|
|
* Technically we could catch the exec() failure, but that's
|
|
|
|
* in a sub-process so it's hard to feed back a useful error.
|
|
|
|
*/
|
|
|
|
if (!virFileIsExecutable(binary)) {
|
|
|
|
virReportSystemError(errno, _("QEMU binary %s is not executable"),
|
|
|
|
binary);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2017-07-18 14:14:07 +00:00
|
|
|
if (virQEMUCapsInitQMP(qemuCaps, libDir, runUid, runGid, &qmperr) < 0) {
|
|
|
|
virQEMUCapsLogProbeFailure(binary);
|
2012-08-22 17:05:08 +00:00
|
|
|
goto error;
|
2017-07-18 14:14:07 +00:00
|
|
|
}
|
2012-08-22 17:05:08 +00:00
|
|
|
|
2018-03-28 20:46:41 +00:00
|
|
|
if (!qemuCaps->usedQMP) {
|
2017-07-18 14:14:07 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Failed to probe QEMU binary with QMP: %s"),
|
|
|
|
qmperr ? qmperr : _("unknown error"));
|
|
|
|
virQEMUCapsLogProbeFailure(binary);
|
|
|
|
goto error;
|
|
|
|
}
|
2014-03-05 16:51:59 +00:00
|
|
|
|
2017-07-18 14:14:07 +00:00
|
|
|
qemuCaps->libvirtCtime = virGetSelfLastChanged();
|
|
|
|
qemuCaps->libvirtVersion = LIBVIR_VERSION_NUMBER;
|
2016-06-15 12:35:18 +00:00
|
|
|
|
2017-07-21 13:09:54 +00:00
|
|
|
virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_KVM);
|
|
|
|
virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_QEMU);
|
2012-08-22 17:05:08 +00:00
|
|
|
|
2018-01-22 10:37:04 +00:00
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) {
|
2017-12-12 15:23:41 +00:00
|
|
|
qemuCaps->microcodeVersion = microcodeVersion;
|
|
|
|
|
2018-01-22 10:37:04 +00:00
|
|
|
if (VIR_STRDUP(qemuCaps->kernelVersion, kernelVersion) < 0)
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2016-06-15 12:35:18 +00:00
|
|
|
cleanup:
|
2014-12-04 15:26:41 +00:00
|
|
|
VIR_FREE(qmperr);
|
2013-02-01 13:48:58 +00:00
|
|
|
return qemuCaps;
|
2012-09-10 10:47:56 +00:00
|
|
|
|
2014-03-25 06:49:44 +00:00
|
|
|
error:
|
2013-02-01 13:48:58 +00:00
|
|
|
virObjectUnref(qemuCaps);
|
|
|
|
qemuCaps = NULL;
|
2016-06-15 12:35:18 +00:00
|
|
|
goto cleanup;
|
2012-09-10 10:47:56 +00:00
|
|
|
}
|
|
|
|
|
2017-07-19 15:01:56 +00:00
|
|
|
static void *
|
|
|
|
virQEMUCapsNewData(const char *binary,
|
|
|
|
void *privData)
|
2016-04-26 13:03:06 +00:00
|
|
|
{
|
2017-07-19 15:01:56 +00:00
|
|
|
virQEMUCapsCachePrivPtr priv = privData;
|
|
|
|
|
|
|
|
return virQEMUCapsNewForBinaryInternal(priv->hostArch,
|
|
|
|
binary,
|
|
|
|
priv->libDir,
|
|
|
|
priv->runUid,
|
|
|
|
priv->runGid,
|
2017-12-12 15:23:41 +00:00
|
|
|
priv->microcodeVersion,
|
2018-03-28 20:46:41 +00:00
|
|
|
priv->kernelVersion);
|
2017-07-19 15:01:56 +00:00
|
|
|
}
|
2017-07-18 14:14:07 +00:00
|
|
|
|
|
|
|
|
2017-07-19 15:01:56 +00:00
|
|
|
static void *
|
|
|
|
virQEMUCapsLoadFile(const char *filename,
|
|
|
|
const char *binary,
|
|
|
|
void *privData)
|
|
|
|
{
|
|
|
|
virQEMUCapsPtr qemuCaps = virQEMUCapsNew();
|
|
|
|
virQEMUCapsCachePrivPtr priv = privData;
|
2017-07-18 14:14:07 +00:00
|
|
|
|
2017-07-19 15:01:56 +00:00
|
|
|
if (!qemuCaps)
|
|
|
|
return NULL;
|
2017-07-18 14:14:07 +00:00
|
|
|
|
2017-07-19 15:01:56 +00:00
|
|
|
if (VIR_STRDUP(qemuCaps->binary, binary) < 0)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
if (virQEMUCapsLoadCache(priv->hostArch, qemuCaps, filename) < 0)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
cleanup:
|
2017-07-18 14:14:07 +00:00
|
|
|
return qemuCaps;
|
|
|
|
|
|
|
|
error:
|
|
|
|
virObjectUnref(qemuCaps);
|
2017-07-19 15:01:56 +00:00
|
|
|
qemuCaps = NULL;
|
|
|
|
goto cleanup;
|
2016-04-26 13:03:06 +00:00
|
|
|
}
|
|
|
|
|
2012-09-10 10:47:56 +00:00
|
|
|
|
2015-02-12 13:50:31 +00:00
|
|
|
struct virQEMUCapsMachineTypeFilter {
|
|
|
|
const char *machineType;
|
|
|
|
virQEMUCapsFlags *flags;
|
|
|
|
size_t nflags;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct virQEMUCapsMachineTypeFilter virQEMUCapsMachineFilter[] = {
|
|
|
|
/* { "blah", virQEMUCapsMachineBLAHFilter,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsMachineBLAHFilter) }, */
|
|
|
|
{ "", NULL, 0 },
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
virQEMUCapsFilterByMachineType(virQEMUCapsPtr qemuCaps,
|
|
|
|
const char *machineType)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
if (!machineType)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_CARDINALITY(virQEMUCapsMachineFilter); i++) {
|
|
|
|
const struct virQEMUCapsMachineTypeFilter *filter = &virQEMUCapsMachineFilter[i];
|
|
|
|
size_t j;
|
|
|
|
|
|
|
|
if (STRNEQ(filter->machineType, machineType))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (j = 0; j < filter->nflags; j++)
|
|
|
|
virQEMUCapsClear(qemuCaps, filter->flags[j]);
|
|
|
|
}
|
|
|
|
|
2016-07-29 07:45:19 +00:00
|
|
|
if (!virQEMUCapsGetMachineHotplugCpus(qemuCaps, machineType))
|
|
|
|
virQEMUCapsClear(qemuCaps, QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);
|
2015-02-12 13:50:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-19 15:01:56 +00:00
|
|
|
virFileCacheHandlers qemuCapsCacheHandlers = {
|
|
|
|
.isValid = virQEMUCapsIsValid,
|
|
|
|
.newData = virQEMUCapsNewData,
|
|
|
|
.loadFile = virQEMUCapsLoadFile,
|
|
|
|
.saveFile = virQEMUCapsSaveFile,
|
|
|
|
.privFree = virQEMUCapsCachePrivFree,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
virFileCachePtr
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsCacheNew(const char *libDir,
|
2014-03-05 16:51:59 +00:00
|
|
|
const char *cacheDir,
|
2013-02-01 13:48:58 +00:00
|
|
|
uid_t runUid,
|
2017-12-12 15:23:41 +00:00
|
|
|
gid_t runGid,
|
|
|
|
unsigned int microcodeVersion)
|
2012-08-22 12:54:13 +00:00
|
|
|
{
|
2017-07-19 15:01:56 +00:00
|
|
|
char *capsCacheDir = NULL;
|
|
|
|
virFileCachePtr cache = NULL;
|
|
|
|
virQEMUCapsCachePrivPtr priv = NULL;
|
2018-01-22 13:51:11 +00:00
|
|
|
struct utsname uts;
|
2012-08-22 12:54:13 +00:00
|
|
|
|
2017-07-19 15:01:56 +00:00
|
|
|
if (virAsprintf(&capsCacheDir, "%s/capabilities", cacheDir) < 0)
|
2012-08-22 12:54:13 +00:00
|
|
|
goto error;
|
2017-07-19 15:01:56 +00:00
|
|
|
|
|
|
|
if (!(cache = virFileCacheNew(capsCacheDir, "xml", &qemuCapsCacheHandlers)))
|
2014-03-05 16:51:59 +00:00
|
|
|
goto error;
|
2012-08-22 12:54:13 +00:00
|
|
|
|
2017-07-19 15:01:56 +00:00
|
|
|
if (VIR_ALLOC(priv) < 0)
|
2017-06-20 14:17:23 +00:00
|
|
|
goto error;
|
2017-07-19 15:01:56 +00:00
|
|
|
virFileCacheSetPriv(cache, priv);
|
2017-06-20 14:17:23 +00:00
|
|
|
|
2017-07-19 15:01:56 +00:00
|
|
|
if (VIR_STRDUP(priv->libDir, libDir) < 0)
|
2017-06-20 14:17:23 +00:00
|
|
|
goto error;
|
|
|
|
|
2017-07-19 15:01:56 +00:00
|
|
|
priv->hostArch = virArchFromHost();
|
2017-07-21 13:09:54 +00:00
|
|
|
|
2017-07-19 15:01:56 +00:00
|
|
|
priv->runUid = runUid;
|
|
|
|
priv->runGid = runGid;
|
2017-12-12 15:23:41 +00:00
|
|
|
priv->microcodeVersion = microcodeVersion;
|
2012-11-26 14:17:13 +00:00
|
|
|
|
2018-01-22 10:37:04 +00:00
|
|
|
if (uname(&uts) == 0 &&
|
|
|
|
virAsprintf(&priv->kernelVersion, "%s %s", uts.release, uts.version) < 0)
|
|
|
|
goto error;
|
|
|
|
|
2017-07-19 15:01:56 +00:00
|
|
|
cleanup:
|
|
|
|
VIR_FREE(capsCacheDir);
|
2012-08-22 12:54:13 +00:00
|
|
|
return cache;
|
|
|
|
|
2014-03-25 06:49:44 +00:00
|
|
|
error:
|
2017-07-19 15:01:56 +00:00
|
|
|
virObjectUnref(cache);
|
|
|
|
cache = NULL;
|
|
|
|
goto cleanup;
|
2016-11-16 12:47:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsPtr
|
2017-07-19 15:01:56 +00:00
|
|
|
virQEMUCapsCacheLookup(virFileCachePtr cache,
|
2016-06-15 11:48:19 +00:00
|
|
|
const char *binary)
|
2012-08-22 12:54:13 +00:00
|
|
|
{
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsPtr ret = NULL;
|
2015-09-09 14:03:14 +00:00
|
|
|
|
2017-07-19 15:01:56 +00:00
|
|
|
ret = virFileCacheLookup(cache, binary);
|
2016-11-16 12:47:09 +00:00
|
|
|
|
|
|
|
VIR_DEBUG("Returning caps %p for %s", ret, binary);
|
2012-08-22 12:54:13 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsPtr
|
2017-07-19 15:01:56 +00:00
|
|
|
virQEMUCapsCacheLookupCopy(virFileCachePtr cache,
|
2015-02-12 12:48:42 +00:00
|
|
|
const char *binary,
|
2015-02-12 13:50:31 +00:00
|
|
|
const char *machineType)
|
2012-08-22 12:54:13 +00:00
|
|
|
{
|
2017-07-21 13:09:54 +00:00
|
|
|
virQEMUCapsPtr qemuCaps = virQEMUCapsCacheLookup(cache, binary);
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsPtr ret;
|
2012-08-22 12:54:13 +00:00
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
if (!qemuCaps)
|
2012-08-22 12:54:13 +00:00
|
|
|
return NULL;
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
ret = virQEMUCapsNewCopy(qemuCaps);
|
|
|
|
virObjectUnref(qemuCaps);
|
2017-02-09 14:13:35 +00:00
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
return NULL;
|
|
|
|
|
2015-02-12 13:50:31 +00:00
|
|
|
virQEMUCapsFilterByMachineType(ret, machineType);
|
2012-08-22 12:54:13 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-30 14:12:07 +00:00
|
|
|
static int
|
|
|
|
virQEMUCapsCompareArch(const void *payload,
|
|
|
|
const void *name ATTRIBUTE_UNUSED,
|
|
|
|
const void *opaque)
|
|
|
|
{
|
2018-04-25 12:42:34 +00:00
|
|
|
struct virQEMUCapsSearchData *data = (struct virQEMUCapsSearchData *)opaque;
|
2014-06-30 14:12:07 +00:00
|
|
|
const virQEMUCaps *qemuCaps = payload;
|
|
|
|
|
|
|
|
return qemuCaps->arch == data->arch;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
virQEMUCapsPtr
|
2017-07-19 15:01:56 +00:00
|
|
|
virQEMUCapsCacheLookupByArch(virFileCachePtr cache,
|
2014-06-30 14:12:07 +00:00
|
|
|
virArch arch)
|
|
|
|
{
|
|
|
|
virQEMUCapsPtr ret = NULL;
|
2015-09-15 13:58:09 +00:00
|
|
|
virArch target;
|
2014-06-30 14:12:07 +00:00
|
|
|
struct virQEMUCapsSearchData data = { .arch = arch };
|
|
|
|
|
2017-07-19 15:01:56 +00:00
|
|
|
ret = virFileCacheLookupByFunc(cache, virQEMUCapsCompareArch, &data);
|
2015-09-15 13:58:09 +00:00
|
|
|
if (!ret) {
|
|
|
|
/* If the first attempt at finding capabilities has failed, try
|
|
|
|
* again using the QEMU target as lookup key instead */
|
|
|
|
target = virQEMUCapsFindTarget(virArchFromHost(), data.arch);
|
|
|
|
if (target != data.arch) {
|
|
|
|
data.arch = target;
|
2017-07-19 15:01:56 +00:00
|
|
|
ret = virFileCacheLookupByFunc(cache, virQEMUCapsCompareArch, &data);
|
2015-09-15 13:58:09 +00:00
|
|
|
}
|
|
|
|
}
|
2016-11-16 13:17:12 +00:00
|
|
|
|
2017-07-19 15:01:56 +00:00
|
|
|
if (!ret) {
|
2016-11-16 13:17:12 +00:00
|
|
|
virReportError(VIR_ERR_INVALID_ARG,
|
|
|
|
_("unable to find any emulator to serve '%s' "
|
|
|
|
"architecture"), virArchToString(arch));
|
|
|
|
}
|
|
|
|
|
2015-09-15 13:58:09 +00:00
|
|
|
VIR_DEBUG("Returning caps %p for arch %s", ret, virArchToString(arch));
|
|
|
|
|
2014-06-30 14:12:07 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-04-21 11:28:40 +00:00
|
|
|
bool
|
|
|
|
virQEMUCapsSupportsVmport(virQEMUCapsPtr qemuCaps,
|
|
|
|
const virDomainDef *def)
|
|
|
|
{
|
|
|
|
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_VMPORT_OPT))
|
|
|
|
return false;
|
|
|
|
|
2017-04-18 10:43:58 +00:00
|
|
|
return qemuDomainIsI440FX(def) ||
|
|
|
|
qemuDomainIsQ35(def) ||
|
2015-04-21 11:28:40 +00:00
|
|
|
STREQ(def->os.machine, "isapc");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-07-13 12:09:20 +00:00
|
|
|
bool
|
|
|
|
virQEMUCapsSupportsSMM(virQEMUCapsPtr qemuCaps,
|
|
|
|
const virDomainDef *def)
|
|
|
|
{
|
|
|
|
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_SMM_OPT))
|
|
|
|
return false;
|
|
|
|
|
2017-04-18 10:43:58 +00:00
|
|
|
return qemuDomainIsQ35(def);
|
2016-07-13 12:09:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-30 14:31:51 +00:00
|
|
|
bool
|
|
|
|
virQEMUCapsIsMachineSupported(virQEMUCapsPtr qemuCaps,
|
|
|
|
const char *canonical_machine)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
for (i = 0; i < qemuCaps->nmachineTypes; i++) {
|
2016-07-29 08:13:46 +00:00
|
|
|
if (STREQ(canonical_machine, qemuCaps->machineTypes[i].name))
|
2014-06-30 14:31:51 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2014-06-30 14:39:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
const char *
|
|
|
|
virQEMUCapsGetDefaultMachine(virQEMUCapsPtr qemuCaps)
|
|
|
|
{
|
|
|
|
if (!qemuCaps->nmachineTypes)
|
|
|
|
return NULL;
|
2016-07-29 08:13:46 +00:00
|
|
|
return qemuCaps->machineTypes[0].name;
|
2014-06-30 14:39:18 +00:00
|
|
|
}
|
2014-06-25 16:39:29 +00:00
|
|
|
|
|
|
|
|
2014-09-17 09:33:35 +00:00
|
|
|
static int
|
2016-05-20 11:29:54 +00:00
|
|
|
virQEMUCapsFillDomainLoaderCaps(virDomainCapsLoaderPtr capsLoader,
|
2016-05-17 22:45:27 +00:00
|
|
|
virFirmwarePtr *firmwares,
|
|
|
|
size_t nfirmwares)
|
2014-09-16 12:47:47 +00:00
|
|
|
{
|
2014-09-16 23:52:54 +00:00
|
|
|
size_t i;
|
|
|
|
|
2016-03-10 18:52:52 +00:00
|
|
|
capsLoader->supported = true;
|
2014-09-16 12:47:47 +00:00
|
|
|
|
2016-05-17 22:45:27 +00:00
|
|
|
if (VIR_ALLOC_N(capsLoader->values.values, nfirmwares) < 0)
|
2014-09-16 23:52:54 +00:00
|
|
|
return -1;
|
|
|
|
|
2016-05-17 22:45:27 +00:00
|
|
|
for (i = 0; i < nfirmwares; i++) {
|
|
|
|
const char *filename = firmwares[i]->name;
|
2014-09-16 23:52:54 +00:00
|
|
|
|
|
|
|
if (!virFileExists(filename)) {
|
|
|
|
VIR_DEBUG("loader filename=%s does not exist", filename);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2014-09-18 06:30:40 +00:00
|
|
|
if (VIR_STRDUP(capsLoader->values.values[capsLoader->values.nvalues],
|
2014-09-16 23:52:54 +00:00
|
|
|
filename) < 0)
|
|
|
|
return -1;
|
2014-09-18 06:30:40 +00:00
|
|
|
capsLoader->values.nvalues++;
|
2014-09-16 23:52:54 +00:00
|
|
|
}
|
|
|
|
|
2014-09-18 06:30:40 +00:00
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(capsLoader->type,
|
2014-09-16 12:47:47 +00:00
|
|
|
VIR_DOMAIN_LOADER_TYPE_ROM);
|
|
|
|
|
2015-11-06 18:20:20 +00:00
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(capsLoader->type,
|
|
|
|
VIR_DOMAIN_LOADER_TYPE_PFLASH);
|
2014-09-16 12:47:47 +00:00
|
|
|
|
|
|
|
|
2016-05-20 11:29:54 +00:00
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(capsLoader->readonly,
|
|
|
|
VIR_TRISTATE_BOOL_YES,
|
|
|
|
VIR_TRISTATE_BOOL_NO);
|
2014-09-17 09:33:35 +00:00
|
|
|
return 0;
|
2014-09-16 12:47:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-17 09:33:35 +00:00
|
|
|
static int
|
2016-05-20 11:29:54 +00:00
|
|
|
virQEMUCapsFillDomainOSCaps(virDomainCapsOSPtr os,
|
2016-05-17 22:45:27 +00:00
|
|
|
virFirmwarePtr *firmwares,
|
|
|
|
size_t nfirmwares)
|
2014-09-16 12:47:47 +00:00
|
|
|
{
|
2014-09-18 06:30:40 +00:00
|
|
|
virDomainCapsLoaderPtr capsLoader = &os->loader;
|
2014-09-16 12:47:47 +00:00
|
|
|
|
2016-03-10 18:52:52 +00:00
|
|
|
os->supported = true;
|
2016-05-17 22:45:27 +00:00
|
|
|
if (virQEMUCapsFillDomainLoaderCaps(capsLoader, firmwares, nfirmwares) < 0)
|
2014-09-17 09:33:35 +00:00
|
|
|
return -1;
|
|
|
|
return 0;
|
2014-09-16 12:47:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-22 20:22:30 +00:00
|
|
|
static int
|
|
|
|
virQEMUCapsFillDomainCPUCaps(virCapsPtr caps,
|
|
|
|
virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainCapsPtr domCaps)
|
|
|
|
{
|
2016-08-03 14:22:30 +00:00
|
|
|
if (virQEMUCapsIsCPUModeSupported(qemuCaps, caps, domCaps->virttype,
|
|
|
|
VIR_CPU_MODE_HOST_PASSTHROUGH))
|
2016-04-22 20:22:30 +00:00
|
|
|
domCaps->cpu.hostPassthrough = true;
|
|
|
|
|
2016-08-03 14:22:30 +00:00
|
|
|
if (virQEMUCapsIsCPUModeSupported(qemuCaps, caps, domCaps->virttype,
|
2017-02-22 15:51:50 +00:00
|
|
|
VIR_CPU_MODE_HOST_MODEL)) {
|
2017-04-11 09:14:30 +00:00
|
|
|
virCPUDefPtr cpu = virQEMUCapsGetHostModel(qemuCaps, domCaps->virttype,
|
|
|
|
VIR_QEMU_CAPS_HOST_CPU_REPORTED);
|
2017-02-22 15:51:50 +00:00
|
|
|
domCaps->cpu.hostModel = virCPUDefCopy(cpu);
|
|
|
|
}
|
2016-08-03 14:22:30 +00:00
|
|
|
|
|
|
|
if (virQEMUCapsIsCPUModeSupported(qemuCaps, caps, domCaps->virttype,
|
|
|
|
VIR_CPU_MODE_CUSTOM)) {
|
|
|
|
virDomainCapsCPUModelsPtr filtered = NULL;
|
|
|
|
char **models = NULL;
|
2016-11-20 22:21:19 +00:00
|
|
|
const char *blacklist[] = { "host", NULL };
|
2016-04-22 20:22:30 +00:00
|
|
|
|
2016-11-04 13:20:39 +00:00
|
|
|
if (virCPUGetModels(domCaps->arch, &models) >= 0) {
|
2016-11-14 16:21:30 +00:00
|
|
|
virDomainCapsCPUModelsPtr cpus;
|
|
|
|
|
|
|
|
if (domCaps->virttype == VIR_DOMAIN_VIRT_KVM)
|
|
|
|
cpus = qemuCaps->kvmCPUModels;
|
|
|
|
else
|
|
|
|
cpus = qemuCaps->tcgCPUModels;
|
|
|
|
|
|
|
|
filtered = virDomainCapsCPUModelsFilter(cpus,
|
2018-04-25 12:42:34 +00:00
|
|
|
(const char **)models,
|
2016-11-20 22:21:19 +00:00
|
|
|
blacklist);
|
2016-11-25 08:18:35 +00:00
|
|
|
virStringListFree(models);
|
2016-08-03 14:22:30 +00:00
|
|
|
}
|
|
|
|
domCaps->cpu.custom = filtered;
|
2016-04-29 08:42:56 +00:00
|
|
|
}
|
2016-04-22 20:22:30 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-10-19 12:19:38 +00:00
|
|
|
static int
|
|
|
|
virQEMUCapsFillDomainIOThreadCaps(virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainCapsPtr domCaps)
|
|
|
|
{
|
|
|
|
domCaps->iothreads = virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_IOTHREAD);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-17 09:33:35 +00:00
|
|
|
static int
|
2014-06-25 16:39:29 +00:00
|
|
|
virQEMUCapsFillDomainDeviceDiskCaps(virQEMUCapsPtr qemuCaps,
|
2015-07-30 11:54:26 +00:00
|
|
|
const char *machine,
|
2014-06-25 16:39:29 +00:00
|
|
|
virDomainCapsDeviceDiskPtr disk)
|
|
|
|
{
|
2016-03-10 18:52:52 +00:00
|
|
|
disk->supported = true;
|
2014-06-25 16:39:29 +00:00
|
|
|
/* QEMU supports all of these */
|
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(disk->diskDevice,
|
|
|
|
VIR_DOMAIN_DISK_DEVICE_DISK,
|
2016-05-16 08:29:57 +00:00
|
|
|
VIR_DOMAIN_DISK_DEVICE_CDROM,
|
|
|
|
VIR_DOMAIN_DISK_DEVICE_LUN);
|
2015-07-30 11:54:26 +00:00
|
|
|
|
|
|
|
/* PowerPC pseries based VMs do not support floppy device */
|
2017-04-13 14:24:45 +00:00
|
|
|
if (!qemuDomainMachineIsPSeries(machine, qemuCaps->arch))
|
2015-07-30 11:54:26 +00:00
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(disk->diskDevice, VIR_DOMAIN_DISK_DEVICE_FLOPPY);
|
2014-06-25 16:39:29 +00:00
|
|
|
|
2017-04-13 13:29:16 +00:00
|
|
|
if (qemuDomainMachineHasBuiltinIDE(machine))
|
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(disk->bus, VIR_DOMAIN_DISK_BUS_IDE);
|
|
|
|
|
2014-06-25 16:39:29 +00:00
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(disk->bus,
|
|
|
|
VIR_DOMAIN_DISK_BUS_SCSI,
|
|
|
|
VIR_DOMAIN_DISK_BUS_VIRTIO,
|
|
|
|
/* VIR_DOMAIN_DISK_BUS_SD */);
|
|
|
|
|
2015-07-30 11:54:26 +00:00
|
|
|
/* PowerPC pseries based VMs do not support floppy device */
|
2017-04-13 14:24:45 +00:00
|
|
|
if (!qemuDomainMachineIsPSeries(machine, qemuCaps->arch))
|
2015-07-30 11:54:26 +00:00
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(disk->bus, VIR_DOMAIN_DISK_BUS_FDC);
|
|
|
|
|
2014-06-25 16:39:29 +00:00
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_USB_STORAGE))
|
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(disk->bus, VIR_DOMAIN_DISK_BUS_USB);
|
2017-03-06 16:16:07 +00:00
|
|
|
|
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_ICH9_AHCI))
|
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(disk->bus, VIR_DOMAIN_DISK_BUS_SATA);
|
|
|
|
|
2014-09-17 09:33:35 +00:00
|
|
|
return 0;
|
2014-06-25 16:39:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-05-08 15:57:20 +00:00
|
|
|
static int
|
|
|
|
virQEMUCapsFillDomainDeviceGraphicsCaps(virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainCapsDeviceGraphicsPtr dev)
|
|
|
|
{
|
|
|
|
dev->supported = true;
|
|
|
|
|
2018-03-29 10:51:55 +00:00
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(dev->type, VIR_DOMAIN_GRAPHICS_TYPE_SDL);
|
2016-05-08 15:57:20 +00:00
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VNC))
|
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(dev->type, VIR_DOMAIN_GRAPHICS_TYPE_VNC);
|
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SPICE))
|
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(dev->type, VIR_DOMAIN_GRAPHICS_TYPE_SPICE);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-05-08 16:11:39 +00:00
|
|
|
static int
|
|
|
|
virQEMUCapsFillDomainDeviceVideoCaps(virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainCapsDeviceVideoPtr dev)
|
|
|
|
{
|
|
|
|
dev->supported = true;
|
|
|
|
|
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VGA))
|
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(dev->modelType, VIR_DOMAIN_VIDEO_TYPE_VGA);
|
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_CIRRUS_VGA))
|
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(dev->modelType, VIR_DOMAIN_VIDEO_TYPE_CIRRUS);
|
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VMWARE_SVGA))
|
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(dev->modelType, VIR_DOMAIN_VIDEO_TYPE_VMVGA);
|
2016-10-11 15:42:37 +00:00
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QXL))
|
2016-05-08 16:11:39 +00:00
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(dev->modelType, VIR_DOMAIN_VIDEO_TYPE_QXL);
|
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_GPU))
|
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(dev->modelType, VIR_DOMAIN_VIDEO_TYPE_VIRTIO);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-17 09:33:35 +00:00
|
|
|
static int
|
2014-06-25 16:39:29 +00:00
|
|
|
virQEMUCapsFillDomainDeviceHostdevCaps(virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainCapsDeviceHostdevPtr hostdev)
|
|
|
|
{
|
|
|
|
bool supportsPassthroughKVM = qemuHostdevHostSupportsPassthroughLegacy();
|
|
|
|
bool supportsPassthroughVFIO = qemuHostdevHostSupportsPassthroughVFIO();
|
|
|
|
|
2016-03-10 18:52:52 +00:00
|
|
|
hostdev->supported = true;
|
2014-06-25 16:39:29 +00:00
|
|
|
/* VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES is for containers only */
|
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(hostdev->mode,
|
|
|
|
VIR_DOMAIN_HOSTDEV_MODE_SUBSYS);
|
|
|
|
|
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(hostdev->startupPolicy,
|
|
|
|
VIR_DOMAIN_STARTUP_POLICY_DEFAULT,
|
|
|
|
VIR_DOMAIN_STARTUP_POLICY_MANDATORY,
|
|
|
|
VIR_DOMAIN_STARTUP_POLICY_REQUISITE,
|
|
|
|
VIR_DOMAIN_STARTUP_POLICY_OPTIONAL);
|
|
|
|
|
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(hostdev->subsysType,
|
|
|
|
VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB,
|
|
|
|
VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI);
|
2016-05-20 12:33:58 +00:00
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SCSI_GENERIC))
|
2014-06-25 16:39:29 +00:00
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(hostdev->subsysType,
|
|
|
|
VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI);
|
|
|
|
|
|
|
|
/* No virDomainHostdevCapsType for QEMU */
|
|
|
|
virDomainCapsEnumClear(&hostdev->capsType);
|
|
|
|
|
|
|
|
virDomainCapsEnumClear(&hostdev->pciBackend);
|
|
|
|
if (supportsPassthroughVFIO &&
|
|
|
|
virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) {
|
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(hostdev->pciBackend,
|
|
|
|
VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT,
|
|
|
|
VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO);
|
|
|
|
}
|
|
|
|
|
2016-05-20 12:33:58 +00:00
|
|
|
if (supportsPassthroughKVM) {
|
2014-06-25 16:39:29 +00:00
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(hostdev->pciBackend,
|
|
|
|
VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT,
|
|
|
|
VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM);
|
|
|
|
}
|
2014-09-17 09:33:35 +00:00
|
|
|
return 0;
|
2014-06-25 16:39:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-05-16 11:23:01 +00:00
|
|
|
/**
|
|
|
|
* virQEMUCapsSupportsGICVersion:
|
|
|
|
* @qemuCaps: QEMU capabilities
|
|
|
|
* @virtType: domain type
|
|
|
|
* @version: GIC version
|
|
|
|
*
|
|
|
|
* Checks the QEMU binary with capabilities @qemuCaps supports a specific
|
2017-08-16 13:44:35 +00:00
|
|
|
* GIC version for a domain of type @virtType. If @qemuCaps is NULL, the GIC
|
|
|
|
* @version is considered unsupported.
|
2016-05-16 11:23:01 +00:00
|
|
|
*
|
|
|
|
* Returns: true if the binary supports the requested GIC version, false
|
|
|
|
* otherwise
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
virQEMUCapsSupportsGICVersion(virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainVirtType virtType,
|
|
|
|
virGICVersion version)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
2017-08-16 13:44:35 +00:00
|
|
|
if (!qemuCaps)
|
|
|
|
return false;
|
|
|
|
|
2016-05-16 11:23:01 +00:00
|
|
|
for (i = 0; i < qemuCaps->ngicCapabilities; i++) {
|
|
|
|
virGICCapabilityPtr cap = &(qemuCaps->gicCapabilities[i]);
|
|
|
|
|
|
|
|
if (cap->version != version)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (virtType == VIR_DOMAIN_VIRT_KVM &&
|
|
|
|
cap->implementation & VIR_GIC_IMPLEMENTATION_KERNEL)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (virtType == VIR_DOMAIN_VIRT_QEMU &&
|
|
|
|
cap->implementation & VIR_GIC_IMPLEMENTATION_EMULATED)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-03-09 18:18:24 +00:00
|
|
|
/**
|
|
|
|
* virQEMUCapsFillDomainFeatureGICCaps:
|
|
|
|
* @qemuCaps: QEMU capabilities
|
|
|
|
* @domCaps: domain capabilities
|
|
|
|
*
|
|
|
|
* Take the information about GIC capabilities that has been obtained
|
|
|
|
* using the 'query-gic-capabilities' QMP command and stored in @qemuCaps
|
|
|
|
* and convert it to a form suitable for @domCaps.
|
|
|
|
*
|
|
|
|
* @qemuCaps contains complete information about the GIC capabilities for
|
|
|
|
* the corresponding QEMU binary, stored as custom objects; @domCaps, on
|
|
|
|
* the other hand, should only contain information about the GIC versions
|
|
|
|
* available for the specific combination of architecture, machine type
|
|
|
|
* and virtualization type. Moreover, a common format is used to store
|
|
|
|
* information about enumerations in @domCaps, so further processing is
|
|
|
|
* required.
|
|
|
|
*
|
|
|
|
* Returns: 0 on success, <0 on failure
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
virQEMUCapsFillDomainFeatureGICCaps(virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainCapsPtr domCaps)
|
|
|
|
{
|
|
|
|
virDomainCapsFeatureGICPtr gic = &domCaps->gic;
|
2016-05-16 11:23:01 +00:00
|
|
|
virGICVersion version;
|
2016-03-09 18:18:24 +00:00
|
|
|
|
2017-05-12 09:03:19 +00:00
|
|
|
if (!qemuDomainMachineIsVirt(domCaps->machine, domCaps->arch))
|
2016-03-09 18:18:24 +00:00
|
|
|
return 0;
|
|
|
|
|
2016-05-16 11:23:01 +00:00
|
|
|
for (version = VIR_GIC_VERSION_LAST - 1;
|
|
|
|
version > VIR_GIC_VERSION_NONE;
|
|
|
|
version--) {
|
|
|
|
if (!virQEMUCapsSupportsGICVersion(qemuCaps,
|
|
|
|
domCaps->virttype,
|
|
|
|
version))
|
2016-03-09 18:18:24 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
gic->supported = true;
|
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(gic->version,
|
2016-05-16 11:23:01 +00:00
|
|
|
version);
|
2016-03-09 18:18:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-17 09:33:35 +00:00
|
|
|
int
|
2016-04-22 20:22:30 +00:00
|
|
|
virQEMUCapsFillDomainCaps(virCapsPtr caps,
|
|
|
|
virDomainCapsPtr domCaps,
|
2014-09-16 23:52:54 +00:00
|
|
|
virQEMUCapsPtr qemuCaps,
|
2016-05-17 22:45:27 +00:00
|
|
|
virFirmwarePtr *firmwares,
|
2016-06-27 13:12:34 +00:00
|
|
|
size_t nfirmwares)
|
2014-06-25 16:39:29 +00:00
|
|
|
{
|
2014-09-16 12:47:47 +00:00
|
|
|
virDomainCapsOSPtr os = &domCaps->os;
|
2014-06-25 16:39:29 +00:00
|
|
|
virDomainCapsDeviceDiskPtr disk = &domCaps->disk;
|
|
|
|
virDomainCapsDeviceHostdevPtr hostdev = &domCaps->hostdev;
|
2016-05-08 15:57:20 +00:00
|
|
|
virDomainCapsDeviceGraphicsPtr graphics = &domCaps->graphics;
|
2016-05-08 16:11:39 +00:00
|
|
|
virDomainCapsDeviceVideoPtr video = &domCaps->video;
|
2014-06-25 16:39:29 +00:00
|
|
|
|
2016-06-24 15:04:13 +00:00
|
|
|
domCaps->maxvcpus = virQEMUCapsGetMachineMaxCpus(qemuCaps,
|
|
|
|
domCaps->machine);
|
2016-06-27 13:12:34 +00:00
|
|
|
if (domCaps->virttype == VIR_DOMAIN_VIRT_KVM) {
|
2016-06-27 11:53:43 +00:00
|
|
|
int hostmaxvcpus;
|
|
|
|
|
|
|
|
if ((hostmaxvcpus = virHostCPUGetKVMMaxVCPUs()) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
domCaps->maxvcpus = MIN(domCaps->maxvcpus, hostmaxvcpus);
|
2016-06-24 15:04:13 +00:00
|
|
|
}
|
2014-06-25 16:39:29 +00:00
|
|
|
|
2016-05-17 22:45:27 +00:00
|
|
|
if (virQEMUCapsFillDomainOSCaps(os, firmwares, nfirmwares) < 0 ||
|
2016-04-22 20:22:30 +00:00
|
|
|
virQEMUCapsFillDomainCPUCaps(caps, qemuCaps, domCaps) < 0 ||
|
2017-10-19 12:19:38 +00:00
|
|
|
virQEMUCapsFillDomainIOThreadCaps(qemuCaps, domCaps) < 0 ||
|
2016-05-08 15:57:20 +00:00
|
|
|
virQEMUCapsFillDomainDeviceDiskCaps(qemuCaps,
|
|
|
|
domCaps->machine, disk) < 0 ||
|
|
|
|
virQEMUCapsFillDomainDeviceGraphicsCaps(qemuCaps, graphics) < 0 ||
|
2016-05-08 16:11:39 +00:00
|
|
|
virQEMUCapsFillDomainDeviceVideoCaps(qemuCaps, video) < 0 ||
|
2016-03-09 18:18:24 +00:00
|
|
|
virQEMUCapsFillDomainDeviceHostdevCaps(qemuCaps, hostdev) < 0 ||
|
|
|
|
virQEMUCapsFillDomainFeatureGICCaps(qemuCaps, domCaps) < 0)
|
2014-09-17 09:33:35 +00:00
|
|
|
return -1;
|
|
|
|
return 0;
|
2014-06-25 16:39:29 +00:00
|
|
|
}
|
2017-12-12 15:23:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
virQEMUCapsSetMicrocodeVersion(virQEMUCapsPtr qemuCaps,
|
|
|
|
unsigned int microcodeVersion)
|
|
|
|
{
|
|
|
|
qemuCaps->microcodeVersion = microcodeVersion;
|
|
|
|
}
|