Commit Graph

40024 Commits

Author SHA1 Message Date
Jianan Gao
99e5c011b3 news: Document apparmor improvements in v6.7.0
Add news about apparmor improvements.

Signed-off-by: Jianan Gao <jgao@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2020-11-16 12:37:38 +01:00
Andrea Bolognani
57515a4c36 util: Make virFileClose() quiet on success
While it's certainly good to log events like "failed to close fd"
and "tried to close invalid fd", which are likely to be the
consequence of some bug in libvirt, logging a message every single
time a file descriptor is closed successfully is perhaps excessive
and can lead to useful information being missed among the noise.

Log filters don't help in this situation, because filtering out all
of util.file is too big a hammer and would cause important messages
to be left out as well.

To give an idea of just how much noise this single debug statement
can cause, here's a real life example from a quite large libvirtd
log I had to look at recently:

  $ grep virFile libvirt.log | wc -l
  1307
  $ grep virFile libvirt.log | grep -v 'Closed fd' | wc -l
  343

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-16 09:18:03 +01:00
Laine Stump
7754933983 util: remove ATTRIBUTE_NONNULL from virDirClose declaration
Before commit 24d8968c, virDirClose took a DIR**, and that was never
NULL, so its declaration included ATTRIBUTE_NONNULL(1). Since that
commit, virDirClose takes a DIR*, and it may be NULL (e.g. if the DIR*
is initialized to NULL and was never closed).

Even though virDirClose() is currently only called implicitly (as the
cleanup for a g_autoptr(DIR)), and (as I've just newly learned) the
autocleanup function g_autoptr will only be called if the pointer in
question is non-null (see the definition of
_GLIB_AUTOPTR_CLEAR_FUNC_NAME in
/usr/include/glib-2.0/glib/gmacros.h), it does still cause Coverity to
complain that it *could* be called with a NULL, and it's also possible
that in the future someone might add code that explicitly calls
virDirClose.

To eliminate the Coverity complaints, and protect against the
hypothetical future where someone both explicitly calls virDirClose()
with a potentially NULL value, *and* re-enables the nonnull directive
when not building with Coverity (disabled by commit eefb881) this
patch removes the ATTRIBUTE_NONNULL(1) from the declaration of
virDirClose().

Fixes: 24d8968cd0
Reported-by: John Ferlan <jferlan@redhat.com>
Details-Research-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Laine Stump <laine@redhat.com>
2020-11-13 14:58:48 -05:00
Daniel Henrique Barboza
c441f60be8 qemu_driver.c: do not redefine 'event' in qemuDomainDefineXMLFlags()
A bad merge while rebasing 74b2834333 caused the @event variable
to be defined twice, inside the 'cleanup' label, causing coverity
errors.

This code was originally moved outside of the label by commit
773c7c4361. Delete the unintended code in the 'cleanup'
label.

Fixes: 74b2834333
Reported-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-13 16:53:22 -03:00
Andrea Bolognani
045ecbeec6 kbase: Shorten "less verbose QEMU logging" example
Rationale for the changes:

  * access can be filtered out entirely, as nothing very
    interesting is produced by the only other component in the
    same package (access.accessdriverpolkit);

  * util.udev doesn't exist.

Related filters are also more consistently grouped together.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-11-13 18:15:38 +01:00
Michal Privoznik
1b077e6116 virnetdevopenvswitch: Fix ATTRIBUTE_NONNULL() tag for virNetDevOpenvswitchGetVhostuserIfname()
After e4c29e2904 the function has one argument more and the
argument that can't be NULL moved from second to third position.

Reported-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-13 18:12:49 +01:00
Jonathan Watt
1423c1d8bc docs: compiling.html: pass -d to xz to decompress
tar on macOS recognizes XZ compression automatically, but that is
not the case for GNU tar (1.32 at least).  On Fedora 33 the current
instructions result in the following error:

  $ xz -c libvirt-6.9.0.tar.xz | tar xvf -
  tar: Archive is compressed. Use -J option
  tar: Error is not recoverable: exiting now

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Jonathan Watt <jwatt@jwatt.org>
2020-11-13 16:22:43 +00:00
Daniel Henrique Barboza
66ee13809c qemu_domain.c: modernize qemuMonitorGetCpuHalted()
Use g_autoptr() and remove the 'cleanup' label.

Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-13 12:11:44 -03:00
Daniel Henrique Barboza
8a778ebfe1 qemu_domain.c: modernize qemuDomainWriteMasterKeyFile()
Use VIR_AUTOCLOSE with 'fd' and delete the 'cleanup' label.

Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-13 12:11:44 -03:00
Daniel Henrique Barboza
5a5fde03bb qemu_domain.c: modernize qemuDomainFixupCPUs()
Use g_autoptr() to deprecate the 'cleanup' label.

Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-13 12:11:44 -03:00
Daniel Henrique Barboza
f17de6c173 qemu_domain.c: remove unneeded cleanup labels
Remove obsolete 'cleanup' labels after the changes from the
previous patch.

Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-13 12:11:44 -03:00
Daniel Henrique Barboza
c269d7ad2d qemu_domain.c: use g_autoptr() with virDomainDef pointers
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-13 12:11:44 -03:00
Daniel Henrique Barboza
0ea83f7ebb qemu_snapshot.c: remove uneeded 'cleanup' label in qemuSnapshotDelete()
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-13 12:11:44 -03:00
Daniel Henrique Barboza
269dffd0ce qemu_driver.c: remove unneeded 'cleanup' labels
Some labels became deprecated after the previous patches.

Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-13 12:11:44 -03:00
Daniel Henrique Barboza
9c215628d6 qemu_driver.c: use g_autoptr() with virDomainDeviceDefPtr
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-13 12:11:44 -03:00
Daniel Henrique Barboza
94196ba605 qemu_driver.c: use g_autoptr() with qemuMigrationParams pointers
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-13 12:11:43 -03:00
Daniel Henrique Barboza
74b2834333 qemu_driver.c: use g_autoptr() with virDomainDef pointers
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-13 12:11:43 -03:00
Thomas Huth
6f0ee50be2 migration.html: Fix the spelling of the --persistent parameter
"--persist" is missing the "ent" at the end.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2020-11-13 15:58:52 +01:00
Thomas Huth
0b6d0e2046 migration.html: Fix the spelling of the --undefinesource parameter
There is no dash between "undefine" and "source" in this parameter.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2020-11-13 15:22:37 +01:00
Nikolay Shirokovskiy
b814d499a7 qemu: remove possible garbage left from previous rename/undefine
Due to failures to unlink on previous rename/undefine we can already have
autolink etc files for the domain to be defined. Remove them.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-13 14:49:50 +03:00
Nikolay Shirokovskiy
773c7c4361 qemu: qemuDomainDefineXMLFlags: move cleanup logic to cleanup section
Let's move objlist restoring to cleanup section so that we can handle failure
of actions between virDomainObjListAdd and virDomainDefSave. We are going
to add such actions in next patch.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-13 14:49:50 +03:00
Nikolay Shirokovskiy
e2738b2bd7 qemu: rename: remove snapshot/checkpoint restriction
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-13 14:49:50 +03:00
Nikolay Shirokovskiy
a3259e47d2 qemu: update name on reverting from snapshot
If domain name is changed since snapshot we need to update it to current in
config taken from snapshot.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-13 14:49:50 +03:00
Nikolay Shirokovskiy
3b1244bffd qemu: rename: support renaming checkpoints directory
This is basically just saves checkpoints metadata on disk after name is changed
in memory as path to domain checkpoints directory depends on name. After that
old checkpoint directory is deleted with checkpoint metadata files.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-13 14:49:50 +03:00
Nikolay Shirokovskiy
4770a96c66 qemu: rename: support renaming snapshots directory
This is basically just saves snapshots metadata on disk after name is changed
in memory as path to domain snapshot directory depends on name. After that
old snapshot directory is deleted with snapshot metadata files.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-13 14:49:50 +03:00
Nikolay Shirokovskiy
1f209eac1d qemu: remove duplicate code for removing remnant files
This patch also changes functionality a bit.

First if unlinking of old config file is failed we rollback and return error
previously and now we return success. I don't think this makes much difference.
I guess in both cases on libvirtd restart we have to deal with both new and old
config existing on disk with different names but same uuid.

Second if unlinking of old autolink is failed we rollback previously which
was not right as at this point we already unlink old config file. So this
is fixed now.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-13 14:49:50 +03:00
Nikolay Shirokovskiy
a6c3b5e6a1 qemu: rename: return instead of goto if no cleanup required
Going to cleanup label is mere return -1 thus let's just return
instead of goto to this label.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-13 14:49:49 +03:00
Nikolay Shirokovskiy
9a5ac61c4e qemu: rename: send events only on success
We can simplify cleanup section by moving sending events to success path only
because only on sucess path events are not NULL.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-13 14:49:49 +03:00
Nikolay Shirokovskiy
8afbd34ba9 qemu: qemuDomainRenameCallback: fix sending false undefined event
For example if saving config file with new name fails we send false undefine
event currently.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-13 14:49:49 +03:00
Olaf Hering
f76f6d1556 meson: fix yajl detection
yajl_tree_parse is declared in yajl/yajl_tree.h
autoconf is more forgiving, the error did not trigger because
yajl_tree_parse is not actually used.

Fixes: 44b8df4cb4
Fixes: 88ab32a4e5
Signed-off-by: Olaf Hering <olaf@aepfle.de>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2020-11-13 11:23:13 +01:00
Peter Krempa
d2d23aa2a6 tools: virsh: Reset error when keepalive registration fails
We try to enable keepalive oportunistically. If it's not supported by
the connection driver and it was not explicitly requested we keep the
error object set and can report it in some cases accidentally:

 --- stdout ---
 TEST: /home/pipo/libvirt/tests/virsh-self-test
       !                                        1   FAILED
 --- stderr ---
 error: parameter 'target' of command 'attach-disk' must be listed before optional parameters
 error: this function is not supported by the connection driver: virConnectSetKeepAlive
 -------

Clear the stored libvirt error.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-13 11:12:30 +01:00
Peter Krempa
a1ed7f37ce tools: vshCmddefOptParse: Remove return value
The function can't fail so there's no need to return a value or check it
in the callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-13 11:12:30 +01:00
Peter Krempa
fde5b4cf9d tools: vshCmddefHelp: Don't call vshCmddefOptParse
The help formatter called vshCmddefOptParse just for validation
purposes. Since vshCmddefOptParse no longer validates the command itself
and we don't need the bitmaps returned by it we can drop the call
entirely.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-13 11:12:30 +01:00
Peter Krempa
cd0602290a tools: vshCmddefOptParse: Remove 'optional' command validation
Since vshCmddefCheckInternals now has this check we no longer need it in
vshCmddefOptParse.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-13 11:12:29 +01:00
Peter Krempa
0d00e95298 tools: cmdSelfTest: Drop misleading comment
We no longer print help for every command to validate the args.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-13 11:12:29 +01:00
Peter Krempa
fa7265e127 tools: vshCmddefCheckInternals: Port mandatory options check from vshCmddefOptParse
'vshCmddefCheckInternals' is the go-to place for all checks related to
the definition of parameters for commands, but the check that all
mandatory parameters must be ordered before optional parameters was
still only in vshCmddefOptParse.

Adding a non-compliant option would not be caught by our test suite as
'virsh self-test' doesn't call vshCmddefOptParse.

Re-implement the check in vshCmddefCheckInternals.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-13 11:12:29 +01:00
Peter Krempa
b070332261 tools: vshCmddefCheckInternals: Add parameter name to error message
If a parameter definition is invalid we can include the name of the
parameter for simpler debugging.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-13 11:12:29 +01:00
Peter Krempa
f2a602f5a3 tools: vsh: Unexport vshCmddefHelp
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-13 11:12:29 +01:00
Peter Krempa
0956edee37 tests: qemucapabilities: Update latest qemu caps to qemu v5.2.0-rc1
Synchronize with the latest release candidate.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-13 11:12:29 +01:00
Michal Privoznik
4895a3e55d kbase: Document minimal libvirt version for NUMA-less virtiofs
Using virtiofs without NUMA was implemented in v6.9.0-rc1~161 but
our kbase document only mentions QEMU version which may confuse
users.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-13 10:02:56 +01:00
Matt Coleman
09ba97ad6b news: implement vCPU APIs in the Hyper-V driver
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-12 18:58:57 +01:00
Matt Coleman
0b27822472 hyperv: implement domainSetVcpus and domainSetVcpusFlags
Co-authored-by: Sri Ramanujam <sramanujam@datto.com>
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-12 18:58:57 +01:00
Matt Coleman
30525b759b hyperv: implement domainGetMaxVcpus
Co-authored-by: Sri Ramanujam <sramanujam@datto.com>
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-12 18:58:57 +01:00
Matt Coleman
b516400976 hyperv: implement domainGetVcpusFlags
Co-authored-by: Sri Ramanujam <sramanujam@datto.com>
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-12 18:58:57 +01:00
Matt Coleman
01a93d55a0 hyperv: implement domainGetVcpus
Co-authored-by: Sri Ramanujam <sramanujam@datto.com>
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-12 18:58:57 +01:00
Matt Coleman
265e3244c2 domain: introduce constants for virVcpuInfo->cpu state values
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-12 18:58:57 +01:00
Jiri Denemark
d8e5b45600 qemu: Do not require TSC frequency to strictly match host
Some CPUs provide a way to read exact TSC frequency, while measuring it
is required on other CPUs. However, measuring is never exact and the
result may slightly differ across reboots. For this reason both Linux
kernel and QEMU recently started allowing for guests TSC frequency to
fall into +/- 250 ppm tolerance interval around the host TSC frequency.

Let's do the same to avoid unnecessary failures (esp. during migration)
in case the host frequency does not exactly match the frequency
configured in a domain XML.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-12 17:29:16 +01:00
Andrea Bolognani
6c1ad2735a Fix capitalization "CLang" -> "Clang"
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2020-11-12 15:01:42 +01:00
Daniel P. Berrangé
b3710e9a2a Set -Wno-incompatible-pointer-types-discards-qualifiers
With Clang we're getting failures from casts in GLib macros

../dist-unpack/libvirt-6.10.0/src/util/vireventthread.c:35:1:
  error: passing 'typeof (*(&g_define_type_id__volatile)) *'
  (aka 'volatile unsigned long *') to parameter of type
  'gsize *' (aka 'unsigned long *') discards qualifiers
  [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
G_DEFINE_TYPE(virEventThread, vir_event_thread, G_TYPE_OBJECT)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The cast is valid and there's no way for libvirt to workaround
the issue, so we must disable this Clang warning flag.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-11-12 11:21:26 +00:00
Matt Coleman
db98d17709 news: some memory and scheduler Hyper-V APIs
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-12 09:43:59 +01:00