]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
13 years agoutil: fix compile error on debian
Eli Qiao [Fri, 11 Nov 2011 05:50:46 +0000 (13:50 +0800)]
util: fix compile error on debian

Add virnetdev.h,virnetdevbridge.h,virnetdevtap.h to private symbols,
since debian linker no longer allows transitive link resolution

Signed-off-by: Eli Qiao <taget@linux.vnet.ibm.com>
13 years agoqemu: fix domjobabort regression
Eric Blake [Tue, 8 Nov 2011 19:01:48 +0000 (12:01 -0700)]
qemu: fix domjobabort regression

This reverts commit ef1065cf5ac; see also this bug report:
https://bugzilla.redhat.com/show_bug.cgi?id=751900

In qemu 0.15.1 and earlier, during migration to file, the
qemu_savevm_state_begin and qemu_savevm_state_iterate methods
will both process as much migration data as possible until either

  1. The file descriptor returns EAGAIN
  2. The bandwidth rate limit is reached

If we set the rate limit to ULONG_MAX, test 2 never becomes true. We're
passing a plain file descriptor to QEMU and POSIX does not support EAGAIN on
regular files / block devices, so test 1 never becomes true either.

In the 'virsh save --bypass-cache' case, we pass a pipe instead of a
regular fd, but using a pipe adds I/O overhead, so always passing a
pipe just so qemu can see EAGAIN doesn't seem nice.

The ultimate fix needs to come from qemu - background migration must
respect asynchronous abort requests, or else periodically return
control to the main handling loop without an EAGAIN and without
waiting to hit an insanely large amount of data.  But until a
version of qemu is fixed to support "unlimited" data rates while
still allowing cancellation, the best we can do is avoid the
automatic use of unlimited rates from within libvirt (users can
still explicitly change the migration rates, if they are aware that
they are giving up the ability to cancel a job).

Reverting the lone use of QEMU_DOMAIN_FILE_MIG_BANDWIDTH_MAX is
the simplest patch; this slows migration back down to a default
32M/sec cap, but also ensures that the main qemu processing loop
will still be responsive to cancellation requests.  Hopefully
upstream qemu will provide us a means of safely using unlimited
speed, including a runtime probe of that capability.

* src/qemu/qemu_migration.c (qemuMigrationToFile): Revert attempt
to use unlimited migration bandwidth when migrating to file.

Signed-off-by: Daniel Veillard <veillard@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agofix two bugs in bridge_driver.c
Hu Tao [Fri, 11 Nov 2011 08:20:19 +0000 (16:20 +0800)]
fix two bugs in bridge_driver.c

steps to reproduce:

1. having a network xml file(named default.xml) like this one:

<network>
  <name>default</name>
  <uuid>c5322c4c-81d0-4985-a363-ad6389780d89</uuid>
  <bridge name="virbr0" />
  <forward/>
  <ip address="192.168.122.1" netmask="255.255.255.0">
    <dhcp>
      <range start="192.168.122.2" end="192.168.122.254" />
    </dhcp>
  </ip>
</network>

in /etc/libvirt/qemu/networks/, and mark it as autostart:

$ ls -l /etc/libvirt/qemu/networks/autostart
total 0
lrwxrwxrwx 1 root root 14 Oct 12 14:02 default.xml -> ../default.xml

2. start libvirtd and the device virbr0 is not automatically up.

The reason is that the function virNetDevExists is now returns 1 if
the device exists, comparing to the former one returns 0 if the device
exists. But with only this fix will cause a segmentation fault(the same
steps as above)  that is fixed by the second chunk of code.

13 years agobuild: drop useless dirent.h includes
Eric Blake [Mon, 7 Nov 2011 17:47:31 +0000 (10:47 -0700)]
build: drop useless dirent.h includes

* .gnulib: Update to latest, for improved syntax-check.
* src/lxc/lxc_container.c (includes): Drop unused include.
* src/network/bridge_driver.c: Likewise.
* src/node_device/node_device_linux_sysfs.c: Likewise.
* src/openvz/openvz_driver.c: Likewise.
* src/qemu/qemu_conf.c: Likewise.
* src/storage/storage_backend_iscsi.c: Likewise.
* src/storage/storage_backend_mpath.c: Likewise.
* src/uml/uml_conf.c: Likewise.
* src/uml/uml_driver.c: Likewise.

13 years agoxenapi: remove unused variable
Eric Blake [Fri, 11 Nov 2011 18:10:18 +0000 (11:10 -0700)]
xenapi: remove unused variable

  CC     libvirt_driver_xenapi_la-xenapi_driver.lo
xenapi/xenapi_driver.c: In function 'xenapiDomainGetVcpus':
xenapi/xenapi_driver.c:1209:21: error: variable 'cpus' set but not used [-Werror=unused-but-set-variable]

* src/xenapi/xenapi_driver.c (xenapiDomainGetVcpus): Silence
compiler warning.

13 years agomaint: use mailmap, not AUTHORS, for secondary addresses
Eric Blake [Fri, 11 Nov 2011 15:22:23 +0000 (08:22 -0700)]
maint: use mailmap, not AUTHORS, for secondary addresses

* AUTHORS: Move Stefan's second entry...
* .mailmap: ...here.

13 years agomaint: fix make syntax-check
Stefan Berger [Thu, 10 Nov 2011 16:34:53 +0000 (11:34 -0500)]
maint: fix make syntax-check

Add my 2nd email to the list of AUTHORS to get 'make syntax-check'
to pass.

13 years agoRemove code instantiating filters on direct interfaces
Stefan Berger [Thu, 10 Nov 2011 16:16:22 +0000 (11:16 -0500)]
Remove code instantiating filters on direct interfaces

Remove the code that instantiates network filters on direct type
of interfaces. The parser already does not accept it.

13 years agoDisable numactl on ARM architectures too
Daniel P. Berrange [Thu, 10 Nov 2011 11:33:17 +0000 (11:33 +0000)]
Disable numactl on ARM architectures too

* libvirt.spec.in: Disable numactl on ARM

13 years agoAdd libvirt confdir to files section in mingw32 spec
Daniel P. Berrange [Thu, 10 Nov 2011 11:30:57 +0000 (11:30 +0000)]
Add libvirt confdir to files section in mingw32 spec

* mingw32-libvirt.spec.in: Ensure we own the confdir

13 years agonwfilter: simplify execution of ebiptables scripts
Eric Blake [Wed, 9 Nov 2011 17:29:57 +0000 (10:29 -0700)]
nwfilter: simplify execution of ebiptables scripts

It's not worth even worrying about a temporary file, unless we
ever expect the script to exceed maximum command-line argument
length limits.

* src/nwfilter/nwfilter_ebiptables_driver.c (ebiptablesExecCLI):
Run the commands as an argument to /bin/sh, rather than worrying
about a temporary file.
(ebiptablesWriteToTempFile): Delete unused function.

13 years agonwfilter: avoid failure with noexec /tmp
Eric Blake [Wed, 9 Nov 2011 17:23:49 +0000 (10:23 -0700)]
nwfilter: avoid failure with noexec /tmp

If /tmp is mounted with the noexec flag (common on security-conscious
systems), then nwfilter will fail to initialize, because we cannot
run any temporary script via virRun("/tmp/script"); but we _can_
use "/bin/sh /tmp/script".  For that matter, using /tmp risks collisions
with other unrelated programs; we already have /var/run/libvirt as a
dedicated temporary directory for use by libvirt.

* src/nwfilter/nwfilter_ebiptables_driver.c
(ebiptablesWriteToTempFile): Use internal directory, not /tmp;
drop attempts to make script executable; and detect close error.
(ebiptablesExecCLI): Switch to virCommand, and invoke the shell to
read the script, rather than requiring an executable script.

13 years agoAdjust naming of network device bandwidth management APIs
Daniel P. Berrange [Wed, 2 Nov 2011 14:29:05 +0000 (14:29 +0000)]
Adjust naming of network device bandwidth management APIs

Rename virBandwidth to virNetDevBandwidth, and virRate to
virNetDevBandwidthRate.

* src/util/network.c, src/util/network.h: Rename bandwidth
  structs and APIs
* src/conf/domain_conf.c, src/conf/domain_conf.h,
  src/conf/network_conf.c, src/conf/network_conf.h,
  src/lxc/lxc_driver.c, src/network/bridge_driver.c,
  src/qemu/qemu_command.c, src/util/macvtap.c,
  src/util/macvtap.h, tools/virsh.c: Update for API changes.

13 years agoSantize naming of socket address APIs
Daniel P. Berrange [Wed, 2 Nov 2011 14:06:59 +0000 (14:06 +0000)]
Santize naming of socket address APIs

The socket address APIs in src/util/network.h either take the
form  virSocketAddrXXX, virSocketXXX or virSocketXXXAddr.

Sanitize this so everything is virSocketAddrXXXX, and ensure
that the virSocketAddr parameter is always the first one.

* src/util/network.c, src/util/network.h: Santize socket
  address API naming
* src/conf/domain_conf.c, src/conf/network_conf.c,
  src/conf/nwfilter_conf.c, src/network/bridge_driver.c,
  src/nwfilter/nwfilter_ebiptables_driver.c,
  src/nwfilter/nwfilter_learnipaddr.c,
  src/qemu/qemu_command.c, src/rpc/virnetsocket.c,
  src/util/dnsmasq.c, src/util/iptables.c,
  src/util/virnetdev.c, src/vbox/vbox_tmpl.c: Update for
  API renaming

13 years agoSplit bridge.h into three separate files
Daniel P. Berrange [Wed, 2 Nov 2011 13:41:58 +0000 (13:41 +0000)]
Split bridge.h into three separate files

Following the renaming of the bridge management APIs, we can now
split the source file into 3 corresponding pieces

 * src/util/virnetdev.c: APIs for any type of network interface
 * src/util/virnetdevbridge.c: APIs for bridge interfaces
 * src/util/virnetdevtap.c: APIs for TAP interfaces

* src/util/virnetdev.c, src/util/virnetdev.h,
  src/util/virnetdevbridge.c, src/util/virnetdevbridge.h,
  src/util/virnetdevtap.c, src/util/virnetdevtap.h: Copied
  from bridge.{c,h}
* src/util/bridge.c, src/util/bridge.h: Split into 3 pieces
* src/lxc/lxc_driver.c, src/network/bridge_driver.c,
  src/openvz/openvz_driver.c, src/qemu/qemu_command.c,
  src/qemu/qemu_conf.h, src/uml/uml_conf.c, src/uml/uml_conf.h,
  src/uml/uml_driver.c: Update #include directives

13 years agoRemove usage of brctl command line tool
Daniel P. Berrange [Wed, 2 Nov 2011 13:05:27 +0000 (13:05 +0000)]
Remove usage of brctl command line tool

Convert the virNetDevBridgeSetSTP and virNetDevBridgeSetSTPDelay
to use ioctls instead of spawning brctl.

Implement the virNetDevBridgeGetSTP and virNetDevBridgeGetSTPDelay
methods which were declared in the header but never existed

* src/util/bridge.c: Convert to use bridge ioctls instead of brctl

13 years agoAdd an API for retrieving the MAC address of an interface
Daniel P. Berrange [Wed, 2 Nov 2011 13:00:09 +0000 (13:00 +0000)]
Add an API for retrieving the MAC address of an interface

* src/util/bridge.c, src/util/bridge.h: Add virNetDevGetMAC

13 years agoExpose MTU management APIs
Daniel P. Berrange [Wed, 2 Nov 2011 12:57:41 +0000 (12:57 +0000)]
Expose MTU management APIs

The MTU management APIs are useful to other code inside libvirt,
so should be exposed as non-static APIs.

* src/util/bridge.c, src/util/bridge.h: Expose virNetDevSetMTU,
  virNetDevSetMTUFromDevice & virNetDevGetMTU

13 years agoTurn two int parameters into bools in bridge APIs
Daniel P. Berrange [Wed, 2 Nov 2011 12:54:45 +0000 (12:54 +0000)]
Turn two int parameters into bools in bridge APIs

* src/util/bridge.c, src/util/bridge.h: s/int/bool/ in
  virNetDevSetOnline and virNetDevBridgeSetSTP

13 years agoRename all brXXXX APIs to follow new convention
Daniel P. Berrange [Wed, 2 Nov 2011 12:35:18 +0000 (12:35 +0000)]
Rename all brXXXX APIs to follow new convention

The existing brXXX APIs in src/util/bridge.h are renamed to
follow one of three different conventions

 - virNetDevXXX       - operations for any type of interface
 - virNetDevBridgeXXX - operations for bridge interfaces
 - virNetDevTapXXX    - operations for tap interfaces

* src/util/bridge.h, src/util/bridge.c: Rename all APIs
* src/lxc/lxc_driver.c, src/network/bridge_driver.c,
  src/qemu/qemu_command.c, src/uml/uml_conf.c,
  src/uml/uml_driver.c: Update for API renaming

13 years agoMake all brXXX APIs raise errors, instead of returning errnos
Daniel P. Berrange [Wed, 2 Nov 2011 12:00:28 +0000 (12:00 +0000)]
Make all brXXX APIs raise errors, instead of returning errnos

Currently every caller of the brXXX APIs has to store the returned
errno value and then raise an error message. This results in
inconsistent error messages across drivers, additional burden on
the callers and makes the error reporting inaccurate since it is
hard to distinguish different scenarios from 1 errno value.

* src/util/bridge.c: Raise errors instead of returning errnos
* src/lxc/lxc_driver.c, src/network/bridge_driver.c,
  src/qemu/qemu_command.c, src/uml/uml_conf.c,
  src/uml/uml_driver.c: Remove error reporting code

13 years agoRemove 'brControl' object
Daniel P. Berrange [Wed, 2 Nov 2011 10:56:38 +0000 (10:56 +0000)]
Remove 'brControl' object

The bridge management APIs in src/util/bridge.c require a brControl
object to be passed around. This holds the file descriptor for the
control socket. This extra object complicates use of the API for
only a minor efficiency gain, which is in turn entirely offset by
the need to fork/exec the brctl command for STP configuration.

This patch removes the 'brControl' object entirely, instead opening
the control socket & closing it again within the scope of each method.

The parameter names for the APIs are also made to consistently use
'brname' for bridge device name, and 'ifname' for an interface
device name. Finally annotations are added for non-NULL parameters
and return check validation

* src/util/bridge.c, src/util/bridge.h: Remove brControl object
  and update API parameter names & annotations.
* src/lxc/lxc_driver.c, src/network/bridge_driver.c,
  src/uml/uml_conf.h, src/uml/uml_conf.c, src/uml/uml_driver.c,
  src/qemu/qemu_command.c, src/qemu/qemu_conf.h,
  src/qemu/qemu_driver.c: Remove reference to 'brControl' object

13 years agobuild: fix mingw build of gnulib openpty
Eric Blake [Wed, 9 Nov 2011 00:14:34 +0000 (17:14 -0700)]
build: fix mingw build of gnulib openpty

Commit f7bd00c12 pulled in a gnulib module that fails to compile
on mingw.  Work around it while waiting for an upstream gnulib fix.

* gnulib/local/lib/pty.in.h (openpty): Provide forward
declarations of opaque structs not present on mingw.
* gnulib/local/lib/openpty.c (openpty): Provide stub for mingw.

13 years agobuild: allow for local gnulib diffs
Eric Blake [Wed, 9 Nov 2011 00:06:27 +0000 (17:06 -0700)]
build: allow for local gnulib diffs

Commit f7bd00c12 pulled in a gnulib module that fails to compile
on mingw.  While it would be nice to pull in a newer version of
.gnulib that fixes this, it is difficult to backport any .gnulib
update to older releases.  So, it makes sense to take advantage
of gnulib-tool's ability to support local diffs, where we can
apply specific diffs in our use of gnulib without waiting for
upstream gnulib to pick up those changes, as well as avoiding
a wholesale .gnulib update.  The existence of local diffs will
also make it easier to backport fixes against a tarball (as long
as a tarball and libvirt.git share the same .gnulib commit, then
the tarball can be patched by applying the same local diffs as
a post-release libvirt.git commit, without having to rerun an
entire gnulib-tool bootstrap).

This patch introduces the framework for supporting local diffs,
without actually introducing any.

* bootstrap.conf (local_gl_dir): New variable.
* autogen.sh (bootstrap_hash): Hash any local diffs, to force a
re-bootstrap if just diffs change.
* cfg.mk (_update_required): Likewise.

13 years agolxc: free error object to avoid memory leak
Alex Jia [Wed, 9 Nov 2011 06:20:28 +0000 (14:20 +0800)]
lxc: free error object to avoid memory leak

Detected by Coverity. Leak introduced in commit 9d201a5.

* src/lxc/lxc_driver.c: Clean up on failure.

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agolxc: free 'ttyFDs' array on return from lxcVmStart
Alex Jia [Wed, 9 Nov 2011 06:51:26 +0000 (14:51 +0800)]
lxc: free 'ttyFDs' array on return from lxcVmStart

Detected by Coverity. Leak introduced in commit 0f31f7b.

* src/lxc/lxc_driver.c: Clean up on failure.

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agoqemu: Fix improper error message for disk detaching
Osier Yang [Wed, 9 Nov 2011 05:58:51 +0000 (13:58 +0800)]
qemu: Fix improper error message for disk detaching

s/virDomainDeviceTypeToString/virDomainDiskDeviceTypeToString/

Report by Xu He Jie <xuhj@linux.vnet.ibm.

13 years agovirsh: Add VSH_OFLAG_EMPTY_OK for attach-disk command
Xu He Jie [Tue, 8 Nov 2011 07:16:34 +0000 (15:16 +0800)]
virsh: Add VSH_OFLAG_EMPTY_OK for attach-disk command

As the description of removing CDROM media from
  http://wiki.libvirt.org/page/QEMUSwitchToLibvirt#eject_DEV

Add flag 'VSH_OFLAG_EMPTY_OK' to the option 'source' of attach-disk

Then avoid outputting <source> in the XML if 'source' was empty,
rather than trusting libvirt domain_conf.c to understand an empty
string.

Signed-off-by: Xu He Jie <xuhj@linux.vnet.ibm.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agoRelease of libvirt-0.9.7
Daniel Veillard [Tue, 8 Nov 2011 06:55:25 +0000 (14:55 +0800)]
Release of libvirt-0.9.7

* confiure.ac docs/news.html.in libvirt.spec.in: update for release
* po/*.po*: update localizations and rebuilt

13 years agobuild: fix build on platforms without ptsname_r
Eric Blake [Thu, 3 Nov 2011 20:56:13 +0000 (14:56 -0600)]
build: fix build on platforms without ptsname_r

MacOS lacks ptsname_r, and gnulib doesn't (yet) provide it.
But we can avoid it altogether, by using gnulib openpty()
instead.  Note that we do _not_ want the pt_chown module;
gnulib uses it only to implement a replacement openpty() if
the system lacks both openpty() and granpt(), but all
systems that we currently port to either have at least one of
openpty() and/or grantpt(), or lack ptys altogether.  That is,
we aren't porting to any system that requires us to deal with
the hassle of installing a setuid pt_chown helper just to use
gnulib's ability to provide openpty() on obscure platforms.

* .gnulib: Update to latest, for openpty fixes
* bootstrap.conf (gnulib_modules): Add openpty, ttyname_r.
(gnulib_tool_option_extras): Exclude pt_chown module.
* src/util/util.c (virFileOpenTty): Rewrite in terms of openpty
and ttyname_r.
* src/util/util.h (virFileOpenTtyAt): Delete dead prototype.

13 years agoAdd missing defaultConsoleTargetType callback for AppArmour
Daniel P. Berrange [Mon, 7 Nov 2011 10:17:28 +0000 (10:17 +0000)]
Add missing defaultConsoleTargetType callback for AppArmour

Every instance of virCapsPtr must have the defaultConsoleTargetType
field set.

* src/security/virt-aa-helper.c: Add defaultConsoleTargetType to
  virCapsPtr

13 years agoFix sending/receiving of FDs when stream returns EAGAIN
Daniel P. Berrange [Fri, 4 Nov 2011 16:02:14 +0000 (16:02 +0000)]
Fix sending/receiving of FDs when stream returns EAGAIN

The code calling sendfd/recvfd was mistakenly assuming those
calls would never block. They can in fact return EAGAIN and
this is causing us to drop the client connection when blocking
ocurrs while sending/receiving FDs.

Fixing this is a little hairy on the incoming side, since at
the point where we see the EAGAIN, we already thought we had
finished receiving all data for the packet. So we play a little
trick to reset bufferOffset again and go back into polling for
more data.

* src/rpc/virnetsocket.c, src/rpc/virnetsocket.h: Update
  virNetSocketSendFD/RecvFD to return 0 on EAGAIN, or 1
  on success
* src/rpc/virnetclient.c: Move decoding of header & fds
  out of virNetClientCallDispatch and into virNetClientIOHandleInput.
  Handling blocking when sending/receiving FDs
* src/rpc/virnetmessage.h: Add a 'donefds' field to track
  how many FDs we've sent / received
* src/rpc/virnetserverclient.c: Handling blocking when
  sending/receiving FDs

13 years agobuild: silence compiler warning on BSD
Eric Blake [Fri, 4 Nov 2011 22:32:30 +0000 (16:32 -0600)]
build: silence compiler warning on BSD

Building on 64-bit FreeBSD 8.2 complained about a cast between
a pointer and a smaller integer.  Going through an intermediate
cast shuts up the compiler.

* src/util/threads-pthread.c (virThreadSelfID): Silence a warning.

13 years agobuild: fix linking on BSD
Eric Blake [Fri, 4 Nov 2011 20:53:15 +0000 (14:53 -0600)]
build: fix linking on BSD

While building on FreeBSD (and after fixing a ptsname_r link error),
I got this failure:

./.libs/libvirt_util.a(libvirt_util_la-threads.o)(.text+0x240): In function `virThreadCreate':
util/threads-pthread.c:185: undefined reference to `pthread_create'

It turns out that gnulib used only pthread_join for LIB_PTHREAD,
but on FreeBSD, libc provides that (as a stub function); whereas
the more complex pthread_create really does require -pthread,
which gnulib tracked under [LT]LIBMULTITHREAD.

* configure.ac (LIBS): Check LIBMULTITHREAD alongside LIB_PTHREAD.
* src/Makefile.am (THREAD_LIBS): New variable.
(libvirt_util_la_LIBADD, libvirt_lxc_LDADD): Use it.

13 years agoremote: fix mingw32 build
Laine Stump [Fri, 4 Nov 2011 20:10:54 +0000 (16:10 -0400)]
remote: fix mingw32 build

tty is initialized, and later set in code that is compiled for all
platforms, but is only used in a section that's inside #ifndef WIN32.

13 years agolxc: avoid use-after-free
Eric Blake [Thu, 3 Nov 2011 23:24:32 +0000 (17:24 -0600)]
lxc: avoid use-after-free

I got this weird failure:

error: Failed to start domain simple
error: internal error cannot mix caller fds with blocking execution

and tracked it down to a use-after-free - virCommandSetOutputFD
was storing the address of a stack-local variable, which then
went out of scope before the virCommandRun that dereferenced it.

Bug introduced in commit 451cfd05 (0.9.2).

* src/lxc/lxc_driver.c (lxcBuildControllerCmd): Move log fd
registration...
(lxcVmStart): ...to caller.

13 years agoFix naming of constant for disk event
Daniel P. Berrange [Fri, 4 Nov 2011 12:16:19 +0000 (12:16 +0000)]
Fix naming of constant for disk event

All constants related to events should have a prefix of
VIR_DOMAIN_EVENT_

* include/libvirt/libvirt.h.in, src/qemu/qemu_domain.c:
  Rename VIR_DOMAIN_DISK_CHANGE_MISSING_ON_START to
  VIR_DOMAIN_EVENT_DISK_CHANGE_MISSING_ON_START

13 years agoconf: Don't free uninitialized pointer
Jiri Denemark [Fri, 4 Nov 2011 08:25:20 +0000 (09:25 +0100)]
conf: Don't free uninitialized pointer

This causes libvirtd to crash when both <boot dev='...'/> and <boot
order='...'/> are used in one domain XML. Introduced by
5fa3d775a9f8cdb3423373eb084219aaf778df11

13 years agobuild: fix deep VPATH builds
Eric Blake [Thu, 3 Nov 2011 19:50:13 +0000 (13:50 -0600)]
build: fix deep VPATH builds

I ran into the following build failure:
$ mkdir -p build1 build2/a/very/deep/hierarcy
$ cd build2/a/very/deep/hierarcy
$ ../../../../../configure && make
$ cd ../../../../build1
$ ../configure && make
...
../../src/remote/remote_protocol.c:7:55: fatal error: ../../../../../src/remote/remote_protocol.h: No such file or directory

Turns out that we were sometimes generating the remote_protocol.c
file with information from the VPATH build, which is bad, since
any file shipped in the tarball should be idempotent no matter how
deep the VPATH build tree that created it.

* src/rpc/genprotocol.pl: Don't embed VPATH into generated file.

13 years agodoc: Add <deviceboot> capability.
Philipp Hahn [Tue, 1 Nov 2011 09:27:47 +0000 (10:27 +0100)]
doc: Add <deviceboot> capability.

Allow /capabilities/guest/features/deviceboot.

Signed-off-by: Philipp Hahn <hahn@univention.de>
13 years agolxc: use common code for process cleanup
Eric Blake [Fri, 21 Oct 2011 17:09:23 +0000 (11:09 -0600)]
lxc: use common code for process cleanup

Based on a Coverity report - the return value of waitpid() should
always be checked, to avoid problems with leaking resources.

* src/lxc/lxc_controller.c (lxcControllerRun): Use simpler virPidAbort.

13 years agoFix default console type setting
Daniel P. Berrange [Thu, 20 Oct 2011 13:56:20 +0000 (14:56 +0100)]
Fix default console type setting

The default console type may vary based on the OS type. ie a Xen
paravirt guests wants a 'xen' console, while a fullvirt guests
wants a 'serial' console.

A plain integer default console type in the capabilities does
not suffice. Instead introduce a callback that is passed the
OS type.

* src/conf/capabilities.h: Use a callback for default console
  type
* src/conf/domain_conf.c, src/conf/domain_conf.h: Use callback
  for default console type. Add missing LXC/OpenVZ console types.
* src/esx/esx_driver.c, src/libxl/libxl_conf.c,
  src/lxc/lxc_conf.c, src/openvz/openvz_conf.c,
  src/phyp/phyp_driver.c, src/qemu/qemu_capabilities.c,
  src/uml/uml_conf.c, src/vbox/vbox_tmpl.c,
  src/vmware/vmware_conf.c, src/xen/xen_hypervisor.c,
  src/xenapi/xenapi_driver.c: Set default console type callback

13 years agoSet aliases for LXC/UML console devices
Daniel P. Berrange [Thu, 20 Oct 2011 13:57:10 +0000 (14:57 +0100)]
Set aliases for LXC/UML console devices

To allow virDomainOpenConsole to access non-primary consoles,
device aliases are required to be set. Until now only the QEMU
driver has done this. Update LXC & UML to set aliases for any
console devices

* src/lxc/lxc_driver.c, src/uml/uml_driver.c: Set aliases
  for console devices

13 years agoDefault console target type with no <target> element
Daniel P. Berrange [Thu, 20 Oct 2011 13:56:30 +0000 (14:56 +0100)]
Default console target type with no <target> element

When no <target> element was set at all, the default console
target type was not being honoured

* src/conf/domain_conf.c: Set default target type for consoles
  with no <target>

13 years agoAdd support for multiple consoles in LXC
Daniel P. Berrange [Thu, 20 Oct 2011 08:44:31 +0000 (09:44 +0100)]
Add support for multiple consoles in LXC

Currently the LXC controller only supports setup of a single
text console. This is wired up to the container init's stdio,
as well as /dev/console and /dev/tty1. Extending support for
multiple consoles, means wiring up additional PTYs to /dev/tty2,
/dev/tty3, etc, etc. The LXC controller is passed multiple open
file handles, one for each console requested.

* src/lxc/lxc_container.c, src/lxc/lxc_container.h: Wire up
  all the /dev/ttyN links required to symlink to /dev/pts/NN
* src/lxc/lxc_container.h: Open more container side /dev/pts/NN
  devices, and adapt event loop to handle I/O from all consoles
* src/lxc/lxc_driver.c: Setup multiple host side PTYs

13 years agoRewrite LXC I/O forwarding to use main event loop
Daniel P. Berrange [Wed, 19 Oct 2011 15:22:24 +0000 (16:22 +0100)]
Rewrite LXC I/O forwarding to use main event loop

The current I/O code for LXC uses a hand crafted event loop
to forward I/O between the container & host app, based on
epoll to handle EOF on PTYs. This event loop is not easily
extensible to add more consoles, or monitor other types of
file descriptors.

Remove the custom event loop and replace it with a normal
libvirt event loop. When detecting EOF on a PTY, disable
the event watch on that FD, and fork off a background thread
that does a edge-triggered epoll() on the FD. When the FD
finally shows new incoming data, the thread re-enables the
watch on the FD and exits.

When getting EOF from a read() on the PTY, the existing code
would do waitpid(WNOHANG) to see if the container had exited.
Unfortunately there is a race condition, because even though
the process has closed its stdio handles, it might still
exist.

To deal with this the new event loop uses a SIG_CHILD handler
to perform the waitpid only when the container is known to
have actually exited.

* src/lxc/lxc_controller.c: Rewrite the event loop to use
  the standard APIs.

13 years agoFix crash formatting virtio console
Daniel P. Berrange [Wed, 19 Oct 2011 10:45:10 +0000 (11:45 +0100)]
Fix crash formatting virtio console

qemuBuildVirtioSerialPortDevStr was mistakenly accessing the
target.name field in the virDomainChrDef object for chardevs
belonging to a console. Those chardevs only have port set,
and if there's > 1 console, the > 1port number results in
trying to access a target.name with address 0x1

* src/qemu/qemu_command.c: Fix target.name handling and
  make code more robust wrt error reporting

* src/qemu/qemu_command.c: Conditionally access target.name

13 years agoAllow multiple consoles per virtual guest
Daniel P. Berrange [Wed, 23 Feb 2011 18:27:23 +0000 (18:27 +0000)]
Allow multiple consoles per virtual guest

While Xen only has a single paravirt console, UML, and
QEMU both support multiple paravirt consoles. The LXC
driver can also be trivially made to support multiple
consoles. This patch extends the XML to allow multiple
<console> elements in the XML. It also makes the UML
and QEMU drivers support this config.

* src/conf/domain_conf.c, src/conf/domain_conf.h: Allow
  multiple <console> devices
* src/lxc/lxc_driver.c, src/xen/xen_driver.c,
  src/xenxs/xen_sxpr.c, src/xenxs/xen_xm.c: Update for
  internal API changes
* src/security/security_selinux.c, src/security/virt-aa-helper.c:
  Only label consoles that aren't a copy of the serial device
* src/qemu/qemu_command.c, src/qemu/qemu_driver.c,
  src/qemu/qemu_process.c, src/uml/uml_conf.c,
  src/uml/uml_driver.c: Support multiple console devices
* tests/qemuxml2xmltest.c, tests/qemuxml2argvtest.c: Extra
  tests for multiple virtio consoles. Set QEMU_CAPS_CHARDEV
  for all console /channel tests
* tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-auto.args,
  tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.args
  tests/qemuxml2argvdata/qemuxml2argv-console-virtio.args: Update
  for correct chardev syntax
* tests/qemuxml2argvdata/qemuxml2argv-console-virtio-many.args,
  tests/qemuxml2argvdata/qemuxml2argv-console-virtio-many.xml: New
  test file

13 years agoRemove translations in socket test case
Daniel P. Berrange [Thu, 3 Nov 2011 10:52:44 +0000 (10:52 +0000)]
Remove translations in socket test case

The test case errors should not be translated since they're only
targetted at developers, not users.

* tests/virnetsockettest.c: Remove error reporting with translations

13 years agovirnetsockettest: Use a temporary directory in /tmp
Guido Günther [Wed, 2 Nov 2011 21:06:44 +0000 (22:06 +0100)]
virnetsockettest: Use a temporary directory in /tmp

to avoid exceeding UNIX_PATH_MAX

13 years agoUse ENAMETOOLONG if the the socket path is longer than UNIX_PATH_MAX
Guido Günther [Wed, 2 Nov 2011 20:39:31 +0000 (21:39 +0100)]
Use ENAMETOOLONG if the the socket path is longer than UNIX_PATH_MAX

13 years agoxen: allow getting < max typed parameters
Eric Blake [Wed, 2 Nov 2011 17:57:29 +0000 (11:57 -0600)]
xen: allow getting < max typed parameters

Allow the user to call with nparams too small, per API documentation.

* src/xen/xen_hypervisor.c (xenHypervisorGetSchedulerParameters):
Allow fewer than max.
* src/xen/xend_internal.c (xenDaemonGetSchedulerParameters):
Likewise.

13 years agotest: drop redundant check
Eric Blake [Wed, 2 Nov 2011 17:53:33 +0000 (11:53 -0600)]
test: drop redundant check

libvirt.c guarantees that nparams is non-zero for scheduler parameters.

* src/test/test_driver.c (testDomainGetSchedulerParamsFlags): Drop
redundant check.  Avoid strcpy.

13 years agolxc: allow getting < max typed parameters
Eric Blake [Wed, 2 Nov 2011 17:50:08 +0000 (11:50 -0600)]
lxc: allow getting < max typed parameters

Allow the user to call with nparams too small, per API documentation.
Also, libvirt.c filters out nparams of 0 for scheduler parameters.

* src/lxc/lxc_driver.c (lxcDomainGetMemoryParameters): Allow fewer
than max.
(lxcGetSchedulerParametersFlags): Drop redundant check.

13 years agolibxl: allow getting < max typed parameters
Eric Blake [Wed, 2 Nov 2011 17:42:38 +0000 (11:42 -0600)]
libxl: allow getting < max typed parameters

Allow the user to call with nparams too small, per API documentation.

* src/libxl/libxl_driver.c
(libxlDomainGetSchedulerParametersFlags): Allow fewer than max.

13 years agoesx: allow getting < max typed parameters
Eric Blake [Wed, 2 Nov 2011 17:36:12 +0000 (11:36 -0600)]
esx: allow getting < max typed parameters

Allow the user to call with nparams too small, per API documentation.

* src/esx/esx_driver.c (esxDomainGetMemoryParameters): Drop
redundant check.
(esxDomainGetSchedulerParametersFlags): Allow fewer than max.

13 years agoAPI: document scheduler parameter names
Eric Blake [Tue, 1 Nov 2011 20:38:42 +0000 (14:38 -0600)]
API: document scheduler parameter names

Document the parameter names that will be used by
virDomain{Get,Set}SchedulerParameters{,Flags}, rather than
hard-coding those names in each driver, to match what is
done with memory, blkio, and blockstats parameters.

* include/libvirt/libvirt.h.in (VIR_DOMAIN_SCHEDULER_CPU_SHARES)
(VIR_DOMAIN_SCHEDULER_VCPU_PERIOD)
(VIR_DOMAIN_SCHEDULER_VCPU_QUOTA, VIR_DOMAIN_SCHEDULER_WEIGHT)
(VIR_DOMAIN_SCHEDULER_CAP, VIR_DOMAIN_SCHEDULER_RESERVATION)
(VIR_DOMAIN_SCHEDULER_LIMIT, VIR_DOMAIN_SCHEDULER_SHARES): New
field name macros.
* src/qemu/qemu_driver.c (qemuSetSchedulerParametersFlags)
(qemuGetSchedulerParametersFlags): Use new defines.
* src/test/test_driver.c (testDomainGetSchedulerParamsFlags)
(testDomainSetSchedulerParamsFlags): Likewise.
* src/xen/xen_hypervisor.c (xenHypervisorGetSchedulerParameters)
(xenHypervisorSetSchedulerParameters): Likewise.
* src/xen/xend_internal.c (xenDaemonGetSchedulerParameters)
(xenDaemonSetSchedulerParameters): Likewise.
* src/lxc/lxc_driver.c (lxcSetSchedulerParametersFlags)
(lxcGetSchedulerParametersFlags): Likewise.
* src/esx/esx_driver.c (esxDomainGetSchedulerParametersFlags)
(esxDomainSetSchedulerParametersFlags): Likewise.
* src/libxl/libxl_driver.c (libxlDomainGetSchedulerParametersFlags)
(libxlDomainSetSchedulerParametersFlags): Likewise.

13 years agoFix off-by-one printing month in logging code
Daniel P. Berrange [Mon, 24 Oct 2011 16:33:00 +0000 (17:33 +0100)]
Fix off-by-one printing month in logging code

The field 'mon' in 'struct tm' gives months 0-11, where as
humans tend to expect months 1-12. Thus the month number
needing adjusting by 1

* src/util/logging.c: Use human friendly month number

13 years agoAdd missing param initialization in qemuDomainBlockStatsFlags
Daniel P. Berrange [Wed, 2 Nov 2011 10:28:05 +0000 (10:28 +0000)]
Add missing param initialization in qemuDomainBlockStatsFlags

* src/qemu/qemu_driver.c: Fix use of uninitialized 'params'

13 years agofix crash when starting network
Wen Congyang [Wed, 2 Nov 2011 05:17:16 +0000 (13:17 +0800)]
fix crash when starting network

commit 27908453 introduces a regression, and it will
cause libvirt crashed when starting network.

The reason is that tapfd may be NULL, but we dereference
it without checking whether it is NULL.

13 years agoqemu: allow getting < max typed parameters
Eric Blake [Mon, 31 Oct 2011 23:17:12 +0000 (17:17 -0600)]
qemu: allow getting < max typed parameters

Since all virTypedParameter APIs allow us to return the number
of slots we actually populated, we should allow the user to
call with nparams too small (without overrunning their array)
or too large (ignoring the tail of the array that we can't fill),
rather than requiring that they get things exactly right.

Making this change will make it easier for a future patch to
introduce VIR_TYPED_PARAM_STRING, with filtering in libvirt.c
rather than in every single driver, since users already have
to be prepared for *nparams to be smaller on exit than on entry.

* src/qemu/qemu_driver.c (qemuDomainGetBlkioParameters)
(qemuDomainGetMemoryParameters): Allow variable nparams on entry.
(qemuGetSchedulerParametersFlags): Drop redundant check.
(qemudDomainBlockStats, qemudDomainBlockStatsFlags): Rename...
(qemuDomainBlockStats, qemuDomainBlockStatsFlags): ...to this.
Don't return unavailable stats.

13 years agodocs: improve typed parameter documentation
Eric Blake [Mon, 31 Oct 2011 22:35:26 +0000 (16:35 -0600)]
docs: improve typed parameter documentation

virDomainBlockStatsFlags was missing a check that was present in
virDomainGetMemoryParameters.  Additionally, I found that the
existing descriptions were a bit hard to read.  A later patch
will fix qemu to return fewer than max parameters if @nparams
was too small on input.

* src/libvirt.c (virDomainGetMemoryParameters)
(virDomainGetBlkioParameters, virDomainGetSchedulerParameters)
(virDomainGetSchedulerParametersFlags):
Tweak documentation wording.
(virDomainBlockStatsFlags): Likewise, and add sanity check.

13 years agoDon't overwrite error message during VM cleanup
Daniel P. Berrange [Tue, 1 Nov 2011 16:27:41 +0000 (16:27 +0000)]
Don't overwrite error message during VM cleanup

If an LXC VM fails to start, quite a few cleanup paths will
result in the original error message being overwritten. Some
other cleanup paths also forgot to actually terminate the VM.

* src/lxc/lxc_driver.c: Ensure VM is terminated on startup
  failure and preserve original error

13 years agoAdd support for probing filesystem with libblkid
Daniel P. Berrange [Tue, 1 Nov 2011 14:59:51 +0000 (14:59 +0000)]
Add support for probing filesystem with libblkid

The LXC code for mounting container filesystems from block devices
tries all filesystems in /etc/filesystems and possibly those in
/proc/filesystems. The regular mount binary, however, first tries
using libblkid to detect the format. Add support for doing the same
in libvirt, since Fedora's /etc/filesystems is missing many formats,
most notably ext4 which is the default filesystem Fedora uses!

* src/Makefile.am: Link libvirt_lxc to libblkid
* src/lxc/lxc_container.c: Probe filesystem format with libblkid

13 years agoFix error message when failing to detect filesystem
Daniel P. Berrange [Tue, 1 Nov 2011 14:34:02 +0000 (14:34 +0000)]
Fix error message when failing to detect filesystem

If we looped through /etc/filesystems trying to mount with each
type and failed all options, we forget to actually raise an
error message.

* src/lxc/lxc_container.c: Raise error if unable to detect
  the filesystems. Also fix existing error message

13 years agoWorkaround for broken kernel autofs mounts
Daniel P. Berrange [Tue, 1 Nov 2011 12:56:53 +0000 (12:56 +0000)]
Workaround for broken kernel autofs mounts

The kernel automounter is mostly broken wrt to containers. Most
notably if you start a new filesystem namespace and then attempt
to unmount any autofs filesystem, it will typically fail with a
weird error message like

  Failed to unmount '/.oldroot/sys/kernel/security':Too many levels of symbolic links

Attempting to detach the autofs mount using umount2(MNT_DETACH)
will also fail with the same error. Therefore if we get any error on
unmount()ing a filesystem from the old root FS when starting a
container, we must immediately break out and detach the entire
old root filesystem (ignoring any mounts below it).

This has the effect of making the old root filesystem inaccessible
to anything inside the container, but at the cost that the mounts
live on in the kernel until the container exits. Given that SystemD
uses autofs by default, we need LXC to be robust this scenario and
thus this tradeoff is worthwhile.

* src/lxc/lxc_container.c: Detach root filesystem if any umount
  operation fails.

13 years agoCorrectly handle '*' in /etc/filesystems
Daniel P. Berrange [Tue, 1 Nov 2011 12:29:25 +0000 (12:29 +0000)]
Correctly handle '*' in /etc/filesystems

The /etc/filesystems file can contain a '*' on the last line to
indicate that /proc/filessystems should be tried next. We have
a check that this '*' only occurs on the last line. Unfortunately
when we then start reading /proc/filesystems, we mistakenly think
we've seen '*' in /proc/filesystems and fail

* src/lxc/lxc_container.c: Skip '*' validation when we're reading
  /proc/filesystems

13 years agoEnsure errno is valid when returning from lxcContainerWaitForContinue
Daniel P. Berrange [Tue, 1 Nov 2011 12:28:26 +0000 (12:28 +0000)]
Ensure errno is valid when returning from lxcContainerWaitForContinue

Only some of the return paths of lxcContainerWaitForContinue will
have set errno. In other paths we need to set it manually to avoid
the caller getting a random stale errno value

* src/lxc/lxc_container.c: Set errno in lxcContainerWaitForContinue

13 years agoCreate /var/lib/libvirt/filesystems for LXC trees
Daniel P. Berrange [Tue, 1 Nov 2011 11:21:21 +0000 (11:21 +0000)]
Create /var/lib/libvirt/filesystems for LXC trees

We already have a /var/lib/libvirt/images for OS install images.
We need a separate /var/lib/libvirt/filesystems for OS install
trees, since SELinux labelling will be different

* libvirt.spec.in: Add /var/lib/libvirt/filesystems
* src/Makefile.am: Create /var/lib/libvirt/filesystems

13 years agoesx: Support folders in the path of vpx:// connection URIs
Matthias Bolte [Tue, 1 Nov 2011 16:12:37 +0000 (17:12 +0100)]
esx: Support folders in the path of vpx:// connection URIs

Allow the datacenter and compute resource parts of the path
to be prefixed with folders. Therefore, the way the path is
parsed has changed. Before, it was split in 2 or 3 items and
the items' meanings were determined by their positions. Now
the path can have 2 or more items and the the vCenter server
is asked whether a folder, datacenter of compute resource
with the specified name exists at the current hierarchy level.

Before the datacenter and compute resource lookup automatically
traversed folders during lookup. This is logic got removed
and folders have to be specified explicitly.

The proper datacenter path including folders is now used when
accessing a datastore over HTTPS. This makes virsh dumpxml
and define work for datacenters in folders.

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

13 years agoesx: Support vSphere 5.x
Patrice LACHANCE [Fri, 21 Oct 2011 05:56:07 +0000 (07:56 +0200)]
esx: Support vSphere 5.x

And virtual hardware version 8.

13 years agoFix URI alias prefix matching
Wen Ruo Lv [Tue, 1 Nov 2011 09:49:06 +0000 (17:49 +0800)]
Fix URI alias prefix matching

with /etc/libvirt/libvirt.conf below:
uri_aliases = [
  "hail=qemu:///system",
  "sleet=qemu+ssh://root 9 115 122 57/system",
  "sam=qemu+unix:///system?socket=/var/run/libvirt/libvirt-sock",
]
Neither "virsh -c hailly" nor "hai" should result in matching "hail=qemu:///system"

Fix URI alias prefix matching when connecting

Signed-off-by: Wen Ruo Lv <lvroyce@linux.vnet.ibm.com>
13 years agodocs: fix typo in <disk>/<target> example
Eric Blake [Tue, 1 Nov 2011 16:39:48 +0000 (10:39 -0600)]
docs: fix typo in <disk>/<target> example

* docs/formatdomain.html.in: Use dev, not def.
Reported by Alexander Biryukov.

13 years agoServerClient: Flush cached data
Michal Privoznik [Tue, 1 Nov 2011 13:14:54 +0000 (14:14 +0100)]
ServerClient: Flush cached data

If daemon is using SASL it reads client data into a cache. This cache is
big (usually 65KB) and can thus contain 2 or more messages. However,
on socket event we can dispatch only one message. So if we read two
messages at once, the second will not be dispatched as the socket event
goes away with filling the cache.
Moreover, when dispatching the cache we need to remember to take care
of client max requests limit.

13 years agoFix storage pool source comparison to avoid comparing with self
Daniel P. Berrange [Fri, 7 Oct 2011 16:38:09 +0000 (17:38 +0100)]
Fix storage pool source comparison to avoid comparing with self

If we are comparing storage pools we must skip comparing with
ourself, so that re-defining an existing pool works

* conf/storage_conf.c: Skip self when comparing

13 years agoqemu: pass virConnectPtr into Domain{Attach,Detach}*
Sage Weil [Mon, 31 Oct 2011 19:06:23 +0000 (13:06 -0600)]
qemu: pass virConnectPtr into Domain{Attach,Detach}*

The qemu RBD driver needs access to the conn in order to get the secret
needed for connecting to the ceph cluster.

Signed-off-by: Sage Weil <sage@newdream.net>
13 years agoqemu: plug memory leak
Alex Jia [Sat, 29 Oct 2011 17:12:56 +0000 (01:12 +0800)]
qemu: plug memory leak

Detected by Coverity. Leak introduced in commit 6cabc0b.

* src/qemu/qemu_command.c: Clean up on failure.

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agopython: Fix documentation of virStream recv
Matthias Bolte [Mon, 31 Oct 2011 16:11:33 +0000 (17:11 +0100)]
python: Fix documentation of virStream recv

This was fixed in be757a3f7baf93b for libvirt.c.

13 years agostartupPolicty: Minor cleanups
Michal Privoznik [Wed, 26 Oct 2011 09:12:45 +0000 (11:12 +0200)]
startupPolicty: Minor cleanups

This patch does some cleanups to my previous startupPolicy patchset.

13 years agoqemu: Restore the original states of PCI device when restarting daemon
Osier Yang [Thu, 20 Oct 2011 09:50:10 +0000 (17:50 +0800)]
qemu: Restore the original states of PCI device when restarting daemon

To support "managed" mode of host PCI device, we record the original
states (unbind_from_stub, remove_slot, and reprobe) so that could
reattach the device to host with original driver. But there is no XML
for theses attrs, and thus after daemon is restarted, we lose the
original states. It's easy to reproduce:

    1) virsh start domain
    2) virsh attach-device dom hostpci.xml (in 'managed' mode)
    3) service libvirtd restart
    4) virsh destroy domain

    You will see the device won't be bound to the original driver
if there was one.

This patch is to solve the problem by introducing internal XML
(won't be dumped to user, only dumped to status XML). The XML is:
    <origstates>
      <unbind/>
      <remove_slot/>
      <reprobe/>
    </origstates>

Which will be child node of <hostdev><source>...</souce></hostdev>.
(only for PCI device).

A new struct "virDomainHostdevOrigStates" is introduced for the XML,
and the according members are updated when preparing the PCI device.
And function "qemuUpdateActivePciHostdevs" is modified to honor
the original states. Use of qemuGetPciHostDeviceList is removed
in function "qemuUpdateActivePciHostdevs", and the "managed" value of
the device config is honored by the change. This fixes another problem
alongside:

    qemuGetPciHostDeviceList set the device as "managed" force
    regardless of whether the device is configured as "managed='yes'"
    or not in XML, which is not right.

13 years agovbox: Add support for VirtualBox 4.1
Matthias Bolte [Sat, 29 Oct 2011 19:26:57 +0000 (21:26 +0200)]
vbox: Add support for VirtualBox 4.1

Deal with the incompatible changes in the VirtualBox 4.1 API.

INetworkAdapter has its different AttachTo* method replaced by
a settable attachmentType property.

The maximum number of network adapters is now requestable per
chipset type.

The OpenMedium method got a bool parameter to request opening
a medium under a new IID.

13 years agovbox: Support shared folders
Matthias Bolte [Tue, 7 Jun 2011 11:29:34 +0000 (13:29 +0200)]
vbox: Support shared folders

Shared folders are handled as filesystems and can also be hotplugged.

13 years agoxenapi: Improve error reporting in xenapiOpen once again
Matthias Bolte [Thu, 21 Jul 2011 13:16:11 +0000 (15:16 +0200)]
xenapi: Improve error reporting in xenapiOpen once again

privP->session->error_description is a list and in order to get the
complete error message all parts of the list should be concatenated.
xenapiSessionErrorHandler does this when its third parameter is NULL.
The current code discards all but the first part of the error message
resulting in a potentially incomplete error message.

This partly reverts 006be75ee214f9b4, that tried to avoid reporting
a (null) in the error message. The actual problem is more general in
returnErrorFromSession that might return NULL if there is no error.

Make sure that returnErrorFromSession return non-NULL always. Also
don't skip the last error message part.

13 years agomacvtap: Fix error return value convention/inconsistencies
Roopa Prabhu [Fri, 28 Oct 2011 22:04:07 +0000 (15:04 -0700)]
macvtap: Fix error return value convention/inconsistencies

- changed some return 1's to return -1
- changed if (rc) error checks to if (rc < 0)
- fixed some other minor convention violations

I might have missed some. Can fix in another patch or can respin

Signed-off-by: Roopa Prabhu <roprabhu@cisco.com>
Reported-by: Eric Blake <eblake@redhat.com>
Reported-by: Laine Stump <laine@laine.org>
Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agoUse a common xml type for ceph secret usage.
Josh Durgin [Fri, 28 Oct 2011 21:19:34 +0000 (14:19 -0700)]
Use a common xml type for ceph secret usage.

The types used in domaincommon.rng and secret.rng should be the same.

Move genericName to basictypes.rng, then drop redundant types now
that secret.rng uses basictypes.rng.

Signed-off-by: Josh Durgin <josh.durgin@dreamhost.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agopci address conflict when virtio disk with drive type
Xu He Jie [Fri, 28 Oct 2011 09:57:21 +0000 (17:57 +0800)]
pci address conflict when virtio disk with drive type

When using the xml as below:
------------------------------------------------------
<devices>
  <emulator>/home/soulxu/data/work-code/qemu-kvm/x86_64-softmmu/qemu-system-x86_64</emulator>
    <disk type='file' device='disk'>
    <driver name='qemu' type='qcow2'/>
    <source file='/home/soulxu/data/VM/images/linux.img'/>
    <target dev='vda' bus='virtio'/>
    <address type='drive' controller='0' bus='0' unit='0'/>
  </disk>
  <input type='mouse' bus='ps2'/>
  <graphics type='vnc' port='-1' autoport='yes'/>
  <video>
    <model type='cirrus' vram='9216' heads='1'/>
    <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
  </video>
  <memballoon model='virtio'>
    <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
  </memballoon>
</devices>
------------------------------------------------------

Then can't startup qemu, the error message as below:
virsh # start test-vm
error: Failed to start domain test-vm
error: internal error process exited while connecting to monitor: qemu-system-x86_64: -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3: PCI: slot 3 function 0 not available for virtio-balloon-pci, in use by virtio-blk-pci
qemu-system-x86_64: -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3: Device 'virtio-balloon-pci' could not be initialized

So adding check for bus type and address type. Only the address of pci type support by virtio bus.

Signed-off-by: Xu He Jie <xuhj@linux.vnet.ibm.com>
13 years agosecret: fix bad patch application
Eric Blake [Fri, 28 Oct 2011 18:55:04 +0000 (12:55 -0600)]
secret: fix bad patch application

In hand-applying Josh and Sage's patch, I missed out on a break.

* src/conf/secret_conf.c (virSecretDefFree): Fix my botch.

13 years agostorage: add auth to virDomainDiskDef
Josh Durgin [Fri, 28 Oct 2011 18:29:39 +0000 (12:29 -0600)]
storage: add auth to virDomainDiskDef

Add additional fields to let you specify the how to authenticate with a disk.
The secret to use may be referenced by a usage string or a UUID, i.e.:

<auth username='myuser'>
 <secret type='ceph' usage='secretname'/>
</auth>

or

<auth username='myuser'>
 <secret type='ceph' uuid='0a81f5b2-8403-7b23-c8d6-21ccc2f80d6f'/>
</auth>

Signed-off-by: Josh Durgin <josh.durgin@dreamhost.com>
13 years agosecret: add Ceph secret type
Sage Weil [Fri, 28 Oct 2011 17:30:45 +0000 (11:30 -0600)]
secret: add Ceph secret type

Add a new secret type to store a Ceph authentication key. The name
is simply an identifier for easy human reference.

The xml looks like this:

<secret ephemeral='no' private='no'>
 <uuid>0a81f5b2-8403-7b23-c8d6-21ccc2f80d6f</uuid>
 <usage type='ceph'>
   <name>mycluster_admin</name>
 </usage>
</secret>

Signed-off-by: Sage Weil <sage@newdream.net>
Signed-off-by: Josh Durgin <josh.durgin@dreamhost.net>
13 years agoqemu: plug memory leak
Alex Jia [Fri, 28 Oct 2011 11:35:09 +0000 (19:35 +0800)]
qemu: plug memory leak

Leak introduced in commit c1bc3d89.
Detected by valgrind:

==18462== 1,100 bytes in 1 blocks are definitely lost in loss record 183 of 184
==18462==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==18462==    by 0x4A06167: realloc (vg_replace_malloc.c:525)
==18462==    by 0x4AADBB: virReallocN (memory.c:161)
==18462==    by 0x4A975E: virBufferGrow (buf.c:117)
==18462==    by 0x4A9D92: virBufferVasprintf (buf.c:290)
==18462==    by 0x4A9EF7: virBufferAsprintf (buf.c:263)
==18462==    by 0x429488: qemuBuildControllerDevStr (qemu_command.c:1993)
==18462==    by 0x42C4B6: qemuBuildCommandLine (qemu_command.c:3803)
==18462==    by 0x41A604: testCompareXMLToArgvHelper (qemuxml2argvtest.c:124)
==18462==    by 0x41BB81: virtTestRun (testutils.c:141)
==18462==    by 0x416DFF: mymain (qemuxml2argvtest.c:369)
==18462==    by 0x41B277: virtTestMain (testutils.c:696)
==18462==
==18462== LEAK SUMMARY:
==18462==    definitely lost: 1,100 bytes in 1 blocks
==18462==    indirectly lost: 0 bytes in 0 blocks

* src/qemu/qemu_command.c (qemuBuildCommandLine): Clean up on success.

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agoqemu: avoid leaking uninit data from hotplug to dumpxml
Eric Blake [Wed, 26 Oct 2011 23:40:12 +0000 (17:40 -0600)]
qemu: avoid leaking uninit data from hotplug to dumpxml

Detected by Coverity.  The fix in 2c27dfa didn't catch all bad
instances of memcpy().  Thankfully, on further analysis, all of
the problematic uses are only triggered by old qemu that lacks
-device.

* src/qemu/qemu_hotplug.c (qemuDomainAttachPciDiskDevice)
(qemuDomainAttachNetDevice, qemuDomainAttachHostPciDevice): Init
all fields since monitor only populates some of them.

13 years agoutil: Fix virUUIDGeneratePseudoRandomBytes
Ryota Ozaki [Fri, 28 Oct 2011 11:06:20 +0000 (20:06 +0900)]
util: Fix virUUIDGeneratePseudoRandomBytes

It forgets to move a pointer to a buffer for UUID and as a result
fills only the first byte of the buffer.

13 years agoImplement RPC driver support for virDomainOpenGraphics
Daniel P. Berrange [Fri, 21 Oct 2011 11:49:23 +0000 (12:49 +0100)]
Implement RPC driver support for virDomainOpenGraphics

Since it needs to access file descriptors passed in the msg,
the RPC driver for virDomainOpenGraphics needs to be manually
implemented.

* daemon/remote.c: RPC server dispatcher
* src/remote/remote_driver.c: RPC client dispatcher
* src/remote/remote_protocol.x: Define protocol

13 years agoExtend RPC server to allow FD passing
Daniel P. Berrange [Fri, 21 Oct 2011 11:12:28 +0000 (12:12 +0100)]
Extend RPC server to allow FD passing

The RPC server classes are extended to allow FDs to be received
from clients with calls. There is not currently any way for a
procedure to pass FDs back to the client with replies

* daemon/remote.c, src/rpc/gendispatch.pl: Change virNetMessageHeaderPtr
  param to virNetMessagePtr in dispatcher impls
* src/rpc/virnetserver.c, src/rpc/virnetserverclient.c,
  src/rpc/virnetserverprogram.c, src/rpc/virnetserverprogram.h:
  Extend to support FD passing

13 years agoAdd client side support for FD passing
Daniel P. Berrange [Fri, 21 Oct 2011 10:48:03 +0000 (11:48 +0100)]
Add client side support for FD passing

Extend the RPC client code to allow file descriptors to be sent
to the server with calls, and received back with replies.

* src/remote/remote_driver.c: Stub extra args
* src/libvirt_private.syms, src/rpc/virnetclient.c,
  src/rpc/virnetclient.h, src/rpc/virnetclientprogram.c,
  src/rpc/virnetclientprogram.h: Extend APIs to allow
  FD passing

13 years agoExtend RPC protocol to allow FD passing
Daniel P. Berrange [Fri, 21 Oct 2011 10:30:12 +0000 (11:30 +0100)]
Extend RPC protocol to allow FD passing

Define two new RPC message types VIR_NET_CALL_WITH_FDS and
VIR_NET_REPLY_WITH_FDS. These message types are equivalent
to VIR_NET_CALL and VIR_NET_REPLY, except that between the
message header, and payload there is a 32-bit integer field
specifying how many file descriptors have been passed.

The actual file descriptors are sent/recv'd out of band.

* src/rpc/virnetmessage.c, src/rpc/virnetmessage.h,
  src/libvirt_private.syms: Add support for handling
  passed file descriptors
* src/rpc/virnetprotocol.x: Extend protocol for FD
  passing

13 years agoAdd APIs for virNetSocket for sending/receiving file descriptors
Daniel P. Berrange [Fri, 21 Oct 2011 10:13:21 +0000 (11:13 +0100)]
Add APIs for virNetSocket for sending/receiving file descriptors

Add APIs to the virNetSocket object, to allow file descriptors
to be sent/received over UNIX domain socket connections

* src/rpc/virnetsocket.c, src/rpc/virnetsocket.h,
  src/libvirt_private.syms: Add APIs for FD send/recv

13 years agoWire up QEMU implementation for virDomainOpenGraphics
Daniel P. Berrange [Fri, 21 Oct 2011 08:00:13 +0000 (09:00 +0100)]
Wire up QEMU implementation for virDomainOpenGraphics

The QEMU monitor command 'add_client' can be used to connect to
a VNC or SPICE graphics display. This allows for implementation
of the virDomainOpenGraphics API

* src/qemu/qemu_driver.c: Implement virDomainOpenGraphics
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
  src/qemu/qemu_monitor_json.c, src/qemu/qemu_monitor_json.h,
  src/qemu/qemu_monitor_text.c, src/qemu/qemu_monitor_text.h:
  Add binding for 'add_client' command

13 years agoExtend graphics event to include UNIX socket
Daniel P. Berrange [Fri, 21 Oct 2011 08:14:02 +0000 (09:14 +0100)]
Extend graphics event to include UNIX socket

Not all VNC/SPICE servers use a TCP socket for their connections.
It is possible to configure a UNIX socket server. The graphics
event must thus include a UNIX socket address type.

* include/libvirt/libvirt.h.in: Add UNIX socket address type
  for graphics event
* src/qemu/qemu_monitor_json.c: Add 'unix' string to address
  type enum

13 years agoIntroduce the virDomainOpenGraphics API
Daniel P. Berrange [Fri, 21 Oct 2011 08:00:37 +0000 (09:00 +0100)]
Introduce the virDomainOpenGraphics API

The virDomainOpenGraphics API allows a libvirt client to pass in
a file descriptor for an open socket pair, and get it connected
to the graphics display of the guest. This is limited to working
with local libvirt hypervisors connected over a UNIX domain
socket, since it will use UNIX FD passing

* include/libvirt/libvirt.h.in: Define virDomainOpenGraphics
* src/driver.h: Define driver for virDomainOpenGraphics
* src/libvirt_public.syms, src/libvirt.c: Entry point for
  virDomainOpenGraphics
* src/libvirt_internal.h: VIR_DRV_FEATURE_FD_PASSING