]> xenbits.xensource.com Git - people/dariof/libvirt.git/log
people/dariof/libvirt.git
11 years agobuild: work around broken kernel headers
Eric Blake [Tue, 23 Jul 2013 23:45:21 +0000 (17:45 -0600)]
build: work around broken kernel headers

Thanks to a lack of coordination between kernel and glibc folks,
it has been impossible to mix code using <linux/in.h> and
<net/in.h> for some time now (see for example commit c308a9a).
On at least RHEL 6, <linux/if_bridge.h> tries to use the kernel
side, and fails due to our desire to use the glibc side elsewhere:

In file included from /usr/include/linux/if_bridge.h:17,
                 from util/virnetdevbridge.c:42:
/usr/include/linux/in6.h:31: error: redefinition of ‘struct in6_addr’
/usr/include/linux/in6.h:48: error: redefinition of ‘struct sockaddr_in6’
/usr/include/linux/in6.h:56: error: redefinition of ‘struct ipv6_mreq’

Thankfully, the kernel layout of these structs is ABI-compatible,
they only differ in the type system presented to the C compiler.
While there are other versions of kernel headers that avoid the
problem, it is easier to just work around the issue than to expect
all developers to upgrade to working kernel headers.

* src/util/virnetdevbridge.c (includes): Coerce the kernel version
of in.h to not collide with the normal version.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agodbus: work with older dbus
Eric Blake [Tue, 23 Jul 2013 23:06:26 +0000 (17:06 -0600)]
dbus: work with older dbus

dbus 1.2.24 (on RHEL 6) lacks DBUS_TYPE_UNIX_FD; but as we aren't
trying to pass one of those anyways, we can just drop support for
it in our wrapper.  Solves this build error introduced in commit
834c9c94:

  CC     libvirt_util_la-virdbus.lo
util/virdbus.c:242: error: 'DBUS_TYPE_UNIX_FD' undeclared here (not in a function)

* src/util/virdbus.c (virDBusBasicTypes): Drop support for unix fds.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agovalgrind.supp: Add more valgrind suppression paths
John Ferlan [Tue, 23 Jul 2013 14:29:10 +0000 (10:29 -0400)]
valgrind.supp: Add more valgrind suppression paths

Update based on recent run/failures seen

11 years agodomain_event: Resolve memory leak found by Valgrind
John Ferlan [Tue, 23 Jul 2013 14:06:02 +0000 (10:06 -0400)]
domain_event: Resolve memory leak found by Valgrind

Commit id '4421e257' strdup'd devAlias, but didn't free

Running qemuhotplugtest under valgrind resulted in the following:

==7375== 9 bytes in 1 blocks are definitely lost in loss record 11 of 70
==7375==    at 0x4A0887C: malloc (vg_replace_malloc.c:270)
==7375==    by 0x37C1085D71: strdup (strdup.c:42)
==7375==    by 0x4CBBD5F: virStrdup (virstring.c:554)
==7375==    by 0x4CFF9CB: virDomainEventDeviceRemovedNew (domain_event.c:1174)
==7375==    by 0x427791: qemuDomainRemoveChrDevice (qemu_hotplug.c:2508)
==7375==    by 0x42C65D: qemuDomainDetachChrDevice (qemu_hotplug.c:3357)
==7375==    by 0x41C94F: testQemuHotplug (qemuhotplugtest.c:115)
==7375==    by 0x41D817: virtTestRun (testutils.c:168)
==7375==    by 0x41C400: mymain (qemuhotplugtest.c:322)
==7375==    by 0x41DF3A: virtTestMain (testutils.c:764)
==7375==    by 0x37C1021A04: (below main) (libc-start.c:225)

11 years agolxc: Resolve Coverity warning
John Ferlan [Mon, 22 Jul 2013 20:59:41 +0000 (16:59 -0400)]
lxc: Resolve Coverity warning

Commit 'c8695053' resulted in the following:

Coverity error seen in the output:
    ERROR: REVERSE_INULL
    FUNCTION: lxcProcessAutoDestroy

Due to the 'dom' being checked before 'dom->persistent' since 'dom'
is already dereferenced prior to that.

11 years agoCreate + setup cgroups atomically for LXC process
Daniel P. Berrange [Mon, 22 Jul 2013 15:36:06 +0000 (16:36 +0100)]
Create + setup cgroups atomically for LXC process

Currently the LXC driver creates the VM's cgroup prior to
forking, and then libvirt_lxc moves the child process
into the cgroup. This won't work with systemd whose APIs
do the creation of cgroups + attachment of processes atomically.

Fortunately we simply move the entire cgroups setup into
the libvirt_lxc child process. We make it take place before
fork'ing into the background, so by the time virCommandRun
returns in the LXC driver, the cgroup is guaranteed to be
present.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoCreate + setup cgroups atomically for QEMU process
Daniel P. Berrange [Mon, 22 Jul 2013 14:21:15 +0000 (15:21 +0100)]
Create + setup cgroups atomically for QEMU process

Currently the QEMU driver creates the VM's cgroup prior to
forking, and then uses a virCommand hook to move the child
into the cgroup. This won't work with systemd whose APIs
do the creation of cgroups + attachment of processes atomically.

Fortunately we have a handshake taking place between the
QEMU driver and the child process prior to QEMU being exec()d,
which was introduced to allow setup of disk locking. By good
fortune this synchronization point can be used to enable the
QEMU driver to do atomic setup of cgroups removing the use
of the hook script.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoRemove obsolete cgroups creation apis
Daniel P. Berrange [Mon, 22 Jul 2013 13:03:54 +0000 (14:03 +0100)]
Remove obsolete cgroups creation apis

The virCgroupNewDomainDriver and virCgroupNewDriver methods
are obsolete now that we can auto-detect existing cgroup
placement. Delete them to reduce code bloat.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAuto-detect existing cgroup placement
Daniel P. Berrange [Mon, 22 Jul 2013 12:59:28 +0000 (13:59 +0100)]
Auto-detect existing cgroup placement

Use the new virCgroupNewDetect function to determine cgroup
placement of existing running VMs. This will allow the legacy
cgroups creation APIs to be removed entirely

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd API for checking if a cgroup is valid for a domain
Daniel P. Berrange [Tue, 23 Jul 2013 14:26:21 +0000 (15:26 +0100)]
Add API for checking if a cgroup is valid for a domain

Add virCgroupIsValidMachine API to check whether an auto
detected cgroup is valid for a machine. This lets us
check if a VM has just been placed into some generic
shared cgroup, or worse, the root cgroup

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd a virCgroupNewDetect API for finding cgroup placement
Daniel P. Berrange [Fri, 19 Jul 2013 10:13:05 +0000 (11:13 +0100)]
Add a virCgroupNewDetect API for finding cgroup placement

Add a virCgroupNewDetect API which is used to initialize a
cgroup object with the placement of an arbitrary process.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd logic for handling systemd-machined non-existance
Daniel P. Berrange [Mon, 22 Jul 2013 15:33:37 +0000 (16:33 +0100)]
Add logic for handling systemd-machined non-existance

If systemd machine does not exist, return -2 instead of -1,
so that applications don't need to repeat the tedious error
checking code

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix handling of DBus errors emitted by the bus itself
Daniel P. Berrange [Mon, 22 Jul 2013 15:32:28 +0000 (16:32 +0100)]
Fix handling of DBus errors emitted by the bus itself

Current code for handling dbus errors only works for errors
received from the remote application itself. We must also
handle errors emitted by the bus itself, for example, when
it fails to spawn the target service.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agostorage: Add connection for autostart storage pool
John Ferlan [Mon, 15 Jul 2013 20:26:10 +0000 (16:26 -0400)]
storage: Add connection for autostart storage pool

Add a privileged field to storageDriverState

Use the privileged value in order to generate a connection which could
be passed to the various storage backend drivers.

In particular, the iSCSI driver will need a connect in order to perform
pool authentication using the 'chap' secrets and the RBD driver utilizes
the connection during pool refresh for pools using 'ceph' secrets.

For now that connection will be to be to qemu driver until a mechanism
is devised to get a connection to just the secret driver without qemu.

11 years agoAdjust 'ceph' authentication secret usage for rbd pool.
John Ferlan [Mon, 15 Jul 2013 18:44:32 +0000 (14:44 -0400)]
Adjust 'ceph' authentication secret usage for rbd pool.

Update virStorageBackendRBDOpenRADOSConn() to use the internal API to the
secret driver in order to get the secret value instead of the external
virSecretGetValue() path. Without the flag VIR_SECRET_GET_VALUE_INTERNAL_CALL
there is no way to get the value of private secret.

This also requires ensuring there is a connection which wasn't true for
for the refreshPool() path calls from storageDriverAutostart() prior to
adding support for the connection to a qemu driver. It seems calls to
virSecretLookupByUUIDString() and virSecretLookupByUsage() from the
refreshPool() path would have failed with no way to find the secret - that is
theoretically speaking since the 'conn' was NULL the failure would have been
"failed to find the secret".

11 years agostorage: Support "chap" authentication for iscsi pool
John Ferlan [Mon, 15 Jul 2013 17:23:45 +0000 (13:23 -0400)]
storage: Support "chap" authentication for iscsi pool

Although the XML for CHAP authentication with plain "password"
was introduced long ago, the function was never implemented. This
patch replaces the login/password mechanism by following the
'ceph' (or RBD) model of using a 'username' with a 'secret' which
has the authentication information.

This patch performs the authentication during startPool() processing
of pools with an authType of VIR_STORAGE_POOL_AUTH_CHAP specified
for iSCSI pools.

There are two types of CHAP configurations supported for iSCSI
authentication:

  * Initiator Authentication
      Forward, one-way; The initiator is authenticated by the target.

  * Target Authentication
      Reverse, Bi-directional, mutual, two-way; The target is authenticated
      by the initiator; This method also requires Initiator Authentication

This only supports the "Initiator Authentication". (I don't have any
enterprise iSCSI env for testing, only have a iSCSI target setup with
tgtd, which doesn't support "Target Authentication").

"Discovery authentication" is not supported by tgt yet too. So this only
setup the session authentication by executing 3 iscsiadm commands, E.g:

% iscsiadm -m node --target "iqn.2013-05.test:iscsi.foo" --name \
  "node.session.auth.authmethod" -v "CHAP" --op update

% iscsiadm -m node --target "iqn.2013-05.test:iscsi.foo" --name \
  "node.session.auth.username" -v "Jim" --op update

% iscsiadm -m node --target "iqn.2013-05.test:iscsi.foo" --name \
  "node.session.auth.password" -v "Jimsecret" --op update

11 years agoqemu_common: Create qemuBuildVolumeString() to process storage pool
John Ferlan [Tue, 16 Jul 2013 16:11:10 +0000 (12:11 -0400)]
qemu_common: Create qemuBuildVolumeString() to process storage pool

Split out into its own separate routine

11 years agoqemu: Create a common qemuGetSecretString
John Ferlan [Wed, 17 Jul 2013 13:44:42 +0000 (09:44 -0400)]
qemu: Create a common qemuGetSecretString

Make the secret fetching code common for qemuBuildRBDString() and
qemuBuildDriveURIString() using the virDomainDiskDef.

11 years agoqemu: Add source pool auth info to virDomainDiskDef for iSCSI
John Ferlan [Fri, 19 Jul 2013 18:38:45 +0000 (14:38 -0400)]
qemu: Add source pool auth info to virDomainDiskDef for iSCSI

During qemuTranslateDiskSourcePool() execution, if the srcpool has been
defined with authentication information, then for iSCSI pools copy the
authentication and host information to virDomainDiskDef.

11 years agoqemu: Take error path if acquiring of job fails in qemuDomainSaveInternal
Peter Krempa [Tue, 23 Jul 2013 13:35:02 +0000 (15:35 +0200)]
qemu: Take error path if acquiring of job fails in qemuDomainSaveInternal

Due to a goto statement missed when refactoring in 2771f8b74c1bf50d1fa
when acquiring of a domain job failed the error path was not taken. This
resulted into a crash afterwards as an extra reference was removed from a
domain object leading to it being freed. An attempt to list the domains
leaded to a crash of the daemon afterwards.

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

11 years agobuild: fix make rpm failure
Laine Stump [Tue, 23 Jul 2013 13:40:06 +0000 (09:40 -0400)]
build: fix make rpm failure

util/virdbuspriv.h needed to be added to UTIL_SOURCES in the makefile.

11 years agobridge driver: use more general function names
Roman Bogorodskiy [Mon, 22 Jul 2013 18:14:22 +0000 (14:14 -0400)]
bridge driver: use more general function names

Continue preparation for extracting platform-specific
parts from bridge_driver: s/Iptables/Firewall/ for
firewall related function names.

11 years agoAdd virDBusMessage(Encode,Decode) stubs
Roman Bogorodskiy [Mon, 22 Jul 2013 18:32:49 +0000 (14:32 -0400)]
Add virDBusMessage(Encode,Decode) stubs

Commit 834c9c94 introduced virDBusMessageEncode and
virDBusMessageDecode functions, however corresponding stubs
were not added to !WITH_DBUS section, therefore 'make check'
started to fail when compiled w/out dbus support like that:

Expected symbol virDBusMessageDecode is not in ELF library

11 years agovirsh: fix change-media bug on disk block type
Guannan Ren [Mon, 22 Jul 2013 07:38:43 +0000 (15:38 +0800)]
virsh: fix change-media bug on disk block type

Resolves:https://bugzilla.redhat.com/show_bug.cgi?id=923053
When cdrom is block type, the virsh change-media failed to insert
source info because virsh uses "<source block='/dev/sdb'/>" while
the correct name of the attribute for block disks is "dev".

11 years agoqemu: Translate the volume type disk source before cgroup setting
Osier Yang [Tue, 18 Jun 2013 08:36:42 +0000 (16:36 +0800)]
qemu: Translate the volume type disk source before cgroup setting

The translation must be done before both of cgroup and security
setting, otherwise since the disk source is not translated yet,
it might be skipped on cgroup and security setting.

11 years agoconf: Ignore the volume type disk if its mode is "direct"
Osier Yang [Tue, 18 Jun 2013 08:36:41 +0000 (16:36 +0800)]
conf: Ignore the volume type disk if its mode is "direct"

virDomainDiskDefForeachPath is not only used by the security
setting helpers, also used by cgroup setting helpers, so this
is to ignore the volume type disk with mode="direct" for cgroup
setting.

11 years agoqemu: Translate the iscsi pool/volume disk source
John Ferlan [Thu, 18 Jul 2013 11:00:19 +0000 (07:00 -0400)]
qemu: Translate the iscsi pool/volume disk source

The difference with already supported pool types (dir, fs, block)
is: there are two modes for iscsi pool (or network pools in future),
one can specify it either to use the volume target path (the path
showed up on host) with mode='host', or to use the remote URI qemu
supports (e.g. file=iscsi://example.org:6000/iqn.1992-01.com.example/1)
with mode='direct'.

For 'host' mode, it copies the volume target path into disk->src. For
'direct' mode, the corresponding info in the *one* pool source host def
is copied to disk->hosts[0].

11 years agoconf: Introduce virDomainDiskSourceIsBlockType
John Ferlan [Thu, 18 Jul 2013 10:39:55 +0000 (06:39 -0400)]
conf: Introduce virDomainDiskSourceIsBlockType

Introduce a new helper to check if the disk source is of block type

11 years agoconf: Introduce new XML tag "mode" for disk source
John Ferlan [Thu, 18 Jul 2013 17:18:03 +0000 (13:18 -0400)]
conf: Introduce new XML tag "mode" for disk source

There are two ways to use a iSCSI LUN as disk source for qemu.

 * The LUN's path as it shows up on host, e.g.
   /dev/disk/by-path/ip-$ip:3260-iscsi-$iqn-fc18:iscsi.iscsi0-lun-1

 * The libiscsi URI from the storage pool source element host attribute, e.g.
   iscsi://demo.org:6000/iqn.1992-01.com.example/1

For a "volume" type disk, if the specified "pool" is of iscsi
type, we should support to use the LUN in either of above 2 ways.
That's why to introduce a new XML tag "mode" for the disk source
(libvirt should support iscsi pool with libiscsi, but it's another
new feature, which should be done later).

The "mode" can be either of "host" or "direct". Use "host" to indicate
use of the LUN with the path as it shows up on host. Use "direct" to
indicate to use it with the source pool host URI (future patches may support
to use network type libvirt storage too, e.g. Ceph)

11 years agostorage_iscsi: Reflect the default target port
John Ferlan [Thu, 18 Jul 2013 16:30:29 +0000 (12:30 -0400)]
storage_iscsi: Reflect the default target port

Make sure default iSCSI target is 3260.

11 years agotests: Free test at the end of GetDeviceAliases JSON test
Jiri Denemark [Mon, 22 Jul 2013 12:56:21 +0000 (14:56 +0200)]
tests: Free test at the end of GetDeviceAliases JSON test

Commit 58b147ad07c9432b53e66ca20aff74d812647c57 added a test for
qemuMonitorGetDeviceAliases but forgot to free the test object at the
end which causes all sort of weird errors and failures when new tests
are added after the GetDeviceAliases.

11 years agodoc: Fix copy-paste-error in virNodeGetMemoryStats
Philipp Hahn [Mon, 22 Jul 2013 11:58:16 +0000 (13:58 +0200)]
doc: Fix copy-paste-error in virNodeGetMemoryStats

The description seems to be copied from virNodeGetCpuState.
Change wrong 'cpu' to 'memory'.

Signed-off-by: Philipp Hahn <hahn@univention.de>
11 years agobridge driver: s/network_driver/virNetworkDriverState/
Roman Bogorodskiy [Mon, 22 Jul 2013 11:08:22 +0000 (15:08 +0400)]
bridge driver: s/network_driver/virNetworkDriverState/

This is another cleanup before extracting platform-specific
parts from bridge_driver.

Rename struct network_driver to _virNetworkDriverState and
add appropriate typedefs: virNetworkDriverState and
virNetworkDriverStatePtr.

This will help us to avoid potential problems when moving
this struct to the .h file.

11 years agoConvert remainder of cgroups code to report errors
Daniel P. Berrange [Mon, 8 Jul 2013 10:08:46 +0000 (11:08 +0100)]
Convert remainder of cgroups code to report errors

Convert the remaining methods in vircgroup.c to report errors
instead of returning errno values.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoConvert the virCgroupKill* APIs to report errors
Daniel P. Berrange [Fri, 19 Jul 2013 14:43:04 +0000 (15:43 +0100)]
Convert the virCgroupKill* APIs to report errors

Instead of returning errno values, change the virCgroupKill*
APIs to fully report errors.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoReport full errors from virCgroupNew*
Daniel P. Berrange [Thu, 4 Jul 2013 15:49:24 +0000 (16:49 +0100)]
Report full errors from virCgroupNew*

Instead of returning raw errno values, report full libvirt
errors in virCgroupNew* functions.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd helpers for dealing with system errors
Daniel P. Berrange [Fri, 19 Jul 2013 10:14:51 +0000 (11:14 +0100)]
Add helpers for dealing with system errors

Add virErrorSetErrnoFromLastError and virLastErrorIsSystemErrno
to simplify code which wants to handle system errors in a more
graceful fashion.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd API for calling systemd-machined's DBus API
Daniel P. Berrange [Thu, 18 Jul 2013 09:54:21 +0000 (10:54 +0100)]
Add API for calling systemd-machined's DBus API

To register virtual machines and containers with systemd-machined,
and thus have cgroups auto-created, we need to talk over DBus.
This is somewhat tedious code, so introduce a dedicated function
to isolate the DBus call in one place.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoIntroduce virDBusCallMethod & virDBusMessageRead methods
Daniel P. Berrange [Fri, 12 Jul 2013 10:13:04 +0000 (11:13 +0100)]
Introduce virDBusCallMethod & virDBusMessageRead methods

Doing DBus method calls using libdbus.so is tedious in the
extreme. systemd developers came up with a nice high level
API for DBus method calls (sd_bus_call_method). While
systemd doesn't use libdbus.so, their API design can easily
be ported to libdbus.so.

This patch thus introduces methods virDBusCallMethod &
virDBusMessageRead, which are based on the code used for
sd_bus_call_method and sd_bus_message_read. This code in
systemd is under the LGPLv2+, so we're license compatible.

This code is probably pretty unintelligible unless you are
familiar with the DBus type system. So I added some API
docs trying to explain how to use them, as well as test
cases to validate that I didn't screw up the adaptation
from the original systemd code.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agocpu: Let explicit features override model features
Jiri Denemark [Sat, 20 Jul 2013 22:27:40 +0000 (00:27 +0200)]
cpu: Let explicit features override model features

Until now CPU features inherited from a specified CPU model could only
be overridden with 'disable' policy. With this patch, any explicitly
specified feature always overrides the same feature inherited from a CPU
model regardless on the specified policy.

The CPU in x86-exact-force-Haswell.xml would previously be incompatible
with x86-host-SandyBridge.xml CPU even though x86-host-SandyBridge.xml
provides all features required by x86-exact-force-Haswell.xml.

11 years agovmware: Fix bogus CPU arch copy
Jiri Denemark [Sun, 21 Jul 2013 22:15:02 +0000 (00:15 +0200)]
vmware: Fix bogus CPU arch copy

11 years agocpu: Store arch in virCPUData
Jiri Denemark [Tue, 16 Jul 2013 12:39:40 +0000 (14:39 +0200)]
cpu: Store arch in virCPUData

11 years agoReplace union cpuData with virCPUData
Jiri Denemark [Tue, 18 Dec 2012 18:44:23 +0000 (19:44 +0100)]
Replace union cpuData with virCPUData

11 years agocpu_x86: Use x86-specific CPU data structure
Jiri Denemark [Tue, 18 Dec 2012 20:27:09 +0000 (21:27 +0100)]
cpu_x86: Use x86-specific CPU data structure

11 years agoLXC: Set default driver for image backed filesystems
Daniel P. Berrange [Tue, 9 Jul 2013 13:23:06 +0000 (14:23 +0100)]
LXC: Set default driver for image backed filesystems

If no explicit driver is set for an image backed filesystem,
set it to use the loop driver (if raw) or nbd driver (if
non-raw)

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoLXC: Fix some error reporting in filesystem setup
Daniel P. Berrange [Tue, 9 Jul 2013 13:24:10 +0000 (14:24 +0100)]
LXC: Fix some error reporting in filesystem setup

A couple of places in LXC setup for filesystems did not do
a "goto cleanup" after reporting errors. While fixing this,
also add in many more debug statements to aid troubleshooting

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoqemu: Shorten SCSI hostdev alias to avoid QEMU failure
Viktor Mihajlovski [Fri, 12 Jul 2013 15:13:56 +0000 (17:13 +0200)]
qemu: Shorten SCSI hostdev alias to avoid QEMU failure

The alias for hostdevs of type SCSI can be too long for QEMU if
larger LUNs are encountered. Here's a real life example:

    <hostdev mode='subsystem' type='scsi' managed='no'>
      <source>
        <adapter name='scsi_host0'/>
        <address bus='0' target='19' unit='1088634913'/>
      </source>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </hostdev>

this results in a too long drive id, resulting in QEMU yelling

Property 'scsi-generic.drive' can't find value 'drive-hostdev-scsi_host0-0-19-1088634913'

This commit changes the alias back to the default hostdev$(index)
scheme.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
11 years agoqemu: Unplug devices that disappeared when libvirtd was down
Jiri Denemark [Fri, 19 Jul 2013 13:08:29 +0000 (15:08 +0200)]
qemu: Unplug devices that disappeared when libvirtd was down

In case libvirtd is asked to unplug a device but the device is actually
unplugged later when libvirtd is not running, we need to detect that and
remove such device when libvirtd starts again and reconnects to running
domains.

11 years agoqemu: Introduce qemuMonitorGetDeviceAliases
Jiri Denemark [Fri, 19 Jul 2013 13:01:38 +0000 (15:01 +0200)]
qemu: Introduce qemuMonitorGetDeviceAliases

This API provides a NULL-terminated list of devices which are currently
attached to a QEMU domain.

11 years agoconf: Make error reporting in virDomainDefFindDevice optional
Jiri Denemark [Fri, 19 Jul 2013 12:59:36 +0000 (14:59 +0200)]
conf: Make error reporting in virDomainDefFindDevice optional

11 years agoutil: Non-existent string array does not contain any string
Jiri Denemark [Fri, 19 Jul 2013 12:55:41 +0000 (14:55 +0200)]
util: Non-existent string array does not contain any string

Make virStringArrayHasString return false when called on a non-existent
string array.

11 years agosecurity: fix deadlock with prefork
Eric Blake [Fri, 19 Jul 2013 15:07:19 +0000 (09:07 -0600)]
security: fix deadlock with prefork

Attempts to start a domain with both SELinux and DAC security
modules loaded will deadlock; latent problem introduced in commit
fdb3bde and exposed in commit 29fe5d7.  Basically, when recursing
into the security manager for other driver's prefork, we have to
undo the asymmetric lock taken at the manager level.

Reported by Jiri Denemark, with diagnosis help from Dan Berrange.

* src/security/security_stack.c (virSecurityStackPreFork): Undo
extra lock grabbed during recursion.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoChange s/i/iv/ in test code to avoid syntax-check
Daniel P. Berrange [Fri, 19 Jul 2013 12:07:41 +0000 (13:07 +0100)]
Change s/i/iv/ in test code to avoid syntax-check

The code parsing VIR_TEST_RANGE mistakenly used 'unsigned int i'
which violated syntax-check rules

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAllow test cases to be run selectively
Daniel P. Berrange [Thu, 18 Jul 2013 14:02:19 +0000 (15:02 +0100)]
Allow test cases to be run selectively

When debugging a failing test with many test cases, it is useful
to be able to skip most tests. Introducing a new environment
variable VIR_TEST_RANGE=N-M enables execution of only the test
cases numbered N-M inclusive, starting from 1.

For example, to skip all the cgroup tests except 2

$ VIR_TEST_RANGE=2-3 VIR_TEST_DEBUG=1 ./vircgrouptest
TEST: vircgrouptest
 2) New cgroup for driver                                             ... Unexpected found LXC cgroup: 1
libvirt: Cgroup error : Failed to create controller cpu for group: No such file or directory
FAILED
 3) New cgroup for domain driver                                      ... Cannot find LXC cgroup: 1
libvirt: Cgroup error : Failed to create controller cpu for group: No such file or directory
FAILED

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agomaint: update to latest gnulib
Eric Blake [Thu, 18 Jul 2013 21:47:41 +0000 (15:47 -0600)]
maint: update to latest gnulib

Upstream gnulib recently patched a bug in bootstrap, for projects
that use a different name than build-aux for a subdirectory.  We
don't, but it doesn't hurt to update.

* .gnulib: Update, for bootstrap fix.
* bootstrap: Sync to upstream.
* bootstrap.conf: Match upstream bug fix.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoautogen: Handle case when libvirt's submodule
Michal Privoznik [Fri, 19 Jul 2013 07:07:56 +0000 (09:07 +0200)]
autogen: Handle case when libvirt's submodule

Currently, in the autogen.sh script we check whether .git is an existing
directory in which case bootstrap is run. However, if libvirt is a
submodule, then the .git is just a file (with reference to the topmost
.git directory). However, our submodule routines work well. So there's
no real reason why we should prohibit users to build libvirt from
submodule.

11 years agomaint: split long lines in Makefiles
Eric Blake [Thu, 18 Jul 2013 15:37:52 +0000 (09:37 -0600)]
maint: split long lines in Makefiles

Makefiles are another easy file to enforce line limits.

Mostly straightforward; interesting tricks worth noting:
src/Makefile.am: $(confdir) was already defined, use it in more places
tests/Makefile.am: path_add and VG required some interesting compression

* cfg.mk (sc_prohibit_long_lines): Add another test.
* Makefile.am: Fix offenders.
* daemon/Makefile.am: Likewise.
* docs/Makefile.am: Likewise.
* python/Makefile.am: Likewise.
* src/Makefile.am: Likewise.
* tests/Makefile.am: Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agosecurity_dac: compute supplemental groups before fork
Eric Blake [Fri, 12 Jul 2013 20:55:21 +0000 (14:55 -0600)]
security_dac: compute supplemental groups before fork

Commit 75c1256 states that virGetGroupList must not be called
between fork and exec, then commit ee777e99 promptly violated
that for lxc's use of virSecurityManagerSetProcessLabel.  Hoist
the supplemental group detection to the time that the security
manager needs to fork.  Qemu is safe, as it uses
virSecurityManagerSetChildProcessLabel which in turn uses
virCommand to determine supplemental groups.

This does not fix the fact that virSecurityManagerSetProcessLabel
calls virSecurityDACParseIds calls parseIds which eventually
calls getpwnam_r, which also violates fork/exec async-signal-safe
safety rules, but so far no one has complained of hitting
deadlock in that case.

* src/security/security_dac.c (_virSecurityDACData): Track groups
in private data.
(virSecurityDACPreFork): New function, to set them.
(virSecurityDACClose): Clean up new fields.
(virSecurityDACGetIds): Alter signature.
(virSecurityDACSetSecurityHostdevLabelHelper)
(virSecurityDACSetChardevLabel, virSecurityDACSetProcessLabel)
(virSecurityDACSetChildProcessLabel): Update callers.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agosecurity: framework for driver PreFork handler
Eric Blake [Wed, 17 Jul 2013 21:35:50 +0000 (15:35 -0600)]
security: framework for driver PreFork handler

A future patch wants the DAC security manager to be able to safely
get the supplemental group list for a given uid, but at the time
of a fork rather than during initialization so as to pick up on
live changes to the system's group database.  This patch adds the
framework, including the possibility of a pre-fork callback
failing.

For now, any driver that implements a prefork callback must be
robust against the possibility of being part of a security stack
where a later element in the chain fails prefork.  This means
that drivers cannot do any action that requires a call to postfork
for proper cleanup (no grabbing a mutex, for example).  If this
is too prohibitive in the future, we would have to switch to a
transactioning sequence, where each driver has (up to) 3 callbacks:
PreForkPrepare, PreForkCommit, and PreForkAbort, to either clean
up or commit changes made during prepare.

* src/security/security_driver.h (virSecurityDriverPreFork): New
callback.
* src/security/security_manager.h (virSecurityManagerPreFork):
Change signature.
* src/security/security_manager.c (virSecurityManagerPreFork):
Optionally call into driver, and allow returning failure.
* src/security/security_stack.c (virSecurityDriverStack):
Wrap the handler for the stack driver.
* src/qemu/qemu_process.c (qemuProcessStart): Adjust caller.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoUse AC_LINK_IFELSE
Guido Günther [Thu, 18 Jul 2013 15:35:12 +0000 (17:35 +0200)]
Use AC_LINK_IFELSE

instead of the deprecated AC_TRY_LINK

11 years agotests: split long lines
Eric Blake [Wed, 17 Jul 2013 17:47:01 +0000 (11:47 -0600)]
tests: split long lines

Long lines are harder to read and harder to diff; in fact, if lines get
too long (> 1000 bytes), it starts causing issues where git send-email
refuses to send patches for the file.  I've cleaned up the tests
directory in the past (see commits bd6c46f3b750d1), but new long
lines have been introduced in the meantime.

Why 90 instead of 80? Because there were too many tests on the fringe
edge, and I didn't want to edit that many files.

Add a syntax check to prevent future long lines.

* cfg.mk (sc_prohibit_long_lines): New rule.
* tests/qemuxml2argvdata/qemuxml2argv-*.args: Split lines of any
file with content longer than 90 columns.
* tests/storagevolxml2argvdata/*.argv: Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoCheck for link_addr more thoroughly
Guido Günther [Wed, 17 Jul 2013 18:02:17 +0000 (20:02 +0200)]
Check for link_addr more thoroughly

Some versions of kFreeBSD (like 9.0) declare link_addr in a header
but lack an implementation. This makes ./configure pass but breaks
compilation later with a

     undefined reference to `link_addr'

Althought that's a bug in the OS header we can detect it easily by also
trying to link.

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

11 years agoqemu: Emit VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED events
Jiri Denemark [Thu, 11 Jul 2013 15:30:56 +0000 (17:30 +0200)]
qemu: Emit VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED events

11 years agoqemu: Remove devices only after DEVICE_DELETED event
Jiri Denemark [Thu, 11 Jul 2013 15:11:02 +0000 (17:11 +0200)]
qemu: Remove devices only after DEVICE_DELETED event

11 years agoqemu: Add support for DEVICE_DELETED event
Jiri Denemark [Thu, 11 Jul 2013 15:07:26 +0000 (17:07 +0200)]
qemu: Add support for DEVICE_DELETED event

11 years agoAdd virDomainDefFindDevice for looking up a device by its alias
Jiri Denemark [Thu, 11 Jul 2013 14:54:16 +0000 (16:54 +0200)]
Add virDomainDefFindDevice for looking up a device by its alias

11 years agoClarify virDomainDetachDeviceFlags documentation
Jiri Denemark [Wed, 19 Jun 2013 13:48:55 +0000 (15:48 +0200)]
Clarify virDomainDetachDeviceFlags documentation

11 years agoexamples: Handle VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED event
Jiri Denemark [Wed, 19 Jun 2013 13:28:00 +0000 (15:28 +0200)]
examples: Handle VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED event

11 years agoAdd VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED event
Jiri Denemark [Wed, 19 Jun 2013 13:27:29 +0000 (15:27 +0200)]
Add VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED event

11 years agoqemu: Separate char device removal into a standalone function
Jiri Denemark [Tue, 16 Jul 2013 19:16:09 +0000 (21:16 +0200)]
qemu: Separate char device removal into a standalone function

11 years agoqemu: Cleanup coding style nits in qemu_cgroup.c
Peter Krempa [Thu, 18 Jul 2013 09:29:27 +0000 (11:29 +0200)]
qemu: Cleanup coding style nits in qemu_cgroup.c

11 years agoqemu: Set cpuset.cpus for domain process
Osier Yang [Fri, 24 May 2013 09:08:28 +0000 (17:08 +0800)]
qemu: Set cpuset.cpus for domain process

When either "cpuset" of <vcpu> is specified, or the "placement" of
<vcpu> is "auto", only setting the cpuset.mems might cause the guest
starting to fail. E.g. ("placement" of both <vcpu> and <numatune> is
"auto"):

1) Related XMLs
  <vcpu placement='auto'>4</vcpu>
  <numatune>
    <memory mode='strict' placement='auto'/>
  </numatune>

2) Host NUMA topology
  % numactl --hardware
  available: 8 nodes (0-7)
  node 0 cpus: 0 4 8 12 16 20 24 28
  node 0 size: 16374 MB
  node 0 free: 11899 MB
  node 1 cpus: 32 36 40 44 48 52 56 60
  node 1 size: 16384 MB
  node 1 free: 15318 MB
  node 2 cpus: 2 6 10 14 18 22 26 30
  node 2 size: 16384 MB
  node 2 free: 15766 MB
  node 3 cpus: 34 38 42 46 50 54 58 62
  node 3 size: 16384 MB
  node 3 free: 15347 MB
  node 4 cpus: 3 7 11 15 19 23 27 31
  node 4 size: 16384 MB
  node 4 free: 15041 MB
  node 5 cpus: 35 39 43 47 51 55 59 63
  node 5 size: 16384 MB
  node 5 free: 15202 MB
  node 6 cpus: 1 5 9 13 17 21 25 29
  node 6 size: 16384 MB
  node 6 free: 15197 MB
  node 7 cpus: 33 37 41 45 49 53 57 61
  node 7 size: 16368 MB
  node 7 free: 15669 MB

4) cpuset.cpus will be set as: (from debug log)

2013-05-09 16:50:17.296+0000: 417: debug : virCgroupSetValueStr:331 :
Set value '/sys/fs/cgroup/cpuset/libvirt/qemu/toy/cpuset.cpus'
to '0-63'

5) The advisory nodeset got from querying numad (from debug log)

2013-05-09 16:50:17.295+0000: 417: debug : qemuProcessStart:3614 :
Nodeset returned from numad: 1

6) cpuset.mems will be set as: (from debug log)

2013-05-09 16:50:17.296+0000: 417: debug : virCgroupSetValueStr:331 :
Set value '/sys/fs/cgroup/cpuset/libvirt/qemu/toy/cpuset.mems'
to '0-7'

I.E, the domain process's memory is restricted on the first NUMA node,
however, it can use all of the CPUs, which will likely cause the domain
process to fail to start because of the kernel fails to allocate
memory with the the memory policy as "strict".

% tail -n 20 /var/log/libvirt/qemu/toy.log
...
2013-05-09 05:53:32.972+0000: 7318: debug : virCommandHandshakeChild:377 :
Handshake with parent is done
char device redirected to /dev/pts/2 (label charserial0)
kvm_init_vcpu failed: Cannot allocate memory
...

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
11 years agocaps: Add helpers to convert NUMA nodes to corresponding CPUs
Peter Krempa [Thu, 18 Jul 2013 09:21:48 +0000 (11:21 +0200)]
caps: Add helpers to convert NUMA nodes to corresponding CPUs

These helpers use the remembered host capabilities to retrieve the cpu
map rather than query the host again. The intended usage for this
helpers is to fix automatic NUMA placement with strict memory alloc. The
code doing the prepare needs to pin the emulator process only to cpus
belonging to a subset of NUMA nodes of the host.

11 years agoAdd virtio-scsi to fallback models of scsi controller
Martin Kletzander [Mon, 15 Jul 2013 07:19:06 +0000 (09:19 +0200)]
Add virtio-scsi to fallback models of scsi controller

When user does not specify any model for scsi controller, or worse, no
controller at all, but libvirt automatically adds scsi controller with
no model, we are not searching for virtio-scsi and thus this can fail
for example on qemu which doesn't support lsi logic adapter.

This means that when qemu on x86 doesn't support lsi53c895a and the
user adds the following to an XML without any scsi controller:

<disk ...>
  ...
  <target dev='sda'>
</disk>

libvirt fails like this:
 # virsh define asdf.xml
 error: Failed to define domain from asdf.xml
 error: internal error Unable to determine model for scsi controller

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

11 years agoIntroduce lxcDomObjFromDomain
Michal Privoznik [Wed, 17 Jul 2013 07:37:09 +0000 (09:37 +0200)]
Introduce lxcDomObjFromDomain

Similarly to qemu driver, we can use a helper function to
lookup a domain instead of copying multiple lines around.

11 years agoRemove lxcDriverLock from almost everywhere
Michal Privoznik [Wed, 17 Jul 2013 07:20:26 +0000 (09:20 +0200)]
Remove lxcDriverLock from almost everywhere

With the majority of fields in the virLXCDriverPtr struct
now immutable or self-locking, there is no need for practically
any methods to be using the LXC driver lock. Only a handful
of helper APIs now need it.

11 years agolxc: Make activeUsbHostdevs use locks
Michal Privoznik [Wed, 17 Jul 2013 07:14:42 +0000 (09:14 +0200)]
lxc: Make activeUsbHostdevs use locks

The activeUsbHostdevs item in LXCDriver are lockable, but the lock has
to be called explicitly. Call the virObject(Un)Lock() in order to
achieve mutual exclusion once lxcDriverLock is removed.

11 years agoStop accessing driver->caps directly in LXC driver
Michal Privoznik [Mon, 15 Jul 2013 09:43:10 +0000 (11:43 +0200)]
Stop accessing driver->caps directly in LXC driver

The 'driver->caps' pointer can be changed on the fly. Accessing
it currently requires the global driver lock. Isolate this
access in a single helper, so a future patch can relax the
locking constraints.

11 years agolxc: switch to virCloseCallbacks API
Michal Privoznik [Mon, 15 Jul 2013 17:08:11 +0000 (19:08 +0200)]
lxc: switch to virCloseCallbacks API

11 years agoIntroduce annotations for virLXCDriverPtr fields
Michal Privoznik [Tue, 16 Jul 2013 17:20:24 +0000 (19:20 +0200)]
Introduce annotations for virLXCDriverPtr fields

Annotate the fields in virLXCDriverPtr to indicate the locking
rules for their use.

11 years agolxc: Use atomic ops for driver->nactive
Michal Privoznik [Tue, 16 Jul 2013 17:05:06 +0000 (19:05 +0200)]
lxc: Use atomic ops for driver->nactive

11 years agoIntroduce a virLXCDriverConfigPtr object
Michal Privoznik [Tue, 16 Jul 2013 15:45:05 +0000 (17:45 +0200)]
Introduce a virLXCDriverConfigPtr object

Currently the virLXCDriverPtr struct contains an wide variety
of data with varying access needs. Move all the static config
data into a dedicated virLXCDriverConfigPtr object. The only
locking requirement is to hold the driver lock, while obtaining
an instance of virLXCDriverConfigPtr. Once a reference is held
on the config object, it can be used completely lockless since
it is immutable.

NB, not all APIs correctly hold the driver lock while getting
a reference to the config object in this patch. This is safe
for now since the config is never updated on the fly. Later
patches will address this fully.

11 years agovirLXCDriver: Drop unused @cgroup
Michal Privoznik [Thu, 18 Jul 2013 11:34:55 +0000 (13:34 +0200)]
virLXCDriver: Drop unused @cgroup

It is not used anywhere, so it makes no sense to have it there.

11 years agoqemu: Move close callbacks handling into util/virclosecallbacks.c
Michal Privoznik [Mon, 15 Jul 2013 14:53:13 +0000 (16:53 +0200)]
qemu: Move close callbacks handling into util/virclosecallbacks.c

11 years agoqemuhotplugtest: Resolve some memleaks
Michal Privoznik [Thu, 18 Jul 2013 10:38:02 +0000 (12:38 +0200)]
qemuhotplugtest: Resolve some memleaks

If testQemuHotplugAttach succeeds, the vm->def steals the dev pointer.
However, not the envelope, which needs to be freed. In addition,
driver.config is allocated, but never freed.

11 years agoqemuDomainDetachChrDevice: Don't leak @charAlias
Michal Privoznik [Thu, 18 Jul 2013 10:35:51 +0000 (12:35 +0200)]
qemuDomainDetachChrDevice: Don't leak @charAlias

Moreover, since virAsprintf now does report OOM error, there's no need
to call virReportOOMError in error path.

11 years agovirAsprintf: correctly check return value
Ján Tomko [Thu, 18 Jul 2013 10:13:46 +0000 (12:13 +0200)]
virAsprintf: correctly check return value

When virAsprintf was changed from a function to a macro
reporting OOM error in dc6f2da, it was documented as returning
0 on success. This is incorrect, it returns the number of bytes
written as asprintf does.

Some of the functions were converted to use virAsprintf's return
value directly, changing the return value on success from 0 to >= 0.

For most of these, this is not a problem, but the change in
virPCIDriverDir breaks PCI passthrough.

The return value check in virhashtest pre-dates virAsprintf OOM
conversion.

vmwareMakePath seems to be unused.

11 years agoMerge virCommandPreserveFD / virCommandTransferFD
Daniel P. Berrange [Thu, 11 Jul 2013 10:31:56 +0000 (11:31 +0100)]
Merge virCommandPreserveFD / virCommandTransferFD

Merge the virCommandPreserveFD / virCommandTransferFD methods
into a single virCommandPasFD method, and use a new
VIR_COMMAND_PASS_FD_CLOSE_PARENT to indicate their difference
in behaviour

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoEnable FD passing when starting guests with virsh
Daniel P. Berrange [Thu, 11 Jul 2013 15:32:14 +0000 (16:32 +0100)]
Enable FD passing when starting guests with virsh

Add a "--pass-fds N,M,..." arg to the virsh start/create
methods. This allows pre-opened file descriptors from the
shell to be passed on into the guest

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoLXC: Wire up the virDomainCreate{XML}WithFiles methods
Daniel P. Berrange [Tue, 9 Jul 2013 17:15:45 +0000 (18:15 +0100)]
LXC: Wire up the virDomainCreate{XML}WithFiles methods

Wire up the new virDomainCreate{XML}WithFiles methods in the
LXC driver, so that FDs get passed down to the init process.

The lxc_container code needs to do a little dance in order
to renumber the file descriptors it receives into linear
order, starting from STDERR_FILENO + 1.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix impl of virDomainCreateWithFlags remote client helper
Daniel P. Berrange [Fri, 12 Jul 2013 10:56:00 +0000 (11:56 +0100)]
Fix impl of virDomainCreateWithFlags remote client helper

In the following commit:

  commit 03d813bbcd7b4a18360105500672b84d985dd889
  Author: Marek Marczykowski <marmarek@invisiblethingslab.com>
  Date:   Thu May 23 02:01:30 2013 +0200

    remote: fix dom->id after virDomainCreateWithFlags

The virDomainCreateWithFlags remote client helper was made to
invoke REMOTE_PROC_DOMAIN_LOOKUP_BY_UUID to refresh the 'id'
of the domain, following the pattern used in the previous
virDomainCreate method impl.

The remote protocol for virDomainCreateWithFlags though did
actually fix the design flaw in virDomainCreate, by directly
returning the new domain info. For some reason, this data was
never used. So we can just use that data now instead.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoIntroduce remote protocol support for virDomainCreate{XML}WithFiles
Daniel P. Berrange [Tue, 9 Jul 2013 17:03:18 +0000 (18:03 +0100)]
Introduce remote protocol support for virDomainCreate{XML}WithFiles

Since they make use of file descriptor passing, the remote protocol
methods for virDomainCreate{XML}WithFiles must be written by hand.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoIntroduce new domain create APIs to pass pre-opened FDs to LXC
Daniel P. Berrange [Tue, 9 Jul 2013 16:12:38 +0000 (17:12 +0100)]
Introduce new domain create APIs to pass pre-opened FDs to LXC

With container based virt, it is useful to be able to pass
pre-opened file descriptors to the container init process.
This allows for containers to be auto-activated from incoming
socket connections, passing the active socket into the container.

To do this, introduce a pair of new APIs, virDomainCreateXMLWithFiles
and virDomainCreateWithFiles, which accept an array of file
descriptors. For the LXC driver, UNIX file descriptor passing
will be used to send them to libvirtd, which will them pass
them down to libvirt_lxc, which will then pass them to the container
init process.

This will only be implemented for LXC right now, but the design
is generic enough it could work with other hypervisors, hence
I suggest adding this to libvirt.so, rather than libvirt-lxc.so

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agomaint: Make ctags work out of the box
Jiri Denemark [Wed, 17 Jul 2013 10:43:53 +0000 (12:43 +0200)]
maint: Make ctags work out of the box

The .ctags file specifies default options for ctags so that it does not
ignore libvirt.h.in and ignores uninteresting files. As a result, you
can just run "ctags" and navigating to a public API won't get you to a
useless entry in api.html.

11 years agoesx: Support for disk-only and quiescing snapshots.
Geoff Hickey [Wed, 17 Jul 2013 18:28:33 +0000 (14:28 -0400)]
esx: Support for disk-only and quiescing snapshots.

Add support for creating disk-only (no memory) snapshots in esx, and
for quiescing the VM before taking the snapshot. The VMware API
supports these operations directly, so adding support to libvirt is
just a matter of setting the flags correctly when calling
VMware. VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY and
VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE are now valid flags for esx.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agolibxl: implement virDomainGetNumaParameters
Dario Faggioli [Sat, 13 Jul 2013 00:27:18 +0000 (02:27 +0200)]
libxl: implement virDomainGetNumaParameters

Although, having it depending on Xen >= 4.3 (by using the proper
libxl feature flag).

Xen currently implements a NUMA placement policy which is basically
the same as the 'interleaved' policy of `numactl', although it can
be applied on a subset of the available nodes. We therefore hardcode
"interleave" as 'numa_mode', and we use the newly introduced libxl
interface to figure out what nodes a domain spans ('numa_nodeset').

With this change, it is now possible to query the NUMA node
affinity of a running domain:

[raistlin@Zhaman ~]$ sudo virsh --connect xen:/// list
 Id    Name                           State
----------------------------------------------------
 23    F18_x64                        running

[raistlin@Zhaman ~]$ sudo virsh --connect xen:/// numatune 23
numa_mode      : interleave
numa_nodeset   : 1

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
11 years agolibxl: advertise the support for VIR_TYPED_PARAM_STRING
Dario Faggioli [Sat, 13 Jul 2013 00:27:10 +0000 (02:27 +0200)]
libxl: advertise the support for VIR_TYPED_PARAM_STRING

domainGetNumaParameters has a string typed parameter, hence it
is necessary for the libxl driver to support this.

This change implements the connectSupportsFeature hook for the
libxl driver, advertising that VIR_DRV_FEATURE_TYPED_PARAM_STRING
is supported.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Cc: Eric Blake <eblake@redhat.com>
11 years agoxen: Add interface versions for Xen 4.3
Stefan Bader [Tue, 16 Jul 2013 16:11:16 +0000 (18:11 +0200)]
xen: Add interface versions for Xen 4.3

Xen 4.3 changes sysctl version to 10 and domctl version to 9. Update
the hypervisor driver to work with those.

Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
11 years agolxc_container: Don't call virGetGroupList during exec
Michal Privoznik [Wed, 17 Jul 2013 09:21:09 +0000 (11:21 +0200)]
lxc_container: Don't call virGetGroupList during exec

Commit 75c1256 states that virGetGroupList must not be called
between fork and exec, then commit ee777e99 promptly violated
that for lxc.

Patch originally posted by Eric Blake <eblake@redhat.com>.

11 years agocgroup: reuse buffer for getline
Ján Tomko [Wed, 17 Jul 2013 08:56:05 +0000 (10:56 +0200)]
cgroup: reuse buffer for getline

Reuse the buffer for getline and track buffer allocation
separately from the string length to prevent unlikely
out-of-bounds memory access.

This fixes the following leak that happened when zero bytes were read:

==404== 120 bytes in 1 blocks are definitely lost in loss record 1,344 of 1,671
==404==    at 0x4C2C71B: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==404==    by 0x906F862: getdelim (iogetdelim.c:68)
==404==    by 0x52A48FB: virCgroupPartitionNeedsEscaping (vircgroup.c:1136)
==404==    by 0x52A0FB4: virCgroupPartitionEscape (vircgroup.c:1171)
==404==    by 0x52A0EA4: virCgroupNewDomainPartition (vircgroup.c:1450)