Commit Graph

23536 Commits

Author SHA1 Message Date
Andrea Bolognani
55d8daa07e spec: Fix indentation
Commit ffc49e579c broke syntax-check:

  cppi: libvirt.spec.in: line 622: not properly indented
  cppi: libvirt.spec.in: line 624: not properly indented
  cppi: libvirt.spec.in: line 640: not properly indented
  cppi: libvirt.spec.in: line 642: not properly indented
  maint.mk: incorrect preprocessor indentation
  cfg.mk:697: recipe for target 'sc_spec_indentation' failed

Indent the new conditionals properly.
2016-07-13 19:02:15 +02:00
Martin Kletzander
05f89657ee conf: Make really sure we don't access non-existing vCPUs again
MinGW complained that we might be dereferencing a NULL pointer.  While
that can't be true, the logic certainly allows for that.

../../src/conf/domain_conf.c: In function 'virDomainDefPostParse':
../../src/conf/domain_conf.c:4224:18: error: potential null pointer dereference [-Werror=null-dereference]
         if (!vcpu->online && vcpu->cpumask) {
              ~~~~^~~~~~~~

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-07-13 17:55:50 +01:00
Daniel P. Berrange
ffc49e579c libvirt.spec.in: require systemd-container on >= f24
The systemd-machined tools libvirt uses were split into a
systemd-container RPM. Without depending on this, libvirt
may silently fallback to the non-systemd cgroup impl which
is not desirable.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-07-13 17:13:07 +01:00
Andrea Bolognani
968ae60b55 qemu: command: Fix awkward formatting 2016-07-13 17:51:17 +02:00
Martin Kletzander
a6ab72a9c3 conf: Make really sure we don't access non-existing vCPUs
MinGW complained that we might be dereferencing a NULL pointer.  While
that can't be true, the logic certainly allows for that.

src/conf/domain_conf.c: In function 'virDomainDefGetVcpuPinInfoHelper':
src/conf/domain_conf.c:1545:17: error: potential null pointer dereference [-Werror=null-dereference]
         if (vcpu->cpumask)
              ~~~~^~~~~~~~~

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-07-13 14:23:14 +02:00
Maxim Perevedentsev
527968d433 dnsmasq: disable IPv6 default gateway in RA for isolated networks
IPv6 RA always contains an implicit default route via
the link-local address of the source of RA. This forces
the guest to install a route via isolated network, which
may disturb the guest's networking in case of multiple interfaces.
More info in 013427e6e7.

The validity of this route is controlled by "default [route] lifetime"
field of RA. If the lifetime is set to 0 seconds, then no route
is installed by receiver.

dnsmasq 2.67+ supports "ra-param=<interface>,<RA interval>,<default
lifetime>" option. We pass "ra-param=*,0,0"
(here, RA_interval=0 means default) to disable default gateway in RA
for isolated networks.
2016-07-13 13:49:03 +03:00
Maxim Perevedentsev
a96528e957 Fix message about dnsmasq BINDTODEVICE capability. 2016-07-13 13:49:02 +03:00
Yan Fu
8305322d24 qemu: getAutoDumpPath() return value should be dumpfile not domname.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1354238

So we spend some time and effort constructing perfect file name
for an automatic coredump of a domain, but then just leak it and
use the domain name anyway. This is probably due to a silly
mistake that slipped even through review.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-07-13 07:05:21 +02:00
Jim Fehlig
c8f08e4876 systemd: fix ready notification on abstract socket
At least with systemd v210, NOTIFY_SOCKET is abstact, e.g.
@/org/freedesktop/systemd1/notify. sendmsg() fails on such a socket
with "Connection refused". The unix(7) man page contains the following
details wrt abstract socket addresses

abstract: an abstract socket address is distinguished (from a
          pathname socket) by the fact that sun_path[0] is a null byte
          ('\0').  The socket's address in this namespace is given by the
          additional bytes in sun_path that are covered by the specified
          length of the address structure.  (Null bytes in the name have
          no special significance.)

So we need to be more precise about the address length, setting it to
the sizeof sa_family_t + length of address copied to sun_path instead
of setting it to the sizeof the entire sockaddr_un struct.

Resolves: https://bugzilla.opensuse.org/show_bug.cgi?id=987668
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2016-07-12 13:53:51 -06:00
Tomáš Golembiovský
8ddc56e751 esx: Fetch snapshot info directly for filtering
When fetching domains with virConnectListAllDomains() and when filtering
by snapshot existence is requested the ESX driver first lists all the
domains and then check one-by-one for snapshot existence. This process
takes unnecessarily long time.

To significantly improve the time necessary to finish the query we can
request the snapshot related info directly when querying the list of
domains from VMware.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2016-07-12 18:04:41 +02:00
Eric Blake
999af9cfc3 build: drop hack for old mingw ssize_t
The old 32-bit-only mingw project had a mismatch in its <sys/types.h>
that omitted ssize_t, but where size_t was a different rank than
int as picked by gnulib.  But now that mingw64 (both 32- and 64-bit)
is the more popular platform (Fedora has dropped mingw in favor of
mingw64), we no longer need to carry a hack to gnulib to cater to
the old mingw.  This reverts part of commit 1012dc2933.

Signed-off-by: Eric Blake <eblake@redhat.com>
2016-07-12 08:57:13 -06:00
Eric Blake
fc9cc507b8 build: virrandommock.c not needed on mingw
We can't mock tests on Mingw, which lacks dlopen() and friends;
follow the paradigms used in other mock files of conditionally
compiling nothing when not building for Linux.

Signed-off-by: Eric Blake <eblake@redhat.com>
2016-07-12 08:51:15 -06:00
Michal Privoznik
ca10bb040f virCommandExec: Report error if execve fails
In an unlikely event of execve() failing, the virCommandExec()
function does not report any error, even though checks that are
at the beginning of the function are verbose when failing.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-07-12 13:34:35 +02:00
Olga Krishtal
88c61785b2 storage: dir: adapts .wipeVol for ploop volumes
The modification of .volWipe callback wipes ploop volume using one of
given wiping algorithm: dod, nnsa, etc.
However, in case of ploop volume we need to reinitialize root.hds and DiskDescriptor.xml.

v2:
- added check on ploop tools presens
- virCommandAddArgFormat changed to virCommandAddArg

Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com>
2016-07-12 13:16:13 +02:00
Ján Tomko
4c382376da qemu: format intel-iommu on the command line
<devices>
  <iommu model='intel'/>
</devices>

results in:

-device intel-iommu

https://bugzilla.redhat.com/show_bug.cgi?id=1235580
2016-07-12 12:36:13 +02:00
Ján Tomko
8e7e79738d Add QEMU_CAPS_DEVICE_INTEL_IOMMU
Check whether QEMU supports -device intel-iommu

Note that the presence of this option does not mean that it's
usable because of a bug in earlier QEMU versions, but it's
better than nothing.

https://bugzilla.redhat.com/show_bug.cgi?id=1235580
2016-07-12 12:36:13 +02:00
Ján Tomko
ea0ed35d6e Introduce <iommu> device
A device with an attribute 'model', with just one model
so far:

<devices>
  ...
  <iommu model='intel'/>
</devices>

https://bugzilla.redhat.com/show_bug.cgi?id=1235580
2016-07-12 12:36:13 +02:00
Ján Tomko
4808ebdef6 test-wrap-argv: set cutoff at 78 characters
For every but the last argument, we also need space for a space
and a backslash.

Rewrap everything longer than 78 characters.
2016-07-12 12:35:41 +02:00
Ján Tomko
a5dace965a test-wrap-argv: print diff instead of the incorrectly wrapped file
Commit c9c03ea stopped creating an intermediate file during syntax-check
to save on execution time. It also switched to outputting the whole
incorrectly wrapped file instead of a diff needed to fix it.

Feed the newly wrapped file to diff via a pipe.

Note that fixing it by running test-wrap-argv.pl --in-place or
the unit test with VIR_TEST_REGENERATE_OUTPUT is easier.
2016-07-12 12:15:50 +02:00
Ján Tomko
cc04181a7c testutils: only rewrap args files
test-wrap-argv.pl does not know how to rewrap other files.
2016-07-12 12:15:50 +02:00
Ján Tomko
bd6708a862 testutils: find perl early
Commit 843a70a changed test-wrap-argv.pl to use
/usr/bin/env perl
instead of
/usr/bin/perl

However when called from qemuxml2argvtest with
VIR_TEST_REGENERATE_OUTPUT, PATH is set to '/bin'.

Find the path to perl early in virTestMain, in case we
are going to need it later after we've overridden PATH.
2016-07-12 12:15:50 +02:00
Ján Tomko
45ff2362e4 qemuxml2argvtest: drop empty pseries-vio-address-clash.args
Unused since its introduction in commit 4b942fe.
2016-07-12 12:15:50 +02:00
Luyao Huang
92560419e1 tests: add missing directories in EXTRA_DIST
In commit ec5dcf2a and b0b4a35c we have moved qemuhotplugtest's XMLs to
new directories but forgot to fix the Makefile. Add 2 directories in
EXTRA_DIST to fix broken VPATH build. Also remove now unused
qemuhotplugtestdata directory from the Makefile as well as from the
tree.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-07-12 11:52:10 +02:00
Daniel P. Berrange
f3b860e871 remote: convert to typesafe virConf accessors
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-07-12 09:58:22 +01:00
Daniel P. Berrange
544f087e41 sanlock: convert to typesafe virConf accessors
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-07-12 09:58:22 +01:00
Daniel P. Berrange
b474952eb7 lockd: convert to typesafe virConf accessors
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-07-12 09:58:22 +01:00
Daniel P. Berrange
b9c8af4d71 selinux: convert to typesafe virConf accessors
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-07-12 09:58:22 +01:00
Daniel P. Berrange
740e4d7052 virt-login-shell: convert to typesafe virConf accessors
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-07-12 09:58:21 +01:00
Daniel P. Berrange
b8b31acdf6 uri: convert to typesafe virConf accessors
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-07-12 09:58:21 +01:00
Daniel P. Berrange
571bced207 libxl: convert to typesafe virConf accessors
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-07-12 09:58:21 +01:00
Daniel P. Berrange
51eeb756d2 lxc: convert to typesafe virConf accessors
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-07-12 09:58:21 +01:00
Daniel P. Berrange
46dbc97e65 virtlogd: convert to typedef virConf accessors
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-07-12 09:58:21 +01:00
Daniel P. Berrange
2666b2905f virtlockd: convert to typesafe virConf accessors
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-07-12 09:58:21 +01:00
Daniel P. Berrange
f5da0d1805 libvirt: convert to typesafe virConf accessors
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-07-12 09:58:13 +01:00
Daniel P. Berrange
a933139409 qemu: convert to typesafe virConf accessors
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-07-12 09:57:15 +01:00
Daniel P. Berrange
54628f5434 libvirtd: convert to typesafe virConf accessors
The libvirtdconftest was previously used to test data type
handling of the libvirtd config file. Now we're using the
typedef APIs, this test case has little value, and is pretty
hard to fixup with deal with the new APIs.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-07-12 09:57:01 +01:00
Daniel P. Berrange
6381c89f8c virconf: add typed value accessor methods
Currently many users of virConf APIs are defining the same
macros for calling virConfValue() and then doing type
checking. To remove this repeated code, add a set of
typesafe accessor methods.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-07-12 09:57:01 +01:00
Daniel P. Berrange
fe2d37295e virconf: fix off-by-1 when appending \n to config file
If the config file does not end with a \n, the parser will append
one. When re-allocating the array though, it is mistakenly assuming
that 'len' is the length including the trailing NUL, but it does
not. So we must add 2 to len, when reallocating, not 1.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-07-12 09:57:00 +01:00
Daniel P. Berrange
776925096d tests: remove pointless virconftest.sh wrapper
The virconftest is different from all our other tests in that
the C program only tests a single in/out config file pair. It
relies on a shell wrapper to invoke it once for each test
file.

This gets rid of the shell wrapper and makes the C program
actually run over each test file using the normal test pattern.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-07-12 09:57:00 +01:00
Tomasz Flendrich
b0b4a35c53 qemuhotplugtest: Move domain and device XMLs to different directories
This way we can safely differentiate what XMLs contain whole domain
definitions and which contain just devices.  Thanks to that we can
test the domain XMLs in virschematest again.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-07-11 17:09:29 +02:00
Tomasz Flendrich
ec5dcf2a5d qemuhotplugtest: Move all XMLs to one directory
This makes the search for related XMLs easier, plus they are not used in
the xml2argv tests anyway.  This also makes future patches cleaner.
While on that remove unnecessary '-hotplug' from the filenames.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-07-11 17:09:29 +02:00
Michal Privoznik
1cbb8d4a5e qemuxml2argvmock: Don't leak @netdef->ifname
In the mock, we have a stub for virNetDevTapCreate(). However,
the mocked version does not exactly as it's native counterpart.
The function receives a string, which is an interface name that
caller would like to have, but it's not guaranteed that they will
get just that one. If they don't, the function free()-s the one
passed and returns the new one. Just like the mocked version. But
what is the mocked version missing is the free().

==1068== 6 bytes in 1 blocks are definitely lost in loss record 9 of 132
==1068==    at 0x4C29F80: malloc (vg_replace_malloc.c:296)
==1068==    by 0xDE13356: xmlStrndup (in /usr/lib64/libxml2.so.2.9.4)
==1068==    by 0xAE2333E: virXMLPropString (virxml.c:479)
==1068==    by 0xAE45975: virDomainNetDefParseXML (domain_conf.c:9038)
==1068==    by 0xAE5C0BB: virDomainDefParseXML (domain_conf.c:16734)
==1068==    by 0xAE5EB96: virDomainDefParseNode (domain_conf.c:17444)
==1068==    by 0xAE5EA05: virDomainDefParse (domain_conf.c:17391)
==1068==    by 0xAE5EA93: virDomainDefParseFile (domain_conf.c:17415)
==1068==    by 0x433430: testCompareXMLToArgvFiles (qemuxml2argvtest.c:278)
==1068==    by 0x433A18: testCompareXMLToArgvHelper (qemuxml2argvtest.c:414)
==1068==    by 0x446ED4: virTestRun (testutils.c:179)
==1068==    by 0x43A099: mymain (qemuxml2argvtest.c:1016)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-07-11 16:25:08 +02:00
Michal Privoznik
958d6208a3 qemuxml2argvtest: Don't leak dummy monitor
It's just test, but why leak it?

==26971== 20 bytes in 1 blocks are definitely lost in loss record 623 of 704
==26971==    at 0x4C29F80: malloc (vg_replace_malloc.c:296)
==26971==    by 0xE560447: vasprintf (vasprintf.c:76)
==26971==    by 0xAE0DEE2: virVasprintfInternal (virstring.c:480)
==26971==    by 0xAE0DFF7: virAsprintfInternal (virstring.c:501)
==26971==    by 0x4751F3: qemuProcessPrepareMonitorChr (qemu_process.c:2651)
==26971==    by 0x4334B1: testCompareXMLToArgvFiles (qemuxml2argvtest.c:297)
==26971==    by 0x4339AC: testCompareXMLToArgvHelper (qemuxml2argvtest.c:413)
==26971==    by 0x446E7A: virTestRun (testutils.c:179)
==26971==    by 0x445D33: mymain (qemuxml2argvtest.c:2029)
==26971==    by 0x44886F: virTestMain (testutils.c:969)
==26971==    by 0x445D9B: main (qemuxml2argvtest.c:2036)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-07-11 16:24:51 +02:00
Michal Privoznik
6b6e2cf92b qemuDomainObjPrivateFree: Free @masterKey too
This one's a bit more complicated. In qemuProcessPrepareDomain()
a master key for encrypting secret for ciphered disks is created.
This object lives within qemuDomainObjPrivate object. It is freed
in qemuProcessStop(), but if nobody calls it (for instance like
our qemuxml2argvtest does), the key object leaks.

==17078== 32 bytes in 1 blocks are definitely lost in loss record 633 of 707
==17078==    at 0x4C2C070: calloc (vg_replace_malloc.c:623)
==17078==    by 0xAD924DF: virAllocN (viralloc.c:191)
==17078==    by 0x5050BA6: virCryptoGenerateRandom (qemuxml2argvmock.c:166)
==17078==    by 0x453DC8: qemuDomainMasterKeyCreate (qemu_domain.c:678)
==17078==    by 0x47A36B: qemuProcessPrepareDomain (qemu_process.c:4913)
==17078==    by 0x47C728: qemuProcessCreatePretendCmd (qemu_process.c:5542)
==17078==    by 0x433698: testCompareXMLToArgvFiles (qemuxml2argvtest.c:332)
==17078==    by 0x4339AC: testCompareXMLToArgvHelper (qemuxml2argvtest.c:413)
==17078==    by 0x446E7A: virTestRun (testutils.c:179)
==17078==    by 0x445BD9: mymain (qemuxml2argvtest.c:2022)
==17078==    by 0x44886F: virTestMain (testutils.c:969)
==17078==    by 0x445D9B: main (qemuxml2argvtest.c:2036)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-07-11 16:24:04 +02:00
Michal Privoznik
87df945240 qemuBuildCpuCommandLine: Don't leak @buf
Just like every other qemuBuild*CommandLine() function, this uses
a buffer to hold partial cmd line strings too. However, if
there's an error, the control jumps to 'cleanup' label leaving
the buffer behind and thus leaking it.

==2013== 1,006 bytes in 1 blocks are definitely lost in loss record 701 of 711
==2013==    at 0x4C29F80: malloc (vg_replace_malloc.c:296)
==2013==    by 0x4C2C32F: realloc (vg_replace_malloc.c:692)
==2013==    by 0xAD925A8: virReallocN (viralloc.c:245)
==2013==    by 0xAD95EA8: virBufferGrow (virbuffer.c:130)
==2013==    by 0xAD95F78: virBufferAdd (virbuffer.c:165)
==2013==    by 0x5097F5: qemuBuildCpuModelArgStr (qemu_command.c:6339)
==2013==    by 0x509CC3: qemuBuildCpuCommandLine (qemu_command.c:6437)
==2013==    by 0x51142C: qemuBuildCommandLine (qemu_command.c:9174)
==2013==    by 0x47CA3A: qemuProcessCreatePretendCmd (qemu_process.c:5546)
==2013==    by 0x433698: testCompareXMLToArgvFiles (qemuxml2argvtest.c:332)
==2013==    by 0x4339AC: testCompareXMLToArgvHelper (qemuxml2argvtest.c:413)
==2013==    by 0x446E7A: virTestRun (testutils.c:179)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-07-11 14:21:01 +02:00
Michal Privoznik
b04835258f virStorageEncryptionSecretFree: Don't leak secret lookup definition
When storage secret is parsed in virStorageEncryptionSecretParse(),
virSecretLookupParseSecret() which allocates some memory. This is
however never freed.

==21711== 134 bytes in 6 blocks are definitely lost in loss record 70 of 85
==21711==    at 0x4C29F80: malloc (vg_replace_malloc.c:296)
==21711==    by 0xBCA0356: xmlStrndup (in /usr/lib64/libxml2.so.2.9.4)
==21711==    by 0xA9F432E: virXMLPropString (virxml.c:479)
==21711==    by 0xA9D25B0: virSecretLookupParseSecret (virsecret.c:70)
==21711==    by 0xA9D616E: virStorageEncryptionSecretParse (virstorageencryption.c:172)
==21711==    by 0xA9D66B2: virStorageEncryptionParseXML (virstorageencryption.c:281)
==21711==    by 0xA9D68DF: virStorageEncryptionParseNode (virstorageencryption.c:338)
==21711==    by 0xAA12575: virDomainDiskDefParseXML (domain_conf.c:7606)
==21711==    by 0xAA2CAC6: virDomainDefParseXML (domain_conf.c:16658)
==21711==    by 0xAA2FC75: virDomainDefParseNode (domain_conf.c:17472)
==21711==    by 0xAA2FAE4: virDomainDefParse (domain_conf.c:17419)
==21711==    by 0xAA2FB72: virDomainDefParseFile (domain_conf.c:17443)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-07-11 14:21:01 +02:00
Chen Hanxiao
8f5becf3a3 virsh: allow both --uuid and --name at same time
#virsh list --uuid --name
49c765a0-25e7-40d0-964f-dac99724b32c   c7
918f1dd6-b19f-412b-ba17-d113bad89af8   f23

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
2016-07-11 14:00:51 +02:00
Martin Kletzander
949c43370e qemu: Use qemuProcessSetupPid() in qemuProcessSetupVcpu()
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-07-11 11:39:55 +02:00
Martin Kletzander
d65534f3ec qemu: Use qemuProcessSetupPid() in qemuProcessSetupEmulator()
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-07-11 11:36:19 +02:00
Martin Kletzander
71e419bbeb qemu: Add qemuProcessSetupPid() and use it in qemuProcessSetupIOThread()
Setting up cgroups and other things for all kinds of threads (the
emulator thread, vCPU threads, I/O threads) was copy-pasted every time
new thing was added.  Over time each one of those functions changed a
bit differently.  So create one function that does all that setup and
start using it, starting with I/O thread setup.  That will shave some
duplicated code and maybe fix some bugs as well.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-07-11 11:36:19 +02:00