Commit Graph

17330 Commits

Author SHA1 Message Date
John Ferlan
e1d0471e58 commandtest: Resolve Coverity RESOURCE_LEAK
Since '62f263a73' - Coverity complains if the !pidfile path is taken,
then newfd1 would be leaked.
2014-08-22 13:02:47 -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
John Ferlan
f335ed77a6 formatdomain: Reformat vCPU description
Reformat the vCPU description to use list elements rather than one long
run-on paragraph

Signed-off-by: John Ferlan <jferlan@redhat.com>
2014-08-22 10:16:13 -04: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
Li Yang
bf90846909 virsh: Fix help info for freepages
Signed-off-by: Li Yang <liyang.fnst@cn.fujitsu.com>
2014-08-22 12:22:59 +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
1e9808d3a1 daemon: use socket activation with systemd
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-08-22 09:12:14 +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
241ac07124 tests: support dynamic prefixes in commandtest
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-08-22 09:12:14 +02:00
Martin Kletzander
1734f9e6c0 cfg.mk: allow integers to be assigned a value computed with i|j|k
Even line like this:

int asdf = i - somevar;

was matched by the regex, so this patch adds '=' to the list of
characters that break the regexp.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-08-22 09:12:14 +02:00
Martin Kletzander
27a7081c29 daemon: support passing FDs from the calling process
First FD is the RW unix socket to listen on, second one (if
applicable) is the RO unix socket.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-08-22 09:12:13 +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
Li Yang
b2e87c3628 virsh: man: Add LXC format info for domxml-from/to-native
Signed-off-by: Li Yang <liyang.fnst@cn.fujitsu.com>
2014-08-21 15:47:48 +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
Peter Krempa
b470a38fa9 virsh: Don't print extra '-'s in error message for -k and -K options
The error message contains one extra dash.
2014-08-21 09:58:34 +02: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
Peter Krempa
d88f9027ae examples: test: Kill unsupported maxMemory element
The "maxMemory" element was never supported by libvirt. Remove it from
the test XMLs. (Found while actually trying to add support for a
identically named element).
2014-08-20 15:27:18 +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
Peter Krempa
afa44743b6 qemu: Explicitly state that hotplugging cdroms and floppies doesn't work 2014-08-20 09:28:03 +02:00
Giuseppe Scrivano
2143934009 conf: fix comment
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2014-08-19 21:47:49 +02:00
Giuseppe Scrivano
62df8ce07f qemu_command: fix block indentation
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2014-08-19 21:47:49 +02:00
Giuseppe Scrivano
583b7aa7d9 conf, virDomainFSDefPtr: rename "path" argument to "target"
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2014-08-19 21:47:49 +02:00