]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/log
people/liuw/libxenctrl-split/libvirt.git
11 years agoopenvzDomainSetNetwork: use virCommand
Michal Privoznik [Sun, 19 May 2013 09:17:19 +0000 (11:17 +0200)]
openvzDomainSetNetwork: use virCommand

Currently, the openvzDomainSetNetwork function constructs an
array of strings representing a command line for VZCTL binary.
This is a overkill since our virCommand APIs can cover all the
functionality. Moreover, the function is not following our
structure where return value is set to -1 initially, and after
all operations succeeded then it is set to zero.

11 years agoqemu: Add callback struct for qemuBuildCommandLine
Osier Yang [Fri, 17 May 2013 10:34:24 +0000 (18:34 +0800)]
qemu: Add callback struct for qemuBuildCommandLine

Since 0d70656afded, it starts to access the sysfs files to build
the qemu command line (by virSCSIDeviceGetSgName, which is to find
out the scsi generic device name by adpater:bus:target:unit), there
is no way to work around, qemu wants to see the scsi generic device
like "/dev/sg6" anyway.

And there might be other places which need to access sysfs files
when building qemu command line in future.

Instead of increasing the arguments of qemuBuildCommandLine, this
introduces a new callback for qemuBuildCommandLine, and thus tests
can register their own callbacks for sysfs test input files accessing.

* src/qemu/qemu_command.h: (New callback struct
                            qemuBuildCommandLineCallbacks;
                            extern buildCommandLineCallbacks)
* src/qemu/qemu_command.c: (wire up the callback struct)
* src/qemu/qemu_driver.c: (Use the new syntax of qemuBuildCommandLine)
* src/qemu/qemu_hotplug.c: Likewise
* src/qemu/qemu_process.c: Likewise
* tests/testutilsqemu.[ch]: (Helper testSCSIDeviceGetSgName;
                             callback struct testCallbacks;)
* tests/qemuxml2argvtest.c: (Use testCallbacks)
* src/tests/qemuxmlnstest.c: (Like above)

11 years agostorage_conf: Improve the coding style in storage_conf.h
Osier Yang [Thu, 16 May 2013 12:40:54 +0000 (20:40 +0800)]
storage_conf: Improve the coding style in storage_conf.h

Changes:
  * Remove useless comments
  * Remove useless blank lines
  * If the struct member is a enum type, comment it like
    /* enum fooBar */
  * Break the long lines
  * Prefer the common function style for the inline function

11 years agostorage_conf: Fix indentions in storage_conf.c
Osier Yang [Thu, 16 May 2013 12:40:51 +0000 (20:40 +0800)]
storage_conf: Fix indentions in storage_conf.c

Uses the 4 spaces for indention.

11 years agostorage_conf: Fix the coding stype in storage_conf.c
Osier Yang [Thu, 16 May 2013 12:40:50 +0000 (20:40 +0800)]
storage_conf: Fix the coding stype in storage_conf.c

Changes:
  * Remove the useless space in "for" statement (e.g.
    for (i = 0 ; i < something ; i++)

  * Change the function's style to:
    void
    foo(bar)
    {
        printf("foo is not bar\n");
    }

  * Don't lose "{}" for "if...else" branches if one of the branch
    has more than one line block. Example of the old ones:
    if (a) {
        printf("a is not funny");
    } else
        printf("a is funny");

  * Remove the 1 space before "goto" label.

  * Remove the useless blank line(s)

  * Add blank line if it can make the code more clear to eyes.

11 years agoqemu: Abstract code for cpuset controller setting into a helper
Osier Yang [Fri, 17 May 2013 11:59:34 +0000 (19:59 +0800)]
qemu: Abstract code for cpuset controller setting into a helper

11 years agoqemu: Abstract code for devices controller setting into a helper
Osier Yang [Fri, 17 May 2013 11:59:33 +0000 (19:59 +0800)]
qemu: Abstract code for devices controller setting into a helper

11 years agoqemu: Abstract code for memory controller setting into a helper
Osier Yang [Mon, 20 May 2013 11:39:54 +0000 (19:39 +0800)]
qemu: Abstract code for memory controller setting into a helper

11 years agoqemu: Abstract the code for blkio controller setting into a helper
Osier Yang [Fri, 17 May 2013 11:59:31 +0000 (19:59 +0800)]
qemu: Abstract the code for blkio controller setting into a helper

11 years agoesx: Fix error reporting in esxVI_LookupManagedObjectHelper
Matthias Bolte [Wed, 15 May 2013 21:43:04 +0000 (23:43 +0200)]
esx: Fix error reporting in esxVI_LookupManagedObjectHelper

As the name parameter can be NULL the error message can only contain it
conditionally.

11 years agoAdd missing c-ctype.h to virfile.c
Daniel P. Berrange [Fri, 17 May 2013 12:32:59 +0000 (13:32 +0100)]
Add missing c-ctype.h to virfile.c

The virfile.c file uses c_isalpha on Win32 platforms, so must
include c-ctype.h

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd libvirt-daemon-vbox & libvirt-daemon-driver-vbox RPMs
Daniel P. Berrange [Fri, 17 May 2013 12:31:59 +0000 (13:31 +0100)]
Add libvirt-daemon-vbox & libvirt-daemon-driver-vbox RPMs

Now the VirtualBox driver is a loadable module, it needs
to live in its own sub-RPM

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoInclude GNULIB mkdtemp module
Daniel P. Berrange [Fri, 17 May 2013 12:30:37 +0000 (13:30 +0100)]
Include GNULIB mkdtemp module

The mkdtemp function is missing on mingw platforms. It is
used in various Linux specific places in libvirt, but
recently became used in fdstreamtest.c which is cross
platform. Thus the GNULIB mkdtemp module should be used
to provide mkdtemp.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoSet PKG_CONFIG_LIBDIR in autobuild.sh
Daniel P. Berrange [Fri, 17 May 2013 12:29:12 +0000 (13:29 +0100)]
Set PKG_CONFIG_LIBDIR in autobuild.sh

If PKG_CONFIG_LIBDIR is not set when doing mingw32/64 builds,
then pkg-config may silently fallback to native versions of
libraries, with predictably bad results. Setting PKG_CONFIG_LIBDIR
forces it to only consider the mingw32/64 libraries.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agodocs: add another user
Eric Blake [Fri, 17 May 2013 15:14:16 +0000 (09:14 -0600)]
docs: add another user

Described here:
https://www.redhat.com/archives/libvir-list/2013-May/msg01329.html

* docs/apps.html.in: Mention Cracow Cloud One.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoqemu: report useful error failling to destroy domain gracefully
Guannan Ren [Fri, 17 May 2013 14:22:46 +0000 (22:22 +0800)]
qemu: report useful error failling to destroy domain gracefully

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

 #kill -STOP `pidof qemu-kvm`
 #virsh destroy $guest --graceful
 error: Failed to destroy domain testVM
 error: An error occurred, but the cause is unknown

With --graceful, SIGTERM always is emitted to kill driver
process, but it won't success till burning out waiting time
in case of process being stopped.
But domain destroy without --graceful can work, SIGKILL will
be emitted to the stopped process after 10 secs which always
kills a process even one that is currently stopped.
So report an error after burning out waiting time in this case.

11 years agoqemu: Check conflicts for shared scsi host device
Osier Yang [Fri, 3 May 2013 18:07:44 +0000 (02:07 +0800)]
qemu: Check conflicts for shared scsi host device

Just like previous patches, this changes qemuCheckSharedDisk
into qemuCheckSharedDevice, which takes a virDomainDeviceDefPtr
argument instead.

11 years agotest: fix VPATH fchosttest failure
Viktor Mihajlovski [Thu, 16 May 2013 15:49:59 +0000 (17:49 +0200)]
test: fix VPATH fchosttest failure

Running make check in a VPATH configured build directory fails
in fchosttest as the test data files are searched for relative to
the current working directory.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
11 years agoRe-add selinux/selinux.h to lxc_container.c
Daniel P. Berrange [Fri, 17 May 2013 09:59:25 +0000 (10:59 +0100)]
Re-add selinux/selinux.h to lxc_container.c

Re-add the selinux header to lxc_container.c since other
functions now use it, beyond the patch that was just
reverted.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix failure to detect missing cgroup partitions
Daniel P. Berrange [Thu, 16 May 2013 17:47:07 +0000 (18:47 +0100)]
Fix failure to detect missing cgroup partitions

Change bbe97ae968eba60b71e0066d49f9fc909966d9d6 caused the
QEMU driver to ignore ENOENT errors from cgroups, in order
to cope with missing /proc/cgroups. This is not good though
because many other things can cause ENOENT and should not
be ignored. The callers expect to see ENXIO when cgroups
are not present, so adjust the code to report that errno
when /proc/cgroups is missing

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoRevert "Change label of fusefs mounted at /proc/meminfo in lxc containers"
Daniel P. Berrange [Fri, 17 May 2013 09:22:54 +0000 (10:22 +0100)]
Revert "Change label of fusefs mounted at /proc/meminfo in lxc containers"

This reverts commit 940c6f1085c3aafced51152b17a044af8c42b16e.

11 years agolibxl: fix leaking libxl events
Jim Fehlig [Thu, 16 May 2013 15:38:56 +0000 (09:38 -0600)]
libxl: fix leaking libxl events

libxl expects the event handler to free the event passed to it.  From
libxl_event.h:

   event becomes owned by the application and must be freed, either
   by event_occurs or later

11 years agolibxl: fix build with Xen4.3
Jim Fehlig [Thu, 16 May 2013 14:42:21 +0000 (08:42 -0600)]
libxl: fix build with Xen4.3

Xen 4.3 fixes a mistake in the libxl event handler signature where the
event owned by the application was defined as const.  Detect this and
define the libvirt libxl event handler signature appropriately.

11 years agoschema: make source optional in volume XML
Ján Tomko [Thu, 16 May 2013 13:43:06 +0000 (15:43 +0200)]
schema: make source optional in volume XML

We don't parse it anyway.

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

11 years agoschema: require target path in storage pool xml
Ján Tomko [Thu, 16 May 2013 13:37:14 +0000 (15:37 +0200)]
schema: require target path in storage pool xml

Make target path mandatory for pool types that require target,
since we refuse to parse a target without a path.

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

11 years agoqemu: Change values of disk discard
Osier Yang [Fri, 17 May 2013 02:35:02 +0000 (10:35 +0800)]
qemu: Change values of disk discard

QEMU might support more values for "-drive discard", so using Bi-state
values (on/off) for it doesn't make sense.

"on" maps to "unmap", "off" maps to "ignore":

<...>
@var{discard} is one of "ignore" (or "off") or "unmap" (or "on") and
controls whether @dfn{discard} (also known as @dfn{trim} or @dfn{unmap})
requests are ignored or passed to the filesystem.  Some machine types
may not support discard requests.
</...>

11 years agoqemu: Implement support for locking domain's memory pages
Jiri Denemark [Thu, 16 May 2013 20:01:05 +0000 (22:01 +0200)]
qemu: Implement support for locking domain's memory pages

11 years agoAdd support for locking domain's memory pages
Jiri Denemark [Thu, 16 May 2013 20:00:03 +0000 (22:00 +0200)]
Add support for locking domain's memory pages

The following XML configuration can be used to request all domain's
memory pages to be kept locked in host's memory (i.e., domain's memory
pages will not be swapped out):

      <memoryBacking>
        <locked/>
      </memoryBacking>

11 years agoFix build with VirtualBox
Jiri Denemark [Thu, 16 May 2013 20:56:56 +0000 (22:56 +0200)]
Fix build with VirtualBox

Commit ba5f3c7c moved vbox driver into libvirtd but forgot to adapt
daemon's Makefile.am.

11 years agoqemu: Fix cgroup handling when setting VCPU BW
Martin Kletzander [Thu, 16 May 2013 12:37:54 +0000 (14:37 +0200)]
qemu: Fix cgroup handling when setting VCPU BW

Commit 632f78c introduced a regression which causes schedinfo being
unable to set some parameters.  When migrating to priv->cgroup there
was missing variable left out and due to passed NULL to underlying
function, the setting failed.

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

11 years agoqemu: Set unpriv_sgio for scsi host device
Osier Yang [Fri, 3 May 2013 18:07:43 +0000 (02:07 +0800)]
qemu: Set unpriv_sgio for scsi host device

11 years agoqemu: Refactor qemuSetUnprivSGIO to support scsi host device
Osier Yang [Fri, 3 May 2013 18:07:42 +0000 (02:07 +0800)]
qemu: Refactor qemuSetUnprivSGIO to support scsi host device

Just like what previous patches do, it refactors qemuSetUnprivSGIO
to take the virDomainDeviceDefPtr as argument instead.

11 years agoqemu: Move qemuSetUnprivSGIO into qemu_conf.c
Osier Yang [Fri, 3 May 2013 18:07:41 +0000 (02:07 +0800)]
qemu: Move qemuSetUnprivSGIO into qemu_conf.c

unpriv_sgio setting is tight with the shared device helpers, let's
put them together in qemu_conf.c

11 years agoconf: Introduce sgio for hostdev
Osier Yang [Fri, 3 May 2013 18:07:40 +0000 (02:07 +0800)]
conf: Introduce sgio for hostdev

"sgio" is only valid for scsi host device.

11 years agoRename virDomainDiskSGIO to virDomainDeviceSGIO
Osier Yang [Fri, 3 May 2013 18:07:39 +0000 (02:07 +0800)]
Rename virDomainDiskSGIO to virDomainDeviceSGIO

SCSI host device will also support "sgio", and perhaps we could
use "sgio" in other places too in future, renaming the enum to
reuse.

11 years agoqemu: Manage shared device entry for scsi host device
Osier Yang [Fri, 3 May 2013 18:07:38 +0000 (02:07 +0800)]
qemu: Manage shared device entry for scsi host device

This adds the shared device entry when starting domain (more
exactly, when preparing host devices), and remove the entry
when destroying domain (when reattaching host devices).

11 years agoqemu: Refactor the helpers to track shared scsi host device
Osier Yang [Fri, 3 May 2013 18:07:37 +0000 (02:07 +0800)]
qemu: Refactor the helpers to track shared scsi host device

This changes the helpers qemu{Add,Remove}SharedDisk into
qemu{Add,Remove}SharedDevice, as most of the code in the helpers
can be reused for scsi host device.

To track the shared scsi host device, first it finds out the
device path (e.g. /dev/s[dr]*) which is mapped to the sg device,
and use device ID of the found device path (/dev/s[dr]*) as the
hash key. This is because of the device ID is not unique between
between /dev/s[dr]* and /dev/sg*, e.g.

% sg_map
/dev/sg0  /dev/sda
/dev/sg1  /dev/sr0

% ls -l /dev/sda
brw-rw----. 1 root disk 8, 0 May  2 19:26 /dev/sda

%ls -l /dev/sg0
crw-rw----. 1 root disk 21, 0 May  2 19:26 /dev/sg0

11 years agoutils: Add a helper to get the device name that sg device mapped to
Osier Yang [Fri, 3 May 2013 18:07:36 +0000 (02:07 +0800)]
utils: Add a helper to get the device name that sg device mapped to

E.g.

% sg_map
/dev/sg0  /dev/sda
/dev/sg1  /dev/sr0

What the helper gets for /dev/sg0 is /dev/sda, it will be used by
later patch.

11 years agoqemu: Rename qemu_driver->sharedDisks to qemu_driver->sharedDevices
Osier Yang [Fri, 3 May 2013 18:07:35 +0000 (02:07 +0800)]
qemu: Rename qemu_driver->sharedDisks to qemu_driver->sharedDevices

"Shared disk" is not only the thing we should care about after "scsi
hostdev" is introduced. A same scsi device can be used as "disk" for
one domain, and as "scsi hostdev" for another domain at the same time.
That's why this patch renames qemu_driver->sharedDisks. Related functions
and structs are also renamed.

11 years agoconf: Introduce <shareable> for hostdev
Osier Yang [Fri, 3 May 2013 18:07:33 +0000 (02:07 +0800)]
conf: Introduce <shareable> for hostdev

Unlike disk device, the scsi-generic always writethrough the data,
so no need to introduce a "cache" tag, and set "cache=off".

11 years agoDon't mount selinux fs in LXC if selinux is disabled
Daniel P. Berrange [Wed, 15 May 2013 15:26:59 +0000 (16:26 +0100)]
Don't mount selinux fs in LXC if selinux is disabled

Before trying to mount the selinux filesystem in a container
use is_selinux_enabled() to check if the machine actually
has selinux support (eg not booted with selinux=0)

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoMove VirtualBox driver into libvirtd
Daniel P. Berrange [Wed, 15 May 2013 10:31:36 +0000 (11:31 +0100)]
Move VirtualBox driver into libvirtd

Change the build process & driver initialization so that the
VirtualBox driver is built into libvirtd, instead of libvirt.so
This change avoids the VirtualBox GPLv2-only license causing
compatibility problems with libvirt.so which is under the
GPLv2-or-later license.

NB this change prevents use of the VirtualBox driver on the
Windows platform, until such time as libvirtd can be made
to work there.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix LXC startup when /var/run is an absolute symlink
Daniel P. Berrange [Wed, 15 May 2013 09:49:20 +0000 (10:49 +0100)]
Fix LXC startup when /var/run is an absolute symlink

During startup, the LXC driver uses paths such as

  /.oldroot/var/run/libvirt/lxc/...

to access directories from the previous root filesystem
after doing a pivot_root(). Unfortunately if /var/run
is an absolute symlink to /run, instead of a relative
symlink to ../run, these paths break.

At least one Linux distro is known to use an absolute
symlink for /var/run, so workaround this, by resolving
all symlinks before doing the pivot_root().

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoconf: Fix the bug of disk->copy_on_read formating
Osier Yang [Tue, 14 May 2013 09:03:02 +0000 (17:03 +0800)]
conf: Fix the bug of disk->copy_on_read formating

The reason for it's not exposed for such long time is that the
enums for VirtioEventIdx and CopyOnReadType have same enum values
and Correspondingstrings. This fixes the bug and adds test.

11 years agodatatypes: fix virGetStoragePool's comment
Ján Tomko [Thu, 16 May 2013 14:26:21 +0000 (16:26 +0200)]
datatypes: fix virGetStoragePool's comment

11 years agodaemon: fix leak after listing all volumes
Ján Tomko [Fri, 12 Apr 2013 15:30:56 +0000 (17:30 +0200)]
daemon: fix leak after listing all volumes

CVE-2013-1962

remoteDispatchStoragePoolListAllVolumes wasn't freeing the pool.
The pool also held a reference to the connection, preventing it from
getting freed and closing the netcf interface driver, which held two
sockets open.

11 years agoqemu: Fix crash in migration of graphics-less guests.
Viktor Mihajlovski [Thu, 16 May 2013 12:41:29 +0000 (14:41 +0200)]
qemu: Fix crash in migration of graphics-less guests.

Commit 7f15ebc7a2b599ab10dbc15bca6f823591213e67 introduced a bug
happening when guests without a <graphics> element are migrated.
The initialization of listenAddress happens unconditionally
from the cookie even if the cookie->graphics pointer was NULL.
Moved the initialization to where it is safe.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
11 years agobuild: Fix check-driverimpls in VPATH
Jiri Denemark [Thu, 16 May 2013 06:16:13 +0000 (08:16 +0200)]
build: Fix check-driverimpls in VPATH

DRIVER_SOURCE_FILES mixes files with absolute path (inherited from
REMOTE_DRIVER_GENERATED) with file paths that are relative to srcdir but
check-driverimpls.pl needs full paths.

11 years agoutil: Fix build without devmapper
Jiri Denemark [Thu, 16 May 2013 09:49:12 +0000 (11:49 +0200)]
util: Fix build without devmapper

stdlib.h header file needed for getenv was only transitively included
through libdevmapper.h.

11 years agoExpand documentation for LXC driver
Daniel P. Berrange [Tue, 14 May 2013 13:36:09 +0000 (14:36 +0100)]
Expand documentation for LXC driver

Update the LXC driver documentation to describe the way
containers are setup by default. Also describe the common
virsh commands for managing containers and a little about
the security. Placeholders for docs about configuring
containers still to be filled in.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoconf: Improve the coding style
Osier Yang [Thu, 16 May 2013 03:10:28 +0000 (11:10 +0800)]
conf: Improve the coding style

Add spaces around "<<", and remove the useless blank-line.

11 years agostring: test VIR_STRDUP
Eric Blake [Tue, 7 May 2013 21:26:28 +0000 (15:26 -0600)]
string: test VIR_STRDUP

The surest way to avoid regressions is to test documented behavior :)

* tests/virstringtest.c (testStrdup): New test case.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agovirsh: lookup interface by name or mac other than one by one
Guannan Ren [Wed, 15 May 2013 14:15:03 +0000 (22:15 +0800)]
virsh: lookup interface by name or mac other than one by one

Use virMacAddrParse() to distinguish interface name from interface
mac address.

11 years agonwfilter: check for inverted ctdir
Stefan Berger [Thu, 16 May 2013 01:02:11 +0000 (21:02 -0400)]
nwfilter: check for inverted ctdir

Linux netfilter at some point (Linux 2.6.39) inverted the meaning of the
'--ctdir reply' and newer netfilter implementations now expect
'--ctdir original' instead and vice-versa.
We check for the kernel version and assume that all Linux kernels with version
2.6.39 have the newer inverted logic.

Any distro backporting the Linux kernel patch that inverts the --ctdir logic
(Linux commit 96120d86f) must also backport this patch for Linux and
adapt the kernel version being tested for.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
11 years agoFreeBSD: disable buggy -fstack-protector-all
Roman Bogorodskiy [Wed, 15 May 2013 15:41:49 +0000 (19:41 +0400)]
FreeBSD: disable buggy -fstack-protector-all

FreeBSD ships an old gcc 4.2.1 which generates
bogus code, e.g. getsockopt() call returns
struct xucred with bogus values, which doesn't even
allow to connect to libvirtd:

error: Failed to find group record for gid '1284660778': No error: 0

So roll back to just -fstack-protector on FreeBSD.

11 years agoAdjust improperly formatted <sysinfo> uuid
John Ferlan [Fri, 26 Apr 2013 18:29:37 +0000 (14:29 -0400)]
Adjust improperly formatted <sysinfo> uuid

If the <sysinfo> system table 'uuid' field is improperly formatted,
then qemu will fail to start the guest with the error:

virsh start dom
error: Failed to start domain dom
error: internal error process exited while connecting to monitor: Invalid SMBIOS UUID string

This was because the parsing rules were lax with respect to allowing extraneous
spaces and dashes in the provided UUID.  As long as there were 32 hexavalues
that matched the UUID for the domain the string was accepted. However startup
failed because the string format wasn't correct. This patch will adjust the
string format so that when it's presented to the driver it's in the expected
format.

Added a test for uuid comparison within sysinfo.

11 years agoValidate the bios_date format for <sysinfo>
John Ferlan [Fri, 26 Apr 2013 12:33:26 +0000 (08:33 -0400)]
Validate the bios_date format for <sysinfo>

Add incorrectly formatted bios_date validation test

11 years agodocs: Fix/update syntax in Sysinfo/SMBIOS description
John Ferlan [Thu, 25 Apr 2013 20:42:31 +0000 (16:42 -0400)]
docs: Fix/update syntax in Sysinfo/SMBIOS description

11 years agoChange label of fusefs mounted at /proc/meminfo in lxc containers
Dan Walsh [Wed, 15 May 2013 14:35:48 +0000 (10:35 -0400)]
Change label of fusefs mounted at /proc/meminfo in lxc containers

We do not want to allow contained applications to be able to read fusefs_t.
So we want /proc/meminfo label to match the system default proc_t.

Fix checking of error codes

11 years agoRemove obsolete skipRoot flag in LXC driver
Daniel P. Berrange [Wed, 15 May 2013 09:53:15 +0000 (10:53 +0100)]
Remove obsolete skipRoot flag in LXC driver

The lxcContainerMountAllFS method had a 'bool skipRoot'
flag to control whether it mounts the / filesystem. Since
removal of the non-pivot root container setup codepaths,
this flag is obsolete as the only caller always passes
'true'.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoStop passing around old root directory prefix
Daniel P. Berrange [Wed, 15 May 2013 09:53:14 +0000 (10:53 +0100)]
Stop passing around old root directory prefix

Many methods accept a string parameter specifying the
old root directory prefix. Since removal of the non-pivot
root container setup codepaths, this parameter is obsolete
in many methods where the callers always pass "/.oldroot".

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoRemove obsolete pivotRoot flag in LXC driver
Daniel P. Berrange [Wed, 15 May 2013 09:53:13 +0000 (10:53 +0100)]
Remove obsolete pivotRoot flag in LXC driver

The lxcContainerMountBasicFS method had a 'bool pivotRoot'
flag to control whether it mounted a private /dev. Since
removal of the non-pivot root container setup codepaths,
this flag is obsolete as the only caller always passes
'true'.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agostorage: Ensure 'qemu-img resize' size arg is a 512 multiple
Christophe Fergeau [Tue, 14 May 2013 13:48:21 +0000 (15:48 +0200)]
storage: Ensure 'qemu-img resize' size arg is a 512 multiple

qemu-img resize will fail with "The new size must be a multiple of 512"
if libvirt doesn't round it first.
This fixes rhbz#951495

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
11 years agoqemu: Support discard for disk
Osier Yang [Tue, 14 May 2013 12:44:54 +0000 (20:44 +0800)]
qemu: Support discard for disk

QEMU introduced "discard" option for drive since commit a9384aff53,

<...>
@var{discard} is one of "ignore" (or "off") or "unmap" (or "on") and
controls whether @dfn{discard} (also known as @dfn{trim} or @dfn{unmap})
requests are ignored or passed to the filesystem.  Some machine types
may not support discard requests.
</...>

This patch exposes the support in libvirt.

QEMU supported "discard" for "-drive" since v1.5.0-rc0:

% git tag --contains a9384aff53
contains
v1.5.0-rc0
v1.5.0-rc1

So this only detects the capability bit using virQEMUCapsProbeQMPCommandLine.

11 years agodocs: Update formatdomain for lifecycle events
John Ferlan [Tue, 23 Apr 2013 21:51:08 +0000 (17:51 -0400)]
docs: Update formatdomain for lifecycle events

11 years agoHandle the domain event 'on_reboot' and 'on_poweroff' settings
John Ferlan [Tue, 23 Apr 2013 19:13:59 +0000 (15:13 -0400)]
Handle the domain event 'on_reboot' and 'on_poweroff' settings

11 years agoAdjust comments to describe on_poweroff and on_reboot action
John Ferlan [Tue, 23 Apr 2013 19:10:13 +0000 (15:10 -0400)]
Adjust comments to describe on_poweroff and on_reboot action

11 years agoAdjust usage of qemu -no-reboot and -no-shutdown options
John Ferlan [Tue, 23 Apr 2013 13:02:07 +0000 (09:02 -0400)]
Adjust usage of qemu -no-reboot and -no-shutdown options

During building of the qemu command line determine whether to add/use the
'-no-reboot' option only if each of the 'on' events want to to destroy
the domain; otherwise, use the '-no-shutdown' option.

Prior to this change both could be on the command line, which while allowed
could be construed as a conflict.

11 years agoqemu: Add VNC WebSocket support
Martin Kletzander [Tue, 30 Apr 2013 14:26:43 +0000 (16:26 +0200)]
qemu: Add VNC WebSocket support

Adding a VNC WebSocket support for QEMU driver.  This functionality is
in upstream qemu from commit described as v1.3.0-982-g7536ee4, so the
capability is being recognized based on QEMU version for now.

11 years agoAdd VNC WebSocket support
Martin Kletzander [Mon, 29 Apr 2013 12:34:01 +0000 (14:34 +0200)]
Add VNC WebSocket support

Adding support for new attribute 'websocket' in the '<graphics>'
element, the attribute value is the port to listen on with '-1'
meaning auto-allocation, '0' meaning no websockets.

11 years agotests: Sort the EXTRA_DIST list
Osier Yang [Wed, 15 May 2013 03:34:27 +0000 (11:34 +0800)]
tests: Sort the EXTRA_DIST list

Commit 1cc8259bfe17 fixes the build failure, but forgot to keep the
list alphanumeric sorted.

11 years agoqemu: New XML to disable memory merge at guest startup
Osier Yang [Tue, 14 May 2013 05:25:50 +0000 (13:25 +0800)]
qemu: New XML to disable memory merge at guest startup

QEMU introduced command line "-mem-merge=on|off" (defaults to on) to
enable/disable the memory merge (KSM) at guest startup. This exposes
it by new XML:
  <memoryBacking>
    <nosharepages/>
  </memoryBacking>

The XML tag is same with what we used internally for old RHEL.

11 years agoqemu: detect -machine mem-merge capability
Eric Blake [Tue, 14 May 2013 05:25:49 +0000 (13:25 +0800)]
qemu: detect -machine mem-merge capability

* src/qemu/qemu_capabilities.h: New capability bit.
* src/qemu/qemu_capabilities.c (virQEMUCapsProbeQMPCommandLine): New
function, based on qemuMonitorGetCommandLineOptionParameters, which was
introduced by commit bd56d0d813; use it to set new capability bit.
(virQEMUCapsInitQMP): Use new function.

11 years agospec: fix outdated comment
Eric Blake [Wed, 15 May 2013 02:14:34 +0000 (20:14 -0600)]
spec: fix outdated comment

https://bugzilla.redhat.com/show_bug.cgi?id=963016 points out that
we don't use initscripts by default on Fedora any more.

* libvirt.spec.in (Requires): Better explanation of gettext.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoRename rbd-invalid.xml to rbd-no-colon.xml
Daniel P. Berrange [Tue, 14 May 2013 18:55:13 +0000 (19:55 +0100)]
Rename rbd-invalid.xml to rbd-no-colon.xml

Files ending in -invalid.xml are expected to violate the
XML schema check. The RBD file does not so must have a
different filename.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agotests: Add fchostdata in EXTRA_DIST
Osier Yang [Tue, 14 May 2013 17:18:26 +0000 (01:18 +0800)]
tests: Add fchostdata in EXTRA_DIST

Pushed under build-breaker rule.

11 years agovirsh: Pretty the output of qemu-agent-command
Osier Yang [Tue, 14 May 2013 15:32:33 +0000 (23:32 +0800)]
virsh: Pretty the output of qemu-agent-command

This adds a new option "--pretty" for qemu-agent-command, to
pretty-format the returned JSON string.

11 years agovirsh: Use vshPrint instead of printf
Osier Yang [Tue, 14 May 2013 15:27:01 +0000 (23:27 +0800)]
virsh: Use vshPrint instead of printf

11 years agoFix invalid argument reference in virnetdev.h
Martin Kletzander [Tue, 14 May 2013 16:24:52 +0000 (18:24 +0200)]
Fix invalid argument reference in virnetdev.h

Commit ccff335f added ATTRIBUTE_NONNULL for an attribute which is not
a pointer and made files including virnetdev.h not compilable, so fix
that.

11 years agoForbid use of ':' in RBD pool names
Daniel P. Berrange [Mon, 13 May 2013 12:58:22 +0000 (13:58 +0100)]
Forbid use of ':' in RBD pool names

The QEMU command line syntax for RBD disks is

   file=rbd:pool/image:opt1=val1:opt2=val2...

There is no way to escape the ':' if it appears in the
pool or image name. Thus it must be explicitly forbidden
if it occurs in the libvirt XML. People are known to
be abusing the lack of escaping in current libvirt to
pass arbitrary args to QEMU.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoDon't duplicate compiler warning flags when linking
Daniel P. Berrange [Mon, 13 May 2013 11:50:22 +0000 (12:50 +0100)]
Don't duplicate compiler warning flags when linking

Automake already passes all CFLAGS to the linker too, so it
is not necessary to set WARN_LDFLAGS in addition to the
WARN_CFLAGS variable.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoOnly pass -export-dynamic to linker, not compiler
Daniel P. Berrange [Mon, 13 May 2013 11:48:06 +0000 (12:48 +0100)]
Only pass -export-dynamic to linker, not compiler

Clang does not like the -export-dynamic flag. The compiler does
not need it in the first place, so we can avoid the problem by
only setting it for the linker

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoCorrectly detect warning flags with clang
Daniel P. Berrange [Mon, 13 May 2013 11:45:54 +0000 (12:45 +0100)]
Correctly detect warning flags with clang

Clang will happily claim to support any warning flags
unless the -Werror and -Wunknown-warning-option flags
are set. Thus we need to make sure these are set when
testing for clags.

We must also set the clang specific warning flags
-Wno-unused-command-line-argument to avoid a warning
from the ssp-buffer-size flag when linking .o files.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoIgnore cast alignment warnings in inotify code for Xen.
Daniel P. Berrange [Mon, 13 May 2013 11:44:15 +0000 (12:44 +0100)]
Ignore cast alignment warnings in inotify code for Xen.

The inotify Xen code causes a cast alignment warning, but this
is harmless since the kernel inotify interface will ensure
sufficient alignment of the inotify structs in the buffer being
read

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoWorkaround issue with clang and inline functions with static vars
Daniel P. Berrange [Mon, 13 May 2013 11:43:08 +0000 (12:43 +0100)]
Workaround issue with clang and inline functions with static vars

Clang does not like it when you pass a static variable to an
inline function

 vircgroupmock.c:462:22: error: static variable 'fakesysfsdir' is
  used in an inline function with external linkage [-Werror,-Wstatic-in-inline]

Just make the var non-static to avoid this

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoEnsure consistent enablement of gcc 'diagnostic' pragma
Daniel P. Berrange [Mon, 13 May 2013 11:41:07 +0000 (12:41 +0100)]
Ensure consistent enablement of gcc 'diagnostic' pragma

The virt-compile-warnings.m4 file would do an explicit
check for whether the compile could use the 'diagnostic'
pragma push/pop feature. The src/internal.h file would
then only enable it for GCC >= 4.6

This breaks with clang which supports the pragma but
does not claim GCC 4.6 compat. Export a variable from
the m4 check to the header file so they are consistent.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agodocs: Fix the wrong links in secret documentation
Osier Yang [Tue, 14 May 2013 13:48:31 +0000 (21:48 +0800)]
docs: Fix the wrong links in secret documentation

docs/formatsecret.html.in: (s/domain\.html/formatdomain\.html/g)

11 years agodocs: Add the missed usage type 'iscsi'
Osier Yang [Tue, 14 May 2013 13:42:51 +0000 (21:42 +0800)]
docs: Add the missed usage type 'iscsi'

Pushed under trivial rule.

11 years agoqemu: fix bad free
Eric Blake [Mon, 13 May 2013 22:48:55 +0000 (16:48 -0600)]
qemu: fix bad free

Commit bd56d0d8 could lead to freeing an uninitialized pointer:

qemu/qemu_monitor_json.c: In function 'qemuMonitorJSONGetCommandLineOptionParameters':
qemu/qemu_monitor_json.c:4284: warning: 'cmd' may be used uninitialized in this function

* src/qemu/qemu_monitor_json.c
(qemuMonitorJSONGetCommandLineOptionParameters): Initialize variable.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: avoid gcrypt deprecation warnings
Roman Bogorodskiy [Sat, 11 May 2013 14:27:26 +0000 (18:27 +0400)]
build: avoid gcrypt deprecation warnings

When combining old gcc (4.2.1) and new gcrypt (1.5.2), such as
when using the Ports repository on FreeBSD, the build fails with:

  CC       libvirt_driver_la-libvirt.lo
cc1: warnings being treated as errors
In file included from libvirt.c:58:
/usr/local/include/gcrypt.h:1336: warning: 'gcry_ac_io_mode_t' is deprecated [-Wdeprecated-declarations]

Relevant part of gcrypt.h:
1333 typedef struct gcry_ac_io
1334 {
1335   /* This is an INTERNAL structure, do NOT use manually.  */
1336   gcry_ac_io_mode_t mode _GCRY_ATTR_INTERNAL;
1337   gcry_ac_io_type_t type _GCRY_ATTR_INTERNAL;
1338   union

The sad part is that we aren't even using the deprecated symbols - their
mere inclusion in the installed header is provoking the problems.  It
looks like newer gcc is a bit more tolerant (that is, this is a
shortcoming of FreeBSD's use of an older compiler).

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoqemu: query command line options in QMP
Eric Blake [Fri, 26 Apr 2013 17:13:45 +0000 (11:13 -0600)]
qemu: query command line options in QMP

Ever since the conversion to using only QMP for probing features
of qemu 1.2 and newer, we have been unable to detect features
that are added only by additional command line options.  For
example, we'd like to know if '-machine mem-merge=on' (added
in qemu 1.5) is present.  To do this, we will take advantage
of qemu 1.5's query-command-line-parameters QMP call [1].

This patch wires up the framework for probing the command results;
if the QMP command is missing, or if a particular command line
option does not output any parameters (for example, -net uses
a polymorphic parser, which showed up as no parameters as of qemu
1.5), we silently treat that command as having no results.

[1] https://lists.gnu.org/archive/html/qemu-devel/2013-04/msg05180.html

* src/qemu/qemu_monitor.h (qemuMonitorGetOptions)
(qemuMonitorSetOptions)
(qemuMonitorGetCommandLineOptionParameters): New functions.
* src/qemu/qemu_monitor_json.h
(qemuMonitorJSONGetCommandLineOptionParameters): Likewise.
* src/qemu/qemu_monitor.c (_qemuMonitor): Add cache field.
(qemuMonitorDispose): Clean it.
(qemuMonitorGetCommandLineOptionParameters): Implement new function.
* src/qemu/qemu_monitor_json.c
(qemuMonitorJSONGetCommandLineOptionParameters): Likewise.
(testQemuMonitorJSONGetCommandLineParameters): Test it.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoqemu: simplify string cleanup
Eric Blake [Fri, 26 Apr 2013 17:47:23 +0000 (11:47 -0600)]
qemu: simplify string cleanup

No need to open code a string list cleanup, if we are nice
to the caller by guaranteeing a NULL-terminated result.

* src/qemu/qemu_monitor_json.c (qemuMonitorJSONGetCPUDefinitions)
(qemuMonitorJSONGetCommands, qemuMonitorJSONGetEvents)
(qemuMonitorJSONGetObjectTypes, qemuMonitorJSONGetObjectProps):
Use simpler cleanup.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoqemu: use bool in monitor struct
Eric Blake [Fri, 26 Apr 2013 02:32:41 +0000 (20:32 -0600)]
qemu: use bool in monitor struct

Follows on the heels of other bool cleanups, such as commit 93002b98.

* src/qemu/qemu_monitor.h (qemuMonitorOpen, qemuMonitorOpenFD):
Update json parameter type.
* src/qemu/qemu_monitor.c (qemuMonitorOpen, qemuMonitorOpenFD):
Likewise.
(_qemuMonitor): Adjust field type.
* src/qemu/qemu_domain.h (_qemuDomainObjPrivate): Likewise.
* src/qemu/qemu_domain.c (qemuDomainObjPrivateXMLParse): Adjust
client.
* src/qemu/qemu_process.c (qemuProcessStart): Likewise.
* tests/qemumonitortestutils.c (qemuMonitorTestNew): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agojson: support removing a value from an object
Eric Blake [Fri, 26 Apr 2013 14:59:02 +0000 (08:59 -0600)]
json: support removing a value from an object

In an upcoming patch, I need the way to safely transfer a nested
virJSON object out of its parent container for independent use,
even after the parent is freed.

* src/util/virjson.h (virJSONValueObjectRemoveKey): New function.
(_virJSONObject, _virJSONArray): Use correct type.
* src/util/virjson.c (virJSONValueObjectRemoveKey): Implement it.
* src/libvirt_private.syms (virjson.h): Export it.
* tests/jsontest.c (mymain): Test it.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoSupport for static routes on a virtual bridge
Gene Czarcinski [Tue, 7 May 2013 17:42:55 +0000 (13:42 -0400)]
Support for static routes on a virtual bridge

network: static route support for <network>

This patch adds the <route> subelement of <network> to define a static
route.  the address and prefix (or netmask) attribute identify the
destination network, and the gateway attribute specifies the next hop
address (which must be directly reachable from the containing
<network>) which is to receive the packets destined for
"address/(prefix|netmask)".

These attributes are translated into an "ip route add" command that is
executed when the network is started. The command used is of the
following form:

  ip route add <address>/<prefix> via <gateway> \
               dev <virbr-bridge> proto static metric <metric>

Tests are done to validate that the input data are correct.  For
example, for a static route ip definition, the address must be a
network address and not a host address.  Additional checks are added
to ensure that the specified gateway is directly reachable via this
network (i.e. that the gateway IP address is in the same subnet as one
of the IP's defined for the network).

prefix='0' is supported for both family='ipv4' address='0.0.0.0'
netmask='0.0.0.0' or prefix='0', and for family='ipv6' address='::',
prefix=0', although care should be taken to not override a desired
system default route.

Anytime an attempt is made to define a static route which *exactly*
duplicates an existing static route (for example, address=::,
prefix=0, metric=1), the following error message will be sent to
syslog:

    RTNETLINK answers: File exists

This can be overridden by decreasing the metric value for the route
that should be preferred, or increasing the metric for the route that
shouldn't be preferred (and is thus in place only in anticipation that
the preferred route may be removed in the future).  Caution should be
used when manipulating route metrics, especially for a default route.

Note: The use of the command-line interface should be replaced by
direct use of libnl so that error conditions can be handled better.  But,
that is being left as an exercise for another day.

Signed-off-by: Gene Czarcinski <gene@czarc.net>
Signed-off-by: Laine Stump <laine@laine.org>
11 years agobuild: avoid shadowed variable in fdstreamtest
Eric Blake [Mon, 13 May 2013 19:38:18 +0000 (13:38 -0600)]
build: avoid shadowed variable in fdstreamtest

On RHEL 6.4 (gcc 4.4.7), I got:

fdstreamtest.c: In function 'testFDStreamReadCommon':
fdstreamtest.c:44: error: declaration of 'tmpfile' shadows a global declaration [-Wshadow]

* tests/fdstreamtest.c (testFDStreamReadCommon)
(testFDStreamWriteCommon): Rename 'tmpfile' variable.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoDon't overwrite useful message when creating macvlan fails
Daniel P. Berrange [Mon, 13 May 2013 16:32:55 +0000 (17:32 +0100)]
Don't overwrite useful message when creating macvlan fails

Currently we report a bogus error message when macvlan
creation fails:

error: Failed to start domain migtest
error: operation failed: Unable to create macvlan device

With this removed, we see the real error:

error: Failed to start domain migtest
error: Unable to get index for interface p31p1: No such device

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoRemove & ban use of select() for waiting for I/O
Daniel P. Berrange [Mon, 13 May 2013 13:43:20 +0000 (14:43 +0100)]
Remove & ban use of select() for waiting for I/O

Use of the select() system call is inherantly dangerous since
applications will hit a buffer overrun if any FD number exceeds
the size of the select set size (typically 1024). Replace the
two uses of select() with poll() and use cfg.mk to ban any
future use of select().

NB: This changes the phyp driver so that it uses an infinite
timeout, instead of busy-waiting for 1ms at a time.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoqemu: Add hotplug support for scsi host device
Han Cheng [Fri, 3 May 2013 18:07:31 +0000 (02:07 +0800)]
qemu: Add hotplug support for scsi host device

This adds both attachment and detachment support for scsi host
device.

Signed-off-by: Han Cheng <hanc.fnst@cn.fujitsu.com>
Signed-off-by: Osier Yang <jyang@redhat>
11 years agoFix starting domains when kernel has no cgroups support
Jim Fehlig [Fri, 10 May 2013 18:05:00 +0000 (12:05 -0600)]
Fix starting domains when kernel has no cgroups support

Found that I was unable to start existing domains after updating
to a kernel with no cgroups support

  # zgrep CGROUP /proc/config.gz
  # CONFIG_CGROUPS is not set
  # virsh start test
  error: Failed to start domain test
  error: Unable to initialize /machine cgroup: Cannot allocate memory

virCgroupPartitionNeedsEscaping() correctly returns errno (ENOENT) when
attempting to open /proc/cgroups on such a system, but it was being
dropped in virCgroupSetPartitionSuffix().

Change virCgroupSetPartitionSuffix() to propagate errors returned by
its callees.  Also check for ENOENT in qemuInitCgroup() when determining
if cgroups support is available.