]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
12 years agobuild: clean up stray files found by 'make distcheck'
Eric Blake [Mon, 6 May 2013 16:21:55 +0000 (10:21 -0600)]
build: clean up stray files found by 'make distcheck'

'make distcheck' complained:

ERROR: files left in build directory after distclean:
./python/libvirt.pyc
./tests/commandhelper.log

Problems introduced in commits f015495 and 25ea8e4 (both v1.0.3).

* tests/commandtest.c (test21): Check (and clean) log file.
* tests/commanddata/test21.log: New file.
* python/Makefile.am (CLEANFILES): Clean up compiled python files.

Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agobuild: always include libvirt_lxc.syms in tarball
Eric Blake [Thu, 2 May 2013 23:35:50 +0000 (17:35 -0600)]
build: always include libvirt_lxc.syms in tarball

On a mingw build, 'make distcheck' fails with:

  GEN      libvirt_qemu.def
make[3]: *** No rule to make target `../../src/libvirt_lxc.syms', needed by `libvirt_lxc.def'.  Stop.

I traced it to a missing entry in EXTRA_DIST.  But rather than keep
the entire list in sync, it is easier to list the three syms files
that drive .so files directly, and then reuse existing makefile
variables for the remaining files (that is, I validated that all
remaining files are added to SYM_FILES, possibly via USED_SYM_FILES,
according to makefile conditionals).

Problem introduced in commit 3d1596b (v1.0.2).

* src/Makefile.am (EXTRA_DIST): Ensure all syms files are shipped.

Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agoAdapt to VIR_STRDUP and VIR_STRNDUP in daemon/*
Michal Privoznik [Fri, 3 May 2013 12:39:39 +0000 (14:39 +0200)]
Adapt to VIR_STRDUP and VIR_STRNDUP in daemon/*

12 years agovirstring: Introduce VIR_STRDUP and VIR_STRNDUP
Michal Privoznik [Wed, 3 Apr 2013 12:51:20 +0000 (14:51 +0200)]
virstring: Introduce VIR_STRDUP and VIR_STRNDUP

The code adaptation is not done right now, but in subsequent patches.
Hence I am not implementing syntax-check rule as it would break
compilation. Developers are strongly advised to use these new macros.
They are similar to VIR_ALLOC() logic: VIR_STRDUP(dst, src) returns zero
on success, -1 otherwise. In case you don't want to report OOM error,
use the _QUIET variant of a macro.

12 years agoFix a few more docs XSL bugs related to the TOC
Daniel P. Berrange [Fri, 3 May 2013 19:56:04 +0000 (20:56 +0100)]
Fix a few more docs XSL bugs related to the TOC

Add missing 'html:' namespace prefix to a few more XSL
rules for generating the table of contents links

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoqemu: fix stupid typos in VFIO cgroup setup/teardown
Laine Stump [Fri, 3 May 2013 18:30:55 +0000 (14:30 -0400)]
qemu: fix stupid typos in VFIO cgroup setup/teardown

I must have looked at this a couple dozen times before I noticed it
had "!=" instead of "==". Not doing this setup prevented qemu from
doing anything with the vfio group device.

12 years agoFix docs generator regression in previous commit
Daniel P. Berrange [Fri, 3 May 2013 15:57:05 +0000 (16:57 +0100)]
Fix docs generator regression in previous commit

The previous commit failed to update the XSL to take account
of fact that in XHTML mode the elements need namespace
prefixes. This caused every web page to be blank!

12 years agoFix multiple formatting problems in HTML docs
Daniel P. Berrange [Fri, 3 May 2013 14:25:37 +0000 (15:25 +0100)]
Fix multiple formatting problems in HTML docs

The rule generating the HTML docs passing the --html flag
to xsltproc. This makes it use the legacy HTML parser, which
either ignores or tries to fix all sorts of broken XML tags.
There's no reason why we should be writing broken XML in
the first place, so removing --html and adding the XHTML
doctype to all files forces us to create good XML.

This adds the XHTML doc type and fixes many, many XML tag
problems it exposes.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoMake detect_scsi_host_caps a function on all architectures
Guido Günther [Fri, 3 May 2013 06:03:26 +0000 (08:03 +0200)]
Make detect_scsi_host_caps a function on all architectures

In the non linux case some callers like gather_scsi_host_caps needed the
return code of -1 while others like update_caps needed an empty
statement (to avoid a "statement without effect" warning). This is much
simpler solved by using a function instead of a define.

12 years agoFixup rpcgen code on kFreeBSD too
Guido Günther [Fri, 3 May 2013 05:17:18 +0000 (07:17 +0200)]
Fixup rpcgen code on kFreeBSD too

since it uses glibc's rpcgen.

12 years agoIgnore 'uri' parameter in lockd driver
Daniel P. Berrange [Fri, 3 May 2013 13:23:03 +0000 (14:23 +0100)]
Ignore 'uri' parameter in lockd driver

A 'uri' parameter was added for the benefit of sanlock. This
causes a warning in the lockd driver though

2013-05-03 13:20:35.347+0000: 28403: error : virLockManagerLockDaemonNew:482 : internal error Unexpected parameter uri for object

Ignore this parameter, since lockd does not require it and it
is harmless if not used.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agonetwork: fix network driver startup for qemu:///session
Laine Stump [Thu, 2 May 2013 17:59:52 +0000 (13:59 -0400)]
network: fix network driver startup for qemu:///session

This should resolve https://bugzilla.redhat.com/show_bug.cgi?id=958907

Recent new addition of code to read/write active network state to the
NETWORK_STATE_DIR in the network driver broke startup for
qemu:///session. The network driver had several state file paths
hardcoded to /var, which could never possibly work in session mode.

This patch modifies *all* state files to use a variable string that is
set differently according to whether or not we're running
privileged. (It turns out that logDir was never used, so it's been
completely eliminated.)

There are very definitely other problems preventing dnsmasq and radvd
from running in non-privileged mode, but it's more consistent to have
the directories used by them be determined in the same fashion.

NB: I've noted before that the network driver is storing its state
(including dnsmasq and radvd state) in /var/lib, while qemu stores its
state in /var/run. It would probably have been better if the two
matched, but it's been this way for a long time, and changing it would
break running installations during an upgrade, so it's best to just
leave it as it is.

12 years agoFix warning about unsupported cookie flags in QEMU driver
Daniel P. Berrange [Fri, 3 May 2013 09:55:49 +0000 (10:55 +0100)]
Fix warning about unsupported cookie flags in QEMU driver

The QEMU migration code unconditionally sets the 'persistent'
cookie flag on the source host. The dest host, however, only
allows it during parsing if VIR_MIGRATE_PERSIST_DEST was
set. Make the source host only set it if this flag is
present.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix release of resources with lockd plugin
Daniel P. Berrange [Fri, 3 May 2013 11:00:15 +0000 (12:00 +0100)]
Fix release of resources with lockd plugin

The lockd plugin for the lock manager was not correctly
handling the release of resource locks. This meant that
during migration, or when pausing a VM, the locks would
not get released. This in turn made it impossible to
resume the domain, or finish migration

12 years agoFix F_DUPFD_CLOEXEC operation args
Daniel P. Berrange [Fri, 3 May 2013 10:10:50 +0000 (11:10 +0100)]
Fix F_DUPFD_CLOEXEC operation args

The F_DUPFD_CLOEXEC operation with fcntl() expects a single
int argument, specifying the minimum FD number for the newly
dup'd file descriptor. We were not specifying that causing
random stack data to be accessed as the FD number. Sometimes
that worked, sometimes it didn't.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agobuild: avoid non-portable cast of pthread_t
Eric Blake [Thu, 2 May 2013 20:23:02 +0000 (14:23 -0600)]
build: avoid non-portable cast of pthread_t

POSIX says pthread_t is opaque.  We can't guarantee if it is scaler
or a pointer, nor what size it is; and BSD differs from Linux.
We've also had reports of gcc complaining on attempts to cast it,
if we use a cast to the wrong type (for example, pointers have to be
cast to void* or intptr_t before being narrowed; while casting a
function return of scalar pthread_t to void* triggers a different
warning).

Give up on casts, and use unions to get at decent bits instead.  And
rather than futz around with figuring which 32 bits of a potentially
64-bit pointer are most likely to be unique, convert the rest of
the code base to use 64-bit values when using a debug id.

Based on a report by Guido Günther against kFreeBSD, but with a
fix that doesn't regress commit 4d970fd29 for FreeBSD.

* src/util/virthreadpthread.c (virThreadSelfID, virThreadID): Use
union to get at a decent bit representation of thread_t bits.
* src/util/virthread.h (virThreadSelfID, virThreadID): Alter
signature.
* src/util/virthreadwin32.c (virThreadSelfID, virThreadID):
Likewise.
* src/qemu/qemu_domain.h (qemuDomainJobObj): Alter type of owner.
* src/qemu/qemu_domain.c (qemuDomainObjTransferJob)
(qemuDomainObjSetJobPhase, qemuDomainObjReleaseAsyncJob)
(qemuDomainObjBeginNestedJob, qemuDomainObjBeginJobInternal): Fix
clients.
* src/util/virlog.c (virLogFormatString): Likewise.
* src/util/vireventpoll.c (virEventPollInterruptLocked):
Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agobuild: fix make rpm failure
Laine Stump [Fri, 3 May 2013 11:52:22 +0000 (07:52 -0400)]
build: fix make rpm failure

Commit 297c99a accidentally put a { where a ( belonged, causing make
rpm to fail.

12 years agoMore paranoid initialization of 'nparams' variable in dispatch code
Daniel P. Berrange [Thu, 2 May 2013 11:36:53 +0000 (12:36 +0100)]
More paranoid initialization of 'nparams' variable in dispatch code

Since the 'nparams' variable passed to virTypedParametersFree is
supposed to represent the size of the 'params' array, it is bad
practice to initialize it to a non-zero value, until the array
has been allocated.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix potential use of undefined variable in remote dispatch code
Daniel P. Berrange [Thu, 2 May 2013 11:35:47 +0000 (12:35 +0100)]
Fix potential use of undefined variable in remote dispatch code

If an early dispatch check caused a jump to the 'cleanup' branch
then virTypeParamsFree() would be called with an uninitialized
'nparams' variable. Fortunately 'params' is initialized to NULL,
so the uninitialized 'nparams' variable would not be used.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoRemove redundant () in expression
Daniel P. Berrange [Thu, 2 May 2013 11:35:14 +0000 (12:35 +0100)]
Remove redundant () in expression

The use of () in a simple boolean comparison was not
required

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix format string handling in network driver
Daniel P. Berrange [Thu, 2 May 2013 11:33:55 +0000 (12:33 +0100)]
Fix format string handling in network driver

The call to virReportError conditionally switched between
two format strings, with different numbers of placeholders.
This meant the format string with no placeholders was not
protected by a "%s".

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agodocs: fix 'since' for socket path generation
Ján Tomko [Fri, 3 May 2013 07:24:00 +0000 (09:24 +0200)]
docs: fix 'since' for socket path generation

Commit 297c99a says it works from 1.0.5 but it only got pushed
after the 1.0.5 release.

12 years agoesx: Reduce code duplication in generator
Matthias Bolte [Wed, 1 May 2013 13:54:30 +0000 (15:54 +0200)]
esx: Reduce code duplication in generator

12 years agobuild: Fix build when WITH_HAL is defined
Jim Fehlig [Thu, 2 May 2013 21:54:22 +0000 (15:54 -0600)]
build: Fix build when WITH_HAL is defined

Commit 7c9a2d88 missed inclusion of virstring.h in a few places
when WITH_HAL is defined, causing build failures.

12 years agobuild: fix mingw build of vbox
Eric Blake [Thu, 2 May 2013 21:53:27 +0000 (15:53 -0600)]
build: fix mingw build of vbox

More fallout from commit 7c9a2d88 dropping too many headers.  Fixes:

In file included from ../../src/vbox/vbox_glue.c:26:0:
../../src/vbox/vbox_MSCOMGlue.c: In function 'vboxLookupVersionInRegistry':
../../src/vbox/vbox_MSCOMGlue.c:435:5: error: implicit declaration of function 'virParseVersionString' [-Werror=implicit-function-declaration]
...
../../src/vbox/vbox_driver.c: In function 'vboxConnectOpen':
../../src/vbox/vbox_driver.c:147:5: error: implicit declaration of function 'getuid' [-Werror=implicit-function-declaration]
../../src/vbox/vbox_driver.c:147:5: error: nested extern declaration of 'getuid' [-Werror=nested-externs]

* src/vbox/vbox_MSCOMGlue.c (includes): Add missing includes.
* src/vbox/vbox_driver.c (includes): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agobuild: fix mingw build of virprocess.c
Eric Blake [Thu, 2 May 2013 21:46:19 +0000 (15:46 -0600)]
build: fix mingw build of virprocess.c

Commit 776d49f4 added a static function that is only called
conditionally; leading to this compile error on mingw:

  CC       libvirt_util_la-virprocess.lo
../../src/util/virprocess.c:624:26: error: 'struct rlimit' declared inside parameter list [-Werror]
../../src/util/virprocess.c:624:26: error: its scope is only this definition or declaration, which is probably not what you want [-Werror]
../../src/util/virprocess.c:622:1: error: 'virProcessPrLimit' defined but not used [-Werror=unused-function]

* src/util/virprocess.c (virProcessPrLimit): Only declare
virProcessPrLimit when used.

Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agobuild: fix FreeBSD build
Eric Blake [Thu, 2 May 2013 21:30:48 +0000 (15:30 -0600)]
build: fix FreeBSD build

Commit 7c9a2d88 cleaned up too many headers; FreeBSD builds
failed due to:

util/virutil.c:556: warning: implicit declaration of function 'canonicalize_file_name'

(Not sure which Linux header leaked this declaration, but gnulib
only guarantees it in stdlib.h)

libvirt.c:956: warning: implicit declaration of function 'virGetUserConfigDirectory'

(Here, a build on Linux was picking up virutil.h indirectly via
one of the conditional driver headers, where that driver was not
being built on my FreeBSD setup)

* src/util/virutil.c (includes): Need <stdlib.h> for
canonicalize_file_name.
* src/libvirt.c (includes): Use "virutil.h" unconditionally,
rather than relying on conditional indirect inclusion.

Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agobuild: avoid useless virAsprintf
Eric Blake [Thu, 2 May 2013 19:35:26 +0000 (13:35 -0600)]
build: avoid useless virAsprintf

virAsprintf(&foo, "%s", bar) is wasteful compared to
foo = strdup(bar) (or eventually, VIR_STRDUP(foo, bar),
but one thing at a time...).

Noticed while reviewing Laine's attempt to clean up broken
qemu:///session.

* cfg.mk (sc_prohibit_asprintf): Enhance rule.
* src/esx/esx_storage_backend_vmfs.c
(esxStorageBackendVMFSVolumeLookupByKey): Fix offender.
* src/network/bridge_driver.c (networkStateInitialize): Likewise.
* src/nwfilter/nwfilter_dhcpsnoop.c (virNWFilterSnoopDHCPOpen):
Likewise.
* src/storage/storage_backend_sheepdog.c
(virStorageBackendSheepdogRefreshVol): Likewise.
* src/util/vircgroup.c (virCgroupAddTaskStrController): Likewise.
* src/util/virdnsmasq.c (addnhostsAdd): Likewise.
* src/xen/block_stats.c (xenLinuxDomainDeviceID): Likewise.
* src/xen/xen_driver.c (xenUnifiedConnectOpen): Likewise.
* tools/virsh.c (vshGetTypedParamValue): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agobuild: always include sanitytest in tarball
Eric Blake [Thu, 2 May 2013 17:56:34 +0000 (11:56 -0600)]
build: always include sanitytest in tarball

The libvirt 1.0.5 tarball is missing a file which renders 'make
check' broken; first reported on list by Guido Günther.

* python/Makefile.am (EXTRA_DIST): Hoist sanitytest.py out of
HAVE_PYTHON conditional.

Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agoutil: fix compile errors caused by moving string functions
Laine Stump [Thu, 2 May 2013 17:24:02 +0000 (13:24 -0400)]
util: fix compile errors caused by moving string functions

commit 7c9a2d8 missed adding in a few #include "virstring.h"s, causing
builds to fail.

12 years agovirutil: Move string related functions to virstring.c
Michal Privoznik [Wed, 3 Apr 2013 10:36:23 +0000 (12:36 +0200)]
virutil: Move string related functions to virstring.c

The source code base needs to be adapted as well. Some files
include virutil.h just for the string related functions (here,
the include is substituted to match the new file), some include
virutil.h without any need (here, the include is removed), and
some require both.

12 years agoqemu: Generate agent socket path if missing
Michal Privoznik [Tue, 9 Apr 2013 17:04:00 +0000 (19:04 +0200)]
qemu: Generate agent socket path if missing

It's not desired to force users imagine path for a socket they
are not even supposed to connect to. On the other hand, we
already have a release where the qemu agent socket path is
exposed to XML, so we cannot silently drop it from there.
The new path is generated in form:

$LOCALSTATEDIR/lib/libvirt/qemu/channel/target/$domain.$name

for qemu system mode, and

$XDG_CONFIG_HOME/qemu/lib/channel/target/$domain.$name

for qemu session mode.

12 years agovirInitctlRequest: unbreak make syntax check
Guido Günther [Thu, 2 May 2013 07:17:44 +0000 (09:17 +0200)]
virInitctlRequest: unbreak make syntax check

introduced by dcf97846d54b9ae20181f0f29c684b6ae4de89ee

To trigger this cppi needs to be installed.

12 years agovirInitctlRequest: unbreak make syntax check
Guido Günther [Thu, 2 May 2013 07:17:44 +0000 (09:17 +0200)]
virInitctlRequest: unbreak make syntax check

introduced by dcf97846d54b9ae20181f0f29c684b6ae4de89ee

12 years agoRelease of libvirt-1.0.5
Daniel Veillard [Thu, 2 May 2013 06:58:48 +0000 (14:58 +0800)]
Release of libvirt-1.0.5

* configure.ac docs/news.html.in libvirt.spec.in: updated for the release
* po/*.po*: pulled and merged a number of new localization updates

12 years agovirInitctlRequest: Don't hardcode 384 bytes size
Guido Günther [Wed, 1 May 2013 20:35:44 +0000 (22:35 +0200)]
virInitctlRequest: Don't hardcode 384 bytes size

When MAXHOSTNAMELEN is set we have to take it's value into account.
Otherwise the build fails on kFreeBSD (FreeBSD kernel and GNU userland)

12 years agopci: autolearn name of stub driver, remove from arglist
Laine Stump [Wed, 1 May 2013 18:44:10 +0000 (14:44 -0400)]
pci: autolearn name of stub driver, remove from arglist

virPCIDeviceReattach and virPCIDeviceUnbindFromStub (called by
virPCIDeviceReattach) had previously required the name of the stub
driver as input. This is unnecessary, because the name of the driver
the device is currently bound to can be found by looking at the link:

  /sys/bus/pci/dddd:bb:ss.ff/driver

Instead of requiring that the name of the expected stub driver name
and only unbinding if that one name is matched, we no longer take a
driver name in the arglist for either of these
functions. virPCIDeviceUnbindFromStub just compares the name of the
currently bound driver to a list of "well known" stubs (right now
contains "pci-stub" and "vfio-pci" for qemu, and "pciback" for xen),
and only performs the unbind if it's one of those devices.

This allows virsh nodedevice-reattach to work properly across a
libvirtd restart, and fixes a couple of cases where we were
erroneously still hard-coding "pci-stub" as the drive name.

For some unknown reason, virPCIDeviceReattach had been calling
modprobe on the stub driver prior to unbinding the device. This was
problematic because we no longer know the name of the stub driver in
that function. However, it is pointless to probe for the stub driver
at that time anyway - because the device is bound to the stub driver,
we are guaranteed that it is already loaded, and so that call to
modprobe has been removed.

12 years agospec: collect all BuildRequires into one area
Eric Blake [Wed, 1 May 2013 20:16:10 +0000 (14:16 -0600)]
spec: collect all BuildRequires into one area

Conditional BuildRequires: should be at the top level, rather
than appearing in conditional sub-package sections.  This
appears to be the only offender.

* libvirt.spec.in (BuildRequires): Move libblkid-devel into
correct area.

Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agodocs: Fix closing tag in snapshot documentation
Christophe Fergeau [Wed, 1 May 2013 17:59:56 +0000 (19:59 +0200)]
docs: Fix closing tag in snapshot documentation

Commit cc6d19f3 added text containing "<code>snapshot<code>" to
formatsnapshot.html.in. The closing tag is missing '/' which causes
the documentation to misrender.

12 years agoESX: Fix DISPATCH_FREE generation code to free all extended objects
Ata E Husain Bohra [Wed, 2 Jan 2013 06:22:28 +0000 (22:22 -0800)]
ESX: Fix DISPATCH_FREE generation code to free all extended objects

Python code generator "generate_source" section that handles
code generation to "free" inherited objects needs to generate
DISPATCH_FREE calls for all extended_by objects.

12 years agoS390: Do not generate a default USB controller
Viktor Mihajlovski [Mon, 29 Apr 2013 16:11:29 +0000 (18:11 +0200)]
S390: Do not generate a default USB controller

For s390 we don't want to have a default USB device generated even
if QEMU is silently tolerating -usb on the command line. This may change
in the future.
Another reason to avoid the USB controller is that it implies a PCI
bus which might cause a regression at some later point in time.
The following change will set the USB controller model to 'none'
unless a model or address has been specified, which can be the case
if a legacy definition is loaded or the XML writer knows what
she/he's doing.
Requiring the user to explicitly disable USB on systems not supporting
it seems cumbersome.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
12 years agoS390: Mention changed USB behavior
Viktor Mihajlovski [Mon, 29 Apr 2013 16:11:28 +0000 (18:11 +0200)]
S390: Mention changed USB behavior

Add a line saying that no USB controllers are generated by default
on s390.

12 years agoqemu: fix failure to start with spice graphics and no tls
Laine Stump [Tue, 30 Apr 2013 18:04:59 +0000 (14:04 -0400)]
qemu: fix failure to start with spice graphics and no tls

Commit eca3fdf inadvertantly caused a failure to start for any domain
with the following in its config:

    <graphics type='spice' autoport='yes'/>

The problem is that when tlsPort == 0 and defaultMode == "any" (which
is the default for defaultMode), this would be flagged in the code as
"needTLSPort", and if there was then no spice tls config, the new
error+fail would happen.

This patch checks for the case of defaultMode == "any", and in that
case simply doesn't allocate a TLS port (since that's probably not
what the user wanted, and it would have failed later anyway.). It does
leave the error in place for cases when the user specifically asked to
use tls in one way or another, though.

12 years agobuild: fix cygwin build in virnetdev
Eric Blake [Tue, 30 Apr 2013 19:42:59 +0000 (13:42 -0600)]
build: fix cygwin build in virnetdev

On cygwin, compilation failed because SIOCSIFHWADDR is undefined.

* src/util/virnetdev.c (virNetDevSetMAC): Cygwin can query but not
set mac address.

Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agoNeed to call virFreeError after virSaveLastError
John Ferlan [Tue, 30 Apr 2013 17:39:28 +0000 (13:39 -0400)]
Need to call virFreeError after virSaveLastError

12 years agoResolve valgrind error
John Ferlan [Mon, 29 Apr 2013 11:52:49 +0000 (07:52 -0400)]
Resolve valgrind error

As a result of commit id '19c345f2', 'make -C tests valgrind' has the
following for qemuxml2argvtest:

==22482== 197 (80 direct, 117 indirect) bytes in 1 blocks are definitely lost in loss record 101 of 120
==22482==    at 0x4A06B6F: calloc (vg_replace_malloc.c:593)
==22482==    by 0x4C6F301: virAlloc (viralloc.c:124)
==22482==    by 0x4C840FC: virSaveLastError (virerror.c:308)
==22482==    by 0x431882: qemuBuildCommandLine (qemu_command.c:8204)
==22482==    by 0x41E8F0: testCompareXMLToArgvHelper (qemuxml2argvtest.c:155)
==22482==    by 0x41FE9F: virtTestRun (testutils.c:157)
==22482==    by 0x419DEB: mymain (qemuxml2argvtest.c:654)
==22482==    by 0x4204DA: virtTestMain (testutils.c:719)
==22482==    by 0x39D0821A04: (below main) (libc-start.c:225)
==22482==

12 years agolibvirt-guests: status: return non-zero when stopped
Ján Tomko [Tue, 30 Apr 2013 11:44:33 +0000 (13:44 +0200)]
libvirt-guests: status: return non-zero when stopped

Return 3 when the service is stopped, whether there
are saved guests or not, to conform with the LSB standards:

http://refspecs.linuxbase.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/iniscrptact.html

12 years agoportability: handle ifreq differences in virnetdev
Roman Bogorodskiy [Sat, 27 Apr 2013 15:50:19 +0000 (19:50 +0400)]
portability: handle ifreq differences in virnetdev

FreeBSD (and maybe other BSDs) have different member
names in struct ifreq when compared to Linux, such as:

 - uses ifr_data instead of ifr_newname for setting
   interface names
 - uses ifr_index instead of ifr_ifindex for interface
   index

Also, add a check for SIOCGIFHWADDR for virNetDevValidateConfig().

Use AF_LOCAL if AF_PACKET is not available.

Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agosecurity driver: eliminate memory leaks in failure paths
Laine Stump [Tue, 30 Apr 2013 14:59:29 +0000 (10:59 -0400)]
security driver: eliminate memory leaks in failure paths

If virPCIDeviceGetVFIOGroupDev() failed,
virSecurity*(Set|Restore)HostdevLabel() would fail to free a
virPCIDevice that had been allocated.

These leaks were all introduced (by me) very recently, in commit
f0bd70a.

12 years agolibxl: Fix double-dispose of libxl domain config
Jim Fehlig [Mon, 29 Apr 2013 23:04:55 +0000 (17:04 -0600)]
libxl: Fix double-dispose of libxl domain config

libxlBuildDomainConfig() was disposing the libxl_domain_config object
on error, only to have it disposed again by libxlBuildDomainConfig()'s
caller, which resulted in a segfault.  Leave disposing of the config
object to it's owner.

12 years agoesx: Support virtualHW version 9
Martin Kletzander [Tue, 30 Apr 2013 12:46:54 +0000 (14:46 +0200)]
esx: Support virtualHW version 9

We already support ESX 5.1, but virtualHW version used by such
hypervisor [1] wasn't taken into account.

[1] http://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&externalId=1003746

12 years agoFix typo in augeas comment
Martin Kletzander [Tue, 30 Apr 2013 14:28:20 +0000 (16:28 +0200)]
Fix typo in augeas comment

12 years agobuild: mark conditionally unused variables
Eric Blake [Tue, 30 Apr 2013 14:21:26 +0000 (08:21 -0600)]
build: mark conditionally unused variables

These fixes solve a compilation failure on FreeBSD:

util/virnetdevtap.c: In function 'virNetDevTapGetName':
util/virnetdevtap.c:56: warning: unused parameter 'tapfd' [-Wunused-parameter]
util/virnetdevtap.c:56: warning: unused parameter 'ifname' [-Wunused-parameter]

* src/util/virnetdevtap.c (virNetDevTapGetName): Add attributes
when TUNGETIFF is not present.

Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agovirsh: clarify vol-{down,up}load description
Ján Tomko [Tue, 30 Apr 2013 12:19:49 +0000 (14:19 +0200)]
virsh: clarify vol-{down,up}load description

Mention file/volume contents instead of just 'file'/'volume'.

Also change Download->download in vol-download help,
to be consistent with other volume commands.

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

12 years agoqemu: report an error if memballoon has wrong address type
Ján Tomko [Mon, 29 Apr 2013 18:01:19 +0000 (20:01 +0200)]
qemu: report an error if memballoon has wrong address type

qemuBuildMemballoonDevStr returns NULL if memballoon doesn't have
the right address type, but it doesn't report an error, leading to:
error: An error occurred, but the cause is unknown

Report a helpful error message instead, e.g.:
error: XML error: memballoon unsupported with address type 'usb'

12 years agoqemu: assign addresses when converting xml to native
Ján Tomko [Mon, 29 Apr 2013 17:54:07 +0000 (19:54 +0200)]
qemu: assign addresses when converting xml to native

This adds addresses to domxml-to-native output and chooses
the correct virtio devices for ccw and s390 machines.

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

12 years agovirsh: fix incorrect argument errors for long options
Ján Tomko [Mon, 29 Apr 2013 17:12:17 +0000 (19:12 +0200)]
virsh: fix incorrect argument errors for long options

For long options, print:
* the option as specified by the user if it's unknown
* the canonical long option if its argument is not
  a number (and should be)

And for missing arguments, print both the short and
the long option name.
(Doing only one of those would require either parsing
argv ourselves or let getopt print the errors, since
we can't tell long and short options apart by optopt
or longindex)

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

Unsupported long option:

$ virsh --pm
Before:
error: unsupported option '-
After:
error: unsupported option '--pm'. See --help.

Missing parameter:

$ virsh --deb
Before:
error: option '-d' requires an argument
After:
error: option '-d'/'--debug' requires an argument

$ virsh -rd
Before:
error: option '-d' requires an argument
After:
error: option '-d'/'--debug' requires an argument

Non-numeric parameter:

$ virsh --deb duck
Before:
error: option -d takes a numeric argument
After:
error: option --debug takes a numeric argument

12 years agoqemu: Error out if spice port autoallocation is requested, but disabled
Peter Krempa [Mon, 29 Apr 2013 11:41:27 +0000 (13:41 +0200)]
qemu: Error out if spice port autoallocation is requested, but disabled

When a user requests auto-allocation of the spice TLS port but spice TLS
is disabled in qemu.conf, we start the machine and let qemu fail instead
of erroring out sooner.

Add an error message so that this doesn't happen.

12 years agonetwork: Don't remove transient network if creating of config file fails
Peter Krempa [Mon, 22 Apr 2013 09:10:39 +0000 (11:10 +0200)]
network: Don't remove transient network if creating of config file fails

On the off-chance that creation of persistent configuration file would
fail when defining a network that is already started as transient, the
code would remove the transient data structure and thus the network.

This patch changes the code so that in such case, the network is again
marked as transient and left behind.

12 years agoqemu: put usb cgroup setup in common function
Laine Stump [Mon, 29 Apr 2013 20:19:19 +0000 (16:19 -0400)]
qemu: put usb cgroup setup in common function

The USB-specific cgroup setup had been inserted inline in
qemuDomainAttachHostUsbDevice and qemuSetupCgroup, but now there is a
common cgroup setup function called for all hostdevs, so it makes sens
to put the usb-specific setup there and just rely on that function
being called.

The one thing I'm uncertain of here (and a reason for not pushing
until after release) is that previously hostdev->missing was checked
only when starting a domain (and cgroup setup for the device skipped
if missing was true), but with this consolidation, it is now checked
in the case of hotplug as well. I don't know if this will have any
practical effect (does it make sense to hotplug a "missing" usb
device?)

12 years agoqemu: add vfio devices to cgroup ACL when appropriate
Laine Stump [Mon, 29 Apr 2013 17:15:26 +0000 (13:15 -0400)]
qemu: add vfio devices to cgroup ACL when appropriate

PCIO device assignment using VFIO requires read/write access by the
qemu process to /dev/vfio/vfio, and /dev/vfio/nn, where "nn" is the
VFIO group number that the assigned device belongs to (and can be
found with the function virPCIDeviceGetVFIOGroupDev)

/dev/vfio/vfio can be accessible to any guest without danger
(according to vfio developers), so it is added to the static ACL.

The group device must be dynamically added to the cgroup ACL for each
vfio hostdev in two places:

1) for any devices in the persistent config when the domain is started
   (done during qemuSetupCgroup())

2) at device attach time for any hotplug devices (done in
   qemuDomainAttachHostDevice)

The group device must be removed from the ACL when a device it
"hot-unplugged" (in qemuDomainDetachHostDevice())

Note that USB devices are already doing their own cgroup setup and
teardown in the hostdev-usb specific function. I chose to make the new
functions generic and call them in a common location though. We can
then move the USB-specific code (which is duplicated in two locations)
to this single location. I'll be posting a followup patch to do that.

12 years agoqemu: honor allowDiskFormatProbing when parsing command line
Ján Tomko [Mon, 29 Apr 2013 13:42:45 +0000 (15:42 +0200)]
qemu: honor allowDiskFormatProbing when parsing command line

My commit 024e9af broke this.

12 years agoconf: add missing error on OOM
Ján Tomko [Fri, 26 Apr 2013 16:12:58 +0000 (18:12 +0200)]
conf: add missing error on OOM

I removed it in 5c3d5b2 by accident.

12 years agoqemu: prevent invalid reads in qemuAssignDevicePCISlots
Ján Tomko [Fri, 26 Apr 2013 16:05:46 +0000 (18:05 +0200)]
qemu: prevent invalid reads in qemuAssignDevicePCISlots

Don't reserve slot 2 for video if the machine has no PCI buses.
Error out when the user specifies a video device without
a PCI address when there are no PCI buses.

(This wouldn't work on a machine with no PCI bus anyway since
we do add PCI addresses for video devices to the command line)

12 years agoqemu: don't always reserve PCI addresses for implicit controllers
Ján Tomko [Fri, 26 Apr 2013 15:50:36 +0000 (17:50 +0200)]
qemu: don't always reserve PCI addresses for implicit controllers

In the past we automatically added a USB controller and assigned
it a PCI address (0:0:1.2) even on machines without a PCI bus.
This didn't break machines with no PCI bus  because the command
line for it is just '-usb', with no mention of the PCI bus.

The implicit IDE controller (reserved address 0:0:1.1) has
no command line at all.

Commit b33eb0dc removed the ability to reserve PCI addresses
on machines without a PCI bus. This made them stop working,
since there would always be the implicit USB controller.

Skip the reservation of addresses for these controllers when
there is no PCI bus, instead of failing.

12 years agoconf: remove extraneous _TYPE from driver backend enums
Laine Stump [Fri, 26 Apr 2013 20:44:05 +0000 (16:44 -0400)]
conf: remove extraneous _TYPE from driver backend enums

This isn't strictly speaking a bugfix, but I realized I'd gotten a bit
too verbose when I chose the names for
VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_*. This shortens them all a bit.

12 years agonetwork: support <driver name='vfio'/> in network definitions
Laine Stump [Fri, 26 Apr 2013 20:23:27 +0000 (16:23 -0400)]
network: support <driver name='vfio'/> in network definitions

I remembered to document this bit, but somehow forgot to implement it.

This adds <driver name='kvm|vfio'/> as a subelement to the <forward>
element of a network (this puts it parallel to the match between
mode='hostdev' attribute in a network and type='hostdev' in an
<interface>).

Since it's already documented, only the parser, formatter, backend
driver recognition (it just translates/moves the flag into the
<interface> at the appropriate time), and a test case were needed.

(I used a separate enum for the values both because the original is
defined in domain_conf.h, which is unavailable from network_conf.h,
and because in the future it's possible that we may want to support
other non-hostdev oriented driver names in the network parser; this
makes sure that one can be expanded without the other).

12 years agoqemu: launch bridge helper from libvirtd
Paolo Bonzini [Sat, 20 Apr 2013 09:11:25 +0000 (11:11 +0200)]
qemu: launch bridge helper from libvirtd

<source type='bridge'> uses a helper application to do the necessary
TUN/TAP setup to use an existing network bridge, thus letting
unprivileged users use TUN/TAP interfaces.

However, libvirt should be preventing QEMU from running any setuid
programs at all, which would include this helper program.  From
a security POV, any setuid helper needs to be run by libvirtd itself,
not QEMU.

This is what this patch does.  libvirt now invokes the setuid helper,
gets the TAP fd and then passes it to QEMU in the normal manner.
The path to the helper is specified in qemu.conf.

As a small advantage, this adds a <target dev='tap0'/> element to the
XML of an active domain using <interface type='bridge'>.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agovirnetdevtap: add virNetDevTapGetName
Paolo Bonzini [Sat, 20 Apr 2013 09:11:24 +0000 (11:11 +0200)]
virnetdevtap: add virNetDevTapGetName

This will be used on a tap file descriptor returned by the bridge helper
to populate the <target> element, because the helper does not provide
the interface name.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoqemu: don't assign a PCI address to 'none' USB controller
Ján Tomko [Fri, 26 Apr 2013 17:52:43 +0000 (19:52 +0200)]
qemu: don't assign a PCI address to 'none' USB controller

Adjust the usb-none test, since it gives the memballoon a lower PCI slot now.
Add a test for 'none' controller on s390, which doesn't have PCI buses.

12 years agofix segfault during virsh save in pv guest
Bamvor Jian Zhang [Fri, 26 Apr 2013 14:53:42 +0000 (22:53 +0800)]
fix segfault during virsh save in pv guest

this patch fix the wrong sequence for fd and timeout register. the sequence
was right in dfa1e1dd for fd register, but it changed in e0622ca2.
in this patch, set priv, xl_priv in info and increase info->priv ref count
before virEventAddHandle. if do this after virEventAddHandle, the fd
callback or fd deregister maybe got the empty priv, xl_priv or wrong ref
count.

after apply this patch, test more than 100 rounds passed compare to fail
within 3 rounds without this patch. each round includes define -> start ->
destroy -> create -> suspend -> resume -> reboot -> shutdown -> save ->
resotre -> dump -> destroy -> create -> setmem -> setvcpus -> destroy.

Signed-off-by: Bamvor Jian Zhang <bjzhang@suse.com>
12 years agoqemu: set qemu process' RLIMIT_MEMLOCK when VFIO is used
Laine Stump [Thu, 25 Apr 2013 16:45:55 +0000 (12:45 -0400)]
qemu: set qemu process' RLIMIT_MEMLOCK when VFIO is used

VFIO requires all of the guest's memory and IO space to be lockable in
RAM. The domain's max_balloon is the maximum amount of memory the
domain can have (in KiB). We add a generous 1GiB to that for IO space
(still much better than KVM device assignment, where the KVM module
actually *ignores* the process limits and locks everything anyway),
and convert from KiB to bytes.

In the case of hotplug, we are changing the limit for the already
existing qemu process (prlimit() is used under the hood), and for
regular commandline additions of vfio devices, we schedule a call to
setrlimit() that will happen after the qemu process is forked.

12 years agoqemu: use new virCommandSetMax(Processes|Files)
Laine Stump [Thu, 25 Apr 2013 16:16:25 +0000 (12:16 -0400)]
qemu: use new virCommandSetMax(Processes|Files)

These were previously being set in a custom hook function, but now
that virCommand directly supports setting them, we can eliminate that
part of the hook and call the APIs directly.

12 years agoutil: new virCommandSetMax(MemLock|Processes|Files)
Laine Stump [Thu, 25 Apr 2013 16:10:10 +0000 (12:10 -0400)]
util: new virCommandSetMax(MemLock|Processes|Files)

This patch adds two sets of functions:

1) lower level virProcessSet*() functions that will immediately set
the RLIMIT_MEMLOCK. RLIMIT_NPROC, or RLIMIT_NOFILE of either the
current process (using setrlimit()) or any other process (using
prlimit()). "current process" is indicated by passing a 0 for pid.

2) functions for virCommand* that will setup a virCommand object to
set those limits at a later time just after it has forked a new
process, but before it execs the new program.

configure.ac has prlimit and setrlimit added to the list of functions
to check for, and the low level functions log an "unsupported" error)
on platforms that don't support those functions.

12 years agoDo proper escaping of cgroup resource partitions
Daniel P. Berrange [Fri, 26 Apr 2013 09:50:24 +0000 (10:50 +0100)]
Do proper escaping of cgroup resource partitions

If a user cgroup name begins with "cgroup.", "_" or with any of
the controllers from /proc/cgroups followed by a dot, then they
need to be prefixed with a single underscore. eg if there is
an object "cpu.service", then this would end up as "_cpu.service"
in the cgroup filesystem tree, however, "waldo.service" would
stay "waldo.service", at least as long as nobody comes up with
a cgroup controller called "waldo".

Since we require a '.XXXX' suffix on all partitions, there is
no scope for clashing with the kernel 'tasks' and 'release_agent'
files.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoEnsure all cgroup partitions have a suffix of ".partition"
Daniel P. Berrange [Fri, 26 Apr 2013 09:23:51 +0000 (10:23 +0100)]
Ensure all cgroup partitions have a suffix of ".partition"

If the partition named passed in the XML does not already have
a suffix, ensure it gets a '.partition' added to each component.
The exceptions are /machine, /user and /system which do not need
to have a suffix, since they are fixed partitions at the top
level.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoChange VM cgroup suffix from '{lxc,qemu}.libvirt' to 'libvirt-{lxc,qemu}'
Daniel P. Berrange [Fri, 26 Apr 2013 08:52:47 +0000 (09:52 +0100)]
Change VM cgroup suffix from '{lxc,qemu}.libvirt' to 'libvirt-{lxc,qemu}'

Recently we changed to create VM cgroups with the naming pattern
$VMNAME.$DRIVER.libvirt. Following discussions with the systemd
community it was decided that only having a single '.' in the
names is preferrable. So this changes the naming scheme to be
$VMNAME.libvirt-$DRIVER. eg for LXC 'mycontainer.libvirt-lxc' or
for KVM 'myvm.libvirt-qemu'.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agotest: Add JSON test for query-tpm-types
Stefan Berger [Fri, 26 Apr 2013 11:13:05 +0000 (07:13 -0400)]
test: Add JSON test for query-tpm-types

Add a test case for query-tpm-models QMP command.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
12 years agovirsh: suppress aliases in group help
Eric Blake [Fri, 26 Apr 2013 10:20:29 +0000 (04:20 -0600)]
virsh: suppress aliases in group help

'virsh help | grep nodedev-det' shows only nodedev-detach, but
'virsh help nodedev | grep nodedev-det' also shows the old alias
nodedev-dettach that we intentionally hid in commit af3f9aab.

See also commit 787f4fe and this bug report:
https://bugzilla.redhat.com/show_bug.cgi?id=956966

* tools/virsh.c (vshCmdGrpHelp): Copy suppression of vshCmdHelp.

Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agosecurity: update hostdev labelling functions for VFIO
Laine Stump [Thu, 25 Apr 2013 10:37:21 +0000 (06:37 -0400)]
security: update hostdev labelling functions for VFIO

Legacy kvm style pci device assignment requires changes to the
labelling of several sysfs files for each device, but for vfio device
assignment, the only thing that needs to be relabelled/chowned is the
"group" device for the group that contains the device to be assigned.

12 years agoutil: new function virPCIDeviceGetVFIOGroupDev
Laine Stump [Thu, 25 Apr 2013 10:34:43 +0000 (06:34 -0400)]
util: new function virPCIDeviceGetVFIOGroupDev

Given a virPCIDevice, this function returns the path for the device
that controls the vfio group the device belongs to,
e.g. "/dev/vfio/15".

12 years agovirsh: use new virNodeDeviceDetachFlags
Laine Stump [Wed, 24 Apr 2013 18:22:36 +0000 (14:22 -0400)]
virsh: use new virNodeDeviceDetachFlags

The virsh nodedev-detach command has a new --driver option. If it's
given virsh will attempt to use the new virNodeDeviceDetachFlags API
instead of virNodeDeviceDettach. Validation of the driver name string
is left to the hypervisor (qemu accepts "kvm" or "vfio". The only
other hypervisor that implements these functions is xen, and it only
accepts NULL).

12 years agoxen: implement virNodeDeviceDetachFlags backend
Laine Stump [Wed, 24 Apr 2013 18:06:42 +0000 (14:06 -0400)]
xen: implement virNodeDeviceDetachFlags backend

This was the only hypervisor driver other than qemu that implemented
virNodeDeviceDettach. It doesn't currently support multiple pci device
assignment driver backends, but it is simple to plug in this new API,
which will make it easier for Xen people to fill it in later when they
decide to support VFIO (or whatever other) device assignment. Also it
means that management applications will have the same API available to
them for both hypervisors on any given version of libvirt.

The only acceptable value for driverName in this case is NULL, since
there is no alternate, and I'm not willing to pick a name for the
default driver used by Xen.

12 years agoqemu: implement virNodeDeviceDetachFlags backend
Laine Stump [Wed, 24 Apr 2013 18:03:39 +0000 (14:03 -0400)]
qemu: implement virNodeDeviceDetachFlags backend

The differences from virNodeDeviceDettach are very minor:

1) Check that the flags are 0.

2) Set the virPCIDevice's stubDriver according to the driverName that
   is passed in.

3) Call virPCIDeviceDetach with a NULL stubDriver, indicating it
   should get the name of the stub driver from the virPCIDevice
   object.

12 years agohypervisor api: implement RPC calls for virNodeDeviceDetachFlags
Laine Stump [Wed, 24 Apr 2013 17:42:04 +0000 (13:42 -0400)]
hypervisor api: implement RPC calls for virNodeDeviceDetachFlags

This requires a custom function for remoteNodeDeviceDetachFlags,
because it is named *NodeDevice, but it goes through the hypervisor
driver rather than nodedevice driver, and so it uses privateData
instead of nodeDevicePrivateData. (It has to go through the hypervisor
driver, because that is the driver that knows about the backend drivers
that will perform the pci device assignment).

12 years agohypervisor api: new virNodeDeviceDetachFlags
Laine Stump [Wed, 24 Apr 2013 16:56:10 +0000 (12:56 -0400)]
hypervisor api: new virNodeDeviceDetachFlags

The existing virNodeDeviceDettach() assumes that there is only a
single PCI device assignment backend driver appropriate for any
hypervisor. This is no longer true, as the qemu driver is getting
support for PCI device assignment via VFIO. The new API
virNodeDeviceDetachFlags adds a driverName arg that should be set to
the exact same string set in a domain <hostdev>'s <driver name='x'/>
element (i.e. "vfio", "kvm", or NULL for default). It also adds a
flags arg for good measure (and because it's possible we may need it
when we start dealing with VFIO's "device groups").

12 years agoqemu: bind/unbind stub driver according to config <driver name='x'/>
Laine Stump [Tue, 23 Apr 2013 18:53:36 +0000 (14:53 -0400)]
qemu: bind/unbind stub driver according to config <driver name='x'/>

If the config for a device has specified <driver name='vfio'/>,
"backend" in the pci part of the hostdev object will be set to
..._VFIO. In this case, when creating a virPCIDevice set the
stubDriver to "vfio-pci", otherwise set it to "pci-stub". We will rely
on the lower levels to report an error if the vfio driver isn't
loaded.

The detach/attach functions in virpci.c will pay attention to the
stubDriver setting in the device, and bind/unbind the appropriate
driver when preparing hostdevs for the domain.

Note that we don't yet attempt to do anything to mark active any other
devices in the same vfio "group" as a single device that is being
marked active. We do need to do that, but in order to get basic VFIO
functionality testing sooner rather than later, initially we'll just
live with more cryptic errors when someone tries to do that.

12 years agopci: keep a stubDriver in each virPCIDevice
Laine Stump [Tue, 23 Apr 2013 18:50:15 +0000 (14:50 -0400)]
pci: keep a stubDriver in each virPCIDevice

This can be set when the virPCIDevice is created and placed on a list,
then used later when traversing the list to determine which stub
driver to bind/unbind for managed devices.

The existing Detach and Attach functions' signatures haven't been
changed (they still accept a stub driver name in the arg list), but if
the arg list has NULL for stub driver and one is available in the
device's object, that will be used. (we may later deprecate and remove
the arg from those functions).

12 years agoqemu: use vfio-pci on commandline when appropriate
Laine Stump [Thu, 25 Apr 2013 11:58:37 +0000 (07:58 -0400)]
qemu: use vfio-pci on commandline when appropriate

The device option for vfio-pci is nearly identical to that for
pci-assign - only the configfd parameter isn't supported (or needed).

Checking for presence of the bootindex parameter is done separately
from constructing the commandline, similar to how it is done for
pci-assign.

This patch contains tests to check for proper commandline
construction. It also includes tests for parser-formatter-parser
roundtrips (xml2xml), because those tests use the same data files, and
would have failed had they been included before now.

qemu: xml/args tests for VFIO hostdev and <interface type='hostdev'/>

These should be squashed in with the patch that adds commandline
handling of vfio (they would fail at any earlier time).

12 years agoconf: formatter/parser/RNG/docs for hostdev <driver name='kvm|vfio'/>
Laine Stump [Fri, 15 Mar 2013 19:15:14 +0000 (15:15 -0400)]
conf: formatter/parser/RNG/docs for hostdev <driver name='kvm|vfio'/>

A domain's <interface> or <hostdev>, as well as a <network>'s
<forward>, can now have an optional <driver name='kvm|vfio'/>
element. As of this patch, there is no functionality behind this new
knob - this patch adds support to the domain and network
formatter/parser, and to the RNG and documentation.

When the backend is added, legacy KVM PCI device assignment will
continue to be used when no driver name is specified (or if <driver
name='kvm'/> is specified), but if driver name is 'vfio', the new UEFI
Secure Boot compatible VFIO device assignment will be used.

Note that the parser doesn't automatically insert the current default
value of this setting. This is done on purpose because the two
possibilities are functionally equivalent from the guest's point of
view, and we want to be able to automatically start using vfio as the
default (even for existing domains) at some time in the future. This
is similar to what was done with the "vhost" driver option in
<interface>.

12 years agoconf: put hostdev pci address in a struct
Laine Stump [Mon, 18 Mar 2013 19:56:12 +0000 (15:56 -0400)]
conf: put hostdev pci address in a struct

There will soon be other items related to pci hostdevs that need to be
in the same part of the hostdevsubsys union as the pci address (which
is currently a single member called "pci". This patch replaces the
single member named pci with a struct named pci that contains a single
member named "addr".

12 years agoqemu: detect vfio-pci device and its bootindex parameter
Laine Stump [Wed, 17 Apr 2013 18:16:28 +0000 (14:16 -0400)]
qemu: detect vfio-pci device and its bootindex parameter

QEMU_CAPS_DEVICE_VFIO_PCI is set if the device named "vfio-pci" is
supported in the qemu binary.

QEMU_CAPS_VFIO_PCI_BOOTINDEX is set if the vfio-pci device supports
the "bootindex" parameter;  for some reason, the bootindex parameter
wasn't included in early versions of vfio support (qemu 1.4) so we
have to check for it separately from vfio itself.

12 years agobuild: avoid unsafe functions in libgen.h
Eric Blake [Thu, 25 Apr 2013 20:24:42 +0000 (14:24 -0600)]
build: avoid unsafe functions in libgen.h

POSIX says that both basename() and dirname() may return static
storage (aka they need not be thread-safe); and that they may but
not must modify their input argument.  Furthermore, <libgen.h>
is not available on all platforms.  For these reasons, you should
never use these functions in a multi-threaded library.

Gnulib instead recommends a way to avoid the portability nightmare:
gnulib's "dirname.h" provides useful thread-safe counterparts.  The
obvious dir_name() and base_name() are GPL (because they malloc(),
but call exit() on failure) so we can't use them; but the LGPL
variants mdir_name() (malloc's or returns NULL) and last_component
(always points into the incoming string without modifying it,
differing from basename semantics only on corner cases like the
empty string that we shouldn't be hitting in the first place) are
already in use in libvirt.  This finishes the swap over to the safe
functions.

* cfg.mk (sc_prohibit_libgen): New rule.
* src/util/vircgroup.c: Fix offenders.
* src/parallels/parallels_storage.c (parallelsPoolAddByDomain):
Likewise.
* src/parallels/parallels_network.c (parallelsGetBridgedNetInfo):
Likewise.
* src/node_device/node_device_udev.c (udevProcessSCSIHost)
(udevProcessSCSIDevice): Likewise.
* src/storage/storage_backend_disk.c
(virStorageBackendDiskDeleteVol): Likewise.
* src/util/virpci.c (virPCIGetDeviceAddressFromSysfsLink):
Likewise.
* src/util/virstoragefile.h (_virStorageFileMetadata): Avoid false
positive.

Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agoFix VIR_DOMAIN_EVENT_ID_PMSUSPEND capitalization in API doc
Christophe Fergeau [Thu, 25 Apr 2013 19:56:08 +0000 (21:56 +0200)]
Fix VIR_DOMAIN_EVENT_ID_PMSUSPEND capitalization in API doc

It was written VIR_DOMAIN_EVENT_ID_PMSuspend

12 years agoImprove /domainsnapshot/disks/disk@snapshot doc
Christophe Fergeau [Thu, 25 Apr 2013 19:40:33 +0000 (21:40 +0200)]
Improve /domainsnapshot/disks/disk@snapshot doc

The previous description was a bit confusing.

12 years agoqemu: fix build error with older platforms
Eric Blake [Thu, 25 Apr 2013 17:22:39 +0000 (11:22 -0600)]
qemu: fix build error with older platforms

Jim Fehlig reported on IRC that older gcc/glibc triggers this warning:

cc1: warnings being treated as errors
qemu/qemu_domain.c: In function 'qemuDomainDefFormatBuf':
qemu/qemu_domain.c:1297: error: declaration of 'remove' shadows a global declaration [-Wshadow]
/usr/include/stdio.h:157: error: shadowed declaration is here [-Wshadow]
make[3]: *** [libvirt_driver_qemu_impl_la-qemu_domain.lo] Error 1

Fix it like we have done in the past (such as commit 2e6322a).

* src/qemu/qemu_domain.c (qemuDomainDefFormatBuf): Avoid shadowing
a function name.

Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agodocs: fix memballoon examples
Ján Tomko [Thu, 25 Apr 2013 16:53:07 +0000 (18:53 +0200)]
docs: fix memballoon examples

Use a pair of 'memballoon' tags instead of single 'watchdog' one.
Add a few missing colons.

12 years agoconf: reject controllers with duplicate indexes
Ján Tomko [Tue, 23 Apr 2013 12:24:32 +0000 (14:24 +0200)]
conf: reject controllers with duplicate indexes

Reject multiple controllers with the same index,
except for USB controllers.
Multi-function USB controllers can have the same index.

12 years agoqemu: auto-add pci-root to 'pc-i440*' machines too
Ján Tomko [Thu, 25 Apr 2013 13:17:12 +0000 (15:17 +0200)]
qemu: auto-add pci-root to 'pc-i440*' machines too

Commit b33eb0d missed this machine type.

12 years agofix typo introduced by 90430791
Bamvor Jian Zhang [Thu, 25 Apr 2013 12:17:43 +0000 (20:17 +0800)]
fix typo introduced by 90430791

Signed-off-by: Bamvor Jian Zhang <bjzhang@suse.com>