Commit Graph

20364 Commits

Author SHA1 Message Date
ik.nitk
c27553b6e2 lxc: Inherit namespace feature
This patch adds feature for lxc containers to inherit namespaces.
This is very similar to what lxc-tools or docker provides.  Look
for "man lxc-start" and you will find that you can pass command
args as [ --share-[net|ipc|uts] name|pid ]. Or check out docker
networking option in which you can give --net=container:NAME_or_ID
as an option for sharing +namespace.

>From this patch you can add extra libvirt option to share
namespace in following way.

 <lxc:namespace>
   <lxc:sharenet type='netns' value='red'/>
   <lxc:shareipc type='pid' value='12345'/>
   <lxc:shareuts type='name' value='container1'/>
 </lxc:namespace>

The netns option is specific to sharenet. It can be used to
inherit from existing network namespace.

Co-authored: Daniel P. Berrange <berrange@redhat.com>
2015-08-26 11:28:30 +01:00
Martin Kletzander
f674dc6794 qemu: Label correct per-VM path when starting
Commit f1f68ca334 overused mdir_name()
event though it was not needed in the latest version, hence labelling
directory one level up in the tree and not the one it should.

If anyone with SElinux managed to try run a domain with guest agent set
up, it's highly possible that they will need to run 'restorecon -F
/var/lib/libvirt/qemu/channel/target' to fix what was done.

Reported-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-08-26 10:44:14 +02:00
Luyao Huang
bf2788218a qemu: Update blkio.weight value after successful set
https://bugzilla.redhat.com/show_bug.cgi?id=1253107

Make a call virCgroupGetBlkioWeight to re-read blkio.weight right
after it is set in order to keep internal data up-to-date.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
2015-08-25 16:20:39 -04:00
Sergey Bronnikov
ed7b4814b6 Rename page about vz driver 2015-08-25 07:36:37 -04:00
Sergey Bronnikov
4076d30f85 docs: Rename 'parallels' to 'vz'
Parallels driver was renamed to Virtuozzo. Replace old name by new
one for libvirt docs and schemas.
2015-08-25 07:21:33 -04:00
Vasiliy Tolstov
bbc705d130 Eliminate incorrect and unnecessary check for changed IP address
Commit aa2cc7 modified a previously unnecessary but innocuous check
for interface IP address during interface update incorrectly, causing
all attempted updates (e.g. changing link state) to interfaces of
type='ethernet' for QEMU to fail.

This patch fixes the issue by completely removing the check for IP
address, which is pointless since QEMU doesn't support setting
interface IP addresses from the domain interface XML anyway.

Signed-off-by: Vasiliy Tolstov <v.tolstov@selfip.ru>
Signed-off-by: Laine Stump <laine@laine.org>
2015-08-24 10:23:40 -04:00
Tomas Meszaros
6c2702eddf virDomainRename: Extend API documentation
Signed-off-by: Tomas Meszaros <exo@tty.sk>
2015-08-24 15:20:35 +02:00
Luyao Huang
c8e5177303 qemu: add a check for nodeset in qemuDomainSetNumaParamsLive
We will try to set the node to cpuset.mems without check if
it is available, since we already have helper to check this.
Call virNumaNodesetIsAvailable to check if node is available,
then try to change it in the cgroup.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
2015-08-24 15:20:35 +02:00
Guido Günther
4d4c90dfd5 selinux: fix compile errors
Remove unused variable, tag unused parameter and adjust return type.

introduced by 3f48345f7e

CC     security/libvirt_security_manager_la-security_selinux.lo
security/security_selinux.c: In function 'virSecuritySELinuxDomainSetDirLabel':
security/security_selinux.c:2520:5: error: return makes pointer from integer without a cast [-Werror]
security/security_selinux.c:2514:9: error: unused variable 'ret' [-Werror=unused-variable]
security/security_selinux.c:2509:59: error: unused parameter 'mgr' [-Werror=unused-parameter]
2015-08-24 14:15:12 +02:00
Guido Günther
269d39afe5 storage: only run safezero if allocation is > 0
While a zero allocation in safezero should be fine it isn't when we use
posix_fallocate which returns EINVAL on a zero allocation.

While we could skip the zero allocation in safezero_posix_fallocate it's
an optimization to do it for all allocations.

This fixes vm installation via virtinst for me which otherwise aborts
like:

   Starting install...
   Retrieving file linux...               | 5.9 MB     00:01 ...
   Retrieving file initrd.gz...           |  29 MB     00:07 ...
   ERROR    Couldn't create storage volume 'virtinst-linux.sBgds4': 'cannot fill file '/var/lib/libvirt/boot/virtinst-linux.sBgds4': Invalid argument'

The error was introduced by e30297b0 as spotted by Chunyan Liu
2015-08-24 13:51:44 +02:00
intrigeri
2f01cfdf05 virt-aa-helper: allow access to /usr/share/ovmf/
We forbid access to /usr/share/, but (at least on Debian-based systems)
the Open Virtual Machine Firmware files needed for booting UEFI virtual
machines in QEMU live in /usr/share/ovmf/. Therefore, we need to add
that directory to the list of read only paths.

A similar patch was suggested by Jamie Strandboge <jamie@canonical.com>
on https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1483071.
2015-08-24 13:00:39 +02:00
Guido Günther
d25a5e087a virt-aa-helper: Simplify restriction logic
First check overrides, then read only files then restricted access
itself.

This allows us to mark files for read only access whose parents were
already restricted for read write.

Based on a proposal by Martin Kletzander
2015-08-24 13:00:39 +02:00
Guido Günther
26c5fa3a9b virt-aa-helper: document --probing and --dry-run 2015-08-24 13:00:39 +02:00
Martin Kletzander
f1e927c4bf tests: Use qemuProcessPrepareMonitorChr in qemuxmlnstest
The output of that function was not tested until now.  In order to keep
the paths in /tmp, the test driver config is "fixed" as well.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-08-24 11:53:17 +02:00
Martin Kletzander
f1f68ca334 qemu: Fix access to auto-generated socket paths
We are automatically generating some socket paths for domains, but all
those paths end up in a directory that's the same for multiple domains.
The problem is that multiple domains can each run with different
seclabels (users, selinux contexts, etc.).  The idea here is to create a
per-domain directory labelled in a way that each domain can access its
own unix sockets.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-08-24 11:53:17 +02:00
Martin Kletzander
f4c60dfbf2 security_dac: Add SetDirLabel support
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-08-24 11:53:17 +02:00
Martin Kletzander
3f48345f7e security_selinux: Add SetDirLabel support
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-08-24 11:53:17 +02:00
Martin Kletzander
99cf04e32d security_stack: Add SetDirLabel support
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-08-24 11:53:17 +02:00
Martin Kletzander
f65a2a12f4 security: Add virSecurityDomainSetDirLabel
That function can be used for setting security labels on arbitrary
directories.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-08-24 11:53:17 +02:00
Martin Kletzander
7b6953bc22 security_dac: Label non-listening sockets
SELinux security driver already does that, but DAC driver somehow missed
the memo.  Let's fix it so it works the same way.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-08-24 11:53:17 +02:00
Martin Kletzander
4ac6ce38d3 security_selinux: Use proper structure to access socket data
In virSecuritySELinuxSetSecurityChardevLabel() we are labelling unix
socket path, but accessing another structure of the union.  This does
not pose a problem currently as both paths are at the same offset, but
this should be fixed for the future.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-08-24 11:53:17 +02:00
Erik Skultety
f08b1c58f3 locking: Remove redundant 'srv' element from virLockDaemon
Now that we have virNetDaemon object holding all the data and being
capable of referencing multiple servers, having a duplicate reference to
a single server stored in virLockDaemon isn't necessary anymore. This
patch removes the above described element.
2015-08-24 10:37:12 +02:00
Erik Skultety
4ac0d545e8 test: Replace tabs with spaces in virnetdaemondata json files
JSON data that are used to initialize tests in virnetdaemontest should
be in a consistent format, i.e. not using tabs for indentation, those
should be replaced by spaces.
2015-08-24 09:30:40 +02:00
Andrea Bolognani
7dc52241b3 tests: Add some compatibility-related cases to the CPU tests 2015-08-21 15:42:38 -07:00
Andrea Bolognani
5750149fed cpu: Move check for NULL CPU model inside the driver
While the check is appropriate for eg. the x86 and generic drivers,
there are some valid ppc64 guest configurations where the CPU
model is supposed to be NULL.

Moving this check from the generic code to the drivers makes it
possible to accomodate both use cases.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1251927
2015-08-21 15:42:38 -07:00
Andrea Bolognani
2f913162ed cpu: Better support for ppc64 compatibility modes
Not all combinations of host CPU models and compatibility modes
are valid, so we need to make sure we don't try to do something
that QEMU will reject.

Moreover, we need to apply a different logic to guests using
host-model and host-passthrough modes when testing them for host
compatibility.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1251927
2015-08-21 15:42:33 -07:00
Andrea Bolognani
6d7c2f65c1 cpu: Don't update host-model guest CPUs on ppc64
If a guest CPU is defined using

  <cpu mode='host-model'/>

the <model> sub-element will contain the compatibility mode to use.
That means we can't just copy the host CPU model on cpuUpdate(),
otherwise we'll overwrite that information and migration of such
guests will fail.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1251927
2015-08-21 14:51:31 -07:00
Martin Kletzander
14d84db863 Add generated libvirt_admin.syms into .gitignore
Commit a2c5d16a70 switched to generating
libvirt_admin.syms, but forgot to add the generated file into
.gitignore, hence causing tree pollution post-build.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-08-20 11:17:27 -07:00
John Ferlan
cb5d0193aa conf: Check for attach disk usage of iothread=0
Since iothreadid = 0 is invalid, we need to check for it when attempting
to add a disk; otherwise, someone would think/believe their attempt to
add an IOThread to the disk would succeed. Luckily other code ignored
things when ->iothread == 0...
2015-08-20 12:10:21 -04:00
Guido Günther
e5470dd0e0 docs: Drop unused rule for internals/%.html.tmp target
We're using the %.html.tmp for all html files now so drop the unused one
and rather make sure the needed directory exists.

This fixes build failures as described in

    https://www.redhat.com/archives/libvir-list/2015-August/msg00603.html
2015-08-20 10:19:27 +02:00
Guido Günther
a2c5d16a70 libvirt-admin: Generate symbols file
Since we're linking this into libvirtd we need some symbols to be public
but not part of the public API so mark them as
LIBVIRT_ADMIN_PRIVATE_<VERSION> as we do with libvirt.

Making all other symbols local makes sure we don't accidentally leak
unwanted ones.
2015-08-20 10:19:27 +02:00
Guido Günther
6d71d54812 daemon: Use $(NULL) for libvird_admin's flags
This makes it consistent with the other FLAGS in this file and reduced
clutter in the diff when adding new entries.
2015-08-20 10:19:27 +02:00
Roman Bogorodskiy
46550cde0f util: fix build without cgroup
Commit 89c509a0 added getters for cgroup block device I/O throttling,
however stub versions of these functions have not matching function
prototypes that result in compilation fail on platforms not supporting
cgroup.

Fix build by correcting prototypes of the stubbed functions.

Pushing under build-breaker rule.
2015-08-20 09:42:56 +03:00
Cao jin
d0fbaf16cc virconf: correct code formatting
Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2015-08-20 01:41:28 +02:00
Cao jin
4cbeb48713 virConfWalk: fix the inconsistent name
Fix inconsistency between function description and actual
parameter name.

Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
2015-08-20 01:03:42 +02:00
Martin Kletzander
c7596cf0e0 qemu: Report better error message when renaming to existing domain name
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-08-19 14:13:06 -07:00
Martin Kletzander
7b5acf9461 qemu: Sync BlkioDevice values when setting them in cgroups
The problem here is that there are some values that kernel accepts, but
does not set them, for example 18446744073709551615 which acts the same
way as zero.  Let's do the same thing we do with other tuning options
and re-read them right after they are set in order to keep our internal
structures up-to-date.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-08-18 16:27:43 -07:00
Martin Kletzander
4563c59b5b lxc: Sync BlkioDevice values when setting them in cgroups
The problem here is that there are some values that kernel accepts, but
does not set them, for example 18446744073709551615 which acts the same
way as zero.  Let's do the same thing we do with other tuning options
and re-read them right after they are set in order to keep our internal
structures up-to-date.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-08-18 16:27:43 -07:00
Martin Kletzander
89c509a0c1 util: Add getters for cgroup block device I/O throttling
Since now they were not needed, but I sense they will be in a short
while.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-08-18 16:25:16 -07:00
Martin Kletzander
ea9db906fc util: Add virCgroupGetBlockDevString
This function translates device paths to "major:minor " string, and all
virCgroupSetBlkioDevice* functions are modified to use it.  It's a
cleanup with no functional change.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-08-18 16:16:38 -07:00
Martin Kletzander
1fe69c4656 util: Add virStringGetFirstWithPrefix
That function takes string list and returns first string in that list
that starts with the @prefix parameter with that prefix being skipped as
the caller knows what it starts with (also for easier manipulation in
future).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-08-18 16:16:37 -07:00
Michal Privoznik
ed4da64657 qemuDomainRename: Don't leave a domain locked uppon fail
Well, yet again one case of 'goto cleanup' while 'goto endjob'
was needed. Sorry.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-08-18 20:42:44 +02:00
John Ferlan
32c6b1908b qemu: Add check for invalid iothread_id in qemuDomainChgIOThread
https://bugzilla.redhat.com/show_bug.cgi?id=1251886

Since iothread_id == 0 is an invalid value for QEMU let's point
that out specifically.  For the IOThreadDel code, the failure would
have ended up being a failure to find the IOThread ID; however, for
the IOThreadAdd code - an IOThread 0 was added and that isn't good.

It seems during many reviews/edits to the code the check for
iothread_id = 0 being invalid was lost - it could have originally
been in the API code, but requested to be moved - I cannot remember.
2015-08-18 14:36:21 -04:00
John Ferlan
53058e11aa api: Adjust comment for virDomainAddIOThread
The comment for the function indicated that iothread_id had to be
a positive non-zero value; however, that wasn't checked - that is
a value of 0 is/was allowed by the API and was left up to the
hypervisor to reject the value.

More than likely this nuance was missed during the many "adjustments"
to the API in the review phase.
2015-08-18 14:36:21 -04:00
John Ferlan
d64b81a8f0 api: Remove check on iothread_id arg in virDomainPinIOThread
Allow 0 as an iothread_id and force the hypervisor to handle.
The qemuDomainPinIOThread API will look up the iothread_id of
0 and not find it and message that anyway.
2015-08-18 14:36:21 -04:00
Luyao Huang
4153a74105 qemuDomainAddCgroupForThread: Don't overwrite the error
Just like in commit 704cf06, if virCgroup*() fails, the error is
already reported. There's no need to overwrite the error with a
generic one and possibly hiding the true root cause of the error.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
2015-08-18 19:53:58 +02:00
Cao jin
d5d710a199 virconf: fix the inconsistent name
Fix inconsistency between function description and actual
parameter name in virConfGetValue/virConfSetValue.

Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
2015-08-18 19:42:49 +02:00
Luyao Huang
70f56dd72c virsh: Reset global error after successfull domain lookup
When looking up a domain, we try to look up by ID, UUID and NAME
consequently while not really caring which of those lookups succeeds.
The problem is that if any of them fails, we dispatch the error from the
driver and that means setting both threadlocal and global error. Let's
say the last lookup (by NAME) succeeds and resets the threadlocal error as any
other API does, however leaving the global error unchanged. If the underlying
virsh command does not succeed afterwards, our cleanup routine in
vshCommandRun ensures that no libvirt error will be forgotten and that's
exactly where this global error comes in incorrectly.

 # virsh domif-setlink 123 vnet1 up
 error: interface (target: vnet1) not found
 error: Domain not found: no domain with matching id 123

This patch also resets the global error which would otherwise cause some
minor confusion in reported error messages.

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

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
2015-08-18 14:54:45 +02:00
Eric Blake
0a617b53d4 build: fix mingw build
Ever since commit e44b0269, 64-bit mingw compilation fails with:

../../src/util/virprocess.c: In function 'virProcessGetPids':
../../src/util/virprocess.c:628:50: error: passing argument 4 of 'virStrToLong_i' from incompatible pointer type [-Werror=incompatible-pointer-types]
         if (virStrToLong_i(ent->d_name, NULL, 10, &tmp_pid) < 0)
                                                  ^
In file included from ../../src/util/virprocess.c:59:0:
../../src/util/virstring.h:53:5: note: expected 'int *' but argument is of type 'pid_t * {aka long long int *}'
 int virStrToLong_i(char const *s,
     ^
cc1: all warnings being treated as errors

Although mingw won't be using this function, it does compile the
file, and the fix is relatively simple.

* src/util/virprocess.c (virProcessGetPids): Don't assume pid_t
fits in int.

Signed-off-by: Eric Blake <eblake@redhat.com>
2015-08-17 16:03:40 -07:00
Michal Privoznik
0ace4d985a qemuDomainRename: Explicitly check if domain is renaming to itself
It may happen that user (mistakenly) wants to rename a domain to
itself. Which is no renaming at all. We should reject that with
some meaningful error message.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-08-17 23:41:17 +02:00