]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
5 years agoqemu: Refactor qemuDomainDefNamespaceParse
Peter Krempa [Mon, 17 Jun 2019 14:10:12 +0000 (16:10 +0200)]
qemu: Refactor qemuDomainDefNamespaceParse

Rename 'cmd' to 'nsdef' and improve the control flow.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Extract parsing of qemu namespace env vars into separate function
Peter Krempa [Mon, 17 Jun 2019 13:41:50 +0000 (15:41 +0200)]
qemu: Extract parsing of qemu namespace env vars into separate function

Simplify the main function by splitting out how we parse the extra
passthrough environment variables.

Note that the validation function checks that the first letter must be a
character or underscore which makes the check whether the name is
redundant.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Extract parsing of qemu namespace arguments into separate function
Peter Krempa [Mon, 17 Jun 2019 13:41:50 +0000 (15:41 +0200)]
qemu: Extract parsing of qemu namespace arguments into separate function

Simplify the main function by splitting out how we parse the extra
passthrough commandline arguments.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: domain: Use virStringListFreeCount in qemuDomainXmlNsDefFree
Peter Krempa [Mon, 17 Jun 2019 13:12:13 +0000 (15:12 +0200)]
qemu: domain: Use virStringListFreeCount in qemuDomainXmlNsDefFree

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Move qemuDomainXmlNsDef(Free) from qemu_conf.(ch)
Peter Krempa [Mon, 17 Jun 2019 13:07:00 +0000 (15:07 +0200)]
qemu: Move qemuDomainXmlNsDef(Free) from qemu_conf.(ch)

qemu_conf.c deals with the configuration file. Better fit for the
structure and freeing function will be qemu_domain.c where the rest of
the namespace parsing/formatting stuff resides.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Rename qemuDomainCmdlineDefPtr to qemuDomainXmlNsDefPtr
Peter Krempa [Fri, 14 Jun 2019 12:18:37 +0000 (14:18 +0200)]
qemu: Rename qemuDomainCmdlineDefPtr to qemuDomainXmlNsDefPtr

The data injected via the namespace may contain also other things than
commandline passthrough definitions. Rename it to make it more
universal.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: vircgroupv2: add support for BFQ files
Pavel Hrdina [Tue, 18 Jun 2019 13:19:43 +0000 (15:19 +0200)]
util: vircgroupv2: add support for BFQ files

In kernel 4.12 there was introduced new BFQ scheduler and in kernel
5.0 the old CFQ scheduler was removed.  This has an implication on
the cgroups file names.

If the CFQ controller is enabled we use one file:

    io.weight

The new BFQ controller expose one file with different name:

    io.bfq.weight

Except for different name they have different syntax.

io.weight:

    default $val
    major:minor $val

io.bfq.weight:

    $val

The difference is that BFQ doesn't support per-device weight.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: vircgroupv1: add support for BFQ blkio files
Pavel Hrdina [Tue, 18 Jun 2019 13:15:43 +0000 (15:15 +0200)]
util: vircgroupv1: add support for BFQ blkio files

In kernel 4.12 there was introduced new BFQ scheduler and in kernel
5.0 the old CFQ scheduler was removed.  This has an implication on
the cgroups file names.

If the CFQ controller is enabled we use these two files:

    blkio.weight
    blkio.weight_device

The new BFQ controller expose only one file with different name:

    blkio.bfq.weight

The reason is that BFQ controller doesn't support per-device weight.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: vircgroup: move virCgroupGetValueStr out of virCgroupGetValueForBlkDev
Pavel Hrdina [Tue, 18 Jun 2019 13:24:41 +0000 (15:24 +0200)]
util: vircgroup: move virCgroupGetValueStr out of virCgroupGetValueForBlkDev

If we need to get a path of specific file and we need to check its
existence before we use it then we can reuse that path to get value
for specific device.  This way we will not build the path again in
virCgroupGetValueForBlkDev.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: vircgroup: introduce virCgroup(Get|Set)ValueRaw
Pavel Hrdina [Tue, 18 Jun 2019 13:01:39 +0000 (15:01 +0200)]
util: vircgroup: introduce virCgroup(Get|Set)ValueRaw

If we need to get a path of specific file and we need to check its
existence before we use it then we can reuse that path to get/set
values instead of calling the existing get/set value functions which
would be building the path again.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agodocs: Space out entries in news.html
Peter Krempa [Fri, 21 Jun 2019 08:01:00 +0000 (10:01 +0200)]
docs: Space out entries in news.html

The header for the news entry blends together with the text and other
entries. This patch tries to space them out somewhat for better visual
separation.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agoremote: use VIR_DRV_OPEN_REMOTE_USER in ssh transport checks
Daniel P. Berrangé [Thu, 22 Mar 2018 17:31:56 +0000 (17:31 +0000)]
remote: use VIR_DRV_OPEN_REMOTE_USER in ssh transport checks

We currently refuse to connect to remote libvirtd over SSH if we see the
path ends in /session. Earlier on though we checked for /session and set
the VIR_DRV_OPEN_REMOTE_USER flag. There is one subtle distinction
though with the test driver. All test URIs are marked with this flag,
regardless of whether the URI indicates a local or remote connection.
Previously a local connection to the test driver would have used the
unprivileged libvirtd while a remote connection would have tried the
privileged libvirtd. With this we are consistent and use the
unprivileged for both local & remote, if the current user is non-root.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoremote: refactor how unprivileged user session connection is identified
Daniel P. Berrangé [Thu, 22 Mar 2018 15:13:48 +0000 (15:13 +0000)]
remote: refactor how unprivileged user session connection is identified

Currently the VIR_DRV_OPEN_REMOTE_USER flag is only set when we identify
that we're connecting to a local libvirtd daemon. We would like to be
able to set that even if connecting to a remote libvirtd daemon. This
entails refactoring the conditional check.

One subtle change is that the VIR_DRV_OPEN_REMOTE_USER is now set when
the test+XXX://  URI is used, even if a servername is present. This has
no effect in this patch, but will later.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoremote: delete the avahi mDNS support
Daniel P. Berrangé [Wed, 19 Jun 2019 14:19:23 +0000 (15:19 +0100)]
remote: delete the avahi mDNS support

Libvirtd has long had integration with avahi for advertising libvirtd
using mDNS when TCP/TLS listening is enabled. For a long time the
virt-manager application had support for auto-detecting libvirtds
on the local network using mDNS, but this was removed last year

  commit fc8f8d5d7e3ba80a0771df19cf20e84a05ed2422
  Author: Cole Robinson <crobinso@redhat.com>
  Date:   Sat Oct 6 20:55:31 2018 -0400

    connect: Drop avahi support

    Libvirtd can advertise itself over avahi. The feature is disabled by
    default though and in practice I hear of no one actually using it
    and frankly I don't think it's all that useful

    The 'Open Connection' wizard has a disproportionate amount of code
    devoted to this feature, but I don't think it's useful or worth
    maintaining, so let's drop it

I've never heard of any other applications having support for using
mDNS to detect libvirtd instances. Though it is theoretically possible
something exists out there, it is clearly going to be a niche use case
in the virt ecosystem as a whole.

By removing avahi integration we can cut down the dependency chain for
the basic libvirtd install and reduce our code maint burden.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoremote: drop code for migrating config files from pre-XDG dir layout
Daniel P. Berrangé [Wed, 19 Jun 2019 13:25:52 +0000 (14:25 +0100)]
remote: drop code for migrating config files from pre-XDG dir layout

The unprivileged libvirtd daemon switched to use the XDG dir layout in
the 0.9.13 release, and included code for moving config files from the
old location. The chances of someone upgrading libvirt from <= 0.9.12
directly to libvirt >= 5.5.0 is close enough to zero that we can
reasonably drop the back compat code.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agorpc: virnetlibsshsession: update deprecated functions
Pavel Hrdina [Fri, 21 Jun 2019 07:18:11 +0000 (09:18 +0200)]
rpc: virnetlibsshsession: update deprecated functions

In libssh 0.9.0 functions ssh_is_server_known and ssh_write_knownhost
are marked as deprecated.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1722735

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoRevert "news: Document removal of qemu commandline parsing"
Peter Krempa [Fri, 21 Jun 2019 06:47:58 +0000 (08:47 +0200)]
Revert "news: Document removal of qemu commandline parsing"

Jano probably based his branch on top of mine and didn't notice
when I moved the section up slightly and thus git applied it again.

Keep only the instance followin the new features section.

This reverts commit 9c68bb4a5c2c8c050e531533e5188a637ba1dd9f.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
5 years agoFix 'validate' typo in comments
Jonathon Jongsma [Thu, 20 Jun 2019 19:36:18 +0000 (14:36 -0500)]
Fix 'validate' typo in comments

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
5 years agotest_driver: properly handle DHCP ranges and IPv6 networks in testDomainInterfaceAddr...
Ilias Stamatis [Wed, 19 Jun 2019 16:45:30 +0000 (18:45 +0200)]
test_driver: properly handle DHCP ranges and IPv6 networks in testDomainInterfaceAddresses

testDomainInterfaceAddresses always returns the same hard-coded
addresses. Change the behavior such as if there is a DHCP range defined,
addresses are returned from that pool.

The specific address returned depends on both the domain id and the
specific guest interface in an attempt to return unique addresses *most
of the time*.

Additionally, properly handle IPv6 networks which were previously
ignored completely.

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: process: Report better error when virtlogd connection fails
Peter Krempa [Tue, 11 Jun 2019 11:58:29 +0000 (13:58 +0200)]
qemu: process: Report better error when virtlogd connection fails

When connecting to virtlogd fails e.g. due to wrong libvirtd selinux
process label we'd report an utterly useless error message:

$ virsh start upstream
error: Failed to start domain upstream
error: Cannot recv data: Connection reset by peer

Use virLastErrorPrefixMessage in the correct place to give a better
sense of what's going on:

$ virsh start upstream
error: Failed to start domain upstream
error: can't connect to virtlogd: Cannot recv data: Connection reset by peer

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoutil: error: Add API for prefixing last set error with a string
Peter Krempa [Tue, 11 Jun 2019 09:23:48 +0000 (11:23 +0200)]
util: error: Add API for prefixing last set error with a string

In some cases we report a low level error message which does not have
enough information to see what the problem is. To allow improving on
this add an API which will prefix the error message with another error
message string which can be used to describe where the error comes from.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: domainsnapshotxml2xml: make 'disk-seclabel' test operational
Peter Krempa [Tue, 5 Jun 2018 14:02:11 +0000 (16:02 +0200)]
tests: domainsnapshotxml2xml: make 'disk-seclabel' test operational

Now that we added the seclabels to the schema we can test that they are
parsed and formatted correctly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
5 years agodocs: schemas: Add 'seclabel' for external disk snapshot
Peter Krempa [Tue, 5 Jun 2018 13:54:00 +0000 (15:54 +0200)]
docs: schemas: Add 'seclabel' for external disk snapshot

Allow using seclabels the same way as disk images allow it. Currently
the snapshot code copies the seclabels from the original image if no
seclabel is provided. Also there's no code change required as the
snapshot XML parser actually uses parts of the disk parser thus
seclabels are already parsed and formatted and even applied thus this is
just a formalization of our support for this.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
5 years agodocs: snapshot: Encourage people ot use disk 'target' to refer to disks
Peter Krempa [Thu, 20 Jun 2019 07:57:54 +0000 (09:57 +0200)]
docs: snapshot: Encourage people ot use disk 'target' to refer to disks

Change the example and add a recommendation to use disk target rather
than path.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
5 years agodocs: Fix Blog Planet links
Martin Kletzander [Thu, 20 Jun 2019 15:00:17 +0000 (17:00 +0200)]
docs: Fix Blog Planet links

They were pointing to the blogs instead, now they point the articles.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
5 years agovirsh: snapshot: Don't block --no-metadata with --print-xml
Peter Krempa [Thu, 20 Jun 2019 12:44:51 +0000 (14:44 +0200)]
virsh: snapshot: Don't block --no-metadata with --print-xml

When testing stuff you might want to print the XML. Interlocking it with
no metadata adds exactly 0 value to the user.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: driver: Fix off-by-one in qemuDomainSnapshotDiskDataCollect
Peter Krempa [Thu, 20 Jun 2019 13:41:48 +0000 (15:41 +0200)]
qemu: driver: Fix off-by-one in qemuDomainSnapshotDiskDataCollect

Commit f34397e51c17 introduced a crash-inducing problem when collecting
disk snapshot data, where the array would be filled starting from the
second element.

The code then dereferenced the first one.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Remove qemuMonitorTextSetCPU
Peter Krempa [Thu, 20 Jun 2019 11:15:04 +0000 (13:15 +0200)]
qemu: Remove qemuMonitorTextSetCPU

It's not used any more.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: monitor: Remove text monitor support for cpu hot(un)plug
Peter Krempa [Thu, 20 Jun 2019 11:12:04 +0000 (13:12 +0200)]
qemu: monitor: Remove text monitor support for cpu hot(un)plug

The "cpu-add" command is supported in all supported qemu versions and
cpu unplug did not work at all until the new cpu unplug approach (using
device_add/del) was implemented.

Remove the support for falling back to the text monitor.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirNetworkGetDHCPLeases: fix docstring format
Ilias Stamatis [Tue, 18 Jun 2019 14:21:57 +0000 (16:21 +0200)]
virNetworkGetDHCPLeases: fix docstring format

The docstring of virNetworkGetDHCPLeases is not correctly formatted and
as a result the example code snippet appears as normal text under the
"Returns:" section. This patch fixes the problem.

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
5 years agotest_driver: check that the domain is running in testDomainGetTime
Ilias Stamatis [Thu, 20 Jun 2019 11:41:01 +0000 (13:41 +0200)]
test_driver: check that the domain is running in testDomainGetTime

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
5 years agodocs: Remove unused JavaScript libraries
Martin Kletzander [Wed, 19 Jun 2019 14:49:15 +0000 (16:49 +0200)]
docs: Remove unused JavaScript libraries

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agodocs: Use our own implementation for fetching the RSS data
Martin Kletzander [Wed, 19 Jun 2019 13:50:40 +0000 (15:50 +0200)]
docs: Use our own implementation for fetching the RSS data

It will not be executed when the page is loaded locally.  It needs
planet.virt-tools.org to supply the right headers (which it does now).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agodocs: Some JavaScript clean-up
Martin Kletzander [Thu, 20 Jun 2019 09:21:37 +0000 (11:21 +0200)]
docs: Some JavaScript clean-up

Don't use the global namespace, unify quotes and semicolons at the end of lines
and "use strict".

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agoqemu: Drop MSR features from host-model with old QEMU
Jiri Denemark [Wed, 19 Jun 2019 20:22:09 +0000 (22:22 +0200)]
qemu: Drop MSR features from host-model with old QEMU

With QEMU versions which lack "unavailable-features" we use CPUID based
detection of features which were enabled or disabled once QEMU starts.
Thus using MSR features with host-model would result in all of them
being marked as disabled in the active domain definition even though
QEMU did not actually disable them.

Let's make sure we add MSR features to host-model only when
"unavailable-features" property is supported by QEMU.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Forbid MSR features with old QEMU
Jiri Denemark [Wed, 19 Jun 2019 19:59:49 +0000 (21:59 +0200)]
qemu: Forbid MSR features with old QEMU

Without "unavailable-features" CPU property we cannot properly detect
whether a specific MSR feature we asked for (either explicitly or
implicitly via a CPU model) was disabled by QEMU for some reason.
Because this could break migration, snapshots, and save/restore
operaions, it's better to just forbid any use of MSR features with QEMU
which lacks "unavailable-features" CPU property.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agocpu_map: Introduce IA32_ARCH_CAPABILITIES MSR features
Jiri Denemark [Thu, 14 Mar 2019 14:44:38 +0000 (15:44 +0100)]
cpu_map: Introduce IA32_ARCH_CAPABILITIES MSR features

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agocpu_x86: Read CPU features from IA32_ARCH_CAPABILITIES MSR
Jiri Denemark [Fri, 22 Mar 2019 15:52:21 +0000 (16:52 +0100)]
cpu_x86: Read CPU features from IA32_ARCH_CAPABILITIES MSR

This is used by the host capabilities code to construct host CPU
definition.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agocpu_x86: Introduce virCPUx86FeatureFilter*MSR
Jiri Denemark [Wed, 19 Jun 2019 19:59:12 +0000 (21:59 +0200)]
cpu_x86: Introduce virCPUx86FeatureFilter*MSR

This functions may be used as a virCPUDefFeatureFilter callbacks for
virCPUDefCheckFeatures, virCPUDefFilerFeatures, and similar functions to
select (virCPUx86FeatureFilterSelectMSR) or drop
(virCPUx86FeatureFilterDropMSR) features reported via MSR.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agocpu_x86: Turn virCPUx86DataIteratorInit into a function
Jiri Denemark [Wed, 19 Jun 2019 19:58:01 +0000 (21:58 +0200)]
cpu_x86: Turn virCPUx86DataIteratorInit into a function

Until now, this was a macro usable for direct initialization when a
variable is defined. Turning the macro into a function makes it more
general.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoconf: Introduce virCPUDefCheckFeatures
Jiri Denemark [Wed, 19 Jun 2019 17:01:30 +0000 (19:01 +0200)]
conf: Introduce virCPUDefCheckFeatures

This API can be used to check whether a CPU definition contains features
matching a given filter.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoapi: disallow virConnect*HypervisorCPU on read-only connections
Ján Tomko [Fri, 14 Jun 2019 07:17:39 +0000 (09:17 +0200)]
api: disallow virConnect*HypervisorCPU on read-only connections

These APIs can be used to execute arbitrary emulators.
Forbid them on read-only connections.

Fixes: CVE-2019-10168
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoapi: disallow virConnectGetDomainCapabilities on read-only connections
Ján Tomko [Fri, 14 Jun 2019 07:16:14 +0000 (09:16 +0200)]
api: disallow virConnectGetDomainCapabilities on read-only connections

This API can be used to execute arbitrary emulators.
Forbid it on read-only connections.

Fixes: CVE-2019-10167
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoapi: disallow virDomainManagedSaveDefineXML on read-only connections
Ján Tomko [Fri, 14 Jun 2019 07:14:53 +0000 (09:14 +0200)]
api: disallow virDomainManagedSaveDefineXML on read-only connections

The virDomainManagedSaveDefineXML can be used to alter the domain's
config used for managedsave or even execute arbitrary emulator binaries.
Forbid it on read-only connections.

Fixes: CVE-2019-10166
Reported-by: Matthias Gerstner <mgerstner@suse.de>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoapi: disallow virDomainSaveImageGetXMLDesc on read-only connections
Ján Tomko [Fri, 14 Jun 2019 06:47:42 +0000 (08:47 +0200)]
api: disallow virDomainSaveImageGetXMLDesc on read-only connections

The virDomainSaveImageGetXMLDesc API is taking a path parameter,
which can point to any path on the system. This file will then be
read and parsed by libvirtd running with root privileges.

Forbid it on read-only connections.

Fixes: CVE-2019-10161
Reported-by: Matthias Gerstner <mgerstner@suse.de>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: monitor: s/ret/rc/ in UpdateVideoSize functions
Ján Tomko [Fri, 14 Jun 2019 19:40:19 +0000 (21:40 +0200)]
qemu: monitor: s/ret/rc/ in UpdateVideoSize functions

Use 'rc' to temporarily store the subfunction return values,
instead of ret.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu: monitor: use VIR_AUTOFREE in qemuMonitor*VideoSize
Ján Tomko [Fri, 14 Jun 2019 19:38:40 +0000 (21:38 +0200)]
qemu: monitor: use VIR_AUTOFREE in qemuMonitor*VideoSize

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu: monitor: remove the json field
Ján Tomko [Fri, 14 Jun 2019 18:05:26 +0000 (20:05 +0200)]
qemu: monitor: remove the json field

Now that it is no longer used, remove it.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu: monitor: remove mon->json checks
Ján Tomko [Fri, 14 Jun 2019 18:06:48 +0000 (20:06 +0200)]
qemu: monitor: remove mon->json checks

Remove all the mon->json checks in qemuMonitor functions.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu: monitor: assume JSON in QEMU_CHECK_MONITOR macro
Ján Tomko [Fri, 14 Jun 2019 18:05:44 +0000 (20:05 +0200)]
qemu: monitor: assume JSON in QEMU_CHECK_MONITOR macro

In preparation to removing the json field from qemuMonitor,
stop checking for it in QEMU_CHECK_MONITOR.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu: remove json argument from qemuMonitorOpen
Ján Tomko [Fri, 14 Jun 2019 18:08:00 +0000 (20:08 +0200)]
qemu: remove json argument from qemuMonitorOpen

Always assume JSON monitor was requested, since all the callers
pass true anyway.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu: domain: remove monJSON field
Ján Tomko [Fri, 14 Jun 2019 19:14:42 +0000 (21:14 +0200)]
qemu: domain: remove monJSON field

If we have a monitor, it is a JSON monitor.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu: assume monJSON is always true
Ján Tomko [Fri, 14 Jun 2019 19:13:58 +0000 (21:13 +0200)]
qemu: assume monJSON is always true

Now that we no longer support the HMP monitor, remove some dead code.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
5 years agonews: Document removal of qemu commandline parsing
Peter Krempa [Mon, 17 Jun 2019 12:12:46 +0000 (14:12 +0200)]
news: Document removal of qemu commandline parsing

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
5 years agodocs: Update documentation for spapr-vio addresses
Andrea Bolognani [Fri, 14 Jun 2019 11:19:49 +0000 (13:19 +0200)]
docs: Update documentation for spapr-vio addresses

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Format spapr-vio addresses as 32-bit
Andrea Bolognani [Fri, 14 Jun 2019 10:46:15 +0000 (12:46 +0200)]
qemu: Format spapr-vio addresses as 32-bit

No reason not to be consistent with the user-visible value.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf: Format spapr-vio addresses as 32-bit
Andrea Bolognani [Fri, 14 Jun 2019 10:46:05 +0000 (12:46 +0200)]
conf: Format spapr-vio addresses as 32-bit

Using 8 hex digits all the time, regardless of whether the
actual value can fit in fewer, makes it more obvious to the
user what the limits are.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: Add pseries-spaprvio-invalid
Andrea Bolognani [Fri, 14 Jun 2019 10:50:43 +0000 (12:50 +0200)]
tests: Add pseries-spaprvio-invalid

This test case shows that we now reject invalid spapr-vio
addresses.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Validate spapr-vio addresses
Andrea Bolognani [Fri, 14 Jun 2019 10:50:22 +0000 (12:50 +0200)]
qemu: Validate spapr-vio addresses

According to sPAPR, addresses are 32-bit rather than 64-bit.
Update qemuDomainDeviceDefValidateAddress() accordingly.

https://bugzilla.redhat.com/show_bug.cgi?id=1598657

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Rework qemuDomainDeviceDefValidateAddress()
Andrea Bolognani [Wed, 12 Jun 2019 11:05:24 +0000 (13:05 +0200)]
qemu: Rework qemuDomainDeviceDefValidateAddress()

Introduce a switch() statement and prepare for validating
more address types than just PCI.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agodocs: Fix validation of spapr-vio addresses
Andrea Bolognani [Fri, 14 Jun 2019 10:50:32 +0000 (12:50 +0200)]
docs: Fix validation of spapr-vio addresses

According to sPAPR, addresses are 32-bit (8 hex digits) rather
than 64-bit (16 hex digits). Update the schema accordingly.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: also delete qemuProcessAttach
Ján Tomko [Fri, 14 Jun 2019 18:59:32 +0000 (20:59 +0200)]
qemu: also delete qemuProcessAttach

Now that the virDomainQemuAttach API returns an error, we can remove the
unused qemuProcessAttach function as well, deleting the only user
that possibly could have requested to open a non-JSON monitor.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
5 years agodocs: drvqemu: Drop old example for domxml-to-native
Peter Krempa [Tue, 18 Jun 2019 11:33:52 +0000 (13:33 +0200)]
docs: drvqemu: Drop old example for domxml-to-native

The example is very outdated and we dropped the support for it anyways.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agodocs: drvqemu: Add note about deprecation of domxml-from-native
Peter Krempa [Tue, 18 Jun 2019 11:32:57 +0000 (13:32 +0200)]
docs: drvqemu: Add note about deprecation of domxml-from-native

Add a warning that the operation will no longer work.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agodocs: css: Add style for <span class='deprecated'> ...
Peter Krempa [Tue, 18 Jun 2019 11:32:04 +0000 (13:32 +0200)]
docs: css: Add style for <span class='deprecated'> ...

Allow marking of the deprecation of features similarly how we mark
introduction of features.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agodocs: drvqemu: Remove outdated example of virsh domxml-from-native
Peter Krempa [Tue, 18 Jun 2019 11:26:54 +0000 (13:26 +0200)]
docs: drvqemu: Remove outdated example of virsh domxml-from-native

The current version will definitely not provide such a neat commandline.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agodocs: drvqemu: Clarify caveats of domxml-to-native
Peter Krempa [Tue, 18 Jun 2019 11:25:20 +0000 (13:25 +0200)]
docs: drvqemu: Clarify caveats of domxml-to-native

Explicitly state that the conversion nowadays produces results which
aren't really usable manually as it requires all the stuff which is
usually prepared by libvirtd.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Move qemuParseKeywords(Free) to the monitor code
Peter Krempa [Mon, 17 Jun 2019 12:18:51 +0000 (14:18 +0200)]
qemu: Move qemuParseKeywords(Free) to the monitor code

The only user is now in qemu_monitor_json.c to re-parse the command line
format into keyvalue pairs for use in QMP command construction.

Move and rename the functions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agoqemu: Move QEMU_QXL_VGAMEM_DEFAULT macro
Peter Krempa [Mon, 17 Jun 2019 07:50:08 +0000 (09:50 +0200)]
qemu: Move QEMU_QXL_VGAMEM_DEFAULT macro

qemu_domain.c is now the only place that uses it, so we can move it from
qemu_parse_command.h

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agoqemu: parse: Drop unused qemu command line parsing infrastructure
Peter Krempa [Fri, 14 Jun 2019 13:17:26 +0000 (15:17 +0200)]
qemu: parse: Drop unused qemu command line parsing infrastructure

It's now unused and utterly obsolete.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agotests: Drop qemuargv2xmltest
Peter Krempa [Fri, 14 Jun 2019 13:03:04 +0000 (15:03 +0200)]
tests: Drop qemuargv2xmltest

Now that we no longer use that functionality we can also drop the tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agonews: Document removal of qemu commandline parsing
Peter Krempa [Mon, 17 Jun 2019 12:12:46 +0000 (14:12 +0200)]
news: Document removal of qemu commandline parsing

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agoqemu: driver: Remove support for native->XML conversion
Peter Krempa [Fri, 14 Jun 2019 12:56:35 +0000 (14:56 +0200)]
qemu: driver: Remove support for native->XML conversion

This code is really neglected and does not at all work reliably. It
can't even be used for converting our own commandline back.

Since this was mostly useful for aiding migration from manually run qemu
to libvirt and will not work for this puspose in many cases it's not
worth having.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agoqemu: parse: Drop qemuParseCommandLinePid and friends
Peter Krempa [Fri, 14 Jun 2019 12:43:14 +0000 (14:43 +0200)]
qemu: parse: Drop qemuParseCommandLinePid and friends

Now that we no longer support attaching to a live QEMU process not
managed by libvirt we can drop the backend functions as well.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agoqemu: driver: Drop support for qemu-attach
Peter Krempa [Fri, 14 Jun 2019 12:33:52 +0000 (14:33 +0200)]
qemu: driver: Drop support for qemu-attach

Attaching to modern qemu will not work with all this code and attempting
to ressurect it would be mostly pointless.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agodocs: hvsupport: Add support for deprecating hypervisor implementations
Peter Krempa [Mon, 17 Jun 2019 11:59:31 +0000 (13:59 +0200)]
docs: hvsupport: Add support for deprecating hypervisor implementations

Allow expressing that a hypervisor implementation was deleted by adding
a end-version when the implementation was removed to our hypervisor
support matrix.

This patch hacks the perl script that generates the support matrix to
support comments like:

.domainQemuAttach = qemuDomainQemuAttach, /* 0.8.3 (deprecated: 5.5.0) */

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agotests: qemuMonitorTest: drop the JSON field
Ján Tomko [Wed, 19 Jun 2019 20:41:55 +0000 (22:41 +0200)]
tests: qemuMonitorTest: drop the JSON field

Now that we no longer support testing HMP monitor,
the json field is pointless.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agotests: qemuMonitorTestProcessCommandDefaultValidate: simplify condition
Ján Tomko [Sat, 15 Jun 2019 09:47:34 +0000 (11:47 +0200)]
tests: qemuMonitorTestProcessCommandDefaultValidate: simplify condition

We return success when running this function for either non-JSON monitor
testing or guest agent testing.

However we no longer test HMP monitor and we do not try to validate
the guest agent interaction.

Drop the test->json check and report a proper error if someone tries
to run this function for the guest agent without properly wiring it up.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agotests: assume JSON in qemuMonitorTestIO
Ján Tomko [Fri, 14 Jun 2019 18:39:24 +0000 (20:39 +0200)]
tests: assume JSON in qemuMonitorTestIO

The QMP monitor only uses a newline to separate lines,
while HMP and the guest agent also use a carriage return.

In preparation to dropping support for testing HMP interaction,
only skip the carriage return if we're dealing with the guest agent,
removing the need to check the 'json' field.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agovirhostdev: Use VIR_AUTOPTR more
Michal Privoznik [Sat, 15 Jun 2019 07:56:59 +0000 (09:56 +0200)]
virhostdev: Use VIR_AUTOPTR more

There are couple of functions which get shorter after the
treatment.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirHostdevPrepareSCSIVHostDevices: Simplify logic
Michal Privoznik [Sat, 15 Jun 2019 07:37:18 +0000 (09:37 +0200)]
virHostdevPrepareSCSIVHostDevices: Simplify logic

Couple of things happening in this patch:

1) We can mark the device we're adding onto active list as used
   way before - when adding it onto temporary list.

2) When actually moving device from a temporary helper list onto
   the list of active devices we check if the device isn't
   already there. The same check is performed by
   virSCSIVHostDeviceListAdd() later. Drop this duplicity.

3) The 'error' label is renamed to 'rollback' to reflect what it
   is actually doing. While in the rest of the code we don't
   allow random label names, this source file is different.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirHostdevFindUSBDevice: Simplify flow a bit
Michal Privoznik [Sat, 15 Jun 2019 07:22:12 +0000 (09:22 +0200)]
virHostdevFindUSBDevice: Simplify flow a bit

When looking up a USB device by vendor the
virUSBDeviceFindByVendor() is used. The function returns number
of items found. But the logic in caller to process it is
needlessly complicated.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirhostdev: Use VIR_AUTOUNREF more
Michal Privoznik [Sat, 15 Jun 2019 07:03:47 +0000 (09:03 +0200)]
virhostdev: Use VIR_AUTOUNREF more

There are couple of functions which get shorter after the
treatment.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirHostdevReAttachPCIDevices: Construct pcidevs list earlier
Michal Privoznik [Mon, 10 Jun 2019 15:19:01 +0000 (17:19 +0200)]
virHostdevReAttachPCIDevices: Construct pcidevs list earlier

There's no need to translate virDomainHostdevDef-s into
virPCIDevice-s with locked list of PCI devices.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirHostdevPreparePCIDevices: Construct pcidevs list earlier
Michal Privoznik [Fri, 7 Jun 2019 11:56:46 +0000 (13:56 +0200)]
virHostdevPreparePCIDevices: Construct pcidevs list earlier

There's no need to translate virDomainHostdevDef-s into
virPCIDevice-s with locked list of PCI devices.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirHostdevGetPCIHostDeviceList: Use VIR_AUTOPTR for virPCIDevice
Michal Privoznik [Sat, 15 Jun 2019 06:28:05 +0000 (08:28 +0200)]
virHostdevGetPCIHostDeviceList: Use VIR_AUTOPTR for virPCIDevice

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirHostdevGetPCIHostDeviceList: Add @pci a bit later
Michal Privoznik [Sat, 15 Jun 2019 06:25:33 +0000 (08:25 +0200)]
virHostdevGetPCIHostDeviceList: Add @pci a bit later

This function is a good candidate for VIR_AUTOPTR() conversion.
But this conversion will be easier if we only add @pci device
onto @pcidevs list after it was all set up.

This is no functional change.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuProcessLaunch: Return earlier if spawning qemu failed
Michal Privoznik [Thu, 23 May 2019 09:00:27 +0000 (11:00 +0200)]
qemuProcessLaunch: Return earlier if spawning qemu failed

If spawning qemu fails then we report an error and proceed to
writing status XML onto the disk. This is unnecessary as we are
sure that the domain is not running.

At the same time, if virPidFileReadPath() fails it returns
-errno. Use it in the error message. It may explain what went
wrong.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agodocs: Advertise pcie-to-pci-bridge for use on q35
Andrea Bolognani [Fri, 7 Jun 2019 08:27:43 +0000 (10:27 +0200)]
docs: Advertise pcie-to-pci-bridge for use on q35

We support pcie-to-pci-bridge, and prefer it to
dmi-to-pci-bridge, since libvirt 4.3.0, but we didn't
update all the documentation accordingly at the time.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: qapi: Implement support for 'features'
Peter Krempa [Wed, 10 Apr 2019 12:52:48 +0000 (14:52 +0200)]
qemu: qapi: Implement support for 'features'

Starting from version 4.1 qemu allows reporting 'features' for a given
QAPI type object. This allows reporting support of fixes and additions
which are otherwise invisible in the QAPI schema.

Implement a possibility to query 'features' in the QAPI query strings.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agotests: qemucaps: Update 4.1.0 capabilities to a more recent version
Peter Krempa [Thu, 20 Jun 2019 05:47:43 +0000 (07:47 +0200)]
tests: qemucaps: Update 4.1.0 capabilities to a more recent version

Update the capabilities from a non-upstream version (9c70209b63 is not
in qemu.git) to qemu upstream commit 33d6099906 (2019/06/18) so that we
get the QMP schema 'features' field support and are able to detect that
the 'file' block backend supports dynamic auto-read-only.

Note that I've rebuilt this on a machine with a more modern kernel and
microcode which exposes e.g. the recent CPU bug mitigations, thus I
opted to keep the CPU changes rather than trying to do a franken-caps
by updating only the output of query-qmp-schema.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agosyntax check: update header guard check
Jonathon Jongsma [Wed, 19 Jun 2019 19:48:36 +0000 (14:48 -0500)]
syntax check: update header guard check

Internal headers should use #pragma once instead of the standard #ifndef
guard. Public headers still require the existing header guard.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu_process: Prefer generic qemuMonitorGetGuestCPU
Jiri Denemark [Mon, 17 Jun 2019 21:38:46 +0000 (23:38 +0200)]
qemu_process: Prefer generic qemuMonitorGetGuestCPU

When updating guest CPU definition according to the vCPU actually
created by QEMU, we want to use the generic qemuMonitorGetGuestCPU to
get both CPUID and MSR features.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Introduce generic qemuMonitorGetGuestCPU
Jiri Denemark [Mon, 17 Jun 2019 21:36:53 +0000 (23:36 +0200)]
qemu: Introduce generic qemuMonitorGetGuestCPU

Unlike the old version (which is now called qemuMonitorGetGuestCPUx86),
this monitor API checks for individual features by their names rather
than processing CPUID bits. Thus we can get the list of enabled and
disabled features for both CPUID and MSR features.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Add type filter to qemuMonitorJSONParsePropsList
Jiri Denemark [Mon, 17 Jun 2019 19:51:20 +0000 (21:51 +0200)]
qemu: Add type filter to qemuMonitorJSONParsePropsList

The function converts a list of QOM properties into a NULL-terminated
array of property names. The new type parameter may be used to limit the
result to properties of a specific type.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agocpu: Introduce virCPUDataAddFeature
Jiri Denemark [Tue, 18 Jun 2019 08:09:31 +0000 (10:09 +0200)]
cpu: Introduce virCPUDataAddFeature

This is a generic replacement for the former virCPUx86DataAddFeature,
which worked on the generic virCPUDataPtr anyway.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Make qemuMonitorGetGuestCPU usable on x86 only
Jiri Denemark [Mon, 17 Jun 2019 14:56:32 +0000 (16:56 +0200)]
qemu: Make qemuMonitorGetGuestCPU usable on x86 only

It was never implemented or used for anything else anyway. Mainly
because it uses CPUID features bits. The function is renamed as
qemuMonitorGetGuestCPUx86 to make this explicit.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Don't use full CPU model expansion
Jiri Denemark [Wed, 12 Jun 2019 11:54:27 +0000 (13:54 +0200)]
qemu: Don't use full CPU model expansion

We used type=full expansion on the result of previous type=static
expansion to get all possible spellings of CPU features. Since we can
now translate the QEMU's canonical names to our names, we can drop this
magic and do only type=static CPU model expansion.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Translate feature names from query-cpu-model-expansion
Jiri Denemark [Mon, 17 Jun 2019 11:54:53 +0000 (13:54 +0200)]
qemu: Translate feature names from query-cpu-model-expansion

By default query-cpu-model-expansion only reports canonical names of all
CPU features. We do some magic and call the command twice to get all
possible spellings of the features, but being able to consume canonical
names will allow us to drop this magic.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu_command: Use canonical names of CPU features
Jiri Denemark [Fri, 7 Jun 2019 13:00:28 +0000 (15:00 +0200)]
qemu_command: Use canonical names of CPU features

When building QEMU command line, we should use the preferred spelling of
each CPU feature without relying on compatibility aliases (which may be
removed at some point).

The "unavailable-features" CPU property is used as a witness for the
correct names of the features in our translation table.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>