Commit Graph

43231 Commits

Author SHA1 Message Date
Michal Privoznik
50809fcc86 NEWS: Move my contributions to correct release
In previous commit I've documented my contributions for upcoming
7.7.0 release. But unfortunately I've placed the lines into wrong
release (7.6.0).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2021-08-27 17:39:33 +02:00
Michal Privoznik
08199a4e33 NEWS: Document my contributions for the upcoming release
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2021-08-27 16:09:02 +02:00
Jim Fehlig
f924fe7243 NEWS: Mention new SecurityManager APIs for labeling network devices
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2021-08-27 08:02:25 -06:00
Kristina Hanicova
23dc1f43d1 NEWS: Document new '--validate' option for virsh define commands
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2021-08-27 15:27:19 +02:00
Jim Fehlig
2e8ebfe3fa qemu: Set label on vhostuser net device when hotplugging
Attaching a newly created vhostuser port to a VM fails due to an
apparmor denial

internal error: unable to execute QEMU command 'chardev-add': Failed
to bind socket to /run/openvswitch/vhu838c4d29-c9: Permission denied

In the case of a net device type VIR_DOMAIN_NET_TYPE_VHOSTUSER, the
underlying chardev is not labeled in qemuDomainAttachNetDevice prior
to calling qemuMonitorAttachCharDev.

A simple fix would be to call qemuSecuritySetChardevLabel using the
embedded virDomainChrSourceDef in the virDomainNetDef vhostuser data,
but this incurs the risk of incorrectly restoring the label. E.g.
consider the DAC driver behavior with a vhostuser net device, which
uses a socket for the chardev backend. The DAC driver uses XATTRS to
store original labelling information, but XATTRS are not compatible
with sockets. Without the original labelling information, the socket
labels will be restored with root ownership, preventing other
less-privileged processes from connecting to the socket.

This patch avoids overloading chardev labelling with vhostuser net
devices by introducing virSecurityManager{Set,Restore}NetdevLabel,
which is currently only implemented for the apparmor driver. The
new APIs are then used to set and restore labels for the vhostuser
net devices.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-26 16:06:45 -06:00
Pavel Hrdina
3796e8e1ff src: fix generation of default resource partition
Now that resource structure can have appid as well we need to adapt code
that creates default resource partition if not provided by user.
Otherwise starting a VM with appid defined would fail with following
error:

    error: unsupported configuration: Resource partition '(null)' must start with '/'

Fixes: 38b5f4faab
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-26 18:25:29 +02:00
Ján Tomko
cb6c650064 docs: formatdomain: fix typo
combiatnion -> combination

Fixes: 4ffc807214
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2021-08-26 16:32:46 +02:00
Jiri Denemark
2806b403e6 po: Refresh potfile for v7.7.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2021-08-26 12:10:50 +02:00
Tim Wiederhake
1452317b5c tests: Fix typos
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-26 11:40:49 +02:00
Michal Privoznik
cb50dc0ecb virscsi: Drop @tmp from virSCSIDeviceListDel
Clang on Rawhide started to complain that @tmp variable in
virSCSIDeviceListDel() is set but not used. This is obviously a
false positive because the variable is used to free device stolen
from the list. Anyway, we can do without the variable so in this
specific case let's fix our code to appease Clang.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-08-26 09:16:44 +02:00
Michal Privoznik
9f28af4920 test: Drop unused @cfg from qemu*test
In qemumigrationcookiexmltest and qemustatusxml2xmltest there is
@cfg variable that is unused. It's set via virQEMUDriverGetConfig()
but then never used. Drop it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-08-26 09:16:44 +02:00
Michal Privoznik
8340ce57b4 virpci: Clarify lifetime of temporary object
The virPCIDeviceIsBehindSwitchLackingACS() function checks
whether given PCI device is not behind a switch that lacks ACS.
It does so by starting at given device and traversing up, one
parent at time towards the root. The parent device is obtained
via virPCIDeviceGetParent() which allocates new virPCIDevice
structure. For freeing the structure we use g_autoptr() and a
temporary variable @tmp. However, Clang fails to understand our
clever algorithm and complains that the variable is set but never
used. This is obviously a false positive, but using a small trick
we can shut Clang up.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-08-26 09:16:44 +02:00
Peter Krempa
97e4fb3c10 qemu: snapshot: Translate 'volume' disks before attempting offline snapshot manipulation
When the VM is inactive the 'virStorageSource' struct doesn't have the
necessary data pointing to the actual storage. This is a problem for
inactive snapshot operations on VMs which use disk type='volume'.

Add the translation steps for reversion and deletion of snapshots.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1977155
Resolves: https://gitlab.com/libvirt/libvirt/-/issues/202
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-25 15:48:25 +02:00
Peter Krempa
9eef395fcc qemu: process: Ignore 'RESET' event during startup
In cases when we are adding a <transient/> disk with sharing backend
(and thus hotplugging it) we need to re-initialize ACPI tables so that
the VM boots from the correct device.

This has a side-effect of emitting the RESET event and forwarding it to
the clients which is not correct.

Fix this by ignoring RESET events during startup of the VM.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-25 15:32:45 +02:00
Peter Krempa
526cff4f03 qemuDomainSetLifecycleAction: Properly update 'onReboot' action in qemu
When qemu supports 'set-action' command we can update what happens on
reboot. Additionally we can fully relax the checks as we now properly
update the lifecycle actions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-25 15:32:45 +02:00
Peter Krempa
3061f8f9cb qemu: process: Don't set 'allowReboot' when qemu supports 'set-action'
We don't use the value of the flag when the new handling is in place so
we don't have to initialize it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-25 15:32:45 +02:00
Peter Krempa
b67e450a5a qemu: command: Always use '-no-shutdown'
The '-no-shutdown' flag prevents qemu from terminating if a shutdown was
requested. Libvirt will handle the termination of the qemu process
anyways and using this consistently will allow greater flexibility for
the virDomainSetLifecycleAction API as well as will allow using
the 'system-reset' QMP command during startup to reinitiate devices
exported to the firmware.

This efectively partially reverts 0e034efaf9

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-25 15:32:45 +02:00
Peter Krempa
d0fad4ab2e qemuProcessLaunch: Setup handling of 'on_reboot' via QMP when starting the process
Rather than using '-no-reboot' use the QMP command to update the
lifecycle action of 'on_reboot'.

This will be identical to how we set the behaviour during lifetime and
also avoids problems with use of the 'system-reset' QMP command during
bringup of the VM (used to update the firmware table of disks when disks
were hotplugged as part of startup).

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-25 15:32:45 +02:00
Peter Krempa
24dab19f8a qemuProcessHandleReset: Don't emulate lifecycle actions for RESET event
The RESET event is delivered by qemu only when the guest OS is actually
allowed to reboot ('-no-reboot' or equivalent is not used) and due to
the nature of async handling of the events VM is actually already
executing guest code after the reboot, until our code gets to killing
it.

In general it should have been impossible to reach a state where the
reboot action is 'destroy' but we didn't use '-no-reboot' but due to
various bugs it was.

Due to the fact that this was not a desired operation and additionally
guest code already is executing I think the best option is not to kill
the VM any more (possible data loss?) and rely for the proper fix where
we use the new 'set-action' QMP command to enable an equivalent
behaviour to '-no-reboot' during runtime.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-25 15:32:44 +02:00
Peter Krempa
5fb54459e3 qemuDomainSetLifecycleAction: Forbid live update of 'on_reboot'
Without the ability to tell qemu to change the behaviour on reboot of
the guest it's fundamentally unsafe to change the action as the guest
would be able to execute instructions after the reboot before libvirt
terminates it due to the async nature of QMP events.

Stricten the code for now until we implement support for 'set-action'
QMP command.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-25 15:32:44 +02:00
Peter Krempa
fa11852433 qemu: domain: Remove qemuDomainIsUsingNoShutdown
Directly use 'priv->allowReboot' as we now document what the behaiour is
to avoid another lookup.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-25 15:32:44 +02:00
Peter Krempa
6997cf6f5d qemu: migration: Don't transfer 'allowReboot' flag
The original idea was to ensure that the destination has the same
original state of the '-no-reboot' flag to ensure identical behaviour of
the 'vidDomainModifyLifecycleAction' API.

With newer qemu's we'll be able to modify the behaviour using the
monitor so old daemons won't be able to keep up anyways.

Remove this feature as it's not very useful and will be replaced by a
proper solution.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-25 15:32:44 +02:00
Peter Krempa
6ab6d3f074 qemuDomainObjPrivate: Annotate 'allowReboot' field
Save further readers the headache of determining what it actually does
and note that it's not used with qemu version supporting the
'set-action' command.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-25 15:32:44 +02:00
Peter Krempa
851ae580cf qemuxml2argvtest: Add 'LATEST' version of 'misc-no-reboot' test case
Upcoming patches will modify how '-no-reboot' is handled when qemu
supports the 'set-action' QMP command. Add a test for it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-25 15:32:44 +02:00
Peter Krempa
6625961d15 qemuDomainAttachWatchdog: Use 'set-action' instead of 'watchdog-set-action' if supported
If current qemu supports 'set-action' use it instead of the single-use
command.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-25 15:32:44 +02:00
Peter Krempa
32c5d30f4d qemu: monitor: Implement monitor code for 'set-action' command
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-25 15:32:44 +02:00
Peter Krempa
feb0a0c7f5 qemu: capablities: Detect presence of 'set-action' as QEMU_CAPS_SET_ACTION
The 'set-action' QMP command allows modifying the behaviour when the
guest resets.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-25 15:32:44 +02:00
Peter Krempa
4ffc807214 qemu: Honor 'restart' action for 'on_poweroff'
We simply terminate qemu instead of issuing a reset as the semantics of
the setting dictate.

Fix it by handling it identically to 'fake reboot'.

We need to forbid the combination of 'onReboot' -> 'destroy' and
'onPoweroff' -> reboot though as the handling would be hairy and it
honetly makes no sense.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-25 15:32:44 +02:00
Peter Krempa
b1b85a475f qemu: Reject 'preserve' action for 'on_reboot'/'on_poweroff'/'on_crash'
The qemu driver didn't ever implement any meaningful handling for the
'preserve' action.

Forbid the flag in the qemu def validator and update the documentation
to be factual.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-25 15:32:44 +02:00
Peter Krempa
507e608835 qemu: driver: Validate lifecycle actions in 'qemuDomainSetLifecycleAction'
Some actions are not supported by qemu. Use the recently added
'qemuValidateLifecycleAction' helper to ensure that the API does the
same validation as we do on startup in the validation callbacks.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-25 15:32:44 +02:00
Peter Krempa
2b81fbb22e qemu: Reject 'rename-restart' action for 'on_reboot'/'on_poweroff'/'on_crash'
The qemu driver didn't ever implement any meaningful handling for the
'rename-restart' action.

At this point the following handling would take place:

'on_reboot' set to 'rename-restart' is ignored on guest-initiated
reboots, the guest simply reboots.

For on_poweroff set to 'rename-restart' the following happens:

guest initiated shutdown -> 'destroy'
libvirt initiated shutdown -> 'reboot'

In addition when 'on_reboot' is 'destroy' in addition to 'on_poweroff'
being 'rename-restart' the guest is able to execute instructions after
issuing a reset before libvirt terminates it. This will be addressed
separately later.

Forbid the flag in the qemu def validator and update the documentation
to be factual.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-25 15:32:44 +02:00
Peter Krempa
d28103b4c4 qemu: validate: Reformat header and purge unused includes
Use the new style header formatting.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-25 15:32:44 +02:00
Peter Krempa
effeee5c2f qemu: driver: Use 'qemuDomainSaveStatus' for saving status XML
We've got multiple random open-coded versions. Switch to the helper
function which doesn't report errors as they'd be mostly wrong as the
operation was indeed successful.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-25 15:32:43 +02:00
Peter Krempa
a640237b53 qemuDomainSetLifecycleAction: Add a note about argument range-check
The public API wrapper range-checks the arguments. Save the next reader
the hassle of looking it up.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-25 15:32:43 +02:00
Peter Krempa
ae6045ca84 qemuMonitorJSONSetWatchdogAction: Use automatic memory clearing
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-25 15:32:43 +02:00
Peter Krempa
cc6241677b qemuxml2argvtest: Add LATEST version of 'cpu-host-model'
This one will be slightly unstable given that CPU features are being
modified frequently in qemu especially when used with a modern cpu.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-25 10:33:38 +02:00
Peter Krempa
cc82b6a095 qemucapabilitiesdata: Update qemu caps dump for 6.1.0 release
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-25 10:33:38 +02:00
Peter Krempa
edf0b8211d qemuxml2argvtest: Add 'cpu-host-model' cases for all x86-64 real qemu caps versions
The host model expansion depends on the capability data, so in this case
it makes sense to have specific invocations of the test for all qemu
versions we have.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-25 10:33:38 +02:00
Peter Krempa
db8ed4fed4 qemuxml2argvtest: Slightly modernize "cpu-host-model" case
Switch to q35 in anticipation of using DO_TEST_CAPS* in further patches.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-25 10:33:38 +02:00
Peter Krempa
d1e48bd3db qemuxml2argvtest: Unify 'cpu-tsc-frequency' and 'cpu-tsc-high-frequency' case
Use the larger number in the original test to avoid having two files.

Additionally this avoids use of 'host-model' with DO_TEST_CAPS_LATEST in
cases when it isn't necessary for the purpose of the test as the CPU
model tends to change.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-25 10:33:38 +02:00
Peter Krempa
1e5c4d9999 qemuxml2argvdata: Don't use 'host-model' cpu in 'hugepages-memaccess3'
The test case doesn't really test anything about the specific CPU. Using
a host-model cpu with DO_TEST_CAPS_LATEST results in commandline changes
every time qemu updates the cpu definiton.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-25 10:33:38 +02:00
Kristina Hanicova
5ca09c6b27 virsh: add support for '--validate' option in define storage pool
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-25 09:57:58 +02:00
Kristina Hanicova
77b4fe8143 storage_driver & test_driver: allow VIR_STORAGE_POOL_DEFINE_VALIDATE flag
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-25 09:57:55 +02:00
Kristina Hanicova
59abe66f57 storage_conf: add validation against schema in pool define
We need to validate the XML against schema if option '--validate'
was passed to the virsh command. This patch also includes
propagation of flags into the virStoragePoolDefParse() function.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-25 09:57:51 +02:00
Kristina Hanicova
7097367b25 api: add virStoragePoolDefineFlags
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-25 09:57:47 +02:00
Kristina Hanicova
e70e8e2dd8 lxcxml2xmltest: Substitute 'inactive' variable with 'active'
I removed negation from the name of a variable to make the code
more readable.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-25 09:52:06 +02:00
Ján Tomko
fb234839a7 API: discourage usage of non-ListAll APIs
They require the caller to provide the maximum number
of array elements upfront, leading to either incomplete
results or violations of the zero-one-infinity rule.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-08-24 16:26:55 +02:00
Ján Tomko
c7f3a1f787 qemu: simplify machine-type check for implicit floppy controller
Q35 machine types 2.3 and older had an integrated floppy controller.

Support for these machine types was removed by QEMU commit

  commit 86165b499edf8b03bb2d0e926d116c2f12a95bfe
      q35: Remove old machine versions
  git describe: v2.5.0-1530-g86165b499e contains: v2.6.0-rc0~76^2~4

In libvirt, we have bumped the minimum QEMU version to 2.11:

  commit b4cbdbe90b
    qemu: Formally deprecate support for qemu < 2.11
  git describe: v7.3.0-13-gb4cbdbe90b contains: v7.4.0-rc1~300

Since this QEMU version only supports Q35 machine versions 2.4+,
remove the code dealing with older ones.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-08-24 16:26:55 +02:00
Simon Rowe
e72fe141f8 qemu: check unlink hint from virQEMUFileOpenAs()
Signed-off-by: Simon Rowe <simon.rowe@nutanix.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-24 16:02:41 +02:00
Simon Rowe
5646b7c5e1 iohelper: skip lseek() and ftruncate() on block devices
Signed-off-by: Simon Rowe <simon.rowe@nutanix.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-24 16:02:38 +02:00