]> git.ipfire.org Git - thirdparty/libvirt.git/log
thirdparty/libvirt.git
4 years agonodedev: fix parent device of inactive mdevs
Jonathon Jongsma [Wed, 7 Jul 2021 21:29:28 +0000 (16:29 -0500)] 
nodedev: fix parent device of inactive mdevs

Inactive mdevs were simply formatting their parent name as the value
received from mdevctl rather than looking up the libvirt nodedev name of
the parent device. This resulted in a parent value of e.g.
'0000:5b:00.0' instead of 'pci_0000_5b_00_0'. This prevented defining a
new mdev device from the output of nodedev-dumpxml.

Unfortunately, it's not simple to fix this comprehensively due to the
fact that mdevctl supports defining (inactive) mdevs for parent devices
that do not actually exist on the host (yet). So for those persistent
mdev definitions that do not have a valid parent in the device list, the
parent device will be set to the root "computer" device.

Unfortunately, because the value of the 'parent' field now depends on
the configuration of the host, the mdevctl parsing test will output
'computer' for all test devices. Fixing this would require a more
extensive mock test environment.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1979761
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirNWFilterDHCPSnoopInit: `virHashNew` cannot return NULL
Tim Wiederhake [Tue, 6 Jul 2021 08:23:19 +0000 (10:23 +0200)] 
virNWFilterDHCPSnoopInit: `virHashNew` cannot return NULL

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirNWFilterBuildAll: `virHashNew` cannot return NULL
Tim Wiederhake [Tue, 6 Jul 2021 08:16:42 +0000 (10:16 +0200)] 
virNWFilterBuildAll: `virHashNew` cannot return NULL

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirNWFilterBindingObjListNew: `virHashNew` cannot return NULL
Tim Wiederhake [Tue, 6 Jul 2021 08:15:45 +0000 (10:15 +0200)] 
virNWFilterBindingObjListNew: `virHashNew` cannot return NULL

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirNWFilterBindingDefForNet: Remove superfluous `goto`s
Tim Wiederhake [Tue, 6 Jul 2021 08:14:59 +0000 (10:14 +0200)] 
virNWFilterBindingDefForNet: Remove superfluous `goto`s

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirNWFilterBindingDefForNet: Use automatic memory management
Tim Wiederhake [Tue, 6 Jul 2021 08:14:10 +0000 (10:14 +0200)] 
virNWFilterBindingDefForNet: Use automatic memory management

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirNWFilterBindingDefForNet: `virHashNew` cannot return NULL
Tim Wiederhake [Tue, 6 Jul 2021 08:12:39 +0000 (10:12 +0200)] 
virNWFilterBindingDefForNet: `virHashNew` cannot return NULL

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirNWFilterBindingDefCopy: Remove superfluous `goto`s
Tim Wiederhake [Tue, 6 Jul 2021 11:45:47 +0000 (13:45 +0200)] 
virNWFilterBindingDefCopy: Remove superfluous `goto`s

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirNWFilterBindingDefCopy: Use automatic memory management
Tim Wiederhake [Tue, 6 Jul 2021 08:11:19 +0000 (10:11 +0200)] 
virNWFilterBindingDefCopy: Use automatic memory management

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirNWFilterBindingDefCopy: `virHashNew` cannot return NULL
Tim Wiederhake [Tue, 6 Jul 2021 08:07:39 +0000 (10:07 +0200)] 
virNWFilterBindingDefCopy: `virHashNew` cannot return NULL

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoconf: Add AUTOPTR_CLEANUP_FUNC for virNWFilterBindingDef
Tim Wiederhake [Tue, 6 Jul 2021 08:10:23 +0000 (10:10 +0200)] 
conf: Add AUTOPTR_CLEANUP_FUNC for virNWFilterBindingDef

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agonetwork: Allow adding DNS entries sharing hostname for multiple addreses
Peter Krempa [Wed, 14 Jul 2021 10:58:12 +0000 (12:58 +0200)] 
network: Allow adding DNS entries sharing hostname for multiple addreses

Having multiple addresses having same hostname is a common config either
to have IPv4 and IPv6 address for the same hostname or even for DNS
round robin. The validation in the network update code didn't allow
adding such entries despite the fact that it is possible to define a
network with them.

Don't check hostname duplicity when adding a DNS entry.

The update of the test case adds another entry for the 'pudding'
hostname which is added in one of the networkxml2xmlupdate test cases.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agonetworkxml2xmltest: Add example of multiple addresses having the same hostname
Peter Krempa [Wed, 14 Jul 2021 07:20:18 +0000 (09:20 +0200)] 
networkxml2xmltest: Add example of multiple addresses having the same hostname

Having multiple addresses for the same hostname is a legitimate
configuration in DNS. Add test data to cover this case.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu: capabilities: fill in domcaps <memoryBacking>
Kristina Hanicova [Thu, 15 Jul 2021 12:18:05 +0000 (14:18 +0200)] 
qemu: capabilities: fill in domcaps <memoryBacking>

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoconf: domcaps: Report <memoryBacking>
Kristina Hanicova [Thu, 15 Jul 2021 12:18:04 +0000 (14:18 +0200)] 
conf: domcaps: Report <memoryBacking>

We need to report via domcapabilities if specifying shared memory
is supported without hugepages or numa config in order to find
out if domain has suitable setup to make virtiofs work.
The solution is to report source types of memory backing to
determine if memfd is a valid option.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agowhitespace clean-ups
Martin Kletzander [Wed, 14 Jul 2021 13:56:26 +0000 (15:56 +0200)] 
whitespace clean-ups

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
4 years agoutil: Make one debug message nicer
Martin Kletzander [Thu, 15 Jul 2021 10:06:55 +0000 (12:06 +0200)] 
util: Make one debug message nicer

This was bothering someone as the debug message looked like there was an issue
despite it being just a debug message.  Change it to what is actually happening
and why the name is being skipped.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
4 years agoci: refresh cirrus variables for FreeBSD python rename
Daniel P. Berrangé [Wed, 14 Jul 2021 12:34:29 +0000 (13:34 +0100)] 
ci: refresh cirrus variables for FreeBSD python rename

All the python packages got renamed from py37- to py38-

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: Do not erase duplicate devices from namespace if error occurs
Kristina Hanicova [Wed, 14 Jul 2021 14:46:54 +0000 (16:46 +0200)] 
qemu: Do not erase duplicate devices from namespace if error occurs

If the attempt to attach a device failed, we erased the
unattached device from the namespace. This resulted in erasing an
already attached device in case of a duplicate. We need to check
for existing file in the namespace in order to determine erasing
it in case of a failure.

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

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirprocess: Return retval of the child on success, not 0
Kristina Hanicova [Wed, 14 Jul 2021 14:46:53 +0000 (16:46 +0200)] 
virprocess: Return retval of the child on success, not 0

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu: Check for existing file in namespace
Kristina Hanicova [Wed, 14 Jul 2021 14:46:52 +0000 (16:46 +0200)] 
qemu: Check for existing file in namespace

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoApparmor: Add profile for virtxend
Jim Fehlig [Tue, 15 Jun 2021 17:24:14 +0000 (11:24 -0600)] 
Apparmor: Add profile for virtxend

A new apparmor profile initially derived from the libvirtd profile.
All rules were prefixed with the 'audit' qualifier to verify they
are actually used by virtxend. It turns out that several, beyond
the obvious ones, can be dropped in the resulting virtxend profile.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
4 years agoApparmor: Add profile for virtqemud
Jim Fehlig [Tue, 15 Jun 2021 17:13:33 +0000 (11:13 -0600)] 
Apparmor: Add profile for virtqemud

A new apparmor profile derived from the libvirtd profile, with non-QEMU
related rules removed. Adopt the libvirt-qemu abstraction to work with
the new profile.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
4 years agoapparmor: Allow /usr/libexec for private xen-tools binaries
Olaf Hering [Tue, 13 Jul 2021 13:43:58 +0000 (15:43 +0200)] 
apparmor: Allow /usr/libexec for private xen-tools binaries

This is a followup for commit e906c4d02bdcddf141b4d124afd68c8ee10134fe
("apparmor: Allow /usr/libexec for libxl-save-helper and pygrub"):

In recent rpm versions --libexecdir changed from /usr/lib64 to
/usr/libexec. A plain rpmbuild %configure in xen.git will install all
files, including the private copies of qemu, into /usr/libexec/xen/bin.
Expand the existing pattern to cover also this libexecdir variant.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirfile: Update example use of virDirRead()
Michal Privoznik [Wed, 14 Jul 2021 14:54:54 +0000 (16:54 +0200)] 
virfile: Update example use of virDirRead()

We have an example in virDirRead() documentation on how to use
the function. In there, the directory structure is plain DIR, but
that won't work anymore. Switch over to g_autoptr(DIR) which is
what we use now.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agosyntax-check: s/VIR_DIR_CLOSE/g_autoptr(DIR)/
Michal Privoznik [Wed, 14 Jul 2021 14:53:04 +0000 (16:53 +0200)] 
syntax-check: s/VIR_DIR_CLOSE/g_autoptr(DIR)/

We have a syntax-check rule that forbids explicit closedir().
However, the error message suggest using VIR_DIR_CLOSE() which
was removed a few releases ago (v6.10.0-rc1~389).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agotestQemuMonitorJSONqemuMonitorJSONGetChardevInfo: `virHashNew` cannot return NULL
Tim Wiederhake [Mon, 5 Jul 2021 14:49:52 +0000 (16:49 +0200)] 
testQemuMonitorJSONqemuMonitorJSONGetChardevInfo: `virHashNew` cannot return NULL

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agotestQemuMonitorJSONqemuMonitorJSONGetChardevInfo: Remove superfluous `goto`s
Tim Wiederhake [Mon, 5 Jul 2021 14:49:05 +0000 (16:49 +0200)] 
testQemuMonitorJSONqemuMonitorJSONGetChardevInfo: Remove superfluous `goto`s

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agotestQemuMonitorJSONqemuMonitorJSONGetChardevInfo: Use automatic memory management
Tim Wiederhake [Mon, 5 Jul 2021 14:48:02 +0000 (16:48 +0200)] 
testQemuMonitorJSONqemuMonitorJSONGetChardevInfo: Use automatic memory management

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agotestQemuMonitorJSONqemuMonitorJSONGetBlockInfo: `virHashNew` cannot return NULL
Tim Wiederhake [Mon, 5 Jul 2021 14:36:01 +0000 (16:36 +0200)] 
testQemuMonitorJSONqemuMonitorJSONGetBlockInfo: `virHashNew` cannot return NULL

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agotestQemuMonitorJSONqemuMonitorJSONGetBlockInfo: Remove superfluous `goto`s
Tim Wiederhake [Mon, 5 Jul 2021 14:35:09 +0000 (16:35 +0200)] 
testQemuMonitorJSONqemuMonitorJSONGetBlockInfo: Remove superfluous `goto`s

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agotestQemuMonitorJSONqemuMonitorJSONGetBlockInfo: Use automatic memory management
Tim Wiederhake [Mon, 5 Jul 2021 14:33:56 +0000 (16:33 +0200)] 
testQemuMonitorJSONqemuMonitorJSONGetBlockInfo: Use automatic memory management

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agotestQemuMonitorJSONqemuMonitorJSONGetAllBlockStatsInfo: `virHashNew` cannot return...
Tim Wiederhake [Mon, 5 Jul 2021 14:32:07 +0000 (16:32 +0200)] 
testQemuMonitorJSONqemuMonitorJSONGetAllBlockStatsInfo: `virHashNew` cannot return NULL

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agotestQemuMonitorJSONqemuMonitorJSONGetAllBlockStatsInfo: Remove superfluous `goto`s
Tim Wiederhake [Mon, 5 Jul 2021 14:31:31 +0000 (16:31 +0200)] 
testQemuMonitorJSONqemuMonitorJSONGetAllBlockStatsInfo: Remove superfluous `goto`s

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agotestQemuMonitorJSONqemuMonitorJSONGetAllBlockStatsInfo: Use automatic memory management
Tim Wiederhake [Mon, 5 Jul 2021 14:29:49 +0000 (16:29 +0200)] 
testQemuMonitorJSONqemuMonitorJSONGetAllBlockStatsInfo: Use automatic memory management

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agonwfilterxml2firewalltest.c: testCompareXMLToArgvFiles: `virHashNew` cannot return...
Tim Wiederhake [Mon, 5 Jul 2021 14:20:04 +0000 (16:20 +0200)] 
nwfilterxml2firewalltest.c: testCompareXMLToArgvFiles: `virHashNew` cannot return NULL

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemuMonitorGetMemoryDeviceInfo: `virHashNew` cannot return NULL
Tim Wiederhake [Mon, 5 Jul 2021 14:03:19 +0000 (16:03 +0200)] 
qemuMonitorGetMemoryDeviceInfo: `virHashNew` cannot return NULL

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemuMonitorGetMemoryDeviceInfo: Use automatic memory management
Tim Wiederhake [Mon, 5 Jul 2021 14:02:40 +0000 (16:02 +0200)] 
qemuMonitorGetMemoryDeviceInfo: Use automatic memory management

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemuMonitorGetMemoryDeviceInfo: Assign hash table only on success
Tim Wiederhake [Mon, 5 Jul 2021 14:01:00 +0000 (16:01 +0200)] 
qemuMonitorGetMemoryDeviceInfo: Assign hash table only on success

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoiptablesPrivateChainCreate: Remove superfluous `goto`s
Tim Wiederhake [Mon, 5 Jul 2021 13:46:54 +0000 (15:46 +0200)] 
iptablesPrivateChainCreate: Remove superfluous `goto`s

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoiptablesPrivateChainCreate: Use automatic memory management
Tim Wiederhake [Mon, 5 Jul 2021 13:45:17 +0000 (15:45 +0200)] 
iptablesPrivateChainCreate: Use automatic memory management

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoiptablesPrivateChainCreate: `virHashNew` cannot return NULL
Tim Wiederhake [Mon, 5 Jul 2021 13:44:20 +0000 (15:44 +0200)] 
iptablesPrivateChainCreate: `virHashNew` cannot return NULL

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirNWFilterRuleDefToRuleInst: `virHashNew` cannot return NULL
Tim Wiederhake [Tue, 6 Jul 2021 11:26:10 +0000 (13:26 +0200)] 
virNWFilterRuleDefToRuleInst: `virHashNew` cannot return NULL

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirNWFilterCreateVarsFrom: Remove superfluous `goto`s
Tim Wiederhake [Tue, 6 Jul 2021 08:18:57 +0000 (10:18 +0200)] 
virNWFilterCreateVarsFrom: Remove superfluous `goto`s

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirNWFilterCreateVarsFrom: Use automatic memory management
Tim Wiederhake [Tue, 6 Jul 2021 08:18:24 +0000 (10:18 +0200)] 
virNWFilterCreateVarsFrom: Use automatic memory management

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirNWFilterCreateVarsFrom: `virHashNew` cannot return NULL
Tim Wiederhake [Tue, 6 Jul 2021 08:17:22 +0000 (10:17 +0200)] 
virNWFilterCreateVarsFrom: `virHashNew` cannot return NULL

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoAUTHORS: Add myself to the list of commiters
Tim Wiederhake [Wed, 14 Jul 2021 12:37:02 +0000 (14:37 +0200)] 
AUTHORS: Add myself to the list of commiters

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirt-aa-helper: Allow swtpm to fsync on dir
Stefan Berger [Tue, 13 Jul 2021 18:38:32 +0000 (14:38 -0400)] 
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>
4 years agoqemuMonitorGetChardevInfo: `virHashNew` cannot return NULL
Tim Wiederhake [Tue, 6 Jul 2021 12:37:59 +0000 (14:37 +0200)] 
qemuMonitorGetChardevInfo: `virHashNew` cannot return NULL

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuMonitorGetChardevInfo: Use automatic memory management
Tim Wiederhake [Tue, 6 Jul 2021 12:37:58 +0000 (14:37 +0200)] 
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>
4 years agoqemuMonitorGetChardevInfo: Remove superfluous variable "ret"
Tim Wiederhake [Tue, 6 Jul 2021 12:37:57 +0000 (14:37 +0200)] 
qemuMonitorGetChardevInfo: Remove superfluous variable "ret"

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuMonitorGetBlockInfo: `virHashNew` cannot return NULL
Tim Wiederhake [Tue, 6 Jul 2021 12:37:56 +0000 (14:37 +0200)] 
qemuMonitorGetBlockInfo: `virHashNew` cannot return NULL

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuMonitorGetBlockInfo: Use automatic memory management
Tim Wiederhake [Tue, 6 Jul 2021 12:37:55 +0000 (14:37 +0200)] 
qemuMonitorGetBlockInfo: Use automatic memory management

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuMonitorGetBlockInfo: Remove superfluous variable "ret"
Tim Wiederhake [Tue, 6 Jul 2021 12:37:54 +0000 (14:37 +0200)] 
qemuMonitorGetBlockInfo: Remove superfluous variable "ret"

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuMonitorGetAllBlockStatsInfo: `virHashNew` cannot return NULL
Tim Wiederhake [Tue, 6 Jul 2021 12:37:53 +0000 (14:37 +0200)] 
qemuMonitorGetAllBlockStatsInfo: `virHashNew` cannot return NULL

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuMonitorGetAllBlockStatsInfo: Use automatic memory management
Tim Wiederhake [Tue, 6 Jul 2021 12:37:52 +0000 (14:37 +0200)] 
qemuMonitorGetAllBlockStatsInfo: Use automatic memory management

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuMonitorGetAllBlockStatsInfo: Assign hash table only on success
Tim Wiederhake [Tue, 6 Jul 2021 12:37:51 +0000 (14:37 +0200)] 
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>
4 years agoqemuMonitorGetAllBlockStatsInfo: Remove superfluous variable initialization
Tim Wiederhake [Tue, 6 Jul 2021 12:37:50 +0000 (14:37 +0200)] 
qemuMonitorGetAllBlockStatsInfo: Remove superfluous variable initialization

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuMonitorGetAllBlockStatsInfo: Clean up line break
Tim Wiederhake [Tue, 6 Jul 2021 12:37:49 +0000 (14:37 +0200)] 
qemuMonitorGetAllBlockStatsInfo: Clean up line break

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirsh: Fix the order of format arguments in doDump
Han Han [Tue, 13 Jul 2021 08:04:12 +0000 (16:04 +0800)] 
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>
4 years agolibxl: Add helper function for running the hook script
Jim Fehlig [Wed, 30 Jun 2021 00:11:29 +0000 (18:11 -0600)] 
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>
4 years agolibxl: Introduce libxlDomainStartPerform
Jim Fehlig [Tue, 29 Jun 2021 23:47:41 +0000 (17:47 -0600)] 
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>
4 years agolibxl: Introduce libxlDomainStartPrepare
Jim Fehlig [Tue, 29 Jun 2021 23:32:37 +0000 (17:32 -0600)] 
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>
4 years agolibxl: Add a helper function to unprepare network devices
Jim Fehlig [Wed, 17 Feb 2021 22:24:58 +0000 (15:24 -0700)] 
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>
4 years agolibxl: Move managed save logic to libxlDomainStartNew
Jim Fehlig [Wed, 17 Feb 2021 21:13:24 +0000 (14:13 -0700)] 
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>
4 years agolibxl: Drop unused 'cfg' parameter from libxlDomainSaveImageOpen
Jim Fehlig [Wed, 17 Feb 2021 21:19:54 +0000 (14:19 -0700)] 
libxl: Drop unused 'cfg' parameter from libxlDomainSaveImageOpen

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoNEWS: Mention implications of the bug in migration code
Peter Krempa [Fri, 2 Jul 2021 12:17:58 +0000 (14:17 +0200)] 
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>
4 years agoqemu: migration: Use correct flag constant for enabling storage migration
Peter Krempa [Fri, 2 Jul 2021 12:17:57 +0000 (14:17 +0200)] 
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: da69f4b2084bff140238e450e264d6036ebef898
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirDomainSetBlockThreshold: Document that two events are fired when index isn't used
Peter Krempa [Thu, 1 Jul 2021 14:03:58 +0000 (16:03 +0200)] 
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>
4 years agoqemu: Prevent two threshold events when it was registered with index
Peter Krempa [Thu, 1 Jul 2021 14:03:57 +0000 (16:03 +0200)] 
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>
4 years agostorage_source: Add flag storing whether threshold event was registered with index
Peter Krempa [Thu, 1 Jul 2021 14:03:56 +0000 (16:03 +0200)] 
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>
4 years agoqemu: interface: check and use ovs command to set qos of ovs managed port
zhangjl02 [Wed, 7 Jul 2021 09:18:19 +0000 (17:18 +0800)] 
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>
4 years agoqemu: interface: remove setting noqueue for ovs port
zhangjl02 [Wed, 7 Jul 2021 09:18:18 +0000 (17:18 +0800)] 
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>
4 years agovirDomain: interface: add virNetDevOpenvswitchInterfaceSetQos and virNetDevOpenvswitc...
zhangjl02 [Wed, 7 Jul 2021 09:18:17 +0000 (17:18 +0800)] 
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>
4 years agovirDomain: interface: add virDomainNetDefIsOvsport
zhangjl02 [Wed, 7 Jul 2021 09:18:16 +0000 (17:18 +0800)] 
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>
4 years agoqemu: remove default audio backend for migratable XML
Daniel P. Berrangé [Wed, 7 Jul 2021 18:45:51 +0000 (19:45 +0100)] 
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>
4 years agolib: Specify domain redefinition requirements
Roman Bolshakov [Wed, 30 Jun 2021 16:16:33 +0000 (19:16 +0300)] 
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. https://github.com/ansible-collections/community.libvirt/blob/b973d7c4b405818b9fe77bbb0432c67acc12e82f/plugins/modules/virt.py#L533

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovircgroup: Improve virCgroupControllerAvailable wrt to CGroupsV2
Michal Privoznik [Thu, 8 Jul 2021 14:44:21 +0000 (16:44 +0200)] 
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>
4 years agoschemas: Allow cache attribute for bandwidth element for HMAT
Michal Privoznik [Wed, 7 Jul 2021 14:00:49 +0000 (16:00 +0200)] 
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: a89bbbac86383a10be0cec5a93feb7ed820871eb
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>
4 years agovirtlockd: Don't report error if lockspace exists
Jim Fehlig [Wed, 30 Jun 2021 22:36:42 +0000 (16:36 -0600)] 
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>
4 years agoqemu: Don't use memory-backend-memfd for NVDIMMs
Michal Privoznik [Mon, 21 Jun 2021 15:14:15 +0000 (17:14 +0200)] 
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>
4 years agovirDomainMachineNameAppendValid: Handle special characters better
Michal Privoznik [Fri, 25 Jun 2021 13:51:52 +0000 (15:51 +0200)] 
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>
4 years agovirresctrl: Fix updating the mask for a cache resource
Vinayak Kale [Fri, 2 Jul 2021 07:23:15 +0000 (12:53 +0530)] 
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: d8a354954aba9cd45ab0317915a0a2be27c04767
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>
4 years agovirDomainSEVDefParseXML: Remove superfluous variable initialization
Tim Wiederhake [Mon, 5 Jul 2021 10:46:54 +0000 (12:46 +0200)] 
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>
4 years agovirDomainSEVDefParseXML: Remove superfluous `goto`s
Tim Wiederhake [Mon, 5 Jul 2021 10:46:53 +0000 (12:46 +0200)] 
virDomainSEVDefParseXML: Remove superfluous `goto`s

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>
4 years agovirDomainSEVDefParseXML: Use automatic memory management
Tim Wiederhake [Mon, 5 Jul 2021 10:46:52 +0000 (12:46 +0200)] 
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>
4 years agovirDomainSEVDefParseXML: Use virXMLPropEnum
Tim Wiederhake [Mon, 5 Jul 2021 10:46:51 +0000 (12:46 +0200)] 
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>
4 years agoconf: virDomainSEVDef: Change type of "sectype" to virDomainLaunchSecurity
Tim Wiederhake [Mon, 5 Jul 2021 10:46:50 +0000 (12:46 +0200)] 
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>
4 years agoconf: Add AUTOPTR_CLEANUP_FUNC for virDomainSEVDef
Tim Wiederhake [Mon, 5 Jul 2021 10:46:49 +0000 (12:46 +0200)] 
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>
4 years agomeson: check for `XDR` and `driver_remote` early
Pavel Hrdina [Wed, 7 Jul 2021 11:00:12 +0000 (13:00 +0200)] 
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>
4 years agoTranslated using Weblate (Indonesian)
Didik Supriadi [Tue, 6 Jul 2021 16:04:27 +0000 (18:04 +0200)] 
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>
4 years agoTranslated using Weblate (Korean)
simmon [Tue, 6 Jul 2021 16:04:26 +0000 (18:04 +0200)] 
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>
4 years agoTranslated using Weblate (Finnish)
Ricky Tigg [Tue, 6 Jul 2021 16:04:25 +0000 (18:04 +0200)] 
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>
4 years agodocs: add go-import meta tags for new go modules
Daniel P. Berrangé [Fri, 2 Jul 2021 10:54:03 +0000 (11:54 +0100)] 
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>
4 years agodocs: point go imports to gitlab.com repos
Daniel P. Berrangé [Fri, 2 Jul 2021 10:50:20 +0000 (11:50 +0100)] 
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>
4 years agovirSetUIDGIDWithCaps: Assume PR_CAPBSET_DROP is always defined
Michal Privoznik [Thu, 24 Jun 2021 14:58:53 +0000 (16:58 +0200)] 
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>
4 years agonodedev: improve error message when destroying an inactive device
Jonathon Jongsma [Tue, 22 Jun 2021 19:53:36 +0000 (14:53 -0500)] 
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>
4 years agonodedev: handle mdevctl errors consistently
Jonathon Jongsma [Tue, 22 Jun 2021 19:53:35 +0000 (14:53 -0500)] 
nodedev: handle mdevctl errors consistently

Currently, we have three different types of mdevctl errors:
 1. the command cannot be constructed ecause of unsatisfied
    preconditions
 2. the command cannot be executed due to some error
 3. the command is executed, but returns an error status

These different failures are handled differently. Some cases set an
error and return and error status, and some return a error message but
do not set an error.

This means that the caller has to check both whether the return value is
negative and whether the errmsg parameter is non-NULL before deciding
whether to report the error or not. The situation is further complicated
by the fact that there are occasional instances where mdevctl exits with
an error status but does not print an error message.  This results in
errmsg being an empty string "" (i.e. non-NULL).

Simplify the situation by ensuring that virReportError() is called for
all error conditions rather than returning an error message back to the
calling function.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
4 years agonodedev: add macro to handle command errors
Jonathon Jongsma [Tue, 22 Jun 2021 19:53:34 +0000 (14:53 -0500)] 
nodedev: add macro to handle command errors

This macro will be utilized in the following patch. Since mdevctl
commands can fail with or without an error message, this macro makes it
easy to print a fallback error in the case that the error message is not
set.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
4 years agonodedev: Handle NULL command variable
Jonathon Jongsma [Tue, 22 Jun 2021 19:53:33 +0000 (14:53 -0500)] 
nodedev: Handle NULL command variable

In commit 68580a51, I removed the checks for NULL cmd variables because
virCommandRun() already handles the case where it is called with a NULL
cmd. Unfortunately, it handles this case by raising a generic error
which is both unhelpful and overwrites our existing error message. So
for example, when I attempt to create a mediated device with an invalid
parent, I get the following output:

    virsh # nodedev-create mdev-test.xml
    error: Failed to create node device from mdev-test.xml
    error: internal error: invalid use of command API

With this patch, I now get a useful error message again:

    virsh # nodedev-create mdev-test.xml
    error: Failed to create node device from mdev-test.xml
    error: internal error: unable to find parent device 'pci_0000_00_03_0'

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>