Commit Graph

1012 Commits

Author SHA1 Message Date
Ján Tomko
a4b1371803 Use virDomainObjGetDefs in lxcDomainGetMemoryParameters
Instead of virDomainLiveConfigHelperMethod.
2016-06-08 15:23:40 +02:00
Ján Tomko
c643910486 Use virDomainObjGetDefs in lxcDomainGetSchedulerParametersFlags
On LXC domain startup we have already called virDomainObjSetDefTransient
to fill vm->newDef.

There is no need to call virDomainLiveConfigHelperMethod which has the
ability to fill newDef if it's NULL.
2016-06-08 15:22:36 +02:00
Ján Tomko
1ca45c8fb5 Use virDomainObjGetDefs in lxcDomainSetSchedulerParametersFlags
On LXC domain startup we have already called virDomainObjSetDefTransient
to fill vm->newDef.

There is no need to call virDomainLiveConfigHelperMethod which has the
ability to fill newDef if it's NULL.
2016-06-08 15:22:00 +02:00
Ján Tomko
15654cc594 Use virDomainObjGetDefs in lxcDomainSetMemoryFlags
On LXC domain startup we have already called virDomainObjSetDefTransient
to fill vm->newDef.

There is no need to call virDomainLiveConfigHelperMethod which has the
ability to fill newDef if it's NULL.
2016-06-08 15:21:57 +02:00
Ján Tomko
c646cd742a lxc: rename vmdef to persistentDef
A few functions using virDomainLiveConfigHelperMethod use the generic
name 'vmdef' to point to the persistent definition.

Use persistentDef and/or persistentDefCopy to make its purpose obvious.
2016-06-08 15:20:35 +02:00
Daniel P. Berrange
5f1837eaca Pass config file object through to driver open methods
The virConnectOpenInternal method opens the libvirt client
config file and uses it to resolve things like URI aliases.

There may be driver specific things that are useful to
store in the config file too, so rather than have them
re-parse the same file, pass the virConfPtr down to the
drivers.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-06-08 13:48:45 +01:00
Peter Krempa
9890a7a183 conf: Add device def validation callback
Similarly to the domain definition validator add a device validator. The
change to the prototype of the domain validator is necessary as
virDomainDeviceInfoIterateInternal requires a non-const pointer.
2016-06-07 13:02:20 +02:00
Peter Krempa
998c9e34e6 conf: Rename VIR_DOMAIN_DEF_PARSE_VALIDATE to VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA
Make it obvious that the flag is controlling RNG schema validation.
2016-06-07 13:02:20 +02:00
Ján Tomko
8c40ede4a4 Do not check for domain liveness in virDomainObjSetDefTransient
Remove the live attribute and mark the definition as transient
whether the domain is runing or not.

There were only two callers left calling with live=false:
* testDomainStartState, where the domain already is active
  because we assigned vm->def->id just a few lines above the call
* virDomainObjGetPersistentDef, which now only calls
  virDomainObjSetDefTransient for an active domain
2016-06-06 08:34:22 +02:00
Ján Tomko
9b111048ad Clean up redundant usage of virDomainObjSetDefTransient
Commit 45ec297d from November 2010:
    Make state driver device hotplug/update actually transient
added virDomainObjSetDefTransient calls to the domain startup
function in several drivers.

In November 2011, commit 8866eed:
    Set aliases for LXC/UML console devices
added a call earlier in the startup function, without removing the
existing ones.

Also, in the UML driver it seems the function never did anything
useful - vm->def->id is set asynchronnously in umlNotifyEvent.
At the time of calling virDomainObjSetDefTransient with live=false,
vm->def->id was likely still -1, making the call a no-op.
2016-06-06 08:34:22 +02:00
Martin Kletzander
3470cd860d Fix building with -Og
When building using -Og, gcc sees that some variables can be used
uninitialized  It can be debatable whether it is possible with our
codeflow, but functions should be self-contained and initializations are
always good.  The return instead of goto is due to actualType being used
in the cleanup.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-06-03 13:26:30 +02:00
Katerina Koukiou
9b9d0f13d3 lxc: Fix virLXCDomainObjBeginJob position in lxcDomainSetMemoryParameters
Adjust the code to perform the virLXCDomainObjBeginJob first
and then the call virDomainLiveConfigHelperMethod.
As Ján Tomko pointed out, in virDomainLiveConfigHelperMethod,
there is a check to see if the domain is active when AFFECT_LIVE is set.
Since virLXCDomainObjBeginJob unlocks the virDomainObjPtr lock,
the domain could possibly be destroyed while we wait for the job
and the check results would no longer be valid.

Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com>
2016-05-27 15:15:44 +02:00
Peter Krempa
e6e144689d conf: Change virDomainCputune member 'shares' to unsigned long long
cgroup functions set and get the longer type so use it everywhere
2016-05-25 16:59:58 +02:00
John Ferlan
cb0159df9f lxc: Fix lxcDomainDestroyFlags endjob processing
Commit id '15ccb0dbf' added job functions for the lxc driver; however,
for shutdown and nonpersistent path, the vm was removed from the domain
object list and the vm pointer cleared before the endjob.

Adjust the code to perform the endjob first and then perform the
ObjListRemove as long as the vm wasn't NULL. This follows more closely
models from qemu and libxl

Found by Coverity (FORWARD_NULL)
2016-05-25 06:02:42 -04:00
Laine Stump
002b7704ff lxc: support <interface type='ethernet'>
This is identical to type='bridge', but without the "connect to a
bridge" part, so it can be handled by using the same functions (and
often even the same cases in switch statements), after renaming
virLXCProcessSetupInterfaceBridged() to virLXCProcessInterfaceTap()
and enhancing it to skip bridge-related items when brname == NULL.

To be truly useful, we need to support setting the ip address on the
host side veth as well as guest side veth (already supported for
type='bridge'), as well as setting the peer address for both.

The <script> element (supported by type='ethernet' in qemu) isn't
supported in this patch. An error is logged at domain start time if it
is encountered. This may be changed in a later patch.
2016-05-24 15:21:05 -04:00
Katerina Koukiou
306b3a8504 lxc: completely rework reference counting
This patch follows the pattern used in qemu driver regarding
reference counting.
It changes lxcDomObjFromDomain() to ref the domain (using
virDomainObjListFindByUUIDRef()) and adds virDomainObjEndAPI() which
should be the only function in which the return value of
virObjectUnref() is checked.  This makes all reference counting
deterministic and makes the code a bit clearer.

Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com>
2016-05-24 16:54:01 +02:00
Katerina Koukiou
6ce89dcae0 lxc: use job functions in lxcDomainLxcOpenNamespace & lxcDomainSendProcessSignal
Use the recently added job functions in lxcDomainLxcOpenNamespace,
lxcDomainSendProcessSignal.

Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com>
2016-05-24 16:35:02 +02:00
Jovanka Gulicoska
b29e08dbe3 More usage of virGetLastErrorMessage
Convert to virGetLastErrorMessage() in the rest of the code
2016-05-19 15:17:03 -04:00
Katerina Koukiou
15ccb0dbf3 lxc: use job functions in lxcDomain* functions that perform modify actions.
Use the recently added job functions and unlock the virDomainObj while
performing the respective modify operation.
This commit affects lxcDomain{DestroyFlags, Reboot, SetBlkioParameters,
SetMemoryParameters, SetMetadata, SetSchedulerParameterFlags, ShutdownFlags}

Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com>
2016-05-19 18:42:08 +02:00
Katerina Koukiou
95cee48056 lxc: use job functions in lxcDomain* functions that do query operations.
This commit affects lxcDomain{InterfaceStats, MemoryStats, BlockStats,
BlockStatsFlags}

Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com>
2016-05-19 18:42:08 +02:00
Katerina Koukiou
30129edd5f lxc: add job functions in lxcDomainSetAutostart
This operation isn't necessarily time consuming, but need to
wait in the queue of modify jobs.

Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com>
2016-05-19 18:42:08 +02:00
Katerina Koukiou
0fc0f715be lxc: use job functions in lxcDomain{AttachDeviceFlags, DetachDeviceFlags, UpdateDeviceFlags}
These operations aren't necessarily time consuming, but need to
wait in the queue of modify jobs.

Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com>
2016-05-19 18:42:08 +02:00
Katerina Koukiou
91f433e45c lxc: use job functions in lxcDomain{Suspend, Resume}
These operations aren't necessarily time consuming, but need to
wait in the queue of modify jobs.

Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com>
2016-05-19 18:42:08 +02:00
Katerina Koukiou
f5df98aae4 lxc: use job functions in lxcDomainSetMemoryFlags
Large balloon operation can be time consuming.  Use the recently
added job functions and unlock the virDomainObj while ballooning.

Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com>
2016-05-19 18:42:08 +02:00
Katerina Koukiou
c066f9eed3 lxc: use job functions in lxcDomain{CreateXMLWithFiles, CreateWithFiles}
Creating a large domain could potentially be time consuming.  Use the
recently added job functions and unlock the virDomainObj while
the create operation is in progress.

Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com>
2016-05-19 18:42:08 +02:00
Katerina Koukiou
03e9077bd1 lxc: Add job support to lxc driver
Follows the pattern used in the libxl driver for managing multiple,
simultaneous jobs within the driver.

Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com>
2016-05-19 18:42:08 +02:00
Erik Skultety
898c0bbea7 headers: Remove unnecessary keyword extern from function declaration
Usage of this keyword in front of function declaration that is exported via a
header file is unnecessary, since internally, this has been the default for most
compilers for quite some time.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-05-11 09:06:32 +02:00
Laine Stump
75db9997a0 util: set vlan tag for macvtap passthrough mode on SRIOV VFs
SRIOV VFs used in macvtap passthrough mode can take advantage of the
SRIOV card's transparent vlan tagging. All the code was there to set
the vlan tag, and it has been used for SRIOV VFs used for hostdev
interfaces for several years, but for some reason, the vlan tag for
macvtap passthrough devices was stubbed out with a -1.

This patch moves a bit of common validation down to a lower level
(virNetDevReplaceNetConfig()) so it is shared by hostdev and macvtap
modes, and updates the macvtap caller to actually send the vlan config
instead of -1.
2016-05-10 14:04:19 -04:00
Peter Krempa
5e9d56f83f lxc: Fix wrong error message on disk hotplug
Commit 36025c552 tried to improve error reporting for <disk type="lun">
but reused the code in LXC which doesn't care about the actual disk
type. The error messages would then contain a bogous hint that the
config for the 'lun' device is invalid which might not be the case.

Re-do the relevant portion of the commit with the original message.
2016-05-09 12:44:52 +02:00
Peter Krempa
3ec7bb354a util: Replace virDomainDiskSourceIsBlockType with a new helper
For disks sources described by a libvirt volume we don't need to do a
complicated check since virStorageTranslateDiskSourcePool already
correctly determines the actual disk type.

Replace the checks using a new accessor that does not open-code the
whole logic.
2016-05-09 12:36:52 +02:00
Erik Skultety
5841d64d25 rpc: virnetserverclient: Identify clients by an integer ID
Admin API needs a way of addressing specific clients. Unlike servers, which we
are happy to address by names both because its name reflects its purpose (to
some extent) and we only have two of them (so far), naming clients doesn't make
any sense, since a) each client is an anonymous, i.e. not recognized after a
disconnect followed by a reconnect, b) we can't predict what kind of requests
it's going to send to daemon, and c) the are loads of them comming and going,
so the only viable option is to use an ID which is of a reasonably wide data
type.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-05-02 22:25:51 +02:00
John Ferlan
27726d8c21 qemu: Introduce qemuDomainHostdevPrivatePtr
Modeled after the qemuDomainDiskPrivatePtr logic, create a privateData
pointer in the _virDomainHostdevDef to allow storage of private data
for a hypervisor in order to at least temporarily store auth/secrets
data for usage during qemuBuildCommandLine.

NB: Since the qemu_parse_command (qemuParseCommandLine) code is not
expecting to restore the auth/secret data, there's no need to add
code to handle this new structure there.

Updated copyrights for modules touched. Some didn't have updates in a
couple years even though changes have been made.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-05-02 06:10:19 -04:00
Laine Stump
70aa318b82 Revert "lxc domain allow to set peer address"
This reverts commit afee47d07c, which
added support to lxc for the "peer" attribute in domain interface <ip>
elements.

It's being removed temporarily for the release of libvirt 1.3.4
because the feature doesn't work, and there are concerns that it may
need to be modified in an externally visible manner which could create
backward compatibility problems.
2016-04-29 12:46:25 -04:00
Cole Robinson
27f2b74782 lxc: explicitly error on interface type=ethernet
It isn't implemented and does not work:

error: internal error: guest failed to start: /usr/lib/libvirt/libvirt_lxc: option '--veth' requires an argument
syntax: /usr/lib/libvirt/libvirt_lxc [OPTIONS] ...

We previously threw an explicit error, but this changed in
22cff52a2b , which I suspect was
untested for LXC
2016-04-18 17:49:45 -04:00
Martin Kletzander
aca4d72b2a Include sysmacros.h where needed
So in glibc-2.23 sys/sysmacros.h is no longer included from sys/types.h
and we don't build because of the usage of major/minor/makedev macros.
Autoconf already has AC_HEADER_MAJOR macro that check where exactly
these functions/macros are defined, so let's use that.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-04-18 20:36:57 +02:00
Cole Robinson
e7db227810 util: Add virGettextInitialize, convert the code
Take setlocale/gettext error handling pattern from tools/virsh-*
and use it for all standalone binaries via a new shared
virGettextInitialize routine. The virsh* pattern differed slightly
from other callers. All users now consistently:

* Ignore setlocale errors. virsh has done this forever, presumably for
  good reason. This has been partially responsible for some bug reports:

  https://bugzilla.redhat.com/show_bug.cgi?id=1312688
  https://bugzilla.redhat.com/show_bug.cgi?id=1026514
  https://bugzilla.redhat.com/show_bug.cgi?id=1016158

* Report the failed function name
* Report strerror
2016-04-14 13:22:40 -04:00
Vasiliy Tolstov
afee47d07c lxc domain allow to set peer address
Signed-off-by: Vasiliy Tolstov <v.tolstov@selfip.ru>
2016-04-07 18:27:15 +01:00
Vasiliy Tolstov
b3d069872c virnetdev allow to set peer address
Signed-off-by: Vasiliy Tolstov <v.tolstov@selfip.ru>
2016-04-07 18:22:58 +01:00
Michal Privoznik
865764de06 Drop paths.h include
We include the file in plenty of places. This is mostly due to
historical reasons. The only place that needs something from the
header file is storage_backend_fs which opens _PATH_MOUNTED. But
it gets the file included indirectly via mntent.h. At no other
place in our code we need _PATH_.*. Drop the include and
configure check then.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-18 09:43:45 +01:00
Martin Kletzander
fd4f278e1a daemon: Get server name from the server itself
Since servers know their name, there is no need to supply such
information twice.  Also defeats inconsistencies.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-03-11 12:58:41 +01:00
Martin Kletzander
dad3b07814 server: Store server name in server object
At first I did not want to do this, but after trying to implement some
newer feaures in the admin API I realized we need that to make our lives
easier.  On the other hand they are not saved redundantly and the
virNetServer objects are still kept in a hash table.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-03-11 12:58:41 +01:00
Peter Krempa
185d13b1b0 conf: refactor checking for unsupported memory devices
Introduce a helper to check supported device and domain config and move
the memory hotplug checks to it.

The advantage of this approach is that by default all new features are
considered unsupported by all hypervisors unless specifically changed
rather than the previous approach where every hypervisor would need to
declare that a given feature is unsupported.
2016-03-09 10:09:16 +01:00
Yuri Chornoivan
47b70b8793 Fix minor typos 2016-03-07 18:37:25 +01:00
Michal Privoznik
f3c47aafa4 virLXCProcessMonitorInitNotify: Initialize @inode
This is an error message I've just seen. Fix it by initializing
@inode.

  CC       lxc/libvirt_driver_lxc_impl_la-lxc_process.lo
lxc/lxc_process.c: In function 'virLXCProcessMonitorInitNotify':
lxc/lxc_process.c:767:23: error: 'inode' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     virDomainAuditInit(vm, initpid, inode);
                       ^

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-04 15:23:16 +01:00
Nikolay Shirokovskiy
7d3230d36d lxc: reuse virDomainObjUpdateModificationImpact
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-03-04 07:39:01 -05:00
Erik Skultety
252610f7dd virnetdaemon: Store servers in a hash table
Since the daemon can manage and add (at fresh start) multiple servers,
we also should be able to add them from a JSON state file in case of a
daemon restart, so post exec restart support for multiple servers is also
provided. Patch also updates virnetdaemontest accordingly.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-02-17 12:46:34 +01:00
Peter Krempa
cf113e8d54 util: cgroup: Allow ignoring EACCES in virCgroup(Allow|Deny)DevicePath
When adding disk images to ACL we may call those functions on NFS
shares. In that case we might get an EACCES, which isn't really relevant
since NFS would not hold a block device. This patch adds a flag that
allows to stop reporting an error on EACCES to avoid spaming logs.

Currently there's no functional change.
2016-02-17 10:54:05 +01:00
Peter Krempa
9cd5da710e util: cgroup: Drop virCgroup(Allow|Deny)DeviceMajor
Since commit 47e5b5ae virCgroupAllowDevice allows to pass -1 as either
the minor or major device number and it automatically uses '*' in place
of that. Reuse the new approach through the code and drop the duplicated
functions.
2016-02-17 10:54:05 +01:00
Michal Privoznik
d1a7102389 virStringListLength: Ensure const correctness
The virStringListLength function does not ever modify the passed
string list. It merely counts the items in it. Make sure that we
reflect this bit in the function header.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>

(crobinso: fix up spacing and squash in sheepdog bit suggested
 by Andrea)
2016-02-09 15:44:58 -05:00
Peter Krempa
7938b533d5 cgroup: Prepare for sparse vCPU topologies in virCgroupGetPercpuStats
Pass a bitmap of enabled guest vCPUs to virCgroupGetPercpuStats so that
non-continuous vCPU topologies can be used.
2016-02-08 09:51:34 +01:00