]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
13 years agosnapshot: framework for more efficient relation traversal
Eric Blake [Fri, 7 Oct 2011 18:41:50 +0000 (12:41 -0600)]
snapshot: framework for more efficient relation traversal

No one was using virDomainSnapshotHasChildren, but that was an
O(n) function.  Exposing and tracking a bit more metadata for each
snapshot will allow the same query to be made with an O(1) query
of the member field.  For single snapshot operations (create,
delete), callers can be trusted to maintain the metadata themselves,
but for reloading, we can't compute parents as we go since there
is no guarantee that parents were parsed before children, so we also
provide a function to refresh the relationships, and which can
be used to detect if the user has ignored our warnings and been
directly modifying files in /var/lib/libvirt/qemu/snapshot.  This
patch only adds metadata; later patches will actually use it.

This layout intentionally hardcodes the size of each snapshot struct,
by tracking sibling pointers, rather than having to deal with the
headache of yet more memory management by directly sticking a
dynamically sized child[] on each parent.

* src/conf/domain_conf.h (_virDomainSnapshotObj)
(_virDomainSnapshotObjList): Add members.
(virDomainSnapshotUpdateRelations, virDomainSnapshotDropParent):
New prototypes.
(virDomainSnapshotHasChildren): Delete.
* src/conf/domain_conf.c (virDomainSnapshotSetRelations)
(virDomainSnapshotUpdateRelations, virDomainSnapshotDropParent):
New functions.
(virDomainSnapshotHasChildren): Drop unused function.
* src/libvirt_private.syms (domain_conf): Update exports.

13 years agosnapshot: use correct qmp monitor command
Eric Blake [Mon, 10 Oct 2011 20:20:38 +0000 (14:20 -0600)]
snapshot: use correct qmp monitor command

To date, JSON disk snapshots worked by accident, as they were always
using hmp fallback due to a typo in commit e702b5b not picking up
on the (intentional) difference in command names between the two
monitor protocols.

* src/qemu/qemu_monitor_json.c (qemuMonitorJSONDiskSnapshot):
Spell QMP command correctly.
Reported by Luiz Capitulino.

13 years agosnapshot: virsh shorthand for operating on current snap
Eric Blake [Thu, 6 Oct 2011 21:01:18 +0000 (15:01 -0600)]
snapshot: virsh shorthand for operating on current snap

Rather than having to do:

$ virsh snapshot-revert dom $(virsh snapshot-current dom --name)

I thought it would be nice to do:

$ virsh snapshot-revert dom --current

I didn't add 'virsh snapshot-dumpxml --current' since we already have
'virsh snapshot-current' for the same task.  snapshot-list accepted
a name but did not require it, and that remains the case, with
--current serving in place of that name.  For all other commands,
name used to be required, and can now be replaced by --current;
I intentionally made it so that omitting both --current and a name
is an error (having the absence of a name imply --current seems
just a bit too magic, so --current must be explicit).  I also had
to keep snapshot-edit backwards-compatible, as the only command
that already had a --current argument alongside a name, which still
works to both edit a named snapshot and make it current.

* tools/virsh.c (vshLookupSnapshot): New helper function.
(cmdSnapshotEdit, cmdSnapshotList, cmdSnapshotParent)
(cmdSnapshotDelete, cmdDomainSnapshotRevert): Use it, adding an
option where needed.
* tools/virsh.pod (snapshot-delete, snapshot-edit)
(snapshot-list, snapshot-parent, snapshot-revert): Document
use of --current.
(snapshot-dumpxml): Mention alternative.

13 years agobuild: fix mingw build without sasl
Eric Blake [Tue, 11 Oct 2011 22:22:44 +0000 (16:22 -0600)]
build: fix mingw build without sasl

Detected by autogen.sh on a cross-mingw build:

Creating library file: .libs/libvirt.dll.a
Cannot export virNetSASLContextCheckIdentity: symbol not defined
Cannot export virNetSASLContextNewServer: symbol not defined
...

* src/libvirt_private.syms (virnetsaslcontext.h): Move symbols...
* src/libvirt_sasl.syms: ...to new file.
* src/Makefile.am (USED_SYM_FILES) [HAVE_SASL]: Use new file.
(EXTRA_DIST): Ship it.

13 years agobuild: fix 'make rpm'
Eric Blake [Tue, 11 Oct 2011 21:44:55 +0000 (15:44 -0600)]
build: fix 'make rpm'

Since commit ddf3bd3, 'make rpm' failed with:

RPM build errors:
    File not found: /home/remote/eblake/rpmbuild/BUILDROOT/libvirt-0.9.6-1.fc14.eblake1318366440.x86_64/usr/share/systemtap/tapset/libvirtd.stp

* libvirt.spec.in (with_dtrace): Match installed .stp files.

13 years agobuild: fix 'make distcheck'
Eric Blake [Tue, 11 Oct 2011 21:10:17 +0000 (15:10 -0600)]
build: fix 'make distcheck'

I got these distcheck failures with sanlock enabled:

ERROR: files left in build directory after distclean:
./tools/virt-sanlock-cleanup
./src/locking/qemu-sanlock.conf

* src/Makefile.am (DISTCLEANFILES) [HAVE_SANLOCK]: Clean built
file.
* tools/Makefile.am (DISTCLEANFILES): Likewise.

13 years agobuild: ship helper scripts
Eric Blake [Tue, 11 Oct 2011 20:33:43 +0000 (14:33 -0600)]
build: ship helper scripts

Otherwise, 'make rpm' fails with:

  GEN    libvirt_qemu.def
make[2]: *** No rule to make target `dtrace2systemtap.pl', needed by `libvirt_probes.stp'.  Stop.

* src/Makefile.am (EXTRA_DIST): Add recent script additions.

13 years agodisable xenlight for non-Xen platforms
Dan Horák [Tue, 11 Oct 2011 15:30:50 +0000 (17:30 +0200)]
disable xenlight for non-Xen platforms

when building libvirt in Fedora/s390x I've found that xenlight needs to
be explicitly disabled in the spec file. Configure properly sets the
library as non-existent, but the %files section still wants to package
the 3 /var/*/libvirt/libxl directories. See also
https://bugzilla.redhat.com/show_bug.cgi?id=745020

13 years agobuild: fix 'make check' linkage with dtrace
Eric Blake [Tue, 11 Oct 2011 19:18:37 +0000 (13:18 -0600)]
build: fix 'make check' linkage with dtrace

Building on Linux with dtrace enabled was failing 'make check':

  CCLD   nodeinfotest
../src/.libs/libvirt_test.a(libvirt_net_rpc_client_la-virnetclient.o): In function `virNetClientNew':
/home/remote/eblake/libvirt/src/rpc/virnetclient.c:162: undefined reference to `libvirt_rpc_client_new_semaphore'

On looking further, I see some earlier warnings emitted from libtool:

*** Warning: Linking the shared library libvirt.la against the non-libtool
*** objects  probes.o is not portable!

Since src/probes.o is only built on Linux, and even then, only when
dtrace is enabled, this failure does not affect other platforms, and
despite libtool warning that it is not generally portable, it is not
a problem for our use-case in libvirt.la.  But it turns out that while
libtool is willing to jam raw .o files into an installed shared
library (libvirt.la becomes libvirt.so), it is NOT willing to jam
the same .o file into the convenience library libvirt_test.la.
Perhaps this is a bug in libtool, but even if we get libtool fixed,
libvirt must continue to build on platforms with older libtool.  So,
the fix is the same as we are already using for the libvirt_lxc
executable - don't rely on the .o file being in the convenience
library, but instead use LDADD to pull it in directly.

* tests/Makefile.am (PROBES_O): New macro.
(LDADDS): Use it to fix link errors.

13 years agobuild: Fix VPATH build with new probes
Jiri Denemark [Tue, 11 Oct 2011 14:45:57 +0000 (16:45 +0200)]
build: Fix VPATH build with new probes

13 years agoFix deps for probes.o to ensure correct build ordering
Daniel P. Berrange [Tue, 11 Oct 2011 15:43:58 +0000 (16:43 +0100)]
Fix deps for probes.o to ensure correct build ordering

13 years agoUpdate examples for probing with systemtap
Daniel P. Berrange [Fri, 7 Oct 2011 15:36:05 +0000 (16:36 +0100)]
Update examples for probing with systemtap

This removes the old example for legacy probes and adds two
new scripts demonstrating many of the new probe point facilities.

The rpc-monitor.stp script will print out friendly details of all
RPC traffic between a libvirt client/server. This is incredibly
useful in seeing what RPC calls are being made, and also debugging
problems in the RPC protocol code

The events.stp script will print out lots of info about the poll
event loop, which is useful for debugging event handling problems

* examples/systemtap/events.stp, examples/systemtap/rpc-monitor.stp:
  New examples
* examples/systemtap/client.stp: Remove obsolete example

13 years agoRewrite all the DTrace/SystemTAP probing
Daniel P. Berrange [Fri, 30 Sep 2011 13:40:23 +0000 (14:40 +0100)]
Rewrite all the DTrace/SystemTAP probing

The libvirtd daemon had a few crude system tap probes. Some of
these were broken during the RPC rewrite. The new modular RPC
code is structured in a way that allows much more effective
tracing. Instead of trying to hook up the original probes,
define a new set of probes for the RPC and event code.

The master probes file is now src/probes.d.  This contains
probes for virNetServerClientPtr, virNetClientPtr, virSocketPtr
virNetTLSContextPtr and virNetTLSSessionPtr modules. Also add
probes for the poll event loop.

The src/dtrace2systemtap.pl script can convert the probes.d
file into a libvirt_probes.stp file to make use from systemtap
much simpler.

The src/rpc/gensystemtap.pl script can generate a set of
systemtap functions for translating RPC enum values into
printable strings. This works for all RPC header enums (program,
type, status, procedure) and also the authentication enum

The PROBE macro will automatically generate a VIR_DEBUG
statement, so any place with a PROBE can remove any existing
manual DEBUG statements.

* daemon/libvirtd.stp, daemon/probes.d: Remove obsolete probing
* daemon/libvirtd.h: Remove probe macros
* daemon/Makefile.am: Remove all probe buildings/install
* daemon/remote.c: Update authentication probes
* src/dtrace2systemtap.pl, src/rpc/gensystemtap.pl: Scripts
  to generate STP files
* src/internal.h: Add probe macros
* src/probes.d: Master list of probes
* src/rpc/virnetclient.c, src/rpc/virnetserverclient.c,
  src/rpc/virnetsocket.c, src/rpc/virnettlscontext.c,
  src/util/event_poll.c: Insert probe points, removing any
  DEBUG statements that duplicate the info

13 years agoFix missing lock calls on virNetTLSContextRef
Daniel P. Berrange [Fri, 7 Oct 2011 15:42:54 +0000 (16:42 +0100)]
Fix missing lock calls on virNetTLSContextRef

The virNetTLSContextRef API forgot to acquire/release the lock
while changing ctxt->refs

* src/rpc/virnettlscontext.c: Add lock calls

13 years agoRefactor TLS to facilitate dynamic probing
Daniel P. Berrange [Fri, 7 Oct 2011 15:42:41 +0000 (16:42 +0100)]
Refactor TLS to facilitate dynamic probing

Pull the call to gnutls_x509_crt_get_dn up into a higher function
so that the 'dname' variable will be available for probe points

* src/rpc/virnettlscontext.c: Pull gnutls_x509_crt_get_dn up
  one level

13 years agoAdd virSocketRef API to facilitate dynamic probing
Daniel P. Berrange [Fri, 7 Oct 2011 15:39:37 +0000 (16:39 +0100)]
Add virSocketRef API to facilitate dynamic probing

Instead of directly manipulating sock->refs, add a virSocketRef
API

* src/rpc/virnetsocket.c, src/rpc/virnetsocket.h: Add virSocketRef

13 years agoIf receiving a stream error, mark EOF on the stream
Daniel P. Berrange [Fri, 7 Oct 2011 10:35:31 +0000 (11:35 +0100)]
If receiving a stream error, mark EOF on the stream

If we receive an error on the stream, set the EOF marker so
that any further (bogus) incoming data is dropped.

* src/rpc/virnetclientstream.c: Set EOF on stream

13 years agoMake libvirt.so include the RPC server code
Daniel P. Berrange [Fri, 30 Sep 2011 13:38:39 +0000 (14:38 +0100)]
Make libvirt.so include the RPC server code

To avoid static linking libvirtd to the RPC server code, which
then prevents sane introduction of DTrace probes, put it all
in the libvirt.so, and export it

* daemon/Makefile.am: Don't link to RPC libraries
* src/Makefile.am: Link all RPC libraries to libvirt.so
* src/libvirt_private.syms: Export all RPC functions

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

It was fairly trivial to return snapshot listing based on a
point in the hierarchy, rather than starting at all roots.

* src/esx/esx_driver.c (esxDomainSnapshotNumChildren)
(esxDomainSnapshotListChildrenNames): New functions.

13 years agosnapshot: implement snapshot children listing in qemu
Eric Blake [Thu, 29 Sep 2011 18:42:36 +0000 (12:42 -0600)]
snapshot: implement snapshot children listing in qemu

Not too hard to wire up.  The trickiest part is realizing that
listing children of a snapshot cannot use SNAPSHOT_LIST_ROOTS,
and that we overloaded that bit to also mean SNAPSHOT_LIST_DESCENDANTS;
we use that bit to decide which iteration to use, but don't want
the existing counting/listing functions to see that bit.

* src/conf/domain_conf.h (virDomainSnapshotObjListNumFrom)
(virDomainSnapshotObjListGetNamesFrom): New prototypes.
* src/conf/domain_conf.c (virDomainSnapshotObjListNumFrom)
(virDomainSnapshotObjListGetNamesFrom): New functions.
* src/libvirt_private.syms (domain_conf.h): Export them.
* src/qemu/qemu_driver.c (qemuDomainSnapshotNumChildren)
(qemuDomainSnapshotListChildrenNames): New functions.

13 years agosnapshot: remote protocol for snapshot children
Eric Blake [Thu, 29 Sep 2011 18:06:49 +0000 (12:06 -0600)]
snapshot: remote protocol for snapshot children

Very mechanical.  I'm so glad we've automated the generation of things,
compared to what it was in 0.8.x days, where this would be much longer.

* src/remote/remote_protocol.x
(REMOTE_PROC_DOMAIN_SNAPSHOT_NUM_CHILDREN)
(REMOTE_PROC_DOMAIN_SNAPSHOT_LIST_CHILDREN_NAMES): New rpcs.
(remote_domain_snapshot_num_children_args)
(remote_domain_snapshot_num_children_ret)
(remote_domain_snapshot_list_children_names_args)
(remote_domain_snapshot_list_children_names_ret): New structs.
* src/remote/remote_driver.c (remote_driver): Use it.
* src/remote_protocol-structs: Update.

13 years agosnapshot: virsh fallback for snapshot-list --descendants --from
Eric Blake [Thu, 29 Sep 2011 22:31:02 +0000 (16:31 -0600)]
snapshot: virsh fallback for snapshot-list --descendants --from

Given a list of snapshots and their parents, finding all descendants
requires a hairy traversal.  This code is O(n^3); it could maybe be
made to scale O(n^2) with the use of a hash table, but that costs more
memory.  Hopefully there aren't too many people with a hierarchy
so large as to approach REMOTE_DOMAIN_SNAPSHOT_LIST_NAMES_MAX (1024).

* tools/virsh.c (cmdSnapshotList): Add final fallback.

13 years agosnapshot: virsh fallback for snapshot-list --from children
Eric Blake [Thu, 29 Sep 2011 21:57:52 +0000 (15:57 -0600)]
snapshot: virsh fallback for snapshot-list --from children

Iterating over one level of children requires parsing all snapshots
and their parents; a bit of code shuffling makes it pretty easy
to do this as well.

* tools/virsh.c (cmdSnapshotList): Add another fallback.

13 years agosnapshot: virsh fallback for snapshot-list --tree --from
Eric Blake [Thu, 29 Sep 2011 21:18:50 +0000 (15:18 -0600)]
snapshot: virsh fallback for snapshot-list --tree --from

Emulating --from requires grabbing the entire list of snapshots
and their parents, and recursively iterating over the list from
the point of interest - but we already do that for --tree.  This
turns on emulation for that situation.

* tools/virsh.c (__vshControl): Rename member.
(vshReconnect, cmdConnect, vshGetSnapshotParent): Update clients.
(cmdSnapshotList): Add fallback.

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.