]> xenbits.xensource.com Git - people/dariof/libvirt.git/log
people/dariof/libvirt.git
11 years agolibxl: implement virDomainGetNumaParameters libxl-numa-v2
Dario Faggioli [Fri, 14 Jun 2013 10:25:55 +0000 (12:25 +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>
---
Changes from v1:
 * fixed coding style, as requested during review;
 * VIR_TYPED_PARAM_STRING_OKAY handled more properly;

11 years agolibxl: advertise the support for VIR_TYPED_PARAM_STRING
Dario Faggioli [Fri, 28 Jun 2013 05:22:34 +0000 (07:22 +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>
---
Changes from v1:
 * commit message improved, as requested during review;
 * added VIR_TYPED_PARAM_STRING_OKAY handling code in
   libxlDomainGetSchedulerParametersFlags();

11 years agolibxl: implement NUMA capabilities reporting
Dario Faggioli [Fri, 14 Jun 2013 10:24:15 +0000 (12:24 +0200)]
libxl: implement NUMA capabilities reporting

Starting from Xen 4.2, libxl has all the bits and pieces in place
for retrieving an adequate amount of information about the host
NUMA topology. It is therefore possible, after a bit of shuffling,
to arrange those information in the way libvirt wants to present
them to the outside world.

Therefore, with this patch, the <topology> section of the host
capabilities is properly populated, when running on Xen, so that
we can figure out whether or not we're running on a NUMA host,
and what its characteristics are.

[raistlin@Zhaman ~]$ sudo virsh --connect xen:/// capabilities
<capabilities>
  <host>
    <cpu>
    ....
    <topology>
      <cells num='2'>
        <cell id='0'>
          <memory unit='KiB'>6291456</memory>
          <cpus num='8'>
            <cpu id='0' socket_id='1' core_id='0' siblings='0-1'/>
            <cpu id='1' socket_id='1' core_id='0' siblings='0-1'/>
            <cpu id='2' socket_id='1' core_id='1' siblings='2-3'/>
            <cpu id='3' socket_id='1' core_id='1' siblings='2-3'/>
            <cpu id='4' socket_id='1' core_id='9' siblings='4-5'/>
            <cpu id='5' socket_id='1' core_id='9' siblings='4-5'/>
            <cpu id='6' socket_id='1' core_id='10' siblings='6-7'/>
            <cpu id='7' socket_id='1' core_id='10' siblings='6-7'/>
          </cpus>
        </cell>
        <cell id='1'>
          <memory unit='KiB'>6881280</memory>
          <cpus num='8'>
            <cpu id='8' socket_id='0' core_id='0' siblings='8-9'/>
            <cpu id='9' socket_id='0' core_id='0' siblings='8-9'/>
            <cpu id='10' socket_id='0' core_id='1' siblings='10-11'/>
            <cpu id='11' socket_id='0' core_id='1' siblings='10-11'/>
            <cpu id='12' socket_id='0' core_id='9' siblings='12-13'/>
            <cpu id='13' socket_id='0' core_id='9' siblings='12-13'/>
            <cpu id='14' socket_id='0' core_id='10' siblings='14-15'/>
            <cpu id='15' socket_id='0' core_id='10' siblings='14-15'/>
          </cpus>
        </cell>
      </cells>
    </topology>
  </host>
  ....

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
---
Changes from v1:
 * fixed a typo in the commit message, as requested during review;
 * fixed coding style (one function parameters per line and no spaces
   between variable definitions), as requested during review;
 * avoid zero-filling memory after VIR_ALLOC_N(), since it does that
   already, as requested during review;
 * improved out of memory error reporting, as requested during review;
 * libxlMakeNumaCapabilities() created, accommodating all the NUMA
   related additions, instead of having them within
   libxlMakeCapabilitiesInternal(), as suggested during review.

11 years agoUnlock the storage volume object after looking it up
Ján Tomko [Thu, 4 Jul 2013 12:41:46 +0000 (14:41 +0200)]
Unlock the storage volume object after looking it up

Introduced by c930410.

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

11 years agoFix build with clang
Ján Tomko [Thu, 4 Jul 2013 09:35:59 +0000 (11:35 +0200)]
Fix build with clang

Partially revert cdd703f's revert of c163410, as linking with clang
with --param=ssp-buffer-size=4 still fails with:
"argument unused during compilation".

11 years agolibxl: fix deadlock in libxlReconnectDomain
Marek Marczykowski-Górecki [Thu, 13 Jun 2013 01:54:09 +0000 (03:54 +0200)]
libxl: fix deadlock in libxlReconnectDomain

Use virDomainObjListRemoveLocked instead of virDomainObjListRemove, as
driver->domains is already taken by virDomainObjListForEach.

Above deadlock can be triggered when libvirtd is started after some
domain have been started by hand (in which case driver will not find
libvirt-xml domain config).

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
11 years agoconf: virDomainObjListRemoveLocked function
Marek Marczykowski-Górecki [Thu, 13 Jun 2013 01:54:08 +0000 (03:54 +0200)]
conf: virDomainObjListRemoveLocked function

While iterating with virDomainObjListForEach it is safe to remove
current element. But while iterating, 'doms' lock is already taken, so
can't use standard virDomainObjListRemove. So introduce
virDomainObjListRemoveLocked for this purpose.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
11 years agomaint: update to latest gnulib
Eric Blake [Tue, 2 Jul 2013 23:26:42 +0000 (17:26 -0600)]
maint: update to latest gnulib

The latest mingw headers on Fedora 19 fail to build with gnulib
without an update.

Meanwhile, now that upstream gnulib has better handling of -W
probing for clang, we can drop some of our own solutions in
favor of upstream; thus this reverts commit c1634100, "Correctly
detect warning flags with clang".

* .gnulib: Update to latest, for mingw and clang.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoExtend the ACL test case to validate filter rule checks
Daniel P. Berrange [Thu, 27 Jun 2013 16:12:20 +0000 (17:12 +0100)]
Extend the ACL test case to validate filter rule checks

The 'check-aclrules' test case validates that there are ACL
checks in each method. This extends it so that it can also
validate that methods which return info about lists of objects,
will filter their returned info throw an ACL check.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd access control filtering of interface objects
Daniel P. Berrange [Thu, 27 Jun 2013 16:07:22 +0000 (17:07 +0100)]
Add access control filtering of interface objects

Ensure that all APIs which list interface objects filter
them against the access control system.

This makes the APIs for listing names and counting devices
slightly less efficient, since we can't use the direct
netcf APIs for these tasks. Instead we have to ask netcf
for the full list of objects & iterate over the list
filtering them out.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd access control filtering of nwfilter objects
Daniel P. Berrange [Thu, 27 Jun 2013 11:18:33 +0000 (12:18 +0100)]
Add access control filtering of nwfilter objects

Ensure that all APIs which list nwfilter objects filter
them against the access control system.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd access control filtering of secret objects
Daniel P. Berrange [Thu, 27 Jun 2013 11:12:30 +0000 (12:12 +0100)]
Add access control filtering of secret objects

Ensure that all APIs which list secret objects filter
them against the access control system.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd access control filtering of storage objects
Daniel P. Berrange [Wed, 26 Jun 2013 17:47:48 +0000 (18:47 +0100)]
Add access control filtering of storage objects

Ensure that all APIs which list storage objects filter
them against the access control system.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd access control filtering of node device objects
Daniel P. Berrange [Wed, 26 Jun 2013 16:50:54 +0000 (17:50 +0100)]
Add access control filtering of node device objects

Ensure that all APIs which list node device objects filter
them against the access control system.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd access control filtering of network objects
Daniel P. Berrange [Wed, 26 Jun 2013 15:42:27 +0000 (16:42 +0100)]
Add access control filtering of network objects

Ensure that all APIs which list network objects filter
them against the access control system.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoChange signature of ACL filter functions
Daniel P. Berrange [Wed, 3 Jul 2013 14:32:01 +0000 (15:32 +0100)]
Change signature of ACL filter functions

Change the ACL filter functions to use a 'bool' return
type instead of a tri-state 'int' return type. The callers
of these functions don't want to distinguish 'auth failed'
from other errors.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd access control filtering of domain objects
Daniel P. Berrange [Mon, 24 Jun 2013 16:49:47 +0000 (17:49 +0100)]
Add access control filtering of domain objects

Ensure that all APIs which list domain objects filter
them against the access control system.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoPut virt-sanlock-cleanup into section 8
Guido Günther [Tue, 2 Jul 2013 21:15:53 +0000 (23:15 +0200)]
Put virt-sanlock-cleanup into section 8

as indicated by the filename.

11 years agoqemu: Allow seamless migration for domains with multiple graphics
Martin Kletzander [Mon, 1 Jul 2013 12:16:51 +0000 (14:16 +0200)]
qemu: Allow seamless migration for domains with multiple graphics

Since commit 23e8b5d8, the code is refactored in a way that supports
domains with multiple graphics elements and commit 37b415200 allows
starting such domains.  However none of those commits take migration
into account.  Even though qemu doesn't support relocation for
anything else than SPICE and for no more than one graphics, there is no
reason to hardcode one graphics into this part of the code as well.

11 years agoqemu: Don't miss errors when changing graphics passwords
Martin Kletzander [Mon, 1 Jul 2013 07:23:04 +0000 (09:23 +0200)]
qemu: Don't miss errors when changing graphics passwords

Commit 23e8b5d8e7a92bac85b7fd2aca8992501bf680ee forgot to check the
return value for all calls to qemuDomainChangeGraphicsPasswords().

11 years agoLXC: blkio: allow to setup weight_device
Gao feng [Wed, 3 Jul 2013 11:35:54 +0000 (12:35 +0100)]
LXC: blkio: allow to setup weight_device

libivrt lxc can only set generic weight for container,
This patch allows user to setup per device blkio
weigh for container.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
11 years agoLXC: fix memory leak when userns configuration is incorrect
Gao feng [Wed, 3 Jul 2013 11:19:50 +0000 (12:19 +0100)]
LXC: fix memory leak when userns configuration is incorrect

We forgot to free the stack when Kernel doesn't
support user namespace.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
11 years agovirNetDevBandwidthUnplug: Don't leak @cmd
Michal Privoznik [Wed, 3 Jul 2013 07:43:14 +0000 (09:43 +0200)]
virNetDevBandwidthUnplug: Don't leak @cmd

When removing a TAP device, the associated bandwidth settings are
removed. Currently, the /sbin/tc is used for that. It is spawned
several times. Moreover, we use the same @cmd variable to
construct the command and its arguments. That means we need to
virCommandFree(cmd); prior to each virCommandNew(TC); which
wasn't done.

11 years agovirCgroupNewPartition: Don't leak @newpath
Michal Privoznik [Wed, 3 Jul 2013 07:42:11 +0000 (09:42 +0200)]
virCgroupNewPartition: Don't leak @newpath

The @newpath variable is allocated in virCgroupSetPartitionSuffix(). But
it's newer freed.

11 years agoqemu: Implement 'oncrash' coredump events when guest panicked
Chen Fan [Fri, 7 Jun 2013 10:23:35 +0000 (18:23 +0800)]
qemu: Implement 'oncrash' coredump events when guest panicked

Add doDumpCoreToAutoPath to implement
'coredump-destroy' and 'coredump-restart' events of the 'on_crash'
in the XML when domain crashed.

11 years agoqemu: Implement 'oncrash' events when guest panicked
Chen Fan [Fri, 7 Jun 2013 10:23:34 +0000 (18:23 +0800)]
qemu: Implement 'oncrash' events when guest panicked

Add monitor callback API domainGuestPanic, that implements
'destroy', 'restart' and 'preserve' events of the 'on_crash'
in the XML when domain crashed.

11 years agoqemu: expose qemuProcessShutdownOrReboot()
Chen Fan [Fri, 7 Jun 2013 10:23:33 +0000 (18:23 +0800)]
qemu: expose qemuProcessShutdownOrReboot()

Later code will need this outside of qemu_process.c

11 years agoqemu: refactor processWatchdogEvent
Chen Fan [Fri, 7 Jun 2013 10:23:32 +0000 (18:23 +0800)]
qemu: refactor processWatchdogEvent

Split the code to make the driver workpool more generalized

11 years agolibvirt: Define domain crash event types
Chen Fan [Fri, 7 Jun 2013 10:23:31 +0000 (18:23 +0800)]
libvirt: Define domain crash event types

This patch introduces domain crashed types and crashed reasons which
will be used while guest panicked.

11 years agobuild: don't ship access syms files in tarball
Eric Blake [Tue, 2 Jul 2013 16:28:20 +0000 (10:28 -0600)]
build: don't ship access syms files in tarball

On a mingw VPATH build (such as done by ./autobuild.sh), the tarball
created by 'make dist' was including generated files.  The VPATH
rules were then seeing that the tarball files were up-to-date, and
not regenerating files locally, leading to this failure:

  GEN      libvirt.syms
cat: libvirt_access.syms: No such file or directory
cat: libvirt_access_qemu.syms: No such file or directory
cat: libvirt_access_lxc.syms: No such file or directory
make: *** [libvirt.syms] Error 1

We already have a category for generated sym files, which are
intentionally not part of the tarball; stick the access sym
files in that category.  The rearrange the declarations a bit
to make it harder to repeat the problem, dropping things that
are now redundant (for example, BUILT_FILES already includes
GENERATED_SYM_FILES, so it does not also need to call out
ACCESS_DRIVER_SYM_FILES).

* src/Makefile.am (USED_SYM_FILES): Don't include generated files.
(GENERATED_SYM_FILES): Access syms files are generated.
(libvirt.syms): Include access syms files here.
(ACCESS_DRIVER_SYMFILES): Rename...
(ACCESS_DRIVER_SYM_FILES): ...for consistency.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoAdd some misc debugging to LXC startup
Daniel P. Berrange [Mon, 1 Jul 2013 16:42:25 +0000 (17:42 +0100)]
Add some misc debugging to LXC startup

Add some debug logging of LXC wait/continue messages
and uid/gid map update code.

11 years agoIgnore failure to mount SELinux filesystem in container
Daniel P. Berrange [Mon, 1 Jul 2013 16:41:21 +0000 (17:41 +0100)]
Ignore failure to mount SELinux filesystem in container

User namespaces will deny the ability to mount the SELinux
filesystem. This is harmless for libvirt's LXC needs, so the
error can be ignored.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agobuild: work around mingw header pollution
Eric Blake [Tue, 2 Jul 2013 12:09:30 +0000 (06:09 -0600)]
build: work around mingw header pollution

On Fedora 18, when cross-compiling to mingw with the mingw*-dbus
packages installed, compilation fails with:

  CC       libvirt_net_rpc_server_la-virnetserver.lo
In file included from /usr/i686-w64-mingw32/sys-root/mingw/include/dbus-1.0/dbus/dbus-connection.h:32:0,
                 from /usr/i686-w64-mingw32/sys-root/mingw/include/dbus-1.0/dbus/dbus-bus.h:30,
                 from /usr/i686-w64-mingw32/sys-root/mingw/include/dbus-1.0/dbus/dbus.h:31,
                 from ../../src/util/virdbus.h:26,
                 from ../../src/rpc/virnetserver.c:39:
/usr/i686-w64-mingw32/sys-root/mingw/include/dbus-1.0/dbus/dbus-message.h:74:58: error: expected ';', ',' or ')' before 'struct'

I have reported this as a bug against two packages:
- mingw-headers, for polluting the namespace
https://bugzilla.redhat.com/show_bug.cgi?id=980270
- dbus, for not dealing with the pollution
https://bugzilla.redhat.com/show_bug.cgi?id=980278

At least dbus has agreed that a future version of dbus headers will
do s/interface/iface/, regardless of what happens in mingw. But it
is also easy to workaround in libvirt in the meantime, without having
to wait for either mingw or dbus to upgrade.

* src/util/virdbus.h (includes): Undo mingw's pollution so that
dbus doesn't fail.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoqemuNodeDeviceDetachFlags: Avoid use of uninitialized variables
Michal Privoznik [Tue, 2 Jul 2013 09:20:53 +0000 (11:20 +0200)]
qemuNodeDeviceDetachFlags: Avoid use of uninitialized variables

After abf75aea24 the compiler screams:

qemu/qemu_driver.c: In function 'qemuNodeDeviceDetachFlags':
qemu/qemu_driver.c:10693:9: error: 'domain' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     pci = virPCIDeviceNew(domain, bus, slot, function);
         ^
qemu/qemu_driver.c:10693:9: error: 'bus' may be used uninitialized in this function [-Werror=maybe-uninitialized]
qemu/qemu_driver.c:10693:9: error: 'slot' may be used uninitialized in this function [-Werror=maybe-uninitialized]
qemu/qemu_driver.c:10693:9: error: 'function' may be used uninitialized in this function [-Werror=maybe-uninitialized]

Since the other functions qemuNodeDeviceReAttach and qemuNodeDeviceReset
looks exactly the same, I've initialized the variables there as well.
However, I am still wondering why those functions don't matter to gcc
while the first one does.

11 years agoLXC: fuse: Change files owner to the root user of container
Gao feng [Fri, 7 Jun 2013 07:12:27 +0000 (15:12 +0800)]
LXC: fuse: Change files owner to the root user of container

The owner of the /proc/meminfo in container should
be the root user of container.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
11 years agoLXC: controller: change the owner of /dev/pts and ptmx to the root of container
Gao feng [Fri, 7 Jun 2013 07:12:26 +0000 (15:12 +0800)]
LXC: controller: change the owner of /dev/pts and ptmx to the root of container

These files are created for container,
the owner should be the root user of container.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
11 years agoLXC: controller: change the owner of devices created on host
Gao feng [Fri, 7 Jun 2013 07:12:25 +0000 (15:12 +0800)]
LXC: controller: change the owner of devices created on host

Since these devices are created for the container.
the owner should be the root user of the container.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
11 years agoLXC: controller: change the owner of /dev to the root user of container
Gao feng [Fri, 7 Jun 2013 07:12:24 +0000 (15:12 +0800)]
LXC: controller: change the owner of /dev to the root user of container

container will create /dev/pts directory in /dev.
the owner of /dev should be the root user of container.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
11 years agoLXC: controller: change the owner of tty devices to the root user of container
Gao feng [Fri, 7 Jun 2013 07:12:23 +0000 (15:12 +0800)]
LXC: controller: change the owner of tty devices to the root user of container

Since these tty devices will be used by container,
the owner of them should be the root user of container.

This patch also adds a new function virLXCControllerChown,
we can use this general function to change the owner of
files.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
11 years agoLXC: Creating devices for container on host side
Gao feng [Fri, 7 Jun 2013 07:12:22 +0000 (15:12 +0800)]
LXC: Creating devices for container on host side

user namespace doesn't allow to create devices in
uninit userns. We should create devices on host side.

We first mount tmpfs on dev directroy under state dir
of container. then create devices under this dev dir.

Finally in container, mount the dev directroy created
on host to the /dev/ directroy of container.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
11 years agoLXC: introduce virLXCControllerSetupUserns and lxcContainerSetID
Gao feng [Fri, 7 Jun 2013 07:12:21 +0000 (15:12 +0800)]
LXC: introduce virLXCControllerSetupUserns and lxcContainerSetID

This patch introduces new helper function
virLXCControllerSetupUserns, in this function,
we set the files uid_map and gid_map of the init
task of container.

lxcContainerSetID is used for creating cred for
tasks running in container. Since after setuid/setgid,
we may be a new user. This patch calls lxcContainerSetUserns
at first to make sure the new created files belong to
right user.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
11 years agoLXC: sort the uidmap/gidmap of domain
Gao feng [Fri, 7 Jun 2013 07:12:20 +0000 (15:12 +0800)]
LXC: sort the uidmap/gidmap of domain

Make sure the mapping line contains the root user of container
is the first element of idmap array. So we can get the real
user id on host for the container easily.

This patch also check the map information, User must map
the root user of container to any user of host.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
11 years agoLXC: enable user namespace only when user set the uidmap
Gao feng [Fri, 7 Jun 2013 07:12:19 +0000 (15:12 +0800)]
LXC: enable user namespace only when user set the uidmap

User namespace will be enabled only when the idmap exist
in configuration.

If you want disable user namespace,just remove these
elements from XML.

If kernel doesn't support user namespace and idmap exist
in configuration file, libvirt lxc will start failed and
return "Kernel doesn't support user namespace" message.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
11 years agoLXC: Introduce New XML element for user namespace
Gao feng [Fri, 7 Jun 2013 07:12:18 +0000 (15:12 +0800)]
LXC: Introduce New XML element for user namespace

This patch introduces new element <idmap> for
user namespace. for example
<idmap>
    <uid start='0' target='1000' count='10'/>
    <gid start='0' target='1000' count='10'/>
</idmap>

this new element is used for setting proc files
/proc/<pid>/{uid_map,gid_map}.

This patch also supports multiple uid/gid elements
setting in XML configuration.

We don't support the semi configuation, user has to
configure uid and gid both.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
11 years agoqemu: Improve info message and remove a variable in qemuDomainManagedSave
Peter Krempa [Tue, 25 Jun 2013 08:43:13 +0000 (10:43 +0200)]
qemu: Improve info message and remove a variable in qemuDomainManagedSave

Mention the domain name that is being saved and remove the unneeded
variable that only stores a constant.

11 years agodocs: Document hypervisor drivers that support certain timer models
Peter Krempa [Mon, 24 Jun 2013 14:03:37 +0000 (16:03 +0200)]
docs: Document hypervisor drivers that support certain timer models

Not every timer model is supported with each hypervisor. Explicitly
mention the driver supporting each timer model.

11 years agoqemu: fix return value of qemuDomainBlockPivot on errors
Ján Tomko [Mon, 1 Jul 2013 10:41:34 +0000 (12:41 +0200)]
qemu: fix return value of qemuDomainBlockPivot on errors

If qemuMonitorBlockJob returned 0, qemuDomainBlockPivot
might return 0 even if an error occured.

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

11 years agolibxl: implement per NUMA node free memory reporting
Dario Faggioli [Fri, 28 Jun 2013 14:32:52 +0000 (16:32 +0200)]
libxl: implement per NUMA node free memory reporting

By providing the implementation of nodeGetCellsFreeMemory for
the driver. This is all just a matter of properly formatting, in
a way that libvirt like, what Xen provides via libxl_get_numainfo().

[raistlin@Zhaman ~]$ sudo virsh --connect xen:/// freecell --all
    0:      25004 KiB
    1:     105848 KiB
--------------------
Total:     130852 KiB

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
11 years agobuild: configure must not affect tarball contents
Eric Blake [Mon, 1 Jul 2013 22:48:11 +0000 (16:48 -0600)]
build: configure must not affect tarball contents

On mingw, configure sets the name of the lxc symfile to
libvirt_lxc.defs rather than libvirt_lxc.syms.  But tarballs
must be arch-independent, regardless of the configure options
used for the tree where we ran 'make dist'.  This led to the
following failure in autobuild.sh:

  CCLD     libvirt-lxc.la
  CCLD     libvirt-qemu.la
/usr/lib64/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/bin/ld: cannot find libvirt_lxc.def: No such file or directory
collect2: error: ld returned 1 exit status
make[3]: *** [libvirt-lxc.la] Error 1
make[3]: *** Waiting for unfinished jobs....

We were already doing the right thing with libvirt_qemu.syms.

* src/Makefile.am (EXTRA_DIST): Don't ship a built file which
depends on configure for its final name.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: avoid build failure without gnutls
Eric Blake [Mon, 1 Jul 2013 19:21:57 +0000 (13:21 -0600)]
build: avoid build failure without gnutls

Found while trying to cross-compile to mingw:

  CC       libvirt_driver_remote_la-remote_driver.lo
../../src/remote/remote_driver.c: In function 'doRemoteOpen':
../../src/remote/remote_driver.c:487:23: error: variable 'verify' set but not used [-Werror=unused-but-set-variable]

* src/remote/remote_driver.c (doRemoteOpen): Also ignore 'verify'.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoDrop iptablesContext
Roman Bogorodskiy [Fri, 28 Jun 2013 04:52:30 +0000 (00:52 -0400)]
Drop iptablesContext

iptablesContext holds only 4 pairs of iptables
(table, chain) and there's no need to pass
it around.

This is a first step towards separating bridge_driver.c
in platform-specific parts.

11 years agoqemu: indentation fix
Ján Tomko [Mon, 1 Jul 2013 15:41:22 +0000 (17:41 +0200)]
qemu: indentation fix

11 years agoqemu: Implement CPUs check against machine type's cpu-max
Michal Novotny [Wed, 26 Jun 2013 15:46:35 +0000 (17:46 +0200)]
qemu: Implement CPUs check against machine type's cpu-max

Implement check whether (maximum) vCPUs doesn't exceed machine
type's cpu-max settings.

On older versions of QEMU the check is disabled.

Signed-off-by: Michal Novotny <minovotn@redhat.com>
11 years agoRelease of libvirt-1.1.0
Daniel Veillard [Mon, 1 Jul 2013 09:22:49 +0000 (17:22 +0800)]
Release of libvirt-1.1.0

* configure.ac docs/news.html.in libvirt.spec.in: updated for the release
* po/*.po*: updated localizations and regenerated

11 years agoCrash of libvirtd by unprivileged user in virConnectListAllInterfaces
Daniel P. Berrange [Fri, 28 Jun 2013 12:21:33 +0000 (13:21 +0100)]
Crash of libvirtd by unprivileged user in virConnectListAllInterfaces

On Thu, Jun 27, 2013 at 03:56:42PM +0100, Daniel P. Berrange wrote:
> Hi Security Team,
>
> I've discovered a way for an unprivileged user with a readonly connection
> to libvirtd, to crash the daemon.

Ok, the final patch for this is issue will be the simpler variant that
Eric suggested

The embargo can be considered to be lifted on Monday July 1st, at
0900 UTC

The following is the GIT change that DV or myself will apply to libvirt
GIT master immediately before the 1.1.0 release:

>From 177b4165c531a4b3ba7f6ab6aa41dca9ceb0b8cf Mon Sep 17 00:00:00 2001
From: "Daniel P. Berrange" <berrange@redhat.com>
Date: Fri, 28 Jun 2013 10:48:37 +0100
Subject: [PATCH] CVE-2013-2218: Fix crash listing network interfaces with
 filters

The virConnectListAllInterfaces method has a double-free of the
'struct netcf_if' object when any of the filtering flags cause
an interface to be skipped over. For example when running the
command 'virsh iface-list --inactive'

This is a regression introduced in release 1.0.6 by

  commit 7ac2c4fe624f30f2c8270116513fa2ddab07631f
  Author: Guannan Ren <gren@redhat.com>
  Date:   Tue May 21 21:29:38 2013 +0800

    interface: list all interfaces with flags == 0

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agopci: initialize virtual_functions array pointer to avoid segfault
Laine Stump [Mon, 1 Jul 2013 03:52:43 +0000 (23:52 -0400)]
pci: initialize virtual_functions array pointer to avoid segfault

This fixes https://bugzilla.redhat.com/show_bug.cgi?id=971325

The problem was that if virPCIGetVirtualFunctions was given the name
of a non-existent interface, it would return to its caller without
initializing the pointer to the array of virtual functions to NULL,
and the caller (virNetDevGetVirtualFunctions) would try to VIR_FREE()
the invalid pointer.

The final error message before the crash would be:

 virPCIGetVirtualFunctions:2088 :
  Failed to open dir '/sys/class/net/eth2/device':
  No such file or directory

In this patch I move the initialization in virPCIGetVirtualFunctions()
to the begining of the function, and also do an explicit
initialization in virNetDevGetVirtualFunctions, just in case someone
in the future adds code into that function prior to the call to
virPCIGetVirtualFunctions.

11 years agonode device driver: update driver name during dumpxml
Laine Stump [Sun, 30 Jun 2013 18:49:21 +0000 (14:49 -0400)]
node device driver: update driver name during dumpxml

This fixes:

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

The node device driver was written with the assumption that udev would
use a "change" event to notify libvirt of any change to device status
(including the name of the driver it was bound to). It turns out this
is not the case (see Comment 4 of BZ 979290). That means that a
dumpxml for a device would always show whatever driver happened to be
bound at the time libvirt was started (when the node device cache was
built).

There was already code in the driver (for the benefit of the HAL
backend) that updated the driver name from sysfs each time a device's
info was retrieved from the cache. This patch just enables that manual
update for the udev backend as well.

11 years agoDocument security reporting & handling process
Daniel P. Berrange [Tue, 4 Jun 2013 10:06:01 +0000 (11:06 +0100)]
Document security reporting & handling process

Historically security issues in libvirt have been primarily
triaged & fixed by the Red Hat libvirt members & Red Hat
security team, who then usually notify other vendors via
appropriate channels. There have been a number of times
when vendors have not been properly notified ahead of
announcement. It has also disadvantaged community members
who have to backport fixes to releases for which there are
no current libvirt stable branches.

To address this, we want to make the libvirt security process
entirely community focused / driven. To this end I have setup
a new email address "libvirt-security@redhat.com" for end
users to report bugs which have (possible) security implications.

This email addr is backed by an invitation only, private
archive, mailing list. The intent is for the list membership
to comprise a subset of the libvirt core team, along with any
vendor security team engineers who wish to participate in a
responsible disclosure process for libvirt. Members of the
list will be responsible for analysing the problem to determine
if a security issue exists and then issue fixes for all current
official stable branches & git master.

I am proposing the following libvirt core team people as
members of the security team / list (all cc'd):

   Daniel Berrange (Red Hat)
   Eric Blake (Red Hat)
   Jiri Denemar (Red Hat)
   Daniel Veillard (Red Hat)
   Jim Fehlig (SUSE)
   Doug Goldstein (Gentoo)
   Guido Günther (Debian)

We don't have anyone from Ubuntu on the libvirt core team.
Serge Hallyn is the most frequent submitter of patches from
Ubuntu in recent history, so I'd like to invite him to join.
Alternatively, Serge, feel free to suggest someone else to
represent Ubuntu's interests.

If any other vendors/distros have security people who are
responsible for dealing with libvirt security issues, and
want to join to get early disclosure of issues, they can
suggest people. Existing security team members will vet /
approve such requests to ensure they are genuine.

Anyone on the team / list will be **required** to honour any
embargo period agreed between members for non-public issues
that are reported. The aim will be to have a maximum 2 week
embargo period in the common case, extendable to 1 month if
there is sufficient justification made. If anyone feels they
are unable to follow such an embargo process for whatever
reason, please decline membership of the security list/team.

The patch which follows puts up some docs on the website
about all of this....

Document how to report security bugs and the process that
will be used for addressing them.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agospec: require xen-devel for libxl driver
Eric Blake [Sat, 29 Jun 2013 20:50:14 +0000 (14:50 -0600)]
spec: require xen-devel for libxl driver

When using 'rpmbuild --define "_without_xen 1"', but on a new enough
Fedora where %{with_libxl} still gets set to 1 by default, the
build dependencies were incomplete, which could result in 'make rpm'
failing because ./configure failed to build the libxl driver.

* libvirt.spec.in (BuildRequires): Fix xen-devel condition.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoResolve valgrind errors for nodedev cap parsing
John Ferlan [Fri, 28 Jun 2013 19:07:05 +0000 (15:07 -0400)]
Resolve valgrind errors for nodedev cap parsing

There were two errors, one as a direct result of commit id '8807b285'
and the other from cut-n-paste

TEST: nodedevxml2xmltest
      ..............                           14  OK
==25735== 3 bytes in 1 blocks are definitely lost in loss record 1 of 24
==25735==    at 0x4A0887C: malloc (vg_replace_malloc.c:270)
==25735==    by 0x344D2AF275: xmlStrndup (in /usr/lib64/libxml2.so.2.9.1)
==25735==    by 0x4D0C767: virNodeDeviceDefParseNode (node_device_conf.c:997)
==25735==    by 0x4D0D3D2: virNodeDeviceDefParse (node_device_conf.c:1337)
==25735==    by 0x401CA4: testCompareXMLToXMLHelper (nodedevxml2xmltest.c:28)
==25735==    by 0x402B2F: virtTestRun (testutils.c:158)
==25735==    by 0x401B27: mymain (nodedevxml2xmltest.c:81)
==25735==    by 0x40316A: virtTestMain (testutils.c:722)
==25735==    by 0x37C1021A04: (below main) (libc-start.c:225)
==25735==
==25735== 16 bytes in 1 blocks are definitely lost in loss record 10 of 24
==25735==    at 0x4A08A6E: realloc (vg_replace_malloc.c:662)
==25735==    by 0x4C7385E: virReallocN (viralloc.c:184)
==25735==    by 0x4C73906: virExpandN (viralloc.c:214)
==25735==    by 0x4C73B4A: virInsertElementsN (viralloc.c:324)
==25735==    by 0x4D0C84C: virNodeDeviceDefParseNode (node_device_conf.c:1026)
==25735==    by 0x4D0D3D2: virNodeDeviceDefParse (node_device_conf.c:1337)
==25735==    by 0x401CA4: testCompareXMLToXMLHelper (nodedevxml2xmltest.c:28)
==25735==    by 0x402B2F: virtTestRun (testutils.c:158)
==25735==    by 0x401B27: mymain (nodedevxml2xmltest.c:81)
==25735==    by 0x40316A: virtTestMain (testutils.c:722)
==25735==    by 0x37C1021A04: (below main) (libc-start.c:225)
==25735==
PASS: nodedevxml2xmltest

The first error was resolved by adding a missing VIR_FREE(numberStr); in
the new function virNodeDevCapPciDevIommuGroupParseXML().

The second error was a bit more opaque as the error was a result of copying
the free methodolgy of the existing code in virNodeDevCapsDefFree(). The code
would free each of the entries in the array, but not the memory for the
array itself.  Added the necessary VIR_FREE(data->pci_dev.iommuGroupDevices)
and while at it added the missing VIR_FREE(data->pci_dev.virtual_functions)
although there wasn't a test that tripped across it (thus it's been lurking
since commit id 'a010165d').

11 years agoResolve valgrind error in remoteConfigGetStringList()
John Ferlan [Fri, 28 Jun 2013 17:10:10 +0000 (13:10 -0400)]
Resolve valgrind error in remoteConfigGetStringList()

Commit id 'ed3bac71' introduced the following:

TEST: libvirtdconftest
      ........................................ 40  OK
==25875== 690 (480 direct, 210 indirect) bytes in 30 blocks are definitely lost in loss record 18 of 24
==25875==    at 0x4A06B6F: calloc (vg_replace_malloc.c:593)
==25875==    by 0x4C737DF: virAllocN (viralloc.c:152)
==25875==    by 0x403BC8: remoteConfigGetStringList (libvirtd-config.c:74)
==25875==    by 0x4042CF: daemonConfigLoadOptions (libvirtd-config.c:382)
==25875==    by 0x4052F5: daemonConfigLoadData (libvirtd-config.c:479)
==25875==    by 0x40222C: testCorrupt (libvirtdconftest.c:112)
==25875==    by 0x40321F: virtTestRun (testutils.c:158)
==25875==    by 0x401FEE: mymain (libvirtdconftest.c:228)
==25875==    by 0x40385A: virtTestMain (testutils.c:722)
==25875==    by 0x37C1021A04: (below main) (libc-start.c:225)
==25875==
PASS: libvirtdconftest

11 years agoResolve valgrind error in virStorageBackendCreateQemuImgCmd()
John Ferlan [Fri, 28 Jun 2013 16:18:01 +0000 (12:18 -0400)]
Resolve valgrind error in virStorageBackendCreateQemuImgCmd()

Commit id '53d5967c' introduced the following:

TEST: storagevolxml2argvtest
      ..............                           14  OK
==25636== 358 (264 direct, 94 indirect) bytes in 1 blocks are definitely lost in loss record 67 of 75
==25636==    at 0x4A06B6F: calloc (vg_replace_malloc.c:593)
==25636==    by 0x4C95791: virAlloc (viralloc.c:124)
==25636==    by 0x4CA0BB4: virCommandNewArgs (vircommand.c:805)
==25636==    by 0x4CA0C88: virCommandNew (vircommand.c:789)
==25636==    by 0x408602: virStorageBackendCreateQemuImgCmd (storage_backend.c:849)
==25636==    by 0x405427: testCompareXMLToArgvHelper (storagevolxml2argvtest.c:61)
==25636==    by 0x4064DF: virtTestRun (testutils.c:158)
==25636==    by 0x40516F: mymain (storagevolxml2argvtest.c:195)
==25636==    by 0x406B1A: virtTestMain (testutils.c:722)
==25636==    by 0x37C1021A04: (below main) (libc-start.c:225)
==25636==
PASS: storagevolxml2argvtest

11 years agoResolve valgrind error in virNetDevVlanParse()
John Ferlan [Fri, 28 Jun 2013 16:04:37 +0000 (12:04 -0400)]
Resolve valgrind error in virNetDevVlanParse()

Commit '861d4056' introduced the following:

TEST: networkxml2xmltest
      ..................                       18  OK
==25504== 7 bytes in 1 blocks are definitely lost in loss record 5 of 23
==25504==    at 0x4A0887C: malloc (vg_replace_malloc.c:270)
==25504==    by 0x37C1085D71: strdup (strdup.c:42)
==25504==    by 0x4CB835F: virStrdup (virstring.c:546)
==25504==    by 0x4CC5179: virXPathString (virxml.c:90)
==25504==    by 0x4CC75C2: virNetDevVlanParse (netdev_vlan_conf.c:78)
==25504==    by 0x4CF928A: virNetworkPortGroupParseXML (network_conf.c:1555)
==25504==    by 0x4CFE385: virNetworkDefParseXML (network_conf.c:2049)
==25504==    by 0x4D0113B: virNetworkDefParseNode (network_conf.c:2273)
==25504==    by 0x4D01254: virNetworkDefParse (network_conf.c:2234)
==25504==    by 0x401E80: testCompareXMLToXMLHelper (networkxml2xmltest.c:32)
==25504==    by 0x402D4F: virtTestRun (testutils.c:158)
==25504==    by 0x401CE9: mymain (networkxml2xmltest.c:110)
==25504==
PASS: networkxml2xmltest

Also changed the label from error to cleanup and adjusted code since it's
all one exit path

11 years agodoc: Fix reference to #elementsUSB
Philipp Hahn [Fri, 28 Jun 2013 17:06:30 +0000 (19:06 +0200)]
doc: Fix reference to #elementsUSB

aae0fc2a922b3e31dae7648c547fca2ac2587625 removed the #elementsUSB anchor
but did not update the links to point to the new section #elementsHostDev.

Signed-off-by: Philipp Hahn <hahn@univention.de>
11 years agoConditionalize use of IF_MAXUNIT in virnetdevtap.c
Daniel P. Berrange [Fri, 28 Jun 2013 14:17:41 +0000 (15:17 +0100)]
Conditionalize use of IF_MAXUNIT in virnetdevtap.c

The IF_MAXUNIT macro is not present on all BSDs, so
make its use conditional, to avoid breaking OS-X.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoReplace use of 'in_addr_t' with 'struct in_addr'
Daniel P. Berrange [Fri, 28 Jun 2013 11:43:39 +0000 (12:43 +0100)]
Replace use of 'in_addr_t' with 'struct in_addr'

The 'in_addr_t' typedef is not present in Mingw64 headers.
Instead we can use the more portable 'struct in_addr' and
then access its 's_addr' field.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAllow RO connections to interface udev backend
Doug Goldstein [Fri, 28 Jun 2013 01:43:00 +0000 (20:43 -0500)]
Allow RO connections to interface udev backend

The udev based interface backend did not allow querying data over a
read-only connection which is different than how the netcf backend
operates. This brings the behavior inline with the default, netcf
backend.

11 years agobuild: Fix VPATH build for access/*
Viktor Mihajlovski [Thu, 27 Jun 2013 16:24:16 +0000 (18:24 +0200)]
build: Fix VPATH build for access/*

VPATH build failed for the generated access driver files.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
11 years agoFix vPort management: FC vHBA creation
Dennis Chen [Fri, 28 Jun 2013 09:59:51 +0000 (11:59 +0200)]
Fix vPort management: FC vHBA creation

When creating a virtual FC HBA with virsh/libvirt API, an error message
will be returned: "error: Node device not found",
also the 'nodedev-dumpxml' shows wrong information of wwpn & wwnn
for the new created device.

Signed-off-by: xschen@tnsoft.com.cn
This reverts f90af69 which switched wwpn & wwwn in the wrong place.

https://www.kernel.org/doc/Documentation/scsi/scsi_fc_transport.txt

11 years agoutil: fix build error on non-Linux systems
Laine Stump [Fri, 28 Jun 2013 08:00:54 +0000 (04:00 -0400)]
util: fix build error on non-Linux systems

Building on FreeBSD had this linker error:

/work/a/ports/devel/libvirt/work/libvirt-1.1.0/src/.libs/libvirt.so:
   undefined reference to `virPCIDeviceAddressParse'

This was caused by the new use of virPCIDeviceAddressParse in a
portion of virpci.c that wasn't linux-only (in commit 72c029d8). The
problem was that virPCIDeviceAddressParse had originally been defined
inside #ifdef _linux (because it was only used by another function
that was inside the same ifdef).

The solution is to move it out to the part of virpci.c that is
compiled on all platforms.

(Because the portion that was "moved" was 40-50 lines, but only moved
up by 15 lines, the diff for the patch is less than non-informative -
rather than showing that part that I moved, it shows the bit that was
previously before the moved part, and now sits *after* it.)

11 years agoconf: Swap order of AddImplicitControllers and DomainDefPostParse
Viktor Mihajlovski [Mon, 17 Jun 2013 14:17:37 +0000 (16:17 +0200)]
conf: Swap order of AddImplicitControllers and DomainDefPostParse

Implicit controllers may be dependent on device definitions altered
in a post-parse callback. Specifically, if a console device is
defined without the target type, the type will be set in QEMU's
callback. In the case of s390, this is virtio, which requires
an implicit virtio-serial controller.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
11 years agoS390: Testcase for console default target type (virtio)
Viktor Mihajlovski [Mon, 17 Jun 2013 14:17:36 +0000 (16:17 +0200)]
S390: Testcase for console default target type (virtio)

For s390 the default console target type is virtio. This also requires
that an implicit virtio-serial controller is instantiated.
This testcase verifies that the target type of virtio is correctly set
in the generated XML if no target element was given and that the
corresponding virtio-serial element is generated too.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
11 years agovirsh: Add parenthesis into virsh nodedev-detach help
xuzhang [Thu, 27 Jun 2013 11:21:07 +0000 (19:21 +0800)]
virsh: Add parenthesis into virsh nodedev-detach help

11 years agobridge: don't crash on bandwidth unplug with no bandwidth
Ján Tomko [Fri, 21 Jun 2013 17:20:31 +0000 (19:20 +0200)]
bridge: don't crash on bandwidth unplug with no bandwidth

If networkUnplugBandwidth is called on a network which has
no bandwidth defined, print a warning instead of crashing.

This can happen when destroying a domain with bandwidth if
bandwidth was removed from the network after the domain was
started.

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

11 years agonodedev: add iommuGroup to node device object
Laine Stump [Sun, 23 Jun 2013 18:01:00 +0000 (14:01 -0400)]
nodedev: add iommuGroup to node device object

This includes adding it to the nodedev parser and formatter, docs, and
test.

An example of the new iommuGroup element that is a part of the output
from "virsh nodedev-dumpxml" (virNodeDeviceGetXMLDesc()):

  <device>
    <name>pci_0000_02_00_1</name>
    <capability type='pci'>
    ...
      <iommuGroup number='12'>
        <address domain='0x0000' bus='0x02' slot='0x00' function='0x0'/>
        <address domain='0x0000' bus='0x02' slot='0x00' function='0x1'/>
      </iommuGroup>
    </capability>
  </device>

11 years agopci: new iommu_group functions
Laine Stump [Sun, 23 Jun 2013 18:47:57 +0000 (14:47 -0400)]
pci: new iommu_group functions

Any device which belongs to an "IOMMU group" (used by vfio) will
have links to all devices of its group listed in
/sys/bus/pci/$device/iommu_group/devices;
/sys/bus/pci/$device/iommu_group is actually a link to
/sys/kernel/iommu_groups/$n, where $n is the group number (there
will be a corresponding device node at /dev/vfio/$n once the
devices are bound to the vfio-pci driver)

The following functions are added:

virPCIDeviceGetIOMMUGroupList

  Gets a virPCIDeviceList with one virPCIDeviceList for each device
  in the same IOMMU group as the provided virPCIDevice (a copy of the
  original device object is included in the list.

virPCIDeviceAddressIOMMUGroupIterate

  Calls the function @actor once for each device in the group that
  contains the given virPCIDeviceAddress.

virPCIDeviceAddressGetIOMMUGroupAddresses

  Fills in a virPCIDeviceAddressPtr * with an array of
  virPCIDeviceAddress, one for each device in the iommu group of the
  provided virPCIDeviceAddress (including a copy of the original).

virPCIDeviceAddressGetIOMMUGroupNum

  Returns the group number as an int (a valid group number will always
  be 0 or greater).  If there is no iommu_group link in the device's
  directory (usually indicating that vfio isn't loaded), -2 will be
  returned. On any real error, -1 will be returned.

11 years agoPlug leak in virCgroupMoveTask
Ján Tomko [Wed, 26 Jun 2013 12:55:27 +0000 (14:55 +0200)]
Plug leak in virCgroupMoveTask

We only break out of the while loop if *content is an empty string.
However the buffer has been allocated to BUFSIZ + 1 (8193 in my case),
but it gets overwritten in the next for iteration.

Move VIR_FREE right before we overwrite it to avoid the leak.

==5777== 16,386 bytes in 2 blocks are definitely lost in loss record 1,022 of 1,027
==5777==    by 0x5296E28: virReallocN (viralloc.c:184)
==5777==    by 0x52B0C66: virFileReadLimFD (virfile.c:1137)
==5777==    by 0x52B0E1A: virFileReadAll (virfile.c:1199)
==5777==    by 0x529B092: virCgroupGetValueStr (vircgroup.c:534)
==5777==    by 0x529AF64: virCgroupMoveTask (vircgroup.c:1079)

Introduced by 83e4c77.

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

11 years agoFix invalid read in virCgroupGetValueStr
Ján Tomko [Wed, 26 Jun 2013 11:07:24 +0000 (13:07 +0200)]
Fix invalid read in virCgroupGetValueStr

Don't check for '\n' at the end of file if zero bytes were read.

Found by valgrind:
==404== Invalid read of size 1
==404==    at 0x529B09F: virCgroupGetValueStr (vircgroup.c:540)
==404==    by 0x529AF64: virCgroupMoveTask (vircgroup.c:1079)
==404==    by 0x1EB475: qemuSetupCgroupForEmulator (qemu_cgroup.c:1061)
==404==    by 0x1D9489: qemuProcessStart (qemu_process.c:3801)
==404==    by 0x18557E: qemuDomainObjStart (qemu_driver.c:5787)
==404==    by 0x190FA4: qemuDomainCreateWithFlags (qemu_driver.c:5839)

Introduced by 0d0b409.

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

11 years agoFix sample TPM XML
Stefan Berger [Wed, 26 Jun 2013 12:29:08 +0000 (08:29 -0400)]
Fix sample TPM XML

Fix an error in the sample TPM XML.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
11 years agonetwork: allow <vlan> in type='hostdev' networks
Laine Stump [Tue, 25 Jun 2013 23:32:07 +0000 (19:32 -0400)]
network: allow <vlan> in type='hostdev' networks

Although SRIOV network cards support setting a vlan tag on their
virtual functions, and although setting this vlan tag via a <vlan>
element in a domain's <interface> works, setting a vlan tag for these
devices in a <network> definition, or in a network <portgroup>
definition is also supposed to work (and the comment that validates
<vlan> usage even says that!). However, the check to allow it only
checked for an openvswitch network, so attempts to add <vlan> to a
network of type='hostdev' would fail.

11 years agodocs: correct and update network vlan example
Laine Stump [Wed, 26 Jun 2013 06:13:45 +0000 (02:13 -0400)]
docs: correct and update network vlan example

Somehow I put an example of a domain interface with a <vlan> element
into the network documentation.

This patch replaces that with an example of a network definition that
has a vlan element with trunk='yes', multiple tags, and even the new
nativeMode attribute. It also includes a <portgroup> that has a vlan
defined.

11 years agotest: include qemuhotplugtest data files in source rpm
Laine Stump [Wed, 26 Jun 2013 05:45:43 +0000 (01:45 -0400)]
test: include qemuhotplugtest data files in source rpm

commit 0fc12bca added a new test called qemuhotplugtest which has
several data files in tests/qemuhotplugtestdata, but didn't add that
directory to EXTRA_DIST in the tests Makefile.am, so the make check
done during a make rpm was failing due to missing data files.

11 years agoqemu: fix infinite loop in OOM error path
Laine Stump [Tue, 25 Jun 2013 02:42:35 +0000 (22:42 -0400)]
qemu: fix infinite loop in OOM error path

A loop in qemuPrepareHostdevPCIDevices() intended to cycle through all
the objects on the list pcidevs was doing "while (listcount > 0)", but
nothing in the body of the loop was reducing the size of the list - it
was instead removing items from a *different* list. It has now been
safely changed to a for() loop.

11 years agopci: fix dangling pointer in qemuDomainReAttachHostdevDevices
Laine Stump [Tue, 25 Jun 2013 02:04:43 +0000 (22:04 -0400)]
pci: fix dangling pointer in qemuDomainReAttachHostdevDevices

(This isn't as bad as it sounds - it's only a problem in case of an
OOM error.)

qemuGetActivePciHostDeviceList() had been creating a list that
contained pointers to objects that were also on the activePciHostdevs
list. In case of an OOM error, this newly created list would be
virObjectUnref'ed, which would cause everything on the list to be
freed. But all of those objects would still be on the
activePciHostdevs list, which could have very bad consequences if that
list was ever again accessed.

The solution used here is to populate the new list with *copies* of
the objects from the original list. It turns out that on return from
qemuGetActivePciHostDeviceList(), the caller would almost immediately
go through all the device objects and "steal" them (i.e. remove the
pointer from the list but not delete it) all from either one list or
the other; we now instead just *delete* (remove from the list and
free) each device from one list or the other, so in the end we have
the same state.

11 years agopci: eliminate leak in OOM condition
Laine Stump [Tue, 25 Jun 2013 01:30:55 +0000 (21:30 -0400)]
pci: eliminate leak in OOM condition

The "fix" I pushed a few commits ago would still leak a virPCIDevice
in case of an OOM error. Although it's inconsequential in practice,
this patch satisfies my OCD.

11 years agopci: virPCIDeviceListAddCopy API
Laine Stump [Tue, 25 Jun 2013 01:27:52 +0000 (21:27 -0400)]
pci: virPCIDeviceListAddCopy API

Make a copy of the device and add the copy to the
list. (virPCIDeviceListAdd() adds the original object to the list
instead).

11 years agopci: update stubDriver name in virPCIDeviceBindToStub
Laine Stump [Mon, 3 Jun 2013 17:50:42 +0000 (13:50 -0400)]
pci: update stubDriver name in virPCIDeviceBindToStub

If the device is bound to a stub driver different from what is saved
in the virPCIDevice's stubDriver attribute, update it.

11 years agopci: eliminate repetitive path constructions in virPCIDeviceBindToStub
Laine Stump [Mon, 3 Jun 2013 16:55:09 +0000 (12:55 -0400)]
pci: eliminate repetitive path constructions in virPCIDeviceBindToStub

The same strings were being re-created multiple times just to save
declaring a new variable. In the meantime, the use of the generic
variable names led to confusion when trying to follow the code. This
patch creates strings for:

 stubDriverName  (was called "driver" in original args)
 stubDriverPath  ("/sys/bus/pci/drivers/${stubDriverName}")
 driverLink      ("${device}/driver")
 oldDriverName   (the final component of path linked to by
                  "${device}/driver")
 oldDriverPath   ("/sys/bus/pci/drivers/${oldDriverName}")

then re-uses them as necessary.

11 years agopci: rename virPCIParseDeviceAddress and make it public
Laine Stump [Mon, 17 Jun 2013 15:57:19 +0000 (11:57 -0400)]
pci: rename virPCIParseDeviceAddress and make it public

This function has utility outside of virpci.c, so make it public.

Also the name didn't fit convention, so change it to
virPCIDeviceAddressParse.

11 years agopci: rename virPCIDeviceGetVFIOGroupDev to virPCIDeviceGetIOMMUGroupDev
Laine Stump [Fri, 14 Jun 2013 20:18:44 +0000 (16:18 -0400)]
pci: rename virPCIDeviceGetVFIOGroupDev to virPCIDeviceGetIOMMUGroupDev

I realized after the fact that it's probably better in the long run to
give this function a name that matches the name of the link used in
sysfs to hold the group (iommu_group).

I'm changing it now because I'm about to add several more functions
that deal with iommu groups.

11 years agopci: eliminate unused driver arg from virPCIDeviceDetach
Laine Stump [Thu, 30 May 2013 18:14:46 +0000 (14:14 -0400)]
pci: eliminate unused driver arg from virPCIDeviceDetach

The driver arg to virPCIDeviceDetach is no longer used (the name of the stub driver is now set in the virPCIDevice object, and virPCIDeviceDetach retrieves it from there). Remove it.

11 years agoutil: fix bug found by Coverity
Laine Stump [Tue, 25 Jun 2013 15:42:13 +0000 (11:42 -0400)]
util: fix bug found by Coverity

Commit 861d40565 added code (my personal change to "clean up" the
submitter's code, *not* the fault of the submitter) that dereferenced
virtVlan without first checking for NULL. This patch fixes that and,
as part of the fix, cleans up some unnecessary obtuseness.

11 years agotests: Introduce qemuhotplugtest
Michal Privoznik [Fri, 21 Jun 2013 14:27:59 +0000 (16:27 +0200)]
tests: Introduce qemuhotplugtest

As my punishment for the break in 7f15ebc7 (fixed in 752596b5dd) I'm
introducing this test to make sure it won't happen again. Currently,
only test for <graphics/> is supported.

11 years agoqemu: Implement support for VIR_MIGRATE_PARAM_GRAPHICS_URI
Jiri Denemark [Tue, 18 Jun 2013 10:17:18 +0000 (12:17 +0200)]
qemu: Implement support for VIR_MIGRATE_PARAM_GRAPHICS_URI

11 years agoImplement extensible migration APIs in qemu driver
Jiri Denemark [Tue, 25 Jun 2013 13:49:21 +0000 (15:49 +0200)]
Implement extensible migration APIs in qemu driver

11 years agoqemu: Move internals of Confirm phase to qemu_migration.c
Jiri Denemark [Tue, 25 Jun 2013 12:55:10 +0000 (14:55 +0200)]
qemu: Move internals of Confirm phase to qemu_migration.c

11 years agoqemu: Move common parts of Prepare phase to qemu_migration.c
Jiri Denemark [Tue, 25 Jun 2013 12:38:05 +0000 (14:38 +0200)]
qemu: Move common parts of Prepare phase to qemu_migration.c

11 years agoqemu: Move internals of Begin phase to qemu_migration.c
Jiri Denemark [Tue, 25 Jun 2013 07:44:14 +0000 (09:44 +0200)]
qemu: Move internals of Begin phase to qemu_migration.c

11 years agoFix possible NULL dereference during migration
Jiri Denemark [Tue, 25 Jun 2013 14:10:09 +0000 (16:10 +0200)]
Fix possible NULL dereference during migration

11 years agoUse 1.1.0 everywhere in the documentation
Ján Tomko [Tue, 25 Jun 2013 13:25:29 +0000 (15:25 +0200)]
Use 1.1.0 everywhere in the documentation

Since we already have the v1.1.0-rc1 tag in git.