]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
13 years agosnapshot: virsh snapshot-list and children
Eric Blake [Thu, 29 Sep 2011 17:51:23 +0000 (11:51 -0600)]
snapshot: virsh snapshot-list and children

Sometimes, we only care about one branch of the snapshot hierarchy.
Make it easier to list a single branch, by using the new APIs.

Technically, I could emulate these new virsh options on old servers
by doing a complete dump, then scraping xml to filter out just the
snapshots that I care about, but I didn't want to do that in this patch.

* tools/virsh.c (cmdSnapshotList): Add --from, --descendants.
* tools/virsh.pod (snapshot-list): Document them.

13 years agosnapshot: new virDomainSnapshotListChildrenNames API
Eric Blake [Sun, 25 Sep 2011 01:56:26 +0000 (19:56 -0600)]
snapshot: new virDomainSnapshotListChildrenNames API

The previous API addition allowed traversal up the hierarchy;
this one makes it easier to traverse down the hierarchy.

In the python bindings, virDomainSnapshotNumChildren can be
generated, but virDomainSnapshotListChildrenNames had to copy
from the hand-written example of virDomainSnapshotListNames.

* include/libvirt/libvirt.h.in (virDomainSnapshotNumChildren)
(virDomainSnapshotListChildrenNames): New prototypes.
(VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS): New flag alias.
* src/libvirt.c (virDomainSnapshotNumChildren)
(virDomainSnapshotListChildrenNames): New functions.
* src/libvirt_public.syms: Export them.
* src/driver.h (virDrvDomainSnapshotNumChildren)
(virDrvDomainSnapshotListChildrenNames): New callbacks.
* python/generator.py (skip_impl, nameFixup): Update lists.
* python/libvirt-override-api.xml: Likewise.
* python/libvirt-override.c
(libvirt_virDomainSnapshotListChildrenNames): New wrapper function.

13 years agodocs: fix html bug
Eric Blake [Mon, 10 Oct 2011 22:32:45 +0000 (16:32 -0600)]
docs: fix html bug

</space> doesn't exist.  Introduced in commit 4bb4109f.

* docs/formatdomain.html.in: Use correct end tag.

13 years agoxen_xs: Guard against set but empty kernel argument
Guido Günther [Mon, 10 Oct 2011 16:22:44 +0000 (18:22 +0200)]
xen_xs: Guard against set but empty kernel argument

On xen 4.1 I observed configurations that look like:

(image
    (hvm
        (kernel '')
        (loader '/foo/bar')
))

The kernel element is there but unset. This leads to an empty <kernel/>
element in the XML and even worse makes us skip the boot order parsing
and therefore not emit a <boot device='$dev>'/> element which breaks CD
booting.

13 years agoxen: add error handling to UUID parsing
Guido Günther [Thu, 6 Oct 2011 10:42:39 +0000 (12:42 +0200)]
xen: add error handling to UUID parsing

otherwise a missing UUID in a domain config just shows:

error: An error occurred, but the cause is unknown

Now we have:

error: configuration file syntax error: config value uuid was missing

13 years agomaint: typo fixes
Eric Blake [Mon, 10 Oct 2011 20:02:06 +0000 (14:02 -0600)]
maint: typo fixes

I noticed a couple typos in recent commits, and fixed the remaining
instances of them.

* docs/internals/command.html.in: Fix spelling errors.
* include/libvirt/libvirt.h.in (virConnectDomainEventCallback):
Likewise.
* python/libvirt-override.py (virEventAddHandle): Likewise.
* src/lxc/lxc_container.c (lxcContainerChild): Likewise.
* src/util/hash.c (virHashCreateFull): Likewise.
* src/storage/storage_backend_logical.c
(virStorageBackendLogicalMakeVol): Likewise.
* src/esx/esx_driver.c (esxFormatVMXFileName): Likewise.
* src/vbox/vbox_tmpl.c (vboxIIDIsEqual_v3_x): Likewise.

13 years agosnapshot: avoid accidental renames with snapshot-edit
Eric Blake [Fri, 7 Oct 2011 22:20:58 +0000 (16:20 -0600)]
snapshot: avoid accidental renames with snapshot-edit

I was a bit surprised that 'virsh snapshot-edit dom name' silently
allowed me to clone things, while still telling me the old name,
especially since other commands like 'virsh edit dom' reject rename
attempts (*).  This fixes things to be more explicit (**).

(*) Technically, 'virsh edit dom' relies on virDomainDefineXML
behavior, which rejects attempts to mix a new name with existing
uuid or new uuid with existing name, but you can create a new
domain by changing both uuid and name.  On the other hand, while
snapshot-edit --clone is a true clone, creating a new domain
would also have to decide whether to clone snapshot metadata,
managed save, and any other secondary data related to the domain.
Domain renames are not trivial either.

(**) Renaming or creating a clone is still a risky proposition -
for offline snapshots and system checkpoints, if the new name
does not match an actual name recorded in the qcow2 internal
snapshots, then you cannot revert to the new checkpoint.  But it
is assumed that anyone using the new virsh flags knows what they
are doing, and can deal with the fallout caused by a rename/clone;
that is, we can't completely prevent a user from shooting
themselves in the foot, so much as we are making the default
action less risky.

* tools/virsh.c (cmdSnapshotEdit): Add --rename, --clone.
* tools/virsh.pod (snapshot-edit): Document them.

13 years agosnapshot: sort snapshot-list --tree
Eric Blake [Fri, 7 Oct 2011 21:55:59 +0000 (15:55 -0600)]
snapshot: sort snapshot-list --tree

Otherwise, the results are not repeatable.

* tools/virsh.c (cmdSnapshotList): Print tree in predictable order.

13 years agostorage: Do not use comma as seperator for lvs output
Osier Yang [Mon, 10 Oct 2011 12:34:59 +0000 (20:34 +0800)]
storage: Do not use comma as seperator for lvs output

* src/storage/storage_backend_logical.c:

If a logical vol is created as striped. (e.g. --stripes 3),
the "device" field of lvs output will have multiple fileds which are
seperated by comma. Thus the RE we write in the codes will not
work well anymore. E.g. (lvs output for a stripped vol, uses "#" as
seperator here):

test_stripes##fSLSZH-zAS2-yAIb-n4mV-Al9u-HA3V-oo9K1B#\
/dev/sdc1(10240),/dev/sdd1(0)#42949672960#4194304

The RE we use:

    const char *regexes[] = {
        "^\\s*(\\S+),(\\S*),(\\S+),(\\S+)\\((\\S+)\\),(\\S+),([0-9]+),?\\s*$"
    };

Also the RE doesn't match the "devices" field of striped vol properly,
it contains multiple "device path" and "offset".

This patch mainly does:
    1) Change the seperator into "#"
    2) Change the RE for "devices" field from "(\\S+)\\((\\S+)\\)"
       into "(\\S+)".
    3) Add two new options for lvs command, (segtype, stripes)
    4) Extend the RE to match the value for the two new fields.
    5) Parse the "devices" field seperately in virStorageBackendLogicalMakeVol,
       multiple "extents" info are generated if the vol is striped. The
       number of "extents" is equal to the stripes number of the striped vol.

A incidental fix: (virStorageBackendLogicalMakeVol)
    Free "vol" if it's new created and there is error.

Demo on striped vol with the patch applied:

% virsh vol-dumpxml /dev/test_vg/vol_striped2
<volume>
  <name>vol_striped2</name>
  <key>QuWqmn-kIkZ-IATt-67rc-OWEP-1PHX-Cl2ICs</key>
  <source>
    <device path='/dev/sda5'>
      <extent start='79691776' end='88080384'/>
    </device>
    <device path='/dev/sda6'>
      <extent start='62914560' end='71303168'/>
    </device>
  </source>
  <capacity>8388608</capacity>
  <allocation>8388608</allocation>
  <target>
    <path>/dev/test_vg/vol_striped2</path>
    <permissions>
      <mode>0660</mode>
      <owner>0</owner>
      <group>6</group>
      <label>system_u:object_r:fixed_disk_device_t:s0</label>
    </permissions>
  </target>
</volume>

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

13 years agoqemuDomainAttach: Initialize pidfile variable
Michal Privoznik [Sun, 9 Oct 2011 08:42:42 +0000 (10:42 +0200)]
qemuDomainAttach: Initialize pidfile variable

If parsing qemu command line fails (e.g. because of non-existing
process number supplied), we jump to cleanup label where we free
pidfile. Therefore it needs to be initialized. Otherwise we free
random pointer.

13 years agoqemu: silence Coverity false positive
Eric Blake [Sat, 8 Oct 2011 02:56:00 +0000 (20:56 -0600)]
qemu: silence Coverity false positive

Coverity complained that 4 out of 5 callers to virJSONValueObjectGetBoolean
checked for errors.  But we documented that we don't care in this case.

* src/qemu/qemu_monitor_json.c (qemuMonitorJSONGetBlockInfo): Use
ignore_value.

13 years agolxc: fix logic bug
Eric Blake [Sat, 8 Oct 2011 02:42:36 +0000 (20:42 -0600)]
lxc: fix logic bug

Detected by Coverity.  We want to increment the size_t counter,
not the pointer to the counter.  Bug present since 5f5c6fde (0.9.5).

* src/lxc/lxc_controller.c (lxcSetupLoopDevices): Use correct
precedence.

13 years agovirsh: Update the help information for undefine command.
tangchen [Fri, 7 Oct 2011 09:34:47 +0000 (17:34 +0800)]
virsh: Update the help information for undefine command.

virsh undefine command can now undefine an active guest, but the help information is still the old.
This patch modifies it and make it coincident to the manpage of virsh.

Signed-off-by: tangchen <tangchen@cn.fujitsu.com>
13 years agoDon't send back unknown program errors for async messages
Daniel P. Berrange [Thu, 6 Oct 2011 09:58:05 +0000 (10:58 +0100)]
Don't send back unknown program errors for async messages

If we send back an unknown program error for async messages,
we will confuse the client because they only expect replies
for method calls. Just log & drop any invalid async messages

* src/rpc/virnetserver.c: Don't send error for async messages

13 years agoFix deadlock when the RPC program is unknown
Daniel P. Berrange [Thu, 6 Oct 2011 09:41:28 +0000 (10:41 +0100)]
Fix deadlock when the RPC program is unknown

Commit 597fe3cee68f561a181967b59a87b4e5c5880c4c accidentally
introduced a deadlock when reporting an unknown RPC program.
The virNetServerDispatchNewMessage method is called with
the client locked, and must therefore not attempt to send
any RPC messages back to the client. Only once the incoming
message is passed off to the virNetServerHandleJob worker
is it safe to start sending messages back

* src/rpc/virnetserver.c: Delay checking for unknown RPC
  program until in worker thread

13 years agosnapshot: simplify redefinition of disk snapshot
Eric Blake [Thu, 6 Oct 2011 21:57:00 +0000 (15:57 -0600)]
snapshot: simplify redefinition of disk snapshot

Redefining disk-only snapshot xml should work even if the user
did not explicitly pass VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY;
the flag is only required for conditions where the <state>
subelement is not already present in parsing (that is, defining
a new snapshot).

Also, fix the error code of some user-visible errors (the remaining
VIR_ERR_INTERNAL_ERROR should not be user-visible, since parsing
of <active> is only done from internal code).

* src/conf/domain_conf.c (virDomainSnapshotDefParseString): Allow
disks during redefinition of disk snapshot.

13 years agosnapshot: let virsh edit disk snapshots
Eric Blake [Thu, 6 Oct 2011 22:58:28 +0000 (16:58 -0600)]
snapshot: let virsh edit disk snapshots

It was impossible for 'virsh snapshot-current dom name' to set name
as the current snapshot, if name is a disk-only snapshot.

Using strstr rather than full-blown xml parsing is safe, since the
xml is assumed to be well-formed coming from libvirtd rather than
arbitrary text coming from the user.

* tools/virsh.c (cmdSnapshotCurrent, cmdSnapshotEdit): Pass
disk_only flag when redefining a disk snapshot.

13 years agosnapshot: fix virsh error message typo
Eric Blake [Fri, 7 Oct 2011 13:53:27 +0000 (07:53 -0600)]
snapshot: fix virsh error message typo

* tools/virsh.c (cmdSnapshotList): Spell exclusive correctly.

13 years agoremote_driver: Avoid double free in EventControl building
Michal Privoznik [Thu, 6 Oct 2011 13:33:40 +0000 (15:33 +0200)]
remote_driver: Avoid double free in EventControl building

Don't xdr_free event data as they are freed by our caller
virNetClientProgramDispatch.

13 years agobuild: fix 'make distcheck' with pdwtags installed
Eric Blake [Tue, 4 Oct 2011 16:24:40 +0000 (10:24 -0600)]
build: fix 'make distcheck' with pdwtags installed

I am getting this failure with 'make distcheck':

  GEN    ../../src/remote_protocol-structs
/bin/sh: ../../src/remote_protocol-structs-t: Permission denied
make[4]: *** [../../src/remote_protocol-structs] Error 1

since it attempts a sub-run of a VPATH 'make check' where $(srcdir)
is intentionally read-only.  I'm not sure which commit introduced
the problem, although I suspect it was around 62dee6f when I
refactored protocol struct checking to be more powerful.

$(@F) is required by POSIX, and although it is not yet portable
to all make implementations, we already require GNU make.

* src/Makefile.am (PDWTAGS): Generate temp file into current
directory, since $(srcdir) is read-only during distcheck.

13 years agoxenParseXM: don't dereference NULL pointer when script is empty
Guido Günther [Thu, 6 Oct 2011 10:56:52 +0000 (12:56 +0200)]
xenParseXM: don't dereference NULL pointer when script is empty

13 years agoqemu: add separate rerror_policy for disk errors
Laine Stump [Tue, 4 Oct 2011 18:17:06 +0000 (14:17 -0400)]
qemu: add separate rerror_policy for disk errors

Previously libvirt's disk device XML only had a single attribute,
error_policy, to control both read and write error policy, but qemu
has separate options for controlling read and write. In one case
(enospc) a policy is allowed for write errors but not read errors.

This patch adds a separate attribute that sets only the read error
policy. If just error_policy is set, it will apply to both read and
write error policy (previous behavior), but if the new rerror_policy
attribute is set, it will override error_policy for read errors only.
Possible values for rerror_policy are "stop", "report", and "ignore"
("report" is the qemu-controlled default for rerror_policy when
error_policy isn't specified).

For consistency, the value "report" has been added to the possible
values for error_policy as well.

13 years agoqemu: leave rerror policy at default when enospace is requested
Laine Stump [Wed, 5 Oct 2011 15:19:28 +0000 (11:19 -0400)]
qemu: leave rerror policy at default when enospace is requested

commit 12062ab set rerror=ignore when error_policy="enospace" was
selected (since the rerror option in qemu doesn't accept "enospc", as
the werror option does).

After that patch was already pushed, Paolo Bonzini noticed it and
commented that leaving rerror at the default ("report") would be a
better choice. This patch corrects the problem - if error_policy =
"enospace" is given, rerror is left off the qemu commandline,
effectively setting it to "report". For other values, rerror is still
set to match werror.

Additionally, the parsing of error_policy was changed to no longer
erroneously allow "default" as a choice - as with most other
attributes, if you want the default setting, just don't specify an
error_policy.

Finally, two ommissions in the first patch were corrected - a
long-dormant qemuxml2argv test for enospace was enabled, and fixed to
pass, and the argv2xml parser in qemu_command.c was updated to
recognize the different spelling on the qemu commandline.

13 years agoqemu: enable multifunction for older qemu
Eric Blake [Wed, 5 Oct 2011 21:48:41 +0000 (15:48 -0600)]
qemu: enable multifunction for older qemu

Now that RHEL 6.2 Beta is out, it would be nice to test multifunction
devices on that platform.  This changes things so that the multifunction
cap bit can be set in two different ways: by version comparison (needed
for qemu 0.13 which lacked a -device query), and by -device query
(provided by qemu.git and backported to the RHEL beta build of
qemu-kvm which still claims to be a modified 0.12, and therefore needed
for RHEL).

* src/qemu/qemu_capabilities.c (qemuCapsParseDeviceStr): Allow
second method of setting multifunction cap bit.
* tests/qemuhelptest.c (mymain): Test it.
* tests/qemuhelpdata/qemu-kvm-0.12.1.2-rhel62-beta: New file.
* tests/qemuhelpdata/qemu-kvm-0.12.1.2-rhel62-beta-device: Likewise.

13 years agoDocument STREQ_NULLABLE and STRNEQ_NULLABLE
Guido Günther [Thu, 6 Oct 2011 11:32:49 +0000 (13:32 +0200)]
Document STREQ_NULLABLE and STRNEQ_NULLABLE

13 years agoMake LXC work with new network configuration types
Daniel P. Berrange [Tue, 4 Oct 2011 12:47:26 +0000 (13:47 +0100)]
Make LXC work with new network configuration types

If using one of the new non-NAT/routed virtual network
configurations, the LXC driver would not know how to
setup the VETH devices. Adding in calls to setup the
"actual" network configuration at VM startup and cleanup
when shutting down fixes this.

* src/lxc/lxc_driver.c: Setup/cleanup actual net devs

13 years agoinit: raise default system aio limits
Eric Blake [Tue, 4 Oct 2011 15:44:25 +0000 (09:44 -0600)]
init: raise default system aio limits

https://bugzilla.redhat.com/show_bug.cgi?id=740899 documents that
if qemu uses aio=native for its disks, then it consumes 128 aio
requests per disk.  On a host with multiple guests, this can quickly
run out of kernel aio requests with the default aio-max-nr of
65536.  Kernel developers have confirmed that there is no up-front
cost to raising this limit (a larger limit merely implies that more
aio requests can be issued in parallel, which in turn will result
in more kernel memory allocation, only if the system really does use
that many requests).  Since the system default limit prevents 256
disks, which is well within libvirt's current scalability, this
patch installs a file to raise the limit and document it in case a
system administrator has further cause to tune the limit.  The
install only works on platforms new enough to source /etc/sysctl.d/*
alongside /etc/sysctl.conf (F14 and RHEL 6).

* daemon/libvirtd.sysctl: New file.
* daemon/Makefile.am (EXTRA_DIST): Ship it.
(install-init, uninstall-init): Install it.
* libvirt.spec.in (%files): Include it in rpm.

13 years agomaint: fix minor issues in virterror public header
Eric Blake [Wed, 5 Oct 2011 18:28:46 +0000 (12:28 -0600)]
maint: fix minor issues in virterror public header

Consistent use of tabs, fewer long lines, and a typo fix.

* include/libvirt/virterror.h: Fix typos, layout.

13 years agosnapshot: enforce REVERT_FORCE on qemu
Eric Blake [Fri, 30 Sep 2011 18:19:41 +0000 (12:19 -0600)]
snapshot: enforce REVERT_FORCE on qemu

Implements the documentation for snapshot revert vs. force.

Part of the patch tightens existing behavior (previously, reverting
to an old snapshot without <domain> was blindly attempted, now it
requires force), while part of it relaxes behavior (previously, it
was not possible to revert an active domain to an ABI-incompatible
active snapshot, now force allows this transition).

* src/qemu/qemu_driver.c (qemuDomainRevertToSnapshot): Check for
risky situations, and allow force to get past them.

13 years agosnapshot: use qemu-img on disks in use at time of snapshot
Eric Blake [Tue, 4 Oct 2011 23:13:48 +0000 (17:13 -0600)]
snapshot: use qemu-img on disks in use at time of snapshot

Once we know which set of disks belong to a snapshot, reverting or
deleting that snapshot should visit just those disks, rather than
also visiting disks that were hot-plugged in the meantime or
skipping disks that were hot-unplugged in the meantime.

* src/qemu/qemu_domain.c (qemuDomainSnapshotForEachQcow2): Use
snapshot domain details when available.  Avoid NULL deref.

13 years agosnapshot: add REVERT_FORCE to API
Eric Blake [Thu, 29 Sep 2011 23:52:06 +0000 (17:52 -0600)]
snapshot: add REVERT_FORCE to API

Although reverting to a snapshot is a form of data loss, this is
normally expected.  However, there are two cases where additional
surprises (failure to run the reverted state, or a break in
connectivity to the domain) can come into play.  Requiring extra
acknowledgment in these cases will make it less likely that
someone can get into an unrecoverable state due to a default revert.

Also create a new error code, so users can distinguish when forcing
would make a difference, rather than having to blindly request force.

* include/libvirt/libvirt.h.in (VIR_DOMAIN_SNAPSHOT_REVERT_FORCE):
New flag.
* src/libvirt.c (virDomainRevertToSnapshot): Document it.
* include/libvirt/virterror.h (VIR_ERR_SNAPSHOT_REVERT_RISKY): New
error value.
* src/util/virterror.c (virErrorMsg): Implement it.
* tools/virsh.c (cmdDomainSnapshotRevert): Add --force to virsh.
* tools/virsh.pod (snapshot-revert): Document it.

13 years agosnapshot: implement snapshot roots listing in vbox
Eric Blake [Mon, 3 Oct 2011 21:20:25 +0000 (15:20 -0600)]
snapshot: implement snapshot roots listing in vbox

Commit 9f5e53e introduced the ability to filter snapshots to
just roots, but it was never implemented for VBox until now.

The VBox implementation prohibits deletion of a snapshot with
multiple children.  Hence, there can only be at most one root,
which is found by searching for the snapshot with a NULL uuid.

Prior to 4.0, snapshotGet looked up by UUID, and snapshotFind
looked up by name; after that point, snapshotGet disappeared
and snapshotFind handles uuid or name.

* src/vbox/vbox_tmpl.c (vboxDomainSnapshotNum)
(vboxDomainSnapshotListNames): Implement limiting list to root.

13 years agoqemu: Don't fail virDomainGetInfo if we can't update balloon info
Jiri Denemark [Wed, 5 Oct 2011 14:07:36 +0000 (16:07 +0200)]
qemu: Don't fail virDomainGetInfo if we can't update balloon info

Qemu driver tries to update balloon data in virDomainGetInfo and if it
can't do so because there is another monitor job running, it just
reports what's known in domain def. However, if there was no job running
but getting the data from qemu fails, we would fail the whole API. This
doesn't make sense. Let's make the failure nonfatal.

13 years agosnapshot: simplify esx snapshot name lookup
Eric Blake [Mon, 3 Oct 2011 18:02:25 +0000 (12:02 -0600)]
snapshot: simplify esx snapshot name lookup

No need to request the parent of a snapshot if we aren't going to use it.

* src/esx/esx_vi.c (esxVI_GetSnapshotTreeByName): Make parent
optional.
* src/esx/esx_driver.c (esxDomainSnapshotCreateXML)
(esxDomainSnapshotLookupByName, esxDomainRevertToSnapshot)
(esxDomainSnapshotDelete): Simplify accordingly.

13 years agosnapshot: implement snapshot roots listing in esx
Eric Blake [Mon, 3 Oct 2011 17:38:21 +0000 (11:38 -0600)]
snapshot: implement snapshot roots listing in esx

Commit 9f5e53e introduced the ability to filter snapshots to
just roots, but it was never implemented for ESX until now.

* src/esx/esx_vi.h (esxVI_GetNumberOfSnapshotTrees)
(esxVI_GetSnapshotTreeNames): Add parameter.
* src/esx/esx_vi.c (esxVI_GetNumberOfSnapshotTrees)
(esxVI_GetSnapshotTreeNames): Allow choice of recursion or not.
* src/esx/esx_driver.c (esxDomainSnapshotNum)
(esxDomainSnapshotListNames): Use it to limit to roots.

13 years agoqemu: correct misspelled 'enospc' option, and only use for werror
Laine Stump [Tue, 4 Oct 2011 17:26:29 +0000 (13:26 -0400)]
qemu: correct misspelled 'enospc' option, and only use for werror

This resolves:

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

When support for setting the qemu disk error policy to "enospc" was
added, it was inadvertently spelled "enospace". This patch corrects
that on the qemu commandline (while retaining the "enospace" spelling
for libvirt's XML).

Also, while examining the qemu source, I found that "enospc" is not
allowed for the read error policy, only for write error policy (makes
sense). Since libvirt currently only has a single error policy
setting, when "enospace" is selected, the read error policy is set to
"ignore".

13 years agosnapshot: better virsh handling of missing current, parent
Eric Blake [Fri, 30 Sep 2011 15:45:43 +0000 (09:45 -0600)]
snapshot: better virsh handling of missing current, parent

Previously, virsh 'snapshot-parent' and 'snapshot-current' were
completely silent in the case where the code conclusively proved
there was no parent or current snapshot, but differed in exit
status; this silence caused some confusion on whether the commands
worked.  Furthermore, commit d1be48f introduced a regression where
snapshot-parent would leak output about an unknown function, but
only on the first attempt, when talking to an older server that
lacks virDomainSnapshotGetParent.  This changes things to consistenly
report an error message and exit with status 1 when no snapshot
exists, and to avoid leaking unknown function warnings when using
fallbacks.

* tools/virsh.c (vshGetSnapshotParent): Alter signature, to
distinguish between real error and missing parent.  Don't pollute
last_error on success.
(cmdSnapshotParent): Adjust caller.  Always output message on
failure.
(cmdSnapshotList): Adjust caller.
(cmdSnapshotCurrent): Always output message on failure.

13 years agoDocument that ff callbacks need to be invoked from a clean stack.
Guido Günther [Mon, 3 Oct 2011 20:24:13 +0000 (22:24 +0200)]
Document that ff callbacks need to be invoked from a clean stack.

Also fix a typo.

13 years agoqemu: Fix migration with dname
Jiri Denemark [Tue, 4 Oct 2011 07:11:35 +0000 (09:11 +0200)]
qemu: Fix migration with dname

Destination libvirtd remembers the original name in the prepare phase
and clears it in the finish phase. The original name is used when
comparing domain name in migration cookie.

13 years agoAllow passing of command line args to LXC container
Daniel P. Berrange [Mon, 3 Oct 2011 17:37:47 +0000 (18:37 +0100)]
Allow passing of command line args to LXC container

When booting a virtual machine with a kernel/initrd it is possible
to pass command line arguments using the <cmdline>...args...</cmdline>
element in the guest XML. These appear to the kernel / init process
in /proc/cmdline.

When booting a container we do not have a custom /proc/cmdline,
but we can easily set an environment variable for it. Ideally
we could pass individual arguments to the init process as a
regular set of 'char *argv[]' parameters, but that would involve
libvirt parsing the <cmdline> XML text. This can easily be added
later, even if we add the env variable now

* docs/drvlxc.html.in: Document env variables passed to LXC
* src/conf/domain_conf.c: Add <cmdline> to be parsed for
  guests of type='exe'
* src/lxc/lxc_container.c: Set LIBVIRT_LXC_CMDLINE env var

13 years agoAdd support for bandwidth filtering on LXC guests
Daniel P. Berrange [Mon, 3 Oct 2011 17:25:10 +0000 (18:25 +0100)]
Add support for bandwidth filtering on LXC guests

Call virBandwidthEnable after creating the LXC veth, so that any
bandwidth controls get applied

* src/lxc/lxc_driver.c: Enable bandwidth limiting

13 years agonetwork: fill in bandwidth from portgroup for all forward modes
Laine Stump [Tue, 4 Oct 2011 03:53:36 +0000 (23:53 -0400)]
network: fill in bandwidth from portgroup for all forward modes

This patch is a fix for:

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

which was discovered by Dan Berrange while making bandwidth
configuration work for LXC guests.

Background: Although virtportprofile data from a network portgroup is
only applicable for direct mode interfaces, the code that copies
bandwidth data from the portgroup was also only being executed in the
case of direct mode interfaces. The result was that interfaces using
traditional virtual networks (forward mode='nat|route|none'), and
those using a host bridge for forwarding, would not pick up bandwidth
data from a portgroup defined in the network.

This patch moves that code outside the conditional, so that bandwidth
information is *alway* copied from the appropriate portgroup (unless
the <interface> definition itself already has bandwidth information,
which would take precedence over what's in the portgroup anyway).

13 years agobridge_driver.c: Fix autoconf setting
Neil Wilson [Mon, 3 Oct 2011 09:58:55 +0000 (10:58 +0100)]
bridge_driver.c: Fix autoconf setting

Code altered so that it is consistent with the associated comment. The
'autoconf' variable is forced to zero.

Signed-off-by: Neil Wilson <neil@brightbox.co.uk>
13 years agoSet to NULL members that have been freed to prevent crashes
Marc-André Lureau [Sat, 1 Oct 2011 01:39:14 +0000 (03:39 +0200)]
Set to NULL members that have been freed to prevent crashes

Do not crash if virStreamFinish is called after error.

==11000== Invalid read of size 4
==11000==    at 0x373A8099A0: pthread_mutex_lock (pthread_mutex_lock.c:51)
==11000==    by 0x4C7CADE: virMutexLock (threads-pthread.c:85)
==11000==    by 0x4D57C31: virNetClientStreamRaiseError (virnetclientstream.c:203)
==11000==    by 0x4D385E4: remoteStreamFinish (remote_driver.c:3541)
==11000==    by 0x4D182F9: virStreamFinish (libvirt.c:14157)
==11000==    by 0x40FDC4: cmdScreenshot (virsh.c:3075)
==11000==    by 0x42BA40: vshCommandRun (virsh.c:14922)
==11000==    by 0x42ECCA: main (virsh.c:16381)
==11000==  Address 0x59b86c0 is 16 bytes inside a block of size 216 free'd
==11000==    at 0x4A06928: free (vg_replace_malloc.c:427)
==11000==    by 0x4C69E2B: virFree (memory.c:310)
==11000==    by 0x4D57B56: virNetClientStreamFree (virnetclientstream.c:184)
==11000==    by 0x4D3DB7A: remoteDomainScreenshot (remote_client_bodies.h:1812)
==11000==    by 0x4CFD245: virDomainScreenshot (libvirt.c:2903)
==11000==    by 0x40FB73: cmdScreenshot (virsh.c:3029)
==11000==    by 0x42BA40: vshCommandRun (virsh.c:14922)
==11000==    by 0x42ECCA: main (virsh.c:16381)

13 years agosnapshot: implement getparent for vbox
Eric Blake [Thu, 29 Sep 2011 20:26:03 +0000 (14:26 -0600)]
snapshot: implement getparent for vbox

Built by copying from existing functions.

* src/vbox/vbox_tmpl.c (vboxDomainSnapshotGetParent): New function.

13 years agosnapshot: implement getparent for esx
Eric Blake [Thu, 29 Sep 2011 20:11:56 +0000 (14:11 -0600)]
snapshot: implement getparent for esx

Pretty easy to paste together compared to existing functions.

* src/esx/esx_driver.c (esxDomainSnapshotGetParent): New function.

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).

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.

13 years agovirsh: do not unlink NULL file
Marc-André Lureau [Sat, 1 Oct 2011 01:05:13 +0000 (03:05 +0200)]
virsh: do not unlink NULL file

error:could not take a screenshot of xp
==6216== Syscall param unlink(pathname) points to unaddressable byte(s)
==6216==    at 0x373A0D4937: unlink (syscall-template.S:82)
==6216==    by 0x40FD73: cmdScreenshot (virsh.c:3070)
==6216==    by 0x42BA0D: vshCommandRun (virsh.c:14920)
==6216==    by 0x42EC97: main (virsh.c:16379)
==6216==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==6216==
error:Requested operation is not valid: domain is not running

13 years agolvm storage backend: handle command_names=1 in lvm.conf
Serge E. Hallyn [Wed, 28 Sep 2011 20:08:34 +0000 (15:08 -0500)]
lvm storage backend: handle command_names=1 in lvm.conf

If the regexes supported (?:pvs)?, then we could handle this by
optionally matching but not returning the initial command name.  But it
doesn't.  So add a new char* argument to
virStorageBackendRunProgRegex().  If that argument is NULL then we act
as usual.  Otherwise, if the string at that argument is found at the
start of a returned line, we drop that before running the regex.

With this patch, virt-manager shows me lvs with command_names 1 or 0.

The definitions of PVS_BASE etc may want to be moved into the configure
scripts (though given how PVS is found, IIUC that could only happen if
pvs was a link to pvs_real), but in any case no sense dealing with that
until we're sure this is an ok way to handle it.

Signed-off-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agoqemu: Check for outstanding async job too
Michal Privoznik [Thu, 29 Sep 2011 13:14:13 +0000 (15:14 +0200)]
qemu: Check for outstanding async job too

Currently, qemuDomainGetXMLDesc and qemudDomainGetInfo check for
outstanding synchronous job before (eventual) monitor entering.
However, there can be already async job set, e.g. migration.

13 years agoqemu: Fix error message mentioning VNC instead of SPICE
Peter Krempa [Thu, 29 Sep 2011 13:00:20 +0000 (15:00 +0200)]
qemu: Fix error message mentioning VNC instead of SPICE

13 years agovirsh: Add 'reset' command for virsh
Xu He Jie [Thu, 29 Sep 2011 08:57:12 +0000 (16:57 +0800)]
virsh: Add 'reset' command for virsh

Signed-off-by: Xu He Jie <xuhj@linux.vnet.ibm.com>
13 years agoremote: Implement 'reset' for remote driver
Xu He Jie [Thu, 29 Sep 2011 08:56:24 +0000 (16:56 +0800)]
remote: Implement 'reset' for remote driver

Signed-off-by: Xu He Jie <xuhj@linux.vnet.ibm.com>
13 years agoqemu: Implement 'reset' for qemu driver
Xu He Jie [Thu, 29 Sep 2011 08:54:44 +0000 (16:54 +0800)]
qemu: Implement 'reset' for qemu driver

Signed-off-by: Xu He Jie <xuhj@linux.vnet.ibm.com>
13 years agoapi: Add public api for 'reset'
Xu He Jie [Thu, 29 Sep 2011 08:53:29 +0000 (16:53 +0800)]
api: Add public api for 'reset'

Add new public api for 'reset'.
It can reset domain immediately without any guest shutdown.

Signed-off-by: Xu He Jie <xuhj@linux.vnet.ibm.com>
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

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.

13 years agohyperv: Report an error for acceptable URI schemes with a transport
Matthias Bolte [Tue, 27 Sep 2011 11:11:14 +0000 (13:11 +0200)]
hyperv: Report an error for acceptable URI schemes with a transport

Before, URIs such as hyperv+ssh:// have been declined by the Hyper-V
driver resulting in the remote driver trying to connect to an
non-existing libvirtd.

Now such URIs trigger an error in the yper-V driver suggesting to
try again without the transport part in the scheme.

13 years agoesx: Report an error for acceptable URI schemes with a transport
Matthias Bolte [Tue, 27 Sep 2011 11:08:09 +0000 (13:08 +0200)]
esx: Report an error for acceptable URI schemes with a transport

Before, URIs such as esx+ssh:// have been declined by the ESX driver
resulting in the remote driver trying to connect to an non-existing
libvirtd.

Now such URIs trigger an error in the ESX driver suggesting to try
again without the transport part in the scheme.

13 years agoformatdomain.html.in: fix tickpolicy
Douglas Schilling Landgraf [Thu, 29 Sep 2011 00:58:00 +0000 (20:58 -0400)]
formatdomain.html.in: fix tickpolicy

there is no option "none":

>From libvirt/src/conf/domain_conf.c

<snip>
VIR_ENUM_IMPL(virDomainTimerTickpolicy,
VIR_DOMAIN_TIMER_TICKPOLICY_LAST,
              "delay",
              "catchup",
              "merge",
              "discard");
</snip>

Replacing with delay.

Signed-off-by: Douglas Schilling Landgraf <dougsland@redhat.com>
13 years agovirsh: describe attach-interface parameter target
Daniel Veillard [Wed, 28 Sep 2011 03:58:29 +0000 (11:58 +0800)]
virsh: describe attach-interface parameter target

This patch is based on a improvement suggested by Kazuhiro Kikuchi
of Fujitsu, it gives a description of the target parameter for that
command

* tools/virsh.pod: add description for target parameter of
  attach-interface

13 years agovirsh: update man page for cpu_shares parameter
Daniel Veillard [Wed, 28 Sep 2011 01:59:43 +0000 (09:59 +0800)]
virsh: update man page for cpu_shares parameter

The man page suggest that the cpu_shares parameter of schedinfo
allows values 0-262144, but the kernel remaps values 0 and 1 to
the minimum 2, just document that behaviour:

[root@test ~]# cat /cgroup/cpu/libvirt/qemu/cpu.shares
1024
[root@test ~]# echo 0 > /cgroup/cpu/libvirt/qemu/cpu.shares
[root@test ~]# cat /cgroup/cpu/libvirt/qemu/cpu.shares
2
[root@test ~]# echo 1 > /cgroup/cpu/libvirt/qemu/cpu.shares
[root@test ~]# cat /cgroup/cpu/libvirt/qemu/cpu.shares
2
[root@test ~]#

* tools/virsh.pod: update description of the cpu_shares parameter
  to indicate the values 0 and 1 are automatically changed by the
  kernel to minimal value 2

13 years agoqemu: Check for ejected media during startup and migration
Michal Privoznik [Tue, 13 Sep 2011 13:49:50 +0000 (15:49 +0200)]
qemu: Check for ejected media during startup and migration

If the daemon is restarted so we reconnect to monitor, cdrom media
can be ejected. In that case we don't want to show it in domain xml,
or require it on migration destination.

To check for disk status use 'info block' monitor command.

13 years agoqemu: add return value check
Alex Jia [Wed, 28 Sep 2011 08:00:49 +0000 (16:00 +0800)]
qemu: add return value check

* src/qemu/qemu_migration.c: if 'vmdef' is NULL, the function
  virDomainSaveConfig still dereferences it, it doesn't make
  sense, so should add return value check to make sure 'vmdef'
  is non-NULL before calling virDomainSaveConfig, in addition,
  in order to debug later, also should record error information
  into log.

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agosnapshot: implement getparent in qemu
Eric Blake [Sun, 25 Sep 2011 00:02:24 +0000 (18:02 -0600)]
snapshot: implement getparent in qemu

First hypervisor implementation of the new API.
Allows 'virsh snapshot-list --tree' to be more efficient.

* src/qemu/qemu_driver.c (qemuDomainSnapshotGetParent): New
function.

13 years agosnapshot: add virsh snapshot-list --tree
Eric Blake [Sat, 24 Sep 2011 23:42:50 +0000 (17:42 -0600)]
snapshot: add virsh snapshot-list --tree

Reuse the tree listing of nodedev-list, coupled with the new helper
function to efficiently grab snapshot parent names, to produce
tree output for a snapshot hierarchy.  For example:

$ virsh snapshot-list dom --tree
root1
 |
  +- sibling1
  +- sibling2
  |   |
  |   +- grandchild
  |
  +- sibling3

root2
 |
  +- child

* tools/virsh.c (cmdSnapshotList): Add --tree.
* tools/virsh.pod (snapshot-list): Document it.

13 years agosnapshot: refactor virsh snapshot parent computation
Eric Blake [Wed, 10 Aug 2011 23:31:04 +0000 (17:31 -0600)]
snapshot: refactor virsh snapshot parent computation

Make parent computation reusable, using virDomainSnapshotGetParent
when possible.

* tools/virsh.c (vshGetSnapshotParent): New helper.
(cmdSnapshotParent): Use it.

13 years agosnapshot: remote protocol for getparent
Eric Blake [Sat, 24 Sep 2011 19:19:35 +0000 (13:19 -0600)]
snapshot: remote protocol for getparent

Mostly straight-forward, although this is the first API that
returns a new snapshot based on a snapshot rather than a domain.

* src/remote/remote_protocol.x
(REMOTE_PROC_DOMAIN_SNAPSHOT_GET_PARENT): New rpc.
(remote_domain_snapshot_get_parent_args)
(remote_domain_snapshot_get_parent_ret): New structs.
* src/rpc/gendispatch.pl: Adjust generator.
* src/remote/remote_driver.c (remote_driver): Use it.
* src/remote_protocol-structs: Update.

13 years agosnapshot: new virDomainSnapshotGetParent API
Eric Blake [Fri, 23 Sep 2011 18:38:04 +0000 (12:38 -0600)]
snapshot: new virDomainSnapshotGetParent API

Although a client can already obtain a snapshot's parent by
dumping and parsing the xml, then doing a snapshot lookup by
name, it is more efficient to get the parent in one step, which
in turn will make operations that must traverse a snapshot
hierarchy easier to perform.

* include/libvirt/libvirt.h.in (virDomainSnapshotGetParent):
Declare.
* src/libvirt.c (virDomainSnapshotGetParent): New function.
* src/libvirt_public.syms: Export it.
* src/driver.h (virDrvDomainSnapshotGetParent): New callback.

13 years agodocs: document node device XML
Eric Blake [Tue, 27 Sep 2011 17:04:52 +0000 (11:04 -0600)]
docs: document node device XML

Coupled with the recent virsh nodedev-* doc patch, this should now
give a better picture of libvirt node device handling.

* docs/formatnode.html.in: Fill in page.

13 years agodocs: document virsh nodedev-* commands
Eric Blake [Fri, 23 Sep 2011 23:26:24 +0000 (17:26 -0600)]
docs: document virsh nodedev-* commands

This section of the man page was completely missing; I stumbled on
it when I had no clue that I had to use nodedev-reattach after
I was done playing with <hostdev> device passthrough to one of my
guests.

* tools/virsh.pod (NODEDEV COMMANDS): New section.
(attach-device, detach-device): Add cross-references.

13 years agosecurity: properly chown/label bidirectional and unidirectional fifos
Laine Stump [Tue, 27 Sep 2011 18:04:53 +0000 (14:04 -0400)]
security: properly chown/label bidirectional and unidirectional fifos

This patch fixes the regression with using named pipes for qemu serial
devices noted in:

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

The problem was that, while new code in libvirt looks for a single
bidirectional fifo of the name given in the config, then relabels that
and continues without looking for / relabelling the two unidirectional
fifos named ${name}.in and ${name}.out, qemu looks in the opposite
order. So if the user had naively created all three fifos, libvirt
would relabel the bidirectional fifo to allow qemu access, but qemu
would attempt to use the two unidirectional fifos and fail (because it
didn't have proper permissions/rights).

This patch changes the order that libvirt looks for the fifos to match
what qemu does - first it looks for the dual fifos, then it looks for
the single bidirectional fifo. If it finds the dual unidirectional
fifos first, it labels/chowns them and ignores any possible
bidirectional fifo.

(Note commit d37c6a3a (which first appeared in libvirt-0.9.2) added
the code that checked for a bidirectional fifo. Prior to that commit,
bidirectional fifos for serial devices didn't work because libvirt
always required the ${name}.(in|out) fifos to exist, and qemu would
always prefer those.

13 years agoqemu: Preserve fakeReboot flag in domain status
Jiri Denemark [Wed, 28 Sep 2011 10:10:13 +0000 (12:10 +0200)]
qemu: Preserve fakeReboot flag in domain status

Thus, when libvirtd is restarted, it will know if a domain is supposed
to be killed or reset when it shuts down.

13 years agoqemu: Finish domain shutdown on reconnect
Jiri Denemark [Tue, 27 Sep 2011 12:56:17 +0000 (14:56 +0200)]
qemu: Finish domain shutdown on reconnect

If a domain started with -no-shutdown shuts down while libvirtd is not
running, it will be seen as paused when libvirtd reconnects to it. Use
the paused reason to detect if a domain was stopped because of shutdown
and finish the process just as if a SHUTDOWN event is delivered from
qemu.

13 years agoqemu: Check domain status details when reconnecting monitor
Jiri Denemark [Tue, 27 Sep 2011 09:42:04 +0000 (11:42 +0200)]
qemu: Check domain status details when reconnecting monitor

Current qemu is able to give us detailed domain status (not just if it
is running or not) which we can translate into a status reason.

13 years agoqemu: Always remove domain object if MigratePrepare fails
Jiri Denemark [Mon, 26 Sep 2011 11:36:37 +0000 (13:36 +0200)]
qemu: Always remove domain object if MigratePrepare fails

If migration failed in Prepare phase after virDomainAssignDef and before
a job was started, the domain object was not properly removed.

13 years agofix AppArmor driver for pipe character devices
Jamie Strandboge [Wed, 28 Sep 2011 07:43:39 +0000 (15:43 +0800)]
fix AppArmor driver for pipe character devices

The AppArmor security driver adds only the path specified in the domain
XML for character devices of type 'pipe'. It should be using <path>.in
and <path>.out. We do this by creating a new vah_add_file_chardev() and
use it for char devices instead of vah_add_file(). Also adjust
valid_path() to accept S_FIFO (since qemu chardevs of type 'pipe' use
fifos). This is https://launchpad.net/bugs/832507

13 years agovirsh: Allow using complete <capabilities> elements with cpu-baseline
Peter Krempa [Thu, 15 Sep 2011 11:51:01 +0000 (13:51 +0200)]
virsh: Allow using complete <capabilities> elements with cpu-baseline

This patch cleans the cpu baseline function using new libvirt helper
functions and fixes XPath expression that selects <cpu> elements from
the source file, that can contain concatenated <capabilities> XMLs,
domain XMLs and bare <cpu> elements. The fixed XPath expression ensures
not to select NUMA <cpu id=... elements.

This patch also removes vshRealloc function, that remained unused after
cleaning up cpu-baseline.

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

13 years agovirsh: Allow using domain and capabilities XMLs with cpu-compare
Peter Krempa [Thu, 15 Sep 2011 07:18:04 +0000 (09:18 +0200)]
virsh: Allow using domain and capabilities XMLs with cpu-compare

This patch adds extraction of the <cpu> element from capabilities and
domain definition XML documents to improve user experience.

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

13 years agosnapshot: fix man page typos
Eric Blake [Tue, 27 Sep 2011 23:33:55 +0000 (17:33 -0600)]
snapshot: fix man page typos

pod2man from perl-5.8.8 (RHEL 5) errors out on ill-formed POD:

*** ERROR: unterminated I<...> at line 1114 in file virsh.pod
*** ERROR: unterminated I<...> at line 1851 in file virsh.pod

Newer pod2man appears to be more tolerant (which is a shame,
because it meant that this error is harder to detect).

* tools/virsh.pod (undefine, snapshot-current): Add missing >.

13 years agoqemu: add ability to set PCI device "rombar" on or off
Laine Stump [Tue, 20 Sep 2011 17:31:52 +0000 (13:31 -0400)]
qemu: add ability to set PCI device "rombar" on or off

This patch was made in response to:

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

In short, qemu's default for the rombar setting (which makes the
firmware ROM of a PCI device visible/not on the guest) was previously
0 (not visible), but they recently changed the default to 1
(visible). Unfortunately, there are some PCI devices that fail in the
guest when rombar is 1, so the setting must be exposed in libvirt to
prevent a regression in behavior (it will still require explicitly
setting <rom bar='off'/> in the guest XML).

rombar is forced on/off by adding:

  <rom bar='on|off'/>

inside a <hostdev> element that defines a PCI device. It is currently
ignored for all other types of devices.

At the moment there is no clean method to determine whether or not the
rombar option is supported by QEMU - this patch uses the advice of a
QEMU developer to assume support for qemu-0.12+. There is currently a
patch in the works to put this information in the output of "qemu-kvm
-device pci-assign,?", but of course if we switch to keying off that,
we would lose support for setting rombar on all the versions of qemu
between 0.12 and whatever version gets that patch.

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.

13 years agoqemu: Relax -no-shutdown check to [0.14.0, 0.15.50)
Jiri Denemark [Tue, 27 Sep 2011 12:46:35 +0000 (14:46 +0200)]
qemu: Relax -no-shutdown check to [0.14.0, 0.15.50)

SIGTERM handling for -no-shutdown is already fixed in qemu git and
libvirt can safely use it. The downside is that 0.15.50 version of qemu
can be any qemu compiled from git, even that without the fix for
SIGTERM. However, I think this patch is worth it since excluding 0.15.50
from the check makes testing current qemu with libvirt much easier and
someone running qemu from git should be able to rebuild fixed qemu from
git if they hit the problem with a hang on shutdown.

13 years agovirsh: Better document --copy-storage migrate options
Jiri Denemark [Mon, 26 Sep 2011 13:09:08 +0000 (15:09 +0200)]
virsh: Better document --copy-storage migrate options

Both --copy-storage-{all,inc} options require disk images to be present
on destination host.

13 years agovirsh: Enhance documentation of commands starting jobs
Jiri Denemark [Mon, 26 Sep 2011 12:55:22 +0000 (14:55 +0200)]
virsh: Enhance documentation of commands starting jobs

Some virsh commands start a (long-running) job that can be monitored
using domjobinfo and aborted with domjobabort. Let's be explicit about
this in virsh man page.

13 years agovirLockManagerNopInit: Rename flags to unused_flags
Michal Privoznik [Tue, 27 Sep 2011 09:11:14 +0000 (11:11 +0200)]
virLockManagerNopInit: Rename flags to unused_flags

As these might be not used and make syntax-check complains about checking
them via virCheckFlags.

13 years agodaemon: Don't remove pidfiles in init scripts
Peter Krempa [Mon, 26 Sep 2011 18:06:39 +0000 (20:06 +0200)]
daemon: Don't remove pidfiles in init scripts

Init scripts removed pid file of the daemon. Removing pid files may be
harmful as new api for crash-safe pidfiles is used (introduced by
c8a3a26).

13 years agodebug: Annotate some variables as unused
Michal Privoznik [Mon, 26 Sep 2011 16:51:47 +0000 (18:51 +0200)]
debug: Annotate some variables as unused

as they are not used with debugging turned off.

13 years agostorage: Do not break the whole vol lookup process in the middle
Osier Yang [Mon, 26 Sep 2011 06:30:44 +0000 (14:30 +0800)]
storage: Do not break the whole vol lookup process in the middle

* src/storage/storage_driver.c: As virStorageVolLookupByPath lookups
all the pool objs of the drivers, breaking when failing on getting
the stable path of the pool will just breaks the whole lookup process,
it can cause the API fails even if the vol exists indeed. It won't get
any benefit. This patch is to fix it.

13 years agomaint: update authors
Peter Krempa [Fri, 23 Sep 2011 17:15:37 +0000 (19:15 +0200)]
maint: update authors

13 years agoAdd unsafe cache mode support for disk driver
Oskari Saarenmaa [Thu, 22 Sep 2011 19:33:47 +0000 (22:33 +0300)]
Add unsafe cache mode support for disk driver

QEMU 0.13 introduced cache=unsafe for -drive, this patch exposes
it in the libvirt layer.

  * Introduced a new QEMU capability flag ($prefix_CACHE_UNSAFE),
    as even if $prefix_CACHE_V2 is set, we can't know if unsafe
    is supported.

  * Improved the reliability of qemu cache type detection.

13 years agoFix synchronous reading of stream data
Daniel P. Berrange [Wed, 21 Sep 2011 13:51:33 +0000 (14:51 +0100)]
Fix synchronous reading of stream data

commit 984840a2c292402926ad100aeea33f8859ff31a9 removed the
notification of waiting calls when VIR_NET_CONTINUE messages
arrive. This was to fix the case of a virStreamAbort() call
being prematurely notified of completion.

The problem is that sometimes there are dummy calls from a
virStreamRecv() call waiting that *do* need to be notified.

These dummy calls should have a status VIR_NET_CONTINUE. So
re-add the notification upon VIR_NET_CONTINUE, but only if
the waiter also has a status of VIR_NET_CONTINUE.

* src/rpc/virnetclient.c: Notify waiting call if stream data
  arrives
* src/rpc/virnetclientstream.c:  Mark dummy stream read packet
  with status VIR_NET_CONTINUE

13 years agoselinux: Correctly report warning if virt_use_nfs not set
Michal Privoznik [Thu, 22 Sep 2011 08:57:24 +0000 (10:57 +0200)]
selinux: Correctly report warning if virt_use_nfs not set

Previous patch c9b37fee tried to deal with virt_use_nfs. But
setfilecon() returns EOPNOTSUPP on NFS so we need to move the
warning to else branch.

13 years agovirsh: Improve virsh manual for virsh memtune command
Peter Krempa [Thu, 22 Sep 2011 10:14:18 +0000 (12:14 +0200)]
virsh: Improve virsh manual for virsh memtune command

Commit 0a22f54 added --min-guarantee option for the memtune command.
This option is supported only by the ESX hypervisor. This patch adds a
statement about this fact, to prevent user confusion.

This patch also adds explanation how to clear/set to unlimited the
memory tunables. (documments the -1 value).

13 years agovirsh: Do not ignore the specified flags for cmdSaveImageDefine
Osier Yang [Thu, 22 Sep 2011 12:01:06 +0000 (20:01 +0800)]
virsh: Do not ignore the specified flags for cmdSaveImageDefine

Introduced by commit 42c52d53c, which added the support for new
flags, but forgot to update the API use to pass the flags.

13 years agoqemu: Transfer inactive XML among cookie
Michal Privoznik [Thu, 15 Sep 2011 13:13:11 +0000 (15:13 +0200)]
qemu: Transfer inactive XML among cookie

If a domain has inactive XML we want to transfer it to destination
when migrating with VIR_MIGRATE_PERSIST_DEST. In order to harm
the migration protocol as least as possible, a optional cookie was
chosen.

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

13 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.

13 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.