Commit Graph

33535 Commits

Author SHA1 Message Date
Michal Privoznik
f45c97eac2 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>
2019-07-03 08:36:03 +02:00
Michal Privoznik
90540a37be 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>
2019-07-03 08:36:03 +02:00
Michal Privoznik
3c02d383f9 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>
2019-07-03 08:36:03 +02:00
Michal Privoznik
1d34d2462e 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>
2019-07-03 08:36:03 +02:00
Michal Privoznik
8ffb5f2738 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>
2019-07-03 08:36:03 +02:00
Michal Privoznik
80cf6ec6f2 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>
2019-07-03 08:36:03 +02:00
Michal Privoznik
854f0e85e4 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>
2019-07-03 08:36:03 +02:00
Michal Privoznik
0a9dcfabf8 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 207860927a 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>
2019-07-03 08:36:03 +02:00
Michal Privoznik
d81d089e17 maint: Post-release version bump to 5.6.0
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2019-07-03 08:30:52 +02:00
Daniel Veillard
d828ca12b0 Release of libvirt-5.5.0
* docs/news.xml: updated for the release

Signed-off-by: Daniel Veillard <veillard@redhat.com>
2019-07-02 22:11:22 +02:00
Daniel P. Berrangé
e0c44300c4 Refresh translations from Zanata
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-07-01 19:02:08 +01:00
John Ferlan
1aa162562c 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>
2019-07-01 11:39:30 -04:00
Andrea Bolognani
599c8a364f 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>
2019-07-01 17:20:32 +02:00
Ján Tomko
bf4a620f17 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>
2019-07-01 17:10:20 +02:00
Andrea Bolognani
df1b5cf02e test_driver: Fix permissions for test_driver.c
Introduced in commit 4a6ee53581.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2019-07-01 17:02:05 +02:00
Andrea Bolognani
06ecf23ef2 docs: Document virDomainQemuAttach() removal
It has been dropped in 215d9393bb, but not all of
the documentation was updated accordingly.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-07-01 15:41:27 +02:00
Andrea Bolognani
d40f7b6bac news: Update for 5.5.0 release
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Michal Privoznik <mprivozn@redhat.com>
2019-06-28 21:28:36 +02:00
Pavel Hrdina
62dd4d25a2 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>
2019-06-28 15:17:37 +02:00
Pavel Hrdina
d117431143 Revert "util: vircgroup: pass parent cgroup into virCgroupDetectControllersCB"
This reverts commit 7bca1c9bdc.

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>
2019-06-28 15:17:26 +02:00
Daniel P. Berrangé
bd17012f0c Revert "error: Add VIR_ERR_DEPRECATED error code"
This reverts commit 226094fbc4.

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>
2019-06-27 14:47:10 +01:00
Daniel P. Berrangé
2fbaa28e12 Revert "news: Mention VIR_ERR_DEPRECATED in improvements"
This reverts commit 3026f6d9d9.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-06-27 14:47:05 +01:00
Daniel P. Berrangé
c0859f3e16 docs: update QEMU driver docs to replace deprecated with deleted
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-06-27 14:43:08 +01:00
Daniel P. Berrangé
464a41bc0d 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>
2019-06-27 14:41:48 +01:00
Peter Krempa
773f923e74 qemu: blockjob: Don't leak 'cfg' from qemuBlockJobEventProcessLegacy
Since c257352797 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>
2019-06-27 13:09:54 +02:00
Jie Wang
cf146eb042 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>
2019-06-26 17:10:52 +02:00
Daniel P. Berrangé
3338c40b47 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>
2019-06-26 14:36:11 +01:00
Pavel Hrdina
05807e5d42 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>
2019-06-26 13:34:01 +02:00
Pavel Hrdina
1d49cdcd11 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>
2019-06-26 13:34:01 +02:00
Pavel Hrdina
29a94a3fef 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>
2019-06-26 13:34:01 +02:00
Pavel Hrdina
f9d1c08557 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>
2019-06-26 13:34:01 +02:00
Pavel Hrdina
535bdf83c0 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>
2019-06-26 13:34:01 +02:00
Pavel Hrdina
d3007c844d 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>
2019-06-26 13:34:01 +02:00
Pavel Hrdina
7bca1c9bdc 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>
2019-06-26 13:34:01 +02:00
Peter Krempa
7d5b283065 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>
2019-06-26 12:28:31 +02:00
Peter Krempa
99917ade0a 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 c9b27af32d 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>
2019-06-26 12:28:31 +02:00
Peter Krempa
76e3de37bf 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>
2019-06-26 12:28:31 +02:00
Peter Krempa
6dd609114d 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>
2019-06-26 12:28:31 +02:00
Andrea Bolognani
1e49d1ec79 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>
2019-06-26 10:37:54 +02:00
Andrea Bolognani
19c6ef2785 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>
2019-06-26 10:37:51 +02:00
Andrea Bolognani
c5fe779342 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>
2019-06-26 10:37:48 +02:00
Andrea Bolognani
e13e64f49a 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>
2019-06-26 10:36:58 +02:00
Marc-André Lureau
fe09cd72aa 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>
2019-06-26 09:24:09 +02:00
Marc-André Lureau
6cff855c73 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>
2019-06-26 09:24:09 +02:00
Marc-André Lureau
caa4f0dd82 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>
2019-06-26 09:24:09 +02:00
Peter Krempa
04c7fc0809 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>
2019-06-26 08:59:37 +02:00
Peter Krempa
9237a81c13 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>
2019-06-26 08:59:37 +02:00
Peter Krempa
513faf6ccc 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>
2019-06-26 08:59:37 +02:00
Peter Krempa
407fd434bc 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>
2019-06-26 08:59:37 +02:00
Peter Krempa
c64010d3e8 qemu: command: get rid of 'cleanup' in qemuBuildDiskSourceCommandLine
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-06-26 08:59:37 +02:00
Peter Krempa
29e4368382 qemu: command: Use VIR_AUTO infrastructure in qemuBuildDiskSourceCommandLine
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-06-26 08:59:37 +02:00