Commit Graph

17469 Commits

Author SHA1 Message Date
John Ferlan
bab35f7419 storage_driver: Resolve Coverity REVERSE_INULL
There were two occurrances of attempting to initialize actualType by
calling virStorageSourceGetActualType(src) prior to a check if (!src)
resulting in Coverity complaining about the possible NULL dereference
in virStorageSourceGetActualType() of src.

Resolve by moving the actualType setting until after checking !src
2014-08-27 12:52:27 -04:00
John Ferlan
cfbbeb36cf xen_xm: Resolve Coverity USE_AFTER_FREE
If virDomainDiskDefFree(disk) is called in 'skipdisk:', then it's possible
to either return to skipdisk without reallocating a new disk (via the if
condition just prior) or to end the loop having deleted the disk. Since
virDomainDiskDefFree() does not pass by reference, disk isn't changed in
this context, thus the possible issue.
2014-08-27 12:52:27 -04:00
John Ferlan
0454f23c31 xen_common: Resolve Coverity USE_AFTER_FREE
There were two warnings in this module

  If the VIR_ALLOC_N(def->serials, 1) fails, then a virDomainChrDefFree(chr)
  is called and we jump to cleanup which makes the same call. Just remove
  the one after VIR_ALLOC_N()

  In the label "skipnic:" a virDomainNetDefFree(net) is made; however, if
  in going back to the top of the loop we jump back down to skipnic for any
  reason, the call will attempt to free an already freed structure since
  "net" was not passed by reference to virDomainNetDefFree().  Just set
  net = NULL in skipnic: to resolve the issue.
2014-08-27 12:52:27 -04:00
John Ferlan
0da9a8a8bf parallels: Resolve Coverity USE_AFTER_FREE
Coverity complains that calling virNetworkDefFree(def), then jumping
to the cleanup: label which calls virNetworkDefFree(def) could result
in a double_free.  Just remove the call from the if statement.
2014-08-27 12:52:26 -04:00
Martin Kletzander
a6a210b879 conf: fix leak with def->mem.hugepages
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-08-27 15:40:37 +02:00
Michal Privoznik
dbb4cbf532 vbox: Register per partes
Since times when vbox moved to the daemon (due to some licensing
issue) the subdrivers that vbox implements were registered, but not
opened since our generic subdrivers took priority. I've tried to fix
this in 65b7d553f3 but it was not correct. Apparently moving
vbox driver registration upfront changes the default connection URI
which makes some users sad. So, this commit breaks vbox into pieces
and register vbox's network and storage drivers first, and vbox driver
then at the end. This way, the vbox driver is registered in the order
it always was, but its subdrivers are registered prior the generic
ones.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-08-27 08:05:25 +02:00
Michal Privoznik
27d59ab7cd virDriverLoadModule: Honor libvirt func name tranlsation
There's this unwritten rule in libvirt that vir_function is translated
into virFunction when needed (e.g. in remote protocol definition,
python, ...). Up till now we ignored such translation in driver module
loading and did fine. Well, we didn't have any module with an
underscore in its name. But this will change in next commit. The
problem is, once an a module is dlopen()-ed, we derive register
function name from its name. So instead of "driver_subdriverRegister"
do some magic to turn that into "driverSubdriverRegister".

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-08-27 07:41:48 +02:00
Michal Privoznik
5feaef1776 virdrivermoduletest: Test all the modules
Even though we kept adding new and new modules (e.g. vbox or bhyve)
the test wasn't updated. Do that now. Moreover, while it's not
crucial, it's nice to reorder test cases to match the order in which
the daemon loads the modules.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-08-27 07:41:48 +02:00
Eric Blake
79f4c4e694 domain_conf: fix internal flag verification
While working on virDomainBlockCopy, I noticed we had a verify()
concerning internal XML flags that was incomplete after several
recent flag additions; move that up higher in the code to make it
harder to forget to modify on the next flag addition.  Adjust
some formatting while at it.

* src/conf/domain_conf.c (verify): Move closer to internal flag
definitions.  Cover missing flags ALLOW_ROM and ALLOW_BOOT.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-08-26 22:34:03 -06:00
Eric Blake
1db2f4f767 virsh: drop unused variable
While prepping for virDomainBlockJob patches, I found some dead code.

* tools/virsh-domain.c (blockJobImpl): Kill unused 'name'.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-08-26 22:17:07 -06:00
Jincheng Miao
03b994fac0 qemu: call endjob in RevertToSnapshot
In qemuDomainRevertToSnapshot(), it will check snap->def->state.
But when the state is PMSUSPENDED/NOSTATE/BLOCKED, it forgets to
call qemuDomainObjEndJob.

https://bugzilla.redhat.com/show_bug.cgi?id=1134154
Bug introduced in commit 1e833899.

Signed-off-by: Jincheng Miao <jmiao@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-08-26 21:11:16 -06:00
Eric Blake
b259e459b9 API: Tweak virDomainOpenGraphics to return fd directly
Let's fix this before we bake in a painful API.  Since we know
that we have exactly one non-negative fd on success, we might
as well return the fd directly instead of forcing the user to
pass in a pointer.  Furthermore, I found some memory and fd
leaks while reviewing the code - the idea is that on success,
libvirtd will have handed two fds in two different directions:
one to qemu, and one to the RPC client.

* include/libvirt/libvirt.h.in (virDomainOpenGraphicsFD): Drop
unneeded parameter.
* src/driver.h (virDrvDomainOpenGraphicsFD): Likewise.
* src/libvirt.c (virDomainOpenGraphicsFD): Adjust interface to
return fd directly.
* daemon/remote.c (remoteDispatchDomainOpenGraphicsFd): Adjust
semantics.
* src/qemu/qemu_driver.c (qemuDomainOpenGraphicsFD): Likewise,
and plug fd leak.
* src/remote/remote_driver.c (remoteDomainOpenGraphicsFD):
Likewise, and plug memory and fd leak.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-08-26 16:36:32 -06:00
Eric Blake
993fa528a6 blockcopy: virDomainBlockCopy with XML destination, typed params
This commit (finally) adds the virDomainBlockCopy API, with the
intent that it will provide more power to the existing 'virsh
blockcopy' command.

'virsh blockcopy' was first added in Apr 2012 (v0.9.12), which
corresponds to the upstream qemu 1.2 timeframe.  It was done as
a hack on top of the existing virDomainBlockRebase() API call,
for two reasons: 1) it was targetting a feature that landed first
in downstream RHEL qemu, but had not stabilized in upstream qemu
at the time (and indeed, 'drive-mirror' only landed upstream in
qemu 1.3 with slight differences to the first RHEL attempt,
and later gained further parameters like granularity and buf-size
that are also worth exposing), and 2) extending an existing API
allowed it to be backported without worrying about bumping .so
versions.  A virDomainBlockCopy() API was proposed at that time
[1], but we decided not to accept it into libvirt until after
upstream qemu stabilized, and it ended up getting scrapped.
Whether or not RHEL should have attempted adding a new feature
without getting it upstream first is a debate that can be held
another day; but enough time has now elapsed that we are ready to
do the interface cleanly.

[1] https://www.redhat.com/archives/libvir-list/2012-April/msg00768.html

Delaying the creation of a clean API until now has also had a
benefit: we've only recently learned of a few shortcomings in the
original design: 1) it is unable to target a network destination
(such as a gluster volume) because it hard-coded the assumption
that the destination is a local file name.  Because of all the
refactoring we've done to add virStorageSourcePtr, we are in a
better position to declare an API that parses XML describing a
host storage source as the copy destination, which was not
possible had we implemented virDomainBlockCopy as it had been
originally envisioned (although a network target will have to wait
until a later libvirt release compared to the API addition to
actually be implemented).  2) the design of using MiB/sec as the
bandwidth throttle is rather coarse; qemu is actually tuned to
bytes/second, and libvirt is preventing access to that level of
detail.  A later patch will add flags to existing block job API
that can request bytes/second instead of back-compat MiB/s, but as
this is a new API, we can get it right to begin with.

At least I had the foresight to create 'virsh blockcopy' as a
separate command at the UI level (commit 1f06c00) rather than
leaking the underlying API overload of virDomainBlockRebase onto
shell users.

A further note on the bandwidth option: virTypedParameters
intentionally lacks unsigned long (since variable-width
interaction between mixed 32- vs. 64-bit client/server setups is
nasty), but we have to deal with the fact that we are interacting
with existing older code that mistakenly chose unsigned long
bandwidth at a point before we decided to prohibit it in all new
API.  The typed parameter is therefore unsigned long long, but
the implementation (in a later patch) will have to do overflow
detection on 32-bit platforms, as well as capping the value to
match the LLONG_MAX>>20 cap of the existing MiB/s interfaces.

* include/libvirt/libvirt.h.in (virDomainBlockCopy): New API.
(virDomainBlockJobType, virConnectDomainEventBlockJobStatus):
Update related documentation.
* src/libvirt.c (virDomainBlockCopy): Implement it.
* src/libvirt_public.syms (LIBVIRT_1.2.8): Export it.
* src/driver.h (_virDriver): New driver callback.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-08-26 15:42:35 -06:00
Peter Krempa
3b20e50ddb virsh: domain: Split out code to lookup domain from string
Split out guts of the function to reuse it to get domain objects from
string.
2014-08-26 22:48:05 +02:00
Peter Krempa
76a5bc4eef lib: Introduce API for retrieving bulk domain stats
The motivation for this API is that management layers that use libvirt
usually poll for statistics using various split up APIs we currently
provide. To get all the necessary stuff, the app needs to issue a lot of
calls and aggregate the results.

The APIs I'm introducing here:
1) Returns data in a format that we can expand in the future and is
(pseudo) hierarchical. The data is returned as typed parameters where
the fields are constructed as dot-separated strings containing names and
other stuff in a list of typed params.

2) Stats for multiple (all) domains can be queried at once and are
returned in one call. This will decrease the overhead necessary to issue
multiple calls per domain multiplied by the count of domains.

3) Selectable (bit mask) fields in the returned format. This will allow
to retrieve only specific stats according to the app's need.

The stats groups will be enabled using a bit field @stats passed as the
function argument. A few sample stats groups that this API will support:

VIR_DOMAIN_STATS_STATE
VIR_DOMAIN_STATS_CPU
VIR_DOMAIN_STATS_BLOCK
VIR_DOMAIN_STATS_INTERFACE

(Note that this is only an example, the initial implementation supports
 only VIR_DOMAIN_STATS_STATE while others will be added later.)

the returned typed params will use the following scheme

state.state = VIR_DOMAIN_RUNNING
state.reason = VIR_DOMAIN_RUNNING_BOOTED (the actual values according to
                                          the enum)
cpu.count = 8
cpu.0.state = running
cpu.0.time = 1234
2014-08-26 22:46:12 +02:00
Ján Tomko
27a20b6c1a Wire up virDomainOpenGraphicsFD in QEMU driver
Should fix https://bugzilla.redhat.com/show_bug.cgi?id=999926
2014-08-26 19:26:35 +02:00
Ján Tomko
408aae3849 Add RPC implementation for virDomainOpenGraphicsFd 2014-08-26 19:26:28 +02:00
Ján Tomko
3ddc85440e Introduce virDomainOpenGraphicsFD API
Define the public API implementation and declare internal
driver prototype.
2014-08-26 18:55:30 +02:00
Erik Skultety
2f0944dec1 blkdeviotune: check for overflow when parsing XML
According to docs/schemas/domaincommon.rng and _virDomainBlockIoTuneInfo
all the iotune values are interpreted as unsigned long long, however
according to qemu_monitor_json.c, qemu silently truncates numbers
larger than LLONG_MAX. There's really not much of a usage for such
large numbers anyway yet. This patch provides the same overflow
check during a domain start as it does during setting
a blkdeviotune element in qemu_driver.c and thus reports an error when
a larger number than LLONG_MAX is detected.

https://bugzilla.redhat.com/show_bug.cgi?id=1131876
2014-08-26 17:22:35 +02:00
Ján Tomko
c285ffc4c2 virsh: Initialize vshData in cmdMigrate
If the virConnect did not succeeed, we called
virConnectClose on uninitialized data.

Introduced by commit 7eabd55.
2014-08-26 13:20:47 +02:00
Chen Fan
d59b2c920c storage: remove unused 'canonPath' in virStorageFileGetMetadata
Introduced by commit 395171f.

Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2014-08-26 10:42:38 +02:00
Alex Williamson
d071164272 Add new 'kvm' domain feature and ability to hide KVM signature
QEMU 2.1 added support for the kvm=off option to the -cpu command,
allowing the KVM hypervisor signature to be hidden from the guest.
This enables disabling of some paravirualization features in the
guest as well as allowing certain drivers which test for the
hypervisor to load.  Domain XML syntax is as follows:

<domain type='kvm>
  ...
  <features>
    ...
    <kvm>
      <hidden state='on'/>
    </kvm>
  </features>
  ...

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
2014-08-26 10:41:24 +02:00
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
Eric Blake
da5792419c spec: drop anything older than Fedora 13
RHEL 5 is based on libvirt 0.8.2, as was Fedora 13.  RHEL 5 also
happens to be the oldest box that we actively support with a
buildbot, so it is time to clean up some crufty conditionals in
the spec file that no longer are necessary for modern Fedora.

Although it is probably okay to make further simplifications to
a newer minimum Fedora version, that can be done as a later patch.
This patch just focuses on cleaning any comparison of %{?fedora}
that will always be true or false once we assume a minimum of F13.

* libvirt.spec.in: Make with_audit default to on. Move other
conditionals to a single RHEL-5 block. Simplify any fedora
comparison older than 13.  Document our assumptions.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-08-25 13:13:39 -06:00
Martin Kletzander
9e766888c7 docs: fix bootmenu timeout description
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-08-25 18:18:51 +02:00
Zhou Yimin
9eac73eb84 daemon: Fix option -v missing info priority log
Introduce by 63fbcc692.

When start libvirtd with commandline "/usr/sbin/libvirtd -d -l -v",
we expect verbose(info level) log if neither environment variable
nor config file about logging controls is set. But in fact we can't
get any info priority log in the default output file.

The log priority of default output is VIR_LOG_DEFAULT(VIR_LOG_WARN),
so the info log is filtered out.
To record info priority log we must parse option -v before setting the
default output.

After this patch, we get all verbose log in the default output file.

Signed-off-by: Zhou Yimin <zhouyimin@huawei.com>
2014-08-25 16:40:20 +02: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
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