]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/log
people/liuw/libxenctrl-split/libvirt.git
13 years agodaemon: Add libvirtd-config.c to the list of files to translate
Jiri Denemark [Tue, 10 Apr 2012 13:42:47 +0000 (15:42 +0200)]
daemon: Add libvirtd-config.c to the list of files to translate

13 years agobuild: avoid s390 compiler warnings
Eric Blake [Tue, 10 Apr 2012 15:46:01 +0000 (09:46 -0600)]
build: avoid s390 compiler warnings

I noticed these compiler warnings when building for the s390 architecture.

* src/node_device/node_device_udev.c (udevDeviceMonitorStartup):
Mark unused variable.
* src/nodeinfo.c (linuxNodeInfoCPUPopulate): Avoid unused variable.

13 years agoWire up <loader> to set the QEMU BIOS path
Daniel P. Berrange [Tue, 10 Apr 2012 14:02:13 +0000 (15:02 +0100)]
Wire up <loader> to set the QEMU BIOS path

* src/qemu/qemu_command.c: Wire up -bios with <loader>
* tests/qemuxml2argvdata/qemuxml2argv-bios.args,
  tests/qemuxml2argvdata/qemuxml2argv-bios.xml: Expand
  existing BIOS test case to cover <loader>

13 years agovirsh: Clean up usage of boolean flag variables
Peter Krempa [Tue, 10 Apr 2012 11:14:23 +0000 (13:14 +0200)]
virsh: Clean up usage of boolean flag variables

This patch cleans up variables used to store boolean command flags that
are inquired by vshCommandOptBool to use the bool data type instead of
an integer.

Additionally this patch cleans up flag variables that are inferred from
existing flags.

13 years agovirsh: Clarify use of the --managed-save flag for the list command
Peter Krempa [Tue, 10 Apr 2012 10:21:03 +0000 (12:21 +0200)]
virsh: Clarify use of the --managed-save flag for the list command

The documentation for the flag doesn't clearly state that the flag only
enhances the output and the user needs to specify other flags to list
inactive domains, that are enhanced by this flag.

13 years agoFix comment about GNUTLS initialization/cleanup
Daniel P. Berrange [Tue, 10 Apr 2012 11:15:46 +0000 (12:15 +0100)]
Fix comment about GNUTLS initialization/cleanup

13 years agoFix compilation error on 32bit
Stefan Berger [Tue, 10 Apr 2012 10:24:03 +0000 (06:24 -0400)]
Fix compilation error on 32bit

Below code failed to compile on a 32 bit machine with error

typewrappers.c: In function 'libvirt_intUnwrap':
typewrappers.c:135:5: error: logical 'and' of mutually exclusive tests is always false [-Werror=logical-op]
cc1: all warnings being treated as errors

The patch fixes this error.

13 years agoReplace daemon-conf test script with a proper test case
Daniel P. Berrange [Wed, 4 Apr 2012 14:01:46 +0000 (15:01 +0100)]
Replace daemon-conf test script with a proper test case

The daemon-conf test script continues to be very fragile to
changes in libvirt. It currently fails 1 time in 3/4 due
to race conditions in startup/shutdown of the test script.

Replace it with a proper test case tailored to the code
being tested

* tests/Makefile.am: Remove daemon-conf, add libvirtdconftest
* tests/daemon-conf: Delete obsolete test
* tests/libvirtdconftest.c: Test config file handling

13 years agoSwitch libvirtd config loading code to use error APIs
Daniel P. Berrange [Wed, 4 Apr 2012 14:00:17 +0000 (15:00 +0100)]
Switch libvirtd config loading code to use error APIs

Using VIR_ERROR means the test suite can't catch error messages
easily. Use the proper error reporting APIs instead

13 years agoAdd API for loading daemon config from in-memory blob
Daniel P. Berrange [Wed, 4 Apr 2012 12:14:19 +0000 (13:14 +0100)]
Add API for loading daemon config from in-memory blob

Rename existing daemonConfigLoad API to daemonConfigLoadFile and
add an alternative daemonConfigLoadData

* daemon/libvirtd-config.c, daemon/libvirtd-config.h: Add
  daemonConfigLoadData and rename daemonConfigLoad to
  daemonConfigLoadFile
* daemon/libvirtd.c: Update for renamed API

13 years agoSplit libvirtd config file loading out into separate files
Daniel P. Berrange [Wed, 4 Apr 2012 12:09:09 +0000 (13:09 +0100)]
Split libvirtd config file loading out into separate files

To enable creation of unit tests, split the libvirtd config file
loading code out into separate files.

* daemon/libvirtd.c: Delete config loading code / structs
* daemon/libvirtd-config.c, daemon/libvirtd-config.h: Config
  file loading APIs

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
13 years agoUML: fix iteration over consoles
MATSUDA, Daiki [Mon, 9 Apr 2012 03:40:52 +0000 (12:40 +0900)]
UML: fix iteration over consoles

I found typo in UML driver.

MATSUDA Daiki

13 years agosnapshot: fix memory leak on error
Eric Blake [Thu, 5 Apr 2012 19:15:03 +0000 (13:15 -0600)]
snapshot: fix memory leak on error

Leak introduced in commit 0436d32.  If we allocate an actions array,
but fail early enough to never consume it with the qemu monitor
transaction call, we leaked memory.

But our semantics of making the transaction command free the caller's
memory is awkward; avoiding the memory leak requires making every
intermediate function in the call chain check for error.  It is much
easier to fix things so that the function that allocates also frees,
while the call chain leaves the caller's data intact.  To do that,
I had to hack our JSON data structure to make it easy to protect a
portion of an arbitrary JSON tree from being freed.

* src/util/json.h (virJSONType): Name the enum.
(_virJSONValue): New field.
* src/util/json.c (virJSONValueFree): Use it to protect a portion
of an array.
* src/qemu/qemu_monitor_json.c (qemuMonitorJSONTransaction): Avoid
freeing caller's data.
* src/qemu/qemu_driver.c (qemuDomainSnapshotCreateDiskActive):
Free actions array on failure.

13 years agoqemu_ga: Don't overwrite errors on FSThaw
Michal Privoznik [Fri, 6 Apr 2012 10:33:48 +0000 (12:33 +0200)]
qemu_ga: Don't overwrite errors on FSThaw

We can tell qemuDomainSnapshotFSThaw if we want it to report errors or
not. However, if we don't want to and an error has been already set by
previous qemuReportError() we must keep copy of that error not just a
pointer to it. Otherwise, it get overwritten if FSThaw reports an error.

13 years agoxen config: No vfb in HVM guest configuration
Stefan Bader [Thu, 5 Apr 2012 16:44:35 +0000 (18:44 +0200)]
xen config: No vfb in HVM guest configuration

This causes an implicit vkbd device to be added which takes
6min to finally fail being initialized in the guest.

http://lists.xen.org/archives/html/xen-devel/2012-04/msg00409.html

Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
13 years agotests: avoid compiler warnings
Eric Blake [Fri, 6 Apr 2012 02:04:23 +0000 (20:04 -0600)]
tests: avoid compiler warnings

gcc 4.7 warns about uninitialized struct members

* tests/testutilsqemu.c (testQemuCapsInit): Populate new members.
* tests/viruritest.c (mymain): Likewise.

13 years agotest: fix build errors with gcc 4.7.0 and -O0
Laine Stump [Thu, 5 Apr 2012 20:31:36 +0000 (16:31 -0400)]
test: fix build errors with gcc 4.7.0 and -O0

When building on Fedora 17 (which uses gcc 4.7.0) with -O0 in CFLAGS,
three of the tests failed to compile.

cputest.c and qemuxml2argvtest.c had non-static structs defined
inside the macro that was being repeatedly invoked. Due to some so-far
unidentified change in gcc, the stack space used by variables defined
inside { } is not recovered/re-used when the block ends, so all these
structs have become additive (this is the same problem worked around
in commit cf57d345b). Fortunately, these two files could be fixed with
a single line addition of "static" to the struct definition in the
macro.

virnettlscontexttest.c was a bit different, though. The problem structs
in the do/while loop of macros had non-constant initializers, so it
took a bit more work and piecemeal initialization instead of member
initialization to get things to be happy.

In an ideal world, none of these changes should be necessary, but not
knowing how long it will be until the gcc regressions are fixed, and
since the code is just as correct after this patch as before, it makes
sense to fix libvirt's build for -O0 while also reporting the gcc
problem.

13 years agovirURIParse: don't forget to copy the user part
Guido Günther [Thu, 5 Apr 2012 15:52:42 +0000 (17:52 +0200)]
virURIParse: don't forget to copy the user part

This got dropped with 300e60e15b22387dda41ed5985a9ebadfd86dd25

Cheers,
 -- Guido

13 years agotest: fix segfault in networkxml2argvtest
Laine Stump [Thu, 5 Apr 2012 07:18:33 +0000 (03:18 -0400)]
test: fix segfault in networkxml2argvtest

This bug resolves https://bugzilla.redhat.com/show_bug.cgi?id=810100

rpm builds for i686 were failing with a segfault in
networkxml2argvtest. Running under valgrind showed that a region of
memory was being referenced after it had been freed (as the result of
realloc - see the valgrind report in the BZ).

The problem (in replaceTokens() - added in commit 22ec60, meaning this
bug was in 0.9.10 and 0.9.11) was that the pointers token_start and
token_end were being computed based on the value of *buf, then *buf
was being realloc'ed (potentially moving it), then token_start and
token_end were used without recomputing them to account for movement
of *buf.

The solution is to change the code so that token_start and token_end
are offsets into *buf rather than pointers. This way there is only a
single pointer to the buffer, and nothing needs readjusting after a
realloc. (You may note that some uses of token_start/token_end didn't
need to be changed to add in "*buf +" - that's because there ended up
being a +*buf and -*buf which canceled each other out).

DV gets the credit for finding this bug and pointing out the valgrind
report.

13 years agoconf: Plug memory leaks on virDomainDiskDefParseXML
Alex Jia [Thu, 5 Apr 2012 09:12:12 +0000 (17:12 +0800)]
conf: Plug memory leaks on virDomainDiskDefParseXML

Detected by valgrind. Leaks are introduced in commit b22eaa7.

* src/conf/domain_conf.c (virDomainDiskDefParseXML): fix memory leaks.

How to reproduce?

% make && make -C tests check TESTS=qemuxml2argvtest
% cd tests && valgrind -v --leak-check=full ./qemuxml2argvtest

actual result:

==2143== 12 bytes in 2 blocks are definitely lost in loss record 74 of 179
==2143==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==2143==    by 0x39D90A67DD: xmlStrndup (xmlstring.c:45)
==2143==    by 0x4F5EC0: virDomainDiskDefParseXML (domain_conf.c:3438)
==2143==    by 0x502F00: virDomainDefParseXML (domain_conf.c:8304)
==2143==    by 0x505FE3: virDomainDefParseNode (domain_conf.c:9080)
==2143==    by 0x5069AE: virDomainDefParse (domain_conf.c:9030)
==2143==    by 0x41CBF4: testCompareXMLToArgvHelper (qemuxml2argvtest.c:105)
==2143==    by 0x41E5DD: virtTestRun (testutils.c:145)
==2143==    by 0x416FA3: mymain (qemuxml2argvtest.c:399)
==2143==    by 0x41DCB7: virtTestMain (testutils.c:700)
==2143==    by 0x39CF01ECDC: (below main) (libc-start.c:226)

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agoopenvz: support vzctl 3.1
Ilja Livenson [Wed, 4 Apr 2012 20:30:43 +0000 (14:30 -0600)]
openvz: support vzctl 3.1

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

Basically, openvz dropped strict version numbering (3.1 vs 3.1.0),
which caused parsing to fail.

13 years agoDon't install sysctl file on non-Linux hosts
Daniel P. Berrange [Wed, 4 Apr 2012 10:16:34 +0000 (11:16 +0100)]
Don't install sysctl file on non-Linux hosts

* configure.ac: Set WITH_SYSCTL only on Linux hosts
* daemon/Makefile.am: Conditionalize install-sysctl using WITH_SYSCTL

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Cc: Jason Helfman <jhelfman@e-e.com>
13 years agoFix parallel build in docs/ directory
Daniel P. Berrange [Wed, 4 Apr 2012 11:26:04 +0000 (12:26 +0100)]
Fix parallel build in docs/ directory

Every now & then, with parallel builds, we get a failure to
validate hvsupport.html.in.  I eventually noticed that this
is because we get 2 instances of the generator running at
once.

We already list hvsupport.html.in in BUILT_SOURCES but this
was not working. It turns out the flaw is that we were
adding deps to the 'all:' target instead of the 'all-am:'
target. BUILT_SOURCES is a dep of 'all', so any custom
targets written in Makefile.am must use 'all-am:' so that
they don't get run until BUILT_SOURCES are completely
generated

* docs/Makefile.am: s/all/all-am/

13 years agoPull in GNULIB regex module for benefit of test suite on Win32
Daniel P. Berrange [Wed, 4 Apr 2012 10:56:04 +0000 (11:56 +0100)]
Pull in GNULIB regex module for benefit of test suite on Win32

13 years agoAdd linuxNodeInfoCPUPopulate to src/libvirt_linux.syms
Daniel P. Berrange [Wed, 4 Apr 2012 10:54:27 +0000 (11:54 +0100)]
Add linuxNodeInfoCPUPopulate to src/libvirt_linux.syms

This symbol is used in the test suites

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
13 years agoFix format specifiers in test cases on Win32
Daniel P. Berrange [Thu, 29 Mar 2012 09:41:37 +0000 (10:41 +0100)]
Fix format specifiers in test cases on Win32

Some of the test suites use fprintf with format specifiers
that are not supported on Win32 and are not fixed by gnulib.

The mingw32 compiler also has trouble detecting ssize_t
correctly, complaining that 'ssize_t' does not match
'signed size_t' (which it expects for %zd). Force the
cast to size_t to avoid this problem

* tests/testutils.c, tests/testutils.h: Fix printf
  annotation on virTestResult. Use virVasprintf
  instead of vfprintf
* tests/virhashtest.c: Use VIR_WARN instead of fprintf(stderr).
  Cast to size_t to avoid mingw32 compiler bug

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
13 years agoqemu: Build activeUsbHostdevs list on process reconnect
Michal Privoznik [Mon, 26 Mar 2012 14:44:19 +0000 (16:44 +0200)]
qemu: Build activeUsbHostdevs list on process reconnect

If the daemon is restarted it will lose list of active
USB devices assigned to active domains. Therefore we need
to rebuild this list on qemuProcessReconnect().

13 years agoqemu: Delete USB devices used by domain on stop
Michal Privoznik [Mon, 26 Mar 2012 14:40:01 +0000 (16:40 +0200)]
qemu: Delete USB devices used by domain on stop

To prevent assigning one USB device to two domains,
we keep a list of assigned USB devices. On domain
startup - qemuProcessStart() - we insert devices
used by domain into the list but remove them only
on detach-device. Devices are, however, released
on qemuProcessStop() as well.

13 years agoqemu: Don't leak temporary list of USB devices
Michal Privoznik [Mon, 26 Mar 2012 14:33:58 +0000 (16:33 +0200)]
qemu: Don't leak temporary list of USB devices

and add debug message when adding USB device
to the list of active devices.

13 years agoFix initial hypervisor conditionals
Daniel P. Berrange [Tue, 3 Apr 2012 11:05:32 +0000 (12:05 +0100)]
Fix initial hypervisor conditionals

The openvz, virtualbox and vmware drivers do not run inside
libvirtd, therefore they should be grouped with the other
client side drivers

13 years agoRemove bogus xen-devel dep from libvirt-devel RPM
Daniel P. Berrange [Tue, 3 Apr 2012 11:02:49 +0000 (12:02 +0100)]
Remove bogus xen-devel dep from libvirt-devel RPM

The public libvirt API does not have any application visible
dependency on Xen libraries. The xen-devel dependency is thus
bogus

13 years agoIntroduce per-hypervisor virtual RPMs
Daniel P. Berrange [Tue, 3 Apr 2012 10:54:27 +0000 (11:54 +0100)]
Introduce per-hypervisor virtual RPMs

Introduce a set sub-RPMs, one per hypervisor, which can be used
as dependency targets by applications wishing to pull in the
full stack of packages required for a specific hypervisor. This
avoids the application needing to know what the hypervisor specific
package set is.

ie, applications should not need to know that using the libvirt
Xen hypervisor requires the 'xen' RPM - libvirt should take care
of that knowledge. All the application wants is 'libvirt-daemon-xen'

There are 5 sub-RPMs:

  libvirt-daemon-qemu - non-native TCG based emulators
  libvirt-daemon-kvm  - native KVM hypervisor
  libvirt-daemon-uml  - User Mode linux
  libvirt-daemon-xen  - Xen, either via XenD or libxl
  libvirt-daemon-lxc  - Linux native containers

When driver modules get turned on, these sub-RPMs will also
gain dependencies on the appropriate driver module .so files

13 years agoSplit config files & daemon off from main daemon RPM
Daniel P. Berrange [Tue, 3 Apr 2012 10:44:59 +0000 (11:44 +0100)]
Split config files & daemon off from main daemon RPM

Take the libvirt RPM and split it into three pieces

 - libvirt-daemon - libvirtd & other mandatory bits for its operation
 - libvirt-daemon-config-network - the virbr0 config definition
 - libvirt-daemon-config-nwfilter - the firewall config rules

For backwards compatibility with existing installs / application RPM
deps, the 'libvirt' RPM is retained, but will have a dependency on
the 3 new RPMs.

13 years agoRemove API XML files from libvirt RPM
Daniel P. Berrange [Tue, 3 Apr 2012 10:24:42 +0000 (11:24 +0100)]
Remove API XML files from libvirt RPM

The API XML files are now formally installed as part of the
libvirt-devel RPM. Thus there is no need to include them as
%doc in the main libvirt RPM

13 years agoMove all documentation into a -docs sub-RPM
Daniel P. Berrange [Tue, 3 Apr 2012 09:52:12 +0000 (10:52 +0100)]
Move all documentation into a -docs sub-RPM

Currently documentation is split between the libvirt RPM and the
libvirt-devel RPM. In the client-only build there is no libvirt
RPM, so the docs need to live elsewhere. The obvious answer is a
dedicated libvirt-docs RPM. For back-compatibility make the
libvirt-devel RPM require the libvirt-docs RPM

* libvirt.spec.in: Create separate libvirt-docs RPM

13 years agodocs: fix typo in previous patch
Eric Blake [Tue, 3 Apr 2012 15:40:04 +0000 (09:40 -0600)]
docs: fix typo in previous patch

* docs/news.html.in: Fix accidental deletion.

13 years agonews.html.in: Fix </br> void tag
Michal Privoznik [Tue, 3 Apr 2012 15:19:56 +0000 (17:19 +0200)]
news.html.in: Fix </br> void tag

Void elements should be written with slash *after* the tag name,
not before, so they are not confused with ending tags.

13 years agovirsh: Clarify escape sequence
Michal Privoznik [Tue, 3 Apr 2012 12:59:06 +0000 (14:59 +0200)]
virsh: Clarify escape sequence

Currently, we put no strains on escape sequence possibly leaving users
with console that cannot be terminated. However, not all ASCII
characters can be used as escape sequence. Only those falling in
@ - _ can be; implement and document this constraint.

13 years agoRelease of libvirt 0.9.11
Daniel Veillard [Tue, 3 Apr 2012 07:06:37 +0000 (15:06 +0800)]
Release of libvirt 0.9.11

* configure.ac docs/news.html.in libvirt.spec.in: update for the release
* po/*.po*: updated a number of languages translation including new
  indian languages and regenerated

13 years agoRevert "Refactor the libvirt RPM daemon pieces"
Daniel Veillard [Tue, 3 Apr 2012 06:26:41 +0000 (14:26 +0800)]
Revert "Refactor the libvirt RPM daemon pieces"

This reverts commit 06a0d57f5a90e408a6280dc2f9db0badeeeb78ee.

13 years agoqemu: Start nested job in qemuDomainCheckEjectableMedia
Jiri Denemark [Mon, 2 Apr 2012 13:55:08 +0000 (15:55 +0200)]
qemu: Start nested job in qemuDomainCheckEjectableMedia

Originally, qemuDomainCheckEjectableMedia was entering monitor with qemu
driver lock. Commit 2067e31bf97667eab9f111b496f5e9a44e827c5b, which I
made to fix that, revealed another issue we had (but didn't notice it
since the driver was locked): we didn't set nested job when
qemuDomainCheckEjectableMedia is called during migration. Thus the
original fix I made was wrong.

13 years agoXen: Fix <clock> handling
Philipp Hahn [Wed, 8 Feb 2012 16:32:34 +0000 (17:32 +0100)]
Xen: Fix <clock> handling

XenD-3.1 introduced managed domains. HV-domains have rtc_timeoffset
(hgd24f37b31030 from 2007-04-03), which tracks the offset between the
hypervisors clock and the domains RTC, and is persisted by XenD.
In combination with localtime=1 this had a bug until XenD-3.4
(hg5d701be7c37b from 2009-04-01) (I'm not 100% sure how that bug
manifests, but at least for me in TZ=Europe/Berlin I see the previous
offset relative to utc being applied to localtime again, which manifests
in an extra hour being added)

XenD implements the following variants for clock/@offset:
- PV domains don't have a RTC → 'localtime' | 'utc'
- <3.1: no managed domains → 'localtime' | 'utc'
- ≥3.1: the offset is tracked for HV → 'variable'
        due to the localtime=1 bug → 'localtime' | 'utc'
- ≥3.4: the offset is tracked for HV → 'variable'

Current libvirtd still thinks XenD only implements <clock offset='utc'/>
and <clock offset='localtime'/>, which is wrong, since the semantic of
'utc' and 'localtime' specifies, that the offset will be reset on
domain-restart, while with 'variable' the offset is kept. (keeping the
offset over "virsh edit" is important, since otherwise the clock might
jump, which confuses certain guest OSs)

xendConfigVersion was last incremented to 4 by the xen-folks for
xen-3.1.0. I know of no way to reliably detect the version of XenD
(user space tools), which may be different from the version of the
hypervisor (kernel) version! Because of this only the change from
'utc'/'localtime' to 'variable' in XenD-3.1 is handled, not the buggy
behaviour of XenD-3.1 until XenD-3.4.

For backward compatibility with previous versions of libvirt Xen-HV
still accepts 'utc' and 'localtime', but they are returned as 'variable'
on the next read-back from Xend to libvirt, since this is what XenD
implements: The RTC is NOT reset back to the specified time on next
restart, but the previous offset is kept.
This behaviour can be turned off by adding the additional attribute
adjustment='reset', in which case libvirt will report an error instead
of doing the conversion. The attribute can also be used as a shortcut to
offset='variable' with basis='...'.

With these changes, it is also necessary to adjust the xen tests:

"localtime = 0" is always inserted, because otherwise on updates the
value is not changed within XenD.

adjustment='reset' is inserted for all cases, since they're all <
XEND_CONFIG_VERSION_3_1_0, only 3.1 introduced persistent
rtc_timeoffset.

Some statements change their order because code was moved around.

Signed-off-by: Philipp Hahn <hahn@univention.de>
13 years agoSupport clock=variable relative to localtime
Philipp Hahn [Mon, 6 Feb 2012 13:59:16 +0000 (14:59 +0100)]
Support clock=variable relative to localtime

Since Xen 3.1 the clock=variable semantic is supported. In addition to
qemu/kvm Xen also knows about a variant where the offset is relative to
'localtime' instead of 'utc'.

Extends the libvirt structure with a flag 'basis' to specify, if the
offset is relative to 'localtime' or 'utc'.

Extends the libvirt structure with a flag 'reset' to force the reset
behaviour of 'localtime' and 'utc'; this is needed for backward
compatibility with previous versions of libvirt, since they report
incorrect XML.

Adapt the only user 'qemu' to the new name.
Extend the RelaxNG schema accordingly.
Document the new 'basis' attribute in the HTML documentation.
Adapt test for the new attribute.

Signed-off-by: Philipp Hahn <hahn@univention.de>
13 years agoFix typos and spacing in messages.
Yuri Chornoivan [Sun, 1 Apr 2012 09:23:56 +0000 (12:23 +0300)]
Fix typos and spacing in messages.

13 years agoqemu: fix memory leak in virDomainGetVcpus
Laine Stump [Mon, 2 Apr 2012 04:26:44 +0000 (00:26 -0400)]
qemu: fix memory leak in virDomainGetVcpus

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

The leak is really in virProcessInfoGetAffinity, as shown in the
valgrind output given in the above bug report - it calls CPU_ALLOC(),
but then fails to call CPU_FREE().

This leak has existed in every version of libvirt since 0.7.5.

13 years agoconf: allow fuzz in XML with cur balloon > max
Eric Blake [Fri, 30 Mar 2012 20:45:48 +0000 (14:45 -0600)]
conf: allow fuzz in XML with cur balloon > max

Commit 1b1402b introduced a regression.  Since older libvirt versions
would silently round memory up (until the previous patch), but populated
current memory based on querying the guest, it was possible to have
dumpxml show cur > max by the amount of the rounding.  For example, if
a user requested 1048570 KiB memory (just shy of 1GiB), the qemu
driver would actually run with 1048576 KiB, and libvirt 0.9.10 would
output a current that was 6KiB larger than the maximum.  Situations
where this could have an impact include, but are not limited to,
migration from old to new libvirt, managedsave in old libvirt and
start in new libvirt, snapshot creation in old libvirt and revert in
new libvirt - without this patch, the new libvirt would reject the
VM because of the rounding discrepancy.

Fix things by adding a fuzz factor, and silently clamp current down to
maximum in that case, rather than failing to reparse XML for an existing
VM.  From a practical standpoint, this has no user impact: 'virsh
dumpxml' will continue to query the running guest rather than rely on
the incoming xml, which will see the currect current value, and even if
clamping down occurs during parsing, it will be by at most the fuzz
factor of a megabyte alignment, and rounded back up when passed back to
the hypervisor.

Meanwhile, we continue to reject cur > max if the difference is beyond
the fuzz factor of nearest megabyte.  But this is not a real change in
behavior, since with 0.9.10, even though the parser allowed it, later
in the processing stream we would reject it at the qemu layer; so
rejecting it in the parser just moves error detection to a nicer place.

* src/conf/domain_conf.c (virDomainDefParseXML): Don't reject
existing XML.
Based on a report by Zhou Peng.

13 years agoqemu: reflect any memory rounding back to xml
Eric Blake [Fri, 30 Mar 2012 15:40:09 +0000 (09:40 -0600)]
qemu: reflect any memory rounding back to xml

If we round up a user's memory request, we should update the XML
to reflect the actual value in use by the VM, rather than giving
an artificially small value back to the user.

* src/qemu/qemu_command.c (qemuBuildNumaArgStr)
(qemuBuildCommandLine): Reflect rounding back to XML.

13 years agopython: improve conversion validation
Eric Blake [Fri, 30 Mar 2012 18:03:20 +0000 (12:03 -0600)]
python: improve conversion validation

Laszlo Ersek pointed out that in trying to convert a long to an
unsigned int, we used:

long long_val = ...;
if ((unsigned int)long_val == long_val)

According to C99 integer promotion rules, the if statement is
equivalent to:

(unsigned long)(unsigned int)long_val == (unsigned long)long_val

since you get an unsigned comparison if at least one side is
unsigned, using the largest rank of the two sides; but on 32-bit
platforms, where unsigned long and unsigned int are the same size,
this comparison is always true and ends up converting negative
long_val into posigive unsigned int values, rather than rejecting
the negative value as we had originally intended (python longs
are unbounded size, and we don't want to do silent modulo
arithmetic when converting to C code).

Fix this by using direct comparisons, rather than casting.

* python/typewrappers.c (libvirt_intUnwrap, libvirt_uintUnwrap)
(libvirt_ulongUnwrap, libvirt_ulonglongUnwrap): Fix conversion
checks.

13 years agoFix client only RPM build & other misc RPM problems
Daniel P. Berrange [Sat, 31 Mar 2012 11:55:41 +0000 (12:55 +0100)]
Fix client only RPM build & other misc RPM problems

* libvirt.spec.in: Remove obsolete --with-remote-pid-file arg.
  Add missing %{without_libxl} statement. Fix handling of docs
  in client only build. Put systemtap files in -client RPM
  instead of -daemon RPM
* examples/xml/nwfilter/Makefile.am: Don't install examples if
  nwfilter is disabled.

13 years agoRefactor the libvirt RPM daemon pieces
Daniel P. Berrange [Fri, 30 Mar 2012 13:14:00 +0000 (14:14 +0100)]
Refactor the libvirt RPM daemon pieces

There are a number of flaws with our packaging of the libvirtd
daemon:

 - Installing 'libvirt' does not install 'qemu-kvm' or 'xen'
   etc which are required to actually run the hypervisor in
   question
 - Installing 'libvirt' pulls in the default configuration
   files which may not be wanted & cause problems if installed
   inside a guest
 - It is not possible to explicitly required all the peices
   required to manage a specific hypervisor

This change takes the 'libvirt' RPM and and changes it thus

 - libvirt: just a virtual package with dep on libvirt-daemon,
   libvirt-daemon-config-network & libvirt-daemon-config-nwfilter
 - libvirt-daemon: the libvirt daemon and related pieces
 - libvirt-daemon-config-network: the default network config
 - libvirt-daemon-config-nwfilter: the network filter configs
 - libvirt-docs: the website HTML

We then introduce some more virtual (empty) packages

 - libvirt-daemon-qemu: Deps on libvirt-daemon & 'qemu'
 - libvirt-daemon-kvm: Deps on libvirt-daemon & 'qemu-kvm'
 - libvirt-daemon-lxc: Deps on libvirt-daemon
 - libvirt-daemon-uml: Deps on libvirt-daemon
 - libvirt-daemon-xen: Deps on libvirt-daemon & 'xen'

 - libvirt-qemu: Deps on libvirt-daemon-qemu & libvirt-daemon-config-{network,nwfilter}
 - libvirt-kvm: Deps on libvirt-daemon-kvm & libvirt-daemon-config-{network,nwfilter}
 - libvirt-lxc: Deps on libvirt-daemon-lxc & libvirt-daemon-config-{network,nwfilter}
 - libvirt-uml: Deps on libvirt-daemon-uml & libvirt-daemon-config-{network,nwfilter}
 - libvirt-xen: Deps on libvirt-daemon-xen & libvirt-daemon-config-network

My intent in the future is to turn on the driver modules by
default, at which time 'libvirt-daemon' will cease to include
any specific drivers, instead we'll get libvirt-daemon-driver-XXXX
packages for each driver. The libvirt-daemon-XXX packages will
then pull in each driver that they require.

It is recommended that applications required a locally installed
libvirtd daemon, use either 'Requires: libvirt-daemon-XXXX' or
'Requires: libvirt-XXX' and *not* "Requires: libvirt-daemon"
or 'Requires: libvirt'

* libvirt.spec.in: Refactor RPMs
* docs/packaging.html.in, docs/sitemap.html.in: Document
  new RPM split rationale

13 years agoqemu: support live change of the bridge used by a guest network device
Hendrik Schwartke [Wed, 28 Mar 2012 19:11:09 +0000 (15:11 -0400)]
qemu: support live change of the bridge used by a guest network device

This patch was created to resolve this upstream bug:

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

and is at least a partial solution to this RHEL RFE:

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

Previously the only attribute of a network device that could be
modified by virUpdateDeviceFlags() ("virsh update-device") was the
link state; attempts to change any other attribute would log an error
and fail.

This patch adds recognition of a change in bridge device name, and
supports reconnecting the guest's interface to the new device.
Standard audit logs for detaching and attaching a network device are
also generated. Although the current auditing function doesn't log the
bridge being attached to, this will later be changed in a separate
patch.

13 years agobuild: fix build on cygwin
Eric Blake [Fri, 30 Mar 2012 22:50:52 +0000 (16:50 -0600)]
build: fix build on cygwin

Regression introduced when we changed types in commit 3e2c3d8f6.

We've done this sort of cleanup before (see commit c685993d7).

* src/conf/storage_conf.c (virStoragePoolDefFormat)
(virStorageVolTargetDefFormat): Cast gid_t and uid_t.

13 years agobuild: fix mingw ssize_t, syntax check
Eric Blake [Fri, 30 Mar 2012 16:28:03 +0000 (10:28 -0600)]
build: fix mingw ssize_t, syntax check

We are so close to a release that we don't want to pull in a
gnulib submodule update and risk regressions, since there has
been a lot of other gnulib churn upstream.  However, there are
a couple of gnulib issues that are worth fixing in isolation,
by applying local patches to gnulib.

There was an upstream gnulib bug in maint.mk that rendered most
of our syntax checks ineffective (and fixing it flushed out a
minor bug in our code):
https://lists.gnu.org/archive/html/bug-gnulib/2012-03/msg00194.html

There is still an upstream bug where gnulib uses the wrong type
for ssize_t on mingw; we need the fix now even though it has not
yet been accepted into gnulib:
https://lists.gnu.org/archive/html/bug-gnulib/2012-03/msg00188.html

* gnulib/local/top/maint.mk.diff: Pick up upstream gnulib
maint.mk.
* gnulib/local/m4/ssize_t.m4.diff: Work around gnulib bug.
* src/libvirt.c: Remove unused header.
* cfg.mk
(exclude_file_name_regexp--sc_prohibit_empty_lines_at_EOF): Exempt
gnulib local files.

13 years agoqemu: eliminate nested switch, simplify code
Laine Stump [Wed, 28 Mar 2012 17:06:37 +0000 (13:06 -0400)]
qemu: eliminate nested switch, simplify code

qemuBuildHostNetStr had a switch-within-a-switch where both were
looking at the same variable. This was apparently to take advantage of
code common to three different cases (while also taking care of some
code that was different). However, there were only 2 lines common to
all, one of those can be eliminated by merging it into the
virAsprintfs that are in each case. On top of that, all the extra
empty cases cause Coverity complaints (because they are unreachable),
but absence of the empty cases causes a compile error due to
"enumeration value not handled in switch".

The solution is to just make each toplevel case independent, folding
in the common code to each.

13 years agoRevert "Set default name for SPICE agent channel"
Laine Stump [Fri, 30 Mar 2012 14:52:46 +0000 (10:52 -0400)]
Revert "Set default name for SPICE agent channel"

This patch reverts commit b0e2bb3. Its functionality has been replaced
by commit 3269ee6.

13 years agoqemu: set default name for SPICE agent channel when generating command
Laine Stump [Fri, 30 Mar 2012 07:16:23 +0000 (03:16 -0400)]
qemu: set default name for SPICE agent channel when generating command

commit b0e2bb33 set a default value for the SPICE agent channel by
inserting it during parsing of the channel XML. That method of setting
a default is problematic because it makes a format/parse roundtrip
unclean, and experience with setting other values as a side effect of
parsing has led to headaches (e.g. automatically setting a MAC address
in the parser when one isn't specified in the input XML).

This patch does not revert commit b0e2bb33 (it will be reverted in a
separate patch) but adds the alternate implementation of simply
inserting the default value in the appropriate place on the qemu
commandline when no value is provided.

13 years agoqemu_agent: Issue guest-sync prior to every command
Michal Privoznik [Wed, 1 Feb 2012 14:44:53 +0000 (15:44 +0100)]
qemu_agent: Issue guest-sync prior to every command

If we issue guest command and GA is not running, the issuing thread
will block endlessly. We can check for GA presence by issuing
guest-sync with unique ID (timestamp). We don't want to issue real
command as even if GA is not running, once it is started, it process
all commands written to GA socket.

13 years agovirnetdevtap: Don't check for flags in virNetDevTapCreateFlags
Michal Privoznik [Fri, 30 Mar 2012 11:37:13 +0000 (13:37 +0200)]
virnetdevtap: Don't check for flags in virNetDevTapCreateFlags

With latest gnulib we are checking even the lowest level functions
whether they check flags. Moreover, we are shadowing the real error
on system without TUNSETIFF support.

13 years agoFix typo in previous patch
Daniel P. Berrange [Fri, 30 Mar 2012 11:44:28 +0000 (12:44 +0100)]
Fix typo in previous patch

* src/remote/remote_driver.c: s/sizeof(ret)2/sizeof(ret2)/

13 years agoConsistent style for usage of sizeof operator
Daniel P. Berrange [Thu, 29 Mar 2012 09:52:04 +0000 (10:52 +0100)]
Consistent style for usage of sizeof operator

The code is splattered with a mix of

  sizeof foo
  sizeof (foo)
  sizeof(foo)

Standardize on sizeof(foo) and add a syntax check rule to
enforce it

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
13 years agoDisable build of commandhelper & ssh on Win32
Daniel P. Berrange [Thu, 29 Mar 2012 09:50:00 +0000 (10:50 +0100)]
Disable build of commandhelper & ssh on Win32

The commandhelper.c & ssh.c programs rely on various APIs not present
on Win32. Disable them, since the tests that uses these helpers are
already disabled

* tests/commandhelper.c, tests/ssh.c: Disable on WIN32

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
13 years agoDon't redefine the CPU comparison constants in CPU test
Daniel P. Berrange [Thu, 29 Mar 2012 09:47:07 +0000 (10:47 +0100)]
Don't redefine the CPU comparison constants in CPU test

Defining an enum with names like "ERROR" causes  a world of
hurt on Win32 whose headers have such symbol names already

* tests/cputest.c: Remove redefinition of CPU constants

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
13 years agoFix some format specifiers for size_t vs ssize_t
Daniel P. Berrange [Thu, 29 Mar 2012 09:01:07 +0000 (10:01 +0100)]
Fix some format specifiers for size_t vs ssize_t

A handful of places used %zd for format specifiers even
though the args was size_t, not ssize_t.

* src/remote/remote_driver.c, src/util/xml.c: s/%zd/%zu/

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
13 years agoconf: Prevent crash of libvirtd without channel target name
Alex Jia [Fri, 30 Mar 2012 09:10:31 +0000 (17:10 +0800)]
conf: Prevent crash of libvirtd without channel target name

* src/conf/domain_conf.c (virDomainChannelDefCheckABIStability): avoid
  crashing libvirtd due to derefing a NULL pointer.

For details, please see bug:
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=808371

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agofix a deadlock when qemu cannot start
Wen Congyang [Fri, 30 Mar 2012 06:21:49 +0000 (14:21 +0800)]
fix a deadlock when qemu cannot start

When qemu cannot start, we may call qemuProcessStop() twice.
We have check whether the vm is running at the beginning of
qemuProcessStop() to avoid libvirt deadlock. We call
qemuProcessStop() with driver and vm locked. It seems that
we can avoid libvirt deadlock. But unfortunately we may
unlock driver and vm in the function qemuProcessKill() while
vm->def->id is not -1. So qemuProcessStop() will be run twice,
and monitor will be freed unexpectedly. So we should set
vm->def->id to -1 at the beginning of qemuProcessStop().

13 years agobuild: silence recent syntax check violations
Eric Blake [Fri, 30 Mar 2012 03:17:30 +0000 (21:17 -0600)]
build: silence recent syntax check violations

An upstream gnulib bug[1] meant that some of our syntax checks
weren't being run.  Fix up our offenders before we upgrade to
a newer gnulib.

[1] https://lists.gnu.org/archive/html/bug-gnulib/2012-03/msg00194.html

* src/util/virnetdevtap.c (virNetDevTapCreate): Use flags.
* tests/lxcxml2xmltest.c (mymain): Strip useless ().

13 years agobuild: avoid 'devname' for BSD
Eric Blake [Thu, 29 Mar 2012 23:08:27 +0000 (17:08 -0600)]
build: avoid 'devname' for BSD

Commit 21b5daa1 was the last time we cleaned this up.

* tools/virt-host-validate-common.c (virHostValidateDevice):
Rename local variable.

13 years agoprivate.syms: Add virNetDevMacVLanRestartWithVPortProfile
Zhou Peng [Thu, 29 Mar 2012 12:55:04 +0000 (20:55 +0800)]
private.syms: Add virNetDevMacVLanRestartWithVPortProfile

virNetDevMacVLanRestartWithVPortProfile is omitted in src/libvirt_private.syms,
which causes link err.

13 years agoqemu: Make migration fail when port profile association fails on the dst host
Christian Benvenuti [Tue, 27 Mar 2012 20:00:01 +0000 (13:00 -0700)]
qemu: Make migration fail when port profile association fails on the dst host

In the current V3 migration protocol, Libvirt does not
check the result of the function

  qemuMigrationVPAssociatePortProfiles

This means that it is possible for a migration to complete
successfully even when the VM loses network connectivity on
the destination host.

With this change libvirt aborts the migration
(during the "finish" step) when the above function fails, that
is to say when at least one of the port profile associations fails.

Signed-off by: Christian Benvenuti <benve@cisco.com>

13 years agoSet default name for SPICE agent channel
Christophe Fergeau [Fri, 23 Mar 2012 10:04:13 +0000 (11:04 +0100)]
Set default name for SPICE agent channel

libvirt documentation for channels with type 'spicevmc' says that the
'target' child node has:
"an optional attribute name controls how the guest will have access
 to the channel, and defaults to name='com.redhat.spice.0'."

However, this default value is never set in libvirt code base,
there's only a check in qemu_command.c to error out if the name
attribute doesn't have the expected value (if it's set).

This commit sets a default target name for spicevmc channels during
the domain configuration parsing so that the code agrees with the
documentation.

13 years agovirsh: plug memory leaks on failure path
Alex Jia [Wed, 28 Mar 2012 08:15:49 +0000 (16:15 +0800)]
virsh: plug memory leaks on failure path

Leaks are introduced in commit 1cf0e3d and fe383bb.

Fixing memory leaks, in addition, the patch also fixes a potential missing
return value issue in 'if (from)' statement, without the fixing, although
the programming met a error, the subsequent codes will be executed
continually.

* tools/virsh.c (cmdSnapshotList): fix memory leaks and missing return value.

* How to reproduce?

% virsh snapshot-list <domain> --parent --roots
% virsh snapshot-list <domain> --parent --tree
% virsh snapshot-list <domain> --roots --tree

actual result:
error: --parent and --roots are mutually exclusive
error: Failed to disconnect from the hypervisor, 1 leaked reference(s)

error: --parent and --tree are mutually exclusive
error: Failed to disconnect from the hypervisor, 1 leaked reference(s)

error: --roots and --tree are mutually exclusive
error: Failed to disconnect from the hypervisor, 1 leaked reference(s)

% virsh snapshot-create-as <domain> --name "hello"
% virsh snapshot-create-as <domain> --name "libvirt"
% virsh snapshot-list <domain> --roots --from "hello"

actual result:
error: --roots and --from are mutually exclusive
 Name                 Creation Time             State
------------------------------------------------------------
 libvirt              2012-03-28 13:46:51 +0800 running

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agopython: make python APIs use these helper functions
Guannan Ren [Tue, 27 Mar 2012 06:06:47 +0000 (14:06 +0800)]
python: make python APIs use these helper functions

    *setPyVirTypedParameter
    *libvirt_virDomainGetCPUStats

13 years agopython: Add new helper functions for python to C integral conversion
Guannan Ren [Tue, 27 Mar 2012 06:06:10 +0000 (14:06 +0800)]
python: Add new helper functions for python to C integral conversion

    int libvirt_intUnwrap(PyObject *obj, int *val);
    int libvirt_uintUnwrap(PyObject *obj, unsigned int *val);
    int libvirt_longUnwrap(PyObject *obj, long *val);
    int libvirt_ulongUnwrap(PyObject *obj, unsigned long *val);
    int libvirt_longlongUnwrap(PyObject *obj, long long *val);
    int libvirt_ulonglongUnwrap(PyObject *obj, unsigned long long *val);
    int libvirt_doubleUnwrap(PyObject *obj, double *val);
    int libvirt_boolUnwrap(PyObject *obj, bool *val);

13 years agosnapshot: fix virsh docs
Eric Blake [Wed, 28 Mar 2012 02:22:49 +0000 (20:22 -0600)]
snapshot: fix virsh docs

Commit d42a2ff forgot to touch up virsh documentation, and commit
4e9953a mis-spelled the option name.

* tools/virsh.pod (snapshot-create, snapshot-create-as): Fix typo
and match recent change in flag meaning.

13 years agoEnable all warnings permanently & default to -Werror for GIT builds
Daniel P. Berrange [Tue, 27 Mar 2012 15:47:11 +0000 (16:47 +0100)]
Enable all warnings permanently & default to -Werror for GIT builds

Given that we auto-detect whether each -Wxxxx flag is supported by
GCC, and we are warning-free and use automake silent rules, there
is no compelling reason to allow compile warnings to be disabled.

Replace the --enable-compile-warnings flag with a simpler
--enable-werror flag, which defaults to 'yes' if building
from GIT, or 'no' if building from tar.gz

This helps ensure that everyone writing patches for libvirt will
take care to fix their warning problems before submitting for
review

* autobuild.sh: Force -Werror
* configure.ac: Update for LIBVIRT_COMPILE_WARNINGS macro change
* m4/virt-compile-warnings.m4: Permanently enable all warnings,
  auto-enable Werror for GIT builds

13 years agoEnable build of test suite programs by default for GIT checkouts
Daniel P. Berrange [Tue, 27 Mar 2012 15:35:01 +0000 (16:35 +0100)]
Enable build of test suite programs by default for GIT checkouts

Add a new flag '--with-test-suite' to configure to control whether
the test suite binaries are built by default. ie built with a
plain 'make', as opposed to delayed until 'make check'

For builds from tar.gz tests will not be built by default. For
builds from GIT, tests with be on by default, to try and ensure
that patch developers don't accidentally break the test suites
without noticing.

* configure.ac: Add --with-test-suite
* tests/Makefile.am: Use noinst_PROGRAMS instead of check_PROGRAMS
  if building tests by default. Consolidate setting of TESTS and
  {noinst,check}_PROGRAMS to avoid duplication

13 years agoChange the default of mdns_adv to false
Stef Walter [Tue, 27 Mar 2012 14:20:54 +0000 (16:20 +0200)]
Change the default of mdns_adv to false

 * Don't advertise information on the network without consent of
   the user, either through manual configuration, or a user
   interface that drives this option.
 * Since libvirtd must be configured for network access anyway
   (for all but ssh), this setting was not useful "out of the box",
   so changing this default setting does not remove "out of the box"
   functionality.

13 years agosnapshot: don't pass NULL to QMP command creation
Eric Blake [Tue, 27 Mar 2012 14:33:23 +0000 (08:33 -0600)]
snapshot: don't pass NULL to QMP command creation

Commit d42a2ff caused a regression in creating a disk-only snapshot
of a qcow2 disk; by passing the wrong variable to the monitor call,
libvirt ended up creating JSON that looked like "format":null instead
of the intended "format":"qcow2".

To make it easier to diagnose this in the future, make JSON creation
error out if "s:arg" is paired with NULL (it is still possible to
use "n:arg" in the rare cases where qemu will accept a null).

* src/qemu/qemu_driver.c
(qemuDomainSnapshotCreateSingleDiskActive): Pass correct value.
* src/qemu/qemu_monitor_json.c (qemuMonitorJSONMakeCommandRaw):
Improve error message.

13 years agoAdd LXC XML files to schema test & fix problems this uncovers
Daniel P. Berrange [Mon, 26 Mar 2012 17:11:09 +0000 (18:11 +0100)]
Add LXC XML files to schema test & fix problems this uncovers

* docs/schemas/domaincommon.rng: Add missing lxc & openvz
  console target types. Allow arch on LXC <os> type element
* tests/domainschematest: Include tests/lxcxml2xmldata/

13 years agoAdd support for setting init argv for LXC
Daniel P. Berrange [Mon, 26 Mar 2012 17:09:31 +0000 (18:09 +0100)]
Add support for setting init argv for LXC

Pass argv to the init binary of LXC, using a new <initarg> element.

* docs/formatdomain.html.in: Document <os> usage for containers
* docs/schemas/domaincommon.rng: Add <initarg> element
* src/conf/domain_conf.c, src/conf/domain_conf.h: parsing and
  formatting of <initarg>
* src/lxc/lxc_container.c: Setup LXC argv
* tests/Makefile.am, tests/lxcxml2xmldata/lxc-systemd.xml,
  tests/lxcxml2xmltest.c, tests/testutilslxc.c,
  tests/testutilslxc.h: Test parsing/formatting of LXC related
  XML parts

13 years agoDetect location fo selinux mount point
Daniel P. Berrange [Mon, 26 Mar 2012 15:39:30 +0000 (16:39 +0100)]
Detect location fo selinux mount point

The SELinux mount point moved from /selinux to /sys/fs/selinux
when systemd came along.

* configure.ac: Probe for SELinux mount point
* src/lxc/lxc_container.c: Use SELinux mount point determined
  by configure.ac

13 years agoExpand docs for timer tick policy
Daniel P. Berrange [Mon, 26 Mar 2012 12:29:41 +0000 (13:29 +0100)]
Expand docs for timer tick policy

13 years agoqemu,util: on restart of libvirt restart vepa callbacks
D. Herrendoerfer [Tue, 27 Mar 2012 12:38:33 +0000 (14:38 +0200)]
qemu,util: on restart of libvirt restart vepa callbacks

When libvirtd is restarted, also restart the netlink event
message callbacks for existing VEPA connections and send
a message to lldpad for these existing links, so it learns
the new libvirtd pid.

Signed-off-by: D. Herrendoerfer <d.herrendoerfer@herrendoerfer.name>
13 years agoqemu: Avoid entering monitor with locked driver
Jiri Denemark [Tue, 27 Mar 2012 11:32:43 +0000 (13:32 +0200)]
qemu: Avoid entering monitor with locked driver

This avoids possible deadlock of the qemu driver in case a domain is
begin migrated (in Begin phase) and unrelated connection to qemu driver
is closed at the right time.

I checked all callers of qemuDomainCheckEjectableMedia() and they are
calling this function with qemu driver locked.

13 years agobuild: fix "missing initializer" error in qemu_process.c
Laine Stump [Mon, 26 Mar 2012 16:39:03 +0000 (12:39 -0400)]
build: fix "missing initializer" error in qemu_process.c

Found when attempting to build on Fedora 17 alpha with:

   ./autogen.sh --system --enable-compile-warnings=error

(this same build command works without problem on Fedora 16). Since
the consumer of the qemuProcessReconnectData doesn't assume that the
other fields of the struct are initialized (although it uses them
internally), the simpler solution is to just switch to C99-style
struct initialization (which doesn't require specification of all
fields).

13 years agobuild: fix "missing initializer" errors in virsh.c
Laine Stump [Mon, 26 Mar 2012 16:58:05 +0000 (12:58 -0400)]
build: fix "missing initializer" errors in virsh.c

Found when attempting to build on Fedora 17 alpha with:

   ./autogen.sh --system --enable-compile-warnings=error

(this same build command works without problem on Fedora 16). All
other struct initializers for this struct have the extra field filled
in (almost always to 0), so the two errant ones were fixed by adding
in the extra 0 field.

13 years agobuild: avoid frame size error when building without -O2
Laine Stump [Mon, 26 Mar 2012 18:42:22 +0000 (14:42 -0400)]
build: avoid frame size error when building without -O2

libvirt always adds -Werror-frame-larger-than=4096 to the flags when
it builds. When building on Fedora 17, two functions with multiple
1024 buffers declared inside if {} blocks would generate frame size
errors; apparently the version of gcc on Fedora 16 will merge these
multiple buffers into a single buffer even when optimization is off,
but Fedora 17 won't.

The fix is to declare a single 1024 buffer at the top of the two
offending functions, and reuse the single buffer throughout the
functions.

13 years agoAdded syntax-check rule for return with parentheses
Martin Kletzander [Fri, 23 Mar 2012 07:34:09 +0000 (08:34 +0100)]
Added syntax-check rule for return with parentheses

After cleanup introduced with previous commit, there is a need for
syntax-check rule taking care of return(). Regexp used in 'prohibit'
parameter is taken from the cleanup commit and modified so it fits
'grep -E' format. Semicolon at the end is needed, otherwise the regexp
could match return with cast.

Exception is created for python source files because we don't have any
documentation restricting the use of return that matches this case.

13 years agoCleanup for a return statement in source files
Martin Kletzander [Thu, 22 Mar 2012 11:33:35 +0000 (12:33 +0100)]
Cleanup for a return statement in source files

Return statements with parameter enclosed in parentheses were modified
and parentheses were removed. The whole change was scripted, here is how:

List of files was obtained using this command:
git grep -l -e '\<return\s*([^()]*\(([^()]*)[^()]*\)*)\s*;' |             \
grep -e '\.[ch]$' -e '\.py$'

Found files were modified with this command:
sed -i -e                                                                 \
's_^\(.*\<return\)\s*(\(\([^()]*([^()]*)[^()]*\)*\))\s*\(;.*$\)_\1 \2\4_' \
-e 's_^\(.*\<return\)\s*(\([^()]*\))\s*\(;.*$\)_\1 \2\3_'

Then checked for nonsense.

The whole command looks like this:
git grep -l -e '\<return\s*([^()]*\(([^()]*)[^()]*\)*)\s*;' |             \
grep -e '\.[ch]$' -e '\.py$' | xargs sed -i -e                            \
's_^\(.*\<return\)\s*(\(\([^()]*([^()]*)[^()]*\)*\))\s*\(;.*$\)_\1 \2\4_' \
-e 's_^\(.*\<return\)\s*(\([^()]*\))\s*\(;.*$\)_\1 \2\3_'

13 years agoFix and test round-trip of query parameters
Eric Blake [Mon, 26 Mar 2012 10:23:45 +0000 (11:23 +0100)]
Fix and test round-trip of query parameters

When qparams support was dropped in commit bc1ff160, we forgot
to add tests to ensure that viruri can do the same round trip
handling of a URI. This round trip was broken, due to use
of the old 'query' field of xmlUriPtr, instead of the new
'query_raw'

Also, we forgot to report an OOM error.

* tests/viruritest.c (mymain): Add tests based on just-deleted
qparamtest.
(testURIParse): Allow difference in input and expected output.
* src/util/viruri.c (virURIFormat): Add missing error. Use
  query_raw, instead of query for xmlUriPtr object.

13 years agospec: Add missed dependancy for numad
Osier Yang [Sat, 24 Mar 2012 01:35:20 +0000 (09:35 +0800)]
spec: Add missed dependancy for numad

numad is available since Fedora 17 and RHEL6.X. And it's not supported
on s390[x] and ARM.

13 years agosnapshot: improve qemu handling of reused snapshot targets
Eric Blake [Tue, 20 Mar 2012 21:03:45 +0000 (15:03 -0600)]
snapshot: improve qemu handling of reused snapshot targets

The oVirt developers have stated that the real reasons they want
to have qemu reuse existing volumes when creating a snapshot are:
1. the management framework is set up so that creation has to be
done from a central node for proper resource tracking, and having
libvirt and/or qemu create things violates the framework, and
2. qemu defaults to creating snapshots with an absolute path to
the backing file, but oVirt wants to manage a backing chain that
uses just relative names, to allow for easier migration of a chain
across storage locations.

When 0.9.10 added VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT (commit
4e9953a4), it only addressed point 1, but libvirt was still using
O_TRUNC which violates point 2.  Meanwhile, the new qemu
'transaction' monitor command includes a new optional mode argument
that will force qemu to reuse the metadata of the file it just
opened (with the burden on the caller to have valid metadata there
in the first place).  So, this tweaks the meaning of the flag to
cover both points as intended for use by oVirt.  It is not strictly
backward-compatible to 0.9.10 behavior, but it can be argued that
the O_TRUNC of 0.9.10 was a bug.

Note that this flag is all-or-nothing, and only selects between
'existing' and the default 'absolute-paths'.  A more flexible
approach that would allow per-disk selections, as well as adding
support for the 'no-backing-file' mode, would be possible by
extending the <domainsnapshot> xml to have a per-disk mode, but
until we have a management application expressing a need for that
additional complexity, it is not worth doing.

* src/libvirt.c (virDomainSnapshotCreateXML): Tweak documentation.
* src/qemu/qemu_monitor.h (qemuMonitorDiskSnapshot): Add
parameters.
* src/qemu/qemu_monitor_json.h (qemuMonitorJSONDiskSnapshot):
Likewise.
* src/qemu/qemu_monitor.c (qemuMonitorDiskSnapshot): Pass them
through.
* src/qemu/qemu_monitor_json.c (qemuMonitorJSONDiskSnapshot): Use
new monitor command arguments.
* src/qemu/qemu_driver.c (qemuDomainSnapshotCreateDiskActive)
(qemuDomainSnapshotCreateSingleDiskActive): Adjust callers.
(qemuDomainSnapshotDiskPrepare): Allow qed, modify rules on reuse.

13 years agosnapshot: wire up qemu transaction command
Eric Blake [Sat, 17 Mar 2012 20:16:25 +0000 (14:16 -0600)]
snapshot: wire up qemu transaction command

The hardest part about adding transactions is not using the new
monitor command, but undoing the partial changes we made prior
to a failed transaction.

* src/qemu/qemu_driver.c (qemuDomainSnapshotCreateDiskActive): Use
transaction when available.
(qemuDomainSnapshotUndoSingleDiskActive): New function.
(qemuDomainSnapshotCreateSingleDiskActive): Pass through actions.
(qemuDomainSnapshotCreateXML): Adjust caller.

13 years agosnapshot: add support for qemu transaction command
Eric Blake [Sat, 17 Mar 2012 04:17:28 +0000 (22:17 -0600)]
snapshot: add support for qemu transaction command

QEmu 1.1 is adding a 'transaction' command to the JSON monitor.
Each element of a transaction corresponds to a top-level command,
with the additional guarantee that the transaction flushes all
pending I/O, then guarantees that all actions will be successful
as a group or that failure will roll back the state to what it
was before the monitor command.  The difference between a
top-level command:

{ "execute": "blockdev-snapshot-sync", "arguments":
  { "device": "virtio0", ... } }

and a transaction:

{ "execute": "transaction", "arguments":
  { "actions": [
    { "type": "blockdev-snapshot-sync", "data":
      { "device": "virtio0", ... } } ] } }

is just a couple of changed key names and nesting the shorter
command inside a JSON array to the longer command.  This patch
just adds the framework; the next patch will actually use a
transaction.

* src/qemu/qemu_monitor_json.c (qemuMonitorJSONMakeCommand): Move
guts...
(qemuMonitorJSONMakeCommandRaw): ...into new helper.  Add support
for array element.
(qemuMonitorJSONTransaction): New command.
(qemuMonitorJSONDiskSnapshot): Support use in a transaction.
* src/qemu/qemu_monitor_json.h (qemuMonitorJSONDiskSnapshot): Add
argument.
(qemuMonitorJSONTransaction): New declaration.
* src/qemu/qemu_monitor.h (qemuMonitorTransaction): Likewise.
(qemuMonitorDiskSnapshot): Add argument.
* src/qemu/qemu_monitor.c (qemuMonitorTransaction): New wrapper.
(qemuMonitorDiskSnapshot): Pass argument on.
* src/qemu/qemu_driver.c
(qemuDomainSnapshotCreateSingleDiskActive): Update caller.

13 years agosnapshot: rudimentary qemu support for atomic disk snapshot
Eric Blake [Fri, 16 Mar 2012 21:17:13 +0000 (15:17 -0600)]
snapshot: rudimentary qemu support for atomic disk snapshot

Taking an external snapshot of just one disk is atomic, without having
to pause and resume the VM.  This also paves the way for later patches
to interact with the new qemu 'transaction' monitor command.

The various scenarios when requesting atomic are:
online, 1 disk, old qemu - safe, allowed by this patch
online, more than 1 disk, old qemu - failure, this patch
offline snapshot - safe, once a future patch implements offline disk snapshot
online, 1 or more disks, new qemu - safe, once future patch uses transaction

Taking an online system checkpoint snapshot is atomic, since it is
done via a single 'savevm' monitor command.  Taking an offline system
checkpoint snapshot is atomic, thanks to the previous patch.

* src/qemu/qemu_driver.c (qemuDomainSnapshotCreateXML): Support
new flag for single-disk setups.
(qemuDomainSnapshotDiskPrepare): Check for atomic here.
(qemuDomainSnapshotCreateDiskActive): Skip pausing the VM when
atomic supported.
(qemuDomainSnapshotIsAllowed): Use bool instead of int.

13 years agosnapshot: make offline qemu snapshots atomic
Eric Blake [Sat, 17 Mar 2012 15:54:44 +0000 (09:54 -0600)]
snapshot: make offline qemu snapshots atomic

Offline internal snapshots can be rolled back with just a little
bit of refactoring, meaning that we are now automatically atomic.

* src/qemu/qemu_domain.c (qemuDomainSnapshotForEachQcow2): Move
guts...
(qemuDomainSnapshotForEachQcow2Raw): ...to new helper, to allow
rollbacks.

13 years agosnapshot: add atomic create flag
Eric Blake [Fri, 16 Mar 2012 21:23:00 +0000 (15:23 -0600)]
snapshot: add atomic create flag

Right now, it is appallingly easy to cause qemu disk snapshots
to alter a domain then fail; for example, by requesting a two-disk
snapshot where the second disk name resides on read-only storage.
In this failure scenario, libvirt reports failure, but modifies
the live domain XML in-place to record that the first disk snapshot
was taken; and places a difficult burden on the management app
to grab the XML and reparse it to see which disks, if any, were
altered by the partial snapshot.

This patch adds a new flag where implementations can request that
the hypervisor make snapshots atomically; either no changes to
XML occur, or all disks were altered as a group.  If you request
the flag, you either get outright failure up front, or you take
advantage of hypervisor abilities to make an atomic snapshot. Of
course, drivers should prefer the atomic means even without the
flag explicitly requested.

There's no way to make snapshots 100% bulletproof - even if the
hypervisor does it perfectly atomic, we could run out of memory
during the followup tasks of updating our in-memory XML, and report
a failure.  However, these sorts of catastrophic failures are rare
and unlikely, and it is still nicer to know that either all
snapshots happened or none of them, as that is an easier state to
recover from.

* include/libvirt/libvirt.h.in
(VIR_DOMAIN_SNAPSHOT_CREATE_ATOMIC): New flag.
* src/libvirt.c (virDomainSnapshotCreateXML): Document it.
* tools/virsh.c (cmdSnapshotCreate, cmdSnapshotCreateAs): Expose it.
* tools/virsh.pod (snapshot-create, snapshot-create-as): Document
it.

13 years agosnapshot: add qemu capability for 'transaction' command
Eric Blake [Wed, 14 Mar 2012 22:29:21 +0000 (16:29 -0600)]
snapshot: add qemu capability for 'transaction' command

We need a capability bit to gracefully error out if some of the
additions in future patches can't be implemented by the running qemu.

* src/qemu/qemu_capabilities.h (QEMU_CAPS_TRANSACTION): New cap.
* src/qemu/qemu_capabilities.c (qemuCaps): Name it.
* src/qemu/qemu_monitor_json.c (qemuMonitorJSONCheckCommands): Set
it.

13 years agobuild: drop obsolete qparams test
Eric Blake [Fri, 23 Mar 2012 22:04:18 +0000 (16:04 -0600)]
build: drop obsolete qparams test

Otherwise, 'make check' breaks since commit bc1ff160 deleted
qparams.h.  A later patch will ensure that viruri takes over
what qparams used to do.

* tests/qparamtest.c (mymain): Delete, now that we have viruri.
* tests/Makefile.am (check_PROGRAMS, TESTS, qparamtest_SOURCES):
Delete old test.
* .gitignore: Add recent test additions.

13 years agobuild: fix incorrect enum declaration
Eric Blake [Fri, 23 Mar 2012 20:23:43 +0000 (14:23 -0600)]
build: fix incorrect enum declaration

Recent changes have caused build failures on systems where pdwtags works:
commit a26a196 mistakenly exported a public variable
commits a26a19657ddcc2487c063 all had copy-paste bugs in
hand-updating the golden API rather than rerunning pdwtags

* include/libvirt/libvirt.h.in (virDomainEventTrayChangeReason):
Make this a typedef, not external storage.
* src/remote_protocol-structs (remote_procedure): Fix spelling.