]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
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
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
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
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
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.

8 years agoconf: Don't accept dummy values for <memoryBacking/> attributes
Michal Privoznik [Tue, 21 Feb 2017 16:24:17 +0000 (17:24 +0100)]
conf: Don't accept dummy values for <memoryBacking/> attributes

Our virSomeEnumTypeFromString() functions return either the value
of item from the enum or -1 on error. Usually however the value 0
means 'this value is not set in the domain XML, use some sensible
default'. Therefore, we don't accept corresponding string in
domain XML, for instance:

<memoryBacking>
  <source mode="none"/>
  <access mode="default"/>
  <allocation mode="none"/>
</memoryBacking>

should be rejected as invalid XML.

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

Fix a leak introduced by 4337bc57b when VIR_STRDUP'g the parent.

8 years agoconf: Cleanup matchFCHostToSCSIHost
John Ferlan [Mon, 20 Feb 2017 18:59:36 +0000 (13:59 -0500)]
conf: Cleanup matchFCHostToSCSIHost

Rather than the inlined VIR_FREE's, use a cleanup: label... Fixes an
issue introduced by 03346def where @name was free'd before usage in
a virAsprintf to format scsi_host_name.

8 years agoqemu: Fix deadlock across fork() in QEMU driver
Marc Hartmayer [Tue, 21 Feb 2017 12:11:00 +0000 (13:11 +0100)]
qemu: Fix deadlock across fork() in QEMU driver

The functions in virCommand() after fork() must be careful with regard
to accessing any mutexes that may have been locked by other threads in
the parent process. It is possible that another thread in the parent
process holds the lock for the virQEMUDriver while fork() is called.
This leads to a deadlock in the child process when
'virQEMUDriverGetConfig(driver)' is called and therefore the handshake
never completes between the child and the parent process. Ultimately
the virDomainObjectPtr will never be unlocked.

It gets much worse if the other thread of the parent process, that
holds the lock for the virQEMUDriver, tries to lock the already locked
virDomainObject. This leads to a completely unresponsive libvirtd.

It's possible to reproduce this case with calling 'virsh start XXX'
and 'virsh managedsave XXX' in a tight loop for multiple domains.

This commit fixes the deadlock in the same way as it is described in
commit 61b52d2e3813cc8c9ff3ab67f232bd0c65f7318d.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
8 years agonews: Mention specific vCPU hotplug API
Peter Krempa [Fri, 10 Feb 2017 17:03:52 +0000 (18:03 +0100)]
news: Mention specific vCPU hotplug API

8 years agotest: qemuhotplugtest: Add testing of individual vcpu hotplug
Peter Krempa [Fri, 10 Feb 2017 16:14:22 +0000 (17:14 +0100)]
test: qemuhotplugtest: Add testing of individual vcpu hotplug

Test that the vcpu entity selection code works properly

8 years agoqemu: Implement individual vcpu hotplug API
Peter Krempa [Tue, 21 Jun 2016 15:17:41 +0000 (17:17 +0200)]
qemu: Implement individual vcpu hotplug API

Add code that validates user's selection of cores and then uses the
existing code to plug in the vCPU.

8 years agovirsh: Implement command for virDomainSetVcpu called setvcpu
Peter Krempa [Tue, 21 Jun 2016 08:55:30 +0000 (10:55 +0200)]
virsh: Implement command for virDomainSetVcpu called setvcpu

Add a simple virsh command handler which makes use of the new API.

8 years agolib: Add API for specific vCPU hot(un)plug
Peter Krempa [Tue, 21 Jun 2016 08:44:51 +0000 (10:44 +0200)]
lib: Add API for specific vCPU hot(un)plug

Similarly to domainSetGuestVcpus this commit adds API which allows to
modify state of individual vcpus rather than just setting the count.

This allows to enable CPUs in specific guest NUMA nodes to achieve any
necessary configuration.

8 years agoqemu: Fix build breaker after incomplete merge
Martin Kletzander [Tue, 21 Feb 2017 13:17:10 +0000 (14:17 +0100)]
qemu: Fix build breaker after incomplete merge

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoqemu: Forbid slashes in shmem name
Martin Kletzander [Wed, 1 Feb 2017 16:14:00 +0000 (17:14 +0100)]
qemu: Forbid slashes in shmem name

With that users could access files outside /dev/shm.  That itself
isn't a security problem, but might cause some errors we want to
avoid.  So let's forbid slashes as we do with domain and volume names
and also mention that in the schema.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agostorage: Turn storage backends into static modules
Peter Krempa [Thu, 19 Jan 2017 14:14:20 +0000 (15:14 +0100)]
storage: Turn storage backends into static modules

Compile the storage driver into modules rather than by compiling all
files together. All modules are still linked together statically.

8 years agostorage: backend: Refactor registration of the backend drivers
Peter Krempa [Fri, 13 Jan 2017 15:50:11 +0000 (16:50 +0100)]
storage: backend: Refactor registration of the backend drivers

Add APIs that allow to dynamically register driver backends so that the
list of available drivers does not need to be known during compile time.

This will allow us to modularize the storage driver on runtime.

8 years agodaemon: Refactor connection driver module loading
Peter Krempa [Thu, 26 Jan 2017 13:57:41 +0000 (14:57 +0100)]
daemon: Refactor connection driver module loading

Pass the registration function name to virDriverLoadModule so that we
can later call specific functions if necessary (e.g. for testing
purposes). This gets rid of the rather ugly automatic name generator and
unifies the code to load/initialize the modules.

It's also clear which registration function gets called.

8 years agodriver: Split/refactor driver module loading
Peter Krempa [Wed, 18 Jan 2017 15:44:20 +0000 (16:44 +0100)]
driver: Split/refactor driver module loading

Split the convoluted driver loader function into simpler parts which
will potentially allow reuse.

8 years agotests: drivermodule: Drop unused macro arguments
Peter Krempa [Wed, 18 Jan 2017 12:19:59 +0000 (13:19 +0100)]
tests: drivermodule: Drop unused macro arguments

Refactors of the test resulted into the second argument of the 'TEST'
macro to be unused. Drop them.

8 years agotests: storagepoolxml2xml: Remove compile conditionals
Peter Krempa [Fri, 27 Jan 2017 16:02:19 +0000 (17:02 +0100)]
tests: storagepoolxml2xml: Remove compile conditionals

The XML2XML test should work properly even if the storage backend is
disabled, since it does not use it.

8 years agoconfigure: Fix configure output for RBD storage backend
Peter Krempa [Fri, 27 Jan 2017 16:46:32 +0000 (17:46 +0100)]
configure: Fix configure output for RBD storage backend

We'd print status for the 'dir' backend instead of the correct one.

8 years agoFormat printf format specifier used with niothreadids
Daniel P. Berrange [Mon, 20 Feb 2017 18:24:06 +0000 (18:24 +0000)]
Format printf format specifier used with niothreadids

The niothreadids struct field is size_t, so must use %zu not %lu
with printf. While they're identical on some platforms, on others
they are different, causing warnings

conf/domain_conf.c: In function 'virDomainDefCheckABIStabilityFlags':
conf/domain_conf.c:19575:26: error: format '%lu' expects argument of type 'long unsigned int', but argument 7 has type 'size_t {aka unsigned int}' [-Werror=format=]
                        _("Target domain iothreads count %lu does not "
                          ^

conf/domain_conf.c: In function 'virDomainDefFormatInternal':
conf/domain_conf.c:23915:46: error: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'size_t {aka unsigned int}' [-Werror=format=]
         virBufferAsprintf(buf, "<iothreads>%lu</iothreads>\n",
                                              ^

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoqemu_driver: move iothread duplicate check into one place
Pavel Hrdina [Mon, 13 Feb 2017 14:34:16 +0000 (15:34 +0100)]
qemu_driver: move iothread duplicate check into one place

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemu_driver: check whether iothread is used by controller
Pavel Hrdina [Sun, 12 Feb 2017 16:58:05 +0000 (17:58 +0100)]
qemu_driver: check whether iothread is used by controller

This follows the same check for disk, because we cannot remove iothread
if it's used by disk or by controller.  It could lead to crashing QEMU.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemu_driver: move iothread existence check into one place
Pavel Hrdina [Sun, 12 Feb 2017 18:13:47 +0000 (19:13 +0100)]
qemu_driver: move iothread existence check into one place

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemu_driver: always check whether iothread is used by disk or not
Pavel Hrdina [Sun, 12 Feb 2017 16:49:21 +0000 (17:49 +0100)]
qemu_driver: always check whether iothread is used by disk or not

If virDomainDelIOThread API was called with VIR_DOMAIN_AFFECT_LIVE
and VIR_DOMAIN_AFFECT_CONFIG and both XML were already a different
it could result in removing iothread from config XML even if there
was a disk using that iothread.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoconf: move iothread XML validation from qemu_command
Pavel Hrdina [Sun, 12 Feb 2017 14:05:53 +0000 (15:05 +0100)]
conf: move iothread XML validation from qemu_command

This will ensure that IOThreads are properly validated while
a domain is defined.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemu_process: remove unnecessary iothread check
Pavel Hrdina [Mon, 20 Feb 2017 17:05:18 +0000 (18:05 +0100)]
qemu_process: remove unnecessary iothread check

The situation covered by the removed code will not ever happen.
This code is called only while starting a new QEMU process where
the capabilities where already checked and while attaching to
existing QEMU process where we don't even detect the iothreads.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemu_process: move capabilities check for iothreads
Pavel Hrdina [Sun, 12 Feb 2017 03:14:32 +0000 (04:14 +0100)]
qemu_process: move capabilities check for iothreads

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemu_driver: check invalid iothread_id before we do anything else
Pavel Hrdina [Sun, 12 Feb 2017 01:53:38 +0000 (02:53 +0100)]
qemu_driver: check invalid iothread_id before we do anything else

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoconf: display all iothread ids in the XML if one of them is not generated
Pavel Hrdina [Mon, 20 Feb 2017 17:03:08 +0000 (18:03 +0100)]
conf: display all iothread ids in the XML if one of them is not generated

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoconf: move iothread parse code into its own function
Pavel Hrdina [Mon, 20 Feb 2017 09:26:07 +0000 (10:26 +0100)]
conf: move iothread parse code into its own function

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoconf: remove redundant iothreads variable
Pavel Hrdina [Fri, 10 Feb 2017 23:20:34 +0000 (00:20 +0100)]
conf: remove redundant iothreads variable

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoconf: fix indentation
Pavel Hrdina [Fri, 10 Feb 2017 15:13:32 +0000 (16:13 +0100)]
conf: fix indentation

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoDisallow inclusion of files from src/conf into src/utils
Peter Krempa [Mon, 20 Feb 2017 13:54:12 +0000 (14:54 +0100)]
Disallow inclusion of files from src/conf into src/utils

The utils code should stay separated from other code (except for very
well justified cases). Unfortunately commit 272769beccd7479c75e700a6cb
made it trivial to break the separation (and not get slapped by the
syntax-check rule) by adding -I src/conf to the CFLAGS for utils.

Remove this shortcut and except the two offenders from the syntax check
so that the codebase can be kept separated.

8 years agonode_device: Check return value for udev_new()
Marc Hartmayer [Fri, 10 Feb 2017 09:44:44 +0000 (10:44 +0100)]
node_device: Check return value for udev_new()

The comment was actually wrong as
https://www.freedesktop.org/software/systemd/man/udev_new.html#
mentions that on failure NULL is returned.  Also the same return value
is checked in src/interface/interface_backend_udev.c already.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
8 years agotests: add QEMU 2.9.0 caps data
Pavel Hrdina [Sun, 19 Feb 2017 22:47:21 +0000 (23:47 +0100)]
tests: add QEMU 2.9.0 caps data

QEMU 2.9.0 is not released yet but it's close to its release and
we need this data to implement new features that will be in
that release.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agotests: update QEMU 2.8.0 caps data
Pavel Hrdina [Sun, 19 Feb 2017 22:45:22 +0000 (23:45 +0100)]
tests: update QEMU 2.8.0 caps data

The old data was generated from not released QEMU.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemu: Allow @rendernode for virgl domains
Michal Privoznik [Thu, 9 Feb 2017 16:53:53 +0000 (17:53 +0100)]
qemu: Allow @rendernode for virgl domains

When enabling virgl, qemu opens /dev/dri/render*. So far, we are
not allowing that in devices CGroup nor creating the file in
domain's namespace and thus requiring users to set the paths in
qemu.conf. This, however, is suboptimal as it allows access to
ALL qemu processes even those which don't have virgl configured.
Now that we have a way to specify render node that qemu will use
we can be more cautious and enable just that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agonews: add entries for recent nodedev driver improvements
Michal Privoznik [Fri, 17 Feb 2017 15:52:44 +0000 (16:52 +0100)]
news: add entries for recent nodedev driver improvements

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemuDomainGetHostdevPath: Report /dev/vfio/vfio less frequently
Michal Privoznik [Thu, 9 Feb 2017 13:14:09 +0000 (14:14 +0100)]
qemuDomainGetHostdevPath: Report /dev/vfio/vfio less frequently

So far, qemuDomainGetHostdevPath has no knowledge of the reasong
it is called and thus reports /dev/vfio/vfio for every VFIO
backed device. This is suboptimal, as we want it to:

a) report /dev/vfio/vfio on every addition or domain startup
b) report /dev/vfio/vfio only on last VFIO device being unplugged

If a domain is being stopped then namespace and CGroup die with
it so no need to worry about that. I mean, even when a domain
that's exiting has more than one VFIO devices assigned to it,
this function does not clean /dev/vfio/vfio in CGroup nor in the
namespace. But that doesn't matter.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
8 years agoqemuDomainGetHostdevPath: Create /dev/vfio/vfio iff needed
Michal Privoznik [Wed, 8 Feb 2017 13:23:30 +0000 (14:23 +0100)]
qemuDomainGetHostdevPath: Create /dev/vfio/vfio iff needed

So far, we are allowing /dev/vfio/vfio in the devices cgroup
unconditionally (and creating it in the namespace too). Even if
domain has no hostdev assignment configured. This is potential
security hole. Therefore, when starting the domain (or
hotplugging a hostdev) create & allow /dev/vfio/vfio too (if
needed).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
8 years agoqemuSetupHostdevCgroup: Use qemuDomainGetHostdevPath
Michal Privoznik [Thu, 9 Feb 2017 10:01:29 +0000 (11:01 +0100)]
qemuSetupHostdevCgroup: Use qemuDomainGetHostdevPath

Since these two functions are nearly identical (with
qemuSetupHostdevCgroup actually calling virCgroupAllowDevicePath)
we can have one function call the other and thus de-duplicate
some code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
8 years agoqemu_cgroup: Kill qemuSetupHostSCSIVHostDeviceCgroup
Michal Privoznik [Thu, 9 Feb 2017 09:30:23 +0000 (10:30 +0100)]
qemu_cgroup: Kill qemuSetupHostSCSIVHostDeviceCgroup

There's no need for this function. Currently it is passed as a
callback to virSCSIVHostDeviceFileIterate(). However, SCSI host
devices have just one file path. Therefore we can mimic approach
used in qemuDomainGetHostdevPath() to get path and call
virCgroupAllowDevicePath() directly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
8 years agoqemu_cgroup: Kill qemuSetupHostSCSIDeviceCgroup
Michal Privoznik [Thu, 9 Feb 2017 09:25:28 +0000 (10:25 +0100)]
qemu_cgroup: Kill qemuSetupHostSCSIDeviceCgroup

There's no need for this function. Currently it is passed as a
callback to virSCSIDeviceFileIterate(). However, SCSI devices
have just one file path. Therefore we can mimic approach used in
qemuDomainGetHostdevPath() to get path and call
virCgroupAllowDevicePath() directly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
8 years agoqemu_cgroup: Kill qemuSetupHostUSBDeviceCgroup
Michal Privoznik [Thu, 9 Feb 2017 09:16:12 +0000 (10:16 +0100)]
qemu_cgroup: Kill qemuSetupHostUSBDeviceCgroup

There's no need for this function. Currently it is passed as a
callback to virUSBDeviceFileIterate(). However, USB devices have
just one file path. Therefore we can mimic approach used in
qemuDomainGetHostdevPath() to get path and call
virCgroupAllowDevicePath() directly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
8 years agoutil: virvhba: fix typo that breaks build on non-linux systems
Pavel Hrdina [Sun, 19 Feb 2017 14:47:27 +0000 (15:47 +0100)]
util: virvhba: fix typo that breaks build on non-linux systems

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agotests: Add createVHBAByNodeDevice-parent-fabric-wwn to fchosttest
John Ferlan [Tue, 24 Jan 2017 18:53:08 +0000 (13:53 -0500)]
tests: Add createVHBAByNodeDevice-parent-fabric-wwn to fchosttest

Add a test that allows providing the parent fabric_wwn in the input XML
in order to create the vHBA.

This also fixes a mixed setting of the fabric_wwn field from the read
test driver XML strings.