]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
11 years agolxc: Add metadata modification APIs
Peter Krempa [Fri, 6 Sep 2013 15:42:38 +0000 (17:42 +0200)]
lxc: Add metadata modification APIs

11 years agolib: Don't force the key argument when deleting metadata
Peter Krempa [Tue, 10 Sep 2013 09:25:55 +0000 (11:25 +0200)]
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.

11 years agoconf: allow to add XML metadata using the virDomainSetMetadata api
Peter Krempa [Mon, 9 Sep 2013 09:49:11 +0000 (11:49 +0200)]
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.

11 years agoconf: Add support for requesting of XML metadata via the API
Peter Krempa [Fri, 6 Sep 2013 15:34:43 +0000 (17:34 +0200)]
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.

11 years agovirsh-domain: Add command to allow modifications of XML metadata
Peter Krempa [Mon, 9 Sep 2013 08:54:04 +0000 (10:54 +0200)]
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.

11 years agovirsh-domain: use virXMLNodeToString instead of xmlNodeDump
Peter Krempa [Wed, 4 Sep 2013 15:27:27 +0000 (17:27 +0200)]
virsh-domain: use virXMLNodeToString instead of xmlNodeDump

11 years agoutil: Add helper to convert libxml2 nodes to a string
Peter Krempa [Wed, 4 Sep 2013 14:49:40 +0000 (16:49 +0200)]
util: Add helper to convert libxml2 nodes to a string

11 years agoconf: Factor out setting of metadata to simplify code
Peter Krempa [Fri, 6 Sep 2013 14:38:55 +0000 (16:38 +0200)]
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.

11 years agoqemu: Factor out body of qemuDomainSetMetadata for universal use
Peter Krempa [Tue, 11 Jun 2013 13:45:05 +0000 (15:45 +0200)]
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.

11 years agoqemu: Factor out body of qemuDomainGetMetadata for universal use
Peter Krempa [Tue, 11 Jun 2013 13:45:05 +0000 (15:45 +0200)]
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.

11 years agovirsh-domain: Line up signal names array
Peter Krempa [Mon, 9 Sep 2013 09:47:20 +0000 (11:47 +0200)]
virsh-domain: Line up signal names array

Line up the array so that the grid is visible.

11 years agovirsh-domain: Remove spurious ATTRIBUTE_UNUSED from cmdDesc
Peter Krempa [Mon, 9 Sep 2013 08:52:08 +0000 (10:52 +0200)]
virsh-domain: Remove spurious ATTRIBUTE_UNUSED from cmdDesc

The "cmd" variable is actually used so remove the attribute.

11 years agoqemu: Use "migratable" XML definition when doing external checkpoints
Peter Krempa [Mon, 16 Sep 2013 11:40:42 +0000 (13:40 +0200)]
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 07966f6a8b5ccb5bb4c716b25deb8ba2e572cc67 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

11 years agoqemu: Fix checking of ABI stability when restoring external checkpoints
Peter Krempa [Mon, 16 Sep 2013 11:37:34 +0000 (13:37 +0200)]
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 07966f6a8b5ccb5bb4c716b25deb8ba2e572cc67 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

11 years agovirsh: Fix a wrong check in cmdEcho()
Hongwei Bi [Tue, 17 Sep 2013 06:21:32 +0000 (14:21 +0800)]
virsh: Fix a wrong check in cmdEcho()

What should be checked here is xmlbuf rather than buf.

11 years agoAllow LUN type disks to have no source
Doug Goldstein [Sun, 8 Sep 2013 18:58:06 +0000 (13:58 -0500)]
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.

11 years agoAlways free network and graphics cookies
Ján Tomko [Mon, 16 Sep 2013 11:26:46 +0000 (13:26 +0200)]
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)

11 years agoFree slicename in virSystemdCreateMachine
Ján Tomko [Mon, 16 Sep 2013 13:27:42 +0000 (15:27 +0200)]
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)

11 years agobuild: make autobuild require rpm build deps
Eric Blake [Sat, 14 Sep 2013 11:29:42 +0000 (05:29 -0600)]
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>
11 years agobuild: fix build with latest rawhide kernel headers
Eric Blake [Fri, 13 Sep 2013 16:11:26 +0000 (10:11 -0600)]
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>
11 years agocgroup: Move [qemu|lxc]GetCpuBWStatus to vicgroup.c and refactor it
Peter Krempa [Fri, 13 Sep 2013 14:03:14 +0000 (16:03 +0200)]
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.

11 years agocleanup: Kill usage of access(PATH, F_OK) in favor of virFileExists()
Peter Krempa [Fri, 13 Sep 2013 13:32:43 +0000 (15:32 +0200)]
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.

11 years agoutil: Declare that virFileExists shall honor errno
Peter Krempa [Fri, 13 Sep 2013 12:35:34 +0000 (14:35 +0200)]
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.

11 years agovirsh: move command maxvcpus from domain group to host group.
yangdongsheng [Mon, 9 Sep 2013 02:14:22 +0000 (10:14 +0800)]
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>
11 years agoExplicitly link libvirt_net_rpc against SELINUX_LIBS
Guido Günther [Fri, 13 Sep 2013 15:42:58 +0000 (17:42 +0200)]
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

11 years agodocs: mention hostname subtlety
Eric Blake [Thu, 12 Sep 2013 19:19:23 +0000 (13:19 -0600)]
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>
11 years agotools: add missing 'interface' type and update man page
Alex Jia [Wed, 11 Sep 2013 03:47:14 +0000 (11:47 +0800)]
tools: add missing 'interface' type and update man page

Signed-off-by: Alex Jia <ajia@redhat.com>
11 years agotests: Don't test user config file if ran as root
Martin Kletzander [Thu, 12 Sep 2013 10:15:23 +0000 (12:15 +0200)]
tests: Don't test user config file if ran as root

11 years agotest-lib: Make case skipping possible
Martin Kletzander [Thu, 12 Sep 2013 10:12:23 +0000 (12:12 +0200)]
test-lib: Make case skipping possible

11 years agoFix naming of permission for detecting storage pools
Daniel P. Berrange [Thu, 12 Sep 2013 13:35:45 +0000 (14:35 +0100)]
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>
11 years agoLXC: don't try to mount selinux filesystem when user namespace enabled
Gao feng [Thu, 12 Sep 2013 03:51:31 +0000 (11:51 +0800)]
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>
11 years agoqemu: Fix checking of guest ABI compatibility when reverting snapshots
Peter Krempa [Thu, 12 Sep 2013 09:37:57 +0000 (11:37 +0200)]
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

11 years agonetcf driver: use a single netcf handle for all connections
Laine Stump [Wed, 28 Aug 2013 16:56:21 +0000 (12:56 -0400)]
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.

11 years agorename "struct interface_driver" to virNetcfDriverState
Laine Stump [Tue, 27 Aug 2013 16:26:48 +0000 (12:26 -0400)]
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.

11 years agoEnsure root filesystem is recursively mounted readonly
Daniel P. Berrange [Mon, 9 Sep 2013 15:17:19 +0000 (16:17 +0100)]
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>
11 years agoMove array of mounts out of lxcContainerMountBasicFS
Daniel P. Berrange [Tue, 10 Sep 2013 12:35:12 +0000 (13:35 +0100)]
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>
11 years agoAdd some notes about security considerations when using LXC
Daniel P. Berrange [Tue, 10 Sep 2013 09:58:45 +0000 (10:58 +0100)]
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>
11 years agoFix launching of VMs on when only logind part of systemd is present
Daniel P. Berrange [Wed, 11 Sep 2013 18:15:52 +0000 (19:15 +0100)]
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>
11 years agoFix polkit permission names for storage pools, vols & node devices
Daniel P. Berrange [Wed, 11 Sep 2013 13:23:24 +0000 (14:23 +0100)]
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>
11 years agovirsh domjobinfo: Do not return 1 if job is NONE
Jiri Denemark [Wed, 11 Sep 2013 13:49:48 +0000 (15:49 +0200)]
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.

11 years agoRepair the search on libvirt.org
Daniel Veillard [Thu, 12 Sep 2013 09:18:32 +0000 (17:18 +0800)]
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

11 years agoapi-docs: Fix description of virConnectGetType() API function
Michal Novotny [Wed, 11 Sep 2013 12:19:19 +0000 (14:19 +0200)]
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>
11 years agobuild: require libnl-3 if netcf uses it
Eric Blake [Wed, 4 Sep 2013 21:12:48 +0000 (15:12 -0600)]
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>
11 years agoFix virsystemdtest for previous commit
Daniel P. Berrange [Wed, 11 Sep 2013 14:29:52 +0000 (15:29 +0100)]
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>
11 years agoDBus: introduce virDBusIsServiceEnabled
Gao feng [Wed, 11 Sep 2013 03:15:02 +0000 (11:15 +0800)]
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>
11 years agoLXC: introduce lxcContainerUnmountForSharedRoot
Gao feng [Wed, 11 Sep 2013 08:07:54 +0000 (16:07 +0800)]
LXC: introduce lxcContainerUnmountForSharedRoot

Move the unmounting private or useless filesystems for
container to this function.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
11 years agoLXC: umount the temporary filesystem created by libvirt
Gao feng [Wed, 11 Sep 2013 08:07:53 +0000 (16:07 +0800)]
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>
11 years agoAdd test for the nodemask double free crash
Ján Tomko [Wed, 11 Sep 2013 08:49:39 +0000 (10:49 +0200)]
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>

11 years agoUpdate docs about user namespace for LXC
Daniel P. Berrange [Tue, 10 Sep 2013 09:00:15 +0000 (10:00 +0100)]
Update docs about user namespace for LXC

Mention that user namespace can be enabled using the UID/GID
mapping schema.

Fix typo in link anchor for container args in domain XML docs.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix cgroups when all are mounted on /sys/fs/cgroup
Daniel P. Berrange [Tue, 10 Sep 2013 13:31:53 +0000 (14:31 +0100)]
Fix cgroups when all are mounted on /sys/fs/cgroup

Some users in Ubuntu/Debian seem to have a setup where all the
cgroup controllers are mounted on /sys/fs/cgroup rather than
any /sys/fs/cgroup/<controller> name. In the loop which detects
which controllers are present for a mount point we were modifying
'mnt_dir' field in the 'struct mntent' var, but not always restoring
the original value. This caused detection to break in the all-in-one
mount setup.

Fix that logic bug and add test case coverage for this mount
setup.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agovirDomainDefParseXML: set the argument of virBitmapFree to NULL after calling virBitm...
Liuji (Jeremy) [Wed, 11 Sep 2013 02:13:32 +0000 (22:13 -0400)]
virDomainDefParseXML: set the argument of virBitmapFree to NULL after calling virBitmapFree

After freeing the bitmap pointer, it must set the pointer to NULL.
This will avoid any other use of the freed memory of the bitmap pointer.

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

Signed-off-by: Liuji (Jeremy) <jeremy.liu@huawei.com>
11 years agodocs, comments: minor typo fixes
Oskari Saarenmaa [Tue, 10 Sep 2013 18:10:55 +0000 (21:10 +0300)]
docs, comments: minor typo fixes

Signed-off-by: Oskari Saarenmaa <os@ohmu.fi>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: fix regression in requiring yajl for new enough qemu
Eric Blake [Thu, 5 Sep 2013 20:32:25 +0000 (14:32 -0600)]
build: fix regression in requiring yajl for new enough qemu

Jonathan Lebon reported an issue to me off-list about his build
failing to use qemu because he failed to install yajl-devel.  But
I recalled specifically tweaking configure.ac to die in that
situation (commits 350583cba9c38b).  After a bit more
head-scratching, we found the cause of the regression: commit
654c709 rearranged things so that the qemu version check now
occurs before AC_ARG_WITH has had a chance to set either
$with_qemu or $with_yajl.

Coincidentally, this fix aligns with a documentation patch that
was just posted to the autoconf mailing list :)
http://thread.gmane.org/gmane.comp.sysutils.autoconf.patches/8324

* m4/virt-lib.m4 (LIBVIRT_CHECK_LIB, LIBVIRT_CHECK_LIB_ALT)
(LIBVIRT_CHECK_PKG): Populate defaults earlier.
* configure.ac (AC_ARG_WITH): Likewise for drivers.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: avoid obsolete AC_HELP_STRING
Eric Blake [Thu, 5 Sep 2013 21:24:55 +0000 (15:24 -0600)]
build: avoid obsolete AC_HELP_STRING

Autoconf states that AC_HELP_STRING is obsolete, and that new
programs should use AS_HELP_STRING.  We also had instances of
not properly quoting the macro usage, and not relying on autoconf's
word-wrapping abilities to avoid long lines.  I validated that this
commit has no impact to the generated configure file.

* configure.ac (AC_ARG_WITH, AC_ARG_ENABLE): Autoconf recommends
the use of AS_HELP_STRING.  Also, use proper quoting and wrap long
lines.
* m4/virt-apparmor.m4 (LIBVIRT_CHECK_APPARMOR): Likewise.
* m4/virt-selinux.m4 (LIBVIRT_CHECK_SELINUX): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoqemu: endjob returns a bool
Eric Blake [Mon, 9 Sep 2013 19:07:29 +0000 (13:07 -0600)]
qemu: endjob returns a bool

Osier Yang pointed out that ever since commit 31cb030, the
signature of qemuDomainObjEndJob was changed to return a bool.
While comparison against 0 or > 0 still gives the right results,
it looks fishy; we also had one place that was comparing < 0
which is effectively dead code.

* src/qemu/qemu_migration.c (qemuMigrationPrepareAny): Fix dead
code bug.
(qemuMigrationBegin): Use more canonical form of bool check.
* src/qemu/qemu_driver.c (qemuAutostartDomain)
(qemuDomainCreateXML, qemuDomainSuspend, qemuDomainResume)
(qemuDomainShutdownFlags, qemuDomainReboot, qemuDomainReset)
(qemuDomainDestroyFlags, qemuDomainSetMemoryFlags)
(qemuDomainSetMemoryStatsPeriod, qemuDomainInjectNMI)
(qemuDomainSendKey, qemuDomainGetInfo, qemuDomainScreenshot)
(qemuDomainSetVcpusFlags, qemuDomainGetVcpusFlags)
(qemuDomainRestoreFlags, qemuDomainGetXMLDesc)
(qemuDomainCreateWithFlags, qemuDomainAttachDeviceFlags)
(qemuDomainUpdateDeviceFlags, qemuDomainDetachDeviceFlags)
(qemuDomainBlockResize, qemuDomainBlockStats)
(qemuDomainBlockStatsFlags, qemuDomainMemoryStats)
(qemuDomainMemoryPeek, qemuDomainGetBlockInfo)
(qemuDomainAbortJob, qemuDomainMigrateSetMaxDowntime)
(qemuDomainMigrateGetCompressionCache)
(qemuDomainMigrateSetCompressionCache)
(qemuDomainMigrateSetMaxSpeed)
(qemuDomainSnapshotCreateActiveInternal)
(qemuDomainRevertToSnapshot, qemuDomainSnapshotDelete)
(qemuDomainQemuMonitorCommand, qemuDomainQemuAttach)
(qemuDomainBlockJobImpl, qemuDomainBlockCopy)
(qemuDomainBlockCommit, qemuDomainOpenGraphics)
(qemuDomainGetBlockIoTune, qemuDomainGetDiskErrors)
(qemuDomainPMSuspendForDuration, qemuDomainPMWakeup)
(qemuDomainQemuAgentCommand, qemuDomainFSTrim): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: use automake subdir-objects
Eric Blake [Sat, 7 Sep 2013 22:18:06 +0000 (16:18 -0600)]
build: use automake subdir-objects

Automake 2.0 will enable subdir-objects by default; in preparation
for that change, automake 1.14 outputs LOADS of warnings:

daemon/Makefile.am:38: warning: source file '../src/remote/remote_protocol.c' is in a subdirectory,
daemon/Makefile.am:38: but option 'subdir-objects' is disabled
automake-1.14: warning: possible forward-incompatibility.
automake-1.14: At least a source file is in a subdirectory, but the 'subdir-objects'
automake-1.14: automake option hasn't been enabled.  For now, the corresponding output
automake-1.14: object file(s) will be placed in the top-level directory.  However,
automake-1.14: this behaviour will change in future Automake versions: they will
automake-1.14: unconditionally cause object files to be placed in the same subdirectory
automake-1.14: of the corresponding sources.
automake-1.14: You are advised to start using 'subdir-objects' option throughout your
automake-1.14: project, to avoid future incompatibilities.
daemon/Makefile.am:38: warning: source file '../src/remote/lxc_protocol.c' is in a subdirectory,
daemon/Makefile.am:38: but option 'subdir-objects' is disabled
...

As automake 1.9 also supported this option, and the previous patches
fixed up the code base to work with it, it is safe to now turn it on
unconditionally.

* configure.ac (AM_INIT_AUTOMAKE): Enable subdir-objects.
* .gitignore: Ignore .dirstamp directories.
* src/Makefile.am (PDWTAGS, *-protocol-struct): Adjust to
new subdir-object location of .lo files.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agotests: check remaining .x files
Eric Blake [Sat, 7 Sep 2013 21:22:18 +0000 (15:22 -0600)]
tests: check remaining .x files

We have been adding new .x files without keeping the list of
*-structs files up-to-date.  This adds the support for the
recent additions.

In the process of testing this, I also noticed that Fedora 19's
use of dwarves-1.10 (providing pdwtags version 1.9) was producing
a single line on stderr but still giving enough useful info on
stdout that we could check structs; the real goal of checking
stderr separately from stdout was to avoid the bug in dwarves-1.9
where stdout was empty (see bug http://bugzilla.redhat.com/772358).

* src/Makefile.am (struct_prefix, PROTOCOL_STRUCTS): Add missing
struct tests.
(PDWTAGS): Work with Fedora 19 pdwtags.
(lxc_monitor_protocol-struct, lock_protocol-struct): New rules.
* src/lxc_monitor_protocol-structs: New file.
* src/lock_protocol-structs): Likewise.
* cfg.mk (generated_files): Enlarge list.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: use library rather than cross-directory compilation
Eric Blake [Sun, 8 Sep 2013 02:49:17 +0000 (20:49 -0600)]
build: use library rather than cross-directory compilation

If we use subdir-objects with automake, any reference to a
cross-directory .c file will result in automake creating
rules that track dependency in the cross directory.  But this
presents a problem during 'make distclean' - if the cross
directory is cleaned up first, then the daemon directory will
be left with dangling references to .Po dependency files that
no longer exist.

Meanwhile, referring to the cross-directory .c file means
that we are compiling the file twice - once in src, and once
in daemon.  Better is to compile just once in src into a
convenience library, and then use that library from daemon.

The tests directory had a similar situation of a cross-directory
.c file; to solve that, we actually need a convenience library.

* daemon/Makefile.am (DAEMON_SOURCES): Drop .c files...
(libvirtd_LDADD): ...and instead use library.
(libvirtd_conf_la_SOURCES): Declare a new convenience library.
(libvirtd_LDFLAGS): Drop duplicate flag.
* tests/Makefile.am (libvirtdconftest_SOURCES): Drop .c file...
(libvirtdconftest_LDADD): ..and instead use library.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: avoid $(srcdir) in *_SOURCES
Eric Blake [Fri, 6 Sep 2013 22:54:39 +0000 (16:54 -0600)]
build: avoid $(srcdir) in *_SOURCES

Trying to enable automake's subdir-objects option resulted in
the creation of literal directories such as src/$(srcdir)/remote/.
I traced this to the fact that we had used a literal $(srcdir)
in a location that later fed an automake *_SOURCES variable.
This has also been reported as an automake bug:
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13928
but it's better to fix our code than to wait for an automake fix.

Some things to remember that affect VPATH builds, and where an
in-tree build is blissfully unaware of the issues: if a VPATH
build fails to find a file that was used as a prereq of any
other target, then the rule for that file will expand $@ to
prefer the current build dir (bad because a VPATH build on a
fresh checkout will then stick $@ in the current directory
instead of the desired srcdir); conversely, if a VPATH build
finds the file in srcdir but decides it needs to be rebuilt,
then the rule for that file will expand $@ to include the
directory where it was found out-of-date (bad for an explicit
listing of $(srcdir)/$@ because an incremental VPATH build will
then expand srcdir twice).  As we want these files to go into
srcdir unconditionally, we have to massage or avoid $@ for any
recipe that involves one of these files.

Therefore, this patch removes all uses of $(srcdir) from any
generated file name that later feeds a *_SOURCES variable, and
then rewrites all the recipes to generate those files to
hard-code their creation into srcdir without the use of $@.

* src/Makefile.am (REMOTE_DRIVER_GENERATED): Drop $(srcdir); VPATH
builds know how to find the files, and automake subdir-objects
fails with it in place.
(LXC_MONITOR_PROTOCOL_GENERATED, (LXC_MONITOR_GENERATED)
(ACCESS_DRIVER_GENERATED, LOCK_PROTOCOL_GENERATED): Likewise.
(*_client_bodies.h): Hard-code rules to write into srcdir, as
VPATH tries to build $@ locally if missing.
(util/virkeymaps.h): Likewise.
(lxc/lxc_monitor_dispatch.h): Likewise.
(access/viraccessapi*): Likewise.
(locking/lock_daemon_dispatch_stubs.h): Likewise.
* daemon/Makeflie.am (DAEMON_GENERATED, remote_dispatch.h):
Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
fixup DAEMON_GENERATED

11 years agocpu: Cleanup ppcCompute to avoid memory leak
Li Zhang [Mon, 9 Sep 2013 05:56:33 +0000 (13:56 +0800)]
cpu: Cleanup ppcCompute to avoid memory leak

This patch is to Cleanup ppcCompute to avoid memory leak to make
the code better.

Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com>
11 years agoqemu: don't leak vm on failure
Eric Blake [Wed, 28 Aug 2013 20:27:44 +0000 (14:27 -0600)]
qemu: don't leak vm on failure

Failure to attach to a domain during 'virsh qemu-attach' left
the list of domains in an odd state:

$ virsh qemu-attach 4176
error: An error occurred, but the cause is unknown

$ virsh list --all
 Id    Name                           State
----------------------------------------------------
 2     foo                            shut off

$ virsh qemu-attach 4176
error: Requested operation is not valid: domain is already active as 'foo'

$ virsh undefine foo
error: Failed to undefine domain foo
error: Requested operation is not valid: cannot undefine transient domain

$ virsh shutdown foo
error: Failed to shutdown domain foo
error: invalid argument: monitor must not be NULL

It all stems from leaving the list of domains unmodified on
the initial failure; we should follow the lead of createXML
which removes vm on failure (the actual initial failure still
needs to be fixed in a later patch, but at least this patch
gets us to the point where we aren't getting stuck with an
unremovable "shut off" transient domain).

While investigating, I also found a leak in qemuDomainCreateXML;
the two functions should behave similarly.  Note that there are
still two unusual paths: if dom is not allocated, the user will
see an OOM error even though the vm remains registered (but oom
errors already indicate tricky cleanup); and if the vm starts
and then quits again all before the job ends, it is possible
to return a non-NULL dom even though the dom will no longer be
useful for anything (but this at least lets the user know their
short-lived vm ran).

* src/qemu/qemu_driver.c (qemuDomainCreateXML): Don't leak vm on
failure to obtain job.
(qemuDomainQemuAttach): Match cleanup of qemuDomainCreateXML.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoAdd ARM v7 big-endian architecture (armv7b)
Yogesh Tillu [Mon, 9 Sep 2013 09:37:06 +0000 (10:37 +0100)]
Add ARM v7 big-endian architecture (armv7b)

ARM v7 can operate in either little or big endian modes. Add
support for the big-endian version known as armv7b from uname.

Signed-off-by: Yogesh Tillu <tillu.yogesh@gmail.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoqemu: avoid users specifying CPU features for non-x86 plaftorm.
Li Zhang [Fri, 6 Sep 2013 11:15:25 +0000 (12:15 +0100)]
qemu: avoid users specifying CPU features for non-x86 plaftorm.

Currently, only X86 provides users CPU features with CPUID instruction.
If users specify the features for non-x86, it should tell users to
remove them.

This patch is to report one error if features are specified by
users for non-x86 platform.

Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com>
11 years agoLXC: Free variable vroot in lxcDomainDetachDeviceHostdevUSBLive()
Hongwei Bi [Mon, 9 Sep 2013 06:05:20 +0000 (14:05 +0800)]
LXC: Free variable vroot in lxcDomainDetachDeviceHostdevUSBLive()

The variable vroot should be freed in label cleanup.

11 years agoqemu: don't leave shutdown inhibited on attach failure
Eric Blake [Wed, 28 Aug 2013 22:22:46 +0000 (16:22 -0600)]
qemu: don't leave shutdown inhibited on attach failure

While debugging a failure of 'virsh qemu-attach', I noticed that
we were leaking the count of active domains on failure.  This
means that a libvirtd session that is supposed to quit after
active domains disappear will hang around forever.

* src/qemu/qemu_process.c (qemuProcessAttach): Undo count of
active domains on failure.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoqemu: recognize -machine accel=kvm when parsing native
Eric Blake [Wed, 28 Aug 2013 03:45:46 +0000 (21:45 -0600)]
qemu: recognize -machine accel=kvm when parsing native

In Fedora 19, 'qemu-kvm' is a simple wrapper that calls
'qemu-system-x86_64 -machine accel=kvm'.  Attempting
to use 'virsh qemu-attach $pid' to a machine started as:

qemu-kvm -cdrom /var/lib/libvirt/images/foo.img \
 -monitor unix:/tmp/demo,server,nowait -name foo \
 --uuid cece4f9f-dff0-575d-0e8e-01fe380f12ea

was failing with:
error: XML error: No PCI buses available

because we did not see 'kvm' in the executable name read from
/proc/$pid/cmdline, and tried to assign os.machine as
"accel=kvm" instead of "pc"; this in turn led to refusal to
recognize the pci bus.

Noticed while investigating https://bugzilla.redhat.com/995312
although there are still other issues to fix before that bug
will be completely solved.

I've concluded that the existing parser code for native-to-xml
is a horrendous hodge-podge of ad-hoc approaches; I basically
rewrote the -machine section to be a bit saner.

* src/qemu/qemu_command.c (qemuParseCommandLine): Don't assume
-machine argument is always appropriate for os.machine; set
virtType if accel is present.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoqemu: only parse basename when determining emulator properties
Eric Blake [Mon, 26 Aug 2013 22:04:19 +0000 (16:04 -0600)]
qemu: only parse basename when determining emulator properties

'virsh domxml-from-native' and 'virsh qemu-attach' could misbehave
for an emulator installed in (a somewhat unlikely) location
such as /usr/local/qemu-1.6/qemu-system-x86_64 or (an even less
likely) /opt/notxen/qemu-system-x86_64.  Limit the strstr seach
to just the basename of the file where we are assuming details
about the binary based on its name.

While testing, I accidentally triggered a core dump during strcmp
when I forgot to set os.type on one of my code paths; this patch
changes such a coding error to raise a nicer internal error instead.

* src/qemu/qemu_command.c (qemuParseCommandLine): Compute basename
earlier.
* src/conf/domain_conf.c (virDomainDefPostParseInternal): Avoid
NULL deref.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoLXC: fix typos in lxc_container.c
Chen Hanxiao [Fri, 6 Sep 2013 11:14:00 +0000 (12:14 +0100)]
LXC: fix typos in lxc_container.c

Fix docs and error message typos in lxc_container.c

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
11 years agoDocs: fix a typo in virt-login-shell.pod
Alex Jia [Tue, 3 Sep 2013 03:51:32 +0000 (11:51 +0800)]
Docs: fix a typo in virt-login-shell.pod

Signed-off-by: Alex Jia <ajia@redhat.com>
11 years agolibxl: Compile regular expression where it is used
Jim Fehlig [Wed, 4 Sep 2013 22:14:30 +0000 (16:14 -0600)]
libxl: Compile regular expression where it is used

The regular expression used to determine guest capabilities
was compiled in libxlCapsInitHost() but used in libxlCapsInitGuests().
Move compilation to libxlCapsInitGuests() where it is used, and free
the compiled regex after use.  Ensure not to free the regex if
compilation fails.

11 years agoDon't call regfree() if regcomp() fails
Jim Fehlig [Wed, 4 Sep 2013 21:58:27 +0000 (15:58 -0600)]
Don't call regfree() if regcomp() fails

POSIX states that the preg parameter to regcomp() is undefined on
failure, so no need to call regfree() in these cases.

http://pubs.opengroup.org/onlinepubs/009695399/functions/regcomp.html

See also a discussion on the libvirt dev list

https://www.redhat.com/archives/libvir-list/2013-September/msg00262.html

11 years agospec: make client-only testing easier
Eric Blake [Wed, 4 Sep 2013 20:59:49 +0000 (14:59 -0600)]
spec: make client-only testing easier

Several recent patches cleaned up 'make rpm' for the situation
when client_only is true; these were done by manual spec file
editing (since it's relatively hard to come by a RHEL 5 s390
box).  Make it easier to do in the future via a simpler command
line override.

* libvirt.spec.in (client_only): Allow for override.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: shut up automake warnings
Eric Blake [Wed, 4 Sep 2013 16:26:30 +0000 (10:26 -0600)]
build: shut up automake warnings

I'm tired of seeing screenfuls of messages like these when using
automake 1.13 (Fedora 19):

configure.ac:2121: warning: The 'AM_PROG_MKDIR_P' macro is deprecated, and its use is discouraged.
configure.ac:2121: You should use the Autoconf-provided 'AC_PROG_MKDIR_P' macro instead,
configure.ac:2121: and use '$(MKDIR_P)' instead of '$(mkdir_p)'in your Makefile.am files.
daemon/Makefile.am:19: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')

seeing as how we MUST use those constructs for the benefit of
automake 1.9 (RHEL 5).  Conversely, RHEL 5 automake complained:

aclocal:configure.ac:36: warning: macro `AM_SILENT_RULES' not found in library

Obviously, I tested this patch on both Fedora 19 and RHEL 5.

* configure.ac (AM_INIT_AUTOMAKE): Avoid obsoletion warnings.
(AM_SILENT_RULES): Avoid unknown macro warning.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoFix a typo in network XML docs
Ján Tomko [Thu, 5 Sep 2013 09:32:19 +0000 (11:32 +0200)]
Fix a typo in network XML docs

11 years agoChange 'shortforward' to bool.
Ján Tomko [Thu, 5 Sep 2013 09:27:36 +0000 (11:27 +0200)]
Change 'shortforward' to bool.

11 years agoAdd '<nat>' element to '<forward>' network schemas
Ján Tomko [Thu, 5 Sep 2013 09:08:38 +0000 (11:08 +0200)]
Add '<nat>' element to '<forward>' network schemas

Commits 905629f4 and 1716e7a6 have added support for specifying
an IPv4 range and a port range to be used by NAT:
<forward mode='nat'>
  <nat>
    <address start='10.20.30.40' end='10.20.30.44'/>
    <port start='60000' end='65432'/>
  </nat>
</forward>

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

11 years agocpu: Add cpu test cases for PPC CPU driver.
Li Zhang [Tue, 3 Sep 2013 06:28:25 +0000 (14:28 +0800)]
cpu: Add cpu test cases for PPC CPU driver.

This patch is to add cpu test casses for PPC CPU driver.

Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com>
11 years agocpu: Implement guestData and update for PPC
Li Zhang [Tue, 3 Sep 2013 06:28:24 +0000 (14:28 +0800)]
cpu: Implement guestData and update for PPC

On Power platform, Power7+ can support Power7 guest.
It needs to define XML configuration to specify guest's CPU model.

For exmaple:
  <cpu match='exact'>
    <model>POWER7_v2.1</model>
    <vendor>IBM</vendor>
  </cpu>

Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com>
11 years agoqemu: Remove CPU features functions calling for non-x86 platform.
Li Zhang [Tue, 3 Sep 2013 06:28:23 +0000 (14:28 +0800)]
qemu: Remove CPU features functions calling for non-x86 platform.

CPU features are not supported on non-x86 and hasFeatures will be NULL.

This patch is to remove CPU features functions calling to avoid errors.

Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com>
11 years agoUse loop-control to allocate loop device.
Ian Main [Thu, 5 Sep 2013 11:04:33 +0000 (12:04 +0100)]
Use loop-control to allocate loop device.

This patch changes virFileLoopDeviceOpen() to use the new loop-control
device to allocate a new loop device.  If this behavior is unsupported
we fall back to the previous method of searching /dev for a free device.

With this patch you can start as many image based LXC domains as you
like (well almost).

Fixes bug https://bugzilla.redhat.com/show_bug.cgi?id=995543

11 years agoLXC: Don't mount securityfs when user namespace enabled
Gao feng [Thu, 5 Sep 2013 10:50:40 +0000 (11:50 +0100)]
LXC: Don't mount securityfs when user namespace enabled

Right now, securityfs is disallowed to be mounted in non-initial
user namespace, so we must avoid trying to mount securityfs in
a container which has user namespace enabled.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
11 years agoStop calling virAllocN directly from ESX code
Daniel P. Berrange [Tue, 3 Sep 2013 15:22:48 +0000 (16:22 +0100)]
Stop calling virAllocN directly from ESX code

The ESX code has a method esxVI_Alloc which would call
virAllocN directly, instead of using the VIR_ALLOC_N
macro. Remove this method and make the callers just
use VIR_ALLOC as is normal practice.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agovirDomainDeviceIsUSB: Drop check for USB controller
Liuji (Jeremy) [Thu, 5 Sep 2013 02:40:25 +0000 (02:40 +0000)]
virDomainDeviceIsUSB: Drop check for USB controller

Delete the USB controller check from the USB Device checklist in
virDomainDeviceIsUSB as USB controller is a PCI device rather than
a USB one.

Signed-off-by: Liu Ji <jeremy.liu@huawei.com>
11 years agoEnsure 'arch' is always set in cpuArchNodeData
Daniel P. Berrange [Wed, 4 Sep 2013 16:41:55 +0000 (17:41 +0100)]
Ensure 'arch' is always set in cpuArchNodeData

The s390, ppc and arm CPU drivers never set the 'arch' field
in their impl of cpuArchNodeData. This leads to error messages
being reported from cpuDataFree later, due to trying to use
VIR_ARCH_NONE.

 #0  virRaiseErrorFull (filename=filename@entry=0x76f94434 "cpu/cpu.c", funcname=funcname@entry=0x76f942dc <__FUNCTION__.18096> "cpuGetSubDriver", linenr=linenr@entry=58,
     domain=domain@entry=31, code=code@entry=1, level=level@entry=VIR_ERR_ERROR, str1=0x76f70e18 "internal error: %s",
     str2=str2@entry=0x7155f2ec "undefined hardware architecture", str3=str3@entry=0x0, int1=int1@entry=-1, int2=int2@entry=-1, fmt=0x76f70e18 "internal error: %s")
     at util/virerror.c:646
 #1  0x76e682ea in virReportErrorHelper (domcode=domcode@entry=31, errorcode=errorcode@entry=1, filename=0x76f94434 "cpu/cpu.c",
     funcname=0x76f942dc <__FUNCTION__.18096> "cpuGetSubDriver", linenr=linenr@entry=58, fmt=0x76f7e7e4 "%s") at util/virerror.c:1292
 #2  0x76ed82d4 in cpuGetSubDriver (arch=<optimized out>) at cpu/cpu.c:57
 #3  cpuGetSubDriver (arch=VIR_ARCH_NONE) at cpu/cpu.c:51
 #4  0x76ed8818 in cpuDataFree (data=data@entry=0x70c22d78) at cpu/cpu.c:216
 #5  0x716aaec0 in virQEMUCapsInitCPU (arch=VIR_ARCH_ARMV7L, caps=0x70c29a08) at qemu/qemu_capabilities.c:867

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoStop free'ing 'const char *' strings
Daniel P. Berrange [Tue, 3 Sep 2013 11:36:22 +0000 (12:36 +0100)]
Stop free'ing 'const char *' strings

The VIR_FREE() macro will cast away any const-ness. This masked a
number of places where we passed a 'const char *' string to
VIR_FREE. Fortunately in all of these cases, the variable was not
in fact const data, but a heap allocated string. Fix all the
variable declarations to reflect this.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoqemu: simplify list cleanup
Eric Blake [Wed, 28 Aug 2013 21:01:23 +0000 (15:01 -0600)]
qemu: simplify list cleanup

No need to open code now that we have a nice function.

Interestingly, our virStringFreeList function is typed correctly
(a malloc'd list of malloc'd strings is NOT const, whether at the
point where it is created, or at the point where it is cleand up),
so using it with a 'const char **' argument would require a cast
to keep the compiler.  I chose instead to remove const from code
even where we don't modify the argument, just to avoid the need
to cast.

* src/qemu/qemu_command.h (qemuParseCommandLine): Drop declaration.
* src/qemu/qemu_command.c (qemuParseProcFileStrings)
(qemuStringToArgvEnv): Don't force malloc'd result to be const.
(qemuParseCommandLinePid, qemuParseCommandLineString): Simplify
cleanup.
(qemuParseCommandLine, qemuFindEnv): Drop const-correctness to
avoid the need to cast in callers.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoconf: Don't deref NULL actual network in virDomainNetGetActualHostdev()
Peter Krempa [Wed, 4 Sep 2013 15:32:12 +0000 (17:32 +0200)]
conf: Don't deref NULL actual network in virDomainNetGetActualHostdev()

In commit 991270db99690 I've used virDomainNetGetActualHostdev() to get
the actual hostdev from a network when removing the network from the
list to avoid leaving the hostdev in the list. I didn't notice that this
function doesn't check if the actual network is allocated and
dereferences it. This crashes the daemon when cleaning up a domain
object in early startup phases when the actual network definition isn't
allocated. When the actual definition isn't present, the hostdev that
might correspond to it won't be present anyways so it's safe to return
NULL.

Thanks to Cole Robinson for noticing this problem.

11 years agolibxl: Unconditionally call virSysinfoRead() on driver init
Jim Fehlig [Wed, 4 Sep 2013 22:59:59 +0000 (16:59 -0600)]
libxl: Unconditionally call virSysinfoRead() on driver init

No need to check if privileged when reading hostsysinfo, since
that check was already done in libxlDriverShouldLoad().  The
libxl driver fails to load if not privileged.

11 years agolibxl: Check for regcomp failure
Jim Fehlig [Wed, 4 Sep 2013 06:21:42 +0000 (00:21 -0600)]
libxl: Check for regcomp failure

Change libxlGetAutoballoonConf() function to return an int
for success/failure, and fail if regcomp fails.

11 years agovirsh: fix build on mingw, which lacks termios stuff
Eric Blake [Wed, 4 Sep 2013 21:57:30 +0000 (15:57 -0600)]
virsh: fix build on mingw, which lacks termios stuff

Recent patches to fix handling of Ctrl-C when interacting with
ssh are not portable to mingw, which lacks termios handling.
The simplest solution is to just compile that code out, and
if someone ever appears that has a serious interest in getting
virsh fully functional even with ssh connections, they can
provide patches at that time.

* tools/virsh.h (_vshControl): Make termattr conditional.
* tools/virsh.c (vshTTYIsInterruptCharacter)
(vshTTYDisableInterrupt, vshTTYRestore, cfmakeraw, vshTTYMakeRaw)
(main): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agolibxl: Fix Coverity warning
Jim Fehlig [Wed, 4 Sep 2013 20:27:20 +0000 (14:27 -0600)]
libxl: Fix Coverity warning

John Ferlan reported the following Coverity warning:

In libxlDomainCoreDump() Coverity has noted a FORWARD_NULL reference:

2004      if ((flags & VIR_DUMP_CRASH) && !vm->persistent) {
2005          virDomainObjListRemove(driver->domains, vm);

(20) Event assign_zero:  Assigning: "vm" = "NULL".
Also see events:  [var_deref_model]

2006          vm = NULL;
2007      }
2008
2009      ret = 0;
2010
2011  cleanup_unpause:

(21) Event var_deref_model:  Passing null pointer "vm" to function
     "virDomainObjIsActive(virDomainObjPtr)", which dereferences it. [details]
Also see events:  [assign_zero]

2012      if (virDomainObjIsActive(vm) && paused) {
2013          if (libxl_domain_unpause(priv->ctx, dom->id) != 0) {
2014              virReportError(VIR_ERR_INTERNAL_ERROR,

Removing the vm from domain obj list and setting it to NULL can be
done in the previous 'if (flags & VIR_DUMP_CRASH)' conditional.  Fix
the Coverity warning by ensuring vm is not NULL before testing if it
is still active.

11 years agospec: default vbox according to libvirtd build
Eric Blake [Tue, 3 Sep 2013 23:08:25 +0000 (17:08 -0600)]
spec: default vbox according to libvirtd build

Commit ba5f3c7 moved virtualBox support into libvirtd, but the spec
file was still unconditionally requesting it even when not building
the server side.  Thankfully there were no ill effects for a
client_only build, as most uses of %{with_vbox} were guarded by
%{with_libvirtd}; but we might as well avoid confusion by more
closely matching the makefile.

* libvirt.spec.in (with_vbox): Hoist to server conditionals.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: avoid stranded polkit file in client-only build
Eric Blake [Wed, 4 Sep 2013 03:00:40 +0000 (21:00 -0600)]
build: avoid stranded polkit file in client-only build

daemon/Makefile.am installs a .policy file if WITH_LIBVIRTD and
WITH_POLKIT are both set.  src/Makefile.am, on the other hand,
installs a .policy file if WITH_POLKIT1 is set, but without checking
WITH_LIBVIRTD.  When running 'make rpm' with client_only manually
set, on a Fedora 19 box, that leads to a failure:

RPM build errors:
    Installed (but unpackaged) file(s) found:
   /usr/share/polkit-1/actions/org.libvirt.api.policy

Fix it by adding another conditional.

* src/Makefile.am (polkitaction_DATA): Make conditional.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: only install nwfilter examples when building nwfilter
Eric Blake [Tue, 3 Sep 2013 23:23:57 +0000 (17:23 -0600)]
build: only install nwfilter examples when building nwfilter

'make rpm' with client_local set to 1 (by manual modification,
or with RHEL 5 on s390) warns:

RPM build errors:
    Installed (but unpackaged) file(s) found:
   /etc/libvirt/nwfilter/allow-arp.xml
   /etc/libvirt/nwfilter/allow-dhcp-server.xml
   /etc/libvirt/nwfilter/allow-dhcp.xml
   /etc/libvirt/nwfilter/allow-incoming-ipv4.xml
   /etc/libvirt/nwfilter/allow-ipv4.xml
   /etc/libvirt/nwfilter/clean-traffic.xml
   /etc/libvirt/nwfilter/no-arp-ip-spoofing.xml
   /etc/libvirt/nwfilter/no-arp-mac-spoofing.xml
   /etc/libvirt/nwfilter/no-arp-spoofing.xml
   /etc/libvirt/nwfilter/no-ip-multicast.xml
   /etc/libvirt/nwfilter/no-ip-spoofing.xml
   /etc/libvirt/nwfilter/no-mac-broadcast.xml
   /etc/libvirt/nwfilter/no-mac-spoofing.xml
   /etc/libvirt/nwfilter/no-other-l2-traffic.xml
   /etc/libvirt/nwfilter/no-other-rarp-traffic.xml
   /etc/libvirt/nwfilter/qemu-announce-self-rarp.xml
   /etc/libvirt/nwfilter/qemu-announce-self.xml
   /usr/share/polkit-1/actions/org.libvirt.api.policy

The bulk of these are fixed with this patch.

* examples/xml/nwfilter/Makefile.am (install-data-local)
(uninstall-local): Make conditional.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: only run fdstreamtest when libvirtd is built
Eric Blake [Tue, 3 Sep 2013 21:55:21 +0000 (15:55 -0600)]
build: only run fdstreamtest when libvirtd is built

An rpm build with client_only set to 1 (for example, RHEL 5 on
s390, or by modifying libvirt.spec.in) failed with

TEST: fdstreamtest
 1) Stream read blocking                                              ... OK
 2) Stream read non-blocking                                          ... Unexpected EOF block 0 want 128
FAILED
 3) Stream write blocking                                             ... OK
 4) Stream write non-blocking                                         ... Failed to finish stream: internal error: libvirt:  error : cannot execute binary /home/eblake/rpmbuild/BUILD/libvirt-1.1.1/tests/../src/libvirt_iohelper: No such file or directory

Since the test depends on something that was only built for
WITH_LIBVIRTD (see src/Makefile.am), we must do the same for
the test.

* tests/Makefile.am (test_programs): Make fdstreamtest conditional.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agospec: fix rpm build when lxc disabled
Eric Blake [Tue, 3 Sep 2013 21:10:01 +0000 (15:10 -0600)]
spec: fix rpm build when lxc disabled

'make rpm' failed if ~/.rpmmacros contains '%_without_lxc 1',
which simulates the case of not having lxc available.

RPM build errors:
    File not found: /home/eblake/rpmbuild/BUILDROOT/libvirt-1.1.1-1.fc19.x86_64/etc/libvirt/virt-login-shell.conf
    File not found by glob: /home/eblake/rpmbuild/BUILDROOT/libvirt-1.1.1-1.fc19.x86_64/usr/share/man/man1/virt-login-shell.1*
    File not found: /home/eblake/rpmbuild/BUILDROOT/libvirt-1.1.1-1.fc19.x86_64/usr/bin/virt-login-shell
make: *** [rpm] Error 1

Reported by Dan Berrange.

* libvirt.spec.in: Mark virt-login-shell as conditional on lxc.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agovirGet{User,Group}Ent() don't say success on fail
Doug Goldstein [Wed, 4 Sep 2013 16:15:34 +0000 (11:15 -0500)]
virGet{User,Group}Ent() don't say success on fail

When virGetUserEnt() and virGetGroupEnt() fail due to the uid or gid not
existing on the machine they'll print a message like:

$ virsh -c vbox:///session list
error: failed to connect to the hypervisor
error: Failed to find user record for uid '32655': Success

The success at the end is a bit confusing. This changes it to:

$ virsh -c vbox:///session list
error: failed to connect to the hypervisor
error: Failed to find user record for uid '32655'

11 years agobuild: enforce makefile conditional style
Eric Blake [Wed, 4 Sep 2013 02:39:16 +0000 (20:39 -0600)]
build: enforce makefile conditional style

Automake has builtin support to prevent botched conditional nesting,
but only if you use:
if FOO
else !FOO
endif !FOO

An example error message when using the wrong name:

daemon/Makefile.am:378: error: else reminder (LIBVIRT_INIT_SCRIPT_SYSTEMD_TRUE) incompatible with current conditional: LIBVIRT_INIT_SCRIPT_SYSTEMD_FALSE
daemon/Makefile.am:381: error: endif reminder (LIBVIRT_INIT_SCRIPT_SYSTEMD_TRUE) incompatible with current conditional: LIBVIRT_INIT_SCRIPT_SYSTEMD_FALSE

As our makefiles tend to have quite a bit of nested conditionals,
it's better to take advantage of the benefits of the build system
double-checking that our conditionals are well-nested, but that
requires a syntax check to enforce our usage style.

Alas, unlike C preprocessor and spec files, we can't use indentation
to make it easier to see how deeply nesting goes.

* cfg.mk (sc_makefile_conditionals): New rule.
* daemon/Makefile.am: Enforce the style.
* gnulib/tests/Makefile.am: Likewise.
* python/Makefile.am: Likewise.
* src/Makefile.am: Likewise.
* tests/Makefile.am: Likewise.
* tools/Makefile.am: Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agodocs: Add OpenStack into references
Martin Kletzander [Wed, 4 Sep 2013 07:20:59 +0000 (09:20 +0200)]
docs: Add OpenStack into references

11 years agoDon't call VIR_ALLOC on def->uuid in parallels storage driver
Daniel P. Berrange [Tue, 3 Sep 2013 15:23:42 +0000 (16:23 +0100)]
Don't call VIR_ALLOC on def->uuid in parallels storage driver

The 'uuid' field in virDomainDefPtr is not a pointer, it is a
fixed length array. Calling VIR_ALLOC on it is thus wrong and
leaks memory.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>