]> xenbits.xensource.com Git - people/dariof/libvirt.git/log
people/dariof/libvirt.git
12 years agobuild: avoid C99 for loop
Eric Blake [Mon, 26 Nov 2012 16:25:21 +0000 (09:25 -0700)]
build: avoid C99 for loop

Although we require various C99 features, we don't yet require a
complete C99 compiler.  On RHEL 5, compilation complained:

qemu/qemu_command.c: In function 'qemuBuildGraphicsCommandLine':
qemu/qemu_command.c:4688: error: 'for' loop initial declaration used outside C99 mode

* src/qemu/qemu_command.c (qemuBuildGraphicsCommandLine): Declare
variable sooner.
* src/qemu/qemu_process.c (qemuProcessInitPasswords): Likewise.

12 years agoRefactor ESX storage driver to implement facade pattern
Ata E Husain Bohra [Sat, 10 Nov 2012 07:18:07 +0000 (23:18 -0800)]
Refactor ESX storage driver to implement facade pattern

The patch refactors the current ESX storage driver due to following reasons:

1. Given most of the public APIs exposed by the storage driver in Libvirt
remains same, ESX storage driver should not implement logic specific
for only one supported format (current implementation only supports VMFS).
2. Decoupling interface from specific storage implementation gives us an
extensible design to hook implementation for other supported storage
formats.

This patch refactors the current driver to implement it as a facade pattern i.e.
the driver exposes all the public libvirt APIs, but uses backend drivers to get
the required task done. The backend drivers provide implementation specific to
the type of storage device.

File changes:
------------------
esx_storage_driver.c ----> esx_storage_driver.c (base storage driver)
                     |
                     |---> esx_storage_backend_vmfs.c (VMFS backend)

12 years agolxc: Don't crash if no security driver is specified in libvirt_lxc
Peter Krempa [Mon, 26 Nov 2012 14:17:58 +0000 (15:17 +0100)]
lxc: Don't crash if no security driver is specified in libvirt_lxc

When no security driver is specified libvirt_lxc segfaults as a debug
message tries to access security labels for the container that are not
present.

This problem was introduced in commit 6c3cf57d6cb27cf10064baf8cca0f39.

12 years agolxc: Avoid segfault of libvirt_lxc helper on early cleanup paths
Peter Krempa [Mon, 26 Nov 2012 11:13:56 +0000 (12:13 +0100)]
lxc: Avoid segfault of libvirt_lxc helper on early cleanup paths

Early jumps to the cleanup label caused a crash of the libvirt_lxc
container helper as the cleanup section called
virLXCControllerDeleteInterfaces(ctrl) without checking the ctrl argument
for NULL. The argument was de-referenced soon after.

$ /usr/libexec/libvirt_lxc
/usr/libexec/libvirt_lxc: missing --name argument for configuration
Segmentation fault

12 years agoAdd private data pointer to virStoragePool and virStorageVol
Ata E Husain Bohra [Sat, 10 Nov 2012 07:18:07 +0000 (23:18 -0800)]
Add private data pointer to virStoragePool and virStorageVol

This will simplify the refactoring of the ESX storage driver to support
a VMFS and an iSCSI backend.

One of the tasks the storage driver needs to do is to decide which backend
driver needs to be invoked for a given request. This approach extends
virStoragePool and virStorageVol to store extra parameters:

1. privateData: stores pointer to respective backend storage driver.
2. privateDataFreeFunc: stores cleanup function pointer.

virGetStoragePool and virGetStorageVol are modfied to accept these extra
parameters as user params. virStoragePoolDispose and virStorageVolDispose
checks for cleanup operation if available.

The private data pointer allows the ESX storage driver to store a pointer
to the used backend with each storage pool and volume. This avoids the need
to detect the correct backend in each storage driver function call.

12 years agocpu: Add Intel Haswell cpu model
Peter Krempa [Tue, 30 Oct 2012 15:16:10 +0000 (16:16 +0100)]
cpu: Add Intel Haswell cpu model

The new model supports following features in addition to those supported
by SandyBridge:

fma, pcid, movbe, fsgsbase, bmi1, hle, avx2, smep, bmi2, erms, invpcid,
rtm

12 years agostorage: fix logical volume cloning
Ján Tomko [Sun, 25 Nov 2012 01:59:33 +0000 (02:59 +0100)]
storage: fix logical volume cloning

Commit 258e06c removed setting of the volume type to
VIR_STORAGE_VOL_BLOCK, which leads to failures in
storageVolumeCreateXMLFrom.

The type (and target.format) of the volume was set to zero. In
virStorageBackendGetBuildVolFromFunction, this gets interpreted as
VIR_STORAGE_FILE_NONE and the qemu-img tool is called with unknown
"none" format.

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

12 years agobuild: fix build --without-network
Ján Tomko [Wed, 21 Nov 2012 13:59:47 +0000 (14:59 +0100)]
build: fix build --without-network

bridge_driver.h: silence gcc warnings:
statement with no effect [-Wunused-value]
unused variable 'net' [-Wunused-variable]

virdrivermoduletest.c: don't require network driver module
if it hasn't been built.

12 years agoutil: Use virReportSystemError for system error in pci.c
Osier Yang [Fri, 23 Nov 2012 08:02:07 +0000 (16:02 +0800)]
util: Use virReportSystemError for system error in pci.c

12 years agoutil: Fix the indention
Osier Yang [Sun, 25 Nov 2012 15:21:58 +0000 (23:21 +0800)]
util: Fix the indention

12 years agovirsh: Report error when taking a snapshot with empty --memspec argument
Peter Krempa [Thu, 22 Nov 2012 10:00:14 +0000 (11:00 +0100)]
virsh: Report error when taking a snapshot with empty --memspec argument

When the value of memspec was empty taking of a snapshot failed without
reporting an error.

12 years agoFix exiting of libvirt_lxc program on container quit
Daniel P. Berrange [Thu, 22 Nov 2012 16:45:39 +0000 (16:45 +0000)]
Fix exiting of libvirt_lxc program on container quit

The virLXCControllerClientCloseHook method was mistakenly
assuming that the private data associated with the network
client was the virLXCControllerPtr. In fact it was just a
dummy int, so we were derefencing a bogus struct. The
frequent result of this was that we would never quit, because
we tried to arm a non-existant timer.

Fix the code by removing the dummy private data and just
using the virLXCControllerPtr instance as private data

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoSkip deleted timers when calculting next timeout
Daniel P. Berrange [Thu, 22 Nov 2012 16:43:57 +0000 (16:43 +0000)]
Skip deleted timers when calculting next timeout

It is possible for there to be deleted timers when we
calculate the next timeout, and they must be skipped.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoWarn if requesting update to non-existent timer/handle watch
Daniel P. Berrange [Thu, 22 Nov 2012 16:42:30 +0000 (16:42 +0000)]
Warn if requesting update to non-existent timer/handle watch

The event code is a no-op if requested to update a non-existent
timer/handle watch. This makes it hard to detect bugs in the
caller who have passed bogus data. Add a VIR_WARN output in
such cases, since the API does not allow for return errors.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix virDiskNameToIndex to actually ignore partition numbers
Daniel P. Berrange [Thu, 22 Nov 2012 14:56:08 +0000 (14:56 +0000)]
Fix virDiskNameToIndex to actually ignore partition numbers

The docs for virDiskNameToIndex claim it ignores partition
numbers. In actual fact though, a code ordering bug means
that a partition number will cause the code to accidentally
multiply the result by 26.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoqemuhelpdata: Revert my 'fix'
Michal Privoznik [Fri, 23 Nov 2012 08:25:20 +0000 (09:25 +0100)]
qemuhelpdata: Revert my 'fix'

I was convicted that space at EOL should no be there
even for qemu help data. Hence, I've removed one in
commit bb2f6216119d50. However, it turns out we want
it exactly the way qemu produces it. So I should undo
my premature fix. A patch against qemu has been posted
as well.

12 years agoqemu: Stop recursive detection of image chains when an image is missing
Peter Krempa [Wed, 21 Nov 2012 10:57:22 +0000 (11:57 +0100)]
qemu: Stop recursive detection of image chains when an image is missing

Commit e0c469e58b93f852a72265919703cb6abd3779f8 that fixes the detection
of image chain wasn't complete. Iteration through the backing image
chain has to stop at the last existing image if some of the images are
missing otherwise the backing chain that is cached contains entries with
paths being set to NULL resulting to:

error: Unable to allow access for disk path (null): Bad address

Fortunately stat() is kind enough not to crash when it's presented with
a NULL argument. At least on Linux.

12 years agoconf: Report sensible error for invalid disk name
Martin Kletzander [Tue, 20 Nov 2012 13:45:56 +0000 (14:45 +0100)]
conf: Report sensible error for invalid disk name

The error "... but the cause is unknown" appeared for XMLs similar to
this:

 <disk type='file' device='cdrom'>
   <driver name='qemu' type='raw'/>
   <source file='/dev/zero'/>
   <target dev='sr0'/>
 </disk>

Notice unsupported disk type (for the driver), but also no address
specified. The first part is not a problem and we should not abort
immediately because of that, but the combination with the address
unknown was causing an unspecified error.

While fixing this, I added an error to one place where this return
value was not managed properly.

12 years agobuild: trivial fix error: implicit declaration of function 'malloc'
Natanael Copa [Thu, 22 Nov 2012 12:28:08 +0000 (13:28 +0100)]
build: trivial fix error: implicit declaration of function 'malloc'

Fixes this error when building with -Werror on Alpine Linux:

util/processinfo.c: In function 'virProcessInfoSetAffinity':
util/processinfo.c:52:5: error: implicit declaration of function 'malloc' [-Werror=implicit-function-declaration]

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
12 years agoLog an audit message with the LXC init pid
Daniel P. Berrange [Tue, 20 Nov 2012 17:49:25 +0000 (17:49 +0000)]
Log an audit message with the LXC init pid

Currently the LXC driver logs audit messages when a container
is started or stopped. These audit messages, however, contain
the PID of the libvirt_lxc supervisor process. To enable
sysadmins to correlate with audit messages generated by
processes /inside/ the container, we need to include the
container init process PID.

We can't do this in the main 'start' audit message, since
the init PID is not available at that point. Instead we output
a completely new audit record, that lists both PIDs.

type=VIRT_CONTROL msg=audit(1353433750.071:363): pid=20180 uid=0 auid=501 ses=3 subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 msg='virt=lxc op=init vm="busy" uuid=dda7b947-0846-1759-2873-0f375df7d7eb vm-pid=20371 init-pid=20372 exe="/home/berrange/src/virt/libvirt/daemon/.libs/lt-libvirtd" hostname=? addr=? terminal=pts/6 res=success'

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoUse virNetServerRun instead of custom main loop
Daniel P. Berrange [Fri, 16 Nov 2012 09:11:23 +0000 (09:11 +0000)]
Use virNetServerRun instead of custom main loop

The LXC controller code currently directly invokes the
libvirt main loop code. The problem is that this misses
the cleanup of virNetServerClient connections that
virNetServerRun takes care of.

The result is that when libvirtd is stopped, the
libvirt_lxc controller process gets stuck in a I/O loop.
When libvirtd is then started again, it fails to connect
to the controller and thus kills off the entire domain.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agostorage: Improve virStorageBackendFileSystemStop
Osier Yang [Wed, 21 Nov 2012 02:41:02 +0000 (10:41 +0800)]
storage: Improve virStorageBackendFileSystemStop

It's actually not used for DIR pool. So removing the checking.

12 years agostorage: Fix bug of fs pool destroying
Osier Yang [Wed, 21 Nov 2012 03:22:39 +0000 (11:22 +0800)]
storage: Fix bug of fs pool destroying

Regression introduced by commit 258e06c85b7, "ret" could be set to 1
or 0 by virStorageBackendFileSystemIsMounted before goto cleanup.
This could mislead the callers (up to the public API
virStoragePoolDestroy) to return success even the underlying umount
command fails.

12 years agoqemu: fix RBD attach regression
Scott Sullivan [Wed, 21 Nov 2012 18:06:25 +0000 (13:06 -0500)]
qemu: fix RBD attach regression

I have been testing libvirt v1.0.0 for deployment within my
organization, and in the process discovered what appears to be a bug
that breaks virsh attach-device, when attaching an RBD volume to an
instance. First, here is the error presented, with v1.0.0 (this worked
in v0.10.2):

[root@host ~]# virsh attach-device W5APQ8  G84VV1.xml
error: Failed to attach device from G84VV1.xml
error: cannot open file 'dc3-1-test/G84VV1': No such file or directory

Using git bisect, I narrowed the problem down to this as the first
commit to break this setup:

4d34c92947e8cf9e9bedfa227ada1d2dba92d68a is the first bad commit

12 years agotests: update qemuhelptest data
Ján Tomko [Tue, 20 Nov 2012 18:47:10 +0000 (19:47 +0100)]
tests: update qemuhelptest data

Both generated with
qemu-system-x86_64 --help > qemu-1.2.0

qemu-system-x86_64 \
-device ? \
-device pci-assign,? \
-device virtio-blk-pci,? \
-device virtio-net-pci,? \
-device scsi-disk,? \
-device PIIX4_PM,? \
-device usb-redir,? \
-device ide-drive,? \
-device usb-host,? 2> qemu-1.2.0-device

It seems I missed a few -device flags when doing this last time and I
mixed up qemu and qemu-kvm.

12 years agotests: add boot order for host and redirected USB to qemu argv test
Ján Tomko [Tue, 20 Nov 2012 18:47:09 +0000 (19:47 +0100)]
tests: add boot order for host and redirected USB to qemu argv test

12 years agodocs: Fix a few spaces
Ján Tomko [Wed, 21 Nov 2012 17:22:37 +0000 (18:22 +0100)]
docs: Fix a few spaces

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
12 years agodocs: boot order for host and redirected USB devices
Ján Tomko [Wed, 21 Nov 2012 17:21:09 +0000 (18:21 +0100)]
docs: boot order for host and redirected USB devices

12 years agoconf: add support for booting from redirected USB devices
Ján Tomko [Tue, 20 Nov 2012 18:47:07 +0000 (19:47 +0100)]
conf: add support for booting from redirected USB devices

Commit a4c19459aa8634c43b51e8138fb1d7eec4c17824 only added the
QEMU capability flag, command line option and added the boot element
for redirdev's in the XML schema.

This patch adds support for parsing and writing the XML with redirdevs
with the boot flag. It also ignores unknown XML elements in redirdev
instead of failing with:
"error: An error occurred, but the cause is unknown"

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

12 years agorun bootstrap if .gnulib is not present
Hu Tao [Fri, 9 Nov 2012 08:47:04 +0000 (16:47 +0800)]
run bootstrap if .gnulib is not present

If .gnulib is deleted unexpectedly, autogen.sh will fail with message:

fatal: ambiguous argument '.gnulib': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

which is actually given by git diff .gnulib, which doesn't exist.

In the case to run bootstrap to create .gnulib.

12 years agoqemu/qemu_command.c: fix indent of label
Alon Levy [Sat, 10 Nov 2012 01:40:25 +0000 (02:40 +0100)]
qemu/qemu_command.c: fix indent of label

12 years agoqemu: graphics support for simultaneous one of each sdl, vnc, spice
Alon Levy [Sat, 10 Nov 2012 01:40:24 +0000 (02:40 +0100)]
qemu: graphics support for simultaneous one of each sdl, vnc, spice

12 years agoqemu: refactor graphics code to not hardcode a single display
Alon Levy [Sat, 10 Nov 2012 01:40:23 +0000 (02:40 +0100)]
qemu: refactor graphics code to not hardcode a single display

The check for a single display remains so no new functionality is added.

12 years agosnapshot: make cloning of domain definition easier
Eric Blake [Thu, 15 Nov 2012 20:40:25 +0000 (13:40 -0700)]
snapshot: make cloning of domain definition easier

Upcoming patches for revert-and-clone branching of snapshots need
to be able to copy a domain definition; make this step reusable.

* src/conf/domain_conf.h (virDomainDefCopy): New prototype.
* src/conf/domain_conf.c (virDomainObjCopyPersistentDef): Split...
(virDomainDefCopy): ...into new function.
(virDomainObjSetDefTransient): Use it.
* src/libvirt_private.syms (domain_conf.h): Export it.
* src/qemu/qemu_driver.c (qemuDomainRevertToSnapshot): Use it.

12 years agosnapshot: expose location through virsh snapshot-info
Eric Blake [Tue, 13 Nov 2012 17:40:28 +0000 (10:40 -0700)]
snapshot: expose location through virsh snapshot-info

Now that we can filter on this information, we should also make
it easy to get at.

* tools/virsh-snapshot.c (cmdSnapshotInfo): Add another output
row, and switch to XPath queries rather than strstr.

12 years agosnapshot: implement new filter sets
Eric Blake [Tue, 13 Nov 2012 18:32:19 +0000 (11:32 -0700)]
snapshot: implement new filter sets

Relatively straight-forward.  And since qemu was already using
VIR_DOMAIN_SNAPSHOT_FILTERS_ALL, with 6 different APIs all calling
into this common code, I've instantly added all 5 flags to 6 APIs.

* src/conf/snapshot_conf.h (VIR_DOMAIN_SNAPSHOT_FILTERS_ALL):
Enable new filters.
* src/conf/snapshot_conf.c (virDomainSnapshotObjListGetNames):
Prep the new flags.
(virDomainSnapshotObjListCopyNames): Actually do the filtering.

12 years agosnapshot: add virsh back-compat support for new filters
Eric Blake [Tue, 13 Nov 2012 16:40:37 +0000 (09:40 -0700)]
snapshot: add virsh back-compat support for new filters

Snapshot filtering based on types is useful enough to add
back-compat support into virsh.  It is also rather easy - all
versions of libvirt that don't understand the new filter flags
already gave us sufficient information in a single XML field
to reconstruct all the information we need (that is, it isn't
until libvirt 1.0.1 that we have more interesting types of
snapshots, such as offline external).

* tools/virsh-snapshot.c (vshSnapshotFilter): New function.
(vshSnapshotListCollect): Add fallback support.

12 years agosnapshot: add two more filter sets to API
Eric Blake [Mon, 12 Nov 2012 17:29:14 +0000 (10:29 -0700)]
snapshot: add two more filter sets to API

As we enable more modes of snapshot creation, it becomes more important
to be able to quickly filter based on snapshot properties.  This patch
introduces new filter flags; subsequent patches will introduce virsh
back-compat filtering, as well as actual libvirt filtering.

* include/libvirt/libvirt.h.in (virDomainSnapshotListFlags): Add
five new flags in two new groups.
* src/libvirt.c (virDomainSnapshotNum, virDomainSnapshotListNames)
(virDomainListAllSnapshots, virDomainSnapshotNumChildren)
(virDomainSnapshotListChildrenNames)
(virDomainSnapshotListAllChildren): Document them.
* src/conf/snapshot_conf.h (VIR_DOMAIN_SNAPSHOT_FILTERS_STATUS)
(VIR_DOMAIN_SNAPSHOT_FILTERS_LOCATION): Add new convenience filter
collection macros.
* tools/virsh-snapshot.c (cmdSnapshotList): Add 5 new flags.
* tools/virsh.pod (snapshot-list): Document them.

12 years agoqemu: allow larger discrepency between memory & currentMemory in domain xml
Laine Stump [Fri, 16 Nov 2012 15:53:04 +0000 (10:53 -0500)]
qemu: allow larger discrepency between memory & currentMemory in domain xml

This resolves:

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

The reported problem is that an attempt to restore a saved domain that
was configured with <currentMemory> and <memory> set to some (same for
both) number that's not a multiple of 4096KiB results in an error like
this:

  error: Failed to start domain libvirt_test_api
  error: XML error: current memory '4001792k' exceeds maximum '4000768k'

(in this case, currentMemory was set to 4000000KiB).

The reason for this failure is:

1) a saved image contains the "live xml" of the domain at the time of
the save.

2) the live xml of a running domain gets its currentMemory
(a.k.a. cur_balloon) directly from the qemu monitor rather than from
the configuration of the domain.

3) the value reported by qemu is (sometimes) not exactly what was
originally given to qemu when the domain was started, but is rounded
up to [some indeterminate granularity] - in some versions of qemu that
granularity is apparently 1MiB, and in others it is 4MiB.

4) When the XML is parsed to setup the state of the restored domain,
the XML parser for <currentMemory> compares it to <memory> (which is
the maximum allowed memory size for the domain) and if <currentMemory>
is greater than the next 1024KiB boundary above <memory>, it spits out
an error and fails.

For example (from the BZ) if you start qemu on RHEL6 with both
<currentMemory> and <memory> of 4000000 (this number is in KiB),
libvirt's dominfo or dumpxml will report "4001792" back (rounded up to
next 4MiB) for 10-20 seconds after the start, then revert to reporting
"4000000". On Fedora 16 (which uses qemu-1.0), it will instead report
"4000768" (rounded up to next 1MiB). On Fedora 17 (qemu-1.2), it seems
to always report "4000000". ("4000000" is of course okay, and
"4000768" is also okay since that's the next 1024KiB boundary above
"4000000" and the parser was already allowing for that. But "4001792
is *not* okay and produces the error message.)

This patch solves the problem by changing the allowed "fudge factor"
when parsing from 1024KiB to 4096KiB to match the maximum up-rounding
that could be done in qemu.

(I had earlier thought to fix this by up-rounding <memory> in the
dumpxml that's put into the saved image, but that wouldn't have fixed
the case where the save image was produced by an "unfixed"
libvirtd.)

12 years agoadd ppc64 and s390x to arches where qemu-kvm exists
Dan Horák [Fri, 16 Nov 2012 17:50:20 +0000 (18:50 +0100)]
add ppc64 and s390x to arches where qemu-kvm exists

QEMU in Fedora >= 18 is configured with ppc64 and s390x as architectures
where KVM is enabled.

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

12 years agonodeinfo: port nodecpumap to RHEL5
Eric Blake [Thu, 15 Nov 2012 14:04:33 +0000 (07:04 -0700)]
nodeinfo: port nodecpumap to RHEL5

Prior to this patch, 'virsh nodecpumap' on older kernels reported:
error: Unable to get cpu map
error: out of memory

* src/nodeinfo.c (linuxParseCPUmax): Don't overwrite error.
(nodeGetCPUBitmap): Provide backup implementation.

12 years agonodeinfo: support kernels that lack socket information
Eric Blake [Thu, 1 Nov 2012 22:20:09 +0000 (16:20 -0600)]
nodeinfo: support kernels that lack socket information

On RHEL 5, I was getting a segfault trying to start libvirtd,
because we were failing virNodeParseSocket but not checking
for errors, and then calling CPU_SET(-1, &sock_map) as a result.
But if you don't have a topology/physical_package_id file,
then you can just assume that the cpu belongs to socket 0.

* src/nodeinfo.c (virNodeGetCpuValue): Change bool into
default_value.
(virNodeParseSocket): Allow for default value when file is missing,
different from fatal error on reading file.
(virNodeParseNode): Update call sites to fail on error.

12 years agoRevert "virsh: add aliases 'boot', 'stop', and 'restart'"
Eric Blake [Fri, 16 Nov 2012 15:23:17 +0000 (08:23 -0700)]
Revert "virsh: add aliases 'boot', 'stop', and 'restart'"

This reverts commits 5f63a5cb42642f945696c51bbce7fdc160325510
and ff86b0c97b0525a2cd26048a0dbf16e600aaeb7b.  After much list
discussion, consensus was that libvirt aliases should be reserved
to correct typos, otherwise it risks confusion.  Rather, we
should implement a way for users to provide their own aliases
as part of their virsh configuration preferences.

12 years agosnapshot: require user to supply external memory file name
Eric Blake [Thu, 15 Nov 2012 23:38:13 +0000 (16:38 -0700)]
snapshot: require user to supply external memory file name

For disk snapshots, the user could request an external snapshot
but not supply a filename; later on, we would check this condition
and generate a suitable name if possible, or gracefully error out
when not possible (such as when the original file was a block
device).  But unless we come up with a suitable way to generate
external memory file names, we have no later code point that was
checking for NULL, so we should forbid this up front.

* src/conf/snapshot_conf.c (virDomainSnapshotDefParseString):
Avoid NULL deref, since we don't generate names yet.

12 years agoqemu: Beautify code indent in migration codes
liguang [Fri, 16 Nov 2012 08:03:42 +0000 (16:03 +0800)]
qemu: Beautify code indent in migration codes

Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
12 years agosanlock: Retry after EINPROGRESS
Michal Privoznik [Thu, 15 Nov 2012 10:19:08 +0000 (11:19 +0100)]
sanlock: Retry after EINPROGRESS

It may take some time for sanlock to add a lockspace. And if user
restart libvirtd service meanwhile, the fresh daemon can fail adding
the same lockspace with EINPROGRESS. Recent sanlock has
sanlock_inq_lockspace() function which should block until lockspace
changes state. If we are building against older sanlock we should
retry a few times before claiming an error. This issue can be easily
reproduced:

for i in {1..1000} ; do echo $i; service libvirtd restart; sleep 2; done
20
Stopping libvirtd daemon:                                  [FAILED]
Starting libvirtd daemon:                                  [  OK  ]
21
Stopping libvirtd daemon:                                  [  OK  ]
Starting libvirtd daemon:                                  [  OK  ]
22
Stopping libvirtd daemon:                                  [  OK  ]
Starting libvirtd daemon:                                  [  OK  ]

 error : virLockManagerSanlockSetupLockspace:334 : Unable to add
 lockspace /var/lib/libvirt/sanlock/__LIBVIRT__DISKS__: Operation now in
 progress

12 years agovirsh: save: report an error if XML file can't be read
Ján Tomko [Thu, 15 Nov 2012 13:25:09 +0000 (14:25 +0100)]
virsh: save: report an error if XML file can't be read

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

12 years agovirsh: Use virNodeGetCPUMap if possible
Viktor Mihajlovski [Tue, 13 Nov 2012 12:54:39 +0000 (13:54 +0100)]
virsh: Use virNodeGetCPUMap if possible

Modified the places where virNodeGetInfo was used for the purpose
of obtaining the maximum node CPU number. Transparently falling
back to virNodeGetInfo in case of failure.
Wrote utility function vshNodeGetCPUCount to compute node CPU
number.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
12 years agopython: Use virNodeGetCPUMap where possible
Viktor Mihajlovski [Tue, 13 Nov 2012 12:54:38 +0000 (13:54 +0100)]
python: Use virNodeGetCPUMap where possible

Modified the places where virNodeGetInfo was used for the purpose
of obtaining the maximum node CPU number. Transparently falling
back to virNodeGetInfo in case of failure.
Wrote a utility function getPyNodeCPUCount for that purpose.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
12 years agoqemu, lxc: Change host CPU number detection logic.
Viktor Mihajlovski [Tue, 13 Nov 2012 12:54:37 +0000 (13:54 +0100)]
qemu, lxc: Change host CPU number detection logic.

The drivers for QEMU and LXC use virNodeGetInfo only to determine
the number of host CPUs. On Linux hosts nodeGetCPUCount has less
overhead.

12 years agovirsh: fix uninitialized variable in cmdSnapshotEdit
Ján Tomko [Thu, 15 Nov 2012 10:37:32 +0000 (11:37 +0100)]
virsh: fix uninitialized variable in cmdSnapshotEdit

If the domain can't be looked up, name is used unitialized after the
cleanup label.

Found by coverity.

12 years agonodeinfo: enable nodeGetCPUCount for older kernels
Viktor Mihajlovski [Tue, 13 Nov 2012 12:54:36 +0000 (13:54 +0100)]
nodeinfo: enable nodeGetCPUCount for older kernels

Since /sys/devices/system/cpu/present is not available on
older kernels like on RHEL 5.x nodeGetCPUCount will
fail there. The fallback implemented is to scan for
/sys/devices/system/cpu/cpuNN entries.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
12 years agoUse helper functions to format the journal iov array
Miloslav Trmač [Wed, 17 Oct 2012 18:17:16 +0000 (20:17 +0200)]
Use helper functions to format the journal iov array

This simplifies the top-level code, at the cost of using a little more
stack space.  The primary benefit is being able to send more fields
without knowing in advance how many of them, and of which types, these
fields will be, and without having to individually add buffer variables.

The code imposes an upper limit on the total number of iovs/buffers
used, and fields that wouldn't fit are silently dropped.  This is not
significant in this patch, but will affect the following one.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
12 years agoAdd metadata to virLogOutputFunc
Miloslav Trmač [Wed, 17 Oct 2012 18:17:15 +0000 (20:17 +0200)]
Add metadata to virLogOutputFunc

... and update all users.  No change in functionality, the parameter
will be used in the next patch.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
12 years agoAdd a metadata parameter to virLog{, V}Message
Miloslav Trmač [Wed, 17 Oct 2012 18:17:14 +0000 (20:17 +0200)]
Add a metadata parameter to virLog{, V}Message

... and update all users.  No change in functionality, the parameter
will be used later.

The metadata representation is as minimal as possible, but requires
the caller to allocate an array on stack explicitly.

The alternative of using varargs in the virLogMessage() callers:
* Would not allow the caller to optionally omit some metadata elements,
  except by having two calls to virLogMessage.
* Would not be as type-safe (e.g. using int vs. size_t), and the compiler
  wouldn't be able to do type checking
* Depending on parameter order:
  a) virLogMessage(..., message format, message params...,
                   metadata..., NULL)
     can not be portably implemented (parse_printf_format() is a glibc
     function)
  b) virLogMessage(..., metadata..., NULL,
                   message format, message params...)
     would prevent usage of ATTRIBUTE_FMT_PRINTF and the associated
     compiler checking.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
12 years agoqemu: add bootindex for usb-host and usb-redir devices
Ján Tomko [Wed, 14 Nov 2012 14:51:30 +0000 (15:51 +0100)]
qemu: add bootindex for usb-host and usb-redir devices

Allow bootindex to be specified for redirected USB devices and host USB
devices.

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

12 years agoDoug Goldstein gained commit capability
Daniel Veillard [Thu, 15 Nov 2012 01:34:01 +0000 (09:34 +0800)]
Doug Goldstein gained commit capability

12 years agobuild: rerun bootstrap if AUTHORS is missing
Eric Blake [Wed, 14 Nov 2012 20:20:55 +0000 (13:20 -0700)]
build: rerun bootstrap if AUTHORS is missing

Ever since commit 7b21981c started generating AUTHORS, we now have
the situation that if you flip between two branches in the same
git repository that cross that commit boundary, then 'make' will
fail due to automake complaining about AUTHORS not existing.  The
simplest solution is to realize that if AUTHORS does not exist,
then we flipped branches so we will need to rerun bootstrap
anyways; and rerunning bootstrap ensures AUTHORS will exist in time.

* cfg.mk (_update_required): Also depend on AUTHORS.

12 years agoutil: fix index when building lock owners array
Laine Stump [Wed, 14 Nov 2012 17:07:13 +0000 (12:07 -0500)]
util: fix index when building lock owners array

The "restart" function for locks allocates a new array according to
and pre-sets its length, then reads the owner pids from a JSON
document in a loop. Rather than adding each owner at a different
index, though, it repeatedly overwrites the last element of the array
with all the owners.

12 years agoFix uninitialized variable in virLXCControllerSetupDevPTS
Daniel P. Berrange [Wed, 14 Nov 2012 15:39:48 +0000 (15:39 +0000)]
Fix uninitialized variable in virLXCControllerSetupDevPTS

The lack of initialization of 'opts' caused a SEGV in the
cleanup: path if the root->src directory did not exist

12 years agoqemu: Don't force port=0 for SPICE
Michal Privoznik [Mon, 12 Nov 2012 17:03:24 +0000 (18:03 +0100)]
qemu: Don't force port=0 for SPICE

If domain uses only TLS port we don't want to add
'port=0' explicitly to command line.

12 years agosnapshot: qemu: Fix detection of external snapshots when deleting
Peter Krempa [Fri, 19 Oct 2012 09:55:36 +0000 (11:55 +0200)]
snapshot: qemu: Fix detection of external snapshots when deleting

This patch adds a helper to determine if snapshots are external and uses
the helper to fix detection of those in snapshot deletion code.

Snapshots are external if they have an external memory image or if the
disk locations are external. As mixed snapshots are forbidden for now
we need to check just one disk to know.

12 years agotests: Remove temporary directories in qemumonitorjsontest
Peter Krempa [Mon, 12 Nov 2012 14:33:55 +0000 (15:33 +0100)]
tests: Remove temporary directories in qemumonitorjsontest

qemumonitorjsontest creates a temporary directory to hold the socket
that is simulating the monitor socket. The directory containing the
socket wasn't disposed properly at the end of the test leaving garbage
in the temporary folder.

12 years agotests: Fix qemumonitorjsontest deadlock when the machine is under load
Peter Krempa [Mon, 12 Nov 2012 10:34:41 +0000 (11:34 +0100)]
tests: Fix qemumonitorjsontest deadlock when the machine is under load

When doing the qemumonitorjsontest on a machine under heavy load the
test tends to deadlock from time to time. This patch adds the hack to
break the event loop that is used in virsh.

12 years agonodeinfotest: Add test data from a AMD bulldozer machine.
Peter Krempa [Wed, 7 Nov 2012 14:50:56 +0000 (15:50 +0100)]
nodeinfotest: Add test data from a AMD bulldozer machine.

The AMD Bulldozer architecture uses so called "Clustered integer core
modules" that count both as threads and cores. This patch expects the
cpu to be detected using the new fallback condition otherwise twice the
number of processors would be detected.

12 years agonodeinfotest: Add test data for 2 processor host with broken NUMA
Peter Krempa [Wed, 7 Nov 2012 14:19:47 +0000 (15:19 +0100)]
nodeinfotest: Add test data for 2 processor host with broken NUMA

This test data was gathered on an AMD MagnyCours machine that reports it
has only one NUMA node although the hardware is consisting of 4. As
duplicate core id's are ignored the reported topology was bogous. This
should be fixed by the previous patch.

Reported and data provided by George-Cristian Bîrzan.

12 years agonodeinfo: Add check and workaround to guarantee valid cpu topologies
Peter Krempa [Wed, 7 Nov 2012 13:53:36 +0000 (14:53 +0100)]
nodeinfo: Add check and workaround to guarantee valid cpu topologies

Lately there were a few reports of the output of the virsh nodeinfo
command being inaccurate. This patch tries to avoid that by checking if
the topology actually makes sense. If it doesn't we then report a
synthetic topology that indicates to the user that the host capabilities
should be checked for the actual topology.

12 years agoAbortJob: Fix documentation
Michal Privoznik [Thu, 8 Nov 2012 14:11:41 +0000 (15:11 +0100)]
AbortJob: Fix documentation

This API was never synchronous and probably doesn't even need to be.

12 years agoqemu: Allow migration to be cancelled at prepare phase
Michal Privoznik [Thu, 8 Nov 2012 13:49:55 +0000 (14:49 +0100)]
qemu: Allow migration to be cancelled at prepare phase

Currently, if user calls virDomainAbortJob we just issue
'migrate_cancel' and hope for the best. However, if user calls
the API in wrong phase when migration hasn't been started yet
(perform phase) the cancel request is just ignored. With this
patch, the request is remembered and as soon as perform phase
starts, migration is cancelled.

12 years agocapabilities: defaultConsoleTargetType can depend on architecture
Viktor Mihajlovski [Fri, 9 Nov 2012 15:00:36 +0000 (16:00 +0100)]
capabilities: defaultConsoleTargetType can depend on architecture

For S390, the default console target type cannot be of type 'serial'.
It is necessary to at least interpret the 'arch' attribute
value of the os/type element to produce the correct default type.

Therefore we need to extend the signature of defaultConsoleTargetType
to account for architecture. As a consequence all the drivers
supporting this capability function must be updated.

Despite the amount of changed files, the only change in behavior is
that for S390 the default console target type will be 'virtio'.

N.B.: A more future-proof approach could be to to use hypervisor
specific capabilities to determine the best possible console type.
For instance one could add an opaque private data pointer to the
virCaps structure (in case of QEMU to hold capsCache) which could
then be passed to the defaultConsoleTargetType callback to determine
the console target type.
Seems to be however a bit overengineered for the use case...

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
12 years agoqemu: Fix domain ID numbering race condition
Peter Krempa [Thu, 8 Nov 2012 12:48:37 +0000 (13:48 +0100)]
qemu: Fix domain ID numbering race condition

When the libvirt daemon is restarted it tries to reconnect to running
qemu domains. Since commit d38897a5d4b1880e1998394b2a37bba979bbdff1 the
re-connection code runs in separate threads. In the original
implementation the maximum of domain ID's (that is used as an
initializer for numbering guests created next) while libvirt was
reconnecting to the guest.

With the threaded implementation this opens a possibility for race
conditions with the thread that is autostarting guests. When there's a
guest running with id 1 and the daemon is restarted. The autostart code
is reached first and spawns the first guest that should be autostarted
as id 1. This results into the following unwanted situation:

 # virsh list
   Id    Name                           State
  ----------------------------------------------------
   1     guest1                         running
   1     guest2                         running

This patch extracts the detection code before the re-connection threads
are started so that the maximum id of the guests being reconnected to is
known.

The only semantic change created by this is if the guest with greatest ID
quits before we are able to reconnect it's ID is used anyway as the
greatest one as without this patch the greatest ID of a process we could
successfuly reconnect to would be used.

12 years agostorage: fix broken backing chain
Philipp Hahn [Wed, 7 Nov 2012 13:53:49 +0000 (14:53 +0100)]
storage: fix broken backing chain

82507838 refactored the code to keep both the raw and canonicalized form
of the backingStore, which breaks badly when the storage pool contains a
storage volume, which is missing its backing store file:
 # ./daemon/libvirtd -l
 2012-11-07 12:43:33.279+0000: 22175: info : libvirt version: 1.0.0
 2012-11-07 12:43:33.279+0000: 22175: error : absolutePathFromBaseFile:542 : Can't canonicalize path '/var/lib/libvirt/images/base.qcow2': No such file or directory
 2012-11-07 12:43:33.280+0000: 22175: error : storageDriverAutostart:115 : Failed to autostart storage pool 'default': Can't canonicalize path '/var/lib/libvirt/images/base.qcow2': No such file or directory

This is because virStorageFileGetMetadataFromBuf() aborts with -1 if the
filename of the backingStore can not be canonicalized:
 #0  absolutePathFromBaseFile () at util/storage_file.c:541
 #1  virStorageFileGetMetadataFromBuf () at util/storage_file.c:728
 #2  virStorageFileGetMetadataFromFD () at util/storage_file.c:932
 #3  virStorageBackendProbeTarget () at storage/storage_backend_fs.c:94
 #4  virStorageBackendFileSystemRefresh () at storage/storage_backend_fs.c:849
 #5  storagePoolStart () at storage/storage_driver.c:700
 #6  virStoragePoolCreate () at libvirt.c:12471
 ...

Treat files which miss their backing file as standalone files.

Signed-off-by: Philipp Hahn <hahn@univention.de>
12 years agoqemu: Fix function header formating of 2 functions
Peter Krempa [Thu, 8 Nov 2012 12:45:45 +0000 (13:45 +0100)]
qemu: Fix function header formating of 2 functions

Headers of qemuDomainSnapshotLoad and qemuDomainNetsRestart were
improperly formatted.

12 years agosnapshot: qemu: Add support for external inactive snapshots
Peter Krempa [Mon, 15 Oct 2012 15:35:24 +0000 (17:35 +0200)]
snapshot: qemu: Add support for external inactive snapshots

This patch adds support for external disk snapshots of inactive domains.
The snapshot is created by calling using qemu-img by calling:

 qemu-img create -f format_of_snapshot -o
 backing_file=/path/to/src,backing_fmt=format_of_backing_image
 /path/to/snapshot

in case the backing image format is known or probing is allowed and
otherwise:

 qemu-img create -f format_of_snapshot -o  backing_file=/path/to/src
 /path/to/snapshot

on each of the disks selected for snapshotting. This patch also modifies
the snapshot preparing function to support creating external snapshots
and to sanitize arguments. For now the user isn't able to mix external
and internal snapshots but this restriction might be lifted in the
future.

12 years agoFix "virsh create" example
Guido Günther [Wed, 7 Nov 2012 20:35:55 +0000 (21:35 +0100)]
Fix "virsh create" example

We require a file and don't accept standard input:

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=692322

12 years agovirsh: add snapshot-create-as memspec support
Eric Blake [Wed, 7 Nov 2012 03:55:53 +0000 (20:55 -0700)]
virsh: add snapshot-create-as memspec support

External checkpoints could be created with snapshot-create, but
without libvirt supplying a default name for the memory file,
it is essential to add a new argument to snapshot-create-as to
allow the user to choose the memory file name.  This adds the
option --memspec [file=]name[,snapshot=type], where type can
be none, internal, or external.  For an example,

virsh snapshot-create-as $dom --memspec /path/to/file

is the shortest possible command line for creating an external
checkpoint, named after the current timestamp.

* tools/virsh-snapshot.c (vshParseSnapshotMemspec): New function.
(cmdSnapshotCreateAs): Use it.
* tests/virsh-optparse (test_url): Test it.
* tools/virsh.pod (snapshot-create-as): Document it.

12 years agovirsh: make ,, escape parsing common
Eric Blake [Wed, 7 Nov 2012 00:45:09 +0000 (17:45 -0700)]
virsh: make ,, escape parsing common

So far, none of the existing callers of vshStringToArray expected
the user to ever pass a literal comma; meanwhile, snapshot parsing
had rolled its own array parser.  Moving the comma escaping into
the common function won't affect any existing callers, and will make
this function reusable for adding memory handling to snapshot parsing.

As a bonus, the testsuite was already testing snapshot parsing, so
the fact that the test still passes means that we are now giving
testsuite exposure to vshStringToArray.

* tools/virsh-snapshot.c (vshParseSnapshotDiskspec): Move ,,
parsing...
* tools/virsh.c (vshStringToArray): ...into common function.
Also, vshStrdup can't fail.

12 years agoqemu: Emit event if 'cont' fails
Michal Privoznik [Mon, 5 Nov 2012 14:33:12 +0000 (15:33 +0100)]
qemu: Emit event if 'cont' fails

Some operations, APIs needs domain to be paused prior operation can be
performed, e.g. (managed-) save of a domain. The processors should be
restored in the end. However, if 'cont' fails for some reason, we log a
message but this is not sufficient as an event should be emitted as
well. Mgmt application can then decide what to do.

12 years agoIntroduce new VIR_DOMAIN_EVENT_SUSPENDED_API_ERROR event
Michal Privoznik [Tue, 6 Nov 2012 17:39:18 +0000 (18:39 +0100)]
Introduce new VIR_DOMAIN_EVENT_SUSPENDED_API_ERROR event

This is supposed to be thrown every time we need to pause domain
because of API execution (e.g. qemuDomainSaveInternal) but fails
to restore it back after. In this case, domain remains paused,
however, none of existing reasons can fit this scenario.

12 years agovirsh: document which term is older
Eric Blake [Tue, 6 Nov 2012 15:09:32 +0000 (08:09 -0700)]
virsh: document which term is older

Make it clear that the alternate terms have no difference except
for length of time they were supported.

* tools/virsh.pod (start, shutdown, reboot): More documentation.

12 years agovirsh: add aliases 'boot', 'stop', and 'restart'
Eric Blake [Mon, 5 Nov 2012 19:54:59 +0000 (12:54 -0700)]
virsh: add aliases 'boot', 'stop', and 'restart'

https://bugzilla.redhat.com/show_bug.cgi?id=873344 suggested that
the grouping 'boot', 'shutdown', 'reboot'; as well as the grouping
'start', 'stop', 'restart'; might be easier to remember than the
current mix of 'start', 'shutdown', 'reboot'.

Also, touch up the wording of 'reboot' to be more accurate.

* tools/virsh-domain.c (domManagementCmds): Add other command names.
* tools/virsh.pod (start, shutdown, reboot): Document the aliases.

12 years agoqemu: Don't corrupt pointer in qemuDomainSaveMemory()
Peter Krempa [Tue, 6 Nov 2012 09:55:26 +0000 (10:55 +0100)]
qemu: Don't corrupt pointer in qemuDomainSaveMemory()

The code that was split out into the qemuDomainSaveMemory expands the
pointer containing the XML description of the domain that it gets from
higher layers. If the pointer changes the old one is invalid and the
upper layer function tries to free it causing an abort.

This patch changes the expansion of the original string to a new
allocation and copy of the contents.

12 years agoesx: Yet another connection fix for 5.1
Martin Kletzander [Tue, 6 Nov 2012 09:08:43 +0000 (10:08 +0100)]
esx: Yet another connection fix for 5.1

After the connection to ESX 5.1 being broken since g1e7cd39, the fix
in bab7752c helped a bit, but still missed a spot, so the connection
is now successful, but some APIs (for example defineXML) don't work.
Two cases missing are added in this patch to avoid that.

12 years agotests: Add test for controller order
Michal Privoznik [Mon, 5 Nov 2012 11:12:04 +0000 (12:12 +0100)]
tests: Add test for controller order

12 years agoqemu: Add controllers in specified order
Michal Privoznik [Mon, 5 Nov 2012 10:51:44 +0000 (11:51 +0100)]
qemu: Add controllers in specified order

qemu is sensitive to the order of arguments passed. Hence, if a
device requires a controller, the controller cmd string must
precede device cmd string. The same apply for controllers, when
for instance ccid controller requires usb controller. So
controllers create partial ordering in which they should be added
to qemu cmd line.

12 years agoqemu: Wrap controllers code into dummy loop
Michal Privoznik [Mon, 5 Nov 2012 10:42:51 +0000 (11:42 +0100)]
qemu: Wrap controllers code into dummy loop

which just re-indent code and prepare it for next patch.

12 years agospec: replace scriptlets with new systemd macros
Václav Pavlín [Thu, 25 Oct 2012 10:10:55 +0000 (12:10 +0200)]
spec: replace scriptlets with new systemd macros

https://bugzilla.redhat.com/850186

I added %with_systemd_macros so it should now work in F17 with old
scriptlets and in F18+/RHEL7+ with systemd macros
(see https://fedoraproject.org/wiki/Packaging:ScriptletSnippets#Systemd)

I missed libvirt-guests.service because there is no systemctl call for
it. So I only added systemd macros calls.

12 years agospec: don't enable cgconfig under systemd
Eric Blake [Mon, 5 Nov 2012 16:48:28 +0000 (09:48 -0700)]
spec: don't enable cgconfig under systemd

In Fedora 16, we quit enabling cgconfig because systemd set up
default cgroups that were good enough for our use.  But in F17,
when we switched to systemd, we reverted and started up cgconfig
again.  See also the tail of this thread:
https://www.redhat.com/archives/libvir-list/2012-October/msg01657.html

* libvirt.spec.in (with_systemd): Rely on systemd for cgroups.

12 years agoiohelper: Don't report errors on special FDs
Michal Privoznik [Mon, 5 Nov 2012 14:42:53 +0000 (15:42 +0100)]
iohelper: Don't report errors on special FDs

Some FDs may not implement fdatasync() functionality,
e.g.  pipes. In that case EINVAL or EROFS is returned.
We don't want to fail then nor report any error.

Reported-by: Christophe Fergeau <cfergeau@redhat.com>
12 years agogitignore: ignore more files
liguang [Mon, 5 Nov 2012 04:59:53 +0000 (12:59 +0800)]
gitignore: ignore more files

ignore cscope.in.out, cscope.po.out

Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
12 years agosnapshot: qemu: Remove restrictions preventing external checkpoints
Peter Krempa [Mon, 8 Oct 2012 17:28:08 +0000 (19:28 +0200)]
snapshot: qemu: Remove restrictions preventing external checkpoints

Some of the pre-snapshot check have restrictions wired in regarding
configuration options that influence taking of external checkpoints.

This patch removes restrictions that would inhibit taking of such a
snapshot.

12 years agosnapshot: qemu: Add support for external checkpoints
Peter Krempa [Mon, 8 Oct 2012 17:38:44 +0000 (19:38 +0200)]
snapshot: qemu: Add support for external checkpoints

This patch adds support to take external system checkpoints.

The functionality is layered on top of the previous disk-only snapshot
code. When the checkpoint is requested the domain memory is saved to the
memory image file using migration to file. (The user may specify to
take the memory image while the guest is live with the
VIR_DOMAIN_SNAPSHOT_CREATE_LIVE flag.)

The memory save image shares format with the image created by
virDomainSave() API.

12 years agosnapshot: qemu: Rename qemuDomainSnapshotCreateActive
Peter Krempa [Mon, 8 Oct 2012 14:45:04 +0000 (16:45 +0200)]
snapshot: qemu: Rename qemuDomainSnapshotCreateActive

Before now, libvirt supported only internal snapshots for active guests.
This patch renames this function to qemuDomainSnapshotCreateActiveInternal
to prepare the grounds for external active snapshots.

12 years agosnapshot: qemu: Add async job type for snapshots
Peter Krempa [Mon, 8 Oct 2012 14:34:19 +0000 (16:34 +0200)]
snapshot: qemu: Add async job type for snapshots

The new external system checkpoints will require an async job while the
snapshot is taken. This patch adds QEMU_ASYNC_JOB_SNAPSHOT to track this
job type.

12 years agosnapshot: Add flag to enable creating checkpoints in live state
Peter Krempa [Tue, 9 Oct 2012 10:11:56 +0000 (12:11 +0200)]
snapshot: Add flag to enable creating checkpoints in live state

The default behavior while creating external checkpoints is to pause the
guest while the memory state is captured. We want the users to sacrifice
space saving for creating the memory save image while the guest is live
to minimize downtime.

This patch adds a flag that causes the guest not to be paused before
taking the snapshot.
 *include/libvirt/libvirt.h.in:
    - add new paused reason: VIR_DOMAIN_PAUSED_SNAPSHOT
    - add new flag for taking snapshot: VIR_DOMAIN_SNAPSHOT_CREATE_LIVE
 *tools/virsh-domain-monitor.c:
    - add string representation for VIR_DOMAIN_PAUSED_SNAPSHOT
 *tools/virsh-snapshot.c:
    - add support for VIR_DOMAIN_SNAPSHOT_CREATE_LIVE
 *tools/virsh.pod:
    - add docs for --live option added to use
    VIR_DOMAIN_SNAPSHOT_CREATE_LIVE flag

12 years agoqemu: Split out domain memory saving code to allow reuse
Peter Krempa [Wed, 26 Sep 2012 12:10:56 +0000 (14:10 +0200)]
qemu: Split out domain memory saving code to allow reuse

The code that saves domain memory by migration to file can be reused
while doing external checkpoints of a machine. This patch extracts the
common code and places it in a separate function.

12 years agoqemu: Clean up snapshot retrieval to use the new helper
Peter Krempa [Thu, 11 Oct 2012 09:59:40 +0000 (11:59 +0200)]
qemu: Clean up snapshot retrieval to use the new helper

Two other places were left with the old code to look up snapshots.
Change them to use the snapshot lookup helper.

12 years agocpu: Add AMD Opteron G5 cpu model
Peter Krempa [Tue, 30 Oct 2012 15:15:35 +0000 (16:15 +0100)]
cpu: Add AMD Opteron G5 cpu model

12 years agocpu: Add newly added cpu flags
Peter Krempa [Tue, 30 Oct 2012 13:58:55 +0000 (14:58 +0100)]
cpu: Add newly added cpu flags

This patch adds a few new processor feature flags. Namely:
 f16c rdrand lwp tbm topoext perfctr_core perfctr_nb fsgsbase bmi1 hle
 avx2 bmi2 erms invpcid rtm rdseed adx tce

12 years agoqemu: Fix possible race when pausing guest
Peter Krempa [Thu, 1 Nov 2012 14:45:47 +0000 (15:45 +0100)]
qemu: Fix possible race when pausing guest

When pausing the guest while migration is running (to speed up
convergence) the virDomainSuspend API checks if the migration job is
active before entering the job. This could cause a possible race if the
virDomainSuspend is called while the job is active but ends before the
Suspend API enters the job (this would require that the migration is
aborted). This would cause a incorrect event to be emitted.