Commit Graph

23881 Commits

Author SHA1 Message Date
Laine Stump
25e8112d7c network: new network forward mode 'open'
The new forward mode 'open' is just like mode='route', except that no
firewall rules are added to assure that any traffic does or doesn't
pass. It is assumed that either they aren't necessary, or they will be
setup outside the scope of libvirt.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=846810
2016-08-19 21:05:15 -04:00
Michal Privoznik
5dd3aa2d1c networkxml2conftest: Don't leak dnsmasq capabilities
==18324== 32 bytes in 1 blocks are still reachable in loss record 41 of 114
==18324==    at 0x4C2C070: calloc (vg_replace_malloc.c:623)
==18324==    by 0x4EA479B: virAlloc (viralloc.c:144)
==18324==    by 0x4EA674A: virBitmapNewQuiet (virbitmap.c:77)
==18324==    by 0x4EA67F7: virBitmapNew (virbitmap.c:106)
==18324==    by 0x4EC777D: dnsmasqCapsNewEmpty (virdnsmasq.c:801)
==18324==    by 0x4EC781B: dnsmasqCapsNewFromBuffer (virdnsmasq.c:815)
==18324==    by 0x407CF4: mymain (networkxml2conftest.c:99)
==18324==    by 0x409CF0: virTestMain (testutils.c:982)
==18324==    by 0x4080EA: main (networkxml2conftest.c:136)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-08-19 11:14:14 +02:00
Mikhail Feoktistov
72abe56448 vz: add validation callbacks
This patch fixes a bug which occurs when we check a bus and unit number
for a new attached disk. We should do this check in ValidadionCallback,
not in PostParse callback. Because in PostParse we have not initialized
disk->info.addr.drive struct yet.
Move part of code from domainPostParseCallback to domainValidateCallback
and part from devicesPostParseCallback to deviceValidateCallback.
PostParse callbacks are for modification data.
ValidateCallbacks are only for checks.
2016-08-18 20:37:09 +03:00
Olga Krishtal
b880ff42dd vz: fixed race in vzDomainAttach/DettachDevice
While dettaching/attaching device in OpenStack, nova
calls vzDomainDettachDevice twice, because the update of the internal
configuration of the ct comes a bit latter than the update event.
As the result, we suffer from the second call to dettach the same device.

Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com>
2016-08-18 20:37:09 +03:00
Maxim Nestratov
0970a066d1 vz: specify VIR_DOMAIN_NET_TYPE_NETWORK for routed networks
Somehow we lost this during recent refactoring

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
2016-08-18 20:37:09 +03:00
Maxim Nestratov
0f13dc81d7 vz: reset errors after ignoring return values
If we are going to ignore return value of a functions
that can raise an error, it's not enough to use ignore_value
construction. We should explicitly call virResetLastError

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
2016-08-18 20:37:08 +03:00
Maxim Nestratov
d9e0d4ecbb vz: don't fail query domain info in case we don't have valid stats handle
Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
2016-08-18 20:37:08 +03:00
Maxim Nestratov
9e8cbe185d vz: get additional error information from job correctly
First, make function logPrlEventErrorHelper be void and only
print information (if any) from an event.
Second, don't rewrite original error with any errors we get
during parsing event info.
Third, ignore PRL_ERR_NO_DATA at all.

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
2016-08-18 20:37:08 +03:00
Ján Tomko
f9785569de cfg.mk: join not_streq and not_strneq tests
The marginally nicer error message is not worth the extra lines in
cfg.mk.

Also drop the excludes since there was only one offender in the tests.
2016-08-18 13:37:08 +02:00
Ján Tomko
b3e3fc3257 cfg.mk: drop redundant sc_prohibit_gethostby
Both gethostbyaddr and gethostbyname* are already checked
by sc_prohibit_nonreentrant.
2016-08-18 13:37:08 +02:00
Ján Tomko
1fe77f9f7f cfg.mk: use subst instead of tr
GNU make is able to replace characters, no need to call tr.
2016-08-18 13:37:08 +02:00
Ján Tomko
5e045eca90 tests: fix the return value of test-wrap-argv
The script was returning success unless it failed on the last file.
This went unnoticed because sc_prohibit_long_lines forbids lines
longer than 90 characters in .arg[sv] files.
2016-08-18 13:37:08 +02:00
Ján Tomko
212564a0d1 maint: update to latest gnulib
Pick up the new syntax-check speedups.
2016-08-18 13:36:39 +02:00
Ján Tomko
41f5c2ca27 Introduce QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY
Check whether the disable-legacy property is present on the following
devices:
  virtio-balloon-pci
  virtio-blk-pci
  virtio-scsi-pci
  virtio-serial-pci
  virtio-9p-pci
  virtio-net-pci
  virtio-rng-pci
  virtio-gpu-pci
  virtio-input-host-pci
  virtio-keyboard-pci
  virtio-mouse-pci
  virtio-tablet-pci

Assuming that if QEMU knows other virtio devices where this property
is applicable, it will have at least one of these devices.

Added in QEMU by:
commit e266d421490e0ae83044bbebb209b2d3650c0ba6
    virtio-pci: add flags to enable/disable legacy/modern
2016-08-17 18:13:06 +02:00
John Ferlan
d53d465083 qemu: Fix the command line generation for rbd auth using aes secrets
https://bugzilla.redhat.com/show_bug.cgi?id=1182074

Since libvirt still uses a legacy qemu arg format to add a disk, the
manner in which the 'password-secret' argument is passed to qemu needs
to change to prepend a 'file.' If in the future, usage of the more
modern disk format, then the prepended 'file.' can be removed.

Fix based on Jim Fehlig <jfehlig@suse.com> posting and subsequent
upstream list followups, see:

http://www.redhat.com/archives/libvir-list/2016-August/msg00777.html

for details. Introduced by commit id 'a1344f70'.
2016-08-17 08:03:48 -04:00
Chen Hanxiao
9cc871718f qemu_driver: update comments for qemuDomainSaveInternal
s/libvirt.c/libvirt-domain.c

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
2016-08-17 13:55:49 +02:00
John Ferlan
4b15fd0d1f conf: Provide error on undefined vcpusched entry
Modify virDomainDefGetVcpuSched to emit an error message if
virDomainDefGetVcpu returns NULL meaning the vcpu could not
be found. Prior to commit id '9cc931f0b' the error message
would have been issued in virDomainDefGetVcpu.
2016-08-17 06:42:54 -04:00
Pavel Hrdina
f0551b9bc4 qemu_process: graphics: setup listen types before ports are reserved/allocated
The code that setups listen types may change a listen type from address to
socket based on configuration from qemu.conf.  This needs to be done before we
reserve/allocate ports that won't be used.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-08-17 10:06:47 +02:00
Pavel Hrdina
be51dcb852 qemu_process: graphics: reserve port only if listen type is address or network
Ports are valid only for listen types 'address' and 'network', other listen
types doesn't use them so we should not try to reserve any ports.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-08-17 10:05:21 +02:00
Pavel Hrdina
f6a8df41db qemu_process: graphics: extract for loop out of qemuProcessGraphicsReservePorts
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-08-17 10:04:47 +02:00
Pavel Hrdina
675f9bde2b qemu_process: graphics: extract port allocation into function
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-08-17 10:04:47 +02:00
Pavel Hrdina
eaa20e68b3 qemu_process: graphics: ref driver config only in function where it is used
Signed-off-by: Pavel Hrdina <phrdina@redhat.com
2016-08-17 10:04:47 +02:00
Andrea Bolognani
3edcf83433 util: Make virStringArrayHasString() const-correct
The first argument should be const char ** instead of
char **, because this is a search function and as such it
doesn't, and shouldn't, alter the haystack in any way.

This change means we no longer have to cast arrays of
immutable strings to arrays of mutable strings; we still
have to do the opposite, though, but that's reasonable.
2016-08-16 19:32:58 +02:00
John Ferlan
8c6b29e7b4 conf: Provide error on undefined iothreadsched entry
When commit id '6dfb4507' refactored where the iothreadsched data was
stored, the error message for when the virDomainIOThreadIDFind failed
to find an iothreadid ("iothreadsched attribute 'iothreads' uses
undefined iothread ids") was lost. This led to the possibility that
someone would try to use it, but receive the generic message "An error
occurred, but the cause is unknown".

This patch adds the error message back so that someone will know that
they have an invalid configuration.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-08-16 11:29:22 -04:00
Peter Krempa
c6f26fc207 qemu: driver: Split out regular vcpu hotplug code into a function
All other modes of qemuDomainSetVcpusFlags have helpers so finish the
work by splitting the regular code into a new function.

This patch also touches up the coding (spacing) style.
2016-08-16 14:31:31 +02:00
Peter Krempa
2fa7db93de qemu: driver: Extract setting of live vcpu count
The live code does ugly things. Contain it in a separate function.
2016-08-16 14:28:38 +02:00
Peter Krempa
f10da2f553 qemu: setvcpus: Extract setting of maximum vcpu count
Setting of the maximum vcpu count is slightly semantically different
thus split it into a self-contained func.
2016-08-16 14:14:05 +02:00
Peter Krempa
c2e12b01ba utils: storage: Fix JSON field name for uri based storage
qemu uses 'url' instead of 'uri'. They unfortunately look very similar.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1367260
2016-08-16 13:30:45 +02:00
Ján Tomko
ef66bd5df8 conf: report an error message for non-existing USB hubs
If any of the devices referenced a USB hub that does not exist,
defining the domain would either fail with:
error: An error occurred, but the cause is unknown
(if only the last hub in the path is missing)
or crash.

Return a proper error instead of crashing.

https://bugzilla.redhat.com/show_bug.cgi?id=1367130
2016-08-16 12:31:41 +02:00
Ján Tomko
d49f6853b3 conf: free the ports array of a USB hub
The array needs to be freed too, not just its members.

https://bugzilla.redhat.com/show_bug.cgi?id=1366097
2016-08-16 12:31:41 +02:00
Peter Krempa
e96041ff1a qemu: setcpus: Report better errors
Mention whether it was the live or persistent definition which caused an
error reported and explicitly error out in case when attempting to set
maximum vcpu count for a live domain.
2016-08-16 10:54:23 +02:00
Daniel P. Berrange
57487085dc lxc: don't try to reference NULL when mounting filesystems
<filesystem type='ram' accessmode='passthrough'>
    <source usage='524288' units='KiB'/>
    <target dir='/dev/shm'/>
  </filesystem>

would lead to lxcContainerMountAllFS calling STRPREFIX
on a NLL pointer because it failed to check if fs->src->path
was non-NULL. This is a regression caused by

  commit da665fbd48
  Author: Olga Krishtal <okrishtal@virtuozzo.com>
  Date:   Thu Jul 14 16:52:38 2016 +0300

    filesystem: adds possibility to use storage pool as fs source

    Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com>

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-08-16 09:36:35 +01:00
Daniel P. Berrange
81aa4385d7 lxc: don't try to resolve a NULL path for filesystems
<filesystem type='ram' accessmode='passthrough'>
    <source usage='524288' units='KiB'/>
    <target dir='/dev/shm'/>
  </filesystem>

would lead to lxcContainerResolveSymlinks calling
access(NULL) because it failed to check if fs->src->path
was non-NULL. This is a regression caused by

  commit da665fbd48
  Author: Olga Krishtal <okrishtal@virtuozzo.com>
  Date:   Thu Jul 14 16:52:38 2016 +0300

    filesystem: adds possibility to use storage pool as fs source

    Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com>

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-08-16 09:36:35 +01:00
Michal Privoznik
2140e3da9a libxl_driver: Indent LIBXL_VBD_SECTOR_SIZE macro correctly
Because of change in caaa1bd357 this macro is no under
#ifdef block. That means it needs to be re-intended correctly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-08-16 09:07:30 +02:00
Roman Bogorodskiy
da5dfd0e06 tests: fix domaincapstest linking for libxl
Commit 11567cf added some libxl tests into domaincapstest and
added libvirt_driver_libxl_impl.la to domaincapstest_LDADD.

This causes link fail on systems without GNU regex implementation:

gmake[2]: Entering directory '/usr/home/novel/code/libvirt/tests'
  CCLD     domaincapstest
  ../src/.libs/libvirt_driver_libxl_impl.a(libvirt_driver_libxl_impl_la-libxl_capabilities.o):
  In function `libxlMakeCapabilities':
  libxl/libxl_capabilities.c:(.text+0x6b2): undefined reference to
  `rpl_regcomp'
  libxl/libxl_capabilities.c:(.text+0x6d0): undefined reference to
  `rpl_regerror'
  libxl/libxl_capabilities.c:(.text+0x803): undefined reference to
  `rpl_regexec'
  libxl/libxl_capabilities.c:(.text+0xa58): undefined reference to
  `rpl_regfree'
  clang-3.8: error: linker command failed with exit code 1 (use -v to
  see invocation)

This happens because on these system it tries to use gnulib's builtin
regex implementation, but doesn't link to gnulib.

Fix by adding $(GNULIB_LIBS) along with libvirt_driver_libxl_impl.la to
domaincapstest_LDADD.
2016-08-16 03:12:05 +03:00
Roman Bogorodskiy
caaa1bd357 libxl: fix unused functions
Commit eee7bd4e introduced two functions: libxlDiskPathToID and
libxlDiskSectorSize.

However, as they're used only by code under #ifdef __linux__,
on non-Linux platforms it results in errors similar to this:

 CC       libxl/libvirt_driver_libxl_impl_la-libxl_driver.lo
libxl/libxl_driver.c:5263:1: error: unused function 'libxlDiskPathToID' [-Werror,-Wunused-function]
libxlDiskPathToID(const char *virtpath)
^
libxl/libxl_driver.c:5312:1: error: unused function 'libxlDiskSectorSize' [-Werror,-Wunused-function]
libxlDiskSectorSize(int domid, int devno)
^
2 errors generated.

Fix that by moving these functions under the #ifdef __linux__ block.
2016-08-16 03:12:05 +03:00
Jovanka Gulicoska
43a6b37b24 Introduce node device update event as top level event
This event is emitted when a nodedev XML definition is updated,
like when cdrom media is changed in a cdrom block device.

Also includes node device update event implementation for udev
backend, virsh nodedev-event support, and event-test support
2016-08-15 08:30:56 -04:00
John Ferlan
18701e9d62 virsh: Fix core for cmdSecretGetValue
https://bugzilla.redhat.com/show_bug.cgi?id=1366611

When commit id 'cb2e3e50' reworked the cmdSecretGetValue call to use
VIR_DISPOSE_STRING for base64, it neglected to initialize the base64
value to NULL since the cleanup: label could be reached prior to the
base64 value being set or not.  This resulted in a core dump, adding
the initialization will avoid the issue.
2016-08-15 07:53:45 -04:00
Pavel Hrdina
ef11e770da qemu_command: don't modify heads for graphics device
Setting heads to 0 in case that *max_outputs* is not supported while building
command line doesn't have any real effect.  It only removes *heads* attribute
from live XML, but after restarting libvirt the default value is restored.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-08-15 12:47:37 +02:00
Michal Privoznik
cba18f8ac2 virschematest: Make sure that validator is initialized
It may happen that a developer wants to run just a specific
subset of tests:

tests $ VIR_TEST_RANGE=22 ../run ./virschematest

This now fails miserably:

    ==6840== Invalid read of size 8
    ==6840==    at 0x4F397C0: virXMLValidatorValidate (virxml.c:1216)
    ==6840==    by 0x402B72: testSchemaFile (virschematest.c:53)
    ==6840==    by 0x403737: virTestRun (testutils.c:180)
    ==6840==    by 0x402CF5: testSchemaDir (virschematest.c:98)
    ==6840==    by 0x402EB1: testSchemaDirs (virschematest.c:131)
    ==6840==    by 0x40314D: mymain (virschematest.c:194)
    ==6840==    by 0x4051AF: virTestMain (testutils.c:982)
    ==6840==    by 0x4035A9: main (virschematest.c:217)
    ==6840==  Address 0x10 is not stack'd, malloc'd or (recently) free'd

Problem is, we are trying to do two types of tests here: validate
RNG schema itself, and validate XML files against RNG schemas.
And the latter tries to re-use a resource allocated in the
former. Therefore if the former is skipped (due to
VIR_TEST_RANGE) we have to allocate the resource manually.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-08-15 09:51:10 +02:00
Jim Fehlig
541e9ae6d4 cpu_x86: fix libvirtd crash when host cpu vendor is not available
When starting a guest and copying host vendor cpuid to the guest
cpu, libvirtd would crash if the host cpu contained a NULL vendor
field. Avoid the crash by checking for a valid vendor in the host
cpu before copying the cpuid to the guest cpu.

For completeness, here is a backtrace from the crash

(gdb) bt
f0  0x00007ffff739bf33 in x86DataCpuid (cpuid=0x8, cpuid=0x8,
    data=data@entry=0x7fffb800ee78) at cpu/cpu_x86.c:287
f1  virCPUx86DataAddCPUID (data=data@entry=0x7fffb800ee78, cpuid=0x8)
    at cpu/cpu_x86.c:355
f2  0x00007ffff739ef47 in x86Compute (host=<optimized out>, cpu=0x7fffb8000cc0,
    guest=0x7fffecca7348, message=<optimized out>) at cpu/cpu_x86.c:1580
f3  0x00007fffd2b38e53 in qemuBuildCpuModelArgStr (migrating=false,
    hasHwVirt=<synthetic pointer>, qemuCaps=0x7fffb8001040, buf=0x7fffecca7360,
    def=0x7fffc400ce20, driver=0x1c) at qemu/qemu_command.c:6283
f4  qemuBuildCpuCommandLine (cmd=cmd@entry=0x7fffb8002f60,
    driver=driver@entry=0x7fffc80882c0, def=def@entry=0x7fffc400ce20,
    qemuCaps=qemuCaps@entry=0x7fffb8001040, migrating=<optimized out>)
    at qemu/qemu_command.c:6445
(gdb) f2
(gdb) p *host_model
$23 = {name = 0x7fffb800ec50 "qemu64", vendor = 0x0, signature = 0, data = {
    len = 2, data = 0x7fffb800e720}}
2016-08-12 18:47:53 -06:00
Andrea Bolognani
f257a4adf1 qemu: command: Simplify USB controller model selection
Since we now pick the default USB controller model when parsing
the guest XML, we can get rid of some duplicated code so that
the default model selection happens in one place only.

Add some comments as well.
2016-08-12 17:38:02 +02:00
Andrea Bolognani
31de0fab93 qemu: domain: Drop piix3-ohci controller for migration
Now that the default USB controller model is explicit rather
than implicit for i440fx machines, we have to tweak the
conditions for dropping it in order to keep migration towards
libvirt <= 0.9.4 working.
2016-08-12 17:38:02 +02:00
Andrea Bolognani
f55eaccb0c qemu: domain: Reflect USB controller model in guest XML
When the user doesn't specify any model for a USB controller,
we use an architecture-dependent default, but we don't reflect
it in the guest XML.

Pick the default USB controller model when parsing the guest
XML instead of when creating the QEMU command line, so that
our choice is saved back to disk.
2016-08-12 17:38:02 +02:00
Michal Privoznik
f87cc927f7 virschematest: Initialize @data
==8630== Invalid read of size 8
==8630==    at 0x4EA4F0F: virFree (viralloc.c:582)
==8630==    by 0x4F398F0: virXMLValidatorFree (virxml.c:1257)
==8630==    by 0x40305C: mymain (virschematest.c:191)
==8630==    by 0x405159: virTestMain (testutils.c:982)
==8630==    by 0x403553: main (virschematest.c:215)
==8630==  Address 0xcd72243 is 131 bytes inside a block of size 177 free'd
==8630==    at 0x4C2B1F0: free (vg_replace_malloc.c:473)
==8630==    by 0x4EA4F19: virFree (viralloc.c:582)
==8630==    by 0x4ED0973: virFindFileInPath (virfile.c:1646)
==8630==    by 0x405149: virTestMain (testutils.c:980)
==8630==    by 0x403553: main (virschematest.c:215)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-08-12 17:13:35 +02:00
Michal Privoznik
c4b92f1a8a schema: Don't validate paths
https://bugzilla.redhat.com/show_bug.cgi?id=1353296

On UNIX like systems there are no constraints on what characters
can be in file/dir names (except for NULL, obviously). Moreover,
some values that we think of as paths (e.g. disk source) are not
necessarily paths at all. For instance, some hypervisors take
that as an arbitrary identifier and corresponding file is then
looked up by hypervisor in its table. Instead of trying to fix
our regular expressions (and forgetting to include yet another
character there), lets drop the validation completely.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-08-12 10:59:21 +02:00
Michal Privoznik
9aea8cd4ae virNetDevMacVLanCreateWithVPortProfile: Drop @ret
Usually, this variable is used to hold the return value for a
function of ours. Well, this is not the case. Its use does not
match our pattern and therefore it is very misleading. Drop it
and define an alternative @rc variable, but only in that single
block where it is needed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-08-10 16:56:45 +02:00
Michal Privoznik
42712002fd virNetDevMacVLanCreateWithVPortProfile: Drop @rc
This variable is very misleading. We use VIR_FORCE_CLOSE to set
it to -1 and returning it even though it does not refer to a FD
at all. It merely holds 0 or -1. Drop it completely. Also, at the
same time some corner cases are fixed too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-08-10 16:56:22 +02:00
Michal Privoznik
96e2486156 virNetDevMacVLanCreateWithVPortProfile: Don't mask virNetDevMacVLanTapOpen error
https://bugzilla.redhat.com/show_bug.cgi?id=1240439

In this function we create a macvtap device and open its tap
device. Possibly multiple times. Now the thing is, if opening the
tap device fails, that is virNetDevMacVLanTapOpen() returns a
negative value, we unroll all the changes BUT return 0 fooling
caller into thinking everything went okay.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-08-10 16:54:41 +02:00
Cole Robinson
856965b362 qemu: fix qemu.conf security_driver
Since a9331394 (first release v2.1.0), specifying a manual
security_driver setting in qemu.conf causes the daemon to fail to
start, erroring with 'Duplicate security driver X'.

The duplicate checking was incorrectly comparing every entry
against itself, guaranteeing a false positive.

https://bugzilla.redhat.com/show_bug.cgi?id=1365607
2016-08-10 10:41:07 -04:00