]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/log
people/liuw/libxenctrl-split/libvirt.git
13 years agoPerform feature flag compat checking in QEMU migration cookies
Daniel P. Berrange [Wed, 18 May 2011 15:33:17 +0000 (11:33 -0400)]
Perform feature flag compat checking in QEMU migration cookies

To allow new mandatory migration cookie data to be introduced,
add support for checking supported feature flags when parsing
migration cookie.

* src/qemu/qemu_migration.c: Feature flag checking in migration
  cookie parsing

13 years agoReplace all remaining setgid/setuid calls with virSetUIDGID
Jiri Denemark [Sun, 22 May 2011 14:05:07 +0000 (17:05 +0300)]
Replace all remaining setgid/setuid calls with virSetUIDGID

Two additional places need initgroups call to properly work in an
environment where the UID is allowed to open/create stuff through its
supplementary groups.

13 years agoutil: Keep errno set to the root error after when returning from virSetUIDGID
Jiri Denemark [Sun, 22 May 2011 14:16:44 +0000 (17:16 +0300)]
util: Keep errno set to the root error after when returning from virSetUIDGID

13 years agopython: Don't free must-not-free variables
Michal Privoznik [Mon, 23 May 2011 12:41:00 +0000 (14:41 +0200)]
python: Don't free must-not-free variables

py_str() function call PyString_AsString(). As written in documentation,
the caller must not free the returned value, because it points to some
internal structures.

13 years agostorage: Add comment to picking return value of qemu-img
Michal Privoznik [Tue, 24 May 2011 06:54:37 +0000 (08:54 +0200)]
storage: Add comment to picking return value of qemu-img

Commit d7b2679253504d6defa9fc7159b572cfd6a25a95 introduced
a return value picking of qemu-img on '-h', but without any comment.

13 years agospice: support streaming-video parameter
Alon Levy [Mon, 23 May 2011 15:16:42 +0000 (18:16 +0300)]
spice: support streaming-video parameter

This adds a streaming-video=filter|all|off attribute. It is used to change
the behavior of video stream detection in spice, the default is filter (the
default for libvirt is not to specify it - the actual default is defined in
libspice-server.so).

Usage:

    <graphics type='spice' autoport='yes'>
      <streaming mode='off'/>
    </graphics>

Tested with the above and with tests/qemuxml2argvtest.

Signed-off-by: Alon Levy <alevy@redhat.com>
13 years agonwfilter: enable filtering of gratuitous ARP packets
Stefan Berger [Mon, 23 May 2011 23:41:18 +0000 (19:41 -0400)]
nwfilter: enable filtering of gratuitous ARP packets

This patch enables filtering of gratuitous ARP packets using the following XML:

<rule action='accept' direction='in' priority='425'>
<arp gratuitous='true'/>
</rule>

13 years agoqemu: don't require is_kvm for vhost-net support
Laine Stump [Mon, 23 May 2011 16:59:41 +0000 (12:59 -0400)]
qemu: don't require is_kvm for vhost-net support

This was discussed in:

  https://www.redhat.com/archives/libvir-list/2011-May/msg01370.html

The capabilities code only sets the flag to allow use of vhost-net if
kvm is detected (set if the help string contains "(qemu-kvm-" or
"(kvm-"), but actually vhost-net is available in some qemu builds that
don't have kvm in their name, so just checking for ",vhost=" is enough.

13 years agoUse per-user TLS certificates when possible
Doug Goldstein [Fri, 20 May 2011 20:18:09 +0000 (15:18 -0500)]
Use per-user TLS certificates when possible

When using TLS authentication and operating as the non-root user,
initially attempt to use that specific user's TLS certificates before
attempting to use the system wide TLS certificates.

Signed-off-by: Doug Goldstein <cardoe@cardoe.com>
13 years agopython: Fix typo in bindings
Michal Privoznik [Mon, 23 May 2011 08:51:46 +0000 (10:51 +0200)]
python: Fix typo in bindings

This typo caused a bug in which we wanted to free() invalid pointer.

13 years agostorage: pick return value of qemu-img
Michal Privoznik [Mon, 23 May 2011 07:08:01 +0000 (09:08 +0200)]
storage: pick return value of qemu-img

qemu-img returns non-zero status on -h. Therefore we need to
provide virCommandRun() a non-NULL exit status pointer.

13 years agobuild: generate files when building without libvirtd
Wen Congyang [Fri, 13 May 2011 08:02:13 +0000 (16:02 +0800)]
build: generate files when building without libvirtd

Steps to reproduce this problem:
1. # ./autogen.sh --without-libvirtd
2. # make dist
   ...
   make[1]: Entering directory `/home/wency/source/libvirt-nodaemon/daemon'
   make[1]: *** No rule to make target `remote_dispatch_prototypes.h', needed by `distdir'.  Stop.
   make[1]: Leaving directory `/home/wency/source/libvirt-nodaemon/daemon'
   make: *** [distdir] Error 1

13 years agodocs: Fix error syntax of vcpupin example XML
Osier Yang [Sat, 21 May 2011 09:12:23 +0000 (17:12 +0800)]
docs: Fix error syntax of vcpupin example XML

Lacks of "/", push this directly in trivial rule.

13 years agoremote generator: Add special case for virConnectGetType
Matthias Bolte [Mon, 16 May 2011 18:10:06 +0000 (20:10 +0200)]
remote generator: Add special case for virConnectGetType

13 years agolibvirt.spec: /var/cache/libvirt should be 0711.
Richard W.M. Jones [Fri, 20 May 2011 15:18:11 +0000 (16:18 +0100)]
libvirt.spec: /var/cache/libvirt should be 0711.

This allows qemu to create files in /var/cache/libvirt/qemu/, and
specifically is required to fix virDomainMemoryPeek.

13 years agoremote: remove bogus virDomainFree.
Richard W.M. Jones [Fri, 20 May 2011 14:55:40 +0000 (15:55 +0100)]
remote: remove bogus virDomainFree.

13 years agoqemudDomainMemoryPeek: change ownership/selinux label on temporary file.
Richard W.M. Jones [Fri, 20 May 2011 12:56:46 +0000 (13:56 +0100)]
qemudDomainMemoryPeek: change ownership/selinux label on temporary file.

Otherwise qemu is unable to write to it, with the error:

libvir: QEMU error : internal error unable to execute QEMU command 'memsave': Could not open '/var/cache/libvirt/qemu/qemu.mem.RRNvLv'

13 years agoremote generator: Don't rely on $_ being stable over a large function
Matthias Bolte [Sun, 15 May 2011 06:14:35 +0000 (08:14 +0200)]
remote generator: Don't rely on $_ being stable over a large function

Replace $calls{$_} with $call in the dispatch bodies generator function.

No functional change included.

13 years agobuild: require newer gettext
Eric Blake [Thu, 12 May 2011 15:29:51 +0000 (09:29 -0600)]
build: require newer gettext

Now that RHEL 5.6 ships with gettext 0.17, we can get out of the
stone age and use the newer gettext capabilities and improved
macros for certain configure tests.

* configure.ac (AM_GNU_GETTEXT_VERSION): Bump to 0.17.
(MKINSTALLDIRS): Delete hack that is no longer needed.
* bootstrap.conf (buildreq): Check for minimum gettext version.
Based on a report by Wen Congyang.

13 years agovirsh: Use Env variables for debug level and logfile
Supriya Kannery [Mon, 9 May 2011 07:08:06 +0000 (12:38 +0530)]
virsh: Use Env variables for debug level and logfile

Use variables VIRSH_DEBUG and VIRSH_LOG_FILE for controlling virsh logging.

Signed-off-by: Supriya Kannery <supriyak@in.ibm.com>
13 years agoDon't generate cookies with v2 migration protocol.
Daniel P. Berrange [Wed, 18 May 2011 16:34:08 +0000 (12:34 -0400)]
Don't generate cookies with v2 migration protocol.

The v2 migration protocol had a limit on cookie length that was
too small to be useful for QEMU. Avoid generating cookies with
v2 protocol, so that old libvirtd can still reliably migrate a
guest to new libvirtd uses v2 protocol.

* src/qemu/qemu_driver.c: Avoid migration cookies with v2
  migration

13 years agoFix QEMU migration cookie crash for guests with no graphics
Daniel P. Berrange [Tue, 17 May 2011 08:54:22 +0000 (04:54 -0400)]
Fix QEMU migration cookie crash for guests with no graphics

When generating a cookie for a guest with no data, the
QEMU_MIGRATION_COOKIE_GRAPHICS flag was set even if no
graphics data was added. Avoid setting the flag unless
it was needed, also add a safety check for mig->graphics
being non-NULL

* src/qemu/qemu_migration.c: Avoid cookie crash for guest
  with no graphics

13 years agoEnsure p2p and direct migration use the new v3 protocol if available
Daniel P. Berrange [Tue, 17 May 2011 12:38:30 +0000 (08:38 -0400)]
Ensure p2p and direct migration use the new v3 protocol if available

The internal virDomainMigratePeer2Peer and virDomainMigrateDirect
helper methods were not checking whether the target supports the
v3 migration protocol.

* src/libvirt.c: Use v3 migration protocol for p2p/direct
  migration if available.

13 years agoBlank out the 'listenAddr' parameter if empty string
Daniel P. Berrange [Wed, 18 May 2011 13:52:26 +0000 (09:52 -0400)]
Blank out the 'listenAddr' parameter if empty string

Some bogus apps are generating a VNC/SPICE/RFB listen attribute
with no content. This then causes a failure with the graphics
migration cookie parsing. Blank out the 'listenAddr' parameter
after parsing domain XML if it is the empty string, so the host
default takes over

* src/qemu/qemu_migration.c: Blank out listenAddr parameter
  if empty

13 years agoremote: remove special case for getting version
Eric Blake [Wed, 11 May 2011 22:48:35 +0000 (16:48 -0600)]
remote: remove special case for getting version

The on-the-wire protocol is identical; XDR guarantees that
both 'hyper' and 'unsigned hyper' are transmitted as 8 bytes.

* src/remote/remote_protocol.x (remote_get_version_ret)
(remote_get_lib_version_ret): Match public API.
* daemon/remote_generator.pl: Drop special case.
* src/remote_protocol-structs: Reflect updated type.

13 years agobuild: silence clang false positive
Eric Blake [Thu, 12 May 2011 01:41:46 +0000 (19:41 -0600)]
build: silence clang false positive

Clang couldn't quite see that the same condition of
(flags & VIR_DOMAIN_MEM_CONFIG) is used twice, such that
the second block is guaranteed that def was assigned in
the first block.

* src/libxl/libxl_driver.c (libxlDomainSetMemoryFlags): Add a hint
for clang.

13 years agovirsh: optimize creation of default connection
Eric Blake [Mon, 14 Mar 2011 20:30:24 +0000 (14:30 -0600)]
virsh: optimize creation of default connection

Ramon de Carvalho Valle reported a problem with:
virsh connect qemu:///system
as a non-root user.  The real root problem appears to be a regression
in libvirtd being auto-started on the default qemu:///session URI;
however, the symptom points to an independent flaw in virsh - we
shouldn't be wasting efforts on making a connection if we aren't going
to be using that connection.  Fixing virsh avoids Ramon's issue, while
I work in the meantime to fix the real libvirtd regression.

This patch looks big, but that's because 'gcc -Wmissing-field-initializers'
gets triggered by './autobuild.sh --enable-compile-warnings=error', so I
had to add 0 initialization to everyone (rather than my preference of
just adding the non-zero flags to virshCmds and to cmdConnect).

Meanwhile, if you use 'virsh -c URI', the connection must succeed; this
patch _only_ optimizes the default connection to be deferred to a later
point where we know if a particular command to be run needs a connection.

* tools/virsh.c (VSH_CMD_FLAG_NOCONNECT): New flag.
(vshCmdDef): Add new flags field.
(vshCommandRun): Honor new flag.
(domManagementCmds, domMonitoringCmds, storagePoolCmds)
(storageVolCmds, networkCmds, nodedevCmds, ifaceCmds)
(nwfilterCmds, secretCmds, virshCmds, snapshotCmds)
(hostAndHypervisorCmds): Populate new field.
(vshReconnect): Don't warn on initial connection.

13 years agoImprove invalid argument checks for the public API
Matthias Bolte [Wed, 18 May 2011 09:42:50 +0000 (11:42 +0200)]
Improve invalid argument checks for the public API

13 years agoClarify that virDomainGet(Memory|Blkio)Parameters doesn't support subsets
Matthias Bolte [Wed, 18 May 2011 09:33:42 +0000 (11:33 +0200)]
Clarify that virDomainGet(Memory|Blkio)Parameters doesn't support subsets

Improve invalid argument checks in the size query case. The drivers already
relied on this unchecked behavior.

Relax the implementation of virDomainGet(Memory|Blkio)MemoryParameters
in the drivers and allow to pass more memory than necessary for all
parameters.

13 years agoClarify that virDomainSet(Memory|Blkio)Parameters can take parameter subsets
Matthias Bolte [Wed, 18 May 2011 09:24:07 +0000 (11:24 +0200)]
Clarify that virDomainSet(Memory|Blkio)Parameters can take parameter subsets

13 years agoClarify that virDomainSetSchedulerParameters(Flags) can take subsets
Matthias Bolte [Wed, 18 May 2011 09:04:12 +0000 (11:04 +0200)]
Clarify that virDomainSetSchedulerParameters(Flags) can take subsets

Add invalid argument checks for params and nparams to the public API
and remove them from the drivers (e.g. xend).

Add subset handling to libxl and test drivers.

13 years agoClarify the semantic of virDomainGetSchedulerParameters arguments
Matthias Bolte [Wed, 18 May 2011 08:52:57 +0000 (10:52 +0200)]
Clarify the semantic of virDomainGetSchedulerParameters arguments

params and nparams are essential and cannot be NULL. Check this in
libvirt.c and remove redundant checks from the drivers (e.g. xend).

Instead of enforcing that nparams must point to exact same value as
returned by virDomainGetSchedulerType relax this to a lower bound
check. This is what some drivers (e.g. xen hypervisor and esx)
already did. Other drivers (e.g. xend) didn't check nparams at all
and assumed that there is enough space in params.

Unify the behavior in all drivers to a lower bound check and update
nparams to the number of valid values in params on success.

13 years agoClarify semantic of nparams argument of virDomainGetSchedulerType
Matthias Bolte [Wed, 18 May 2011 07:55:32 +0000 (09:55 +0200)]
Clarify semantic of nparams argument of virDomainGetSchedulerType

Some drivers assumed it can be NULL (e.g. qemu and lxc) and check it
before assigning to it, other drivers assumed it must be non-NULL
(e.g. test and esx) and just assigned to it.

Unify this to nparams being optional and document it.

13 years agoFix messages using VIR_ERR_XML_ERROR
Cole Robinson [Thu, 12 May 2011 21:22:29 +0000 (17:22 -0400)]
Fix messages using VIR_ERR_XML_ERROR

This error code has existed since the dawn of time, yet the messages it
generates are almost universally busted. Here's a small sampling:

src/conf/domain_conf.c:4889 : XML description for missing root element is not well formed or invalid
src/conf/domain_conf.c:4951 : XML description for unknown device type is not well formed or invalid
src/conf/domain_conf.c:5460 : XML description for maximum vcpus must be an integer is not well formed or invalid
src/conf/domain_conf.c:5468 : XML description for invalid maxvcpus %(count)lu is not well formed or invalid

Fix up the error code to instead be

XML error: <msg>

Adjust the few locations that were using the original correctly (or shouldn't
have been using the error code at all).

v2:
    Fix wording of error code without a passed argument

13 years agolibvirt.h: consolidate typed parameter handling
Eric Blake [Tue, 17 May 2011 17:44:53 +0000 (11:44 -0600)]
libvirt.h: consolidate typed parameter handling

The new type is identical to the three old types that it replaces,
and by creating a common type, this allows future patches to share
common code that manipulates typed parameters.

This change is backwards-compatible in API (recompilation works
without any edits) and ABI (an older client that has not been
recompiled uses the same layout) for code using only public
names; only code using private names (those beginning with _)
will have to adapt.

* include/libvirt/libvirt.h.in (virTypedParameterType)
(VIR_TYPED_PARAM_FIELD_LENGTH, _virTypedParameter): New enum,
macro, and type.
(virSchedParameter, virBlkioParameter, virMemoryParameter):
Rewrite in terms of a common type, while keeping all old public
names for backwards compatibility.
(struct _virSchedParameter, struct _virBlkioParameter)
(struct _virMemoryParameter): Delete - these are private names.
* python/generator.py (enum): Cope with the refactoring.

13 years agobuild: update to latest gnulib
Eric Blake [Fri, 13 May 2011 18:55:44 +0000 (12:55 -0600)]
build: update to latest gnulib

* .gnulib: Update, for bootstrap and other fixes.
* bootstrap: Resynchronize with gnulib.

13 years agoAdd support for 'passthru' mode for direct network interfaces
Dirk Herrendorefer [Tue, 17 May 2011 11:26:09 +0000 (13:26 +0200)]
Add support for 'passthru' mode for direct network interfaces

starting with kernel 2.6.38 macvtap supports a 'passthru' mode for
attaching virtual functions of a SRIOV capable network card directly to a VM.
This patch adds the capability to configure such a device.

Signed-off-by: Dirk Herrendoerfer <d.herrendoerfer@herrendoerfer.name>
13 years agoqemu: fix typo in spice migration code
Michal Privoznik [Wed, 18 May 2011 09:57:07 +0000 (11:57 +0200)]
qemu: fix typo in spice migration code

This typo caused XPath returning improper value and thus not
working spice after migration.

13 years agovirsh: add parameters --live, --config and --current to cmd schedinfo
Hu Tao [Tue, 17 May 2011 06:20:03 +0000 (14:20 +0800)]
virsh: add parameters --live, --config and --current to cmd schedinfo

This enables user to modify cpu.shares even when domain is inactive.

13 years agoremote: introduce remoteSetSchedulerParametersFlags
Hu Tao [Tue, 17 May 2011 06:20:02 +0000 (14:20 +0800)]
remote: introduce remoteSetSchedulerParametersFlags

support for virDomainSetSchedulerParametersFlags of remote driver.

13 years agoqemu: introduce qemuSetSchedulerParametersFlags
Hu Tao [Tue, 17 May 2011 06:20:01 +0000 (14:20 +0800)]
qemu: introduce qemuSetSchedulerParametersFlags

Support for virDomainSetSchedulerParametersFlags of qemu driver.

13 years agosched: adjust parameter values to make current = 0
Eric Blake [Tue, 17 May 2011 16:02:07 +0000 (10:02 -0600)]
sched: adjust parameter values to make current = 0

See virDomainMemoryModFlags for precedent.

* include/libvirt/libvirt.h.in (virDomainSchedParameterFlags): Set
CURRENT as a synonym to 0.

13 years agointroduce virDomainSetSchedulerParametersFlags
Hu Tao [Tue, 17 May 2011 06:20:00 +0000 (14:20 +0800)]
introduce virDomainSetSchedulerParametersFlags

This new function allows aditional flags to be passed into from
the virsh command line.

13 years agobuild: drop unused <sys/syslimits.h> header
Eric Blake [Mon, 16 May 2011 19:27:42 +0000 (13:27 -0600)]
build: drop unused <sys/syslimits.h> header

<sys/syslimits.h> is not standardized, so portable programs should
not need to rely on it.  If there really is something that we need
where <sys/syslimits.h> provided the limit but <limits.h> did not,
then that would be a candidate for fixing in gnulib.  But this patch
did not turn up any compilation failures on Linux.

* src/internal.h (includes): Drop unused header.
* daemon/libvirtd.h (includes): Likewise.
* configure.ac (AC_CHECK_HEADERS): Likewise.
Based on a report by Matthias Bolte.

13 years agoFix prototype of virRun for Win32 targets
Daniel P. Berrange [Tue, 17 May 2011 15:22:49 +0000 (16:22 +0100)]
Fix prototype of virRun for Win32 targets

* src/util/util.c: Fix virRun prototype

13 years agobuild: tolerate unlimited group size
Eric Blake [Mon, 16 May 2011 21:37:15 +0000 (15:37 -0600)]
build: tolerate unlimited group size

POSIX allows sysconf(_SC_GETPW_R_SIZE_MAX) to return -1 if there
is no fixed limit, and requires ERANGE errors to track real size.
Model our behavior after the example in POSIX itself:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/getpwuid_r.html

Also, on error for get*_r functions, errno is undefined, and the
real error was the return value.

* src/util/util.c (virGetUserEnt, virGetUserID, virGetGroupID)
(virSetUIDGID):  Cope with sysconf failure or too small buffer.
Reported by Matthias Bolte.

13 years agoopenvz: fix logic bug in previous patch
Eric Blake [Tue, 17 May 2011 15:12:16 +0000 (09:12 -0600)]
openvz: fix logic bug in previous patch

We want to free names on failure, not on success.

* src/openvz/openvz_driver.c (openvzListDefinedDomains): Use
correct condition.

13 years agostorage_backend: Convert virRunWithHook usage to virCommand
Cole Robinson [Fri, 6 May 2011 18:35:51 +0000 (14:35 -0400)]
storage_backend: Convert virRunWithHook usage to virCommand

virRunWithHook is now unused, so we can drop it. Tested w/ raw + qcow2
volume creation and copying.

v2:
    Use opaque data to skip hook second time around
    Simply command building

v3:
    Drop explicit FindFileInPath

13 years agostorage_backend: Fix error reporting with regex helper
Cole Robinson [Tue, 10 May 2011 19:36:50 +0000 (15:36 -0400)]
storage_backend: Fix error reporting with regex helper

Some clients overwrite the error from the regex helper, or do half-baked
error reporting with the exitstatus.

13 years agostorage: Covert regex helpers to virCommand
Cole Robinson [Fri, 6 May 2011 19:47:36 +0000 (15:47 -0400)]
storage: Covert regex helpers to virCommand

v2:
    Simplify command creation
    Add a missing virCommandFree
    Use virCommand auto-cleanup for async process

13 years agoopenvz: Convert virExec usage to virCommand
Cole Robinson [Fri, 6 May 2011 20:21:58 +0000 (16:21 -0400)]
openvz: Convert virExec usage to virCommand

v2:
    Use virCommand's autocleanup

v3:
    Don't free 'names' on success

13 years agostorage: iscsi: Convert virExec to virCommand
Cole Robinson [Fri, 6 May 2011 20:00:23 +0000 (16:00 -0400)]
storage: iscsi: Convert virExec to virCommand

v2:
    Use virCommand auto-cleanup

13 years agoFix error reporting in stream creation code
Matthias Bolte [Sat, 14 May 2011 15:46:00 +0000 (17:46 +0200)]
Fix error reporting in stream creation code

virStreamNew needs to dispatch the error that virGetStream reports
on failure.

remoteCreateClientStream can fail due to virStreamNew or due to
VIR_ALLOC. Report OOM error for VIR_ALLOC failure to report errors
in all error cases.

Remove OOM error reporting from remoteCreateClientStream callers.

13 years agoremote generator, client: Add more special case handling
Matthias Bolte [Sat, 14 May 2011 13:56:03 +0000 (15:56 +0200)]
remote generator, client: Add more special case handling

For virDomainDestroy and virDrvSupportsFeature.

13 years agoremote generator, client: Handle functions that return an optional string
Matthias Bolte [Sat, 14 May 2011 13:35:27 +0000 (15:35 +0200)]
remote generator, client: Handle functions that return an optional string

13 years agoesx: Simplify some esxVI_Boolean to bool
Matthias Bolte [Sun, 1 May 2011 19:57:45 +0000 (21:57 +0200)]
esx: Simplify some esxVI_Boolean to bool

13 years agoesx: Convert autoAnswer from esxVI_Boolean to a simple bool
Matthias Bolte [Sun, 1 May 2011 19:57:44 +0000 (21:57 +0200)]
esx: Convert autoAnswer from esxVI_Boolean to a simple bool

Just true/false is good enough for it. Also use it directly from the
parsed URI instead of caching it in esxPrivate.

13 years agoesx: Fix race condition in esxVI_EnsureSession
Matthias Bolte [Sun, 1 May 2011 19:57:43 +0000 (21:57 +0200)]
esx: Fix race condition in esxVI_EnsureSession

When the session has expired then multiple threads can race while
reestablishing it.

This race condition is not that critical as it requires a special usage
pattern to be triggered. It can only happen when an application doesn't
do API calls for quite some time (the session expires after 30 min
inactivity) and then multiple threads doing simultaneous API calls and
end up doing simultaneous calls to esxVI_EnsureSession.

13 years agovirsh: Correctly initialize libvirt
Jiri Denemark [Mon, 9 May 2011 11:57:09 +0000 (13:57 +0200)]
virsh: Correctly initialize libvirt

virsh didn't call virInitialize(), which (among other things)
initializes virLastErr thread local variable. As a result of that, virsh
could just segfault in virEventRegisterDefaultImpl() since that is the
first call that touches (resets) virLastErr.

I have no idea what lucky coincidence made this bug visible but I was
able to reproduce it in 100% cases but only in one specific environment
which included building in sandbox.

13 years agoesx: Whitespace cleanup in the generator
Matthias Bolte [Sun, 1 May 2011 19:57:42 +0000 (21:57 +0200)]
esx: Whitespace cleanup in the generator

Break long lines and change spacing of keyword arguments to match
Python style standards better.

No functional change included.

13 years agoFix leak of mime type string in screenshot dispatcher
Daniel P. Berrange [Mon, 16 May 2011 17:29:19 +0000 (18:29 +0100)]
Fix leak of mime type string in screenshot dispatcher

* daemon/remote.c: Free mime string

13 years agoRemove obsolete remoteDispatchOOMError method
Daniel P. Berrange [Mon, 16 May 2011 17:27:53 +0000 (18:27 +0100)]
Remove obsolete remoteDispatchOOMError method

No new code should be using remoteDispatchOOMError()

* daemon/dispatch.c, daemon/dispatch.h: Remove remoteDispatchOOMError

13 years agoesx: Change some alignments in the input file
Matthias Bolte [Sun, 1 May 2011 09:52:33 +0000 (11:52 +0200)]
esx: Change some alignments in the input file

No functional change included.

13 years agoesx: Change generated method parameter autobinding
Matthias Bolte [Sun, 1 May 2011 09:51:19 +0000 (11:51 +0200)]
esx: Change generated method parameter autobinding

Instead of specifying the type of the managed object directly specify
the ServiceContent member name. This way the mapping dictionary can be
removed.

13 years agoFix remote dispatcher for screenshot command
Daniel P. Berrange [Mon, 16 May 2011 17:12:17 +0000 (18:12 +0100)]
Fix remote dispatcher for screenshot command

* daemon/remote.c: Update screenshot dispatcher to follow
  standard practice

13 years agovirsh: Report an error when virGetUserDirectory fails
Matthias Bolte [Sun, 15 May 2011 05:31:42 +0000 (07:31 +0200)]
virsh: Report an error when virGetUserDirectory fails

Otherwise virsh shows the interactive greeting and then silently exists
instead of entering interactive mode.

13 years agomaint: mark more perl scripts executable
Eric Blake [Mon, 16 May 2011 16:12:21 +0000 (10:12 -0600)]
maint: mark more perl scripts executable

* src/remote/rpcgen_fix.pl: Add executable bit.
* tests/oomtrace.pl: Likewise.

13 years agomaint: mark perl script executable
Eric Blake [Mon, 16 May 2011 16:09:36 +0000 (10:09 -0600)]
maint: mark perl script executable

* docs/hvsupport.pl: Add execute bit.

13 years agomaint: ignore generated file
Eric Blake [Mon, 16 May 2011 15:33:56 +0000 (09:33 -0600)]
maint: ignore generated file

* .gitignore: Ignore recently added file.

13 years agoAdd missing initialization to 'ret' in qemu migration
Daniel P. Berrange [Mon, 16 May 2011 15:10:35 +0000 (16:10 +0100)]
Add missing initialization to 'ret' in qemu migration

* src/qemu/qemu_migration.c: Add missing 'ret' initializer
  in qemuMigrationCookieXMLParseStr

13 years agoDisable virCommandExec on Win32
Daniel P. Berrange [Thu, 12 May 2011 09:33:31 +0000 (10:33 +0100)]
Disable virCommandExec on Win32

Mingw execve() has a broken signature. Disable this
function until gnulib fixes the signature, since we
don't really need this on Win32 anyway.

* src/util/command.c: Disable virCommandExec on Win32

13 years agoImprove error message when XDR marshalling fails
Daniel P. Berrange [Thu, 21 Apr 2011 15:58:41 +0000 (16:58 +0100)]
Improve error message when XDR marshalling fails

When failing to marshall an XDR message, include the
full program/version/status/proc/type info, to allow
easier debugging & diagnosis of the problem.

* src/remote/remote_driver.c: Improve error when marshalling
  fails

13 years agoRun tunnelled migration IO in separate thread
Daniel P. Berrange [Mon, 9 May 2011 15:52:42 +0000 (16:52 +0100)]
Run tunnelled migration IO in separate thread

By running the doTunnelSendAll code in a separate thread, the
main thread can do qemuMigrationWaitForCompletion as with
normal migration. This in turn ensures that job signals work
correctly and that progress monitoring can be done

* src/qemu/qemu_migration.c: Run tunnelled migration in
  separate thread

13 years agoDon't overwrite error when stream send fails
Daniel P. Berrange [Thu, 21 Apr 2011 16:24:39 +0000 (17:24 +0100)]
Don't overwrite error when stream send fails

virStreamSend already sets an error message, so don't
overwrite it

* src/qemu/qemu_migration.c: Remove bogus error report

13 years agoClose all sockets before cancelling QEMU migration
Daniel P. Berrange [Thu, 21 Apr 2011 16:23:13 +0000 (17:23 +0100)]
Close all sockets before cancelling QEMU migration

Cancelling the QEMU migration may cause QEMU to flush pending
data on the migration socket. This may in turn block QEMU if
nothing reads from the other end of the socket. Closing the
socket before cancelling QEMU migration avoids this possible
deadlock.

* src/qemu/qemu_migration.c: Close sockets before cancelling
  migration on failure

13 years agoEnsure we always read a full buffer in tunnelled migration
Daniel P. Berrange [Thu, 21 Apr 2011 16:13:56 +0000 (17:13 +0100)]
Ensure we always read a full buffer in tunnelled migration

The 'nbytes' variable was not re-initialized to the
buffer size on each iteration of the tunnelled migration
loop. While saferead() will ensure a full read, except
on EOF, it is clearer to use the real buffer size

* src/qemu/qemu_migration.c: Always read full buffer of data

13 years agoMake tunnelled migration honour resource restriction
Daniel P. Berrange [Wed, 20 Apr 2011 16:56:35 +0000 (17:56 +0100)]
Make tunnelled migration honour resource restriction

The doTunnelMigrate method forgot to set the bandwidth
resource restriction

* src/qemu/qemu_migration.c: Set resource restriction

13 years agoRefactor migration completion loop to allow code reuse
Daniel P. Berrange [Wed, 20 Apr 2011 16:33:27 +0000 (17:33 +0100)]
Refactor migration completion loop to allow code reuse

The qemuMigrationWaitForCompletion method contains a loop which
repeatedly queries QEMU to check migration progress, and also
processes job signals (pause, setspeed, setbandwidth, cancel).

The tunnelled migration loop does not currently support this
functionality, but should. Refactor the code to allow it to
be used with tunnelled migration.

13 years agoImplement migration v3 protocol in QEMU driver
Daniel P. Berrange [Thu, 3 Feb 2011 11:09:28 +0000 (11:09 +0000)]
Implement migration v3 protocol in QEMU driver

Implement the v3 migration protocol, which has two extra
steps, 'begin' on the source host and 'confirm' on the
source host. All other methods also gain both input and
output cookies to allow bi-directional data passing at
all stages.

The QEMU peer2peer migration method gains another impl
to provide the v3 migration. This finally allows migration
cookies to work with tunnelled migration, which is required
for Spice seamless migration & the lock manager transfer

* src/qemu/qemu_driver.c: Wire up migrate v3 APIs
* src/qemu/qemu_migration.c, src/qemu/qemu_migration.h: Add
  begin & confirm methods, and peer2peer impl of v3

13 years agoMerge tunnel & non-tunnel migration impl into one
Daniel P. Berrange [Wed, 20 Apr 2011 12:48:58 +0000 (13:48 +0100)]
Merge tunnel & non-tunnel migration impl into one

Merge the doNonTunnelMigrate2 and doTunnelMigrate2 methods
into one doPeer2PeerMigrate2 method, since they are substantially
the same. With the introduction of v3 migration, this will be
even more important, to avoid massive code duplication.

* src/qemu/qemu_migration.c: Merge tunnel & non-tunnel migration

13 years agoFix VM teardown if prepare returns invalid URI in v2 migration
Daniel P. Berrange [Wed, 20 Apr 2011 12:48:11 +0000 (13:48 +0100)]
Fix VM teardown if prepare returns invalid URI in v2 migration

The v2 migration protocol was accidentally missing out the
finish step, when prepare succeeded, but returned an invalid
URI

* src/libvirt.c: Teardown VM if prepare returns invalid URI

13 years agoRefactor tunnelled migration methods
Daniel P. Berrange [Wed, 20 Apr 2011 12:12:43 +0000 (13:12 +0100)]
Refactor tunnelled migration methods

To facilitate the introduction of the v3 migration protocol,
the doTunnelMigrate method is refactored into two pieces. One
piece is intended to mirror the flow of virDomainMigrateVersion2,
while the other is the helper for setting up sockets and processing
the data.

Previously socket setup would be done before the 'prepare' step,
so errors could be dealt with immediately, avoiding need to shut
off the destination QEMU. In the new split, socket setup is done
after the 'prepare' step. This is not a serious problem, since
the control flow already requires calling 'finish' to tear down
the destination QEMU upon several errors.

* src/qemu/qemu_migration.c:

13 years agoWire up SPICE client relocation with QEMU migration
Daniel P. Berrange [Thu, 17 Feb 2011 13:39:36 +0000 (13:39 +0000)]
Wire up SPICE client relocation with QEMU migration

Use the graphics information from the QEMU migration cookie to
issue a 'client_migrate_info' monitor command to QEMU. This causes
the SPICE client to automatically reconnect to the target host
when migration completes

* src/qemu/qemu_migration.c: Set data for SPICE client relocation
  before starting migration on src
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
  src/qemu/qemu_monitor_json.c, src/qemu/qemu_monitor_json.h,
  src/qemu/qemu_monitor_text.c, src/qemu/qemu_monitor_text.h: Add
  new qemuMonitorGraphicsRelocate() command

13 years agoPass graphics setup from dst back to src via migration cookies
Daniel P. Berrange [Thu, 17 Feb 2011 13:17:59 +0000 (13:17 +0000)]
Pass graphics setup from dst back to src via migration cookies

Extend the QEMU migration cookie structure to allow information
about the destination host graphics setup to be passed by to
the source host. This will enable seamless migration of any
connected graphics clients

* src/qemu/qemu_migration.c: Add graphics info to migration
  cookies
* daemon/libvirtd.c: Always initialize gnutls to enable
  x509 cert parsing in QEMU

13 years agoIntroduce migration cookies to QEMU driver
Daniel P. Berrange [Mon, 24 Jan 2011 18:06:16 +0000 (18:06 +0000)]
Introduce migration cookies to QEMU driver

The migration protocol has support for a 'cookie' parameter which
is an opaque array of bytes as far as libvirt is concerned. Drivers
may use this for passing around arbitrary extra data they might
need during migration. The QEMU driver needs to do a few things:

 - Pass hostname/uuid to allow strict protection against localhost
   migration attempts
 - Pass SPICE/VNC server port from the target back to the source to
   allow seamless relocation of client sessions
 - Pass lock driver state from source to destination

This patch introduces the basic glue for handling cookies
but only includes the host/guest UUID & name.

* src/libvirt_private.syms: Export virXMLParseStrHelper
* src/qemu/qemu_migration.c, src/qemu/qemu_migration.h: Parsing
  and formatting of migration cookies
* src/qemu/qemu_driver.c: Pass in cookie parameters where possible
* src/remote/remote_protocol.h, src/remote/remote_protocol.x: Change
  cookie max length to 16384 bytes

13 years agoFix locking with qemuMigrationPrepareTunnel method
Daniel P. Berrange [Mon, 16 May 2011 14:17:15 +0000 (15:17 +0100)]
Fix locking with qemuMigrationPrepareTunnel method

The qemuMigrationPrepareTunnel method should not unlock the
qemu driver, since that is the caller's job.

* src/qemu/qemu_migration.c: Fix qemuMigrationPrepareTunnel
  unlocking of QEMU driver

13 years agoRemote driver implementation of new migration API
Daniel P. Berrange [Tue, 1 Feb 2011 14:23:40 +0000 (14:23 +0000)]
Remote driver implementation of new migration API

* src/remote/remote_protocol.x: Define wire protocol for migration
  protocol v3
* daemon/remote.c: Server side dispatch
* src/remote/remote_driver.c: Client side serialization
* src/remote/remote_protocol.c, src/remote/remote_protocol.h,
  daemon/remote_dispatch_args.h, daemon/remote_dispatch_prototypes.h,
  daemon/remote_dispatch_ret.h, daemon/remote_dispatch_table.h:
  Re-generate files
* src/remote_protocol-structs: Declare new ABIs

13 years agoIntroduce yet another migration version in API.
Daniel P. Berrange [Tue, 2 Nov 2010 12:43:44 +0000 (12:43 +0000)]
Introduce yet another migration version in API.

Migration just seems to go from bad to worse. We already had to
introduce a second migration protocol when adding the QEMU driver,
since the one from Xen was insufficiently flexible to cope with
passing the data the QEMU driver required.

It turns out that this protocol still has some flaws that we
need to address. The current sequence is

 *  Src: DumpXML
          - Generate XML to pass to dst

 *  Dst: Prepare
          - Get ready to accept incoming VM
          - Generate optional cookie to pass to src

 *  Src: Perform
          - Start migration and wait for send completion
          - Kill off VM if successful, resume if failed

 *  Dst: Finish
          - Wait for recv completion and check status
          - Kill off VM if unsuccessful

The problems with this are:

 - Since the first step is a generic 'DumpXML' call, we can't
   add in other migration specific data. eg, we can't include
   any VM lease data from lock manager plugins
 - Since the first step is a generic 'DumpXML' call, we can't
   emit any 'migration begin' event on the source, or have
   any hook that runs right at the start of the process
 - Since there is no final step on the source, if the Finish
   method fails to receive all migration data & has to kill
   the VM, then there's no way to resume the original VM
   on the source

This patch attempts to introduce a version 3 that uses the
improved 5 step sequence

 *  Src: Begin
          - Generate XML to pass to dst
          - Generate optional cookie to pass to dst

 *  Dst: Prepare
          - Get ready to accept incoming VM
          - Generate optional cookie to pass to src

 *  Src: Perform
          - Start migration and wait for send completion
          - Generate optional cookie to pass to dst

 *  Dst: Finish
          - Wait for recv completion and check status
          - Kill off VM if failed, resume if success
          - Generate optional cookie to pass to src

 *  Src: Confirm
          - Kill off VM if success, resume if failed

The API is designed to allow both input and output cookies
in all methods where applicable. This lets us pass around
arbitrary extra driver specific data between src & dst during
migration. Combined with the extra 'Begin' method this lets
us pass lease information from source to dst at the start of
migration

Moving the killing of the source VM out of Perform and
into Confirm, means we can now recover if the dst host
can't successfully Finish receiving migration data.

13 years agoAutomatically generate the hvsupport.html.in file from source files
Daniel P. Berrange [Fri, 13 May 2011 10:00:56 +0000 (11:00 +0100)]
Automatically generate the hvsupport.html.in file from source files

The hvsupport.html.in file is forever out of date. By annotating
the driver struct tables in each driver with version information,
we can auto-generate the hvsupport.html.in file. Annotating the
drivers will be mandatory for new patches, ensuring hvsupport.html.in
is never out of date again.

* docs/hvsupport.html.in: Delete
* hvsupport.pl: Script to generate hvsupport.html.in
* Makefile.am: Autogenerate hvsupport.html.in

13 years agoAdd many version number annotations to drivers
Daniel P. Berrange [Fri, 13 May 2011 13:35:01 +0000 (14:35 +0100)]
Add many version number annotations to drivers

Add many version number annotations to the internal driver
tables, to allow hvsupport.html to display more accurate
information

13 years agoConvert all driver struct intializers to C99 style
Daniel P. Berrange [Fri, 13 May 2011 10:16:31 +0000 (11:16 +0100)]
Convert all driver struct intializers to C99 style

Change all the driver struct initializers to use the
C99 style, leaving out unused fields. This will make
it possible to add new APIs without changing every
driver. eg change:

    qemudDomainResume, /* domainResume */
    qemudDomainShutdown, /* domainShutdown */
    NULL, /* domainReboot */
    qemudDomainDestroy, /* domainDestroy */

to

    .domainResume = qemudDomainResume,
    .domainShutdown = qemudDomainShutdown,
    .domainDestroy = qemudDomainDestroy,

And get rid of any existing C99 style initializersr which
set NULL, eg change

     .listPools          = vboxStorageListPools,
     .numOfDefinedPools  = NULL,
     .listDefinedPools   = NULL,
     .findPoolSources    = NULL,
     .poolLookupByName   = vboxStoragePoolLookupByName,

to

     .listPools          = vboxStorageListPools,
     .poolLookupByName   = vboxStoragePoolLookupByName,

13 years agoTweak driver naming for consistency with public API
Daniel P. Berrange [Wed, 11 May 2011 17:01:23 +0000 (18:01 +0100)]
Tweak driver naming for consistency with public API

Fix some driver names:

  s/virDrvCPUCompare/virDrvCompareCPU/
  s/virDrvCPUBaseline/virDrvBaselineCPU/
  s/virDrvQemuDomainMonitorCommand/virDrvDomainQemuMonitorCommand/
  s/virDrvSecretNumOfSecrets/virDrvNumOfSecrets/
  s/virDrvSecretListSecrets/virDrvListSecrets/

And some driver struct field names:

  s/getFreeMemory/nodeGetFreeMemory/

13 years agoqemu: Update domain state when reconnecting monitor
Jiri Denemark [Thu, 5 May 2011 11:50:25 +0000 (13:50 +0200)]
qemu: Update domain state when reconnecting monitor

A qemu domain can get paused when libvirtd is stopped (e.g., because of
I/O error) so we should check its current state when reconnecting to it.

13 years agoImplement domain state reason
Jiri Denemark [Wed, 4 May 2011 09:07:01 +0000 (11:07 +0200)]
Implement domain state reason

Only in drivers which use virDomainObj, drivers that query hypervisor
for domain status need to be updated separately in case their hypervisor
supports this functionality.

The reason is also saved into domain state XML so if a domain is not
running (i.e., no state XML exists) the reason will be lost by libvirtd
restart. I think this is an acceptable limitation.

13 years agoImplement basic virDomainGetState in all drivers
Jiri Denemark [Mon, 2 May 2011 09:35:29 +0000 (11:35 +0200)]
Implement basic virDomainGetState in all drivers

Reason is currently always set to 0 (i.e., *_UNKNOWN).

13 years agovirsh: Prefer virDomainGetState over virDomainGetInfo
Jiri Denemark [Fri, 29 Apr 2011 08:20:49 +0000 (10:20 +0200)]
virsh: Prefer virDomainGetState over virDomainGetInfo

13 years agoWire protocol format and remote driver for virDomainGetState
Jiri Denemark [Tue, 26 Apr 2011 14:47:22 +0000 (16:47 +0200)]
Wire protocol format and remote driver for virDomainGetState

13 years agovirDomainGetState public API implementation
Jiri Denemark [Tue, 26 Apr 2011 10:26:36 +0000 (12:26 +0200)]
virDomainGetState public API implementation

13 years agoInternal driver API for virDomainGetState
Jiri Denemark [Fri, 22 Apr 2011 11:49:01 +0000 (13:49 +0200)]
Internal driver API for virDomainGetState

13 years agovirDomainGetState public API
Jiri Denemark [Fri, 22 Apr 2011 11:31:35 +0000 (13:31 +0200)]
virDomainGetState public API

This API is supposed to replace virDomainGetInfo when the only purpose
of calling it is getting current domain status.