]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
4 years agosrc: don't hide error in VIR_DRV_SUPPORTS_FEATURE
Nikolay Shirokovskiy [Fri, 18 Dec 2020 06:40:04 +0000 (09:40 +0300)]
src: don't hide error in VIR_DRV_SUPPORTS_FEATURE

Otherwise we can get misleading error messages. One example is when connection
is broken we got "this function is not supported by the connection driver:
virDomainMigrate3" from virDomainMigrate3.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: adopt to VIR_DRV_SUPPORTS_FEATURE return -1
Nikolay Shirokovskiy [Thu, 17 Dec 2020 12:28:25 +0000 (15:28 +0300)]
qemu: adopt to VIR_DRV_SUPPORTS_FEATURE return -1

Otherwise in some places we can mistakenly report 'unsupported' error instead
of root cause. So let's handle root cause explicitly from the macro.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agolibxl: adopt to VIR_DRV_SUPPORTS_FEATURE return -1
Nikolay Shirokovskiy [Thu, 17 Dec 2020 12:27:41 +0000 (15:27 +0300)]
libxl: adopt to VIR_DRV_SUPPORTS_FEATURE return -1

Otherwise in some places we can mistakenly report 'unsupported' error instead
of root cause. So let's handle root cause explicitly from the macro.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agosrc: adopt to VIR_DRV_SUPPORTS_FEATURE return -1
Nikolay Shirokovskiy [Thu, 17 Dec 2020 12:20:57 +0000 (15:20 +0300)]
src: adopt to VIR_DRV_SUPPORTS_FEATURE return -1

Otherwise in some places we can mistakenly report 'unsupported' error instead
of root cause. So let's handle root cause explicitly from the macro.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoschemas: Allow direct children of <filesystem/> to be interleaved
Michal Privoznik [Wed, 6 Jan 2021 11:52:13 +0000 (12:52 +0100)]
schemas: Allow direct children of <filesystem/> to be interleaved

Now that individual child elements allow their children to be
interleaved, let's allow direct children of <filesystem/> to be
interleaved too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoschemas: Allow interleaving of fsBinary children
Michal Privoznik [Wed, 6 Jan 2021 11:43:05 +0000 (12:43 +0100)]
schemas: Allow interleaving of fsBinary children

The <binary/> element of <filesystem/> can have children elements
(<cache/> and <lock/>). Allow them to be interleaved.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoschemas: Allow fsDriver to be interleaved
Michal Privoznik [Wed, 6 Jan 2021 11:41:40 +0000 (12:41 +0100)]
schemas: Allow fsDriver to be interleaved

Our <filesystem/> element can have <driver/> child element. But
with the way our schema is written it can't be interleaved and
has to go first.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Restore default root qdisc when QoS is cleared out
Michal Privoznik [Fri, 4 Dec 2020 11:50:58 +0000 (12:50 +0100)]
qemu: Restore default root qdisc when QoS is cleared out

When an interface has some bandwidth limitation set (it's root
qdisc is htb in that case) but this gets cleared out via public
API call (virDomainSetInterfaceParameters() or
virDomainUpdateDeviceFlags()) then virNetDevBandwidthSet() clears
out whatever qdiscs were set on the interface and kernel places
the default qdisc at the root. What we need to do next is to
replace the root qdisc with the one we want.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1329644
Fixes: 0b66196d86ea375234cb0ee99289c486f9921820
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: Set default qdisc before setting bandwidth
Michal Privoznik [Fri, 4 Dec 2020 12:02:53 +0000 (13:02 +0100)]
qemu: Set default qdisc before setting bandwidth

While the code that's setting default qdisc is clever enough to
not overwrite any bandwidth (potentially) set by
virNetDevBandwidthSet() (and thus the root qdisc htb is not
replaced with noqueue), it does print a debug message when that's
the case. It's needless. We can set the root qdisc beforehand and
let virNetDevBandwidthSet() overwrite it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu_process: Release domain seclabel later in qemuProcessStop()
Michal Privoznik [Wed, 9 Dec 2020 10:06:29 +0000 (11:06 +0100)]
qemu_process: Release domain seclabel later in qemuProcessStop()

Some secdrivers (typically SELinux driver) generate unique
dynamic seclabel for each domain (unless a static one is
requested in domain XML). This is achieved by calling
qemuSecurityGenLabel() from qemuProcessPrepareDomain() which
allocates unique seclabel and stores it in domain def->seclabels.
The counterpart is qemuSecurityReleaseLabel() which releases the
label and removes it from def->seclabels. Problem is, that with
current code the qemuProcessStop() may still want to use the
seclabel after it was released, e.g. when it wants to restore the
label of a disk mirror.

What is happening now, is that in qemuProcessStop() the
qemuSecurityReleaseLabel() is called, which removes the SELinux
seclabel from def->seclabels, yada yada yada and eventually
qemuSecurityRestoreImageLabel() is called. This bubbles down to
virSecuritySELinuxRestoreImageLabelSingle() which find no SELinux
seclabel (using virDomainDefGetSecurityLabelDef()) and this
returns early doing nothing.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1751664
Fixes: 8fa0374c5b8e834fcbdeae674cc6cc9e6bf9019f
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirstoragefile: move virStorageFileIsClusterFS into virfile
Pavel Hrdina [Mon, 7 Dec 2020 11:04:41 +0000 (12:04 +0100)]
virstoragefile: move virStorageFileIsClusterFS into virfile

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirstoragefile: move virStorageFileResize into virfile
Pavel Hrdina [Mon, 7 Dec 2020 11:04:04 +0000 (12:04 +0100)]
virstoragefile: move virStorageFileResize into virfile

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirfile: refactor virFileNBDDeviceAssociate
Pavel Hrdina [Wed, 6 Jan 2021 12:02:38 +0000 (13:02 +0100)]
virfile: refactor virFileNBDDeviceAssociate

The only reason why virstoragefile.h needs to be included in virfile.h
is that virFileNBDDeviceAssociate() takes virStorageFileFormat argument.
The function doesn't need the enum value as it converts the value to
string and uses only that.

Change the argument to string which will allow us to remove that
include.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agosrc: add missing headers to various files
Pavel Hrdina [Wed, 6 Jan 2021 11:56:11 +0000 (12:56 +0100)]
src: add missing headers to various files

All these headers are indirectly included provided by virfile.h having
virstoragefile.h which will be removed in the following patch.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoutil: move virStorageFileCheckCompat into conf
Pavel Hrdina [Mon, 7 Dec 2020 12:34:18 +0000 (13:34 +0100)]
util: move virStorageFileCheckCompat into conf

It is not used anywhere else.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoutil: move virStorageFileGetLVMKey to locking
Pavel Hrdina [Fri, 4 Dec 2020 05:52:18 +0000 (06:52 +0100)]
util: move virStorageFileGetLVMKey to locking

The function doesn't take virStorageSource as argument and has nothing
in common with virStorageSource or storage file.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoutil: move virQEMUBuildQemuImgKeySecretOpts into storage
Pavel Hrdina [Tue, 1 Dec 2020 15:30:21 +0000 (16:30 +0100)]
util: move virQEMUBuildQemuImgKeySecretOpts into storage

Function virQEMUBuildQemuImgKeySecretOpts is not used anywhere else
so there is no need to have it in util.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirstoragefile: remove unused virStorageFileChainCheckBroken
Pavel Hrdina [Mon, 7 Dec 2020 11:02:14 +0000 (12:02 +0100)]
virstoragefile: remove unused virStorageFileChainCheckBroken

The last usage outside of tests was removed by commit
<780f8c94ca8b3dee7eb59c1bfbc32f672f965df8>.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoutil: remove unused virStorageGenerateQcowPassphrase
Pavel Hrdina [Tue, 1 Dec 2020 15:36:44 +0000 (16:36 +0100)]
util: remove unused virStorageGenerateQcowPassphrase

The last user was removed by commit
<40f0e0348dfc84f28a500e262c4953b0d3b44fa0>.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoschema: Fix TPM version rules
Michal Privoznik [Wed, 6 Jan 2021 10:50:56 +0000 (11:50 +0100)]
schema: Fix TPM version rules

According to our parser (virDomainTPMDefParseXML()) the version
is an optional attribute and independent of TPM backend type.
Therefore, it's not a choice group, which is what our RNG schema
suggests.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agomanpage: virsh: Drop note that 'domrename' doesn't work with snapshots/checkpoints
Peter Krempa [Wed, 6 Jan 2021 09:56:12 +0000 (10:56 +0100)]
manpage: virsh: Drop note that 'domrename' doesn't work with snapshots/checkpoints

As of commits 3b1244bffdb and 4770a96c662 renaming of the domain works
also with checkpoints and snapshots. Update the docs.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Han Han <hhan@redhat.com>
4 years agoconf: Add support for keeping TPM emulator state
Eiichi Tsukata [Mon, 4 Jan 2021 02:31:59 +0000 (02:31 +0000)]
conf: Add support for keeping TPM emulator state

Currently, swtpm TPM state file is removed when a transient domain is
powered off or undefined. When we store TPM state on a shared storage
such as NFS and use transient domain, TPM states should be kept as it is.

Add per-TPM emulator option `persistent_sate` for keeping TPM state.
This option only works for the emulator type backend and looks as follows:

  <tpm model='tpm-tis'>
    <backend type='emulator' persistent_state='yes'/>
  </tpm>

Signed-off-by: Eiichi Tsukata <eiichi.tsukata@nutanix.com>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu: The TSC tolerance interval should be closed
Jiri Denemark [Tue, 5 Jan 2021 22:53:25 +0000 (23:53 +0100)]
qemu: The TSC tolerance interval should be closed

The kernel refuses to set guest TSC frequency less than a minimum
frequency or greater than maximum frequency (both computed based on the
host TSC frequency). When writing the libvirt code with a reversed logic
(return success when the requested frequency falls within the tolerance
interval) I forgot to include the boundaries.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemu: backup: Properly delete temporary bitmap after push-mode incremental backup
Peter Krempa [Tue, 5 Jan 2021 14:43:21 +0000 (15:43 +0100)]
qemu: backup: Properly delete temporary bitmap after push-mode incremental backup

Refactor in 0316c28a453ac used incorrect source variable to initialize
the variable which holds the name of the bitmap which needs to be
deleted after the backup job finishes. This resulted into deleting the
source bitmap of the backup rather than the temporary one.

Use 'dd->incrementalBitmap' which holds the temporary bitmap name
instead of 'dd->backupdisk->incremental' which holds the name of the
source bitmap which is used by the backup.

Fixes: 0316c28a453ac15f58c61f30359f66ab9a649884
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1908647
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirsh-domain: Add quotes around '%s' formatting domain name
Peter Krempa [Tue, 5 Jan 2021 12:02:34 +0000 (13:02 +0100)]
virsh-domain: Add quotes around '%s' formatting domain name

Domain name can contain spaces in which case it's not immediately clear
from virsh messages where the boundary of the name is. Enclose all %s
formatters in apostrophes as delimiters.

Done via the following vim regex:

 %s/omain %s/omain '%s'/g

This patch changes:

 $ virsh undefine --snapshots-metadata 'OWASP Broken Web Apps VM v1.2'
 Domain OWASP Broken Web Apps VM v1.2 has been undefined

to:

 $ virsh undefine --snapshots-metadata 'OWASP Broken Web Apps VM v1.2'
 Domain 'OWASP Broken Web Apps VM v1.2' has been undefined

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu: Properly handle setting of <iotune> for empty cdrom
Peter Krempa [Tue, 5 Jan 2021 11:06:32 +0000 (12:06 +0100)]
qemu: Properly handle setting of <iotune> for empty cdrom

When starting a VM with an empty cdrom which has <iotune> configured the
startup fails as qemu is not happy about setting tuning for an empty
drive:

 error: internal error: unable to execute 'block_set_io_throttle', unexpected error: 'Device has no medium'

Resolve this by skipping the setting of throttling for empty drives and
updating the throttling when new medium is inserted into the drive.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/111
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agovmx: Treat missing cdrom-image as empty drive
Martin Kletzander [Mon, 21 Dec 2020 15:34:32 +0000 (16:34 +0100)]
vmx: Treat missing cdrom-image as empty drive

This is perfectly valid in VMWare and the VM just boots with an empty drive.  We
used to just skip the whole drive before, but since we changed how we parse
empty cdrom drives this results in an error.  Make it behave more closer to
VMWare.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
4 years agoesx: Handle missing images in esxParseVMXFileName
Martin Kletzander [Tue, 5 Jan 2021 12:58:53 +0000 (13:58 +0100)]
esx: Handle missing images in esxParseVMXFileName

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
4 years agotests: Test vmx files with missing images
Martin Kletzander [Tue, 5 Jan 2021 13:19:34 +0000 (14:19 +0100)]
tests: Test vmx files with missing images

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
4 years agovmx: Allow missing cdrom image file in virVMXParseFileName
Martin Kletzander [Mon, 21 Dec 2020 15:51:31 +0000 (16:51 +0100)]
vmx: Allow missing cdrom image file in virVMXParseFileName

This will be used later.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
4 years agotests: Allow testing for parse failures in vmx2xmltest
Martin Kletzander [Tue, 5 Jan 2021 13:19:21 +0000 (14:19 +0100)]
tests: Allow testing for parse failures in vmx2xmltest

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
4 years agovmx: Make virVMXParseFileName return an integer
Martin Kletzander [Mon, 21 Dec 2020 13:48:49 +0000 (14:48 +0100)]
vmx: Make virVMXParseFileName return an integer

And return the actual extracted value in a parameter.  This way we can later
return success even without any extracted value.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
4 years agotests: Use g_autofree in testParseVMXFileName
Martin Kletzander [Mon, 21 Dec 2020 15:56:25 +0000 (16:56 +0100)]
tests: Use g_autofree in testParseVMXFileName

There's only one variable to clean-up, others are just tokens inside that
variable, but it is nicer anyway.  Positive returns have not been converted
because the function will change soon and it would not make much sense.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
4 years agoesx: Unindent unnecessary conditional branch
Martin Kletzander [Mon, 21 Dec 2020 13:38:30 +0000 (14:38 +0100)]
esx: Unindent unnecessary conditional branch

The positive branch can just return and the huge negative part does not need to
be indented an extra level.  Best viewed with `-w`.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
4 years agorpm: fix ownership of the swtpm log directory
Daniel P. Berrangé [Mon, 4 Jan 2021 18:03:55 +0000 (18:03 +0000)]
rpm: fix ownership of the swtpm log directory

As soon as a guest using a <tpm> device is launched, libvirt will change
the ownership to 'tss' user and group, with mode 0730, which will cause
RPM verify to then fail.

Reviewed-by: Laine Stump <laine@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agorpm: ensure swtpm tools are installed with QEMU
Daniel P. Berrangé [Mon, 4 Jan 2021 18:03:24 +0000 (18:03 +0000)]
rpm: ensure swtpm tools are installed with QEMU

These are needed for the <tpm> devices to be usable.

Reviewed-by: Laine Stump <laine@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agostorage_util: Rework storageBackendCreateRaw() slightly
Yi Li [Tue, 5 Jan 2021 14:43:32 +0000 (22:43 +0800)]
storage_util: Rework storageBackendCreateRaw() slightly

Remove @ret and @created variables which are not needed really.

Signed-off-by: Yi Li <yili@winhong.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirStorageBackendCopyToFD: remove unused return variable
Yi Li [Tue, 5 Jan 2021 14:43:31 +0000 (22:43 +0800)]
virStorageBackendCopyToFD: remove unused return variable

None of the callers care about errno really. The errno will be
reported by virReportSystemError().

Signed-off-by: Yi Li <yili@winhong.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agocreateRawFile: remove unused return variable
Yi Li [Tue, 5 Jan 2021 14:43:30 +0000 (22:43 +0800)]
createRawFile: remove unused return variable

The caller doesn't care about errno really. The errno will be
reported by virReportSystemError().

Signed-off-by: Yi Li <yili@winhong.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agodocs: support qcow2 format in luks encryption volume
Meina Li [Thu, 24 Dec 2020 09:31:55 +0000 (04:31 -0500)]
docs: support qcow2 format in luks encryption volume

Signed-off-by: Meina Li <meili@redhat.com>
Reviewed-by: Han Han <hhan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agodocs: migration: remove xenmigr
Olaf Hering [Tue, 5 Jan 2021 10:41:24 +0000 (11:41 +0100)]
docs: migration: remove xenmigr

xenmigr was for xend which was removed in in 4.3.0.

Fixes: 1dac5fbbbb06a0341e8087dc33af75c8352d77a4
Signed-off-by: Olaf Hering <olaf@aepfle.de>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu: Don't prealloc mem for real NVDIMMs
Michal Privoznik [Mon, 30 Nov 2020 10:06:14 +0000 (11:06 +0100)]
qemu: Don't prealloc mem for real NVDIMMs

Currently, we configure QEMU to prealloc memory almost by
default. Well, by default for NVDIMMs, hugepages and if user
asked us to (via memoryBacking <allocation mode="immediate"/>).

However, when guest's NVDIMM is backed by real life NVDIMM this
approach is not the best. In this case users should put <pmem/>
into the <memory/> device <source/>, like this:

  <memory model='nvdimm' access='shared'>
    <source>
      <path>/dev/pmem0</path>
      <pmem/>
    </source>
  </memory>

Instructing QEMU to do prealloc in this case means that each
page of the NVDIMM is "touched" (the first byte is read and
written back - see QEMU commit v2.9.0-rc1~26^2) which cripples
device wear.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1894053
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agonetworkGetDHCPLeases: Don't assign @ipdef_tmp twice
Michal Privoznik [Tue, 5 Jan 2021 11:54:40 +0000 (12:54 +0100)]
networkGetDHCPLeases: Don't assign @ipdef_tmp twice

When rewriting the function, I've mistakenly declared a variable
and assigned it to itself. Let's initialize the variable properly.

Fixes: 5fb6d98c881c42ab41ca72060217b846949a438f
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
4 years agodocs: Fix dead link
Tim Wiederhake [Mon, 21 Dec 2020 08:01:36 +0000 (09:01 +0100)]
docs: Fix dead link

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
4 years agoEnable VMware driver by default
Michal Privoznik [Tue, 5 Jan 2021 09:18:57 +0000 (10:18 +0100)]
Enable VMware driver by default

During rewrite to meson it was mistakenly disabled. Originally,
we had:

  LIBVIRT_ARG_WITH_FEATURE([VMWARE], [VMware], [yes])

which enabled the driver by default. But in meson we are checking
whether the 'driver_vmware' option is enabled without anything
enabling it automagically.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agouse more virStrcpy() and virStrcpyStatic()
Michal Privoznik [Sat, 26 Dec 2020 19:04:49 +0000 (20:04 +0100)]
use more virStrcpy() and virStrcpyStatic()

There are a few places where we open code virStrcpy() or
virStrcpyStatic(). Call respective functions instead.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agodomain_conf: Parse full length of some <seclabel/> attributes
Michal Privoznik [Wed, 21 Aug 2019 11:07:57 +0000 (13:07 +0200)]
domain_conf: Parse full length of some <seclabel/> attributes

In virSecurityLabelDefParseXML() we are parsing the <seclabel/>
element among with its attributes. Some of the attributes are
limited in length (because of virNodeGetSecurityModel()), however
some are not. And for the latter ones we don't need to use
virXMLPropStringLimit() to parse them. Moreover, using
VIR_SECURITY_LABEL_BUFLEN as the limit is wrong - we are not
storing the parsed strings into a static buffer of that size
rather than checking if the string passes string -> enum
conversion.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Fix retval if ACL check fails in qemuNodeGetSecurityModel
Michal Privoznik [Wed, 21 Aug 2019 11:05:16 +0000 (13:05 +0200)]
qemu: Fix retval if ACL check fails in qemuNodeGetSecurityModel

While previously we returned 0 this is not correct. We have to
return a negative value to indicate error.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Obtain @caps only after ACL check in qemuNodeGetSecurityModel
Michal Privoznik [Wed, 21 Aug 2019 09:47:56 +0000 (11:47 +0200)]
qemu: Obtain @caps only after ACL check in qemuNodeGetSecurityModel

Even though we are getting driver capabilities with
refresh=false (so that it is not expensive), we still should do
ACL check first because there is no point in bothering with the
capabilities if caller doesn't have permissions to call the API.
Also, this way the comment makes more sense.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Use virStrcpy in qemuNodeGetSecurityModel()
Michal Privoznik [Wed, 21 Aug 2019 09:41:28 +0000 (11:41 +0200)]
qemu: Use virStrcpy in qemuNodeGetSecurityModel()

The code we have there to copy seclabel model or doi can be
replaced by virStrcpy() calls which do exactly the same checks.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agonss: handle leases with infinite expiry time
Michal Privoznik [Fri, 18 Dec 2020 15:09:16 +0000 (16:09 +0100)]
nss: handle leases with infinite expiry time

After v6.3.0-rc1~64 a lease can have infinite expiry time. This
means that the expiration time will appear as a value of zero.
Do the expiration check only if the expiration time is not zero.

Fixes: 97a0aa246799c97d0a9ca9ecd6b4fd932ae4756c
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agonetworkGetDHCPLeases: Handle leases with infinite expiry time
Michal Privoznik [Fri, 18 Dec 2020 15:09:15 +0000 (16:09 +0100)]
networkGetDHCPLeases: Handle leases with infinite expiry time

After v6.3.0-rc1~64 a lease can have infinite expiry time. This
means that the expiration time will appear as a value of zero.
Do the expiration check only if the expiration time is not zero.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1908053
Fixes: 97a0aa246799c97d0a9ca9ecd6b4fd932ae4756c
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agonetwork: Rework networkGetDHCPLeases()
Michal Privoznik [Fri, 18 Dec 2020 15:09:14 +0000 (16:09 +0100)]
network: Rework networkGetDHCPLeases()

Firstly, bring variables that are used only within loops into
their respective loops. Secondly, drop 'error' label which is
redundant since we have @rv which holds the return value.
Thirdly, fix indendation in one case, the rest is indented
properly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agonetworkGetDHCPLeases: Use VIR_APPEND_ELEMENT() instead of VIR_INSERT_ELEMENT()
Michal Privoznik [Fri, 18 Dec 2020 15:09:13 +0000 (16:09 +0100)]
networkGetDHCPLeases: Use VIR_APPEND_ELEMENT() instead of VIR_INSERT_ELEMENT()

This function is misusing VIR_INSERT_ELEMENT() to behave like
VIR_APPEND_ELEMENT(). Use the latter to make it explicit what we
are trying to achieve.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agonetwork: Drop @custom_lease_file_len variable from networkGetDHCPLeases()
Michal Privoznik [Fri, 18 Dec 2020 15:09:12 +0000 (16:09 +0100)]
network: Drop @custom_lease_file_len variable from networkGetDHCPLeases()

We don't need to track the lease file size. Instead, we can
simply check if the file was empty by comparing the buffer the
file was read into with an empty string.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirlease: Allow infinite lease expiry time
Michal Privoznik [Fri, 18 Dec 2020 15:09:11 +0000 (16:09 +0100)]
virlease: Allow infinite lease expiry time

When adding a new lease by our leaseshelper then virLeaseNew() is
called. Here, we check for DNSMASQ_LEASE_EXPIRES environment
variable which is the expiration time for the lease. For infinite
lease time the value is zero. However, our code is not prepared
for that and adds "expiry-time" into the JSON file only if lease
expiry time is non-zero. This breaks the assumption that the
"expiry-time" attribute is always present (as can be seen in
virLeaseReadCustomLeaseFile() and virLeasePrintLeases()).

Store "expiry-time" always.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirlease: Use virTrimSpaces() instead of open coded alternative
Michal Privoznik [Fri, 18 Dec 2020 15:09:10 +0000 (16:09 +0100)]
virlease: Use virTrimSpaces() instead of open coded alternative

In virLeaseNew() we are trying to remove trailing space (per
comment it may happen that older versions of dnsmasq put it into
an env variable). Well, instead of open coding it, we can use
virTrimSpaces().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirlease: Rework virLeaseReadCustomLeaseFile()
Michal Privoznik [Fri, 18 Dec 2020 15:09:09 +0000 (16:09 +0100)]
virlease: Rework virLeaseReadCustomLeaseFile()

There are some variables which are used only inside the single
loop the function has. Let's declare them inside the loop body to
make that obvious. Also, fix indendation.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoleaseshelper: Report errors on failure
Michal Privoznik [Fri, 18 Dec 2020 15:09:08 +0000 (16:09 +0100)]
leaseshelper: Report errors on failure

If leasehelper fails all that we are left with is a simple error
message produced by dnsmasq:

  lease-init script returned exit code 1

This is because the leasehelper did not write any message to
stderr. According to dnsmasq's manpage, whenever it's invoking
leasehelper the stderr is kept open:

  All file descriptors are closed except stdin, which is open to
  /dev/null, and stdout and stderr which capture output for
  logging by dnsmasq.

As debugging leasehelper is not trivial (because dnsmasq invokes
it with plenty of env vars set - that's how data is passed onto
helper), let's print an error into stderr if exiting with an
error. And since we are not calling public APIs, we have to call
virDispatchError() explicitly and since we don't have any
connection open, we have to pass NULL.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agodocs: Document ability to configure lease time
Michal Privoznik [Fri, 18 Dec 2020 15:09:07 +0000 (16:09 +0100)]
docs: Document ability to configure lease time

In v6.3.0-rc1~64 we've introduced ability to configure lease
time, but forgot to document the feature. Let's fix that.

Fixes: 97a0aa246799c97d0a9ca9ecd6b4fd932ae4756c
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1908631
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoUpdate translation files
Weblate [Mon, 4 Jan 2021 13:36:42 +0000 (14:36 +0100)]
Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

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

Co-authored-by: Weblate <noreply@weblate.org>
Signed-off-by: Fedora Weblate Translation <i18n@lists.fedoraproject.org>
4 years agoTranslated using Weblate (Bulgarian)
Nickys Music Group [Mon, 4 Jan 2021 13:36:42 +0000 (14:36 +0100)]
Translated using Weblate (Bulgarian)

Currently translated at 3.1% (329 of 10440 strings)

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

Co-authored-by: Nickys Music Group <nickys.music.group@gmail.com>
Signed-off-by: Nickys Music Group <nickys.music.group@gmail.com>
4 years agoTranslated using Weblate (Polish)
Piotr Drąg [Mon, 4 Jan 2021 13:36:41 +0000 (14:36 +0100)]
Translated using Weblate (Polish)

Currently translated at 23.4% (2444 of 10440 strings)

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

Co-authored-by: Piotr Drąg <piotrdrag@gmail.com>
Signed-off-by: Piotr Drąg <piotrdrag@gmail.com>
4 years agoTranslated using Weblate (Swedish)
Göran Uddeborg [Mon, 4 Jan 2021 13:36:40 +0000 (14:36 +0100)]
Translated using Weblate (Swedish)

Currently translated at 20.2% (2119 of 10440 strings)

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

Translated using Weblate (Swedish)

Currently translated at 20.0% (2089 of 10440 strings)

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

Translated using Weblate (Swedish)

Currently translated at 19.1% (1999 of 10440 strings)

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

Translated using Weblate (Swedish)

Currently translated at 18.5% (1941 of 10440 strings)

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

Translated using Weblate (Swedish)

Currently translated at 18.0% (1880 of 10440 strings)

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

Translated using Weblate (Swedish)

Currently translated at 17.7% (1852 of 10440 strings)

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

Translated using Weblate (Swedish)

Currently translated at 17.1% (1790 of 10440 strings)

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

Translated using Weblate (Swedish)

Currently translated at 16.8% (1760 of 10440 strings)

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

Translated using Weblate (Swedish)

Currently translated at 16.2% (1698 of 10440 strings)

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

Translated using Weblate (Swedish)

Currently translated at 15.9% (1669 of 10440 strings)

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

Translated using Weblate (Swedish)

Currently translated at 15.7% (1640 of 10440 strings)

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

Translated using Weblate (Swedish)

Currently translated at 15.4% (1610 of 10440 strings)

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

Translated using Weblate (Swedish)

Currently translated at 15.1% (1580 of 10440 strings)

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

Translated using Weblate (Swedish)

Currently translated at 14.8% (1550 of 10440 strings)

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

Co-authored-by: Göran Uddeborg <goeran@uddeborg.se>
Signed-off-by: Göran Uddeborg <goeran@uddeborg.se>
4 years agoqemu: Drop has_ccw_address from _qemuAgentDiskAddress
Michal Privoznik [Thu, 10 Dec 2020 11:37:26 +0000 (12:37 +0100)]
qemu: Drop has_ccw_address from _qemuAgentDiskAddress

In recent patches new mambers to _qemuAgentDiskAddress struct
were introduced to keep optional CCW address sent by the guest
agent. These two members are a struct to store CCW address into
and a boolean to keep track whether the CCW address is valid.
Well, we can hold the same information with a pointer - instead
of storing the CCW address structure let's keep just a pointer to
it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agokbase: debuglogs: Fix typo in unprivileged libvirtd config path
Tomáš Janoušek [Mon, 4 Jan 2021 10:35:02 +0000 (11:35 +0100)]
kbase: debuglogs: Fix typo in unprivileged libvirtd config path

Signed-off-by: Tomáš Janoušek <tomi@nomi.cz>
4 years agodomain_conf: Allow to look up scsi disks when controller uses a CCW address
Thomas Huth [Wed, 25 Nov 2020 11:06:48 +0000 (12:06 +0100)]
domain_conf: Allow to look up scsi disks when controller uses a CCW address

On s390x, devices are attached to the channel IO subsytem by default,
so we need to look up scsi controllers via their CCW address there
instead of using PCI.

This fixes "virsh domfsinfo" on s390x for virtio-scsi devices (the first
attempt from commit f8333b3b0a7 did it in the wrong way, reporting the
device name on the guest side instead of the target name on the host side).

Fixes: f8333b3b0a ("qemu: Fix domfsinfo for non-PCI device information ...")
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1858771
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agodomain_conf: Allow to look up virtio-block devices by their CCW address
Thomas Huth [Wed, 25 Nov 2020 11:06:47 +0000 (12:06 +0100)]
domain_conf: Allow to look up virtio-block devices by their CCW address

On s390x, devices are accessed via the channel subsystem by default,
so we need to look up the devices via their CCW address there instead
of using PCI.

This fixes "virsh domfsinfo" on s390x for virtio-block devices (the first
attempt from commit f8333b3b0a7 did it in the wrong way, reporting the
device name on the guest side instead of the target name on the host side).

Fixes: f8333b3b0a ("qemu: Fix domfsinfo for non-PCI device information ...")
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1858771
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu: agent: Store CCW address in qemuAgentDiskInfo if provided by the guest
Thomas Huth [Wed, 25 Nov 2020 11:06:46 +0000 (12:06 +0100)]
qemu: agent: Store CCW address in qemuAgentDiskInfo if provided by the guest

Newer versions of the QEMU guest agent will provide the CCW address
of devices on s390x. Store this information in the qemuAgentDiskInfo
so that we can use this later.

We also map the CSSID 0 from the guest to the value 0xfe on the host,
see https://www.qemu.org/docs/master/system/s390x/css.html for details.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agocpu-gather: Add IA32_CORE_CAPABILITY_MSR
Tim Wiederhake [Tue, 15 Dec 2020 16:25:15 +0000 (17:25 +0100)]
cpu-gather: Add IA32_CORE_CAPABILITY_MSR

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agocpu-gather: Prepare gather_msr for reading multiple msr
Tim Wiederhake [Tue, 15 Dec 2020 16:25:14 +0000 (17:25 +0100)]
cpu-gather: Prepare gather_msr for reading multiple msr

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agocpu-gather: Allow gathering and parsing data in one step.
Tim Wiederhake [Tue, 15 Dec 2020 16:25:13 +0000 (17:25 +0100)]
cpu-gather: Allow gathering and parsing data in one step.

Make
  ./cpu-gather.py --gather --parse
an alias of
  ./cpu-gather.py [--gather] | ./cpu-gather.py --parse

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agocpu-gather: Parse cpuid leaves early
Tim Wiederhake [Tue, 15 Dec 2020 16:25:12 +0000 (17:25 +0100)]
cpu-gather: Parse cpuid leaves early

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agocpu-gather: Ignore shutdown messages from qemu
Tim Wiederhake [Tue, 15 Dec 2020 16:25:11 +0000 (17:25 +0100)]
cpu-gather: Ignore shutdown messages from qemu

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agocpu-gather: Ignore empty responses from qemu
Tim Wiederhake [Tue, 15 Dec 2020 16:25:10 +0000 (17:25 +0100)]
cpu-gather: Ignore empty responses from qemu

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agocpu-parse: Delete old script
Tim Wiederhake [Tue, 15 Dec 2020 16:25:09 +0000 (17:25 +0100)]
cpu-parse: Delete old script

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agocpu-parse: Move call to cpu-cpuid.py to new script
Tim Wiederhake [Tue, 15 Dec 2020 16:25:08 +0000 (17:25 +0100)]
cpu-parse: Move call to cpu-cpuid.py to new script

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agocpu-parse: Move json output to new script
Tim Wiederhake [Tue, 15 Dec 2020 16:25:07 +0000 (17:25 +0100)]
cpu-parse: Move json output to new script

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agocpu-parse: Move xml output to new script
Tim Wiederhake [Tue, 15 Dec 2020 16:25:06 +0000 (17:25 +0100)]
cpu-parse: Move xml output to new script

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agocpu-parse: Move file name generation to new script
Tim Wiederhake [Tue, 15 Dec 2020 16:25:05 +0000 (17:25 +0100)]
cpu-parse: Move file name generation to new script

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agocpu-parse: Move model name detection to new script
Tim Wiederhake [Tue, 15 Dec 2020 16:25:04 +0000 (17:25 +0100)]
cpu-parse: Move model name detection to new script

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agocpu-gather: Transport data as json
Tim Wiederhake [Tue, 15 Dec 2020 16:25:03 +0000 (17:25 +0100)]
cpu-gather: Transport data as json

More reliable, easier to parse, easier to edit.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agocpu-parse: Wrap with python script
Tim Wiederhake [Tue, 15 Dec 2020 16:25:02 +0000 (17:25 +0100)]
cpu-parse: Wrap with python script

This changes the invocation from
  ./cpu-gather.py | ./cpu-parse.sh
to
  ./cpu-gather.py [--gather] | ./cpu-gather.py --parse

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agocpu-gather: Separate data input and output
Tim Wiederhake [Tue, 15 Dec 2020 16:25:01 +0000 (17:25 +0100)]
cpu-gather: Separate data input and output

This is a preparatory step to replace the output format with
something more readable.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agocpu-gather: Delete old script
Tim Wiederhake [Tue, 15 Dec 2020 16:25:00 +0000 (17:25 +0100)]
cpu-gather: Delete old script

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agocpu-gather: Merge model gathering logic
Tim Wiederhake [Tue, 15 Dec 2020 16:24:59 +0000 (17:24 +0100)]
cpu-gather: Merge model gathering logic

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agocpu-gather: Move full model extraction to new script
Tim Wiederhake [Tue, 15 Dec 2020 16:24:58 +0000 (17:24 +0100)]
cpu-gather: Move full model extraction to new script

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agocpu-gather: Move simple model extraction to new script
Tim Wiederhake [Tue, 15 Dec 2020 16:24:57 +0000 (17:24 +0100)]
cpu-gather: Move simple model extraction to new script

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agocpu-gather: Move static model extraction to new script
Tim Wiederhake [Tue, 15 Dec 2020 16:24:56 +0000 (17:24 +0100)]
cpu-gather: Move static model extraction to new script

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agocpu-gather: Move static model expansion to new script
Tim Wiederhake [Tue, 15 Dec 2020 16:24:55 +0000 (17:24 +0100)]
cpu-gather: Move static model expansion to new script

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agocpu-gather: Move qemu detection to new script
Tim Wiederhake [Tue, 15 Dec 2020 16:24:54 +0000 (17:24 +0100)]
cpu-gather: Move qemu detection to new script

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agocpu-gather: Move msr decoding to new script
Tim Wiederhake [Tue, 15 Dec 2020 16:24:53 +0000 (17:24 +0100)]
cpu-gather: Move msr decoding to new script

Fixes the leaking file descriptors. Does not silently ignore errors
(e.g. permission denied on /dev/cpu/0/msr if run as non-root) and
always attempt to read from /dev/kvm if /dev/cpu/0/msr failed.

'gather_msr()' returns a dictionary of values, as a later patch will
add more registers to be interrogated.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agocpu-gather: Allow overwriting cpuid binary location
Tim Wiederhake [Tue, 15 Dec 2020 16:24:52 +0000 (17:24 +0100)]
cpu-gather: Allow overwriting cpuid binary location

This is useful if cpuid was compiled from source in a non-standard
location.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agocpu-gather: Move cpuid call to new script
Tim Wiederhake [Tue, 15 Dec 2020 16:24:51 +0000 (17:24 +0100)]
cpu-gather: Move cpuid call to new script

Turn the comment on how to aquire cpuid into a runtime error message.
Use "http" instead of "https" in the URL, as the latter is broken.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agocpu-gather: Allow overwriting model name
Tim Wiederhake [Tue, 15 Dec 2020 16:24:50 +0000 (17:24 +0100)]
cpu-gather: Allow overwriting model name

Some hardware, e.g. exotic platforms or pre-production hardware, may
report wrong or random data for the cpu model name. As the name of
the created files is derived from that name, this may lead to issues.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agocpu-gather: Move model_name to new script
Tim Wiederhake [Tue, 15 Dec 2020 16:24:49 +0000 (17:24 +0100)]
cpu-gather: Move model_name to new script

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agocpu-gather: Create python wrapper for shell script
Tim Wiederhake [Tue, 15 Dec 2020 16:24:48 +0000 (17:24 +0100)]
cpu-gather: Create python wrapper for shell script

This changes the invocation from
  ./cpu-gather.sh | ./cpu-parse.sh
to
  ./cpu-gather.py | ./cpu-parse.sh

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 agocpu-cpuid: Shorten overly long line
Tim Wiederhake [Tue, 15 Dec 2020 16:24:47 +0000 (17:24 +0100)]
cpu-cpuid: Shorten overly long line

flake8 was complaining.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoschema: Allow counter element in host cpu definition
Tim Wiederhake [Tue, 15 Dec 2020 12:16:48 +0000 (13:16 +0100)]
schema: Allow counter element in host cpu definition

If the capabilities include a counter element, e.g.
  <counter name='tsc' frequency='2591999000' scaling='no'/>
the XML could not be validated:
  $ virsh capabilities > cap.xml
  $ virsh [hypervisor-]cpu-compare cap.xml --validate
  error: Failed to compare hypervisor CPU with cap.txt
  error: XML document failed to validate against schema: Unable to validate doc against /usr/share/libvirt/schemas/cpu.rng
  Did not expect element counter there

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoschemas: Deduplicate cpuTopology in cputypes.rng
Tim Wiederhake [Tue, 15 Dec 2020 12:16:47 +0000 (13:16 +0100)]
schemas: Deduplicate cpuTopology in cputypes.rng

The duplicate had the "dies" attribute missing, causing
  $ virsh capabilities > cap.xml
  $ virsh [hypervisor-]cpu-compare cap.xml --validate
to fail with
  error: Failed to compare hypervisor CPU with cap.xml
  error: XML document failed to validate against schema: Unable to validate doc against /usr/share/libvirt/schemas/cpu.rng
  Invalid attribute dies for element topology

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>