Commit Graph

25549 Commits

Author SHA1 Message Date
Tomáš Golembiovský
e4c6d4ae55 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>
2017-02-22 10:39:57 +01:00
Tomáš Golembiovský
cb4adb43d6 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>
2017-02-22 10:39:39 +01:00
Peter Krempa
b26401fab3 news: Mention storage driver split 2017-02-22 09:31:33 +01:00
Peter Krempa
27c8e36d60 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.
2017-02-22 09:31:33 +01:00
Peter Krempa
93a3f516ee 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.
2017-02-22 09:31:33 +01:00
Peter Krempa
0a6d3e51b4 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.
2017-02-22 09:31:33 +01:00
Peter Krempa
4fb105f681 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.
2017-02-22 09:31:33 +01:00
Michal Privoznik
0888cb6ab4 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>
2017-02-22 09:11:33 +01:00
John Ferlan
5ad03b9db2 conf: Fix leak in virNodeDeviceObjListExport
Fix a leak introduced by 4337bc57b when VIR_STRDUP'g the parent.
2017-02-21 10:52:20 -05:00
John Ferlan
0a6cb28b9a 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.
2017-02-21 10:52:20 -05:00
Marc Hartmayer
e22de286b1 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 61b52d2e38.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
2017-02-21 15:47:32 +01:00
Peter Krempa
6304277534 news: Mention specific vCPU hotplug API 2017-02-21 15:28:07 +01:00
Peter Krempa
bd8f10c62a test: qemuhotplugtest: Add testing of individual vcpu hotplug
Test that the vcpu entity selection code works properly
2017-02-21 15:27:24 +01:00
Peter Krempa
f557b3351e 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.
2017-02-21 15:27:20 +01:00
Peter Krempa
f0326d6dd9 virsh: Implement command for virDomainSetVcpu called setvcpu
Add a simple virsh command handler which makes use of the new API.
2017-02-21 15:06:59 +01:00
Peter Krempa
8f657259bb 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.
2017-02-21 15:06:59 +01:00
Martin Kletzander
054358e8de qemu: Fix build breaker after incomplete merge
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-02-21 14:17:10 +01:00
Martin Kletzander
1c06d0faba 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>
2017-02-21 12:47:24 +01:00
Peter Krempa
e441de669f 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.
2017-02-21 09:55:01 +01:00
Peter Krempa
f813fe810f 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.
2017-02-21 09:34:30 +01:00
Peter Krempa
633b7592d6 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.
2017-02-21 09:24:33 +01:00
Peter Krempa
0e1404d444 driver: Split/refactor driver module loading
Split the convoluted driver loader function into simpler parts which
will potentially allow reuse.
2017-02-21 08:48:51 +01:00
Peter Krempa
2e4e6affdd tests: drivermodule: Drop unused macro arguments
Refactors of the test resulted into the second argument of the 'TEST'
macro to be unused. Drop them.
2017-02-21 08:19:11 +01:00
Peter Krempa
58ea495988 tests: storagepoolxml2xml: Remove compile conditionals
The XML2XML test should work properly even if the storage backend is
disabled, since it does not use it.
2017-02-21 08:19:11 +01:00
Peter Krempa
17c4b07a38 configure: Fix configure output for RBD storage backend
We'd print status for the 'dir' backend instead of the correct one.
2017-02-21 08:19:11 +01:00
Daniel P. Berrange
f88b6e4285 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>
2017-02-20 18:24:06 +00:00
Pavel Hrdina
7f602b8291 qemu_driver: move iothread duplicate check into one place
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-02-20 18:44:47 +01:00
Pavel Hrdina
99f00fb8bc 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>
2017-02-20 18:44:24 +01:00
Pavel Hrdina
c6d2fba69c qemu_driver: move iothread existence check into one place
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-02-20 18:44:02 +01:00
Pavel Hrdina
ae27cb9add 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>
2017-02-20 18:43:11 +01:00
Pavel Hrdina
c96bd78e4e 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>
2017-02-20 18:42:24 +01:00
Pavel Hrdina
5b37115c3c 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>
2017-02-20 18:41:51 +01:00
Pavel Hrdina
7e3dd50650 qemu_process: move capabilities check for iothreads
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-02-20 18:41:30 +01:00
Pavel Hrdina
caf66e0196 qemu_driver: check invalid iothread_id before we do anything else
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-02-20 18:41:06 +01:00
Pavel Hrdina
a4a1ad2066 conf: display all iothread ids in the XML if one of them is not generated
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-02-20 18:40:54 +01:00
Pavel Hrdina
3fc6512a3d conf: move iothread parse code into its own function
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-02-20 17:30:55 +01:00
Pavel Hrdina
875b77821f conf: remove redundant iothreads variable
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-02-20 17:30:55 +01:00
Pavel Hrdina
2b5dcda7a9 conf: fix indentation
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-02-20 17:30:54 +01:00
Peter Krempa
b4c7310633 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 272769becc
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.
2017-02-20 15:12:07 +01:00
Marc Hartmayer
3427b36cc1 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>
2017-02-20 14:44:27 +01:00
Pavel Hrdina
579fc9a287 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>
2017-02-20 13:13:52 +01:00
Pavel Hrdina
a6e28aa599 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>
2017-02-20 12:46:15 +01:00
Michal Privoznik
5c74cf1f44 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>
2017-02-20 10:44:22 +01:00
Michal Privoznik
dfa79bd82b news: add entries for recent nodedev driver improvements
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-02-20 07:39:34 +01:00
Michal Privoznik
1bb787fdc9 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>
2017-02-20 07:21:59 +01:00
Michal Privoznik
b8e659aa98 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>
2017-02-20 07:21:58 +01:00
Michal Privoznik
9d92f533f8 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>
2017-02-20 07:21:58 +01:00
Michal Privoznik
60ddceff8f 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>
2017-02-20 07:21:58 +01:00
Michal Privoznik
7bb01ed3cd 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>
2017-02-20 07:21:58 +01:00
Michal Privoznik
4d7d1c4bc3 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>
2017-02-20 07:21:58 +01:00