]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
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>
4 years agocpu_map: Introduce ARM cpu models
Zhenyu Zheng [Wed, 13 May 2020 10:48:36 +0000 (18:48 +0800)]
cpu_map: Introduce ARM cpu models

Introduce vendors and some commonly used models
for ARM arch, these will be used for virConnectionGetCapabilities
for ARM CPUs.

Signed-off-by: Zhenyu Zheng <zheng.zhenyu@outlook.com>
Message-Id: <TY2PR01MB3113973DDB36C7A5E18F451299BF0@TY2PR01MB3113.jpnprd01.prod.outlook.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agocpu: Introduce getHost support for ARM CPU driver
Zhenyu Zheng [Wed, 13 May 2020 10:48:34 +0000 (18:48 +0800)]
cpu: Introduce getHost support for ARM CPU driver

Introduce getHost support for ARM CPU driver,
read CPU vendor_id, part_id and flags from
registers directly. These codes will only be
compiled on aarch64 hardware.

Signed-off-by: Zhenyu Zheng <zheng.zhenyu@outlook.com>
Message-Id: <TY2PR01MB311380AFE294266B4E87B85699BF0@TY2PR01MB3113.jpnprd01.prod.outlook.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agocpu: Add helper functions to parse vendor and model
Zhenyu Zheng [Wed, 13 May 2020 10:48:32 +0000 (18:48 +0800)]
cpu: Add helper functions to parse vendor and model

Add helper functions to parse vendor and model for
ARM CPUs, and use them as callbacks when load cpu
maps.

Signed-off-by: Zhenyu Zheng <zheng.zhenyu@outlook.com>
Message-Id: <TY2PR01MB3113C158B8C2822E75DB5EAE99BF0@TY2PR01MB3113.jpnprd01.prod.outlook.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agocpu: Introduce virCPUarmData and related struts
Zhenyu Zheng [Wed, 13 May 2020 10:48:30 +0000 (18:48 +0800)]
cpu: Introduce virCPUarmData and related struts

Introduce virCPUarmData to virCPUData and related
structs to cpu_arm.c for ARM cpus.

Signed-off-by: Zhenyu Zheng <zheng.zhenyu@outlook.com>
Message-Id: <TY2PR01MB31130D12A95144FF88C1E32499BF0@TY2PR01MB3113.jpnprd01.prod.outlook.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agocpu: Properly define g_autoptr for virCPUData
Jiri Denemark [Thu, 14 May 2020 08:36:22 +0000 (10:36 +0200)]
cpu: Properly define g_autoptr for virCPUData

The structure is not specific to x86 and thus its cleanup function
should be defined in cpu.h and be available to all users.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuBlockJobDataDisposeJobdata: Free data.commit.disabledBitmapsBase
Michal Privoznik [Thu, 14 May 2020 09:26:22 +0000 (11:26 +0200)]
qemuBlockJobDataDisposeJobdata: Free data.commit.disabledBitmapsBase

==179663== 35 (24 direct, 11 indirect) bytes in 1 blocks are definitely lost in loss record 205 of 461
==179663==    at 0x4839EC6: calloc (vg_replace_malloc.c:762)
==179663==    by 0x5791AC0: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.6400.1)
==179663==    by 0x190C79: qemuDomainObjPrivateXMLParseBlockjobDataCommit (qemu_domain.c:3295)
==179663==    by 0x190DF7: qemuDomainObjPrivateXMLParseBlockjobDataSpecific (qemu_domain.c:3331)
==179663==    by 0x19157D: qemuDomainObjPrivateXMLParseBlockjobData (qemu_domain.c:3469)
==179663==    by 0x1918E8: qemuDomainObjPrivateXMLParseBlockjobs (qemu_domain.c:3498)
==179663==    by 0x193841: qemuDomainObjPrivateXMLParse (qemu_domain.c:3944)
==179663==    by 0x4A1BA9D: virDomainObjParseXML (domain_conf.c:22306)
==179663==    by 0x4A1BFE9: virDomainObjParseNode (domain_conf.c:22429)
==179663==    by 0x4A1C0B4: virDomainObjParseFile (domain_conf.c:22443)
==179663==    by 0x1431E1: testCompareStatusXMLToXMLFiles (qemuxml2xmltest.c:61)
==179663==    by 0x177722: virTestRun (testutils.c:142)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemuDomainStorageSourcePrivateDispose: Free httpcookie
Michal Privoznik [Thu, 14 May 2020 08:47:42 +0000 (10:47 +0200)]
qemuDomainStorageSourcePrivateDispose: Free httpcookie

==156803== 58 (40 direct, 18 indirect) bytes in 1 blocks are definitely lost in loss record 306 of 463
==156803==    at 0x4839EC6: calloc (vg_replace_malloc.c:762)
==156803==    by 0x5791AC0: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.6400.1)
==156803==    by 0x48F60DC: virAlloc (viralloc.c:48)
==156803==    by 0x18DD74: qemuStorageSourcePrivateDataAssignSecinfo (qemu_domain.c:2384)
==156803==    by 0x18DFD5: qemuStorageSourcePrivateDataParse (qemu_domain.c:2433)
==156803==    by 0x49EC884: virDomainStorageSourceParse (domain_conf.c:9857)
==156803==    by 0x49ECBA3: virDomainDiskBackingStoreParse (domain_conf.c:9909)
==156803==    by 0x49F129D: virDomainDiskDefParseXML (domain_conf.c:10785)
==156803==    by 0x4A1804E: virDomainDefParseXML (domain_conf.c:21543)
==156803==    by 0x4A1B60C: virDomainObjParseXML (domain_conf.c:22254)
==156803==    by 0x4A1BFE9: virDomainObjParseNode (domain_conf.c:22429)
==156803==    by 0x4A1C0B4: virDomainObjParseFile (domain_conf.c:22443

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agocputest: Add data for AMD Ryzen 9 3900X 12-Core Processor
Jiri Denemark [Mon, 20 Apr 2020 13:22:37 +0000 (15:22 +0200)]
cputest: Add data for AMD Ryzen 9 3900X 12-Core Processor

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agotools: mention server-update-tls supports virtproxyd
Daniel P. Berrangé [Tue, 12 May 2020 09:49:10 +0000 (10:49 +0100)]
tools: mention server-update-tls supports virtproxyd

Reviewed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: only stop external devices after the domain
Ján Tomko [Tue, 12 May 2020 10:59:07 +0000 (12:59 +0200)]
qemu: only stop external devices after the domain

A failure in qemuProcessLaunch would lead to qemuExtDevicesStop
being called twice - once in the cleanup section and then again
in qemuProcessStop.

However, the first one is called while the QEMU process is
still running, which is too soon for the swtpm process, because
the swtmp_ioctl command can lock up:

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

Remove the first call and only leave the one in qemuProcessStop,
which is called after the QEMU process is killed.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agovirNetDevOpenvswitchGetVhostuserIfname: Drop cleanup label
Michal Privoznik [Wed, 13 May 2020 09:49:37 +0000 (11:49 +0200)]
virNetDevOpenvswitchGetVhostuserIfname: Drop cleanup label

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirNetDevOpenvswitchGetVhostuserIfname: Fix const correctness
Michal Privoznik [Wed, 13 May 2020 09:57:37 +0000 (11:57 +0200)]
virNetDevOpenvswitchGetVhostuserIfname: Fix const correctness

The @tmpIfname is a pointer into a const string. To avoid
mistakenly changing the const string via the pointer, make the
pointer const too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirNetDevOpenvswitchConstructVlans: return void
Michal Privoznik [Wed, 13 May 2020 09:56:59 +0000 (11:56 +0200)]
virNetDevOpenvswitchConstructVlans: return void

This function returns nothing else than zero. Make it void.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirNetDevOpenvswitchConstructVlans: Bring @i into the block where it's used
Michal Privoznik [Wed, 13 May 2020 09:49:07 +0000 (11:49 +0200)]
virNetDevOpenvswitchConstructVlans: Bring @i into the block where it's used

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirNetDevOpenvswitchConstructVlans: Use g_auto() for virBuffer
Michal Privoznik [Wed, 13 May 2020 09:47:37 +0000 (11:47 +0200)]
virNetDevOpenvswitchConstructVlans: Use g_auto() for virBuffer

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu: reject readonly attribute for virtiofs
Ján Tomko [Wed, 13 May 2020 08:52:36 +0000 (10:52 +0200)]
qemu: reject readonly attribute for virtiofs

This is not yet supported by virtiofsd.

Fixes #23 a.k.a. https://gitlab.com/libvirt/libvirt/-/issues/23

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
4 years agoutil: virnetdevopenvswitch: Delete unused code
Yan Wang [Wed, 13 May 2020 02:51:50 +0000 (10:51 +0800)]
util: virnetdevopenvswitch: Delete unused code

It was never used since commit 57b5e27d3d7 introduced it.

Signed-off-by: Yan Wang <wangyan122@huawei.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agotests: qemuxml2argvtest: Add vmpvscsi to disk-scsi test
Chris Jester-Young [Wed, 13 May 2020 01:55:48 +0000 (21:55 -0400)]
tests: qemuxml2argvtest: Add vmpvscsi to disk-scsi test

Signed-off-by: Chris Jester-Young <cky@cky.nz>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agotests: qemuxml2xmltest: Convert disk-scsi to DO_TEST_CAPS_LATEST
Chris Jester-Young [Wed, 13 May 2020 01:55:47 +0000 (21:55 -0400)]
tests: qemuxml2xmltest: Convert disk-scsi to DO_TEST_CAPS_LATEST

Signed-off-by: Chris Jester-Young <cky@cky.nz>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemu: pvscsi: Add support for vmpvscsi controller model
Chris Jester-Young [Wed, 13 May 2020 01:55:46 +0000 (21:55 -0400)]
qemu: pvscsi: Add support for vmpvscsi controller model

Availability of the vmpvscsi controller model is gated by the pvscsi
capability.

Signed-off-by: Chris Jester-Young <cky@cky.nz>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemu: pvscsi: Add capability
Chris Jester-Young [Wed, 13 May 2020 01:55:45 +0000 (21:55 -0400)]
qemu: pvscsi: Add capability

This capability flags support for `-device pvscsi`, which provides the
VMware paravirtual SCSI controller.

Signed-off-by: Chris Jester-Young <cky@cky.nz>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemu: blockcopy: Allow copy of read-only disks with -blockdev
Peter Krempa [Wed, 6 May 2020 16:32:09 +0000 (18:32 +0200)]
qemu: blockcopy: Allow copy of read-only disks with -blockdev

'blockdev-mirror' requires the write permission internally to do the
copy. This means that we have to force the image to be read-write for
the duration of the copy and can fix it after the copy is done.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: snapshot: Allow snapshots of read-only disks when we can create them
Peter Krempa [Wed, 6 May 2020 15:41:12 +0000 (17:41 +0200)]
qemu: snapshot: Allow snapshots of read-only disks when we can create them

With -blockdev or when reusing externally created images and thus
without the need for formatting the image we actually can support
snapshots of read-only disks. Arguably it's not very useful so they are
not done by default but users of libvirt such as oVirt are actually
using this.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuBlockStorageSourceCreateFormat: Force write access when formatting images
Peter Krempa [Mon, 11 May 2020 12:23:13 +0000 (14:23 +0200)]
qemuBlockStorageSourceCreateFormat: Force write access when formatting images

We need qemu to be able to write the newly created images so that it can
format them to the specified storage format.

Force write access by relabelling the images when formatting.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agostorage_file: create: Create new images with write permission bit
Peter Krempa [Mon, 11 May 2020 13:38:28 +0000 (15:38 +0200)]
storage_file: create: Create new images with write permission bit

The 'Create' API of the two storage file backends is used only on
code-paths where we need to format the image after creating an empty
file. Since the DAC security driver only modifies the owner of the file
and not the mode we need to create all files which are going to be
formatted with the write bit set for the user.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoconf: Store 'diskElementAuth' and 'diskElementEnc' properties in status XML
Peter Krempa [Thu, 7 May 2020 13:01:54 +0000 (15:01 +0200)]
conf: Store 'diskElementAuth' and 'diskElementEnc' properties in status XML

Remember the preferred placement of <auth> and <encryption> for a disk
source across libvirtd restarts.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>