Commit Graph

22180 Commits

Author SHA1 Message Date
Erik Skultety
c618d48a38 admin: Prepare admin protocol for future worker related procedures
Before any getter or setter methods can be introduced, first specify a set of
public attributes/flags that these methods will be compatible with.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-04-18 17:07:27 +02:00
Erik Skultety
c516e7d31a util: Add more getters to threadpool parameters
In order for the client to see all thread counts and limits, current total
and free worker count getters need to be introduced. Client might also be
interested in the job queue length, so provide a getter for that too. As with
the other getters, preparing for the admin interface, mutual exclusion is used
within all getters.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-04-18 17:07:18 +02:00
Erik Skultety
e981607e4a util: Use a mutex when retrieving threadpool data
So far, the values the affected getters retrieve are static, i.e. there's no
way of changing them during runtime. But admin interface will later enable
not only getting but changing them as well. So to prevent phenomenons like
torn reads or concurrent reads and writes of unaligned values, use mutual
exclusion when getting these values (writes do, understandably, use them
already).

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-04-18 17:07:09 +02:00
Erik Skultety
7968517593 util: Report system error when virThreadCreateFull fails
Otherwise 'Unknown' error will be returned to client.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-04-18 17:06:54 +02:00
Erik Skultety
396f80519e util: Refactor thread creation by introducing virThreadPoolExpand
When either creating a threadpool, or creating a new thread to accomplish a job
that had been placed into the jobqueue, every time thread-specific data need to
be allocated, threadpool needs to be (re)-allocated and thread count indicators
updated. Make the code clearer to read by compressing these operations into a
more complex one.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-04-18 17:06:40 +02:00
Erik Skultety
84d21591a8 admin: Enable usage of typed parameters
Make all relevant changes to admin protocol, in order to achieve $(subj)

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-04-18 17:06:19 +02:00
Erik Skultety
f5d9c5d00c libvirt-host: Move virTypedParam* to libvirt-common
Commits 0472cef6, 9afc115f, 8cd1d546 exported typed params handlers internally,
but a commit which would move the public definition from libvirt-host to
libvirt-common was missing.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-04-18 17:05:48 +02:00
Peter Krempa
dc7aeeade1 event-test: Enforce domain event sync
Use verify to force adding new events by means of static assertions.
2016-04-18 16:31:30 +02:00
Peter Krempa
09b28782de event-test: Add VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON
When adding the static check I've noticed that one other event is
missing.
2016-04-18 16:31:29 +02:00
Peter Krempa
cecbb0642e event-test: Add VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_FAILED 2016-04-18 16:31:29 +02:00
Peter Krempa
9e9a5cf0f4 event-test: Add VIR_DOMAIN_EVENT_ID_JOB_COMPLETED 2016-04-18 16:31:29 +02:00
Peter Krempa
bb25001a5b event-test: Add VIR_DOMAIN_EVENT_ID_MIGRATION_ITERATION callback 2016-04-18 16:31:29 +02:00
Peter Krempa
9da32b368e event-test: Add VIR_DOMAIN_EVENT_ID_BLOCK_JOB and VIR_DOMAIN_EVENT_ID_BLOCK_JOB_2 2016-04-18 16:31:29 +02:00
Peter Krempa
e55b149169 event-test: make domain event registration declarative
Rather than copying loads of ugly code, let's help out by a few C
tricks.
2016-04-18 16:31:29 +02:00
Peter Krempa
16dfe015f9 event-test: warn on unhandled enum values
Avoid forgetting to add the correct fields to the switches in
event-test.
2016-04-18 16:31:29 +02:00
Peter Krempa
ab48005f10 event-test: make few switch statements future proof
Make them return "uknown" for invalid values without breaking compiler
checks to add new values.
2016-04-18 16:31:28 +02:00
Peter Krempa
5ffc742c17 event-test: Use switch instead of if/else if chains for lifecycle event translation 2016-04-18 16:31:28 +02:00
Peter Krempa
f3f01f771b event-test: Use typecasted enum to convert graphics event phase 2016-04-18 16:31:28 +02:00
Peter Krempa
09ddd86027 event-test: Force compiler check in switch for connectClose callback 2016-04-18 16:31:28 +02:00
Peter Krempa
fa95523b24 lib: document fields virConnectDomainEventDiskChangeReason 2016-04-18 16:31:28 +02:00
Peter Krempa
e1128b3a4c event-test: Use functions with typecasted switch to convert enums
Arrays would induce crash if a new value was introduced without adding
it here. This could happen for
VIR_DOMAIN_EVENT_DISK_DROP_MISSING_ON_START
2016-04-18 16:31:27 +02:00
Peter Krempa
2e0f34530b event-test: touch up coding style
Break long lines and format headers correctly.
2016-04-18 16:31:27 +02:00
Peter Krempa
6e71d1e824 event-test: Remove unnecessary 'usage' function 2016-04-18 16:31:27 +02:00
Peter Krempa
e1389f3983 event-test: Get rid of useless and ambiguous VIR_DEBUG macro
The event test does not try to include libvirt internals. Using a macro
named VIR_DEBUG might hint to such usage. Additionally it's useless
since it's used only in the main() function.

Modernize the message strings while touching them.
2016-04-18 16:31:27 +02:00
Peter Krempa
fda27347d5 event-test: Remove forward declarations
Most of the functions are no longer in this file. 'usage' does not need
a declaration.
2016-04-18 16:31:27 +02:00
Jason J. Herne
0e570a6acc Libvirt: virTypedParamsValidate: Fix detection of multiple parameters
virTypedParamsValidate currently uses an index based check to find
duplicate parameters. This check does not work. Consider the following
simple example:

We have only 2 keys
A  (multiples allowed)
B  (multiples NOT allowed)

We are given the following list of parameters to check:
A
A
B

If you work through the validation loop you will see that our last iteration
through the loop has i=2 and j=1. In this case, i > j and keys[j].value.i will
indicate that multiples are not allowed. Both conditionals are satisfied so
an incorrect error will be given: "parameter '%s' occurs multiple times"

This patch replaces the index based check with code that remembers
the name of the last parameter seen and only triggers the error case if
the current parameter name equals the last one. This works because the
list is sorted and duplicate parameters will be grouped together.

In reality, we hit this bug while using selective block migration to migrate
a guest with 5 disks. 5 was apparently just the right number to push i > j
and hit this bug.

virsh migrate --live guestname --copy-storage-all
              --migrate-disks vdb,vdc,vdd,vde,vdf
              qemu+ssh://dsthost/system

Signed-off-by: Jason J. Herne <jjherne@linux.vnet.ibm.com>
Reviewed-by: Eric Farman <farman@linux.vnet.ibm.com>
2016-04-18 15:57:20 +02:00
Dmitry Andreev
b028e9d7c2 qemu: migration: new migration param for persistent destination XML
Migration API allows to specify a destination domain configuration.
Offline domain has only inactive XML and it is replaced by configuration
specified using VIR_MIGRATE_PARAM_DEST_XML param. In case of live
migration VIR_MIGRATE_PARAM_DEST_XML param is applied for active XML.

This commit introduces the new VIR_MIGRATE_PARAM_PERSIST_XML param
that can be used within live migration to replace persistent/inactive
configuration.

Required for: https://bugzilla.redhat.com/show_bug.cgi?id=835300
2016-04-18 14:45:58 +02:00
Dmitry Andreev
dc311c64ea qemuMigrationCookieAddPersistent: move it out and change argument type
This changes allow to use qemuMigrationCookieAddPersistent with
an XML definition that isn't assigned to any domain.
2016-04-18 14:02:39 +02:00
Richard Laager
c81bba4f6f ZFS: Support sparse volumes
By default, `zfs create -V ...` reserves space for the entire volsize,
plus some extra (which attempts to account for overhead).

If `zfs create -s -V ...` is used instead, zvols are (fully) sparse.

A middle ground (partial allocation) can be achieved with
`zfs create -s -o refreservation=... -V ...`.  Both libvirt and ZFS
support this approach, so the ZFS storage backend should support it.

Signed-off-by: Richard Laager <rlaager@wiktel.com>
2016-04-17 07:32:27 +03:00
John Ferlan
727a3c5860 Resolve a couple of memory leaks
Commit id '4b75237f' seems to have triggered Coverity into finding
at least one memory leak in xen_xl.c for error path for cleanup where
the listenAddr would be leaked. Reviewing other callers, it seems that
qemu_parse_command.c would have the same issue, so just it too.
2016-04-16 08:04:14 -04:00
John Ferlan
cb31d618fd tools: Fix memory leak
Coverity found that commit id 'c661b675f' needed to create a cleanup
path to handle the closing of 'fp' if the virBitmapNewQuiet failed.
2016-04-16 08:04:14 -04:00
John Ferlan
6c09c17e0d qemu: Fix qemuBuildCommandLine prototype
Commit id '0da965c5e' removed the 11th parameter, but neglected to
remove the ATTRIBUTE_NONNULL for it and adjust the 17th and 18th.
2016-04-16 08:04:14 -04:00
Jim Fehlig
e744065679 libxl: use LIBXL_API_VERSION 0x040200
To ensure the libvirt libxl driver will build with future versions
of Xen where the libxl API may change in incompatible ways,
explicitly use LIBXL_API_VERSION 0x040200. The libxl driver
does use new libxl APIs that have been added since Xen 4.2, but
currently it does not make use of any changes made to existing
APIs such as libxl_domain_create_restore or libxl_set_vcpuaffinity.
The version can be bumped if/when the libxl driver consumes the
changed APIs.

Further details can be found in the following discussion thread

https://www.redhat.com/archives/libvir-list/2016-April/msg00178.html
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2016-04-15 12:02:32 -06:00
Martin Kletzander
744d74fafd qemu: Label master key file
When creating the master key, we used mode 0600 (which we should) but
because we were creating it as root, the file is not readable by any
qemu running as non-root.  Fortunately, it's just a matter of labelling
the file.  We are generating the file path few times already, so let's
label it in the same function that has access to the path already.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-04-15 12:15:28 -04:00
Jiri Denemark
00307b5d82 ploop: Fix build with gluster
Recent patches addiing support for ploop volumes did not properly update
gluster backend.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-04-15 18:09:18 +02:00
Richard W.M. Jones
beaa447a29 Add functions for handling exponential backoff loops.
In a few places in libvirt we busy-wait for events, for example qemu
creating a monitor socket.  This is problematic because:

 - We need to choose a sufficiently small polling period so that
   libvirt doesn't add unnecessary delays.

 - We need to choose a sufficiently large polling period so that
   the effect of busy-waiting doesn't affect the system.

The solution to this conflict is to use an exponential backoff.

This patch adds two functions to hide the details, and modifies a few
places where we currently busy-wait.

Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
2016-04-15 16:54:28 +01:00
Olga Krishtal
03e750f35d storage: dir: adapt .uploadVol .dowloadVol for ploop volume
In case of ploop volume, target path of the volume is the path to the
directory that contains image file named root.hds and DiskDescriptor.xml.
While using uploadVol and downloadVol callbacks we need to open root.hds
itself.
Upload or download operations with ploop volume are only allowed when
images do not have snapshots. Otherwise operation fails.

Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2016-04-15 17:27:32 +02:00
Olga Krishtal
ea94be4703 storage: dir: adapt .refreshVol and .refreshPool for ploop volumes
Refreshes meta-information such as allocation, capacity, format, etc.
Ploop volumes differ from other volume types. Path to volume is the path
to directory with image file root.hds and DiskDescriptor.xml.
https://openvz.org/Ploop/format
Due to this fact, operations of opening the volume have to be done once
again. get the information.

To decide whether the given volume is ploops one, it is necessary to check
the presence of root.hds and DiskDescriptor.xml files in volumes' directory.
Only in this case the volume can be manipulated as the ploops one.
Such strategy helps us to resolve problems that might occure, when we
upload some other volume type from ploop source.

Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2016-04-15 17:27:32 +02:00
Olga Krishtal
0927fb3ea8 storage: dir: .wipeVol is left unsupported for ploop volume
Returns error in case of vol-wipe cmd for a ploop volume

Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com>
2016-04-15 17:27:32 +02:00
Olga Krishtal
d957ba8deb storage: dir: .resizeVol callback for ploop volume
Changes the size of given ploop volume via ploop resize tool.

Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com>
2016-04-15 17:27:32 +02:00
Olga Krishtal
02d1e45654 storage: dir: .deleteVol callback for ploop volume
Recursively deletes whole directory of a ploop volume.
To delete ploop image it has to be unmounted.

Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com>
2016-04-15 17:27:32 +02:00
Olga Krishtal
cff2138b71 storage: dir: .buildVol and .buildVolFrom callbacks for ploop
These callbacks let us to create ploop volumes in dir, fs and etc. pools.
If a ploop volume was created via buildVol callback, then this volume
is an empty ploop device with DiskDescriptor.xml.
If the volume was created via .buildFrom - then its content is similar to
input volume content.

Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2016-04-15 17:27:32 +02:00
Olga Krishtal
ee36975597 storage: add ploop volume type
Ploop image consists of directory with two files: ploop image itself,
called root.hds and DiskDescriptor.xml that contains information about
ploop device: https://openvz.org/Ploop/format.
Such volume are difficult to manipulate in terms of existing volume types
because they are neither a single files nor a directory.
This patch introduces new volume type - ploop. This volume type is used
by ploop volume's exclusively.

Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2016-04-15 17:27:32 +02:00
Andrea Bolognani
294d22c8d6 cfg.mk: Get rid of quotation tricks
To prevent the error messages in cfg.mk from triggering the very
same rules they're supposed to explain, we split the message in
the middle of a symbol name, ending up with stuff like

  'I am a me'ssage

Instead of relying on these quotation tricks, simply exclude
cfg.mk from the relevant checks.
2016-04-15 16:05:41 +02:00
Nitesh Konkar
0ed35e0939 Return error when --start <number> in cpu-stats is invalid.
Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
2016-04-15 15:20:11 +02:00
Peter Krempa
6306ee6249 qemu: hotplug: Properly recalculate/reload balloon size after hot(un)plug
Rather than trying some magic calculations on our side query the monitor
for the current size of the memory balloon both on hotplug and
hotunplug.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1220702
2016-04-15 14:27:09 +02:00
Peter Krempa
1996da216a qemu: process: Simplify condition in qemuProcessRefreshBalloonState
No need to store failure and re-check right away.
2016-04-15 14:27:09 +02:00
Peter Krempa
c0e962b6f3 qemu: driver: Reuse qemuDomainGetMonitor in qemuDomainMemoryStats 2016-04-15 14:27:09 +02:00
Peter Krempa
d6cb0d256a domain: Add helper to determine presence of memory baloon 2016-04-15 14:27:08 +02:00
Peter Krempa
33b9598c41 qemu: command: Refactor memballoon command line formatting
Now that there is just one format of the memory balloon command line
used the code can be merged into a single function.

Additionally with some tweaks to the control flow the code is easier to
read.
2016-04-15 14:27:08 +02:00