]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
12 years agoSet legacy USB option with default for ppc64.
Li Zhang [Fri, 19 Apr 2013 10:26:36 +0000 (11:26 +0100)]
Set legacy USB option with default for ppc64.

Currently, -device xxx still doesn't work well for ppc64 platform.
It's better use legacy USB option with default for ppc64.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoqemu: fix default spice password setting
Ján Tomko [Fri, 19 Apr 2013 05:00:44 +0000 (07:00 +0200)]
qemu: fix default spice password setting

Set spice password even if default VNC password hasn't been set.

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

12 years agoqemu_conf: add new configuration key bridge_helper
Paolo Bonzini [Mon, 25 Mar 2013 14:25:30 +0000 (15:25 +0100)]
qemu_conf: add new configuration key bridge_helper

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoutil: allow using virCommandAllowCap with setuid helpers
Paolo Bonzini [Mon, 25 Mar 2013 14:25:29 +0000 (15:25 +0100)]
util: allow using virCommandAllowCap with setuid helpers

When running unprivileged, virSetUIDGIDWithCaps will fail because it
tries to add the requested capabilities to the permitted and effective
sets.

Detect this case, and invoke the child with cleared permitted and
effective sets.  If it is a setuid program, it will get them.

Some care is needed also because you cannot drop capabilities from the
bounding set without CAP_SETPCAP.  Because of that, ignore errors from
setting the bounding set.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoutil: simplify virSetUIDGIDWithCaps
Paolo Bonzini [Mon, 25 Mar 2013 14:25:28 +0000 (15:25 +0100)]
util: simplify virSetUIDGIDWithCaps

The need_prctl variable is not really needed.  If it is false,
capng_apply will be called twice with the same set, causing
a little extra work but no problem.  This keeps the code a bit
simpler.

It is also clearer to invoke capng_apply(CAPNG_SELECT_BOUNDS)
separately, to make sure it is done while we have CAP_SETPCAP.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agovirsh-domain: Report errors on invalid --holdtime value for cmdSendKey
Peter Krempa [Thu, 18 Apr 2013 08:42:47 +0000 (10:42 +0200)]
virsh-domain: Report errors on invalid --holdtime value for cmdSendKey

Using of a incorrect value for the --holdtime option was silently
ignored and 0 was used. In case a negative number was used, it
overflowed as the API expects a unsigned int.

Fix the data type and getter function type and report errors on
incorrect values.

12 years agovirsh-domain: Clean up cmdSendKey
Peter Krempa [Thu, 18 Apr 2013 08:40:49 +0000 (10:40 +0200)]
virsh-domain: Clean up cmdSendKey

Rename the get_integer_keycode helper to vshKeyCodeGetInt and get rid of
a unneeded typecast.

12 years agoqemu: simplify use of virArchFromHost
Tal Kain [Mon, 8 Apr 2013 12:33:07 +0000 (15:33 +0300)]
qemu: simplify use of virArchFromHost

Reusing the result of virArchFromHost instead of calling it multiple times

Signed-off-by: Tal Kain <tal.kain@ravellosystems.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agorng: tighten up domain <controller> schema
Laine Stump [Thu, 18 Apr 2013 04:25:18 +0000 (00:25 -0400)]
rng: tighten up domain <controller> schema

The rng schema for <controller> had been non-specific about which
types of controllers allowed which models, and also allowed the
num_queues attribute (since that hasn't been released yet, should we
rename it to "numQueues"?) and <master> subelement to be included for
any controller type. In reality, half of the models are allowed only
for type='scsi', and the other half only for type='usb', num_queues is
allowed only for type='scsi', and <master> only for type='usb'.

This patch makes a separate <group> for type='scsi' and type='usb',
with each group allowing only the appropriate model values, and
allowing num_queue and <master> only when appropriate.

<interleave> also hadn't been specified, forcing a specific order of
subelements, which should never be done. (Note that the <interleave>
had to surround the main element attributes that are in the <group>
subelements, due to one of the <group>s containing a subelement).

12 years agonetwork: remove autostart flag from network when undefining it
Peter Krempa [Wed, 17 Apr 2013 08:13:35 +0000 (10:13 +0200)]
network: remove autostart flag from network when undefining it

When turning a started persistent network into a transient one we forgot
to remove the autostart flag that is no longer valid at that point.

12 years agodocs: Update HACKING
Osier Yang [Wed, 17 Apr 2013 10:19:20 +0000 (18:19 +0800)]
docs: Update HACKING

To tell libvirt-{qemu,lxc}.h shouldn't be included either.

12 years agosyntax-check: Only allows to include public headers in external tools
Osier Yang [Wed, 17 Apr 2013 10:19:19 +0000 (18:19 +0800)]
syntax-check: Only allows to include public headers in external tools

With this patch, include public headers in "" form is only allowed
for "internal.h". And only the external tools (examples|tools|python
|include/libvirt) can include the public headers in <> form.

12 years agosyntax-check: Don't include public headers in internal source
Osier Yang [Wed, 17 Apr 2013 10:19:18 +0000 (18:19 +0800)]
syntax-check: Don't include public headers in internal source

Directories python/tools/examples should include them in <> form,
though this patch allows "" form in these directories by excluding
them, a later patch will do the cleanup.

12 years agosyntax-check: Don't include duplicate header
Osier Yang [Wed, 17 Apr 2013 10:25:57 +0000 (18:25 +0800)]
syntax-check: Don't include duplicate header

gnulib is excluded.

12 years agoconf: fix comment about parsing graphics listen address
Ján Tomko [Mon, 15 Apr 2013 10:53:41 +0000 (12:53 +0200)]
conf: fix comment about parsing graphics listen address

12 years agoremote: Revert removing "libvirt/libvirt.h" in remote_protocol.x
Osier Yang [Wed, 17 Apr 2013 15:14:52 +0000 (23:14 +0800)]
remote: Revert removing "libvirt/libvirt.h" in remote_protocol.x

Commit 2d25fd4f410f removed the including of "libvirt/libvirt.h",
which breaks the build. Pushed under build-breaker rule.

12 years agoqemu: Allow the disk wwn to have "0x" prefix
Osier Yang [Wed, 17 Apr 2013 13:23:44 +0000 (21:23 +0800)]
qemu: Allow the disk wwn to have "0x" prefix

The recent qemu requires "0x" prefix for the disk wwn, this patch
changes virValidateWWN to allow the prefix, and prepend "0x" if
it's not specified. E.g.

qemu-kvm: -device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=0,\
drive=drive-scsi0-0-0-0,id=scsi0-0-0-0,wwn=6000c60016ea71ad:
Property 'scsi-hd.wwn' doesn't take value '6000c60016ea71ad'

Though it's a qemu regression, but it's nice to allow the prefix,
and doesn't hurt for us to always output "0x".

12 years agocleanup: Don't include libvirt/virterror.h
Osier Yang [Tue, 16 Apr 2013 13:41:46 +0000 (21:41 +0800)]
cleanup: Don't include libvirt/virterror.h

Which is already included in "internal.h", later patch will add
syntax-check to avoid it.

12 years agocleanup: Don't include libvirt/libvirt.h
Osier Yang [Tue, 16 Apr 2013 13:41:45 +0000 (21:41 +0800)]
cleanup: Don't include libvirt/libvirt.h

Which is already included by "internal.h", later patch will add
syntax-check to avoid it.

12 years agocleanup: Remove the duplicate header
Osier Yang [Tue, 16 Apr 2013 13:41:43 +0000 (21:41 +0800)]
cleanup: Remove the duplicate header

Detected by a simple Shell script:

for i in $(git ls-files -- '*.[ch]'); do
    awk 'BEGIN {
        fail=0
    }
    /# *include.*\.h/{
        match($0, /["<][^">]*[">]/)
        arr[substr($0, RSTART+1, RLENGTH-2)]++
    }
    END {
        for (key in arr) {
            if (arr[key] > 1) {
                fail=1
                printf("%d %s\n", arr[key], key)
            }
        }
        if (fail == 1)
            exit 1
    }' $i

    if test $? != 0; then
        echo "Duplicate header(s) in $i"
    fi
done;

A later patch will add the syntax-check to avoid duplicate
headers.

12 years agocleanup: Only include testutils.h once
Osier Yang [Tue, 16 Apr 2013 13:41:44 +0000 (21:41 +0800)]
cleanup: Only include testutils.h once

No reason to include it in both "if" and "else" branches.

12 years agoFix compilation error in util/vircgroup.c
Stefan Berger [Tue, 16 Apr 2013 12:16:37 +0000 (08:16 -0400)]
Fix compilation error in util/vircgroup.c

Fix the error

util/vircgroup.c: In function 'virCgroupNewDomainPartition':
util/vircgroup.c:1299:11: error: declaration of 'dirname' shadows a global declaration [-Werror=shadow]

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
12 years agoFix build breaker with ATTRIBUTE_NONNULL defs
John Ferlan [Tue, 16 Apr 2013 11:17:00 +0000 (07:17 -0400)]
Fix build breaker with ATTRIBUTE_NONNULL defs

Using "./autogen.sh --system lv_cv_static_analysis=yes" for my daily
Coverity builds resulted in the following error when building:

In file included from util/vircgrouppriv.h:32:0,
                 from util/vircgroup.c:44:
util/vircgroup.h:59:5: error: nonnull argument with out-of-range operand number (argument 1, operand 5)
util/vircgroup.h:74:5: error: nonnull argument references non-pointer operand (argument 1, operand 4)
make[3]: *** [libvirt_util_la-vircgroup.lo] Error 1
make[3]: Leaving directory `/home/jferlan/libvirt.cov.curr/src'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/home/jferlan/libvirt.cov.curr/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/jferlan/libvirt.cov.curr'
make: *** [all] Error 2

12 years agoResolve valgrind error
John Ferlan [Mon, 15 Apr 2013 15:50:59 +0000 (11:50 -0400)]
Resolve valgrind error

Commit id '1acfc171' resulted in the following valgrind failure:

==25317== 136 (24 direct, 112 indirect) bytes in 1 blocks are definitely lost in loss record 4 of 4
==25317==    at 0x4A06B6F: calloc (vg_replace_malloc.c:593)
==25317==    by 0x4C6F851: virAlloc (viralloc.c:124)
==25317==    by 0x4C71493: virBitmapNew (virbitmap.c:74)
==25317==    by 0x4C71B79: virBitmapNewData (virbitmap.c:434)
==25317==    by 0x402EF2: test8 (virbitmaptest.c:436)
==25317==    by 0x40499F: virtTestRun (testutils.c:157)
==25317==    by 0x402E8D: mymain (virbitmaptest.c:474)
==25317==    by 0x404FDA: virtTestMain (testutils.c:719)
==25317==    by 0x39D0821A04: (below main) (in /usr/lib64/libc-2.16.so)

12 years agoCheck for unsupported QMP command
Stefan Berger [Tue, 16 Apr 2013 11:05:21 +0000 (07:05 -0400)]
Check for unsupported QMP command

Check for an unsupported QMP command when using the query-tpm-models
and query-tpm-types commands before checking for general errors
in order to avoid error messages in the log.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
12 years agoRevert checking for QMP query-tpm-models
Stefan Berger [Tue, 16 Apr 2013 11:05:21 +0000 (07:05 -0400)]
Revert checking for QMP query-tpm-models

Revert the patch checking for the QMP query-tpm-models
command.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
12 years agoqemu_agent: Add support for appending arrays to commands
Peter Krempa [Mon, 15 Apr 2013 15:00:04 +0000 (17:00 +0200)]
qemu_agent: Add support for appending arrays to commands

Add support for array elements for agent commands just like 64d5e815 did for
monitor commands

12 years agolib: Fix docs about return value of virDomainGetVcpusFlags()
Peter Krempa [Mon, 15 Apr 2013 09:04:56 +0000 (11:04 +0200)]
lib: Fix docs about return value of virDomainGetVcpusFlags()

The return value description stated that 0 is returned in case of success
instead of the count of vCPUs.

12 years agoCheck for QMP query-tpm-models
Stefan Berger [Mon, 15 Apr 2013 20:46:53 +0000 (16:46 -0400)]
Check for QMP query-tpm-models

Check for QMP query-tpm-models and set a capability flag. Do not use
this QMP command if it is not supported.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
12 years agoAdd support for perf_event and net_cls cgroup controllers
Daniel P. Berrange [Mon, 15 Apr 2013 14:17:33 +0000 (15:17 +0100)]
Add support for perf_event and net_cls cgroup controllers

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoReplace LXC cgroup mount code with call to virCgroupIsolateMount
Daniel P. Berrange [Fri, 5 Apr 2013 11:50:27 +0000 (12:50 +0100)]
Replace LXC cgroup mount code with call to virCgroupIsolateMount

The LXC driver currently has code to detect cgroups mounts
and then re-mount them inside the new root filesystem. Replace
this fragile code with a call to virCgroupIsolateMount.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoAdd an API for re-mounting cgroups, to isolate the process location
Daniel P. Berrange [Fri, 5 Apr 2013 11:48:47 +0000 (12:48 +0100)]
Add an API for re-mounting cgroups, to isolate the process location

Add a virCgroupIsolateMount method which looks at where the
current process is place in the cgroups (eg /system/demo.lxc.libvirt)
and then remounts the cgroups such that this sub-directory
becomes the root directory from the current process' POV.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoTrack symlinks for co-mounted cgroup controllers
Daniel P. Berrange [Fri, 5 Apr 2013 10:28:04 +0000 (11:28 +0100)]
Track symlinks for co-mounted cgroup controllers

If a cgroup controller is co-mounted with another, eg

   /sys/fs/cgroup/cpu,cpuacct

Then it is a requirement that there exist symlinks at

   /sys/fs/cgroup/cpu
   /sys/fs/cgroup/cpuacct

pointing to the real mount point. Add support to virCgroupPtr
to detect and track these symlinks

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoRemove non-functional code for setting up non-root cgroups
Daniel P. Berrange [Thu, 4 Apr 2013 11:10:55 +0000 (12:10 +0100)]
Remove non-functional code for setting up non-root cgroups

The virCgroupNewDriver method had a 'bool privileged' param.
If a false value was ever passed in, it would simply not
work, since non-root users don't have any privileges to create
new cgroups. Just delete this broken code entirely and make
the QEMU driver skip cgroup setup in non-privileged mode

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoChange default cgroup layout for QEMU/LXC and honour XML config
Daniel P. Berrange [Wed, 3 Apr 2013 10:01:49 +0000 (11:01 +0100)]
Change default cgroup layout for QEMU/LXC and honour XML config

Historically QEMU/LXC guests have been placed in a cgroup layout
that is

   $LOCATION-OF-LIBVIRTD/libvirt/{qemu,lxc}/$VMNAME

This is bad for a number of reasons

 - The cgroup hierarchy gets very deep which seriously
   impacts kernel performance due to cgroups scalability
   limitations.

 - It is hard to setup cgroup policies which apply across
   services and virtual machines, since all VMs are underneath
   the libvirtd service.

To address this the default cgroup location is changed to
be

    /system/$VMNAME.{lxc,qemu}.libvirt

This puts virtual machines at the same level in the hierarchy
as system services, allowing consistent policy to be setup
across all of them.

This also honours the new resource partition location from the
XML configuration, for example

  <resource>
    <partition>/virtualmachines/production</partitions>
  </resource>

will result in the VM being placed at

    /virtualmachines/production/$VMNAME.{lxc,qemu}.libvirt

NB, with the exception of the default, /system, path which
is intended to always exist, libvirt will not attempt to
auto-create the partitions in the XML. It is the responsibility
of the admin/app to configure the partitions. Later libvirt
APIs will provide a way todo this.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoAdd XML config for resource partitions
Daniel P. Berrange [Thu, 21 Mar 2013 11:28:10 +0000 (11:28 +0000)]
Add XML config for resource partitions

Allow VMs to be placed into resource groups using the
following syntax

  <resource>
    <partition>/virtualmachines/production</partition>
  </resource>

A resource cgroup will be backed by some hypervisor specific
functionality, such as cgroups with KVM/LXC.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoAdd a new virCgroupNewPartition for setting up resource partitions
Daniel P. Berrange [Thu, 28 Mar 2013 18:08:39 +0000 (18:08 +0000)]
Add a new virCgroupNewPartition for setting up resource partitions

A resource partition is an absolute cgroup path, ignoring the
current process placement. Expose a virCgroupNewPartition API
for constructing such cgroups

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoCleanup if creating cgroup directories fails
Daniel P. Berrange [Wed, 3 Apr 2013 17:08:41 +0000 (18:08 +0100)]
Cleanup if creating cgroup directories fails

Currently if virCgroupMakeGroup fails, we can get in a situation
where some controllers have been setup, but others not. Ensure
we call virCgroupRemove to remove what we've done upon failure

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoAdd misc extra debugging into cgroups code
Daniel P. Berrange [Wed, 3 Apr 2013 17:06:41 +0000 (18:06 +0100)]
Add misc extra debugging into cgroups code

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoRefactor cgroups internal data structures
Daniel P. Berrange [Fri, 22 Mar 2013 11:11:34 +0000 (11:11 +0000)]
Refactor cgroups internal data structures

Currently the virCgroupPtr struct contains 3 pieces of
information

 - path - path of the cgroup, relative to current process'
   cgroup placement
 - placement - current process' placement in each controller
 - mounts - mount point of each controller

When reading/writing cgroup settings, the path & placement
strings are combined to form the file path. This approach
only works if we assume all cgroups will be relative to
the current process' cgroup placement.

To allow support for managing cgroups at any place in the
heirarchy a change is needed. The 'placement' data should
reflect the absolute path to the cgroup, and the 'path'
value should no longer be used to form the paths to the
cgroup attribute files.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoAdd a test suite for cgroups functionality
Daniel P. Berrange [Thu, 28 Mar 2013 14:36:52 +0000 (14:36 +0000)]
Add a test suite for cgroups functionality

Some aspects of the cgroups setup / detection code are quite subtle
and easy to break. It would greatly benefit from unit testing, but
this is difficult because the test suite won't have privileges to
play around with cgroups. The solution is to use monkey patching
via LD_PRELOAD to override the fopen, open, mkdir, access functions
to redirect access of cgroups files to some magic stubs in the
test suite.

Using this we provide custom content for the /proc/cgroup and
/proc/self/mounts files which report a fixed cgroup setup. We
then override open/mkdir/access so that access to the cgroups
filesystem gets redirected into files in a temporary directory
tree in the test suite build dir.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoRename virCgroupForXXX to virCgroupNewXXX
Daniel P. Berrange [Thu, 28 Mar 2013 16:33:22 +0000 (16:33 +0000)]
Rename virCgroupForXXX to virCgroupNewXXX

Rename all the virCgroupForXXX methods to use the form
virCgroupNewXXX since they are all constructors. Also
make sure the output parameter is the last one in the
list, and annotate all pointers as non-null. Fix up
all callers, and make sure they use true/false not 0/1
for the boolean parameters

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoPull definition of structs out of vircgroup.c to vircgrouppriv.h
Daniel P. Berrange [Thu, 28 Mar 2013 14:32:23 +0000 (14:32 +0000)]
Pull definition of structs out of vircgroup.c to vircgrouppriv.h

The definition of structs for cgroups are kept in vircgroup.c since
they are intended to be private from users of the API. To enable
effective testing, however, they need to be accessible. To address
the latter issue, without compronmising the former, this introduces
a new vircgrouppriv.h file to hold the struct definitions.

To prevent other files including this private header, it requires
that __VIR_CGROUP_ALLOW_INCLUDE_PRIV_H__ be defined before inclusion

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoStore a virCgroupPtr instance in virLXCDomainObjPrivatePtr
Daniel P. Berrange [Thu, 21 Mar 2013 14:40:29 +0000 (14:40 +0000)]
Store a virCgroupPtr instance in virLXCDomainObjPrivatePtr

Instead of calling virCgroupForDomain every time we need
the virCgrouPtr instance, just do it once at Vm startup
and cache a reference to the object in virLXCDomainObjPrivatePtr
until shutdown of the VM. Removing the virCgroupPtr from
the LXC driver state also means we don't have stale mount
info, if someone mounts the cgroups filesystem after libvirtd
has been started

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoStore a virCgroupPtr instance in qemuDomainObjPrivatePtr
Daniel P. Berrange [Thu, 21 Mar 2013 14:40:29 +0000 (14:40 +0000)]
Store a virCgroupPtr instance in qemuDomainObjPrivatePtr

Instead of calling virCgroupForDomain every time we need
the virCgrouPtr instance, just do it once at Vm startup
and cache a reference to the object in qemuDomainObjPrivatePtr
until shutdown of the VM. Removing the virCgroupPtr from
the QEMU driver state also means we don't have stale mount
info, if someone mounts the cgroups filesystem after libvirtd
has been started

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoAdd missing param to virCgroupForDriver stub
Daniel P. Berrange [Mon, 15 Apr 2013 16:06:19 +0000 (17:06 +0100)]
Add missing param to virCgroupForDriver stub

The virCgroupForDriver method recently gained an 'int controllers'
parameter, but the stub impl did not

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoIntroduce a virFileDeleteTree method
Daniel P. Berrange [Thu, 28 Mar 2013 14:46:45 +0000 (14:46 +0000)]
Introduce a virFileDeleteTree method

Introduce a method virFileDeleteTree for recursively deleting
an entire directory tree

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoConditionally compile storagevolxml2argvtest
Daniel P. Berrange [Mon, 15 Apr 2013 16:01:02 +0000 (17:01 +0100)]
Conditionally compile storagevolxml2argvtest

Only compile storagevolxml2argvtest if WITH_STORAGE is
set, because it links to that driver

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoConditionalize use of symlink() function in test suite
Daniel P. Berrange [Mon, 15 Apr 2013 16:00:17 +0000 (17:00 +0100)]
Conditionalize use of symlink() function in test suite

On Win32 symlink() is not available, so virstoragetest.c
must be conditionalized to avoid compile failures.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix signature of dummy virNetlinkCommand stub
Daniel P. Berrange [Mon, 15 Apr 2013 15:59:36 +0000 (16:59 +0100)]
Fix signature of dummy virNetlinkCommand stub

The second param of virNetlinkCommand should be
struct nlmsghdr, not unsigned char.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoAdd empty stub for virThreadCancel on Win32
Daniel P. Berrange [Mon, 15 Apr 2013 15:58:56 +0000 (16:58 +0100)]
Add empty stub for virThreadCancel on Win32

Win32 does not like undefined symbols, so define an
empty virThreadCancel impl.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoDon't enable -fPIE on Win32 platforms
Daniel P. Berrange [Mon, 15 Apr 2013 15:56:38 +0000 (16:56 +0100)]
Don't enable -fPIE on Win32 platforms

On win32, all code is position independent and adding -fPIE
to the compiler flags results in warnings being printed

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agomaint: update to latest gnulib
Eric Blake [Mon, 15 Apr 2013 14:54:53 +0000 (08:54 -0600)]
maint: update to latest gnulib

Upstream gnulib determined that we were needlessly compiling in
gnulib's regex instead of glibc's when targetting new-enough glibc,
because the m4 test was being too strict in requiring a particular
answer to undefined behavior.
https://lists.gnu.org/archive/html/bug-gnulib/2013-04/msg00032.html

* .gnulib: Update to latest, for regex.

12 years agoUse unsigned int instead of unsigned
Osier Yang [Mon, 15 Apr 2013 10:29:23 +0000 (18:29 +0800)]
Use unsigned int instead of unsigned

Though they are the same thing, mixed use of them is uncomfortable.
"unsigned" is used a lot in old codes, this just tries to change the
ones in utils.

12 years agoDo more complete initialization of libgcrypt
Daniel P. Berrange [Fri, 12 Apr 2013 16:25:03 +0000 (17:25 +0100)]
Do more complete initialization of libgcrypt

If libvirt makes any gcry_control() calls, then this
prevents gnutls for doing any initialization. As such
we must take care to do full initialization of libcrypt
on a par with what gnutls would have done. In particular
we must disable "sec mem" for cases where the user does
not have mlock() permission. We also skip our init of
libgcrypt if something else (ie the app using libvirt)
has beaten us to it.

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

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoqemu: Report also domain name in error message when domain object wasn't found
Peter Krempa [Wed, 10 Apr 2013 12:06:38 +0000 (14:06 +0200)]
qemu: Report also domain name in error message when domain object wasn't found

Report the errors as:
Domain not found: no domain with matching uuid '41414141-4141-4141-4141-414141414141' (crashtest)
instead of:
Domain not found: no domain with matching uuid '41414141-4141-4141-4141-414141414141'

12 years agoqemu: Refactor lookup of domain object
Peter Krempa [Wed, 10 Apr 2013 12:04:45 +0000 (14:04 +0200)]
qemu: Refactor lookup of domain object

Use the helper to lookup the domain object in the remaining places.

This patch also fixes error reporting when the domain was not found in several
functions that were printing the raw UUID buffer instead of the formatted
string. The offending functions were:

qemuDomainGetInterfaceParameters
qemuDomainSetInterfaceParameters
qemuGetSchedulerParametersFlags
qemuSetSchedulerParametersFlags
qemuDomainGetNumaParameters
qemuDomainSetNumaParameters
qemuDomainGetMemoryParameters
qemuDomainSetMemoryParameters
qemuDomainGetBlkioParameters
qemuDomainSetBlkioParameters
qemuDomainGetCPUStats

12 years agostorage: Fix the indention
Osier Yang [Sat, 13 Apr 2013 07:22:01 +0000 (15:22 +0800)]
storage: Fix the indention

Pushed under trivial rule

12 years agocleanup: Change datatype of net->stp to boolean
Osier Yang [Fri, 12 Apr 2013 09:08:59 +0000 (17:08 +0800)]
cleanup: Change datatype of net->stp to boolean

12 years agocleanup: Change datatype of usbdev->allow to boolean
Osier Yang [Fri, 12 Apr 2013 08:51:36 +0000 (16:51 +0800)]
cleanup: Change datatype of usbdev->allow to boolean

12 years agocleanup: Change datatype of graphic's members to boolean
Osier Yang [Fri, 12 Apr 2013 08:49:38 +0000 (16:49 +0800)]
cleanup: Change datatype of graphic's members to boolean

12 years agocleanup: Change datatype of accel's members to boolean
Osier Yang [Thu, 11 Apr 2013 04:10:37 +0000 (12:10 +0800)]
cleanup: Change datatype of accel's members to boolean

12 years agoAdd test case for TPM passthrough
Stefan Berger [Fri, 12 Apr 2013 20:55:46 +0000 (16:55 -0400)]
Add test case for TPM passthrough

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Tested-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
12 years agoTPM support for QEMU command line
Stefan Berger [Fri, 12 Apr 2013 20:55:46 +0000 (16:55 -0400)]
TPM support for QEMU command line

For TPM passthrough device support create command line parameters like:

-tpmdev passthrough,id=tpm-tpm0,path=/dev/tpm0,cancel-path=/sys/class/misc/tpm0/device/cancel -device tpm-tis,tpmdev=tpm-tpm0,id=tpm0

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Tested-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
12 years agoQEMU Cgroup support for TPM passthrough
Stefan Berger [Fri, 12 Apr 2013 20:55:46 +0000 (16:55 -0400)]
QEMU Cgroup support for TPM passthrough

Some refactoring for virDomainChrSourceDef type of devices so
we can use common code.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Tested-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
12 years agoAudit the starting of a guest using TPM passthrough
Stefan Berger [Fri, 12 Apr 2013 20:55:46 +0000 (16:55 -0400)]
Audit the starting of a guest using TPM passthrough

When a VM with a TPM passthrough device is started, the audit daemon
logs the following type of message:

type=VIRT_RESOURCE msg=audit(1365170222.460:3378): pid=16382 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:virtd_t:s0-s0:c0.c1023 msg='virt=kvm resrc=dev reason=start vm="TPM-PT" uuid=a4d7cd22-da89-3094-6212-079a48a309a1 device="/dev/tpm0" exe="/usr/sbin/libvirtd" hostname=? addr=? terminal=? res=success'

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Tested-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
12 years agoAdd SELinux and DAC labeling support for TPM passthrough
Stefan Berger [Fri, 12 Apr 2013 20:55:46 +0000 (16:55 -0400)]
Add SELinux and DAC labeling support for TPM passthrough

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Tested-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
12 years agoConvert QMP strings into QEMU capability bits
Stefan Berger [Fri, 12 Apr 2013 20:55:45 +0000 (16:55 -0400)]
Convert QMP strings into QEMU capability bits

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Tested-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
12 years agoParse TPM passthrough XML in the domain XML
Stefan Berger [Fri, 12 Apr 2013 20:55:45 +0000 (16:55 -0400)]
Parse TPM passthrough XML in the domain XML

Parse the domain XML with TPM passthrough support.
The TPM passthrough XML may look like this:

    <tpm model='tpm-tis'>
      <backend type='passthrough'>
        <device path='/dev/tpm0'/>
      </backend>
    </tpm>

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Tested-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
12 years agoHelper functions for host TPM support
Stefan Berger [Fri, 12 Apr 2013 20:55:45 +0000 (16:55 -0400)]
Helper functions for host TPM support

Implement helper function to create the TPM's sysfs cancel file.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Tested-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
12 years agoAdd documentation and schema for TPM passthrough
Stefan Berger [Fri, 12 Apr 2013 20:55:45 +0000 (16:55 -0400)]
Add documentation and schema for TPM passthrough

Supported TPM passthrough XML may look as follows:

    <tpm model='tpm-tis'>
      <backend type='passthrough'>
        <device path='/dev/tpm0'/>
      </backend>
    </tpm>

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Tested-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
12 years agoAdd function to find a needle in a string array
Stefan Berger [Fri, 12 Apr 2013 20:55:45 +0000 (16:55 -0400)]
Add function to find a needle in a string array

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Tested-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
12 years agoAdd QMP probing for TPM
Stefan Berger [Fri, 12 Apr 2013 20:55:45 +0000 (16:55 -0400)]
Add QMP probing for TPM

Probe for QEMU's QMP TPM support by querying the lists of
supported TPM models (query-tpm-models) and backend types
(query-tpm-types).

The setting of the capability flags following the strings
returned from the commands above is only provided in the
patch where domain_conf.c gets TPM support due to dependencies
on functions only introduced there.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Tested-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
12 years agoconf: Allow for non-contiguous device boot orders
Peter Krempa [Thu, 4 Apr 2013 13:29:16 +0000 (15:29 +0200)]
conf: Allow for non-contiguous device boot orders

This patch adds the ability to configure non-contiguous boot orders on boot
devices. This allows unplugging devices that have boot order specified without
breaking migration.

The new code now uses a slightly less memory efficient approach to store the
boot order fields in a hashtable instead of a bitmap.

12 years agoTweak EOF handling of streams
Daniel P. Berrange [Tue, 9 Apr 2013 12:24:02 +0000 (13:24 +0100)]
Tweak EOF handling of streams

Typically when you get EOF on a stream, poll will return
POLLIN|POLLHUP at the same time. Thus when we deal with
stream reads, if we see EOF during the read, we can then
clear the VIR_STREAM_EVENT_HANGUP & VIR_STREAM_EVENT_ERROR
event bits.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoAdd USB option capability
Li Zhang [Sun, 7 Apr 2013 08:31:57 +0000 (16:31 +0800)]
Add USB option capability

To avoid the collision for creating USB controllers in machine->init()
and -device xx command line, it needs to set usb=off to avoid one USB
controller created in machine->init(). So that libvirt can use -device
or -usb to create USB controller sucessfully.
So QEMU_CAPS_MACHINE_USB_OPT capability is added, and it is for QEMU
v1.3.0 onwards which supports USB option.

Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com>
12 years agoAdd error handling to optional arguments in cmdCPUStats
John Ferlan [Mon, 8 Apr 2013 14:49:34 +0000 (10:49 -0400)]
Add error handling to optional arguments in cmdCPUStats

12 years agoRemove extraneous comma in info_cpu_stats and opts_cpu_stats
John Ferlan [Mon, 8 Apr 2013 14:15:42 +0000 (10:15 -0400)]
Remove extraneous comma in info_cpu_stats and opts_cpu_stats

12 years agoqemu: Do not report unsafe migration for local files
Jiri Denemark [Thu, 11 Apr 2013 16:28:35 +0000 (18:28 +0200)]
qemu: Do not report unsafe migration for local files

When migrating a domain with disk images stored locally (and using
storage migration), we should not complain about unsafe migration no
matter what cache policy is used for that disk.

12 years agovirsh: Document that using incomplete XML files may have unexpected results
Peter Krempa [Thu, 11 Apr 2013 14:27:23 +0000 (16:27 +0200)]
virsh: Document that using incomplete XML files may have unexpected results

Explicitly state that using incomplete XML definition snippets for hot-management
commands may have unexpected results due to autogenerating values for some of
the fields if they aren't specified explicitly.

12 years agoqemu: Try to use QMP for send-key if supported
Peter Krempa [Thu, 11 Apr 2013 12:33:43 +0000 (14:33 +0200)]
qemu: Try to use QMP for send-key if supported

Instead of always using HMP use the QMP send-key command introduced in qemu 1.3.

12 years agovirsh: Update list of shutdown/reboot modes
Michal Privoznik [Thu, 11 Apr 2013 11:03:55 +0000 (13:03 +0200)]
virsh: Update list of shutdown/reboot modes

As of 76d9f65644 we are supporting two new modes: initctl and signal.
However, these are missing in help listing.

12 years agoqemu: Set correct migrate host in client_migrate_info
Michal Privoznik [Wed, 10 Apr 2013 15:16:06 +0000 (17:16 +0200)]
qemu: Set correct migrate host in client_migrate_info

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

Currently, we are discarding listen attribute from qemu cookie even though
we strive to gather it. This result in not so cool bug: if user have
different networks, one for management/migration, and one for VNC/SPICE we
pass incorrect host to the qemu in client_migrate_info. What we actually
pass is remote hostname, while we should be passing remote listen address.
It doesn't matter as long as these two are the same, but they don't need
necessary to be like that.

12 years agoqemu: fix crash in qemuOpen
Ján Tomko [Thu, 11 Apr 2013 09:37:25 +0000 (11:37 +0200)]
qemu: fix crash in qemuOpen

If the path part of connection URI is not present, cfg is used
unitialized.

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

12 years agoconf: fix error for parallel port mismatch
Ján Tomko [Thu, 11 Apr 2013 07:13:32 +0000 (09:13 +0200)]
conf: fix error for parallel port mismatch

12 years agocleanup: Change datatype of secret->private to boolean
Osier Yang [Thu, 11 Apr 2013 03:54:37 +0000 (11:54 +0800)]
cleanup: Change datatype of secret->private to boolean

12 years agocleanup: Change datatype of secret->ephemeral to boolean
Osier Yang [Thu, 11 Apr 2013 03:50:23 +0000 (11:50 +0800)]
cleanup: Change datatype of secret->ephemeral to boolean

12 years agocleanup: Change datatype of fs->readonly to boolean
Osier Yang [Wed, 10 Apr 2013 12:15:31 +0000 (20:15 +0800)]
cleanup: Change datatype of fs->readonly to boolean

12 years agocleanup: Change datatype of disk->readonly to boolean
Osier Yang [Wed, 10 Apr 2013 11:23:56 +0000 (19:23 +0800)]
cleanup: Change datatype of disk->readonly to boolean

12 years agocleanup: Change datatype of disk->transient to boolean
Osier Yang [Wed, 10 Apr 2013 11:01:48 +0000 (19:01 +0800)]
cleanup: Change datatype of disk->transient to boolean

12 years agocleanup: Change datatype of disk->shared to boolean
Osier Yang [Wed, 10 Apr 2013 10:59:44 +0000 (18:59 +0800)]
cleanup: Change datatype of disk->shared to boolean

12 years agocleanup: Change datatype of auth->expires to boolean
Osier Yang [Wed, 10 Apr 2013 10:54:17 +0000 (18:54 +0800)]
cleanup: Change datatype of auth->expires to boolean

12 years agocleanup: Change datatype of hostdev->missing to boolean
Osier Yang [Wed, 10 Apr 2013 10:46:56 +0000 (18:46 +0800)]
cleanup: Change datatype of hostdev->missing to boolean

12 years agoCleanup: Change datatype of origstate's members to boolean
Osier Yang [Wed, 10 Apr 2013 10:44:41 +0000 (18:44 +0800)]
Cleanup: Change datatype of origstate's members to boolean

Members of struct virPCIDevice are changed together.

12 years agoCleanup: Change datatype of hostdev->managed to boolean
Osier Yang [Wed, 10 Apr 2013 10:09:23 +0000 (18:09 +0800)]
Cleanup: Change datatype of hostdev->managed to boolean

12 years agoconf: fix a memory leak when parsing nat port XML nodes
Guannan Ren [Wed, 10 Apr 2013 09:38:07 +0000 (17:38 +0800)]
conf: fix a memory leak when parsing nat port XML nodes

 ==5306== 8 bytes in 1 blocks are definitely lost in loss record 24 of 277
 ==5306==    at 0x4C28B2F: calloc (vg_replace_malloc.c:593)
 ==5306==    by 0x5293CAF: virAllocN (viralloc.c:152)
 ==5306==    by 0x52DFEAE: virXPathNodeSet (virxml.c:611)
 ==5306==    by 0x5313DD9: virNetworkDefParseXML (network_conf.c:1408)
 ==5306==    by 0x53170F6: virNetworkObjUpdateParseFile (network_conf.c:2031)
 ==5306==    by 0x131DA63C: networkStartup (bridge_driver.c:279)
 ==5306==    by 0x53481DF: virStateInitialize (libvirt.c:822)
 ==5306==    by 0x40DF44: daemonRunStateInit (libvirtd.c:877)
 ==5306==    by 0x52D2FF5: virThreadHelper (virthreadpthread.c:161)
 ==5306==    by 0x5D00C52: start_thread (in /usr/lib64/libpthread-2.17.so)
 ==5306==    by 0x6410ECC: clone (in /usr/lib64/libc-2.17.so)

12 years agoconf: Fix race between looking up a domain object and freeing it
Peter Krempa [Tue, 9 Apr 2013 11:56:26 +0000 (13:56 +0200)]
conf: Fix race between looking up a domain object and freeing it

This patch fixes crash of the daemon that happens due to the following race
condition:

Let's have two threads in the libvirtd daemon's qemu driver:
A - thread executing undefine on the same domain
B - thread executing a API call to get information about a domain

Assume following serialization of operations done by the threads:
1) A has the lock on the domain object and is executing some code prior to
   virDomainObjListRemove()
2) B takes the lock on the domain object list, looks up the domain object
pointer and blocks in the attempt to lock the domain object as A is holding the
lock
3) A reaches virDomainObjListRemove() and unlocks the lock on the domain object
4) A blocks on the attempt to get the domain list lock
5) B is able to lock the domain object now and unlocks the domain list
6) A is now able to lock the domain list, and sheds the last reference on the
domain object, this triggers the freeing function.
6) B starts executing the code on the pointer that is being freed
7) The libvirtd daemon crashes while attempting to access invalid pointer in
thread B.

This patch fixes the race by acquiring a reference on the domain object before
unlocking it in virDomainObjListRemove() and re-locks the object prior to
removing and freeing it. This ensures that no thread holds a lock on the domain
object at the time it is removed from the list, and that doing a list lookup
will never find a domain that is about to vanish.

This is a minimal fix of the problem, but a better solution will be to switch to
full reference counting for domain objects.

12 years agodocs: fix typo when using Kerberos principals
Eric Blake [Tue, 9 Apr 2013 22:39:19 +0000 (16:39 -0600)]
docs: fix typo when using Kerberos principals

Kerberos uses 'primary' or 'key' files (principals), not 'abstract
ideal' or 'rule' files (principles).  Reported by Jason Meinzer.

Reflow a paragraph to fit in 80 columns in the process.

* docs/auth.html.in: Fix spelling.

12 years agomaint: update to latest gnulib
Eric Blake [Mon, 1 Apr 2013 18:49:05 +0000 (12:49 -0600)]
maint: update to latest gnulib

While this update doesn't address any reported problems in libvirt,
doing a post-release update to latest gnulib makes it easier to
stay in sync with best upstream practices.

* .gnulib: Update to latest.
* bootstrap: Resynchronize.

12 years agoFix crash in virNetDevGetVirtualFunctions
Laine Stump [Tue, 9 Apr 2013 18:06:51 +0000 (14:06 -0400)]
Fix crash in virNetDevGetVirtualFunctions

Commit 9a3ff01d7f16cc280ce3176620c0714f55511a65 (which was ACKed at
the end of January, but for some reason didn't get pushed until during
the 1.0.4 freeze) fixed the logic in virPCIGetVirtualFunctions().
Unfortunately, a typo in the fix (replacing VIR_REALLOC_N with
VIR_ALLOC_N during code movement) caused not only a memory leak, but
also resulted in most of the elements of the result array being
replaced with NULL. virNetDevGetVirtualFunctions() assumed (and I think
rightly so) that virPCIGetVirtualFunctions() wouldn't return any NULL
elements in the array, so it ended up segfaulting.

This was found when attempting to use a virtual network with an
auto-created pool of SRIOV VFs, e.g.:

    <forward mode='hostdev' managed='yes'>
      <pf dev='eth4'/>
    </forward>

(the pool of PCI addresses is discovered by calling
virNetDevGetVirtualFunctions() on the PF dev).