Commit Graph

42486 Commits

Author SHA1 Message Date
Stefan Berger
1c78675c6c virt-aa-helper: Allow swtpm to fsync on dir
Allow swtpm (0.7.0 or later) to fsync on the directory where it writes
its state files into so that "the entry in the directory containing the
file has also reached disk" (fsync(2)).

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-07-14 13:29:59 +02:00
Tim Wiederhake
772a9875f7 qemuMonitorGetChardevInfo: virHashNew cannot return NULL
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-07-13 14:40:28 +02:00
Tim Wiederhake
c30410a0c4 qemuMonitorGetChardevInfo: Use automatic memory management
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-07-13 14:40:28 +02:00
Tim Wiederhake
9a4402dd91 qemuMonitorGetChardevInfo: Remove superfluous variable "ret"
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-07-13 14:40:28 +02:00
Tim Wiederhake
317938165c qemuMonitorGetBlockInfo: virHashNew cannot return NULL
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-07-13 14:40:28 +02:00
Tim Wiederhake
e2f27936f1 qemuMonitorGetBlockInfo: Use automatic memory management
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-07-13 14:40:28 +02:00
Tim Wiederhake
b1dd164b1a qemuMonitorGetBlockInfo: Remove superfluous variable "ret"
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-07-13 14:40:28 +02:00
Tim Wiederhake
1067bf55fe qemuMonitorGetAllBlockStatsInfo: virHashNew cannot return NULL
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-07-13 14:40:28 +02:00
Tim Wiederhake
389049a4db qemuMonitorGetAllBlockStatsInfo: Use automatic memory management
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-07-13 14:40:28 +02:00
Tim Wiederhake
00a7e385f1 qemuMonitorGetAllBlockStatsInfo: Assign hash table only on success
`virHashNew` cannot return NULL, the check is not needed.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-07-13 14:40:28 +02:00
Tim Wiederhake
31678663b3 qemuMonitorGetAllBlockStatsInfo: Remove superfluous variable initialization
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-07-13 14:40:28 +02:00
Tim Wiederhake
952bf22ea1 qemuMonitorGetAllBlockStatsInfo: Clean up line break
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-07-13 14:40:28 +02:00
Han Han
78b1a53df1 virsh: Fix the order of format arguments in doDump
According to definition of virDomainCoreDumpFormat, the "elf" should be
the first argument in VIR_ENUM_*.

Fixes: 84cc4543be

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

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-07-13 11:21:23 +02:00
Jim Fehlig
0d1ccad240 libxl: Add helper function for running the hook script
The same pattern of retrieving the domXML, running the hook script, and
checking for error is used throughout the libxl driver. Remove some
repetitive code by adding a helper function to perform these tasks.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-07-12 14:02:18 -06:00
Jim Fehlig
fc94e5c1c2 libxl: Introduce libxlDomainStartPerform
Introduce libxlDomainStartPerform as part of decomposing libxlDomainStart.
Perform all operations that are part of starting a domain. On error the
domain is destroyed from libxl's perspective, but the operations perfomed
in libxlDomainStartPrepare must be unwound by libxlDomainStart.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-07-12 14:02:18 -06:00
Jim Fehlig
b84d6ed2fe libxl: Introduce libxlDomainStartPrepare
Introduce libxlDomainStartPrepare as part of decomposing libxlDomainStart.
Perform all prepratory operations such as hostdevs, network devs, etc.
Also ensure all such operations are properly unwound on error.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-07-12 14:02:18 -06:00
Jim Fehlig
caed469ef5 libxl: Add a helper function to unprepare network devices
Move network device cleanup code from libxlDomainCleanup to a helper
function for use in a subsequent patch.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-07-12 14:02:18 -06:00
Jim Fehlig
572d161f10 libxl: Move managed save logic to libxlDomainStartNew
the logic to check for existence of a managed save image and use it to
start the VM can be moved to libxlDomainStartNew. libxlDomainStart has
become unwieldy and this is a small step to make it more manageable.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-07-12 14:02:18 -06:00
Jim Fehlig
8dab64bda4 libxl: Drop unused 'cfg' parameter from libxlDomainSaveImageOpen
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-07-12 14:02:18 -06:00
Peter Krempa
b249fa7871 NEWS: Mention implications of the bug in migration code
Wrong flag use could have user-visible implications. Mention the fix.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-07-12 16:35:22 +02:00
Peter Krempa
f58349c9c6 qemu: migration: Use correct flag constant for enabling storage migration
The 'storageMigration' flag is supposed to be true if storage migration
is requested, which is based on VIR_MIGRATE_NON_SHARED_DISK or
VIR_MIGRATE_NON_SHARED_INC flags. The assignment to the variable used
QEMU_MONITOR_MIGRATE_NON_SHARED_INC (0x04) instead of
VIR_MIGRATE_NON_SHARED_INC (0x80), caused libvirtd to skip the actual
copy of data.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1978526
Fixes: da69f4b208
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-07-12 16:34:44 +02:00
Peter Krempa
0ba4066819 virDomainSetBlockThreshold: Document that two events are fired when index isn't used
Libvirt started emitting two threshold events, once with index and once
withouth when the index isn't registered. Document this caveat.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-07-12 16:34:26 +02:00
Peter Krempa
a3edda6b9e qemu: Prevent two threshold events when it was registered with index
Remember whether the user passed an explicit index when registering the
event so that we can avoid the top level event when it isn't needed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-07-12 16:34:17 +02:00
Peter Krempa
2ddff1cc40 storage_source: Add flag storing whether threshold event was registered with index
When users register the threshold event for the top level image with an
explicit index (e.g. vda[3]) they are clearly expecting the index in the
event.

This flag will help avoiding emission of the second event without the
index when the client clearly requested one with the index.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-07-12 16:34:07 +02:00
zhangjl02
2f922b2c46 qemu: interface: check and use ovs command to set qos of ovs managed port
When qos is set or delete, we have to check if the port is an ovs managed
port. If true, call the virNetDevOpenvswitchInterfaceSetQos function when qos
is set, and call the virNetDevOpenvswitchInterfaceClearQos function when
the interface is to be destroyed.

Signed-off-by: Jinsheng Zhang <zhangjl02@inspur.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-07-12 09:40:13 +02:00
zhangjl02
e2c225f57c qemu: interface: remove setting noqueue for ovs port
Return 0 directly if the port is ovs managed. When the ovs port is set
noqueue, qos config on this port will not work.

Signed-off-by: Jinsheng Zhang <zhangjl02@inspur.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-07-12 09:40:13 +02:00
zhangjl02
7c07b48942 virDomain: interface: add virNetDevOpenvswitchInterfaceSetQos and virNetDevOpenvswitchInterfaceClearQos
Introduce qos setting and cleaning method. Use ovs command to set qos
parameters on specific interface of qemu virtual machine.

When an ovs port is created, we add 'ifname' to external-ids. When setting
qos on an ovs port, query its qos and queue. If found, change qos on queried
queue and qos, otherwise create new queue and qos. When cleaning qos, query
and clean queues and qos in ovs table record by 'ifname' and 'vmid'.

Signed-off-by: Jinsheng Zhang <zhangjl02@inspur.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-07-12 09:40:13 +02:00
zhangjl02
b9cbf5587e virDomain: interface: add virDomainNetDefIsOvsport
Tell whether a port definition is an ovs managed virtual port

Signed-off-by: Jinsheng Zhang <zhangjl02@inspur.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-07-12 09:40:13 +02:00
Daniel P. Berrangé
11fcf054e6 qemu: remove default audio backend for migratable XML
When seeing a guest with a sound device, and no audio backend, we
automatically add an audio backend XML element based on the historical
QEMU driver behaviour. Unfortunately when we live migrate back to an
old libvirt, it may not understand the audio driver type we configured.
We thus need to strip the default audio backend when migrating.

Fixes https://gitlab.com/libvirt/libvirt/-/issues/179
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-07-09 13:15:13 +01:00
Roman Bolshakov
91f696a6a4 lib: Specify domain redefinition requirements
There might be misunderstanding [1] when libvirt permits domain
redefinition and if it's a valid case at all.

1. b973d7c4b4/plugins/modules/virt.py (L533)

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-07-09 12:11:29 +02:00
Michal Privoznik
c159db4cc0 vircgroup: Improve virCgroupControllerAvailable wrt to CGroupsV2
It all started as a simple bug: trying to move domain memory
between NUMA nodes (e.g. via virsh numatune) did not work. I've
traced the problem to qemuProcessHook() because that's where we
decide whether to rely on CGroups or use numactl APIs to satisfy
<numatune/>. The problem was that virCgroupControllerAvailable()
was telling us that cpuset controller is unavailable. This is
CGroupsV2, and pretty weird because CGroupsV2 definitely do
support cpuset controller and I had them mounted in a standard
way. What I found out (with Pavel's help) was that
virCgroupNewSelf() was looking into the following path to detect
supported controllers:

  /sys/fs/cgroup/system.slice/cgroup.controllers

However, if there's no other VM running then the system.slice
only has 'memory' and 'pids' controllers. Therefore, we saw
'cpuset' as not available. The fix is to look at the top most
path, which has the full set of controllers:

  /sys/fs/cgroup/cgroup.controllers

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1976690
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-07-09 09:05:08 +02:00
Michal Privoznik
12f96b0611 schemas: Allow cache attribute for bandwidth element for HMAT
Turns out, when introducing HMAT support in v6.6.0-rc1~249
I've forgot to allow "cache" attribute for <bandwidth/> element
in RNG. It's parsed and formatted, but schema does not allow it.

Fixes: a89bbbac86
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1980162
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-07-08 16:28:30 +02:00
Jim Fehlig
de1e0ae0e3 virtlockd: Don't report error if lockspace exists
When the qemu or libxl driver is configured to use lockd and
file_lockspace_dir is set, virtlockd emits an error when libvirtd
is retarted

May 25 15:44:31 virt81 virtlockd[7723]: Requested operation is not
valid: Lockspace for path /data/libvirtd/lockspace already exists

There is really no need to fail when the lockspace already exists,
paricularly since the user is expected to create the lockspace
specified in file_lockspace_dir. Failure to do so will prevent
starting any domains

virsh start test
error: Failed to start domain 'test'
error: Unable to open/create resource /data/libvirtd/lockspace/de22c4bf931e7c48b49e8ca64b477d44e78a51543e534df488b05ccd08ec5caa: No such file or directory

Also, virLockManagerLockDaemonSetupLockspace already has logic to ignore
the error. Since callers are not interested in the error, change
virtlockd to not report or return an error when the specified lockspace
already exists.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2021-07-07 09:40:38 -06:00
Michal Privoznik
c6d7b9a261 qemu: Don't use memory-backend-memfd for NVDIMMs
If guest is configured to use memfd then the function that build
memory-backend-* part of command line will put
memory-backend-memfd, always. Even for NVDIMMs. This is not
correct, because NVDIMMs need a backing path (usually to a real
host NVDIMM device). Therefore, regardless of memfd being
requested, we have to stick with memory-backend-file.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2021-07-07 16:25:03 +02:00
Michal Privoznik
cda47bac25 virDomainMachineNameAppendValid: Handle special characters better
When constructing guest name for machined we have to be very
cautious as machined expects a name that's basically a valid URI.
Therefore, if there's a dot it has to be followed by a letter or
a number. And if there's a sequence of two or more dashes they
should be joined into a single dash. These rules are implemented
in virDomainMachineNameAppendValid(). There's the @skip variable
which is supposed to track whether it is safe to append a dot or
a dash into name. However, the variable is set to false (meaning
it is safe to append a dot or a dash) even if the current
character we are processing is not in the set of allowed
characters (and thus skipped over).

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1948433
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2021-07-07 16:23:37 +02:00
Vinayak Kale
a9c7da6126 virresctrl: Fix updating the mask for a cache resource
In 'virResctrlAllocUpdateMask', mask is updated only if 'previous mask' is NULL.

By default, the bitmask for a cache resource for a VM is initialized with
'default-resctrl-group' bitmask. So the 'previous mask' would not be NULL and
mask won't get updated if cachetune is configured for a VM. This causes libvirt
to use same bitmask as 'default-resctrl-group' bitmask for a cache resource for
a VM. This patch fixes the issue.

Fixes: d8a354954a

Signed-off-by: Vinayak Kale <vkale@nvidia.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2021-07-07 16:19:40 +02:00
Tim Wiederhake
6bda1eb157 virDomainSEVDefParseXML: Remove superfluous variable initialization
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2021-07-07 15:34:12 +02:00
Tim Wiederhake
3994a36ec7 virDomainSEVDefParseXML: Remove superfluous gotos
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2021-07-07 15:34:12 +02:00
Tim Wiederhake
6cc25a6bc6 virDomainSEVDefParseXML: Use automatic memory management
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2021-07-07 15:34:12 +02:00
Tim Wiederhake
42c0c7275d virDomainSEVDefParseXML: Use virXMLPropEnum
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2021-07-07 15:34:11 +02:00
Tim Wiederhake
d09a191f62 conf: virDomainSEVDef: Change type of "sectype" to virDomainLaunchSecurity
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2021-07-07 15:34:11 +02:00
Tim Wiederhake
b765bc05a0 conf: Add AUTOPTR_CLEANUP_FUNC for virDomainSEVDef
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2021-07-07 15:34:11 +02:00
Pavel Hrdina
988beaf1d0 meson: check for XDR and driver_remote early
We have several other options that depend on result of `driver_remote`
option check so we need to do it early to have the result available.

Fixes: https://gitlab.com/libvirt/libvirt/-/issues/185
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-07-07 15:25:11 +02:00
Didik Supriadi
094671b1e7 Translated using Weblate (Indonesian)
Currently translated at 3.1% (326 of 10342 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/id/

Co-authored-by: Didik Supriadi <didiksupriadi41@gmail.com>
Signed-off-by: Didik Supriadi <didiksupriadi41@gmail.com>
2021-07-06 18:04:27 +02:00
simmon
450761d7e3 Translated using Weblate (Korean)
Currently translated at 45.0% (4655 of 10342 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/ko/

Co-authored-by: simmon <simmon@nplob.com>
Signed-off-by: simmon <simmon@nplob.com>
2021-07-06 18:04:26 +02:00
Ricky Tigg
9bc8ac2beb Translated using Weblate (Finnish)
Currently translated at 22.2% (2302 of 10342 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/fi/

Co-authored-by: Ricky Tigg <ricky.tigg@gmail.com>
Signed-off-by: Ricky Tigg <ricky.tigg@gmail.com>
2021-07-06 18:04:25 +02:00
Daniel P. Berrangé
45f94690d2 docs: add go-import meta tags for new go modules
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-07-02 15:05:15 +01:00
Daniel P. Berrangé
b8e1521afb docs: point go imports to gitlab.com repos
The gitlab.com repos are the primary source, with libvirt.org just a
read-only mirror.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-07-02 15:05:15 +01:00
Michal Privoznik
e3c05984f2 virSetUIDGIDWithCaps: Assume PR_CAPBSET_DROP is always defined
Bounding set capabilities were introduced in kernel commit of
v2.6.25-rc1~912. I guess it is safe to assume that all Linux
hosts we ran on have at least that version or newer.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-07-01 16:41:50 +02:00
Jonathon Jongsma
dfa1e9b3eb nodedev: improve error message when destroying an inactive device
When trying to destroy a node device that is not active, we end up with
a confusing error message:

  # nodedev-destroy mdev_88a6b868_46bd_4015_8e5b_26107f82da38
  error: Failed to destroy node device 'mdev_88a6b868_46bd_4015_8e5b_26107f82da38'
  error: failed to access '/sys/bus/mdev/devices/88a6b868-46bd-4015-8e5b-26107f82da38/iommu_group': No such file or directory

With this patch, the error is more clear:

  # nodedev-destroy mdev_88a6b868_46bd_4015_8e5b_26107f82da38
  error: Failed to destroy node device 'mdev_88a6b868_46bd_4015_8e5b_26107f82da38'
  error: Requested operation is not valid: Device 'mdev_88a6b868_46bd_4015_8e5b_26107f82da38' is not active

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
2021-07-01 16:34:03 +02:00