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
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "qemu_capabilities.h"
|
2012-12-12 18:06:53 +00:00
|
|
|
#include "viralloc.h"
|
2020-06-15 08:28:07 +00:00
|
|
|
#include "virarch.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"
|
2018-12-13 14:53:50 +00:00
|
|
|
#define LIBVIRT_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"
|
2019-01-13 00:50:00 +00:00
|
|
|
#include "qemu_process.h"
|
2019-04-04 10:42:14 +00:00
|
|
|
#include "qemu_firmware.h"
|
2020-02-16 21:59:28 +00:00
|
|
|
#include "virutil.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>
|
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
|
|
|
|
*/
|
2019-03-16 18:20:32 +00:00
|
|
|
VIR_ENUM_IMPL(virQEMUCaps,
|
|
|
|
QEMU_CAPS_LAST, /* virQEMUCaps grouping marker */
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 0 */
|
2011-05-04 11:55:38 +00:00
|
|
|
"vnc-colon",
|
|
|
|
"no-reboot",
|
|
|
|
"drive",
|
|
|
|
"drive-boot",
|
2019-04-03 07:13:21 +00:00
|
|
|
"name",
|
2011-05-04 11:55:38 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 5 */
|
2011-05-04 11:55:38 +00:00
|
|
|
"uuid",
|
|
|
|
"domid",
|
|
|
|
"vnet-hdr",
|
|
|
|
"migrate-kvm-stdio",
|
2019-04-03 07:13:21 +00:00
|
|
|
"migrate-qemu-tcp",
|
2011-05-04 11:55:38 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 10 */
|
2011-05-04 11:55:38 +00:00
|
|
|
"migrate-qemu-exec",
|
|
|
|
"drive-cache-v2",
|
|
|
|
"kvm",
|
|
|
|
"drive-format",
|
2019-04-03 07:13:21 +00:00
|
|
|
"vga",
|
2011-05-04 11:55:38 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 15 */
|
2011-05-04 11:55:38 +00:00
|
|
|
"0.10",
|
|
|
|
"pci-device",
|
|
|
|
"mem-path",
|
|
|
|
"drive-serial",
|
2019-04-03 07:13:21 +00:00
|
|
|
"xen-domid",
|
2011-05-04 11:55:38 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 20 */
|
2011-05-04 11:55:38 +00:00
|
|
|
"migrate-qemu-unix",
|
|
|
|
"chardev",
|
|
|
|
"enable-kvm",
|
|
|
|
"monitor-json",
|
2019-04-03 07:13:21 +00:00
|
|
|
"balloon",
|
2011-05-04 11:55:38 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 25 */
|
2011-05-04 11:55:38 +00:00
|
|
|
"device",
|
|
|
|
"sdl",
|
|
|
|
"smp-topology",
|
|
|
|
"netdev",
|
2019-04-03 07:13:21 +00:00
|
|
|
"rtc",
|
2011-05-04 11:55:38 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 30 */
|
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",
|
2019-04-03 07:13:21 +00:00
|
|
|
"tdf",
|
2011-05-04 11:55:38 +00:00
|
|
|
|
2017-06-20 14:15:11 +00:00
|
|
|
/* 35 */
|
2011-05-04 11:55:38 +00:00
|
|
|
"pci-configfd",
|
|
|
|
"nodefconfig",
|
|
|
|
"boot-menu",
|
2017-06-20 14:15:11 +00:00
|
|
|
"fsdev",
|
2011-05-04 11:55:38 +00:00
|
|
|
"nesting",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 40 */
|
2011-05-04 11:55:38 +00:00
|
|
|
"name-process",
|
|
|
|
"drive-readonly",
|
|
|
|
"smbios-type",
|
2017-06-20 14:15:11 +00:00
|
|
|
"vga-qxl",
|
2011-05-04 11:55:38 +00:00
|
|
|
"spice",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 45 */
|
2011-05-04 11:55:38 +00:00
|
|
|
"vga-none",
|
|
|
|
"migrate-qemu-fd",
|
|
|
|
"boot-index",
|
2017-06-20 14:15:11 +00:00
|
|
|
"hda-duplex",
|
2011-05-04 11:55:38 +00:00
|
|
|
"drive-aio",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 50 */
|
2011-05-04 11:55:38 +00:00
|
|
|
"pci-multibus",
|
|
|
|
"pci-bootindex",
|
|
|
|
"ccid-emulated",
|
2017-06-20 14:15:11 +00:00
|
|
|
"ccid-passthru",
|
2011-05-04 11:55:38 +00:00
|
|
|
"chardev-spicevmc",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 55 */
|
2011-05-04 11:55:38 +00:00
|
|
|
"device-spicevmc",
|
|
|
|
"virtio-tx-alg",
|
|
|
|
"device-qxl-vga",
|
2017-06-20 14:15:11 +00:00
|
|
|
"pci-multifunction",
|
2011-06-20 08:26:47 +00:00
|
|
|
"virtio-blk-pci.ioeventfd",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 60 */
|
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",
|
2017-06-20 14:15:11 +00:00
|
|
|
"cache-directsync",
|
2011-09-02 12:56:50 +00:00
|
|
|
"piix3-usb-uhci",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 65 */
|
2011-09-02 12:56:50 +00:00
|
|
|
"piix4-usb-uhci",
|
|
|
|
"usb-ehci",
|
|
|
|
"ich9-usb-ehci1",
|
2017-06-20 14:15:11 +00:00
|
|
|
"vt82c686b-usb-uhci",
|
2011-09-02 12:56:50 +00:00
|
|
|
"pci-ohci",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 70 */
|
2011-09-02 12:56:50 +00:00
|
|
|
"usb-redir",
|
2011-09-02 14:20:40 +00:00
|
|
|
"usb-hub",
|
2011-09-21 08:25:29 +00:00
|
|
|
"no-shutdown",
|
2017-06-20 14:15:11 +00:00
|
|
|
"cache-unsafe",
|
2011-09-20 17:31:52 +00:00
|
|
|
"rombar",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 75 */
|
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",
|
2017-06-20 14:15:11 +00:00
|
|
|
"virtio-blk-pci.scsi",
|
2011-11-29 18:37:27 +00:00
|
|
|
"blk-sg-io",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 80 */
|
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",
|
2017-06-20 14:15:11 +00:00
|
|
|
"drive-iotune",
|
2012-02-13 11:19:24 +00:00
|
|
|
"system_wakeup",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 85 */
|
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",
|
2017-06-20 14:15:11 +00:00
|
|
|
"block-job-sync",
|
2012-04-11 21:40:16 +00:00
|
|
|
"block-job-async",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 90 */
|
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",
|
2017-06-20 14:15:11 +00:00
|
|
|
"hda-micro",
|
2012-06-12 03:06:33 +00:00
|
|
|
"dump-guest-memory",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 95 */
|
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",
|
2017-06-20 14:15:11 +00:00
|
|
|
"bridge",
|
2012-08-08 06:25:24 +00:00
|
|
|
"lsi",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 100 */
|
2012-08-08 06:25:24 +00:00
|
|
|
"virtio-scsi-pci",
|
2012-09-04 14:30:55 +00:00
|
|
|
"blockio",
|
2012-08-02 10:14:39 +00:00
|
|
|
"disable-s3",
|
2017-06-20 14:15:11 +00:00
|
|
|
"disable-s4",
|
2012-08-19 15:42:44 +00:00
|
|
|
"usb-redir.filter",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 105 */
|
2012-09-18 02:12:11 +00:00
|
|
|
"ide-drive.wwn",
|
|
|
|
"scsi-disk.wwn",
|
2012-09-18 07:24:51 +00:00
|
|
|
"seccomp-sandbox",
|
2017-06-20 14:15:11 +00:00
|
|
|
"reboot-timeout",
|
2012-08-15 07:59:24 +00:00
|
|
|
"dump-guest-core",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 110 */
|
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",
|
2017-06-20 14:15:11 +00:00
|
|
|
"drive-mirror",
|
2012-11-14 14:51:30 +00:00
|
|
|
"usb-redir.bootindex",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 115 */
|
2012-11-14 14:51:30 +00:00
|
|
|
"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
|
|
|
"VGA",
|
2012-12-14 07:06:31 +00:00
|
|
|
"cirrus-vga",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 120 */
|
2012-12-14 07:06:31 +00:00
|
|
|
"vmware-svga",
|
|
|
|
"device-video-primary",
|
2013-01-07 17:17:15 +00:00
|
|
|
"s390-sclp",
|
2017-06-20 14:15:11 +00:00
|
|
|
"usb-serial",
|
2013-01-03 07:13:05 +00:00
|
|
|
"usb-net",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 125 */
|
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
|
|
|
"rng-random",
|
2013-02-13 10:22:23 +00:00
|
|
|
"rng-egd",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 130 */
|
2013-03-14 04:49:43 +00:00
|
|
|
"virtio-ccw",
|
|
|
|
"dtb",
|
2013-03-21 14:11:39 +00:00
|
|
|
"megasas",
|
2017-06-20 14:15:11 +00:00
|
|
|
"ipv6-migration",
|
2013-03-29 05:22:46 +00:00
|
|
|
"machine-opt",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 135 */
|
2013-04-07 08:31:57 +00:00
|
|
|
"machine-usb-opt",
|
2013-04-12 20:55:45 +00:00
|
|
|
"tpm-passthrough",
|
|
|
|
"tpm-tis",
|
2017-06-20 14:15:11 +00:00
|
|
|
"nvram",
|
2013-05-03 18:07:21 +00:00
|
|
|
"pci-bridge",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 140 */
|
2013-05-03 18:07:21 +00:00
|
|
|
"vfio-pci",
|
|
|
|
"vfio-pci.bootindex",
|
|
|
|
"scsi-generic",
|
2017-06-20 14:15:11 +00:00
|
|
|
"scsi-generic.bootindex",
|
2013-05-14 05:25:49 +00:00
|
|
|
"mem-merge",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 145 */
|
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",
|
2017-06-20 14:15:11 +00:00
|
|
|
"vnc-share-policy",
|
2013-07-11 15:07:26 +00:00
|
|
|
"device-del-event",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 150 */
|
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",
|
2017-06-20 14:15:11 +00:00
|
|
|
"usb-storage",
|
2013-08-23 10:38:11 +00:00
|
|
|
"usb-storage.removable",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 155 */
|
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",
|
2017-06-20 14:15:11 +00:00
|
|
|
"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",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 160 */
|
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
|
|
|
"enable-fips",
|
2014-01-30 11:19:12 +00:00
|
|
|
"spice-file-xfer-disable",
|
|
|
|
"spiceport",
|
2017-06-20 14:15:11 +00:00
|
|
|
"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",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 165 */
|
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",
|
2017-06-20 14:15:11 +00:00
|
|
|
"memory-backend-ram",
|
2014-06-17 11:43:19 +00:00
|
|
|
"numa",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 170 */
|
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",
|
2017-06-20 14:15:11 +00:00
|
|
|
"splash-timeout",
|
2014-08-22 22:15:30 +00:00
|
|
|
"iothread",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 175 */
|
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",
|
2017-06-20 14:15:11 +00:00
|
|
|
"VGA.vgamem_mb",
|
2014-11-12 12:58:33 +00:00
|
|
|
"vmware-svga.vgamem_mb",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 180 */
|
2014-11-12 12:58:33 +00:00
|
|
|
"qxl.vgamem_mb",
|
|
|
|
"qxl-vga.vgamem_mb",
|
2014-10-06 12:16:47 +00:00
|
|
|
"pc-dimm",
|
2017-06-20 14:15:11 +00:00
|
|
|
"machine-vmport-opt",
|
2015-04-27 21:57:29 +00:00
|
|
|
"aes-key-wrap",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 185 */
|
2015-04-27 21:57:29 +00:00
|
|
|
"dea-key-wrap",
|
2015-05-06 15:50:03 +00:00
|
|
|
"pci-serial",
|
2015-05-21 22:18:20 +00:00
|
|
|
"aarch64-off",
|
2017-06-20 14:15:11 +00:00
|
|
|
"vhost-user-multiqueue",
|
2015-05-28 11:35:52 +00:00
|
|
|
"migration-event",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 190 */
|
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",
|
2017-06-20 14:15:11 +00:00
|
|
|
"xio3130-downstream",
|
2015-09-04 14:23:46 +00:00
|
|
|
"rtl8139",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 195 */
|
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",
|
2017-06-20 14:15:11 +00:00
|
|
|
"incoming-defer",
|
2015-11-25 08:42:32 +00:00
|
|
|
"virtio-gpu",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 200 */
|
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
|
|
|
"virtio-tablet",
|
2015-11-13 14:41:20 +00:00
|
|
|
"virtio-input-host",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 205 */
|
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",
|
2017-06-20 14:15:11 +00:00
|
|
|
"vserport-change-event",
|
2016-01-08 10:45:06 +00:00
|
|
|
"virtio-balloon-pci.deflate-on-oom",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 210 */
|
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
|
|
|
"qxl-vga.vram64_size_mb",
|
2016-02-23 11:56:34 +00:00
|
|
|
"chardev-logfile",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 215 */
|
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",
|
2017-06-20 14:15:11 +00:00
|
|
|
"pxb-pcie",
|
2016-04-29 11:49:13 +00:00
|
|
|
"device-tray-moved-event",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 220 */
|
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",
|
2017-06-20 14:15:11 +00:00
|
|
|
"qxl.max_outputs",
|
2015-12-11 13:26:24 +00:00
|
|
|
"qxl-vga.max_outputs",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 225 */
|
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",
|
2017-06-20 14:15:11 +00:00
|
|
|
"display",
|
2016-06-22 15:24:24 +00:00
|
|
|
"intel-iommu",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 230 */
|
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",
|
2017-06-20 14:15:11 +00:00
|
|
|
"virtio-net.rx_queue_size",
|
2016-10-03 12:31:12 +00:00
|
|
|
"machine-iommu",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 235 */
|
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
|
|
|
"ivshmem-doorbell",
|
2016-10-19 12:40:53 +00:00
|
|
|
"query-qmp-schema",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 240 */
|
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",
|
2017-06-20 14:15:11 +00:00
|
|
|
"query-cpu-model-expansion",
|
2017-01-23 13:33:20 +00:00
|
|
|
"virtio-net.host_mtu",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 245 */
|
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-06-20 14:15:11 +00:00
|
|
|
"query-cpu-definitions",
|
2017-02-22 15:52:22 +00:00
|
|
|
"block-write-threshold",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 250 */
|
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-06-20 14:15:11 +00:00
|
|
|
"kernel-irqchip",
|
2017-03-17 07:26:49 +00:00
|
|
|
"kernel-irqchip.split",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 255 */
|
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-06-20 14:15:11 +00:00
|
|
|
"intel-iommu.device-iotlb",
|
2017-05-24 15:09:12 +00:00
|
|
|
"virtio.iommu_platform",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 260 */
|
2017-05-24 15:09:12 +00:00
|
|
|
"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-21 08:02:32 +00:00
|
|
|
"spapr-pci-host-bridge.numa_node",
|
2017-07-12 12:19:26 +00:00
|
|
|
"vnc-multi-servers",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 265 */
|
2017-07-12 12:19:26 +00:00
|
|
|
"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
|
|
|
"vxhs",
|
2017-09-30 17:15:35 +00:00
|
|
|
"virtio-blk.num-queues",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 270 */
|
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
|
|
|
"sclplmconsole",
|
2017-11-14 13:29:20 +00:00
|
|
|
"numa.dist",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 275 */
|
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
|
|
|
"pl011",
|
2018-01-05 13:47:46 +00:00
|
|
|
"machine.pseries.max-cpu-compat",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 280 */
|
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",
|
|
|
|
"virtio-mouse-ccw",
|
|
|
|
"virtio-tablet-ccw",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 285 */
|
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
|
|
|
"query-cpus-fast",
|
2018-04-03 17:11:22 +00:00
|
|
|
"disk-write-cache",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 290 */
|
2018-04-26 11:11:05 +00:00
|
|
|
"nbd-tls",
|
2018-04-26 17:42:17 +00:00
|
|
|
"tpm-crb",
|
2018-02-19 06:41:25 +00:00
|
|
|
"pr-manager-helper",
|
2018-04-20 08:31:54 +00:00
|
|
|
"qom-list-properties",
|
2018-04-20 08:25:49 +00:00
|
|
|
"memory-backend-file.discard-data",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 295 */
|
2018-05-07 14:41:11 +00:00
|
|
|
"virtual-css-bridge",
|
2018-05-07 14:41:12 +00:00
|
|
|
"virtual-css-bridge.cssid-unrestricted",
|
|
|
|
"vfio-ccw",
|
2018-05-10 10:53:58 +00:00
|
|
|
"sdl-gl",
|
2018-05-17 09:41:37 +00:00
|
|
|
"screendump_device",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 300 */
|
2018-05-22 11:12:33 +00:00
|
|
|
"hda-output",
|
2018-03-29 11:22:04 +00:00
|
|
|
"blockdev-del",
|
2018-03-16 21:23:05 +00:00
|
|
|
"vmgenid",
|
2017-11-01 15:13:27 +00:00
|
|
|
"vhost-vsock",
|
2018-03-14 10:34:37 +00:00
|
|
|
"chardev-fd-pass",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 305 */
|
2017-04-04 16:22:31 +00:00
|
|
|
"tpm-emulator",
|
2018-05-10 21:27:57 +00:00
|
|
|
"mch",
|
|
|
|
"mch.extended-tseg-mbytes",
|
2018-06-08 14:40:51 +00:00
|
|
|
"sev-guest",
|
2018-06-19 11:51:05 +00:00
|
|
|
"machine.pseries.cap-hpt-max-page-size",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 310 */
|
2018-06-19 11:51:05 +00:00
|
|
|
"machine.pseries.cap-htm",
|
2018-07-09 14:35:02 +00:00
|
|
|
"usb-storage.werror",
|
2018-06-30 14:16:24 +00:00
|
|
|
"egl-headless",
|
2018-05-24 15:27:33 +00:00
|
|
|
"vfio-pci.display",
|
2018-03-28 15:57:14 +00:00
|
|
|
"blockdev",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 315 */
|
2018-10-18 14:54:06 +00:00
|
|
|
"vfio-ap",
|
2018-11-08 11:00:20 +00:00
|
|
|
"zpci",
|
2018-11-15 11:55:51 +00:00
|
|
|
"memory-backend-memfd",
|
2018-11-15 11:55:52 +00:00
|
|
|
"memory-backend-memfd.hugetlb",
|
2018-10-05 19:59:49 +00:00
|
|
|
"iothread.poll-max-ns",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 320 */
|
2018-11-20 12:56:38 +00:00
|
|
|
"machine.pseries.cap-nested-hv",
|
2018-12-20 09:14:43 +00:00
|
|
|
"egl-headless.rendernode",
|
|
|
|
"memory-backend-file.align",
|
2018-12-20 09:14:44 +00:00
|
|
|
"memory-backend-file.pmem",
|
2018-12-20 09:14:45 +00:00
|
|
|
"nvdimm.unarmed",
|
2019-04-03 07:13:21 +00:00
|
|
|
|
|
|
|
/* 325 */
|
2019-01-28 08:30:41 +00:00
|
|
|
"scsi-disk.device_id",
|
2019-01-22 18:17:06 +00:00
|
|
|
"virtio-pci-non-transitional",
|
2019-04-12 08:16:06 +00:00
|
|
|
"overcommit",
|
2019-04-24 21:16:27 +00:00
|
|
|
"query-current-machine",
|
2019-05-17 07:15:27 +00:00
|
|
|
"machine.virt.iommu",
|
2019-06-06 02:25:05 +00:00
|
|
|
|
|
|
|
/* 330 */
|
|
|
|
"bitmap-merge",
|
|
|
|
"nbd-bitmap",
|
2019-06-10 14:46:10 +00:00
|
|
|
"x86-max-cpu",
|
2019-06-10 14:49:22 +00:00
|
|
|
"cpu-unavailable-features",
|
2019-06-07 13:00:28 +00:00
|
|
|
"canonical-cpu-features",
|
2019-07-12 20:12:15 +00:00
|
|
|
|
|
|
|
/* 335 */
|
|
|
|
"bochs-display",
|
2019-08-13 13:17:36 +00:00
|
|
|
"migration-file-drop-cache",
|
2019-08-08 14:54:57 +00:00
|
|
|
"dbus-vmstate",
|
2019-09-23 10:44:29 +00:00
|
|
|
"vhost-user-gpu",
|
|
|
|
"vhost-user-vga",
|
2019-09-26 11:01:30 +00:00
|
|
|
|
|
|
|
/* 340 */
|
|
|
|
"incremental-backup",
|
2019-09-19 20:24:59 +00:00
|
|
|
"query-cpu-model-baseline",
|
2019-09-19 20:25:03 +00:00
|
|
|
"query-cpu-model-comparison",
|
2019-09-13 21:20:28 +00:00
|
|
|
"ramfb",
|
2019-10-08 20:06:23 +00:00
|
|
|
"machine.pseries.cap-ccf-assist",
|
2019-07-08 11:21:00 +00:00
|
|
|
|
|
|
|
/* 345 */
|
|
|
|
"arm-max-cpu",
|
2019-04-08 15:10:37 +00:00
|
|
|
"blockdev-file-dynamic-auto-read-only",
|
2019-09-17 15:10:08 +00:00
|
|
|
"savevm-monitor-nodes",
|
2019-06-05 14:11:03 +00:00
|
|
|
"drive-nvme",
|
2019-12-16 15:28:09 +00:00
|
|
|
"smp-dies",
|
2020-01-15 12:23:56 +00:00
|
|
|
|
|
|
|
/* 350 */
|
|
|
|
"i8042",
|
2020-01-09 08:00:05 +00:00
|
|
|
"rng-builtin",
|
2019-12-08 19:22:34 +00:00
|
|
|
"virtio-net.failover",
|
2020-02-05 18:35:47 +00:00
|
|
|
"tpm-spapr",
|
2020-01-31 13:28:57 +00:00
|
|
|
"cpu.kvm-no-adjvtime",
|
2019-02-06 12:29:00 +00:00
|
|
|
|
|
|
|
/* 355 */
|
|
|
|
"vhost-user-fs",
|
2020-01-21 14:13:47 +00:00
|
|
|
"query-named-block-nodes.flat",
|
2020-03-05 13:28:50 +00:00
|
|
|
"blockdev-snapshot.allow-write-only-overlay",
|
2020-02-27 11:23:29 +00:00
|
|
|
"blockdev-reopen",
|
2020-04-01 08:22:30 +00:00
|
|
|
"storage.werror",
|
2020-03-30 18:04:47 +00:00
|
|
|
|
|
|
|
/* 360 */
|
|
|
|
"fsdev.multidevs",
|
2020-04-06 13:13:24 +00:00
|
|
|
"virtio.packed",
|
2020-02-27 20:22:59 +00:00
|
|
|
"pcie-root-port.hotplug",
|
2020-04-21 12:19:34 +00:00
|
|
|
"aio.io_uring",
|
2020-04-27 12:14:26 +00:00
|
|
|
"machine.pseries.cap-cfpc",
|
2020-04-27 12:14:28 +00:00
|
|
|
|
|
|
|
/* 365 */
|
|
|
|
"machine.pseries.cap-sbbc",
|
2020-04-27 12:14:30 +00:00
|
|
|
"machine.pseries.cap-ibs",
|
2020-04-28 09:04:14 +00:00
|
|
|
"tcg",
|
2020-05-06 20:01:51 +00:00
|
|
|
"virtio-blk-pci.scsi.default.disabled",
|
2020-05-13 01:55:45 +00:00
|
|
|
"pvscsi",
|
2020-06-02 18:15:53 +00:00
|
|
|
|
|
|
|
/* 370 */
|
|
|
|
"cpu.migratable",
|
2020-06-02 23:05:36 +00:00
|
|
|
"query-cpu-model-expansion.migratable",
|
2020-06-02 14:57:56 +00:00
|
|
|
"fw_cfg",
|
2020-06-10 13:09:00 +00:00
|
|
|
"migration-param.bandwidth",
|
|
|
|
"migration-param.downtime",
|
|
|
|
|
|
|
|
/* 375 */
|
|
|
|
"migration-param.xbzrle-cache-size",
|
2020-06-04 07:42:43 +00:00
|
|
|
"intel-iommu.aw-bits",
|
2020-06-10 18:11:44 +00:00
|
|
|
"spapr-tpm-proxy",
|
2020-05-27 09:00:07 +00:00
|
|
|
"numa.hmat",
|
2020-08-03 14:20:28 +00:00
|
|
|
"blockdev-hostdev-scsi",
|
2020-09-09 09:13:52 +00:00
|
|
|
|
|
|
|
/* 380 */
|
|
|
|
"usb-host.hostdevice",
|
2020-10-12 23:35:37 +00:00
|
|
|
"virtio-balloon.free-page-reporting",
|
2020-10-14 09:42:58 +00:00
|
|
|
"block-export-add",
|
2020-10-14 17:08:26 +00:00
|
|
|
"netdev.vhost-vdpa",
|
2020-10-08 14:32:23 +00:00
|
|
|
"fsdev.createmode",
|
2020-11-18 16:37:54 +00:00
|
|
|
|
|
|
|
/* 385 */
|
|
|
|
"ncr53c90",
|
|
|
|
"dc390",
|
|
|
|
"am53c974",
|
2021-01-15 12:31:51 +00:00
|
|
|
"virtio-pmem-pci",
|
2021-01-04 15:03:57 +00:00
|
|
|
"vhost-user-fs.bootindex",
|
2021-02-02 12:37:02 +00:00
|
|
|
|
|
|
|
/* 390 */
|
|
|
|
"vhost-user-blk",
|
2021-02-05 18:21:14 +00:00
|
|
|
"cpu-max",
|
2021-01-11 17:15:57 +00:00
|
|
|
"memory-backend-file.x-use-canonical-path-for-ramblock-id",
|
2021-02-16 11:45:46 +00:00
|
|
|
"vnc-opts",
|
2020-08-07 09:29:18 +00:00
|
|
|
"migration-param.block-bitmap-mapping",
|
2021-02-16 13:34:26 +00:00
|
|
|
|
|
|
|
/* 395 */
|
|
|
|
"vnc-power-control",
|
2021-02-23 16:16:28 +00:00
|
|
|
"audiodev",
|
2011-05-04 11:55:38 +00:00
|
|
|
);
|
|
|
|
|
2014-03-05 16:51:59 +00:00
|
|
|
|
2019-10-30 00:04:06 +00:00
|
|
|
typedef struct _virQEMUCapsMachineType virQEMUCapsMachineType;
|
|
|
|
typedef virQEMUCapsMachineType *virQEMUCapsMachineTypePtr;
|
|
|
|
struct _virQEMUCapsMachineType {
|
2016-07-29 08:13:46 +00:00
|
|
|
char *name;
|
|
|
|
char *alias;
|
|
|
|
unsigned int maxCpus;
|
2016-07-29 07:45:19 +00:00
|
|
|
bool hotplugCpus;
|
2018-08-10 12:18:27 +00:00
|
|
|
bool qemuDefault;
|
2019-07-18 17:21:55 +00:00
|
|
|
char *defaultCPU;
|
2020-05-14 11:11:01 +00:00
|
|
|
bool numaMemSupported;
|
2020-05-25 17:13:43 +00:00
|
|
|
char *defaultRAMid;
|
2021-01-22 12:16:23 +00:00
|
|
|
bool deprecated;
|
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
|
2020-07-09 04:42:21 +00:00
|
|
|
* re-computed from other fields and external data sources every time we
|
2017-04-07 16:15:26 +00:00
|
|
|
* 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
|
|
|
};
|
|
|
|
|
2019-10-23 10:29:52 +00:00
|
|
|
typedef struct _virQEMUCapsAccel virQEMUCapsAccel;
|
|
|
|
typedef virQEMUCapsAccel *virQEMUCapsAccelPtr;
|
|
|
|
struct _virQEMUCapsAccel {
|
2019-10-24 12:19:38 +00:00
|
|
|
size_t nmachineTypes;
|
|
|
|
virQEMUCapsMachineTypePtr machineTypes;
|
2019-10-23 10:29:52 +00:00
|
|
|
virQEMUCapsHostCPUData hostCPU;
|
|
|
|
qemuMonitorCPUDefsPtr cpuModels;
|
|
|
|
};
|
|
|
|
|
2020-01-24 09:43:29 +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
|
|
|
|
2018-11-12 19:58:09 +00:00
|
|
|
bool kvmSupportsNesting;
|
2020-06-15 08:28:07 +00:00
|
|
|
bool kvmSupportsSecureGuest;
|
2012-08-22 17:05:08 +00:00
|
|
|
|
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;
|
2020-08-20 21:52:17 +00:00
|
|
|
time_t modDirMtime;
|
2019-12-20 11:56:38 +00:00
|
|
|
bool invalidation;
|
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;
|
2020-05-15 20:00:29 +00:00
|
|
|
char *hostCPUSignature;
|
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-03-08 17:24:18 +00:00
|
|
|
size_t ngicCapabilities;
|
|
|
|
virGICCapability *gicCapabilities;
|
2016-06-15 12:35:18 +00:00
|
|
|
|
2018-06-08 14:40:51 +00:00
|
|
|
virSEVCapability *sevCapabilities;
|
|
|
|
|
2019-10-23 10:29:52 +00:00
|
|
|
/* Capabilities which may differ depending on the accelerator. */
|
|
|
|
virQEMUCapsAccel kvm;
|
|
|
|
virQEMUCapsAccel tcg;
|
2012-08-20 16:44:14 +00:00
|
|
|
};
|
|
|
|
|
2014-06-30 14:12:07 +00:00
|
|
|
struct virQEMUCapsSearchData {
|
|
|
|
virArch arch;
|
2018-09-14 12:36:15 +00:00
|
|
|
const char *binaryFilter;
|
2014-06-30 14:12:07 +00:00
|
|
|
};
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-01-20 17:23:29 +00:00
|
|
|
VIR_ONCE_GLOBAL_INIT(virQEMUCaps);
|
2012-08-20 16:44:14 +00:00
|
|
|
|
2019-02-26 09:42:38 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-02-26 09:42:38 +00:00
|
|
|
const char *virQEMUCapsArchToString(virArch arch)
|
2012-12-11 13:06:45 +00:00
|
|
|
{
|
|
|
|
if (arch == VIR_ARCH_I686)
|
|
|
|
return "i386";
|
2018-11-28 21:45:14 +00:00
|
|
|
else if (arch == VIR_ARCH_ARMV6L || arch == VIR_ARCH_ARMV7L)
|
2012-12-11 13:06:45 +00:00
|
|
|
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)
|
|
|
|
{
|
2018-09-18 11:32:29 +00:00
|
|
|
/* host & guest arches match */
|
2016-06-14 15:25:58 +00:00
|
|
|
if (host == guest)
|
|
|
|
return true;
|
|
|
|
|
2018-09-18 11:32:29 +00:00
|
|
|
/* hostarch is x86_64 and guest arch is i686 (needs -cpu qemu32) */
|
2016-06-14 15:25:58 +00:00
|
|
|
if (host == VIR_ARCH_X86_64 && guest == VIR_ARCH_I686)
|
|
|
|
return true;
|
|
|
|
|
2018-09-18 11:32:29 +00:00
|
|
|
/* hostarch is aarch64 and guest arch is armv7l (needs -cpu aarch64=off) */
|
2016-06-14 15:25:58 +00:00
|
|
|
if (host == VIR_ARCH_AARCH64 && guest == VIR_ARCH_ARMV7L)
|
|
|
|
return true;
|
|
|
|
|
2018-09-18 11:32:29 +00:00
|
|
|
/* hostarch and guestarch are both ppc64 */
|
2016-06-14 15:25:58 +00:00
|
|
|
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
|
|
|
|
2019-10-23 10:46:28 +00:00
|
|
|
static virQEMUCapsAccelPtr
|
|
|
|
virQEMUCapsGetAccel(virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainVirtType type)
|
|
|
|
{
|
|
|
|
if (type == VIR_DOMAIN_VIRT_KVM)
|
|
|
|
return &qemuCaps->kvm;
|
|
|
|
|
|
|
|
return &qemuCaps->tcg;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-30 18:22:42 +00:00
|
|
|
static void
|
2019-10-24 12:19:38 +00:00
|
|
|
virQEMUCapsSetDefaultMachine(virQEMUCapsAccelPtr caps,
|
2013-02-01 13:48:58 +00:00
|
|
|
size_t defIdx)
|
2012-11-30 18:22:42 +00:00
|
|
|
{
|
2019-10-24 12:19:38 +00:00
|
|
|
virQEMUCapsMachineType tmp = caps->machineTypes[defIdx];
|
2013-02-01 13:48:58 +00:00
|
|
|
|
2019-10-24 12:19:38 +00:00
|
|
|
memmove(caps->machineTypes + 1,
|
|
|
|
caps->machineTypes,
|
|
|
|
sizeof(caps->machineTypes[0]) * defIdx);
|
2016-07-29 08:13:46 +00:00
|
|
|
|
2019-10-24 12:19:38 +00:00
|
|
|
caps->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
|
|
|
|
2019-10-22 13:26:14 +00:00
|
|
|
binary = g_strdup_printf(format, archstr);
|
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;
|
|
|
|
|
2018-09-18 14:27:42 +00:00
|
|
|
/* armv7l guests can only take advantage of KVM on aarch64 hosts by
|
|
|
|
* using the qemu-system-aarch64 binary, so look for that one first
|
|
|
|
* to avoid using qemu-system-arm (and thus TCG) instead */
|
|
|
|
if (hostarch == VIR_ARCH_AARCH64 && guestarch == VIR_ARCH_ARMV7L) {
|
|
|
|
archstr = virQEMUCapsArchToString(hostarch);
|
|
|
|
if ((ret = virQEMUCapsFindBinary("qemu-system-%s", archstr)) != NULL)
|
2020-01-06 21:57:40 +00:00
|
|
|
return ret;
|
2018-09-18 14:27:42 +00:00
|
|
|
}
|
|
|
|
|
2015-09-15 13:58:09 +00:00
|
|
|
/* First attempt: try the guest architecture as it is */
|
|
|
|
archstr = virQEMUCapsArchToString(guestarch);
|
|
|
|
if ((ret = virQEMUCapsFindBinary("qemu-system-%s", archstr)) != NULL)
|
2020-01-06 21:57:40 +00:00
|
|
|
return ret;
|
2015-09-15 13:58:09 +00:00
|
|
|
|
|
|
|
/* 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)
|
2020-01-06 21:57:40 +00:00
|
|
|
return ret;
|
2012-12-11 13:06:45 +00:00
|
|
|
}
|
2012-08-22 16:59:39 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-11-26 16:53:53 +00:00
|
|
|
|
|
|
|
char *
|
|
|
|
virQEMUCapsGetDefaultEmulator(virArch hostarch,
|
|
|
|
virArch guestarch)
|
2010-12-16 15:07:07 +00:00
|
|
|
{
|
|
|
|
char *binary = NULL;
|
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
|
|
|
|
2018-09-18 15:45:40 +00:00
|
|
|
/* RHEL doesn't follow the usual naming for QEMU binaries and ships
|
|
|
|
* a single binary named qemu-kvm outside of $PATH instead */
|
2019-10-20 11:49:46 +00:00
|
|
|
if (virQEMUCapsGuestIsNative(hostarch, guestarch) && !binary)
|
|
|
|
binary = g_strdup("/usr/libexec/qemu-kvm");
|
2018-09-18 15:45:40 +00:00
|
|
|
|
2019-11-26 16:53:53 +00:00
|
|
|
return binary;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
virQEMUCapsInitGuest(virCapsPtr caps,
|
|
|
|
virFileCachePtr cache,
|
|
|
|
virArch hostarch,
|
|
|
|
virArch guestarch)
|
|
|
|
{
|
|
|
|
char *binary = NULL;
|
|
|
|
virQEMUCapsPtr qemuCaps = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
binary = virQEMUCapsGetDefaultEmulator(hostarch, guestarch);
|
|
|
|
|
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) {
|
2018-09-18 16:24:35 +00:00
|
|
|
if (!(qemuCaps = virQEMUCapsCacheLookup(cache, binary))) {
|
2012-08-22 13:37:05 +00:00
|
|
|
virResetLastError();
|
|
|
|
VIR_FREE(binary);
|
|
|
|
}
|
|
|
|
}
|
2012-07-13 14:30:55 +00:00
|
|
|
|
2014-03-17 15:19:45 +00:00
|
|
|
ret = virQEMUCapsInitGuestFromBinary(caps,
|
2018-09-18 16:24:35 +00:00
|
|
|
binary, qemuCaps,
|
2014-03-17 15:19:45 +00:00
|
|
|
guestarch);
|
|
|
|
|
|
|
|
VIR_FREE(binary);
|
2018-09-18 16:24:35 +00:00
|
|
|
virObjectUnref(qemuCaps);
|
2014-03-17 15:19:45 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-10-23 15:08:57 +00:00
|
|
|
|
|
|
|
static int
|
|
|
|
virQEMUCapsGetMachineTypesCaps(virQEMUCapsPtr qemuCaps,
|
|
|
|
size_t *nmachines,
|
|
|
|
virCapsGuestMachinePtr **machines)
|
|
|
|
{
|
|
|
|
size_t i;
|
2019-10-24 12:19:38 +00:00
|
|
|
virQEMUCapsAccelPtr accel;
|
|
|
|
|
|
|
|
/* Guest capabilities do not report TCG vs. KVM caps separately. We just
|
|
|
|
* take the set of machine types we probed first. */
|
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM))
|
|
|
|
accel = &qemuCaps->kvm;
|
|
|
|
else
|
|
|
|
accel = &qemuCaps->tcg;
|
2019-10-23 15:08:57 +00:00
|
|
|
|
|
|
|
*machines = NULL;
|
2019-10-24 12:19:38 +00:00
|
|
|
*nmachines = accel->nmachineTypes;
|
2019-10-23 15:08:57 +00:00
|
|
|
|
2020-10-05 10:25:44 +00:00
|
|
|
if (*nmachines)
|
|
|
|
*machines = g_new0(virCapsGuestMachinePtr, accel->nmachineTypes);
|
2019-10-23 15:08:57 +00:00
|
|
|
|
2019-10-24 12:19:38 +00:00
|
|
|
for (i = 0; i < accel->nmachineTypes; i++) {
|
2019-10-23 15:08:57 +00:00
|
|
|
virCapsGuestMachinePtr mach;
|
2020-10-05 10:25:44 +00:00
|
|
|
mach = g_new0(virCapsGuestMachine, 1);
|
2019-10-23 15:08:57 +00:00
|
|
|
(*machines)[i] = mach;
|
2019-10-24 12:19:38 +00:00
|
|
|
if (accel->machineTypes[i].alias) {
|
|
|
|
mach->name = g_strdup(accel->machineTypes[i].alias);
|
|
|
|
mach->canonical = g_strdup(accel->machineTypes[i].name);
|
2019-10-23 15:08:57 +00:00
|
|
|
} else {
|
2019-10-24 12:19:38 +00:00
|
|
|
mach->name = g_strdup(accel->machineTypes[i].name);
|
2019-10-23 15:08:57 +00:00
|
|
|
}
|
2019-10-24 12:19:38 +00:00
|
|
|
mach->maxCpus = accel->machineTypes[i].maxCpus;
|
2021-01-22 12:16:23 +00:00
|
|
|
mach->deprecated = accel->machineTypes[i].deprecated;
|
2019-10-23 15:08:57 +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;
|
2020-10-05 10:25:44 +00:00
|
|
|
mach = g_new0(virCapsGuestMachine, 1);
|
2019-10-23 15:08:57 +00:00
|
|
|
if (VIR_INSERT_ELEMENT_COPY(*machines, i, *nmachines, mach) < 0) {
|
|
|
|
VIR_FREE(mach);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
mach->name = g_strdup(machine->canonical);
|
|
|
|
mach->maxCpus = machine->maxCpus;
|
2021-01-22 12:16:23 +00:00
|
|
|
mach->deprecated = machine->deprecated;
|
2019-10-23 15:08:57 +00:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
error:
|
|
|
|
virCapabilitiesFreeMachines(*machines, *nmachines);
|
|
|
|
*nmachines = 0;
|
|
|
|
*machines = NULL;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-17 15:19:45 +00:00
|
|
|
int
|
|
|
|
virQEMUCapsInitGuestFromBinary(virCapsPtr caps,
|
|
|
|
const char *binary,
|
2018-09-18 16:24:35 +00:00
|
|
|
virQEMUCapsPtr qemuCaps,
|
2014-03-17 15:19:45 +00:00
|
|
|
virArch guestarch)
|
|
|
|
{
|
|
|
|
virCapsGuestPtr guest;
|
|
|
|
virCapsGuestMachinePtr *machines = NULL;
|
|
|
|
size_t nmachines = 0;
|
|
|
|
int ret = -1;
|
|
|
|
|
2010-12-16 15:07:07 +00:00
|
|
|
if (!binary)
|
|
|
|
return 0;
|
|
|
|
|
2018-09-18 16:24:35 +00:00
|
|
|
if (virQEMUCapsGetMachineTypesCaps(qemuCaps, &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' */
|
2019-11-12 12:57:23 +00:00
|
|
|
virCapabilitiesAddGuestFeature(guest, VIR_CAPS_GUEST_FEATURE_TYPE_CPUSELECTION);
|
|
|
|
virCapabilitiesAddGuestFeature(guest, VIR_CAPS_GUEST_FEATURE_TYPE_DEVICEBOOT);
|
|
|
|
virCapabilitiesAddGuestFeatureWithToggle(guest, VIR_CAPS_GUEST_FEATURE_TYPE_DISKSNAPSHOT,
|
|
|
|
true, false);
|
2014-03-17 15:19:44 +00:00
|
|
|
|
2020-04-22 21:50:42 +00:00
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_TCG)) {
|
|
|
|
if (virCapabilitiesAddGuestDomain(guest,
|
|
|
|
VIR_DOMAIN_VIRT_QEMU,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
NULL) == NULL) {
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
}
|
2010-12-16 15:07:07 +00:00
|
|
|
|
2018-09-18 16:24:35 +00:00
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) {
|
2018-09-18 15:06:48 +00:00
|
|
|
if (virCapabilitiesAddGuestDomain(guest,
|
|
|
|
VIR_DOMAIN_VIRT_KVM,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
NULL) == NULL) {
|
2014-03-17 15:19:45 +00:00
|
|
|
goto cleanup;
|
2012-08-22 16:29:01 +00:00
|
|
|
}
|
2017-03-02 17:57:51 +00:00
|
|
|
}
|
2010-12-16 15:07:07 +00:00
|
|
|
|
2019-11-12 12:57:23 +00:00
|
|
|
if ((ARCH_IS_X86(guestarch) || guestarch == VIR_ARCH_AARCH64))
|
|
|
|
virCapabilitiesAddGuestFeatureWithToggle(guest, VIR_CAPS_GUEST_FEATURE_TYPE_ACPI,
|
|
|
|
true, true);
|
2010-12-16 15:07:07 +00:00
|
|
|
|
2019-11-12 12:57:23 +00:00
|
|
|
if (ARCH_IS_X86(guestarch))
|
|
|
|
virCapabilitiesAddGuestFeatureWithToggle(guest, VIR_CAPS_GUEST_FEATURE_TYPE_APIC,
|
|
|
|
true, false);
|
2012-08-22 16:59:39 +00:00
|
|
|
|
2019-11-12 12:57:23 +00:00
|
|
|
if (guestarch == VIR_ARCH_I686) {
|
|
|
|
virCapabilitiesAddGuestFeature(guest, VIR_CAPS_GUEST_FEATURE_TYPE_PAE);
|
|
|
|
virCapabilitiesAddGuestFeature(guest, VIR_CAPS_GUEST_FEATURE_TYPE_NONPAE);
|
|
|
|
}
|
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
|
2019-06-03 11:13:38 +00:00
|
|
|
virQEMUCapsProbeHostCPU(virArch hostArch,
|
|
|
|
virDomainCapsCPUModelsPtr models)
|
2017-03-08 12:32:46 +00:00
|
|
|
{
|
2019-06-03 11:13:38 +00:00
|
|
|
return virCPUGetHost(hostArch, VIR_CPU_TYPE_GUEST, NULL, models);
|
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
|
|
|
|
2017-03-29 13:52:31 +00:00
|
|
|
if (virCapabilitiesInitCaches(caps) < 0)
|
|
|
|
VIR_WARN("Failed to get host CPU cache info");
|
|
|
|
|
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");
|
|
|
|
|
2018-06-01 08:15:59 +00:00
|
|
|
/* Add IOMMU info */
|
|
|
|
virCapabilitiesHostInitIOMMU(caps);
|
|
|
|
|
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[] = {
|
|
|
|
{ "dump-guest-memory", QEMU_CAPS_DUMP_GUEST_MEMORY },
|
|
|
|
{ "query-spice", QEMU_CAPS_SPICE },
|
|
|
|
{ "query-vnc", QEMU_CAPS_VNC },
|
|
|
|
{ "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 },
|
2018-04-20 08:31:54 +00:00
|
|
|
{ "qom-list-properties", QEMU_CAPS_QOM_LIST_PROPERTIES },
|
2018-03-29 11:22:04 +00:00
|
|
|
{ "blockdev-del", QEMU_CAPS_BLOCKDEV_DEL },
|
2019-04-24 21:16:27 +00:00
|
|
|
{ "query-current-machine", QEMU_CAPS_QUERY_CURRENT_MACHINE },
|
2019-06-06 02:25:05 +00:00
|
|
|
{ "block-dirty-bitmap-merge", QEMU_CAPS_BITMAP_MERGE },
|
2019-09-19 20:24:59 +00:00
|
|
|
{ "query-cpu-model-baseline", QEMU_CAPS_QUERY_CPU_MODEL_BASELINE },
|
2019-09-19 20:25:03 +00:00
|
|
|
{ "query-cpu-model-comparison", QEMU_CAPS_QUERY_CPU_MODEL_COMPARISON },
|
2020-10-26 12:09:17 +00:00
|
|
|
{ "block-export-add", QEMU_CAPS_BLOCK_EXPORT_ADD },
|
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 },
|
|
|
|
};
|
|
|
|
|
2019-02-07 11:50:27 +00:00
|
|
|
/* Use virQEMUCapsQMPSchemaQueries for querying parameters of events */
|
2013-06-19 07:24:54 +00:00
|
|
|
struct virQEMUCapsStringFlags virQEMUCapsEvents[] = {
|
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 },
|
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 },
|
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 },
|
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 },
|
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 },
|
2018-03-26 10:27:16 +00:00
|
|
|
{ "pr-manager-helper", QEMU_CAPS_PR_MANAGER_HELPER },
|
2018-05-07 14:41:11 +00:00
|
|
|
{ "virtual-css-bridge", QEMU_CAPS_CCW },
|
2018-05-07 14:41:12 +00:00
|
|
|
{ "vfio-ccw", QEMU_CAPS_DEVICE_VFIO_CCW },
|
2018-05-22 11:12:33 +00:00
|
|
|
{ "hda-output", QEMU_CAPS_HDA_OUTPUT },
|
2018-03-16 21:23:05 +00:00
|
|
|
{ "vmgenid", QEMU_CAPS_DEVICE_VMGENID },
|
2017-11-01 15:13:27 +00:00
|
|
|
{ "vhost-vsock-device", QEMU_CAPS_DEVICE_VHOST_VSOCK },
|
2018-05-10 21:27:57 +00:00
|
|
|
{ "mch", QEMU_CAPS_DEVICE_MCH },
|
2018-06-08 14:40:51 +00:00
|
|
|
{ "sev-guest", QEMU_CAPS_SEV_GUEST },
|
2018-10-18 14:54:06 +00:00
|
|
|
{ "vfio-ap", QEMU_CAPS_DEVICE_VFIO_AP },
|
2018-11-08 11:00:20 +00:00
|
|
|
{ "zpci", QEMU_CAPS_DEVICE_ZPCI },
|
2018-11-15 11:55:51 +00:00
|
|
|
{ "memory-backend-memfd", QEMU_CAPS_OBJECT_MEMORY_MEMFD },
|
2019-01-22 18:17:06 +00:00
|
|
|
{ "virtio-blk-pci-transitional", QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL },
|
|
|
|
{ "virtio-blk-pci-non-transitional", QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL },
|
|
|
|
{ "virtio-net-pci-transitional", QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL },
|
|
|
|
{ "virtio-net-pci-non-transitional", QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL },
|
|
|
|
{ "vhost-scsi-pci-transitional", QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL },
|
|
|
|
{ "vhost-scsi-pci-non-transitional", QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL },
|
|
|
|
{ "virtio-rng-pci-transitional", QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL },
|
|
|
|
{ "virtio-rng-pci-non-transitional", QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL },
|
|
|
|
{ "virtio-9p-pci-transitional", QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL },
|
|
|
|
{ "virtio-9p-pci-non-transitional", QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL },
|
|
|
|
{ "virtio-balloon-pci-transitional", QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL },
|
|
|
|
{ "virtio-balloon-pci-non-transitional", QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL },
|
|
|
|
{ "vhost-vsock-pci-transitional", QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL },
|
|
|
|
{ "vhost-vsock-pci-non-transitional", QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL },
|
|
|
|
{ "virtio-input-host-pci-transitional", QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL },
|
|
|
|
{ "virtio-input-host-pci-non-transitional", QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL },
|
|
|
|
{ "virtio-scsi-pci-transitional", QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL },
|
|
|
|
{ "virtio-scsi-pci-non-transitional", QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL },
|
|
|
|
{ "virtio-serial-pci-transitional", QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL },
|
|
|
|
{ "virtio-serial-pci-non-transitional", QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL },
|
2019-06-10 14:46:10 +00:00
|
|
|
{ "max-x86_64-cpu", QEMU_CAPS_X86_MAX_CPU },
|
2019-07-12 20:12:15 +00:00
|
|
|
{ "bochs-display", QEMU_CAPS_DEVICE_BOCHS_DISPLAY },
|
2019-09-19 09:27:12 +00:00
|
|
|
{ "dbus-vmstate", QEMU_CAPS_DBUS_VMSTATE },
|
2019-09-23 10:44:29 +00:00
|
|
|
{ "vhost-user-gpu", QEMU_CAPS_DEVICE_VHOST_USER_GPU },
|
|
|
|
{ "vhost-user-vga", QEMU_CAPS_DEVICE_VHOST_USER_VGA },
|
2019-09-13 21:20:28 +00:00
|
|
|
{ "ramfb", QEMU_CAPS_DEVICE_RAMFB },
|
2019-07-08 11:21:00 +00:00
|
|
|
{ "max-arm-cpu", QEMU_CAPS_ARM_MAX_CPU },
|
2020-01-15 12:23:56 +00:00
|
|
|
{ "i8042", QEMU_CAPS_DEVICE_I8042 },
|
2020-01-09 08:00:05 +00:00
|
|
|
{ "rng-builtin", QEMU_CAPS_OBJECT_RNG_BUILTIN },
|
2020-02-05 18:35:47 +00:00
|
|
|
{ "tpm-spapr", QEMU_CAPS_DEVICE_TPM_SPAPR },
|
2019-02-06 12:29:00 +00:00
|
|
|
{ "vhost-user-fs-device", QEMU_CAPS_DEVICE_VHOST_USER_FS },
|
2020-04-28 09:04:14 +00:00
|
|
|
{ "tcg-accel", QEMU_CAPS_TCG },
|
2020-05-13 01:55:45 +00:00
|
|
|
{ "pvscsi", QEMU_CAPS_SCSI_PVSCSI },
|
2020-06-10 18:11:44 +00:00
|
|
|
{ "spapr-tpm-proxy", QEMU_CAPS_DEVICE_SPAPR_TPM_PROXY },
|
2020-11-18 16:37:54 +00:00
|
|
|
/*
|
|
|
|
* We don't probe 'esp' directly, because it is often reported
|
|
|
|
* as present for all QEMU binaries, due to it being enabled
|
|
|
|
* for built as a dependancy of dc390/am53c974 PCI SCSI
|
|
|
|
* controllers.
|
|
|
|
*
|
|
|
|
* The base 'esp' device is only used as a built-in device
|
|
|
|
* and is not user-creatable. So we turn this cap on later
|
|
|
|
* based on arch.
|
|
|
|
*
|
|
|
|
* { "esp", QEMU_CAPS_SCSI_NCR53C90 },
|
|
|
|
*/
|
|
|
|
{ "dc390", QEMU_CAPS_SCSI_DC390 },
|
|
|
|
{ "am53c974", QEMU_CAPS_SCSI_AM53C974 },
|
2021-01-15 12:31:51 +00:00
|
|
|
{ "virtio-pmem-pci", QEMU_CAPS_DEVICE_VIRTIO_PMEM_PCI },
|
2021-02-02 12:37:02 +00:00
|
|
|
{ "vhost-user-blk", QEMU_CAPS_DEVICE_VHOST_USER_BLK },
|
2012-09-13 17:04:24 +00:00
|
|
|
};
|
|
|
|
|
2020-05-06 19:29:55 +00:00
|
|
|
|
|
|
|
struct virQEMUCapsDevicePropsFlags {
|
|
|
|
const char *value;
|
|
|
|
int flag;
|
|
|
|
int (*cb)(virJSONValuePtr props, virQEMUCapsPtr caps);
|
2016-01-08 10:45:06 +00:00
|
|
|
};
|
|
|
|
|
2020-05-06 19:29:55 +00:00
|
|
|
|
|
|
|
static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsVirtioBalloon[] = {
|
|
|
|
{ "deflate-on-oom", QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE, NULL },
|
|
|
|
{ "disable-legacy", QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY, NULL },
|
|
|
|
{ "iommu_platform", QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM, NULL },
|
|
|
|
{ "ats", QEMU_CAPS_VIRTIO_PCI_ATS, NULL },
|
|
|
|
{ "packed", QEMU_CAPS_VIRTIO_PACKED_QUEUES, NULL },
|
2020-10-12 23:35:37 +00:00
|
|
|
{ "free-page-reporting", QEMU_CAPS_VIRTIO_BALLOON_FREE_PAGE_REPORTING, NULL },
|
2012-09-13 17:04:24 +00:00
|
|
|
};
|
|
|
|
|
2020-05-06 20:01:51 +00:00
|
|
|
|
|
|
|
static int
|
|
|
|
virQEMUCapsDevicePropsVirtioBlkSCSIDefault(virJSONValuePtr props,
|
|
|
|
virQEMUCapsPtr qemuCaps)
|
|
|
|
{
|
|
|
|
bool def = false;
|
|
|
|
|
|
|
|
if (virJSONValueObjectGetBoolean(props, "default-value", &def) < 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (def == false)
|
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_VIRTIO_BLK_SCSI_DEFAULT_DISABLED);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-05-06 19:29:55 +00:00
|
|
|
static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsVirtioBlk[] = {
|
|
|
|
{ "ioeventfd", QEMU_CAPS_VIRTIO_IOEVENTFD, NULL },
|
|
|
|
{ "event_idx", QEMU_CAPS_VIRTIO_BLK_EVENT_IDX, NULL },
|
2020-05-06 20:01:51 +00:00
|
|
|
{ "scsi", QEMU_CAPS_VIRTIO_BLK_SCSI, virQEMUCapsDevicePropsVirtioBlkSCSIDefault },
|
2020-05-06 19:29:55 +00:00
|
|
|
{ "logical_block_size", QEMU_CAPS_BLOCKIO, NULL },
|
|
|
|
{ "num-queues", QEMU_CAPS_VIRTIO_BLK_NUM_QUEUES, NULL },
|
|
|
|
{ "share-rw", QEMU_CAPS_DISK_SHARE_RW, NULL },
|
|
|
|
{ "disable-legacy", QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY, NULL },
|
|
|
|
{ "iommu_platform", QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM, NULL },
|
|
|
|
{ "ats", QEMU_CAPS_VIRTIO_PCI_ATS, NULL },
|
|
|
|
{ "write-cache", QEMU_CAPS_DISK_WRITE_CACHE, NULL },
|
|
|
|
{ "werror", QEMU_CAPS_STORAGE_WERROR, NULL },
|
|
|
|
{ "packed", QEMU_CAPS_VIRTIO_PACKED_QUEUES, NULL },
|
2012-09-13 17:04:24 +00:00
|
|
|
};
|
|
|
|
|
2020-05-06 19:29:55 +00:00
|
|
|
static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsVirtioNet[] = {
|
|
|
|
{ "tx", QEMU_CAPS_VIRTIO_TX_ALG, NULL },
|
|
|
|
{ "event_idx", QEMU_CAPS_VIRTIO_NET_EVENT_IDX, NULL },
|
|
|
|
{ "rx_queue_size", QEMU_CAPS_VIRTIO_NET_RX_QUEUE_SIZE, NULL },
|
|
|
|
{ "tx_queue_size", QEMU_CAPS_VIRTIO_NET_TX_QUEUE_SIZE, NULL },
|
|
|
|
{ "host_mtu", QEMU_CAPS_VIRTIO_NET_HOST_MTU, NULL },
|
|
|
|
{ "disable-legacy", QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY, NULL },
|
|
|
|
{ "iommu_platform", QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM, NULL },
|
|
|
|
{ "ats", QEMU_CAPS_VIRTIO_PCI_ATS, NULL },
|
|
|
|
{ "failover", QEMU_CAPS_VIRTIO_NET_FAILOVER, NULL },
|
|
|
|
{ "packed", QEMU_CAPS_VIRTIO_PACKED_QUEUES, NULL },
|
2020-02-27 20:22:59 +00:00
|
|
|
};
|
|
|
|
|
2020-05-06 19:29:55 +00:00
|
|
|
static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsPCIeRootPort[] = {
|
|
|
|
{ "hotplug", QEMU_CAPS_PCIE_ROOT_PORT_HOTPLUG, NULL },
|
2017-07-21 08:02:32 +00:00
|
|
|
};
|
|
|
|
|
2020-09-09 09:13:52 +00:00
|
|
|
static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsUSBHost[] = {
|
|
|
|
{ "hostdevice", QEMU_CAPS_USB_HOST_HOSTDEVICE, NULL },
|
|
|
|
};
|
|
|
|
|
2020-05-06 19:29:55 +00:00
|
|
|
static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsSpaprPCIHostBridge[] = {
|
|
|
|
{ "numa_node", QEMU_CAPS_SPAPR_PCI_HOST_BRIDGE_NUMA_NODE, NULL },
|
2016-04-20 18:43:04 +00:00
|
|
|
};
|
|
|
|
|
2020-05-06 19:29:55 +00:00
|
|
|
static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsVirtioSCSI[] = {
|
|
|
|
{ "iothread", QEMU_CAPS_VIRTIO_SCSI_IOTHREAD, NULL },
|
|
|
|
{ "disable-legacy", QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY, NULL },
|
|
|
|
{ "iommu_platform", QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM, NULL },
|
|
|
|
{ "ats", QEMU_CAPS_VIRTIO_PCI_ATS, NULL },
|
|
|
|
{ "packed", QEMU_CAPS_VIRTIO_PACKED_QUEUES, NULL },
|
2013-04-17 18:16:28 +00:00
|
|
|
};
|
|
|
|
|
2020-05-06 19:29:55 +00:00
|
|
|
static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsVfioPCI[] = {
|
|
|
|
{ "display", QEMU_CAPS_VFIO_PCI_DISPLAY, NULL },
|
2012-09-13 17:04:24 +00:00
|
|
|
};
|
|
|
|
|
2020-05-06 19:29:55 +00:00
|
|
|
static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsSCSIDisk[] = {
|
|
|
|
{ "channel", QEMU_CAPS_SCSI_DISK_CHANNEL, NULL },
|
|
|
|
{ "wwn", QEMU_CAPS_SCSI_DISK_WWN, NULL },
|
|
|
|
{ "share-rw", QEMU_CAPS_DISK_SHARE_RW, NULL },
|
|
|
|
{ "write-cache", QEMU_CAPS_DISK_WRITE_CACHE, NULL },
|
|
|
|
{ "device_id", QEMU_CAPS_SCSI_DISK_DEVICE_ID, NULL },
|
|
|
|
{ "werror", QEMU_CAPS_STORAGE_WERROR, NULL },
|
2012-09-13 17:04:24 +00:00
|
|
|
};
|
|
|
|
|
2020-05-06 19:29:55 +00:00
|
|
|
static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsIDEDrive[] = {
|
|
|
|
{ "wwn", QEMU_CAPS_IDE_DRIVE_WWN, NULL },
|
|
|
|
{ "share-rw", QEMU_CAPS_DISK_SHARE_RW, NULL },
|
|
|
|
{ "write-cache", QEMU_CAPS_DISK_WRITE_CACHE, NULL },
|
2012-09-13 17:04:24 +00:00
|
|
|
};
|
|
|
|
|
2020-05-06 19:29:55 +00:00
|
|
|
static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsPiix4PM[] = {
|
|
|
|
{ "disable_s3", QEMU_CAPS_PIIX_DISABLE_S3, NULL },
|
|
|
|
{ "disable_s4", QEMU_CAPS_PIIX_DISABLE_S4, NULL },
|
2012-11-14 14:51:30 +00:00
|
|
|
};
|
|
|
|
|
2020-05-06 19:29:55 +00:00
|
|
|
static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsUSBRedir[] = {
|
|
|
|
{ "filter", QEMU_CAPS_USB_REDIR_FILTER, NULL },
|
2013-08-12 11:48:34 +00:00
|
|
|
};
|
|
|
|
|
2020-05-06 19:29:55 +00:00
|
|
|
static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsI440FXPCIHost[] = {
|
|
|
|
{ "pci-hole64-size", QEMU_CAPS_I440FX_PCI_HOLE64_SIZE, NULL },
|
2013-08-12 11:48:34 +00:00
|
|
|
};
|
|
|
|
|
2020-05-06 19:29:55 +00:00
|
|
|
static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsQ35PCIHost[] = {
|
|
|
|
{ "pci-hole64-size", QEMU_CAPS_Q35_PCI_HOLE64_SIZE, NULL },
|
2013-08-23 10:38:11 +00:00
|
|
|
};
|
|
|
|
|
2020-05-06 19:29:55 +00:00
|
|
|
static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsUSBStorage[] = {
|
|
|
|
{ "removable", QEMU_CAPS_USB_STORAGE_REMOVABLE, NULL },
|
|
|
|
{ "share-rw", QEMU_CAPS_DISK_SHARE_RW, NULL },
|
|
|
|
{ "write-cache", QEMU_CAPS_DISK_WRITE_CACHE, NULL },
|
|
|
|
{ "werror", QEMU_CAPS_USB_STORAGE_WERROR, NULL },
|
2013-07-01 16:28:50 +00:00
|
|
|
};
|
|
|
|
|
2020-05-06 19:29:55 +00:00
|
|
|
static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsKVMPit[] = {
|
|
|
|
{ "lost_tick_policy", QEMU_CAPS_KVM_PIT_TICK_POLICY, NULL },
|
2014-11-12 12:58:33 +00:00
|
|
|
};
|
|
|
|
|
2020-05-06 19:29:55 +00:00
|
|
|
static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsVGA[] = {
|
|
|
|
{ "vgamem_mb", QEMU_CAPS_VGA_VGAMEM, NULL },
|
2014-11-12 12:58:33 +00:00
|
|
|
};
|
|
|
|
|
2020-05-06 19:29:55 +00:00
|
|
|
static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsVmwareSvga[] = {
|
|
|
|
{ "vgamem_mb", QEMU_CAPS_VMWARE_SVGA_VGAMEM, NULL },
|
2014-11-12 12:58:33 +00:00
|
|
|
};
|
|
|
|
|
2020-05-06 19:29:55 +00:00
|
|
|
static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsQxl[] = {
|
|
|
|
{ "vgamem_mb", QEMU_CAPS_QXL_VGAMEM, NULL },
|
|
|
|
{ "vram64_size_mb", QEMU_CAPS_QXL_VRAM64, NULL },
|
|
|
|
{ "max_outputs", QEMU_CAPS_QXL_MAX_OUTPUTS, NULL },
|
2015-11-25 08:42:33 +00:00
|
|
|
};
|
|
|
|
|
2020-05-06 19:29:55 +00:00
|
|
|
static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsVirtioGpu[] = {
|
|
|
|
{ "virgl", QEMU_CAPS_VIRTIO_GPU_VIRGL, NULL },
|
|
|
|
{ "max_outputs", QEMU_CAPS_VIRTIO_GPU_MAX_OUTPUTS, NULL },
|
|
|
|
{ "disable-legacy", QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY, NULL },
|
|
|
|
{ "iommu_platform", QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM, NULL },
|
|
|
|
{ "ats", QEMU_CAPS_VIRTIO_PCI_ATS, NULL },
|
|
|
|
{ "packed", QEMU_CAPS_VIRTIO_PACKED_QUEUES, NULL },
|
2016-01-09 20:58:50 +00:00
|
|
|
};
|
|
|
|
|
2020-05-06 19:29:55 +00:00
|
|
|
static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsICH9[] = {
|
|
|
|
{ "disable_s3", QEMU_CAPS_ICH9_DISABLE_S3, NULL },
|
|
|
|
{ "disable_s4", QEMU_CAPS_ICH9_DISABLE_S4, NULL },
|
2016-04-24 14:52:38 +00:00
|
|
|
};
|
|
|
|
|
2020-05-06 19:29:55 +00:00
|
|
|
static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsUSBNECXHCI[] = {
|
|
|
|
{ "p3", QEMU_CAPS_NEC_USB_XHCI_PORTS, NULL },
|
2017-05-03 13:23:12 +00:00
|
|
|
};
|
|
|
|
|
2020-05-06 19:29:55 +00:00
|
|
|
static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsIntelIOMMU[] = {
|
|
|
|
{ "intremap", QEMU_CAPS_INTEL_IOMMU_INTREMAP, NULL },
|
|
|
|
{ "caching-mode", QEMU_CAPS_INTEL_IOMMU_CACHING_MODE, NULL },
|
|
|
|
{ "eim", QEMU_CAPS_INTEL_IOMMU_EIM, NULL },
|
|
|
|
{ "device-iotlb", QEMU_CAPS_INTEL_IOMMU_DEVICE_IOTLB, NULL },
|
2020-06-04 07:42:43 +00:00
|
|
|
{ "aw-bits", QEMU_CAPS_INTEL_IOMMU_AW_BITS, NULL },
|
2018-05-07 14:41:12 +00:00
|
|
|
};
|
|
|
|
|
2020-05-06 19:29:55 +00:00
|
|
|
static struct virQEMUCapsDevicePropsFlags virQEMUCapsObjectPropsVirtualCSSBridge[] = {
|
|
|
|
{ "cssid-unrestricted", QEMU_CAPS_CCW_CSSID_UNRESTRICTED, NULL },
|
2018-05-10 21:27:57 +00:00
|
|
|
};
|
|
|
|
|
2020-05-06 19:29:55 +00:00
|
|
|
static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsMCH[] = {
|
|
|
|
{ "extended-tseg-mbytes", QEMU_CAPS_MCH_EXTENDED_TSEG_MBYTES, NULL },
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsNVDIMM[] = {
|
|
|
|
{ "unarmed", QEMU_CAPS_DEVICE_NVDIMM_UNARMED, NULL },
|
2018-12-20 09:14:45 +00:00
|
|
|
};
|
|
|
|
|
2021-01-04 15:03:57 +00:00
|
|
|
static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsVhostUserFS[] = {
|
|
|
|
{ "bootindex", QEMU_CAPS_VHOST_USER_FS_BOOTINDEX, NULL },
|
|
|
|
};
|
|
|
|
|
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 },
|
2018-05-17 09:41:37 +00:00
|
|
|
{ "screendump/arg-type/device", QEMU_CAPS_SCREENDUMP_DEVICE },
|
2018-08-14 15:53:05 +00:00
|
|
|
{ "block-commit/arg-type/*top", QEMU_CAPS_ACTIVE_COMMIT },
|
2018-10-05 19:59:49 +00:00
|
|
|
{ "query-iothreads/ret-type/poll-max-ns", QEMU_CAPS_IOTHREAD_POLLING },
|
2018-11-21 13:07:01 +00:00
|
|
|
{ "query-display-options/ret-type/+egl-headless/rendernode", QEMU_CAPS_EGL_HEADLESS_RENDERNODE },
|
2019-06-06 02:25:05 +00:00
|
|
|
{ "nbd-server-add/arg-type/bitmap", QEMU_CAPS_NBD_BITMAP },
|
2019-08-13 13:17:36 +00:00
|
|
|
{ "blockdev-add/arg-type/+file/drop-cache", QEMU_CAPS_MIGRATION_FILE_DROP_CACHE },
|
2019-04-08 15:10:37 +00:00
|
|
|
{ "blockdev-add/arg-type/+file/$dynamic-auto-read-only", QEMU_CAPS_BLOCK_FILE_AUTO_READONLY_DYNAMIC },
|
2019-09-17 15:10:08 +00:00
|
|
|
{ "human-monitor-command/$savevm-monitor-nodes", QEMU_CAPS_SAVEVM_MONITOR_NODES },
|
2019-06-05 14:11:03 +00:00
|
|
|
{ "blockdev-add/arg-type/+nvme", QEMU_CAPS_DRIVE_NVME },
|
2020-01-21 14:13:47 +00:00
|
|
|
{ "query-named-block-nodes/arg-type/flat", QEMU_CAPS_QMP_QUERY_NAMED_BLOCK_NODES_FLAT },
|
2020-03-05 13:28:50 +00:00
|
|
|
{ "blockdev-snapshot/$allow-write-only-overlay", QEMU_CAPS_BLOCKDEV_SNAPSHOT_ALLOW_WRITE_ONLY },
|
2020-04-21 12:19:34 +00:00
|
|
|
{ "blockdev-add/arg-type/+file/aio/^io_uring", QEMU_CAPS_AIO_IO_URING },
|
2020-06-10 13:09:00 +00:00
|
|
|
{ "migrate-set-parameters/arg-type/max-bandwidth", QEMU_CAPS_MIGRATION_PARAM_BANDWIDTH },
|
|
|
|
{ "migrate-set-parameters/arg-type/downtime-limit", QEMU_CAPS_MIGRATION_PARAM_DOWNTIME },
|
|
|
|
{ "migrate-set-parameters/arg-type/xbzrle-cache-size", QEMU_CAPS_MIGRATION_PARAM_XBZRLE_CACHE_SIZE },
|
2020-05-27 09:00:07 +00:00
|
|
|
{ "set-numa-node/arg-type/+hmat-lb", QEMU_CAPS_NUMA_HMAT },
|
2020-10-14 17:08:26 +00:00
|
|
|
{ "netdev_add/arg-type/+vhost-vdpa", QEMU_CAPS_NETDEV_VHOST_VDPA },
|
2020-08-07 09:29:18 +00:00
|
|
|
{ "migrate-set-parameters/arg-type/block-bitmap-mapping/bitmaps/transform",
|
|
|
|
QEMU_CAPS_MIGRATION_PARAM_BLOCK_BITMAP_MAPPING },
|
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
|
|
|
};
|
|
|
|
|
2020-05-06 19:29:55 +00:00
|
|
|
|
|
|
|
typedef struct _virQEMUCapsDeviceTypeProps virQEMUCapsDeviceTypeProps;
|
|
|
|
struct _virQEMUCapsDeviceTypeProps {
|
|
|
|
const char *type;
|
|
|
|
struct virQEMUCapsDevicePropsFlags *props;
|
|
|
|
size_t nprops;
|
|
|
|
int capsCondition;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static virQEMUCapsDeviceTypeProps virQEMUCapsDeviceProps[] = {
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "virtio-blk-pci", virQEMUCapsDevicePropsVirtioBlk,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(virQEMUCapsDevicePropsVirtioBlk),
|
2017-03-20 15:08:48 +00:00
|
|
|
-1 },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "virtio-net-pci", virQEMUCapsDevicePropsVirtioNet,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(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,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(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,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(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,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(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,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(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,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(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,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(virQEMUCapsDevicePropsVirtioNet),
|
2018-03-06 12:49:39 +00:00
|
|
|
QEMU_CAPS_DEVICE_VIRTIO_NET },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "vfio-pci", virQEMUCapsDevicePropsVfioPCI,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(virQEMUCapsDevicePropsVfioPCI),
|
2018-03-06 12:49:39 +00:00
|
|
|
QEMU_CAPS_DEVICE_VFIO_PCI },
|
2019-01-28 09:03:25 +00:00
|
|
|
{ "scsi-hd", virQEMUCapsDevicePropsSCSIDisk,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(virQEMUCapsDevicePropsSCSIDisk),
|
2017-03-20 15:08:48 +00:00
|
|
|
-1 },
|
2019-01-28 13:52:22 +00:00
|
|
|
{ "ide-hd", virQEMUCapsDevicePropsIDEDrive,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(virQEMUCapsDevicePropsIDEDrive),
|
2017-03-20 15:08:48 +00:00
|
|
|
-1 },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "PIIX4_PM", virQEMUCapsDevicePropsPiix4PM,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(virQEMUCapsDevicePropsPiix4PM),
|
2017-03-20 15:08:48 +00:00
|
|
|
-1 },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "usb-redir", virQEMUCapsDevicePropsUSBRedir,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(virQEMUCapsDevicePropsUSBRedir),
|
2018-03-06 12:49:39 +00:00
|
|
|
QEMU_CAPS_USB_REDIR },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "i440FX-pcihost", virQEMUCapsDevicePropsI440FXPCIHost,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(virQEMUCapsDevicePropsI440FXPCIHost),
|
2017-03-20 15:08:48 +00:00
|
|
|
-1 },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "q35-pcihost", virQEMUCapsDevicePropsQ35PCIHost,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(virQEMUCapsDevicePropsQ35PCIHost),
|
2017-03-20 15:08:48 +00:00
|
|
|
-1 },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "usb-storage", virQEMUCapsDevicePropsUSBStorage,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(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,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(virQEMUCapsDevicePropsKVMPit),
|
2017-03-20 15:08:48 +00:00
|
|
|
-1 },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "VGA", virQEMUCapsDevicePropsVGA,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(virQEMUCapsDevicePropsVGA),
|
2018-03-06 12:49:39 +00:00
|
|
|
QEMU_CAPS_DEVICE_VGA },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "vmware-svga", virQEMUCapsDevicePropsVmwareSvga,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(virQEMUCapsDevicePropsVmwareSvga),
|
2018-03-06 12:49:39 +00:00
|
|
|
QEMU_CAPS_DEVICE_VMWARE_SVGA },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "qxl", virQEMUCapsDevicePropsQxl,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(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,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(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,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(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,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(virQEMUCapsDevicePropsICH9),
|
2017-03-20 15:08:48 +00:00
|
|
|
-1 },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "virtio-balloon-pci", virQEMUCapsDevicePropsVirtioBalloon,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(virQEMUCapsDevicePropsVirtioBalloon),
|
2017-03-20 15:08:48 +00:00
|
|
|
-1 },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "virtio-balloon-ccw", virQEMUCapsDevicePropsVirtioBalloon,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(virQEMUCapsDevicePropsVirtioBalloon),
|
2017-03-20 15:08:48 +00:00
|
|
|
-1 },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "virtio-balloon-device", virQEMUCapsDevicePropsVirtioBalloon,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(virQEMUCapsDevicePropsVirtioBalloon),
|
2017-03-20 15:08:48 +00:00
|
|
|
-1 },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "nec-usb-xhci", virQEMUCapsDevicePropsUSBNECXHCI,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(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,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(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,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(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,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(virQEMUCapsDevicePropsVirtioGpu),
|
2018-03-23 17:22:38 +00:00
|
|
|
QEMU_CAPS_DEVICE_VIRTIO_GPU_CCW },
|
2018-05-07 14:41:12 +00:00
|
|
|
{ "virtual-css-bridge", virQEMUCapsObjectPropsVirtualCSSBridge,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(virQEMUCapsObjectPropsVirtualCSSBridge),
|
2018-05-07 14:41:12 +00:00
|
|
|
QEMU_CAPS_CCW },
|
2018-05-10 21:27:57 +00:00
|
|
|
{ "mch", virQEMUCapsDevicePropsMCH,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(virQEMUCapsDevicePropsMCH),
|
2018-05-10 21:27:57 +00:00
|
|
|
QEMU_CAPS_DEVICE_MCH },
|
2018-12-20 09:14:45 +00:00
|
|
|
{ "nvdimm", virQEMUCapsDevicePropsNVDIMM,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(virQEMUCapsDevicePropsNVDIMM),
|
2018-12-20 09:14:45 +00:00
|
|
|
QEMU_CAPS_DEVICE_NVDIMM },
|
2020-02-27 20:22:59 +00:00
|
|
|
{ "pcie-root-port", virQEMUCapsDevicePropsPCIeRootPort,
|
|
|
|
G_N_ELEMENTS(virQEMUCapsDevicePropsPCIeRootPort),
|
|
|
|
QEMU_CAPS_DEVICE_PCIE_ROOT_PORT },
|
2020-09-09 09:13:52 +00:00
|
|
|
{ "usb-host", virQEMUCapsDevicePropsUSBHost,
|
|
|
|
G_N_ELEMENTS(virQEMUCapsDevicePropsUSBHost),
|
|
|
|
-1 },
|
2021-01-04 15:03:57 +00:00
|
|
|
{ "vhost-user-fs-device", virQEMUCapsDevicePropsVhostUserFS,
|
|
|
|
G_N_ELEMENTS(virQEMUCapsDevicePropsVhostUserFS),
|
|
|
|
QEMU_CAPS_DEVICE_VHOST_USER_FS },
|
2012-09-13 17:04:24 +00:00
|
|
|
};
|
|
|
|
|
2018-04-20 08:25:49 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsMemoryBackendFile[] = {
|
|
|
|
{ "discard-data", QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD },
|
2018-12-20 09:14:43 +00:00
|
|
|
{ "align", QEMU_CAPS_OBJECT_MEMORY_FILE_ALIGN },
|
2018-12-20 09:14:44 +00:00
|
|
|
{ "pmem", QEMU_CAPS_OBJECT_MEMORY_FILE_PMEM },
|
2021-01-11 17:15:57 +00:00
|
|
|
/* As of QEMU commit 8db0b20415c129cf5e577a593a4a0372d90b7cc9 the
|
|
|
|
* "x-use-canonical-path-for-ramblock-id" property is considered stable and
|
|
|
|
* supported. The 'x-' prefix was kept for compatibility with already
|
|
|
|
* released qemu versions. */
|
|
|
|
{ "x-use-canonical-path-for-ramblock-id", QEMU_CAPS_X_USE_CANONICAL_PATH_FOR_RAMBLOCK_ID },
|
2018-04-20 08:25:49 +00:00
|
|
|
};
|
|
|
|
|
2018-11-15 11:55:52 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsMemoryBackendMemfd[] = {
|
|
|
|
{ "hugetlb", QEMU_CAPS_OBJECT_MEMORY_MEMFD_HUGETLB },
|
|
|
|
};
|
|
|
|
|
2019-07-08 11:14:53 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsMaxCPU[] = {
|
2019-06-10 14:49:22 +00:00
|
|
|
{ "unavailable-features", QEMU_CAPS_CPU_UNAVAILABLE_FEATURES },
|
2020-01-31 13:28:57 +00:00
|
|
|
{ "kvm-no-adjvtime", QEMU_CAPS_CPU_KVM_NO_ADJVTIME },
|
2020-06-02 18:15:53 +00:00
|
|
|
{ "migratable", QEMU_CAPS_CPU_MIGRATABLE },
|
2019-06-10 14:49:22 +00:00
|
|
|
};
|
|
|
|
|
2018-04-20 08:25:49 +00:00
|
|
|
static virQEMUCapsObjectTypeProps virQEMUCapsObjectProps[] = {
|
|
|
|
{ "memory-backend-file", virQEMUCapsObjectPropsMemoryBackendFile,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(virQEMUCapsObjectPropsMemoryBackendFile),
|
2018-04-20 08:25:49 +00:00
|
|
|
QEMU_CAPS_OBJECT_MEMORY_FILE },
|
2018-11-15 11:55:52 +00:00
|
|
|
{ "memory-backend-memfd", virQEMUCapsObjectPropsMemoryBackendMemfd,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(virQEMUCapsObjectPropsMemoryBackendMemfd),
|
2018-11-15 11:55:52 +00:00
|
|
|
QEMU_CAPS_OBJECT_MEMORY_MEMFD },
|
2019-07-08 11:14:53 +00:00
|
|
|
{ "max-x86_64-cpu", virQEMUCapsObjectPropsMaxCPU,
|
|
|
|
G_N_ELEMENTS(virQEMUCapsObjectPropsMaxCPU),
|
2019-06-10 14:49:22 +00:00
|
|
|
QEMU_CAPS_X86_MAX_CPU },
|
2019-07-08 11:46:37 +00:00
|
|
|
{ "max-arm-cpu", virQEMUCapsObjectPropsMaxCPU,
|
|
|
|
G_N_ELEMENTS(virQEMUCapsObjectPropsMaxCPU),
|
|
|
|
QEMU_CAPS_ARM_MAX_CPU },
|
2019-05-16 13:45:08 +00:00
|
|
|
};
|
|
|
|
|
2019-05-16 08:34:01 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsMachinePropsPSeries[] = {
|
2019-05-16 13:45:08 +00:00
|
|
|
{ "cap-hpt-max-page-size", QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE },
|
|
|
|
{ "cap-htm", QEMU_CAPS_MACHINE_PSERIES_CAP_HTM },
|
|
|
|
{ "cap-nested-hv", QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV },
|
2019-10-08 20:06:23 +00:00
|
|
|
{ "cap-ccf-assist", QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST },
|
2020-04-27 12:14:26 +00:00
|
|
|
{ "cap-cfpc", QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC },
|
2020-04-27 12:14:28 +00:00
|
|
|
{ "cap-sbbc", QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC },
|
2020-04-27 12:14:30 +00:00
|
|
|
{ "cap-ibs", QEMU_CAPS_MACHINE_PSERIES_CAP_IBS },
|
2019-05-16 13:45:08 +00:00
|
|
|
};
|
|
|
|
|
2019-05-17 07:15:27 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsMachinePropsVirt[] = {
|
|
|
|
{ "iommu", QEMU_CAPS_MACHINE_VIRT_IOMMU },
|
|
|
|
};
|
|
|
|
|
2019-05-16 13:45:08 +00:00
|
|
|
static virQEMUCapsObjectTypeProps virQEMUCapsMachineProps[] = {
|
2019-05-16 08:34:01 +00:00
|
|
|
{ "pseries", virQEMUCapsMachinePropsPSeries,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(virQEMUCapsMachinePropsPSeries),
|
2018-06-19 11:51:05 +00:00
|
|
|
-1 },
|
2019-05-17 07:15:27 +00:00
|
|
|
{ "virt", virQEMUCapsMachinePropsVirt,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(virQEMUCapsMachinePropsVirt),
|
2019-05-17 07:15:27 +00:00
|
|
|
-1 },
|
2018-04-20 08:25:49 +00:00
|
|
|
};
|
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
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2019-12-20 11:56:38 +00:00
|
|
|
qemuCaps->invalidation = true;
|
2020-10-01 15:42:11 +00:00
|
|
|
qemuCaps->flags = virBitmapNew(QEMU_CAPS_LAST);
|
2011-02-08 14:22:39 +00:00
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
return qemuCaps;
|
2011-02-08 14:22:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-20 12:28:57 +00:00
|
|
|
virQEMUCapsPtr
|
|
|
|
virQEMUCapsNewBinary(const char *binary)
|
|
|
|
{
|
|
|
|
virQEMUCapsPtr qemuCaps = virQEMUCapsNew();
|
|
|
|
|
2020-03-30 08:56:08 +00:00
|
|
|
if (qemuCaps)
|
|
|
|
qemuCaps->binary = g_strdup(binary);
|
2019-12-20 12:28:57 +00:00
|
|
|
|
|
|
|
return qemuCaps;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
2018-09-08 22:40:30 +00:00
|
|
|
virQEMUCapsHostCPUDataClear(virQEMUCapsHostCPUDataPtr cpuData)
|
2017-04-07 15:43:59 +00:00
|
|
|
{
|
2018-09-08 22:40:30 +00:00
|
|
|
qemuMonitorCPUModelInfoFree(cpuData->info);
|
2017-04-07 16:15:26 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-08-09 13:27:26 +00:00
|
|
|
static int
|
|
|
|
virQEMUCapsSEVInfoCopy(virSEVCapabilityPtr *dst,
|
|
|
|
virSEVCapabilityPtr src)
|
|
|
|
{
|
2019-10-15 12:47:50 +00:00
|
|
|
g_autoptr(virSEVCapability) tmp = NULL;
|
2018-08-09 13:27:26 +00:00
|
|
|
|
2020-10-05 10:25:44 +00:00
|
|
|
tmp = g_new0(virSEVCapability, 1);
|
2018-08-09 13:27:26 +00:00
|
|
|
|
2019-10-20 11:49:46 +00:00
|
|
|
tmp->pdh = g_strdup(src->pdh);
|
|
|
|
tmp->cert_chain = g_strdup(src->cert_chain);
|
|
|
|
|
2018-08-09 13:27:26 +00:00
|
|
|
tmp->cbitpos = src->cbitpos;
|
|
|
|
tmp->reduced_phys_bits = src->reduced_phys_bits;
|
|
|
|
|
2019-10-16 11:43:18 +00:00
|
|
|
*dst = g_steal_pointer(&tmp);
|
2018-08-09 13:27:26 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-10-24 09:35:10 +00:00
|
|
|
static void
|
2019-10-24 12:19:38 +00:00
|
|
|
virQEMUCapsAccelCopyMachineTypes(virQEMUCapsAccelPtr dst,
|
|
|
|
virQEMUCapsAccelPtr src)
|
2019-10-24 09:35:10 +00:00
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
dst->machineTypes = g_new0(virQEMUCapsMachineType, src->nmachineTypes);
|
|
|
|
|
|
|
|
dst->nmachineTypes = src->nmachineTypes;
|
|
|
|
for (i = 0; i < src->nmachineTypes; i++) {
|
|
|
|
dst->machineTypes[i].name = g_strdup(src->machineTypes[i].name);
|
|
|
|
dst->machineTypes[i].alias = g_strdup(src->machineTypes[i].alias);
|
2019-07-18 17:21:55 +00:00
|
|
|
dst->machineTypes[i].defaultCPU = g_strdup(src->machineTypes[i].defaultCPU);
|
2019-10-24 09:35:10 +00:00
|
|
|
dst->machineTypes[i].maxCpus = src->machineTypes[i].maxCpus;
|
|
|
|
dst->machineTypes[i].hotplugCpus = src->machineTypes[i].hotplugCpus;
|
|
|
|
dst->machineTypes[i].qemuDefault = src->machineTypes[i].qemuDefault;
|
2020-05-14 11:11:01 +00:00
|
|
|
dst->machineTypes[i].numaMemSupported = src->machineTypes[i].numaMemSupported;
|
2020-05-25 17:13:43 +00:00
|
|
|
dst->machineTypes[i].defaultRAMid = g_strdup(src->machineTypes[i].defaultRAMid);
|
2021-01-22 12:16:23 +00:00
|
|
|
dst->machineTypes[i].deprecated = src->machineTypes[i].deprecated;
|
2019-10-24 09:35:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-10-23 10:41:31 +00:00
|
|
|
static int
|
|
|
|
virQEMUCapsAccelCopy(virQEMUCapsAccelPtr dst,
|
|
|
|
virQEMUCapsAccelPtr src)
|
|
|
|
{
|
2019-10-24 12:19:38 +00:00
|
|
|
virQEMUCapsAccelCopyMachineTypes(dst, src);
|
|
|
|
|
2019-10-23 10:41:31 +00:00
|
|
|
if (virQEMUCapsHostCPUDataCopy(&dst->hostCPU, &src->hostCPU) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
dst->cpuModels = qemuMonitorCPUDefsCopy(src->cpuModels);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsPtr virQEMUCapsNewCopy(virQEMUCapsPtr qemuCaps)
|
2012-09-11 12:42:20 +00:00
|
|
|
{
|
2019-12-20 12:28:57 +00:00
|
|
|
virQEMUCapsPtr ret = virQEMUCapsNewBinary(qemuCaps->binary);
|
2012-09-11 12:42:20 +00:00
|
|
|
size_t i;
|
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
return NULL;
|
|
|
|
|
2019-12-20 11:56:38 +00:00
|
|
|
ret->invalidation = qemuCaps->invalidation;
|
2018-11-12 19:58:09 +00:00
|
|
|
ret->kvmSupportsNesting = qemuCaps->kvmSupportsNesting;
|
2020-06-15 08:28:07 +00:00
|
|
|
ret->kvmSupportsSecureGuest = qemuCaps->kvmSupportsSecureGuest;
|
2016-08-04 14:45:53 +00:00
|
|
|
|
2016-08-04 14:48:40 +00:00
|
|
|
ret->ctime = qemuCaps->ctime;
|
|
|
|
|
2020-10-02 08:26:34 +00:00
|
|
|
virBitmapFree(ret->flags);
|
|
|
|
ret->flags = virBitmapNewCopy(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;
|
2020-05-15 20:00:29 +00:00
|
|
|
ret->hostCPUSignature = g_strdup(qemuCaps->hostCPUSignature);
|
2015-02-02 10:28:30 +00:00
|
|
|
|
2019-10-20 11:49:46 +00:00
|
|
|
ret->package = g_strdup(qemuCaps->package);
|
|
|
|
ret->kernelVersion = g_strdup(qemuCaps->kernelVersion);
|
2018-01-22 10:37:04 +00:00
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
ret->arch = qemuCaps->arch;
|
2012-09-11 12:42:20 +00:00
|
|
|
|
2019-10-23 10:41:31 +00:00
|
|
|
if (virQEMUCapsAccelCopy(&ret->kvm, &qemuCaps->kvm) < 0 ||
|
|
|
|
virQEMUCapsAccelCopy(&ret->tcg, &qemuCaps->tcg) < 0)
|
2017-01-06 07:52:22 +00:00
|
|
|
goto error;
|
|
|
|
|
2020-10-05 10:25:44 +00:00
|
|
|
ret->gicCapabilities = g_new0(virGICCapability, qemuCaps->ngicCapabilities);
|
2016-08-04 14:48:40 +00:00
|
|
|
ret->ngicCapabilities = qemuCaps->ngicCapabilities;
|
|
|
|
for (i = 0; i < qemuCaps->ngicCapabilities; i++)
|
|
|
|
ret->gicCapabilities[i] = qemuCaps->gicCapabilities[i];
|
|
|
|
|
2018-08-09 13:27:26 +00:00
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SEV_GUEST) &&
|
|
|
|
virQEMUCapsSEVInfoCopy(&ret->sevCapabilities,
|
|
|
|
qemuCaps->sevCapabilities) < 0)
|
|
|
|
goto error;
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-10-23 10:42:54 +00:00
|
|
|
static void
|
|
|
|
virQEMUCapsAccelClear(virQEMUCapsAccelPtr caps)
|
|
|
|
{
|
2019-10-24 12:19:38 +00:00
|
|
|
size_t i;
|
|
|
|
|
|
|
|
for (i = 0; i < caps->nmachineTypes; i++) {
|
|
|
|
VIR_FREE(caps->machineTypes[i].name);
|
|
|
|
VIR_FREE(caps->machineTypes[i].alias);
|
2019-07-18 17:21:55 +00:00
|
|
|
VIR_FREE(caps->machineTypes[i].defaultCPU);
|
2020-05-25 17:13:43 +00:00
|
|
|
VIR_FREE(caps->machineTypes[i].defaultRAMid);
|
2019-10-24 12:19:38 +00:00
|
|
|
}
|
|
|
|
VIR_FREE(caps->machineTypes);
|
|
|
|
|
2019-10-23 10:42:54 +00:00
|
|
|
virQEMUCapsHostCPUDataClear(&caps->hostCPU);
|
2019-11-25 15:35:27 +00:00
|
|
|
qemuMonitorCPUDefsFree(caps->cpuModels);
|
2019-10-23 10:42:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
virBitmapFree(qemuCaps->flags);
|
2012-09-10 10:47:56 +00:00
|
|
|
|
2021-02-03 20:13:53 +00:00
|
|
|
g_free(qemuCaps->package);
|
|
|
|
g_free(qemuCaps->kernelVersion);
|
|
|
|
g_free(qemuCaps->binary);
|
|
|
|
g_free(qemuCaps->hostCPUSignature);
|
2016-03-08 17:24:18 +00:00
|
|
|
|
2021-02-03 20:13:53 +00:00
|
|
|
g_free(qemuCaps->gicCapabilities);
|
2016-06-15 12:35:18 +00:00
|
|
|
|
2018-09-08 23:26:36 +00:00
|
|
|
virSEVCapabilitiesFree(qemuCaps->sevCapabilities);
|
|
|
|
|
2019-10-23 10:42:54 +00:00
|
|
|
virQEMUCapsAccelClear(&qemuCaps->kvm);
|
|
|
|
virQEMUCapsAccelClear(&qemuCaps->tcg);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-03-13 19:03:45 +00:00
|
|
|
void
|
|
|
|
virQEMUCapsSetList(virQEMUCapsPtr qemuCaps, ...)
|
|
|
|
{
|
|
|
|
va_list list;
|
2019-03-27 16:19:37 +00:00
|
|
|
int flag;
|
2019-03-13 19:03:45 +00:00
|
|
|
|
|
|
|
va_start(list, qemuCaps);
|
2019-03-27 16:19:37 +00:00
|
|
|
while ((flag = va_arg(list, int)) < QEMU_CAPS_LAST)
|
|
|
|
virQEMUCapsSet(qemuCaps, 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
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
2018-09-12 12:41:25 +00:00
|
|
|
* bamboo: 1.1.0 (<= 1.5.0, so basically forever)
|
2014-04-23 15:35:37 +00:00
|
|
|
* mac99: 2.0.0
|
|
|
|
* g3beige: 2.0.0
|
2018-09-12 12:41:25 +00:00
|
|
|
* prep: 1.4.0 (<= 1.5.0, so basically forever)
|
2014-04-23 15:35:37 +00:00
|
|
|
* 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;
|
|
|
|
|
2018-09-12 12:41:25 +00:00
|
|
|
if (STREQ(def->os.machine, "bamboo") ||
|
|
|
|
STREQ(def->os.machine, "mpc8544ds") ||
|
|
|
|
STREQ(def->os.machine, "prep")) {
|
2014-04-23 15:35:37 +00:00
|
|
|
return true;
|
2018-09-12 12:41:25 +00:00
|
|
|
}
|
2014-04-23 15:35:37 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-11-08 11:00:22 +00:00
|
|
|
/* S390 supports PCI-multibus. */
|
|
|
|
if (ARCH_IS_S390(def->os.arch))
|
|
|
|
return true;
|
|
|
|
|
2018-09-21 13:29:38 +00:00
|
|
|
/* If the virt machine, both on ARM and RISC-V, supports PCI,
|
|
|
|
* then it also supports multibus */
|
|
|
|
if (qemuDomainIsARMVirt(def) ||
|
|
|
|
qemuDomainIsRISCVVirt(def)) {
|
2016-06-22 16:55:37 +00:00
|
|
|
return true;
|
2018-09-21 13:29:38 +00:00
|
|
|
}
|
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;
|
2019-09-24 14:38:05 +00:00
|
|
|
size_t start;
|
2019-10-23 10:46:28 +00:00
|
|
|
virQEMUCapsAccelPtr accel = virQEMUCapsGetAccel(qemuCaps, type);
|
|
|
|
qemuMonitorCPUDefsPtr defs = accel->cpuModels;
|
2019-09-24 14:38:05 +00:00
|
|
|
|
|
|
|
if (defs) {
|
|
|
|
start = defs->ncpus;
|
2016-11-14 16:21:30 +00:00
|
|
|
|
2019-09-24 14:38:05 +00:00
|
|
|
if (VIR_EXPAND_N(defs->cpus, defs->ncpus, count) < 0)
|
|
|
|
return -1;
|
|
|
|
} else {
|
|
|
|
start = 0;
|
|
|
|
|
|
|
|
if (!(defs = qemuMonitorCPUDefsNew(count)))
|
2016-11-14 16:21:30 +00:00
|
|
|
return -1;
|
|
|
|
|
2019-10-23 10:46:28 +00:00
|
|
|
accel->cpuModels = defs;
|
2016-11-14 16:21:30 +00:00
|
|
|
}
|
2016-04-21 10:51:01 +00:00
|
|
|
|
|
|
|
for (i = 0; i < count; i++) {
|
2019-09-24 14:38:05 +00:00
|
|
|
qemuMonitorCPUDefInfoPtr cpu = defs->cpus + start + i;
|
|
|
|
|
|
|
|
cpu->usable = usable;
|
|
|
|
cpu->name = g_strdup(name[i]);
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-09-24 13:59:34 +00:00
|
|
|
static virDomainCapsCPUModelsPtr
|
|
|
|
virQEMUCapsCPUDefsToModels(qemuMonitorCPUDefsPtr defs,
|
2020-06-16 10:16:43 +00:00
|
|
|
const char **modelAllowed,
|
|
|
|
const char **modelForbidden)
|
2019-09-24 13:59:34 +00:00
|
|
|
{
|
|
|
|
g_autoptr(virDomainCapsCPUModels) cpuModels = NULL;
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
if (!(cpuModels = virDomainCapsCPUModelsNew(defs->ncpus)))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
for (i = 0; i < defs->ncpus; i++) {
|
|
|
|
qemuMonitorCPUDefInfoPtr cpu = defs->cpus + i;
|
|
|
|
|
2021-02-03 17:39:47 +00:00
|
|
|
if (modelAllowed && !g_strv_contains(modelAllowed, cpu->name))
|
2019-09-24 13:59:34 +00:00
|
|
|
continue;
|
|
|
|
|
2021-02-03 17:39:47 +00:00
|
|
|
if (modelForbidden && g_strv_contains(modelForbidden, cpu->name))
|
2019-09-24 13:59:34 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if (virDomainCapsCPUModelsAdd(cpuModels, cpu->name, cpu->usable,
|
2021-01-22 11:15:08 +00:00
|
|
|
cpu->blockers, cpu->deprecated) < 0)
|
2019-09-24 13:59:34 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return g_steal_pointer(&cpuModels);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-22 13:51:33 +00:00
|
|
|
virDomainCapsCPUModelsPtr
|
2019-10-09 08:14:59 +00:00
|
|
|
virQEMUCapsGetCPUModels(virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainVirtType type,
|
2020-06-16 10:16:43 +00:00
|
|
|
const char **modelAllowed,
|
|
|
|
const char **modelForbidden)
|
2012-08-22 10:11:28 +00:00
|
|
|
{
|
2019-09-24 14:38:05 +00:00
|
|
|
qemuMonitorCPUDefsPtr defs;
|
2019-09-20 20:41:34 +00:00
|
|
|
|
2019-10-23 10:46:28 +00:00
|
|
|
if (!(defs = virQEMUCapsGetAccel(qemuCaps, type)->cpuModels))
|
2019-09-20 20:41:34 +00:00
|
|
|
return NULL;
|
|
|
|
|
2020-06-16 10:16:43 +00:00
|
|
|
return virQEMUCapsCPUDefsToModels(defs, modelAllowed, modelForbidden);
|
2012-08-22 10:11:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2019-10-23 10:57:20 +00:00
|
|
|
virQEMUCapsHostCPUDataPtr cpuData;
|
2017-04-07 16:15:26 +00:00
|
|
|
|
2019-10-23 10:57:20 +00:00
|
|
|
cpuData = &virQEMUCapsGetAccel(qemuCaps, type)->hostCPU;
|
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
|
|
|
{
|
2019-10-23 10:57:20 +00:00
|
|
|
virQEMUCapsHostCPUDataPtr cpuData;
|
2017-04-07 16:15:26 +00:00
|
|
|
|
2019-10-23 10:57:20 +00:00
|
|
|
cpuData = &virQEMUCapsGetAccel(qemuCaps, type)->hostCPU;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-03 10:49:49 +00:00
|
|
|
bool
|
|
|
|
virQEMUCapsIsArchSupported(virQEMUCapsPtr qemuCaps,
|
|
|
|
virArch arch)
|
|
|
|
{
|
|
|
|
if (arch == qemuCaps->arch)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (qemuCaps->arch == VIR_ARCH_X86_64 && arch == VIR_ARCH_I686)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (qemuCaps->arch == VIR_ARCH_AARCH64 && arch == VIR_ARCH_ARMV7L)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (qemuCaps->arch == VIR_ARCH_ARMV7L && arch == VIR_ARCH_ARMV6L)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (qemuCaps->arch == VIR_ARCH_PPC64 && arch == VIR_ARCH_PPC64LE)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
virQEMUCapsIsVirtTypeSupported(virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainVirtType virtType)
|
|
|
|
{
|
2020-04-22 21:50:42 +00:00
|
|
|
if (virtType == VIR_DOMAIN_VIRT_QEMU &&
|
|
|
|
virQEMUCapsGet(qemuCaps, QEMU_CAPS_TCG))
|
2019-12-03 10:49:49 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
if (virtType == VIR_DOMAIN_VIRT_KVM &&
|
|
|
|
virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-02-06 09:22:23 +00:00
|
|
|
const char *s390HostPassthroughOnlyMachines[] = {
|
|
|
|
"s390-ccw-virtio-2.4",
|
|
|
|
"s390-ccw-virtio-2.5",
|
|
|
|
"s390-ccw-virtio-2.6",
|
|
|
|
"s390-ccw-virtio-2.7",
|
|
|
|
NULL
|
|
|
|
};
|
2019-12-03 10:49:49 +00:00
|
|
|
|
2016-08-03 14:22:30 +00:00
|
|
|
bool
|
|
|
|
virQEMUCapsIsCPUModeSupported(virQEMUCapsPtr qemuCaps,
|
2019-11-26 17:51:22 +00:00
|
|
|
virArch hostarch,
|
2016-08-03 14:22:30 +00:00
|
|
|
virDomainVirtType type,
|
2020-02-05 14:51:09 +00:00
|
|
|
virCPUMode mode,
|
2020-02-06 09:22:23 +00:00
|
|
|
const char *machineType)
|
2016-08-03 14:22:30 +00:00
|
|
|
{
|
2019-09-24 14:38:05 +00:00
|
|
|
qemuMonitorCPUDefsPtr cpus;
|
2016-11-14 16:21:30 +00:00
|
|
|
|
2020-02-06 09:22:23 +00:00
|
|
|
/* CPU models (except for "host") are not supported by QEMU for on s390
|
|
|
|
* KVM domains with old machine types regardless on QEMU version. */
|
|
|
|
if (ARCH_IS_S390(qemuCaps->arch) &&
|
|
|
|
type == VIR_DOMAIN_VIRT_KVM &&
|
|
|
|
mode != VIR_CPU_MODE_HOST_PASSTHROUGH &&
|
|
|
|
machineType &&
|
|
|
|
g_strv_contains(s390HostPassthroughOnlyMachines, machineType)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-08-03 14:22:30 +00:00
|
|
|
switch (mode) {
|
|
|
|
case VIR_CPU_MODE_HOST_PASSTHROUGH:
|
|
|
|
return type == VIR_DOMAIN_VIRT_KVM &&
|
2019-11-26 17:51:22 +00:00
|
|
|
virQEMUCapsGuestIsNative(hostarch, qemuCaps->arch);
|
2016-08-03 14:22:30 +00:00
|
|
|
|
|
|
|
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:
|
2019-10-23 10:46:28 +00:00
|
|
|
cpus = virQEMUCapsGetAccel(qemuCaps, type)->cpuModels;
|
2019-09-24 14:38:05 +00:00
|
|
|
return cpus && cpus->ncpus > 0;
|
2016-08-03 14:22:30 +00:00
|
|
|
|
2021-02-05 15:51:09 +00:00
|
|
|
case VIR_CPU_MODE_MAXIMUM:
|
2021-02-05 18:35:10 +00:00
|
|
|
return virQEMUCapsGet(qemuCaps, QEMU_CAPS_CPU_MAX);
|
|
|
|
|
2016-08-03 14:22:30 +00:00
|
|
|
case VIR_CPU_MODE_LAST:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
2019-10-24 06:52:21 +00:00
|
|
|
const char *
|
|
|
|
virQEMUCapsGetCanonicalMachine(virQEMUCapsPtr qemuCaps,
|
2019-10-24 12:19:38 +00:00
|
|
|
virDomainVirtType virtType,
|
2019-10-24 06:52:21 +00:00
|
|
|
const char *name)
|
2012-08-22 10:11:28 +00:00
|
|
|
{
|
2019-10-24 12:19:38 +00:00
|
|
|
virQEMUCapsAccelPtr accel;
|
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
|
|
|
|
2019-10-24 12:19:38 +00:00
|
|
|
accel = virQEMUCapsGetAccel(qemuCaps, virtType);
|
|
|
|
|
|
|
|
for (i = 0; i < accel->nmachineTypes; i++) {
|
|
|
|
if (!accel->machineTypes[i].alias)
|
2012-08-22 10:11:28 +00:00
|
|
|
continue;
|
2019-10-24 12:19:38 +00:00
|
|
|
if (STREQ(accel->machineTypes[i].alias, name))
|
|
|
|
return accel->machineTypes[i].name;
|
2012-08-22 10:11:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return name;
|
|
|
|
}
|
2012-09-10 10:47:56 +00:00
|
|
|
|
|
|
|
|
2019-10-24 06:52:21 +00:00
|
|
|
int
|
|
|
|
virQEMUCapsGetMachineMaxCpus(virQEMUCapsPtr qemuCaps,
|
2019-10-24 12:19:38 +00:00
|
|
|
virDomainVirtType virtType,
|
2019-10-24 06:52:21 +00:00
|
|
|
const char *name)
|
2013-06-26 15:46:35 +00:00
|
|
|
{
|
2019-10-24 12:19:38 +00:00
|
|
|
virQEMUCapsAccelPtr accel;
|
2013-06-26 15:46:35 +00:00
|
|
|
size_t i;
|
|
|
|
|
|
|
|
if (!name)
|
|
|
|
return 0;
|
|
|
|
|
2019-10-24 12:19:38 +00:00
|
|
|
accel = virQEMUCapsGetAccel(qemuCaps, virtType);
|
|
|
|
|
|
|
|
for (i = 0; i < accel->nmachineTypes; i++) {
|
|
|
|
if (!accel->machineTypes[i].maxCpus)
|
2013-06-26 15:46:35 +00:00
|
|
|
continue;
|
2019-10-24 12:19:38 +00:00
|
|
|
if (STREQ(accel->machineTypes[i].name, name))
|
|
|
|
return accel->machineTypes[i].maxCpus;
|
2013-06-26 15:46:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-10-24 06:52:21 +00:00
|
|
|
bool
|
|
|
|
virQEMUCapsGetMachineHotplugCpus(virQEMUCapsPtr qemuCaps,
|
2019-10-24 12:19:38 +00:00
|
|
|
virDomainVirtType virtType,
|
2019-10-24 06:52:21 +00:00
|
|
|
const char *name)
|
2016-07-29 07:45:19 +00:00
|
|
|
{
|
2019-10-24 12:19:38 +00:00
|
|
|
virQEMUCapsAccelPtr accel;
|
2016-07-29 07:45:19 +00:00
|
|
|
size_t i;
|
|
|
|
|
2019-10-24 12:19:38 +00:00
|
|
|
accel = virQEMUCapsGetAccel(qemuCaps, virtType);
|
|
|
|
|
|
|
|
for (i = 0; i < accel->nmachineTypes; i++) {
|
|
|
|
if (STREQ_NULLABLE(accel->machineTypes[i].name, name))
|
|
|
|
return accel->machineTypes[i].hotplugCpus;
|
2016-07-29 07:45:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-09-26 13:22:38 +00:00
|
|
|
const char *
|
|
|
|
virQEMUCapsGetMachineDefaultCPU(virQEMUCapsPtr qemuCaps,
|
|
|
|
const char *name,
|
|
|
|
virDomainVirtType type)
|
|
|
|
{
|
|
|
|
virQEMUCapsAccelPtr accel = virQEMUCapsGetAccel(qemuCaps, type);
|
|
|
|
qemuMonitorCPUDefsPtr defs = accel->cpuModels;
|
|
|
|
const char *cpuType = NULL;
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
if (!name || !defs)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
for (i = 0; i < accel->nmachineTypes; i++) {
|
|
|
|
if (STREQ(accel->machineTypes[i].name, name)) {
|
|
|
|
cpuType = accel->machineTypes[i].defaultCPU;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!cpuType)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
for (i = 0; i < defs->ncpus; i++) {
|
|
|
|
if (STREQ_NULLABLE(defs->cpus[i].type, cpuType))
|
|
|
|
return defs->cpus[i].name;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-22 11:48:23 +00:00
|
|
|
bool
|
|
|
|
virQEMUCapsIsCPUDeprecated(virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainVirtType type,
|
|
|
|
const char *model)
|
|
|
|
{
|
|
|
|
virQEMUCapsAccelPtr accel = virQEMUCapsGetAccel(qemuCaps, type);
|
|
|
|
qemuMonitorCPUDefsPtr defs = accel->cpuModels;
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
for (i = 0; i < defs->ncpus; i++) {
|
|
|
|
if (STREQ_NULLABLE(defs->cpus[i].name, model))
|
|
|
|
return defs->cpus[i].deprecated;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-22 11:48:23 +00:00
|
|
|
bool
|
|
|
|
virQEMUCapsIsMachineDeprecated(virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainVirtType type,
|
|
|
|
const char *machine)
|
|
|
|
{
|
|
|
|
virQEMUCapsAccelPtr accel = virQEMUCapsGetAccel(qemuCaps, type);
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
for (i = 0; i < accel->nmachineTypes; i++) {
|
|
|
|
if (STREQ_NULLABLE(accel->machineTypes[i].name, machine))
|
|
|
|
return accel->machineTypes[i].deprecated;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-05-14 11:11:01 +00:00
|
|
|
bool
|
|
|
|
virQEMUCapsGetMachineNumaMemSupported(virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainVirtType virtType,
|
|
|
|
const char *name)
|
|
|
|
{
|
|
|
|
virQEMUCapsAccelPtr accel;
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
accel = virQEMUCapsGetAccel(qemuCaps, virtType);
|
|
|
|
|
|
|
|
for (i = 0; i < accel->nmachineTypes; i++) {
|
|
|
|
if (STREQ(accel->machineTypes[i].name, name))
|
|
|
|
return accel->machineTypes[i].numaMemSupported;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-05-25 17:13:43 +00:00
|
|
|
const char *
|
|
|
|
virQEMUCapsGetMachineDefaultRAMid(virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainVirtType virtType,
|
|
|
|
const char *name)
|
|
|
|
{
|
|
|
|
virQEMUCapsAccelPtr accel;
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
accel = virQEMUCapsGetAccel(qemuCaps, virtType);
|
|
|
|
|
|
|
|
for (i = 0; i < accel->nmachineTypes; i++) {
|
|
|
|
if (STREQ(accel->machineTypes[i].name, name))
|
|
|
|
return accel->machineTypes[i].defaultRAMid;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-06-08 14:40:55 +00:00
|
|
|
virSEVCapabilityPtr
|
|
|
|
virQEMUCapsGetSEVCapabilities(virQEMUCapsPtr qemuCaps)
|
|
|
|
{
|
|
|
|
return qemuCaps->sevCapabilities;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(virQEMUCapsCommands),
|
2013-06-19 08:00:10 +00:00
|
|
|
virQEMUCapsCommands,
|
|
|
|
ncommands, commands);
|
2017-03-03 20:31:26 +00:00
|
|
|
virStringListFreeCount(commands, ncommands);
|
2012-09-13 14:54:02 +00:00
|
|
|
|
2018-08-14 15:53:05 +00:00
|
|
|
/* Probe for active commit of qemu 2.1. We don't need to query directly
|
|
|
|
* if we have QMP schema support */
|
|
|
|
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_QMP_SCHEMA) &&
|
2014-06-17 03:42:49 +00:00
|
|
|
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;
|
|
|
|
|
2019-02-07 11:50:27 +00:00
|
|
|
/* we can probe events also from the QMP schema so we can skip this here */
|
2019-02-07 12:03:37 +00:00
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_QMP_SCHEMA))
|
2019-02-07 11:50:27 +00:00
|
|
|
return 0;
|
2019-02-07 12:03:37 +00:00
|
|
|
|
|
|
|
if ((nevents = qemuMonitorGetEvents(mon, &events)) < 0)
|
|
|
|
return -1;
|
2019-02-07 11:50:27 +00:00
|
|
|
|
2013-06-19 07:24:54 +00:00
|
|
|
virQEMUCapsProcessStringFlags(qemuCaps,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(virQEMUCapsEvents),
|
2013-06-19 07:24:54 +00:00
|
|
|
virQEMUCapsEvents,
|
|
|
|
nevents, events);
|
2017-03-03 20:31:26 +00:00
|
|
|
virStringListFreeCount(events, nevents);
|
2012-09-13 14:54:02 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-05-06 14:53:31 +00:00
|
|
|
|
2012-08-22 17:05:08 +00:00
|
|
|
static int
|
2020-05-06 14:53:31 +00:00
|
|
|
virQEMUCapsProbeQMPObjectTypes(virQEMUCapsPtr qemuCaps,
|
|
|
|
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,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(virQEMUCapsObjectTypes),
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsObjectTypes,
|
|
|
|
nvalues, values);
|
2017-03-03 20:31:26 +00:00
|
|
|
virStringListFreeCount(values, nvalues);
|
2013-02-01 13:48:58 +00:00
|
|
|
|
2020-05-06 14:53:31 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2012-08-22 17:05:08 +00:00
|
|
|
|
2018-04-20 08:25:49 +00:00
|
|
|
|
2020-05-06 14:53:31 +00:00
|
|
|
static int
|
|
|
|
virQEMUCapsProbeQMPDeviceProperties(virQEMUCapsPtr qemuCaps,
|
|
|
|
qemuMonitorPtr mon)
|
|
|
|
{
|
2020-05-06 15:12:12 +00:00
|
|
|
size_t i;
|
|
|
|
|
|
|
|
for (i = 0; i < G_N_ELEMENTS(virQEMUCapsDeviceProps); i++) {
|
2020-05-06 19:29:55 +00:00
|
|
|
virQEMUCapsDeviceTypeProps *device = virQEMUCapsDeviceProps + i;
|
2020-10-22 17:04:18 +00:00
|
|
|
g_autoptr(GHashTable) qemuprops = NULL;
|
2020-05-06 17:53:43 +00:00
|
|
|
size_t j;
|
2020-05-06 15:12:12 +00:00
|
|
|
|
|
|
|
if (device->capsCondition >= 0 &&
|
|
|
|
!virQEMUCapsGet(qemuCaps, device->capsCondition))
|
|
|
|
continue;
|
|
|
|
|
2020-05-06 17:53:43 +00:00
|
|
|
if (!(qemuprops = qemuMonitorGetDeviceProps(mon, device->type)))
|
2020-05-06 15:12:12 +00:00
|
|
|
return -1;
|
|
|
|
|
2020-05-06 17:53:43 +00:00
|
|
|
for (j = 0; j < device->nprops; j++) {
|
|
|
|
virJSONValuePtr entry = virHashLookup(qemuprops, device->props[j].value);
|
|
|
|
|
|
|
|
if (!entry)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
virQEMUCapsSet(qemuCaps, device->props[j].flag);
|
2020-05-06 19:29:55 +00:00
|
|
|
|
|
|
|
if (device->props[j].cb &&
|
|
|
|
device->props[j].cb(entry, qemuCaps) < 0)
|
|
|
|
return -1;
|
2020-05-06 17:53:43 +00:00
|
|
|
}
|
2020-05-06 15:12:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2020-05-06 14:53:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
virQEMUCapsProbeQMPObjectProperties(virQEMUCapsPtr qemuCaps,
|
|
|
|
qemuMonitorPtr mon)
|
|
|
|
{
|
2020-05-06 15:15:14 +00:00
|
|
|
size_t i;
|
|
|
|
|
2020-05-06 14:53:31 +00:00
|
|
|
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QOM_LIST_PROPERTIES))
|
|
|
|
return 0;
|
|
|
|
|
2020-05-06 15:15:14 +00:00
|
|
|
for (i = 0; i < G_N_ELEMENTS(virQEMUCapsObjectProps); i++) {
|
|
|
|
virQEMUCapsObjectTypeProps *props = virQEMUCapsObjectProps + i;
|
2020-12-01 08:21:32 +00:00
|
|
|
g_auto(GStrv) values = NULL;
|
2020-05-06 15:15:14 +00:00
|
|
|
int nvalues;
|
|
|
|
|
|
|
|
if (props->capsCondition >= 0 &&
|
|
|
|
!virQEMUCapsGet(qemuCaps, props->capsCondition))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if ((nvalues = qemuMonitorGetObjectProps(mon, props->type, &values)) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
virQEMUCapsProcessStringFlags(qemuCaps,
|
|
|
|
props->nprops,
|
|
|
|
props->props,
|
|
|
|
nvalues, values);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2012-08-22 17:05:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-08-03 12:29:26 +00:00
|
|
|
/* Historically QEMU x86 targets defaulted to 'pc' machine type but
|
|
|
|
* in future x86_64 might switch to 'q35'. Such a change is considered
|
|
|
|
* an ABI break from libvirt's POV. Other QEMU targets may not declare
|
|
|
|
* a default machine at all, causing libvirt to use the first reported
|
|
|
|
* machine in the list.
|
|
|
|
*
|
|
|
|
* Here we record a preferred default machine for all arches, so
|
|
|
|
* that we're not vulnerable to changes in QEMU defaults or machine
|
|
|
|
* list ordering.
|
|
|
|
*/
|
2018-08-23 16:46:52 +00:00
|
|
|
static const char *preferredMachines[] =
|
2018-08-03 12:29:26 +00:00
|
|
|
{
|
2018-08-23 16:46:52 +00:00
|
|
|
NULL, /* VIR_ARCH_NONE (not a real arch :) */
|
|
|
|
"clipper", /* VIR_ARCH_ALPHA */
|
2018-11-28 21:45:14 +00:00
|
|
|
"integratorcp", /* VIR_ARCH_ARMV6L */
|
2018-08-23 16:46:52 +00:00
|
|
|
"integratorcp", /* VIR_ARCH_ARMV7L */
|
|
|
|
"integratorcp", /* VIR_ARCH_ARMV7B */
|
|
|
|
|
|
|
|
"integratorcp", /* VIR_ARCH_AARCH64 */
|
|
|
|
"axis-dev88", /* VIR_ARCH_CRIS */
|
|
|
|
"pc", /* VIR_ARCH_I686 */
|
|
|
|
NULL, /* VIR_ARCH_ITANIUM (doesn't exist in QEMU any more) */
|
|
|
|
"lm32-evr", /* VIR_ARCH_LM32 */
|
|
|
|
|
|
|
|
"mcf5208evb", /* VIR_ARCH_M68K */
|
|
|
|
"petalogix-s3adsp1800", /* VIR_ARCH_MICROBLAZE */
|
|
|
|
"petalogix-s3adsp1800", /* VIR_ARCH_MICROBLAZEEL */
|
|
|
|
"malta", /* VIR_ARCH_MIPS */
|
|
|
|
"malta", /* VIR_ARCH_MIPSEL */
|
|
|
|
|
|
|
|
"malta", /* VIR_ARCH_MIPS64 */
|
|
|
|
"malta", /* VIR_ARCH_MIPS64EL */
|
|
|
|
"or1k-sim", /* VIR_ARCH_OR32 */
|
|
|
|
NULL, /* VIR_ARCH_PARISC (no QEMU impl) */
|
|
|
|
NULL, /* VIR_ARCH_PARISC64 (no QEMU impl) */
|
|
|
|
|
|
|
|
"g3beige", /* VIR_ARCH_PPC */
|
|
|
|
"g3beige", /* VIR_ARCH_PPCLE */
|
|
|
|
"pseries", /* VIR_ARCH_PPC64 */
|
|
|
|
"pseries", /* VIR_ARCH_PPC64LE */
|
|
|
|
"bamboo", /* VIR_ARCH_PPCEMB */
|
|
|
|
|
2018-08-22 09:15:22 +00:00
|
|
|
"spike_v1.10", /* VIR_ARCH_RISCV32 */
|
|
|
|
"spike_v1.10", /* VIR_ARCH_RISCV64 */
|
2018-08-23 16:46:52 +00:00
|
|
|
NULL, /* VIR_ARCH_S390 (no QEMU impl) */
|
|
|
|
"s390-ccw-virtio", /* VIR_ARCH_S390X */
|
|
|
|
"shix", /* VIR_ARCH_SH4 */
|
2018-08-22 09:15:22 +00:00
|
|
|
|
2018-08-23 16:46:52 +00:00
|
|
|
"shix", /* VIR_ARCH_SH4EB */
|
|
|
|
"SS-5", /* VIR_ARCH_SPARC */
|
|
|
|
"sun4u", /* VIR_ARCH_SPARC64 */
|
|
|
|
"puv3", /* VIR_ARCH_UNICORE32 */
|
|
|
|
"pc", /* VIR_ARCH_X86_64 */
|
2018-08-22 09:15:22 +00:00
|
|
|
|
2018-08-23 16:46:52 +00:00
|
|
|
"sim", /* VIR_ARCH_XTENSA */
|
|
|
|
"sim", /* VIR_ARCH_XTENSAEB */
|
2018-08-03 12:29:26 +00:00
|
|
|
};
|
2020-01-09 10:39:55 +00:00
|
|
|
G_STATIC_ASSERT(G_N_ELEMENTS(preferredMachines) == VIR_ARCH_LAST);
|
2018-08-03 12:29:26 +00:00
|
|
|
|
|
|
|
|
2019-12-02 12:19:44 +00:00
|
|
|
void
|
|
|
|
virQEMUCapsAddMachine(virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainVirtType virtType,
|
|
|
|
const char *name,
|
|
|
|
const char *alias,
|
|
|
|
const char *defaultCPU,
|
|
|
|
int maxCpus,
|
|
|
|
bool hotplugCpus,
|
2020-05-14 11:11:01 +00:00
|
|
|
bool isDefault,
|
2020-05-25 17:13:43 +00:00
|
|
|
bool numaMemSupported,
|
2021-01-22 12:16:23 +00:00
|
|
|
const char *defaultRAMid,
|
|
|
|
bool deprecated)
|
2019-12-02 12:19:44 +00:00
|
|
|
{
|
|
|
|
virQEMUCapsAccelPtr accel = virQEMUCapsGetAccel(qemuCaps, virtType);
|
|
|
|
virQEMUCapsMachineTypePtr mach;
|
|
|
|
|
|
|
|
accel->machineTypes = g_renew(virQEMUCapsMachineType,
|
|
|
|
accel->machineTypes,
|
|
|
|
++accel->nmachineTypes);
|
|
|
|
|
|
|
|
mach = &(accel->machineTypes[accel->nmachineTypes - 1]);
|
|
|
|
|
|
|
|
mach->alias = g_strdup(alias);
|
|
|
|
mach->name = g_strdup(name);
|
|
|
|
mach->defaultCPU = g_strdup(defaultCPU);
|
|
|
|
|
|
|
|
mach->maxCpus = maxCpus;
|
|
|
|
mach->hotplugCpus = hotplugCpus;
|
|
|
|
|
|
|
|
mach->qemuDefault = isDefault;
|
2020-05-14 11:11:01 +00:00
|
|
|
|
|
|
|
mach->numaMemSupported = numaMemSupported;
|
2020-05-25 17:13:43 +00:00
|
|
|
|
|
|
|
mach->defaultRAMid = g_strdup(defaultRAMid);
|
2021-01-22 12:16:23 +00:00
|
|
|
mach->deprecated = deprecated;
|
2019-12-02 12:19:44 +00:00
|
|
|
}
|
|
|
|
|
2020-01-23 12:21:47 +00:00
|
|
|
/**
|
|
|
|
* virQEMUCapsHasMachines:
|
|
|
|
* @qemuCaps: qemu capabilities object
|
|
|
|
*
|
|
|
|
* Returns true if @qemuCaps has at least one machine type defined. This is
|
|
|
|
* called by the test suite to figure out whether to populate fake machine types
|
|
|
|
* into the list.
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
virQEMUCapsHasMachines(virQEMUCapsPtr qemuCaps)
|
|
|
|
{
|
|
|
|
|
|
|
|
return !!qemuCaps->kvm.nmachineTypes || !!qemuCaps->tcg.nmachineTypes;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-08-22 17:05:08 +00:00
|
|
|
static int
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsProbeQMPMachineTypes(virQEMUCapsPtr qemuCaps,
|
2019-12-02 12:19:44 +00:00
|
|
|
virDomainVirtType virtType,
|
2013-02-01 13:48:58 +00:00
|
|
|
qemuMonitorPtr mon)
|
2012-08-22 17:05:08 +00:00
|
|
|
{
|
|
|
|
qemuMonitorMachineInfoPtr *machines = NULL;
|
|
|
|
int nmachines = 0;
|
|
|
|
size_t i;
|
2018-08-03 12:29:26 +00:00
|
|
|
ssize_t defIdx = -1;
|
|
|
|
ssize_t preferredIdx = -1;
|
|
|
|
const char *preferredMachine = preferredMachines[qemuCaps->arch];
|
2019-12-02 12:19:44 +00:00
|
|
|
virQEMUCapsAccelPtr accel = virQEMUCapsGetAccel(qemuCaps, virtType);
|
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-05-21 07:21:20 +00:00
|
|
|
for (i = 0; i < nmachines; i++) {
|
2013-11-06 07:31:24 +00:00
|
|
|
if (STREQ(machines[i]->name, "none"))
|
|
|
|
continue;
|
2016-07-29 08:35:48 +00:00
|
|
|
|
2019-12-02 12:19:44 +00:00
|
|
|
virQEMUCapsAddMachine(qemuCaps,
|
|
|
|
virtType,
|
|
|
|
machines[i]->name,
|
|
|
|
machines[i]->alias,
|
|
|
|
machines[i]->defaultCPU,
|
|
|
|
machines[i]->maxCpus,
|
|
|
|
machines[i]->hotplugCpus,
|
2020-05-14 11:11:01 +00:00
|
|
|
machines[i]->isDefault,
|
2020-05-25 17:13:43 +00:00
|
|
|
machines[i]->numaMemSupported,
|
2021-01-22 12:16:23 +00:00
|
|
|
machines[i]->defaultRAMid,
|
|
|
|
machines[i]->deprecated);
|
2016-07-29 08:35:48 +00:00
|
|
|
|
2018-08-03 12:29:26 +00:00
|
|
|
if (preferredMachine &&
|
2019-12-02 12:19:44 +00:00
|
|
|
(STREQ_NULLABLE(machines[i]->alias, preferredMachine) ||
|
|
|
|
STREQ(machines[i]->name, preferredMachine))) {
|
2019-10-24 12:19:38 +00:00
|
|
|
preferredIdx = accel->nmachineTypes - 1;
|
2018-08-03 12:29:26 +00:00
|
|
|
}
|
|
|
|
|
2019-12-02 12:19:44 +00:00
|
|
|
if (machines[i]->isDefault)
|
2019-10-24 12:19:38 +00:00
|
|
|
defIdx = accel->nmachineTypes - 1;
|
2012-08-22 17:05:08 +00:00
|
|
|
}
|
2012-11-30 18:22:42 +00:00
|
|
|
|
2018-08-03 12:29:26 +00:00
|
|
|
/*
|
|
|
|
* We'll prefer to use our own historical default machine
|
|
|
|
* to avoid mgmt apps seeing semantics changes when QEMU
|
|
|
|
* alters its defaults.
|
|
|
|
*
|
|
|
|
* Our preferred machine might have been compiled out of
|
|
|
|
* QEMU at build time though, so we still fallback to honouring
|
|
|
|
* QEMU's reported default in that case
|
|
|
|
*/
|
|
|
|
if (preferredIdx == -1)
|
|
|
|
preferredIdx = defIdx;
|
|
|
|
if (preferredIdx != -1)
|
2019-10-24 12:19:38 +00:00
|
|
|
virQEMUCapsSetDefaultMachine(accel, preferredIdx);
|
2012-08-22 17:05:08 +00:00
|
|
|
|
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);
|
2019-12-02 12:19:44 +00:00
|
|
|
return 0;
|
2012-08-22 17:05:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-22 09:06:53 +00:00
|
|
|
bool
|
2019-10-23 15:51:50 +00:00
|
|
|
virQEMUCapsIsMachineSupported(virQEMUCapsPtr qemuCaps,
|
2019-10-24 12:19:38 +00:00
|
|
|
virDomainVirtType virtType,
|
2019-10-23 15:51:50 +00:00
|
|
|
const char *canonical_machine)
|
|
|
|
{
|
2019-10-24 12:19:38 +00:00
|
|
|
virQEMUCapsAccelPtr accel = virQEMUCapsGetAccel(qemuCaps, virtType);
|
2019-10-23 15:51:50 +00:00
|
|
|
size_t i;
|
|
|
|
|
2019-10-24 12:19:38 +00:00
|
|
|
for (i = 0; i < accel->nmachineTypes; i++) {
|
|
|
|
if (STREQ(canonical_machine, accel->machineTypes[i].name))
|
2019-10-23 15:51:50 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-16 13:45:08 +00:00
|
|
|
static int
|
|
|
|
virQEMUCapsProbeQMPMachineProps(virQEMUCapsPtr qemuCaps,
|
2019-10-24 06:52:21 +00:00
|
|
|
virDomainVirtType virtType,
|
2019-05-16 13:45:08 +00:00
|
|
|
qemuMonitorPtr mon)
|
|
|
|
{
|
|
|
|
char **values;
|
|
|
|
int nvalues;
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QOM_LIST_PROPERTIES))
|
|
|
|
return 0;
|
|
|
|
|
2019-10-15 11:55:26 +00:00
|
|
|
for (i = 0; i < G_N_ELEMENTS(virQEMUCapsMachineProps); i++) {
|
2019-05-16 13:45:08 +00:00
|
|
|
virQEMUCapsObjectTypeProps props = virQEMUCapsMachineProps[i];
|
2019-10-24 06:52:21 +00:00
|
|
|
const char *canon = virQEMUCapsGetCanonicalMachine(qemuCaps, virtType, props.type);
|
2019-10-15 13:16:31 +00:00
|
|
|
g_autofree char *type = NULL;
|
2019-05-16 08:18:58 +00:00
|
|
|
|
2019-10-24 06:52:21 +00:00
|
|
|
if (!virQEMUCapsIsMachineSupported(qemuCaps, virtType, canon))
|
2019-05-16 10:04:48 +00:00
|
|
|
continue;
|
|
|
|
|
2019-05-16 08:18:58 +00:00
|
|
|
/* The QOM type for machine types is the machine type name
|
|
|
|
* followed by the -machine suffix */
|
2019-10-22 13:26:14 +00:00
|
|
|
type = g_strdup_printf("%s-machine", canon);
|
2019-05-16 13:45:08 +00:00
|
|
|
|
|
|
|
if ((nvalues = qemuMonitorGetObjectProps(mon, type, &values)) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
virQEMUCapsProcessStringFlags(qemuCaps,
|
|
|
|
props.nprops,
|
|
|
|
props.props,
|
|
|
|
nvalues, values);
|
|
|
|
|
|
|
|
virStringListFreeCount(values, nvalues);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-10-09 08:16:17 +00:00
|
|
|
static int
|
|
|
|
virQEMUCapsFetchCPUDefinitions(qemuMonitorPtr mon,
|
|
|
|
virArch arch,
|
|
|
|
qemuMonitorCPUDefsPtr *cpuDefs)
|
2012-08-22 17:05:08 +00:00
|
|
|
{
|
2019-09-24 11:42:00 +00:00
|
|
|
g_autoptr(qemuMonitorCPUDefs) defs = NULL;
|
2016-04-21 10:51:01 +00:00
|
|
|
size_t i;
|
2019-10-10 14:44:40 +00:00
|
|
|
|
2019-10-09 08:16:17 +00:00
|
|
|
*cpuDefs = NULL;
|
2012-08-22 17:05:08 +00:00
|
|
|
|
2019-09-24 11:42:00 +00:00
|
|
|
if (qemuMonitorGetCPUDefinitions(mon, &defs) < 0)
|
2019-10-10 14:44:40 +00:00
|
|
|
return -1;
|
|
|
|
|
2019-09-24 13:59:34 +00:00
|
|
|
if (!defs)
|
|
|
|
return 0;
|
2012-08-22 17:05:08 +00:00
|
|
|
|
2018-05-17 15:08:42 +00:00
|
|
|
/* QEMU 2.11 for Power renamed all CPU models to lower case, we need to
|
|
|
|
* translate them back to libvirt's upper case model names. */
|
2019-10-18 18:20:43 +00:00
|
|
|
if (ARCH_IS_PPC64(arch)) {
|
2020-12-01 08:21:32 +00:00
|
|
|
g_auto(GStrv) libvirtModels = NULL;
|
2018-05-17 15:08:42 +00:00
|
|
|
char **name;
|
|
|
|
|
|
|
|
if (virCPUGetModels(arch, &libvirtModels) < 0)
|
2019-09-24 13:59:34 +00:00
|
|
|
return -1;
|
2018-05-17 15:08:42 +00:00
|
|
|
|
|
|
|
for (name = libvirtModels; name && *name; name++) {
|
2019-09-24 11:42:00 +00:00
|
|
|
for (i = 0; i < defs->ncpus; i++) {
|
2019-09-24 11:45:37 +00:00
|
|
|
if (STRCASENEQ(defs->cpus[i].name, *name))
|
2018-05-17 15:08:42 +00:00
|
|
|
continue;
|
|
|
|
|
2019-09-24 11:45:37 +00:00
|
|
|
VIR_FREE(defs->cpus[i].name);
|
|
|
|
defs->cpus[i].name = g_strdup(*name);
|
2018-05-17 15:08:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-09 08:16:17 +00:00
|
|
|
*cpuDefs = g_steal_pointer(&defs);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
virQEMUCapsFetchCPUModels(qemuMonitorPtr mon,
|
|
|
|
virArch arch,
|
|
|
|
virDomainCapsCPUModelsPtr *cpuModels)
|
|
|
|
{
|
|
|
|
g_autoptr(qemuMonitorCPUDefs) defs = NULL;
|
|
|
|
|
|
|
|
*cpuModels = NULL;
|
|
|
|
|
|
|
|
if (virQEMUCapsFetchCPUDefinitions(mon, arch, &defs) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (defs && !(*cpuModels = virQEMUCapsCPUDefsToModels(defs, NULL, NULL)))
|
2019-09-24 13:59:34 +00:00
|
|
|
return -1;
|
2019-10-10 14:44:40 +00:00
|
|
|
|
2019-09-24 13:59:34 +00:00
|
|
|
return 0;
|
2012-08-22 17:05:08 +00:00
|
|
|
}
|
|
|
|
|
2017-12-07 10:21:48 +00:00
|
|
|
|
2019-10-23 12:08:16 +00:00
|
|
|
static int
|
2017-12-07 10:21:48 +00:00
|
|
|
virQEMUCapsProbeQMPCPUDefinitions(virQEMUCapsPtr qemuCaps,
|
2019-10-23 14:48:17 +00:00
|
|
|
virQEMUCapsAccelPtr accel,
|
|
|
|
qemuMonitorPtr mon)
|
2017-12-07 10:21:48 +00:00
|
|
|
{
|
2021-02-05 18:21:14 +00:00
|
|
|
qemuMonitorCPUDefsPtr defs;
|
|
|
|
size_t i;
|
|
|
|
|
2017-12-07 10:21:48 +00:00
|
|
|
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_DEFINITIONS))
|
|
|
|
return 0;
|
|
|
|
|
2019-10-23 14:48:17 +00:00
|
|
|
if (virQEMUCapsFetchCPUDefinitions(mon, qemuCaps->arch, &accel->cpuModels) < 0)
|
2017-12-07 10:21:48 +00:00
|
|
|
return -1;
|
|
|
|
|
2021-02-05 18:21:14 +00:00
|
|
|
defs = accel->cpuModels;
|
|
|
|
for (i = 0; i < defs->ncpus; i++) {
|
|
|
|
if (STREQ_NULLABLE(defs->cpus[i].name, "max")) {
|
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_CPU_MAX);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-07 10:21:48 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-10-23 12:08:16 +00:00
|
|
|
int
|
|
|
|
virQEMUCapsProbeCPUDefinitionsTest(virQEMUCapsPtr qemuCaps,
|
|
|
|
qemuMonitorPtr mon)
|
|
|
|
{
|
2019-10-23 14:48:17 +00:00
|
|
|
return virQEMUCapsProbeQMPCPUDefinitions(qemuCaps, &qemuCaps->kvm, mon);
|
2019-10-23 12:08:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-06 07:52:22 +00:00
|
|
|
static int
|
|
|
|
virQEMUCapsProbeQMPHostCPU(virQEMUCapsPtr qemuCaps,
|
2019-10-23 14:48:17 +00:00
|
|
|
virQEMUCapsAccelPtr accel,
|
2017-02-22 15:51:50 +00:00
|
|
|
qemuMonitorPtr mon,
|
2019-10-23 14:48:17 +00:00
|
|
|
virDomainVirtType virtType)
|
2017-01-06 07:52:22 +00:00
|
|
|
{
|
2019-10-23 14:48:17 +00:00
|
|
|
const char *model = virtType == VIR_DOMAIN_VIRT_KVM ? "host" : "max";
|
2017-04-07 16:15:26 +00:00
|
|
|
qemuMonitorCPUModelInfoPtr modelInfo = NULL;
|
2017-03-29 08:58:41 +00:00
|
|
|
qemuMonitorCPUModelInfoPtr nonMigratable = NULL;
|
2020-10-22 17:04:18 +00:00
|
|
|
GHashTable *hash = NULL;
|
2019-09-19 20:24:54 +00:00
|
|
|
virCPUDefPtr cpu;
|
2017-02-23 12:53:51 +00:00
|
|
|
qemuMonitorCPUModelExpansionType type;
|
2019-09-19 20:24:56 +00:00
|
|
|
bool fail_no_props = true;
|
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;
|
|
|
|
|
2019-11-29 11:00:26 +00:00
|
|
|
cpu = virCPUDefNew();
|
2019-09-19 20:24:54 +00:00
|
|
|
|
2019-10-20 11:49:46 +00:00
|
|
|
cpu->model = g_strdup(model);
|
|
|
|
|
2020-10-09 10:47:18 +00:00
|
|
|
/* Some x86_64 features defined in src/cpu_map/ use spelling which differ
|
2017-02-23 12:53:51 +00:00
|
|
|
* from the one preferred by QEMU. Static expansion would give us only the
|
2019-06-12 11:54:27 +00:00
|
|
|
* preferred spelling. With new QEMU we always use the QEMU's canonical
|
|
|
|
* names of all features and translate between them and our names. But for
|
|
|
|
* older version of QEMU we need to do a full expansion on the result of
|
|
|
|
* the initial static expansion to get all variants of feature names.
|
2017-02-23 12:53:51 +00:00
|
|
|
*/
|
2019-06-12 11:54:27 +00:00
|
|
|
if (ARCH_IS_X86(qemuCaps->arch) &&
|
2019-06-24 12:16:17 +00:00
|
|
|
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CANONICAL_CPU_FEATURES)) {
|
2017-02-23 12:53:51 +00:00
|
|
|
type = QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC_FULL;
|
2019-06-24 12:16:17 +00:00
|
|
|
} else if (ARCH_IS_ARM(qemuCaps->arch)) {
|
|
|
|
type = QEMU_MONITOR_CPU_MODEL_EXPANSION_FULL;
|
|
|
|
} else {
|
2017-02-23 12:53:51 +00:00
|
|
|
type = QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC;
|
2019-06-24 12:16:17 +00:00
|
|
|
}
|
2017-02-23 12:53:51 +00:00
|
|
|
|
2019-09-19 20:24:56 +00:00
|
|
|
/* Older s390 models do not report a feature set */
|
|
|
|
if (ARCH_IS_S390(qemuCaps->arch))
|
|
|
|
fail_no_props = false;
|
|
|
|
|
|
|
|
if (qemuMonitorGetCPUModelExpansion(mon, type, cpu, true, fail_no_props,
|
|
|
|
&modelInfo) < 0)
|
2017-04-07 16:15:26 +00:00
|
|
|
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 &&
|
2020-06-02 23:07:06 +00:00
|
|
|
virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_MIGRATABLE) &&
|
2019-09-19 20:24:56 +00:00
|
|
|
qemuMonitorGetCPUModelExpansion(mon, type, cpu, false, fail_no_props,
|
2017-03-29 08:58:41 +00:00
|
|
|
&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;
|
|
|
|
|
2020-10-20 16:43:20 +00:00
|
|
|
if (!(hash = virHashNew(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
|
|
|
}
|
|
|
|
|
2019-10-23 14:48:17 +00:00
|
|
|
accel->hostCPU.info = g_steal_pointer(&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);
|
2019-09-19 20:24:54 +00:00
|
|
|
virCPUDefFree(cpu);
|
2017-03-29 08:58:41 +00:00
|
|
|
|
|
|
|
return ret;
|
2017-01-06 07:52:22 +00:00
|
|
|
}
|
|
|
|
|
2018-05-15 20:03:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get NULL terminated list of features supported by QEMU.
|
|
|
|
*
|
|
|
|
* Returns -1 on error,
|
|
|
|
* 0 on success (@features will be NULL if QEMU does not support this),
|
|
|
|
* 1 when @features is filled in, but migratability info is not available.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
virQEMUCapsGetCPUFeatures(virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainVirtType virtType,
|
|
|
|
bool migratable,
|
|
|
|
char ***features)
|
|
|
|
{
|
2019-02-25 09:00:53 +00:00
|
|
|
qemuMonitorCPUModelInfoPtr modelInfo;
|
2018-05-15 20:03:19 +00:00
|
|
|
char **list;
|
|
|
|
size_t i;
|
|
|
|
size_t n;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
*features = NULL;
|
2019-02-25 09:00:53 +00:00
|
|
|
modelInfo = virQEMUCapsGetCPUModelInfo(qemuCaps, virtType);
|
2018-05-15 20:03:19 +00:00
|
|
|
|
2019-02-25 09:00:53 +00:00
|
|
|
if (!modelInfo)
|
2018-05-15 20:03:19 +00:00
|
|
|
return 0;
|
|
|
|
|
2020-10-05 10:25:44 +00:00
|
|
|
list = g_new0(char *, modelInfo->nprops + 1);
|
2018-05-15 20:03:19 +00:00
|
|
|
|
|
|
|
n = 0;
|
2019-02-25 09:00:53 +00:00
|
|
|
for (i = 0; i < modelInfo->nprops; i++) {
|
|
|
|
qemuMonitorCPUPropertyPtr prop = modelInfo->props + i;
|
2018-05-15 20:03:19 +00:00
|
|
|
|
|
|
|
if (migratable && prop->migratable == VIR_TRISTATE_BOOL_NO)
|
|
|
|
continue;
|
|
|
|
|
2019-10-20 11:49:46 +00:00
|
|
|
list[n++] = g_strdup(virQEMUCapsCPUFeatureFromQEMU(qemuCaps, prop->name));
|
2018-05-15 20:03:19 +00:00
|
|
|
}
|
|
|
|
|
2019-10-16 11:43:18 +00:00
|
|
|
*features = g_steal_pointer(&list);
|
2019-02-25 09:00:53 +00:00
|
|
|
if (migratable && !modelInfo->migratability)
|
2018-05-15 20:03:19 +00:00
|
|
|
ret = 1;
|
|
|
|
else
|
|
|
|
ret = 0;
|
|
|
|
|
2020-08-02 17:36:03 +00:00
|
|
|
g_strfreev(list);
|
2018-05-15 20:03:19 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
},
|
2017-04-04 16:22:31 +00:00
|
|
|
{
|
|
|
|
.type = VIR_DOMAIN_TPM_TYPE_EMULATOR,
|
|
|
|
.caps = QEMU_CAPS_DEVICE_TPM_EMULATOR,
|
|
|
|
},
|
2013-04-12 20:55:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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,
|
|
|
|
},
|
2020-02-05 18:35:47 +00:00
|
|
|
{
|
|
|
|
.type = VIR_DOMAIN_TPM_MODEL_SPAPR,
|
|
|
|
.caps = QEMU_CAPS_DEVICE_TPM_SPAPR,
|
|
|
|
},
|
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) {
|
2019-10-15 11:55:26 +00:00
|
|
|
for (i = 0; i < G_N_ELEMENTS(virQEMUCapsTPMModelsToCaps); i++) {
|
2013-04-12 20:55:45 +00:00
|
|
|
const char *needle = virDomainTPMModelTypeToString(
|
|
|
|
virQEMUCapsTPMModelsToCaps[i].type);
|
2021-02-03 17:39:47 +00:00
|
|
|
if (g_strv_contains((const char **)entries, needle))
|
2013-04-12 20:55:45 +00:00
|
|
|
virQEMUCapsSet(qemuCaps,
|
|
|
|
virQEMUCapsTPMModelsToCaps[i].caps);
|
|
|
|
}
|
|
|
|
}
|
2020-08-02 17:36:03 +00:00
|
|
|
g_strfreev(entries);
|
2013-04-12 20:55:45 +00:00
|
|
|
|
|
|
|
if ((nentries = qemuMonitorGetTPMTypes(mon, &entries)) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (nentries > 0) {
|
2019-10-15 11:55:26 +00:00
|
|
|
for (i = 0; i < G_N_ELEMENTS(virQEMUCapsTPMTypesToCaps); i++) {
|
2013-04-12 20:55:45 +00:00
|
|
|
const char *needle = virDomainTPMBackendTypeToString(
|
|
|
|
virQEMUCapsTPMTypesToCaps[i].type);
|
2021-02-03 17:39:47 +00:00
|
|
|
if (g_strv_contains((const char **)entries, needle))
|
2013-04-12 20:55:45 +00:00
|
|
|
virQEMUCapsSet(qemuCaps, virQEMUCapsTPMTypesToCaps[i].caps);
|
|
|
|
}
|
|
|
|
}
|
2020-08-02 17:36:03 +00:00
|
|
|
g_strfreev(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;
|
|
|
|
|
|
|
|
if (qemuMonitorGetKVMState(mon, &enabled, &present) < 0)
|
|
|
|
return -1;
|
|
|
|
|
2018-09-13 14:56:55 +00:00
|
|
|
if (present && enabled)
|
|
|
|
virQEMUCapsSet(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;
|
|
|
|
}
|
|
|
|
|
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 },
|
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-05-18 12:46:54 +00:00
|
|
|
{ "sandbox", "enable", QEMU_CAPS_SECCOMP_SANDBOX },
|
2018-03-31 20:15:02 +00:00
|
|
|
{ "sandbox", "elevateprivileges", QEMU_CAPS_SECCOMP_BLACKLIST },
|
2018-03-14 10:34:37 +00:00
|
|
|
{ "chardev", "fd", QEMU_CAPS_CHARDEV_FD_PASS },
|
2019-04-12 08:16:06 +00:00
|
|
|
{ "overcommit", NULL, QEMU_CAPS_OVERCOMMIT },
|
2019-12-16 15:28:09 +00:00
|
|
|
{ "smp-opts", "dies", QEMU_CAPS_SMP_DIES },
|
2020-03-30 18:04:47 +00:00
|
|
|
{ "fsdev", "multidevs", QEMU_CAPS_FSDEV_MULTIDEVS },
|
2020-06-02 14:57:56 +00:00
|
|
|
{ "fw_cfg", "file", QEMU_CAPS_FW_CFG },
|
2020-10-08 14:32:23 +00:00
|
|
|
{ "fsdev", "fmode", QEMU_CAPS_FSDEV_CREATEMODE }, /* Could have also checked fsdev->dmode */
|
2021-02-16 11:45:46 +00:00
|
|
|
{ "vnc", "display", QEMU_CAPS_VNC_OPTS },
|
2021-02-16 13:34:26 +00:00
|
|
|
{ "vnc", "power-control", QEMU_CAPS_VNC_POWER_CONTROL },
|
2021-02-23 16:16:28 +00:00
|
|
|
{ "vnc", "audiodev", QEMU_CAPS_AUDIODEV },
|
2013-05-14 05:25:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
virQEMUCapsProbeQMPCommandLine(virQEMUCapsPtr qemuCaps,
|
|
|
|
qemuMonitorPtr mon)
|
|
|
|
{
|
2020-11-30 17:05:23 +00:00
|
|
|
g_autoptr(GHashTable) options = NULL;
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
if (!(options = qemuMonitorGetCommandLineOptions(mon)))
|
|
|
|
return -1;
|
2013-05-14 05:25:49 +00:00
|
|
|
|
2019-10-15 11:55:26 +00:00
|
|
|
for (i = 0; i < G_N_ELEMENTS(virQEMUCapsCommandLine); i++) {
|
2020-11-30 17:05:23 +00:00
|
|
|
virJSONValuePtr option = g_hash_table_lookup(options, virQEMUCapsCommandLine[i].option);
|
|
|
|
size_t j;
|
2014-06-17 11:41:16 +00:00
|
|
|
|
2020-11-30 17:05:23 +00:00
|
|
|
if (!option)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* not looking for a specific argument */
|
|
|
|
if (!virQEMUCapsCommandLine[i].param) {
|
2014-06-17 11:41:16 +00:00
|
|
|
virQEMUCapsSet(qemuCaps, virQEMUCapsCommandLine[i].flag);
|
2020-11-30 17:05:23 +00:00
|
|
|
continue;
|
|
|
|
}
|
2014-06-17 11:41:16 +00:00
|
|
|
|
2020-11-30 17:05:23 +00:00
|
|
|
for (j = 0; j < virJSONValueArraySize(option); j++) {
|
|
|
|
virJSONValuePtr param = virJSONValueArrayGet(option, j);
|
|
|
|
const char *paramname = virJSONValueObjectGetString(param, "name");
|
|
|
|
|
|
|
|
if (STREQ_NULLABLE(virQEMUCapsCommandLine[i].param, paramname))
|
2013-05-14 05:25:49 +00:00
|
|
|
virQEMUCapsSet(qemuCaps, virQEMUCapsCommandLine[i].flag);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(virQEMUCapsMigration),
|
2014-09-11 12:11:54 +00:00
|
|
|
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;
|
|
|
|
|
2019-04-02 10:31:31 +00:00
|
|
|
if (!(qemuCaps->arch == VIR_ARCH_AARCH64 ||
|
|
|
|
qemuCaps->arch == VIR_ARCH_ARMV6L ||
|
|
|
|
qemuCaps->arch == VIR_ARCH_ARMV7L))
|
|
|
|
return 0;
|
|
|
|
|
2016-03-08 17:24:18 +00:00
|
|
|
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
|
|
|
|
2018-06-08 14:40:51 +00:00
|
|
|
static int
|
|
|
|
virQEMUCapsProbeQMPSEVCapabilities(virQEMUCapsPtr qemuCaps,
|
|
|
|
qemuMonitorPtr mon)
|
|
|
|
{
|
2018-08-14 13:54:46 +00:00
|
|
|
int rc = -1;
|
2018-06-08 14:40:51 +00:00
|
|
|
virSEVCapability *caps = NULL;
|
|
|
|
|
2019-04-02 10:31:31 +00:00
|
|
|
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SEV_GUEST))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if ((rc = qemuMonitorGetSEVCapabilities(mon, &caps)) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
/* SEV isn't actually supported */
|
|
|
|
if (rc == 0) {
|
|
|
|
virQEMUCapsClear(qemuCaps, QEMU_CAPS_SEV_GUEST);
|
|
|
|
return 0;
|
|
|
|
}
|
2018-06-08 14:40:51 +00:00
|
|
|
|
2018-06-12 11:38:29 +00:00
|
|
|
virSEVCapabilitiesFree(qemuCaps->sevCapabilities);
|
|
|
|
qemuCaps->sevCapabilities = caps;
|
2019-04-02 10:31:31 +00:00
|
|
|
return 0;
|
2018-06-08 14:40:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-06 12:39:52 +00:00
|
|
|
/*
|
|
|
|
* Filter for features which should never be passed to QEMU. Either because
|
|
|
|
* QEMU never supported them or they were dropped as they never did anything
|
|
|
|
* useful.
|
|
|
|
*/
|
2017-09-13 15:28:13 +00:00
|
|
|
bool
|
2016-07-21 15:02:37 +00:00
|
|
|
virQEMUCapsCPUFilterFeatures(const char *name,
|
2019-11-07 15:25:47 +00:00
|
|
|
virCPUFeaturePolicy policy G_GNUC_UNUSED,
|
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") ||
|
2019-06-06 12:39:52 +00:00
|
|
|
STREQ(name, "mbm_local") ||
|
|
|
|
STREQ(name, "osxsave") ||
|
|
|
|
STREQ(name, "ospke"))
|
2016-07-21 15:02:37 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-06 07:27:18 +00:00
|
|
|
typedef struct _virQEMUCapsCPUFeatureTranslationTable virQEMUCapsCPUFeatureTranslationTable;
|
|
|
|
typedef virQEMUCapsCPUFeatureTranslationTable *virQEMUCapsCPUFeatureTranslationTablePtr;
|
|
|
|
struct _virQEMUCapsCPUFeatureTranslationTable {
|
|
|
|
const char *libvirt;
|
|
|
|
const char *qemu;
|
|
|
|
};
|
|
|
|
|
|
|
|
virQEMUCapsCPUFeatureTranslationTable virQEMUCapsCPUFeaturesX86[] = {
|
|
|
|
{"cmp_legacy", "cmp-legacy"},
|
|
|
|
{"ds_cpl", "ds-cpl"},
|
|
|
|
{"fxsr_opt", "fxsr-opt"},
|
|
|
|
{"kvm_pv_eoi", "kvm-pv-eoi"},
|
|
|
|
{"kvm_pv_unhalt", "kvm-pv-unhalt"},
|
|
|
|
{"lahf_lm", "lahf-lm"},
|
|
|
|
{"nodeid_msr", "nodeid-msr"},
|
|
|
|
{"pclmuldq", "pclmulqdq"},
|
|
|
|
{"perfctr_core", "perfctr-core"},
|
|
|
|
{"perfctr_nb", "perfctr-nb"},
|
|
|
|
{"tsc_adjust", "tsc-adjust"},
|
|
|
|
{NULL, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
virQEMUCapsCPUFeatureTranslate(virQEMUCapsPtr qemuCaps,
|
|
|
|
const char *feature,
|
|
|
|
bool reversed)
|
|
|
|
{
|
|
|
|
virQEMUCapsCPUFeatureTranslationTablePtr table = NULL;
|
|
|
|
virQEMUCapsCPUFeatureTranslationTablePtr entry;
|
|
|
|
|
|
|
|
if (ARCH_IS_X86(qemuCaps->arch))
|
|
|
|
table = virQEMUCapsCPUFeaturesX86;
|
|
|
|
|
2019-06-07 13:00:28 +00:00
|
|
|
if (!table ||
|
|
|
|
!feature ||
|
|
|
|
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CANONICAL_CPU_FEATURES))
|
2019-06-06 07:27:18 +00:00
|
|
|
return feature;
|
|
|
|
|
|
|
|
for (entry = table; entry->libvirt; entry++) {
|
|
|
|
const char *key = reversed ? entry->qemu : entry->libvirt;
|
|
|
|
|
|
|
|
if (STREQ(feature, key))
|
|
|
|
return reversed ? entry->libvirt : entry->qemu;
|
|
|
|
}
|
|
|
|
|
|
|
|
return feature;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const char *
|
|
|
|
virQEMUCapsCPUFeatureToQEMU(virQEMUCapsPtr qemuCaps,
|
|
|
|
const char *feature)
|
|
|
|
{
|
|
|
|
return virQEMUCapsCPUFeatureTranslate(qemuCaps, feature, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const char *
|
|
|
|
virQEMUCapsCPUFeatureFromQEMU(virQEMUCapsPtr qemuCaps,
|
|
|
|
const char *feature)
|
|
|
|
{
|
|
|
|
return virQEMUCapsCPUFeatureTranslate(qemuCaps, feature, 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
|
|
|
|
2019-10-20 11:49:46 +00:00
|
|
|
cpu->model = g_strdup(modelInfo->name);
|
2020-10-05 10:25:44 +00:00
|
|
|
cpu->features = g_new0(virCPUFeatureDef, modelInfo->nprops);
|
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;
|
2019-06-17 11:54:53 +00:00
|
|
|
const char *name = virQEMUCapsCPUFeatureFromQEMU(qemuCaps, prop->name);
|
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
|
|
|
|
2019-10-20 11:49:46 +00:00
|
|
|
feature->name = g_strdup(name);
|
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
|
|
|
|
2019-02-25 08:39:17 +00:00
|
|
|
virCPUDataPtr
|
2019-06-17 11:54:53 +00:00
|
|
|
virQEMUCapsGetCPUModelX86Data(virQEMUCapsPtr qemuCaps,
|
|
|
|
qemuMonitorCPUModelInfoPtr model,
|
2019-02-25 08:39:17 +00:00
|
|
|
bool migratable)
|
2017-01-11 13:36:34 +00:00
|
|
|
{
|
|
|
|
unsigned long long sigFamily = 0;
|
|
|
|
unsigned long long sigModel = 0;
|
2017-10-10 11:34:28 +00:00
|
|
|
unsigned long long sigStepping = 0;
|
2019-02-25 08:39:17 +00:00
|
|
|
virCPUDataPtr data = NULL;
|
|
|
|
virCPUDataPtr ret = NULL;
|
2017-01-11 13:36:34 +00:00
|
|
|
size_t i;
|
|
|
|
|
|
|
|
if (!(data = virCPUDataNew(VIR_ARCH_X86_64)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
for (i = 0; i < model->nprops; i++) {
|
|
|
|
qemuMonitorCPUPropertyPtr prop = model->props + i;
|
2019-06-17 11:54:53 +00:00
|
|
|
const char *name = virQEMUCapsCPUFeatureFromQEMU(qemuCaps, prop->name);
|
2017-01-11 13:36:34 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2019-06-18 08:09:31 +00:00
|
|
|
if (virCPUDataAddFeature(data, 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:
|
2019-06-17 11:54:53 +00:00
|
|
|
if (STREQ(name, "vendor") &&
|
2017-01-11 13:36:34 +00:00
|
|
|
virCPUx86DataSetVendor(data, prop->value.string) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case QEMU_MONITOR_CPU_PROPERTY_NUMBER:
|
2019-06-17 11:54:53 +00:00
|
|
|
if (STREQ(name, "family"))
|
2017-01-11 13:36:34 +00:00
|
|
|
sigFamily = prop->value.number;
|
2019-06-17 11:54:53 +00:00
|
|
|
else if (STREQ(name, "model"))
|
2017-01-11 13:36:34 +00:00
|
|
|
sigModel = prop->value.number;
|
2019-06-17 11:54:53 +00:00
|
|
|
else if (STREQ(name, "stepping"))
|
2017-10-10 11:34:28 +00:00
|
|
|
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;
|
|
|
|
|
2019-10-16 11:43:18 +00:00
|
|
|
ret = g_steal_pointer(&data);
|
2019-02-25 08:39:17 +00:00
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virCPUDataFree(data);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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,
|
|
|
|
qemuMonitorCPUModelInfoPtr model,
|
|
|
|
virCPUDefPtr cpu,
|
|
|
|
bool migratable)
|
|
|
|
{
|
2019-09-20 20:41:34 +00:00
|
|
|
g_autoptr(virDomainCapsCPUModels) cpuModels = NULL;
|
2019-02-25 08:39:17 +00:00
|
|
|
virCPUDataPtr data = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
if (!model)
|
|
|
|
return 1;
|
|
|
|
|
2019-06-17 11:54:53 +00:00
|
|
|
if (!(data = virQEMUCapsGetCPUModelX86Data(qemuCaps, model, migratable)))
|
2019-02-25 08:39:17 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2019-10-09 08:14:59 +00:00
|
|
|
cpuModels = virQEMUCapsGetCPUModels(qemuCaps, type, NULL, NULL);
|
2019-09-20 20:41:34 +00:00
|
|
|
|
|
|
|
if (cpuDecode(cpu, data, cpuModels) < 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
|
|
|
{
|
2019-02-25 09:00:53 +00:00
|
|
|
qemuMonitorCPUModelInfoPtr modelInfo = virQEMUCapsGetCPUModelInfo(qemuCaps, type);
|
2017-01-10 18:16:24 +00:00
|
|
|
int ret = 1;
|
|
|
|
|
2019-02-25 09:00:53 +00:00
|
|
|
if (migratable && modelInfo && !modelInfo->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)) {
|
2019-02-25 09:00:53 +00:00
|
|
|
ret = virQEMUCapsInitCPUModelS390(qemuCaps, type, modelInfo,
|
2017-04-07 16:15:26 +00:00
|
|
|
cpu, migratable);
|
|
|
|
} else if (ARCH_IS_X86(qemuCaps->arch)) {
|
2019-02-25 09:00:53 +00:00
|
|
|
ret = virQEMUCapsInitCPUModelX86(qemuCaps, type, modelInfo,
|
2017-04-07 16:15:26 +00:00
|
|
|
cpu, migratable);
|
2020-05-05 16:35:26 +00:00
|
|
|
} else if (ARCH_IS_ARM(qemuCaps->arch)) {
|
|
|
|
ret = 2;
|
2017-04-07 16:15:26 +00:00
|
|
|
}
|
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)
|
|
|
|
{
|
2019-11-29 11:00:26 +00:00
|
|
|
virCPUDefPtr cpu = virCPUDefNew();
|
2017-03-29 13:31:17 +00:00
|
|
|
|
|
|
|
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) {
|
2019-09-20 20:41:34 +00:00
|
|
|
g_autoptr(virDomainCapsCPUModels) cpuModels = NULL;
|
|
|
|
|
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
|
|
|
|
2019-10-09 08:14:59 +00:00
|
|
|
cpuModels = virQEMUCapsGetCPUModels(qemuCaps, type, NULL, NULL);
|
2019-09-20 20:41:34 +00:00
|
|
|
hostCPU = virQEMUCapsProbeHostCPU(hostArch, cpuModels);
|
|
|
|
|
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)) {
|
2019-06-03 11:13:38 +00:00
|
|
|
if (!(fullCPU = virQEMUCapsProbeHostCPU(qemuCaps->arch, 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;
|
|
|
|
}
|
|
|
|
|
2019-06-19 20:22:09 +00:00
|
|
|
if (ARCH_IS_X86(qemuCaps->arch) &&
|
|
|
|
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CPU_UNAVAILABLE_FEATURES)) {
|
|
|
|
if (cpu &&
|
|
|
|
virCPUDefFilterFeatures(cpu, virCPUx86FeatureFilterDropMSR, NULL) < 0)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
if (migCPU &&
|
|
|
|
virCPUDefFilterFeatures(migCPU, virCPUx86FeatureFilterDropMSR, NULL) < 0)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
if (fullCPU &&
|
|
|
|
virCPUDefFilterFeatures(fullCPU, virCPUx86FeatureFilterDropMSR, NULL) < 0)
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-02-25 09:01:34 +00:00
|
|
|
qemuMonitorCPUModelInfoPtr
|
|
|
|
virQEMUCapsGetCPUModelInfo(virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainVirtType type)
|
|
|
|
{
|
2019-10-23 10:57:20 +00:00
|
|
|
return virQEMUCapsGetAccel(qemuCaps, type)->hostCPU.info;
|
2019-02-25 09:01:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-23 13:31:23 +00:00
|
|
|
void
|
|
|
|
virQEMUCapsSetCPUModelInfo(virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainVirtType type,
|
|
|
|
qemuMonitorCPUModelInfoPtr modelInfo)
|
|
|
|
{
|
2019-10-23 10:57:20 +00:00
|
|
|
virQEMUCapsGetAccel(qemuCaps, type)->hostCPU.info = modelInfo;
|
2017-02-23 13:31:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-06 07:52:22 +00:00
|
|
|
static int
|
2019-10-23 10:59:43 +00:00
|
|
|
virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccelPtr caps,
|
2017-02-22 15:51:50 +00:00
|
|
|
xmlXPathContextPtr ctxt,
|
2019-10-23 10:59:43 +00:00
|
|
|
const char *typeStr)
|
2017-01-06 07:52:22 +00:00
|
|
|
{
|
|
|
|
char *str = NULL;
|
|
|
|
xmlNodePtr hostCPUNode;
|
2017-01-30 15:30:13 +00:00
|
|
|
xmlNodePtr *nodes = NULL;
|
2020-07-28 19:47:48 +00:00
|
|
|
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
2017-01-06 07:52:22 +00:00
|
|
|
qemuMonitorCPUModelInfoPtr hostCPU = NULL;
|
2019-10-23 10:59:43 +00:00
|
|
|
g_autofree char *xpath = g_strdup_printf("./hostCPU[@type='%s']", typeStr);
|
2017-01-06 07:52:22 +00:00
|
|
|
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
|
|
|
|
2019-10-23 10:59:43 +00:00
|
|
|
if (!(hostCPUNode = virXPathNode(xpath, ctxt))) {
|
2017-01-06 07:52:22 +00:00
|
|
|
ret = 0;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2020-10-05 10:25:44 +00:00
|
|
|
hostCPU = g_new0(qemuMonitorCPUModelInfo, 1);
|
2017-01-06 07:52:22 +00:00
|
|
|
|
|
|
|
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) {
|
2020-10-05 10:25:44 +00:00
|
|
|
hostCPU->props = g_new0(qemuMonitorCPUProperty, n);
|
2017-01-06 07:52:22 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-23 10:59:43 +00:00
|
|
|
caps->hostCPU.info = g_steal_pointer(&hostCPU);
|
2017-01-06 07:52:22 +00:00
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
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
|
2019-10-23 10:59:43 +00:00
|
|
|
virQEMUCapsLoadCPUModels(virQEMUCapsAccelPtr caps,
|
2016-11-14 16:21:30 +00:00
|
|
|
xmlXPathContextPtr ctxt,
|
2019-10-23 10:59:43 +00:00
|
|
|
const char *typeStr)
|
2016-11-14 20:51:19 +00:00
|
|
|
{
|
2019-09-24 14:38:05 +00:00
|
|
|
g_autoptr(qemuMonitorCPUDefs) defs = NULL;
|
2019-09-24 12:55:26 +00:00
|
|
|
g_autofree xmlNodePtr * nodes = NULL;
|
2019-10-23 10:59:43 +00:00
|
|
|
g_autofree char *xpath = g_strdup_printf("./cpu[@type='%s']", typeStr);
|
2016-11-14 20:51:19 +00:00
|
|
|
size_t i;
|
|
|
|
int n;
|
2017-09-21 14:11:14 +00:00
|
|
|
xmlNodePtr node;
|
2016-11-14 20:51:19 +00:00
|
|
|
|
2019-10-23 10:59:43 +00:00
|
|
|
if ((n = virXPathNodeSet(xpath, ctxt, &nodes)) < 0) {
|
2016-11-14 20:51:19 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("failed to parse qemu capabilities cpus"));
|
2019-09-24 12:55:26 +00:00
|
|
|
return -1;
|
2016-11-14 20:51:19 +00:00
|
|
|
}
|
|
|
|
|
2019-09-24 12:55:26 +00:00
|
|
|
if (n == 0)
|
|
|
|
return 0;
|
2016-11-14 20:51:19 +00:00
|
|
|
|
2019-09-24 14:38:05 +00:00
|
|
|
if (!(defs = qemuMonitorCPUDefsNew(n)))
|
2019-09-24 12:55:26 +00:00
|
|
|
return -1;
|
2016-11-14 20:51:19 +00:00
|
|
|
|
|
|
|
for (i = 0; i < n; i++) {
|
2019-09-24 14:38:05 +00:00
|
|
|
qemuMonitorCPUDefInfoPtr cpu = defs->cpus + i;
|
2016-04-21 11:08:12 +00:00
|
|
|
int usable = VIR_DOMCAPS_CPU_USABLE_UNKNOWN;
|
2019-09-24 12:55:26 +00:00
|
|
|
g_autofree char * strUsable = NULL;
|
|
|
|
g_autofree xmlNodePtr * blockerNodes = NULL;
|
2021-01-22 11:15:08 +00:00
|
|
|
g_autofree char *deprecated = NULL;
|
2019-09-24 12:55:26 +00:00
|
|
|
int nblockers;
|
|
|
|
|
|
|
|
if ((strUsable = virXMLPropString(nodes[i], "usable")) &&
|
|
|
|
(usable = virDomainCapsCPUUsableTypeFromString(strUsable)) < 0) {
|
2016-04-21 11:08:12 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
2019-09-24 12:55:26 +00:00
|
|
|
_("unknown value '%s' in attribute 'usable'"),
|
|
|
|
strUsable);
|
|
|
|
return -1;
|
2016-04-21 11:08:12 +00:00
|
|
|
}
|
2019-09-24 14:38:05 +00:00
|
|
|
cpu->usable = usable;
|
2016-04-21 11:08:12 +00:00
|
|
|
|
2019-09-24 14:38:05 +00:00
|
|
|
if (!(cpu->name = virXMLPropString(nodes[i], "name"))) {
|
2016-11-14 20:51:19 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("missing cpu name in QEMU capabilities cache"));
|
2019-09-24 12:55:26 +00:00
|
|
|
return -1;
|
2016-11-14 20:51:19 +00:00
|
|
|
}
|
|
|
|
|
2019-09-19 18:47:37 +00:00
|
|
|
cpu->type = virXMLPropString(nodes[i], "typename");
|
|
|
|
|
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"));
|
2019-09-24 12:55:26 +00:00
|
|
|
return -1;
|
2017-09-21 14:11:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (nblockers > 0) {
|
|
|
|
size_t j;
|
|
|
|
|
2020-10-05 10:25:44 +00:00
|
|
|
cpu->blockers = g_new0(char *, nblockers + 1);
|
2017-09-21 14:11:14 +00:00
|
|
|
|
|
|
|
for (j = 0; j < nblockers; j++) {
|
2019-09-24 14:38:05 +00:00
|
|
|
if (!(cpu->blockers[j] = virXMLPropString(blockerNodes[j], "name"))) {
|
2017-09-21 14:11:14 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("missing blocker name in QEMU "
|
|
|
|
"capabilities cache"));
|
2019-09-24 12:55:26 +00:00
|
|
|
return -1;
|
2017-09-21 14:11:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-01-22 11:15:08 +00:00
|
|
|
|
|
|
|
deprecated = virXMLPropString(nodes[i], "deprecated");
|
|
|
|
if (deprecated &&
|
|
|
|
STREQ(deprecated, "yes"))
|
|
|
|
cpu->deprecated = true;
|
2016-11-14 20:51:19 +00:00
|
|
|
}
|
|
|
|
|
2019-10-23 10:59:43 +00:00
|
|
|
caps->cpuModels = g_steal_pointer(&defs);
|
2019-09-24 12:55:26 +00:00
|
|
|
return 0;
|
2016-11-14 20:51:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-10-23 16:05:45 +00:00
|
|
|
static int
|
2019-10-24 12:19:38 +00:00
|
|
|
virQEMUCapsLoadMachines(virQEMUCapsAccelPtr caps,
|
|
|
|
xmlXPathContextPtr ctxt,
|
|
|
|
const char *typeStr)
|
2019-10-23 16:05:45 +00:00
|
|
|
{
|
2019-10-24 12:19:38 +00:00
|
|
|
g_autofree char *xpath = g_strdup_printf("./machine[@type='%s']", typeStr);
|
2019-10-23 16:05:45 +00:00
|
|
|
g_autofree xmlNodePtr *nodes = NULL;
|
|
|
|
size_t i;
|
|
|
|
int n;
|
|
|
|
|
2019-10-24 12:19:38 +00:00
|
|
|
if ((n = virXPathNodeSet(xpath, ctxt, &nodes)) < 0) {
|
2019-10-23 16:05:45 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("failed to parse qemu capabilities machines"));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (n == 0)
|
|
|
|
return 0;
|
|
|
|
|
2019-10-24 12:19:38 +00:00
|
|
|
caps->nmachineTypes = n;
|
2020-10-05 10:25:44 +00:00
|
|
|
caps->machineTypes = g_new0(virQEMUCapsMachineType, caps->nmachineTypes);
|
2019-10-23 16:05:45 +00:00
|
|
|
|
|
|
|
for (i = 0; i < n; i++) {
|
2021-02-09 15:29:39 +00:00
|
|
|
g_autofree char *str = NULL;
|
|
|
|
|
2019-10-24 12:19:38 +00:00
|
|
|
if (!(caps->machineTypes[i].name = virXMLPropString(nodes[i], "name"))) {
|
2019-10-23 16:05:45 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("missing machine name in QEMU capabilities cache"));
|
|
|
|
return -1;
|
|
|
|
}
|
2019-10-24 12:19:38 +00:00
|
|
|
caps->machineTypes[i].alias = virXMLPropString(nodes[i], "alias");
|
2019-10-23 16:05:45 +00:00
|
|
|
|
|
|
|
str = virXMLPropString(nodes[i], "maxCpus");
|
|
|
|
if (str &&
|
2019-10-24 12:19:38 +00:00
|
|
|
virStrToLong_ui(str, NULL, 10, &(caps->machineTypes[i].maxCpus)) < 0) {
|
2019-10-23 16:05:45 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("malformed machine cpu count in QEMU capabilities cache"));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
VIR_FREE(str);
|
|
|
|
|
|
|
|
str = virXMLPropString(nodes[i], "hotplugCpus");
|
|
|
|
if (STREQ_NULLABLE(str, "yes"))
|
2019-10-24 12:19:38 +00:00
|
|
|
caps->machineTypes[i].hotplugCpus = true;
|
2019-10-23 16:05:45 +00:00
|
|
|
VIR_FREE(str);
|
|
|
|
|
|
|
|
str = virXMLPropString(nodes[i], "default");
|
|
|
|
if (STREQ_NULLABLE(str, "yes"))
|
2019-10-24 12:19:38 +00:00
|
|
|
caps->machineTypes[i].qemuDefault = true;
|
2019-10-23 16:05:45 +00:00
|
|
|
VIR_FREE(str);
|
2019-07-18 17:21:55 +00:00
|
|
|
|
2020-05-14 11:11:01 +00:00
|
|
|
str = virXMLPropString(nodes[i], "numaMemSupported");
|
|
|
|
if (STREQ_NULLABLE(str, "yes"))
|
|
|
|
caps->machineTypes[i].numaMemSupported = true;
|
|
|
|
VIR_FREE(str);
|
|
|
|
|
2019-07-18 17:21:55 +00:00
|
|
|
caps->machineTypes[i].defaultCPU = virXMLPropString(nodes[i], "defaultCPU");
|
2020-05-25 17:13:43 +00:00
|
|
|
caps->machineTypes[i].defaultRAMid = virXMLPropString(nodes[i], "defaultRAMid");
|
2021-02-09 15:36:17 +00:00
|
|
|
|
|
|
|
str = virXMLPropString(nodes[i], "deprecated");
|
|
|
|
if (STREQ_NULLABLE(str, "yes"))
|
|
|
|
caps->machineTypes[i].deprecated = true;
|
|
|
|
VIR_FREE(str);
|
2019-10-23 16:05:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-10-23 08:24:46 +00:00
|
|
|
static int
|
|
|
|
virQEMUCapsLoadAccel(virQEMUCapsPtr qemuCaps,
|
|
|
|
xmlXPathContextPtr ctxt,
|
|
|
|
virDomainVirtType type)
|
|
|
|
{
|
2019-10-23 10:59:43 +00:00
|
|
|
virQEMUCapsAccelPtr caps = virQEMUCapsGetAccel(qemuCaps, type);
|
|
|
|
const char *typeStr = type == VIR_DOMAIN_VIRT_KVM ? "kvm" : "tcg";
|
|
|
|
|
|
|
|
if (virQEMUCapsLoadHostCPUModelInfo(caps, ctxt, typeStr) < 0)
|
2019-10-23 08:24:46 +00:00
|
|
|
return -1;
|
|
|
|
|
2019-10-23 10:59:43 +00:00
|
|
|
if (virQEMUCapsLoadCPUModels(caps, ctxt, typeStr) < 0)
|
2019-10-23 08:24:46 +00:00
|
|
|
return -1;
|
|
|
|
|
2019-10-24 12:19:38 +00:00
|
|
|
if (virQEMUCapsLoadMachines(caps, ctxt, typeStr) < 0)
|
|
|
|
return -1;
|
|
|
|
|
2019-10-23 08:24:46 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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;
|
2020-05-15 20:00:29 +00:00
|
|
|
char *hostCPUSignature;
|
2018-10-29 17:34:58 +00:00
|
|
|
|
|
|
|
/* cache whether /dev/kvm is usable as runUid:runGuid */
|
|
|
|
virTristateBool kvmUsable;
|
|
|
|
time_t kvmCtime;
|
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;
|
|
|
|
|
2021-02-03 19:36:01 +00:00
|
|
|
g_free(priv->libDir);
|
|
|
|
g_free(priv->kernelVersion);
|
|
|
|
g_free(priv->hostCPUSignature);
|
|
|
|
g_free(priv);
|
2017-06-20 14:17:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-08-09 13:27:26 +00:00
|
|
|
static int
|
|
|
|
virQEMUCapsParseSEVInfo(virQEMUCapsPtr qemuCaps, xmlXPathContextPtr ctxt)
|
|
|
|
{
|
2019-10-15 12:47:50 +00:00
|
|
|
g_autoptr(virSEVCapability) sev = NULL;
|
2018-08-09 13:27:26 +00:00
|
|
|
|
|
|
|
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SEV_GUEST))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (virXPathBoolean("boolean(./sev)", ctxt) == 0) {
|
|
|
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
|
|
_("missing SEV platform data in QEMU "
|
|
|
|
"capabilities cache"));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2020-10-05 10:25:44 +00:00
|
|
|
sev = g_new0(virSEVCapability, 1);
|
2018-08-09 13:27:26 +00:00
|
|
|
|
|
|
|
if (virXPathUInt("string(./sev/cbitpos)", ctxt, &sev->cbitpos) < 0) {
|
|
|
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
|
|
_("missing or malformed SEV cbitpos information "
|
|
|
|
"in QEMU capabilities cache"));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (virXPathUInt("string(./sev/reducedPhysBits)", ctxt,
|
|
|
|
&sev->reduced_phys_bits) < 0) {
|
|
|
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
|
|
_("missing or malformed SEV reducedPhysBits information "
|
|
|
|
"in QEMU capabilities cache"));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(sev->pdh = virXPathString("string(./sev/pdh)", ctxt))) {
|
|
|
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
|
|
_("missing SEV pdh information "
|
|
|
|
"in QEMU capabilities cache"));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(sev->cert_chain = virXPathString("string(./sev/certChain)", ctxt))) {
|
|
|
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
|
|
_("missing SEV certChain information "
|
|
|
|
"in QEMU capabilities cache"));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2019-10-16 11:43:18 +00:00
|
|
|
qemuCaps->sevCapabilities = g_steal_pointer(&sev);
|
2018-08-09 13:27:26 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-05 16:51:59 +00:00
|
|
|
/*
|
|
|
|
* Parsing a doc that looks like
|
|
|
|
*
|
|
|
|
* <qemuCaps>
|
2019-12-10 10:23:14 +00:00
|
|
|
* <emulator>/some/path</emulator>
|
2014-03-05 16:51:59 +00:00
|
|
|
* <qemuctime>234235253</qemuctime>
|
2020-08-20 21:52:17 +00:00
|
|
|
* <qemumoddirmtime>234235253</qemumoddirmtime>
|
2014-03-05 16:51:59 +00:00
|
|
|
* <selfctime>234235253</selfctime>
|
2015-05-23 14:19:20 +00:00
|
|
|
* <selfvers>1002016</selfvers>
|
2014-03-05 16:51:59 +00:00
|
|
|
* <flag name='foo'/>
|
|
|
|
* <flag name='bar'/>
|
|
|
|
* ...
|
|
|
|
* <cpu name="pentium3"/>
|
|
|
|
* ...
|
2020-05-14 11:11:01 +00:00
|
|
|
* <machine name='pc-1.0' alias='pc' hotplugCpus='yes' maxCpus='4' default='yes' numaMemSupported='yes'/>
|
2014-03-05 16:51:59 +00:00
|
|
|
* ...
|
|
|
|
* </qemuCaps>
|
2020-06-18 13:44:16 +00:00
|
|
|
*
|
|
|
|
* Returns 0 on success, 1 if outdated, -1 on error
|
2014-03-05 16:51:59 +00:00
|
|
|
*/
|
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,
|
2020-06-18 13:44:16 +00:00
|
|
|
const char *filename,
|
|
|
|
bool skipInvalidation)
|
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;
|
|
|
|
|
2019-09-09 06:33:58 +00:00
|
|
|
if (!(ctxt = virXMLXPathContextNew(doc)))
|
2014-03-05 16:51:59 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2020-06-18 13:44:16 +00:00
|
|
|
if (virXPathLongLong("string(./selfctime)", ctxt, &l) < 0) {
|
|
|
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
|
|
_("missing selfctime in QEMU capabilities XML"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
qemuCaps->libvirtCtime = (time_t)l;
|
|
|
|
|
|
|
|
qemuCaps->libvirtVersion = 0;
|
|
|
|
if (virXPathULong("string(./selfvers)", ctxt, &lu) == 0)
|
|
|
|
qemuCaps->libvirtVersion = lu;
|
|
|
|
|
|
|
|
if (!skipInvalidation &&
|
|
|
|
(qemuCaps->libvirtCtime != virGetSelfLastChanged() ||
|
|
|
|
qemuCaps->libvirtVersion != LIBVIR_VERSION_NUMBER)) {
|
|
|
|
VIR_DEBUG("Outdated capabilities in %s: libvirt changed "
|
|
|
|
"(%lld vs %lld, %lu vs %lu), stopping load",
|
|
|
|
qemuCaps->binary,
|
|
|
|
(long long)qemuCaps->libvirtCtime,
|
|
|
|
(long long)virGetSelfLastChanged(),
|
|
|
|
(unsigned long)qemuCaps->libvirtVersion,
|
|
|
|
(unsigned long)LIBVIR_VERSION_NUMBER);
|
|
|
|
ret = 1;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2019-12-10 10:23:14 +00:00
|
|
|
if (!(str = virXPathString("string(./emulator)", ctxt))) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("missing emulator in QEMU capabilities cache"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
if (STRNEQ(str, qemuCaps->binary)) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Expected caps for '%s' but saw '%s'"),
|
|
|
|
qemuCaps->binary, str);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
VIR_FREE(str);
|
2014-03-05 16:51:59 +00:00
|
|
|
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
|
|
|
|
2020-08-20 21:52:17 +00:00
|
|
|
if (virXPathLongLong("string(./qemumoddirmtime)", ctxt, &l) == 0)
|
|
|
|
qemuCaps->modDirMtime = (time_t)l;
|
|
|
|
|
2014-03-05 16:51:59 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2020-05-15 20:00:29 +00:00
|
|
|
qemuCaps->hostCPUSignature = virXPathString("string(./hostCPUSignature)", ctxt);
|
|
|
|
|
2016-08-04 20:43:22 +00:00
|
|
|
if (virXPathBoolean("boolean(./package)", ctxt) > 0) {
|
|
|
|
qemuCaps->package = virXPathString("string(./package)", ctxt);
|
2019-10-18 13:08:21 +00:00
|
|
|
if (!qemuCaps->package)
|
|
|
|
qemuCaps->package = g_strdup("");
|
2016-08-04 20:43:22 +00:00
|
|
|
}
|
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
|
|
|
|
2019-10-23 08:24:46 +00:00
|
|
|
if (virQEMUCapsLoadAccel(qemuCaps, ctxt, VIR_DOMAIN_VIRT_KVM) < 0 ||
|
|
|
|
virQEMUCapsLoadAccel(qemuCaps, ctxt, VIR_DOMAIN_VIRT_QEMU) < 0)
|
2014-03-05 16:51:59 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
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;
|
2020-10-05 10:25:44 +00:00
|
|
|
qemuCaps->gicCapabilities = g_new0(virGICCapability, n);
|
2016-03-10 16:59:51 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2018-08-09 13:27:26 +00:00
|
|
|
if (virQEMUCapsParseSEVInfo(qemuCaps, ctxt) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
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
|
|
|
|
2018-11-12 19:58:09 +00:00
|
|
|
if (virXPathBoolean("boolean(./kvmSupportsNesting)", ctxt) > 0)
|
|
|
|
qemuCaps->kvmSupportsNesting = true;
|
|
|
|
|
2020-06-15 08:28:07 +00:00
|
|
|
if (virXPathBoolean("boolean(./kvmSupportsSecureGuest)", ctxt) > 0)
|
|
|
|
qemuCaps->kvmSupportsSecureGuest = true;
|
|
|
|
|
2020-06-18 13:44:16 +00:00
|
|
|
if (skipInvalidation)
|
|
|
|
qemuCaps->invalidation = false;
|
|
|
|
|
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
|
2019-10-23 11:00:31 +00:00
|
|
|
virQEMUCapsFormatHostCPUModelInfo(virQEMUCapsAccelPtr caps,
|
2017-02-22 15:51:50 +00:00
|
|
|
virBufferPtr buf,
|
2019-10-23 11:00:31 +00:00
|
|
|
const char *typeStr)
|
2017-01-13 17:42:57 +00:00
|
|
|
{
|
2019-10-23 11:00:31 +00:00
|
|
|
qemuMonitorCPUModelInfoPtr model = caps->hostCPU.info;
|
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
|
2019-10-23 11:00:31 +00:00
|
|
|
virQEMUCapsFormatCPUModels(virQEMUCapsAccelPtr caps,
|
2016-11-14 16:21:30 +00:00
|
|
|
virBufferPtr buf,
|
2019-10-23 11:00:31 +00:00
|
|
|
const char *typeStr)
|
2016-11-14 20:51:31 +00:00
|
|
|
{
|
2019-10-23 11:00:31 +00:00
|
|
|
qemuMonitorCPUDefsPtr defs = caps->cpuModels;
|
2016-11-14 20:51:31 +00:00
|
|
|
size_t i;
|
|
|
|
|
2019-09-24 14:38:05 +00:00
|
|
|
if (!defs)
|
2016-11-14 16:21:30 +00:00
|
|
|
return;
|
|
|
|
|
2019-09-24 14:38:05 +00:00
|
|
|
for (i = 0; i < defs->ncpus; i++) {
|
|
|
|
qemuMonitorCPUDefInfoPtr cpu = defs->cpus + i;
|
2016-04-21 11:08:12 +00:00
|
|
|
|
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);
|
2019-09-19 18:47:37 +00:00
|
|
|
virBufferEscapeString(buf, " typename='%s'", cpu->type);
|
2016-04-21 11:08:12 +00:00
|
|
|
if (cpu->usable) {
|
|
|
|
virBufferAsprintf(buf, " usable='%s'",
|
|
|
|
virDomainCapsCPUUsableTypeToString(cpu->usable));
|
|
|
|
}
|
2021-01-22 11:15:08 +00:00
|
|
|
if (cpu->deprecated)
|
|
|
|
virBufferAddLit(buf, " deprecated='yes'");
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-10-23 16:29:39 +00:00
|
|
|
static void
|
2019-10-24 12:19:38 +00:00
|
|
|
virQEMUCapsFormatMachines(virQEMUCapsAccelPtr caps,
|
|
|
|
virBufferPtr buf,
|
|
|
|
const char *typeStr)
|
2019-10-23 16:29:39 +00:00
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
2019-10-24 12:19:38 +00:00
|
|
|
for (i = 0; i < caps->nmachineTypes; i++) {
|
|
|
|
virBufferAsprintf(buf, "<machine type='%s'", typeStr);
|
|
|
|
virBufferEscapeString(buf, " name='%s'",
|
|
|
|
caps->machineTypes[i].name);
|
2019-10-23 16:29:39 +00:00
|
|
|
virBufferEscapeString(buf, " alias='%s'",
|
2019-10-24 12:19:38 +00:00
|
|
|
caps->machineTypes[i].alias);
|
|
|
|
if (caps->machineTypes[i].hotplugCpus)
|
2019-10-23 16:29:39 +00:00
|
|
|
virBufferAddLit(buf, " hotplugCpus='yes'");
|
|
|
|
virBufferAsprintf(buf, " maxCpus='%u'",
|
2019-10-24 12:19:38 +00:00
|
|
|
caps->machineTypes[i].maxCpus);
|
|
|
|
if (caps->machineTypes[i].qemuDefault)
|
2019-10-23 16:29:39 +00:00
|
|
|
virBufferAddLit(buf, " default='yes'");
|
2019-07-18 17:21:55 +00:00
|
|
|
virBufferEscapeString(buf, " defaultCPU='%s'",
|
|
|
|
caps->machineTypes[i].defaultCPU);
|
2020-05-14 11:11:01 +00:00
|
|
|
if (caps->machineTypes[i].numaMemSupported)
|
|
|
|
virBufferAddLit(buf, " numaMemSupported='yes'");
|
2020-05-25 17:13:43 +00:00
|
|
|
virBufferEscapeString(buf, " defaultRAMid='%s'",
|
|
|
|
caps->machineTypes[i].defaultRAMid);
|
2021-01-22 12:16:23 +00:00
|
|
|
if (caps->machineTypes[i].deprecated)
|
|
|
|
virBufferAddLit(buf, " deprecated='yes'");
|
2019-10-23 16:29:39 +00:00
|
|
|
virBufferAddLit(buf, "/>\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-10-23 08:24:46 +00:00
|
|
|
static void
|
|
|
|
virQEMUCapsFormatAccel(virQEMUCapsPtr qemuCaps,
|
|
|
|
virBufferPtr buf,
|
|
|
|
virDomainVirtType type)
|
|
|
|
{
|
2019-10-23 11:00:31 +00:00
|
|
|
virQEMUCapsAccelPtr caps = virQEMUCapsGetAccel(qemuCaps, type);
|
|
|
|
const char *typeStr = type == VIR_DOMAIN_VIRT_KVM ? "kvm" : "tcg";
|
|
|
|
|
|
|
|
virQEMUCapsFormatHostCPUModelInfo(caps, buf, typeStr);
|
|
|
|
virQEMUCapsFormatCPUModels(caps, buf, typeStr);
|
2019-10-24 12:19:38 +00:00
|
|
|
virQEMUCapsFormatMachines(caps, buf, typeStr);
|
|
|
|
|
2019-10-23 08:24:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-08-09 13:27:26 +00:00
|
|
|
static void
|
|
|
|
virQEMUCapsFormatSEVInfo(virQEMUCapsPtr qemuCaps, virBufferPtr buf)
|
|
|
|
{
|
|
|
|
virSEVCapabilityPtr sev = virQEMUCapsGetSEVCapabilities(qemuCaps);
|
|
|
|
|
|
|
|
virBufferAddLit(buf, "<sev>\n");
|
|
|
|
virBufferAdjustIndent(buf, 2);
|
|
|
|
virBufferAsprintf(buf, "<cbitpos>%u</cbitpos>\n", sev->cbitpos);
|
|
|
|
virBufferAsprintf(buf, "<reducedPhysBits>%u</reducedPhysBits>\n",
|
|
|
|
sev->reduced_phys_bits);
|
|
|
|
virBufferEscapeString(buf, "<pdh>%s</pdh>\n", sev->pdh);
|
|
|
|
virBufferEscapeString(buf, "<certChain>%s</certChain>\n",
|
|
|
|
sev->cert_chain);
|
|
|
|
virBufferAdjustIndent(buf, -2);
|
|
|
|
virBufferAddLit(buf, "</sev>\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2020-07-02 22:26:41 +00:00
|
|
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
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
|
|
|
|
2019-12-10 10:23:14 +00:00
|
|
|
virBufferEscapeString(&buf, "<emulator>%s</emulator>\n",
|
|
|
|
qemuCaps->binary);
|
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);
|
2020-08-20 21:52:17 +00:00
|
|
|
if (qemuCaps->modDirMtime > 0) {
|
|
|
|
virBufferAsprintf(&buf, "<qemumoddirmtime>%llu</qemumoddirmtime>\n",
|
|
|
|
(long long)qemuCaps->modDirMtime);
|
|
|
|
}
|
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
|
|
|
|
|
|
|
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);
|
2020-05-15 20:00:29 +00:00
|
|
|
virBufferEscapeString(&buf, "<hostCPUSignature>%s</hostCPUSignature>\n",
|
|
|
|
qemuCaps->hostCPUSignature);
|
2017-12-12 15:23:41 +00:00
|
|
|
|
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));
|
|
|
|
|
2019-10-23 08:24:46 +00:00
|
|
|
virQEMUCapsFormatAccel(qemuCaps, &buf, VIR_DOMAIN_VIRT_KVM);
|
2019-10-24 07:04:58 +00:00
|
|
|
virQEMUCapsFormatAccel(qemuCaps, &buf, VIR_DOMAIN_VIRT_QEMU);
|
|
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
2018-08-09 13:27:26 +00:00
|
|
|
if (qemuCaps->sevCapabilities)
|
|
|
|
virQEMUCapsFormatSEVInfo(qemuCaps, &buf);
|
|
|
|
|
2018-11-12 19:58:09 +00:00
|
|
|
if (qemuCaps->kvmSupportsNesting)
|
|
|
|
virBufferAddLit(&buf, "<kvmSupportsNesting/>\n");
|
|
|
|
|
2020-06-15 08:28:07 +00:00
|
|
|
if (qemuCaps->kvmSupportsSecureGuest)
|
|
|
|
virBufferAddLit(&buf, "<kvmSupportsSecureGuest/>\n");
|
|
|
|
|
2014-03-13 00:35:01 +00:00
|
|
|
virBufferAdjustIndent(&buf, -2);
|
2014-03-05 16:51:59 +00:00
|
|
|
virBufferAddLit(&buf, "</qemuCaps>\n");
|
|
|
|
|
2020-05-04 15:03:42 +00:00
|
|
|
return virBufferContentAndReset(&buf);
|
2016-04-28 12:59:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2017-07-19 15:01:56 +00:00
|
|
|
virQEMUCapsSaveFile(void *data,
|
|
|
|
const char *filename,
|
2019-10-14 12:45:33 +00:00
|
|
|
void *privData G_GNUC_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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-06-15 08:28:07 +00:00
|
|
|
/*
|
|
|
|
* Check whether IBM Secure Execution (S390) is enabled
|
|
|
|
*/
|
|
|
|
static bool
|
|
|
|
virQEMUCapsKVMSupportsSecureGuestS390(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
g_autofree char *cmdline = NULL;
|
|
|
|
static const char *kValues[] = {"y", "Y", "on", "ON", "oN", "On", "1"};
|
|
|
|
|
|
|
|
if (!virFileIsDir("/sys/firmware/uv"))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (virFileReadValueString(&cmdline, "/proc/cmdline") < 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* we're prefix matching rather than equality matching here, because kernel
|
|
|
|
* would treat even something like prot_virt='yFOO' as enabled */
|
|
|
|
if (virKernelCmdlineMatchParam(cmdline, "prot_virt", kValues,
|
|
|
|
G_N_ELEMENTS(kValues),
|
|
|
|
VIR_KERNEL_CMDLINE_FLAGS_SEARCH_FIRST |
|
|
|
|
VIR_KERNEL_CMDLINE_FLAGS_CMP_PREFIX))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-06-15 08:28:08 +00:00
|
|
|
/*
|
|
|
|
* Check whether AMD Secure Encrypted Virtualization (x86) is enabled
|
|
|
|
*/
|
|
|
|
static bool
|
|
|
|
virQEMUCapsKVMSupportsSecureGuestAMD(void)
|
|
|
|
{
|
|
|
|
g_autofree char *modValue = NULL;
|
|
|
|
|
|
|
|
if (virFileReadValueString(&modValue, "/sys/module/kvm_amd/parameters/sev") < 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (modValue[0] != '1')
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (virFileExists(QEMU_DEV_SEV))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-06-15 08:28:07 +00:00
|
|
|
/*
|
|
|
|
* Check whether the secure guest functionality is enabled.
|
|
|
|
* See the specific architecture function for details on the verifications made.
|
|
|
|
*/
|
|
|
|
static bool
|
|
|
|
virQEMUCapsKVMSupportsSecureGuest(void)
|
|
|
|
{
|
|
|
|
virArch arch = virArchFromHost();
|
|
|
|
|
|
|
|
if (ARCH_IS_S390(arch))
|
|
|
|
return virQEMUCapsKVMSupportsSecureGuestS390();
|
2020-06-15 08:28:08 +00:00
|
|
|
|
|
|
|
if (ARCH_IS_X86(arch))
|
|
|
|
return virQEMUCapsKVMSupportsSecureGuestAMD();
|
|
|
|
|
2020-06-15 08:28:07 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-11-12 19:58:09 +00:00
|
|
|
/* Check the kernel module parameters 'nested' file to determine if enabled
|
|
|
|
*
|
|
|
|
* Intel: 'kvm_intel' uses 'Y'
|
|
|
|
* AMD: 'kvm_amd' uses '1'
|
|
|
|
* PPC64: 'kvm_hv' uses 'Y'
|
|
|
|
* S390: 'kvm' uses '1'
|
|
|
|
*/
|
|
|
|
static bool
|
|
|
|
virQEMUCapsKVMSupportsNesting(void)
|
|
|
|
{
|
|
|
|
static char const * const kmod[] = {"kvm_intel", "kvm_amd",
|
|
|
|
"kvm_hv", "kvm"};
|
2019-10-15 13:16:31 +00:00
|
|
|
g_autofree char *value = NULL;
|
2018-11-12 19:58:09 +00:00
|
|
|
int rc;
|
|
|
|
size_t i;
|
|
|
|
|
2019-10-15 11:55:26 +00:00
|
|
|
for (i = 0; i < G_N_ELEMENTS(kmod); i++) {
|
2018-11-12 19:58:09 +00:00
|
|
|
VIR_FREE(value);
|
|
|
|
rc = virFileReadValueString(&value, "/sys/module/%s/parameters/nested",
|
|
|
|
kmod[i]);
|
|
|
|
if (rc == -2)
|
|
|
|
continue;
|
|
|
|
if (rc < 0) {
|
|
|
|
virResetLastError();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (value[0] == 'Y' || value[0] == 'y' || value[0] == '1')
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-10-29 17:34:58 +00:00
|
|
|
/* Determine whether '/dev/kvm' is usable as QEMU user:QEMU group. */
|
|
|
|
static bool
|
|
|
|
virQEMUCapsKVMUsable(virQEMUCapsCachePrivPtr priv)
|
|
|
|
{
|
|
|
|
struct stat sb;
|
|
|
|
static const char *kvm_device = "/dev/kvm";
|
|
|
|
virTristateBool value;
|
|
|
|
virTristateBool cached_value = priv->kvmUsable;
|
|
|
|
time_t kvm_ctime;
|
|
|
|
time_t cached_kvm_ctime = priv->kvmCtime;
|
|
|
|
|
|
|
|
if (stat(kvm_device, &sb) < 0) {
|
|
|
|
if (errno != ENOENT) {
|
|
|
|
virReportSystemError(errno,
|
|
|
|
_("Failed to stat %s"), kvm_device);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
kvm_ctime = sb.st_ctime;
|
|
|
|
|
|
|
|
if (kvm_ctime != cached_kvm_ctime) {
|
|
|
|
VIR_DEBUG("%s has changed (%lld vs %lld)", kvm_device,
|
|
|
|
(long long)kvm_ctime, (long long)cached_kvm_ctime);
|
|
|
|
cached_value = VIR_TRISTATE_BOOL_ABSENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cached_value != VIR_TRISTATE_BOOL_ABSENT)
|
|
|
|
return cached_value == VIR_TRISTATE_BOOL_YES;
|
|
|
|
|
|
|
|
if (virFileAccessibleAs(kvm_device, R_OK | W_OK,
|
|
|
|
priv->runUid, priv->runGid) == 0) {
|
|
|
|
value = VIR_TRISTATE_BOOL_YES;
|
|
|
|
} else {
|
|
|
|
value = VIR_TRISTATE_BOOL_NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* There is a race window between 'stat' and
|
|
|
|
* 'virFileAccessibleAs'. However, since we're only interested in
|
|
|
|
* detecting changes *after* the virFileAccessibleAs check, we can
|
|
|
|
* neglect this here.
|
|
|
|
*/
|
|
|
|
priv->kvmCtime = kvm_ctime;
|
|
|
|
priv->kvmUsable = value;
|
|
|
|
|
|
|
|
return value == VIR_TRISTATE_BOOL_YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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;
|
2018-11-12 19:58:09 +00:00
|
|
|
bool kvmSupportsNesting;
|
2017-06-19 12:03:06 +00:00
|
|
|
|
2019-12-20 11:56:38 +00:00
|
|
|
if (!qemuCaps->invalidation)
|
|
|
|
return true;
|
|
|
|
|
2017-06-19 12:03:06 +00:00
|
|
|
if (!qemuCaps->binary)
|
|
|
|
return true;
|
|
|
|
|
2020-08-20 21:52:17 +00:00
|
|
|
if (virFileExists(QEMU_MODDIR)) {
|
|
|
|
if (stat(QEMU_MODDIR, &sb) < 0) {
|
|
|
|
VIR_DEBUG("Failed to stat QEMU module directory '%s': %s",
|
|
|
|
QEMU_MODDIR,
|
|
|
|
g_strerror(errno));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sb.st_mtime != qemuCaps->modDirMtime) {
|
|
|
|
VIR_DEBUG("Outdated capabilities for '%s': QEMU modules "
|
|
|
|
"directory '%s' changed (%lld vs %lld)",
|
|
|
|
qemuCaps->binary, QEMU_MODDIR,
|
|
|
|
(long long)sb.st_mtime, (long long)qemuCaps->modDirMtime);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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) {
|
|
|
|
VIR_DEBUG("Failed to stat QEMU binary '%s': %s",
|
|
|
|
qemuCaps->binary,
|
2020-02-26 17:57:34 +00:00
|
|
|
g_strerror(errno));
|
2017-06-22 10:53:26 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2018-09-17 10:23:43 +00:00
|
|
|
if (!virQEMUCapsGuestIsNative(priv->hostArch, qemuCaps->arch)) {
|
|
|
|
VIR_DEBUG("Guest arch (%s) is not native to host arch (%s), "
|
|
|
|
"skipping KVM-related checks",
|
|
|
|
virArchToString(qemuCaps->arch),
|
|
|
|
virArchToString(priv->hostArch));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-10-29 17:34:58 +00:00
|
|
|
kvmUsable = virQEMUCapsKVMUsable(priv);
|
2017-06-19 12:03:06 +00:00
|
|
|
|
|
|
|
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_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)) {
|
2020-05-15 20:00:29 +00:00
|
|
|
if (STRNEQ_NULLABLE(priv->hostCPUSignature, qemuCaps->hostCPUSignature)) {
|
|
|
|
VIR_DEBUG("Outdated capabilities for '%s': host CPU changed "
|
|
|
|
"('%s' vs '%s')",
|
|
|
|
qemuCaps->binary,
|
|
|
|
priv->hostCPUSignature,
|
|
|
|
qemuCaps->hostCPUSignature);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-01-22 10:37:04 +00:00
|
|
|
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;
|
|
|
|
}
|
2018-11-12 19:58:09 +00:00
|
|
|
|
|
|
|
kvmSupportsNesting = virQEMUCapsKVMSupportsNesting();
|
|
|
|
if (kvmSupportsNesting != qemuCaps->kvmSupportsNesting) {
|
|
|
|
VIR_DEBUG("Outdated capabilities for '%s': kvm kernel nested "
|
|
|
|
"value changed from %d",
|
|
|
|
qemuCaps->binary, qemuCaps->kvmSupportsNesting);
|
|
|
|
return false;
|
|
|
|
}
|
2020-06-15 08:28:07 +00:00
|
|
|
|
|
|
|
if (virQEMUCapsKVMSupportsSecureGuest() != qemuCaps->kvmSupportsSecureGuest) {
|
|
|
|
VIR_DEBUG("Outdated capabilities for '%s': kvm kernel secure guest "
|
|
|
|
"value changed from %d",
|
|
|
|
qemuCaps->binary, qemuCaps->kvmSupportsSecureGuest);
|
|
|
|
return false;
|
|
|
|
}
|
2017-12-12 15:23:41 +00:00
|
|
|
}
|
|
|
|
|
2017-06-19 12:03:06 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2021-03-10 07:46:29 +00:00
|
|
|
g_autofree char *archstr = NULL;
|
2013-05-07 11:34:27 +00:00
|
|
|
|
|
|
|
if (!(archstr = qemuMonitorGetTargetArch(mon)))
|
2021-03-10 07:46:29 +00:00
|
|
|
return -1;
|
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);
|
2021-03-10 07:46:29 +00:00
|
|
|
return -1;
|
2013-05-07 11:34:27 +00:00
|
|
|
}
|
|
|
|
|
2021-03-10 07:46:29 +00:00
|
|
|
return 0;
|
2017-03-27 14:42:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
}
|
|
|
|
|
2018-05-03 08:38:42 +00:00
|
|
|
/* HPET is 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
|
|
|
}
|
2012-08-22 17:05:08 +00:00
|
|
|
|
2016-10-19 12:40:53 +00:00
|
|
|
|
2019-03-29 08:05:45 +00:00
|
|
|
/**
|
|
|
|
* virQEMUCapsInitQMPVersionCaps:
|
|
|
|
* @qemuCaps: QEMU capabilities
|
|
|
|
*
|
|
|
|
* Add all QEMU capabilities based on version of QEMU.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
virQEMUCapsInitQMPVersionCaps(virQEMUCapsPtr qemuCaps)
|
|
|
|
{
|
|
|
|
if (qemuCaps->version >= 1006000)
|
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
|
|
|
|
|
|
|
|
/* vmport option is supported v2.2.0 onwards */
|
|
|
|
if (qemuCaps->version >= 2002000)
|
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_VMPORT_OPT);
|
|
|
|
|
|
|
|
/* -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);
|
|
|
|
|
|
|
|
/* vhost-user supports multi-queue from v2.4.0 onwards,
|
|
|
|
* but there is no way to query for that capability */
|
|
|
|
if (qemuCaps->version >= 2004000)
|
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_VHOSTUSER_MULTIQUEUE);
|
|
|
|
|
|
|
|
/* smm option is supported from v2.4.0 */
|
|
|
|
if (qemuCaps->version >= 2004000)
|
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_SMM_OPT);
|
|
|
|
|
|
|
|
/* sdl -gl option is supported from v2.4.0 (qemu commit id 0b71a5d5) */
|
|
|
|
if (qemuCaps->version >= 2004000)
|
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_SDL_GL);
|
|
|
|
|
|
|
|
/* Since 2.4.50 ARM virt machine supports gic-version option */
|
|
|
|
if (qemuCaps->version >= 2004050)
|
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACH_VIRT_GIC_VERSION);
|
|
|
|
|
|
|
|
/* no way to query if -machine kernel_irqchip supports split */
|
|
|
|
if (qemuCaps->version >= 2006000)
|
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_KERNEL_IRQCHIP_SPLIT);
|
|
|
|
|
|
|
|
/* 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);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* '-display egl-headless' cmdline option is supported since QEMU 2.10, but
|
|
|
|
* there's no way to probe it */
|
|
|
|
if (qemuCaps->version >= 2010000)
|
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_EGL_HEADLESS);
|
|
|
|
|
|
|
|
/* no way to query for -numa dist */
|
|
|
|
if (qemuCaps->version >= 2010000)
|
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_NUMA_DIST);
|
|
|
|
|
|
|
|
/* 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);
|
|
|
|
}
|
2020-04-28 09:04:14 +00:00
|
|
|
|
|
|
|
/* TCG couldn't be disabled nor queried until QEMU 2.10 */
|
|
|
|
if (qemuCaps->version < 2010000)
|
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_TCG);
|
2020-10-20 16:48:59 +00:00
|
|
|
|
|
|
|
/* -enable-fips is deprecated in QEMU 5.2.0, and QEMU
|
|
|
|
* should be built with gcrypt to achieve FIPS compliance
|
|
|
|
* automatically / implicitly
|
|
|
|
*/
|
|
|
|
if (qemuCaps->version < 5002000)
|
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_ENABLE_FIPS);
|
2019-03-29 08:05:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-25 11:59:51 +00:00
|
|
|
/**
|
|
|
|
* virQEMUCapsInitProcessCapsInterlock:
|
|
|
|
* @qemuCaps: QEMU capabilities
|
|
|
|
*
|
|
|
|
* A capability which requires a different capability being present in order
|
|
|
|
* for libvirt to be able to drive it properly should be processed here.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
virQEMUCapsInitProcessCapsInterlock(virQEMUCapsPtr qemuCaps)
|
|
|
|
{
|
2019-10-16 11:57:49 +00:00
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV) &&
|
|
|
|
virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV_REOPEN) &&
|
|
|
|
virQEMUCapsGet(qemuCaps, QEMU_CAPS_MIGRATION_PARAM_BLOCK_BITMAP_MAPPING))
|
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_INCREMENTAL_BACKUP);
|
2020-04-01 08:22:30 +00:00
|
|
|
|
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_USB_STORAGE) &&
|
|
|
|
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_USB_STORAGE_WERROR)) {
|
|
|
|
virQEMUCapsClear(qemuCaps, QEMU_CAPS_STORAGE_WERROR);
|
|
|
|
}
|
2020-07-08 13:02:56 +00:00
|
|
|
|
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV))
|
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_BLOCKDEV_HOSTDEV_SCSI);
|
2019-11-25 11:59:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-03-29 08:12:09 +00:00
|
|
|
/**
|
|
|
|
* virQEMUCapsInitProcessCaps:
|
|
|
|
* @qemuCaps: QEMU capabilities
|
|
|
|
*
|
|
|
|
* Some capability bits are enabled or disabled according to specific logic.
|
|
|
|
* This function collects all capability processing after the capabilities
|
|
|
|
* are detected.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
virQEMUCapsInitProcessCaps(virQEMUCapsPtr qemuCaps)
|
|
|
|
{
|
|
|
|
/* '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);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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. */
|
2019-11-24 08:55:42 +00:00
|
|
|
if (qemuCaps->version < 2009000)
|
2019-03-29 08:12:09 +00:00
|
|
|
virQEMUCapsClear(qemuCaps, QEMU_CAPS_DEVICE_NVDIMM);
|
|
|
|
|
|
|
|
if (ARCH_IS_X86(qemuCaps->arch) &&
|
2020-06-02 23:05:36 +00:00
|
|
|
virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION)) {
|
2019-03-29 08:12:09 +00:00
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_CPU_CACHE);
|
|
|
|
|
2020-06-02 23:05:36 +00:00
|
|
|
/* Old x86 QEMU supported migratable:false property in
|
|
|
|
* query-cpu-model-expansion arguments even though it was not properly
|
|
|
|
* advertised as a CPU property.
|
|
|
|
*/
|
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_CPU_MIGRATABLE) ||
|
|
|
|
qemuCaps->version < 2012000)
|
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_MIGRATABLE);
|
|
|
|
}
|
|
|
|
|
2019-03-29 08:12:09 +00:00
|
|
|
if (ARCH_IS_S390(qemuCaps->arch)) {
|
|
|
|
/* Legacy assurance for QEMU_CAPS_CCW */
|
|
|
|
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CCW) &&
|
|
|
|
virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_CCW))
|
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_CCW);
|
|
|
|
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CCW_CSSID_UNRESTRICTED))
|
|
|
|
virQEMUCapsClear(qemuCaps, QEMU_CAPS_DEVICE_VFIO_CCW);
|
|
|
|
}
|
|
|
|
|
2019-06-07 13:00:28 +00:00
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_CPU_UNAVAILABLE_FEATURES))
|
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_CANONICAL_CPU_FEATURES);
|
2019-01-07 10:45:19 +00:00
|
|
|
|
|
|
|
/* To avoid guest ABI regression, blockdev shall be enabled only when
|
|
|
|
* we are able to pass the custom 'device_id' for SCSI disks and cdroms. */
|
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCK_FILE_AUTO_READONLY_DYNAMIC) &&
|
|
|
|
virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_DISK_DEVICE_ID) &&
|
|
|
|
virQEMUCapsGet(qemuCaps, QEMU_CAPS_SAVEVM_MONITOR_NODES))
|
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_BLOCKDEV);
|
2019-11-25 11:59:51 +00:00
|
|
|
|
2020-11-18 16:37:54 +00:00
|
|
|
/* We can't probe "esp" as a type via virQEMUCapsObjectTypes
|
|
|
|
* array as it is only usable when builtin to the machine type
|
|
|
|
*/
|
|
|
|
if (qemuCaps->arch == VIR_ARCH_SPARC ||
|
|
|
|
qemuCaps->arch == VIR_ARCH_M68K ||
|
|
|
|
qemuCaps->arch == VIR_ARCH_MIPS)
|
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_SCSI_NCR53C90);
|
|
|
|
|
2019-11-25 11:59:51 +00:00
|
|
|
virQEMUCapsInitProcessCapsInterlock(qemuCaps);
|
2019-03-29 08:12:09 +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;
|
2020-10-22 17:04:18 +00:00
|
|
|
GHashTable *schema = NULL;
|
2016-10-19 12:40:53 +00:00
|
|
|
size_t i;
|
|
|
|
|
2019-04-02 10:31:31 +00:00
|
|
|
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_QMP_SCHEMA))
|
|
|
|
return 0;
|
|
|
|
|
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;
|
|
|
|
|
2019-10-15 11:55:26 +00:00
|
|
|
for (i = 0; i < G_N_ELEMENTS(virQEMUCapsQMPSchemaQueries); i++) {
|
2016-10-19 12:40:53 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2019-02-07 11:50:27 +00:00
|
|
|
/* probe also for basic event support */
|
2019-10-15 11:55:26 +00:00
|
|
|
for (i = 0; i < G_N_ELEMENTS(virQEMUCapsEvents); i++) {
|
2019-02-07 11:50:27 +00:00
|
|
|
entry = virQEMUCapsEvents + i;
|
|
|
|
|
|
|
|
if (virQEMUQAPISchemaPathExists(entry->value, schema))
|
|
|
|
virQEMUCapsSet(qemuCaps, entry->flag);
|
|
|
|
}
|
|
|
|
|
2016-10-19 12:40:53 +00:00
|
|
|
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
|
|
|
|
2020-04-22 21:50:43 +00:00
|
|
|
virDomainVirtType
|
|
|
|
virQEMUCapsGetVirtType(virQEMUCapsPtr qemuCaps)
|
|
|
|
{
|
|
|
|
virDomainVirtType type;
|
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM))
|
|
|
|
type = VIR_DOMAIN_VIRT_KVM;
|
|
|
|
else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_TCG))
|
|
|
|
type = VIR_DOMAIN_VIRT_QEMU;
|
|
|
|
else
|
|
|
|
type = VIR_DOMAIN_VIRT_NONE;
|
|
|
|
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
2013-09-19 11:14:25 +00:00
|
|
|
int
|
|
|
|
virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps,
|
|
|
|
qemuMonitorPtr mon)
|
|
|
|
{
|
|
|
|
int major, minor, micro;
|
2019-10-15 13:16:31 +00:00
|
|
|
g_autofree char *package = NULL;
|
2019-10-23 14:48:17 +00:00
|
|
|
virQEMUCapsAccelPtr accel;
|
|
|
|
virDomainVirtType type;
|
2013-09-19 11:14:25 +00:00
|
|
|
|
|
|
|
/* @mon is supposed to be locked by callee */
|
|
|
|
|
2019-03-29 08:28:56 +00:00
|
|
|
if (qemuMonitorGetVersion(mon, &major, &minor, µ, &package) < 0)
|
2019-03-29 08:25:21 +00:00
|
|
|
return -1;
|
2013-09-19 11:14:25 +00:00
|
|
|
|
|
|
|
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);
|
2019-03-29 08:25:21 +00:00
|
|
|
return -1;
|
2013-09-19 11:14:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
qemuCaps->version = major * 1000000 + minor * 1000 + micro;
|
2019-10-16 11:43:18 +00:00
|
|
|
qemuCaps->package = g_steal_pointer(&package);
|
2013-09-19 11:14:25 +00:00
|
|
|
|
2017-03-27 14:42:17 +00:00
|
|
|
if (virQEMUCapsInitQMPArch(qemuCaps, mon) < 0)
|
2019-03-29 08:25:21 +00:00
|
|
|
return -1;
|
2013-09-19 11:14:25 +00:00
|
|
|
|
2017-03-27 14:42:17 +00:00
|
|
|
virQEMUCapsInitQMPBasicArch(qemuCaps);
|
|
|
|
|
2020-07-09 04:42:21 +00:00
|
|
|
/* initiate all capabilities based on qemu version */
|
2019-03-29 08:05:45 +00:00
|
|
|
virQEMUCapsInitQMPVersionCaps(qemuCaps);
|
2018-01-05 13:47:46 +00:00
|
|
|
|
2013-09-19 11:14:25 +00:00
|
|
|
if (virQEMUCapsProbeQMPCommands(qemuCaps, mon) < 0)
|
2019-03-29 08:25:21 +00:00
|
|
|
return -1;
|
2016-06-10 17:14:52 +00:00
|
|
|
|
|
|
|
/* Some capabilities may differ depending on KVM state */
|
|
|
|
if (virQEMUCapsProbeQMPKVMState(qemuCaps, mon) < 0)
|
2019-03-29 08:25:21 +00:00
|
|
|
return -1;
|
2016-06-10 17:14:52 +00:00
|
|
|
|
2020-04-22 21:50:43 +00:00
|
|
|
type = virQEMUCapsGetVirtType(qemuCaps);
|
2019-10-23 14:48:17 +00:00
|
|
|
accel = virQEMUCapsGetAccel(qemuCaps, type);
|
|
|
|
|
2013-09-19 11:14:25 +00:00
|
|
|
if (virQEMUCapsProbeQMPEvents(qemuCaps, mon) < 0)
|
2019-03-29 08:25:21 +00:00
|
|
|
return -1;
|
2020-05-06 14:53:31 +00:00
|
|
|
if (virQEMUCapsProbeQMPObjectTypes(qemuCaps, mon) < 0)
|
|
|
|
return -1;
|
|
|
|
if (virQEMUCapsProbeQMPDeviceProperties(qemuCaps, mon) < 0)
|
|
|
|
return -1;
|
|
|
|
if (virQEMUCapsProbeQMPObjectProperties(qemuCaps, mon) < 0)
|
2019-03-29 08:25:21 +00:00
|
|
|
return -1;
|
2019-12-02 12:19:44 +00:00
|
|
|
if (virQEMUCapsProbeQMPMachineTypes(qemuCaps, type, mon) < 0)
|
2019-03-29 08:25:21 +00:00
|
|
|
return -1;
|
2019-10-24 06:52:21 +00:00
|
|
|
if (virQEMUCapsProbeQMPMachineProps(qemuCaps, type, mon) < 0)
|
2019-05-16 13:46:58 +00:00
|
|
|
return -1;
|
2019-10-23 14:48:17 +00:00
|
|
|
if (virQEMUCapsProbeQMPCPUDefinitions(qemuCaps, accel, mon) < 0)
|
2019-03-29 08:25:21 +00:00
|
|
|
return -1;
|
2013-09-19 11:14:25 +00:00
|
|
|
if (virQEMUCapsProbeQMPTPM(qemuCaps, mon) < 0)
|
2019-03-29 08:25:21 +00:00
|
|
|
return -1;
|
2013-09-19 11:14:25 +00:00
|
|
|
if (virQEMUCapsProbeQMPCommandLine(qemuCaps, mon) < 0)
|
2019-03-29 08:25:21 +00:00
|
|
|
return -1;
|
2014-09-11 12:11:54 +00:00
|
|
|
if (virQEMUCapsProbeQMPMigrationCapabilities(qemuCaps, mon) < 0)
|
2019-03-29 08:25:21 +00:00
|
|
|
return -1;
|
2019-04-02 10:31:31 +00:00
|
|
|
if (virQEMUCapsProbeQMPSchemaCapabilities(qemuCaps, mon) < 0)
|
2019-03-29 08:25:21 +00:00
|
|
|
return -1;
|
2019-04-02 10:31:31 +00:00
|
|
|
if (virQEMUCapsProbeQMPGICCapabilities(qemuCaps, mon) < 0)
|
2019-03-29 08:25:21 +00:00
|
|
|
return -1;
|
2019-04-02 10:31:31 +00:00
|
|
|
if (virQEMUCapsProbeQMPSEVCapabilities(qemuCaps, mon) < 0)
|
2019-03-29 08:25:21 +00:00
|
|
|
return -1;
|
2018-06-08 14:40:51 +00:00
|
|
|
|
2019-03-29 08:12:09 +00:00
|
|
|
virQEMUCapsInitProcessCaps(qemuCaps);
|
2019-01-28 16:12:01 +00:00
|
|
|
|
2019-06-17 11:16:51 +00:00
|
|
|
/* The following probes rely on other previously probed capabilities.
|
|
|
|
* No capabilities bits should be set below this point. */
|
|
|
|
|
2019-10-23 14:48:17 +00:00
|
|
|
if (virQEMUCapsProbeQMPHostCPU(qemuCaps, accel, mon, type) < 0)
|
2019-06-17 11:16:51 +00:00
|
|
|
return -1;
|
|
|
|
|
2019-03-29 08:25:21 +00:00
|
|
|
return 0;
|
2013-09-19 11:14:25 +00:00
|
|
|
}
|
|
|
|
|
2013-07-22 17:38:37 +00:00
|
|
|
|
2016-06-10 15:16:21 +00:00
|
|
|
int
|
2019-04-02 11:29:18 +00:00
|
|
|
virQEMUCapsInitQMPMonitorTCG(virQEMUCapsPtr qemuCaps,
|
2016-06-10 15:16:21 +00:00
|
|
|
qemuMonitorPtr mon)
|
|
|
|
{
|
2019-10-23 14:48:17 +00:00
|
|
|
virQEMUCapsAccelPtr accel = virQEMUCapsGetAccel(qemuCaps, VIR_DOMAIN_VIRT_QEMU);
|
|
|
|
|
|
|
|
if (virQEMUCapsProbeQMPCPUDefinitions(qemuCaps, accel, mon) < 0)
|
2019-04-02 11:31:52 +00:00
|
|
|
return -1;
|
2016-11-14 16:21:30 +00:00
|
|
|
|
2019-10-23 14:48:17 +00:00
|
|
|
if (virQEMUCapsProbeQMPHostCPU(qemuCaps, accel, mon, VIR_DOMAIN_VIRT_QEMU) < 0)
|
2019-04-02 11:31:52 +00:00
|
|
|
return -1;
|
2017-02-22 15:51:50 +00:00
|
|
|
|
2019-12-02 12:19:44 +00:00
|
|
|
if (virQEMUCapsProbeQMPMachineTypes(qemuCaps, VIR_DOMAIN_VIRT_QEMU, mon) < 0)
|
2019-10-24 12:21:46 +00:00
|
|
|
return -1;
|
2019-10-24 12:19:38 +00:00
|
|
|
|
2019-04-02 11:31:52 +00:00
|
|
|
return 0;
|
2016-06-10 15:16:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-02-12 13:50:39 +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 },
|
|
|
|
};
|
|
|
|
|
|
|
|
virLogMessage(&virLogSelf,
|
|
|
|
VIR_LOG_WARN,
|
|
|
|
__FILE__, __LINE__, __func__,
|
|
|
|
meta,
|
|
|
|
_("Failed to probe capabilities for %s: %s"),
|
|
|
|
binary, virGetLastErrorMessage());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-22 17:38:37 +00:00
|
|
|
static int
|
2019-02-11 16:06:31 +00:00
|
|
|
virQEMUCapsInitQMPSingle(virQEMUCapsPtr qemuCaps,
|
|
|
|
const char *libDir,
|
|
|
|
uid_t runUid,
|
|
|
|
gid_t runGid,
|
|
|
|
bool onlyTCG)
|
2013-07-22 17:38:37 +00:00
|
|
|
{
|
2020-07-17 21:15:56 +00:00
|
|
|
g_autoptr(qemuProcessQMP) proc = NULL;
|
2013-07-22 17:38:37 +00:00
|
|
|
int ret = -1;
|
|
|
|
|
2019-01-13 00:50:03 +00:00
|
|
|
if (!(proc = qemuProcessQMPNew(qemuCaps->binary, libDir,
|
2019-02-12 14:00:42 +00:00
|
|
|
runUid, runGid, onlyTCG)))
|
2013-07-22 17:38:37 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2019-01-13 00:50:10 +00:00
|
|
|
if (qemuProcessQMPStart(proc) < 0)
|
2013-07-22 17:38:37 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2019-02-11 16:06:31 +00:00
|
|
|
if (onlyTCG)
|
|
|
|
ret = virQEMUCapsInitQMPMonitorTCG(qemuCaps, proc->mon);
|
|
|
|
else
|
|
|
|
ret = virQEMUCapsInitQMPMonitor(qemuCaps, proc->mon);
|
2013-07-22 17:38:37 +00:00
|
|
|
|
|
|
|
cleanup:
|
2019-02-12 13:50:39 +00:00
|
|
|
if (ret < 0)
|
|
|
|
virQEMUCapsLogProbeFailure(qemuCaps->binary);
|
|
|
|
|
2012-08-22 17:05:08 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-02-11 16:06:31 +00:00
|
|
|
static int
|
|
|
|
virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps,
|
|
|
|
const char *libDir,
|
|
|
|
uid_t runUid,
|
2019-02-12 14:00:42 +00:00
|
|
|
gid_t runGid)
|
2019-02-11 16:06:31 +00:00
|
|
|
{
|
2019-02-12 14:00:42 +00:00
|
|
|
if (virQEMUCapsInitQMPSingle(qemuCaps, libDir, runUid, runGid, false) < 0)
|
2019-02-11 16:06:31 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If KVM was enabled during the first probe, we need to explicitly probe
|
|
|
|
* for TCG capabilities by asking the same binary again and turning KVM
|
|
|
|
* off.
|
|
|
|
*/
|
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM) &&
|
2020-04-22 21:50:42 +00:00
|
|
|
virQEMUCapsGet(qemuCaps, QEMU_CAPS_TCG) &&
|
2019-02-12 14:00:42 +00:00
|
|
|
virQEMUCapsInitQMPSingle(qemuCaps, libDir, runUid, runGid, true) < 0)
|
2019-02-11 16:06:31 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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,
|
2020-05-15 20:00:29 +00:00
|
|
|
const char *hostCPUSignature,
|
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;
|
|
|
|
|
2019-12-20 12:28:57 +00:00
|
|
|
if (!(qemuCaps = virQEMUCapsNewBinary(binary)))
|
2014-08-27 13:43:52 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2020-08-20 21:52:17 +00:00
|
|
|
if (virFileExists(QEMU_MODDIR)) {
|
|
|
|
if (stat(QEMU_MODDIR, &sb) < 0) {
|
|
|
|
virReportSystemError(errno, _("Cannot check QEMU module directory %s"),
|
|
|
|
QEMU_MODDIR);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
qemuCaps->modDirMtime = sb.st_mtime;
|
|
|
|
}
|
|
|
|
|
2019-02-12 14:00:42 +00:00
|
|
|
if (virQEMUCapsInitQMP(qemuCaps, libDir, runUid, runGid) < 0)
|
2012-08-22 17:05:08 +00:00
|
|
|
goto error;
|
|
|
|
|
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)) {
|
2020-05-15 20:00:29 +00:00
|
|
|
qemuCaps->hostCPUSignature = g_strdup(hostCPUSignature);
|
2017-12-12 15:23:41 +00:00
|
|
|
qemuCaps->microcodeVersion = microcodeVersion;
|
|
|
|
|
2019-10-20 11:49:46 +00:00
|
|
|
qemuCaps->kernelVersion = g_strdup(kernelVersion);
|
2018-11-12 19:58:09 +00:00
|
|
|
|
|
|
|
qemuCaps->kvmSupportsNesting = virQEMUCapsKVMSupportsNesting();
|
2020-06-15 08:28:07 +00:00
|
|
|
|
|
|
|
qemuCaps->kvmSupportsSecureGuest = virQEMUCapsKVMSupportsSecureGuest();
|
2018-01-22 10:37:04 +00:00
|
|
|
}
|
|
|
|
|
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);
|
2020-01-06 21:57:40 +00:00
|
|
|
return NULL;
|
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,
|
2020-05-15 20:00:29 +00:00
|
|
|
priv->hostCPUSignature,
|
2020-08-24 13:27:53 +00:00
|
|
|
virHostCPUGetMicrocodeVersion(priv->hostArch),
|
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,
|
2020-06-18 13:44:16 +00:00
|
|
|
void *privData,
|
|
|
|
bool *outdated)
|
2017-07-19 15:01:56 +00:00
|
|
|
{
|
2019-12-20 12:28:57 +00:00
|
|
|
virQEMUCapsPtr qemuCaps = virQEMUCapsNewBinary(binary);
|
2017-07-19 15:01:56 +00:00
|
|
|
virQEMUCapsCachePrivPtr priv = privData;
|
2020-06-18 13:44:16 +00:00
|
|
|
int ret;
|
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
|
|
|
|
2020-06-18 13:44:16 +00:00
|
|
|
ret = virQEMUCapsLoadCache(priv->hostArch, qemuCaps, filename, false);
|
|
|
|
if (ret < 0)
|
2017-07-19 15:01:56 +00:00
|
|
|
goto error;
|
2020-06-18 13:44:16 +00:00
|
|
|
if (ret == 1) {
|
|
|
|
*outdated = true;
|
|
|
|
goto error;
|
|
|
|
}
|
2017-07-19 15:01:56 +00:00
|
|
|
|
2017-07-18 14:14:07 +00:00
|
|
|
return qemuCaps;
|
|
|
|
|
|
|
|
error:
|
|
|
|
virObjectUnref(qemuCaps);
|
2020-01-06 21:57:40 +00:00
|
|
|
return NULL;
|
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,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(virQEMUCapsMachineBLAHFilter) }, */
|
2015-02-12 13:50:31 +00:00
|
|
|
{ "", NULL, 0 },
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
virQEMUCapsFilterByMachineType(virQEMUCapsPtr qemuCaps,
|
2019-10-24 06:52:21 +00:00
|
|
|
virDomainVirtType virtType,
|
2015-02-12 13:50:31 +00:00
|
|
|
const char *machineType)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
if (!machineType)
|
|
|
|
return;
|
|
|
|
|
2019-10-15 11:55:26 +00:00
|
|
|
for (i = 0; i < G_N_ELEMENTS(virQEMUCapsMachineFilter); i++) {
|
2015-02-12 13:50:31 +00:00
|
|
|
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]);
|
|
|
|
}
|
|
|
|
|
2019-10-24 06:52:21 +00:00
|
|
|
if (!virQEMUCapsGetMachineHotplugCpus(qemuCaps, virtType, machineType))
|
2016-07-29 07:45:19 +00:00
|
|
|
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,
|
2019-04-12 19:21:05 +00:00
|
|
|
gid_t runGid)
|
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
|
|
|
|
2019-10-22 13:26:14 +00:00
|
|
|
capsCacheDir = g_strdup_printf("%s/capabilities", cacheDir);
|
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
|
|
|
|
2020-10-05 10:25:44 +00:00
|
|
|
priv = g_new0(virQEMUCapsCachePriv, 1);
|
2017-07-19 15:01:56 +00:00
|
|
|
virFileCacheSetPriv(cache, priv);
|
2017-06-20 14:17:23 +00:00
|
|
|
|
2019-10-20 11:49:46 +00:00
|
|
|
priv->libDir = g_strdup(libDir);
|
2017-06-20 14:17:23 +00:00
|
|
|
|
2017-07-19 15:01:56 +00:00
|
|
|
priv->hostArch = virArchFromHost();
|
2017-07-21 13:09:54 +00:00
|
|
|
|
2020-05-15 20:00:29 +00:00
|
|
|
if (virHostCPUGetSignature(&priv->hostCPUSignature) < 0)
|
|
|
|
goto error;
|
|
|
|
|
2017-07-19 15:01:56 +00:00
|
|
|
priv->runUid = runUid;
|
|
|
|
priv->runGid = runGid;
|
2018-10-29 17:34:58 +00:00
|
|
|
priv->kvmUsable = VIR_TRISTATE_BOOL_ABSENT;
|
2012-11-26 14:17:13 +00:00
|
|
|
|
2019-10-22 13:26:14 +00:00
|
|
|
if (uname(&uts) == 0)
|
|
|
|
priv->kernelVersion = g_strdup_printf("%s %s", uts.release, uts.version);
|
2018-01-22 10:37:04 +00:00
|
|
|
|
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
|
|
|
{
|
2019-04-12 19:21:05 +00:00
|
|
|
virQEMUCapsCachePrivPtr priv = virFileCacheGetPriv(cache);
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsPtr ret = NULL;
|
2015-09-09 14:03:14 +00:00
|
|
|
|
2020-08-24 13:27:53 +00:00
|
|
|
priv->microcodeVersion = virHostCPUGetMicrocodeVersion(priv->hostArch);
|
2019-04-12 19:21:05 +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,
|
2019-10-24 06:52:21 +00:00
|
|
|
virDomainVirtType virtType,
|
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;
|
|
|
|
|
2019-10-24 06:52:21 +00:00
|
|
|
virQEMUCapsFilterByMachineType(ret, virtType, machineType);
|
2012-08-22 12:54:13 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-05-07 20:51:57 +00:00
|
|
|
/**
|
|
|
|
* virQEMUCapsCacheLookupDefault:
|
|
|
|
* @cache: QEMU capabilities cache
|
|
|
|
* @binary: optional path to QEMU binary
|
|
|
|
* @archStr: optional guest architecture
|
|
|
|
* @virttypeStr: optional virt type
|
|
|
|
* @machine: optional machine type
|
|
|
|
* @retArch: if non-NULL, guest architecture will be returned here
|
|
|
|
* @retVirttype: if non-NULL, domain virt type will be returned here
|
|
|
|
* @retMachine: if non-NULL, canonical machine type will be returned here
|
|
|
|
*
|
|
|
|
* Looks up the QEMU binary specified by @binary and @archStr, checks it can
|
|
|
|
* provide the required @virttypeStr and @machine and returns its capabilities.
|
|
|
|
* Sensible defaults are used for any argument which is NULL (the function can
|
|
|
|
* even be called with all NULL arguments).
|
|
|
|
*
|
|
|
|
* Returns QEMU capabilities matching the requirements, NULL on error.
|
|
|
|
*/
|
|
|
|
virQEMUCapsPtr
|
|
|
|
virQEMUCapsCacheLookupDefault(virFileCachePtr cache,
|
|
|
|
const char *binary,
|
|
|
|
const char *archStr,
|
|
|
|
const char *virttypeStr,
|
|
|
|
const char *machine,
|
|
|
|
virArch *retArch,
|
|
|
|
virDomainVirtType *retVirttype,
|
|
|
|
const char **retMachine)
|
|
|
|
{
|
|
|
|
int virttype = VIR_DOMAIN_VIRT_NONE;
|
2020-01-17 13:25:02 +00:00
|
|
|
virArch hostarch = virArchFromHost();
|
|
|
|
virArch arch = hostarch;
|
2018-05-07 20:51:57 +00:00
|
|
|
virDomainVirtType capsType;
|
2020-06-22 13:32:33 +00:00
|
|
|
g_autoptr(virQEMUCaps) qemuCaps = NULL;
|
2020-01-17 13:25:02 +00:00
|
|
|
virArch arch_from_caps;
|
|
|
|
g_autofree char *probedbinary = NULL;
|
2018-05-07 20:51:57 +00:00
|
|
|
|
|
|
|
if (virttypeStr &&
|
|
|
|
(virttype = virDomainVirtTypeFromString(virttypeStr)) < 0) {
|
|
|
|
virReportError(VIR_ERR_INVALID_ARG,
|
|
|
|
_("unknown virttype: %s"), virttypeStr);
|
2020-06-22 13:32:33 +00:00
|
|
|
return NULL;
|
2018-05-07 20:51:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (archStr &&
|
|
|
|
(arch = virArchFromString(archStr)) == VIR_ARCH_NONE) {
|
|
|
|
virReportError(VIR_ERR_INVALID_ARG,
|
|
|
|
_("unknown architecture: %s"), archStr);
|
2020-06-22 13:32:33 +00:00
|
|
|
return NULL;
|
2018-05-07 20:51:57 +00:00
|
|
|
}
|
|
|
|
|
2020-01-17 13:25:02 +00:00
|
|
|
if (!binary) {
|
|
|
|
probedbinary = virQEMUCapsGetDefaultEmulator(hostarch, arch);
|
|
|
|
binary = probedbinary;
|
|
|
|
}
|
2020-06-15 12:43:26 +00:00
|
|
|
if (!binary) {
|
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
|
|
_("unable to find any emulator to serve '%s' architecture"),
|
|
|
|
archStr);
|
|
|
|
return NULL;
|
|
|
|
}
|
2018-05-07 20:51:57 +00:00
|
|
|
|
2020-01-17 13:25:02 +00:00
|
|
|
if (!(qemuCaps = virQEMUCapsCacheLookup(cache, binary)))
|
2020-06-22 13:32:33 +00:00
|
|
|
return NULL;
|
2018-05-07 20:51:57 +00:00
|
|
|
|
2020-01-17 13:25:02 +00:00
|
|
|
arch_from_caps = virQEMUCapsGetArch(qemuCaps);
|
2018-05-07 20:51:57 +00:00
|
|
|
|
2020-01-17 13:25:02 +00:00
|
|
|
if (arch_from_caps != arch &&
|
|
|
|
!((ARCH_IS_X86(arch) && ARCH_IS_X86(arch_from_caps)) ||
|
|
|
|
(ARCH_IS_PPC(arch) && ARCH_IS_PPC(arch_from_caps)) ||
|
|
|
|
(ARCH_IS_ARM(arch) && ARCH_IS_ARM(arch_from_caps)) ||
|
|
|
|
(ARCH_IS_S390(arch) && ARCH_IS_S390(arch_from_caps)))) {
|
|
|
|
virReportError(VIR_ERR_INVALID_ARG,
|
|
|
|
_("architecture from emulator '%s' doesn't "
|
|
|
|
"match given architecture '%s'"),
|
|
|
|
virArchToString(arch_from_caps),
|
|
|
|
virArchToString(arch));
|
2020-06-22 13:32:33 +00:00
|
|
|
return NULL;
|
2018-05-07 20:51:57 +00:00
|
|
|
}
|
|
|
|
|
2020-04-22 21:50:43 +00:00
|
|
|
capsType = virQEMUCapsGetVirtType(qemuCaps);
|
2018-05-07 20:51:57 +00:00
|
|
|
|
|
|
|
if (virttype == VIR_DOMAIN_VIRT_NONE)
|
|
|
|
virttype = capsType;
|
|
|
|
|
|
|
|
if (virttype == VIR_DOMAIN_VIRT_KVM && capsType == VIR_DOMAIN_VIRT_QEMU) {
|
|
|
|
virReportError(VIR_ERR_INVALID_ARG,
|
|
|
|
_("KVM is not supported by '%s' on this host"),
|
|
|
|
binary);
|
2020-06-22 13:32:33 +00:00
|
|
|
return NULL;
|
2018-05-07 20:51:57 +00:00
|
|
|
}
|
|
|
|
|
2019-10-24 06:52:21 +00:00
|
|
|
if (machine) {
|
|
|
|
/* Turn @machine into canonical name */
|
|
|
|
machine = virQEMUCapsGetCanonicalMachine(qemuCaps, virttype, machine);
|
|
|
|
|
|
|
|
if (!virQEMUCapsIsMachineSupported(qemuCaps, virttype, machine)) {
|
|
|
|
virReportError(VIR_ERR_INVALID_ARG,
|
|
|
|
_("the machine '%s' is not supported by emulator '%s'"),
|
|
|
|
machine, binary);
|
2020-06-22 13:32:33 +00:00
|
|
|
return NULL;
|
2019-10-24 06:52:21 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
machine = virQEMUCapsGetPreferredMachine(qemuCaps, virttype);
|
|
|
|
}
|
|
|
|
|
2018-05-07 20:51:57 +00:00
|
|
|
if (retArch)
|
|
|
|
*retArch = arch;
|
|
|
|
if (retVirttype)
|
|
|
|
*retVirttype = virttype;
|
|
|
|
if (retMachine)
|
|
|
|
*retMachine = machine;
|
|
|
|
|
2020-06-22 13:32:33 +00:00
|
|
|
return g_steal_pointer(&qemuCaps);
|
2018-05-07 20:51:57 +00:00
|
|
|
}
|
|
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-08-10 14:06:38 +00:00
|
|
|
/*
|
|
|
|
* The preferred machine to use if none is listed explicitly
|
|
|
|
* Note that this may differ from QEMU's own default machine
|
|
|
|
*/
|
2014-06-30 14:39:18 +00:00
|
|
|
const char *
|
2019-10-24 06:52:21 +00:00
|
|
|
virQEMUCapsGetPreferredMachine(virQEMUCapsPtr qemuCaps,
|
2019-10-24 12:19:38 +00:00
|
|
|
virDomainVirtType virtType)
|
2014-06-30 14:39:18 +00:00
|
|
|
{
|
2019-10-24 12:19:38 +00:00
|
|
|
virQEMUCapsAccelPtr accel = virQEMUCapsGetAccel(qemuCaps, virtType);
|
|
|
|
|
|
|
|
if (!accel->nmachineTypes)
|
2014-06-30 14:39:18 +00:00
|
|
|
return NULL;
|
2019-10-24 12:19:38 +00:00
|
|
|
return accel->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,
|
2019-04-04 10:42:14 +00:00
|
|
|
bool secure,
|
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;
|
|
|
|
|
2019-02-08 23:03:20 +00:00
|
|
|
capsLoader->supported = VIR_TRISTATE_BOOL_YES;
|
2019-03-06 23:21:45 +00:00
|
|
|
capsLoader->type.report = true;
|
|
|
|
capsLoader->readonly.report = true;
|
2019-04-04 10:42:14 +00:00
|
|
|
capsLoader->secure.report = true;
|
2014-09-16 12:47:47 +00:00
|
|
|
|
2020-10-05 10:25:44 +00:00
|
|
|
capsLoader->values.values = g_new0(char *, nfirmwares);
|
2014-09-16 23:52:54 +00:00
|
|
|
|
2016-05-17 22:45:27 +00:00
|
|
|
for (i = 0; i < nfirmwares; i++) {
|
|
|
|
const char *filename = firmwares[i]->name;
|
2019-09-12 11:07:31 +00:00
|
|
|
size_t j;
|
2014-09-16 23:52:54 +00:00
|
|
|
|
|
|
|
if (!virFileExists(filename)) {
|
|
|
|
VIR_DEBUG("loader filename=%s does not exist", filename);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2019-09-12 11:07:31 +00:00
|
|
|
/* Put only unique FW images onto the list */
|
|
|
|
for (j = 0; j < capsLoader->values.nvalues; j++) {
|
|
|
|
if (STREQ(filename, capsLoader->values.values[j]))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (j != capsLoader->values.nvalues)
|
|
|
|
continue;
|
|
|
|
|
2019-10-20 11:49:46 +00:00
|
|
|
capsLoader->values.values[capsLoader->values.nvalues] = g_strdup(filename);
|
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);
|
2019-04-04 10:42:14 +00:00
|
|
|
|
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(capsLoader->secure,
|
|
|
|
VIR_TRISTATE_BOOL_NO);
|
|
|
|
|
|
|
|
if (secure)
|
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(capsLoader->secure,
|
|
|
|
VIR_TRISTATE_BOOL_YES);
|
|
|
|
|
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,
|
2019-04-04 10:42:14 +00:00
|
|
|
const char *machine,
|
|
|
|
virArch arch,
|
|
|
|
bool privileged,
|
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;
|
2019-04-04 10:42:14 +00:00
|
|
|
uint64_t autoFirmwares = 0;
|
|
|
|
bool secure = false;
|
2019-08-05 09:29:05 +00:00
|
|
|
virFirmwarePtr *firmwaresAlt = NULL;
|
|
|
|
size_t nfirmwaresAlt = 0;
|
|
|
|
int ret = -1;
|
2014-09-16 12:47:47 +00:00
|
|
|
|
2019-02-08 23:03:20 +00:00
|
|
|
os->supported = VIR_TRISTATE_BOOL_YES;
|
2019-04-04 10:42:14 +00:00
|
|
|
os->firmware.report = true;
|
|
|
|
|
2019-08-05 12:56:32 +00:00
|
|
|
if (qemuFirmwareGetSupported(machine, arch, privileged,
|
2019-08-05 09:29:05 +00:00
|
|
|
&autoFirmwares, &secure,
|
|
|
|
&firmwaresAlt, &nfirmwaresAlt) < 0)
|
2019-04-04 10:42:14 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (autoFirmwares & (1ULL << VIR_DOMAIN_OS_DEF_FIRMWARE_BIOS))
|
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(os->firmware, VIR_DOMAIN_OS_DEF_FIRMWARE_BIOS);
|
|
|
|
if (autoFirmwares & (1ULL << VIR_DOMAIN_OS_DEF_FIRMWARE_EFI))
|
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(os->firmware, VIR_DOMAIN_OS_DEF_FIRMWARE_EFI);
|
|
|
|
|
2019-08-05 09:29:05 +00:00
|
|
|
if (virQEMUCapsFillDomainLoaderCaps(capsLoader, secure,
|
|
|
|
firmwaresAlt ? firmwaresAlt : firmwares,
|
|
|
|
firmwaresAlt ? nfirmwaresAlt : nfirmwares) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
cleanup:
|
|
|
|
virFirmwareFreeList(firmwaresAlt, nfirmwaresAlt);
|
|
|
|
return ret;
|
2014-09-16 12:47:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-10-25 11:25:20 +00:00
|
|
|
static void
|
2019-11-26 17:51:22 +00:00
|
|
|
virQEMUCapsFillDomainCPUCaps(virQEMUCapsPtr qemuCaps,
|
|
|
|
virArch hostarch,
|
2016-04-22 20:22:30 +00:00
|
|
|
virDomainCapsPtr domCaps)
|
|
|
|
{
|
2019-11-26 17:51:22 +00:00
|
|
|
if (virQEMUCapsIsCPUModeSupported(qemuCaps, hostarch, domCaps->virttype,
|
2020-02-05 14:51:09 +00:00
|
|
|
VIR_CPU_MODE_HOST_PASSTHROUGH,
|
2020-06-02 22:28:10 +00:00
|
|
|
domCaps->machine)) {
|
2016-04-22 20:22:30 +00:00
|
|
|
domCaps->cpu.hostPassthrough = true;
|
|
|
|
|
2020-06-02 22:28:10 +00:00
|
|
|
domCaps->cpu.hostPassthroughMigratable.report = true;
|
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_CPU_MIGRATABLE)) {
|
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(domCaps->cpu.hostPassthroughMigratable,
|
|
|
|
VIR_TRISTATE_SWITCH_ON);
|
|
|
|
}
|
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(domCaps->cpu.hostPassthroughMigratable,
|
|
|
|
VIR_TRISTATE_SWITCH_OFF);
|
|
|
|
}
|
|
|
|
|
2021-02-05 18:35:10 +00:00
|
|
|
if (virQEMUCapsIsCPUModeSupported(qemuCaps, hostarch, domCaps->virttype,
|
|
|
|
VIR_CPU_MODE_MAXIMUM,
|
|
|
|
domCaps->machine)) {
|
|
|
|
domCaps->cpu.maximum = true;
|
|
|
|
|
|
|
|
domCaps->cpu.maximumMigratable.report = true;
|
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(domCaps->cpu.maximumMigratable,
|
|
|
|
VIR_TRISTATE_SWITCH_ON);
|
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(domCaps->cpu.maximumMigratable,
|
|
|
|
VIR_TRISTATE_SWITCH_OFF);
|
|
|
|
}
|
|
|
|
|
2019-11-26 17:51:22 +00:00
|
|
|
if (virQEMUCapsIsCPUModeSupported(qemuCaps, hostarch, domCaps->virttype,
|
2020-02-05 14:51:09 +00:00
|
|
|
VIR_CPU_MODE_HOST_MODEL,
|
|
|
|
domCaps->machine)) {
|
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
|
|
|
|
2019-11-26 17:51:22 +00:00
|
|
|
if (virQEMUCapsIsCPUModeSupported(qemuCaps, hostarch, domCaps->virttype,
|
2020-02-05 14:51:09 +00:00
|
|
|
VIR_CPU_MODE_CUSTOM,
|
|
|
|
domCaps->machine)) {
|
2020-06-16 10:16:43 +00:00
|
|
|
const char *forbidden[] = { "host", NULL };
|
2020-12-01 08:21:32 +00:00
|
|
|
g_auto(GStrv) models = NULL;
|
2016-04-22 20:22:30 +00:00
|
|
|
|
2016-11-04 13:20:39 +00:00
|
|
|
if (virCPUGetModels(domCaps->arch, &models) >= 0) {
|
2019-10-09 08:14:59 +00:00
|
|
|
domCaps->cpu.custom = virQEMUCapsGetCPUModels(qemuCaps,
|
|
|
|
domCaps->virttype,
|
|
|
|
(const char **)models,
|
2020-06-16 10:16:43 +00:00
|
|
|
forbidden);
|
2019-09-20 20:54:13 +00:00
|
|
|
} else {
|
|
|
|
domCaps->cpu.custom = NULL;
|
2016-08-03 14:22:30 +00:00
|
|
|
}
|
2016-04-29 08:42:56 +00:00
|
|
|
}
|
2016-04-22 20:22:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-10-30 15:40:03 +00:00
|
|
|
struct virQEMUCapsDomainFeatureCapabilityTuple {
|
|
|
|
virDomainCapsFeature domcap;
|
|
|
|
virQEMUCapsFlags qemucap;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This maps the qemu features to the entries in <features> of the domain
|
|
|
|
* capability XML.
|
|
|
|
* */
|
|
|
|
static const struct virQEMUCapsDomainFeatureCapabilityTuple domCapsTuples[] = {
|
|
|
|
{ VIR_DOMAIN_CAPS_FEATURE_IOTHREADS, QEMU_CAPS_OBJECT_IOTHREAD },
|
|
|
|
{ VIR_DOMAIN_CAPS_FEATURE_VMCOREINFO, QEMU_CAPS_DEVICE_VMCOREINFO },
|
|
|
|
{ VIR_DOMAIN_CAPS_FEATURE_GENID, QEMU_CAPS_DEVICE_VMGENID },
|
2019-11-18 15:56:51 +00:00
|
|
|
{ VIR_DOMAIN_CAPS_FEATURE_BACKING_STORE_INPUT, QEMU_CAPS_BLOCKDEV },
|
2019-12-03 16:38:13 +00:00
|
|
|
{ VIR_DOMAIN_CAPS_FEATURE_BACKUP, QEMU_CAPS_INCREMENTAL_BACKUP },
|
2019-10-30 15:40:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2019-10-25 11:25:20 +00:00
|
|
|
static void
|
2019-10-30 15:40:03 +00:00
|
|
|
virQEMUCapsFillDomainFeaturesFromQEMUCaps(virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainCapsPtr domCaps)
|
2017-10-19 12:19:38 +00:00
|
|
|
{
|
2019-10-30 15:40:03 +00:00
|
|
|
size_t i;
|
|
|
|
|
|
|
|
for (i = 0; i < G_N_ELEMENTS(domCapsTuples); i++) {
|
|
|
|
if (virQEMUCapsGet(qemuCaps, domCapsTuples[i].qemucap))
|
|
|
|
domCaps->features[domCapsTuples[i].domcap] = VIR_TRISTATE_BOOL_YES;
|
2019-11-21 08:52:24 +00:00
|
|
|
else
|
|
|
|
domCaps->features[domCapsTuples[i].domcap] = VIR_TRISTATE_BOOL_NO;
|
2019-10-30 15:40:03 +00:00
|
|
|
}
|
2017-10-19 12:19:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-10-25 11:25:20 +00:00
|
|
|
static void
|
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)
|
|
|
|
{
|
2019-02-08 23:03:20 +00:00
|
|
|
disk->supported = VIR_TRISTATE_BOOL_YES;
|
2019-03-06 23:21:45 +00:00
|
|
|
disk->diskDevice.report = true;
|
|
|
|
disk->bus.report = true;
|
|
|
|
disk->model.report = 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 */
|
2018-11-28 15:34:41 +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);
|
2018-11-28 15:34:41 +00:00
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(disk->bus, VIR_DOMAIN_DISK_BUS_FDC);
|
|
|
|
}
|
2014-06-25 16:39:29 +00:00
|
|
|
|
2018-11-28 15:48:41 +00:00
|
|
|
if (qemuDomainMachineHasBuiltinIDE(machine, qemuCaps->arch))
|
2017-04-13 13:29:16 +00:00
|
|
|
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 */);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2019-02-20 19:18:40 +00:00
|
|
|
/* disk->model values */
|
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(disk->model, VIR_DOMAIN_DISK_MODEL_VIRTIO);
|
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY) ||
|
|
|
|
virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL)) {
|
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(disk->model,
|
|
|
|
VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL);
|
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(disk->model,
|
|
|
|
VIR_DOMAIN_DISK_MODEL_VIRTIO_NON_TRANSITIONAL);
|
|
|
|
}
|
2014-06-25 16:39:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-17 10:00:31 +00:00
|
|
|
void
|
2016-05-08 15:57:20 +00:00
|
|
|
virQEMUCapsFillDomainDeviceGraphicsCaps(virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainCapsDeviceGraphicsPtr dev)
|
|
|
|
{
|
2019-02-08 23:03:20 +00:00
|
|
|
dev->supported = VIR_TRISTATE_BOOL_YES;
|
2019-03-06 23:21:45 +00:00
|
|
|
dev->type.report = true;
|
2016-05-08 15:57:20 +00:00
|
|
|
|
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);
|
2020-11-17 10:00:26 +00:00
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_EGL_HEADLESS))
|
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(dev->type, VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS);
|
2016-05-08 15:57:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-17 09:26:14 +00:00
|
|
|
void
|
2016-05-08 16:11:39 +00:00
|
|
|
virQEMUCapsFillDomainDeviceVideoCaps(virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainCapsDeviceVideoPtr dev)
|
|
|
|
{
|
2019-02-08 23:03:20 +00:00
|
|
|
dev->supported = VIR_TRISTATE_BOOL_YES;
|
2019-03-06 23:21:45 +00:00
|
|
|
dev->modelType.report = true;
|
2016-05-08 16:11:39 +00:00
|
|
|
|
2019-10-18 15:30:13 +00:00
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(dev->modelType, VIR_DOMAIN_VIDEO_TYPE_NONE);
|
2016-05-08 16:11:39 +00:00
|
|
|
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);
|
2019-10-03 13:28:40 +00:00
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_BOCHS_DISPLAY))
|
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(dev->modelType, VIR_DOMAIN_VIDEO_TYPE_BOCHS);
|
2019-10-18 15:30:12 +00:00
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_RAMFB))
|
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(dev->modelType, VIR_DOMAIN_VIDEO_TYPE_RAMFB);
|
2016-05-08 16:11:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-10-25 11:25:20 +00:00
|
|
|
static void
|
2014-06-25 16:39:29 +00:00
|
|
|
virQEMUCapsFillDomainDeviceHostdevCaps(virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainCapsDeviceHostdevPtr hostdev)
|
|
|
|
{
|
|
|
|
bool supportsPassthroughVFIO = qemuHostdevHostSupportsPassthroughVFIO();
|
|
|
|
|
2019-02-08 23:03:20 +00:00
|
|
|
hostdev->supported = VIR_TRISTATE_BOOL_YES;
|
2019-03-06 23:21:45 +00:00
|
|
|
hostdev->mode.report = true;
|
|
|
|
hostdev->startupPolicy.report = true;
|
|
|
|
hostdev->subsysType.report = true;
|
|
|
|
hostdev->capsType.report = true;
|
|
|
|
hostdev->pciBackend.report = 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,
|
2018-09-18 10:29:10 +00:00
|
|
|
VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI,
|
|
|
|
VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI);
|
2014-06-25 16:39:29 +00:00
|
|
|
|
2020-01-13 08:04:57 +00:00
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PIIX3_USB_UHCI) ||
|
|
|
|
virQEMUCapsGet(qemuCaps, QEMU_CAPS_PIIX4_USB_UHCI) ||
|
|
|
|
virQEMUCapsGet(qemuCaps, QEMU_CAPS_USB_EHCI) ||
|
|
|
|
virQEMUCapsGet(qemuCaps, QEMU_CAPS_ICH9_USB_EHCI1) ||
|
|
|
|
virQEMUCapsGet(qemuCaps, QEMU_CAPS_VT82C686B_USB_UHCI) ||
|
|
|
|
virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCI_OHCI) ||
|
|
|
|
virQEMUCapsGet(qemuCaps, QEMU_CAPS_NEC_USB_XHCI) ||
|
|
|
|
virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QEMU_XHCI)) {
|
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(hostdev->subsysType,
|
|
|
|
VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB);
|
|
|
|
}
|
|
|
|
|
2014-06-25 16:39:29 +00:00
|
|
|
/* 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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-17 09:37:10 +00:00
|
|
|
void
|
2019-03-31 21:19:40 +00:00
|
|
|
virQEMUCapsFillDomainDeviceRNGCaps(virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainCapsDeviceRNGPtr rng)
|
|
|
|
{
|
|
|
|
rng->supported = VIR_TRISTATE_BOOL_YES;
|
|
|
|
rng->model.report = true;
|
|
|
|
rng->backendModel.report = true;
|
|
|
|
|
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_RNG)) {
|
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(rng->model, VIR_DOMAIN_RNG_MODEL_VIRTIO);
|
|
|
|
|
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL) ||
|
|
|
|
virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY)) {
|
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(rng->model,
|
|
|
|
VIR_DOMAIN_RNG_MODEL_VIRTIO_TRANSITIONAL,
|
|
|
|
VIR_DOMAIN_RNG_MODEL_VIRTIO_NON_TRANSITIONAL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_RNG_EGD))
|
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(rng->backendModel, VIR_DOMAIN_RNG_BACKEND_EGD);
|
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_RNG_RANDOM))
|
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(rng->backendModel, VIR_DOMAIN_RNG_BACKEND_RANDOM);
|
2020-01-09 08:00:08 +00:00
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_RNG_BUILTIN))
|
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(rng->backendModel, VIR_DOMAIN_RNG_BACKEND_BUILTIN);
|
2019-03-31 21:19:40 +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.
|
|
|
|
*/
|
2019-10-25 11:25:20 +00:00
|
|
|
static void
|
2016-03-09 18:18:24 +00:00
|
|
|
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
|
|
|
|
2019-02-19 19:15:06 +00:00
|
|
|
gic->supported = VIR_TRISTATE_BOOL_NO;
|
|
|
|
|
2018-08-22 09:15:20 +00:00
|
|
|
if (!qemuDomainMachineIsARMVirt(domCaps->machine, domCaps->arch))
|
2019-10-25 11:25:20 +00:00
|
|
|
return;
|
2016-03-09 18:18:24 +00:00
|
|
|
|
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;
|
|
|
|
|
2019-02-08 23:03:20 +00:00
|
|
|
gic->supported = VIR_TRISTATE_BOOL_YES;
|
2019-03-06 23:21:45 +00:00
|
|
|
gic->version.report = true;
|
2016-03-09 18:18:24 +00:00
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(gic->version,
|
2016-05-16 11:23:01 +00:00
|
|
|
version);
|
2016-03-09 18:18:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-06-08 14:40:52 +00:00
|
|
|
/**
|
|
|
|
* virQEMUCapsFillDomainFeatureSEVCaps:
|
|
|
|
* @qemuCaps: QEMU capabilities
|
|
|
|
* @domCaps: domain capabilities
|
|
|
|
*
|
|
|
|
* Take the information about SEV capabilities that has been obtained
|
|
|
|
* using the 'query-sev-capabilities' QMP command and stored in @qemuCaps
|
|
|
|
* and convert it to a form suitable for @domCaps.
|
|
|
|
*/
|
2019-10-25 11:25:20 +00:00
|
|
|
static void
|
2018-06-08 14:40:52 +00:00
|
|
|
virQEMUCapsFillDomainFeatureSEVCaps(virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainCapsPtr domCaps)
|
|
|
|
{
|
|
|
|
virSEVCapability *cap = qemuCaps->sevCapabilities;
|
|
|
|
|
|
|
|
if (!cap)
|
2019-10-25 11:25:20 +00:00
|
|
|
return;
|
2018-06-08 14:40:52 +00:00
|
|
|
|
2019-10-25 11:18:55 +00:00
|
|
|
domCaps->sev = g_new0(virSEVCapability, 1);
|
2018-06-08 14:40:52 +00:00
|
|
|
|
2019-10-25 11:18:55 +00:00
|
|
|
domCaps->sev->pdh = g_strdup(cap->pdh);
|
|
|
|
domCaps->sev->cert_chain = g_strdup(cap->cert_chain);
|
|
|
|
domCaps->sev->cbitpos = cap->cbitpos;
|
|
|
|
domCaps->sev->reduced_phys_bits = cap->reduced_phys_bits;
|
2018-06-08 14:40:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-17 09:33:35 +00:00
|
|
|
int
|
2019-11-26 17:51:22 +00:00
|
|
|
virQEMUCapsFillDomainCaps(virQEMUCapsPtr qemuCaps,
|
|
|
|
virArch hostarch,
|
2016-04-22 20:22:30 +00:00
|
|
|
virDomainCapsPtr domCaps,
|
2019-04-04 10:42:14 +00:00
|
|
|
bool privileged,
|
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;
|
2019-03-31 21:19:40 +00:00
|
|
|
virDomainCapsDeviceRNGPtr rng = &domCaps->rng;
|
2014-06-25 16:39:29 +00:00
|
|
|
|
2019-10-30 15:40:03 +00:00
|
|
|
virQEMUCapsFillDomainFeaturesFromQEMUCaps(qemuCaps, domCaps);
|
2019-11-13 15:32:21 +00:00
|
|
|
|
2016-06-24 15:04:13 +00:00
|
|
|
domCaps->maxvcpus = virQEMUCapsGetMachineMaxCpus(qemuCaps,
|
2019-10-24 06:52:21 +00:00
|
|
|
domCaps->virttype,
|
2016-06-24 15:04:13 +00:00
|
|
|
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
|
|
|
|
2019-04-04 10:42:14 +00:00
|
|
|
if (virQEMUCapsFillDomainOSCaps(os,
|
|
|
|
domCaps->machine,
|
|
|
|
domCaps->arch,
|
|
|
|
privileged,
|
2019-10-25 11:25:20 +00:00
|
|
|
firmwares, nfirmwares) < 0)
|
2014-09-17 09:33:35 +00:00
|
|
|
return -1;
|
2018-06-08 14:40:52 +00:00
|
|
|
|
2019-11-26 17:51:22 +00:00
|
|
|
virQEMUCapsFillDomainCPUCaps(qemuCaps, hostarch, domCaps);
|
2019-10-25 11:25:20 +00:00
|
|
|
virQEMUCapsFillDomainDeviceDiskCaps(qemuCaps, domCaps->machine, disk);
|
|
|
|
virQEMUCapsFillDomainDeviceGraphicsCaps(qemuCaps, graphics);
|
|
|
|
virQEMUCapsFillDomainDeviceVideoCaps(qemuCaps, video);
|
|
|
|
virQEMUCapsFillDomainDeviceHostdevCaps(qemuCaps, hostdev);
|
|
|
|
virQEMUCapsFillDomainDeviceRNGCaps(qemuCaps, rng);
|
|
|
|
virQEMUCapsFillDomainFeatureGICCaps(qemuCaps, domCaps);
|
|
|
|
virQEMUCapsFillDomainFeatureSEVCaps(qemuCaps, domCaps);
|
|
|
|
|
2014-09-17 09:33:35 +00:00
|
|
|
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;
|
|
|
|
}
|
2018-06-04 13:30:49 +00:00
|
|
|
|
|
|
|
|
2020-01-23 12:11:08 +00:00
|
|
|
static void
|
|
|
|
virQEMUCapsStripMachineAliasesForVirtType(virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainVirtType virtType)
|
|
|
|
{
|
|
|
|
virQEMUCapsAccelPtr accel = virQEMUCapsGetAccel(qemuCaps, virtType);
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
for (i = 0; i < accel->nmachineTypes; i++) {
|
|
|
|
virQEMUCapsMachineTypePtr mach = &accel->machineTypes[i];
|
2020-01-23 12:20:25 +00:00
|
|
|
g_autofree char *name = g_steal_pointer(&mach->alias);
|
2020-01-23 12:11:08 +00:00
|
|
|
|
2020-01-23 12:20:25 +00:00
|
|
|
if (name) {
|
|
|
|
virQEMUCapsAddMachine(qemuCaps, virtType, name, NULL, mach->defaultCPU,
|
2020-05-14 11:11:01 +00:00
|
|
|
mach->maxCpus, mach->hotplugCpus, mach->qemuDefault,
|
2021-01-22 12:16:23 +00:00
|
|
|
mach->numaMemSupported, mach->defaultRAMid,
|
|
|
|
mach->deprecated);
|
2020-01-23 12:20:25 +00:00
|
|
|
}
|
2020-01-23 12:11:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-06-04 13:30:49 +00:00
|
|
|
/**
|
|
|
|
* virQEMUCapsStripMachineAliases:
|
|
|
|
* @qemuCaps: capabilities object to process
|
|
|
|
*
|
2020-01-23 12:20:25 +00:00
|
|
|
* Replace all aliases by the copy of the machine type they point to without
|
|
|
|
* actually having to modify the name. This allows us to add tests with the
|
|
|
|
* aliased machine without having to change the output files all the time.
|
|
|
|
*
|
2018-06-04 13:30:49 +00:00
|
|
|
* Remove all aliases so that the tests depending on the latest capabilities
|
|
|
|
* file can be stable when new files are added.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
virQEMUCapsStripMachineAliases(virQEMUCapsPtr qemuCaps)
|
|
|
|
{
|
2020-01-23 12:11:08 +00:00
|
|
|
virQEMUCapsStripMachineAliasesForVirtType(qemuCaps, VIR_DOMAIN_VIRT_KVM);
|
|
|
|
virQEMUCapsStripMachineAliasesForVirtType(qemuCaps, VIR_DOMAIN_VIRT_QEMU);
|
2018-06-04 13:30:49 +00:00
|
|
|
}
|