]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
11 years agoqemu: Report the offset from host UTC for RTC_CHANGE event
Osier Yang [Wed, 5 Jun 2013 10:32:59 +0000 (18:32 +0800)]
qemu: Report the offset from host UTC for RTC_CHANGE event

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

Though both libvirt and QEMU's document say RTC_CHANGE returns
the offset from the host UTC, qemu actually returns the offset
from the specified date instead when specific date is provided
(-rtc base=$date).

It's not safe for qemu to fix it in code, it worked like that
for 3 years, changing it now may break other QEMU use cases.
What qemu tries to do is to fix the document:

http://lists.gnu.org/archive/html/qemu-devel/2013-05/msg04782.html

And in libvirt side, instead of replying on the value from qemu,
this converts the offset returned from qemu to the offset from
host UTC, by:

  /*
   * a: the offset from qemu RTC_CHANGE event
   * b: The specified date (-rtc base=$date)
   * c: the host date when libvirt gets the RTC_CHANGE event
   * offset: What libvirt will report
   */

  offset = a + (b - c);

The specified date (-rtc base=$date) is recorded in clock's def as
an internal only member (may be useful to exposed outside?).

Internal only XML tag "basetime" is introduced to not lose the
guest's basetime after libvirt restarting/reloading:

<clock offset='variable' adjustment='304' basis='utc' basetime='1370423588'/>

11 years agoqemu: simplify CPU command line parsing
Ján Tomko [Thu, 2 May 2013 18:21:31 +0000 (20:21 +0200)]
qemu: simplify CPU command line parsing

Use virStringSplit. Change the 'error' label to 'cleanup' to prevent
memory leaks on error.

11 years agoqemu: change two-state int parameters to bool
Ján Tomko [Fri, 24 May 2013 10:47:17 +0000 (12:47 +0200)]
qemu: change two-state int parameters to bool

11 years agonwfilter: change two-state int parameters to bool
Ján Tomko [Fri, 24 May 2013 10:32:31 +0000 (12:32 +0200)]
nwfilter: change two-state int parameters to bool

11 years agoRemove redundant two-state integers
Ján Tomko [Fri, 24 May 2013 10:29:28 +0000 (12:29 +0200)]
Remove redundant two-state integers

11 years agoReplace two-state local integers with bool
Ján Tomko [Fri, 24 May 2013 10:14:02 +0000 (12:14 +0200)]
Replace two-state local integers with bool

Found with 'git grep "= 1"'.

11 years agostorage: Avoid unnecessary ternary operators and refactor the code
Peter Krempa [Wed, 5 Jun 2013 07:42:59 +0000 (09:42 +0200)]
storage: Avoid unnecessary ternary operators and refactor the code

Setting of local variables in virStorageBackendCreateQemuImgCmd was
unnecessarily cluttered with ternary operators and repeated testing of
of conditions.

This patch refactors the function to use if statements and improves
error reporting in case inputvol is specified but does not contain
target path. Previously we would complain about "unknown storage vol
type 0" instead of the actual problem.

11 years agoopenvz: Fix code coverage issue in OpenVZ driver
Alvaro Polo [Thu, 6 Jun 2013 07:53:54 +0000 (09:53 +0200)]
openvz: Fix code coverage issue in OpenVZ driver

After fixing an invalid usage of virDomainNetDef in OpenVZ driver,
a coverage issue appeared. This was caused by a still invalid usage
of net->data.ethernet.dev for non ethernet networking.

11 years agoqemu: Reformat listen address prior to checking
Michal Privoznik [Wed, 5 Jun 2013 15:05:50 +0000 (17:05 +0200)]
qemu: Reformat listen address prior to checking

Currently, a listen address for a SPICE server can be specified. Later,
when the domain is migrated, we need to relocate the graphics which
involves telling new destination to the SPICE server. However, we can't
just assume the listen address is the new location, because the listen
address can be ANYCAST (0.0.0.0 for IPv4, :: for IPv6). In which case,
we want to pass the remote hostname. But there are some troubles with
ANYCAST. In both IPv4 and IPv6 it has many ways for specifying such
address. For instance, in IPv4: 0, 0.0, 0.0.0, 0.0.0.0.  The number of
variations gets bigger in IPv6 world. Hence, in order to check for
ANYCAST address sanely, we should take the provided listen address,
parse it and format back in it's full form. Which is exactly what this
patch does.

11 years agobuild: fix build without posix_fallocate
Eric Blake [Thu, 6 Jun 2013 02:33:15 +0000 (20:33 -0600)]
build: fix build without posix_fallocate

Such as on FreeBSD.  Broken in commit aa2a4cff7.

* src/util/virstoragefile.c (virStorageFileResize): Add missing ';',
mark conditionally unused variables.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoEnsure non-root can read /proc/meminfo file in LXC containers
Daniel P. Berrange [Tue, 4 Jun 2013 16:37:03 +0000 (17:37 +0100)]
Ensure non-root can read /proc/meminfo file in LXC containers

By default files in a FUSE mount can only be accessed by the
user which created them, even if the file permissions would
otherwise allow it. To allow other users to access the FUSE
mount the 'allow_other' mount option must be used. This bug
prevented non-root users in an LXC container from reading
the /proc/meminfo file.

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

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoRemove legacy code for single-instance devpts filesystem
Daniel P. Berrange [Tue, 4 Jun 2013 13:40:57 +0000 (14:40 +0100)]
Remove legacy code for single-instance devpts filesystem

Earlier commit f7e8653f dropped support for using LXC with
kernels having single-instance devpts filesystem from the
LXC controller. It forgot to remove the same code from the
LXC container setup.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agostorage: Provide better error message if metadata pre-alloc is unsupported
Peter Krempa [Wed, 5 Jun 2013 07:38:41 +0000 (09:38 +0200)]
storage: Provide better error message if metadata pre-alloc is unsupported

Instead of a unknown flag error report that metadata pre-allocation is
not supported with the requested volume creation method.

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

11 years agostorage: Clean up function header and reflow error message
Peter Krempa [Wed, 5 Jun 2013 07:41:38 +0000 (09:41 +0200)]
storage: Clean up function header and reflow error message

Comply with the coding standard and save a few lines.

11 years agostoragevolxml2argvtest: Report better error messages on test failure
Peter Krempa [Wed, 5 Jun 2013 08:49:15 +0000 (10:49 +0200)]
storagevolxml2argvtest: Report better error messages on test failure

If the creation of the commandline failed, libvirt always reported "out
of memory" from the virCommandToString function rather than the proper
error that happened in virStorageBackendCreateQemuImgCmd. Error out
earlier.

11 years agomaint: don't use config.h in .h files
Eric Blake [Fri, 31 May 2013 17:52:51 +0000 (11:52 -0600)]
maint: don't use config.h in .h files

Enforce the rule that .h files don't need to (redundantly)
include <config.h>.

* cfg.mk (sc_prohibit_config_h_in_headers): New rule.
(_virsh_includes): Delete; instead, inline a smaller number of
exclusions...
(exclude_file_name_regexp--sc_require_config_h)
(exclude_file_name_regexp--sc_require_config_h_first): ...here.
* daemon/libvirtd.h (includes): Fix offenders.
* src/driver.h (includes): Likewise.
* src/gnutls_1_0_compat.h (includes): Likewise.
* src/libxl/libxl_conf.h (includes): Likewise.
* src/libxl/libxl_driver.h (includes): Likewise.
* src/lxc/lxc_conf.h (includes): Likewise.
* src/lxc/lxc_driver.h (includes): Likewise.
* src/lxc/lxc_fuse.h (includes): Likewise.
* src/network/bridge_driver.h (includes): Likewise.
* src/phyp/phyp_driver.h (includes): Likewise.
* src/qemu/qemu_conf.h (includes): Likewise.
* src/util/virnetlink.h (includes): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoqemu: Abstract code for the cpu controller setting into a helper
Osier Yang [Fri, 24 May 2013 09:08:27 +0000 (17:08 +0800)]
qemu: Abstract code for the cpu controller setting into a helper

11 years agostorage: Forbid to shrink the vol's capacity if no --shrink is specified
Osier Yang [Fri, 31 May 2013 05:16:15 +0000 (13:16 +0800)]
storage: Forbid to shrink the vol's capacity if no --shrink is specified

As the document for "virsh-resize" says:
<...>
Attempts to shrink the volume will fail unless I<--shrink> is present;
</...>

This makes sense as it at least prevent the user shrinking the important
data of volume without a notice.

11 years agostorage: Support preallocate the new capacity for vol-resize
Osier Yang [Fri, 31 May 2013 05:16:14 +0000 (13:16 +0800)]
storage: Support preallocate the new capacity for vol-resize

The document for "vol-resize" says the new capacity will be sparse
unless "--allocate" is specified, however, the "--allocate" flag
is never implemented. This implements the "--allocate" flag for
fs backend's raw type volume, based on posix_fallocate and the
syscall SYS_fallocate.

11 years agovirtlockd: fix socket path
Ján Tomko [Tue, 4 Jun 2013 11:36:56 +0000 (13:36 +0200)]
virtlockd: fix socket path

Change the socket path to match the one used by lockd driver.

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

11 years agosnapshot: remove mutually exclusive memory and disk-only duplicate check
Guannan Ren [Tue, 4 Jun 2013 08:42:55 +0000 (16:42 +0800)]
snapshot: remove mutually exclusive memory and disk-only duplicate check

The work was done at the time of snapshot xmlstring parsing

 if (offline && def->memory &&
     def->memory != VIR_DOMAIN_SNAPSHOT_LOCATION_NONE) {
     virReportError(...);
 }

11 years agonwfilter: grab driver lock earlier during init (bz96649)
Stefan Berger [Tue, 4 Jun 2013 18:50:20 +0000 (14:50 -0400)]
nwfilter: grab driver lock earlier during init (bz96649)

This patch is in relation to Bug 966449:

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

This is a patch addressing the coredump.

Thread 1 must be calling  nwfilterDriverRemoveDBusMatches(). It does so with
nwfilterDriverLock held. In the patch below I am now moving the
nwfilterDriverLock(driverState) further up so that the initialization, which
seems to either take a long time or is entirely stuck, occurs with the lock
held and the shutdown cannot occur at the same time.

Remove the lock in virNWFilterDriverIsWatchingFirewallD to avoid
double-locking.

11 years agoFix a invalid usage of virDomainNetDef in OpenVZ driver
Alvaro Polo [Tue, 4 Jun 2013 07:44:32 +0000 (09:44 +0200)]
Fix a invalid usage of virDomainNetDef in OpenVZ driver

OpenVZ was accessing ethernet data to obtain the guest iface name
regardless the domain is configured to use ethernet or bridged
networking. This prevented the guest network interface to be rightly
named for bridged networking.

11 years agodocs: add spaces to formatstorage.html
Ján Tomko [Tue, 4 Jun 2013 13:20:51 +0000 (15:20 +0200)]
docs: add spaces to formatstorage.html

Let the pool types breathe.

11 years agovirsh: Allow attach-disk to specify disk wwn
Osier Yang [Tue, 4 Jun 2013 03:27:04 +0000 (11:27 +0800)]
virsh: Allow attach-disk to specify disk wwn

Commit 6e73850b01ee support to set wwn for disks, but it was not
exposed to attach-disk.

11 years agotests: fix typo in securityselinuxtest
Ján Tomko [Tue, 4 Jun 2013 11:01:03 +0000 (13:01 +0200)]
tests: fix typo in securityselinuxtest

11 years agovirsh: Obey pool-or-uuid spec when creating volumes
Jiri Denemark [Tue, 4 Jun 2013 08:16:02 +0000 (10:16 +0200)]
virsh: Obey pool-or-uuid spec when creating volumes

Our documentation says a pool may be referenced by its name or UUID
anywhere if it makes sense (pool-name and pool-uuid are the only
exceptions). However, vol-create and vol-create-as commands did not obey
this.

11 years agolibvirt-qemu: Dispatch errors from virDomainQemuAgentCommand()
Peter Krempa [Mon, 3 Jun 2013 14:12:52 +0000 (16:12 +0200)]
libvirt-qemu: Dispatch errors from virDomainQemuAgentCommand()

The original implementation didn't follow the established pattern and
did not dispatch errors in case of failure.

11 years agoqemu: Properly report guest agent errors on command passthrough
Peter Krempa [Mon, 3 Jun 2013 13:58:31 +0000 (15:58 +0200)]
qemu: Properly report guest agent errors on command passthrough

The code for arbitrary guest agent passthrough was horribly broken since
introduction. Fix it to correctly report errors.

11 years agovirsh-domain: Report errors and don't deref NULL in qemu-agent-command
Peter Krempa [Mon, 3 Jun 2013 13:42:26 +0000 (15:42 +0200)]
virsh-domain: Report errors and don't deref NULL in qemu-agent-command

Check the returned value for NULL and take the cleanup path
appropriately if the API fails.

11 years agoRPC: Support up to 16384 cpus on the host and 4096 in the guest
Peter Krempa [Tue, 28 May 2013 12:29:12 +0000 (14:29 +0200)]
RPC: Support up to 16384 cpus on the host and 4096 in the guest

The RPC limits for cpu maps didn't allow to use libvirt on ultra big
boxes. This patch increases size of the limits to support a maximum of
16384 cpus on the host with a maximum of 4096 cpus per guest.
The full cpu map of such a system takes 8 megabytes and the map for
vcpu pinning is 2 kilobytes long.

11 years agospec: Explicitly require libgcrypt-devel
Jiri Denemark [Mon, 3 Jun 2013 12:57:29 +0000 (14:57 +0200)]
spec: Explicitly require libgcrypt-devel

Our configure.ac says:

    Not all versions of gnutls include -lgcrypt, and so we add
    it explicitly for the calls to gcry_control/check_version

Thus we cannot rely on gnutls-devel to bring grcypt-devel as a
dependency.

11 years agovirsh iface-bridge: Ignore delay if stp is turned off
Jiri Denemark [Fri, 31 May 2013 23:28:36 +0000 (01:28 +0200)]
virsh iface-bridge: Ignore delay if stp is turned off

Delay only makes sense with STP enabled.

11 years agoFix warning about using an uninitialized next_unit value
Jiri Denemark [Mon, 3 Jun 2013 10:19:09 +0000 (12:19 +0200)]
Fix warning about using an uninitialized next_unit value

Using an uninitialized value and a bool saying if the value is valid may
confuse compilators.

11 years agovirsh-domain: Add --live, --config, --current logic to cmdAttachInterface
Peter Krempa [Tue, 28 May 2013 09:07:33 +0000 (11:07 +0200)]
virsh-domain: Add --live, --config, --current logic to cmdAttachInterface

Use the approach established in commit
69ce3ffa8d431e9810607c6e00b7cfcc481b491d to improve this function too.

11 years agovirsh-domain: Add --live, --config, --current logic to cmdAttachDisk
Peter Krempa [Tue, 28 May 2013 09:07:33 +0000 (11:07 +0200)]
virsh-domain: Add --live, --config, --current logic to cmdAttachDisk

Use the approach established in commit
69ce3ffa8d431e9810607c6e00b7cfcc481b491d to improve this function too.

11 years agovirsh-domain: Add --live, --config, --current logic to cmdAttachDevice
Peter Krempa [Tue, 28 May 2013 09:07:33 +0000 (11:07 +0200)]
virsh-domain: Add --live, --config, --current logic to cmdAttachDevice

Use the approach established in commit
69ce3ffa8d431e9810607c6e00b7cfcc481b491d to improve this function too.

11 years agouse virBitmapFree instead of VIR_FREE for cpumask
Ján Tomko [Sat, 1 Jun 2013 21:29:09 +0000 (23:29 +0200)]
use virBitmapFree instead of VIR_FREE for cpumask

Found by 'git grep FREE.*cpumask' after looking at 31f1f6b.

11 years agousb: don't spoil decimal addresses
Martin Kletzander [Fri, 31 May 2013 16:36:11 +0000 (18:36 +0200)]
usb: don't spoil decimal addresses

For USB devices, dev->name gets formated as %.3o:%.3o even though the
numbers are decimal.

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

11 years agoRelease of libvirt 1.0.6
Daniel Veillard [Mon, 3 Jun 2013 10:09:56 +0000 (12:09 +0200)]
Release of libvirt 1.0.6

* configure.ac docs/news.html.in libvirt.spec.in: update for the release
* po/*.po*: pull localization updates and regenerate the po

11 years agoStorage: Fix the indention of rbd test file
Osier Yang [Tue, 28 May 2013 06:39:42 +0000 (14:39 +0800)]
Storage: Fix the indention of rbd test file

11 years agonodedev_hal: Modernize the function's style
Osier Yang [Sat, 1 Jun 2013 02:52:17 +0000 (10:52 +0800)]
nodedev_hal: Modernize the function's style

Use style like:

void
foo (const char *name)
{
    printf("Hello, %s\n", name);
}

Later patches will clean up node_device_hal.c more.

11 years agoconf: Generate address for scsi host device automatically
Osier Yang [Fri, 31 May 2013 10:09:24 +0000 (18:09 +0800)]
conf: Generate address for scsi host device automatically

With unknown good reasons, the attribute "bus" of scsi device
address is always set to 0, same for attribute "target". (See
virDomainDiskDefAssignAddress).

Though we might need to change the algorithm to honor "bus"
and "target" too, that's a different issue. The address generator
for scsi host device in this patch just follows the unknown
good reasons, only considering the "controller" and "unit".
It walks through all scsi controllers and their units, to see
if the address $controller:0:0:$unit can be used (if not used
by any disk or scsi host device yet), if found one, it sits on
it, otherwise, it creates a new controller (actually the controller
is implicitly created by someone else), and sits on
$new_controller:0:0:0 instead.

11 years agoqemu: prevent termination of guests w/hostdev on driver reconnect
Laine Stump [Fri, 31 May 2013 18:30:09 +0000 (14:30 -0400)]
qemu: prevent termination of guests w/hostdev on driver reconnect

This should resolve:

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

The problem was that qemuUpdateActivePciHostdevs was returning 0
(success) when no hostdevs were present, but would otherwise return -1
(failure) even when it completed successfully. It is only called from
qemuProcessReconnect(), and when qemuProcessReconnect got back an
error, it would not only stop reconnecting, but would terminate the
guest qemu process "to remove danger of it ending up running twice if
user tries to start it again later".

(This bug was introduced in commit 011cf7ad, which was pushed between
v1.0.2 and v1.0.3, so all maintenance branches from v1.0.3 up to 1.0.5
will need this one line patch applied.)

11 years agovbox: define DYNLIB_NAME for kFreeBSD
Guido Günther [Thu, 30 May 2013 20:07:46 +0000 (22:07 +0200)]
vbox: define DYNLIB_NAME for kFreeBSD

Similar to what Eric did for Cygwin it helps at least to compile
without --without-vbox

11 years agobuild: skip qemu in tests when !WITH_QEMU
Eric Blake [Fri, 31 May 2013 16:47:22 +0000 (10:47 -0600)]
build: skip qemu in tests when !WITH_QEMU

A mingw build (where the qemu driver is not built, so WITH_QEMU
is undefined) failed with:

In file included from ../../src/qemu/qemu_command.h:30:0,
                 from ../../tests/testutilsqemu.h:4,
                 from ../../tests/networkxml2xmltest.c:14:
../../src/qemu/qemu_conf.h:53:4: error: #error "Port me"

But since testutilsqemu.c is already conditional, the header
should be likewise.

* tests/testutilsqemu.h: Make content conditional.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoIntroduce virFilePrintf() as a portable fprintf()
Daniel P. Berrange [Fri, 17 May 2013 14:11:24 +0000 (15:11 +0100)]
Introduce virFilePrintf() as a portable fprintf()

We can't use GNULIB's fprintf-posix due to licensing
incompatibilities. We do already have a portable
formatting via virAsprintf() which we got from GNULIB
though. We can use to create a virFilePrintf() function.

But really gnulib could just provide a 'fprintf'
module, that depended on just its 'asprintf' module.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoDocument that runtime changes may be lost after S4 suspend
Jiri Denemark [Fri, 31 May 2013 16:00:48 +0000 (18:00 +0200)]
Document that runtime changes may be lost after S4 suspend

11 years agoqemu: escape literal IPv6 address in NBD migration
Ján Tomko [Fri, 31 May 2013 11:24:06 +0000 (13:24 +0200)]
qemu: escape literal IPv6 address in NBD migration

A literal IPv6 must be escaped, otherwise migration fails with:
unable to execute QEMU command 'drive-mirror': address resolution failed
for f0::0d:5901: Servname not supported for ai_socktype
since QEMU treats everything after the first ':' as the port.

11 years agoCheck for existence of interface prior to setting terminate flag
John Ferlan [Fri, 31 May 2013 11:26:30 +0000 (07:26 -0400)]
Check for existence of interface prior to setting terminate flag

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

During domain destruction it's possible that the learnIPAddressThread has
already removed the interface prior to the teardown filter path being run.
The teardown code would only be telling the thread to terminate.

11 years agoResolve memory leak found by valgrind
John Ferlan [Fri, 31 May 2013 13:07:28 +0000 (09:07 -0400)]
Resolve memory leak found by valgrind

Commit '6afdfc8e' adjusted the exit and error paths to go through the error
and cleanup labels, but neglected to remove the return ret prior to cleanup.
Also noted the 'type' xml string fetch was never checked for NULL which
could lead to some interesting results.

11 years agoqemu: snapshot: Don't kill access to disk if snapshot creation fails
Peter Krempa [Fri, 31 May 2013 13:38:46 +0000 (15:38 +0200)]
qemu: snapshot: Don't kill access to disk if snapshot creation fails

If snapshot creation failed for example due to invalid use of the
"REUSE_EXTERNAL" flag, libvirt killed access to the original image file
instead of the new image file. On machines with selinux this kills the
whole VM as the selinux context is enforced immediately.

* qemu_driver.c:qemuDomainSnapshotUndoSingleDiskActive():
    - Kill access to the new image file instead of the old one.

Partially resolves: https://bugzilla.redhat.com/show_bug.cgi?id=906639

11 years agoqemu: Fix damaged whitespace
Peter Krempa [Fri, 31 May 2013 13:33:37 +0000 (15:33 +0200)]
qemu: Fix damaged whitespace

After deleting "WithDriver" from the async job function the code was
unaligned.

11 years agoProperly indent function's opening bracket
Martin Kletzander [Fri, 31 May 2013 12:26:16 +0000 (14:26 +0200)]
Properly indent function's opening bracket

11 years agobuild: use correct rpc.h for virtlockd
Eric Blake [Thu, 30 May 2013 21:49:40 +0000 (15:49 -0600)]
build: use correct rpc.h for virtlockd

Commit d671121d was incomplete; I hit another compile fail on
cygwin not finding the correct rpc/rpc.h.

* src/Makefile.am (virtlockd_CFLAGS): Add XDR_CFLAGS.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: work around cygwin header bug
Eric Blake [Thu, 30 May 2013 20:51:58 +0000 (14:51 -0600)]
build: work around cygwin header bug

A bug in Cygwin [1] and poor error messages from gcc [2] lead
to this confusing compilation error:

qemu/qemu_monitor.c:418:9: error: passing argument 2 of 'sendmsg' from incmpatible pointer type
/usr/include/sys/socket.h:42:11: note: expected 'const struct msghdr *' but argument is of type 'struct msghdr *'

[1] http://cygwin.com/ml/cygwin/2013-05/msg00451.html
[2] http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57475

* src/qemu/qemu_monitor.c (includes): Include <sys/socket.h>
before <sys/un.h>.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: cast [ug]id_t when printing
Eric Blake [Thu, 30 May 2013 13:59:14 +0000 (07:59 -0600)]
build: cast [ug]id_t when printing

This is a recurring problem for cygwin :)
For example, see commit 23a4df88.

qemu/qemu_driver.c: In function 'qemuStateInitialize':
qemu/qemu_driver.c:691:13: error: format '%d' expects type 'int', but argument 8 has type 'uid_t' [-Wformat]

* src/qemu/qemu_driver.c (qemuStateInitialize): Add casts.
* daemon/remote.c (remoteDispatchAuthList): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: port qemu to cygwin
Eric Blake [Thu, 30 May 2013 03:00:51 +0000 (21:00 -0600)]
build: port qemu to cygwin

A cygwin build of the qemu driver fails with:

qemu/qemu_process.c: In function 'qemuPrepareCpumap':
qemu/qemu_process.c:1803:31: error: 'CPU_SETSIZE' undeclared (first use in this function)

CPU_SETSIZE is a Linux extension in <sched.h>; a bit more portable
is using sysconf if _SC_NPROCESSORS_CONF is defined (several platforms
have it, including Cygwin).  Ultimately, I would have preferred to
use gnulib's 'nproc' module, but it is currently under an incompatible
license.

* src/qemu/qemu_conf.h (QEMUD_CPUMASK_LEN): Provide definition on
cygwin.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: use correct rpc.h for lockd
Eric Blake [Thu, 30 May 2013 01:52:58 +0000 (19:52 -0600)]
build: use correct rpc.h for lockd

On cygwin, the build failed with:

In file included from ./rpc/virnetmessage.h:24:0,
                 from ./rpc/virnetclient.h:29,
                 from locking/lock_driver_lockd.c:31:
./rpc/virnetprotocol.h:9:21: fatal error: rpc/rpc.h: No such file or directory

* src/Makefile.am (lockd_la_CFLAGS): Add XDR_CFLAGS.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: work around broken sasl header
Eric Blake [Wed, 29 May 2013 19:57:01 +0000 (13:57 -0600)]
build: work around broken sasl header

Compilation on cygwin failed due to a bug in the sasl headers
present on that platform (libsasl2-devel 2.1.26):

In file included from rpc/virnetserverclient.c:27:0:
/usr/include/sasl/sasl.h:230:38: error: expected declaration specifiers or '...' before 'size_t'

Upstream is aware of their bug:
https://bugzilla.cyrusimap.org/show_bug.cgi?id=3759

* src/rpc/virnetserverclient.c (includes): Ensure size_t is
defined before using sasl.h.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: fix typo in earlier commit
Eric Blake [Wed, 29 May 2013 17:06:39 +0000 (11:06 -0600)]
build: fix typo in earlier commit

Bummer, I committed, then fixed a typo, then tested, and forgot to
amend the commit before pushing 7d21d6b6.

* src/rpc/virnettlscontext.c (includes): Use correct spelling.

11 years agovirsh: migrate: Don't disallow --p2p and --migrateuri
Cole Robinson [Tue, 28 May 2013 19:37:53 +0000 (15:37 -0400)]
virsh: migrate: Don't disallow --p2p and --migrateuri

Because it's a valid combination. p2p still uses a separate channel
for qemu migration, so there's value in letting the user specify a manual
migrate URI for overriding auto-port, or libvirt's FQDN lookup.

What _isn't_ allowed is --migrateuri and TUNNELLED, since there is
no separate migration channel. Disallow that instead

11 years agoqemu: migration: error if tunnelled + storage specified
Cole Robinson [Tue, 28 May 2013 19:27:45 +0000 (15:27 -0400)]
qemu: migration: error if tunnelled + storage specified

Since as the code indicates it doesn't work yet, so let's be
explicit about it.

11 years agoqemu: migration: Improve p2p error if we can't open conn
Cole Robinson [Tue, 28 May 2013 19:12:01 +0000 (15:12 -0400)]
qemu: migration: Improve p2p error if we can't open conn

By actually showing the Open() error to the user

11 years agobuild: fix build without libvirtd
Eric Blake [Wed, 29 May 2013 15:05:33 +0000 (09:05 -0600)]
build: fix build without libvirtd

Building when configured --with-libvirtd=no fails with:

In file included from ../src/qemu/qemu_command.h:30:0,
                 from testutilsqemu.h:4,
                 from networkxml2xmltest.c:14:
../src/qemu/qemu_conf.h:175:5: error: expected specifier-qualifier-list before 'virStateInhibitCallback'

* src/libvirt_internal.h (virStateInhibitCallback): Move outside
of conditional.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: fix build with newer gnutls
Eric Blake [Wed, 29 May 2013 03:15:08 +0000 (21:15 -0600)]
build: fix build with newer gnutls

Building with gnutls 3.2.0 (such as shipped with current cygwin) fails
with:

rpc/virnettlscontext.c: In function 'virNetTLSSessionGetKeySize':
rpc/virnettlscontext.c:1358:5: error: implicit declaration of function 'gnutls_cipher_get_key_size' [-Wimplicit-function-declaration]

Yeah, it's stupid that gnutls broke API by moving their declaration
into a new header without including that header from the old one,
but it's easy enough to work around, all without breaking on gnutls
1.4.1 (hello RHEL 5) that lacked the new header.

* configure.ac (gnutls): Check for <gnutls/crypto.h>.
* src/rpc/virnettlscontext.c (includes): Include additional header.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agostorage_conf: Use uid_t/gid_t instead of int to cast the value
Osier Yang [Wed, 22 May 2013 12:05:22 +0000 (20:05 +0800)]
storage_conf: Use uid_t/gid_t instead of int to cast the value

And error out if the casted value is not same with the original
one, which prevents the bug on platform(s) where uid_t/gid_t
has different size with long.

11 years agostorage_conf: Improve error messages
Osier Yang [Wed, 22 May 2013 12:05:21 +0000 (20:05 +0800)]
storage_conf: Improve error messages

virStoragePoolDefParseSource:
  * Better error message

virStoragePoolObjLoad:
  * Break the line line

11 years agostorage_conf: Use NULLSTR instead
Osier Yang [Wed, 22 May 2013 12:05:19 +0000 (20:05 +0800)]
storage_conf: Use NULLSTR instead

11 years agostorage_conf: Improve the memory deallocation of virStorageVolDefParseXML
Osier Yang [Wed, 22 May 2013 12:05:18 +0000 (20:05 +0800)]
storage_conf: Improve the memory deallocation of virStorageVolDefParseXML

Changes:
  * Add a new goto label "error"
  * Free the strings at "cleanup"
  * Remove the unnecessary frees

11 years agostorage_conf: Improve the memory deallocation of pool def parsing
Osier Yang [Wed, 29 May 2013 10:04:33 +0000 (18:04 +0800)]
storage_conf: Improve the memory deallocation of pool def parsing

Changes:
    * Free all the strings at "cleanup", instead of freeing them
      in the middle
    * Remove xmlFree
    * s/tmppath/target_path/, to make it more sensible
    * Add new goto label "error"

11 years agoqemuOpenVhostNet: Decrease vhostfdSize on open failure
Michal Privoznik [Fri, 24 May 2013 12:45:06 +0000 (14:45 +0200)]
qemuOpenVhostNet: Decrease vhostfdSize on open failure

Currently, if there's an error opening /dev/vhost-net (e.g. because
it doesn't exist) but it's not required we proceed with vhostfd array
filled with -1 and vhostfdSize unchanged. Later, when constructing
the qemu command line only non-negative items within vhostfd array
are taken into account. This means, vhostfdSize may be greater than
the actual count of non-negative items in vhostfd array. This results
in improper command line arguments being generated, e.g.:

-netdev tap,fd=21,id=hostnet0,vhost=on,vhostfd=(null)

11 years agobuild: fix build with older gcc
Eric Blake [Tue, 28 May 2013 23:30:30 +0000 (17:30 -0600)]
build: fix build with older gcc

gcc 4.1.2 (hello, RHEL 5!) fails to build on 32-bit platforms with:

conf/domain_conf.c: In function 'virDomainDefParseXML':
conf/domain_conf.c:10581: warning: integer constant is too large for 'long' type

Problem introduced in commit f8e3221f9.

* src/conf/domain_conf.c (virDomainDefParseXML): Mark large constants.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: drop unused variable
Eric Blake [Tue, 28 May 2013 23:11:48 +0000 (17:11 -0600)]
build: drop unused variable

Compilation for mingw failed:

../../src/util/virutil.c: In function 'virGetWin32DirectoryRoot':
../../src/util/virutil.c:1094:9: error: unused variable 'ret' [-Werror=unused-variable]

* src/util/virutil.c (virGetWin32DirectoryRoot): Silence compiler
warning.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agosyntax: fix broken error message in previous patch
Eric Blake [Tue, 28 May 2013 15:49:53 +0000 (09:49 -0600)]
syntax: fix broken error message in previous patch

Osier Yang pointed out that I introduced a syntax error in my
syntax check (I really shouldn't make last-minute changes without
testing them....).

/bin/sh: -c: line 2: syntax error near unexpected token `;'
/bin/sh: -c: line 2: `  { echo 'maint.mk: incorrect whitespace, see HACKING for rules' 2>&; \'
make: *** [bracket-spacing-check] Error 1

* cfg.mk (bracket-spacing-check): Fix copy-and-paste error.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoqemu: Don't report error on successful media eject
Cole Robinson [Tue, 28 May 2013 14:23:00 +0000 (10:23 -0400)]
qemu: Don't report error on successful media eject

If we are just ejecting media, ret == -1 even after the retry loop
determines that the tray is open, as requested. This means media
disconnect always report's error.

Fix it, and fix some other mini issues:

- Don't overwrite the 'eject' error message if the retry loop fails
- Move the retries decrement inside the loop, otherwise the final loop
  might succeed, yet retries == 0 and we will raise error
- Setting ret = -1 in the disk->src check is unneeded
- Fix comment typos

cc: mprivozn@redhat.com

11 years agosyntax-check: mandate space after mid-line semicolon
Eric Blake [Fri, 24 May 2013 16:43:45 +0000 (10:43 -0600)]
syntax-check: mandate space after mid-line semicolon

Enforce the style cleanup in the previous patch.

* build-aux/bracket-spacing.pl: Enforce trailing spacing.
* cfg.mk (bracket-spacing-check): Tweak error wording.
* docs/hacking.html.in: Document the rule.
* HACKING: Regenerate.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agosyntax: prefer space after semicolon in for loop
Eric Blake [Fri, 24 May 2013 16:58:25 +0000 (10:58 -0600)]
syntax: prefer space after semicolon in for loop

I noticed several unusual spacings in for loops, and decided to
fix them up.  See the next commit for the syntax check that found
all of these.

* examples/domsuspend/suspend.c (main): Fix spacing.
* python/libvirt-override.c: Likewise.
* src/conf/interface_conf.c: Likewise.
* src/security/virt-aa-helper.c: Likewise.
* src/util/virconf.c: Likewise.
* src/util/virhook.c: Likewise.
* src/util/virlog.c: Likewise.
* src/util/virsocketaddr.c: Likewise.
* src/util/virsysinfo.c: Likewise.
* src/util/viruuid.c: Likewise.
* src/vbox/vbox_tmpl.c: Likewise.
* src/xen/xen_hypervisor.c: Likewise.
* tools/virsh-domain-monitor.c (vshDomainStateToString): Drop
default case, to let compiler check us.
* tools/virsh-domain.c (vshDomainVcpuStateToString): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoutil: fix the VIR_STRDUP when src is NULL
yangdongsheng [Tue, 28 May 2013 07:13:17 +0000 (15:13 +0800)]
util: fix the VIR_STRDUP when src is NULL

When src is NULL, VIR_STRDUP will return 0 directly.
This patch will set dest to NULL before VIR_STRDUP return.

Example:
[root@yds-pc libvirt]# virsh
Welcome to virsh, the virtualization interactive terminal.

Type: 'help' for help with commands
'quit' to quit

virsh # connect
error: Failed to connect to the hypervisor
error: internal error Unable to parse URI �N�*

Signed-off-by: yangdongsheng <yangds.fnst@cn.fujitsu.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoqemu: Fix build without gnutls
Jiri Denemark [Mon, 27 May 2013 08:19:36 +0000 (10:19 +0200)]
qemu: Fix build without gnutls

"error" label in qemuMigrationCookieGraphicsAlloc is now used
unconditionally thanks to VIR_STRDUP.

11 years agoqemu: save domain state to XML after reboot
Sergey Fionov [Sat, 18 May 2013 11:47:51 +0000 (15:47 +0400)]
qemu: save domain state to XML after reboot

Currently qemuDomainReboot() does reboot in two phases:
qemuMonitorSystemPowerdown() and qemuProcessFakeReboot().

qemuMonitorSystemPowerdown() shutdowns the domain and saves domain
state/reason as VIR_DOMAIN_SHUTDOWN_UNKNOWN.

qemuProcessFakeReboot() sets domain state/reason to
VIR_DOMAIN_RESUMED_UNPAUSED but does not save domain state changes.

Subsequent restart of libvirtd leads to restoring domain state/reason to
saved that is VIR_DOMAIN_SHUTDOWN_UNKNOWN and to automatic shutdown of
the domain. This commit adds virDomainSaveStatus() into
qemuProcessFakeReboot() to avoid unexpected shutdowns.

11 years agoesx: Fix dynamic VI object type detection
Matthias Bolte [Sat, 18 May 2013 09:45:04 +0000 (11:45 +0200)]
esx: Fix dynamic VI object type detection

VI objects support inheritance with subtype polymorphism. For example the
FileInfo object type is extended by FloppyImageFileInfo, FolderFileInfo
etc. Then SearchDatastore_Task returns an array of FileInfo objects and
depending on the represented file the FileInfo is actually a FolderFileInfo
or FloppyImageFileInfo etc. The actual type information is stored as XML
attribute that allows clients such as libvirt to distinguish between the
actual types. esxVI_GetActualObjectType is used to extract the actual type.

I assumed that this mechanism would be used for all VI object types that
have subtypes. But this is not the case. It seems only to be used for types
that are actually used as generic base type such as FileInfo. But it is not
used for types that got extended later such as ElementDescription that was
extended by ExtendedElementDescription (added in vSphere API 4.0) or that
are not meant to be used with subtype polymorphism.

This breaks the deserialization of types that contain ElementDescription
properties such as PerfCounterInfo or ChoiceOption, because the code
expects an ElementDescription object to have an XML attribute named type
that is not present, since ExtendedElementDescription was added to the
esx_vi_generator.input in commit 60f0f55ee4686fecbffc5fb32f90863427d02a14.
This in turn break virtual machine question handling and auto answering.

Fix this by using the base type if no XML type attribute is present.

11 years agospec: Build vbox packages only for x86 architectures
Viktor Mihajlovski [Fri, 24 May 2013 13:44:19 +0000 (15:44 +0200)]
spec: Build vbox packages only for x86 architectures

Commit 6ab6bc19f03513fd87d29ecfd405bb7f4a7de114 has introduced separate
daemon/driver packages for vbox. These should only be built for x86
architectures which is done hereby.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
11 years agosecurity_dac: Fix the coding style
Osier Yang [Fri, 24 May 2013 15:31:28 +0000 (23:31 +0800)]
security_dac: Fix the coding style

Pushed under trivial rule.

11 years agoAdapt to new VIR_STRNDUP behavior
Michal Privoznik [Fri, 24 May 2013 09:21:36 +0000 (11:21 +0200)]
Adapt to new VIR_STRNDUP behavior

With previous patch, we accept negative value as length of string to
duplicate. So there is no need to pass strlen(src) in case we want to do
duplicate the whole string.

11 years agovirStrndup: Accept negative values as string length
Michal Privoznik [Fri, 24 May 2013 08:45:57 +0000 (10:45 +0200)]
virStrndup: Accept negative values as string length

It may shorten the code a bit as the following pattern:

  VIR_STRNDUP(dst, src, cond ? n : strlen(src))

is used on several places among our code. However, we can
move the strlen into virStrndup and thus write just:

  VIR_STRNDUP(dst, src, cond ? n : -1)

11 years agostorage_conf: Fix the error type
Osier Yang [Wed, 22 May 2013 12:05:16 +0000 (20:05 +0800)]
storage_conf: Fix the error type

s/VIR_ERR_INTERNAL_ERROR/VIR_ERR_XML_ERROR/.

11 years agostorage_conf: Put "%s" at the same line with error type
Osier Yang [Wed, 22 May 2013 12:05:15 +0000 (20:05 +0800)]
storage_conf: Put "%s" at the same line with error type

Trivial, but it allows the "error message" to have more spaces.

11 years agostorage_conf: Use xmlStrEqual instead of STREQ
Osier Yang [Wed, 22 May 2013 12:05:14 +0000 (20:05 +0800)]
storage_conf: Use xmlStrEqual instead of STREQ

And improve the error message

11 years agostorage_conf: Remove the useless casting
Osier Yang [Wed, 22 May 2013 12:05:13 +0000 (20:05 +0800)]
storage_conf: Remove the useless casting

11 years agostorage_conf: Don't leak "uuid" in virStoragePoolDefParseAuthCephx
Osier Yang [Wed, 22 May 2013 12:05:12 +0000 (20:05 +0800)]
storage_conf: Don't leak "uuid" in virStoragePoolDefParseAuthCephx

Any string returned from virXPathString should be freed.

11 years agostorage_conf: Fix the wrong error message
Osier Yang [Wed, 22 May 2013 12:05:11 +0000 (20:05 +0800)]
storage_conf: Fix the wrong error message

It's for parsing "login" attribute of "auth".

11 years agosyntax-check: ignore all quoted strings in bracket-spacing
Ján Tomko [Fri, 24 May 2013 08:50:42 +0000 (10:50 +0200)]
syntax-check: ignore all quoted strings in bracket-spacing

Ignore strings with an escaped double quote too.

This removes the need for special handling of quotes in the
semicolon check.

11 years agonwfilter: Remove error report in virNWFilterDHCPSnoopEnd
Stefan Berger [Fri, 24 May 2013 12:01:03 +0000 (08:01 -0400)]
nwfilter: Remove error report in virNWFilterDHCPSnoopEnd

Remove error reporting when calling the virNWFilterDHCPSnoopEnd
function with an interface for which no thread is snooping traffic.

Document the usage of this function.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
11 years agoFix blkdeviotune for shutoff domain
Martin Kletzander [Thu, 23 May 2013 11:07:34 +0000 (13:07 +0200)]
Fix blkdeviotune for shutoff domain

Function qemuDomainSetBlockIoTune() was checking QEMU capabilities
even when !(flags & VIR_DOMAIN_AFFECT_LIVE) and the domain was
shutoff, resulting in the following problem:

 virsh # domstate asdf; blkdeviotune asdf vda --write-bytes-sec 100
 shut off

 error: Unable to change block I/O throttle
 error: unsupported configuration: block I/O throttling not supported with this QEMU binary

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

11 years agocgroups: Do not enforce nonexistent controllers
Viktor Mihajlovski [Thu, 23 May 2013 13:26:31 +0000 (15:26 +0200)]
cgroups: Do not enforce nonexistent controllers

Currently, the controllers argument to virCgroupDetect acts both as
a result filter and a required controller specification, which is
a bit overloaded. If both functionalities are needed, it would be
better to have them seperated into a filter and a requirement mask.
The only situation where it is used today is to ensure that only
CPU related controllers are used for the VCPU directories. But here
we clearly do not want to enforce the existence of cpu, cpuacct and
specifically not cpuset at the same time.
This commit changes the semantics of controllers to "filter only".
Should a required mask ever be needed, more work will have to be done.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
11 years agovirsh: Fix regression of vol-resize
Osier Yang [Fri, 24 May 2013 03:59:14 +0000 (11:59 +0800)]
virsh: Fix regression of vol-resize

Introduced by commit 1daa4ba33acf. vshCommandOptStringReq returns
0 on *success* or the option is not required && not present, both
are right result. Error out when returning 0 is not correct.
the caller, it doesn't have to check wether it

11 years agoIntroduce syntax-check rule to prefer VIR_STRDUP over strdup
Michal Privoznik [Thu, 4 Apr 2013 18:16:43 +0000 (20:16 +0200)]
Introduce syntax-check rule to prefer VIR_STRDUP over strdup

11 years agoAdapt to VIR_STRDUP and VIR_STRNDUP in tools/virsh.c
Michal Privoznik [Thu, 23 May 2013 07:51:59 +0000 (09:51 +0200)]
Adapt to VIR_STRDUP and VIR_STRNDUP in tools/virsh.c

11 years agoAdapt to VIR_STRDUP and VIR_STRNDUP in src/util/*
Michal Privoznik [Fri, 24 May 2013 07:19:51 +0000 (09:19 +0200)]
Adapt to VIR_STRDUP and VIR_STRNDUP in src/util/*