]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
5 years agotest_driver: Don't report VIR_DOMAIN_DISK_ERROR_NONE
Michal Privoznik [Tue, 14 May 2019 15:09:19 +0000 (17:09 +0200)]
test_driver: Don't report VIR_DOMAIN_DISK_ERROR_NONE

In my review of 89320788ac4 I've simplified assigning disk errors
too much as the code I've changed it to will set
VIR_DOMAIN_DISK_ERROR_NONE. This is in contradiction with our
documentation which specifies that disks with no errors are not
reported.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agotest_driver: Don't access @vm after it was set to NULL
Michal Privoznik [Tue, 14 May 2019 15:05:45 +0000 (17:05 +0200)]
test_driver: Don't access @vm after it was set to NULL

If something goes wrong in testDomainGetDiskErrors() then we try
to free any strings that were previously allocated in return
array. Problem is, in my review of original patch (89320788ac4)
I've mistakenly did some changes which result in possible NULL
dereference (@vm is set to NULL as the first thing under cleanup
label).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agodocs: Provide documentation for SEV launch security
Erik Skultety [Thu, 20 Jun 2019 08:14:59 +0000 (10:14 +0200)]
docs: Provide documentation for SEV launch security

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Brijesh Singh <brijesh.singh@amd.com>
5 years agoRevert "qemu: Temporary disable owner remembering"
Michal Privoznik [Tue, 15 Jan 2019 08:50:58 +0000 (09:50 +0100)]
Revert "qemu: Temporary disable owner remembering"

This reverts commit fc3990c7e64be1da1631952d3ec384ebef50e125.

Now that all the reported bugs are fixed let's turn the feature
back on.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: Move image security metadata on snapshot activity
Michal Privoznik [Mon, 25 Mar 2019 16:02:44 +0000 (17:02 +0100)]
qemu: Move image security metadata on snapshot activity

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu_security: Implement qemuSecurityMoveImageMetadata
Michal Privoznik [Thu, 21 Mar 2019 15:36:38 +0000 (16:36 +0100)]
qemu_security: Implement qemuSecurityMoveImageMetadata

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosecurity_selinux: Implement virSecurityManagerMoveImageMetadata
Michal Privoznik [Thu, 21 Mar 2019 15:21:27 +0000 (16:21 +0100)]
security_selinux: Implement virSecurityManagerMoveImageMetadata

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosecurity_dac: Implement virSecurityManagerMoveImageMetadata
Michal Privoznik [Thu, 21 Mar 2019 14:45:29 +0000 (15:45 +0100)]
security_dac: Implement virSecurityManagerMoveImageMetadata

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosecurity_util: Introduce virSecurityMoveRememberedLabel
Michal Privoznik [Thu, 21 Mar 2019 14:44:52 +0000 (15:44 +0100)]
security_util: Introduce virSecurityMoveRememberedLabel

A simple helper function that would be used from DAC and SELinux
drivers.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosecurity: Introduce virSecurityManagerMoveImageMetadata
Michal Privoznik [Thu, 21 Mar 2019 10:44:21 +0000 (11:44 +0100)]
security: Introduce virSecurityManagerMoveImageMetadata

The purpose of this API is to allow caller move XATTRs (or remove
them) from one file to another. This will be needed when moving
top level of disk chain (either by introducing new HEAD or
removing it).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosecurity: Don't remember owner for shared resources
Michal Privoznik [Fri, 15 Feb 2019 10:37:03 +0000 (11:37 +0100)]
security: Don't remember owner for shared resources

This effectively reverts d7420430ce6 and adds new code.

Here is the problem: Imagine a file X that is to be shared
between two domains as a disk. Let the first domain (vm1) have
seclabel remembering turned on and the other (vm2) has it turned
off. Assume that both domains will run under the same user, but
the original owner of X is different (i.e. trying to access X
without relabelling leads to EPERM).

Let's start vm1 first. This will cause X to be relabelled and to
gain new attributes:

  trusted.libvirt.security.ref_dac="1"
  trusted.libvirt.security.dac="$originalOwner"

When vm2 is started, X will again be relabelled, but since the
new label is the same as X already has (because of vm1) nothing
changes and vm1 and vm2 can access X just fine. Note that no
XATTR is changed (especially the refcounter keeps its value of 1)
because the vm2 domain has the feature turned off.

Now, vm1 is shut off and vm2 continues running. In seclabel
restore process we would get to X and since its refcounter is 1
we would restore the $originalOwner on it. But this is unsafe to
do because vm2 is still using X (remember the assumption that
$originalOwner and vm2's seclabel are distinct?).

The problem is that refcounter stored in XATTRs doesn't reflect
the actual times a resource is in use. Since I don't see any easy
way around it let's just not store original owner on shared
resources. Shared resource in world of domain disks is:

  - whole backing chain but the top layer,
  - read only disk (we don't require CDROM to be explicitly
    marked as shareable),
  - disk marked as shareable.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemusecuritymock: Allow some paths to be not restored
Michal Privoznik [Thu, 18 Apr 2019 09:05:18 +0000 (11:05 +0200)]
qemusecuritymock: Allow some paths to be not restored

Some paths will not be restored. Because we can't possibly know
if they are still in use or not. Reflect this in the test so that
we can test more domains. Also see next commit for more detailed
explanation.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosecurity_selinux: Allow caller to suppress owner remembering
Michal Privoznik [Fri, 15 Feb 2019 14:36:06 +0000 (15:36 +0100)]
security_selinux: Allow caller to suppress owner remembering

Just like previous commit allowed to enable or disable owner
remembering for each individual path, do the same for SELinux
driver. This is going to be needed in the next commit.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosecurity_dac: Allow caller to suppress owner remembering
Michal Privoznik [Fri, 15 Feb 2019 10:20:19 +0000 (11:20 +0100)]
security_dac: Allow caller to suppress owner remembering

One caller in particular (virSecurityDACSetImageLabelInternal)
will want to have the feature turned on only in some cases.
Introduce @remember member to _virSecurityDACChownItem to track
whether caller wants to do owner remembering or not.
The actual remembering is then enabled if both caller wanted it
and the feature is turned on in the config file.

Technically, we could skip over paths that don't have remember
enabled when creating a list of paths to lock. We won't touch
their XATTRs after all. Well, I rather play it safe and keep them
on the locking list for now.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosecurity: Document @restore member of transaction list
Michal Privoznik [Fri, 15 Feb 2019 10:23:29 +0000 (11:23 +0100)]
security: Document @restore member of transaction list

Both DAC and SELinux drivers support transactions. Each item on
the transaction list consists of various variables and @restore
is one of them. Document it so that as the list of variables grow
it's easier to spot which variable does what.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosecurity: Don't skip label restore on file systems lacking XATTRs
Michal Privoznik [Tue, 15 Jan 2019 10:15:19 +0000 (11:15 +0100)]
security: Don't skip label restore on file systems lacking XATTRs

The way that virSecurityDACRecallLabel is currently written is
that if XATTRs are not supported for given path to the caller
this is not different than if the path is still in use. The value
of 1 is returned which makes secdrivers skip label restore.
This is clearly a bug as we are not restoring labels on say NFS
even though previously we were.

Strictly speaking, changes to virSecurityDACRememberLabel are not
needed, but they are done anyway so that getter and setter behave
in the same fashion.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovirFileRemoveXAttr: Report error on failure
Michal Privoznik [Fri, 22 Mar 2019 14:41:06 +0000 (15:41 +0100)]
virFileRemoveXAttr: Report error on failure

It's better to have the function report errors, because none of
the callers does.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovirFileSetXAttr: Report error on failure
Michal Privoznik [Fri, 22 Mar 2019 14:34:59 +0000 (15:34 +0100)]
virFileSetXAttr: Report error on failure

It's better to have the function report errors, because none of
the callers does.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovirfile: Make virFileGetXAttr report errors
Michal Privoznik [Fri, 22 Mar 2019 14:08:36 +0000 (15:08 +0100)]
virfile: Make virFileGetXAttr report errors

The way that security drivers use XATTR is kind of verbose. If
error reporting was left for caller then the caller would end up
even more verbose.

There are two places where we do not want to report error if
virFileGetXAttr fails. Therefore virFileGetXAttrQuiet is
introduced as an alternative that doesn't report errors.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovirSecuritySELinuxRestoreAllLabel: Print @migrated in the debug message too
Michal Privoznik [Mon, 4 Feb 2019 15:39:52 +0000 (16:39 +0100)]
virSecuritySELinuxRestoreAllLabel: Print @migrated in the debug message too

Just like it's DAC counterpart is doing,
virSecuritySELinuxRestoreAllLabel() could print @migrated in the
debug message.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotools: Slightly rework libvirt_recover_xattrs.sh
Michal Privoznik [Tue, 15 Jan 2019 08:19:08 +0000 (09:19 +0100)]
tools: Slightly rework libvirt_recover_xattrs.sh

Firstly, there's no reason to enumerate all XATTRs since they
differ only in the prefix and we can construct them in a loop.

Secondly, and more importantly, the script was still looking for
just one prefix "trusted.libvirt.security" even on FreeBSD.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemusecuritytest: Fix capabilities loading
Michal Privoznik [Mon, 15 Apr 2019 14:38:28 +0000 (16:38 +0200)]
qemusecuritytest: Fix capabilities loading

Having to enumerate all capabilities that we want domain to have
is too verbose and prevents us from adding more tests. Have the
domain always have the latest x86_64 capabilities. This means
that we have to drop two arm tests, but on the other hand, I'm
introducing 50 new cases. I've listed 50 biggest .args files and
added those:

  libvirt.git $ ls -Sr $(find tests/qemuxml2argvdata/ \
  -type f -iname "*.x86_64-latest.args") | tail -n 50

Except for two:
1) disk-backing-chains-noindex - this XML has some disks with
backing chain. And since set is done on the whole backing chain
and restore only on the top layer this would lead to instant test
failure. Don't worry, secdrivers will be fixed shortly too and
the test case will be added.

2) hostdev-mdev-display-spice-egl-headless - for this XML
secdriver tries to find IOMMU group that mdev lives in. Since we
are not mocking sysfs access this test case would fail.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemusecuritytest: Use AUTOFREE/AUTOUNREF
Michal Privoznik [Mon, 15 Apr 2019 13:34:54 +0000 (15:34 +0200)]
qemusecuritytest: Use AUTOFREE/AUTOUNREF

This simplifies the code a bit and removes the need for cleanup
label in one case. In the other case the label is kept because
it's going to be used later.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemusecuritytest: Drop unused variable
Michal Privoznik [Thu, 18 Apr 2019 19:01:29 +0000 (21:01 +0200)]
qemusecuritytest: Drop unused variable

The @securityManager variable in testDomain() is unused. Drop it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemusecuritymock: Introduce and use freePaths()
Michal Privoznik [Mon, 15 Apr 2019 14:15:10 +0000 (16:15 +0200)]
qemusecuritymock: Introduce and use freePaths()

Problem with current approach is that if
qemuSecuritySetAllLabel() fails, then the @chown_paths and
@xattr_paths hash tables are not freed and preserve values
already stored there into the next test case.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemusecuritymock: Actually set error on failure
Michal Privoznik [Mon, 15 Apr 2019 11:56:11 +0000 (13:56 +0200)]
qemusecuritymock: Actually set error on failure

I don't really know what happened when I was writing the original
code, but even if error was to be set the corresponding boolean
was set to false meaning no error.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemusecuritymock: Fix bit arithmetic
Michal Privoznik [Mon, 15 Apr 2019 15:17:40 +0000 (17:17 +0200)]
qemusecuritymock: Fix bit arithmetic

One of the functions of this mock is that it spoofs chown() and
stat() calls. But it is doing so in a clever way: it stores the
new owner on chown() and reports it on subsequent stat(). This is
done by using a 32bit unsigned integer where one half is used to
store uid the other is for gid. Later, when stat() is called the
integer is fetched and split into halves again. Well, my bit
operation skills are poor and the code I've written does not do
that properly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemusecuritymock: Mock virProcessRunInFork
Michal Privoznik [Mon, 15 Apr 2019 11:45:38 +0000 (13:45 +0200)]
qemusecuritymock: Mock virProcessRunInFork

This test is beautiful. It checks if we haven't messed up
refcounting on security labels (well, XATTRs where the original
owner is stored). It does this by setting up tracking of XATTR
setting/removing into a hash table, then calling
qemuSecuritySetAllLabel() followed by immediate
qemuSecurityRestoreAllLabel() at which point, the hash table must
be empty. The test so beautifully written that no matter
what you do it won't fail. The reason is that all seclabel work
is done in a child process. Therefore, the hash table in the
parent is never changed and thus always empty.

There are two reasons for forking (only one of them makes sense
here though):

1) namespaces - when chown()-ing a file we have to fork() and
make the child enter desired namespace,
2) locking - because of exclusive access to XATTRs we lock the
files we chown() and this is done in a fork (see 207860927ad for
more info).

While we want to fork in real world, we don't want that in a test
suite. Override virProcessRunInFork() then.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agomaint: Post-release version bump to 5.6.0
Michal Privoznik [Wed, 3 Jul 2019 06:30:52 +0000 (08:30 +0200)]
maint: Post-release version bump to 5.6.0

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoRelease of libvirt-5.5.0
Daniel Veillard [Tue, 2 Jul 2019 20:11:22 +0000 (22:11 +0200)]
Release of libvirt-5.5.0

* docs/news.xml: updated for the release

Signed-off-by: Daniel Veillard <veillard@redhat.com>
5 years agoRefresh translations from Zanata
Daniel P. Berrangé [Mon, 1 Jul 2019 17:58:21 +0000 (18:58 +0100)]
Refresh translations from Zanata

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agorpc: Fix build error for virNetServerNew ATTRIBUTE_NONNULL values
John Ferlan [Sun, 30 Jun 2019 13:56:53 +0000 (09:56 -0400)]
rpc: Fix build error for virNetServerNew ATTRIBUTE_NONNULL values

Commit 5a148ce84 altered the virNetServerNew to remove a parameter
but neglected to update the ATTRIBUTE_NONNULL's which causes a build
failure for when checking is enabled such as when lv_cv_static_analysis
is enabled.

Signed-off-by: John Ferlan <jferlan@redhat.com>
5 years agotools: Fix permissions for virt-pki-validate.in
Andrea Bolognani [Mon, 1 Jul 2019 15:08:28 +0000 (17:08 +0200)]
tools: Fix permissions for virt-pki-validate.in

While the script ultimately needs to be executable, the
source file really shouldn't be.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
5 years agodocs: fix acl permission docs
Ján Tomko [Thu, 27 Jun 2019 15:39:50 +0000 (17:39 +0200)]
docs: fix acl permission docs

We have been grouping network-port and nwfilter-binding permissions
under virNetworkPtr and virNWFilterPtr respectively.

Add the two missing classes that were matched because they contain
a substring of others.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agotest_driver: Fix permissions for test_driver.c
Andrea Bolognani [Mon, 1 Jul 2019 14:55:26 +0000 (16:55 +0200)]
test_driver: Fix permissions for test_driver.c

Introduced in commit 4a6ee53581b3.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
5 years agodocs: Document virDomainQemuAttach() removal
Andrea Bolognani [Mon, 1 Jul 2019 13:30:38 +0000 (15:30 +0200)]
docs: Document virDomainQemuAttach() removal

It has been dropped in 215d9393bb60615f957f4, but not all of
the documentation was updated accordingly.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
5 years agonews: Update for 5.5.0 release
Andrea Bolognani [Fri, 28 Jun 2019 15:27:53 +0000 (17:27 +0200)]
news: Update for 5.5.0 release

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoutil: vircgroupv2: stop enabling missing controllers with systemd
Pavel Hrdina [Thu, 27 Jun 2019 12:54:54 +0000 (14:54 +0200)]
util: vircgroupv2: stop enabling missing controllers with systemd

Because of a systemd delegation policy [1] we should not write to any
cgroups files owned by systemd which in case of cgroups v2 includes
'cgroups.subtree_control'.

systemd will enable controllers automatically for us to have them
available for VM cgroups.

[1] <https://github.com/systemd/systemd/blob/master/docs/CGROUP_DELEGATION.md>

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoRevert "util: vircgroup: pass parent cgroup into virCgroupDetectControllersCB"
Pavel Hrdina [Thu, 27 Jun 2019 13:50:22 +0000 (15:50 +0200)]
Revert "util: vircgroup: pass parent cgroup into virCgroupDetectControllersCB"

This reverts commit 7bca1c9bdc85247446129f856e27c80a32819e17.

As it turns out it's not a good idea on systemd hosts.  The root
cgroup can have all controllers enabled but they don't have to be
enabled for sub-cgroups.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoRevert "error: Add VIR_ERR_DEPRECATED error code"
Daniel P. Berrangé [Wed, 26 Jun 2019 15:46:50 +0000 (16:46 +0100)]
Revert "error: Add VIR_ERR_DEPRECATED error code"

This reverts commit 226094fbc483128c8888f4171c353aed738b8346.

A deprecation is a warning to something that use of a feature is
being discouraged. By definition it is not an error condition to
continue to use a deprecated feature.

A VIR_ERR_DEPRECATED constant thus makes no conceptual sense. For
features which are entirely absent we already document that the
VIR_ERR_NO_SUPPORT code will be used. There is no need to distinguish
between a feature which never existed and a feature which previously
existed and was since removed.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoRevert "news: Mention VIR_ERR_DEPRECATED in improvements"
Daniel P. Berrangé [Thu, 27 Jun 2019 08:54:42 +0000 (09:54 +0100)]
Revert "news: Mention VIR_ERR_DEPRECATED in improvements"

This reverts commit 3026f6d9d986ad63c4b4a1c57589e6d05b71bd70.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agodocs: update QEMU driver docs to replace deprecated with deleted
Daniel P. Berrangé [Thu, 27 Jun 2019 08:53:27 +0000 (09:53 +0100)]
docs: update QEMU driver docs to replace deprecated with deleted

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: delete methods which are no longer supported
Daniel P. Berrangé [Wed, 26 Jun 2019 15:45:03 +0000 (16:45 +0100)]
qemu: delete methods which are no longer supported

The public API entry points will report VIR_ERR_NO_SUPPORT to the
caller when a driver does not provide an implementation of a particular
method.

When deleting methods, leaving the driver API entry point explicitly
set to NULL with an version range comment, allows the hvsupport.html
page to document when the AP was removed.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: blockjob: Don't leak 'cfg' from qemuBlockJobEventProcessLegacy
Peter Krempa [Wed, 26 Jun 2019 12:52:08 +0000 (14:52 +0200)]
qemu: blockjob: Don't leak 'cfg' from qemuBlockJobEventProcessLegacy

Since c257352797a a reference of 'cfg' would be leaked if the function
does not need to process anything. Fix it by using VIR_AUTOUNREF.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: distinguish pr disk before qemuHotplugRemoveManagedPR
Jie Wang [Tue, 18 Jun 2019 13:28:26 +0000 (21:28 +0800)]
qemu: distinguish pr disk before qemuHotplugRemoveManagedPR

when a disk without PR perform attach or detach operation,
need not call qemuHotplugRemoveManagedPR, otherwise, it will
print err log about PR, let us fix it.

Signed-off-by: Jie Wang <wangjie88@huawei.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agonetwork: avoid including sys/sysctl.h on Linux
Daniel P. Berrangé [Wed, 26 Jun 2019 13:34:20 +0000 (14:34 +0100)]
network: avoid including sys/sysctl.h on Linux

The sys/sysctl.h header is only needed on BSD platforms to get
the sysctlbyname() function declaration. On Linux we talk to
procfs instead to change sysctls.

Unfortunately a legacy sys/sysctl.h header does exist on Linux
and including it has recently started triggering a deprecation
warning from glibc.

Protect its inclusion with a HAVE_SYSCTLBYNAME check instead
so that it only gets used on platforms where we need that
function declaration.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoutil: vircgroupv2: mark only requested controllers as available
Pavel Hrdina [Sat, 22 Jun 2019 11:46:22 +0000 (13:46 +0200)]
util: vircgroupv2: mark only requested controllers as available

When detecting available controllers on host we can be limited by list
of controllers from qemu.conf file.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agoutil: vircgroupv2: don't error out if enabling controller fails
Pavel Hrdina [Thu, 20 Jun 2019 11:10:20 +0000 (13:10 +0200)]
util: vircgroupv2: don't error out if enabling controller fails

Currently CPU controller cannot be enabled if there is any real-time
task running and is assigned to non-root cgroup which is the case on
several distributions with graphical environment.

Instead of erroring out treat it as the controller is not available.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agoutil: vircgroupv2: separate return values of virCgroupV2EnableController
Pavel Hrdina [Fri, 21 Jun 2019 12:47:47 +0000 (14:47 +0200)]
util: vircgroupv2: separate return values of virCgroupV2EnableController

In order to skip controllers that we are not able to activate we need
to return different return value so the caller can decide what to do.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agoutil: vircgroupv2: enable CPU controller only if it's available
Pavel Hrdina [Thu, 20 Jun 2019 11:09:08 +0000 (13:09 +0200)]
util: vircgroupv2: enable CPU controller only if it's available

It might happen that we are not able to enable CPU controller so we
can enable it for thread sub-cgroups only if it's available in parent
cgroup.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: vircgroupv2: use any controller to create thread directory
Pavel Hrdina [Thu, 20 Jun 2019 11:07:07 +0000 (13:07 +0200)]
util: vircgroupv2: use any controller to create thread directory

The assumption that CPU controller would be always enabled is wrong, we
should use any available controller to create a new sub-cgroup.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: vircgroup: improve controller detection
Pavel Hrdina [Thu, 20 Jun 2019 11:02:57 +0000 (13:02 +0200)]
util: vircgroup: improve controller detection

This affects only cgroups v2 where enabled controllers are not based on
available mount points but on the list provided in cgroup.controllers
file.  However, moving it will fill in placement as well, so it needs
to be freed together with mount point if we don't need that controller.

Before this patch we were assuming that all controllers available in
root cgroup where available in all other sub-cgroups which was wrong.

In order to fix it we need to move the cgroup controllers detection
after cgroup placement was prepared in order to build correct path for
cgroup.controllers file.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agoutil: vircgroup: pass parent cgroup into virCgroupDetectControllersCB
Pavel Hrdina [Thu, 20 Jun 2019 10:59:29 +0000 (12:59 +0200)]
util: vircgroup: pass parent cgroup into virCgroupDetectControllersCB

In cgroups v2 we don't have to detect available controllers every single
time if we are creating a new cgroup based on parent cgroup.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Supply correct default type for 'dir' based VIR_STORAGE_TYPE_VOLUME
Peter Krempa [Tue, 25 Jun 2019 13:23:56 +0000 (15:23 +0200)]
qemu: Supply correct default type for 'dir' based VIR_STORAGE_TYPE_VOLUME

Our code would skip adding the default type in this cases, but since we
know that the only reasonable option here is 'fat' we can add it while
starting the VM.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: domain: Allow 'VIR_STORAGE_TYPE_VOLUME' disks with 'fat' format
Peter Krempa [Tue, 25 Jun 2019 08:36:06 +0000 (10:36 +0200)]
qemu: domain: Allow 'VIR_STORAGE_TYPE_VOLUME' disks with 'fat' format

The storage volume may in fact convert into a directory when starting
the VM so that it may be actually possible to use it.

This is a regression caused by c9b27af32d5 as moving the check to
validation time without adjustment causes problems as the volumes are
not translated yet.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: command: Use 'actualType' when deciding whether to use disk format
Peter Krempa [Tue, 25 Jun 2019 14:16:21 +0000 (16:16 +0200)]
qemu: command: Use 'actualType' when deciding whether to use disk format

qemuBuildDriveSourceStr omits the disk format string when we are
emulating a 'fat' filesystem from a directory. The logic should decide
based on the 'actualType' as a disk type=pool may be converted to a
directory.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: storage: Fix virStorageSourceGetActualType if volume was not translated
Peter Krempa [Tue, 25 Jun 2019 10:59:07 +0000 (12:59 +0200)]
util: storage: Fix virStorageSourceGetActualType if volume was not translated

virStorageSourceGetActualType would return VIR_STORAGE_TYPE_NONE in case
when a virStorageSource of (top level) type VIR_STORAGE_TYPE_VOLUME was
not prepared to use by the vm by calling
virDomainDiskTranslateSourcePool.

Fix this issue by returning VIR_STORAGE_TYPE_VOLUME in case when the
volume was not translated yet.

Additionally also add documentation for the function describing the
quirk.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: Enable *-headless and *-graphics in qemuxml2xml
Andrea Bolognani [Wed, 12 Jun 2019 10:25:28 +0000 (12:25 +0200)]
tests: Enable *-headless and *-graphics in qemuxml2xml

We didn't do this earlier because the DO_TEST_CAPS_ARCH_LATEST()
macro was limited to qemuxml2argv until recently.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: Add riscv64-virt-graphics
Andrea Bolognani [Thu, 13 Jun 2019 11:51:33 +0000 (13:51 +0200)]
tests: Add riscv64-virt-graphics

Support for this has only relatively recently been added to
virt-manager.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: Update *-headless and *-graphics
Andrea Bolognani [Wed, 12 Jun 2019 16:28:25 +0000 (18:28 +0200)]
tests: Update *-headless and *-graphics

Use the latest virt-manager to regenerate the files.

The command line is once again along the lines of

  $ virt-install \
    --name guest --os-variant fedora29 \
    --vcpus 4 --memory 4096 --disk size=5 \
    --graphics (none|vnc) \
    --print-xml

with some minor tweaks performed afterwards.

This removes a number of inconsistencies between the files,
and makes it so the only differences are actually relevant
either to the architecture and machine type at hand, or to
having graphics rather than being headless.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: Normalize quotes for *-graphics
Andrea Bolognani [Wed, 12 Jun 2019 11:49:45 +0000 (13:49 +0200)]
tests: Normalize quotes for *-graphics

Right now *-headless and *-graphics tests are using different
quoting styles, which results in the diff between them being
basically useless, whereas we would like it to be possible to
compare these files directly and easily spot the differences.

Convert all *-graphics tests to single quotes, which is the
style libvirt itself uses when formatting XML: this is a fact
that will come in handy later.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu_firmware: only set nfeatures on success
Marc-André Lureau [Wed, 5 Jun 2019 10:31:01 +0000 (12:31 +0200)]
qemu_firmware: only set nfeatures on success

The field is set just before returning on success.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agotpm: minor argument comment fix
Marc-André Lureau [Wed, 5 Jun 2019 10:31:00 +0000 (12:31 +0200)]
tpm: minor argument comment fix

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agodevice-conf: removed unneeded virDomainDeviceInfoCopy()
Marc-André Lureau [Wed, 5 Jun 2019 10:30:59 +0000 (12:30 +0200)]
device-conf: removed unneeded virDomainDeviceInfoCopy()

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: hotplug: Remove rest of source backend if hotplug fails
Peter Krempa [Thu, 28 Mar 2019 14:59:38 +0000 (15:59 +0100)]
qemu: hotplug: Remove rest of source backend if hotplug fails

When changing media using blockdev-add we need to remove the leftovers
if we didn't succeed plugging in the full chain or closing the tray.
Otherwise the data structures will be freed and thus the backing chain
members will never be unplugged.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: hotplug: Use storage chain helpers in qemuDomainChangeMediaBlockdev
Peter Krempa [Fri, 5 Apr 2019 11:54:48 +0000 (13:54 +0200)]
qemu: hotplug: Use storage chain helpers in qemuDomainChangeMediaBlockdev

As this conversion removes the last use of qemuHotplugDiskSource*
functions we can remove all of them now.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: hotplug: Use storage chain helpers in qemuDomainRemoveDiskDevice
Peter Krempa [Fri, 5 Apr 2019 11:47:44 +0000 (13:47 +0200)]
qemu: hotplug: Use storage chain helpers in qemuDomainRemoveDiskDevice

Use the new helpers for removing the backing chain in case when
-blockdev is used. For -drive this function has a local implementation.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: hotplug: Use storage chain helpers in qemuDomainAttachDiskGeneric
Peter Krempa [Thu, 4 Apr 2019 15:10:27 +0000 (17:10 +0200)]
qemu: hotplug: Use storage chain helpers in qemuDomainAttachDiskGeneric

Replace the use of qemuHotplugDiskSourceAttach* helpers with
qemuBuildStorageSourceChainAttachPrepare(Blockdev|Drive).

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: command: get rid of 'cleanup' in qemuBuildDiskSourceCommandLine
Peter Krempa [Mon, 24 Jun 2019 13:48:59 +0000 (15:48 +0200)]
qemu: command: get rid of 'cleanup' in qemuBuildDiskSourceCommandLine

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: command: Use VIR_AUTO infrastructure in qemuBuildDiskSourceCommandLine
Peter Krempa [Mon, 24 Jun 2019 13:47:48 +0000 (15:47 +0200)]
qemu: command: Use VIR_AUTO infrastructure in qemuBuildDiskSourceCommandLine

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: command: Use storage chain helpers in commandline generator
Peter Krempa [Thu, 4 Apr 2019 14:58:58 +0000 (16:58 +0200)]
qemu: command: Use storage chain helpers in commandline generator

Replace the open-coded local implementation with
qemuBuildStorageSourceChainAttachPrepare(Drive|Blockdev).

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Introduce new set of helpers for attaching and detaching storage chains
Peter Krempa [Thu, 4 Apr 2019 14:50:49 +0000 (16:50 +0200)]
qemu: Introduce new set of helpers for attaching and detaching storage chains

These are meant to replace the ad-hoc helpers qemuHotplugDiskSourceAttach...
and the open-coded version in qemu_command.c for use in command line
generation.

The functions for preparing for attach of chains unfortunately need to
be in qemu_command.c as they use function defined by that file and
inclusion hierarchy.

In this patch new functions are introduced and subsequent patches then
refactor individual parts to use them.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: hotplug: Handle copy-on-read filter separate from rest of backing chain
Peter Krempa [Thu, 28 Mar 2019 15:04:55 +0000 (16:04 +0100)]
qemu: hotplug: Handle copy-on-read filter separate from rest of backing chain

We use only one copy-on-read filter per disk, so we should handle it
separately from the chain.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: block: Move and rename qemuHotplugRemoveStorageSourcePrepareData
Peter Krempa [Wed, 10 Oct 2018 13:30:24 +0000 (15:30 +0200)]
qemu: block: Move and rename qemuHotplugRemoveStorageSourcePrepareData

Move it to qemu_block.c and call it qemuBlockStorageSourceDetachPrepare.
It will be reused in other parts as well.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agonews: Mention VIR_ERR_DEPRECATED in improvements
Peter Krempa [Fri, 21 Jun 2019 06:33:07 +0000 (08:33 +0200)]
news: Mention VIR_ERR_DEPRECATED in improvements

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Use VIR_ERR_DEPRECATED in QemuAttach and DomainXMLFromNative stubs
Peter Krempa [Fri, 21 Jun 2019 06:29:22 +0000 (08:29 +0200)]
qemu: Use VIR_ERR_DEPRECATED in QemuAttach and DomainXMLFromNative stubs

We've deprecated qemuConnectDomainXMLFromNative qemuDomainQemuAttach.
Switch the error code from VIR_ERR_OPERATION_UNSUPPORTED to the new
VIR_ERR_DEPRECATED.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoerror: Add VIR_ERR_DEPRECATED error code
Peter Krempa [Fri, 21 Jun 2019 06:28:17 +0000 (08:28 +0200)]
error: Add VIR_ERR_DEPRECATED error code

Allow a simple programatic check that a given feature is no longer
supported by introducing a separate error code for this scenario.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoconf: storage: also sanitize source dir
Ján Tomko [Tue, 25 Jun 2019 11:37:16 +0000 (13:37 +0200)]
conf: storage: also sanitize source dir

Commit a7fb2258 added sanitization of storage pool target paths,
however source dir paths were left unsanitized.

A netfs pool with:
<source>
  <host name='10.20.30.40'/>
  <dir path='/nfs/'/>
</source>
will not be correctly detected as mounted by
virStorageBackendFileSystemIsMounted, because it shows up in the
mount list without the trailing slash.

Sanitize the source dir as well.

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
5 years agoconf: domain: Restore XPath context after virSecurityDeviceLabelDefParseXML
Peter Krempa [Mon, 24 Jun 2019 16:12:48 +0000 (18:12 +0200)]
conf: domain: Restore XPath context after virSecurityDeviceLabelDefParseXML

The function modifies the context but did not care to restore it back.
If a <seclabel> was used on a disk, the <privateData> would not be
parsed.

Use VIR_XPATH_NODE_AUTORESTORE and add a test case to validate that
everything works.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agostorage: fix omitted comma for ceph mon hosts to librados
Yi Li [Tue, 25 Jun 2019 11:41:25 +0000 (19:41 +0800)]
storage: fix omitted comma for ceph mon hosts to librados

Add omitted comma for multiple hosts.
Fixes: cdd362e0e7a34d4f8f102c75f2ca513d23dd1db0
Signed-off-by: Yi Li <yili@winhong.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agocpu_x86: Handle error in x86DataToCPU when calling x86DataAdd
John Ferlan [Fri, 21 Jun 2019 17:10:35 +0000 (13:10 -0400)]
cpu_x86: Handle error in x86DataToCPU when calling x86DataAdd

Commit 9c9620af called x86DataAdd without checking for an error,
so add the error checking.

Found by Coverity

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agocpu_x86: Fix memory leak - virCPUx86GetHost
John Ferlan [Fri, 21 Jun 2019 17:07:15 +0000 (13:07 -0400)]
cpu_x86: Fix memory leak - virCPUx86GetHost

Commit 56b254dcc called virCPUx86DataAdd, but returned -1 directly
without calling the virCPUx86DataFree.

Found by Coverity.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agovirpci: report dev->name in virPCIGetHeaderType error message
Daniel Henrique Barboza [Fri, 21 Jun 2019 15:58:28 +0000 (12:58 -0300)]
virpci: report dev->name in virPCIGetHeaderType error message

Trivial change. Adding the name of the device that has an
unknown PCI header type in that function helps when debugging
PCI code.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agoqemu: Adjust ATTRIBUTE_NONNULL
John Ferlan [Fri, 21 Jun 2019 16:49:54 +0000 (12:49 -0400)]
qemu: Adjust ATTRIBUTE_NONNULL

Commit 7bf679ae removed the @json argument from the qemuMonitorOpen
prototype; however, it did not update the ATTRIBUTE_NONNULL value
which causes a build failure for when checking is enabled such as
when lv_cv_static_analysis is enabled.

Signed-off-by: John Ferlan <jferlan@redhat.com>
5 years agomaint: Add missing 'global:' tag in libvirt_public.syms
Eric Blake [Fri, 21 Jun 2019 19:23:06 +0000 (14:23 -0500)]
maint: Add missing 'global:' tag in libvirt_public.syms

Fixes: c08fc8d1
Signed-off-by: Eric Blake <eblake@redhat.com>
5 years agovirStorageSourceChainHasManagedPR: Check propely
Michal Privoznik [Fri, 21 Jun 2019 16:01:38 +0000 (18:01 +0200)]
virStorageSourceChainHasManagedPR: Check propely

In the virStorageSourceChainHasManagedPR() function we iterate
over whole backing chain trying to determine if one of the layers
has managed PR configured. But due to a typo we in fact check the
top layer only.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
5 years agorpc: add $(SASL_CFLAGS) to libvirt_net_rpc_server_la_CFLAGS
Daniel P. Berrangé [Fri, 21 Jun 2019 14:39:45 +0000 (15:39 +0100)]
rpc: add $(SASL_CFLAGS) to libvirt_net_rpc_server_la_CFLAGS

The files for libvirt-net-rpc-server.la refernce the sasl/sasl.h
system header but never used the $(SASL_CFLAGS) variable. This
was never noticed previously because the $(AVAHI_CLFAGS) were
set and these typically pulled in the same include directory.

When mDNS/Avahi support was removed this exposed the bug which
caused FreeBSD builds to break as /usr/local/include was no
longer searched for headers.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: Implement support for 'capability_filters' config option
Peter Krempa [Tue, 18 Jun 2019 08:04:32 +0000 (10:04 +0200)]
qemu: Implement support for 'capability_filters' config option

Filter out the given capabilities and set domain taint if we've done so.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: conf: Add debug option to allow disabling qemu capabilities
Peter Krempa [Tue, 18 Jun 2019 07:46:22 +0000 (09:46 +0200)]
qemu: conf: Add debug option to allow disabling qemu capabilities

In cases when e.g. a new feature breaks upstream behaviour it's useful
to allow users to disable the new feature to verify the regression and
possibly use it as a workaround until a fix is available.

The new qemu.conf option named "capability_filters" allows to remove
qemu capabilities from the detected bitmap.

This patch introduces the configuration infrastructure to parse the
option and pass it around.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Remove unused var 'corestr' from virQEMUDriverConfigLoadFile
Peter Krempa [Tue, 18 Jun 2019 07:02:28 +0000 (09:02 +0200)]
qemu: Remove unused var 'corestr' from virQEMUDriverConfigLoadFile

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: qemuxml2argv: Test qemu namespace capability tweaking
Peter Krempa [Tue, 18 Jun 2019 06:29:36 +0000 (08:29 +0200)]
tests: qemuxml2argv: Test qemu namespace capability tweaking

Show that the capability tweaking stuff works by enabling blockdev in
the 'qemu-ns' test even in versions where it's not yet fully supported.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: qemuxml2argv: Modernize and fork 'qemu-ns' test
Peter Krempa [Tue, 18 Jun 2019 06:27:07 +0000 (08:27 +0200)]
tests: qemuxml2argv: Modernize and fork 'qemu-ns' test

Use the DO_TEST_CAPS_LATEST/VER infrastructure to run a more modern
version of this and also fork it to a pre-blockdev version so that we
can check the qemu namespace capability tweaking.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: domain: Add support for modifying qemu capability list via qemu namespace
Peter Krempa [Mon, 17 Jun 2019 15:55:52 +0000 (17:55 +0200)]
qemu: domain: Add support for modifying qemu capability list via qemu namespace

For testing purposes it's sometimes desired to be able to control the
presence of capabilities of qemu. This adds the possibility to do this
via the qemu namespace.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Add support for controling qemu capabilities via the qemu XML namespace
Peter Krempa [Mon, 17 Jun 2019 15:17:56 +0000 (17:17 +0200)]
qemu: Add support for controling qemu capabilities via the qemu XML namespace

Similarly how we allow adding arbitrary command line arguments and
environment variables this patch introduces the ability to control
libvirt's perception of the qemu process by tweaking the capability bits
for testing purposes.

The idea is to allow developers and users either test a new feature by
enabling it early or disabling it to see whether it introduced
regressions.

This feature is not meant for production use though, so users should
handle it with care.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoconf: Add taint flag for custom hypervisor features
Peter Krempa [Mon, 17 Jun 2019 15:31:45 +0000 (17:31 +0200)]
conf: Add taint flag for custom hypervisor features

Upcoming patches will allow enabling/disabling custom hypervisor
features for debugging/testing purposes via the qemu namespace.

Add a taint flag where we will flag such a domain so it's obvious what's
happening.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: domain: Split out commandline namespace data formatting
Peter Krempa [Mon, 17 Jun 2019 14:45:06 +0000 (16:45 +0200)]
qemu: domain: Split out commandline namespace data formatting

Separate it from qemuDomainDefNamespaceFormatXML.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
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>