]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
11 years agoqemu: check presence of each disk and its backing file as well
Guannan Ren [Wed, 31 Jul 2013 07:55:05 +0000 (15:55 +0800)]
qemu: check presence of each disk and its backing file as well

For disk with startupPolicy support, such as cdrom and floppy
when its chain is broken, the startup policy will apply,
otherwise, report an error.

11 years agoqemu: add helper functions for diskchain checking
Guannan Ren [Mon, 29 Jul 2013 12:51:15 +0000 (20:51 +0800)]
qemu: add helper functions for diskchain checking

*src/util/virstoragefile.c: Add a helper function to get
the first name of missing backing files, if the name is NULL,
it means the diskchain is not broken.
*src/qemu/qemu_domain.c: qemuDiskChainCheckBroken(disk) to
check if its chain is broken

11 years agoqemu: refactor qemuDomainCheckDiskPresence for only disk presence check
Guannan Ren [Fri, 26 Jul 2013 12:37:21 +0000 (20:37 +0800)]
qemu: refactor qemuDomainCheckDiskPresence for only disk presence check

Refactor this function to make it focus on disk presence checking,
including diskchain checking, and not only for CDROM and Floppy.
This change is good for the following patches.

11 years agoConfiguring systemd to restart libvirt on failure
Mooli Tayer [Tue, 30 Jul 2013 12:32:59 +0000 (15:32 +0300)]
Configuring systemd to restart libvirt on failure

This will create a respawn behaviour in case libvirt
process exits due to nonzero exit code, is terminated
by a signal, an operation times out or the configured
watchdog timeout is triggered.
see http://www.freedesktop.org/software/systemd/man/systemd.service.html
and https://bugzilla.redhat.com/show_bug.cgi?id=981974

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoxen: Avoid double free of virDomainDef in xenDaemonCreateXML
Stefan Bader [Wed, 31 Jul 2013 09:59:21 +0000 (11:59 +0200)]
xen: Avoid double free of virDomainDef in xenDaemonCreateXML

The virDomainDef is allocated by the caller and also used after
calling to xenDaemonCreateXML. So it must not get freed by the
callee.

Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
11 years agoEnable support for systemd-machined in cgroups creation
Daniel P. Berrange [Mon, 22 Jul 2013 15:34:51 +0000 (16:34 +0100)]
Enable support for systemd-machined in cgroups creation

Make the virCgroupNewMachine method try to use systemd-machined
first. If that fails, then fallback to using the traditional
cgroup setup code path.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoCope with races while killing processes
Daniel P. Berrange [Fri, 26 Jul 2013 15:02:22 +0000 (16:02 +0100)]
Cope with races while killing processes

When systemd is involved in managing processes, it may start
killing off & tearing down croups associated with the process
while we're still doing virCgroupKillPainfully. We must
explicitly check for ENOENT and treat it as if we had finished
killing processes

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd support for systemd cgroup mount
Daniel P. Berrange [Thu, 25 Jul 2013 18:13:44 +0000 (19:13 +0100)]
Add support for systemd cgroup mount

Systemd uses a named cgroup mount for tracking processes. Add
it as another type of controller, albeit one which we have to
special case in a number of places. In particular we must
never create/delete directories there, nor add tasks. Essentially
the systemd mount is to be considered read-only for libvirt.

With this change both the virCgroupDetectPlacement and
virCgroupCopyPlacement methods must be invoked. The copy
placement method will copy setup for resource controllers
only. The detect placement method will probe for any
named controllers, or resource controllers not already
setup.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd APIs for formatting systemd slice/scope names
Daniel P. Berrange [Fri, 26 Jul 2013 14:18:55 +0000 (15:18 +0100)]
Add APIs for formatting systemd slice/scope names

There are some interesting escaping rules to consider when dealing
with systemd slice/scope names. Thus it is helpful to have APIs
for formatting names

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoqemuagenttest: Add tests for CPU plug functions and helpers
Peter Krempa [Tue, 30 Jul 2013 12:09:16 +0000 (14:09 +0200)]
qemuagenttest: Add tests for CPU plug functions and helpers

11 years agoqemuagenttest: Introduce testing of shutdown commands
Peter Krempa [Mon, 29 Jul 2013 15:22:32 +0000 (17:22 +0200)]
qemuagenttest: Introduce testing of shutdown commands

This patch exports a few utility functions and adds testing of shutdown
commands of the guest agent.

11 years agoqemuagenttest: Add testing of agent suspend modes
Peter Krempa [Mon, 29 Jul 2013 13:24:32 +0000 (15:24 +0200)]
qemuagenttest: Add testing of agent suspend modes

11 years agoqemuagenttest: Test the filesystem trimming
Peter Krempa [Mon, 29 Jul 2013 09:02:19 +0000 (11:02 +0200)]
qemuagenttest: Test the filesystem trimming

11 years agotests: Add qemuagenttest
Peter Krempa [Wed, 24 Jul 2013 08:15:37 +0000 (10:15 +0200)]
tests: Add qemuagenttest

Add a basic test framework with two simple tests to test guest agent
interaction.

11 years agoqemumonitortestutils: Add the ability to check arguments of commands
Peter Krempa [Thu, 25 Jul 2013 13:42:38 +0000 (15:42 +0200)]
qemumonitortestutils: Add the ability to check arguments of commands

This patch adds helpers that allow to check for argument values in
commands sent to the monitor.

11 years agoqemumonitortestutils: Improve error reporting from mock qemu monitor
Peter Krempa [Mon, 29 Jul 2013 12:29:15 +0000 (14:29 +0200)]
qemumonitortestutils: Improve error reporting from mock qemu monitor

Use the JSON error messages to report errors back to the caller in
addition to erroring out. The error reported from the event loop from
the mock function of the monitor was later overwritten by the call to
the monitor/agent interaction API. This will also allow testing of error
reporting.

11 years agoqemumonitortestutils: Add instrumentation for guest agent testing
Peter Krempa [Thu, 25 Jul 2013 10:08:25 +0000 (12:08 +0200)]
qemumonitortestutils: Add instrumentation for guest agent testing

Add helper functions to open guest agent connections and a handler for
replying to the "guest-sync" command.

11 years agoqemumonitortestutils: Split lines on \n instead of \r\n
Peter Krempa [Thu, 25 Jul 2013 10:03:29 +0000 (12:03 +0200)]
qemumonitortestutils: Split lines on \n instead of \r\n

The normal monitor uses windows line endings, where the agent monitor
uses only newlines. Change this to tolerate both approaches and allow to
use the utilities for guest agent tests.

11 years agoqemumonitortestutils: Refactor the test helpers to allow reuse
Peter Krempa [Thu, 25 Jul 2013 09:48:11 +0000 (11:48 +0200)]
qemumonitortestutils: Refactor the test helpers to allow reuse

Refactor the test helpers to allow adding callbacks to verify the
monitor responses instead of simple command name checking and clean up
various parts to prepare for adding guest agent tests.

11 years agoqemumonitortestutils: Split up creation of the test to allow reuse
Peter Krempa [Mon, 22 Jul 2013 14:59:22 +0000 (16:59 +0200)]
qemumonitortestutils: Split up creation of the test to allow reuse

The instrumentation for the monitor test can be hacked for qemu agent
testing. Split out the monitor specific stuff to allow using the code in
guest agent tests in the future.

11 years agoqemumonitortestutils: Don't crash on non fully initialized test
Peter Krempa [Mon, 22 Jul 2013 14:57:08 +0000 (16:57 +0200)]
qemumonitortestutils: Don't crash on non fully initialized test

The qemumonitorjsontest crashed when one of the initialization steps
done before starting the worker thread failed. This patch fixes this by
trying to pthread_join() the thread only after it was created.

11 years agoqemumonitortestutils: remove multiline function calls
Peter Krempa [Thu, 25 Jul 2013 09:02:00 +0000 (11:02 +0200)]
qemumonitortestutils: remove multiline function calls

11 years agoqemumonitortestutils: Use VIR_DELETE_ELEMENT and VIR_APPEND_ELEMENT
Peter Krempa [Thu, 18 Jul 2013 15:09:41 +0000 (17:09 +0200)]
qemumonitortestutils: Use VIR_DELETE_ELEMENT and VIR_APPEND_ELEMENT

Simplify the code using the existing helpers instead of open coding the
same functionality.

11 years agoqemumonitortestutils: Use consistent header style and line spacing
Peter Krempa [Thu, 18 Jul 2013 14:17:31 +0000 (16:17 +0200)]
qemumonitortestutils: Use consistent header style and line spacing

11 years agoqemu_agent: Remove obvious comments
Peter Krempa [Thu, 25 Jul 2013 08:59:21 +0000 (10:59 +0200)]
qemu_agent: Remove obvious comments

Most APIs in libvirt report errors, thus no need to state that
explicitly.

11 years agoqemu_agent: Move updater function for VCPU hotplug into qemu_agent.c
Peter Krempa [Tue, 30 Jul 2013 10:04:21 +0000 (12:04 +0200)]
qemu_agent: Move updater function for VCPU hotplug into qemu_agent.c

To allow testing of the cpu updater function, this function needs to be
available separately. Export it from qemu_agent.c where it should
belong.

11 years agoqemu_agent: Output newline at the end of the sync JSON message
Peter Krempa [Wed, 24 Jul 2013 15:52:33 +0000 (17:52 +0200)]
qemu_agent: Output newline at the end of the sync JSON message

Although this isn't apparently needed for the guest agent itself, the
test I will be adding later depends on the newline as a separator of
messages to process.

11 years agoconf: Export virDomainChrSourceDefClear()
Peter Krempa [Mon, 22 Jul 2013 14:45:32 +0000 (16:45 +0200)]
conf: Export virDomainChrSourceDefClear()

11 years agoDon't mark parentIndex with ATTRIBUTE_UNUSED
Ján Tomko [Wed, 31 Jul 2013 07:42:58 +0000 (09:42 +0200)]
Don't mark parentIndex with ATTRIBUTE_UNUSED

parentIndex is used in virNetworkDefUpdateIPDHCPRange

11 years agoadd console support in libxl
Bamvor Jian Zhang [Fri, 26 Jul 2013 03:30:50 +0000 (11:30 +0800)]
add console support in libxl

this patch introduce the console api in libxl driver for both pv and
hvm guest.  and import and update the libxlMakeChrdevStr function
which was deleted in commit dfa1e1dd.

Signed-off-by: Bamvor Jian Zhang <bjzhang@suse.com>
11 years agoutil: add virGetUserDirectoryByUID
Dan Walsh [Tue, 30 Jul 2013 19:55:44 +0000 (15:55 -0400)]
util: add virGetUserDirectoryByUID

This function is needed for virt-login-shell.  Also modify virGirUserDirectory
to use the new function, to simplify the code.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agomaint: fix typo for SENTINEL
Eric Blake [Tue, 30 Jul 2013 16:49:53 +0000 (10:49 -0600)]
maint: fix typo for SENTINEL

* src/openvz/openvz_driver.c: Use correct spelling.
* src/vmware/vmware_conf.c: Likewise.
* src/vmware/vmware_conf.h: Likewise.
* src/vmware/vmware_driver.c: Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agospec: Don't mix commands with macro definitions
Jiri Denemark [Tue, 30 Jul 2013 14:04:48 +0000 (16:04 +0200)]
spec: Don't mix commands with macro definitions

%build section should first define all required macros and then run
commands. Interleaving them makes it harder to spot what commands are
run.

11 years agospec: Use --enable-werror on RHEL
Jiri Denemark [Tue, 30 Jul 2013 14:01:11 +0000 (16:01 +0200)]
spec: Use --enable-werror on RHEL

As RHEL provides a stable tool chain, we don't have to worry about
frequent changes in reported compiler warnings (which prevents us from
enabling -Werror unconditionally).

11 years agospec: RHEL-7 does not have sanlock on i686
Jiri Denemark [Tue, 30 Jul 2013 11:45:04 +0000 (13:45 +0200)]
spec: RHEL-7 does not have sanlock on i686

11 years agospec: Disable libssh2 support for RHEL
Peter Krempa [Mon, 28 Jan 2013 19:17:31 +0000 (20:17 +0100)]
spec: Disable libssh2 support for RHEL

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

Libssh2 isn't reliable enough to support the libvirt transport using it.
The problems include mishandling of "known_hosts" files that may confuse
users.

11 years agotests: Put a mock library at the start of LD_PRELOAD
Jiri Denemark [Tue, 30 Jul 2013 08:41:50 +0000 (10:41 +0200)]
tests: Put a mock library at the start of LD_PRELOAD

This fixes vircgrouptest when run in a sandbox which already overrides
open() and others.

11 years agoSupport apparmor in RPM spec
Daniel P. Berrange [Tue, 30 Jul 2013 11:04:55 +0000 (12:04 +0100)]
Support apparmor in RPM spec

If libapparmor-devel happens to be installed when building the
RPM, it will failed due to unlisted virt-aa-helper in %files.
Add support for apparmor in the spec, so that we can explicitly
turn it on/off, defaulting to off in all distros. This causes
--without-apparmor to be given to configure, preventing the
build failures if the user happens to have libapparmor-devel
present.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoDelete obsolete / unused python test files
Daniel P. Berrange [Tue, 30 Jul 2013 10:24:22 +0000 (11:24 +0100)]
Delete obsolete / unused python test files

The python/tests directory contains a number of so called
"tests" for the python API. These are all hardcoded to
look for Xen and cannot be run in any automated fashion,
and no one is ever manually running them. Given that they
don't meaningully contribute to the test coverage, delete
them.

For some reason these tests were also copied into the
filesystem as part of 'make install'. The change to the
RPM in commit 3347a4203278ec93d7b0ceb88b5ed10e4f14765c
caused a build failure, since it removed the code which
deleted these installed tests.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix minor typos in messages and docs
Yuri Chornoivan [Tue, 30 Jul 2013 08:21:11 +0000 (11:21 +0300)]
Fix minor typos in messages and docs

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoRelease of libvirt-1.1.1
Daniel Veillard [Tue, 30 Jul 2013 09:38:35 +0000 (17:38 +0800)]
Release of libvirt-1.1.1

* configure.ac docs/news.html.in: update for the release
* po/*.po*: update localizations and regenerate

11 years agobuild: fix shunloadtest breakage
Eric Blake [Mon, 29 Jul 2013 19:06:27 +0000 (13:06 -0600)]
build: fix shunloadtest breakage

Commit 93ec384 was tested on mingw, but broke the build on Linux:

  CCLD     shunloadtest
shunloadtest.o: In function `main':
/home/eblake/libvirt/tests/shunloadtest.c:106: undefined reference to `virFilePrintf'
...
ssh.o: In function `main':
/home/eblake/libvirt/tests/ssh.c:43: undefined reference to `virFilePrintf'
/home/eblake/libvirt/tests/ssh.c:49: undefined reference to `virFilePrintf'

* tests/testutils.h (fprintf): Provide escape hatch.
* tests/shunloadtest.c: Use it.
* tests/ssh.c: Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoexamples: fix mingw build vs. printf
Eric Blake [Mon, 29 Jul 2013 18:53:36 +0000 (12:53 -0600)]
examples: fix mingw build vs. printf

Mingw *printf is a moving target; newer mingw now provides a version
of asprintf() that fails to understand %lld:

  CC       event_test-event-test.o
../../../../examples/domain-events/events-c/event-test.c: In function 'myDomainEventRTCChangeCallback':
../../../../examples/domain-events/events-c/event-test.c:270:18: error: unknown conversion type character 'l' in format [-Werror=format=]
                  virDomainGetID(dom), offset) < 0)
                  ^

But since our examples already admitted that they were hacking around
a mingw deficiency, it is easier to just use printf() directly, coupled
with <inttypes.h> macros, for a more portable work-around.

* examples/domain-events/events-c/event-test.c
(myDomainEventRTCChangeCallback): Use PRIdMAX instead of asprintf.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agotests: consistently use virFilePrintf
Eric Blake [Mon, 29 Jul 2013 18:01:19 +0000 (12:01 -0600)]
tests: consistently use virFilePrintf

Commit a2619962 introduced virFilePrintf to work around the fact
that gnulib doesn't (yet) provide guarantees about fprintf() vs.
%z, which in turn causes all sorts of mingw compilation errors:

../../tests/testutils.c: In function 'virtTestResult':
../../tests/testutils.c:101:9: error: unknown conversion type character 'z' in format [-Werror=format=]
         fprintf(stderr, "%3zu) %-60s ", testCounter, name);
         ^

Rather than s/fprintf/virFilePrintf/ (and reformatting loads of
lines) across multiple files, it's easier to just hack the entire
testsuite to take advantage of our helper function.

* tests/testutils.c: s/fprintf/virFilePrintf/ for mingw.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: skip systemd mock on non-Linux
Eric Blake [Mon, 29 Jul 2013 16:47:09 +0000 (10:47 -0600)]
build: skip systemd mock on non-Linux

A cross-compile to mingw failed:

  CC       virsystemdmock_la-virsystemdmock.lo
../../tests/virsystemdmock.c:29:6: error: 'dbus_connection_set_change_sigpipe' redeclared without dllimport attribute: previous dllimport ignored [-Werror=attributes]
 void dbus_connection_set_change_sigpipe(dbus_bool_t will_modify_sigpipe ATTRIBUTE_UNUSED)
      ^

But when you think about it, systemd is Linux-only, and even our
use of LD_PRELOAD to provide mock syscalls is Linux-only.

* tests/virsystemdmock.c: Avoid compilation outside Linux.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoRename VIR_DOMAIN_PAUSED_GUEST_PANICKED to VIR_DOMAIN_PAUSED_CRASHED
Daniel P. Berrange [Mon, 29 Jul 2013 16:54:57 +0000 (17:54 +0100)]
Rename VIR_DOMAIN_PAUSED_GUEST_PANICKED to VIR_DOMAIN_PAUSED_CRASHED

The VIR_DOMAIN_PAUSED_GUEST_PANICKED constant is badly named,
leaking the QEMU event name. Elsewhere in the API we use
'CRASHED' rather than 'PANICKED', and the addition of 'GUEST'
is redundant since all events are guest related.

Thus rename it to VIR_DOMAIN_PAUSED_CRASHED, which matches
with VIR_DOMAIN_RUNNING_CRASHED and VIR_DOMAIN_EVENT_CRASHED.

It was added in commit 14e7e0ae8db9843aea80245a3d9e6cf5f2ef720d
which post-dates v1.1.0, so is safe to rename before 1.1.1

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoRemove VIR_DOMAIN_SHUTDOWN_CRASHED from public API
Daniel P. Berrange [Mon, 29 Jul 2013 16:46:14 +0000 (17:46 +0100)]
Remove VIR_DOMAIN_SHUTDOWN_CRASHED from public API

The VIR_DOMAIN_SHUTDOWN_CRASHED state constant does not appear
to be used in the QEMU code anyway. It also doesn't make much
(any) sense, since the 'shutdown' state is a transient state
between 'running' and 'shutoff' and when a guest crashes, it
does not end up in a 'shutdown' state, only 'shutoff'.

It was added in commit 14e7e0ae8db9843aea80245a3d9e6cf5f2ef720d
which post-dates v1.1.0, so is safe to remove before 1.1.1

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix dbus message reading code on big endian hosts
Daniel P. Berrange [Mon, 29 Jul 2013 16:29:00 +0000 (17:29 +0100)]
Fix dbus message reading code on big endian hosts

The way we were casting small (<32bit) integers was broken
on big endian hosts, causing stack smashing. This was detected
in the test suite either by test failures due to incorrect
results, or by libc/gcc abort'ing with its stack canary
triggered.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agospec: Cat test-suite.log if make check fails
Jiri Denemark [Mon, 29 Jul 2013 15:36:20 +0000 (17:36 +0200)]
spec: Cat test-suite.log if make check fails

Current automake enables parallel test by default, which means test
details are only logged in test-suite.log and not printed to stderr.
This patch makes test failures directly visible in RPM build logs even
when parallel tests are turned on.

11 years agobuild: fix another virdbus issue on mingw
Eric Blake [Mon, 29 Jul 2013 15:58:19 +0000 (09:58 -0600)]
build: fix another virdbus issue on mingw

Depending on the set of mingw packages installed, it is possible
that other .c files hit the mingw header pollution from the
virdbus.h file.

In file included from ../../src/rpc/virnetserver.c:39:0:
../../src/util/virdbus.h:41:35: error: expected ';', ',' or ')' before 'struct'
                       const char *interface,
                                   ^

* src/util/virdbus.h (virDBusCallMethod): Match .c file change.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: fix virutil build on mingw
Eric Blake [Mon, 29 Jul 2013 14:04:35 +0000 (08:04 -0600)]
build: fix virutil build on mingw

On platforms without decent group support, the build failed:

Cannot export virGetGroupList: symbol not defined
./.libs/libvirt_security_manager.a(libvirt_security_manager_la-security_dac.o): In function `virSecurityDACPreFork':
/home/eblake/libvirt-tmp/build/src/../../src/security/security_dac.c:248: undefined reference to `virGetGroupList'
collect2: error: ld returned 1 exit status

* src/util/virutil.c (virGetGroupList): Provide dummy implementation.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: fix virthread build on mingw
Eric Blake [Mon, 29 Jul 2013 13:54:10 +0000 (07:54 -0600)]
build: fix virthread build on mingw

Our recent conversion to make VIR_ALLOC report oom wasn't
tested on mingw:

In file included from ../../src/util/virthread.c:29:0:
../../src/util/virthreadwin32.c: In function 'virCondWait':
../../src/util/virthreadwin32.c:166:81: error: 'VIR_FROM_THIS' undeclared (first use in this function)
     if (VIR_REALLOC_N(c->waiters, c->nwaiters + 1) < 0) {
                                                                                 ^

* src/util/virthreadwin32.c (VIR_FROM_THIS): Define.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: fix virdbus build on mingw
Eric Blake [Mon, 29 Jul 2013 13:54:10 +0000 (07:54 -0600)]
build: fix virdbus build on mingw

Mingw headers pollute the namespace.

  CC       libvirt_util_la-virdbus.lo
../../src/util/virdbus.c:1102:35: error: expected ';', ',' or ')' before 'struct'
                       const char *interface,
                                   ^

* src/util/virdbus.c (virDBusCallMethod): Avoid 'interface'.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: fix vircgroup build on mingw
Eric Blake [Mon, 29 Jul 2013 14:55:05 +0000 (08:55 -0600)]
build: fix vircgroup build on mingw

The previous patch was incomplete.

  CC       libvirt_util_la-vircgroup.lo
../../src/util/vircgroup.c:70:12: error: 'virCgroupPartitionEscape' declared 'static' but never defined [-Werror=unused-function]
 static int virCgroupPartitionEscape(char **path);
            ^

* src/util/vircgroup.c (virCgroupPartitionEscape): Move forward
declaration inside conditional.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoConditionalize build of virCgroupValidateMachineGroup
Daniel P. Berrange [Mon, 29 Jul 2013 13:36:07 +0000 (14:36 +0100)]
Conditionalize build of virCgroupValidateMachineGroup

The virCgroupValidateMachineGroup method calls some functions
which are only conditionally compiled, thus it too must be
made conditional. This fixes the build on non-Linux hosts.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agobuild: fix VPATH 'make check'
Eric Blake [Mon, 29 Jul 2013 13:00:00 +0000 (07:00 -0600)]
build: fix VPATH 'make check'

A VPATH build 'make check' was failing with:

  GEN      check-driverimpls
Can't open ../../src/../../src/lxc/lxc_monitor_protocol.h: No such file or directory at ../../src/check-driverimpls.pl line 29, <> line 27153.
Can't open ../../src/../../src/lxc/lxc_monitor_protocol.c: No such file or directory at ../../src/check-driverimpls.pl line 29, <> line 27153.
...
  GEN      check-aclrules
cannot read ../../src/../../src/remote/remote_protocol.x at ../../src/check-aclrules.pl line 128.

because $(srcdir) was being prepended to file names that already
included it.

* src/Makefile.am (check-driverimpls): Don't add srcdir twice.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agopython: Drop TODO
Cole Robinson [Mon, 29 Jul 2013 11:53:16 +0000 (07:53 -0400)]
python: Drop TODO

File hasn't been really touched for 7 years. And with recent rawhide
changes it contributed to an RPM build failure. Let's drop it.

This also removes installation of a libvirt-python doc dir, so drop
handling of it from the RPM spec.

11 years agoFix probing of legacy Xen driver to not leave URI set
Daniel P. Berrange [Fri, 26 Jul 2013 16:28:02 +0000 (17:28 +0100)]
Fix probing of legacy Xen driver to not leave URI set

When the legacy Xen driver probes with a NULL URI, and
finds itself running on Xen, it will set conn->uri. A
little bit later though it checks to see if libxl support
exists, and if so declines the driver. This leaves the
conn->uri set to 'xen:///', so if libxl also declines
it, it prevents probing of the QEMU driver.

Once a driver has set the conn->uri, it must *never*
decline an open request. So we must move the libxl
check earlier

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agocpu: Fix one compile error for PPC.
Li Zhang [Mon, 29 Jul 2013 07:41:19 +0000 (15:41 +0800)]
cpu: Fix one compile error for PPC.

CPU data structure is refined, which causes one compile error for PPC.

Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com>
11 years agocaps: use -device for primary video when qemu >=1.6
Guannan Ren [Fri, 26 Jul 2013 12:53:47 +0000 (20:53 +0800)]
caps: use -device for primary video when qemu >=1.6

https://bugzilla.redhat.com/show_bug.cgi?id=981094
The commit 0ad9025ef introduce qemu flag QEMU_CAPS_DEVICE_VIDEO_PRIMARY
for using -device VGA, -device cirrus-vga, -device vmware-svga and
-device qxl-vga. In use, for -device qxl-vga, mouse doesn't display
in guest window like the desciption in above bug.
This patch try to use -device for primary video when qemu >=1.6 which
contains the bug fix patch

11 years agobuild: avoid uninitialized use warning
Eric Blake [Fri, 26 Jul 2013 22:37:55 +0000 (16:37 -0600)]
build: avoid uninitialized use warning

Otherwise, with new enough gcc compiling at -O2, the build fails with:
../../src/conf/domain_conf.c: In function ‘virDomainDeviceDefPostParse’:
../../src/conf/domain_conf.c:2821:29: error: ‘cnt’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
             for (i = 0; i < *cnt; i++) {
                             ^
../../src/conf/domain_conf.c:2795:20: note: ‘cnt’ was declared here
         size_t i, *cnt;
                    ^
../../src/conf/domain_conf.c:2794:30: error: ‘arrPtr’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
         virDomainChrDefPtr **arrPtr;
                              ^

* src/conf/domain_conf.c (virDomainChrGetDomainPtrs): Always
assign into output parameters.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoSet default partition in libvirtd instead of libvirt_lxc
Daniel P. Berrange [Fri, 26 Jul 2013 14:59:16 +0000 (15:59 +0100)]
Set default partition in libvirtd instead of libvirt_lxc

By setting the default partition in libvirt_lxc it is not
visible when querying the live XML. Move setting of the
default partition into libvirtd virLXCProcessStart

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agovirStateDriver - Separate AutoStart from Initialize
John Ferlan [Thu, 25 Jul 2013 12:03:38 +0000 (08:03 -0400)]
virStateDriver - Separate AutoStart from Initialize

Adjust these drivers to handle their Autostart functionality after each
of the drivers has gone through their Initialization functions

11 years agoSeparate out StateAutoStart from StateInitialize
John Ferlan [Thu, 25 Jul 2013 12:01:02 +0000 (08:01 -0400)]
Separate out StateAutoStart from StateInitialize

Separation allows for dependent drivers to be make a connection during
the AutoStart phase of state initialization.

11 years agoResolve Coverity complaint in storagevolxml2argvtest
Ján Tomko [Fri, 26 Jul 2013 11:10:12 +0000 (13:10 +0200)]
Resolve Coverity complaint in storagevolxml2argvtest

Ignore NULL pool in testSetVolumeType to silence Coverity,
even though we only call it with NULL pool when vol is also NULL.

(13) Event var_deref_model: Passing null pointer "inputpool" to
function "testSetVolumeType(virStorageVolDefPtr, virStoragePoolDefPtr)",
which dereferences it. [details]
Also see events: [assign_zero]

95    testSetVolumeType(inputvol, inputpool);

11 years agoRemove redundant free in virNetworkDNSHostDefParseXML
Ján Tomko [Fri, 26 Jul 2013 10:21:13 +0000 (12:21 +0200)]
Remove redundant free in virNetworkDNSHostDefParseXML

ip has to be NULL at this point.

11 years agoRemove double space in error messages
Ján Tomko [Fri, 26 Jul 2013 10:15:41 +0000 (12:15 +0200)]
Remove double space in error messages

11 years agoDon't check validity of missing attributes in DNS SRV XML
Ján Tomko [Fri, 26 Jul 2013 10:11:21 +0000 (12:11 +0200)]
Don't check validity of missing attributes in DNS SRV XML

This fixes a crash if one of them is missing.

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

11 years agoSet the number of elements 0 in virNetwork*Clear
Ján Tomko [Fri, 26 Jul 2013 10:04:32 +0000 (12:04 +0200)]
Set the number of elements 0 in virNetwork*Clear

Decrementing it when it was already 0 causes an invalid free
in virNetworkDefUpdateDNSHost if virNetworkDNSHostDefParseXML
fails and virNetworkDNSHostDefClear gets called twice.

virNetworkForwardDefClear left the number untouched even if it
freed all the elements.

11 years agoformatdomain.html.in: Document implementation limitation of QoS
Michal Privoznik [Fri, 26 Jul 2013 09:42:53 +0000 (11:42 +0200)]
formatdomain.html.in: Document implementation limitation of QoS

The outbound/@peak is ignored (since QoS was introduced). This is due to
kernel limitation of know allowing ingress filters to have peak just
average rate. However, we should document this limitation to not confuse
users.

11 years agoformatdomain.html.in: Correctly use <code/> in #elementQoS
Michal Privoznik [Fri, 26 Jul 2013 09:40:52 +0000 (11:40 +0200)]
formatdomain.html.in: Correctly use <code/> in #elementQoS

Interestingly, we had <code>floor<code> ... </code>outbound</code> which
results in much larger block of text to be written in code style that
intended.

11 years agoconf:Fix a copy paste error
Alex Jia [Fri, 26 Jul 2013 09:19:16 +0000 (17:19 +0800)]
conf:Fix a copy paste error

Signed-off-by: Alex Jia <ajia@redhat.com>
11 years agoFix virsh snapshot-list error reporting
Jim Fehlig [Thu, 25 Jul 2013 20:18:14 +0000 (14:18 -0600)]
Fix virsh snapshot-list error reporting

Noticed that the expected "not supported" error is dropped when
invoking 'virsh snapshot-list dom' on a Xen installation running
the libxl driver

 virsh snapshot-list test
 error: Invalid snapshot: virDomainSnapshotFree

The error is overwritten by a call to virDomainSnapshotFree
in cleanup code within cmdSnapshotList.  Prevent overwritting
the real error by not calling virDomainSnapshotFree with a NULL
virDomainSnapshotPtr.

11 years agoSkip detecting placement if controller is disabled
Daniel P. Berrange [Thu, 25 Jul 2013 12:12:30 +0000 (13:12 +0100)]
Skip detecting placement if controller is disabled

If the app has provided a whitelist of controllers to be used,
we skip detecting its mount point. We still, however, fill in
the placement info which later confuses the machine name
validation code. Skip detecting placement if the controller
mount point is not set

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd 'controllers' arg to virCgroupNewDetect
Daniel P. Berrange [Wed, 24 Jul 2013 16:31:25 +0000 (17:31 +0100)]
Add 'controllers' arg to virCgroupNewDetect

When detecting cgroups we must honour any controllers
whitelist the driver may have.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix detection of 'emulator' cgroup
Daniel P. Berrange [Wed, 24 Jul 2013 16:41:44 +0000 (17:41 +0100)]
Fix detection of 'emulator' cgroup

When a VM has an 'emulator' child cgroup present, we must
strip off that suffix when detecting the cgroup for a
machine

Rename the virCgroupIsValidMachineGroup method to
virCgroupValidateMachineGroup to make a bit clearer
that this isn't simply a boolean check, it will make
changes to the object.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoMake virCgroupIsValidMachine static
Daniel P. Berrange [Wed, 24 Jul 2013 16:38:08 +0000 (17:38 +0100)]
Make virCgroupIsValidMachine static

The virCgroupIsValidMachine does not need to be called from
outside the cgroups file now, so make it static.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoIntroduce a more convenient virCgroupNewDetectMachine
Daniel P. Berrange [Wed, 24 Jul 2013 16:36:42 +0000 (17:36 +0100)]
Introduce a more convenient virCgroupNewDetectMachine

Instead of requiring drivers to use a combination of calls
to virCgroupNewDetect and virCgroupIsValidMachine, combine
the two into virCgroupNewDetectMachine

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agovirdbustest: Don't pass number of arguments as long long
Guido Günther [Wed, 24 Jul 2013 21:19:43 +0000 (23:19 +0200)]
virdbustest: Don't pass number of arguments as long long

since sizeof(int) != sizeof(long long) on 32bit archs.

This unbreaks virdbustest which otherwise fails like:

 (gdb) bt
 #0  __strlen_sse2_bsf () at ../sysdeps/i386/i686/multiarch/strlen-sse2-bsf.S:50
 #1  0x405907d2 in ?? () from /lib/i386-linux-gnu/libdbus-1.so.3
 #2  0x4057c140 in ?? () from /lib/i386-linux-gnu/libdbus-1.so.3
 #3  0x4057e7ec in dbus_message_iter_append_basic () from /lib/i386-linux-gnu/libdbus-1.so.3
 #4  0x400742ec in virDBusMessageIterEncode (args=0xbfd4b8f0 "k\321\004\b.", types=0x804d260 "",
     rootiter=0xbfd4b844) at util/virdbus.c:560
 #5  virDBusMessageEncodeArgs (msg=msg@entry=0x893c278, types=types@entry=0x804d25c "sais",
     args=args@entry=0xbfd4b8d8 "r\320\004\b\003") at util/virdbus.c:921
 #6  0x40075917 in virDBusMessageEncode (msg=0x893c278, types=0x804d25c "sais") at util/virdbus.c:959
 #7  0x0804a4a1 in testMessageArray (args=0x0) at virdbustest.c:195
 #8  0x0804c404 in virtTestRun (title=title@entry=0x804cfcb "Test message array ",
     nloops=nloops@entry=1, body=body@entry=0x804a3f0 <testMessageArray>, data=data@entry=0x0)
     at testutils.c:168
 #9  0x08049346 in mymain () at virdbustest.c:384
 #10 0x0804cb2e in virtTestMain (argc=argc@entry=1, argv=argv@entry=0xbfd4bb24,
     func=func@entry=0x80492c0 <mymain>) at testutils.c:764
 #11 0x080491af in main (argc=1, argv=0xbfd4bb24) at virdbustest.c:393

11 years agoAdd inputpool to storagevolxml2argvtest
Ján Tomko [Mon, 22 Jul 2013 13:55:40 +0000 (15:55 +0200)]
Add inputpool to storagevolxml2argvtest

This allows testing the command line for cloning file-based
volumes into logical volumes and vice versa.

11 years agoMove volume XMLs out of storagevolxml2argvdata
Ján Tomko [Mon, 22 Jul 2013 13:44:06 +0000 (15:44 +0200)]
Move volume XMLs out of storagevolxml2argvdata

Reuse the XML files in storagevolxml2xmlin.

(This requires changing a few backing files to /dev/null,
since virStorageBackendCreateQemuImgCmd checks for its
presence)

11 years agoMove pool XML out of storagevolxml2argvdata
Ján Tomko [Mon, 22 Jul 2013 12:56:26 +0000 (14:56 +0200)]
Move pool XML out of storagevolxml2argvdata

Reuse the pool definition from storagepoolxml2xmlin.

11 years agoUse separate macros for failure/success in vol-to-argv test
Ján Tomko [Mon, 22 Jul 2013 07:11:50 +0000 (09:11 +0200)]
Use separate macros for failure/success in vol-to-argv test

Reindent them to put the input volume on a separate line.

11 years agotests: PCI controller checks
Ján Tomko [Mon, 22 Jul 2013 06:51:55 +0000 (08:51 +0200)]
tests: PCI controller checks

Check if PCI bridges with duplicate indexes are rejected.
PCI root controllers with non-zero indexes or addresses should
also be rejected.

11 years agoDon't overwrite errors in qemuTranslateDiskSourcePool
Ján Tomko [Wed, 24 Jul 2013 08:38:20 +0000 (10:38 +0200)]
Don't overwrite errors in qemuTranslateDiskSourcePool

Both virStoragePoolFree and virStorageVolFree reset the last error,
which might lead to the cryptic message:
An error occurred, but the cause is unknown

When the volume wasn't found, virStorageVolFree was called with NULL,
leading to an error:
invalid storage volume pointer in virStorageVolFree

This patch changes it to:
Storage volume not found: no storage vol with matching name 'tomato'

11 years agoProtection against doing bad stuff to the root group
Daniel P. Berrange [Tue, 23 Jul 2013 14:47:03 +0000 (15:47 +0100)]
Protection against doing bad stuff to the root group

Add protection such that the virCgroupRemove and
virCgroupKill* do not do anything to the root cgroup.

Killing all PIDs in the root cgroup does not end well.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoConvert LXC driver to use virCgroupNewMachine
Daniel P. Berrange [Mon, 22 Jul 2013 16:11:09 +0000 (17:11 +0100)]
Convert LXC driver to use virCgroupNewMachine

Convert the LXC driver code to use the new atomic API
for setup of cgroups

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoConvert QEMU driver to use virCgroupNewMachine
Daniel P. Berrange [Mon, 22 Jul 2013 15:44:52 +0000 (16:44 +0100)]
Convert QEMU driver to use virCgroupNewMachine

Convert the QEMU driver code to use the new atomic API
for setup of cgroups

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoNew cgroups API for atomically creating machine cgroups
Daniel P. Berrange [Thu, 18 Jul 2013 15:55:37 +0000 (16:55 +0100)]
New cgroups API for atomically creating machine cgroups

Instead of requiring one API call to create a cgroup and
another to add a task to it, introduce a new API
virCgroupNewMachine which does both jobs at once. This
will facilitate the later code to talk to systemd to
achieve this job which is also atomic.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agovirLXCMonitorClose: Unlock domain while closing monitor
Michal Privoznik [Wed, 24 Jul 2013 07:47:03 +0000 (09:47 +0200)]
virLXCMonitorClose: Unlock domain while closing monitor

There's a race in lxc driver causing a deadlock. If a domain is
destroyed immediately after started, the deadlock can occur. When domain
is started, the even loop tries to connect to the monitor. If the
connecting succeeds, virLXCProcessMonitorInitNotify() is called with
@mon->client locked. The first thing that callee does, is
virObjectLock(vm). So the order of locking is: 1) @mon->client, 2) @vm.

However, if there's another thread executing virDomainDestroy on the
very same domain, the first thing done here is locking the @vm. Then,
the corresponding libvirt_lxc process is killed and monitor is closed
via calling virLXCMonitorClose(). This callee tries to lock @mon->client
too. So the order is reversed to the first case. This situation results
in deadlock and unresponsive libvirtd (since the eventloop is involved).

The proper solution is to unlock the @vm in virLXCMonitorClose prior
entering virNetClientClose(). See the backtrace as follows:

Thread 25 (Thread 0x7f1b7c9b8700 (LWP 16312)):
0  0x00007f1b80539714 in __lll_lock_wait () from /lib64/libpthread.so.0
1  0x00007f1b8053516c in _L_lock_516 () from /lib64/libpthread.so.0
2  0x00007f1b80534fbb in pthread_mutex_lock () from /lib64/libpthread.so.0
3  0x00007f1b82a637cf in virMutexLock (m=0x7f1b3c0038d0) at util/virthreadpthread.c:85
4  0x00007f1b82a4ccf2 in virObjectLock (anyobj=0x7f1b3c0038c0) at util/virobject.c:320
5  0x00007f1b82b861f6 in virNetClientCloseInternal (client=0x7f1b3c0038c0, reason=3) at rpc/virnetclient.c:696
6  0x00007f1b82b862f5 in virNetClientClose (client=0x7f1b3c0038c0) at rpc/virnetclient.c:721
7  0x00007f1b6ee12500 in virLXCMonitorClose (mon=0x7f1b3c007210) at lxc/lxc_monitor.c:216
8  0x00007f1b6ee129f0 in virLXCProcessCleanup (driver=0x7f1b68100240, vm=0x7f1b680ceb70, reason=VIR_DOMAIN_SHUTOFF_DESTROYED) at lxc/lxc_process.c:174
9  0x00007f1b6ee14106 in virLXCProcessStop (driver=0x7f1b68100240, vm=0x7f1b680ceb70, reason=VIR_DOMAIN_SHUTOFF_DESTROYED) at lxc/lxc_process.c:710
10 0x00007f1b6ee1aa36 in lxcDomainDestroyFlags (dom=0x7f1b5c002560, flags=0) at lxc/lxc_driver.c:1291
11 0x00007f1b6ee1ab1a in lxcDomainDestroy (dom=0x7f1b5c002560) at lxc/lxc_driver.c:1321
12 0x00007f1b82b05be5 in virDomainDestroy (domain=0x7f1b5c002560) at libvirt.c:2303
13 0x00007f1b835a7e85 in remoteDispatchDomainDestroy (server=0x7f1b857419d0, client=0x7f1b8574ae40, msg=0x7f1b8574acf0, rerr=0x7f1b7c9b7c30, args=0x7f1b5c004a50) at remote_dispatch.h:3143
14 0x00007f1b835a7d78 in remoteDispatchDomainDestroyHelper (server=0x7f1b857419d0, client=0x7f1b8574ae40, msg=0x7f1b8574acf0, rerr=0x7f1b7c9b7c30, args=0x7f1b5c004a50, ret=0x7f1b5c0029e0) at remote_dispatch.h:3121
15 0x00007f1b82b93704 in virNetServerProgramDispatchCall (prog=0x7f1b8573af90, server=0x7f1b857419d0, client=0x7f1b8574ae40, msg=0x7f1b8574acf0) at rpc/virnetserverprogram.c:435
16 0x00007f1b82b93263 in virNetServerProgramDispatch (prog=0x7f1b8573af90, server=0x7f1b857419d0, client=0x7f1b8574ae40, msg=0x7f1b8574acf0) at rpc/virnetserverprogram.c:305
17 0x00007f1b82b8c0f6 in virNetServerProcessMsg (srv=0x7f1b857419d0, client=0x7f1b8574ae40, prog=0x7f1b8573af90, msg=0x7f1b8574acf0) at rpc/virnetserver.c:163
18 0x00007f1b82b8c1da in virNetServerHandleJob (jobOpaque=0x7f1b8574dca0, opaque=0x7f1b857419d0) at rpc/virnetserver.c:184
19 0x00007f1b82a64158 in virThreadPoolWorker (opaque=0x7f1b8573cb10) at util/virthreadpool.c:144
20 0x00007f1b82a63ae5 in virThreadHelper (data=0x7f1b8574b9f0) at util/virthreadpthread.c:161
21 0x00007f1b80532f4a in start_thread () from /lib64/libpthread.so.0
22 0x00007f1b7fc4f20d in clone () from /lib64/libc.so.6

Thread 1 (Thread 0x7f1b83546740 (LWP 16297)):
0  0x00007f1b80539714 in __lll_lock_wait () from /lib64/libpthread.so.0
1  0x00007f1b8053516c in _L_lock_516 () from /lib64/libpthread.so.0
2  0x00007f1b80534fbb in pthread_mutex_lock () from /lib64/libpthread.so.0
3  0x00007f1b82a637cf in virMutexLock (m=0x7f1b680ceb80) at util/virthreadpthread.c:85
4  0x00007f1b82a4ccf2 in virObjectLock (anyobj=0x7f1b680ceb70) at util/virobject.c:320
5  0x00007f1b6ee13bd7 in virLXCProcessMonitorInitNotify (mon=0x7f1b3c007210, initpid=4832, vm=0x7f1b680ceb70) at lxc/lxc_process.c:601
6  0x00007f1b6ee11fd3 in virLXCMonitorHandleEventInit (prog=0x7f1b3c001f10, client=0x7f1b3c0038c0, evdata=0x7f1b8574a7d0, opaque=0x7f1b3c007210) at lxc/lxc_monitor.c:109
7  0x00007f1b82b8a196 in virNetClientProgramDispatch (prog=0x7f1b3c001f10, client=0x7f1b3c0038c0, msg=0x7f1b3c003928) at rpc/virnetclientprogram.c:259
8  0x00007f1b82b87030 in virNetClientCallDispatchMessage (client=0x7f1b3c0038c0) at rpc/virnetclient.c:1019
9  0x00007f1b82b876bb in virNetClientCallDispatch (client=0x7f1b3c0038c0) at rpc/virnetclient.c:1140
10 0x00007f1b82b87d41 in virNetClientIOHandleInput (client=0x7f1b3c0038c0) at rpc/virnetclient.c:1312
11 0x00007f1b82b88f51 in virNetClientIncomingEvent (sock=0x7f1b3c0044e0, events=1, opaque=0x7f1b3c0038c0) at rpc/virnetclient.c:1832
12 0x00007f1b82b9e1c8 in virNetSocketEventHandle (watch=3321, fd=54, events=1, opaque=0x7f1b3c0044e0) at rpc/virnetsocket.c:1695
13 0x00007f1b82a272cf in virEventPollDispatchHandles (nfds=21, fds=0x7f1b8574ded0) at util/vireventpoll.c:498
14 0x00007f1b82a27af2 in virEventPollRunOnce () at util/vireventpoll.c:645
15 0x00007f1b82a25a61 in virEventRunDefaultImpl () at util/virevent.c:273
16 0x00007f1b82b8e97e in virNetServerRun (srv=0x7f1b857419d0) at rpc/virnetserver.c:1097
17 0x00007f1b8359db6b in main (argc=2, argv=0x7ffff98dbaa8) at libvirtd.c:1512

11 years agolibxl: Correctly initialize vcpu bitmap
Stefan Bader [Wed, 24 Jul 2013 11:43:43 +0000 (13:43 +0200)]
libxl: Correctly initialize vcpu bitmap

The avail_vcpu bitmap has to be allocated before it can be used (using
the maximum allowed value for that). Then for each available VCPU the
bit in the mask has to be set (libxl_bitmap_set takes a bit position
as an argument, not the number of bits to set).

Without this, I would always only get one VCPU for guests created
through libvirt/libxl.

Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
11 years agoAdd a colon after 'internal error'
Ján Tomko [Wed, 24 Jul 2013 08:44:46 +0000 (10:44 +0200)]
Add a colon after 'internal error'

As we do for other errors with an extra string.

11 years agoAdd new virAuth symbols to private.syms
Ján Tomko [Wed, 24 Jul 2013 11:49:24 +0000 (13:49 +0200)]
Add new virAuth symbols to private.syms

Otherwise libvirtd fails to load the lockd plugin.

11 years agoFix virCgroupAvailable() w/o HAVE_GETMNTENT_R defined
Roman Bogorodskiy [Wed, 24 Jul 2013 12:30:33 +0000 (16:30 +0400)]
Fix virCgroupAvailable() w/o HAVE_GETMNTENT_R defined

virCgroupAvailable() implementation calls getmntent_r
without checking if HAVE_GETMNTENT_R is defined, so it fails
to build on platforms without getmntent_r support.

Make virCgroupAvailable() just return false without
HAVE_GETMNTENT_R.

11 years agoFix link_addr detection
Roman Bogorodskiy [Wed, 24 Jul 2013 13:02:00 +0000 (17:02 +0400)]
Fix link_addr detection

link_addr detection in configure always reports that
link_addr is missing because it uses link_addr(NULL, NULL) in
AC_LINK_IFELSE check with limited set of headers that doesn't
define NULL.

Fix by replacing 'NULL' with just '0'.

11 years agoUse qemuOpenFile in qemu_driver.c
Martin Kletzander [Fri, 24 May 2013 16:26:26 +0000 (18:26 +0200)]
Use qemuOpenFile in qemu_driver.c

On two places, the usage of open() is replaced with qemuOpenFile as
that is the preferred method in those cases.

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

11 years agoMake qemuOpenFile aware of per-VM DAC seclabel.
Martin Kletzander [Fri, 24 May 2013 16:26:14 +0000 (18:26 +0200)]
Make qemuOpenFile aware of per-VM DAC seclabel.

Function qemuOpenFile() haven't had any idea about seclabels applied
to VMs only, so in case the seclabel differed from the "user:group"
from configuration, there might have been issues with opening files.

Make qemuOpenFile() VM-aware, but only optionally, passing NULL
argument means skipping VM seclabel info completely.

However, all current qemuOpenFile() calls look like they should use VM
seclabel info in case there is any, so convert these calls as well.

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

11 years agoExpose ownership ID parsing
Martin Kletzander [Fri, 24 May 2013 15:35:01 +0000 (17:35 +0200)]
Expose ownership ID parsing

Parsing 'user:group' is useful even outside the DAC security driver,
so expose the most abstract function which has no DAC security driver
bits in itself.

11 years agoqemu: set/validate slot/connection type when assigning slots for PCI devices
Laine Stump [Mon, 15 Jul 2013 00:09:44 +0000 (20:09 -0400)]
qemu: set/validate slot/connection type when assigning slots for PCI devices

Since PCI bridges, PCIe bridges, PCIe switches, and PCIe root ports
all share the same namespace, they are all defined as controllers of
type='pci' in libvirt (but with a differing model attribute). Each of
these controllers has a certain connection type upstream, allows
certain connection types downstream, and each can either allow a
single downstream connection at slot 0, or connections from slot 1 -
31.

Right now, we only support the pci-root and pci-bridge devices, both
of which only allow PCI devices to connect, and both which have usable
slots 1 - 31. In preparation for adding other types of controllers
that have different capabilities, this patch 1) adds info to the
qemuDomainPCIAddressBus object to indicate the capabilities, 2) sets
those capabilities appropriately for pci-root and pci-bridge devices,
and 3) validates that the controller being connected to is the proper
type when allocating slots or validating that a user-selected slot is
appropriate for a device..

Having this infrastructure in place will make it much easier to add
support for the other PCI controller types.

While it would be possible to do all the necessary checking by just
storing the controller model in the qemyuDomainPCIAddressBus, it
greatly simplifies all the validation code to also keep a "flags",
"minSlot" and "maxSlot" for each - that way we can just check those
attributes rather than requiring a nearly identical switch statement
everywhere we need to validate compatibility.

You may notice many places where the flags are seemingly hard-coded to

  QEMU_PCI_CONNECT_HOTPLUGGABLE | QEMU_PCI_CONNECT_TYPE_PCI

This is currently the correct value for all PCI devices, and in the
future will be the default, with small bits of code added to change to
the flags for the few devices which are the exceptions to this rule.

Finally, there are a few places with "FIXME" comments. Note that these
aren't indicating places that are broken according to the currently
supported devices, they are places that will need fixing when support
for new PCI controller models is added.

To assure that there was no regression in the auto-allocation of PCI
addresses or auto-creation of integrated pci-root, ide, and usb
controllers, a new test case (pci-bridge-many-disks) has been added to
both the qemuxml2argv and qemuxml2xml tests. This new test defines a
domain with several dozen virtio disks but no pci-root or
pci-bridges. The .args file of the new test case was created using
libvirt sources from before this patch, and the test still passes
after this patch has been applied.

11 years agoqemu: make QEMU_PCI_ADDRESS_(SLOT|FUNCTION)_LAST less misleading
Laine Stump [Thu, 11 Jul 2013 04:53:16 +0000 (00:53 -0400)]
qemu: make QEMU_PCI_ADDRESS_(SLOT|FUNCTION)_LAST less misleading

Although these two enums are named ..._LAST, they really had the value
of ..._SIZE. This patch changes their values so that, e.g.,
QEMU_PCI_ADDRESS_SLOT_LAST really is the slot number of the last slot
on a PCI bus.