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"
|
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"
|
2010-12-16 15:07:07 +00:00
|
|
|
|
2013-01-29 16:52:17 +00:00
|
|
|
#include <fcntl.h>
|
2010-12-16 15:07:07 +00:00
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/wait.h>
|
2011-02-08 14:22:39 +00:00
|
|
|
#include <stdarg.h>
|
2018-01-22 10:37:04 +00:00
|
|
|
#include <sys/utsname.h>
|
2010-12-16 15:07:07 +00:00
|
|
|
|
|
|
|
#define VIR_FROM_THIS VIR_FROM_QEMU
|
|
|
|
|
2014-02-28 12:16:17 +00:00
|
|
|
VIR_LOG_INIT("qemu.qemu_capabilities");
|
|
|
|
|
2011-05-04 11:55:38 +00:00
|
|
|
/* While not public, these strings must not change. They
|
|
|
|
* are used in domain status files which are read on
|
|
|
|
* daemon restarts
|
|
|
|
*/
|
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",
|
2011-05-04 11:55:38 +00:00
|
|
|
);
|
|
|
|
|
2014-03-05 16:51:59 +00:00
|
|
|
|
2016-07-29 08:13:46 +00:00
|
|
|
struct virQEMUCapsMachineType {
|
|
|
|
char *name;
|
|
|
|
char *alias;
|
|
|
|
unsigned int maxCpus;
|
2016-07-29 07:45:19 +00:00
|
|
|
bool hotplugCpus;
|
2018-08-10 12:18:27 +00:00
|
|
|
bool qemuDefault;
|
2016-07-29 08:13:46 +00:00
|
|
|
};
|
2017-04-07 16:15:26 +00:00
|
|
|
|
|
|
|
typedef struct _virQEMUCapsHostCPUData virQEMUCapsHostCPUData;
|
|
|
|
typedef virQEMUCapsHostCPUData *virQEMUCapsHostCPUDataPtr;
|
|
|
|
struct _virQEMUCapsHostCPUData {
|
|
|
|
/* Only the "info" part is stored in the capabilities cache, the rest is
|
|
|
|
* re-computed from other fields and external data sources everytime we
|
|
|
|
* probe QEMU or load the cache.
|
|
|
|
*/
|
|
|
|
qemuMonitorCPUModelInfoPtr info;
|
|
|
|
/* Host CPU definition reported in domain capabilities. */
|
|
|
|
virCPUDefPtr reported;
|
2017-03-29 13:31:17 +00:00
|
|
|
/* Migratable host CPU definition used for updating guest CPU. */
|
|
|
|
virCPUDefPtr migratable;
|
2017-04-11 18:46:05 +00:00
|
|
|
/* CPU definition with features detected by libvirt using virCPUGetHost
|
|
|
|
* combined with features reported by QEMU. This is used for backward
|
|
|
|
* compatible comparison between a guest CPU and a host CPU. */
|
|
|
|
virCPUDefPtr full;
|
2017-04-07 16:15:26 +00:00
|
|
|
};
|
|
|
|
|
2014-03-05 16:51:59 +00:00
|
|
|
/*
|
|
|
|
* Update the XML parser/formatter when adding more
|
|
|
|
* information to this struct so that it gets cached
|
|
|
|
* correctly. It does not have to be ABI-stable, as
|
|
|
|
* the cache will be discarded & repopulated if the
|
|
|
|
* timestamp on the libvirtd binary changes.
|
2016-08-04 14:48:40 +00:00
|
|
|
*
|
|
|
|
* And don't forget to update virQEMUCapsNewCopy.
|
2014-03-05 16:51:59 +00:00
|
|
|
*/
|
2013-02-01 13:48:58 +00:00
|
|
|
struct _virQEMUCaps {
|
2018-04-13 11:51:23 +00:00
|
|
|
virObject parent;
|
2012-08-20 16:44:14 +00:00
|
|
|
|
2012-08-22 17:05:08 +00:00
|
|
|
bool usedQMP;
|
2018-11-12 19:58:09 +00:00
|
|
|
bool kvmSupportsNesting;
|
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;
|
2012-09-10 10:47:56 +00:00
|
|
|
|
2012-08-20 16:44:14 +00:00
|
|
|
virBitmapPtr flags;
|
2012-08-22 10:11:28 +00:00
|
|
|
|
|
|
|
unsigned int version;
|
|
|
|
unsigned int kvmVersion;
|
2017-06-13 15:55:45 +00:00
|
|
|
unsigned int libvirtVersion;
|
2017-12-12 15:23:41 +00:00
|
|
|
unsigned int microcodeVersion;
|
2015-02-02 10:28:30 +00:00
|
|
|
char *package;
|
2018-01-22 10:37:04 +00:00
|
|
|
char *kernelVersion;
|
2012-08-22 10:11:28 +00:00
|
|
|
|
2012-12-11 13:06:45 +00:00
|
|
|
virArch arch;
|
2012-08-22 10:11:28 +00:00
|
|
|
|
2016-11-14 16:21:30 +00:00
|
|
|
virDomainCapsCPUModelsPtr kvmCPUModels;
|
|
|
|
virDomainCapsCPUModelsPtr tcgCPUModels;
|
2012-08-22 10:11:28 +00:00
|
|
|
|
|
|
|
size_t nmachineTypes;
|
2016-07-29 08:13:46 +00:00
|
|
|
struct virQEMUCapsMachineType *machineTypes;
|
2016-03-08 17:24:18 +00:00
|
|
|
|
|
|
|
size_t ngicCapabilities;
|
|
|
|
virGICCapability *gicCapabilities;
|
2016-06-15 12:35:18 +00:00
|
|
|
|
2018-06-08 14:40:51 +00:00
|
|
|
virSEVCapability *sevCapabilities;
|
|
|
|
|
2017-04-07 16:15:26 +00:00
|
|
|
virQEMUCapsHostCPUData kvmCPU;
|
|
|
|
virQEMUCapsHostCPUData tcgCPU;
|
2012-08-20 16:44:14 +00:00
|
|
|
};
|
|
|
|
|
2014-06-30 14:12:07 +00:00
|
|
|
struct virQEMUCapsSearchData {
|
|
|
|
virArch arch;
|
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
|
|
|
|
2012-11-30 18:22:42 +00:00
|
|
|
static void
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsSetDefaultMachine(virQEMUCapsPtr qemuCaps,
|
|
|
|
size_t defIdx)
|
2012-11-30 18:22:42 +00:00
|
|
|
{
|
2016-07-29 08:13:46 +00:00
|
|
|
struct virQEMUCapsMachineType tmp = qemuCaps->machineTypes[defIdx];
|
2013-02-01 13:48:58 +00:00
|
|
|
|
|
|
|
memmove(qemuCaps->machineTypes + 1,
|
|
|
|
qemuCaps->machineTypes,
|
|
|
|
sizeof(qemuCaps->machineTypes[0]) * defIdx);
|
2016-07-29 08:13:46 +00:00
|
|
|
|
|
|
|
qemuCaps->machineTypes[0] = tmp;
|
2012-11-30 18:22:42 +00:00
|
|
|
}
|
|
|
|
|
2010-12-16 15:07:07 +00:00
|
|
|
|
2012-08-22 16:59:39 +00:00
|
|
|
static char *
|
2015-09-15 13:58:09 +00:00
|
|
|
virQEMUCapsFindBinary(const char *format,
|
|
|
|
const char *archstr)
|
2012-08-22 16:59:39 +00:00
|
|
|
{
|
2015-09-15 13:58:09 +00:00
|
|
|
char *ret = NULL;
|
|
|
|
char *binary = NULL;
|
2015-02-15 04:18:00 +00:00
|
|
|
|
2015-09-15 13:58:09 +00:00
|
|
|
if (virAsprintf(&binary, format, archstr) < 0)
|
2018-04-13 06:01:45 +00:00
|
|
|
return NULL;
|
2012-12-11 13:06:45 +00:00
|
|
|
|
|
|
|
ret = virFindFileInPath(binary);
|
|
|
|
VIR_FREE(binary);
|
2015-09-15 13:58:09 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
virQEMUCapsFindBinaryForArch(virArch hostarch,
|
|
|
|
virArch guestarch)
|
|
|
|
{
|
|
|
|
char *ret = NULL;
|
|
|
|
const char *archstr;
|
|
|
|
virArch target;
|
|
|
|
|
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)
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/* Second attempt: try looking up by target instead */
|
|
|
|
target = virQEMUCapsFindTarget(hostarch, guestarch);
|
|
|
|
if (target != guestarch) {
|
|
|
|
archstr = virQEMUCapsArchToString(target);
|
|
|
|
if ((ret = virQEMUCapsFindBinary("qemu-system-%s", archstr)) != NULL)
|
|
|
|
goto out;
|
2012-12-11 13:06:45 +00:00
|
|
|
}
|
2012-08-22 16:59:39 +00:00
|
|
|
|
2015-09-15 13:58:09 +00:00
|
|
|
out:
|
2012-08-22 16:59:39 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-12-16 15:07:07 +00:00
|
|
|
static int
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsInitGuest(virCapsPtr caps,
|
2017-07-19 15:01:56 +00:00
|
|
|
virFileCachePtr cache,
|
2013-02-01 13:48:58 +00:00
|
|
|
virArch hostarch,
|
|
|
|
virArch guestarch)
|
2010-12-16 15:07:07 +00:00
|
|
|
{
|
|
|
|
char *binary = NULL;
|
2018-09-18 16:24:35 +00:00
|
|
|
virQEMUCapsPtr qemuCaps = NULL;
|
2010-12-16 15:07:07 +00:00
|
|
|
int ret = -1;
|
|
|
|
|
2012-10-11 16:31:20 +00:00
|
|
|
/* Check for existence of base emulator, or alternate base
|
2010-12-16 15:07:07 +00:00
|
|
|
* which can be used with magic cpu choice
|
|
|
|
*/
|
2013-02-01 13:48:58 +00:00
|
|
|
binary = virQEMUCapsFindBinaryForArch(hostarch, guestarch);
|
2010-12-16 15:07:07 +00:00
|
|
|
|
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 */
|
|
|
|
if (virQEMUCapsGuestIsNative(hostarch, guestarch) && !binary) {
|
|
|
|
if (VIR_STRDUP(binary, "/usr/libexec/qemu-kvm") < 0)
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
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' */
|
|
|
|
if (!virCapabilitiesAddGuestFeature(guest, "cpuselection", true, false))
|
2014-03-17 15:19:45 +00:00
|
|
|
goto cleanup;
|
2010-12-16 15:07:07 +00:00
|
|
|
|
2018-08-09 11:26:17 +00:00
|
|
|
if (!virCapabilitiesAddGuestFeature(guest, "deviceboot", true, false))
|
2014-03-17 15:19:45 +00:00
|
|
|
goto cleanup;
|
2011-01-12 10:33:34 +00:00
|
|
|
|
2018-06-05 11:42:44 +00:00
|
|
|
if (!virCapabilitiesAddGuestFeature(guest, "disksnapshot", true, false))
|
2014-03-17 15:19:45 +00:00
|
|
|
goto cleanup;
|
2014-03-17 15:19:44 +00:00
|
|
|
|
2012-08-22 16:29:01 +00:00
|
|
|
if (virCapabilitiesAddGuestDomain(guest,
|
2015-04-17 22:38:10 +00:00
|
|
|
VIR_DOMAIN_VIRT_QEMU,
|
2012-08-22 16:29:01 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
NULL) == NULL)
|
2014-03-17 15:19:45 +00:00
|
|
|
goto cleanup;
|
2010-12-16 15:07:07 +00:00
|
|
|
|
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
|
|
|
|
2017-03-02 17:57:51 +00:00
|
|
|
if ((ARCH_IS_X86(guestarch) || guestarch == VIR_ARCH_AARCH64) &&
|
|
|
|
virCapabilitiesAddGuestFeature(guest, "acpi", true, true) == NULL) {
|
|
|
|
goto cleanup;
|
2010-12-16 15:07:07 +00:00
|
|
|
}
|
|
|
|
|
2017-03-02 17:00:05 +00:00
|
|
|
if (ARCH_IS_X86(guestarch) &&
|
2017-03-02 17:57:51 +00:00
|
|
|
virCapabilitiesAddGuestFeature(guest, "apic", true, false) == NULL) {
|
2014-03-17 15:19:45 +00:00
|
|
|
goto cleanup;
|
2017-03-02 17:57:51 +00:00
|
|
|
}
|
2012-08-22 16:59:39 +00:00
|
|
|
|
2012-12-10 22:28:09 +00:00
|
|
|
if ((guestarch == VIR_ARCH_I686) &&
|
2014-07-14 12:56:13 +00:00
|
|
|
(virCapabilitiesAddGuestFeature(guest, "pae", true, false) == NULL ||
|
|
|
|
virCapabilitiesAddGuestFeature(guest, "nonpae", true, false) == NULL))
|
2014-03-17 15:19:45 +00:00
|
|
|
goto cleanup;
|
2010-12-16 15:07:07 +00:00
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
|
2014-03-25 06:49:44 +00:00
|
|
|
cleanup:
|
2010-12-16 15:07:07 +00:00
|
|
|
|
|
|
|
virCapabilitiesFreeMachines(machines, nmachines);
|
|
|
|
|
2014-03-17 15:19:45 +00:00
|
|
|
return ret;
|
2010-12-16 15:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-03-08 12:32:46 +00:00
|
|
|
virCPUDefPtr
|
2017-07-21 13:09:54 +00:00
|
|
|
virQEMUCapsProbeHostCPUForEmulator(virArch hostArch,
|
2017-03-08 12:32:46 +00:00
|
|
|
virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainVirtType type)
|
|
|
|
{
|
2017-09-22 13:51:33 +00:00
|
|
|
return virCPUGetHost(hostArch, VIR_CPU_TYPE_GUEST, NULL,
|
|
|
|
virQEMUCapsGetCPUDefinitions(qemuCaps, type));
|
2017-03-08 12:32:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-19 15:01:56 +00:00
|
|
|
virCapsPtr
|
|
|
|
virQEMUCapsInit(virFileCachePtr cache)
|
2010-12-16 15:07:07 +00:00
|
|
|
{
|
|
|
|
virCapsPtr caps;
|
Convert 'int i' to 'size_t i' in src/qemu files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 14:09:33 +00:00
|
|
|
size_t i;
|
2013-04-08 12:33:07 +00:00
|
|
|
virArch hostarch = virArchFromHost();
|
2012-12-10 22:28:09 +00:00
|
|
|
|
2013-04-08 12:33:07 +00:00
|
|
|
if ((caps = virCapabilitiesNew(hostarch,
|
2014-07-14 12:56:13 +00:00
|
|
|
true, true)) == NULL)
|
2012-08-22 16:59:39 +00:00
|
|
|
goto error;
|
2010-12-16 15:07:07 +00:00
|
|
|
|
2018-12-04 17:08:14 +00:00
|
|
|
/* Some machines have problematic NUMA topology causing
|
2010-12-16 15:07:07 +00:00
|
|
|
* unexpected failures. We don't want to break the QEMU
|
|
|
|
* driver in this scenario, so log errors & carry on
|
|
|
|
*/
|
2017-03-07 09:40:15 +00:00
|
|
|
if (virCapabilitiesInitNUMA(caps) < 0) {
|
2010-12-16 15:07:07 +00:00
|
|
|
virCapabilitiesFreeNUMAInfo(caps);
|
2011-05-09 09:24:09 +00:00
|
|
|
VIR_WARN("Failed to query host NUMA topology, disabling NUMA capabilities");
|
2010-12-16 15:07:07 +00:00
|
|
|
}
|
|
|
|
|
2017-03-29 13:52:31 +00:00
|
|
|
if (virCapabilitiesInitCaches(caps) < 0)
|
|
|
|
VIR_WARN("Failed to get host CPU cache info");
|
|
|
|
|
2017-03-15 08:07:38 +00:00
|
|
|
if (!(caps->host.cpu = virCPUProbeHost(caps->host.arch)))
|
2012-08-22 13:37:05 +00:00
|
|
|
VIR_WARN("Failed to get host CPU");
|
2010-12-16 15:07:07 +00:00
|
|
|
|
2011-11-22 03:31:22 +00:00
|
|
|
/* Add the power management features of the host */
|
2011-11-29 14:50:04 +00:00
|
|
|
if (virNodeSuspendGetTargetMask(&caps->host.powerMgmt) < 0)
|
2011-11-22 03:31:22 +00:00
|
|
|
VIR_WARN("Failed to get host power management capabilities");
|
|
|
|
|
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 },
|
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 },
|
2012-09-13 17:04:24 +00:00
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVirtioBalloon[] = {
|
2016-01-08 10:45:06 +00:00
|
|
|
{ "deflate-on-oom", QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE },
|
2018-03-06 13:44:49 +00:00
|
|
|
{ "disable-legacy", QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY },
|
|
|
|
{ "iommu_platform", QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM },
|
|
|
|
{ "ats", QEMU_CAPS_VIRTIO_PCI_ATS },
|
2016-01-08 10:45:06 +00:00
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVirtioBlk[] = {
|
2012-09-13 17:04:24 +00:00
|
|
|
{ "ioeventfd", QEMU_CAPS_VIRTIO_IOEVENTFD },
|
|
|
|
{ "event_idx", QEMU_CAPS_VIRTIO_BLK_EVENT_IDX },
|
|
|
|
{ "scsi", QEMU_CAPS_VIRTIO_BLK_SCSI },
|
|
|
|
{ "logical_block_size", QEMU_CAPS_BLOCKIO },
|
2017-09-30 17:15:35 +00:00
|
|
|
{ "num-queues", QEMU_CAPS_VIRTIO_BLK_NUM_QUEUES },
|
2017-11-15 14:02:58 +00:00
|
|
|
{ "share-rw", QEMU_CAPS_DISK_SHARE_RW },
|
2018-03-06 13:44:49 +00:00
|
|
|
{ "disable-legacy", QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY },
|
|
|
|
{ "iommu_platform", QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM },
|
|
|
|
{ "ats", QEMU_CAPS_VIRTIO_PCI_ATS },
|
2018-04-03 17:11:22 +00:00
|
|
|
{ "write-cache", QEMU_CAPS_DISK_WRITE_CACHE },
|
2012-09-13 17:04:24 +00:00
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVirtioNet[] = {
|
2012-09-13 17:04:24 +00:00
|
|
|
{ "tx", QEMU_CAPS_VIRTIO_TX_ALG },
|
|
|
|
{ "event_idx", QEMU_CAPS_VIRTIO_NET_EVENT_IDX },
|
2016-08-19 06:39:08 +00:00
|
|
|
{ "rx_queue_size", QEMU_CAPS_VIRTIO_NET_RX_QUEUE_SIZE },
|
2017-07-12 12:19:26 +00:00
|
|
|
{ "tx_queue_size", QEMU_CAPS_VIRTIO_NET_TX_QUEUE_SIZE },
|
2017-01-23 13:33:20 +00:00
|
|
|
{ "host_mtu", QEMU_CAPS_VIRTIO_NET_HOST_MTU },
|
2018-03-06 13:44:49 +00:00
|
|
|
{ "disable-legacy", QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY },
|
|
|
|
{ "iommu_platform", QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM },
|
|
|
|
{ "ats", QEMU_CAPS_VIRTIO_PCI_ATS },
|
2012-09-13 17:04:24 +00:00
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsSpaprPCIHostBridge[] = {
|
2017-07-21 08:02:32 +00:00
|
|
|
{ "numa_node", QEMU_CAPS_SPAPR_PCI_HOST_BRIDGE_NUMA_NODE },
|
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVirtioSCSI[] = {
|
2016-04-20 18:43:04 +00:00
|
|
|
{ "iothread", QEMU_CAPS_VIRTIO_SCSI_IOTHREAD },
|
2018-03-06 13:44:49 +00:00
|
|
|
{ "disable-legacy", QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY },
|
|
|
|
{ "iommu_platform", QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM },
|
|
|
|
{ "ats", QEMU_CAPS_VIRTIO_PCI_ATS },
|
2016-04-20 18:43:04 +00:00
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVfioPCI[] = {
|
2018-05-24 15:27:33 +00:00
|
|
|
{ "display", QEMU_CAPS_VFIO_PCI_DISPLAY },
|
2013-04-17 18:16:28 +00:00
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsSCSIDisk[] = {
|
2012-09-13 17:04:24 +00:00
|
|
|
{ "channel", QEMU_CAPS_SCSI_DISK_CHANNEL },
|
|
|
|
{ "wwn", QEMU_CAPS_SCSI_DISK_WWN },
|
2017-11-15 14:02:58 +00:00
|
|
|
{ "share-rw", QEMU_CAPS_DISK_SHARE_RW },
|
2018-04-03 17:11:22 +00:00
|
|
|
{ "write-cache", QEMU_CAPS_DISK_WRITE_CACHE },
|
2019-01-28 08:30:41 +00:00
|
|
|
{ "device_id", QEMU_CAPS_SCSI_DISK_DEVICE_ID },
|
2012-09-13 17:04:24 +00:00
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsIDEDrive[] = {
|
2012-09-13 17:04:24 +00:00
|
|
|
{ "wwn", QEMU_CAPS_IDE_DRIVE_WWN },
|
2017-11-15 14:02:58 +00:00
|
|
|
{ "share-rw", QEMU_CAPS_DISK_SHARE_RW },
|
2018-04-03 17:11:22 +00:00
|
|
|
{ "write-cache", QEMU_CAPS_DISK_WRITE_CACHE },
|
2012-09-13 17:04:24 +00:00
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsPiix4PM[] = {
|
2016-01-04 22:57:06 +00:00
|
|
|
{ "disable_s3", QEMU_CAPS_PIIX_DISABLE_S3 },
|
|
|
|
{ "disable_s4", QEMU_CAPS_PIIX_DISABLE_S4 },
|
2012-09-13 17:04:24 +00:00
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsUSBRedir[] = {
|
2012-09-13 17:04:24 +00:00
|
|
|
{ "filter", QEMU_CAPS_USB_REDIR_FILTER },
|
2012-11-14 14:51:30 +00:00
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsI440FXPCIHost[] = {
|
2013-08-12 11:48:34 +00:00
|
|
|
{ "pci-hole64-size", QEMU_CAPS_I440FX_PCI_HOLE64_SIZE },
|
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsQ35PCIHost[] = {
|
2013-08-12 11:48:34 +00:00
|
|
|
{ "pci-hole64-size", QEMU_CAPS_Q35_PCI_HOLE64_SIZE },
|
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsUSBStorage[] = {
|
2013-08-23 10:38:11 +00:00
|
|
|
{ "removable", QEMU_CAPS_USB_STORAGE_REMOVABLE },
|
2017-11-15 14:02:58 +00:00
|
|
|
{ "share-rw", QEMU_CAPS_DISK_SHARE_RW },
|
2018-04-03 17:11:22 +00:00
|
|
|
{ "write-cache", QEMU_CAPS_DISK_WRITE_CACHE },
|
2018-07-09 14:35:02 +00:00
|
|
|
{ "werror", QEMU_CAPS_USB_STORAGE_WERROR },
|
2013-08-23 10:38:11 +00:00
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsKVMPit[] = {
|
2013-07-01 16:28:50 +00:00
|
|
|
{ "lost_tick_policy", QEMU_CAPS_KVM_PIT_TICK_POLICY },
|
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVGA[] = {
|
2014-11-12 12:58:33 +00:00
|
|
|
{ "vgamem_mb", QEMU_CAPS_VGA_VGAMEM },
|
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVmwareSvga[] = {
|
2014-11-12 12:58:33 +00:00
|
|
|
{ "vgamem_mb", QEMU_CAPS_VMWARE_SVGA_VGAMEM },
|
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsQxl[] = {
|
2014-11-12 12:58:33 +00:00
|
|
|
{ "vgamem_mb", QEMU_CAPS_QXL_VGAMEM },
|
2016-03-01 12:46:37 +00:00
|
|
|
{ "vram64_size_mb", QEMU_CAPS_QXL_VRAM64 },
|
2015-12-11 13:26:24 +00:00
|
|
|
{ "max_outputs", QEMU_CAPS_QXL_MAX_OUTPUTS },
|
2014-11-12 12:58:33 +00:00
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVirtioGpu[] = {
|
2016-10-11 12:06:53 +00:00
|
|
|
{ "virgl", QEMU_CAPS_VIRTIO_GPU_VIRGL },
|
2017-08-23 12:06:17 +00:00
|
|
|
{ "max_outputs", QEMU_CAPS_VIRTIO_GPU_MAX_OUTPUTS },
|
2018-03-06 13:44:49 +00:00
|
|
|
{ "disable-legacy", QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY },
|
|
|
|
{ "iommu_platform", QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM },
|
|
|
|
{ "ats", QEMU_CAPS_VIRTIO_PCI_ATS },
|
2015-11-25 08:42:33 +00:00
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsICH9[] = {
|
2016-01-09 20:58:50 +00:00
|
|
|
{ "disable_s3", QEMU_CAPS_ICH9_DISABLE_S3 },
|
|
|
|
{ "disable_s4", QEMU_CAPS_ICH9_DISABLE_S4 },
|
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsUSBNECXHCI[] = {
|
2016-04-24 14:52:38 +00:00
|
|
|
{ "p3", QEMU_CAPS_NEC_USB_XHCI_PORTS },
|
|
|
|
};
|
|
|
|
|
2018-04-12 11:31:03 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsIntelIOMMU[] = {
|
2017-05-03 13:23:12 +00:00
|
|
|
{ "intremap", QEMU_CAPS_INTEL_IOMMU_INTREMAP },
|
2017-03-17 07:28:04 +00:00
|
|
|
{ "caching-mode", QEMU_CAPS_INTEL_IOMMU_CACHING_MODE },
|
2017-05-18 08:48:03 +00:00
|
|
|
{ "eim", QEMU_CAPS_INTEL_IOMMU_EIM },
|
2017-05-03 15:18:47 +00:00
|
|
|
{ "device-iotlb", QEMU_CAPS_INTEL_IOMMU_DEVICE_IOTLB },
|
2017-05-03 13:23:12 +00:00
|
|
|
};
|
|
|
|
|
2018-05-07 14:41:12 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtualCSSBridge[] = {
|
|
|
|
{ "cssid-unrestricted", QEMU_CAPS_CCW_CSSID_UNRESTRICTED },
|
|
|
|
};
|
|
|
|
|
2018-05-10 21:27:57 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsMCH[] = {
|
|
|
|
{ "extended-tseg-mbytes", QEMU_CAPS_MCH_EXTENDED_TSEG_MBYTES },
|
|
|
|
};
|
|
|
|
|
2018-12-20 09:14:45 +00:00
|
|
|
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsNVDIMM[] = {
|
|
|
|
{ "unarmed", QEMU_CAPS_DEVICE_NVDIMM_UNARMED },
|
|
|
|
};
|
|
|
|
|
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 },
|
2016-10-19 12:40:53 +00:00
|
|
|
};
|
|
|
|
|
2018-04-12 12:39:43 +00:00
|
|
|
typedef struct _virQEMUCapsObjectTypeProps virQEMUCapsObjectTypeProps;
|
|
|
|
struct _virQEMUCapsObjectTypeProps {
|
2012-09-13 17:04:24 +00:00
|
|
|
const char *type;
|
2013-02-01 13:48:58 +00:00
|
|
|
struct virQEMUCapsStringFlags *props;
|
2012-09-13 17:04:24 +00:00
|
|
|
size_t nprops;
|
2017-03-20 15:08:48 +00:00
|
|
|
int capsCondition;
|
2012-09-13 17:04:24 +00:00
|
|
|
};
|
|
|
|
|
2018-04-12 12:39:43 +00:00
|
|
|
typedef int (*virQEMUCapsObjectTypePropsCB)(qemuMonitorPtr mon,
|
|
|
|
const char *type,
|
|
|
|
char ***props);
|
|
|
|
|
|
|
|
static virQEMUCapsObjectTypeProps virQEMUCapsDeviceProps[] = {
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "virtio-blk-pci", virQEMUCapsDevicePropsVirtioBlk,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioBlk),
|
2017-03-20 15:08:48 +00:00
|
|
|
-1 },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "virtio-net-pci", virQEMUCapsDevicePropsVirtioNet,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioNet),
|
2018-03-06 12:49:39 +00:00
|
|
|
QEMU_CAPS_DEVICE_VIRTIO_NET },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "virtio-scsi-pci", virQEMUCapsDevicePropsVirtioSCSI,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioSCSI),
|
2018-03-06 12:49:39 +00:00
|
|
|
QEMU_CAPS_VIRTIO_SCSI },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "virtio-blk-ccw", virQEMUCapsDevicePropsVirtioBlk,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioBlk),
|
2018-03-06 12:49:39 +00:00
|
|
|
QEMU_CAPS_VIRTIO_CCW },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "virtio-net-ccw", virQEMUCapsDevicePropsVirtioNet,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioNet),
|
2018-03-06 12:49:39 +00:00
|
|
|
QEMU_CAPS_DEVICE_VIRTIO_NET },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "virtio-scsi-ccw", virQEMUCapsDevicePropsVirtioSCSI,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioSCSI),
|
2018-03-06 12:49:39 +00:00
|
|
|
QEMU_CAPS_VIRTIO_SCSI },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "virtio-blk-s390", virQEMUCapsDevicePropsVirtioBlk,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioBlk),
|
2018-03-06 12:49:39 +00:00
|
|
|
QEMU_CAPS_VIRTIO_S390 },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "virtio-net-s390", virQEMUCapsDevicePropsVirtioNet,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioNet),
|
2018-03-06 12:49:39 +00:00
|
|
|
QEMU_CAPS_DEVICE_VIRTIO_NET },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "vfio-pci", virQEMUCapsDevicePropsVfioPCI,
|
|
|
|
ARRAY_CARDINALITY(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,
|
2018-04-12 11:31:03 +00:00
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsSCSIDisk),
|
2017-03-20 15:08:48 +00:00
|
|
|
-1 },
|
2019-01-28 13:52:22 +00:00
|
|
|
{ "ide-hd", virQEMUCapsDevicePropsIDEDrive,
|
2018-04-12 11:31:03 +00:00
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsIDEDrive),
|
2017-03-20 15:08:48 +00:00
|
|
|
-1 },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "PIIX4_PM", virQEMUCapsDevicePropsPiix4PM,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsPiix4PM),
|
2017-03-20 15:08:48 +00:00
|
|
|
-1 },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "usb-redir", virQEMUCapsDevicePropsUSBRedir,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsUSBRedir),
|
2018-03-06 12:49:39 +00:00
|
|
|
QEMU_CAPS_USB_REDIR },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "i440FX-pcihost", virQEMUCapsDevicePropsI440FXPCIHost,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsI440FXPCIHost),
|
2017-03-20 15:08:48 +00:00
|
|
|
-1 },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "q35-pcihost", virQEMUCapsDevicePropsQ35PCIHost,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsQ35PCIHost),
|
2017-03-20 15:08:48 +00:00
|
|
|
-1 },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "usb-storage", virQEMUCapsDevicePropsUSBStorage,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsUSBStorage),
|
2018-03-06 12:49:39 +00:00
|
|
|
QEMU_CAPS_DEVICE_USB_STORAGE },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "kvm-pit", virQEMUCapsDevicePropsKVMPit,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsKVMPit),
|
2017-03-20 15:08:48 +00:00
|
|
|
-1 },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "VGA", virQEMUCapsDevicePropsVGA,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVGA),
|
2018-03-06 12:49:39 +00:00
|
|
|
QEMU_CAPS_DEVICE_VGA },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "vmware-svga", virQEMUCapsDevicePropsVmwareSvga,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVmwareSvga),
|
2018-03-06 12:49:39 +00:00
|
|
|
QEMU_CAPS_DEVICE_VMWARE_SVGA },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "qxl", virQEMUCapsDevicePropsQxl,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsQxl),
|
2018-03-06 12:49:39 +00:00
|
|
|
QEMU_CAPS_DEVICE_QXL },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "virtio-gpu-pci", virQEMUCapsDevicePropsVirtioGpu,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioGpu),
|
2018-03-06 12:49:39 +00:00
|
|
|
QEMU_CAPS_DEVICE_VIRTIO_GPU },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "virtio-gpu-device", virQEMUCapsDevicePropsVirtioGpu,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioGpu),
|
2018-03-06 12:49:39 +00:00
|
|
|
QEMU_CAPS_DEVICE_VIRTIO_GPU },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "ICH9-LPC", virQEMUCapsDevicePropsICH9,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsICH9),
|
2017-03-20 15:08:48 +00:00
|
|
|
-1 },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "virtio-balloon-pci", virQEMUCapsDevicePropsVirtioBalloon,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioBalloon),
|
2017-03-20 15:08:48 +00:00
|
|
|
-1 },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "virtio-balloon-ccw", virQEMUCapsDevicePropsVirtioBalloon,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioBalloon),
|
2017-03-20 15:08:48 +00:00
|
|
|
-1 },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "virtio-balloon-device", virQEMUCapsDevicePropsVirtioBalloon,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioBalloon),
|
2017-03-20 15:08:48 +00:00
|
|
|
-1 },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "nec-usb-xhci", virQEMUCapsDevicePropsUSBNECXHCI,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsUSBNECXHCI),
|
2018-03-06 12:49:39 +00:00
|
|
|
QEMU_CAPS_NEC_USB_XHCI },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "intel-iommu", virQEMUCapsDevicePropsIntelIOMMU,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsIntelIOMMU),
|
2017-07-24 05:55:16 +00:00
|
|
|
QEMU_CAPS_DEVICE_INTEL_IOMMU },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "spapr-pci-host-bridge", virQEMUCapsDevicePropsSpaprPCIHostBridge,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsSpaprPCIHostBridge),
|
2017-07-21 08:02:32 +00:00
|
|
|
QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE },
|
2018-04-12 11:31:03 +00:00
|
|
|
{ "virtio-gpu-ccw", virQEMUCapsDevicePropsVirtioGpu,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioGpu),
|
2018-03-23 17:22:38 +00:00
|
|
|
QEMU_CAPS_DEVICE_VIRTIO_GPU_CCW },
|
2018-05-07 14:41:12 +00:00
|
|
|
{ "virtual-css-bridge", virQEMUCapsObjectPropsVirtualCSSBridge,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtualCSSBridge),
|
|
|
|
QEMU_CAPS_CCW },
|
2018-05-10 21:27:57 +00:00
|
|
|
{ "mch", virQEMUCapsDevicePropsMCH,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsMCH),
|
|
|
|
QEMU_CAPS_DEVICE_MCH },
|
2018-12-20 09:14:45 +00:00
|
|
|
{ "nvdimm", virQEMUCapsDevicePropsNVDIMM,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDevicePropsNVDIMM),
|
|
|
|
QEMU_CAPS_DEVICE_NVDIMM },
|
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 },
|
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 },
|
|
|
|
};
|
|
|
|
|
2018-04-20 08:25:49 +00:00
|
|
|
static virQEMUCapsObjectTypeProps virQEMUCapsObjectProps[] = {
|
|
|
|
{ "memory-backend-file", virQEMUCapsObjectPropsMemoryBackendFile,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsObjectPropsMemoryBackendFile),
|
|
|
|
QEMU_CAPS_OBJECT_MEMORY_FILE },
|
2018-11-15 11:55:52 +00:00
|
|
|
{ "memory-backend-memfd", virQEMUCapsObjectPropsMemoryBackendMemfd,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsObjectPropsMemoryBackendMemfd),
|
|
|
|
QEMU_CAPS_OBJECT_MEMORY_MEMFD },
|
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 },
|
|
|
|
};
|
|
|
|
|
|
|
|
static virQEMUCapsObjectTypeProps virQEMUCapsMachineProps[] = {
|
2019-05-16 08:34:01 +00:00
|
|
|
{ "pseries", virQEMUCapsMachinePropsPSeries,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsMachinePropsPSeries),
|
2018-06-19 11:51:05 +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
|
|
|
|
|
|
|
|
2012-08-20 16:44:14 +00:00
|
|
|
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsPtr
|
|
|
|
virQEMUCapsNew(void)
|
2011-02-08 14:22:39 +00:00
|
|
|
{
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsPtr qemuCaps;
|
2011-02-08 14:22:39 +00:00
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
if (virQEMUCapsInitialize() < 0)
|
2012-08-20 16:44:14 +00:00
|
|
|
return NULL;
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
if (!(qemuCaps = virObjectNew(virQEMUCapsClass)))
|
2012-08-20 16:44:14 +00:00
|
|
|
return NULL;
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
if (!(qemuCaps->flags = virBitmapNew(QEMU_CAPS_LAST)))
|
2013-07-04 10:14:12 +00:00
|
|
|
goto error;
|
2011-02-08 14:22:39 +00:00
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
return qemuCaps;
|
2012-08-20 16:44:14 +00:00
|
|
|
|
2014-03-25 06:49:44 +00:00
|
|
|
error:
|
2013-02-01 13:48:58 +00:00
|
|
|
virObjectUnref(qemuCaps);
|
2012-08-20 16:44:14 +00:00
|
|
|
return NULL;
|
2011-02-08 14:22:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-04-07 15:40:31 +00:00
|
|
|
static int
|
2017-04-07 16:15:26 +00:00
|
|
|
virQEMUCapsHostCPUDataCopy(virQEMUCapsHostCPUDataPtr dst,
|
|
|
|
virQEMUCapsHostCPUDataPtr src)
|
2017-04-07 15:40:31 +00:00
|
|
|
{
|
2017-04-07 16:15:26 +00:00
|
|
|
if (src->info &&
|
|
|
|
!(dst->info = qemuMonitorCPUModelInfoCopy(src->info)))
|
2017-04-07 15:40:31 +00:00
|
|
|
return -1;
|
|
|
|
|
2017-04-07 16:15:26 +00:00
|
|
|
if (src->reported &&
|
|
|
|
!(dst->reported = virCPUDefCopy(src->reported)))
|
2017-04-07 15:40:31 +00:00
|
|
|
return -1;
|
|
|
|
|
2017-03-29 13:31:17 +00:00
|
|
|
if (src->migratable &&
|
|
|
|
!(dst->migratable = virCPUDefCopy(src->migratable)))
|
|
|
|
return -1;
|
|
|
|
|
2017-04-11 18:46:05 +00:00
|
|
|
if (src->full &&
|
|
|
|
!(dst->full = virCPUDefCopy(src->full)))
|
|
|
|
return -1;
|
|
|
|
|
2017-04-07 15:40:31 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-04-07 15:43:59 +00:00
|
|
|
static void
|
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)
|
|
|
|
{
|
|
|
|
VIR_AUTOPTR(virSEVCapability) tmp = NULL;
|
|
|
|
|
|
|
|
if (VIR_ALLOC(tmp) < 0 ||
|
|
|
|
VIR_STRDUP(tmp->pdh, src->pdh) < 0 ||
|
|
|
|
VIR_STRDUP(tmp->cert_chain, src->cert_chain) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
tmp->cbitpos = src->cbitpos;
|
|
|
|
tmp->reduced_phys_bits = src->reduced_phys_bits;
|
|
|
|
|
|
|
|
VIR_STEAL_PTR(*dst, tmp);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsPtr virQEMUCapsNewCopy(virQEMUCapsPtr qemuCaps)
|
2012-09-11 12:42:20 +00:00
|
|
|
{
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsPtr ret = virQEMUCapsNew();
|
2012-09-11 12:42:20 +00:00
|
|
|
size_t i;
|
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
return NULL;
|
|
|
|
|
2016-08-04 14:45:53 +00:00
|
|
|
ret->usedQMP = qemuCaps->usedQMP;
|
2018-11-12 19:58:09 +00:00
|
|
|
ret->kvmSupportsNesting = qemuCaps->kvmSupportsNesting;
|
2016-08-04 14:45:53 +00:00
|
|
|
|
2016-08-04 14:48:40 +00:00
|
|
|
if (VIR_STRDUP(ret->binary, qemuCaps->binary) < 0)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
ret->ctime = qemuCaps->ctime;
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
virBitmapCopy(ret->flags, qemuCaps->flags);
|
2012-09-11 12:42:20 +00:00
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
ret->version = qemuCaps->version;
|
|
|
|
ret->kvmVersion = qemuCaps->kvmVersion;
|
2017-12-12 15:23:41 +00:00
|
|
|
ret->microcodeVersion = qemuCaps->microcodeVersion;
|
2015-02-02 10:28:30 +00:00
|
|
|
|
|
|
|
if (VIR_STRDUP(ret->package, qemuCaps->package) < 0)
|
|
|
|
goto error;
|
|
|
|
|
2018-01-22 10:37:04 +00:00
|
|
|
if (VIR_STRDUP(ret->kernelVersion, qemuCaps->kernelVersion) < 0)
|
|
|
|
goto error;
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
ret->arch = qemuCaps->arch;
|
2012-09-11 12:42:20 +00:00
|
|
|
|
2016-11-14 16:21:30 +00:00
|
|
|
if (qemuCaps->kvmCPUModels) {
|
|
|
|
ret->kvmCPUModels = virDomainCapsCPUModelsCopy(qemuCaps->kvmCPUModels);
|
|
|
|
if (!ret->kvmCPUModels)
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (qemuCaps->tcgCPUModels) {
|
|
|
|
ret->tcgCPUModels = virDomainCapsCPUModelsCopy(qemuCaps->tcgCPUModels);
|
|
|
|
if (!ret->tcgCPUModels)
|
2013-05-20 09:23:13 +00:00
|
|
|
goto error;
|
2012-09-11 12:42:20 +00:00
|
|
|
}
|
|
|
|
|
2017-04-07 16:15:26 +00:00
|
|
|
if (virQEMUCapsHostCPUDataCopy(&ret->kvmCPU, &qemuCaps->kvmCPU) < 0 ||
|
|
|
|
virQEMUCapsHostCPUDataCopy(&ret->tcgCPU, &qemuCaps->tcgCPU) < 0)
|
2017-01-06 07:52:22 +00:00
|
|
|
goto error;
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
if (VIR_ALLOC_N(ret->machineTypes, qemuCaps->nmachineTypes) < 0)
|
2013-07-04 10:14:12 +00:00
|
|
|
goto error;
|
2013-02-01 13:48:58 +00:00
|
|
|
ret->nmachineTypes = qemuCaps->nmachineTypes;
|
2013-05-21 07:21:20 +00:00
|
|
|
for (i = 0; i < qemuCaps->nmachineTypes; i++) {
|
2016-07-29 08:13:46 +00:00
|
|
|
if (VIR_STRDUP(ret->machineTypes[i].name, qemuCaps->machineTypes[i].name) < 0 ||
|
|
|
|
VIR_STRDUP(ret->machineTypes[i].alias, qemuCaps->machineTypes[i].alias) < 0)
|
2013-05-20 09:23:13 +00:00
|
|
|
goto error;
|
2016-07-29 08:13:46 +00:00
|
|
|
ret->machineTypes[i].maxCpus = qemuCaps->machineTypes[i].maxCpus;
|
2016-07-29 07:45:19 +00:00
|
|
|
ret->machineTypes[i].hotplugCpus = qemuCaps->machineTypes[i].hotplugCpus;
|
2018-08-10 12:18:27 +00:00
|
|
|
ret->machineTypes[i].qemuDefault = qemuCaps->machineTypes[i].qemuDefault;
|
|
|
|
|
2012-09-11 12:42:20 +00:00
|
|
|
}
|
|
|
|
|
2016-08-04 14:48:40 +00:00
|
|
|
if (VIR_ALLOC_N(ret->gicCapabilities, qemuCaps->ngicCapabilities) < 0)
|
|
|
|
goto error;
|
|
|
|
ret->ngicCapabilities = qemuCaps->ngicCapabilities;
|
|
|
|
for (i = 0; i < qemuCaps->ngicCapabilities; i++)
|
|
|
|
ret->gicCapabilities[i] = qemuCaps->gicCapabilities[i];
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
void virQEMUCapsDispose(void *obj)
|
2012-08-20 16:44:14 +00:00
|
|
|
{
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsPtr qemuCaps = obj;
|
2012-08-22 10:11:28 +00:00
|
|
|
size_t i;
|
|
|
|
|
2013-05-21 07:21:20 +00:00
|
|
|
for (i = 0; i < qemuCaps->nmachineTypes; i++) {
|
2016-07-29 08:13:46 +00:00
|
|
|
VIR_FREE(qemuCaps->machineTypes[i].name);
|
|
|
|
VIR_FREE(qemuCaps->machineTypes[i].alias);
|
2012-08-22 10:11:28 +00:00
|
|
|
}
|
2013-02-01 13:48:58 +00:00
|
|
|
VIR_FREE(qemuCaps->machineTypes);
|
2012-08-22 10:11:28 +00:00
|
|
|
|
2016-11-14 16:21:30 +00:00
|
|
|
virObjectUnref(qemuCaps->kvmCPUModels);
|
|
|
|
virObjectUnref(qemuCaps->tcgCPUModels);
|
2012-08-20 16:44:14 +00:00
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
virBitmapFree(qemuCaps->flags);
|
2012-09-10 10:47:56 +00:00
|
|
|
|
2015-02-02 10:28:30 +00:00
|
|
|
VIR_FREE(qemuCaps->package);
|
2018-01-22 10:37:04 +00:00
|
|
|
VIR_FREE(qemuCaps->kernelVersion);
|
2013-02-01 13:48:58 +00:00
|
|
|
VIR_FREE(qemuCaps->binary);
|
2016-03-08 17:24:18 +00:00
|
|
|
|
|
|
|
VIR_FREE(qemuCaps->gicCapabilities);
|
2016-06-15 12:35:18 +00:00
|
|
|
|
2018-09-08 23:26:36 +00:00
|
|
|
virSEVCapabilitiesFree(qemuCaps->sevCapabilities);
|
|
|
|
|
2017-04-07 16:15:26 +00:00
|
|
|
virQEMUCapsHostCPUDataClear(&qemuCaps->kvmCPU);
|
|
|
|
virQEMUCapsHostCPUDataClear(&qemuCaps->tcgCPU);
|
2012-08-20 16:44:14 +00:00
|
|
|
}
|
|
|
|
|
2011-02-08 14:08:12 +00:00
|
|
|
void
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsSet(virQEMUCapsPtr qemuCaps,
|
2014-06-15 16:32:56 +00:00
|
|
|
virQEMUCapsFlags flag)
|
2011-02-08 14:08:12 +00:00
|
|
|
{
|
2013-02-01 13:48:58 +00:00
|
|
|
ignore_value(virBitmapSetBit(qemuCaps->flags, flag));
|
2011-02-08 14:22:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
char *virQEMUCapsFlagsString(virQEMUCapsPtr qemuCaps)
|
2012-08-20 16:44:14 +00:00
|
|
|
{
|
2017-08-23 07:09:17 +00:00
|
|
|
return virBitmapToString(qemuCaps->flags, true, false);
|
2011-02-08 14:08:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsGet(virQEMUCapsPtr qemuCaps,
|
2014-06-15 16:32:56 +00:00
|
|
|
virQEMUCapsFlags flag)
|
2011-02-08 14:08:12 +00:00
|
|
|
{
|
2015-03-11 15:41:57 +00:00
|
|
|
return qemuCaps && virBitmapIsBitSet(qemuCaps->flags, flag);
|
2011-02-08 14:08:12 +00:00
|
|
|
}
|
2012-08-22 10:11:28 +00:00
|
|
|
|
|
|
|
|
2014-04-23 15:35:37 +00:00
|
|
|
bool virQEMUCapsHasPCIMultiBus(virQEMUCapsPtr qemuCaps,
|
2017-11-15 14:17:39 +00:00
|
|
|
const virDomainDef *def)
|
2014-04-23 15:35:37 +00:00
|
|
|
{
|
2017-03-02 14:40:29 +00:00
|
|
|
/* x86_64 and i686 support PCI-multibus on all machine types
|
|
|
|
* since forever */
|
2017-11-29 13:51:22 +00:00
|
|
|
if (ARCH_IS_X86(def->os.arch))
|
2014-04-23 15:35:37 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
if (def->os.arch == VIR_ARCH_PPC ||
|
2014-11-04 17:21:26 +00:00
|
|
|
ARCH_IS_PPC64(def->os.arch)) {
|
2014-04-23 15:35:37 +00:00
|
|
|
/*
|
|
|
|
* Usage of pci.0 naming:
|
|
|
|
*
|
|
|
|
* ref405ep: no pci
|
|
|
|
* taihu: no pci
|
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;
|
2016-11-14 16:21:30 +00:00
|
|
|
virDomainCapsCPUModelsPtr cpus = NULL;
|
2013-05-20 09:23:13 +00:00
|
|
|
|
2016-11-14 16:21:30 +00:00
|
|
|
if (type == VIR_DOMAIN_VIRT_KVM && qemuCaps->kvmCPUModels)
|
|
|
|
cpus = qemuCaps->kvmCPUModels;
|
|
|
|
else if (type == VIR_DOMAIN_VIRT_QEMU && qemuCaps->tcgCPUModels)
|
|
|
|
cpus = qemuCaps->tcgCPUModels;
|
|
|
|
|
|
|
|
if (!cpus) {
|
|
|
|
if (!(cpus = virDomainCapsCPUModelsNew(count)))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (type == VIR_DOMAIN_VIRT_KVM)
|
|
|
|
qemuCaps->kvmCPUModels = cpus;
|
|
|
|
else
|
|
|
|
qemuCaps->tcgCPUModels = cpus;
|
|
|
|
}
|
2016-04-21 10:51:01 +00:00
|
|
|
|
|
|
|
for (i = 0; i < count; i++) {
|
2017-09-19 16:35:08 +00:00
|
|
|
if (virDomainCapsCPUModelsAdd(cpus, name[i], -1, usable, NULL) < 0)
|
2016-04-21 10:51:01 +00:00
|
|
|
return -1;
|
2012-08-22 15:28:55 +00:00
|
|
|
}
|
2016-04-21 10:51:01 +00:00
|
|
|
|
2012-08-22 15:28:55 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-22 13:51:33 +00:00
|
|
|
virDomainCapsCPUModelsPtr
|
2016-04-21 10:51:01 +00:00
|
|
|
virQEMUCapsGetCPUDefinitions(virQEMUCapsPtr qemuCaps,
|
2017-09-22 13:51:33 +00:00
|
|
|
virDomainVirtType type)
|
2012-08-22 10:11:28 +00:00
|
|
|
{
|
2016-11-14 16:21:30 +00:00
|
|
|
if (type == VIR_DOMAIN_VIRT_KVM)
|
2017-09-22 13:51:33 +00:00
|
|
|
return qemuCaps->kvmCPUModels;
|
2016-11-14 16:21:30 +00:00
|
|
|
else
|
2017-09-22 13:51:33 +00:00
|
|
|
return qemuCaps->tcgCPUModels;
|
2012-08-22 10:11:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-04-07 16:15:26 +00:00
|
|
|
static virQEMUCapsHostCPUDataPtr
|
|
|
|
virQEMUCapsGetHostCPUData(virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainVirtType type)
|
|
|
|
{
|
|
|
|
if (type == VIR_DOMAIN_VIRT_KVM)
|
|
|
|
return &qemuCaps->kvmCPU;
|
|
|
|
else
|
|
|
|
return &qemuCaps->tcgCPU;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-06-22 10:34:07 +00:00
|
|
|
virCPUDefPtr
|
2017-02-22 15:51:50 +00:00
|
|
|
virQEMUCapsGetHostModel(virQEMUCapsPtr qemuCaps,
|
2017-04-11 09:14:30 +00:00
|
|
|
virDomainVirtType type,
|
|
|
|
virQEMUCapsHostCPUType cpuType)
|
2016-06-22 10:34:07 +00:00
|
|
|
{
|
2017-04-07 16:15:26 +00:00
|
|
|
virQEMUCapsHostCPUDataPtr cpuData = virQEMUCapsGetHostCPUData(qemuCaps, type);
|
|
|
|
|
2017-04-11 09:14:30 +00:00
|
|
|
switch (cpuType) {
|
|
|
|
case VIR_QEMU_CAPS_HOST_CPU_REPORTED:
|
|
|
|
return cpuData->reported;
|
2017-03-29 13:31:17 +00:00
|
|
|
|
|
|
|
case VIR_QEMU_CAPS_HOST_CPU_MIGRATABLE:
|
|
|
|
return cpuData->migratable;
|
2017-04-11 18:46:05 +00:00
|
|
|
|
|
|
|
case VIR_QEMU_CAPS_HOST_CPU_FULL:
|
|
|
|
/* 'full' is non-NULL only if we have data from both QEMU and
|
|
|
|
* virCPUGetHost */
|
|
|
|
return cpuData->full ? cpuData->full : cpuData->reported;
|
2017-04-11 09:14:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
2016-06-22 10:34:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-04-07 15:03:38 +00:00
|
|
|
static void
|
|
|
|
virQEMUCapsSetHostModel(virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainVirtType type,
|
2017-03-29 13:31:17 +00:00
|
|
|
virCPUDefPtr reported,
|
2017-04-11 18:46:05 +00:00
|
|
|
virCPUDefPtr migratable,
|
|
|
|
virCPUDefPtr full)
|
2017-04-07 15:03:38 +00:00
|
|
|
{
|
2017-04-07 16:15:26 +00:00
|
|
|
virQEMUCapsHostCPUDataPtr cpuData = virQEMUCapsGetHostCPUData(qemuCaps, type);
|
|
|
|
|
2017-03-29 13:31:17 +00:00
|
|
|
cpuData->reported = reported;
|
|
|
|
cpuData->migratable = migratable;
|
2017-04-11 18:46:05 +00:00
|
|
|
cpuData->full = full;
|
2017-04-07 15:03:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-03 14:22:30 +00:00
|
|
|
bool
|
|
|
|
virQEMUCapsIsCPUModeSupported(virQEMUCapsPtr qemuCaps,
|
|
|
|
virCapsPtr caps,
|
|
|
|
virDomainVirtType type,
|
|
|
|
virCPUMode mode)
|
|
|
|
{
|
2016-11-14 16:21:30 +00:00
|
|
|
virDomainCapsCPUModelsPtr cpus;
|
|
|
|
|
2016-08-03 14:22:30 +00:00
|
|
|
switch (mode) {
|
|
|
|
case VIR_CPU_MODE_HOST_PASSTHROUGH:
|
|
|
|
return type == VIR_DOMAIN_VIRT_KVM &&
|
|
|
|
virQEMUCapsGuestIsNative(caps->host.arch, qemuCaps->arch);
|
|
|
|
|
|
|
|
case VIR_CPU_MODE_HOST_MODEL:
|
2017-04-11 09:14:30 +00:00
|
|
|
return !!virQEMUCapsGetHostModel(qemuCaps, type,
|
|
|
|
VIR_QEMU_CAPS_HOST_CPU_REPORTED);
|
2016-08-03 14:22:30 +00:00
|
|
|
|
|
|
|
case VIR_CPU_MODE_CUSTOM:
|
2016-11-14 16:21:30 +00:00
|
|
|
if (type == VIR_DOMAIN_VIRT_KVM)
|
|
|
|
cpus = qemuCaps->kvmCPUModels;
|
|
|
|
else
|
|
|
|
cpus = qemuCaps->tcgCPUModels;
|
|
|
|
return cpus && cpus->nmodels > 0;
|
2016-08-03 14:22:30 +00:00
|
|
|
|
|
|
|
case VIR_CPU_MODE_LAST:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
int virQEMUCapsGetMachineTypesCaps(virQEMUCapsPtr qemuCaps,
|
|
|
|
size_t *nmachines,
|
|
|
|
virCapsGuestMachinePtr **machines)
|
2012-08-22 13:37:05 +00:00
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
*machines = NULL;
|
2013-02-01 13:48:58 +00:00
|
|
|
*nmachines = qemuCaps->nmachineTypes;
|
2012-08-22 13:37:05 +00:00
|
|
|
|
2014-03-27 11:38:56 +00:00
|
|
|
if (*nmachines &&
|
|
|
|
VIR_ALLOC_N(*machines, qemuCaps->nmachineTypes) < 0)
|
|
|
|
goto error;
|
|
|
|
|
2013-05-21 07:21:20 +00:00
|
|
|
for (i = 0; i < qemuCaps->nmachineTypes; i++) {
|
2012-08-22 13:37:05 +00:00
|
|
|
virCapsGuestMachinePtr mach;
|
|
|
|
if (VIR_ALLOC(mach) < 0)
|
2013-05-20 09:23:13 +00:00
|
|
|
goto error;
|
2014-08-27 18:57:08 +00:00
|
|
|
(*machines)[i] = mach;
|
2016-07-29 08:13:46 +00:00
|
|
|
if (qemuCaps->machineTypes[i].alias) {
|
|
|
|
if (VIR_STRDUP(mach->name, qemuCaps->machineTypes[i].alias) < 0 ||
|
|
|
|
VIR_STRDUP(mach->canonical, qemuCaps->machineTypes[i].name) < 0)
|
2013-05-20 09:23:13 +00:00
|
|
|
goto error;
|
2012-08-22 13:37:05 +00:00
|
|
|
} else {
|
2016-07-29 08:13:46 +00:00
|
|
|
if (VIR_STRDUP(mach->name, qemuCaps->machineTypes[i].name) < 0)
|
2013-05-20 09:23:13 +00:00
|
|
|
goto error;
|
2012-08-22 13:37:05 +00:00
|
|
|
}
|
2016-07-29 08:13:46 +00:00
|
|
|
mach->maxCpus = qemuCaps->machineTypes[i].maxCpus;
|
2012-08-22 13:37:05 +00:00
|
|
|
}
|
|
|
|
|
qemu: Report all supported machine types in capabilities
Some machine types are only reported as canonical names for other
machine types, which make it a bit harder to find what machine types are
supported by a specific QEMU binary. Ideally, one would just use
/capabilities/guest/arch[@name='...']/machine/text() XPath to get a list
of all supported machine types, but it doesn't work right now.
For example, we report
<machine canonical='pc-i440fx-2.3' maxCpus='255'>pc</machine>
in guest capabilities, but the corresponding
<machine maxCpus='255'>pc-i440fx-2.3</machine>
is missing.
This is a result of QMP probing. With "-machine ?" parsing QEMU sends
us two lines:
pc Standard PC (i440FX + PIIX, 1996) (alias of pc-i440fx-2.3)
pc-i440fx-2.3 Standard PC (i440FX + PIIX, 1996) (default)
while query-machines QMP command reports both in the same entry:
{"name": "pc-i440fx-2.3", "is-default": true, "cpu-max": 255, "alias": "pc"}
Let's make sure we always report separate <machine/> for both the
canonical name and its alias and using the canonical name as the default
machine type (i.e., inserting it before its alias) in case is-default is
true.
https://bugzilla.redhat.com/show_bug.cgi?id=1229666
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-06-12 12:36:51 +00:00
|
|
|
/* Make sure all canonical machine types also have their own entry so that
|
|
|
|
* /capabilities/guest/arch[@name='...']/machine/text() XPath selects all
|
|
|
|
* supported machine types.
|
|
|
|
*/
|
|
|
|
i = 0;
|
|
|
|
while (i < *nmachines) {
|
|
|
|
size_t j;
|
|
|
|
bool found = false;
|
|
|
|
virCapsGuestMachinePtr machine = (*machines)[i];
|
|
|
|
|
|
|
|
if (!machine->canonical) {
|
|
|
|
i++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (j = 0; j < *nmachines; j++) {
|
|
|
|
if (STREQ(machine->canonical, (*machines)[j]->name)) {
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!found) {
|
|
|
|
virCapsGuestMachinePtr mach;
|
|
|
|
if (VIR_ALLOC(mach) < 0)
|
|
|
|
goto error;
|
|
|
|
if (VIR_INSERT_ELEMENT_COPY(*machines, i, *nmachines, mach) < 0) {
|
|
|
|
VIR_FREE(mach);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
if (VIR_STRDUP(mach->name, machine->canonical) < 0)
|
|
|
|
goto error;
|
|
|
|
mach->maxCpus = machine->maxCpus;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2012-08-22 13:37:05 +00:00
|
|
|
return 0;
|
|
|
|
|
2014-03-25 06:49:44 +00:00
|
|
|
error:
|
2012-08-22 13:37:05 +00:00
|
|
|
virCapabilitiesFreeMachines(*machines, *nmachines);
|
|
|
|
*nmachines = 0;
|
|
|
|
*machines = NULL;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-08-16 13:37:18 +00:00
|
|
|
/**
|
|
|
|
* virQEMUCapsGetCanonicalMachine:
|
|
|
|
* @qemuCaps: qemu capabilities object
|
|
|
|
* @name: machine name
|
|
|
|
*
|
|
|
|
* Resolves aliased machine names to the actual machine name. If qemuCaps isn't
|
|
|
|
* present @name is returned.
|
|
|
|
*/
|
2013-02-01 13:48:58 +00:00
|
|
|
const char *virQEMUCapsGetCanonicalMachine(virQEMUCapsPtr qemuCaps,
|
|
|
|
const char *name)
|
2012-08-22 10:11:28 +00:00
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
2017-08-16 13:37:18 +00:00
|
|
|
if (!name || !qemuCaps)
|
|
|
|
return name;
|
2012-11-01 11:43:03 +00:00
|
|
|
|
2013-05-21 07:21:20 +00:00
|
|
|
for (i = 0; i < qemuCaps->nmachineTypes; i++) {
|
2016-07-29 08:13:46 +00:00
|
|
|
if (!qemuCaps->machineTypes[i].alias)
|
2012-08-22 10:11:28 +00:00
|
|
|
continue;
|
2016-07-29 08:13:46 +00:00
|
|
|
if (STREQ(qemuCaps->machineTypes[i].alias, name))
|
|
|
|
return qemuCaps->machineTypes[i].name;
|
2012-08-22 10:11:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return name;
|
|
|
|
}
|
2012-09-10 10:47:56 +00:00
|
|
|
|
2018-08-13 11:42:01 +00:00
|
|
|
const char *
|
|
|
|
virQEMUCapsGetDefaultMachine(virQEMUCapsPtr qemuCaps)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
for (i = 0; i < qemuCaps->nmachineTypes; i++) {
|
|
|
|
if (qemuCaps->machineTypes[i].qemuDefault)
|
|
|
|
return qemuCaps->machineTypes[i].name;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2012-09-10 10:47:56 +00:00
|
|
|
|
2013-06-26 15:46:35 +00:00
|
|
|
int virQEMUCapsGetMachineMaxCpus(virQEMUCapsPtr qemuCaps,
|
|
|
|
const char *name)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
if (!name)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
for (i = 0; i < qemuCaps->nmachineTypes; i++) {
|
2016-07-29 08:13:46 +00:00
|
|
|
if (!qemuCaps->machineTypes[i].maxCpus)
|
2013-06-26 15:46:35 +00:00
|
|
|
continue;
|
2016-07-29 08:13:46 +00:00
|
|
|
if (STREQ(qemuCaps->machineTypes[i].name, name))
|
|
|
|
return qemuCaps->machineTypes[i].maxCpus;
|
2013-06-26 15:46:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-07-29 07:45:19 +00:00
|
|
|
bool virQEMUCapsGetMachineHotplugCpus(virQEMUCapsPtr qemuCaps,
|
|
|
|
const char *name)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
for (i = 0; i < qemuCaps->nmachineTypes; i++) {
|
|
|
|
if (STREQ_NULLABLE(qemuCaps->machineTypes[i].name, name))
|
|
|
|
return qemuCaps->machineTypes[i].hotplugCpus;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-05-10 08:50:34 +00:00
|
|
|
/**
|
|
|
|
* virQEMUCapsSetGICCapabilities:
|
|
|
|
* @qemuCaps: QEMU capabilities
|
|
|
|
* @capabilities: GIC capabilities
|
|
|
|
* @ncapabilities: number of GIC capabilities
|
|
|
|
*
|
|
|
|
* Set the GIC capabilities for @qemuCaps.
|
|
|
|
*
|
|
|
|
* The ownership of @capabilities is taken away from the caller, ie. this
|
|
|
|
* function will not make a copy of @capabilities, so releasing that memory
|
|
|
|
* after it's been called is a bug.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
virQEMUCapsSetGICCapabilities(virQEMUCapsPtr qemuCaps,
|
|
|
|
virGICCapability *capabilities,
|
|
|
|
size_t ncapabilities)
|
|
|
|
{
|
|
|
|
VIR_FREE(qemuCaps->gicCapabilities);
|
|
|
|
|
|
|
|
qemuCaps->gicCapabilities = capabilities;
|
|
|
|
qemuCaps->ngicCapabilities = ncapabilities;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsCommands),
|
|
|
|
virQEMUCapsCommands,
|
|
|
|
ncommands, commands);
|
2017-03-03 20:31:26 +00:00
|
|
|
virStringListFreeCount(commands, ncommands);
|
2012-09-13 14:54:02 +00:00
|
|
|
|
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,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsEvents),
|
|
|
|
virQEMUCapsEvents,
|
|
|
|
nevents, events);
|
2017-03-03 20:31:26 +00:00
|
|
|
virStringListFreeCount(events, nevents);
|
2012-09-13 14:54:02 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-04-12 12:39:43 +00:00
|
|
|
static int
|
|
|
|
virQEMUCapsProbeQMPGenericProps(virQEMUCapsPtr qemuCaps,
|
|
|
|
qemuMonitorPtr mon,
|
|
|
|
virQEMUCapsObjectTypeProps *props,
|
|
|
|
size_t nprops,
|
|
|
|
virQEMUCapsObjectTypePropsCB propsGetCB)
|
|
|
|
{
|
|
|
|
int nvalues;
|
|
|
|
char **values;
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
for (i = 0; i < nprops; i++) {
|
|
|
|
const char *type = props[i].type;
|
|
|
|
int cap = props[i].capsCondition;
|
|
|
|
|
|
|
|
if (cap >= 0 && !virQEMUCapsGet(qemuCaps, cap))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if ((nvalues = propsGetCB(mon, type, &values)) < 0)
|
|
|
|
return -1;
|
|
|
|
virQEMUCapsProcessStringFlags(qemuCaps,
|
|
|
|
props[i].nprops,
|
|
|
|
props[i].props,
|
|
|
|
nvalues, values);
|
|
|
|
virStringListFreeCount(values, nvalues);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2012-09-13 14:54:02 +00:00
|
|
|
|
2012-08-22 17:05:08 +00:00
|
|
|
static int
|
2018-04-12 11:31:03 +00:00
|
|
|
virQEMUCapsProbeQMPDevices(virQEMUCapsPtr qemuCaps,
|
2013-02-01 13:48:58 +00:00
|
|
|
qemuMonitorPtr mon)
|
2012-08-22 17:05:08 +00:00
|
|
|
{
|
|
|
|
int nvalues;
|
|
|
|
char **values;
|
|
|
|
|
|
|
|
if ((nvalues = qemuMonitorGetObjectTypes(mon, &values)) < 0)
|
|
|
|
return -1;
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsProcessStringFlags(qemuCaps,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsObjectTypes),
|
|
|
|
virQEMUCapsObjectTypes,
|
|
|
|
nvalues, values);
|
2017-03-03 20:31:26 +00:00
|
|
|
virStringListFreeCount(values, nvalues);
|
2013-02-01 13:48:58 +00:00
|
|
|
|
2018-04-12 12:39:43 +00:00
|
|
|
if (virQEMUCapsProbeQMPGenericProps(qemuCaps,
|
|
|
|
mon,
|
|
|
|
virQEMUCapsDeviceProps,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsDeviceProps),
|
|
|
|
qemuMonitorGetDeviceProps) < 0)
|
|
|
|
return -1;
|
2012-08-22 17:05:08 +00:00
|
|
|
|
2018-04-20 08:25:49 +00:00
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QOM_LIST_PROPERTIES) &&
|
|
|
|
virQEMUCapsProbeQMPGenericProps(qemuCaps,
|
|
|
|
mon,
|
|
|
|
virQEMUCapsObjectProps,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsObjectProps),
|
|
|
|
qemuMonitorGetObjectProps) < 0)
|
|
|
|
return -1;
|
|
|
|
|
2012-08-22 17:05:08 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
};
|
2018-08-23 16:46:52 +00:00
|
|
|
verify(ARRAY_CARDINALITY(preferredMachines) == VIR_ARCH_LAST);
|
2018-08-03 12:29:26 +00:00
|
|
|
|
|
|
|
|
2012-08-22 17:05:08 +00:00
|
|
|
static int
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsProbeQMPMachineTypes(virQEMUCapsPtr qemuCaps,
|
|
|
|
qemuMonitorPtr mon)
|
2012-08-22 17:05:08 +00:00
|
|
|
{
|
|
|
|
qemuMonitorMachineInfoPtr *machines = NULL;
|
|
|
|
int nmachines = 0;
|
|
|
|
int ret = -1;
|
|
|
|
size_t i;
|
2018-08-03 12:29:26 +00:00
|
|
|
ssize_t defIdx = -1;
|
|
|
|
ssize_t preferredIdx = -1;
|
|
|
|
const char *preferredMachine = preferredMachines[qemuCaps->arch];
|
2012-08-22 17:05:08 +00:00
|
|
|
|
|
|
|
if ((nmachines = qemuMonitorGetMachines(mon, &machines)) < 0)
|
2014-09-04 21:15:51 +00:00
|
|
|
return -1;
|
2012-08-22 17:05:08 +00:00
|
|
|
|
2013-07-04 10:14:12 +00:00
|
|
|
if (VIR_ALLOC_N(qemuCaps->machineTypes, nmachines) < 0)
|
2012-08-22 17:05:08 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2013-05-21 07:21:20 +00:00
|
|
|
for (i = 0; i < nmachines; i++) {
|
2016-07-29 08:35:48 +00:00
|
|
|
struct virQEMUCapsMachineType *mach;
|
2013-11-06 07:31:24 +00:00
|
|
|
if (STREQ(machines[i]->name, "none"))
|
|
|
|
continue;
|
2016-07-29 08:35:48 +00:00
|
|
|
|
|
|
|
mach = &(qemuCaps->machineTypes[qemuCaps->nmachineTypes++]);
|
|
|
|
|
|
|
|
if (VIR_STRDUP(mach->alias, machines[i]->alias) < 0 ||
|
|
|
|
VIR_STRDUP(mach->name, machines[i]->name) < 0)
|
2012-12-07 16:30:34 +00:00
|
|
|
goto cleanup;
|
2016-07-29 08:35:48 +00:00
|
|
|
|
|
|
|
mach->maxCpus = machines[i]->maxCpus;
|
2016-07-29 07:45:19 +00:00
|
|
|
mach->hotplugCpus = machines[i]->hotplugCpus;
|
2016-07-29 08:35:48 +00:00
|
|
|
|
2018-08-03 12:29:26 +00:00
|
|
|
if (preferredMachine &&
|
|
|
|
(STREQ_NULLABLE(mach->alias, preferredMachine) ||
|
|
|
|
STREQ(mach->name, preferredMachine))) {
|
|
|
|
preferredIdx = qemuCaps->nmachineTypes - 1;
|
|
|
|
}
|
|
|
|
|
2018-08-10 12:18:27 +00:00
|
|
|
if (machines[i]->isDefault) {
|
|
|
|
mach->qemuDefault = true;
|
2013-12-17 08:33:19 +00:00
|
|
|
defIdx = qemuCaps->nmachineTypes - 1;
|
2018-08-10 12:18:27 +00:00
|
|
|
}
|
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)
|
|
|
|
virQEMUCapsSetDefaultMachine(qemuCaps, preferredIdx);
|
2012-08-22 17:05:08 +00:00
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
|
2014-03-25 06:49:44 +00:00
|
|
|
cleanup:
|
2013-05-21 07:21:20 +00:00
|
|
|
for (i = 0; i < nmachines; i++)
|
2012-08-22 17:05:08 +00:00
|
|
|
qemuMonitorMachineInfoFree(machines[i]);
|
|
|
|
VIR_FREE(machines);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-16 13:45:08 +00:00
|
|
|
static int
|
|
|
|
virQEMUCapsProbeQMPMachineProps(virQEMUCapsPtr qemuCaps,
|
|
|
|
qemuMonitorPtr mon)
|
|
|
|
{
|
|
|
|
char **values;
|
|
|
|
int nvalues;
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QOM_LIST_PROPERTIES))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_CARDINALITY(virQEMUCapsMachineProps); i++) {
|
|
|
|
virQEMUCapsObjectTypeProps props = virQEMUCapsMachineProps[i];
|
2019-05-16 08:34:01 +00:00
|
|
|
const char *canon = virQEMUCapsGetCanonicalMachine(qemuCaps, props.type);
|
2019-05-16 08:18:58 +00:00
|
|
|
VIR_AUTOFREE(char *) type = NULL;
|
|
|
|
|
2019-05-16 10:04:48 +00:00
|
|
|
if (!virQEMUCapsIsMachineSupported(qemuCaps, canon))
|
|
|
|
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-05-16 08:34:01 +00:00
|
|
|
if (virAsprintf(&type, "%s-machine", canon) < 0)
|
2019-05-16 08:18:58 +00:00
|
|
|
return -1;
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-07 10:21:48 +00:00
|
|
|
virDomainCapsCPUModelsPtr
|
|
|
|
virQEMUCapsFetchCPUDefinitions(qemuMonitorPtr mon)
|
2012-08-22 17:05:08 +00:00
|
|
|
{
|
2017-12-07 10:21:48 +00:00
|
|
|
virDomainCapsCPUModelsPtr models = NULL;
|
|
|
|
qemuMonitorCPUDefInfoPtr *cpus = NULL;
|
|
|
|
int ncpus = 0;
|
2016-04-21 10:51:01 +00:00
|
|
|
size_t i;
|
2012-08-22 17:05:08 +00:00
|
|
|
|
2016-04-21 10:51:01 +00:00
|
|
|
if ((ncpus = qemuMonitorGetCPUDefinitions(mon, &cpus)) < 0)
|
2017-12-11 13:34:20 +00:00
|
|
|
return NULL;
|
2012-08-22 17:05:08 +00:00
|
|
|
|
2016-11-14 16:21:30 +00:00
|
|
|
if (!(models = virDomainCapsCPUModelsNew(ncpus)))
|
2017-12-07 10:21:48 +00:00
|
|
|
goto error;
|
2016-11-14 16:21:30 +00:00
|
|
|
|
2016-04-21 10:51:01 +00:00
|
|
|
for (i = 0; i < ncpus; i++) {
|
2016-04-21 11:08:12 +00:00
|
|
|
virDomainCapsCPUUsable usable = VIR_DOMCAPS_CPU_USABLE_UNKNOWN;
|
|
|
|
|
|
|
|
if (cpus[i]->usable == VIR_TRISTATE_BOOL_YES)
|
|
|
|
usable = VIR_DOMCAPS_CPU_USABLE_YES;
|
|
|
|
else if (cpus[i]->usable == VIR_TRISTATE_BOOL_NO)
|
|
|
|
usable = VIR_DOMCAPS_CPU_USABLE_NO;
|
|
|
|
|
2017-09-19 16:35:08 +00:00
|
|
|
if (virDomainCapsCPUModelsAddSteal(models, &cpus[i]->name, usable,
|
2017-09-20 08:45:49 +00:00
|
|
|
&cpus[i]->blockers) < 0)
|
2017-12-07 10:21:48 +00:00
|
|
|
goto error;
|
2016-04-21 10:51:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
for (i = 0; i < ncpus; i++)
|
|
|
|
qemuMonitorCPUDefInfoFree(cpus[i]);
|
|
|
|
VIR_FREE(cpus);
|
2017-12-07 10:21:48 +00:00
|
|
|
return models;
|
|
|
|
|
|
|
|
error:
|
|
|
|
virObjectUnref(models);
|
|
|
|
models = NULL;
|
|
|
|
goto cleanup;
|
2012-08-22 17:05:08 +00:00
|
|
|
}
|
|
|
|
|
2017-12-07 10:21:48 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
virQEMUCapsProbeQMPCPUDefinitions(virQEMUCapsPtr qemuCaps,
|
|
|
|
qemuMonitorPtr mon,
|
|
|
|
bool tcg)
|
|
|
|
{
|
|
|
|
virDomainCapsCPUModelsPtr models = NULL;
|
|
|
|
|
|
|
|
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_DEFINITIONS))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (!(models = virQEMUCapsFetchCPUDefinitions(mon)))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (tcg || !virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM))
|
|
|
|
qemuCaps->tcgCPUModels = models;
|
|
|
|
else
|
|
|
|
qemuCaps->kvmCPUModels = models;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-06 07:52:22 +00:00
|
|
|
static int
|
|
|
|
virQEMUCapsProbeQMPHostCPU(virQEMUCapsPtr qemuCaps,
|
2017-02-22 15:51:50 +00:00
|
|
|
qemuMonitorPtr mon,
|
|
|
|
bool tcg)
|
2017-01-06 07:52:22 +00:00
|
|
|
{
|
2017-04-07 16:15:26 +00:00
|
|
|
qemuMonitorCPUModelInfoPtr modelInfo = NULL;
|
2017-03-29 08:58:41 +00:00
|
|
|
qemuMonitorCPUModelInfoPtr nonMigratable = NULL;
|
|
|
|
virHashTablePtr hash = NULL;
|
2017-02-22 15:51:50 +00:00
|
|
|
const char *model;
|
2017-02-23 12:53:51 +00:00
|
|
|
qemuMonitorCPUModelExpansionType type;
|
2017-04-07 16:15:26 +00:00
|
|
|
virDomainVirtType virtType;
|
2017-03-29 08:58:41 +00:00
|
|
|
int ret = -1;
|
2017-02-22 15:51:50 +00:00
|
|
|
|
|
|
|
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION))
|
2017-01-06 07:52:22 +00:00
|
|
|
return 0;
|
|
|
|
|
2017-02-22 15:51:50 +00:00
|
|
|
if (tcg || !virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) {
|
2017-04-07 16:15:26 +00:00
|
|
|
virtType = VIR_DOMAIN_VIRT_QEMU;
|
2017-02-22 15:51:50 +00:00
|
|
|
model = "max";
|
|
|
|
} else {
|
2017-04-07 16:15:26 +00:00
|
|
|
virtType = VIR_DOMAIN_VIRT_KVM;
|
2017-02-22 15:51:50 +00:00
|
|
|
model = "host";
|
|
|
|
}
|
|
|
|
|
2017-02-23 12:53:51 +00:00
|
|
|
/* Some x86_64 features defined in cpu_map.xml use spelling which differ
|
|
|
|
* from the one preferred by QEMU. Static expansion would give us only the
|
|
|
|
* preferred spelling, thus we need to do a full expansion on the result of
|
|
|
|
* the initial static expansion to get all variants of all features.
|
|
|
|
*/
|
|
|
|
if (ARCH_IS_X86(qemuCaps->arch))
|
|
|
|
type = QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC_FULL;
|
|
|
|
else
|
|
|
|
type = QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC;
|
|
|
|
|
2017-04-07 16:15:26 +00:00
|
|
|
if (qemuMonitorGetCPUModelExpansion(mon, type, model, true, &modelInfo) < 0)
|
|
|
|
goto cleanup;
|
2017-03-29 08:58:41 +00:00
|
|
|
|
|
|
|
/* Try to check migratability of each feature. */
|
2017-04-07 16:15:26 +00:00
|
|
|
if (modelInfo &&
|
2017-03-29 08:58:41 +00:00
|
|
|
qemuMonitorGetCPUModelExpansion(mon, type, model, false,
|
|
|
|
&nonMigratable) < 0)
|
2017-04-07 16:15:26 +00:00
|
|
|
goto cleanup;
|
2017-03-29 08:58:41 +00:00
|
|
|
|
|
|
|
if (nonMigratable) {
|
|
|
|
qemuMonitorCPUPropertyPtr prop;
|
|
|
|
qemuMonitorCPUPropertyPtr nmProp;
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
if (!(hash = virHashCreate(0, NULL)))
|
2017-04-07 16:15:26 +00:00
|
|
|
goto cleanup;
|
2017-03-29 08:58:41 +00:00
|
|
|
|
2017-04-07 16:15:26 +00:00
|
|
|
for (i = 0; i < modelInfo->nprops; i++) {
|
|
|
|
prop = modelInfo->props + i;
|
2017-03-29 08:58:41 +00:00
|
|
|
if (virHashAddEntry(hash, prop->name, prop) < 0)
|
2017-04-07 16:15:26 +00:00
|
|
|
goto cleanup;
|
2017-03-29 08:58:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < nonMigratable->nprops; i++) {
|
|
|
|
nmProp = nonMigratable->props + i;
|
|
|
|
if (!(prop = virHashLookup(hash, nmProp->name)) ||
|
|
|
|
prop->type != QEMU_MONITOR_CPU_PROPERTY_BOOLEAN ||
|
|
|
|
prop->type != nmProp->type)
|
|
|
|
continue;
|
|
|
|
|
2017-03-29 09:00:32 +00:00
|
|
|
if (prop->value.boolean) {
|
2017-03-29 08:58:41 +00:00
|
|
|
prop->migratable = VIR_TRISTATE_BOOL_YES;
|
2017-03-29 09:00:32 +00:00
|
|
|
} else if (nmProp->value.boolean) {
|
|
|
|
prop->value.boolean = true;
|
|
|
|
prop->migratable = VIR_TRISTATE_BOOL_NO;
|
|
|
|
}
|
2017-03-29 08:58:41 +00:00
|
|
|
}
|
|
|
|
|
2017-04-07 16:15:26 +00:00
|
|
|
modelInfo->migratability = true;
|
2017-03-29 08:58:41 +00:00
|
|
|
}
|
|
|
|
|
2019-02-25 09:00:53 +00:00
|
|
|
virQEMUCapsSetCPUModelInfo(qemuCaps, virtType, modelInfo);
|
|
|
|
modelInfo = NULL;
|
2017-03-29 08:58:41 +00:00
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virHashFree(hash);
|
|
|
|
qemuMonitorCPUModelInfoFree(nonMigratable);
|
2017-04-07 16:15:26 +00:00
|
|
|
qemuMonitorCPUModelInfoFree(modelInfo);
|
2017-03-29 08:58:41 +00:00
|
|
|
|
|
|
|
return ret;
|
2017-01-06 07:52:22 +00:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
2019-02-25 09:00:53 +00:00
|
|
|
if (VIR_ALLOC_N(list, modelInfo->nprops + 1) < 0)
|
2018-05-15 20:03:19 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
if (VIR_STRDUP(list[n++], prop->name) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
VIR_STEAL_PTR(*features, 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;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virStringListFree(list);
|
|
|
|
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,
|
|
|
|
},
|
2013-04-12 20:55:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
virQEMUCapsProbeQMPTPM(virQEMUCapsPtr qemuCaps,
|
|
|
|
qemuMonitorPtr mon)
|
|
|
|
{
|
Convert 'int i' to 'size_t i' in src/qemu files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 14:09:33 +00:00
|
|
|
int nentries;
|
|
|
|
size_t i;
|
2013-04-12 20:55:45 +00:00
|
|
|
char **entries = NULL;
|
2013-04-15 20:46:53 +00:00
|
|
|
|
2013-04-12 20:55:45 +00:00
|
|
|
if ((nentries = qemuMonitorGetTPMModels(mon, &entries)) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (nentries > 0) {
|
|
|
|
for (i = 0; i < ARRAY_CARDINALITY(virQEMUCapsTPMModelsToCaps); i++) {
|
|
|
|
const char *needle = virDomainTPMModelTypeToString(
|
|
|
|
virQEMUCapsTPMModelsToCaps[i].type);
|
2018-04-25 12:42:34 +00:00
|
|
|
if (virStringListHasString((const char **)entries, needle))
|
2013-04-12 20:55:45 +00:00
|
|
|
virQEMUCapsSet(qemuCaps,
|
|
|
|
virQEMUCapsTPMModelsToCaps[i].caps);
|
|
|
|
}
|
|
|
|
}
|
2016-11-25 08:18:35 +00:00
|
|
|
virStringListFree(entries);
|
2013-04-12 20:55:45 +00:00
|
|
|
|
|
|
|
if ((nentries = qemuMonitorGetTPMTypes(mon, &entries)) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (nentries > 0) {
|
|
|
|
for (i = 0; i < ARRAY_CARDINALITY(virQEMUCapsTPMTypesToCaps); i++) {
|
|
|
|
const char *needle = virDomainTPMBackendTypeToString(
|
|
|
|
virQEMUCapsTPMTypesToCaps[i].type);
|
2018-04-25 12:42:34 +00:00
|
|
|
if (virStringListHasString((const char **)entries, needle))
|
2013-04-12 20:55:45 +00:00
|
|
|
virQEMUCapsSet(qemuCaps, virQEMUCapsTPMTypesToCaps[i].caps);
|
|
|
|
}
|
|
|
|
}
|
2016-11-25 08:18:35 +00:00
|
|
|
virStringListFree(entries);
|
2013-04-12 20:55:45 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-08-22 17:05:08 +00:00
|
|
|
|
Make non-KVM machines work with QMP probing
When there is no 'qemu-kvm' binary and the emulator used for a machine
is, for example, 'qemu-system-x86_64' that, by default, runs without
kvm enabled, libvirt still supplies '-no-kvm' option to this process,
even though it does not recognize such option (making the start of a
domain fail in that case).
This patch fixes building a command-line for QEMU machines without KVM
acceleration and is based on following assumptions:
- QEMU_CAPS_KVM flag means that QEMU is running KVM accelerated
machines by default (without explicitly requesting that using a
command-line option). It is the closest to the truth according to
the code with the only exception being the comment next to the
flag, so it's fixed in this patch as well.
- QEMU_CAPS_ENABLE_KVM flag means that QEMU is, by default, running
without KVM acceleration and in case we need KVM acceleration it
needs to be explicitly instructed to do so. This is partially
true for the past (this option essentially means that QEMU
recognizes the '-enable-kvm' option, even though it's almost the
same).
2012-10-31 07:31:49 +00:00
|
|
|
static int
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsProbeQMPKVMState(virQEMUCapsPtr qemuCaps,
|
|
|
|
qemuMonitorPtr mon)
|
Make non-KVM machines work with QMP probing
When there is no 'qemu-kvm' binary and the emulator used for a machine
is, for example, 'qemu-system-x86_64' that, by default, runs without
kvm enabled, libvirt still supplies '-no-kvm' option to this process,
even though it does not recognize such option (making the start of a
domain fail in that case).
This patch fixes building a command-line for QEMU machines without KVM
acceleration and is based on following assumptions:
- QEMU_CAPS_KVM flag means that QEMU is running KVM accelerated
machines by default (without explicitly requesting that using a
command-line option). It is the closest to the truth according to
the code with the only exception being the comment next to the
flag, so it's fixed in this patch as well.
- QEMU_CAPS_ENABLE_KVM flag means that QEMU is, by default, running
without KVM acceleration and in case we need KVM acceleration it
needs to be explicitly instructed to do so. This is partially
true for the past (this option essentially means that QEMU
recognizes the '-enable-kvm' option, even though it's almost the
same).
2012-10-31 07:31:49 +00:00
|
|
|
{
|
|
|
|
bool enabled = false;
|
|
|
|
bool present = false;
|
|
|
|
|
|
|
|
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 },
|
2013-05-14 05:25:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
virQEMUCapsProbeQMPCommandLine(virQEMUCapsPtr qemuCaps,
|
|
|
|
qemuMonitorPtr mon)
|
|
|
|
{
|
2014-06-17 11:41:16 +00:00
|
|
|
bool found = false;
|
2013-05-14 05:25:49 +00:00
|
|
|
int nvalues;
|
|
|
|
char **values;
|
|
|
|
size_t i, j;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_CARDINALITY(virQEMUCapsCommandLine); i++) {
|
|
|
|
if ((nvalues = qemuMonitorGetCommandLineOptionParameters(mon,
|
|
|
|
virQEMUCapsCommandLine[i].option,
|
2014-06-17 11:41:16 +00:00
|
|
|
&values,
|
|
|
|
&found)) < 0)
|
2013-05-14 05:25:49 +00:00
|
|
|
return -1;
|
2014-06-17 11:41:16 +00:00
|
|
|
|
|
|
|
if (found && !virQEMUCapsCommandLine[i].param)
|
|
|
|
virQEMUCapsSet(qemuCaps, virQEMUCapsCommandLine[i].flag);
|
|
|
|
|
2013-05-14 05:25:49 +00:00
|
|
|
for (j = 0; j < nvalues; j++) {
|
2014-06-17 11:41:16 +00:00
|
|
|
if (STREQ_NULLABLE(virQEMUCapsCommandLine[i].param, values[j])) {
|
2013-05-14 05:25:49 +00:00
|
|
|
virQEMUCapsSet(qemuCaps, virQEMUCapsCommandLine[i].flag);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-11-25 08:18:35 +00:00
|
|
|
virStringListFree(values);
|
2013-05-14 05:25:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
Make non-KVM machines work with QMP probing
When there is no 'qemu-kvm' binary and the emulator used for a machine
is, for example, 'qemu-system-x86_64' that, by default, runs without
kvm enabled, libvirt still supplies '-no-kvm' option to this process,
even though it does not recognize such option (making the start of a
domain fail in that case).
This patch fixes building a command-line for QEMU machines without KVM
acceleration and is based on following assumptions:
- QEMU_CAPS_KVM flag means that QEMU is running KVM accelerated
machines by default (without explicitly requesting that using a
command-line option). It is the closest to the truth according to
the code with the only exception being the comment next to the
flag, so it's fixed in this patch as well.
- QEMU_CAPS_ENABLE_KVM flag means that QEMU is, by default, running
without KVM acceleration and in case we need KVM acceleration it
needs to be explicitly instructed to do so. This is partially
true for the past (this option essentially means that QEMU
recognizes the '-enable-kvm' option, even though it's almost the
same).
2012-10-31 07:31:49 +00:00
|
|
|
|
2014-09-11 12:11:54 +00:00
|
|
|
static int
|
|
|
|
virQEMUCapsProbeQMPMigrationCapabilities(virQEMUCapsPtr qemuCaps,
|
|
|
|
qemuMonitorPtr mon)
|
|
|
|
{
|
|
|
|
char **caps = NULL;
|
|
|
|
int ncaps;
|
|
|
|
|
|
|
|
if ((ncaps = qemuMonitorGetMigrationCapabilities(mon, &caps)) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
virQEMUCapsProcessStringFlags(qemuCaps,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsMigration),
|
|
|
|
virQEMUCapsMigration,
|
|
|
|
ncaps, caps);
|
2017-03-03 20:31:26 +00:00
|
|
|
virStringListFreeCount(caps, ncaps);
|
2014-09-11 12:11:54 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-03-08 17:24:18 +00:00
|
|
|
/**
|
|
|
|
* virQEMUCapsProbeQMPGICCapabilities:
|
|
|
|
* @qemuCaps: QEMU binary capabilities
|
|
|
|
* @mon: QEMU monitor
|
|
|
|
*
|
|
|
|
* Use @mon to obtain information about the GIC capabilities for the
|
|
|
|
* corresponding QEMU binary, and store them in @qemuCaps.
|
|
|
|
*
|
|
|
|
* Returns: 0 on success, <0 on failure
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
virQEMUCapsProbeQMPGICCapabilities(virQEMUCapsPtr qemuCaps,
|
|
|
|
qemuMonitorPtr mon)
|
|
|
|
{
|
|
|
|
virGICCapability *caps = NULL;
|
|
|
|
int ncaps;
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-13 15:28:13 +00:00
|
|
|
bool
|
2016-07-21 15:02:37 +00:00
|
|
|
virQEMUCapsCPUFilterFeatures(const char *name,
|
2017-01-18 13:05:26 +00:00
|
|
|
void *opaque)
|
2016-07-21 15:02:37 +00:00
|
|
|
{
|
2017-09-13 15:26:07 +00:00
|
|
|
virArch *arch = opaque;
|
2017-01-18 13:05:26 +00:00
|
|
|
|
2017-09-13 15:26:07 +00:00
|
|
|
if (!ARCH_IS_X86(*arch))
|
2017-01-18 13:05:26 +00:00
|
|
|
return true;
|
|
|
|
|
2016-07-21 15:02:37 +00:00
|
|
|
if (STREQ(name, "cmt") ||
|
|
|
|
STREQ(name, "mbm_total") ||
|
|
|
|
STREQ(name, "mbm_local"))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-10 18:16:24 +00:00
|
|
|
/**
|
|
|
|
* Returns 0 when host CPU model provided by QEMU was filled in qemuCaps,
|
|
|
|
* 1 when the caller should fall back to using virCapsPtr->host.cpu,
|
2017-11-27 12:12:17 +00:00
|
|
|
* 2 when cpu model info is not supported for this configuration,
|
2017-01-10 18:16:24 +00:00
|
|
|
* -1 on error.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
virQEMUCapsInitCPUModelS390(virQEMUCapsPtr qemuCaps,
|
2017-11-24 08:02:02 +00:00
|
|
|
virDomainVirtType type,
|
2017-03-30 11:50:44 +00:00
|
|
|
qemuMonitorCPUModelInfoPtr modelInfo,
|
2017-03-29 11:33:50 +00:00
|
|
|
virCPUDefPtr cpu,
|
|
|
|
bool migratable)
|
2016-06-15 12:35:18 +00:00
|
|
|
{
|
2017-01-06 07:52:22 +00:00
|
|
|
size_t i;
|
2016-06-15 12:35:18 +00:00
|
|
|
|
2017-01-10 18:16:24 +00:00
|
|
|
if (!modelInfo) {
|
2017-11-24 08:02:02 +00:00
|
|
|
if (type == VIR_DOMAIN_VIRT_KVM) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("missing host CPU model info from QEMU "
|
|
|
|
"capabilities for binary %s"),
|
|
|
|
qemuCaps->binary);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 2;
|
2017-01-06 07:52:22 +00:00
|
|
|
}
|
qemu: Fix crash in qemucapsprobe
The qemucapsprobe helper calls virQEMUCapsNewForBinaryInternal with
caps == NULL, causing the following crash:
Program received signal SIGSEGV, Segmentation fault.
#0 0x00007ffff788775f in virQEMUCapsInitHostCPUModel
(qemuCaps=qemuCaps@entry=0x649680, host=host@entry=0x10) at
src/qemu/qemu_capabilities.c:2969
#1 0x00007ffff7889dbf in virQEMUCapsNewForBinaryInternal
(caps=caps@entry=0x0, binary=<optimized out>,
libDir=libDir@entry=0x4033f6 "/tmp", cacheDir=cacheDir@entry=0x0,
runUid=runUid@entry=4294967295, runGid=runGid@entry=4294967295,
qmpOnly=true) at src/qemu/qemu_capabilities.c:4039
#2 0x0000000000401702 in main (argc=2, argv=0x7fffffffd968) at
tests/qemucapsprobe.c:73
Caused by v2.2.0-182-g68c7011.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-09-27 11:39:51 +00:00
|
|
|
|
2017-01-06 07:52:22 +00:00
|
|
|
if (VIR_STRDUP(cpu->model, modelInfo->name) < 0 ||
|
|
|
|
VIR_ALLOC_N(cpu->features, modelInfo->nprops) < 0)
|
2017-01-10 18:16:24 +00:00
|
|
|
return -1;
|
2017-01-06 07:52:22 +00:00
|
|
|
|
|
|
|
cpu->nfeatures_max = modelInfo->nprops;
|
|
|
|
cpu->nfeatures = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < modelInfo->nprops; i++) {
|
2017-02-22 15:01:30 +00:00
|
|
|
virCPUFeatureDefPtr feature = cpu->features + cpu->nfeatures;
|
|
|
|
qemuMonitorCPUPropertyPtr prop = modelInfo->props + i;
|
2017-01-06 07:52:22 +00:00
|
|
|
|
2017-02-22 15:01:30 +00:00
|
|
|
if (prop->type != QEMU_MONITOR_CPU_PROPERTY_BOOLEAN)
|
|
|
|
continue;
|
2017-01-06 07:52:22 +00:00
|
|
|
|
2017-02-22 15:01:30 +00:00
|
|
|
if (VIR_STRDUP(feature->name, prop->name) < 0)
|
|
|
|
return -1;
|
2017-03-29 11:33:50 +00:00
|
|
|
|
|
|
|
if (!prop->value.boolean ||
|
|
|
|
(migratable && prop->migratable == VIR_TRISTATE_BOOL_NO))
|
|
|
|
feature->policy = VIR_CPU_FEATURE_DISABLE;
|
|
|
|
else
|
|
|
|
feature->policy = VIR_CPU_FEATURE_REQUIRE;
|
2017-01-06 07:52:22 +00:00
|
|
|
cpu->nfeatures++;
|
|
|
|
}
|
|
|
|
|
2017-01-10 18:16:24 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2017-01-06 07:52:22 +00:00
|
|
|
|
2017-01-10 18:16:24 +00:00
|
|
|
|
2019-02-25 08:39:17 +00:00
|
|
|
virCPUDataPtr
|
|
|
|
virQEMUCapsGetCPUModelX86Data(qemuMonitorCPUModelInfoPtr model,
|
|
|
|
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;
|
|
|
|
|
|
|
|
switch (prop->type) {
|
|
|
|
case QEMU_MONITOR_CPU_PROPERTY_BOOLEAN:
|
2017-03-29 11:33:50 +00:00
|
|
|
if (!prop->value.boolean ||
|
|
|
|
(migratable && prop->migratable == VIR_TRISTATE_BOOL_NO))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (virCPUx86DataAddFeature(data, prop->name) < 0)
|
2017-01-11 13:36:34 +00:00
|
|
|
goto cleanup;
|
2017-03-29 11:33:50 +00:00
|
|
|
|
2017-01-11 13:36:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case QEMU_MONITOR_CPU_PROPERTY_STRING:
|
|
|
|
if (STREQ(prop->name, "vendor") &&
|
|
|
|
virCPUx86DataSetVendor(data, prop->value.string) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case QEMU_MONITOR_CPU_PROPERTY_NUMBER:
|
|
|
|
if (STREQ(prop->name, "family"))
|
|
|
|
sigFamily = prop->value.number;
|
|
|
|
else if (STREQ(prop->name, "model"))
|
|
|
|
sigModel = prop->value.number;
|
2017-10-10 11:34:28 +00:00
|
|
|
else if (STREQ(prop->name, "stepping"))
|
|
|
|
sigStepping = prop->value.number;
|
2017-01-11 13:36:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case QEMU_MONITOR_CPU_PROPERTY_LAST:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-10 11:34:28 +00:00
|
|
|
if (virCPUx86DataSetSignature(data, sigFamily, sigModel, sigStepping) < 0)
|
2017-01-11 13:36:34 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2019-02-25 08:39:17 +00:00
|
|
|
VIR_STEAL_PTR(ret, data);
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
virCPUDataPtr data = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
if (!model)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
if (!(data = virQEMUCapsGetCPUModelX86Data(model, migratable)))
|
|
|
|
goto cleanup;
|
|
|
|
|
2017-09-26 08:24:05 +00:00
|
|
|
if (cpuDecode(cpu, data, virQEMUCapsGetCPUDefinitions(qemuCaps, type)) < 0)
|
2017-01-11 13:36:34 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virCPUDataFree(data);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-10 18:16:24 +00:00
|
|
|
/**
|
|
|
|
* Returns 0 when host CPU model provided by QEMU was filled in qemuCaps,
|
2017-11-27 12:12:17 +00:00
|
|
|
* 1 when the caller should fall back to other methods,
|
|
|
|
* 2 when cpu model info is not supported for this configuration,
|
2017-01-10 18:16:24 +00:00
|
|
|
* -1 on error.
|
|
|
|
*/
|
2017-02-23 13:31:23 +00:00
|
|
|
int
|
2017-01-10 18:16:24 +00:00
|
|
|
virQEMUCapsInitCPUModel(virQEMUCapsPtr qemuCaps,
|
2017-02-22 15:51:50 +00:00
|
|
|
virDomainVirtType type,
|
2017-03-29 11:33:50 +00:00
|
|
|
virCPUDefPtr cpu,
|
|
|
|
bool migratable)
|
2017-01-10 18:16:24 +00:00
|
|
|
{
|
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);
|
|
|
|
}
|
2017-01-10 18:16:24 +00:00
|
|
|
|
2017-01-10 20:07:23 +00:00
|
|
|
if (ret == 0)
|
|
|
|
cpu->fallback = VIR_CPU_FALLBACK_FORBID;
|
|
|
|
|
2017-01-10 18:16:24 +00:00
|
|
|
return ret;
|
2017-01-06 07:52:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-03-29 13:31:17 +00:00
|
|
|
static virCPUDefPtr
|
|
|
|
virQEMUCapsNewHostCPUModel(void)
|
|
|
|
{
|
|
|
|
virCPUDefPtr cpu;
|
|
|
|
|
|
|
|
if (VIR_ALLOC(cpu) < 0)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
cpu->type = VIR_CPU_TYPE_GUEST;
|
|
|
|
cpu->mode = VIR_CPU_MODE_CUSTOM;
|
|
|
|
cpu->match = VIR_CPU_MATCH_EXACT;
|
|
|
|
cpu->fallback = VIR_CPU_FALLBACK_ALLOW;
|
|
|
|
|
|
|
|
return cpu;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-10 18:16:24 +00:00
|
|
|
void
|
|
|
|
virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps,
|
2017-07-21 13:09:54 +00:00
|
|
|
virArch hostArch,
|
2017-02-22 15:51:50 +00:00
|
|
|
virDomainVirtType type)
|
2017-01-06 07:52:22 +00:00
|
|
|
{
|
|
|
|
virCPUDefPtr cpu = NULL;
|
2018-04-11 08:57:32 +00:00
|
|
|
virCPUDefPtr cpuExpanded = NULL;
|
2017-03-29 13:31:17 +00:00
|
|
|
virCPUDefPtr migCPU = NULL;
|
2017-03-08 12:32:46 +00:00
|
|
|
virCPUDefPtr hostCPU = NULL;
|
2017-04-11 18:46:05 +00:00
|
|
|
virCPUDefPtr fullCPU = NULL;
|
|
|
|
size_t i;
|
2017-01-10 18:16:24 +00:00
|
|
|
int rc;
|
2017-01-06 07:52:22 +00:00
|
|
|
|
2017-07-21 13:09:54 +00:00
|
|
|
if (!virQEMUCapsGuestIsNative(hostArch, qemuCaps->arch))
|
2017-01-10 18:16:24 +00:00
|
|
|
return;
|
|
|
|
|
2017-03-29 13:31:17 +00:00
|
|
|
if (!(cpu = virQEMUCapsNewHostCPUModel()))
|
2017-01-10 18:16:24 +00:00
|
|
|
goto error;
|
|
|
|
|
2017-03-29 11:33:50 +00:00
|
|
|
if ((rc = virQEMUCapsInitCPUModel(qemuCaps, type, cpu, false)) < 0) {
|
2017-01-10 18:16:24 +00:00
|
|
|
goto error;
|
|
|
|
} else if (rc == 1) {
|
2017-03-08 12:32:46 +00:00
|
|
|
VIR_DEBUG("No host CPU model info from QEMU; probing host CPU directly");
|
2016-06-15 12:35:18 +00:00
|
|
|
|
2017-07-21 13:09:54 +00:00
|
|
|
hostCPU = virQEMUCapsProbeHostCPUForEmulator(hostArch, qemuCaps, type);
|
2017-03-08 12:32:46 +00:00
|
|
|
if (!hostCPU ||
|
|
|
|
virCPUDefCopyModelFilter(cpu, hostCPU, true,
|
2017-01-18 13:05:26 +00:00
|
|
|
virQEMUCapsCPUFilterFeatures,
|
2017-09-13 15:26:07 +00:00
|
|
|
&qemuCaps->arch) < 0)
|
2016-06-15 12:35:18 +00:00
|
|
|
goto error;
|
2017-11-24 08:02:02 +00:00
|
|
|
} else if (rc == 2) {
|
|
|
|
VIR_DEBUG("QEMU does not provide CPU model for arch=%s virttype=%s",
|
|
|
|
virArchToString(qemuCaps->arch),
|
|
|
|
virDomainVirtTypeToString(type));
|
|
|
|
goto error;
|
2017-04-11 18:46:05 +00:00
|
|
|
} else if (type == VIR_DOMAIN_VIRT_KVM &&
|
|
|
|
virCPUGetHostIsSupported(qemuCaps->arch)) {
|
|
|
|
if (!(fullCPU = virCPUGetHost(qemuCaps->arch, VIR_CPU_TYPE_GUEST,
|
2017-09-22 13:51:33 +00:00
|
|
|
NULL, NULL)))
|
2017-04-11 18:46:05 +00:00
|
|
|
goto error;
|
|
|
|
|
2018-04-11 08:57:32 +00:00
|
|
|
if (!(cpuExpanded = virCPUDefCopy(cpu)) ||
|
|
|
|
virCPUExpandFeatures(qemuCaps->arch, cpuExpanded) < 0)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
for (i = 0; i < cpuExpanded->nfeatures; i++) {
|
|
|
|
if (cpuExpanded->features[i].policy == VIR_CPU_FEATURE_REQUIRE &&
|
|
|
|
virCPUDefUpdateFeature(fullCPU, cpuExpanded->features[i].name,
|
2017-04-11 18:46:05 +00:00
|
|
|
VIR_CPU_FEATURE_REQUIRE) < 0)
|
|
|
|
goto error;
|
|
|
|
}
|
2016-06-15 12:35:18 +00:00
|
|
|
}
|
|
|
|
|
2017-03-29 13:31:17 +00:00
|
|
|
if (!(migCPU = virQEMUCapsNewHostCPUModel()))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
if ((rc = virQEMUCapsInitCPUModel(qemuCaps, type, migCPU, true)) < 0) {
|
|
|
|
goto error;
|
|
|
|
} else if (rc == 1) {
|
|
|
|
VIR_DEBUG("CPU migratability not provided by QEMU");
|
|
|
|
|
|
|
|
virCPUDefFree(migCPU);
|
|
|
|
if (!(migCPU = virCPUCopyMigratable(qemuCaps->arch, cpu)))
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2017-04-11 18:46:05 +00:00
|
|
|
virQEMUCapsSetHostModel(qemuCaps, type, cpu, migCPU, fullCPU);
|
2017-02-22 15:51:50 +00:00
|
|
|
|
2017-03-08 12:32:46 +00:00
|
|
|
cleanup:
|
2018-04-11 08:57:32 +00:00
|
|
|
virCPUDefFree(cpuExpanded);
|
2017-03-08 12:32:46 +00:00
|
|
|
virCPUDefFree(hostCPU);
|
2016-06-15 12:35:18 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
error:
|
|
|
|
virCPUDefFree(cpu);
|
2017-03-29 13:31:17 +00:00
|
|
|
virCPUDefFree(migCPU);
|
2017-04-11 18:46:05 +00:00
|
|
|
virCPUDefFree(fullCPU);
|
2016-06-15 12:35:18 +00:00
|
|
|
virResetLastError();
|
2017-03-08 12:32:46 +00:00
|
|
|
goto cleanup;
|
2016-06-15 12:35:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-02-25 09:01:34 +00:00
|
|
|
qemuMonitorCPUModelInfoPtr
|
|
|
|
virQEMUCapsGetCPUModelInfo(virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainVirtType type)
|
|
|
|
{
|
|
|
|
virQEMUCapsHostCPUDataPtr cpuData = virQEMUCapsGetHostCPUData(qemuCaps, type);
|
|
|
|
|
|
|
|
return cpuData->info;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-23 13:31:23 +00:00
|
|
|
void
|
|
|
|
virQEMUCapsSetCPUModelInfo(virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainVirtType type,
|
|
|
|
qemuMonitorCPUModelInfoPtr modelInfo)
|
|
|
|
{
|
2017-04-07 16:15:26 +00:00
|
|
|
virQEMUCapsHostCPUDataPtr cpuData = virQEMUCapsGetHostCPUData(qemuCaps, type);
|
|
|
|
|
|
|
|
cpuData->info = modelInfo;
|
2017-02-23 13:31:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-06 07:52:22 +00:00
|
|
|
static int
|
|
|
|
virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsPtr qemuCaps,
|
2017-02-22 15:51:50 +00:00
|
|
|
xmlXPathContextPtr ctxt,
|
|
|
|
virDomainVirtType virtType)
|
2017-01-06 07:52:22 +00:00
|
|
|
{
|
|
|
|
char *str = NULL;
|
|
|
|
xmlNodePtr hostCPUNode;
|
2017-01-30 15:30:13 +00:00
|
|
|
xmlNodePtr *nodes = NULL;
|
2019-02-26 16:42:25 +00:00
|
|
|
VIR_XPATH_NODE_AUTORESTORE(ctxt);
|
2017-01-06 07:52:22 +00:00
|
|
|
qemuMonitorCPUModelInfoPtr hostCPU = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
size_t i;
|
|
|
|
int n;
|
2017-03-29 08:33:08 +00:00
|
|
|
int val;
|
2017-01-06 07:52:22 +00:00
|
|
|
|
2017-02-22 15:51:50 +00:00
|
|
|
if (virtType == VIR_DOMAIN_VIRT_KVM)
|
|
|
|
hostCPUNode = virXPathNode("./hostCPU[@type='kvm']", ctxt);
|
|
|
|
else
|
|
|
|
hostCPUNode = virXPathNode("./hostCPU[@type='tcg']", ctxt);
|
|
|
|
|
|
|
|
if (!hostCPUNode) {
|
2017-01-06 07:52:22 +00:00
|
|
|
ret = 0;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (VIR_ALLOC(hostCPU) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (!(hostCPU->name = virXMLPropString(hostCPUNode, "model"))) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("missing host CPU model name in QEMU "
|
|
|
|
"capabilities cache"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2017-03-29 08:33:08 +00:00
|
|
|
if (!(str = virXMLPropString(hostCPUNode, "migratability")) ||
|
|
|
|
(val = virTristateBoolTypeFromString(str)) <= 0) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("invalid migratability value for host CPU model"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
hostCPU->migratability = val == VIR_TRISTATE_BOOL_YES;
|
|
|
|
VIR_FREE(str);
|
|
|
|
|
2017-01-06 07:52:22 +00:00
|
|
|
ctxt->node = hostCPUNode;
|
|
|
|
|
2017-01-30 15:30:13 +00:00
|
|
|
if ((n = virXPathNodeSet("./property", ctxt, &nodes)) > 0) {
|
2017-01-06 07:52:22 +00:00
|
|
|
if (VIR_ALLOC_N(hostCPU->props, n) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
hostCPU->nprops = n;
|
|
|
|
|
|
|
|
for (i = 0; i < n; i++) {
|
2017-02-22 15:01:30 +00:00
|
|
|
qemuMonitorCPUPropertyPtr prop = hostCPU->props + i;
|
|
|
|
|
|
|
|
ctxt->node = nodes[i];
|
|
|
|
|
|
|
|
if (!(prop->name = virXMLPropString(ctxt->node, "name"))) {
|
2017-01-06 07:52:22 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("missing 'name' attribute for a host CPU"
|
2017-01-30 15:30:13 +00:00
|
|
|
" model property in QEMU capabilities cache"));
|
2017-01-06 07:52:22 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2017-02-22 15:01:30 +00:00
|
|
|
if (!(str = virXMLPropString(ctxt->node, "type")) ||
|
2017-03-29 08:33:08 +00:00
|
|
|
(val = qemuMonitorCPUPropertyTypeFromString(str)) < 0) {
|
2017-01-06 07:52:22 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
2017-02-22 15:01:30 +00:00
|
|
|
_("missing or invalid CPU model property type "
|
|
|
|
"in QEMU capabilities cache"));
|
2017-01-06 07:52:22 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
VIR_FREE(str);
|
2017-02-22 15:01:30 +00:00
|
|
|
|
2017-03-29 08:33:08 +00:00
|
|
|
prop->type = val;
|
2017-02-22 15:01:30 +00:00
|
|
|
switch (prop->type) {
|
|
|
|
case QEMU_MONITOR_CPU_PROPERTY_BOOLEAN:
|
|
|
|
if (virXPathBoolean("./@value='true'", ctxt))
|
|
|
|
prop->value.boolean = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case QEMU_MONITOR_CPU_PROPERTY_STRING:
|
|
|
|
prop->value.string = virXMLPropString(ctxt->node, "value");
|
|
|
|
if (!prop->value.string) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("invalid string value for '%s' host CPU "
|
|
|
|
"model property in QEMU capabilities cache"),
|
|
|
|
prop->name);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case QEMU_MONITOR_CPU_PROPERTY_NUMBER:
|
|
|
|
if (virXPathLongLong("string(./@value)", ctxt,
|
|
|
|
&prop->value.number) < 0) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("invalid number value for '%s' host CPU "
|
|
|
|
"model property in QEMU capabilities cache"),
|
|
|
|
prop->name);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case QEMU_MONITOR_CPU_PROPERTY_LAST:
|
|
|
|
break;
|
|
|
|
}
|
2017-03-29 08:33:08 +00:00
|
|
|
|
|
|
|
if ((str = virXMLPropString(ctxt->node, "migratable"))) {
|
|
|
|
if ((val = virTristateBoolTypeFromString(str)) <= 0) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("unknown migratable value for '%s' host "
|
|
|
|
"CPU model property"),
|
|
|
|
prop->name);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
prop->migratable = val;
|
|
|
|
VIR_FREE(str);
|
|
|
|
}
|
2017-01-06 07:52:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-23 13:31:23 +00:00
|
|
|
virQEMUCapsSetCPUModelInfo(qemuCaps, virtType, hostCPU);
|
2017-01-06 07:52:22 +00:00
|
|
|
hostCPU = NULL;
|
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
VIR_FREE(str);
|
2017-01-30 15:30:13 +00:00
|
|
|
VIR_FREE(nodes);
|
2017-01-06 07:52:22 +00:00
|
|
|
qemuMonitorCPUModelInfoFree(hostCPU);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-11-14 20:51:19 +00:00
|
|
|
static int
|
|
|
|
virQEMUCapsLoadCPUModels(virQEMUCapsPtr qemuCaps,
|
2016-11-14 16:21:30 +00:00
|
|
|
xmlXPathContextPtr ctxt,
|
|
|
|
virDomainVirtType type)
|
2016-11-14 20:51:19 +00:00
|
|
|
{
|
2016-11-14 16:21:30 +00:00
|
|
|
virDomainCapsCPUModelsPtr cpus = NULL;
|
2016-11-14 20:51:19 +00:00
|
|
|
xmlNodePtr *nodes = NULL;
|
|
|
|
char *str = NULL;
|
|
|
|
size_t i;
|
|
|
|
int n;
|
|
|
|
int ret = -1;
|
2017-09-21 14:11:14 +00:00
|
|
|
xmlNodePtr node;
|
|
|
|
xmlNodePtr *blockerNodes = NULL;
|
|
|
|
char **blockers = NULL;
|
|
|
|
int nblockers;
|
2016-11-14 20:51:19 +00:00
|
|
|
|
2016-11-14 16:21:30 +00:00
|
|
|
if (type == VIR_DOMAIN_VIRT_KVM)
|
|
|
|
n = virXPathNodeSet("./cpu[@type='kvm']", ctxt, &nodes);
|
|
|
|
else
|
|
|
|
n = virXPathNodeSet("./cpu[@type='tcg']", ctxt, &nodes);
|
|
|
|
|
|
|
|
if (n < 0) {
|
2016-11-14 20:51:19 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("failed to parse qemu capabilities cpus"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (n == 0) {
|
|
|
|
ret = 0;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2016-11-14 16:21:30 +00:00
|
|
|
if (!(cpus = virDomainCapsCPUModelsNew(n)))
|
2016-11-14 20:51:19 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2016-11-14 16:21:30 +00:00
|
|
|
if (type == VIR_DOMAIN_VIRT_KVM)
|
|
|
|
qemuCaps->kvmCPUModels = cpus;
|
|
|
|
else
|
|
|
|
qemuCaps->tcgCPUModels = cpus;
|
|
|
|
|
2016-11-14 20:51:19 +00:00
|
|
|
for (i = 0; i < n; i++) {
|
2016-04-21 11:08:12 +00:00
|
|
|
int usable = VIR_DOMCAPS_CPU_USABLE_UNKNOWN;
|
|
|
|
|
|
|
|
if ((str = virXMLPropString(nodes[i], "usable")) &&
|
|
|
|
(usable = virDomainCapsCPUUsableTypeFromString(str)) < 0) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("unknown value '%s' in attribute 'usable'"), str);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
VIR_FREE(str);
|
|
|
|
|
2016-11-14 20:51:19 +00:00
|
|
|
if (!(str = virXMLPropString(nodes[i], "name"))) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("missing cpu name in QEMU capabilities cache"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2017-09-21 14:11:14 +00:00
|
|
|
node = ctxt->node;
|
|
|
|
ctxt->node = nodes[i];
|
|
|
|
nblockers = virXPathNodeSet("./blocker", ctxt, &blockerNodes);
|
|
|
|
ctxt->node = node;
|
|
|
|
|
|
|
|
if (nblockers < 0) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("failed to parse CPU blockers in QEMU capabilities"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nblockers > 0) {
|
|
|
|
size_t j;
|
|
|
|
|
|
|
|
if (VIR_ALLOC_N(blockers, nblockers + 1) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
for (j = 0; j < nblockers; j++) {
|
|
|
|
if (!(blockers[j] = virXMLPropString(blockerNodes[j], "name"))) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("missing blocker name in QEMU "
|
|
|
|
"capabilities cache"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
}
|
2017-10-27 07:53:03 +00:00
|
|
|
VIR_FREE(blockerNodes);
|
2017-09-21 14:11:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (virDomainCapsCPUModelsAddSteal(cpus, &str, usable, &blockers) < 0)
|
2016-11-14 20:51:19 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
VIR_FREE(nodes);
|
|
|
|
VIR_FREE(str);
|
2017-09-21 14:11:14 +00:00
|
|
|
VIR_FREE(blockerNodes);
|
|
|
|
virStringListFree(blockers);
|
2016-11-14 20:51:19 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-19 15:02:40 +00:00
|
|
|
struct _virQEMUCapsCachePriv {
|
|
|
|
char *libDir;
|
|
|
|
uid_t runUid;
|
|
|
|
gid_t runGid;
|
|
|
|
virArch hostArch;
|
2017-12-12 15:23:41 +00:00
|
|
|
unsigned int microcodeVersion;
|
2018-01-22 10:37:04 +00:00
|
|
|
char *kernelVersion;
|
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;
|
|
|
|
|
2017-06-20 14:17:23 +00:00
|
|
|
VIR_FREE(priv->libDir);
|
2018-01-22 10:37:04 +00:00
|
|
|
VIR_FREE(priv->kernelVersion);
|
2017-06-20 14:17:23 +00:00
|
|
|
VIR_FREE(priv);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-08-09 13:27:26 +00:00
|
|
|
static int
|
|
|
|
virQEMUCapsParseSEVInfo(virQEMUCapsPtr qemuCaps, xmlXPathContextPtr ctxt)
|
|
|
|
{
|
|
|
|
VIR_AUTOPTR(virSEVCapability) sev = NULL;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (VIR_ALLOC(sev) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
VIR_STEAL_PTR(qemuCaps->sevCapabilities, sev);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-05 16:51:59 +00:00
|
|
|
/*
|
|
|
|
* Parsing a doc that looks like
|
|
|
|
*
|
|
|
|
* <qemuCaps>
|
|
|
|
* <qemuctime>234235253</qemuctime>
|
|
|
|
* <selfctime>234235253</selfctime>
|
2015-05-23 14:19:20 +00:00
|
|
|
* <selfvers>1002016</selfvers>
|
2014-03-05 16:51:59 +00:00
|
|
|
* <flag name='foo'/>
|
|
|
|
* <flag name='bar'/>
|
|
|
|
* ...
|
|
|
|
* <cpu name="pentium3"/>
|
|
|
|
* ...
|
2018-08-10 12:18:27 +00:00
|
|
|
* <machine name="pc-1.0" alias="pc" hotplugCpus='yes' maxCpus="4" default="yes"/>
|
2014-03-05 16:51:59 +00:00
|
|
|
* ...
|
|
|
|
* </qemuCaps>
|
|
|
|
*/
|
2016-04-28 13:01:02 +00:00
|
|
|
int
|
2017-07-21 13:09:54 +00:00
|
|
|
virQEMUCapsLoadCache(virArch hostArch,
|
2016-06-15 12:35:18 +00:00
|
|
|
virQEMUCapsPtr qemuCaps,
|
2017-06-13 15:55:45 +00:00
|
|
|
const char *filename)
|
2014-03-05 16:51:59 +00:00
|
|
|
{
|
|
|
|
xmlDocPtr doc = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
size_t i;
|
|
|
|
int n;
|
|
|
|
xmlNodePtr *nodes = NULL;
|
|
|
|
xmlXPathContextPtr ctxt = NULL;
|
2014-03-19 16:13:19 +00:00
|
|
|
char *str = NULL;
|
2014-03-05 16:51:59 +00:00
|
|
|
long long int l;
|
2015-05-23 14:19:20 +00:00
|
|
|
unsigned long lu;
|
2014-03-05 16:51:59 +00:00
|
|
|
|
|
|
|
if (!(doc = virXMLParseFile(filename)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (!(ctxt = xmlXPathNewContext(doc))) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
ctxt->node = xmlDocGetRootElement(doc);
|
|
|
|
|
|
|
|
if (STRNEQ((const char *)ctxt->node->name, "qemuCaps")) {
|
|
|
|
virReportError(VIR_ERR_XML_ERROR,
|
|
|
|
_("unexpected root element <%s>, "
|
|
|
|
"expecting <qemuCaps>"),
|
|
|
|
ctxt->node->name);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (virXPathLongLong("string(./qemuctime)", ctxt, &l) < 0) {
|
|
|
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
|
|
_("missing qemuctime in QEMU capabilities XML"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2016-10-27 08:54:13 +00:00
|
|
|
qemuCaps->ctime = (time_t)l;
|
2014-03-05 16:51:59 +00:00
|
|
|
|
|
|
|
if (virXPathLongLong("string(./selfctime)", ctxt, &l) < 0) {
|
|
|
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
|
|
_("missing selfctime in QEMU capabilities XML"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2017-06-13 15:55:45 +00:00
|
|
|
qemuCaps->libvirtCtime = (time_t)l;
|
2014-03-05 16:51:59 +00:00
|
|
|
|
2017-06-13 15:55:45 +00:00
|
|
|
qemuCaps->libvirtVersion = 0;
|
2015-05-23 14:19:20 +00:00
|
|
|
if (virXPathULong("string(./selfvers)", ctxt, &lu) == 0)
|
2017-06-13 15:55:45 +00:00
|
|
|
qemuCaps->libvirtVersion = lu;
|
2015-05-23 14:19:20 +00:00
|
|
|
|
2014-03-05 16:51:59 +00:00
|
|
|
if ((n = virXPathNodeSet("./flag", ctxt, &nodes)) < 0) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("failed to parse qemu capabilities flags"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
VIR_DEBUG("Got flags %d", n);
|
2016-02-22 10:04:38 +00:00
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
int flag;
|
|
|
|
if (!(str = virXMLPropString(nodes[i], "name"))) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("missing flag name in QEMU capabilities cache"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
flag = virQEMUCapsTypeFromString(str);
|
|
|
|
if (flag < 0) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Unknown qemu capabilities flag %s"), str);
|
|
|
|
goto cleanup;
|
2014-03-05 16:51:59 +00:00
|
|
|
}
|
2016-02-22 10:04:38 +00:00
|
|
|
VIR_FREE(str);
|
|
|
|
virQEMUCapsSet(qemuCaps, flag);
|
2014-03-05 16:51:59 +00:00
|
|
|
}
|
|
|
|
VIR_FREE(nodes);
|
|
|
|
|
|
|
|
if (virXPathUInt("string(./version)", ctxt, &qemuCaps->version) < 0) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("missing version in QEMU capabilities cache"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (virXPathUInt("string(./kvmVersion)", ctxt, &qemuCaps->kvmVersion) < 0) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("missing version in QEMU capabilities cache"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2017-12-12 15:23:41 +00:00
|
|
|
if (virXPathUInt("string(./microcodeVersion)", ctxt,
|
|
|
|
&qemuCaps->microcodeVersion) < 0) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("missing microcode version in QEMU capabilities cache"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2016-08-04 20:43:22 +00:00
|
|
|
if (virXPathBoolean("boolean(./package)", ctxt) > 0) {
|
|
|
|
qemuCaps->package = virXPathString("string(./package)", ctxt);
|
|
|
|
if (!qemuCaps->package &&
|
|
|
|
VIR_STRDUP(qemuCaps->package, "") < 0)
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2015-02-02 10:28:30 +00:00
|
|
|
|
2018-01-22 10:37:04 +00:00
|
|
|
if (virXPathBoolean("boolean(./kernelVersion)", ctxt) > 0) {
|
|
|
|
qemuCaps->kernelVersion = virXPathString("string(./kernelVersion)", ctxt);
|
|
|
|
if (!qemuCaps->kernelVersion)
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2014-03-05 16:51:59 +00:00
|
|
|
if (!(str = virXPathString("string(./arch)", ctxt))) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("missing arch in QEMU capabilities cache"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
if (!(qemuCaps->arch = virArchFromString(str))) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("unknown arch %s in QEMU capabilities cache"), str);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2014-03-19 16:13:19 +00:00
|
|
|
VIR_FREE(str);
|
2014-03-05 16:51:59 +00:00
|
|
|
|
2017-02-22 15:51:50 +00:00
|
|
|
if (virQEMUCapsLoadHostCPUModelInfo(qemuCaps, ctxt, VIR_DOMAIN_VIRT_KVM) < 0 ||
|
|
|
|
virQEMUCapsLoadHostCPUModelInfo(qemuCaps, ctxt, VIR_DOMAIN_VIRT_QEMU) < 0)
|
2017-01-06 07:52:22 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2016-11-14 16:21:30 +00:00
|
|
|
if (virQEMUCapsLoadCPUModels(qemuCaps, ctxt, VIR_DOMAIN_VIRT_KVM) < 0 ||
|
|
|
|
virQEMUCapsLoadCPUModels(qemuCaps, ctxt, VIR_DOMAIN_VIRT_QEMU) < 0)
|
2014-03-05 16:51:59 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if ((n = virXPathNodeSet("./machine", ctxt, &nodes)) < 0) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("failed to parse qemu capabilities machines"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
if (n > 0) {
|
|
|
|
qemuCaps->nmachineTypes = n;
|
2016-07-29 08:13:46 +00:00
|
|
|
if (VIR_ALLOC_N(qemuCaps->machineTypes, qemuCaps->nmachineTypes) < 0)
|
2014-03-05 16:51:59 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
for (i = 0; i < n; i++) {
|
2016-07-29 08:13:46 +00:00
|
|
|
if (!(qemuCaps->machineTypes[i].name = virXMLPropString(nodes[i], "name"))) {
|
2014-03-05 16:51:59 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("missing machine name in QEMU capabilities cache"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2016-07-29 08:13:46 +00:00
|
|
|
qemuCaps->machineTypes[i].alias = virXMLPropString(nodes[i], "alias");
|
2014-03-05 16:51:59 +00:00
|
|
|
|
|
|
|
str = virXMLPropString(nodes[i], "maxCpus");
|
|
|
|
if (str &&
|
2016-07-29 08:13:46 +00:00
|
|
|
virStrToLong_ui(str, NULL, 10, &(qemuCaps->machineTypes[i].maxCpus)) < 0) {
|
2014-03-05 16:51:59 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("malformed machine cpu count in QEMU capabilities cache"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2014-03-19 16:13:19 +00:00
|
|
|
VIR_FREE(str);
|
2016-07-29 07:45:19 +00:00
|
|
|
|
|
|
|
str = virXMLPropString(nodes[i], "hotplugCpus");
|
|
|
|
if (STREQ_NULLABLE(str, "yes"))
|
|
|
|
qemuCaps->machineTypes[i].hotplugCpus = true;
|
|
|
|
VIR_FREE(str);
|
2018-08-10 12:18:27 +00:00
|
|
|
|
|
|
|
str = virXMLPropString(nodes[i], "default");
|
|
|
|
if (STREQ_NULLABLE(str, "yes"))
|
|
|
|
qemuCaps->machineTypes[i].qemuDefault = true;
|
|
|
|
VIR_FREE(str);
|
2014-03-05 16:51:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
VIR_FREE(nodes);
|
|
|
|
|
2016-03-10 16:59:51 +00:00
|
|
|
if ((n = virXPathNodeSet("./gic", ctxt, &nodes)) < 0) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("failed to parse qemu capabilities gic"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
if (n > 0) {
|
|
|
|
unsigned int uintValue;
|
|
|
|
bool boolValue;
|
|
|
|
|
|
|
|
qemuCaps->ngicCapabilities = n;
|
|
|
|
if (VIR_ALLOC_N(qemuCaps->gicCapabilities, n) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
virGICCapabilityPtr cap = &qemuCaps->gicCapabilities[i];
|
|
|
|
|
|
|
|
if (!(str = virXMLPropString(nodes[i], "version"))) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("missing GIC version "
|
|
|
|
"in QEMU capabilities cache"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
if (virStrToLong_ui(str, NULL, 10, &uintValue) < 0) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("malformed GIC version "
|
|
|
|
"in QEMU capabilities cache"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
cap->version = uintValue;
|
|
|
|
VIR_FREE(str);
|
|
|
|
|
|
|
|
if (!(str = virXMLPropString(nodes[i], "kernel"))) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("missing in-kernel GIC information "
|
|
|
|
"in QEMU capabilities cache"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
if (!(boolValue = STREQ(str, "yes")) && STRNEQ(str, "no")) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("malformed in-kernel GIC information "
|
|
|
|
"in QEMU capabilities cache"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
if (boolValue)
|
|
|
|
cap->implementation |= VIR_GIC_IMPLEMENTATION_KERNEL;
|
|
|
|
VIR_FREE(str);
|
|
|
|
|
|
|
|
if (!(str = virXMLPropString(nodes[i], "emulated"))) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("missing emulated GIC information "
|
|
|
|
"in QEMU capabilities cache"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
if (!(boolValue = STREQ(str, "yes")) && STRNEQ(str, "no")) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("malformed emulated GIC information "
|
|
|
|
"in QEMU capabilities cache"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
if (boolValue)
|
|
|
|
cap->implementation |= VIR_GIC_IMPLEMENTATION_EMULATED;
|
|
|
|
VIR_FREE(str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
VIR_FREE(nodes);
|
|
|
|
|
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;
|
|
|
|
|
2014-03-05 16:51:59 +00:00
|
|
|
ret = 0;
|
2014-03-25 06:49:44 +00:00
|
|
|
cleanup:
|
2014-03-19 16:13:19 +00:00
|
|
|
VIR_FREE(str);
|
2014-03-05 16:51:59 +00:00
|
|
|
VIR_FREE(nodes);
|
|
|
|
xmlXPathFreeContext(ctxt);
|
|
|
|
xmlFreeDoc(doc);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-13 17:42:57 +00:00
|
|
|
static void
|
|
|
|
virQEMUCapsFormatHostCPUModelInfo(virQEMUCapsPtr qemuCaps,
|
2017-02-22 15:51:50 +00:00
|
|
|
virBufferPtr buf,
|
|
|
|
virDomainVirtType type)
|
2017-01-13 17:42:57 +00:00
|
|
|
{
|
2019-02-25 09:00:53 +00:00
|
|
|
qemuMonitorCPUModelInfoPtr model = virQEMUCapsGetCPUModelInfo(qemuCaps, type);
|
2017-04-07 16:15:26 +00:00
|
|
|
const char *typeStr = type == VIR_DOMAIN_VIRT_KVM ? "kvm" : "tcg";
|
2017-01-13 17:42:57 +00:00
|
|
|
size_t i;
|
|
|
|
|
2017-02-22 15:51:50 +00:00
|
|
|
if (!model)
|
|
|
|
return;
|
|
|
|
|
2017-03-29 08:33:08 +00:00
|
|
|
virBufferAsprintf(buf,
|
|
|
|
"<hostCPU type='%s' model='%s' migratability='%s'>\n",
|
|
|
|
typeStr, model->name,
|
|
|
|
model->migratability ? "yes" : "no");
|
2017-01-13 17:42:57 +00:00
|
|
|
virBufferAdjustIndent(buf, 2);
|
|
|
|
|
|
|
|
for (i = 0; i < model->nprops; i++) {
|
2017-02-22 15:01:30 +00:00
|
|
|
qemuMonitorCPUPropertyPtr prop = model->props + i;
|
|
|
|
|
|
|
|
virBufferAsprintf(buf, "<property name='%s' type='%s' ",
|
|
|
|
prop->name,
|
|
|
|
qemuMonitorCPUPropertyTypeToString(prop->type));
|
|
|
|
|
|
|
|
switch (prop->type) {
|
|
|
|
case QEMU_MONITOR_CPU_PROPERTY_BOOLEAN:
|
|
|
|
virBufferAsprintf(buf, "value='%s'",
|
|
|
|
prop->value.boolean ? "true" : "false");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case QEMU_MONITOR_CPU_PROPERTY_STRING:
|
|
|
|
virBufferEscapeString(buf, "value='%s'", prop->value.string);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case QEMU_MONITOR_CPU_PROPERTY_NUMBER:
|
|
|
|
virBufferAsprintf(buf, "value='%lld'", prop->value.number);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case QEMU_MONITOR_CPU_PROPERTY_LAST:
|
|
|
|
break;
|
|
|
|
}
|
2017-03-29 08:33:08 +00:00
|
|
|
|
|
|
|
if (prop->migratable > 0)
|
|
|
|
virBufferAsprintf(buf, " migratable='%s'",
|
|
|
|
virTristateBoolTypeToString(prop->migratable));
|
|
|
|
|
2017-02-22 15:01:30 +00:00
|
|
|
virBufferAddLit(buf, "/>\n");
|
2017-01-13 17:42:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virBufferAdjustIndent(buf, -2);
|
|
|
|
virBufferAddLit(buf, "</hostCPU>\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-11-14 20:51:31 +00:00
|
|
|
static void
|
|
|
|
virQEMUCapsFormatCPUModels(virQEMUCapsPtr qemuCaps,
|
2016-11-14 16:21:30 +00:00
|
|
|
virBufferPtr buf,
|
|
|
|
virDomainVirtType type)
|
2016-11-14 20:51:31 +00:00
|
|
|
{
|
2016-11-14 16:21:30 +00:00
|
|
|
virDomainCapsCPUModelsPtr cpus;
|
|
|
|
const char *typeStr;
|
2016-11-14 20:51:31 +00:00
|
|
|
size_t i;
|
|
|
|
|
2016-11-14 16:21:30 +00:00
|
|
|
if (type == VIR_DOMAIN_VIRT_KVM) {
|
|
|
|
typeStr = "kvm";
|
|
|
|
cpus = qemuCaps->kvmCPUModels;
|
|
|
|
} else {
|
|
|
|
typeStr = "tcg";
|
|
|
|
cpus = qemuCaps->tcgCPUModels;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!cpus)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < cpus->nmodels; i++) {
|
2016-04-21 11:08:12 +00:00
|
|
|
virDomainCapsCPUModelPtr cpu = cpus->models + i;
|
|
|
|
|
2016-11-14 16:21:30 +00:00
|
|
|
virBufferAsprintf(buf, "<cpu type='%s' ", typeStr);
|
2016-04-21 11:08:12 +00:00
|
|
|
virBufferEscapeString(buf, "name='%s'", cpu->name);
|
|
|
|
if (cpu->usable) {
|
|
|
|
virBufferAsprintf(buf, " usable='%s'",
|
|
|
|
virDomainCapsCPUUsableTypeToString(cpu->usable));
|
|
|
|
}
|
2017-09-21 14:11:14 +00:00
|
|
|
|
|
|
|
if (cpu->blockers) {
|
|
|
|
size_t j;
|
|
|
|
|
|
|
|
virBufferAddLit(buf, ">\n");
|
|
|
|
virBufferAdjustIndent(buf, 2);
|
|
|
|
|
|
|
|
for (j = 0; cpu->blockers[j]; j++)
|
|
|
|
virBufferAsprintf(buf, "<blocker name='%s'/>\n", cpu->blockers[j]);
|
|
|
|
|
|
|
|
virBufferAdjustIndent(buf, -2);
|
|
|
|
virBufferAddLit(buf, "</cpu>\n");
|
|
|
|
} else {
|
|
|
|
virBufferAddLit(buf, "/>\n");
|
|
|
|
}
|
2016-11-14 20:51:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
{
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
2016-04-28 12:59:15 +00:00
|
|
|
char *ret = NULL;
|
2014-03-05 16:51:59 +00:00
|
|
|
size_t i;
|
|
|
|
|
|
|
|
virBufferAddLit(&buf, "<qemuCaps>\n");
|
2014-03-13 00:35:01 +00:00
|
|
|
virBufferAdjustIndent(&buf, 2);
|
2014-03-05 16:51:59 +00:00
|
|
|
|
2014-03-13 00:35:01 +00:00
|
|
|
virBufferAsprintf(&buf, "<qemuctime>%llu</qemuctime>\n",
|
2018-04-25 12:42:34 +00:00
|
|
|
(long long)qemuCaps->ctime);
|
2014-03-13 00:35:01 +00:00
|
|
|
virBufferAsprintf(&buf, "<selfctime>%llu</selfctime>\n",
|
2018-04-25 12:42:34 +00:00
|
|
|
(long long)qemuCaps->libvirtCtime);
|
2015-05-23 14:19:20 +00:00
|
|
|
virBufferAsprintf(&buf, "<selfvers>%lu</selfvers>\n",
|
2018-04-25 12:42:34 +00:00
|
|
|
(unsigned long)qemuCaps->libvirtVersion);
|
2014-03-05 16:51:59 +00:00
|
|
|
|
|
|
|
for (i = 0; i < QEMU_CAPS_LAST; i++) {
|
|
|
|
if (virQEMUCapsGet(qemuCaps, i)) {
|
2014-03-13 00:35:01 +00:00
|
|
|
virBufferAsprintf(&buf, "<flag name='%s'/>\n",
|
2014-03-05 16:51:59 +00:00
|
|
|
virQEMUCapsTypeToString(i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-13 00:35:01 +00:00
|
|
|
virBufferAsprintf(&buf, "<version>%d</version>\n",
|
2014-03-05 16:51:59 +00:00
|
|
|
qemuCaps->version);
|
|
|
|
|
2014-03-13 00:35:01 +00:00
|
|
|
virBufferAsprintf(&buf, "<kvmVersion>%d</kvmVersion>\n",
|
2014-03-05 16:51:59 +00:00
|
|
|
qemuCaps->kvmVersion);
|
|
|
|
|
2017-12-12 15:23:41 +00:00
|
|
|
virBufferAsprintf(&buf, "<microcodeVersion>%u</microcodeVersion>\n",
|
|
|
|
qemuCaps->microcodeVersion);
|
|
|
|
|
2015-02-02 10:28:30 +00:00
|
|
|
if (qemuCaps->package)
|
|
|
|
virBufferAsprintf(&buf, "<package>%s</package>\n",
|
|
|
|
qemuCaps->package);
|
|
|
|
|
2018-01-22 10:37:04 +00:00
|
|
|
if (qemuCaps->kernelVersion)
|
|
|
|
virBufferAsprintf(&buf, "<kernelVersion>%s</kernelVersion>\n",
|
|
|
|
qemuCaps->kernelVersion);
|
|
|
|
|
2014-03-13 00:35:01 +00:00
|
|
|
virBufferAsprintf(&buf, "<arch>%s</arch>\n",
|
2014-03-05 16:51:59 +00:00
|
|
|
virArchToString(qemuCaps->arch));
|
|
|
|
|
2017-02-22 15:51:50 +00:00
|
|
|
virQEMUCapsFormatHostCPUModelInfo(qemuCaps, &buf, VIR_DOMAIN_VIRT_KVM);
|
|
|
|
virQEMUCapsFormatHostCPUModelInfo(qemuCaps, &buf, VIR_DOMAIN_VIRT_QEMU);
|
2017-01-06 07:52:22 +00:00
|
|
|
|
2016-11-14 16:21:30 +00:00
|
|
|
virQEMUCapsFormatCPUModels(qemuCaps, &buf, VIR_DOMAIN_VIRT_KVM);
|
|
|
|
virQEMUCapsFormatCPUModels(qemuCaps, &buf, VIR_DOMAIN_VIRT_QEMU);
|
2014-03-05 16:51:59 +00:00
|
|
|
|
|
|
|
for (i = 0; i < qemuCaps->nmachineTypes; i++) {
|
2014-03-13 00:35:01 +00:00
|
|
|
virBufferEscapeString(&buf, "<machine name='%s'",
|
2016-07-29 08:13:46 +00:00
|
|
|
qemuCaps->machineTypes[i].name);
|
|
|
|
if (qemuCaps->machineTypes[i].alias)
|
2014-03-05 16:51:59 +00:00
|
|
|
virBufferEscapeString(&buf, " alias='%s'",
|
2016-07-29 08:13:46 +00:00
|
|
|
qemuCaps->machineTypes[i].alias);
|
2016-07-29 07:45:19 +00:00
|
|
|
if (qemuCaps->machineTypes[i].hotplugCpus)
|
|
|
|
virBufferAddLit(&buf, " hotplugCpus='yes'");
|
2018-08-10 12:18:27 +00:00
|
|
|
virBufferAsprintf(&buf, " maxCpus='%u'",
|
2016-07-29 08:13:46 +00:00
|
|
|
qemuCaps->machineTypes[i].maxCpus);
|
2018-08-10 12:18:27 +00:00
|
|
|
if (qemuCaps->machineTypes[i].qemuDefault)
|
|
|
|
virBufferAddLit(&buf, " default='yes'");
|
|
|
|
virBufferAddLit(&buf, "/>\n");
|
2014-03-05 16:51:59 +00:00
|
|
|
}
|
|
|
|
|
2016-03-10 16:59:51 +00:00
|
|
|
for (i = 0; i < qemuCaps->ngicCapabilities; i++) {
|
|
|
|
virGICCapabilityPtr cap;
|
|
|
|
bool kernel;
|
|
|
|
bool emulated;
|
|
|
|
|
|
|
|
cap = &qemuCaps->gicCapabilities[i];
|
|
|
|
kernel = (cap->implementation & VIR_GIC_IMPLEMENTATION_KERNEL);
|
|
|
|
emulated = (cap->implementation & VIR_GIC_IMPLEMENTATION_EMULATED);
|
|
|
|
|
|
|
|
virBufferAsprintf(&buf,
|
|
|
|
"<gic version='%d' kernel='%s' emulated='%s'/>\n",
|
|
|
|
cap->version,
|
|
|
|
kernel ? "yes" : "no",
|
|
|
|
emulated ? "yes" : "no");
|
|
|
|
}
|
|
|
|
|
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");
|
|
|
|
|
2014-03-13 00:35:01 +00:00
|
|
|
virBufferAdjustIndent(&buf, -2);
|
2014-03-05 16:51:59 +00:00
|
|
|
virBufferAddLit(&buf, "</qemuCaps>\n");
|
|
|
|
|
2016-04-28 12:59:15 +00:00
|
|
|
if (virBufferCheckError(&buf) == 0)
|
|
|
|
ret = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2017-07-19 15:01:56 +00:00
|
|
|
virQEMUCapsSaveFile(void *data,
|
|
|
|
const char *filename,
|
|
|
|
void *privData ATTRIBUTE_UNUSED)
|
2016-04-28 12:59:15 +00:00
|
|
|
{
|
2017-07-19 15:01:56 +00:00
|
|
|
virQEMUCapsPtr qemuCaps = data;
|
2016-04-28 12:59:15 +00:00
|
|
|
char *xml = NULL;
|
|
|
|
int ret = -1;
|
2014-03-05 16:51:59 +00:00
|
|
|
|
2017-06-13 15:55:45 +00:00
|
|
|
xml = virQEMUCapsFormatCache(qemuCaps);
|
2014-03-05 16:51:59 +00:00
|
|
|
|
|
|
|
if (virFileWriteStr(filename, xml, 0600) < 0) {
|
|
|
|
virReportSystemError(errno,
|
|
|
|
_("Failed to save '%s' for '%s'"),
|
|
|
|
filename, qemuCaps->binary);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
VIR_DEBUG("Saved caps '%s' for '%s' with (%lld, %lld)",
|
|
|
|
filename, qemuCaps->binary,
|
|
|
|
(long long)qemuCaps->ctime,
|
2017-06-13 15:55:45 +00:00
|
|
|
(long long)qemuCaps->libvirtCtime);
|
2014-03-05 16:51:59 +00:00
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
cleanup:
|
|
|
|
VIR_FREE(xml);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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"};
|
|
|
|
VIR_AUTOFREE(char *) value = NULL;
|
|
|
|
int rc;
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_CARDINALITY(kmod); i++) {
|
|
|
|
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
|
|
|
|
|
|
|
if (!qemuCaps->binary)
|
|
|
|
return true;
|
|
|
|
|
2017-06-22 10:52:35 +00:00
|
|
|
if (qemuCaps->libvirtCtime != virGetSelfLastChanged() ||
|
|
|
|
qemuCaps->libvirtVersion != LIBVIR_VERSION_NUMBER) {
|
|
|
|
VIR_DEBUG("Outdated capabilities for '%s': libvirt changed "
|
|
|
|
"(%lld vs %lld, %lu vs %lu)",
|
|
|
|
qemuCaps->binary,
|
|
|
|
(long long)qemuCaps->libvirtCtime,
|
|
|
|
(long long)virGetSelfLastChanged(),
|
|
|
|
(unsigned long)qemuCaps->libvirtVersion,
|
|
|
|
(unsigned long)LIBVIR_VERSION_NUMBER);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-06-22 10:53:26 +00:00
|
|
|
if (stat(qemuCaps->binary, &sb) < 0) {
|
|
|
|
char ebuf[1024];
|
|
|
|
VIR_DEBUG("Failed to stat QEMU binary '%s': %s",
|
|
|
|
qemuCaps->binary,
|
|
|
|
virStrerror(errno, ebuf, sizeof(ebuf)));
|
|
|
|
return false;
|
2017-06-19 12:03:06 +00:00
|
|
|
}
|
|
|
|
|
2017-06-22 10:53:26 +00:00
|
|
|
if (sb.st_ctime != qemuCaps->ctime) {
|
2017-06-19 12:03:06 +00:00
|
|
|
VIR_DEBUG("Outdated capabilities for '%s': QEMU binary changed "
|
|
|
|
"(%lld vs %lld)",
|
|
|
|
qemuCaps->binary,
|
2018-04-25 12:42:34 +00:00
|
|
|
(long long)sb.st_ctime, (long long)qemuCaps->ctime);
|
2017-06-19 12:03:06 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
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)) {
|
|
|
|
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;
|
|
|
|
}
|
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)
|
|
|
|
{
|
|
|
|
char *archstr = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
if (!(archstr = qemuMonitorGetTargetArch(mon)))
|
2017-03-27 14:42:17 +00:00
|
|
|
goto cleanup;
|
2013-05-07 11:34:27 +00:00
|
|
|
|
|
|
|
if ((qemuCaps->arch = virQEMUCapsArchFromString(archstr)) == VIR_ARCH_NONE) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Unknown QEMU arch %s"), archstr);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2017-03-27 14:42:17 +00:00
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
VIR_FREE(archstr);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* virQEMUCapsInitQMPBasicArch:
|
|
|
|
* @qemuCaps: QEMU capabilities
|
|
|
|
*
|
|
|
|
* Initialize @qemuCaps with basic architecture-dependent capabilities.
|
|
|
|
*/
|
2017-03-02 18:24:22 +00:00
|
|
|
void
|
2017-03-27 14:42:17 +00:00
|
|
|
virQEMUCapsInitQMPBasicArch(virQEMUCapsPtr qemuCaps)
|
|
|
|
{
|
2017-03-02 17:57:51 +00:00
|
|
|
/* ACPI only works on x86 and aarch64 */
|
|
|
|
if (ARCH_IS_X86(qemuCaps->arch) ||
|
|
|
|
qemuCaps->arch == VIR_ARCH_AARCH64) {
|
2013-05-07 11:34:27 +00:00
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_NO_ACPI);
|
2017-03-02 17:57:51 +00:00
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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. */
|
|
|
|
if (qemuCaps->version < 2009000 &&
|
|
|
|
virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_NVDIMM))
|
|
|
|
virQEMUCapsClear(qemuCaps, QEMU_CAPS_DEVICE_NVDIMM);
|
|
|
|
|
|
|
|
if (ARCH_IS_X86(qemuCaps->arch) &&
|
|
|
|
virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION))
|
|
|
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_CPU_CACHE);
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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_SCSI_DISK_DEVICE_ID))
|
|
|
|
virQEMUCapsClear(qemuCaps, QEMU_CAPS_BLOCKDEV);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-10-19 12:40:53 +00:00
|
|
|
static int
|
|
|
|
virQEMUCapsProbeQMPSchemaCapabilities(virQEMUCapsPtr qemuCaps,
|
|
|
|
qemuMonitorPtr mon)
|
|
|
|
{
|
|
|
|
struct virQEMUCapsStringFlags *entry;
|
2018-03-20 08:29:30 +00:00
|
|
|
virJSONValuePtr schemareply;
|
|
|
|
virHashTablePtr schema = NULL;
|
2016-10-19 12:40:53 +00:00
|
|
|
size_t i;
|
|
|
|
|
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;
|
|
|
|
|
2016-10-19 12:40:53 +00:00
|
|
|
for (i = 0; i < ARRAY_CARDINALITY(virQEMUCapsQMPSchemaQueries); i++) {
|
|
|
|
entry = virQEMUCapsQMPSchemaQueries + i;
|
|
|
|
|
2018-03-20 07:57:44 +00:00
|
|
|
if (virQEMUQAPISchemaPathExists(entry->value, schema))
|
2016-10-19 12:40:53 +00:00
|
|
|
virQEMUCapsSet(qemuCaps, entry->flag);
|
|
|
|
}
|
|
|
|
|
2019-02-07 11:50:27 +00:00
|
|
|
/* probe also for basic event support */
|
|
|
|
for (i = 0; i < ARRAY_CARDINALITY(virQEMUCapsEvents); i++) {
|
|
|
|
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
|
|
|
|
2013-09-19 11:14:25 +00:00
|
|
|
int
|
|
|
|
virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps,
|
|
|
|
qemuMonitorPtr mon)
|
|
|
|
{
|
|
|
|
int major, minor, micro;
|
2019-03-29 08:32:14 +00:00
|
|
|
VIR_AUTOFREE(char *) package = NULL;
|
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-03-29 08:32:14 +00:00
|
|
|
VIR_STEAL_PTR(qemuCaps->package, package);
|
2013-09-19 11:14:25 +00:00
|
|
|
qemuCaps->usedQMP = true;
|
|
|
|
|
2017-03-27 14:42:17 +00:00
|
|
|
if (virQEMUCapsInitQMPArch(qemuCaps, mon) < 0)
|
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);
|
|
|
|
|
2019-03-29 08:05:45 +00:00
|
|
|
/* initiate all capapbilities based on qemu version */
|
|
|
|
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
|
|
|
|
2013-09-19 11:14:25 +00:00
|
|
|
if (virQEMUCapsProbeQMPEvents(qemuCaps, mon) < 0)
|
2019-03-29 08:25:21 +00:00
|
|
|
return -1;
|
2018-04-12 11:31:03 +00:00
|
|
|
if (virQEMUCapsProbeQMPDevices(qemuCaps, mon) < 0)
|
2019-03-29 08:25:21 +00:00
|
|
|
return -1;
|
2013-09-19 11:14:25 +00:00
|
|
|
if (virQEMUCapsProbeQMPMachineTypes(qemuCaps, mon) < 0)
|
2019-03-29 08:25:21 +00:00
|
|
|
return -1;
|
2019-05-16 13:46:58 +00:00
|
|
|
if (virQEMUCapsProbeQMPMachineProps(qemuCaps, mon) < 0)
|
|
|
|
return -1;
|
2016-11-14 16:21:30 +00:00
|
|
|
if (virQEMUCapsProbeQMPCPUDefinitions(qemuCaps, mon, false) < 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;
|
2017-02-22 15:51:50 +00:00
|
|
|
if (virQEMUCapsProbeQMPHostCPU(qemuCaps, mon, false) < 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-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)
|
|
|
|
{
|
2016-11-14 16:21:30 +00:00
|
|
|
if (virQEMUCapsProbeQMPCPUDefinitions(qemuCaps, mon, true) < 0)
|
2019-04-02 11:31:52 +00:00
|
|
|
return -1;
|
2016-11-14 16:21:30 +00:00
|
|
|
|
2017-02-22 15:51:50 +00:00
|
|
|
if (virQEMUCapsProbeQMPHostCPU(qemuCaps, mon, true) < 0)
|
2019-04-02 11:31:52 +00:00
|
|
|
return -1;
|
2017-02-22 15:51:50 +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
|
|
|
{
|
2019-01-13 00:50:03 +00:00
|
|
|
qemuProcessQMPPtr 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);
|
|
|
|
|
2019-01-13 00:50:03 +00:00
|
|
|
qemuProcessQMPFree(proc);
|
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) &&
|
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,
|
2017-12-12 15:23:41 +00:00
|
|
|
unsigned int microcodeVersion,
|
2018-03-28 20:46:41 +00:00
|
|
|
const char *kernelVersion)
|
2012-08-22 17:05:08 +00:00
|
|
|
{
|
2014-08-27 13:43:52 +00:00
|
|
|
virQEMUCapsPtr qemuCaps;
|
2012-08-22 17:05:08 +00:00
|
|
|
struct stat sb;
|
|
|
|
|
2014-08-27 13:43:52 +00:00
|
|
|
if (!(qemuCaps = virQEMUCapsNew()))
|
|
|
|
goto error;
|
|
|
|
|
2013-05-20 09:23:13 +00:00
|
|
|
if (VIR_STRDUP(qemuCaps->binary, binary) < 0)
|
|
|
|
goto error;
|
2012-08-22 17:05:08 +00:00
|
|
|
|
|
|
|
/* We would also want to check faccessat if we cared about ACLs,
|
|
|
|
* but we don't. */
|
|
|
|
if (stat(binary, &sb) < 0) {
|
|
|
|
virReportSystemError(errno, _("Cannot check QEMU binary %s"),
|
|
|
|
binary);
|
|
|
|
goto error;
|
|
|
|
}
|
2014-03-10 15:50:19 +00:00
|
|
|
qemuCaps->ctime = sb.st_ctime;
|
2012-08-22 17:05:08 +00:00
|
|
|
|
|
|
|
/* Make sure the binary we are about to try exec'ing exists.
|
|
|
|
* Technically we could catch the exec() failure, but that's
|
|
|
|
* in a sub-process so it's hard to feed back a useful error.
|
|
|
|
*/
|
|
|
|
if (!virFileIsExecutable(binary)) {
|
|
|
|
virReportSystemError(errno, _("QEMU binary %s is not executable"),
|
|
|
|
binary);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
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)) {
|
2017-12-12 15:23:41 +00:00
|
|
|
qemuCaps->microcodeVersion = microcodeVersion;
|
|
|
|
|
2018-01-22 10:37:04 +00:00
|
|
|
if (VIR_STRDUP(qemuCaps->kernelVersion, kernelVersion) < 0)
|
|
|
|
goto error;
|
2018-11-12 19:58:09 +00:00
|
|
|
|
|
|
|
qemuCaps->kvmSupportsNesting = virQEMUCapsKVMSupportsNesting();
|
2018-01-22 10:37:04 +00:00
|
|
|
}
|
|
|
|
|
2016-06-15 12:35:18 +00:00
|
|
|
cleanup:
|
2013-02-01 13:48:58 +00:00
|
|
|
return qemuCaps;
|
2012-09-10 10:47:56 +00:00
|
|
|
|
2014-03-25 06:49:44 +00:00
|
|
|
error:
|
2013-02-01 13:48:58 +00:00
|
|
|
virObjectUnref(qemuCaps);
|
|
|
|
qemuCaps = NULL;
|
2016-06-15 12:35:18 +00:00
|
|
|
goto cleanup;
|
2012-09-10 10:47:56 +00:00
|
|
|
}
|
|
|
|
|
2017-07-19 15:01:56 +00:00
|
|
|
static void *
|
|
|
|
virQEMUCapsNewData(const char *binary,
|
|
|
|
void *privData)
|
2016-04-26 13:03:06 +00:00
|
|
|
{
|
2017-07-19 15:01:56 +00:00
|
|
|
virQEMUCapsCachePrivPtr priv = privData;
|
|
|
|
|
|
|
|
return virQEMUCapsNewForBinaryInternal(priv->hostArch,
|
|
|
|
binary,
|
|
|
|
priv->libDir,
|
|
|
|
priv->runUid,
|
|
|
|
priv->runGid,
|
2019-04-12 19:21:05 +00:00
|
|
|
virHostCPUGetMicrocodeVersion(),
|
2018-03-28 20:46:41 +00:00
|
|
|
priv->kernelVersion);
|
2017-07-19 15:01:56 +00:00
|
|
|
}
|
2017-07-18 14:14:07 +00:00
|
|
|
|
|
|
|
|
2017-07-19 15:01:56 +00:00
|
|
|
static void *
|
|
|
|
virQEMUCapsLoadFile(const char *filename,
|
|
|
|
const char *binary,
|
|
|
|
void *privData)
|
|
|
|
{
|
|
|
|
virQEMUCapsPtr qemuCaps = virQEMUCapsNew();
|
|
|
|
virQEMUCapsCachePrivPtr priv = privData;
|
2017-07-18 14:14:07 +00:00
|
|
|
|
2017-07-19 15:01:56 +00:00
|
|
|
if (!qemuCaps)
|
|
|
|
return NULL;
|
2017-07-18 14:14:07 +00:00
|
|
|
|
2017-07-19 15:01:56 +00:00
|
|
|
if (VIR_STRDUP(qemuCaps->binary, binary) < 0)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
if (virQEMUCapsLoadCache(priv->hostArch, qemuCaps, filename) < 0)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
cleanup:
|
2017-07-18 14:14:07 +00:00
|
|
|
return qemuCaps;
|
|
|
|
|
|
|
|
error:
|
|
|
|
virObjectUnref(qemuCaps);
|
2017-07-19 15:01:56 +00:00
|
|
|
qemuCaps = NULL;
|
|
|
|
goto cleanup;
|
2016-04-26 13:03:06 +00:00
|
|
|
}
|
|
|
|
|
2012-09-10 10:47:56 +00:00
|
|
|
|
2015-02-12 13:50:31 +00:00
|
|
|
struct virQEMUCapsMachineTypeFilter {
|
|
|
|
const char *machineType;
|
|
|
|
virQEMUCapsFlags *flags;
|
|
|
|
size_t nflags;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct virQEMUCapsMachineTypeFilter virQEMUCapsMachineFilter[] = {
|
|
|
|
/* { "blah", virQEMUCapsMachineBLAHFilter,
|
|
|
|
ARRAY_CARDINALITY(virQEMUCapsMachineBLAHFilter) }, */
|
|
|
|
{ "", NULL, 0 },
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
virQEMUCapsFilterByMachineType(virQEMUCapsPtr qemuCaps,
|
|
|
|
const char *machineType)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
if (!machineType)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_CARDINALITY(virQEMUCapsMachineFilter); i++) {
|
|
|
|
const struct virQEMUCapsMachineTypeFilter *filter = &virQEMUCapsMachineFilter[i];
|
|
|
|
size_t j;
|
|
|
|
|
|
|
|
if (STRNEQ(filter->machineType, machineType))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (j = 0; j < filter->nflags; j++)
|
|
|
|
virQEMUCapsClear(qemuCaps, filter->flags[j]);
|
|
|
|
}
|
|
|
|
|
2016-07-29 07:45:19 +00:00
|
|
|
if (!virQEMUCapsGetMachineHotplugCpus(qemuCaps, machineType))
|
|
|
|
virQEMUCapsClear(qemuCaps, QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);
|
2015-02-12 13:50:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-19 15:01:56 +00:00
|
|
|
virFileCacheHandlers qemuCapsCacheHandlers = {
|
|
|
|
.isValid = virQEMUCapsIsValid,
|
|
|
|
.newData = virQEMUCapsNewData,
|
|
|
|
.loadFile = virQEMUCapsLoadFile,
|
|
|
|
.saveFile = virQEMUCapsSaveFile,
|
|
|
|
.privFree = virQEMUCapsCachePrivFree,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
virFileCachePtr
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsCacheNew(const char *libDir,
|
2014-03-05 16:51:59 +00:00
|
|
|
const char *cacheDir,
|
2013-02-01 13:48:58 +00:00
|
|
|
uid_t runUid,
|
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
|
|
|
|
2017-07-19 15:01:56 +00:00
|
|
|
if (virAsprintf(&capsCacheDir, "%s/capabilities", cacheDir) < 0)
|
2012-08-22 12:54:13 +00:00
|
|
|
goto error;
|
2017-07-19 15:01:56 +00:00
|
|
|
|
|
|
|
if (!(cache = virFileCacheNew(capsCacheDir, "xml", &qemuCapsCacheHandlers)))
|
2014-03-05 16:51:59 +00:00
|
|
|
goto error;
|
2012-08-22 12:54:13 +00:00
|
|
|
|
2017-07-19 15:01:56 +00:00
|
|
|
if (VIR_ALLOC(priv) < 0)
|
2017-06-20 14:17:23 +00:00
|
|
|
goto error;
|
2017-07-19 15:01:56 +00:00
|
|
|
virFileCacheSetPriv(cache, priv);
|
2017-06-20 14:17:23 +00:00
|
|
|
|
2017-07-19 15:01:56 +00:00
|
|
|
if (VIR_STRDUP(priv->libDir, libDir) < 0)
|
2017-06-20 14:17:23 +00:00
|
|
|
goto error;
|
|
|
|
|
2017-07-19 15:01:56 +00:00
|
|
|
priv->hostArch = virArchFromHost();
|
2017-07-21 13:09:54 +00:00
|
|
|
|
2017-07-19 15:01:56 +00:00
|
|
|
priv->runUid = runUid;
|
|
|
|
priv->runGid = runGid;
|
2018-10-29 17:34:58 +00:00
|
|
|
priv->kvmUsable = VIR_TRISTATE_BOOL_ABSENT;
|
2012-11-26 14:17:13 +00:00
|
|
|
|
2018-01-22 10:37:04 +00:00
|
|
|
if (uname(&uts) == 0 &&
|
|
|
|
virAsprintf(&priv->kernelVersion, "%s %s", uts.release, uts.version) < 0)
|
|
|
|
goto error;
|
|
|
|
|
2017-07-19 15:01:56 +00:00
|
|
|
cleanup:
|
|
|
|
VIR_FREE(capsCacheDir);
|
2012-08-22 12:54:13 +00:00
|
|
|
return cache;
|
|
|
|
|
2014-03-25 06:49:44 +00:00
|
|
|
error:
|
2017-07-19 15:01:56 +00:00
|
|
|
virObjectUnref(cache);
|
|
|
|
cache = NULL;
|
|
|
|
goto cleanup;
|
2016-11-16 12:47:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsPtr
|
2017-07-19 15:01:56 +00:00
|
|
|
virQEMUCapsCacheLookup(virFileCachePtr cache,
|
2016-06-15 11:48:19 +00:00
|
|
|
const char *binary)
|
2012-08-22 12:54:13 +00:00
|
|
|
{
|
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
|
|
|
|
2019-04-12 19:21:05 +00:00
|
|
|
priv->microcodeVersion = virHostCPUGetMicrocodeVersion();
|
|
|
|
|
2017-07-19 15:01:56 +00:00
|
|
|
ret = virFileCacheLookup(cache, binary);
|
2016-11-16 12:47:09 +00:00
|
|
|
|
|
|
|
VIR_DEBUG("Returning caps %p for %s", ret, binary);
|
2012-08-22 12:54:13 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsPtr
|
2017-07-19 15:01:56 +00:00
|
|
|
virQEMUCapsCacheLookupCopy(virFileCachePtr cache,
|
2015-02-12 12:48:42 +00:00
|
|
|
const char *binary,
|
2015-02-12 13:50:31 +00:00
|
|
|
const char *machineType)
|
2012-08-22 12:54:13 +00:00
|
|
|
{
|
2017-07-21 13:09:54 +00:00
|
|
|
virQEMUCapsPtr qemuCaps = virQEMUCapsCacheLookup(cache, binary);
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsPtr ret;
|
2012-08-22 12:54:13 +00:00
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
if (!qemuCaps)
|
2012-08-22 12:54:13 +00:00
|
|
|
return NULL;
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
ret = virQEMUCapsNewCopy(qemuCaps);
|
|
|
|
virObjectUnref(qemuCaps);
|
2017-02-09 14:13:35 +00:00
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
return NULL;
|
|
|
|
|
2015-02-12 13:50:31 +00:00
|
|
|
virQEMUCapsFilterByMachineType(ret, machineType);
|
2012-08-22 12:54:13 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-30 14:12:07 +00:00
|
|
|
static int
|
|
|
|
virQEMUCapsCompareArch(const void *payload,
|
|
|
|
const void *name ATTRIBUTE_UNUSED,
|
|
|
|
const void *opaque)
|
|
|
|
{
|
2018-04-25 12:42:34 +00:00
|
|
|
struct virQEMUCapsSearchData *data = (struct virQEMUCapsSearchData *)opaque;
|
2014-06-30 14:12:07 +00:00
|
|
|
const virQEMUCaps *qemuCaps = payload;
|
|
|
|
|
2018-09-14 12:36:15 +00:00
|
|
|
if (qemuCaps->arch != data->arch)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (data->binaryFilter &&
|
|
|
|
!strstr(qemuCaps->binary, data->binaryFilter)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2014-06-30 14:12:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
virQEMUCapsPtr
|
2017-07-19 15:01:56 +00:00
|
|
|
virQEMUCapsCacheLookupByArch(virFileCachePtr cache,
|
2014-06-30 14:12:07 +00:00
|
|
|
virArch arch)
|
|
|
|
{
|
2019-04-12 19:21:05 +00:00
|
|
|
virQEMUCapsCachePrivPtr priv = virFileCacheGetPriv(cache);
|
2014-06-30 14:12:07 +00:00
|
|
|
virQEMUCapsPtr ret = NULL;
|
2018-09-14 12:36:15 +00:00
|
|
|
const char *binaryFilters[] = {
|
|
|
|
"qemu-system-",
|
|
|
|
NULL,
|
|
|
|
};
|
2018-09-14 12:29:51 +00:00
|
|
|
virArch archs[] = {
|
|
|
|
arch,
|
|
|
|
virQEMUCapsFindTarget(virArchFromHost(), arch),
|
|
|
|
};
|
2018-09-14 12:36:15 +00:00
|
|
|
size_t i;
|
2018-09-14 12:29:51 +00:00
|
|
|
size_t j;
|
|
|
|
|
2019-04-12 19:21:05 +00:00
|
|
|
priv->microcodeVersion = virHostCPUGetMicrocodeVersion();
|
|
|
|
|
2018-09-14 12:36:15 +00:00
|
|
|
for (i = 0; i < ARRAY_CARDINALITY(binaryFilters); i++) {
|
|
|
|
for (j = 0; j < ARRAY_CARDINALITY(archs); j++) {
|
|
|
|
struct virQEMUCapsSearchData data = {
|
|
|
|
.arch = archs[j],
|
|
|
|
.binaryFilter = binaryFilters[i],
|
|
|
|
};
|
2016-11-16 13:17:12 +00:00
|
|
|
|
2018-09-14 12:36:15 +00:00
|
|
|
ret = virFileCacheLookupByFunc(cache, virQEMUCapsCompareArch, &data);
|
|
|
|
if (ret)
|
|
|
|
goto done;
|
|
|
|
}
|
2016-11-16 13:17:12 +00:00
|
|
|
}
|
|
|
|
|
2018-09-14 12:29:51 +00:00
|
|
|
virReportError(VIR_ERR_INVALID_ARG,
|
|
|
|
_("unable to find any emulator to serve '%s' "
|
|
|
|
"architecture"), virArchToString(arch));
|
|
|
|
|
|
|
|
done:
|
2015-09-15 13:58:09 +00:00
|
|
|
VIR_DEBUG("Returning caps %p for arch %s", ret, virArchToString(arch));
|
|
|
|
|
2014-06-30 14:12:07 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
int arch = virArchFromHost();
|
|
|
|
virDomainVirtType capsType;
|
|
|
|
virQEMUCapsPtr qemuCaps = NULL;
|
|
|
|
virQEMUCapsPtr ret = NULL;
|
|
|
|
|
|
|
|
if (virttypeStr &&
|
|
|
|
(virttype = virDomainVirtTypeFromString(virttypeStr)) < 0) {
|
|
|
|
virReportError(VIR_ERR_INVALID_ARG,
|
|
|
|
_("unknown virttype: %s"), virttypeStr);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (archStr &&
|
|
|
|
(arch = virArchFromString(archStr)) == VIR_ARCH_NONE) {
|
|
|
|
virReportError(VIR_ERR_INVALID_ARG,
|
|
|
|
_("unknown architecture: %s"), archStr);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (binary) {
|
|
|
|
virArch arch_from_caps;
|
|
|
|
|
|
|
|
if (!(qemuCaps = virQEMUCapsCacheLookup(cache, binary)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
arch_from_caps = virQEMUCapsGetArch(qemuCaps);
|
|
|
|
|
|
|
|
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));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!(qemuCaps = virQEMUCapsCacheLookupByArch(cache, arch)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
binary = virQEMUCapsGetBinary(qemuCaps);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (machine) {
|
|
|
|
/* Turn @machine into canonical name */
|
|
|
|
machine = virQEMUCapsGetCanonicalMachine(qemuCaps, machine);
|
|
|
|
|
|
|
|
if (!virQEMUCapsIsMachineSupported(qemuCaps, machine)) {
|
|
|
|
virReportError(VIR_ERR_INVALID_ARG,
|
|
|
|
_("the machine '%s' is not supported by emulator '%s'"),
|
|
|
|
machine, binary);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
} else {
|
2018-08-10 14:06:38 +00:00
|
|
|
machine = virQEMUCapsGetPreferredMachine(qemuCaps);
|
2018-05-07 20:51:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM))
|
|
|
|
capsType = VIR_DOMAIN_VIRT_KVM;
|
|
|
|
else
|
|
|
|
capsType = VIR_DOMAIN_VIRT_QEMU;
|
|
|
|
|
|
|
|
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);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (retArch)
|
|
|
|
*retArch = arch;
|
|
|
|
if (retVirttype)
|
|
|
|
*retVirttype = virttype;
|
|
|
|
if (retMachine)
|
|
|
|
*retMachine = machine;
|
|
|
|
|
|
|
|
VIR_STEAL_PTR(ret, qemuCaps);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virObjectUnref(qemuCaps);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-04-21 11:28:40 +00:00
|
|
|
bool
|
|
|
|
virQEMUCapsSupportsVmport(virQEMUCapsPtr qemuCaps,
|
|
|
|
const virDomainDef *def)
|
|
|
|
{
|
|
|
|
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_VMPORT_OPT))
|
|
|
|
return false;
|
|
|
|
|
2017-04-18 10:43:58 +00:00
|
|
|
return qemuDomainIsI440FX(def) ||
|
|
|
|
qemuDomainIsQ35(def) ||
|
2015-04-21 11:28:40 +00:00
|
|
|
STREQ(def->os.machine, "isapc");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-30 14:31:51 +00:00
|
|
|
bool
|
|
|
|
virQEMUCapsIsMachineSupported(virQEMUCapsPtr qemuCaps,
|
|
|
|
const char *canonical_machine)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
for (i = 0; i < qemuCaps->nmachineTypes; i++) {
|
2016-07-29 08:13:46 +00:00
|
|
|
if (STREQ(canonical_machine, qemuCaps->machineTypes[i].name))
|
2014-06-30 14:31:51 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2014-06-30 14:39:18 +00:00
|
|
|
|
|
|
|
|
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 *
|
2018-08-10 14:06:38 +00:00
|
|
|
virQEMUCapsGetPreferredMachine(virQEMUCapsPtr qemuCaps)
|
2014-06-30 14:39:18 +00:00
|
|
|
{
|
|
|
|
if (!qemuCaps->nmachineTypes)
|
|
|
|
return NULL;
|
2016-07-29 08:13:46 +00:00
|
|
|
return qemuCaps->machineTypes[0].name;
|
2014-06-30 14:39:18 +00:00
|
|
|
}
|
2014-06-25 16:39:29 +00:00
|
|
|
|
|
|
|
|
2014-09-17 09:33:35 +00:00
|
|
|
static int
|
2016-05-20 11:29:54 +00:00
|
|
|
virQEMUCapsFillDomainLoaderCaps(virDomainCapsLoaderPtr capsLoader,
|
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
|
|
|
|
2016-05-17 22:45:27 +00:00
|
|
|
if (VIR_ALLOC_N(capsLoader->values.values, nfirmwares) < 0)
|
2014-09-16 23:52:54 +00:00
|
|
|
return -1;
|
|
|
|
|
2016-05-17 22:45:27 +00:00
|
|
|
for (i = 0; i < nfirmwares; i++) {
|
|
|
|
const char *filename = firmwares[i]->name;
|
2014-09-16 23:52:54 +00:00
|
|
|
|
|
|
|
if (!virFileExists(filename)) {
|
|
|
|
VIR_DEBUG("loader filename=%s does not exist", filename);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2014-09-18 06:30:40 +00:00
|
|
|
if (VIR_STRDUP(capsLoader->values.values[capsLoader->values.nvalues],
|
2014-09-16 23:52:54 +00:00
|
|
|
filename) < 0)
|
|
|
|
return -1;
|
2014-09-18 06:30:40 +00:00
|
|
|
capsLoader->values.nvalues++;
|
2014-09-16 23:52:54 +00:00
|
|
|
}
|
|
|
|
|
2014-09-18 06:30:40 +00:00
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(capsLoader->type,
|
2014-09-16 12:47:47 +00:00
|
|
|
VIR_DOMAIN_LOADER_TYPE_ROM);
|
|
|
|
|
2015-11-06 18:20:20 +00:00
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(capsLoader->type,
|
|
|
|
VIR_DOMAIN_LOADER_TYPE_PFLASH);
|
2014-09-16 12:47:47 +00:00
|
|
|
|
|
|
|
|
2016-05-20 11:29:54 +00:00
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(capsLoader->readonly,
|
|
|
|
VIR_TRISTATE_BOOL_YES,
|
|
|
|
VIR_TRISTATE_BOOL_NO);
|
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;
|
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;
|
|
|
|
|
|
|
|
if (qemuFirmwareGetSupported(machine, arch, privileged, &autoFirmwares, &secure) < 0)
|
|
|
|
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);
|
|
|
|
|
|
|
|
if (virQEMUCapsFillDomainLoaderCaps(capsLoader, secure, firmwares, nfirmwares) < 0)
|
2014-09-17 09:33:35 +00:00
|
|
|
return -1;
|
|
|
|
return 0;
|
2014-09-16 12:47:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-22 20:22:30 +00:00
|
|
|
static int
|
|
|
|
virQEMUCapsFillDomainCPUCaps(virCapsPtr caps,
|
|
|
|
virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainCapsPtr domCaps)
|
|
|
|
{
|
2016-08-03 14:22:30 +00:00
|
|
|
if (virQEMUCapsIsCPUModeSupported(qemuCaps, caps, domCaps->virttype,
|
|
|
|
VIR_CPU_MODE_HOST_PASSTHROUGH))
|
2016-04-22 20:22:30 +00:00
|
|
|
domCaps->cpu.hostPassthrough = true;
|
|
|
|
|
2016-08-03 14:22:30 +00:00
|
|
|
if (virQEMUCapsIsCPUModeSupported(qemuCaps, caps, domCaps->virttype,
|
2017-02-22 15:51:50 +00:00
|
|
|
VIR_CPU_MODE_HOST_MODEL)) {
|
2017-04-11 09:14:30 +00:00
|
|
|
virCPUDefPtr cpu = virQEMUCapsGetHostModel(qemuCaps, domCaps->virttype,
|
|
|
|
VIR_QEMU_CAPS_HOST_CPU_REPORTED);
|
2017-02-22 15:51:50 +00:00
|
|
|
domCaps->cpu.hostModel = virCPUDefCopy(cpu);
|
|
|
|
}
|
2016-08-03 14:22:30 +00:00
|
|
|
|
|
|
|
if (virQEMUCapsIsCPUModeSupported(qemuCaps, caps, domCaps->virttype,
|
|
|
|
VIR_CPU_MODE_CUSTOM)) {
|
|
|
|
virDomainCapsCPUModelsPtr filtered = NULL;
|
|
|
|
char **models = NULL;
|
2016-11-20 22:21:19 +00:00
|
|
|
const char *blacklist[] = { "host", NULL };
|
2016-04-22 20:22:30 +00:00
|
|
|
|
2016-11-04 13:20:39 +00:00
|
|
|
if (virCPUGetModels(domCaps->arch, &models) >= 0) {
|
2016-11-14 16:21:30 +00:00
|
|
|
virDomainCapsCPUModelsPtr cpus;
|
|
|
|
|
|
|
|
if (domCaps->virttype == VIR_DOMAIN_VIRT_KVM)
|
|
|
|
cpus = qemuCaps->kvmCPUModels;
|
|
|
|
else
|
|
|
|
cpus = qemuCaps->tcgCPUModels;
|
|
|
|
|
|
|
|
filtered = virDomainCapsCPUModelsFilter(cpus,
|
2018-04-25 12:42:34 +00:00
|
|
|
(const char **)models,
|
2016-11-20 22:21:19 +00:00
|
|
|
blacklist);
|
2016-11-25 08:18:35 +00:00
|
|
|
virStringListFree(models);
|
2016-08-03 14:22:30 +00:00
|
|
|
}
|
|
|
|
domCaps->cpu.custom = filtered;
|
2016-04-29 08:42:56 +00:00
|
|
|
}
|
2016-04-22 20:22:30 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-10-19 12:19:38 +00:00
|
|
|
static int
|
|
|
|
virQEMUCapsFillDomainIOThreadCaps(virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainCapsPtr domCaps)
|
|
|
|
{
|
2019-02-08 23:03:20 +00:00
|
|
|
domCaps->iothreads = virTristateBoolFromBool(
|
|
|
|
virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_IOTHREAD));
|
2017-10-19 12:19:38 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-17 09:33:35 +00:00
|
|
|
static int
|
2014-06-25 16:39:29 +00:00
|
|
|
virQEMUCapsFillDomainDeviceDiskCaps(virQEMUCapsPtr qemuCaps,
|
2015-07-30 11:54:26 +00:00
|
|
|
const char *machine,
|
2014-06-25 16:39:29 +00:00
|
|
|
virDomainCapsDeviceDiskPtr disk)
|
|
|
|
{
|
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-09-17 09:33:35 +00:00
|
|
|
return 0;
|
2014-06-25 16:39:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-05-08 15:57:20 +00:00
|
|
|
static int
|
|
|
|
virQEMUCapsFillDomainDeviceGraphicsCaps(virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainCapsDeviceGraphicsPtr dev)
|
|
|
|
{
|
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);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-05-08 16:11:39 +00:00
|
|
|
static int
|
|
|
|
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
|
|
|
|
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VGA))
|
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(dev->modelType, VIR_DOMAIN_VIDEO_TYPE_VGA);
|
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_CIRRUS_VGA))
|
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(dev->modelType, VIR_DOMAIN_VIDEO_TYPE_CIRRUS);
|
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VMWARE_SVGA))
|
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(dev->modelType, VIR_DOMAIN_VIDEO_TYPE_VMVGA);
|
2016-10-11 15:42:37 +00:00
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QXL))
|
2016-05-08 16:11:39 +00:00
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(dev->modelType, VIR_DOMAIN_VIDEO_TYPE_QXL);
|
|
|
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_GPU))
|
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(dev->modelType, VIR_DOMAIN_VIDEO_TYPE_VIRTIO);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-17 09:33:35 +00:00
|
|
|
static int
|
2014-06-25 16:39:29 +00:00
|
|
|
virQEMUCapsFillDomainDeviceHostdevCaps(virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainCapsDeviceHostdevPtr hostdev)
|
|
|
|
{
|
|
|
|
bool supportsPassthroughKVM = qemuHostdevHostSupportsPassthroughLegacy();
|
|
|
|
bool supportsPassthroughVFIO = qemuHostdevHostSupportsPassthroughVFIO();
|
|
|
|
|
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,
|
|
|
|
VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB,
|
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
|
|
|
|
|
|
|
/* No virDomainHostdevCapsType for QEMU */
|
|
|
|
virDomainCapsEnumClear(&hostdev->capsType);
|
|
|
|
|
|
|
|
virDomainCapsEnumClear(&hostdev->pciBackend);
|
|
|
|
if (supportsPassthroughVFIO &&
|
|
|
|
virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) {
|
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(hostdev->pciBackend,
|
|
|
|
VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT,
|
|
|
|
VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO);
|
|
|
|
}
|
|
|
|
|
2016-05-20 12:33:58 +00:00
|
|
|
if (supportsPassthroughKVM) {
|
2014-06-25 16:39:29 +00:00
|
|
|
VIR_DOMAIN_CAPS_ENUM_SET(hostdev->pciBackend,
|
|
|
|
VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT,
|
|
|
|
VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM);
|
|
|
|
}
|
2014-09-17 09:33:35 +00:00
|
|
|
return 0;
|
2014-06-25 16:39:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-05-16 11:23:01 +00:00
|
|
|
/**
|
|
|
|
* virQEMUCapsSupportsGICVersion:
|
|
|
|
* @qemuCaps: QEMU capabilities
|
|
|
|
* @virtType: domain type
|
|
|
|
* @version: GIC version
|
|
|
|
*
|
|
|
|
* Checks the QEMU binary with capabilities @qemuCaps supports a specific
|
2017-08-16 13:44:35 +00:00
|
|
|
* GIC version for a domain of type @virtType. If @qemuCaps is NULL, the GIC
|
|
|
|
* @version is considered unsupported.
|
2016-05-16 11:23:01 +00:00
|
|
|
*
|
|
|
|
* Returns: true if the binary supports the requested GIC version, false
|
|
|
|
* otherwise
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
virQEMUCapsSupportsGICVersion(virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainVirtType virtType,
|
|
|
|
virGICVersion version)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
2017-08-16 13:44:35 +00:00
|
|
|
if (!qemuCaps)
|
|
|
|
return false;
|
|
|
|
|
2016-05-16 11:23:01 +00:00
|
|
|
for (i = 0; i < qemuCaps->ngicCapabilities; i++) {
|
|
|
|
virGICCapabilityPtr cap = &(qemuCaps->gicCapabilities[i]);
|
|
|
|
|
|
|
|
if (cap->version != version)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (virtType == VIR_DOMAIN_VIRT_KVM &&
|
|
|
|
cap->implementation & VIR_GIC_IMPLEMENTATION_KERNEL)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (virtType == VIR_DOMAIN_VIRT_QEMU &&
|
|
|
|
cap->implementation & VIR_GIC_IMPLEMENTATION_EMULATED)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-03-09 18:18:24 +00:00
|
|
|
/**
|
|
|
|
* virQEMUCapsFillDomainFeatureGICCaps:
|
|
|
|
* @qemuCaps: QEMU capabilities
|
|
|
|
* @domCaps: domain capabilities
|
|
|
|
*
|
|
|
|
* Take the information about GIC capabilities that has been obtained
|
|
|
|
* using the 'query-gic-capabilities' QMP command and stored in @qemuCaps
|
|
|
|
* and convert it to a form suitable for @domCaps.
|
|
|
|
*
|
|
|
|
* @qemuCaps contains complete information about the GIC capabilities for
|
|
|
|
* the corresponding QEMU binary, stored as custom objects; @domCaps, on
|
|
|
|
* the other hand, should only contain information about the GIC versions
|
|
|
|
* available for the specific combination of architecture, machine type
|
|
|
|
* and virtualization type. Moreover, a common format is used to store
|
|
|
|
* information about enumerations in @domCaps, so further processing is
|
|
|
|
* required.
|
|
|
|
*
|
|
|
|
* Returns: 0 on success, <0 on failure
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
virQEMUCapsFillDomainFeatureGICCaps(virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainCapsPtr domCaps)
|
|
|
|
{
|
|
|
|
virDomainCapsFeatureGICPtr gic = &domCaps->gic;
|
2016-05-16 11:23:01 +00:00
|
|
|
virGICVersion version;
|
2016-03-09 18:18:24 +00:00
|
|
|
|
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))
|
2016-03-09 18:18:24 +00:00
|
|
|
return 0;
|
|
|
|
|
2016-05-16 11:23:01 +00:00
|
|
|
for (version = VIR_GIC_VERSION_LAST - 1;
|
|
|
|
version > VIR_GIC_VERSION_NONE;
|
|
|
|
version--) {
|
|
|
|
if (!virQEMUCapsSupportsGICVersion(qemuCaps,
|
|
|
|
domCaps->virttype,
|
|
|
|
version))
|
2016-03-09 18:18:24 +00:00
|
|
|
continue;
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
*
|
|
|
|
* Returns: 0 on success, -1 on failure
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
virQEMUCapsFillDomainFeatureSEVCaps(virQEMUCapsPtr qemuCaps,
|
|
|
|
virDomainCapsPtr domCaps)
|
|
|
|
{
|
|
|
|
virSEVCapability *cap = qemuCaps->sevCapabilities;
|
2018-08-15 15:02:06 +00:00
|
|
|
VIR_AUTOPTR(virSEVCapability) sev = NULL;
|
2018-06-08 14:40:52 +00:00
|
|
|
|
|
|
|
if (!cap)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (VIR_ALLOC(sev) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (VIR_STRDUP(sev->pdh, cap->pdh) < 0)
|
2018-08-15 15:02:06 +00:00
|
|
|
return -1;
|
2018-06-08 14:40:52 +00:00
|
|
|
|
|
|
|
if (VIR_STRDUP(sev->cert_chain, cap->cert_chain) < 0)
|
2018-08-15 15:02:06 +00:00
|
|
|
return -1;
|
2018-06-08 14:40:52 +00:00
|
|
|
|
|
|
|
sev->cbitpos = cap->cbitpos;
|
|
|
|
sev->reduced_phys_bits = cap->reduced_phys_bits;
|
|
|
|
VIR_STEAL_PTR(domCaps->sev, sev);
|
|
|
|
|
2018-08-15 15:02:06 +00:00
|
|
|
return 0;
|
2018-06-08 14:40:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-17 09:33:35 +00:00
|
|
|
int
|
2016-04-22 20:22:30 +00:00
|
|
|
virQEMUCapsFillDomainCaps(virCapsPtr caps,
|
|
|
|
virDomainCapsPtr domCaps,
|
2014-09-16 23:52:54 +00:00
|
|
|
virQEMUCapsPtr qemuCaps,
|
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;
|
2014-06-25 16:39:29 +00:00
|
|
|
|
2016-06-24 15:04:13 +00:00
|
|
|
domCaps->maxvcpus = virQEMUCapsGetMachineMaxCpus(qemuCaps,
|
|
|
|
domCaps->machine);
|
2016-06-27 13:12:34 +00:00
|
|
|
if (domCaps->virttype == VIR_DOMAIN_VIRT_KVM) {
|
2016-06-27 11:53:43 +00:00
|
|
|
int hostmaxvcpus;
|
|
|
|
|
|
|
|
if ((hostmaxvcpus = virHostCPUGetKVMMaxVCPUs()) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
domCaps->maxvcpus = MIN(domCaps->maxvcpus, hostmaxvcpus);
|
2016-06-24 15:04:13 +00:00
|
|
|
}
|
2014-06-25 16:39:29 +00:00
|
|
|
|
2019-02-08 23:03:20 +00:00
|
|
|
domCaps->vmcoreinfo = virTristateBoolFromBool(
|
|
|
|
virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VMCOREINFO));
|
2018-04-17 17:54:28 +00:00
|
|
|
|
2019-02-08 23:03:20 +00:00
|
|
|
domCaps->genid = virTristateBoolFromBool(
|
|
|
|
virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VMGENID));
|
2018-04-27 12:16:40 +00:00
|
|
|
|
2019-04-04 10:42:14 +00:00
|
|
|
if (virQEMUCapsFillDomainOSCaps(os,
|
|
|
|
domCaps->machine,
|
|
|
|
domCaps->arch,
|
|
|
|
privileged,
|
|
|
|
firmwares, nfirmwares) < 0 ||
|
2016-04-22 20:22:30 +00:00
|
|
|
virQEMUCapsFillDomainCPUCaps(caps, qemuCaps, domCaps) < 0 ||
|
2017-10-19 12:19:38 +00:00
|
|
|
virQEMUCapsFillDomainIOThreadCaps(qemuCaps, domCaps) < 0 ||
|
2016-05-08 15:57:20 +00:00
|
|
|
virQEMUCapsFillDomainDeviceDiskCaps(qemuCaps,
|
|
|
|
domCaps->machine, disk) < 0 ||
|
|
|
|
virQEMUCapsFillDomainDeviceGraphicsCaps(qemuCaps, graphics) < 0 ||
|
2016-05-08 16:11:39 +00:00
|
|
|
virQEMUCapsFillDomainDeviceVideoCaps(qemuCaps, video) < 0 ||
|
2016-03-09 18:18:24 +00:00
|
|
|
virQEMUCapsFillDomainDeviceHostdevCaps(qemuCaps, hostdev) < 0 ||
|
2018-06-08 14:40:52 +00:00
|
|
|
virQEMUCapsFillDomainFeatureGICCaps(qemuCaps, domCaps) < 0 ||
|
|
|
|
virQEMUCapsFillDomainFeatureSEVCaps(qemuCaps, domCaps) < 0)
|
2014-09-17 09:33:35 +00:00
|
|
|
return -1;
|
2018-06-08 14:40:52 +00:00
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* virQEMUCapsStripMachineAliases:
|
|
|
|
* @qemuCaps: capabilities object to process
|
|
|
|
*
|
|
|
|
* 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)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
for (i = 0; i < qemuCaps->nmachineTypes; i++)
|
|
|
|
VIR_FREE(qemuCaps->machineTypes[i].alias);
|
|
|
|
}
|