Commit Graph

29570 Commits

Author SHA1 Message Date
Peter Krempa
d8be0f4bc3 qemu: domain: Use virXMLFormatElement in qemuDomainObjPrivateXMLFormatJob
Modernize the code by using the clever formatter rather than checking
manually when to format the end of the element.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-13 13:54:11 +01:00
Peter Krempa
3a4649b532 qemu: domain: Return early in qemuDomainObjPrivateXMLFormatJob
Remove one level of nesting by returing early.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-13 13:54:11 +01:00
Peter Krempa
d33adb9173 qemu: domain: Don't overwrite job type in private data
The code overwrote the internal job type and then fixed it back. Since
the job type is not accessed in the code this does not make much sense.
Use the temporary value instead.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-13 13:54:11 +01:00
Peter Krempa
d2cd7215e7 qemu: domain: Split out formating of Job data from private data formatter
Separate the code for later refactoring

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-13 13:54:11 +01:00
Peter Krempa
4833e128a2 tests: qemuxml2xml: Add status XML with outgoing migration with NBD
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-13 13:54:11 +01:00
Peter Krempa
881af99766 tests: qemuxml2xml: Add modern example of status XML to the test
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-13 13:54:11 +01:00
Peter Krempa
1b28038300 tests: util: Remove callback from testCompareDomXML2XMLFiles
The testCompareDomXML2XMLPreFormatCallback is no longer used and thus
can be removed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-13 13:54:11 +01:00
Peter Krempa
d1a7fc8bb3 tests: qemuxml2xml: Remove fake status XML testing
Now that the better approach is in place we can remove the old functions
doing the fake formatting.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-13 13:54:11 +01:00
Peter Krempa
99178b050f tests: qemuxml2xml: Add synthetic test for <lockstate> in status XML
Add a random lockstate string to the status XML2XML test.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-13 13:54:11 +01:00
Peter Krempa
99e30acfdc tests: qemuxml2xml: Add proper domain status XML testing
Add new approach to properly test status XML files by supplying a full
XML file rather than generating synthetic test cases by prepending the
status header. The two tests introduced here are copies of existing
cases using the synthetic header so that current level of testing is
kept. The files are chosen to excercising the vcpu and blockjob quirks
present in the current testing.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-13 13:54:11 +01:00
Peter Krempa
c4a5b77ffb tests: domainsnapshotxml2xml: Remove testing with allowed format detection
We have a test of the domain XML that allows format detection, so
there's no need to do it for snapshot XMLs where the parameter would
influence the domain XML portion.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-13 13:54:06 +01:00
Peter Krempa
9fc796887d tests: qemuxml2xml: Remove testing with allowed format detection
Nobody should use format detection due to security implications. The
result of the change is that 'raw' format will be printed unless
specified explicitly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-13 13:05:43 +01:00
Peter Krempa
d493e03ad4 tests: qemu: Explicitly add tests with format probing allowed
Add a single testcase for the case where format probing is allowed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-13 13:05:43 +01:00
Peter Krempa
5972e8631f tests: qemuxml2xml: Rename testInfoFree to testInfoClear
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-13 13:05:43 +01:00
Ján Tomko
1ab2574731 qemuDomainUSBAddressAddHubs: use numeric comparison
Since data.count is not a pointer, but an integer,
compare it against an integer value instead of using
the implicit "boolean" conversion that is customarily
used for pointers.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-03-13 10:38:48 +01:00
Ján Tomko
c8ab5aeb14 Adjust whitespace in virDomainDefHasUSB prototype
To match the rest of the file.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-03-13 10:31:56 +01:00
Jim Fehlig
33c6eb9689 libvirtd: fix potential deadlock when reloading
It is possible to deadlock libvirtd when concurrently starting a domain
and restarting the daemon. Threads involved in the deadlock are

Thread 4 (Thread 0x7fc13b53e700 (LWP 64084)):
/lib64/libpthread.so.0
    at util/virthread.c:154
    at qemu/qemu_monitor.c:1083
    cmd=0x7fc110017700, scm_fd=-1, reply=0x7fc13b53d318) at
qemu/qemu_monitor_json.c:305
cmd=0x7fc110017700,
    reply=0x7fc13b53d318) at qemu/qemu_monitor_json.c:335
    at qemu/qemu_monitor_json.c:1298
    at qemu/qemu_monitor.c:1697
    vm=0x7fc110003d00, asyncJob=QEMU_ASYNC_JOB_START) at qemu/qemu_process.c:1763
vm=0x7fc110003d00,
    asyncJob=6, logCtxt=0x7fc1100089c0) at qemu/qemu_process.c:1835
    vm=0x7fc110003d00, asyncJob=6, logCtxt=0x7fc1100089c0) at
qemu/qemu_process.c:2180
driver=0x7fc12004e1e0,
    vm=0x7fc110003d00, asyncJob=QEMU_ASYNC_JOB_START, incoming=0x0, snapshot=0x0,
    vmop=VIR_NETDEV_VPORT_PROFILE_OP_CREATE, flags=17) at qemu/qemu_process.c:6111
driver=0x7fc12004e1e0,
    vm=0x7fc110003d00, updatedCPU=0x0, asyncJob=QEMU_ASYNC_JOB_START,
migrateFrom=0x0,
    migrateFd=-1, migratePath=0x0, snapshot=0x0,
vmop=VIR_NETDEV_VPORT_PROFILE_OP_CREATE,
    flags=17) at qemu/qemu_process.c:6334
    xml=0x7fc110000ed0 "<!--\nWARNING: THIS IS AN AUTO-GENERATED FILE.
CHANGES TO IT ARE LIKELY TO BE\nOVERWRITTEN AND LOST. Changes to this xml
configuration should be made using:\n  virsh edit testvv\nor other
applicati"..., flags=0) at qemu/qemu_driver.c:1776
...

Thread 1 (Thread 0x7fc143c66880 (LWP 64081)):
/lib64/libpthread.so.0
    at util/virthread.c:122
conf/nwfilter_conf.c:159
sig=0x7ffe0a831e30,
    opaque=0x0) at remote/remote_daemon.c:724
    opaque=0x558c5328b230) at rpc/virnetdaemon.c:654
    at util/vireventpoll.c:508
rpc/virnetdaemon.c:858
remote/remote_daemon.c:1496
(gdb) thr 1
[Switching to thread 1 (Thread 0x7fc143c66880 (LWP 64081))]
/lib64/libpthread.so.0
(gdb) f 1
    at util/virthread.c:122
122	    pthread_rwlock_wrlock(&m->lock);
(gdb) p updateLock
$1 = {lock = {__data = {__lock = 0, __nr_readers = 1, __readers_wakeup = 0,
      __writer_wakeup = 0, __nr_readers_queued = 0, __nr_writers_queued = 1,
__writer = 0,
      __shared = 0, __rwelision = 0 '\000', __pad1 = "\000\000\000\000\000\000",
      __pad2 = 0, __flags = 0},
    __size = "\000\000\000\000\001", '\000' <repeats 15 times>, "\001",
'\000' <repeats 34 times>, __align = 4294967296}}

Reloading of the nwfilter driver is stuck waiting for a write lock, which
already has a reader (from qemuDomainCreateXML) in the critical section.
Since the reload occurs in the context of the main event loop thread,
libvirtd becomes deadlocked. The deadlock can be avoided by offloading
the reload work to a thread.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-03-12 10:30:13 -06:00
Roman Bogorodskiy
de3fe191f5 bhyve: fix crash on missing interface model
The bhyve driver crashes in bhyveBuildNetArgStr() when
network interface model is not defined. As it has to be provided
explicitly, add a check to report an error if it's missing.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2018-03-12 20:08:03 +04:00
Roman Bogorodskiy
1b6ff36c2f Fix build with clang 6.0.0
Clang 6.0.0 complains when initializing structure with { NULL }:

conf/domain_addr.c:1494:38: error: missing field 'type' initializer [-Werror,-Wmissing-field-initializers]
    virDomainDeviceInfo nfo = { NULL };

Use { 0 } instead to make it happy.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2018-03-12 20:04:08 +04:00
Andrea Bolognani
ea9b0e580a keycodemapdb: Update submodule
This time around it's not enough to just pick the latest commit,
because with aed87bb2aa6ed83b49574eb982e3bdd4c36acf17 keycodemapdb
renamed the 'rfb' keycode to 'qnum' and we need to accept the new
name while maintaining backwards compatibility.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-03-12 16:30:49 +01:00
John Ferlan
d45bee449c tools: Add support for additional adapter parent options
Add the ability to provide the adapter parent_wwnn and parent_wwpn
or the parent_fabric_wwn on the virsh command line for the pool
define/create as commands.  Update the virsh.pod description.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-03-12 09:00:37 -04:00
John Ferlan
8d2247dfd1 tools: Update the help description of the adapter-parent field
One short sentence won't do it justice, but it could help by listing
scsi_hostN and vHBA to point one in the right direction.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-03-12 09:00:32 -04:00
John Ferlan
3d79246888 tools: Add the wwnn/wwpn to the man page for storage pool fields
The description was missing the wwnn and wwpn names for the
--adapter-wwnn and --adapter-wwpn switches. Just add it to be
clear that the fields cannot be empty (IOW they are not boolean).

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-03-12 09:00:09 -04:00
Michal Privoznik
e43263601f conf: Check for user aliases duplicates only
https://bugzilla.redhat.com/show_bug.cgi?id=1553162

When validating a device XML config we check if user provided
alias is unique. We do this by maintaining a hash table of device
aliases as we iterated over all devices defined for the domain.
However, it may happen that what appears as two devices in domain
XML is in fact just one interface in hypervisor.  We can assume
libvirt generated aliases to be unique and thus really check user
provided ones only.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-03-12 13:27:24 +01:00
Michal Privoznik
e5673ed444 virDomainDeviceValidateAliasForHotplug: Use correct domain defintion
https://bugzilla.redhat.com/show_bug.cgi?id=1553075

For some weird reason this function is getting live and
persistent def for domain but then accesses vm->def and
vm->newDef directly. This is rather unsafe as we can be
accessing NULL pointer.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-03-12 13:27:24 +01:00
Daniel P. Berrangé
fc0f856315 Update to latest gnulib
GnuLib has now fixed the incompatibility with latest GLibC
that was affecting builds on Fedora rawhide. We can thus
update and drop our local workaround.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-03-12 11:27:54 +00:00
Julio Faracco
dff3fab47f qemu: different declarations for the same method
Recently, this warning is appearing while libvirt is being compiled:
Function 'qemuAssignDeviceDiskAlias' argument order different:
declaration 'vmdef, def' definition 'def, disk'

This commit change the default declaration for qemuAssignDeviceDiskAlias
specified at src/qemu/qemu_alias.c.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2018-03-12 11:02:09 +01:00
Michal Privoznik
bf1b24514b libvirt:spec: Require gcc for build
According to latest discussion on fedora devel list [1] gcc will
be removed from default buildroot and packages requiring it must
have explicit build dependency,

1: https://lists.fedoraproject.org/archives/list/devel-announce@lists.fedoraproject.org/thread/IJFYI5Q2BYZKIGDFS2WLOBDUSEGWHIKV/

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2018-03-12 10:32:44 +01:00
Peter Krempa
2ccfbaa356 qemu: Add qemu functions for storage source private data handling
The qemu driver registered the helpers from util code, but it will be
necessary to format also some qemu-specific data.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-12 10:04:56 +01:00
Andrea Bolognani
b9b9195f15 qemu: Remove old qemuDomainDeviceDefValidateControllerPCI()
We've implemented all existing checks, and more, in the new
function, so we can finally drop the old one.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
2018-03-09 16:57:27 +01:00
Andrea Bolognani
07160b65db qemu: Validate PCI controllers (QEMU capabilities)
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
2018-03-09 16:57:27 +01:00
Andrea Bolognani
97727e060c qemu: Validate PCI controller options (chassis and port)
https://bugzilla.redhat.com/show_bug.cgi?id=1483816

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
2018-03-09 16:57:27 +01:00
Andrea Bolognani
6fef5bf301 qemu: Validate PCI controller options (chassisNr)
https://bugzilla.redhat.com/show_bug.cgi?id=1483816

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
2018-03-09 16:57:27 +01:00
Andrea Bolognani
c651cdbce6 qemu: Validate PCI controller options (numaNode)
This change catches an invalid use of the option in our
test suite.

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
2018-03-09 16:57:27 +01:00
Andrea Bolognani
5bd8764ee0 qemu: Validate PCI controller options (busNr)
This change catches an invalid use of the option in our
test suite.

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
2018-03-09 16:57:27 +01:00
Andrea Bolognani
932b6e1afc qemu: Validate PCI controller options (pcihole64)
https://bugzilla.redhat.com/show_bug.cgi?id=1483816

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
2018-03-09 16:57:26 +01:00
Andrea Bolognani
dd8a8f1df3 qemu: Validate PCI controller options (targetIndex)
https://bugzilla.redhat.com/show_bug.cgi?id=1483816

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
2018-03-09 16:57:22 +01:00
Andrea Bolognani
68b1491e89 qemu: Validate PCI controller options (index)
https://bugzilla.redhat.com/show_bug.cgi?id=1483816

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
2018-03-09 16:57:22 +01:00
Andrea Bolognani
5a8b8b3f00 qemu: Validate PCI controller options (modelName)
https://bugzilla.redhat.com/show_bug.cgi?id=1483816

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
2018-03-09 16:57:19 +01:00
Andrea Bolognani
e43103cbd0 qemu: Create new qemuDomainDeviceDefValidateControllerPCI()
The existing function is renamed and called from the new one, so
that even while we're in the process of implementing new checks
all the existing ones will be performed.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
2018-03-09 16:57:18 +01:00
Ján Tomko
90d7262552 remote: simplify condition
In remoteConnectOpen, conn->uri cannot be NULL in the second
part of the OR expression due to short-circuit evaluation.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-03-08 17:40:57 +01:00
Ján Tomko
451407c8c4 qemu: simplify condition
In qemuMigrationSrcRun, we already checked for non-NULL mig
and then dereferenced it. It's only possible for mig to be
NULL in the error section.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-03-08 17:40:56 +01:00
Christian Ehrhardt
dadfba923a
apparmor: add ro rule for sasl GSSAPI plugin on /etc/gss/mech.d/
If a system has sasl GSSAPI plugin available qemu with sasl support will
try to read /etc/gss/mech.d/.

It is required to allow that to let the modules fully work and it should
be safe to do so as it only registers/configures plugins but has no secrets.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Acked-by: Jamie Strandboge <jamie@canonical.com>
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
2018-03-08 17:35:36 +01:00
Ján Tomko
39a6df5334 virsh: use logical or for boolean values
Bitwise or just looks wrong here.
Introduced by <commit 69e0cd3>.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-03-08 16:51:39 +01:00
Ján Tomko
8a4559c1aa virsh-edit: remove unreachable break
Introduced by <commit 1bb1de8>.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-03-08 16:51:31 +01:00
Ján Tomko
d3b8a81ae6 openvz: pass sizeof to snprintf
The size argument accounts for the nul-byte to terminate
the string. Use sizeof and remove the pointless assignment.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-03-08 16:45:54 +01:00
Ján Tomko
1efdab281f nwfilter: remove pointless assignment
Changing a parameter passed by value has no effect.

Introduced by <commit 3f74b2eb>.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-03-08 16:45:54 +01:00
Ján Tomko
0a12d96c85 maint: use parentheses after if
Some instances of ARCH_IS_PPC64 did not use them.

Introduced by commits da636d8 and ef08a54

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-03-08 16:45:54 +01:00
Daniel P. Berrangé
eefabb38c3 rpc: switch virtlockd and virtlogd to use single-threaded dispatch
Currently both virtlogd and virtlockd use a single worker thread for
dispatching RPC messages. Even this is overkill and their RPC message
handling callbacks all run in short, finite time and so blocking the
main loop is not an issue like you'd see in libvirtd with long running
QEMU commands.

By setting max_workers==0, we can turn off the worker thread and run
these daemons single threaded. This in turn fixes a serious problem in
the virtlockd daemon whereby it loses all fcntl() locks at re-exec due
to multiple threads existing. fcntl() locks only get preserved if the
process is single threaded at time of exec().

Reviewed-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-03-08 15:40:29 +00:00
Daniel P. Berrangé
86cae503a4 rpc: avoid crashing in pre-exec if no workers are present
If max_workers is set to zero, then the worker thread pool won't be
created, so when serializing state for pre-exec we must set various
parameters to zero.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-03-08 15:40:29 +00:00