]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
4 years agosrc: make virObject inherit from GObject
Daniel P. Berrangé [Tue, 19 May 2020 15:15:51 +0000 (16:15 +0100)]
src: make virObject inherit from GObject

To avoid bugs with mixing of g_object_(ref|unref) vs
virObject(Ref|Unref), we want every virObject to be
a GObject.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agosrc: don't use VIR_FREE on an object allocation
Daniel P. Berrangé [Tue, 19 May 2020 14:55:55 +0000 (15:55 +0100)]
src: don't use VIR_FREE on an object allocation

Memory allocated using g_object_new must never be released using
VIR_FREE/g_free because g_object_new uses a special allocation
strategy internally.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agosrc: don't include ref count in debug messages / probes
Daniel P. Berrangé [Tue, 19 May 2020 14:55:01 +0000 (15:55 +0100)]
src: don't include ref count in debug messages / probes

The ref count will be private to the GObject base class
and we must not peek at it, even for debugging messages.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agotest: allocate numa cells separately from driver
Daniel P. Berrangé [Tue, 19 May 2020 14:51:49 +0000 (15:51 +0100)]
test: allocate numa cells separately from driver

GObject has an arbitrary limit on the object struct size of 0xffff
bytes. It is expected that any large fields be separately allocated.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agosrc: make virObjectUnref return void
Daniel P. Berrangé [Fri, 15 May 2020 15:36:00 +0000 (16:36 +0100)]
src: make virObjectUnref return void

To prepare for a conversion to GObject, we need virObjectUnref
to have the same API design as g_object_unref, which means it
needs to be void.

A few places do actually care about the return value though,
and in these cases a thread local flag is used to determine
if the dispose method was invoked.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: stop checking virObjectUnref return value
Daniel P. Berrangé [Fri, 15 May 2020 15:33:43 +0000 (16:33 +0100)]
qemu: stop checking virObjectUnref return value

Some, but not all, of the monitor event handlers check
the virObjectUnref return value to see if the domain
was disposed.

It should not be possible for this to happen, since
the function already holds a lock on the domain and
has only just acquired an extra reference on the
domain a few lines earlier.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agolxc: replace VIR_ALLOC/REALLOC with g_new0/renew
Daniel P. Berrangé [Tue, 12 May 2020 17:31:16 +0000 (18:31 +0100)]
lxc: replace VIR_ALLOC/REALLOC with g_new0/renew

Reviewed-by: Laine Stump <laine@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agolxc: replace VIR_FREE with g_autofree / g_free
Daniel P. Berrangé [Tue, 12 May 2020 16:53:07 +0000 (17:53 +0100)]
lxc: replace VIR_FREE with g_autofree / g_free

Reviewed-by: Laine Stump <laine@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: Skip pre-creation of NVMe disks
Michal Privoznik [Tue, 26 May 2020 14:26:25 +0000 (16:26 +0200)]
qemu: Skip pre-creation of NVMe disks

Upon migration with disks, libvirt determines if each disk exists
on the destination and tries to pre-create missing ones. Well,
NVMe disks can't be pre-created, but they can be checked for
presence.

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

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agodocs: use multiple header levels in virtiofs doc
Daniel P. Berrangé [Mon, 1 Jun 2020 11:45:39 +0000 (12:45 +0100)]
docs: use multiple header levels in virtiofs doc

The heading overline should only be used for the overall document title,
any subsequent headings should be underline only.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agomaint: Post-release version bump to 6.5.0
Andrea Bolognani [Tue, 2 Jun 2020 09:20:16 +0000 (11:20 +0200)]
maint: Post-release version bump to 6.5.0

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
4 years agonews: Update for libvirt 6.4.0
Andrea Bolognani [Mon, 1 Jun 2020 18:43:26 +0000 (20:43 +0200)]
news: Update for libvirt 6.4.0

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoRelease of libvirt 6.4.0
Daniel Veillard [Tue, 2 Jun 2020 08:31:53 +0000 (10:31 +0200)]
Release of libvirt 6.4.0

* docs/news.xml: update for release date

Signed-off-by: Daniel Veillard <veillard@redhat.com>
4 years agoqemu: hotplug: Fix the condition check for net->downscript
Liao Pingfang [Fri, 29 May 2020 15:52:24 +0000 (23:52 +0800)]
qemu: hotplug: Fix the condition check for net->downscript

According to the context, here we are checking net->downscript's validity,

Signed-off-by: Liao Pingfang <liao.pingfang@zte.com.cn>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agodocs: Fixed incorrect XML attribute name in virtio kbase
Jaak Ristioja [Fri, 29 May 2020 20:41:40 +0000 (23:41 +0300)]
docs: Fixed incorrect XML attribute name in virtio kbase

Signed-off-by: Jaak Ristioja <jaak@ristioja.ee>
4 years agonews: Document 'netdev_add' regression and disk type='lun' changes
Peter Krempa [Thu, 28 May 2020 08:26:34 +0000 (10:26 +0200)]
news: Document 'netdev_add' regression and disk type='lun' changes

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agosecurity: don't fail if built without attr support
Christian Ehrhardt [Tue, 26 May 2020 07:33:38 +0000 (09:33 +0200)]
security: don't fail if built without attr support

If built without attr support removing any image will trigger
 qemuBlockRemoveImageMetadata (the one that emits the warning)
   -> qemuSecurityMoveImageMetadata
     -> virSecurityManagerMoveImageMetadata
       -> virSecurityDACMoveImageMetadata
         -> virSecurityDACMoveImageMetadataHelper
           -> virProcessRunInFork (spawns subprocess)
             -> virSecurityMoveRememberedLabel

In there due to !HAVE_LIBATTR virFileGetXAttrQuiet will return
ENOSYS and from there the chain will error out.

That is wrong and looks like:
  libvirtd[6320]: internal error: child reported (status=125):
  libvirtd[6320]: Unable to remove disk metadata on vm testguest from
  /var/lib/uvtool/libvirt/images/testguest.qcow (disk target vda)

This change makes virSecurityDACMoveImageMetadataHelper and
virSecuritySELinuxMoveImageMetadataHelper accept that
error code gracefully and in that sense it is an extension of:
5214b2f1a3f "security: Don't skip label restore on file systems lacking XATTRs"
which does the same for other call chains into the virFile*XAttr functions.

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agonews: add description about downscript
Chen Hanxiao [Tue, 26 May 2020 00:41:01 +0000 (20:41 -0400)]
news: add description about downscript

Signed-off-by: Chen Hanxiao <chen_han_xiao@126.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agodownscript: add support for booting and hotplug interface
Chen Hanxiao [Tue, 26 May 2020 00:41:00 +0000 (20:41 -0400)]
downscript: add support for booting and hotplug interface

Support downscript for booting vm,
and hotunplug interface device.

Signed-off-by: Chen Hanxiao <chen_han_xiao@126.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agointerface: introduce downscript element for interface
Chen Hanxiao [Tue, 26 May 2020 00:40:59 +0000 (20:40 -0400)]
interface: introduce downscript element for interface

https://gitlab.com/libvirt/libvirt/-/issues/13

Add support for downscript:

<interface type='ethernet'>
    <mac address='00:11:22:33:44:55'/>
    <script path='/etc/qemu-ifup'/>
    <downscript path='/path/to/my/downscript'/>
</interface>

Signed-off-by: Chen Hanxiao <chen_han_xiao@126.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agocpu_map: Distribute x86_Cooperlake.xml
Jiri Denemark [Tue, 26 May 2020 10:52:00 +0000 (12:52 +0200)]
cpu_map: Distribute x86_Cooperlake.xml

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoscripts: Fix E741 that pycodesyle is pointing out during syntax-check
Erik Skultety [Mon, 25 May 2020 12:46:26 +0000 (14:46 +0200)]
scripts: Fix E741 that pycodesyle is pointing out during syntax-check

With newer pycodestyle 2.6.0 (which is part of flake8-3.8.2) reports
the following pep violation during syntax-check:

../scripts/check-remote-protocol.py:95:9: E741 ambiguous variable name 'l'
    for l in err.strip().split("\n")

On all the distros we test on, this hasn't occurred yet, but with the
future update of flake8 it likely would. The fix is easy, just name the
variable appropriately.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agocpu_map: Add Cooperlake x86 CPU model
Jiri Denemark [Tue, 19 May 2020 13:08:11 +0000 (15:08 +0200)]
cpu_map: Add Cooperlake x86 CPU model

The stepping range (10-11) is likely incomplete. QEMU uses 10 and the
CPUID data for Cooperlake show 11. We will update the range if needed
once more details about he CPU are available.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agocpu_map: Add pschange-mc-no bit in IA32_ARCH_CAPABILITIES MSR
Jiri Denemark [Mon, 18 May 2020 18:55:42 +0000 (20:55 +0200)]
cpu_map: Add pschange-mc-no bit in IA32_ARCH_CAPABILITIES MSR

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agocputest: Add data for Cooperlake CPU
Jiri Denemark [Tue, 19 May 2020 18:18:12 +0000 (20:18 +0200)]
cputest: Add data for Cooperlake CPU

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoqemuProcessRefreshCPU: skip 'host-model' logic for pSeries guests
Daniel Henrique Barboza [Mon, 25 May 2020 12:39:45 +0000 (09:39 -0300)]
qemuProcessRefreshCPU: skip 'host-model' logic for pSeries guests

Commit v3.10.0-182-g237f045d9a ("qemu: Ignore fallback CPU attribute
on reconnect") forced CPU 'fallback' to ALLOW, regardless of user
choice. This fixed a situation in which guests created with older
Libvirt versions, which used CPU mode 'host-model' in runtime, would
fail to launch in a newer Libvirt if the fallback was set to FORBID.
This would lead to a scenario where the CPU was translated to 'host-model'
to 'custom', but then the FORBID setting would make the translation
process fail.

PSeries can operate with 'host-model' in runtime due to specific PPC64
mechanics regarding compatibility mode. The update() implementation of
the cpuDriverPPC64 driver is a NO-OP if CPU mode is 'host-model', and
the driver does not implement translate(). The commit mentioned above
is causing PSeries guests to get their 'fallback' setting to ALLOW,
overwriting user choice, exposing a design problem in
qemuProcessRefreshCPU() - for PSeries guests, handling 'host-model'
as it is being done does not apply.

All other cpuArchDrivers implements update() and changes guest mode
to VIR_CPU_MODE_CUSTOM, meaning that PSeries is currently the only
exception to this logic. Let's make it official.

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

Suggested-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20200525123945.4049591-2-danielhb413@gmail.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agoqemu: Invalidate capabilities when host CPU changes
Jiri Denemark [Fri, 15 May 2020 20:00:29 +0000 (22:00 +0200)]
qemu: Invalidate capabilities when host CPU changes

The host CPU related info stored in the capabilities cache is no longer
valid after the host CPU changes. This is not a frequent situation in
real world, but it can easily happen in nested scenarios when a disk
image is started with various CPUs.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agohostcpu: Implement virHostCPUGetSignature for s390
Jiri Denemark [Mon, 20 Apr 2020 13:48:13 +0000 (15:48 +0200)]
hostcpu: Implement virHostCPUGetSignature for s390

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
4 years agohostcpu: Implement virHostCPUGetSignature for ppc64
Jiri Denemark [Thu, 2 Apr 2020 20:35:30 +0000 (22:35 +0200)]
hostcpu: Implement virHostCPUGetSignature for ppc64

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agohostcpu: Implement virHostCPUGetSignature for x86
Jiri Denemark [Wed, 1 Apr 2020 17:55:27 +0000 (19:55 +0200)]
hostcpu: Implement virHostCPUGetSignature for x86

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agohostcpu: Introduce virHostCPUGetSignature
Jiri Denemark [Tue, 31 Mar 2020 22:44:00 +0000 (00:44 +0200)]
hostcpu: Introduce virHostCPUGetSignature

The purpose of this function is to give a short description that would
be change when a host CPU is replaced with a different model. This is
currently implemented by reading /proc/cpuinfo.

It should be implemented for all architectures for which the QEMU driver
stores host CPU data in the capabilities cache. In other words for archs
that support host-model CPUs.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoutil: Define g_autoptr callback for FILE
Jiri Denemark [Tue, 31 Mar 2020 23:01:27 +0000 (01:01 +0200)]
util: Define g_autoptr callback for FILE

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu_process.c: modernize qemuProcessUpdateCPU code path
Daniel Henrique Barboza [Fri, 22 May 2020 19:56:19 +0000 (16:56 -0300)]
qemu_process.c: modernize qemuProcessUpdateCPU code path

Use automatic cleanup on qemuProcessUpdateCPU and the functions called
by it.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20200522195620.3843442-5-danielhb413@gmail.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agocpu_s390.c: modernize virCPUs390Update
Daniel Henrique Barboza [Fri, 22 May 2020 19:56:18 +0000 (16:56 -0300)]
cpu_s390.c: modernize virCPUs390Update

Use automatic cleanup of variables.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20200522195620.3843442-4-danielhb413@gmail.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agocpu_arm.c: modernize virCPUarmUpdate
Daniel Henrique Barboza [Fri, 22 May 2020 19:56:17 +0000 (16:56 -0300)]
cpu_arm.c: modernize virCPUarmUpdate

Use automatic cleanup of variables.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20200522195620.3843442-3-danielhb413@gmail.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agocpu_conf.c: modernize virCPUDefCopyWithoutModel and virCPUDefCopy
Daniel Henrique Barboza [Fri, 22 May 2020 19:56:16 +0000 (16:56 -0300)]
cpu_conf.c: modernize virCPUDefCopyWithoutModel and virCPUDefCopy

Use automatic cleanup of variables.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20200522195620.3843442-2-danielhb413@gmail.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agodocs: Fix a typo in formatdomain.html
Han Han [Fri, 22 May 2020 10:25:52 +0000 (18:25 +0800)]
docs: Fix a typo in formatdomain.html

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoscripts: emit raw enum value in API build description
Daniel P. Berrangé [Tue, 19 May 2020 11:32:19 +0000 (12:32 +0100)]
scripts: emit raw enum value in API build description

Currently the value for an enum is only emitted if it is a plain
string. If the enum is an integer or hex value, or a complex code block,
it is omitted from the API build. This fixes that by emitting the raw
value if no string value is present.

With this change:

  <macro name='LIBVIR_CHECK_VERSION'
         file='libvirt-common'
         params='major,minor,micro'>
  <macro name='LIBVIR_VERSION_NUMBER'
         file='libvirt-common'>
  <macro name='VIR_COPY_CPUMAP'
         file='libvirt-domain'
         params='cpumaps,maplen,vcpu,cpumap'>
  ...snip...

  <macro name='LIBVIR_CHECK_VERSION'
         file='libvirt-common'
         params='major,minor,micro'
         raw='((major) * 1000000 + (minor) * 1000 + (micro) <= LIBVIR_VERSION_NUMBER)'>
  <macro name='LIBVIR_VERSION_NUMBER'
         file='libvirt-common'
         raw='6004000'>
  <macro name='VIR_COPY_CPUMAP'
         file='libvirt-domain'
         params='cpumaps,maplen,vcpu,cpumap'
         raw='memcpy(cpumap, VIR_GET_CPUMAP(cpumaps, maplen, vcpu), maplen)'>
  ...snip...

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoscripts: emit enum parameters in API build description
Daniel P. Berrangé [Tue, 19 May 2020 11:30:57 +0000 (12:30 +0100)]
scripts: emit enum parameters in API build description

Currently the information about enums in the API document lacks any
mention of parameters, so it is impossible to tell what kind of enum
declaration is present in the libvirt API header. With this change

  <macro name='LIBVIR_CHECK_VERSION' file='libvirt-common'>
  <macro name='VIR_COPY_CPUMAP' file='libvirt-domain'>
  ...snip...

becomes

  <macro name='LIBVIR_CHECK_VERSION' file='libvirt-common' params='major,minor,micro'>
  <macro name='VIR_COPY_CPUMAP' file='libvirt-domain' params='cpumaps,maplen,vcpu,cpumap'>
  ...snip...

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoscripts: fix tokenizing of enum parameters in API builder
Daniel P. Berrangé [Tue, 19 May 2020 11:27:15 +0000 (12:27 +0100)]
scripts: fix tokenizing of enum parameters in API builder

The API build script tokenizes enums declarations by first splitting on
whitespace. This is unhelpful as it means an enum

 # define VIR_USE_CPU(cpumap, cpu) ((cpumap)[(cpu) / 8] |= (1 << ((cpu) % 8)))

Gets tokenized as

  #define
  VIR_USE_CPU(cpumap,
  cpu)
  ((cpumap)[(cpu)
  /
  8]
  |=
  (1
  <<
  ((cpu)
  %
  8)))

With this change, the set of parameters are all merged into the first
token:

  #define
  VIR_USE_CPU(cpumap,cpu)
  ((cpumap)[(cpu)
  /
  8]
  |=
  (1
  <<
  ((cpu)
  %
  8)))

which is more convenient to process later on in the script.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoscripts: use UTF-8 for API XML files
Daniel P. Berrangé [Tue, 19 May 2020 11:25:21 +0000 (12:25 +0100)]
scripts: use UTF-8 for API XML files

The build system will be running in UTF-8 locale, so any content in the
API XML files will also end up being UTF-8, not ISO-8859-1.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agodocs: Document full node device xml in formatnode.html.in
Jonathon Jongsma [Thu, 21 May 2020 20:09:35 +0000 (15:09 -0500)]
docs: Document full node device xml in formatnode.html.in

Some of the node device xml schema was documented in drvnodedev.html.in
rather than in formatnode.html.in. Move all of the schema documentation
to formatnode.html.in and provide reference links from the
drvnodedev.html.in page.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agodocs: Fix names for PF and VF PCI device capabilities
Jonathon Jongsma [Thu, 21 May 2020 20:09:34 +0000 (15:09 -0500)]
docs: Fix names for PF and VF PCI device capabilities

The proper name for physical function capability is 'phys_function', not
'physical_function'. Likewise, a virtual function capability is
'virt_functions' rather than 'virtual_function'.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agodocs: drvnodedev: Fix a few closing XML elements in the examples
Erik Skultety [Fri, 22 May 2020 09:53:59 +0000 (11:53 +0200)]
docs: drvnodedev: Fix a few closing XML elements in the examples

Signed-off-by: Erik Skultety <eskultet@redhat.com>
4 years agotestCompareXMLToArgvValidateSchema: Construct @vm from scratch
Michal Privoznik [Thu, 21 May 2020 18:55:01 +0000 (20:55 +0200)]
testCompareXMLToArgvValidateSchema: Construct @vm from scratch

Currently, the @vm is passed in as an argument and
testCompareXMLToArgvCreateArgs() is called over it which means
under the hood qemuProcessPrepareDomain() is called. But at the
point where ValidateSchema() is called, the domain object is
already 'prepared', i.e. all device aliases are assigned and so
on. But our code is not prepared to 'prepare' a domain twice - it
simply overwrites all the pointers leading to a memory leak.

Fortunately, this is only the problem of this test.

Resolve this by constructing the domain object from scratch.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemu: only return two values in virQEMUDriverConfigLoadMemoryEntry
Ján Tomko [Mon, 18 May 2020 13:23:46 +0000 (15:23 +0200)]
qemu: only return two values in virQEMUDriverConfigLoadMemoryEntry

The intention of these split Load*Entry functions is to prevent
virQEMUDriverConfigLoadFile from getting too large.

There's no need to signal to the caller whether an entry was found
or not, only whether there was an error.

Remove the non-standard return 1.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoqemu: do not leak the directory in virQEMUDriverConfigLoadMemoryEntry
Ján Tomko [Mon, 18 May 2020 13:23:09 +0000 (15:23 +0200)]
qemu: do not leak the directory in virQEMUDriverConfigLoadMemoryEntry

virConfGetValueString returns an allocated string that needs to be
freed.

Fixes: 34a59fb570dcc1b6b4b4cef1f0eb43fc6f688120
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agologging.html.in: fix number of output formats available
Daniel Henrique Barboza [Tue, 19 May 2020 21:41:30 +0000 (18:41 -0300)]
logging.html.in: fix number of output formats available

There are 4 formats available (x:stderr, x:syslog:name,
x:file:file_path, x:journald), not 3. Use "the following"
instead of the actual number to avoid the need to update
the number every time a new form is added/removed.

Suggested-by: Pino Toscano <ptoscano@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
4 years agoqemuxml2argvtest: Add QAPI/QMP schema validation for -blockdev and -netdev
Peter Krempa [Fri, 15 May 2020 12:33:10 +0000 (14:33 +0200)]
qemuxml2argvtest: Add QAPI/QMP schema validation for -blockdev and -netdev

Our hotplug test cases are weak in comparison to the qemuxml2argvtest.
Use all the the input data to also validate the arguments for -netdev
and -blockdev against the appropriate commands of the QMP schema.

Note that currently it's done just for the _CAPS versions of tests but
commenting out a line in the test file allows to validate even cases
which don't use real capabilities.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agotestutilsqemuschema: Allow loading non-latest schema
Peter Krempa [Fri, 15 May 2020 14:32:40 +0000 (16:32 +0200)]
testutilsqemuschema: Allow loading non-latest schema

Add testQEMUSchemaLoad and refactor internals so that we can load the
QMP schema from an arbitrary caps replies file.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agotestQEMUSchemaLoad: Rename to testQEMUSchemaLoadLatest
Peter Krempa [Fri, 15 May 2020 14:21:25 +0000 (16:21 +0200)]
testQEMUSchemaLoad: Rename to testQEMUSchemaLoadLatest

It always loads the latest schema. Prepare for loading others as well.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agoqemu: Prepare for testing of 'netdev_add' props via qemuxml2argvtest
Peter Krempa [Fri, 15 May 2020 12:24:21 +0000 (14:24 +0200)]
qemu: Prepare for testing of 'netdev_add' props via qemuxml2argvtest

qemuxml2argv test suite is way more comprehensive than the hotplug
suite. Since we share the code paths for monitor and command line
hotplug we can easily test the properties of devices against the QAPI
schema.

To achieve this we'll need to skip the JSON->commandline conversion for
the test run so that we can analyze the pure properties. This patch adds
flags for the comand line generator and hook them into the
JSON->commandline convertor for -netdev. An upcoming patch will make use
of this new infrastructure.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agoqemuMonitorAddNetdev: Convert to the native JSON props object
Peter Krempa [Fri, 15 May 2020 09:36:28 +0000 (11:36 +0200)]
qemuMonitorAddNetdev: Convert to the native JSON props object

Now that all code paths generate JSON props we can remove the conversion
to command line arguments and back in the monitor code.

Note that the test which is removed in this commit will be replaced by a
stronger testsuite later.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agoqemuBuildChannelGuestfwdNetdevProps: Convert to generating JSON props
Peter Krempa [Fri, 15 May 2020 07:46:08 +0000 (09:46 +0200)]
qemuBuildChannelGuestfwdNetdevProps: Convert to generating JSON props

Syntax of guestfwd channel also needs to be modified to conform to the
QAPI schema.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agovirQEMUBuildNetdevCommandlineFromJSON: Prepare for quirky 'guestfwd'
Peter Krempa [Fri, 15 May 2020 08:59:40 +0000 (10:59 +0200)]
virQEMUBuildNetdevCommandlineFromJSON: Prepare for quirky 'guestfwd'

QEMU models guestfwd as:

 'guestfwd': [
                 { "str": "tcp:10.0.2.1:4600-chardev:charchannel0" },
                 { "str": "...."},
             ]

but the command line as:

guestfwd=tcp:10.0.2.1:4600-chardev:charchannel0,guestfwd=...

I guess the original idea was to make it extensible while not worrying
about adding another object for it. Either way it requires us to add yet
another JSON->cmdline convertor for arrays.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agoqemu: command: Generate -netdev command line via JSON->cmdline conversion
Peter Krempa [Thu, 14 May 2020 20:50:59 +0000 (22:50 +0200)]
qemu: command: Generate -netdev command line via JSON->cmdline conversion

The 'netdev_add' command was recently formally described in qemu via the
QMP schema. This means that it also requires the arguments to be
properly formatted. Our current approach is to generate the command line
and then use qemuMonitorJSONKeywordStringToJSON to get the JSON
properties for the monitor. This will not work if we need to pass some
fields as numbers or booleans.

In this step we re-do internals of qemuBuildHostNetStr to format a JSON
object which is converted back via virQEMUBuildNetdevCommandlineFromJSON
to the equivalent command line. This will later allow fixing of the
monitor code to use the JSON object directly rather than rely on the
conversion.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agoutil: virqemu: Introduce virQEMUBuildNetdevCommandlineFromJSON
Peter Krempa [Thu, 14 May 2020 08:10:16 +0000 (10:10 +0200)]
util: virqemu: Introduce virQEMUBuildNetdevCommandlineFromJSON

In preparation for converting the generator of -netdev to generate JSON
which will be used to do the command line rather than the other way
around we need to introduce a convertor which properly configures
virQEMUBuildCommandLineJSON for the quirks of -netdev.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agoqemuMonitorJSON(Add|Remove)Netdev: Refactor cleanup
Peter Krempa [Fri, 15 May 2020 09:16:32 +0000 (11:16 +0200)]
qemuMonitorJSON(Add|Remove)Netdev: Refactor cleanup

Use automatic pointer cleanup for virJSONValuePtrs to get rid of the
cleanup label and ret variable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agotestCompareXMLToArgv: Split out preparation and command formatting
Peter Krempa [Fri, 15 May 2020 06:50:31 +0000 (08:50 +0200)]
testCompareXMLToArgv: Split out preparation and command formatting

There are multiple steps of setting up the domain definition prior to
formatting the command line for the tests. Extract it to a separate
function so that it's self-contained and also will allow re-running the
command line formatting which will be necessary for QMP schema
validation tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agoutil: json: Introduce virJSONValueObjectAppendStringPrintf
Peter Krempa [Thu, 14 May 2020 06:09:56 +0000 (08:09 +0200)]
util: json: Introduce virJSONValueObjectAppendStringPrintf

Add a variant similar to virJSONValueObjectAppendString which also
formats more complex value strings with printf syntax.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agovirCommand: Introduce virCommandGetArgList
Peter Krempa [Wed, 13 May 2020 15:55:21 +0000 (17:55 +0200)]
virCommand: Introduce virCommandGetArgList

The helper returns a list of arguments of a virCommand. This will be
useful in tests where we'll inspect certain already formatted arguments.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agovirQEMUBuildCommandLineJSON: Add possibility for using 'on/off' instead of 'yes/no'
Peter Krempa [Thu, 14 May 2020 20:45:24 +0000 (22:45 +0200)]
virQEMUBuildCommandLineJSON: Add possibility for using 'on/off' instead of 'yes/no'

In some cases we use 'on/off' for command line arguments. Add a switch
which will select the preferred spelling for a specific usage.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agovirQEMUBuildCommandLineJSON: Allow skipping certain keys
Peter Krempa [Thu, 14 May 2020 07:41:48 +0000 (09:41 +0200)]
virQEMUBuildCommandLineJSON: Allow skipping certain keys

Allow reusing this for formatting of netdev_add arguments into -netdev.
We need to be able to skip the 'type' property as it's used without the
prefix by our generator.

Add infrastructure which allows skipping property with a specific name.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agoqemuBuildHostNetStr: Stop using 'ipv6-net' convenience argument
Peter Krempa [Thu, 14 May 2020 10:02:55 +0000 (12:02 +0200)]
qemuBuildHostNetStr: Stop using 'ipv6-net' convenience argument

In qemu the argument of 'ipv6-net' is split up into 'ipv6-prefix' and
'ipv6-prefixlen'. Additionally now that 'netdev_add' was qapified, only
the real properties are allowed. Switch to using them explicitly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agoqemuBuildChannelChrDeviceStr: Remove formatting of properties for -netdev
Peter Krempa [Thu, 14 May 2020 11:01:59 +0000 (13:01 +0200)]
qemuBuildChannelChrDeviceStr: Remove formatting of properties for -netdev

The output of the function is fed as argument to '-device' command line
argument or 'device_add' monitor command except for 'guestfwd' channels
where it needs to be fed to -netdev/netdev_add. This is confusing and
error prone. Split it up since the caller needs to know which
command/option to use anyways, so the caller can call the appropriate
function without any magic.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agoqemuBuildChannelsCommandLine: Extract common formatting of 'chardev'
Peter Krempa [Thu, 14 May 2020 10:51:21 +0000 (12:51 +0200)]
qemuBuildChannelsCommandLine: Extract common formatting of 'chardev'

Both active branches create the same backend chardev. Since there is no
other case, extract it before the switch so that we don't have to
duplicate it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agoqemuBuildChannelsCommandLine: Use typecasted switch for channel type
Peter Krempa [Thu, 14 May 2020 10:32:55 +0000 (12:32 +0200)]
qemuBuildChannelsCommandLine: Use typecasted switch for channel type

Cover all cases of the enum.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agoqemuMonitorJSONParseKeywords: remove constant argument
Peter Krempa [Wed, 13 May 2020 18:54:24 +0000 (20:54 +0200)]
qemuMonitorJSONParseKeywords: remove constant argument

There's just one caller that always passes '1'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agoqemu: domain: Forbid unsupported 'tftp' protocol and handle tests
Peter Krempa [Wed, 13 May 2020 18:41:45 +0000 (20:41 +0200)]
qemu: domain: Forbid unsupported 'tftp' protocol and handle tests

'tftp' storage protocol was supported by qemu until 2.7.0. Add an
interlock when blockdev is used and drop the test case for it as it's
IMO not worth adding another test file just for that.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agotestQEMUSchemaValidate*: Reject usage of fields with 'deprecated' set
Peter Krempa [Wed, 4 Mar 2020 08:02:54 +0000 (09:02 +0100)]
testQEMUSchemaValidate*: Reject usage of fields with 'deprecated' set

Make our QMP schema validator reject any use of schema entries which
were deprecated by QEMU except for those whitelisted.

This will allow us to catch this before qemu actually removed what we'd
still use.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemumonitorjsontest: Mark recently deprecated migration command in our tests
Peter Krempa [Wed, 29 Apr 2020 18:02:28 +0000 (20:02 +0200)]
qemumonitorjsontest: Mark recently deprecated migration command in our tests

"migrate_set_downtime", "migrate_set_speed", and
"query-migrate-cache-size" were marked as deprecated in the QMP schema
in qemu 5.0. Since libvirt still actively uses them we must not mark
them as okay to be missing, but still mark them as deprecated, so that
we can add tests for deprecated commands.

The replacement of the command usage in libvirt is tracked by:
https://bugzilla.redhat.com/show_bug.cgi?id=1829543
https://bugzilla.redhat.com/show_bug.cgi?id=1829544
https://bugzilla.redhat.com/show_bug.cgi?id=1829545

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemumonitorjsontest: Allow use of deprecated 'cpu-add' and 'change' command
Peter Krempa [Wed, 29 Apr 2020 17:59:51 +0000 (19:59 +0200)]
qemumonitorjsontest: Allow use of deprecated 'cpu-add' and 'change' command

Modify the generated test cases for the 'cpu-add' and 'change' command
which are deprecated by qemu. We now use device-add and
blockdev-change-media instead so we are okay if they will be removed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemumonitorjsontest: Allow use of deprecated 'query-cpus'
Peter Krempa [Wed, 29 Apr 2020 17:57:28 +0000 (19:57 +0200)]
qemumonitorjsontest: Allow use of deprecated 'query-cpus'

The command was replaced with 'query-cpus-fast' which is always used
when detected by the capabilities so we can allow our test usage of
the deprecated command even if it will be removed from the schema.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agotestQemuMonitorJSONqemuMonitorJSONQueryCPUs: Split off test for query-cpus-fast
Peter Krempa [Wed, 29 Apr 2020 17:47:36 +0000 (19:47 +0200)]
testQemuMonitorJSONqemuMonitorJSONQueryCPUs: Split off test for query-cpus-fast

Separate the test for the newer command into a new function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemumonitorjsontest: Add infrastructure for generated tests of deprecated commands
Peter Krempa [Wed, 29 Apr 2020 17:41:38 +0000 (19:41 +0200)]
qemumonitorjsontest: Add infrastructure for generated tests of deprecated commands

For sanity-chcecking of deprecated commands which are still used on some
old code paths which used the simple generated test cases add a
mechanism to mark them as deprecated so schema checking can be skipped.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agotestQemuHotplugCpuPrepare: Allow deprecated commands for non-modern cpu hotplug test
Peter Krempa [Wed, 29 Apr 2020 17:20:00 +0000 (19:20 +0200)]
testQemuHotplugCpuPrepare: Allow deprecated commands for non-modern cpu hotplug test

We have a few cases validating that the code behaves correctly in
pre-modern hotplug era. This is controled by the 'modern' flag for the
test. Since 'cpu-add' command is now deprecated in qemu, there is a
modern replacement for it, and the test output is checked against
expected commands we can skip schema validation for the legacy command.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agotestQEMUSchemaValidate(Command): Allow skipping validation of deprecated fields
Peter Krempa [Wed, 29 Apr 2020 15:52:43 +0000 (17:52 +0200)]
testQEMUSchemaValidate(Command): Allow skipping validation of deprecated fields

Some test cases are used to validate interactions with old qemu. We need
to skip validation of deprecation with those once it will be added.

In case of commands which were already replaced by code based on
capabilities we can skip the full validation once the command is
removed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agotestutilsqemuschema: Pass in 'schema' and 'debug' variables to workers in a struct
Peter Krempa [Wed, 29 Apr 2020 15:31:20 +0000 (17:31 +0200)]
testutilsqemuschema: Pass in 'schema' and 'debug' variables to workers in a struct

Refactor the code so that we pass in the repeated 'schema' and 'debug'
arguments via a new struct testQEMUSchemaValidateCtxt. This will
simplify adding new parameters in the future.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agotestutilsqemuschema: Use automatic variable clearing where possible
Peter Krempa [Wed, 29 Apr 2020 15:20:07 +0000 (17:20 +0200)]
testutilsqemuschema: Use automatic variable clearing where possible

Refactor all cleanup to avoid manual clearing, unnecessary labels and
return value variables.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemumonitortestutils: Introduce qemuMonitorTestSkipDeprecatedValidation
Peter Krempa [Wed, 29 Apr 2020 09:03:02 +0000 (11:03 +0200)]
qemumonitortestutils: Introduce qemuMonitorTestSkipDeprecatedValidation

Upcoming patches will add validation which rejects objects with the
'deprecated' feature in the QMP schema. To support tests which deal with
legacy properties in case when a command or argument is marked as
deprecated or removed by qemu qemuMonitorTestSkipDeprecatedValidation
will allow configuring the tests to ignore such errors.

In case of commands/features which are not yet replaced, the
'allowRemoved' bool should not be set to provide a hard notification
once qemu drops the command.

Note that at this point 'allowRemoved' only includes whole commands, but
not specific properties.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuMonitorTestProcessCommandDefaultValidate: Clean up return value use
Peter Krempa [Wed, 29 Apr 2020 08:38:16 +0000 (10:38 +0200)]
qemuMonitorTestProcessCommandDefaultValidate: Clean up return value use

We no longer return the error via the monitor, so the function no longer
returns '1'. Remove the mention from comment and fix callers to stop
looking for the return value of '1'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuMonitorTestProcessCommandDefaultValidate: Use testQEMUSchemaValidateCommand
Peter Krempa [Wed, 4 Mar 2020 09:22:25 +0000 (10:22 +0100)]
qemuMonitorTestProcessCommandDefaultValidate: Use testQEMUSchemaValidateCommand

Remove the ad-hoc command validation in favor of the new helper.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agotestutilsqemuschema: Introduce testQEMUSchemaValidateCommand
Peter Krempa [Wed, 4 Mar 2020 09:22:19 +0000 (10:22 +0100)]
testutilsqemuschema: Introduce testQEMUSchemaValidateCommand

The new helper splits out all steps necessary to validate a QMP command
against the schema.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agotestQemuHotplugCpuPrepare: Allow unused monitor commands only on failure
Peter Krempa [Wed, 29 Apr 2020 16:27:00 +0000 (18:27 +0200)]
testQemuHotplugCpuPrepare: Allow unused monitor commands only on failure

Only tests expected to fail should allow unused commads as the normal
tests will consume all of them.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoREADME.rst: Replace the installation instructions with link to compiling.html.
Liao Pingfang [Mon, 18 May 2020 11:59:22 +0000 (19:59 +0800)]
README.rst: Replace the installation instructions with link to compiling.html.

Remove the installation instructions from README.rst, and
add the link to compiling.html.

Signed-off-by: Liao Pingfang <liao.pingfang@zte.com.cn>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu: conf: fix stray comma
Ján Tomko [Tue, 19 May 2020 08:56:57 +0000 (10:56 +0200)]
qemu: conf: fix stray comma

The qemu.conf change broke our augeas test:

qemu/test_libvirtd_qemu.aug:96.3-203.1:exception thrown in test
qemu/test_libvirtd_qemu.aug:96.8-.34:exception: Iterated lens matched less than it should
    Lens: ../../src/qemu/libvirtd_qemu.aug:170.13-.43:
      Last match: ../../src/qemu/libvirtd_qemu.aug:18.52-.113:
      Not matching: ../../src/qemu/libvirtd_qemu.aug:12.19-.31:
    Error encountered at 48:27 (1615 characters into string)
    <\n    "/dev/ptmx", "/dev/kvm"|=|,\n]\nsave_image_format = "raw>

Fixes: ab5ba57012e9e6ab4f55afdeecd1813dd3ca916b
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: do not allow /dev/rtc or /dev/hpet access via the devices cgroup
Paolo Bonzini [Mon, 18 May 2020 23:06:59 +0000 (01:06 +0200)]
qemu: do not allow /dev/rtc or /dev/hpet access via the devices cgroup

The RTC and HPET modes for the QEMU emulation tick have been dropped
almost 9 years ago, in commit 25f3151ece1d5881826232bebccc21b588d4e03e.
Do not allow them in the devices cgroup policy.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu: prevent attempts to detach a device on a controller with hotplug='off'
Laine Stump [Thu, 14 May 2020 18:01:47 +0000 (14:01 -0400)]
qemu: prevent attempts to detach a device on a controller with hotplug='off'

Although the original patches to support controllers with
hotplug='off' were checking during hotplug/attach requests that the
device was being plugged into a PCI controller that didn't have
hotplug disabled, but I forgot to do the same for device detach (the
main impetus for adding the feature was to prevent unplugs originating
from within the guest, so it slipped my mind). So although the guest
OS was ultimately unable to honor the unplug request, libvirt could
still be used to make such a request, and since device attach/detach
are asynchronous operations, the caller to libvirt would receive a
success status back (the device would stubbornly/correctly remain in
the domain status XML however)

This patch remedies that, by looking at the controller for the device
in the detach request, and immediately failing the operation if that
controller has hotplug=off.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agoqemuProcessStop: Reattach NVMe disks a domain is mirroring into
Michal Privoznik [Mon, 18 May 2020 13:11:49 +0000 (15:11 +0200)]
qemuProcessStop: Reattach NVMe disks a domain is mirroring into

If the mirror destination is not a file but a NVMe disk, then
call qemuHostdevReAttachOneNVMeDisk() to reattach the NVMe back
to the host.

This would be done by blockjob code when the job finishes, but in
this case the job won't finish - QEMU is killed meanwhile.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1825785
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemuProcessStop: Use XATTRs to restore seclabels on disks a domain is mirroring into
Michal Privoznik [Mon, 18 May 2020 13:07:46 +0000 (15:07 +0200)]
qemuProcessStop: Use XATTRs to restore seclabels on disks a domain is mirroring into

In v5.10.0-rc1~42 (which was later fixed in v6.0.0-rc1~487) I am
removing XATTRs for a file that QEMU is mirroring a disk into but
it is killed meanwhile. Well, we can call
qemuSecurityRestoreImageLabel() which will not only remove XATTRs
but also use them to restore the original owner of the file.

This would be done by blockjob code when the job finishes, but in
this case the job won't finish - QEMU is killed meanwhile

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoUnlock the storage pool objects after looking it up
Yi Li [Thu, 7 May 2020 16:23:09 +0000 (00:23 +0800)]
Unlock the storage pool objects after looking it up

Use g_new0 to allocate and remove NULL checks from callers
and the lock will release properly

Signed-off-by: Yi Li <yili@winhong.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuBuildNumaArgStr: Use modern -numa memdev= if old -numa mem= is unsupported
Michal Privoznik [Thu, 14 May 2020 11:56:54 +0000 (13:56 +0200)]
qemuBuildNumaArgStr: Use modern -numa memdev= if old -numa mem= is unsupported

In previous commit we started tracking whether QEMU supports
'-numa mem='. This is tied to the machine type because migration
from '-numa mem=' to '-numa memdev' is impossible (or vice
versa). But since it's tied to a machine type (where migration
from one to another is also unsupported) we can allow QEMU to get
rid of the deprecated command line.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1783355
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuBuildNumaArgStr: Switch order of if() and for()
Michal Privoznik [Thu, 14 May 2020 11:59:34 +0000 (13:59 +0200)]
qemuBuildNumaArgStr: Switch order of if() and for()

When building -numa command line there is a for() loop that
builds '-numa memdev=' for each guest NUMA node. And also
records in a local variable whether any of memory-object-*
backends must be used to satisfy desired config. Well, instead of
checking in each iteration whether corresponding capabilities are
set, we can do swap if() and for() and check only once.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Track numa-mem-supported machine attribute
Michal Privoznik [Thu, 14 May 2020 11:11:01 +0000 (13:11 +0200)]
qemu: Track numa-mem-supported machine attribute

There is 'numa-mem-supported' machine attribute which specifies
whether '-numa mem=' is supported. Store it in our capabilities
as it will be used in later commits when building the command
line.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoDon't require secdrivers to implement .domainMoveImageMetadata
Michal Privoznik [Mon, 18 May 2020 08:07:30 +0000 (10:07 +0200)]
Don't require secdrivers to implement .domainMoveImageMetadata

The AppArmor secdriver does not use labels to grant access to
resources. Therefore, it doesn't use XATTRs and hence it lacks
implementation of .domainMoveImageMetadata callback. This leads
to a harmless but needless error message appearing in the logs:

  virSecurityManagerMoveImageMetadata:476 : this function is not
  supported by the connection driver: virSecurityManagerMoveImageMetadata

Closes: https://gitlab.com/libvirt/libvirt/-/issues/25
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agoqemu_alias.c: fix qemuAssingDeviceMemballoonAlias() typo
Daniel Henrique Barboza [Fri, 15 May 2020 21:51:58 +0000 (18:51 -0300)]
qemu_alias.c: fix qemuAssingDeviceMemballoonAlias() typo

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agovirSecurityManagerRestoreImageLabel: Fix typo
Michal Privoznik [Fri, 15 May 2020 15:37:50 +0000 (17:37 +0200)]
virSecurityManagerRestoreImageLabel: Fix typo

s/enther/enter/ in the function documentation.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
4 years agodocs: Update after libvirt-ruby repository rename
Andrea Bolognani [Fri, 15 May 2020 14:18:18 +0000 (16:18 +0200)]
docs: Update after libvirt-ruby repository rename

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
4 years agocpu_arm: Drop unused variable
Jiri Denemark [Fri, 15 May 2020 12:47:17 +0000 (14:47 +0200)]
cpu_arm: Drop unused variable

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
4 years agodocs: document proper enum for guest agent timeout
Tomáš Golembiovský [Fri, 15 May 2020 10:30:44 +0000 (12:30 +0200)]
docs: document proper enum for guest agent timeout

The documented enum and its values do not exits. The real enum has
slightly different name.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>