Commit Graph

14778 Commits

Author SHA1 Message Date
Peter Krempa
2e23c77b00 tests: Add metadata tests
This test exercises the virDomain[Get|Set]Metadata API and tests it for
regressions
2013-09-17 09:53:30 +02:00
Peter Krempa
f616fbf2a4 test: Add <metadata> support into the test driver 2013-09-17 09:42:50 +02:00
Peter Krempa
f9c7b32e5d lxc: Add metadata modification APIs 2013-09-17 09:42:50 +02:00
Peter Krempa
3b6784d119 lib: Don't force the key argument when deleting metadata
virDomainSetMetadata when operating on the metadata element was
requesting the @key argument to be passed even if @metadata was NULL
used to delete the corresponding metadata element. This is not needed as
the key is only used when adding the element and matching is done via
the XML namespace.
2013-09-17 09:42:49 +02:00
Peter Krempa
73bfac0e71 conf: allow to add XML metadata using the virDomainSetMetadata api
The functionality wasn't originally implemented. This patch adds the
ability to modify domain's XML metadata using the API.
2013-09-17 09:42:49 +02:00
Peter Krempa
ac38bff077 conf: Add support for requesting of XML metadata via the API
The virDomainGetMetadata function was designed to support also retrieval
of app specific metadata from the <metadata> element. This functionality
was never implemented originally.
2013-09-17 09:42:49 +02:00
Peter Krempa
01b03f59e7 virsh-domain: Add command to allow modifications of XML metadata
The metadata modification functions will support modification of the XML
metadata. Add a virsh command to allow using this approach.
2013-09-17 09:42:49 +02:00
Peter Krempa
3df33d7ad5 virsh-domain: use virXMLNodeToString instead of xmlNodeDump 2013-09-17 09:42:49 +02:00
Peter Krempa
be0f0c2292 util: Add helper to convert libxml2 nodes to a string 2013-09-17 09:42:49 +02:00
Peter Krempa
e9cb66f14e conf: Factor out setting of metadata to simplify code
The code to set the metadata in a domain definition is common to live
and inactive domains. Factor it out into a common func.
2013-09-17 09:42:49 +02:00
Peter Krempa
f87a7c67de qemu: Factor out body of qemuDomainSetMetadata for universal use
The function implemented common behavior that can be reused for other
hypervisor drivers that use the virDomainObj data structures. Factor out
the core into a separate helper func.
2013-09-17 09:42:49 +02:00
Peter Krempa
99c51af2ee qemu: Factor out body of qemuDomainGetMetadata for universal use
The function implemented common behavior that can be reused for other
hypervisor drivers that use the virDomainObj data structures. Factor out
the core into a separate helper func.
2013-09-17 09:42:49 +02:00
Peter Krempa
cb356928a6 virsh-domain: Line up signal names array
Line up the array so that the grid is visible.
2013-09-17 09:42:49 +02:00
Peter Krempa
626d4dfc2e virsh-domain: Remove spurious ATTRIBUTE_UNUSED from cmdDesc
The "cmd" variable is actually used so remove the attribute.
2013-09-17 09:42:49 +02:00
Peter Krempa
1b7bfa65e3 qemu: Use "migratable" XML definition when doing external checkpoints
In the original implementation of external checkpoints I've mistakenly
used the live definition to be stored in the save image. The normal
approach is to use the "migratable" definition. This was discovered when
commit 07966f6a8b changed the behavior to
use a converted XML from the user to do the compatibility check to fix
problem when using the regular machine saving.

As the previous patch added a compatibility layer, we can now change the
type of the XML in the image.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1008340
2013-09-17 09:42:43 +02:00
Peter Krempa
59898a88ce qemu: Fix checking of ABI stability when restoring external checkpoints
External checkpoints have a bug in the implementation where they use the
normal definition instead of the "migratable" one. This causes errors
when the snapshot is being reverted using the workaround method via
qemuDomainRestoreFlags() with a custom XML. This issue was introduced
when commit 07966f6a8b changed the code to
compare "migratable" XMLs from the user as we should have used
migratable in the image too.

This patch adds a compatibility layer, so that fixing the snapshot code
won't make existing snapshots fail to load.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1008340
2013-09-17 09:42:43 +02:00
Hongwei Bi
0925ad4e28 virsh: Fix a wrong check in cmdEcho()
What should be checked here is xmlbuf rather than buf.
2013-09-17 09:15:18 +02:00
Doug Goldstein
3efbe13f4d Allow LUN type disks to have no source
CD-ROMs and Floppies are allowed to have no source to imply they are
empty or disconnected. Since the LUN type is used for raw CD-ROM access
with QEMU (and VMWare in the future), it also needs to allow an empty
source when the raw CD-ROM device is disconnected from the domain.
2013-09-16 15:21:28 -05:00
Ján Tomko
102eb00c28 Always free network and graphics cookies
qemuMigrationEatCookie has flags to control if these should
be parsed, but it does not fill mig->flags. These cookies might
get leaked if these flags are not set by qemuMigrationBakeCookie.

42 (32 direct, 10 indirect) bytes in 1 blocks are definitely lost in
loss record 361 of 662
==123== by 0x1BA33FCA: qemuMigrationEatCookie (qemu_migration.c:678)
==123== by 0x1BA34A1E: qemuMigrationRun (qemu_migration.c:3108)
==123== by 0x1BA3622B: doNativeMigrate (qemu_migration.c:3343)
==123== by 0x1BA3B408: qemuMigrationPerform (qemu_migration.c:4138)
2013-09-16 19:26:21 +02:00
Ján Tomko
09b48562aa Free slicename in virSystemdCreateMachine
https://bugzilla.redhat.com/show_bug.cgi?id=1008619

1,003 bytes in 1 blocks are definitely lost in loss record 599 of 635
==404== by 0x50728A7: virBufferAddChar (virbuffer.c:185)
==404== by 0x50BC466: virSystemdEscapeName (virsystemd.c:67)
==404== by 0x50BC6B2: virSystemdMakeSliceName (virsystemd.c:108)
==404== by 0x50BC870: virSystemdCreateMachine (virsystemd.c:169)
==404== by 0x5078267: virCgroupNewMachine (vircgroup.c:1498)
2013-09-16 19:26:21 +02:00
Eric Blake
6ccf92abfe build: make autobuild require rpm build deps
I spent far too long on a new machine trying to figure out why
./autobuild.sh failed due to an rpm build failure (complaining
that libvirt_parthelper was supposed to be packaged but was not
built), and finally traced it to a missing parted-devel
installation.  I learned that --nodeps is in place for
autobuilder setups, but for developers, removing it would make
rpmbuild error out much sooner for a less cryptic failure.

* autobuild.sh: Conditionally drop --nodeps from rpmbuild lines.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-09-16 09:35:05 -06:00
Eric Blake
e62e0094dc build: fix build with latest rawhide kernel headers
Bother those kernel developers.  In the latest rawhide, kernel
and glibc have now been unified so that <netinet/in.h> and
<linux/in6.h> no longer clash; but <linux/if_bridge.h> is still
not self-contained.  Because of the latest header change, the
build is failing with:

checking for linux/param.h... no
configure: error: You must install kernel-headers in order to compile libvirt with QEMU or LXC support

with details:

In file included from conftest.c:561:0:
/usr/include/linux/in6.h:71:18: error: field 'flr_dst' has incomplete type
  struct in6_addr flr_dst;

We need a workaround to avoid our workaround :)

* configure.ac (NETINET_LINUX_WORKAROUND): New test.
* src/util/virnetdevbridge.c (includes): Use it.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-09-16 09:24:12 -06:00
Peter Krempa
d79fe8b50b cgroup: Move [qemu|lxc]GetCpuBWStatus to vicgroup.c and refactor it
The function existed in two identical instances in lxc and qemu. Move it
to vircgroup.c and simplify it. Refactor the callers too.
2013-09-16 11:32:49 +02:00
Peter Krempa
4baa8d7637 cleanup: Kill usage of access(PATH, F_OK) in favor of virFileExists()
Semantics of the libvirt helper are more clear. This change also allows
to clean up some pieces of code.
2013-09-16 10:37:39 +02:00
Peter Krempa
d66e7ce616 util: Declare that virFileExists shall honor errno
Explicitly state that some parts of the code may require virFileExists
to set or preserve a correct errno so that future modifications don't
break.
2013-09-16 08:57:26 +02:00
yangdongsheng
6c038ee330 virsh: move command maxvcpus from domain group to host group.
Since the maxvcpus command query the maximum number of virtual
CPUs supported for a guest VM on this connection, it should be
in virsh-host.c but not virsh-domain.c.

Signed-off-by: yangdongsheng <yangds.fnst@cn.fujitsu.com>
2013-09-15 22:39:41 -05:00
Guido Günther
42c6a0cdf9 Explicitly link libvirt_net_rpc against SELINUX_LIBS
Since virnetsocket conditionally uses selinux we need to link against it
otherwise the build fails with:

CCLD     libvirtd
/usr/bin/ld: ../src/.libs/libvirt-lxc.so: undefined reference to symbol 'freecon'
/lib/i386-linux-gnu/libselinux.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[3]: *** [libvirtd] Error 1
2013-09-14 10:31:23 +02:00
Eric Blake
5c7f820d19 docs: mention hostname subtlety
An off-list bug report mentioned some confusion where the public
documentation of libvirt.c:virConnectGetHostname did not match
the private documentation of util/virutil.c:virGetHostname.

* src/libvirt.c (virConnectGetHostname): Tweak docs.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-09-13 07:59:34 -06:00
Alex Jia
4583ccbcf7 tools: add missing 'interface' type and update man page
Signed-off-by: Alex Jia <ajia@redhat.com>
2013-09-13 14:57:52 +02:00
Martin Kletzander
a1db95d0fe tests: Don't test user config file if ran as root 2013-09-13 10:25:56 +02:00
Martin Kletzander
38716772d0 test-lib: Make case skipping possible 2013-09-13 10:25:56 +02:00
Daniel P. Berrange
935e7d02cf Fix naming of permission for detecting storage pools
The VIR_ACCESS_PERM_CONNECT_DETECT_STORAGE_POOLS enum
constant had its string format be 'detect_storage_pool',
note the missing trailing 's'. This prevent the ACL
check from ever succeeding. Fix this and add a simple
test script to validate this problem of matching names.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-12 17:20:07 +01:00
Gao feng
1c7037cff4 LXC: don't try to mount selinux filesystem when user namespace enabled
Right now we mount selinuxfs even user namespace is enabled and
ignore the error. But we shouldn't ignore these errors when user
namespace is not enabled.

This patch skips mounting selinuxfs when user namespace enabled.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
2013-09-12 15:18:01 +01:00
Peter Krempa
53c39f5837 qemu: Fix checking of guest ABI compatibility when reverting snapshots
When reverting a live internal snapshot with a live guest the ABI
compatiblity check was comparing a "migratable" definition with a normal
one. This resulted in the check failing with:

revert requires force: Target device address type none does not match source pci

This patch generates a "migratable" definition from the actual one to
check against the definition from the snapshot to avoid this problem.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1006886
2013-09-12 15:11:38 +02:00
Laine Stump
822fe1367d netcf driver: use a single netcf handle for all connections
This resolves: https://bugzilla.redhat.com/show_bug.cgi?id=983026

The netcf interface driver previously had no state driver associated
with it - as a connection was opened, it would create a new netcf
instance just for that connection, and close it when it was
finished. the problem with this is that each connection to libvirt
used up a netlink socket, and there is a per process maximum of ~1000
netlink sockets.

The solution is to create a state driver to go along with the netcf
driver. The state driver will opens a netcf instance, then all
connections share that same netcf instance, thus only a single
netlink socket will be used no matter how many connections are mde to
libvirtd.

This was rather simple to do - a new virObjectLockable class is
created for the single driverState object, which is created in
netcfStateInitialize and contains the single netcf handle; instead of
creating a new object for each client connection, netcfInterfaceOpen
now just increments the driverState object's reference count and puts
a pointer to it into the connection's privateData. Similarly,
netcfInterfaceClose() just un-refs the driverState object (as does
netcfStateCleanup()), and virNetcfInterfaceDriverStateDispose()
handles closing the netcf instance. Since all the functions already
have locking around them, the static lock functions used by all
functions just needed to be changed to call virObjectLock() and
virObjectUnlock() instead of directly calling the virMutex* functions.
2013-09-12 07:33:24 -04:00
Laine Stump
4c5fa43097 rename "struct interface_driver" to virNetcfDriverState
This better fits the modern naming scheme in libvirt, and anticipates
an upcoming change where a single instance of this state will be
maintained by a separate state driver, and every instance of the netcf
driver will share the same state.
2013-09-12 07:33:19 -04:00
Daniel P. Berrange
75235a52bc Ensure root filesystem is recursively mounted readonly
If the guest is configured with

    <filesystem type='mount'>
      <source dir='/'/>
      <target dir='/'/>
      <readonly/>
    </filesystem>

Then any submounts under / should also end up readonly, except
for those setup as basic mounts. eg if the user has /home on a
separate volume, they'd expect /home to be readonly, but we
should not touch the /sys, /proc, etc dirs we setup ourselves.

Users can selectively make sub-mounts read-write again by
simply listing them as new mounts without the <readonly>
flag set

    <filesystem type='mount'>
      <source dir='/home'/>
      <target dir='/home'/>
    </filesystem>

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-12 12:01:49 +01:00
Daniel P. Berrange
f27f5f7edd Move array of mounts out of lxcContainerMountBasicFS
Move the array of basic mounts out of the lxcContainerMountBasicFS
function, to a global variable. This is to allow it to be referenced
by other methods wanting to know what the basic mount paths are.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-12 11:52:12 +01:00
Daniel P. Berrange
5e6a85c765 Add some notes about security considerations when using LXC
Describe some of the issues to be aware of when configuring LXC
guests with security isolation as a goal.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-12 11:48:29 +01:00
Daniel P. Berrange
a48838ad2e Fix launching of VMs on when only logind part of systemd is present
Debian systems may run the 'systemd-logind' daemon, which causes the
/sys/fs/cgroup/systemd  mount to be setup, but no other cgroup
controllers are created. While the LXC driver considers cgroups to
be mandatory, the QEMU driver is supposed to accept them as optional.

We detect whether they are present by looking in /proc/mounts for
any mounts of type 'cgroups', but this is not sufficient. We need to
skip any named mounts (as seen by a name=XXX string in the mount
options), so that we only detect actual resource controllers.

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=721979

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-12 11:32:36 +01:00
Daniel P. Berrange
621849383a Fix polkit permission names for storage pools, vols & node devices
The polkit access driver used the wrong permission names for checks
on storage pools, volumes and node devices. This led to them always
being denied access.

The 'dettach' permission was also mis-spelt and should have been
'detach'. While permission names are ABI sensitive, the fact that
the code used the wrong object name for checking node device
permissions, means that no one could have used the mis-spelt
'dettach' permission.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-12 11:15:52 +01:00
Jiri Denemark
f084caae7c virsh domjobinfo: Do not return 1 if job is NONE
https://bugzilla.redhat.com/show_bug.cgi?id=1006864

Commit 38ab1225 changed the default value of ret from true to false but
forgot to set ret = true when job is NONE. Thus, virsh domjobinfo
returned 1 when there was no job running for a domain but it used to
(and should) return 0 in this case.
2013-09-12 11:31:49 +02:00
Daniel Veillard
a41e95db50 Repair the search on libvirt.org
First make sure that the input is xhtml as the stylesheets expect
namespaced element, then use a span element instead of a as a
is treated specially, finally adjust the makefile to check for
the new span element and replace it with the PHP code
2013-09-12 17:18:32 +08:00
Michal Novotny
25b133e771 api-docs: Fix description of virConnectGetType() API function
This fixes the description of virConnectGetType() API function in
API documentation to match the real functionality that it can be
used to get driver name, and provide a hint on how to learn about
full capabilities.

Signed-off-by: Michal Novotny <minovotn@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
2013-09-11 20:12:59 -06:00
Eric Blake
cf83adfb7d build: require libnl-3 if netcf uses it
Commits 9298bfb and f6c2951 both tried to make it possible to
select the correct libnl (1 vs. 3) according to what netcf
used, when both libraries are installed.  This works to avoid
libnl-3 when netcf used libnl-1.  But on the converse side, if
only libnl-1 development code is installed, while netcf uses
libnl-3, then configure happily uses libnl-1 anyways, leading
to a test failure:

$ VIR_TEST_DEBUG=1 ./virdrivermoduletest
TEST: virdrivermoduletest
 1) Test driver "network"                                             ... OK
 2) Test driver "storage"                                             ... OK
 3) Test driver "nodedev"                                             ... OK
 4) Test driver "secret"                                              ... OK
 5) Test driver "nwfilter"                                            ... OK
 6) Test driver "interface"
... lt-virdrivermoduletest: route/tc.c:973: rtnl_tc_register: Assertion
`0' failed.
Aborted

It's much nicer to prevent this at configure time, by requiring that
if we know what netcf used, then we want the same libnl version.  As
before, this can be bypassed by someone who knows what they are doing
by setting LIBNL_CFLAGS (perhaps useful to the rare person where the
build box has a different version of netcf than the installation box).

* configure.ac (LIBNL): If we can prove netcf used libnl-3, then
don't let configure succeed with libnl-1.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-09-11 14:10:33 -06:00
Daniel P. Berrange
468f684e84 Fix virsystemdtest for previous commit
The change to query org.freedesktop.DBus.ListActivatableNames
to detect systemd broke the test suite, since we did not have
stubs to respond to this dbus call.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-11 15:31:28 +01:00
Gao feng
7ada155cdf DBus: introduce virDBusIsServiceEnabled
This patch introduces virDBusIsServiceEnabled, we can use
this method to get if the service is supported.

In one case, if org.freedesktop.machine1 is unavailable on
host, we should skip creating machine through systemd.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
2013-09-11 13:45:25 +01:00
Gao feng
66e2adb2ba LXC: introduce lxcContainerUnmountForSharedRoot
Move the unmounting private or useless filesystems for
container to this function.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
2013-09-11 13:09:31 +01:00
Gao feng
4142bf46b8 LXC: umount the temporary filesystem created by libvirt
The devpts, dev and fuse filesystems are mounted temporarily.
there is no need to export them to container if container shares
the root directory with host.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
2013-09-11 13:09:31 +01:00
Ján Tomko
fd72440a35 Add test for the nodemask double free crash
Commit ef5d51d fixed a crash for numatune with auto placement and
nodeset specified:
<numatune>
    <memory mode='preferred' placement='auto' nodeset='0'/>
</numatune>
2013-09-11 13:40:50 +02:00