Commit Graph

21479 Commits

Author SHA1 Message Date
Peter Krempa
e992aa21f7 conf: Add helper to return a bitmap of active iothread ids 2016-02-05 16:21:45 +01:00
Peter Krempa
9479642fd3 util: bitmap: Introduce bitmap subtraction
Performs binary subtraction of two bitmaps. Stores result in the first
operand.
2016-02-05 16:21:45 +01:00
Martin Kletzander
c3bd0019c0 systemd: Modernize machine naming
So, systemd-machined has this philosophy that machine names are like
hostnames and hence should follow the same rules.  But we always allowed
international characters in domain names.  Thus we need to modify the
machine name we are passing to systemd.

In order to change some machine names that we will be passing to systemd,
we also need to call TerminateMachine at the end of a lifetime of a
domain.  Even for domains that were started with older libvirt.  That
can be achieved thanks to virSystemdGetMachineNameByPID().  And because
we can change machine names, we can get rid of the inconsistent and
pointless escaping of domain names when creating machine names.

So this patch modifies the naming in the following way.  It creates the
name as <drivername>-<id>-<name> where invalid hostname characters are
stripped out of the name and if the resulting name is longer, it
truncates it to 64 characters.  That way we can start domains we
couldn't start before.  Well, at least on systemd.

To make it work all together, the machineName (which is needed only with
systemd) is saved in domain's private data.  That way the generation is
moved to the driver and we don't need to pass various unnecessary
arguments to cgroup functions.

The only thing this complicates a bit is the scope generation when
validating a cgroup where we must check both old and new naming, so a
slight modification was needed there.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-02-05 16:11:50 +01:00
Joao Martins
b8b03f64e1 conf: add caps to virDomainSnapshotDefFormat
The virDomainSnapshotDefFormat calls into virDomainDefFormat,
so should be providing a non-NULL virCapsPtr instance. On the
qemu driver we change qemuDomainSnapshotWriteMetadata to also
include caps since it calls virDomainSnapshotDefFormat.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
2016-02-05 10:57:39 +00:00
Daniel P. Berrange
1036ddadb2 conf: add caps to virDomainObjFormat/SaveStatus
The virDomainObjFormat and virDomainSaveStatus methods
both call into virDomainDefFormat, so should be providing
a non-NULL virCapsPtr instance.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-02-05 10:57:08 +00:00
Roman Bogorodskiy
02a34d2af4 bhyve: fix build
Fix build fail introduced as a side effect of commit d239a54.

Pushed under the build breaker rule.
2016-02-05 05:36:26 +03:00
Nikolay Shirokovskiy
e29990c5a4 qemu migration: factor out setting migration option
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-02-04 16:35:19 +01:00
Peter Krempa
41c987b72d Fix build after recent patches
Few build breaking mistakes in less-popular parts of our code.
2016-02-04 16:34:28 +01:00
John Ferlan
7de8b442ff logical: Clarify pieces of lvs regex
Rather than have a unwieldy regex string - split it up into its components
each having it's own #define and then combine in a different #define

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-02-04 10:15:30 -05:00
Joao Martins
a040ba9ed4 libxl: set net device prefix
Use the newly added virCapabilitiesSetNetPrefix to set
the network prefix for the driver. This in return will
be use by NetDefFormat() and NetDefParseXML() routines
to free any interface name that start with the registered
prefix.

Acked-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
2016-02-04 12:47:42 +00:00
Joao Martins
cd57b7c742 conf: add caps to virDomainSaveConfig
virDomainSaveConfig calls virDomainDefFormat which was setting the caps
to NULL, thus keeping the old behaviour (i.e. not looking at
netprefix). This patch adds the virCapsPtr to the function and allows
the configuration to be saved and skipping interface names that were
registered with virCapabilitiesSetNetPrefix().

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
2016-02-04 12:38:27 +00:00
Joao Martins
d239a5427f conf: add caps to virDomainDefFormat*
And use the newly added caps->host.netprefix (if it exists) for
interface names that match the autogenerated target names.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
2016-02-04 12:38:26 +00:00
Joao Martins
481e9bd0f6 conf: add prefix in virDomainNetDefParseXML
And use the newly added caps->host.netprefix for free interface
names that match the autogenerated target names.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
2016-02-04 11:15:51 +00:00
Joao Martins
819d1d9438 conf: add net device prefix to capabilities
In the reverted commit d2e5538b1, the libxl driver was changed to copy
interface names autogenerated by libxl to the corresponding network def
in the domain's virDomainDef object. The copied name is freed when the
domain transitions to the shutoff state. But when migrating a domain,
the autogenerated name is included in the XML sent to the destination
host.  It is possible an interface with the same name already exists on
the destination host, causing migration to fail.

This patch defines a new capability for setting the network device
prefix that will be used in the driver. Valid prefixes are
VIR_NET_GENERATED_PREFIX or the one announced by the driver.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
2016-02-04 11:15:51 +00:00
Roman Bogorodskiy
6221b8944e virsh: display if ZFS storage backend is enabled
Make 'virsh -V' list ZFS storage backend if it's enabled.
2016-02-04 03:16:50 +03:00
Roman Bogorodskiy
82f17fbe68 configure: zfs: enable on Linux
ZFS-on-Linux implementation of ZFS starting with version 0.6.4
contains all the features we use. Additionally, as we support
'volmode' option handling that's not available on ZoL but is
available on FreeBSD, there is no need to block ZFS storage driver
on Linux anymore.

So un-mark zfs storage driver as FreeBSD-only.
2016-02-04 03:16:50 +03:00
Roman Bogorodskiy
c94f6d4dff storage: zfs: flexible use of 'volmode' option
There are slight differences in various ZFS implementations.
Specifically, ZFS on FreeBSD requires to set value of 'volmode'
option to 'dev' to expose volumes as raw disk device (that's what
we need) rather than geom provides, for example.

With ZFS on Linux, however, such option is not available and
volumes exposed like we need by default.

To make our implementation more flexible, only pass 'volmode'
when it's supported. Support is checked by parsing usage
information of the 'zfs get' command.
2016-02-04 03:16:50 +03:00
Erik Skultety
8cd1d546e6 util: Export remoteSerializeTypedParameters internally via util
Same as for deserializer, this method might get handy for admin one day.
The major reason for this patch is to stay consistent with idea, i.e.
when deserializer can be shared, why not serializer as well. The only
problem to be solved was that the daemon side serializer uses a code
snippet which handles sparse arrays returned by some APIs as well as
removes any string parameters that can't be returned to older clients.
This patch makes of the new virTypedParameterRemote datatype introduced
by one of the pvious patches.
2016-02-03 15:46:45 +01:00
Erik Skultety
9afc115f73 util: Export remoteFreeTypedParameters internally via util
Since the method is static to remote_driver, it can't even be used by our
daemon. Other than that, it would be useful to be able to use it with admin as
well. This patch uses the new virTypedParameterRemote datatype introduced in
one of previous patches.
2016-02-03 15:46:45 +01:00
Erik Skultety
0472cef685 util: Export remoteDeserializeTypedParameters internally via util
Currently, the deserializer is hardcoded into remote_driver which makes
it impossible for admin to use it. One way to achieve a shared implementation
(besides moving the code to another module) would be pass @ret_params_val as a
void pointer as opposed to the remote_typed_param pointer and add a new extra
argument specifying which of those two protocols is being used and typecast
the pointer at the function entry. An example from remote_protocol:

struct remote_typed_param_value {
        int type;
        union {
                int i;
                u_int ui;
                int64_t l;
                uint64_t ul;
                double d;
                int b;
                remote_nonnull_string s;
        } remote_typed_param_value_u;
};
typedef struct remote_typed_param_value remote_typed_param_value;

struct remote_typed_param {
        remote_nonnull_string field;
        remote_typed_param_value value;
};

That would leave us with a bunch of if-then-elses that needed to be used across
the method. This patch takes the other approach using the new datatype
introduced in one of earlier commits.
2016-02-03 15:46:45 +01:00
Erik Skultety
41a459947f util: Introduce virTypedParameterRemote datatype
Both admin and remote protocols define their own types
(remote_typed_param vs admin_typed_param). Because of the naming convention,
admin typed params wouldn't be able to reuse the serialization/deserialization
methods, which are tailored for use by remote protocol, even if those method
were exported properly. In that case, introduce a new internal data type
structurally copying both admin and remote protocols which, eventually, would
allow serializer and deserializer to be used in a more generic way.
2016-02-03 15:46:45 +01:00
Nikolay Shirokovskiy
1e93470df0 qemu: qemuDomainRename and virDomainObjListNumOfDomains ABBA deadlock fix
A pretty nasty deadlock occurs while trying to rename a VM in parallel
with virDomainObjListNumOfDomains.
The short description of the problem is as follows:

Thread #1:

qemuDomainRename:
    ------> aquires domain lock by qemuDomObjFromDomain
       ---------> waits for domain list lock in any of the listed functions:
          - virDomainObjListFindByName
          - virDomainObjListRenameAddNew
          - virDomainObjListRenameRemove

Thread #2:

virDomainObjListNumOfDomains:
    ------> aquires domain list lock
       ---------> waits for domain lock in virDomainObjListCount

Introduce generic virDomainObjListRename function for renaming domains.
It aquires list lock in right order to avoid deadlock. Callback is used
to make driver specific domain updates.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-02-03 15:20:11 +01:00
Martin Kletzander
92757d4d2d systemd: Add virSystemdGetMachineNameByPID
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-02-03 14:57:43 +01:00
Martin Kletzander
9ba2646291 Revert "systemd: Escape only needed characters for machined"
This reverts commit 0e0149ce91.

That commit was added to comply with systemd rules that were changed in
the meantime, so this patch is pointless.
2016-02-03 14:44:37 +01:00
Ján Tomko
e1d7273f24 Simplify virDomainParseMemory
Do not store the return value of virDomainParseScaledValue,
it was overwritten anyway.

Delete the cleanup label, there is nothing to clean up.
2016-02-03 13:22:43 +01:00
Peter Krempa
598927a5bc conf: Split out logic to determine whether cpupin was provided 2016-02-03 13:10:04 +01:00
Peter Krempa
451b955d62 qemu: domain: Prepare qemuDomainDetectVcpuPids for reuse
Free the old vcpupids array in case when this function is called again
during the run of the VM. It will be later reused in the vCPU hotplug
code. The function now returns the number of detected VCPUs.
2016-02-03 13:10:04 +01:00
Peter Krempa
e97d1d20b1 qemu: Move and rename qemuProcessDetectVcpuPIDs to qemuDomainDetectVcpuPids
Future patches will tweak and reuse the function in different places so
move it separately first.
2016-02-03 13:10:04 +01:00
Peter Krempa
a190744aa9 qemu: cpu hotplug: Set vcpu state directly in the new structure
Avoid using virDomainDefSetVcpus when we can set it directly in the
structure.
2016-02-03 13:10:04 +01:00
Peter Krempa
9bf284daa9 conf: Add helper to retrieve bitmap of active vcpus for a definition
In some cases it may be better to have a bitmap representing state of
individual vcpus rather than iterating the definition. The new helper
creates a bitmap representing the state from the domain definition.
2016-02-03 13:10:04 +01:00
Peter Krempa
58578f83bc cgroup: Clean up virCgroupGetPercpuStats
Use 'ret' for return variable name, clarify use of 'param_idx' and avoid
unnecessary 'success' label. No functional changes. Also document the
function.
2016-02-03 13:10:04 +01:00
Martin Kletzander
1794a0103a qemu: Don't crash when create fails early
Since commit 7140807917 we are generating
socket path later than before -- when starting a domain.  That makes one
particular inconsistent state of a chardev, which was not possible
before, currently valid.  However, SELinux security driver forgot to
guard the main restoring function by a check for NULL-paths.  So make it
no-op for NULL paths, as in the DAC driver.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-02-03 11:01:42 +01:00
Erik Skultety
1fe6d8bfa8 cfg.mk: Adjust sc_prohibit_int_ijk to support 'exempt from syntax-check'
There might be cases, like with typed params, where triggering this check isn't
desirable. But including the whole module in the exception regex is not always
to right way of doing things. By adding an option to manually disable this check
on a specific occurrence, the module itself will still be checked against the
rule.
2016-02-03 10:58:01 +01:00
Dmitry Andreev
d2dabff3a0 qemuDomainResume: allow to resume domain with guest panicked
In case of guest panicked, preserved crashed domain has stopped CPUs.
It's not possible to use tools like WinDbg for the problem investigation
until we start CPUs back.
2016-02-03 10:33:48 +01:00
Nikolay Shirokovskiy
4a67b044fb qemu: return -1 on error paths in qemuDomainSaveImageStartVM
Error paths after sending the event that domain is started written as if ret = -1
which is set at the beginning of the function. It's common idioma to keep 'ret'
equal to -1 until the end of function where it is set to 0. But here we use ret
to keep result of restore operation too and thus breaks the idioma and its users :)

Let's use different variable to hold restore result.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-02-03 10:27:35 +01:00
John Ferlan
6ec319b84f logical: Clean up allocation when building regex on the fly
Rather than a loop reallocating space to build the regex, just allocate
it once up front, then if there's more than 1 nextent, append a comma and
another regex_unit string.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-02-02 13:13:05 -05:00
John Ferlan
c6d526f33f logical: Use 'stripes' value for mirror/raid segtype
The 'stripes' value is described as the "Number of stripes or mirrors in
a logical volume". So add "mirror" and anything that starts with "raid"
to the list of segtypes that can have an 'nextents' value greater than one.
Use of raid segtypes (raid1, raid4, raid5*, raid6*, and raid10) is favored
over mirror in more recent lvm code.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-02-02 13:13:01 -05:00
John Ferlan
69267756d0 logical: Use VIR_APPEND_ELEMENT instead of VIR_REALLOC_N
Rather than preallocating a set number of elements, then walking through
the extents and adjusting the specific element in place, use the APPEND
macros to handle that chore.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-02-02 13:12:57 -05:00
Michal Privoznik
0d0e41a719 include: Handle case when builddir == srcdir
In my previous commit a70f3b1c77 I've tried to fix case
when building from VPATH and a file wasn't being installed.
However, my fix broke non-VPATH build.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-02-02 09:31:56 +01:00
Eric Blake
041f7c9304 tests: avoid realpath in test-lib.sh
Ever since commit ace4aecd, running 'make check' on RHEL 6 produces:

./test-lib.sh: line 21: realpath: command not found

for every shell script test, because 'realpath' was not part of
coreutils back then.

* tests/test-lib.sh (_scriptdir): Compute with only portable shell.

Signed-off-by: Eric Blake <eblake@redhat.com>
2016-02-01 13:03:28 -07:00
Michael Chapman
86c4df83b9 virsh: improve waiting for block job readiness
After a block job hits 100%, we only need to apply a timeout waiting for
a block job event if exactly one of the BLOCK_JOB or BLOCK_JOB_2
callbacks were able to be registered.

If neither callback could be registered, there's clearly no need for a
timeout.

If both callbacks were registered, then we're guaranteed to eventually
get one of the events. The path being used by virsh must be exactly the
source path or target device in the domain's disk definition, and these
are the respective strings sent back in these two events.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
2016-02-01 18:04:48 +01:00
Michael Chapman
8fa216bbb4 virsh: ensure SIGINT action is reset on all errors
If virTimeMillisNow() fails, the SIGINT action must be reset back to
its previous state.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
2016-02-01 18:04:48 +01:00
Michael Chapman
15dee2ef24 virsh: be consistent with style of loop exit
When waiting for a block job, the various statuses (COMPLETED, READY,
CANCELED, etc.) should all be treated consistently by having the loop be
exited with "break". Use "goto cleanup" for the error cases only, when
no block job status is available.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
2016-02-01 18:04:48 +01:00
Michael Chapman
704dfd6b0f virsh: avoid unnecessary progress updates
There is no need to call virshPrintJobProgress() unless the block job's
cur or end cursors have changed since the last iteration.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
2016-02-01 18:04:48 +01:00
Cole Robinson
92549b3b8a qemu: Mark some functions as static 2016-02-01 10:33:25 -05:00
Michal Privoznik
c779bf8f62 fdstream: Realign
Some lines in this file are misaligned which fires up my OCD.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-02-01 16:12:22 +01:00
Boris Fiuczynski
f73ad5d47e qemu: Align dump options for watchdog and on_crash events
Having on_crash set to either coredump-destroy or coredump-restart
creates core dumps with option memory-only in the directory specified
by auto_dump_path. When a watchdog is triggered with the action dump
the core dump is also placed into the directory specified by auto_dump_path
but is created without the option memory-only.

This patch sets the option memory-only also for core dumps created by the
watchdog event.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.vnet.ibm.com>
2016-02-01 13:47:56 +01:00
Michal Privoznik
a70f3b1c77 includes: Install libvirt-common.h
The libvirt-common.h is build time generated file from .in.
Obviously, it's generated into builddir and not srcdir. Problem
is, the list of header files to install, virinc_HEADERS contains
only $(srcdir)/*.h and this misses libvirt-common.h. This problem
is pretty obvious when doing a VPATH build.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-01-30 11:55:45 +01:00
John Ferlan
63e15ad5e0 logical: Create helper virStorageBackendLogicalParseVolExtents
Create a helper routine in order to parse any extents information
including the extent size, length, and the device string contained
within the generated 'lvs' output string.

A future patch would then be able to avoid the code more cleanly

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-01-29 14:13:14 -05:00
Wido den Hollander
84678267e4 rbd: Open in Read-Only mode when refreshing a volume
By opening a RBD volume in Read-Only we do not register a
watcher on the header object inside the Ceph cluster.

Refreshing a volume only calls rbd_stat() which is a operation
which does not write to a RBD image.

This allows us to use a cephx user which has no write
permissions if we would want to use the libvirt storage pool
for informational purposes only.

It also saves us a write into the Ceph cluster which should
speed up refreshing a RBD pool.

rbd_open_read_only() is available in all librbd versions which
also support rbd_open().

Signed-off-by: Wido den Hollander <wido@widodh.nl>
2016-01-29 14:09:34 -05:00