Commit Graph

12605 Commits

Author SHA1 Message Date
Jim Fehlig
4dfc34c301 libxl: fix memory corruption introduced by commit b55cc5f4e
Commit b55cc5f4e did a shallow copy of libxl_{sdl,vnc}_info from the
domain config to the build info, which resulted in double-freeing
strings contained in the structures during cleanup, which later
resulted in a libvirtd crash.  Fix by performing a deep copy of the
structure, VIR_STRDUP'ing embedded strings instead of simply copying
their pointers.

Fixes the following issue reported on the libvirt dev list

https://www.redhat.com/archives/libvir-list/2014-August/msg01112.html
2014-08-25 17:35:12 -06:00
Eric Blake
28de556dde maint: drop spurious semicolons
I noticed a line 'int nparams = 0;;' in remote_dispatch.h, and
tracked down where it was generated.  While at it, I found a
couple of other double semicolons.  Additionally, I noticed that
commit df0b57a95 left a stale reference to the file name
remote_dispatch_bodies.h.

* src/conf/numatune_conf.c (virDomainNumatuneNodeParseXML): Drop
empty statement.
* tests/virdbustest.c (testMessageStruct, testMessageSimple):
Likewise.
* src/rpc/gendispatch.pl (remote_dispatch_bodies.h): Likewise, and
update stale comments.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-08-25 17:29:30 -06:00
Erik Skultety
d60c33c6b5 iotune: setting an invalid value now reports error
When trying to set an invalid value into iotune element, standard
behavior was to not report any error, rather to reset all affected
subelements of the iotune element back to 0 which results in ignoring
those particular subelements by XML generator. Patch further
examines the return code of the virXPathULongLong function
and in case of an invalid non-integer value raises an error.
Fixed to preserve consistency with invalid value checking
of other elements.

Resolves https://bugzilla.redhat.com/show_bug.cgi?id=1131811
2014-08-25 16:12:05 +02:00
Martin Kletzander
adfdb8d5bd qemu: add support for splash-timeout
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1021703

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-08-25 14:11:41 +02:00
Martin Kletzander
9e1af156af qemu: add capability probing for splash-timeout
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-08-25 14:10:54 +02:00
Martin Kletzander
43b8123d39 docs, conf: add support for bootmenu timeout
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-08-25 14:10:54 +02:00
Pavel Hrdina
fa82c0f36a fix mingw build
The commit "f5b4c141" introduced new "force" parameter
for "virFDStreamOpenFileInternal" but forget to update
one call of that function.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2014-08-25 09:44:32 +02:00
Roman Bogorodskiy
e3abf2a4cc storage: zfs: implement download and upload
Add an implementation of uploadVol and downloadVol using
virStorageBackendVolUploadLocal and virStorageBackendVolDownloadLocal
respectively.
2014-08-25 10:46:22 +04:00
Roman Bogorodskiy
f5b4c14155 fdstream: introduce virFDStreamOpenBlockDevice
virStorageBackendVolDownloadLocal and virStorageBackendVolUploadLocal
use virFDStreamOpenFile function to work with the volume fd.

virFDStreamOpenFile calls virFDStreamOpenFileInternal that implements
handling of the non-blocking I/O. If a file is not a character device and
not a fifo, it uses libvirt_iohelper.

On FreeBSD, it doesn't work as expected because disk devices (including
ZFS volumes) are exposed as character devices, and ZFS volumes do not
support open(2) with O_NONBLOCK.

To overcome this, introduce a forceIOHelper flag to
virFDStreamOpenFileInternal that forces using libvirt_iohelper. And
introduce virFDStreamOpenBlockDevice that calls
virFDStreamOpenFileInternal with the forceIOHelper set to true.
2014-08-25 10:46:13 +04:00
Roman Bogorodskiy
eb626b49fd fdstream: report error if virSetNonBlock fails
virFDStreamOpenInternal terminates if virSetNonBlock fails. As
virSetNonBlock uses gnulib's set_nonblocking_flag that sets errno,
call virReportSystemError() to let user know the reason of fail.
2014-08-25 09:59:10 +04:00
Eric Blake
4b772e469d maint: fix comment typo
* src/util/virbuffer.h: s/occured/occurred/

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-08-23 14:29:24 -06:00
Eric Blake
2c551d34a9 qemu: check for active domain after agent interaction
Commit b606bbb41 reminded me that any time we drop locks to run
back-to-back guest interaction commands, we have to check that
the guest didn't disappear in between the two commands.  A quick
audit found a couple of spots that were missing this check.

* src/qemu/qemu_driver.c (qemuDomainShutdownFlags)
(qemuDomainSetVcpusFlags): Check that domain is still up.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-08-22 14:30:52 -06:00
John Ferlan
c585334bdd xenconfig: Resolve Coverity RESOURCE_LEAK
Since '337a13628' - Coverity complains that 'net' is VIR_ALLOC()'d, but
on various 'cleanup' exit paths from the code there is no corresponding
cleanup.
2014-08-22 13:02:48 -04:00
John Ferlan
cc1bbbbeba virnetsocket: Resolve Coverity RESOURCE_LEAK
Since '1b807f92d' - Coverity complains that in the error paths of
both virFork() and virProcessWait() that the 'passfd' will not be closed.
Added the VIR_FORCE_CLOSE(passfd) and initialized it to -1.

Also noted that variable 'buf' was never really used - so I removed it
2014-08-22 13:02:48 -04:00
Erik Skultety
b9ff7393bc numatune: setting --mode does not work well
When trying to set numatune mode directly using virsh numatune command,
correct error is raised, however numatune structure was not deallocated,
thus resulting in creating an empty numatune element in the guest XML,
if none was present before. Running the same command aftewards results
in a successful change with broken XML structure. Patch fixes the
deallocation problem as well as checking for invalid attribute
combination VIR_DOMAIN_NUMATUNE_PLACEMENT_AUTO + a nonempty nodeset.

Resolves https://bugzilla.redhat.com/show_bug.cgi?id=1129998
2014-08-22 16:34:23 +02:00
Erik Skultety
36a0993a15 qemu: min_guarantee: Parameter 'min_guarantee' not supported
The 'min_guarantee' is used by VMware ESX and OpenVZ drivers,
with qemu however, libvirt should report error when starting a domain,
because this element is not used.
Resolves https://bugzilla.redhat.com/show_bug.cgi?id=1122455
2014-08-22 16:33:18 +02:00
Michal Privoznik
66eaa887e9 Fix spacing around commas
On some places in the libvirt code we have:

  f(a,z)

instead of

  f(a, z)

This trivial patch fixes couple of such occurrences.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-08-22 15:03:39 +02:00
Alexander Burluka
24b1bad37f Parallels: Change config report errors code.
Wrong error code in config errors reporting was used. Fixed it.
2014-08-22 14:31:29 +02:00
Alexander Burluka
268b4c84e0 Parallels: fix error with video card RAM dimension
Libvirt measures vram in Kbytes, not in bytes, so calculation
of Mbytes was incorrect. PCS server can take vram argument
with units, so I added K postfix to make params a little bit clearer.
2014-08-22 14:31:11 +02:00
Alexander Burluka
75210ef0a3 Parallels: add virNodeGetCPUMap().
That function caused errors in libvirtd logs when OpenStack Nova
starts VM instance.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2014-08-22 14:31:04 +02:00
Martin Kletzander
1b5cff867d util: compare floor attribute in virNetDevBandwidthEqual
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1064770

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-08-22 12:35:39 +02:00
Martin Kletzander
846edeef52 build: fix mingw build with virCommandReorderFDs
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-08-22 11:15:59 +02:00
Martin Kletzander
1b807f92db rpc: pass listen FD to the daemon being started
This eliminates the need for active waiting.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-08-22 09:12:14 +02:00
Martin Kletzander
62f263a73e util: add virCommandPassListenFDs() function
That sets a new flag, but that flag does mean the child will get
LISTEN_FDS and LISTEN_PID environment variables properly set and
passed FDs reordered so that it corresponds with LISTEN_FDS (they must
start right after STDERR_FILENO).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-08-22 09:12:14 +02:00
Martin Kletzander
e1f2ec67c2 rpc: set listen backlog on FDs as well as on other sockets
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-08-22 09:12:13 +02:00
Martin Kletzander
9805256d53 remote: create virNetServerServiceNewFDOrUNIX() wrapper
It's just a wrapper around NewFD and NewUNIX that selects the right
option and increments the number of used FDs.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-08-22 09:12:13 +02:00
Martin Kletzander
8989597cd9 util: abstract parsing of passed FDs into virGetListenFDs()
Since not only systemd can do this (we'll be doing it as well few
patches later), change 'systemd' to 'caller' and fix LISTEN_FDS to
LISTEN_PID where applicable.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-08-22 09:12:13 +02:00
Peter Krempa
4cf1c3fab1 conf: net: Correctly switch how to format address fields
When formatting the forward mode addresses or interfaces the switch was
done based on the type of the network rather than of the type of the
individual <interface>/<address> element. In case a user would specify
an incorrect network type ("passhtrough") with <address> elements,
libvirtd would crash as it would attempt to format an <interface>.

Use the type of the individual element to format the XML.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1132347
2014-08-21 15:55:07 +02:00
John Ferlan
33188c9fcb Perform disk config validity checking for attach-device config
https://bugzilla.redhat.com/show_bug.cgi?id=1078126

Using 'virsh attach-device --config' (or --persistent) to attach a
file backed lun device will succeed; however, subsequent domain restarts
will result in failure because the configuration of a file backed lun
is not supported.

Although allowing 'illegal configurations' is something that can be
allowed, it may not be practical in this case. Generally, when attaching
a device to a domain means the domain must be running. A way around
this is using the --config (or --persistent) option. When an attach
is done to a running domain, a temporary configuration is modified
first followed by the live update. The live update will make a number
of disk validity checks when building the qemu command to attach the
disk. If any fail, then change is rejected.

Rather than allow a potentially illegal combination, adjust the code
in the configuration path to make the same checks as the running path
will make with respect to disk validity checks. This way we avoid
having the potential for some subsequent start/reboot to fail because
an illegal combination was allowed.

NB: The live path still checks the configuration since it is possible
to just do --live guest modification...
2014-08-21 07:06:35 -04:00
Michal Privoznik
cf389258ae hvsupport: Adapt to vbox driver rewrite
Since vbox driver rewrite the virDriver structure init moved from
vbox_tmpl.c into vbox_common.c. However, our hvsupport.pl script
doesn't count with that. It still parses vbox_tmp.c and looks for
virDriver structure which is not found there anymore. As a result,
at hvsupport page is seems like vbox driver doesn't support
anything.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-08-20 18:17:07 +02:00
Michal Privoznik
f4c87a0c35 nodeCapsInitNUMA: Avoid @cpumap leak
In case the host has 2 or more NUMA nodes, we fetch CPU map for each
node. However, we need to free the CPU map in between loops:

==29513== 96 (72 direct, 24 indirect) bytes in 3 blocks are definitely lost in loss record 951 of 1,264
==29513==    at 0x4C2A700: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==29513==    by 0x52AD24B: virAlloc (viralloc.c:144)
==29513==    by 0x52AF0E6: virBitmapNew (virbitmap.c:78)
==29513==    by 0x52FB720: virNumaGetNodeCPUs (virnuma.c:294)
==29513==    by 0x53C700B: nodeCapsInitNUMA (nodeinfo.c:1886)
==29513==    by 0x11759708: vboxCapsInit (vbox_common.c:398)
==29513==    by 0x11759CC4: vboxConnectOpen (vbox_common.c:514)
==29513==    by 0x53C965F: do_open (libvirt.c:1147)
==29513==    by 0x53C9EBC: virConnectOpen (libvirt.c:1317)
==29513==    by 0x142905: remoteDispatchConnectOpen (remote.c:1215)
==29513==    by 0x126ADF: remoteDispatchConnectOpenHelper (remote_dispatch.h:2346)
==29513==    by 0x5453D21: virNetServerProgramDispatchCall (virnetserverprogram.c:437)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-08-20 16:15:00 +02:00
Martin Kletzander
93cf8f9861 cleanup spaces between parentheses and braces
And add a syntax-check for '){$'.  It's not perfect, but better than
nothing.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-08-20 14:50:21 +02:00
Michal Privoznik
b606bbb416 qemu: Issue rtc-reset-reinjection command after guest-set-time
https://bugzilla.redhat.com/show_bug.cgi?id=1103245

An advice appeared there on the qemu-devel list [1]. When a domain is
suspended and then resumed guest kernel is not aware of this. So we've
introduced virDomainSetTime API that resets the time within guest
using qemu-ga. On the other hand, qemu itself is trying to make RTC
beat faster to catch the difference. But if we don't tell qemu that
guest's time was reset via the other method, both mechanisms are
applied resulting in again wrong guest time. In order to avoid summing
both corrections we need to tell qemu that it should not use the RTC
injection if the guest time is set via guest agent.

1: http://www.mail-archive.com/qemu-devel@nongnu.org/msg236435.html

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-08-20 14:20:05 +02:00
Martin Kletzander
970ac2a0fe qemu: forbid negative blkio values
Partially resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1131306

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-08-20 12:54:06 +02:00
Martin Kletzander
e80adb0ed5 lxc: forbid negative blkio values
Partially resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1131306

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-08-20 12:54:06 +02:00
Peter Krempa
e2f14211cf qemu: Fix build error introduced in 653137eb95
The build failure is caused by a false positive of some static analysys
steps done by gcc (that don't happen on -O0).
2014-08-20 11:52:33 +02:00
Peter Krempa
653137eb95 qemu: blkiotune: Avoid accessing non-existing disk configuration
When a user would try changing the persistent IO tuning settings for a
disk that was hotplugged to a vm in a transient way, the
qemuDomainSetBlockIoTune API would use the same index for both the
live and config disk array. The disk was missing from the config array
though causing a crash of libvirtd.

To fix the issue, determine the indexes separately.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1131819
2014-08-20 11:04:53 +02:00
Michal Privoznik
cf976d9dcf qemu: Label all TAP FDs
https://bugzilla.redhat.com/show_bug.cgi?id=1095636

When starting up the domain the domain's NICs are allocated. As of
1f24f682 (v1.0.6) we are able to use multiqueue feature on virtio
NICs. It breaks network processing into multiple queues which can be
processed in parallel by different host CPUs. The queues are, however,
created by opening /dev/net/tun several times. Unfortunately, only the
first FD in the row is labelled so when turning the multiqueue feature
on in the guest, qemu will get AVC denial. Make sure we label all the
FDs needed.

Moreover, the default label of /dev/net/tun doesn't allow
attaching a queue:

    type=AVC msg=audit(1399622478.790:893): avc:  denied  { attach_queue }
    for  pid=7585 comm="qemu-kvm"
    scontext=system_u:system_r:svirt_t:s0:c638,c877
    tcontext=system_u:system_r:virtd_t:s0-s0:c0.c1023
    tclass=tun_socket

And as suggested by SELinux maintainers, the tun FD should be labeled
as svirt_t. Therefore, we don't need to adjust any range (as done
previously by Guannan in ae368ebf) rather set the seclabel of the
domain directly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-08-20 09:42:24 +02:00
Peter Krempa
aecc6bb85d qemu: hotplug: Sanitize shared device removal on media change
Instead of tediously copying of the disk source to remove it later
ensure that the media change function removes the old device after it
succeeds.
2014-08-20 09:28:05 +02:00
Peter Krempa
d49e27a3ed qemu: conf: Split out code to retrieve hostdev key and reuse it
Both addition and removal of a shared hostdev share the code to generate
the hostdev key. Split it out into a separate function and refactor
them.
2014-08-20 09:28:04 +02:00
Peter Krempa
f05de1ef27 qemu: conf: Split up qemuRemoveSharedDevice into per-device-type functions
Removing a shared device needs special steps for disks and hostdevs.
Instead of having one function dealing this split the code into two
separate functions that can be used with better granularity.
2014-08-20 09:28:04 +02:00
Peter Krempa
b2199f9084 qemu: conf: Split up qemuAddSharedDevice into per-device-type functions
Adding a shared device needs special steps for disks and hostdevs.
Instead of having one function dealing this split the code into two
separate functions that can be used with better granularity.
2014-08-20 09:28:04 +02:00
Peter Krempa
3f131ebf62 qemu: conf: rename qemuCheckSharedDevice to qemuCheckSharedDisk
The qemuCheckSharedDevice function is operating only on disk devices.
Rename it and change the arguments to reflect that and refactor some
logic for more readability.
2014-08-20 09:28:04 +02:00
Peter Krempa
62046c1267 qemu: shared: Split out shared device list remove code
Split it out into a separate function and simplify the code. There's no
need to copy the entry to update it as the hash returns pointer to the
existing item.

Also remove the now unused qemuSharedDeviceEntryCopy function.
2014-08-20 09:28:04 +02:00
Peter Krempa
f36a94f236 qemu: shared: Split out insertion code to the shared device list
To allow reuse split the code into a separate function and refactor it.
To update an existing entry there's no need to copy it first, just
update it inplace.
2014-08-20 09:28:04 +02:00
Peter Krempa
b57ca1320c qemu: hotplug: Format proper source string for cdrom media change
Use the qemu source string formatter to format the source string
correctly for remote and other storage instead of passing source->path
blindly.
2014-08-20 09:28:04 +02:00
Peter Krempa
1f39218e4f qemu: hotplug: Change arguments for qemuDomainChangeEjectableMedia
Pass the source of the changed media instead of a complete disk
definition.

Note that the @disk argument now contains what @olddisk would contain.
The new source is passed as a virStorageSource struct.
2014-08-20 09:28:04 +02:00
Peter Krempa
ca91ba78bd qemu: hotplug: Add helper to initialize/teardown new disks for VMs
When we are changing media (or doing other hotplug operations) we need
to setup cgroups, locking and seclabels on the new disk. This is a
multi-step process where every piece can fail. To simplify dealing with
this introduce qemuDomainPrepareDisk that similarly to
qemuDomainPrepareDiskChainElement initializes/tears down  a whole new
disk to be used with the domain.

Additionally the function supports passing a different source struct for
media changes of cdroms that will be refactored later.
2014-08-20 09:28:03 +02:00
Peter Krempa
240eb2fb89 qemu: hotplug: Untangle cleanup paths in qemuDomainChangeEjectableMedia
Avoid the "audit" label to simplify control flow.
2014-08-20 09:28:03 +02:00
Peter Krempa
1cc6bdc2e6 conf: Pass virStorageSource into virDomainDiskSourceIsBlockType
All checks are based on the storage source, thus there's no need to pass
the complete disk def.
2014-08-20 09:28:03 +02:00