]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
6 years agoconf: Use virXMLFormatElement in virDomainDefFormatFeatures
Peter Krempa [Tue, 5 Mar 2019 13:37:11 +0000 (14:37 +0100)]
conf: Use virXMLFormatElement in virDomainDefFormatFeatures

Remove logic necessary to figure out whether to format the 'features'
element by using virXMLFormatElement.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Refactor formating of 'capabilities' features
Peter Krempa [Tue, 5 Mar 2019 12:48:20 +0000 (13:48 +0100)]
conf: Refactor formating of 'capabilities' features

Use virXMLFormatElement for the formatting which allows us to avoid
looking through the array to see if any feature is enabled.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Avoid formatting empty <capabilities> element
Peter Krempa [Tue, 5 Mar 2019 12:56:46 +0000 (13:56 +0100)]
conf: Avoid formatting empty <capabilities> element

If none of the 'capabilities' features are enabled we'd still format the
opening and closing tag for the <capabilities element.

The implementation is suboptimal but will be refactored for a better
approach. This is done prior to the refactor to show that tests are not
impacted.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Avoid extra scope when formatting 'smm' feature
Peter Krempa [Tue, 5 Mar 2019 12:35:21 +0000 (13:35 +0100)]
conf: Avoid extra scope when formatting 'smm' feature

Use an early break and remove the temporary variable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Avoid extra set of temp buffers in virDomainDefFormatFeatures
Peter Krempa [Tue, 5 Mar 2019 12:33:05 +0000 (13:33 +0100)]
conf: Avoid extra set of temp buffers in virDomainDefFormatFeatures

Use the top level set of temp buffers to do the job.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Simplify lifecycle of temp buffers in virDomainDefFormatFeatures
Peter Krempa [Tue, 5 Mar 2019 12:27:45 +0000 (13:27 +0100)]
conf: Simplify lifecycle of temp buffers in virDomainDefFormatFeatures

Use VIR_AUTOCLEAN to avoid leaking the buffer on error path and get rid
of resetting mid loop since virXMLFormatElement does the reset
internally.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Remove impossible error in virDomainDefFormatFeatures
Peter Krempa [Tue, 5 Mar 2019 12:21:39 +0000 (13:21 +0100)]
conf: Remove impossible error in virDomainDefFormatFeatures

'i' is always in range of the enum, thus the name is always populated by
virDomainFeatureTypeToString.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Rename temp buffers in virDomainDefFormatFeatures
Peter Krempa [Tue, 5 Mar 2019 12:17:31 +0000 (13:17 +0100)]
conf: Rename temp buffers in virDomainDefFormatFeatures

These buffers are used temporarily for some of the partial formatters
but not globally. Prefix the name with 'tmp' to be explicit.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Refactor control flow in virDomainDefFormatFeatures
Peter Krempa [Tue, 5 Mar 2019 12:07:40 +0000 (13:07 +0100)]
conf: Refactor control flow in virDomainDefFormatFeatures

Use an early return to avoid one level of nesting scopes.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Split out domain features formatting from virDomainDefFormatInternal
Peter Krempa [Tue, 5 Mar 2019 12:01:26 +0000 (13:01 +0100)]
conf: Split out domain features formatting from virDomainDefFormatInternal

Pure code motion of code for formatting domain features to a function
called virDomainDefFormatFeatures. Best viewed with the '--patience'
option for git show.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: refactor formatting of 'blkiotune' from virDomainDefFormatInternal
Peter Krempa [Tue, 5 Mar 2019 11:50:36 +0000 (12:50 +0100)]
conf: refactor formatting of 'blkiotune' from virDomainDefFormatInternal

Split out the code into a separate function named
virDomainDefFormatBlkiotune and use virXMLFormatElement.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Refactor virDomainHubDefFormat
Peter Krempa [Tue, 5 Mar 2019 09:17:31 +0000 (10:17 +0100)]
conf: Refactor virDomainHubDefFormat

Use virXMLFormatElement to format the internals along with simplifying
cleanup code paths.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Refactor virDomainInputDefFormat
Peter Krempa [Tue, 5 Mar 2019 09:17:31 +0000 (10:17 +0100)]
conf: Refactor virDomainInputDefFormat

Use virXMLFormatElement to format the internals along with simplifying
cleanup code paths.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Refactor formatting of 'driver' in virDomainRNGDefFormat
Peter Krempa [Tue, 5 Mar 2019 09:17:31 +0000 (10:17 +0100)]
conf: Refactor formatting of 'driver' in virDomainRNGDefFormat

Use virXMLFormatElement to format the internals along with simplifying
cleanup code paths.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Refactor virDomainPanicDefFormat
Peter Krempa [Tue, 5 Mar 2019 09:17:31 +0000 (10:17 +0100)]
conf: Refactor virDomainPanicDefFormat

Use virXMLFormatElement to format the internals along with simplifying
cleanup code paths.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Refactor virDomainWatchdogDefFormat
Peter Krempa [Tue, 5 Mar 2019 09:17:31 +0000 (10:17 +0100)]
conf: Refactor virDomainWatchdogDefFormat

Use virXMLFormatElement to format the internals along with simplifying
cleanup code paths.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Refactor virDomainMemballoonDefFormat
Peter Krempa [Tue, 5 Mar 2019 09:17:31 +0000 (10:17 +0100)]
conf: Refactor virDomainMemballoonDefFormat

Use virXMLFormatElement to format the internals along with simplifying
cleanup code paths.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Use virXMLFormatElement in virDomainControllerDefFormat
Peter Krempa [Tue, 5 Mar 2019 09:01:37 +0000 (10:01 +0100)]
conf: Use virXMLFormatElement in virDomainControllerDefFormat

Refactor the function to use the XML formatting aid and use automatic
cleaning to simplify the control flow.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Use virXMLFormatElement in virDomainControllerDriverFormat
Peter Krempa [Tue, 5 Mar 2019 08:51:03 +0000 (09:51 +0100)]
conf: Use virXMLFormatElement in virDomainControllerDriverFormat

Refactor adding of the controller <driver> element.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: xml: Enforce return value check from virXMLFormatElement
Peter Krempa [Fri, 22 Feb 2019 16:36:23 +0000 (17:36 +0100)]
util: xml: Enforce return value check from virXMLFormatElement

The function does not transfer errors from 'attrBuf' and 'childBuf'
arguments into 'buf', but rather reports them right away, thus we need
to make sure that it's always checked.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: Don't set migration caps when changing postcopy bandwidth
Jiri Denemark [Tue, 5 Mar 2019 21:16:03 +0000 (22:16 +0100)]
qemu: Don't set migration caps when changing postcopy bandwidth

The qemuMigrationParamsApply internal API was designed to apply all
migration parameters and capabilities before we start to migrate a
domain. While migration parameters are only passed to QEMU when we
explicitly want to set a specific value, capabilities are always either
enabled or disabled.

Thus when this API is called outside migration job, e.g., via a call to
qemuDomainMigrateSetMaxSpeed with VIR_DOMAIN_MIGRATE_MAX_SPEED_POSTCOPY
flag, we would call migrate-set-capabilities and disable all
capabilities. However, changing capabilities while migration is already
running does not make sense and our code should never be trying to do
so. In fact QEMU even reports an error if migrate-set-capabilities is
called during migration and qemuDomainMigrateSetMaxSpeed would fail
with:

    internal error: unable to execute QEMU command
    migrate-set-capabilities: There's a migration process in progress

With this patch qemuMigrationParamsApply never tries to call
migrate-set-capabilities outside of migration job. When the capabilities
bitmap is all zeros (which is its initial value after
qemuMigrationParamsNew), we just skip the command. But when any
capability bit is set to 1 by a non-migration job, we report an error to
highlight a bug in our code.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
6 years agosecurity: aa-helper: gl devices in sysfs at arbitrary depth
Christian Ehrhardt [Tue, 5 Mar 2019 12:38:38 +0000 (13:38 +0100)]
security: aa-helper: gl devices in sysfs at arbitrary depth

Further testing with more devices showed that we sometimes have a
different depth of pci device paths when accessing sysfs for device
attributes.

But since the access is limited to a set of filenames and read only it
is safe to use a wildcard for that.

Related apparmor denies - while we formerly had only considered:
apparmor="DENIED" operation="open"
  name="/sys/devices/pci0000:00/0000:00:02.1/uevent"
  requested_mask="r"

We now also know of cases like:
apparmor="DENIED" operation="open"
  name="/sys/devices/pci0000:00/0000:00:03.1/0000:1c:00.0/uevent"
  requested_mask="r"

Fixes: https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1817943
Acked-by: Jamie Strandboge <jamie@canonical.com>
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
6 years agosecurity: aa-helper: nvidia rules for gl devices
Christian Ehrhardt [Fri, 1 Mar 2019 06:25:59 +0000 (07:25 +0100)]
security: aa-helper: nvidia rules for gl devices

Further testing with different devices showed that we need more rules
to drive gl backends with nvidia cards. Related denies look like:

apparmor="DENIED" operation="open"
  name="/usr/share/egl/egl_external_platform.d/"
  requested_mask="r"
apparmor="DENIED" operation="open"
  name="/proc/modules"
  requested_mask="r"
apparmor="DENIED" operation="open"
  name="/proc/driver/nvidia/params"
  requested_mask="r"
apparmor="DENIED" operation="mknod"
  name="/dev/nvidiactl"
  requested_mask="c"

Fixes: https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1817943
Acked-by: Jamie Strandboge <jamie@canonical.com>
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
6 years agoRevert "Separate out StateAutoStart from StateInitialize"
Michal Privoznik [Fri, 1 Mar 2019 14:22:40 +0000 (15:22 +0100)]
Revert "Separate out StateAutoStart from StateInitialize"

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

This reverts commit e4a969092bda5b3b952963fdf6658895165040b7.

Now that drivers may call virConnectOpen() on secondary drivers, it
doesn't make much sense to have autostart separated from driver
initialization callback. In fact, it creates a problem because one
driver during its initialization might try to fetch an object from
another driver but since the object is yet to be autostarted the fetch
fails. This has been observed in reality: qemu driver performs
qemuProcessReconnect() during qemu's stateInitialize phase which may
call virDomainDiskTranslateSourcePool() which connects to the storage
driver to look up the volume. But the storage driver did not autostart
its pools yet therefore volume lookup fails and the domain is killed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoRevert "virStateDriver - Separate AutoStart from Initialize"
Michal Privoznik [Fri, 1 Mar 2019 14:16:45 +0000 (15:16 +0100)]
Revert "virStateDriver - Separate AutoStart from Initialize"

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

This reverts commit cefb97fb815c81fc882da752f45effd23bcb9b4b.

The stateAutoStart callback will be removed in the next commit.
Therefore move autostarting of domains, networks and storage
pools back into stateInitialize callbacks.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agobhyve: Move autostarting of domains into bhyveStateInitialize
Michal Privoznik [Fri, 1 Mar 2019 14:01:13 +0000 (15:01 +0100)]
bhyve: Move autostarting of domains into bhyveStateInitialize

The stateAutoStart callback will go away shortly. Therefore, move
the autostart call into state initialize callback.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agodaemon: Register secret driver before storage driver
Michal Privoznik [Fri, 1 Mar 2019 14:48:53 +0000 (15:48 +0100)]
daemon: Register secret driver before storage driver

The order in which drivers are registered is important because
their stateInitialize and stateAutoStart callback are called in
that order. Well, stateAutoStart is going away and therefore if
there is some dependency between two drivers (e.g. when
initializing storage driver expects secret driver to be available
already), the registration of such drivers must happen in correct
order.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agodocs: Fix version number
Andrea Bolognani [Tue, 5 Mar 2019 16:08:47 +0000 (17:08 +0100)]
docs: Fix version number

virtio-(non-)transitional device models have been introduced
in 5.2.0, not 5.1.0.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agocpu_map: Add more signatures for Skylake-Client CPU models
Jiri Denemark [Tue, 26 Feb 2019 20:02:49 +0000 (21:02 +0100)]
cpu_map: Add more signatures for Skylake-Client CPU models

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agocpu_map: Add more signatures for Broadwell CPU models
Jiri Denemark [Fri, 22 Feb 2019 13:45:24 +0000 (14:45 +0100)]
cpu_map: Add more signatures for Broadwell CPU models

This fixes several CPUs which were incorrectly detected as
Skylake-Client.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agocpu_map: Add more signatures for Haswell CPU models
Jiri Denemark [Tue, 26 Feb 2019 11:06:05 +0000 (12:06 +0100)]
cpu_map: Add more signatures for Haswell CPU models

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agocpu_map: Add more signatures for IvyBridge CPU models
Jiri Denemark [Tue, 26 Feb 2019 11:22:00 +0000 (12:22 +0100)]
cpu_map: Add more signatures for IvyBridge CPU models

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agocpu_map: Add more signatures for SandyBridge CPU models
Jiri Denemark [Tue, 26 Feb 2019 19:26:35 +0000 (20:26 +0100)]
cpu_map: Add more signatures for SandyBridge CPU models

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agocpu_map: Add more signatures for Westmere CPU model
Jiri Denemark [Mon, 25 Feb 2019 15:44:11 +0000 (16:44 +0100)]
cpu_map: Add more signatures for Westmere CPU model

This fixes several CPUs which were incorrectly detected as a different
CPU model.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agocpu_map: Add more signatures for Nehalem CPU models
Jiri Denemark [Tue, 26 Feb 2019 11:59:37 +0000 (12:59 +0100)]
cpu_map: Add more signatures for Nehalem CPU models

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agocpu_map: Add more signatures for Penryn CPU model
Jiri Denemark [Tue, 26 Feb 2019 11:59:50 +0000 (12:59 +0100)]
cpu_map: Add more signatures for Penryn CPU model

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agocpu_map: Add more signatures for Conroe CPU model
Jiri Denemark [Tue, 26 Feb 2019 09:45:56 +0000 (10:45 +0100)]
cpu_map: Add more signatures for Conroe CPU model

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agocputest: Test CPU signatures
Jiri Denemark [Mon, 25 Feb 2019 09:05:34 +0000 (10:05 +0100)]
cputest: Test CPU signatures

The signature computation code is not too complicated and it will likely
never change so testing it is not very important. We do it mostly for a
nice side effect of easily accessible signature numbers for all CPU
data files.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agocpu_map: Add hex representation of signatures
Jiri Denemark [Tue, 26 Feb 2019 08:22:36 +0000 (09:22 +0100)]
cpu_map: Add hex representation of signatures

The family/model numbers are nice for humans or for comparing with
/proc/cpuinfo, but sometimes there's a need to see the CPUID
representation of the signature. Let's add it into a comment for each
signature in out cpu_map XMLs as the conversion is not exactly
straightforward.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agocpu_x86: Add virCPUx86DataGetSignature for tests
Jiri Denemark [Mon, 25 Feb 2019 09:04:21 +0000 (10:04 +0100)]
cpu_x86: Add virCPUx86DataGetSignature for tests

The function exports the functionality of x86DataToSignatureFull and
x86MakeSignature to the test suite.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu_capabilities: Use virQEMUCapsGetCPUModelInfo
Jiri Denemark [Mon, 25 Feb 2019 09:00:53 +0000 (10:00 +0100)]
qemu_capabilities: Use virQEMUCapsGetCPUModelInfo

Most places in qemu_capabilities.c which call virQEMUCapsGetHostCPUData
actually need qemuMonitorCPUModelInfoPtr from QEMU caps. Let's use the
wrapper introduced in the previous commit instead.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu_capabilities: Introduce virQEMUCapsGetCPUModelInfo
Jiri Denemark [Mon, 25 Feb 2019 09:01:34 +0000 (10:01 +0100)]
qemu_capabilities: Introduce virQEMUCapsGetCPUModelInfo

This is a simple wrapper around virQEMUCapsGetHostCPUData usable in
tests for getting qemuMonitorCPUModelInfoPtr from QEMU caps.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu_capabilities: Inroduce virQEMUCapsGetCPUModelX86Data
Jiri Denemark [Mon, 25 Feb 2019 08:39:17 +0000 (09:39 +0100)]
qemu_capabilities: Inroduce virQEMUCapsGetCPUModelX86Data

The code for transforming qemuMonitorCPUModelInfo data from QEMU into
virCPUDefPtr consumable by virCPU* APIs was hidden inside
virQEMUCapsInitCPUModelX86. This patch moves it into a new function to
make it usable in tests.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agocpu_x86: Log decoded CPU model and signatures
Jiri Denemark [Mon, 4 Mar 2019 15:37:31 +0000 (16:37 +0100)]
cpu_x86: Log decoded CPU model and signatures

The log message may be useful when debugging why a specific CPU model
was selected for a given set of CPUID data.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agocpu_x86: Allow multiple signatures for a CPU model
Jiri Denemark [Fri, 22 Feb 2019 16:20:59 +0000 (17:20 +0100)]
cpu_x86: Allow multiple signatures for a CPU model

CPU signatures in the cpu_map serve as a hint for CPUID to CPU model
matching algorithm. If the CPU signatures matches any CPU model in the
cpu_map, this model will be the preferred one.

This works out well and solved several mismatches, but in real world
CPUs which should match a single CPU model may be produced with several
different signatures. For example, low voltage Broadwell CPUs for
laptops and Broadwell CPUs for servers differ in CPU model numbers while
we should detect them all as Broadwell CPU model.

This patch adds support for storing several signatures for a single CPU
model to make this hint useful for more CPUs. Later commits will provide
additional signatures for existing CPU models, which will correct some
results in our CPU test suite.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agocpu_x86: Store CPU signature in an array
Jiri Denemark [Mon, 4 Mar 2019 15:36:33 +0000 (16:36 +0100)]
cpu_x86: Store CPU signature in an array

In preparation for storing several CPU signatures in a single CPU model,
we need to turn virCPUx86Model's signature into an array of signatures.

The parser still hardcodes the number of signatures to 1, but the
following patch will drop this limit.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agocpu_x86: Add x86ModelCopySignatures helper
Jiri Denemark [Mon, 4 Mar 2019 15:18:42 +0000 (16:18 +0100)]
cpu_x86: Add x86ModelCopySignatures helper

Introduce a helper for copying CPU signature between two CPU models.

It's not very useful until the way we store signatures is changed in the
next patch.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agocpu_x86: Make sure CPU model names are unique in cpu_map
Jiri Denemark [Tue, 26 Feb 2019 07:33:08 +0000 (08:33 +0100)]
cpu_x86: Make sure CPU model names are unique in cpu_map

Having multiple CPU model definitions with the same name could result in
unexpected behavior.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agocpu_x86: Separate feature list parsing from x86ModelParse
Jiri Denemark [Fri, 22 Feb 2019 15:36:02 +0000 (16:36 +0100)]
cpu_x86: Separate feature list parsing from x86ModelParse

The code is separated into a new x86ModelParseFeatures function.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agocpu_x86: Separate vendor parsing from x86ModelParse
Jiri Denemark [Fri, 22 Feb 2019 14:33:53 +0000 (15:33 +0100)]
cpu_x86: Separate vendor parsing from x86ModelParse

The code is separated into a new x86ModelParseVendor function.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agocpu_x86: Separate signature parsing from x86ModelParse
Jiri Denemark [Fri, 22 Feb 2019 14:32:44 +0000 (15:32 +0100)]
cpu_x86: Separate signature parsing from x86ModelParse

The code is separated into a new x86ModelParseSignature function.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agocpu_x86: Separate ancestor model parsing from x86ModelParse
Jiri Denemark [Fri, 22 Feb 2019 14:22:29 +0000 (15:22 +0100)]
cpu_x86: Separate ancestor model parsing from x86ModelParse

The code is separated into a new x86ModelParseAncestor function.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agocputest: Add data for Intel(R) Core(TM) i7-8700
Jiri Denemark [Mon, 4 Mar 2019 15:45:48 +0000 (16:45 +0100)]
cputest: Add data for Intel(R) Core(TM) i7-8700

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agocputest: Add data for Intel(R) Xeon(R) CPU E5-2650
Jiri Denemark [Wed, 27 Feb 2019 08:49:36 +0000 (09:49 +0100)]
cputest: Add data for Intel(R) Xeon(R) CPU E5-2650

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agocputest: Add data for Intel(R) Xeon(R) CPU E7540
Jiri Denemark [Tue, 26 Feb 2019 20:22:25 +0000 (21:22 +0100)]
cputest: Add data for Intel(R) Xeon(R) CPU E7540

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agocputest: Add data for Intel(R) Core(TM) i7-7600U
Jiri Denemark [Thu, 21 Feb 2019 21:14:53 +0000 (22:14 +0100)]
cputest: Add data for Intel(R) Core(TM) i7-7600U

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agocputest: Add data for Intel(R) Xeon(R) CPU E5-2630 v4
Jiri Denemark [Thu, 21 Feb 2019 20:51:58 +0000 (21:51 +0100)]
cputest: Add data for Intel(R) Xeon(R) CPU E5-2630 v4

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agocputest: Make sure generated files pass syntax-check
Jiri Denemark [Wed, 27 Feb 2019 08:43:23 +0000 (09:43 +0100)]
cputest: Make sure generated files pass syntax-check

The tests/cputestdata/cpu-parse.sh would produce JSON files with QEMU
replies which wouldn't pass syntax-check. Let's fix this by not emitting
an extra new line after reformatting the JSON file.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: Add -inactive suffix when appropriate for qemuxml2xml
Andrea Bolognani [Thu, 28 Feb 2019 16:25:18 +0000 (17:25 +0100)]
tests: Add -inactive suffix when appropriate for qemuxml2xml

Some test cases are only executed using WHEN_INACTIVE, and the
output file name should reflect this for clarity.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: Use WHEN_BOTH in qemuxml2xml whenever possible
Andrea Bolognani [Thu, 28 Feb 2019 16:10:17 +0000 (17:10 +0100)]
tests: Use WHEN_BOTH in qemuxml2xml whenever possible

There are a few cases where we are using either WHEN_ACTIVE
or WHEN_INACTIVE even though WHEN_BOTH would work perfectly
fine: for those, start using the simpler DO_TEST() macro.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: Rename some qemuxml2xml output files for clarity
Andrea Bolognani [Thu, 28 Feb 2019 15:51:52 +0000 (16:51 +0100)]
tests: Rename some qemuxml2xml output files for clarity

disk-mirror-old has different output file for the active and
inactive parts, which should be named accordingly; on the other
hand, both output files for disk-backing-chains-noindex are
identical, so it makes sense to only keep around one and remove
the (in-)active suffix.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoFix the recent CI build failures
Erik Skultety [Tue, 5 Mar 2019 08:41:25 +0000 (09:41 +0100)]
Fix the recent CI build failures

After commits e2087c2 and ec0793de older GCC started act very smart and
complain about potentially uninitialized variable, which existed prior
to these patches + even if the affected vars were left uninitialized the
function responsible for filling them in would have failed with NULL
being returned which the caller has always handled carefully.
Although GCC complained only about a single variable, let's initialize
all of them so as to prevent any further potential breakages.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
6 years agovirsh: Add event name completion to 'network-event' command
Lin Ma [Tue, 5 Mar 2019 03:17:39 +0000 (11:17 +0800)]
virsh: Add event name completion to 'network-event' command

Signed-off-by: Lin Ma <lma@suse.com>
6 years agovirsh-network: Introduce virshNetworkEventCallback to handle network events
Lin Ma [Tue, 5 Mar 2019 03:17:38 +0000 (11:17 +0800)]
virsh-network: Introduce virshNetworkEventCallback to handle network events

Signed-off-by: Lin Ma <lma@suse.com>
6 years agovirsh: Add device name completion for target option of detach-disk command
Lin Ma [Tue, 5 Mar 2019 03:17:37 +0000 (11:17 +0800)]
virsh: Add device name completion for target option of detach-disk command

Signed-off-by: Lin Ma <lma@suse.com>
6 years agoqemu: domcaps: Report disk <enum name="model">
Cole Robinson [Wed, 20 Feb 2019 19:18:40 +0000 (14:18 -0500)]
qemu: domcaps: Report disk <enum name="model">

This generates new XML like:

    <disk>
      <enum name='model'>
        <value>virtio</value>
        <value>virtio-transitional</value>
        <value>virtio-non-transitional</value>
      </enum>
    </disk>

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: domcaps: Add qemu 4.0.0 test case
Cole Robinson [Thu, 17 Jan 2019 17:52:45 +0000 (12:52 -0500)]
tests: domcaps: Add qemu 4.0.0 test case

Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoqemu: Support scsi controller model=virtio-{non-}transitional
Cole Robinson [Thu, 17 Jan 2019 17:52:43 +0000 (12:52 -0500)]
qemu: Support scsi controller model=virtio-{non-}transitional

Add <controller type='scsi' model handling for virtio transitional
devices. Ex:

  <controller type='scsi' model='virtio-transitional'/>

* "virtio-transitional" maps to qemu "virtio-scsi-pci-transitional"
* "virtio-non-transitional" maps to qemu "virtio-scsi-non-transitional"

The naming here doesn't match the pre-existing model=virtio-scsi.
The prescence of '-scsi' there seems kind of redundant as we have
type='scsi' already, so I decided to follow the pattern of other
patches and use virtio-transitional etc.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoqemu: Support virtio-serial controller model=virtio-{non-}transitional
Cole Robinson [Thu, 17 Jan 2019 17:52:44 +0000 (12:52 -0500)]
qemu: Support virtio-serial controller model=virtio-{non-}transitional

Add controller type='virtio-serial' model handling for virtio
transitional devices. Ex:

  <controller type='virtio-serial' model='virtio-transitional'/>

* "virtio-transitional" maps to qemu "virtio-serial-pci-transitional"
* "virtio-non-transitional" maps to qemu "virtio-serial-pci-non-transitional"

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoqemu: Support input model=virtio-{non-}transitional
Cole Robinson [Thu, 17 Jan 2019 17:52:42 +0000 (12:52 -0500)]
qemu: Support input model=virtio-{non-}transitional

Add <input> model handling for virtio transitional devices. Ex:

  <input type='passthrough' bus='virtio' model='virtio-transitional'>
    ...
  </input>

* "virtio-transitional" maps to qemu "virtio-input-host-pci-transitional"
* "virtio-non-transitional" maps to qemu "virtio-input-host-non-transitional"

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoconf: Add <input model='virtio-{non-}transitional'/>
Cole Robinson [Thu, 17 Jan 2019 17:52:41 +0000 (12:52 -0500)]
conf: Add <input model='virtio-{non-}transitional'/>

<input> devices lack the model= attribute which is used by
most other device types. To eventually support
virtio-input-host-pci-{non-}traditional in qemu, let's add
a standard model= attribute. This just adds the domain_conf
wiring

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoqemu: Support vsock model=virtio-{non-}transitional
Cole Robinson [Thu, 17 Jan 2019 17:52:40 +0000 (12:52 -0500)]
qemu: Support vsock model=virtio-{non-}transitional

Add <vsock> model handling for virtio transitional devices. Ex:

  <vsock model='virtio-transitional'>
    ...
  </vsock>

* "virtio-transitional" maps to qemu "vhost-vsock-pci-transitional"
* "virtio-non-transitional" maps to qemu "vhost-vsock-pci-non-transitional"

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoqemu: Support memballoon model=virtio-{non-}transitional
Cole Robinson [Thu, 17 Jan 2019 17:52:39 +0000 (12:52 -0500)]
qemu: Support memballoon model=virtio-{non-}transitional

Add new <memballoon> model values for virtio transitional devices. Ex:

  <memballoon model='virtio-transitional'/>

* "virtio-transitional" maps to qemu "virtio-balloon-pci-transitional"
* "virtio-non-transitional" maps to qemu "virtio-balloon-pci-non-transitional"

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoqemu: Support filesystem model=virtio-{non-}transitional
Cole Robinson [Thu, 17 Jan 2019 17:52:37 +0000 (12:52 -0500)]
qemu: Support filesystem model=virtio-{non-}transitional

Add <filesystem> model handling for virtio transitional devices. Ex:

  <filesystem type='mount' model='virtio-transitional'>
    ...
  </filesystem

* "virtio-transitional" maps to qemu "virtio-9p-pci-transitional"
* "virtio-non-transitional" maps to qemu "virtio-9p-pci-non-transitional"

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoconf: Add <filesystem model='virtio-{non-}transitional'/>
Cole Robinson [Thu, 17 Jan 2019 17:52:36 +0000 (12:52 -0500)]
conf: Add <filesystem model='virtio-{non-}transitional'/>

<filesystem> devices lack the model= attribute which is used by
most other device types. To eventually support
virtio-9p-pci-{non-}traditional in qemu, let's add a standard
model= attribute. The accepted values are:

- virtio
- virtio-transitional
- virtio-non-transitional

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoqemu: Support rng model=virtio-{non-}transitional
Cole Robinson [Thu, 17 Jan 2019 17:52:35 +0000 (12:52 -0500)]
qemu: Support rng model=virtio-{non-}transitional

Add new <rng> model values for virtio transitional devices. Ex:

  <rng model='virtio-transitional'>
    ...
  </rng>

* "virtio-transitional" maps to qemu "virtio-rng-pci-transitional"
* "virtio-non-transitional" maps to qemu "virtio-rng-pci-non-transitional"

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoqemu: Support hostdev model=virtio-{non-}transitional
Cole Robinson [Thu, 17 Jan 2019 17:52:34 +0000 (12:52 -0500)]
qemu: Support hostdev model=virtio-{non-}transitional

Add <hostdev> protocol=vhost model handling for virtio transitional
devices. Ex:

  <hostdev mode='subsystem' type='scsi_host' model='virtio-transitional'>
    <source protocol='vhost' wwpn=X/>
  </hostdev>

* "virtio-transitional" maps to qemu "vhost-scsi-pci-transitional"
* "virtio-non-transitional" maps to qemu "vhost-scsi-pci-non-transitional"

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoconf: Add <hostdev model='virtio-{non-}transitional'/>
Cole Robinson [Thu, 17 Jan 2019 17:52:33 +0000 (12:52 -0500)]
conf: Add <hostdev model='virtio-{non-}transitional'/>

qemu vhost-scsi devices map to XML roughly like:

    <hostdev mode='subsystem' type='scsi_host'>
      <source protocol='vhost' wwpn=X/>
    </hostdev>

To support vhost-scsi-pci-{non-}traditional in qemu, we
need to to extend the SCSI Host hostdev XML to handle
model= value. This matches the XML model= format used
for mediated devices. This is just the domain_conf bits
and some XML test cases.

Use of virtio-X naming here does not match the hostdev
protocol=vhost nor does it match the qemu vhost-X device
naming, however it's more consistent with all other
model= names in this area, and also matches the
inconsistency of <vsock> devices which use model=virtio
but map to vhost-vsock on the qemu commandline

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoqemu: Support interface model=virtio-{non-}transitional
Cole Robinson [Thu, 17 Jan 2019 17:52:32 +0000 (12:52 -0500)]
qemu: Support interface model=virtio-{non-}transitional

Add new <interface> model handling for virtio transitional devices. Ex:

<interface>
  <model type='virtio-transitional'/>
</interface>

* "virtio-transitional" maps to qemu "virtio-net-pci-transitional"
* "virtio-non-transitional" maps to qemu "virtio-net-pci-non-transitional"

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoqemu: Support disk model=virtio-{non-}transitional
Cole Robinson [Fri, 11 Jan 2019 21:30:10 +0000 (16:30 -0500)]
qemu: Support disk model=virtio-{non-}transitional

Add new <disk> model values for virtio transitional devices. When
combined with bus='virtio':

* "virtio-transitional" maps to qemu "virtio-blk-pci-transitional"
* "virtio-non-transitional" maps to qemu "virtio-blk-pci-non-transitional"

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoconf: Add <disk model='virtio-{non-}transitional'/>
Cole Robinson [Fri, 11 Jan 2019 20:06:05 +0000 (15:06 -0500)]
conf: Add <disk model='virtio-{non-}transitional'/>

<disk> devices lack the model= attribute which is used by
most other device types. bus= mostly acts as one, but it
serves other purposes too like determing what target=
prefix to use, and for matching against controller type=
values.

Extending bus= to handle additional virtio transitional
devices will complicate apps lives, and it isn't a clean
mapping anyways. So let's bite the bullet and add a new
<disk model=X/> attribute, and wire up common handling
for virtio and virtio-{non-}transitional

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoqemu: capabilities: Add virtio/vhost {non-}transitional
Cole Robinson [Tue, 22 Jan 2019 18:17:06 +0000 (13:17 -0500)]
qemu: capabilities: Add virtio/vhost {non-}transitional

Add a single QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL that
will be set if any of the following qemu devices are found:

    virtio-blk-pci-transitional
    virtio-blk-pci-non-transitional
    virtio-net-pci-transitional
    virtio-net-pci-non-transitional
    vhost-scsi-pci-transitional
    vhost-scsi-pci-non-transitional
    virtio-rng-pci-transitional
    virtio-rng-pci-non-transitional
    virtio-9p-pci-transitional
    virtio-9p-pci-non-transitional
    virtio-balloon-pci-transitional
    virtio-balloon-pci-non-transitional
    vhost-vsock-pci-transitional
    vhost-vsock-pci-non-transitional
    virtio-input-host-pci-transitional
    virtio-input-host-pci-non-transitional
    virtio-scsi-pci-transitional
    virtio-scsi-pci-non-transitional
    virtio-serial-pci-transitional
    virtio-serial-pci-non-transitional

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoqemu: command: Add qemuCaps to BuildVirtioStr
Cole Robinson [Wed, 23 Jan 2019 13:10:22 +0000 (08:10 -0500)]
qemu: command: Add qemuCaps to BuildVirtioStr

It will be used in future patches

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agovirDomainDiskTranslateSourcePool: Don't set @mode of iscsi-direct
Michal Privoznik [Fri, 1 Mar 2019 15:05:16 +0000 (16:05 +0100)]
virDomainDiskTranslateSourcePool: Don't set @mode of iscsi-direct

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

This function is called when a domain is starting up (in qemu
driver that is when qemu cmd line is generated). It is used to
translate <disk type='volume'/> to something usable by filling in
virStorageSource (e.g. fetching disk path, or some connection URI
for a network FS). But some of these info are not stored in
status XML and thus the function is called on
qemuProcessReconnect too to reconstruct runtime data. But this
poses a problem because after the first run the mode is set to
'direct', but in the second run this triggers a failure because
mode is valid only for 'iscsi' volumes and not 'iscsi-direct'
ones.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoconf: Rework virDomainKeyWrapDefParseXML
John Ferlan [Fri, 1 Mar 2019 16:00:48 +0000 (11:00 -0500)]
conf: Rework virDomainKeyWrapDefParseXML

Rewrite the code to make usage of some VIR_AUTOFREE logic.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoconf: Clean up some unnecessary goto paths
John Ferlan [Fri, 15 Feb 2019 13:47:35 +0000 (08:47 -0500)]
conf: Clean up some unnecessary goto paths

Now that we're using VIR_AUTOFREE there's quite a bit of clean up
possible for now unnecessary goto paths.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoconf: Use VIR_AUTOUNREF in domain_conf
John Ferlan [Fri, 1 Mar 2019 15:34:50 +0000 (10:34 -0500)]
conf: Use VIR_AUTOUNREF in domain_conf

Let's make use of the auto __cleanup capabilities for virObjectUnref
consumers.

Signed-off-by: John Ferlan <jferlan@redhat.com>
6 years agoconf: Use VIR_AUTOFREE in domain_conf
John Ferlan [Wed, 20 Feb 2019 16:25:10 +0000 (11:25 -0500)]
conf: Use VIR_AUTOFREE in domain_conf

Let's make use of the auto __cleanup capabilities for VIR_FREE consumers.
In some cases adding or removing blank lines for readability.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoconf: Remove a few unused variables in domain_conf
John Ferlan [Wed, 20 Feb 2019 16:18:28 +0000 (11:18 -0500)]
conf: Remove a few unused variables in domain_conf

In preparation for VIR_AUTOFREE usage, let's remove a couple
of unused variables so that clang compilations won't fail.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoconf: Clean up some unnecessary goto paths
John Ferlan [Fri, 15 Feb 2019 12:04:13 +0000 (07:04 -0500)]
conf: Clean up some unnecessary goto paths

Now that we're using VIR_AUTOPTR(virBitmap) there's a couple of methods
that we can clean up some now unnecessary goto paths.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoconf: Use VIR_AUTOPTR(virBitmap) in domain_conf
John Ferlan [Wed, 20 Feb 2019 16:04:47 +0000 (11:04 -0500)]
conf: Use VIR_AUTOPTR(virBitmap) in domain_conf

Let's make use of the auto __cleanup capabilities for virBitmapPtr.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoconf: Rework virDomainEmulatorPinDefParseXML
John Ferlan [Wed, 20 Feb 2019 16:07:07 +0000 (11:07 -0500)]
conf: Rework virDomainEmulatorPinDefParseXML

In preparation for using auto free mechanism, change to using the
VIR_STEAL_PTR on @def to @ret and of course be sure to properly clean
up @def in cleanup.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoqemu: Use VIR_XPATH_NODE_AUTORESTORE when XPath context is modified
Peter Krempa [Tue, 26 Feb 2019 16:42:25 +0000 (17:42 +0100)]
qemu: Use VIR_XPATH_NODE_AUTORESTORE when XPath context is modified

Use the new helper when moving around the current node of the XPath
context.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: XML: Introduce automatic reset of XPath's current node
Peter Krempa [Tue, 26 Feb 2019 16:34:57 +0000 (17:34 +0100)]
util: XML: Introduce automatic reset of XPath's current node

Quite a few parts modify the XPath context current node to shift the
scope and allow easier queries. This also means that the node needs
to be restored afterwards.

Introduce a macro based on 'VIR_AUTOCLEAN' which adds a local structure
on the stack remembering the original node along with a function which
will make sure that the node is reset when the local structure leaves
scope.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: alloc: Clarify docs for VIR_DEFINE_AUTOCLEAN_FUNC
Peter Krempa [Tue, 26 Feb 2019 16:46:57 +0000 (17:46 +0100)]
util: alloc: Clarify docs for VIR_DEFINE_AUTOCLEAN_FUNC

Document that @func must take pointer to @type.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: object: Reset pointer when unrefing object in virObjectAutoUnref
Peter Krempa [Tue, 26 Feb 2019 16:07:42 +0000 (17:07 +0100)]
util: object: Reset pointer when unrefing object in virObjectAutoUnref

The helper function is used by the VIR_AUTOUNREF macro. Prior art is to
clear the pointer even if the variable goes out of scope.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agosyntax-check: require intialization for new VIR_AUTO macros
Peter Krempa [Tue, 26 Feb 2019 16:02:58 +0000 (17:02 +0100)]
syntax-check: require intialization for new VIR_AUTO macros

The syntax-check should also check the new ones.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: alloc: Note that VIR_AUTOPTR/VIR_AUTOCLEAN must not be used with vectors
Peter Krempa [Fri, 22 Feb 2019 15:32:11 +0000 (16:32 +0100)]
util: alloc: Note that VIR_AUTOPTR/VIR_AUTOCLEAN must not be used with vectors

We'd free only the first element of the vector leaking the rest.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: string: Remove the 'virString' type
Peter Krempa [Tue, 26 Feb 2019 15:17:54 +0000 (16:17 +0100)]
util: string: Remove the 'virString' type

We don't need it as there's a separate macro for auto-freeing of string
lists.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: string: Use VIR_AUTOSTRINGLIST instead of VIR_AUTOPTR(virString)
Peter Krempa [Fri, 22 Feb 2019 14:01:02 +0000 (15:01 +0100)]
util: string: Use VIR_AUTOSTRINGLIST instead of VIR_AUTOPTR(virString)

Use of VIR_AUTOPTR and virString is confusing as it's a list and not a
single pointer. Replace it by VIR_AUTOSTRINGLIST as string lists are
basically the only sane NULL-terminated list we can have.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>