]> git.ipfire.org Git - thirdparty/libvirt.git/log
thirdparty/libvirt.git
8 years agoUse macros for testing virSystemd APIs
Ján Tomko [Thu, 23 Feb 2017 11:25:33 +0000 (12:25 +0100)] 
Use macros for testing virSystemd APIs

This hides the unused third parameter from every line
and prepares for resetting the environment after each test
case in the future.

8 years agoUnify checking for machine1 systemd service
Ján Tomko [Fri, 24 Jun 2016 15:38:33 +0000 (17:38 +0200)] 
Unify checking for machine1 systemd service

Both virSystemdTerminateMachine and virSystemdCreateMachine
propagate the error to tell between a non-systemd system
and a hard error.

In virSystemdGetMachineNameByPID both are treated the same,
but an error is ignored by the callers.

Split out the checks into a separate function.

8 years agotest: Make common test*ObjFindByUUID helpers
John Ferlan [Sat, 4 Mar 2017 14:48:11 +0000 (09:48 -0500)] 
test: Make common test*ObjFindByUUID helpers

Make common helpers testNetworkObjFindByUUID and testStoragePoolObjFindByUUID
which will replace the repeated patter for each to find objects by UUID.

As a bonus, the error message processing will also provide the failed uuidstr
rather than a generic error message.

8 years agotest: Make a common testNetworkObjFindByName
John Ferlan [Sat, 4 Mar 2017 14:34:53 +0000 (09:34 -0500)] 
test: Make a common testNetworkObjFindByName

Rather than have multiple places using the same pattern to find
a network by name using virNetworkObjFindByName, create a common
helper which will provide a consistent error message as well.

8 years agotest: Make common test*ObjFindByName helpers
John Ferlan [Sat, 4 Mar 2017 14:16:33 +0000 (09:16 -0500)] 
test: Make common test*ObjFindByName helpers

Rather than have continued repeated sequences of :

    testDriverLock()
    xxx = vir*ObjFindByName()
    testDriverUnlock()

    if (xxx == NULL) {
        virReportError
        goto cleanup;
    }

Make some common helpers which will use the pattern and make a single
reference using a single common error message.

Altered for Interfaces, Storage Pools, Storage Volumes, and Node Devices.

For each the common error message can now also indicate which 'name' was
not found. For Storage Volumes, the "new" error will be more specific
rather than just invalid argument.

8 years agoconf: Alter coding style of interface function prototypes
John Ferlan [Thu, 2 Mar 2017 17:01:29 +0000 (12:01 -0500)] 
conf: Alter coding style of interface function prototypes

In an effort to be consistent with the source module, alter the function
prototypes to follow the similar style of source with the "type" on one
line followed by the function name and arguments on subsequent lines with
with argument getting it's own line.

8 years agoconf: Use consistent function name prefixes for virinterfaceobj
John Ferlan [Thu, 2 Mar 2017 16:56:43 +0000 (11:56 -0500)] 
conf: Use consistent function name prefixes for virinterfaceobj

Use "virInterfaceObj" as a prefix for any external API in virinterfaceobj

8 years agoconf: Adjust coding style for interface conf sources
John Ferlan [Thu, 2 Mar 2017 16:44:11 +0000 (11:44 -0500)] 
conf: Adjust coding style for interface conf sources

Alter the format of the code to follow more recent style guidelines of
two empty lines between functions, function decls with "[static] type"
on one line followed by function name with arguments to functions each
on one line.

8 years agoconf: Introduce virinterfaceobj
John Ferlan [Tue, 28 Feb 2017 21:20:44 +0000 (16:20 -0500)] 
conf: Introduce virinterfaceobj

Move all the InterfaceObj API's into their own module virinterfaceobj
from the interface_conf

Purely code motion at this point.

8 years agoqemu: Enforce qemuSecurity wrappers
Michal Privoznik [Mon, 13 Feb 2017 13:36:53 +0000 (14:36 +0100)] 
qemu: Enforce qemuSecurity wrappers

Now that we have some qemuSecurity wrappers over
virSecurityManager APIs, lets make sure everybody sticks with
them. We have them for a reason and calling virSecurityManager
API directly instead of wrapper may lead into accidentally
labelling a file on the host instead of namespace.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agonews: Fix typo
Jiri Denemark [Mon, 6 Mar 2017 07:17:08 +0000 (08:17 +0100)] 
news: Fix typo

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Drop virQEMUCapsFreeStringList
Jiri Denemark [Fri, 3 Mar 2017 20:31:26 +0000 (21:31 +0100)] 
qemu: Drop virQEMUCapsFreeStringList

The implementation matches virStringListFreeCount. The only difference
between the two functions is the ordering of their parameters.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agonode: Replace variable named 'system' with 'syscap'
John Ferlan [Sat, 4 Mar 2017 15:42:33 +0000 (10:42 -0500)] 
node: Replace variable named 'system' with 'syscap'

Changes in commit id 'dec6d9df' caused a compilation failure on a RHEL6
CI build environment. So just replace 'system' with 'syscap' as a name.

cc1: warnings being treated as errors
../../src/conf/node_device_conf.c: In function 'virNodeDevCapSystemParseXML':
../../src/conf/node_device_conf.c:1415: error: declaration of 'system' shadows a global declaration [-Wshadow]

8 years agonodedev: Reduce virNodeDevCapDataPtr usage
John Ferlan [Thu, 2 Mar 2017 15:59:25 +0000 (10:59 -0500)] 
nodedev: Reduce virNodeDevCapDataPtr usage

Replace with more data specific pointer types.

8 years agoconf: Clean up the _virNodeDevCapData
John Ferlan [Thu, 2 Mar 2017 15:08:53 +0000 (10:08 -0500)] 
conf: Clean up the _virNodeDevCapData

Rather than a bunch of embedded union structs, let's create structs
for each of the structs within the union and make the struct easier
to read.

8 years agoconf: Alter coding style of nodedev function prototypes
John Ferlan [Thu, 2 Mar 2017 13:50:27 +0000 (08:50 -0500)] 
conf: Alter coding style of nodedev function prototypes

In an effort to be consistent with the source module, alter the function
prototypes to follow the similar style of source with the "type" on one
line followed by the function name and arguments on subsequent lines with
with argument getting it's own line.

8 years agoconf: Use consistent function name prefixes for virnodedeviceobj
John Ferlan [Thu, 2 Mar 2017 00:17:34 +0000 (19:17 -0500)] 
conf: Use consistent function name prefixes for virnodedeviceobj

Use "virNodeDeviceObj" as a prefix for any external API in virnodedeviceobj

8 years agoconf: Adjust coding style for nodedev conf sources
John Ferlan [Thu, 2 Mar 2017 13:39:11 +0000 (08:39 -0500)] 
conf: Adjust coding style for nodedev conf sources

Alter the format of the code to follow more recent style guidelines of
two empty lines between functions, function decls with "[static] type"
on one line followed by function name with arguments to functions each
on one line.

8 years agoconf: Introduce virnodedeviceobj
John Ferlan [Tue, 28 Feb 2017 18:24:26 +0000 (13:24 -0500)] 
conf: Introduce virnodedeviceobj

Move all the NodeDeviceObj API's into their own module virnodedeviceobj
from the node_device_conf

Purely code motion at this point, plus adjustments to cleanly build.

8 years agolxc: associate armv7l as 32-bit variant of aarch64
Matwey V. Kornilov [Fri, 24 Feb 2017 14:11:52 +0000 (17:11 +0300)] 
lxc: associate armv7l as 32-bit variant of aarch64

AArch64 kernels are technically capable of running armv7l binaries.
Though some vendors disable this feature during kernel build, we
need to allow it in LXC.

Signed-off-by: Matwey V. Kornilov <matwey.kornilov@gmail.com>
8 years agonews: Move host CPU model improvement to 3.2.0
Jiri Denemark [Fri, 3 Mar 2017 19:14:00 +0000 (20:14 +0100)] 
news: Move host CPU model improvement to 3.2.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocputest: Add CPUID data for Haswell with TSX
Jiri Denemark [Thu, 16 Feb 2017 13:41:29 +0000 (14:41 +0100)] 
cputest: Add CPUID data for Haswell with TSX

All existing Haswell CPUID data were gathered from CPUs with broken TSX.
Let's add new data for Haswell with correct TSX implementation.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocpu_x86: Disable TSX on broken models
Jiri Denemark [Wed, 15 Feb 2017 14:01:40 +0000 (15:01 +0100)] 
cpu_x86: Disable TSX on broken models

All Intel Haswell processors (except Xeon E7 v3 with stepping >= 4) have
TSX disabled by microcode update. As not all CPUs are guaranteed to be
patched with microcode updates we need to explicitly disable TSX on
affected CPUs to avoid its accidental usage.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agonews: Detect host CPU model by asking QEMU on x86_64
Jiri Denemark [Wed, 15 Feb 2017 09:29:44 +0000 (10:29 +0100)] 
news: Detect host CPU model by asking QEMU on x86_64

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocputest: Drop .new suffix from CPU test data files
Jiri Denemark [Mon, 13 Feb 2017 14:06:35 +0000 (15:06 +0100)] 
cputest: Drop .new suffix from CPU test data files

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocputest: Drop obsolete CPU test data files
Jiri Denemark [Mon, 13 Feb 2017 14:04:38 +0000 (15:04 +0100)] 
cputest: Drop obsolete CPU test data files

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocputest: Test virQEMUCapsInitCPUModel
Jiri Denemark [Mon, 13 Feb 2017 09:33:52 +0000 (10:33 +0100)] 
cputest: Test virQEMUCapsInitCPUModel

The original test didn't use family/model numbers to make better
decisions about the CPU model and thus mis-detected the model in the two
cases which are modified in this commit. The detected CPU models now
match those obtained from raw CPUID data.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocputest: Convert all json data files to query-cpu-model-expansion
Jiri Denemark [Mon, 13 Feb 2017 13:59:42 +0000 (14:59 +0100)] 
cputest: Convert all json data files to query-cpu-model-expansion

Converted by running the following command, renaming the files as
*.new, and committing only the *.new files.

    (cd tests/cputestdata; ./cpu-convert.py *.json)

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocputest: Switch host CPU data scripts to model expansion
Jiri Denemark [Wed, 1 Feb 2017 16:48:41 +0000 (17:48 +0100)] 
cputest: Switch host CPU data scripts to model expansion

Instantiating "host" CPU and querying it using qom-get has been the only
way of probing host CPU via QEMU until 2.9.0 implemented
query-cpu-model-expansion for x86_64. Even though libvirt never really
used the old way its result can be easily converted into the one
produced by query-cpu-model-expansion. Thus we can reuse the original
test data and possible get new data from hosts where QEMU does not
support the new QMP command.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Make virQEMUCapsInitCPUModel testable
Jiri Denemark [Thu, 23 Feb 2017 13:31:23 +0000 (14:31 +0100)] 
qemu: Make virQEMUCapsInitCPUModel testable

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Use full CPU model expansion on x86
Jiri Denemark [Thu, 23 Feb 2017 12:53:51 +0000 (13:53 +0100)] 
qemu: Use full CPU model expansion on x86

The static CPU model expansion is designed to return only canonical
names of all CPU properties. To maintain backwards compatibility libvirt
is stuck with different spelling of some of the features, but we need to
use the full expansion to get the additional spellings. In addition to
returning all spelling variants for all properties the full expansion
will contain properties which are not guaranteed to be migration
compatible. Thus, we need to combine both expansions. First we need to
call the static expansion to limit the result to migratable properties.
Then we can use the result of the static expansion as an input to the
full expansion to get both canonical names and their aliases.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Use enum for CPU model expansion type
Jiri Denemark [Tue, 31 Jan 2017 12:44:00 +0000 (13:44 +0100)] 
qemu: Use enum for CPU model expansion type

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Get host CPU model from QEMU on x86_64
Jiri Denemark [Wed, 11 Jan 2017 13:36:34 +0000 (14:36 +0100)] 
qemu: Get host CPU model from QEMU on x86_64

Until now host-model CPU mode tried to enable all CPU features supported
by the host CPU even if QEMU/KVM did not support them. This caused a
number of issues and made host-model quite unreliable. Asking QEMU for
the CPU it can provide and the current host makes host-model much more
robust.

This commit fixes the following bugs:

    https://bugzilla.redhat.com/show_bug.cgi?id=1018251
    https://bugzilla.redhat.com/show_bug.cgi?id=1371617
    https://bugzilla.redhat.com/show_bug.cgi?id=1372581
    https://bugzilla.redhat.com/show_bug.cgi?id=1404627
    https://bugzilla.redhat.com/show_bug.cgi?id=870071

In addition to that, the following bug should be mostly limited to cases
when an unsupported feature is explicitly requested:

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Probe "max" CPU model in TCG
Jiri Denemark [Wed, 22 Feb 2017 15:51:50 +0000 (16:51 +0100)] 
qemu: Probe "max" CPU model in TCG

Querying "host" CPU model expansion only makes sense for KVM. QEMU 2.9.0
introduces a new "max" CPU model which can be used to ask QEMU what the
best CPU it can provide to a TCG domain is.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Store more types in qemuMonitorCPUModelInfo
Jiri Denemark [Wed, 22 Feb 2017 15:01:30 +0000 (16:01 +0100)] 
qemu: Store more types in qemuMonitorCPUModelInfo

While query-cpu-model-expansion returns only boolean features on s390,
but x86_64 reports some integer and string properties which we are
interested in.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Prepare for more types in qemuMonitorCPUModelInfo
Jiri Denemark [Wed, 22 Feb 2017 14:46:47 +0000 (15:46 +0100)] 
qemu: Prepare for more types in qemuMonitorCPUModelInfo

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Rename hostCPU/feature element in capabilities cache
Jiri Denemark [Mon, 30 Jan 2017 15:30:13 +0000 (16:30 +0100)] 
qemu: Rename hostCPU/feature element in capabilities cache

The element will be generalized in the following commits.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agodocs: Update description of the host-model CPU mode
Jiri Denemark [Wed, 15 Feb 2017 09:18:53 +0000 (10:18 +0100)] 
docs: Update description of the host-model CPU mode

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agodomaincapstest: Add test data for QEMU 2.9.0
Jiri Denemark [Mon, 30 Jan 2017 15:10:49 +0000 (16:10 +0100)] 
domaincapstest: Add test data for QEMU 2.9.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemucapstest: Update test data for QEMU 2.9.0
Jiri Denemark [Mon, 30 Jan 2017 15:10:22 +0000 (16:10 +0100)] 
qemucapstest: Update test data for QEMU 2.9.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agotest: fix pcie-root-port-too-many test
Laine Stump [Wed, 22 Feb 2017 17:35:49 +0000 (12:35 -0500)] 
test: fix pcie-root-port-too-many test

While reviewing a patch from Andrea that modified this test case, I
realized that although it was "properly failing" (it's a negative
test), that it was failing for the wrong reason (the MULTIFUNCTION cap
wasn't set in the test case, so it was saying that multifunction=on
wasn't supported by the QEMU binary; instead it should have been
complaining that it had run out of PCI slots of the appropriate type
and couldn't automatically add any more).

This improper failure had started when I added the patch to
automatically aggregate pcie-root-ports onto multiple functions of
each pcie-root slot, but I hadn't noticed it because the test still
failed.

This patch corrects the test case to 1) set the MULTIFUNCTION flag in
the caps, and 2) attempt to add 241 pcie-root-ports to a domain. Since
there are 30 slots available on a pcie-root (slot 0 is reserved, and
slot 31 is used by the integrated SATA controller), and a
pcie-root-port can only be placed on a function of a slot on
pcie-root, the maximum number of pcie-root-ports in any domain is 240.

8 years agoFix location of blkid.h in include header
Nehal J Wani [Fri, 3 Mar 2017 15:42:09 +0000 (21:12 +0530)] 
Fix location of blkid.h in include header

The build system for libvirt correctly detects the location of blkid
using PKG_CONFIG_PATH environment variable. The file blkid.pc states
that the include flags should be: 'Cflags: -I${includedir}/blkid' but
libvirt searches for blkid.h inside ${includedir}/blkid/blkid, which is
wrong. Until now, the compilation for libvirt succeeded because of pure
luck, as it had -I/usr/include as a CFLAG. This issue was faced while
compiling libvirt on Ubuntu 16.04.2 with bare minimum dev packages and a
custom compiled blkid kept in a non-standard $prefix.

Signed-off-by: Nehal J Wani <nehaljw.kkd1@gmail.com>
8 years agonews: Add an empty <change> to each <section>
Andrea Bolognani [Fri, 3 Mar 2017 12:11:00 +0000 (13:11 +0100)] 
news: Add an empty <change> to each <section>

The generated HTML will contain <ul></ul> otherwise, which
triggers an error during 'make check'.

The proper fix would be not to generate the problematic
HTML in the first place but, while I'm working on it, this
workaround will do.

8 years agoqemu: Use ARCH_IS_X86() more
Andrea Bolognani [Thu, 2 Mar 2017 17:00:05 +0000 (18:00 +0100)] 
qemu: Use ARCH_IS_X86() more

In a few cases, we checked for VIR_ARCH_X86_64 and
VIR_ARCH_I686 separately: change all those to use the
ARCH_IS_X86() macro instead.

8 years agoqemu: Don't omit parentheses
Andrea Bolognani [Thu, 2 Mar 2017 16:52:45 +0000 (17:52 +0100)] 
qemu: Don't omit parentheses

The ARCH_IS_*() macro are defined in a way that allows
them to be used if a parentheses-less if statement, but
we don't really want that to happen

8 years agotests: Fix aliases for pSeries buses
Andrea Bolognani [Thu, 2 Mar 2017 14:51:44 +0000 (15:51 +0100)] 
tests: Fix aliases for pSeries buses

virQEMUCapsHasPCIMultiBus() performs a version check on
the QEMU binary to figure out whether multiple buses are
supported, so to get the correct aliases assigned when
dealing with pSeries guests we need to spoof the version
accordingly in the test suite.

8 years agoqemu: Drop QEMU_CAPS_PCI_MULTIBUS
Andrea Bolognani [Thu, 2 Mar 2017 14:40:29 +0000 (15:40 +0100)] 
qemu: Drop QEMU_CAPS_PCI_MULTIBUS

Due to the extra architecture-specific logic, it's already
necessary for users to call virQEMUCapsHasPCIMultiBus(),
so the capability itself is just a pointless distraction.

8 years agoPost-release version bump to 3.2.0
Andrea Bolognani [Fri, 3 Mar 2017 11:53:23 +0000 (12:53 +0100)] 
Post-release version bump to 3.2.0

8 years agoRelease of libvirt-3.1.0 v3.1.0
Daniel Veillard [Fri, 3 Mar 2017 10:22:43 +0000 (11:22 +0100)] 
Release of libvirt-3.1.0

* docs/news.xml: updated and regenerated NEWS
* po/*.po*: regenerated

8 years agoqemu: command: Truncate the chardev logging file even if append is not present
Peter Krempa [Wed, 1 Mar 2017 17:15:05 +0000 (18:15 +0100)] 
qemu: command: Truncate the chardev logging file even if append is not present

Our documentation states that the chardev logging file is truncated
unless append='on' is specified. QEMU also behaves the same way and
truncates the file unless we provide the argument. The new virlogd
implementation did not honor if the argument was missing and continued
to append to the file.

Truncate the file even when the 'append' attribute is not present to
behave the same with both implementations and adhere to the docs.

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

8 years agoqemuDomainAttachNetDevice: Support attach of type="user"
Michal Privoznik [Tue, 28 Feb 2017 16:49:49 +0000 (17:49 +0100)] 
qemuDomainAttachNetDevice: Support attach of type="user"

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

This has worked in previous releases.
My commit c266b60440 broke it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agotestNodeDeviceMockCreateVport: Don't call public APIs
Michal Privoznik [Tue, 28 Feb 2017 09:48:05 +0000 (10:48 +0100)] 
testNodeDeviceMockCreateVport: Don't call public APIs

This function is calling public APIs (virNodeDeviceLookupByName
etc.). That requires the driver lock to be unlocked and locked
again. If we, however, replace the public APIs calls with the
internal calls (that public APIs call anyway), we can drop the
lock/unlock exercise.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoconf: Fix leak in virNodeDeviceDefParseXML v3.1.0-rc2
John Ferlan [Mon, 20 Feb 2017 12:19:10 +0000 (07:19 -0500)] 
conf: Fix leak in virNodeDeviceDefParseXML

The 'nodes' is overwritten after the first usage and possibly leaked
if any code in the first set of parsing goes to error.

Found by Coverity.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agovirfile: Fix virFileExists commentary v3.1.0-rc1
Erik Skultety [Fri, 24 Feb 2017 13:33:08 +0000 (14:33 +0100)] 
virfile: Fix virFileExists commentary

Arguably though, function returning only on success is a very
interesting, although quite impractical concept. Also, the errno isn't
and shouldn't be preserved in this case, since the errno can be directly
fed to the virReportSystemError.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agoqemuProcessInit: Jump onto correct label in case of error
Michal Privoznik [Thu, 23 Feb 2017 16:10:55 +0000 (17:10 +0100)] 
qemuProcessInit: Jump onto correct label in case of error

After eca76884ea in case of error in qemuDomainSetPrivatePaths()
in pretended start we jump to stop. I've changed this during
review from 'cleanup' which turned out to be correct. Well, sort
of. We can't call qemuProcessStop() as it decrements
driver->nactive and we did not increment it. However, it calls
virDomainObjRemoveTransientDef() which is basically the only
function we need to call. So call that function and goto cleanup;

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agocputest: Use virArch enum rather than strings
Jiri Denemark [Mon, 13 Feb 2017 13:18:55 +0000 (14:18 +0100)] 
cputest: Use virArch enum rather than strings

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocputest: Rename x86 data files
Jiri Denemark [Mon, 13 Feb 2017 13:12:28 +0000 (14:12 +0100)] 
cputest: Rename x86 data files

While "x86" is a CPU sub driver name, it is not a recognized name of any
architecture known to libvirt. Let's use "x86_64" prefix which can be
used with virArch APIs.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocpu_x86: Introduce virCPUx86DataAddFeature
Jiri Denemark [Thu, 2 Feb 2017 19:30:04 +0000 (20:30 +0100)] 
cpu_x86: Introduce virCPUx86DataAddFeature

The API is useful for creating virCPUData in a hypervisor driver from
data we got by querying the hypervisor.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocpu_x86: Introduce virCPUx86DataSetVendor
Jiri Denemark [Thu, 2 Feb 2017 19:12:38 +0000 (20:12 +0100)] 
cpu_x86: Introduce virCPUx86DataSetVendor

The API is useful for creating virCPUData in a hypervisor driver from
data we got by querying the hypervisor.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocpu_x86: Introduce virCPUx86DataSetSignature
Jiri Denemark [Thu, 2 Feb 2017 15:14:22 +0000 (16:14 +0100)] 
cpu_x86: Introduce virCPUx86DataSetSignature

The API is useful for creating virCPUData in a hypervisor driver from
data we got by querying the hypervisor.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocpu_x86: Make virCPUx86DataAddCPUID work with virCPUDataPtr
Jiri Denemark [Thu, 2 Feb 2017 14:52:13 +0000 (15:52 +0100)] 
cpu_x86: Make virCPUx86DataAddCPUID work with virCPUDataPtr

The CPU driver provides APIs to create and free virCPUDataPtr. Thus all
APIs exported from the driver should work with that rather than
requiring the caller to pass a pointer to an internal part of the
structure.

In other words

    virCPUx86DataAddCPUID(cpudata, &cpuid)

is much better than the original

    virCPUx86DataAddCPUID(&cpudata->data.x86, &cpuid)

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocpu: Rework cpuDataFree
Jiri Denemark [Thu, 2 Feb 2017 14:37:40 +0000 (15:37 +0100)] 
cpu: Rework cpuDataFree

The new API is called virCPUDataFree. Individual CPU drivers are no
longer required to implement their own freeing function unless they need
to free architecture specific data from virCPUData.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocpu_x86: Make virCPUx86DataClear static
Jiri Denemark [Thu, 2 Feb 2017 14:23:36 +0000 (15:23 +0100)] 
cpu_x86: Make virCPUx86DataClear static

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocpu_x86: Drop virCPUx86MakeData and use virCPUDataNew
Jiri Denemark [Thu, 2 Feb 2017 11:19:13 +0000 (12:19 +0100)] 
cpu_x86: Drop virCPUx86MakeData and use virCPUDataNew

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Fix CPU model fallback in domain capabilities
Jiri Denemark [Tue, 10 Jan 2017 20:07:23 +0000 (21:07 +0100)] 
qemu: Fix CPU model fallback in domain capabilities

Our documentation of the domain capabilities XML says that the fallback
attribute of a CPU model is used to indicate whether the CPU model was
detected by libvirt itself (fallback="allow") or by asking the
hypervisor (fallback="forbid"). We need to properly set
fallback="forbid" when CPU model comes from QEMU to match the
documentation.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Refactor virQEMUCapsInitHostCPUModel
Jiri Denemark [Tue, 10 Jan 2017 18:16:24 +0000 (19:16 +0100)] 
qemu: Refactor virQEMUCapsInitHostCPUModel

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: properly escape socket path for graphics
Pavel Hrdina [Wed, 22 Feb 2017 19:25:00 +0000 (20:25 +0100)] 
qemu: properly escape socket path for graphics

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoutil: virqemu: introduce virQEMUBuildBufferEscape
Pavel Hrdina [Wed, 22 Feb 2017 19:20:42 +0000 (20:20 +0100)] 
util: virqemu: introduce virQEMUBuildBufferEscape

This will eventually replace virQEMUBuildBufferEscapeComma, however
it's not possible right now.  Some parts of the code that uses the
old function needs to be refactored.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoutil: virbuffer: introduce virBufferEscapeN
Pavel Hrdina [Thu, 23 Feb 2017 12:43:32 +0000 (13:43 +0100)] 
util: virbuffer: introduce virBufferEscapeN

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agotests: Reduce QEMU_CAPS_DEVICE_{DMI_TO_, }PCI_BRIDGE usage
Andrea Bolognani [Thu, 23 Feb 2017 18:14:15 +0000 (19:14 +0100)] 
tests: Reduce QEMU_CAPS_DEVICE_{DMI_TO_, }PCI_BRIDGE usage

Now that QEMU_CAPS_DEVICE_PCI_BRIDGE is no longer checked
unless a pci-bridge is really part of the configuration,
and most uses of the legacy PCI controller combo have been
dropped from tests that use PCIe machine types, we can
drop the corresponding capabilities from a lot of test
cases.

8 years agotests: Sync tests between qemuxml2argv and qemuxml2xml
Andrea Bolognani [Thu, 23 Feb 2017 17:47:36 +0000 (18:47 +0100)] 
tests: Sync tests between qemuxml2argv and qemuxml2xml

In some cases, only one of the two transformations was
checked; in other cases, the capabilities set differed.

8 years agoqemu_process: spice: don't release used port
Pavel Hrdina [Fri, 24 Feb 2017 01:28:40 +0000 (02:28 +0100)] 
qemu_process: spice: don't release used port

The port is stored in graphics configuration and it will
also get released in qemuProcessStop in case of error.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemu: Don't update physical storage size of empty drives CVE-2017-2635
Peter Krempa [Thu, 23 Feb 2017 09:07:30 +0000 (10:07 +0100)] 
qemu: Don't update physical storage size of empty drives

Previously the code called virStorageSourceUpdateBlockPhysicalSize which
did not do anything on empty drives since it worked only on block
devices. After the refactor in c5f6151390 it's called for all devices
and thus attempts to deref the NULL path of empty drives.

Add a check that skips the update of the physical size if the storage
source is empty.

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

8 years agoqemu: Fix incorrect jump labels in error paths
Marc Hartmayer [Thu, 23 Feb 2017 09:44:08 +0000 (10:44 +0100)] 
qemu: Fix incorrect jump labels in error paths

Fix incorrect jump labels in error paths as the stop jump is only
needed if the driver has already changed the state. For example
'virAtomicIntInc(&driver->nactive)' will be 'reverted' in the
qemuProcessStop call.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemu_cgroup: Only try to allow devices if devices CGroup's available
Michal Privoznik [Wed, 22 Feb 2017 14:20:15 +0000 (15:20 +0100)] 
qemu_cgroup: Only try to allow devices if devices CGroup's available

When a domain needs an access to some device (be it a disk, RNG,
chardev, whatever), we have to allow it in the devices CGroup (if
it is available), because by default we disallow all the devices.
But some of the functions that are responsible for setting up
devices CGroup are lacking check whether there is any CGroup
available. Thus users might be unable to hotplug some devices:

  virsh # attach-device fedora rng.xml
  error: Failed to attach device from rng.xml
  error: internal error: Controller 'devices' is not mounted

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoAdd ATTRIBUTE_FALLTHROUGH for switch cases without break
Daniel P. Berrange [Wed, 22 Feb 2017 17:37:09 +0000 (17:37 +0000)] 
Add ATTRIBUTE_FALLTHROUGH for switch cases without break

In GCC 7 there is a new warning triggered when a switch
case has a conditional statement (eg if ... else...) and
some of the code paths fallthrough to the next switch
statement. e.g.

conf/domain_conf.c: In function 'virDomainChrEquals':
conf/domain_conf.c:14926:12: error: this statement may fall through [-Werror=implicit-fallthrough=]
         if (src->targetTypeAttr != tgt->targetTypeAttr)
            ^
conf/domain_conf.c:14928:5: note: here
     case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE:
     ^~~~
conf/domain_conf.c: In function 'virDomainChrDefFormat':
conf/domain_conf.c:22143:12: error: this statement may fall through [-Werror=implicit-fallthrough=]
         if (def->targetTypeAttr) {
            ^
conf/domain_conf.c:22151:5: note: here
     default:
     ^~~~~~~

GCC introduced a __attribute__((fallthrough)) to let you
indicate that this is intentionale behaviour rather than
a bug.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoqemu: add missing break in qemuDomainDeviceCalculatePCIConnectFlags
Daniel P. Berrange [Wed, 22 Feb 2017 17:33:59 +0000 (17:33 +0000)] 
qemu: add missing break in qemuDomainDeviceCalculatePCIConnectFlags

One of the conditions in qemuDomainDeviceCalculatePCIConnectFlags
was missing a break that could result it in falling through to
an incorrect codepath.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agolibxl: fix empty string check for channel path
Daniel P. Berrange [Wed, 22 Feb 2017 17:18:51 +0000 (17:18 +0000)] 
libxl: fix empty string check for channel path

The libxl code was checking that a 'char *' was != '\0', instead
of checking the first element in the string

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoUse explicit boolean comparison in OOM check
Daniel P. Berrange [Wed, 22 Feb 2017 16:42:45 +0000 (16:42 +0000)] 
Use explicit boolean comparison in OOM check

GCC 7 gets upset by

   if (!tmp && (size * count))

warning

  util/viralloc.c: In function 'virReallocN':
  util/viralloc.c:246:23: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]
     if (!tmp && (size * count)) {
                 ~~~~~~^~~~~~~~

Keep it happy by adding != 0 to the right hand expression
so it realizes we really are wanting to treat the result
of the arithmetic expression as a boolean

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agovz: make more accurate closing connection to sdk
Nikolay Shirokovskiy [Fri, 3 Feb 2017 07:01:55 +0000 (10:01 +0300)] 
vz: make more accurate closing connection to sdk

Current code for example can call unsubscribe if connection
succeeds but subscribing fails. This will probabaly lead
only to spurious error messages without any actual inconsistencies
but nevertheless.

8 years agovirsh: Alter formatting a bit for output of domstats fields
John Ferlan [Thu, 9 Feb 2017 21:34:52 +0000 (16:34 -0500)] 
virsh: Alter formatting a bit for output of domstats fields

Alter the formatting of each line to not give the appearance of
one long run-on sentence and to be consistent between the various
elements of collected/displayed data. The formatting should fit
within the 80 character display. This removes the need for commas
at the end of each line.

8 years agoqemu: Allow multiple bridges when pci-bridges is not available
Andrea Bolognani [Tue, 21 Feb 2017 12:16:52 +0000 (13:16 +0100)] 
qemu: Allow multiple bridges when pci-bridges is not available

qemuDomainAssignPCIAddresses() hardcoded the assumption
that the only way to support devices on a non-zero bus is
to add one or more pci-bridges; however, since we now
support a large selection of PCI controllers that can be
used instead, the assumption is no longer true.

Moreover, this check was always redundant, because the
only sensible time to check for the availability of
pci-bridge is when building the QEMU command line, and
such a check is of course already in place.

In fact, there were *two* such checks, but since one of
the two was relying on the incorrect assumption explained
above, and it was redundant anyway, it has been dropped.

8 years agotests: Reduce usage of legacy PCI controllers on PCIe machines
Andrea Bolognani [Tue, 21 Feb 2017 13:30:39 +0000 (14:30 +0100)] 
tests: Reduce usage of legacy PCI controllers on PCIe machines

Up until a while ago, libvirt would automatically add a legacy
PCI controllers combo (dmi-to-pci-bridge + pci-bridge) to any
PCIe machine type (x86_64/q35 and aarch64/virt).

As a result, a number of input and output files in the test
suite ended up containing the legacy PCI controllers, even
though they are not needed or in any way relevant to the
feature being tested.

Get rid of most of the occurrences. Most of the time, this
just means removing the controllers from the input file and
regenerating the output files; in a few instances, some
minor tweaking is performed on the input file, most notably
removing the memory balloon: as memory balloon support was
not the scope of the test being changed, there is no loss
of test coverage from doing so.

Several occurrences of the legacy PCI controllers remain in
the test suite, both because removing their usage would have
required even more tweaking, and because we still want to
have coverage of this perfectly valid combination.

8 years agoconf: Make switch statements more strict
Andrea Bolognani [Tue, 21 Feb 2017 19:13:47 +0000 (20:13 +0100)] 
conf: Make switch statements more strict

When switching over the values in the virDomainControllerModelPCI
enumeration, make sure the proper cast is in place so that the
compiler can warn us when the coverage is not exaustive.

For the same reason, remove the 'default' case from one of the
existing switch statements.

8 years agoqemu: Make switch statements more strict
Andrea Bolognani [Tue, 21 Feb 2017 19:13:35 +0000 (20:13 +0100)] 
qemu: Make switch statements more strict

When switching over the values in the virDomainControllerModelPCI
enumeration, make sure the proper cast is in place so that the
compiler can warn us when the coverage is not exaustive.

For the same reason, fold some unstructured checks (performed by
comparing directly against some values in the enumeration) inside
an existing switch statement.

8 years agoconf: Remove dead code
Andrea Bolognani [Mon, 20 Feb 2017 14:56:18 +0000 (15:56 +0100)] 
conf: Remove dead code

The switch in virDomainPCIControllerModelToConnectType()
had some code that, while techically part of the
_PCIE_SWITCH_DOWNSTREAM_PORT case, was in fact dead due
to the early return.

Get rid of the dead code, and fix the inaccurate function
description while at it.

8 years agoqemu: Rename qemuAliasTLSObjFromChardevAlias
John Ferlan [Thu, 16 Feb 2017 19:59:06 +0000 (14:59 -0500)] 
qemu: Rename qemuAliasTLSObjFromChardevAlias

It's not really 'Chardev' specific - we can reuse this for other objects.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agocpu: Use virCPUData.arch in cpuDecode
Jiri Denemark [Thu, 2 Feb 2017 21:04:25 +0000 (22:04 +0100)] 
cpu: Use virCPUData.arch in cpuDecode

virCPUDef.arch is not required to be filled in for guest CPU
definitions. It doesn't make sense to artificially mandate it to be set
when cpuDecode is called especially when virCPUData.arch passed to
cpuDecode already contains the architecture.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocpu: Introduce virCPUDataNew
Jiri Denemark [Thu, 2 Feb 2017 11:09:52 +0000 (12:09 +0100)] 
cpu: Introduce virCPUDataNew

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Introduce virQEMUCapsFormatHostCPUModelInfo
Jiri Denemark [Fri, 13 Jan 2017 17:42:57 +0000 (18:42 +0100)] 
qemu: Introduce virQEMUCapsFormatHostCPUModelInfo

The CPU model info formating code in virQEMUCapsFormatCache will get
more complicated soon. Separating the code in
virQEMUCapsFormatHostCPUModelInfo will make the result easier to read.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Skip virQEMUCapsCPUFilterFeatures on non-x86 CPUs
Jiri Denemark [Wed, 18 Jan 2017 13:05:26 +0000 (14:05 +0100)] 
qemu: Skip virQEMUCapsCPUFilterFeatures on non-x86 CPUs

All features the function is currently supposed to filter out are
specific to x86_64. We should avoid removing them on other
architectures. It seems to be quite unlikely other achitectures would
use the same names, but one can never be sure.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agodocs: Fix since statement in host-model documentation
Jiri Denemark [Wed, 15 Feb 2017 08:24:16 +0000 (09:24 +0100)] 
docs: Fix since statement in host-model documentation

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agodocs: Drop obsolete statement about CPU modes and migration
Jiri Denemark [Tue, 14 Feb 2017 22:32:24 +0000 (23:32 +0100)] 
docs: Drop obsolete statement about CPU modes and migration

The guest CPU definition has always been updated automatically during
migration. And currently we just transform any host-model CPU into a
custom one when a domain starts.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoutil: storage: add JSON backing volume parser 'raw' block driver
Tomáš Golembiovský [Mon, 13 Feb 2017 22:53:43 +0000 (23:53 +0100)] 
util: storage: add JSON backing volume parser 'raw' block driver

The 'raw' block driver in Qemu is not directly interesting from
libvirt's perspective, but it can be layered above some other block
drivers and this may be interesting for the user.

The patch adds support for the 'raw' block driver. The driver is treated
simply as a pass-through and child driver in JSON is queried to get the
necessary information.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
8 years agoutil: storage: split function for JSON backing volume parsing in two
Tomáš Golembiovský [Mon, 13 Feb 2017 22:53:42 +0000 (23:53 +0100)] 
util: storage: split function for JSON backing volume parsing in two

Split virStorageSourceParseBackingJSON into two functions so that the
core can be reused by other functions. The new function called
virStorageSourceParseBackingJSONInternal accepts virJSONValuePtr.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
8 years agonews: Mention storage driver split
Peter Krempa [Wed, 8 Feb 2017 16:25:16 +0000 (17:25 +0100)] 
news: Mention storage driver split

8 years agospec: Modularize the storage driver
Peter Krempa [Wed, 8 Feb 2017 08:20:21 +0000 (09:20 +0100)] 
spec: Modularize the storage driver

Create a new set of sub-packages containing the new storage driver
modules so that certain heavy-weight backends (gluster, rbd) can be
installed separately only if required.

To keep backward compatibility the 'libvirt-driver-storage' package
will be turned into a virtual package pulling in all the new storage
backend sub-packages. The storage driver module will be moved into
libvirt-driver-storage-core including the filesystem backend which is
mandatory.

This then allows to make libvirt-daemon-driver-qemu depend only on the
core of the storage driver.

All other meta-packages still depend on the full storage driver and thus
pull in all the backends.

8 years agotests: drivermodule: Make sure that all compiled storage backends can be loaded
Peter Krempa [Tue, 7 Feb 2017 17:58:39 +0000 (18:58 +0100)] 
tests: drivermodule: Make sure that all compiled storage backends can be loaded

Add a new storage driver registration function that will force the
backend code to fail if any of the storage backend modules can't be
loaded. This will make sure that they work and are present.

8 years agostorage: Turn storage backends into dynamic modules
Peter Krempa [Tue, 7 Feb 2017 18:40:29 +0000 (19:40 +0100)] 
storage: Turn storage backends into dynamic modules

If driver modules are enabled turn storage driver backends into
dynamically loadable objects. This will allow greater modularity for
binary distributions, where heavyweight dependencies as rbd and gluster
can be avoided by selecting only a subset of drivers if the rest is not
necessary.

The storage modules are installed into 'LIBDIR/libvirt/storage-backend/'
and users can override the location by using
'LIBVIRT_STORAGE_BACKEND_DIR' environment variable.

rpm based distros will at this point install all the backends when
libvirt-daemon-driver-storage package is installed.

8 years agospec: Don't check for storage driver backends in configure script
Peter Krempa [Tue, 21 Feb 2017 09:16:04 +0000 (10:16 +0100)] 
spec: Don't check for storage driver backends in configure script

Explicitly enable --with-storage-scsi and disable --without-storage-zfs
and --without-storage-vstorage so that the configure script doesn't
check for them.

Note that --with-storage-dir is enabled by default.