]> git.ipfire.org Git - thirdparty/libvirt.git/log
thirdparty/libvirt.git
13 years agostorage: Fix any VolLookupByPath if we have an empty logical pool
Cole Robinson [Wed, 25 Jan 2012 17:07:14 +0000 (12:07 -0500)] 
storage: Fix any VolLookupByPath if we have an empty logical pool

On F16 at least, empty volume groups don't have a directory under /dev.
The directory only appears once a logical volume is created.

This tickles some behavior in BackendStablePath which ends with
libvirt sleeping for 5 seconds while waiting for the directory to appear.
This causes all sorts of problems for the virStorageVolLookupByPath API
which virtinst uses, even if trying to resolve a path that is independent
of the logical pool.

In reality we don't even need to do that checking since logical pools
always have a stable target path. Short circuit the polling in that
case.

Fixes bug 782261
(cherry picked from commit 275155f664614fd32bcf5e963488e6f97b66dae4)

13 years agodaemon: Remove deprecated HAL from init script dependencies
Peter Krempa [Fri, 2 Mar 2012 14:12:32 +0000 (15:12 +0100)] 
daemon: Remove deprecated HAL from init script dependencies

The init script for the daemon requests to start HAL although it has
been deprecated long time ago. This patch removes the dependency.
(cherry picked from commit 2dcca3ec0a28c6562ebfbe7a5eae4729fb5de904)

13 years agovirCommand: Properly handle POLLHUP
Michal Privoznik [Tue, 3 Jan 2012 17:40:55 +0000 (18:40 +0100)] 
virCommand: Properly handle POLLHUP

It is a good practise to set revents to zero before doing any poll().
Moreover, we should check if event we waited for really occurred or
if any of fds we were polling on didn't encountered hangup.
(cherry picked from commit 06b9c5b9231ef4dbd4b5ff69564305cd4f814879)

13 years agoqemu: Check for domain being active on successful job acquire
Michal Privoznik [Tue, 11 Oct 2011 08:40:36 +0000 (10:40 +0200)] 
qemu: Check for domain being active on successful job acquire

As this is needed. Although some functions check for domain
being active before obtaining job, we need to check it after,
because obtaining job unlocks domain object, during which
a state of domain can be changed.
(cherry picked from commit 9bc9999b6eb815268798120d7fe8834d822f098d)

13 years agoAvoid crash in shunloadtest
Daniel P. Berrange [Thu, 1 Dec 2011 16:33:50 +0000 (11:33 -0500)] 
Avoid crash in shunloadtest

For unknown reasons, the shunloadtest will crash on Fedora 16
inside dlopen()

 (gdb) bt
 #0  0x00000000000050e6 in ?? ()
 #1  0x00007ff61a77b9d5 in floor () from /lib64/libm.so.6
 #2  0x00007ff61e522963 in _dl_relocate_object () from /lib64/ld-linux-x86-64.so.2
 #3  0x00007ff61e5297e6 in dl_open_worker () from /lib64/ld-linux-x86-64.so.2
 #4  0x00007ff61e525006 in _dl_catch_error () from /lib64/ld-linux-x86-64.so.2
 #5  0x00007ff61e52917a in _dl_open () from /lib64/ld-linux-x86-64.so.2
 #6  0x00007ff61e0f6f26 in dlopen_doit () from /lib64/libdl.so.2
 #7  0x00007ff61e525006 in _dl_catch_error () from /lib64/ld-linux-x86-64.so.2
 #8  0x00007ff61e0f752f in _dlerror_run () from /lib64/libdl.so.2
 #9  0x00007ff61e0f6fc1 in dlopen@@GLIBC_2.2.5 () from /lib64/libdl.so.2
 #10 0x0000000000400a15 in main (argc=<optimized out>, argv=<optimized out>) at shunloadtest.c:105

Changing from RTLD_NOW to RTLD_LAZY avoids this problem,
but quite possibly does not fix the root cause.

* shunloadtest.c: s/NOW/LAZY/
(cherry picked from commit 24d9792821af4c6b304e5b0ee83f7b233cfa314e)

13 years agospec: make it easier to autoreconf when building rpm
Eric Blake [Mon, 5 Dec 2011 17:22:10 +0000 (10:22 -0700)] 
spec: make it easier to autoreconf when building rpm

Over time, Fedora and RHEL RPMs have often backported upstream
patches that touched configure.ac and/or Makefile.am; this
necessitates rerunning the autotools for the patch to be effective.
Making this a one-liner spec tweak will make it easier for future
backports to pull patches without having to find all the places
to touch to properly use the autotools.  Meanwhile, there have been
historical instances where an update in the autotools caused FTBFS
situations, so this is not on by default.

* libvirt.spec.in (enable_autotools): New variable, default off.
(BuildRequires): Conditionally add autotools.
(%build): Conditionally use them before configure.
* mingw32-libvirt.spec.in: Likewise.
(cherry picked from commit 9c417636c4045735712c066595ff31539ac88bff)

Conflicts:

mingw32-libvirt.spec.in - caused by change in context

13 years agotest: replace deprecated "fedora-13" machine with "pc-0.13"
Laine Stump [Fri, 9 Dec 2011 20:55:14 +0000 (15:55 -0500)] 
test: replace deprecated "fedora-13" machine with "pc-0.13"

One of the xml tests in the test suite was created using a
now-deprecated qemu machine type ("fedora-13", which was only ever
valid for Fedora builds of qemu). Although strictly speaking it's not
necessary to replace it with an actual supported qemu machine type
(since the xml in question is never actually sent to qemu), this patch
changes it to the actually-supported "pc-0.13" just for general
tidiness. (Also, on some Fedora builds which contain a special patch
to rid the world of "fedora-13", having it mentioned in the test suite
will cause make check to fail.)
(cherry picked from commit 7204a9fd31b06a6ce8fe5b08483c39a75faa0392)

13 years agonetwork: don't add iptables rules for externally managed networks
Laine Stump [Tue, 6 Dec 2011 20:13:50 +0000 (15:13 -0500)] 
network: don't add iptables rules for externally managed networks

This patch addresses https://bugzilla.redhat.com/show_bug.cgi?id=760442

When a network has any forward type other than route, nat or none, the
network configuration should be done completely external to libvirt -
libvirt only uses these types to allow configuring guests in a manner
that isn't tied to a specific host (all the host-specific information,
in particular interface names, port profile data, and bandwidth
configuration is in the network definition, and the guest
configuration only references it).

Due to a bug in the bridge network driver, libvirt was adding iptables
rules for networks with forward type='bridge' etc. any time libvirtd
was restarted while one of these networks was active.

This patch eliminates that error by only "reloading" iptables rules if
forward type is route, nat, or none.
(cherry picked from commit ae1232b298323dd7bef909426e2ebafa6bca9157)

13 years agospec: fix logic bug in deciding to turn on cgconfig
Eric Blake [Thu, 8 Dec 2011 20:32:37 +0000 (13:32 -0700)] 
spec: fix logic bug in deciding to turn on cgconfig

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

Commit ecd8725 tried to silence a spurious warning on the initial
libvirt install, and commit ba6cbb1 tried to fix up the logic to the
correct Fedora version, but the warning was still present due to a
logic bug: since %{fedora} and %{rhel} are never simulatanously
set, then 0%{rhel} <= 6 made the %if always true.  Checking for
minimum versions (via >=) is okay, but checking for maximum versions
(via <=) requires a prerequisite test that the platform being tested
is non-zero.

Also fix a bogus setting of with_libxl (although we previously
hard-code with_libxl to 0 for rhel earlier in the file, so this
was not as severe a bug).

* libvirt.spec.in (with_cgconfig): Don't enable cgconfig on F16.
(cherry picked from commit 3b95f284f19d2e43daa32a87cd10eaf42ea8bb4e)

13 years agospec: don't use chkconfig --list
Eric Blake [Tue, 6 Dec 2011 23:16:34 +0000 (16:16 -0700)] 
spec: don't use chkconfig --list

https://bugzilla.redhat.com/show_bug.cgi?id=694403 reports that
the specfile is incorrectly checking for a running libvirt-guests
service.  For example,

$ LC_ALL=es_ES chkconfig --list libvirt-guests
libvirt-guests    0:desactivado  1:desactivado    2:desactivado     3:activo  4:activo  5:activo     6:desactivado

will fail to find 5:on, even though it is active.  But chkconfig
already has a mode where you can silently use the exit status to
check for an active service.

* libvirt.spec.in (%post): Use simpler chkconfig options, to avoid
issues with localization.
(cherry picked from commit fea83dde7b7e0725e4353a2cc5b6e5c7c61cb294)

13 years agospec: add dmidecode as prereq
Eric Blake [Mon, 5 Dec 2011 17:32:41 +0000 (10:32 -0700)] 
spec: add dmidecode as prereq

https://bugzilla.redhat.com/show_bug.cgi?id=754909 complains that
because libvirt didn't require dmidecode, that the logs are noisy
and virConnectGetSysinfo needlessly fails.  Even 'virt-what' requires
dmidecode, so it's not that onerous of a dependency.  We may be
able to drop this in the future when we move to parsing sysfs data,
but for now, listing the dependency will help matters.

* libvirt.spec.in (Requires): Sort Requires before BuildRequires.
Add dmidecode.
(cherry picked from commit e7dfa468f9de796430a4cc9594eb256109a517bf)
extra requires for with_systemd removed, since the patch that adds
that hasn't been backported

13 years agoFix incorrect symbols for virtime.h module breaking Mingw32
Daniel P. Berrange [Mon, 5 Dec 2011 14:04:25 +0000 (14:04 +0000)] 
Fix incorrect symbols for virtime.h module breaking Mingw32

The Mingw32 linker highlighted that the symbols for virtime.h
declared in libvirt_private.syms were incorrect

* src/libvirt_private.syms: Fix virtime.h symbols
(cherry picked from commit b265beda55dd13c6e1a578285ae64191caed2694)

13 years agospec: mark directories in /var/run as ghosts
Eric Blake [Wed, 30 Nov 2011 22:34:42 +0000 (15:34 -0700)] 
spec: mark directories in /var/run as ghosts

We have several directories that are created on the fly, and which
only contain state relevant to a running libvirtd process (all
located in /var/run).  Since the directories are created as needed,
and make no sense without a running libvirtd, we want them deleted
if libvirt is uninstalled.  And in F15 and newer, /var/run is on
tmpfs (forcing us to recreate on the fly); which means that someone
trying to verify a complete rpm will fail if the directory does not
currently exist because libvirtd has not been started since boot.
The solution, then, is to mark the directories as %ghost, so that
rpm knows that we own them and will clean it up if libvirt is
uninstalled, but will no longer create the directory for us at
install, nor complain at verify time if the directory does not exist.

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

* libvirt.spec.in (%files): Add %ghost to temporary directories
that we don't install, but want cleaned up on libvirt removal.
(cherry picked from commit 764574f7c73d72e42f69f225b6bbe61fae5ab28b)

13 years agoRemove time APIs from src/util/util.h
Daniel P. Berrange [Tue, 29 Nov 2011 12:33:23 +0000 (12:33 +0000)] 
Remove time APIs from src/util/util.h

The virTimestamp and virTimeMs functions in src/util/util.h
duplicate functionality from virtime.h, in a non-async signal
safe manner. Remove them, and convert all code over to the new
APIs.

* src/util/util.c, src/util/util.h: Delete virTimeMs and virTimestamp
* src/lxc/lxc_driver.c, src/qemu/qemu_domain.c,
  src/qemu/qemu_driver.c, src/qemu/qemu_migration.c,
  src/qemu/qemu_process.c, src/util/event_poll.c: Convert to use
  virtime APIs
(cherry picked from commit a8bb75a3e65f0ae866f3b3fd60c57b2aa2050017)

Conflicts:

src/lxc/lxc_driver.c
src/qemu/qemu_domain.c
src/qemu/qemu_driver.c
 * the patches contained context with extra include files not
   yet introduced on the branch.
src/util/event_poll.c
 * the branch had context with a call to EVENT_DEBUG that
   was no longer existing in the original patch.

13 years agoMake logging async signal safe wrt time stamp generation
Daniel P. Berrange [Tue, 29 Nov 2011 12:32:31 +0000 (12:32 +0000)] 
Make logging async signal safe wrt time stamp generation

Use the new virTimeStringNowRaw() API for generating log timestamps
in an async signal safe manner

* src/util/logging.c: Use virTimeStringNowRaw
(cherry picked from commit 32d3ec7466a554f7a4a3e9d4017a24aa540ecf18)

Conflicts:

src/util/logging.c

13 years agoAdd internal APIs for dealing with time
Daniel P. Berrange [Tue, 29 Nov 2011 12:11:01 +0000 (12:11 +0000)] 
Add internal APIs for dealing with time

The logging APIs need to be able to generate formatted timestamps
using only async signal safe functions. This rules out using
gmtime/localtime/malloc/gettimeday(!) and much more.

Introduce a new internal API which is async signal safe.

  virTimeMillisNowRaw replacement for gettimeofday. Uses clock_gettime
                      where available, otherwise falls back to the unsafe
                      gettimeofday

  virTimeFieldsNowRaw  replacements for gmtime(), convert a timestamp
  virTimeFieldsThenRaw into a broken out set of fields. No localtime()
                       replacement is provided, because converting to
                       local time is not practical with only async signal
                       safe APIs.

  virTimeStringNowRaw  replacements for strftime() which print a timestamp
  virTimeStringThenRaw into a string, using a pre-determined format, with
                       a fixed size buffer (VIR_TIME_STRING_BUFLEN)

For each of these there is also a version without the Raw postfix
which raises a full libvirt error. These versions are not async
signal safe

* src/Makefile.am, src/util/virtime.c, src/util/virtime.h: New files
* src/libvirt_private.syms: New APis
* configure.ac: Check for clock_gettime in -lrt
* tests/virtimetest.c, tests/Makefile.am: Test new APIs
(cherry picked from commit 3ec128989606278635a7c5dfbeee959692d12e15)

Conflicts:

src/Makefile.am

13 years agologging: Add date to log timestamp
Jiri Denemark [Wed, 28 Sep 2011 14:44:50 +0000 (16:44 +0200)] 
logging: Add date to log timestamp
(cherry picked from commit 11c6e094e4e8789174502bd52c1441caa5865276)

13 years agologging: Do not log timestamp through syslog
Jiri Denemark [Wed, 28 Sep 2011 13:20:07 +0000 (15:20 +0200)] 
logging: Do not log timestamp through syslog

Syslog puts the timestamp to every message anyway so this removes
redundant data.
(cherry picked from commit 2a449549c1db0befef8a807bfe967a04af8b529b)

13 years agoqemu: make PCI multifunction support more manual
Laine Stump [Thu, 29 Sep 2011 17:00:32 +0000 (13:00 -0400)] 
qemu: make PCI multifunction support more manual

When support for was added for PCI multifunction cards (in commit
9f8baf, first included in libvirt 0.9.3), it was done by always
turning on the multifunction bit for all PCI devices. Since that time
it has been realized that this is not an ideal solution, and that the
multifunction bit must be selectively turned on. For example, see

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

and the discussion before and after

  https://www.redhat.com/archives/libvir-list/2011-September/msg01036.html

This patch modifies multifunction support so that the multifunction=on
option is only added to the qemu commandline for a device if its PCI
<address> definition has the attribute "multifunction='on'", e.g.:

  <address type='pci' domain='0x0000' bus='0x00'
           slot='0x04' function='0x0' multifunction='on'/>

In practice, the multifunction bit should only be turned on if
function='0' AND other functions will be used in the same slot - it
usually isn't needed for functions 1-7 (although there are apparently
some exceptions, e.g. the Intel X53 according to the QEMU source
code), and should never be set if only function 0 will be used in the
slot. The test cases have been changed accordingly to illustrate.

With this patch in place, if a user attempts to assign multiple
functions in a slot without setting the multifunction bit for function
0, libvirt will issue an error when the domain is defined, and the
define operation will fail. In the future, we may decide to detect
this situation and automatically add multifunction=on to avoid the
error; even then it will still be useful to have a manual method of
turning on multifunction since, as stated above, there are some
devices that excpect it to be turned on for all functions in a slot.

A side effect of this patch is that attempts to use the same PCI
address for two different devices will now log an error (previously
this would cause the domain define operation to fail, but there would
be no log message generated). Because the function doing this log was
almost completely rewritten, I didn't think it worthwhile to make a
separate patch for that fix (the entire patch would immediately be
obsoleted).
(cherry picked from commit c329db7180d77c8077b9f9cd167a71d7f347227a)

13 years agoconf: remove unused VIR_ENUM_DECL
Laine Stump [Wed, 28 Sep 2011 18:19:59 +0000 (14:19 -0400)] 
conf: remove unused VIR_ENUM_DECL

While adding a new enum, I noticed a VIR_ENUM_DECL for a type that
doesn't exist. There is also of course no matching VIR_ENUM_IMPL for
it.
(cherry picked from commit be7bc4d5ccb502c2da85d3b3db804fd53b70449e)

13 years agospec: F15 still uses cgconfig, RHEL lacks hyperv
Eric Blake [Mon, 26 Sep 2011 20:28:47 +0000 (14:28 -0600)] 
spec: F15 still uses cgconfig, RHEL lacks hyperv

Commit ecd8725c dropped attempts to probe the cgconfig service on
new enough Fedora where systemd took over that aspect of the system,
but mistakenly used F14 instead of F15 as the cutoff point.

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

Also, RHEL does not include HyperV support yet.

* libvirt.spec.in (with_cgconfig): Check cgconfig service in F15.
(%{?rhel}): Provide default for with_hyperv.
(cherry picked from commit ba6cbb182b49ca1f94a40285f40f342f84c0bd2a)

14 years agoRelease of libvirt-0.9.6 v0.9.6
Daniel Veillard [Thu, 22 Sep 2011 06:53:23 +0000 (14:53 +0800)] 
Release of libvirt-0.9.6

14 years agosnapshot: also delete empty directory
Eric Blake [Wed, 21 Sep 2011 22:08:42 +0000 (16:08 -0600)] 
snapshot: also delete empty directory

The previous patch removed all snapshots, but not the directory
where the snapshots lived, which is still a form of stale data.

* src/qemu/qemu_domain.c (qemuDomainRemoveInactive): Wipe any
snapshot directory.

14 years agosnapshot: remove snapshot metadata on transient exit
Eric Blake [Thu, 22 Sep 2011 06:02:03 +0000 (14:02 +0800)] 
snapshot: remove snapshot metadata on transient exit

Commit 282fe1f0 documented that transient domains will auto-delete
any snapshot metadata when the last reference to the domain is
removed, and that management apps are in charge of grabbing any
snapshot metadata prior to that point.  However, this was not
actually implemented for qemu until now.

* src/qemu/qemu_driver.c (qemudDomainCreate)
(qemuDomainDestroyFlags, qemuDomainSaveInternal)
(qemudDomainCoreDump, qemuDomainRestoreFlags, qemudDomainDefine)
(qemuDomainUndefineFlags, qemuDomainMigrateConfirm3)
(qemuDomainRevertToSnapshot): Clean up snapshot metadata.
* src/qemu/qemu_migration.c (qemuMigrationPrepareAny)
(qemuMigrationPerformJob, qemuMigrationPerformPhase)
(qemuMigrationFinish): Likewise.
* src/qemu/qemu_process.c (qemuProcessHandleMonitorEOF)
(qemuProcessReconnect, qemuProcessReconnectHelper)
(qemuProcessAutoDestroyDom): Likewise.

14 years agosnapshot: prepare to remove transient snapshot metadata
Eric Blake [Wed, 21 Sep 2011 19:08:51 +0000 (13:08 -0600)] 
snapshot: prepare to remove transient snapshot metadata

This patch is mostly code motion - moving some functions out
of qemu_driver and into qemu_domain so they can be reused by
multiple qemu_* files (since qemu_driver.h must not grow).
It also adds a new helper function, qemuDomainRemoveInactive,
which will be used in the next patch.

* src/qemu/qemu_domain.h (qemuFindQemuImgBinary)
(qemuDomainSnapshotWriteMetadata, qemuDomainSnapshotForEachQcow2)
(qemuDomainSnapshotDiscard, qemuDomainSnapshotDiscardAll)
(qemuDomainRemoveInactive): New prototypes.
(struct qemu_snap_remove): New struct.
* src/qemu/qemu_domain.c (qemuDomainRemoveInactive)
(qemuDomainSnapshotDiscardAllMetadata): New functions.
(qemuFindQemuImgBinary, qemuDomainSnapshotWriteMetadata)
(qemuDomainSnapshotForEachQcow2, qemuDomainSnapshotDiscard)
(qemuDomainSnapshotDiscardAll): Move here...
* src/qemu/qemu_driver.c (qemuFindQemuImgBinary)
(qemuDomainSnapshotWriteMetadata, qemuDomainSnapshotForEachQcow2)
(qemuDomainSnapshotDiscard, qemuDomainSnapshotDiscardAll): ...from
here.
(qemuDomainUndefineFlags): Update caller.
* src/conf/domain_conf.c (virDomainRemoveInactive): Doc fixes.

14 years agosnapshot: fix logic bug in qemu undefine
Eric Blake [Wed, 21 Sep 2011 19:08:50 +0000 (13:08 -0600)] 
snapshot: fix logic bug in qemu undefine

Commit 19f8c98 introduced VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA,
with the intent that omitting the flag makes undefine fail, and
including the flag deletes metadata.  But it used the wrong logic.
Also, hoist the transient domain sooner, so that we don't
accidentally remove metadata of a transient domain.

* src/qemu/qemu_driver.c (qemuDomainUndefineFlags): Check correct
flag value.

14 years agosanlock: fix memory leak
Eric Blake [Wed, 21 Sep 2011 20:22:57 +0000 (14:22 -0600)] 
sanlock: fix memory leak

Detected by Coverity.  The only way to get to error_unlink is if
path was successfully assigned, so the if was useless.  Meanwhile,
there was a return statement that did not free path.

* src/locking/lock_driver_sanlock.c
(virLockManagerSanlockSetupLockspace): Fix mem-leak, and drop
useless if.

14 years agovirsh: fix regression in argv parsing
Eric Blake [Wed, 21 Sep 2011 14:54:47 +0000 (08:54 -0600)] 
virsh: fix regression in argv parsing

Prior to commit 85d2810, we had an issue where:

snapshot-create-as dom name --diskspec spec --diskspec spec

failed to parse the second spec, because the first spec had marked
that option as no longer requiring an argument.

In commit 85d2810, I fixed it by making argv options no longer mark
the option as seen.  But this in turn breaks mandatory argv options,
which now complain that the argv option is missing.

This patch reverts that part of 85d2810, and instead replaces it with
fixes to no longer clear opts_need_arg of an argv argument.

* tools/virsh.c (vshCmddefGetOption, vshCmddefGetData)
(vshCommandParse): Fix option parsing for required argv option.
(vshCmddefOptParse): Check that argv option is last.
* tests/virsh-optparse: Enhance test.

14 years agovirsh: More friendly err if no pool is specified for looking up a vol
Osier Yang [Wed, 21 Sep 2011 06:29:49 +0000 (14:29 +0800)] 
virsh: More friendly err if no pool is specified for looking up a vol

There are 3 ways to lookup a volume, only virStorageVolLookupByName
needs pool object. So if no --pool is specified, it will tries to
get the volume via virStorageVolLookupByPath/virStorageVolLookupByKey.

But if all 3 ways fails, and no --pool is specified, a friendly
error might help the user get right way quickly.

14 years agostorage: Wait udev events are handled before removing lvm vol
Osier Yang [Wed, 21 Sep 2011 06:02:30 +0000 (14:02 +0800)] 
storage: Wait udev events are handled before removing lvm vol

Related #BZ: https://bugzilla.redhat.com/show_bug.cgi?id=702260.

There are two problems described in the BZ:
1) "Can't remove open logical volume".
2) "Unable to deactivate logical volume "foo""

This patch just intends to fix 2), as 1) is expected if the vol
is still used by something, and you never known if "lvchange -an"
will fail or not either (sometime, it will succeed, sometimes not).
We'd better not look for trouble, :-)

For 2), that's caused by race between lvremove and udev event handling,
the only workable way now is to wait the events handling are finished,
though it might introduce latencies, as "udevadmin settle" exits
after *all* events are handled, it's the only way we can fix
the racing in libvirt layer.

See https://bugzilla.redhat.com/show_bug.cgi?id=570359 for more
details.

14 years agoqemu: avoid dereferencing a NULL pointer
Alex Jia [Wed, 21 Sep 2011 19:02:44 +0000 (03:02 +0800)] 
qemu: avoid dereferencing a NULL pointer

* src/qemu/qemu_process.c: Taking if (qemuDomainObjEndJob(driver, obj) == 0)
  true branch then 'obj' is NULL, virDomainObjIsActive(obj) and
  virDomainObjUnref(obj) will dereference NULL pointer.

Signed-off-by: Alex Jia <ajia@redhat.com>
14 years agotests: improve test failure diagnosis
Oskari Saarenmaa [Wed, 21 Sep 2011 16:29:31 +0000 (19:29 +0300)] 
tests: improve test failure diagnosis

  * qemuhelptest prints test case name on failure.

14 years agoqemu: Avoid loop of fake reboots
Jiri Denemark [Wed, 21 Sep 2011 14:03:22 +0000 (16:03 +0200)] 
qemu: Avoid loop of fake reboots

Once virDomainReboot is called for a domain, guest OS initiated shutdown
would always result in reboot instead of shutdown. Only
virDomainShutdown would actually shutd such domain down. That's because
we forgot to reset fakeReboot flag once we asked the domain to reboot.

14 years agoqemu: Fix shutdown regression with buggy qemu
Jiri Denemark [Wed, 21 Sep 2011 08:25:29 +0000 (10:25 +0200)] 
qemu: Fix shutdown regression with buggy qemu

The commit that prevents disk corruption on domain shutdown
(96fc4784177ecb70357518fa863442455e45ad0e) causes regression with QEMU
0.14.* and 0.15.* because of a regression bug in QEMU that was fixed
only recently in QEMU git. The affected versions of QEMU do not quit on
SIGTERM if started with -no-shutdown, which we use to implement fake
reboot. Since -no-shutdown tells QEMU not to quit automatically on guest
shutdown, domains started using the affected QEMU cannot be shutdown
properly and stay in a paused state.

This patch disables fake reboot feature on such QEMU by not using
-no-shutdown, which makes shutdown work as expected. However,
virDomainReboot will not work in this case and it will report "Requested
operation is not valid: Reboot is not supported with this QEMU binary".

14 years agoAPI: prefer to use NULLSTR macro
Osier Yang [Wed, 21 Sep 2011 09:03:43 +0000 (17:03 +0800)] 
API: prefer to use NULLSTR macro

14 years agoremote: fix crash on OOM
Eric Blake [Tue, 20 Sep 2011 18:11:32 +0000 (12:11 -0600)] 
remote: fix crash on OOM

Bug introduced in commit 675464b.  On an OOM, this would try to
dereference a char* and free the contents as a pointer, which is
doomed to failure.

Adding a syntax check will prevent mistakes like this in the future.

* cfg.mk (sc_prohibit_internal_functions): New syntax check.
(exclude_file_name_regexp--sc_prohibit_internal_functions): Add
exemptions.
* daemon/remote.c (remoteRelayDomainEventIOError)
(remoteRelayDomainEventIOErrorReason)
(remoteRelayDomainEventGraphics, remoteRelayDomainEventBlockJob):
Use correct free function.

14 years agoxen: use typical allocations
Eric Blake [Tue, 20 Sep 2011 18:11:31 +0000 (12:11 -0600)] 
xen: use typical allocations

The next patch will add a syntax check that flags this usage in xen
as awkward - while it was valid memory management, it was very hard
to maintain.  Swapping to a more traditional allocation may be a bit
slower, but easier to understand.

* src/xen/xend_internal.c (xenDaemonListDomainsOld): Use two-level
allocation, rather than abusing allocation function.
(xenDaemonLookupByUUID): Update caller.

14 years agovirsh: Remove useless codes of cmdVolPath
Osier Yang [Tue, 20 Sep 2011 08:33:30 +0000 (16:33 +0800)] 
virsh: Remove useless codes of cmdVolPath

Variable "name" is never used in the codes, it's useless.

14 years agobuild: silence warning on 32-bit build
Eric Blake [Tue, 20 Sep 2011 22:53:58 +0000 (16:53 -0600)] 
build: silence warning on 32-bit build

gcc warns when building libvirt 0.9.5 on a 32-bit machine:

qemu/qemu_migration.c: In function 'qemuMigrationToFile':
qemu/qemu_migration.c:2727:38: error: large integer implicitly truncated to unsigned type [-Woverflow]

* src/qemu/qemu_domain.h (QEMU_DOMAIN_FILE_MIG_BANDWIDTH_MAX): Cap
to long when building for 32-bit platform.

14 years agoRelease of libvirt-0.9.5 v0.9.5
Daniel Veillard [Tue, 20 Sep 2011 06:17:47 +0000 (14:17 +0800)] 
Release of libvirt-0.9.5

* configure.ac docs/news.html.in libvirt.spec.in: update for the release
* po/*.po*: fetch updated translations from transifex and rebuilt

14 years agoFix crash on events due to allocation errors
Daniel Veillard [Tue, 20 Sep 2011 03:51:50 +0000 (11:51 +0800)] 
Fix crash on events due to allocation errors

remoteRelayDomainEventBlockJob, remoteRelayDomainEventIOError,
remoteRelayDomainEventIOErrorReason and remoteRelayDomainEventGraphics
were using const string directly in rpc structure, before calling
remoteDispatchDomainEventSend(). But that routine now frees up all
the pointed allocated memory from the rpc structure and we end up
with a double free.
This now strdup() all the strings passed and provide mem_error goto
labels to be used when an allocation error occurs.
Note that the cleanup isn't completely finished because all relaying
function also call make_nonnull_domain() which also allocate a string
and never handle the error case. This patches doesn't try to address
this as this is only error correctness a priori and touches far more
functions in this module:

* daemon/remote.c: fix string allocations and memory error handling
  for remoteRelayDomainEventBlockJob, remoteRelayDomainEventIOError,
  remoteRelayDomainEventIOErrorReason and remoteRelayDomainEventGraphics

14 years agoUpdate to require sanlock 1.8 for license compliance
Daniel P. Berrange [Mon, 19 Sep 2011 10:04:59 +0000 (11:04 +0100)] 
Update to require sanlock 1.8 for license compliance

Inexplicably the sanlock code all got placed under the GPLv2-only,
so libvirt's use of sanlock introduces a license incompatibility.
The sanlock developers have now rearranged the code such that there
is a 'sanlock_client.so' which is LGPLv2+ while their daemon remains
GPLv2-only. To use the new client library we need to call the new
sanlock_init and sanlock_align APIs instead of sanlock_direct_init
and sanlock_direct_align. These APIs calls are now routed via the
sanlock daemon, instead of doing direct I/O calls to disk.

For all this we require sanlock >= 1.8

* configure.ac: Check for sanlock_client.so instead of sanlock.so
  and fix various comments
* libvirt.spec.in: Mandate sanlock >= 1.8
* src/Makefile.am: Link to -lsanlock_client
* src/locking/lock_driver_sanlock.c: Use sanlock_init and
  sanlock_align

14 years agoconf: Assign newDef of active domain as persistent conf if it is NULL
Osier Yang [Thu, 1 Sep 2011 13:33:29 +0000 (21:33 +0800)] 
conf: Assign newDef of active domain as persistent conf if it is NULL

Libvirt loads the domain conf from status XML if it's running when
starting up. The problem is there is no record of the original conf.
(dom->newDef is NULL here).

So libvirt won't be able to restore the domain conf to original one
when destroying/shutdown. E.g.

1) attach a device without "--persistent"
2) restart libvirtd
3) destroy domain
4) start domain

One will see the the disk still exists.

This patch is to fix the peoblem by assigning persistent domain conf
to dom->newDef if it's NULL and the domain is running.

14 years agostorage: Ensure the device path exists before refreshing disk pool
Osier Yang [Mon, 19 Sep 2011 07:35:15 +0000 (15:35 +0800)] 
storage: Ensure the device path exists before refreshing disk pool

Doing libvirt_parthelper on an not existed device path will get
an unfriendly error message. This patch is to prohibit it.

14 years agodaemon: Error and exit if specified value for timeout is not valid
Osier Yang [Mon, 19 Sep 2011 04:16:45 +0000 (12:16 +0800)] 
daemon: Error and exit if specified value for timeout is not valid

Silently setting "timeout" as -1 if the specified value is invalid
is a bit confused.

14 years agoRemove devname identifier from autogenerated RPC code
Peter Krempa [Mon, 19 Sep 2011 14:14:34 +0000 (16:14 +0200)] 
Remove devname identifier from autogenerated RPC code

Patch 79cf07a missed one instance of "devname" in source for RPC code
generator.

14 years agovirsh: tweak previous domblkstat patch
Eric Blake [Mon, 19 Sep 2011 20:49:08 +0000 (14:49 -0600)] 
virsh: tweak previous domblkstat patch

Translators are likely to botch trailing spacing; by doing the
formatting outside of the translation, we can generally get
better alignment.  Also, for consistency, use 'bytes read' to
match 'bytes written'.

* tools/virsh.c (domblkstat_output): Drop trailing space. Tweak
rd_bytes output.
(cmdDomblkstat, DOMBLKSTAT_LEGACY_PRINT): Update formatting.

14 years agovirsh: doc: Fix supported driver types for attach-disk command
Peter Krempa [Mon, 19 Sep 2011 12:57:07 +0000 (14:57 +0200)] 
virsh: doc: Fix supported driver types for attach-disk command

Virsh man page lists driver types to be used with attach-device
command, but does not specify that those are usable only with the XEN
Hypervisor.

This patch adds statement, that those options specified are applicable
only on the Xen hypervisor and adds option usable with qemu emulator.

This patch also changes type of error returned by QEMU driver if the
user specifies incompatible driver type from VIR_ERR_INTERNAL_ERROR to
VIR_ERR_CONFIG_UNSUPPORTED.

14 years agomaint: Prefer names over email in 'git shortlog'
Eric Blake [Mon, 19 Sep 2011 22:34:10 +0000 (16:34 -0600)] 
maint: Prefer names over email in 'git shortlog'

Alex recently committed some patches with just an email instead
of a preferred name; this fixes things so 'git shortlog' gives
nicer output.

* .mailmap: Update.

14 years agovirsh: Add more human-friendly output of domblkstat command
Peter Krempa [Mon, 19 Sep 2011 12:23:12 +0000 (14:23 +0200)] 
virsh: Add more human-friendly output of domblkstat command

Users of virsh complain that output of the domblkstat command
is not intuitive enough. This patch adds explanation of fields
returned by this command to the help section for domblkstat and
the man page of virsh. Also a switch --human is added for
domblkstat that prints the fields with more descriptive
texts.

This patch also changes sequence of the output fields and their
names back to the order and spelling established by previous
versions of virsh to maintain compatibility with scripts.

Example of ordered and "translated" output:

PRE-patch:

virsh # domblkstat 1 vda
vda wr_bytes 5170176
vda wr_operations 511
vda rd_bytes 82815488
vda rd_operations 3726

POST-patch:

virsh # domblkstat 1 vda
vda rd_req 3726
vda rd_bytes 82815488
vda wr_req 478
vda wr_bytes 4965376

Example of human readable output:

virsh # domblkstat 1 vda --human
Device: vda
 number of read operations:      3726
 number of read bytes:           82815488
 number of write operations:     478
 number of bytes written:        4965376

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

14 years agovmx: avoid memory leak
ajia@redhat.com [Mon, 19 Sep 2011 02:34:06 +0000 (10:34 +0800)] 
vmx: avoid memory leak

* src/vmx/vmx.c: fix memory leak, 'def' has a initial value 'NULL', so
  'goto cleanup' is perfected instead of adding a virConfFree before
  'return NULL'.

Signed-off-by: Alex Jia <ajia@redhat.com>
14 years agoutil: avoid memory leak
ajia@redhat.com [Sun, 18 Sep 2011 16:36:13 +0000 (00:36 +0800)] 
util: avoid memory leak

Leak in pciGetVirtualFunctionIndex present since commit 17d64ca.

* src/util/pci.c: fix memory leak.

Signed-off-by: Alex Jia <ajia@redhat.com>
14 years agoremote: avoid memory leak
ajia@redhat.com [Sun, 18 Sep 2011 16:36:12 +0000 (00:36 +0800)] 
remote: avoid memory leak

Leak present since introduction of remoteDomainBuildEventGraphics
in commit 987e31e.

* src/remote/remote_driver.c: fix memory leak.

Signed-off-by: Alex Jia <ajia@redhat.com>
14 years agoqemu: avoid memory leak
ajia@redhat.com [Sun, 18 Sep 2011 16:36:11 +0000 (00:36 +0800)] 
qemu: avoid memory leak

Leak introduced in commit 036ad50, affects only error case.

* src/qemu/qemu_command.c: fix memory leak.

Signed-off-by: Alex Jia <ajia@redhat.com>
14 years agodaemon: avoid memory leak
ajia@redhat.com [Sun, 18 Sep 2011 16:36:10 +0000 (00:36 +0800)] 
daemon: avoid memory leak

Introduced in commit efa7fc9f.

* daemon/remote.c: fix memory leak in remoteDispatchDomainBlockStatsFlags

Signed-off-by: Alex Jia <ajia@redhat.com>
14 years agospec: silence warnings when installing in F16 v0.9.5-rc3
Eric Blake [Fri, 16 Sep 2011 22:40:25 +0000 (16:40 -0600)] 
spec: silence warnings when installing in F16

https://bugzilla.redhat.com/show_bug.cgi?id=738725 documents that
'yum install libvirt' in Fedora 16 is rather noisy.  This fixes
the problems.

* libvirt.spec.in (%post client): Silence chkconfig warning about
SysV services.
(%post) [with_cgconfig]: Drop for Fedora 15 and newer, where
systemd does this automatically.

14 years agosnapshot: allow disk snapshots of qcow2 disks
Eric Blake [Sat, 17 Sep 2011 12:16:08 +0000 (06:16 -0600)] 
snapshot: allow disk snapshots of qcow2 disks

For all types of disks other than qcow2, we were requesting that
SELinux labeling visit the new file as if it were qcow2, which
means labeling would try to find the backing files of an empty file.
And for a pre-existing qcow2 disk, we were passing NULL, which meant
that labelling tried to probe the file type (and if probing is
disabled, per the default qemu.conf, this made snapshots fail).
What we really want is to make SELinux labeling visit the new
file as raw; it will later be converted to qcow2 if qemu successfully
made the snapshot.

* src/qemu/qemu_driver.c
(qemuDomainSnapshotCreateSingleDiskActive): Force SELinux labeling
to avoid probe of new file.

14 years agosnapshot: affect persistent xml after disk snapshot
Eric Blake [Sat, 17 Sep 2011 03:46:21 +0000 (21:46 -0600)] 
snapshot: affect persistent xml after disk snapshot

For external snapshots to be useful on persistent domains, we must
alter the persistent definition alongside the running definition.
Thanks to the possibility of disk hotplug as well as of edits that
only affect the persistent xml, we can't assume that vm->def and
vm->newDef have the same disk at the same index, so we can only
update the persistent copy if the device destination matches up.

* src/qemu/qemu_driver.c (qemuDomainSnapshotCreateDiskActive)
(qemuDomainSnapshotCreateSingleDiskActive): Also affect newDef, if
present.

14 years agobuild: work around lack of MacOS fdatasync
Eric Blake [Fri, 16 Sep 2011 15:12:07 +0000 (09:12 -0600)] 
build: work around lack of MacOS fdatasync

Mingw lacks fsync, but gnulib provides that.  Meanwhile, gnulib does
not (yet) provide fdatasync, so this is a quick hack to fake that
function on MacOS X; we can revert this configure change once gnulib
gives us a real module.

We have been implicitly relying on gnulib's largefile module being
pulled in by other modules, but it's better to make that explicit.

* bootstrap.conf (gnulib_modules): Add fsync.  Make largefile use
explicit.
* configure.ac (AC_CHECK_FUNCS_ONCE): Check for fdatasync, and
fake it with fsync when not present.

14 years agoPrevent crash from dlclose() of libvirt.so
Daniel P. Berrange [Thu, 1 Sep 2011 16:57:06 +0000 (17:57 +0100)] 
Prevent crash from dlclose() of libvirt.so

When libvirt calls virInitialize it creates a thread local
for the virErrorPtr storage, and registers a callback to
cleanup memory when a thread exits. When libvirt is dlclose()d
or otherwise made non-resident, the callback function is
removed from memory, but the thread local may still exist
and if a thread later exists, it will invoke the callback
and SEGV. There may also be other thread locals with callbacks
pointing to libvirt code, so it is in general never safe to
unload libvirt.so from memory once initialized.

To allow dlclose() to succeed, but keep libvirt.so resident
in memory, link with '-z nodelete'. This issue was first
found with the libvirt CIM provider, but can potentially
hit many of the dynamic language bindings which all ultimately
involve dlopen() in some way, either on libvirt.so itself,
or on the glue code for the binding which in turns links
to libvirt

* configure.ac, src/Makefile.am: Ensure libvirt.so is linked
  with -z nodelete
* cfg.mk, .gitignore, tests/Makefile.am, tests/shunloadhelper.c,
  tests/shunloadtest.c: A test case to unload libvirt while
  a thread is still running.

14 years agoqemu: add return value check
Alex Jia [Fri, 16 Sep 2011 15:51:20 +0000 (23:51 +0800)] 
qemu: add return value check

* src/qemu/qemu_command.c: missing return value check.

Signed-off-by: Alex Jia <ajia@redhat.com>
14 years agoqemu: Introduce shutdown reason for paused state
Jiri Denemark [Thu, 15 Sep 2011 13:07:51 +0000 (15:07 +0200)] 
qemu: Introduce shutdown reason for paused state

Qemu sends STOP event as part of the shutdown process. Detect such STOP
event and consider shutdown to be reason of emitting such event. That's
the best we can do until qemu provides us the reason directly in STOP
event. This allows us to report shutdown reason for paused state so that
apps can detect domains that failed to finish the shutdown process
(e.g., because qemu is buggy and doesn't exit on SIGTERM or it is
blocked in flushing disk buffers).

14 years agoqemu: Prevent disk corruption on domain shutdown
Jiri Denemark [Tue, 13 Sep 2011 16:11:26 +0000 (18:11 +0200)] 
qemu: Prevent disk corruption on domain shutdown

Ever since we introduced fake reboot, we call qemuProcessKill as a
reaction to SHUTDOWN event. Unfortunately, qemu doesn't guarantee it
flushed all internal buffers before sending SHUTDOWN, in which case
killing the process forcibly may result in (virtual) disk corruption.

By sending just SIGTERM without SIGKILL we give qemu time to to flush
all buffers and exit. Once qemu exits, we will see an EOF on monitor
connection and tear down the domain. In case qemu ignores SIGTERM or
just hangs there, the process stays running but that's not any different
from a possible hang anytime during the shutdown process so I think it's
just fine.

Also qemu (since 0.14 until it's fixed) has a bug in SIGTERM processing
which causes it not to exit but instead send new SHUTDOWN event and keep
waiting. I think the best we can do is to ignore duplicate SHUTDOWN
events to avoid a SHUTDOWN-SIGTERM loop and leave the domain in paused
state.

14 years agoqemu: Properly detect crash of a rebooted domain
Jiri Denemark [Tue, 13 Sep 2011 16:48:13 +0000 (18:48 +0200)] 
qemu: Properly detect crash of a rebooted domain

When a domain is rebooted using libvirt API, we use fake reboot
consisting of shutting down and resetting the domain. Thus we see a
SHUTDOWN event and set gotShutdown flag. But we never reset it back and
if the domain crashes after it was rebooted this way, we consider it was
a normal shutdown and not a crash.

14 years agoqemu: Fix shutoff reason when domain crashes
Jiri Denemark [Tue, 13 Sep 2011 16:35:21 +0000 (18:35 +0200)] 
qemu: Fix shutoff reason when domain crashes

Commit 4454a9efc728b91e791b1f14c26ea23a19d57f48 changed shutoff reason
from VIR_DOMAIN_SHUTOFF_CRASHED to VIR_DOMAIN_SHUTOFF_FAILED in case we
see an unexpected EOF on monitor connection. But FAILED reason is
dedicated for domains that fail to start. CRASHED reason is the right
one to use in this situation.

14 years agopython: Fix bindings generated in VPATH build
Jiri Denemark [Fri, 16 Sep 2011 09:46:46 +0000 (11:46 +0200)] 
python: Fix bindings generated in VPATH build

14 years agoRevert "virsh: Use old API if remote libvirtd does not support new"
Eric Blake [Wed, 14 Sep 2011 18:47:07 +0000 (12:47 -0600)] 
Revert "virsh: Use old API if remote libvirtd does not support new"

This reverts commit 799912fa05b8c3aa37bd04c57b196755f3f70552; now
that the rpc regression is fixed, virsh no longer needs the special
case here.

14 years agorpc: convert unknown procedures to VIR_ERR_NO_SUPPORT
Eric Blake [Wed, 14 Sep 2011 18:41:17 +0000 (12:41 -0600)] 
rpc: convert unknown procedures to VIR_ERR_NO_SUPPORT

Libvirt special-cases a specific VIR_ERR_RPC from the remote driver
back into VIR_ERR_NO_SUPPORT on the client, so that clients can
handle missing rpc functions the same whether the hypervisor driver
is local or remote.  However, commit c1b22644 introduced a regression:
VIR_FROM_THIS changed from VIR_FROM_REMOTE to VIR_FROM_RPC, so the
special casing no longer works if the server uses the newer error
domain.

* src/rpc/virnetclientprogram.c
(virNetClientProgramDispatchError): Also cater to 0.9.3 and newer.

14 years agoFix buzzilla 738778
Stefan Berger [Fri, 16 Sep 2011 13:44:43 +0000 (09:44 -0400)] 
Fix buzzilla 738778

This patch fixes the bug shown in bugzilla 738778. It's not an nwfilter problem but a connection sharing / closure issue.

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

Depending on the speed / #CPUs of the machine you are using you may not see this bug all the time.

14 years agoconf: avoid memory leak on virDomainDefParseXML
Alex Jia [Fri, 16 Sep 2011 05:54:47 +0000 (13:54 +0800)] 
conf: avoid memory leak on virDomainDefParseXML

* conf/domain_conf.c: allocate memory to def->redirdevs in
  virDomainDefParseXML such as VIR_ALLOC_N(def->redirdevs, n),
  however, virDomainDefFree(def) hasn't released these memory.

* Detected in valgrind run:

==19820== 209 (16 direct, 193 indirect) bytes in 1 blocks are definitely lost in loss record 25 of 26
==19820==    at 0x4A04A28: calloc (vg_replace_malloc.c:467)
==19820==    by 0x4A13AF: virAllocN (memory.c:129)
==19820==    by 0x4D4A0E: virDomainDefParseXML (domain_conf.c:7258)
==19820==    by 0x4D4C93: virDomainDefParseNode (domain_conf.c:7512)
==19820==    by 0x4D562F: virDomainDefParse (domain_conf.c:7465)
==19820==    by 0x415863: testCompareXMLToXMLFiles (qemuxml2xmltest.c:35)
==19820==    by 0x415982: testCompareXMLToXMLHelper (qemuxml2xmltest.c:80)
==19820==    by 0x416D31: virtTestRun (testutils.c:140)
==19820==    by 0x415604: mymain (qemuxml2xmltest.c:192)
==19820==    by 0x416437: virtTestMain (testutils.c:689)
==19820==    by 0x3CA7A1ECDC: (below main) (in /lib64/libc-2.12.so)
==19820==
==19820== LEAK SUMMARY:
==19820==    definitely lost: 16 bytes in 1 blocks
==19820==    indirectly lost: 193 bytes in 5 blocks
==19820==      possibly lost: 0 bytes in 0 blocks
==19820==    still reachable: 1,054 bytes in 21 blocks

* How to reproduce?
% valgrind -v --leak-check=full ./tests/qemuxml2xmltest

Signed-off-by: Alex Jia <ajia@redhat.com>
14 years agobuild: storage: Macro 'MKFS' is undefined on some platforms.
Peter Krempa [Fri, 16 Sep 2011 12:14:16 +0000 (14:14 +0200)] 
build: storage: Macro 'MKFS' is undefined on some platforms.

Mac OS X 10.6. Snow Leopard and probably other do not provide a mkfs
command to create filesystems. Macro MKFS then remained undefined and
did not provide any substitute, so that build failed on a missing
argument.

14 years agobuild: storage: Conditionaly compiled structure caused build fail on OSX
Peter Krempa [Fri, 16 Sep 2011 12:14:15 +0000 (14:14 +0200)] 
build: storage: Conditionaly compiled structure caused build fail on OSX

Struct virStoragePoolProbeResult was compiled in conditionaly, but
virStorageBackendFileSystemProbe used it unconditionaly. This patch
exempts the struct from conditional include.

14 years agoAvoid using "devname" as an identifier.
Peter Krempa [Fri, 16 Sep 2011 12:05:58 +0000 (14:05 +0200)] 
Avoid using "devname" as an identifier.

/usr/lib/stdlib.h in Mac OS X and probably also in BSD's
exports this symbol :(

14 years agodoc: Add statment about permissions needed to do a core dump
Peter Krempa [Fri, 16 Sep 2011 10:04:40 +0000 (12:04 +0200)] 
doc: Add statment about permissions needed to do a core dump

Documentation did not specify, that some permissions are required on
target path for coredump for the user running the hypervisor.

Diff to v1:
- reword statements

14 years agosnapshot: tweak snapshot-create-as diskspec docs
Eric Blake [Wed, 14 Sep 2011 21:20:08 +0000 (15:20 -0600)] 
snapshot: tweak snapshot-create-as diskspec docs

With this patch, it is hopefully a bit more obvious that for
snapshot-create-as, a literal '--diskspec' is mandatory if name
or description was omitted, but optional if all earlier options
were provided.

These all denote two diskspecs and a description:
virsh snapshot-create-as dom name desc vda vdb
virsh snapshot-create-as dom name desc --diskspec vda --diskspec vdb
virsh snapshot-create-as dom name desc --diskspec vda vdb
virsh snapshot-create-as dom name desc vda --diskspec vdb
virsh snapshot-create-as dom --diskspec vda --diskspec vdb name desc

This gives two diskspecs but no description:
virsh snapshot-create-as dom name --diskspec vda --diskspec vdb

And this treats 'vda' as the description, with only one diskspec:
virsh snapshot-create-as dom name vda vdb

The help output now shows:
    snapshot-create-as <domain> [<name>] [<description>] [--print-xml] [--no-metadata] [--halt] [--disk-only] [[--diskspec] <string>]...

I also checked the help output for echo and send-key, which are two
other variants of argv commands.

* tools/virsh.pod (snapshot-create-as): Document when a literal
--diskspec must preceed a diskspec argument.
* tools/virsh.c (vshCmddefHelp): Update help output for argv when
naming the option is useful.
(vshCmddefGetData): Fix logic on when argv was seen.
* tests/virsh-optparse: Add tests to avoid regressions.

14 years agopython: Fix libvirt.py generation to include virterror info
Cole Robinson [Wed, 14 Sep 2011 20:25:42 +0000 (16:25 -0400)] 
python: Fix libvirt.py generation to include virterror info

Recent generator refactoring broke libvirt.py. With this patch, libvirt.py
is generated exactly the same as before offending commit 9eba0d25.

14 years agoqemu_api: doc improvements
Eric Blake [Wed, 14 Sep 2011 15:49:08 +0000 (09:49 -0600)] 
qemu_api: doc improvements

The new doc text had a few readability issues.  Also, the
monitor command text copied a bit too much from the attach case.

* src/libvirt-qemu.c (virDomainQemuMonitorCommand)
(virDomainQemuAttach): Fix typos and grammar.

14 years agodoc: virsh: Fix command name in man page
Peter Krempa [Thu, 15 Sep 2011 08:31:52 +0000 (10:31 +0200)] 
doc: virsh: Fix command name in man page

Fix cut&paste error having command named domif-setlink instead of
domif-getlink.

14 years agosanlock: add missing test command in virt-sanlock-cleanup.in
Alex Jia [Thu, 15 Sep 2011 06:13:28 +0000 (14:13 +0800)] 
sanlock: add missing test command in virt-sanlock-cleanup.in

* tools/virt-sanlock-cleanup.in: fix missing test command when judging
  second condition.

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

Signed-off-by: Alex Jia <ajia@redhat.com>
14 years agospec: Require augeas for sanlock
Michal Privoznik [Thu, 15 Sep 2011 14:55:36 +0000 (16:55 +0200)] 
spec: Require augeas for sanlock

Even though we BuildRequire augeas in some cases, we need to require
it even after if we build with sanlock. virt-sanlock-cleanup use it.

14 years agoFix build after commit 829bce17
Jim Fehlig [Wed, 14 Sep 2011 23:57:55 +0000 (17:57 -0600)] 
Fix build after commit 829bce17

Pushing under build-breaker rule.

14 years agoUse max bandwidth from qemuDomainObjPrivate struct when migrating
Jim Fehlig [Fri, 26 Aug 2011 18:10:27 +0000 (12:10 -0600)] 
Use max bandwidth from qemuDomainObjPrivate struct when migrating

Adjust qemuMigrationRun() to use migMaxBandwidth in qemuDomainObjPrivate
structure when setting qemu migration speed.  Caller-specified 'resource'
parameter overrides migMaxBandwidth.

14 years agoSet qemu migration speed unlimited when migrating to file
Jim Fehlig [Fri, 26 Aug 2011 18:10:26 +0000 (12:10 -0600)] 
Set qemu migration speed unlimited when migrating to file

The qemu migration speed default is 32MiB/s as defined in migration.c

/* Migration speed throttling */
static int64_t max_throttle = (32 << 20);

There's no need to throttle migration when targeting a file, so set migration
speed to unlimited prior to migration, and restore to libvirt default value
after migration.

Default units is MB for migrate_set_speed monitor command, so
(INT64_MAX / (1024 * 1024)) is used for unlimited migration speed.

Tested with both json and text monitors.

14 years agoSave migration speed in qemuDomainMigrateSetMaxSpeed
Jim Fehlig [Fri, 26 Aug 2011 18:10:25 +0000 (12:10 -0600)] 
Save migration speed in qemuDomainMigrateSetMaxSpeed

Now that migration speed is stored in qemuDomainObjPrivate structure,
save the new value when invoking qemuDomainMigrateSetMaxSpeed().

Allow setting migration speed on inactive domain too.

14 years agoImpl virDomainMigrateGetMaxSpeed in qemu driver
Jim Fehlig [Fri, 26 Aug 2011 18:10:23 +0000 (12:10 -0600)] 
Impl virDomainMigrateGetMaxSpeed in qemu driver

14 years agoStore max migration bandwidth in qemuDomainObjPrivate struct
Jim Fehlig [Fri, 26 Aug 2011 18:10:22 +0000 (12:10 -0600)] 
Store max migration bandwidth in qemuDomainObjPrivate struct

The maximum bandwidth that can be consumed when migrating a domain
is better classified as an operational vs configuration parameter of
the dommain.  As such, store this parameter in qemuDomainObjPrivate
structure.

14 years agoconf: add missing break in virDomainAuditRedirdev
Marc-AndrĂ© Lureau [Wed, 14 Sep 2011 20:02:30 +0000 (22:02 +0200)] 
conf: add missing break in virDomainAuditRedirdev

Also initialize to NULL a few variables that might get
free before being set.

14 years agonetwork: add missing exports
Eric Blake [Wed, 14 Sep 2011 17:55:17 +0000 (11:55 -0600)] 
network: add missing exports

Commit c246b025 added new functions, but forgot to export them,
resulting in a build failure when using modules.

* src/libvirt_private.syms (network.h): Export new functions.

14 years agosnapshot: ABI stability must include memory sizing
Eric Blake [Tue, 13 Sep 2011 20:21:10 +0000 (14:21 -0600)] 
snapshot: ABI stability must include memory sizing

Commit 973fcd8f introduced the ability for qemu to reject snapshot
reversion on an ABI incompatibility; but the very example that was
first proposed on-list[1] as a demonstration of an ABI incompatibility,
namely that of changing the max memory allocation, was not being
checked for, resulting in a cryptic failure when running with larger
max mem than what the snapshot was created with:
error: operation failed: Error -22 while loading VM state

This commit merely protects the three variables within mem that are
referenced by qemu_command.c, rather than all 7 (the other 4 variables
affect cgroup handling, but as far as I can tell, have no visible effect
to the qemu guest).  This also affects migration and save file handling,
which are other places where we perform ABI compatibility checks.

[1] https://www.redhat.com/archives/libvir-list/2010-December/msg00331.html

* src/conf/domain_conf.c (virDomainDefCheckABIStability): Add
memory sizing checks.

14 years agomaint: ignore generated files
Eric Blake [Wed, 14 Sep 2011 15:30:33 +0000 (09:30 -0600)] 
maint: ignore generated files

* .gitignore: Exempt recently added generated files.

14 years agoxml: Clean up rest of virtual XML document names for XML strings
Peter Krempa [Wed, 14 Sep 2011 14:17:57 +0000 (16:17 +0200)] 
xml: Clean up rest of virtual XML document names for XML strings

Commit 498d783 cleans up some of virtual file names for parsing strings
in memory. This patch cleans up (hopefuly) the rest forgotten by the
first patch.

This patch also changes all of the previously modified "filenames" to
valid URI's replacing spaces for underscores.

Changes to v1:
- Replace all spaces for underscores, so that the strings form valid
  URI's
- Replace spaces in places changed by commit 498d783

14 years agoRemove two references to files not generated
Daniel Veillard [Wed, 14 Sep 2011 14:57:46 +0000 (22:57 +0800)] 
Remove two references to files not generated

This was breaking "make dist"

14 years agomake: Fix 'make syntax-check' failing.
Peter Krempa [Wed, 14 Sep 2011 12:20:07 +0000 (14:20 +0200)] 
make: Fix 'make syntax-check' failing.

Commit 2a0d75e5 added file python/libvirt-qemu-override.c that contains
code that does not pass "make syntax-check". This patch adds an
exception for this file and the check.

prohibit_always_true_header_tests
python/libvirt-qemu-override.c:17:#undef HAVE_PTHREAD_H
maint.mk: do not test the above HAVE_<header>_H symbol(s);
  with the corresponding gnulib module, they are always true
make: *** [sc_prohibit_always_true_header_tests] Error 1

14 years agoqemu_api: Update libvirt spec file v0.9.5-rc2
Osier Yang [Fri, 9 Sep 2011 11:11:36 +0000 (19:11 +0800)] 
qemu_api: Update libvirt spec file

14 years agoqemu_api: Update Makefile to generate libvirtmod_qemu lib
Osier Yang [Fri, 9 Sep 2011 11:10:43 +0000 (19:10 +0800)] 
qemu_api: Update Makefile to generate libvirtmod_qemu lib

14 years agoqemu_api: Update Py binding generator to generate files for QEMU APIs
Osier Yang [Fri, 9 Sep 2011 11:09:44 +0000 (19:09 +0800)] 
qemu_api: Update Py binding generator to generate files for QEMU APIs

It will generate:
  libvirt-qemu.py
  libvirt-qemu.h
  libvirt-qemu.c
  libvirt-qemu-export.c

14 years agoqemu_api: Add override XML and C files for QEMU APIs
Osier Yang [Fri, 9 Sep 2011 11:07:56 +0000 (19:07 +0800)] 
qemu_api: Add override XML and C files for QEMU APIs

There is only one function (virDomainQemuMonitorCommand) need to
be hand-craft.

14 years agoqemu_api: Add comments for API virDomainQemuMonitorCommand
Osier Yang [Fri, 9 Sep 2011 11:00:09 +0000 (19:00 +0800)] 
qemu_api: Add comments for API virDomainQemuMonitorCommand

And fix argument @pid's type of virDomainQemuAttach.

14 years agoqemu_api: Update Makefile for subdir docs
Osier Yang [Wed, 14 Sep 2011 03:38:39 +0000 (11:38 +0800)] 
qemu_api: Update Makefile for subdir docs

14 years agoqemu_api: Modify apibuild.py to generate docs for QEMU APIs
Osier Yang [Fri, 9 Sep 2011 10:55:21 +0000 (18:55 +0800)] 
qemu_api: Modify apibuild.py to generate docs for QEMU APIs

The generated docs are: libvirt-qemu-api.xml, libvirt-qemu-refs.xml