]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
12 years agotests: Create test for virCommandDoAsyncIO
Michal Privoznik [Wed, 16 Jan 2013 17:55:06 +0000 (18:55 +0100)]
tests: Create test for virCommandDoAsyncIO

This is just a basic test, so we don't break virCommand in the
future. A "Hello world\n" string is written to commanhelper,
which copies input to stdout and stderr where we read it from.
Then the read strings are compared with expected values.

12 years agoIntroduce event loop to commandtest
Michal Privoznik [Wed, 16 Jan 2013 10:58:00 +0000 (11:58 +0100)]
Introduce event loop to commandtest

This is just preparing environment for the next patch, which is
going to need an event loop.

12 years agovirCommand: Introduce virCommandDoAsyncIO
Michal Privoznik [Wed, 16 Jan 2013 10:33:17 +0000 (11:33 +0100)]
virCommand: Introduce virCommandDoAsyncIO

Currently, if we want to feed stdin, or catch stdout or stderr of a
virCommand we have to use virCommandRun(). When using virCommandRunAsync()
we have to register FD handles by hand. This may lead to code duplication.
Hence, introduce an internal API, which does this automatically within
virCommandRunAsync(). The intended usage looks like this:

    virCommandPtr cmd = virCommandNew*(...);
    char *buf = NULL;

    ...

    virCommandSetOutputBuffer(cmd, &buf);
    virCommandDoAsyncIO(cmd);

    if (virCommandRunAsync(cmd, NULL) < 0)
        goto cleanup;

    ...

    if (virCommandWait(cmd, NULL) < 0)
        goto cleanup;

    /* @buf now contains @cmd's stdout */
    VIR_DEBUG("STDOUT: %s", NULLSTR(buf));

    ...

cleanup:
    VIR_FREE(buf);
    virCommandFree(cmd);

Note, that both stdout and stderr buffers may change until virCommandWait()
returns.

12 years agoconf: Use correct type for device type enum in virDomainDeviceDefFree
Peter Krempa [Thu, 20 Dec 2012 12:41:32 +0000 (13:41 +0100)]
conf: Use correct type for device type enum in virDomainDeviceDefFree

With this change it's easy to spot a forgotten free if a new device
class is added.

12 years agobuild: Add libcurl dependency to libvirt_driver.la
Jiri Denemark [Fri, 1 Feb 2013 12:36:06 +0000 (13:36 +0100)]
build: Add libcurl dependency to libvirt_driver.la

libvirt.c calls curl_global_init() if WITH_CURL is defined and thus it
should be linked with libcurl. This fixes link failure in case neither
xenapi nor esx driver is enabled (they are the only users of libcurl).

12 years agospec: Fix minor changelog issues
Jiri Denemark [Fri, 1 Feb 2013 08:00:16 +0000 (09:00 +0100)]
spec: Fix minor changelog issues

When a changelog entry references an RPM macro, % needs to be escaped so
that it does not appear expanded in package changelog.

Fri Mar  4 2009 is incorrect since Mar 4 was Wednesday. Since
libvirt-0.6.1 was released on Mar 4 2009, we should change Fri to Wed.

12 years agoAdd basic support for VDI images
Martin Kletzander [Mon, 4 Feb 2013 19:18:22 +0000 (20:18 +0100)]
Add basic support for VDI images

QEMU is fully capable of handling VDI images and we just refuse to
work with them.  As qemu-img knows and supports this, there should be
no problem with this addition.

This is of course, just basic functionality, without searching for any
backing files, etc.

12 years agoSupport shifted magic in storage files
Martin Kletzander [Mon, 4 Feb 2013 19:16:22 +0000 (20:16 +0100)]
Support shifted magic in storage files

Some files have the magic shifted to some offset other than 0, so we
have to support that.  I also cleaned up some lines to be more
readable and added missing magic for iso file format.

12 years agovirsh-secret: Refactor error paths
Peter Krempa [Mon, 21 Jan 2013 17:28:47 +0000 (18:28 +0100)]
virsh-secret: Refactor error paths

This patch switches string option retrieval to vshCommandOptStringReq
and refactors some error paths to avoid an unlikely memory leak of a
secret object in cmdSecretSetValue.

12 years agovirsh-nwfilter: Update nwfilter commands to use vshCommandOptStringReq
Peter Krempa [Mon, 21 Jan 2013 17:18:41 +0000 (18:18 +0100)]
virsh-nwfilter: Update nwfilter commands to use vshCommandOptStringReq

12 years agovirsh-snapshot: Update snapshot commands to use vshCommandOptStringReq
Peter Krempa [Mon, 21 Jan 2013 17:11:41 +0000 (18:11 +0100)]
virsh-snapshot: Update snapshot commands to use vshCommandOptStringReq

also avoids potential NULL pointer dereference:

$ virsh snapshot-current asdf ""
error: invalid snapshotname argument '(null)'

by removing the error message in favor of vshCommandOptStringReq

12 years agovirsh-snapshot: Refactor cmdSnapshotDumpXML
Peter Krempa [Mon, 21 Jan 2013 16:54:17 +0000 (17:54 +0100)]
virsh-snapshot: Refactor cmdSnapshotDumpXML

This patch simplifies error paths and switches to use
vshCommandOptStringReq for argument retrieval in cmdSnapshotDumpXML

12 years agovirsh-nodedev: Refactor error paths, error messages and whitespace
Peter Krempa [Mon, 21 Jan 2013 16:41:14 +0000 (17:41 +0100)]
virsh-nodedev: Refactor error paths, error messages and whitespace

This patch adds some empty lines to separate blocks of code, cleans up
unnecessary error message constructs in cmdNodeDeviceDetach,
cmdNodeDeviceReAttach, cmdNodeDeviceReset and refactors error paths in
cmdNodeDeviceDumpXML.

12 years agovirsh-nodedev: Update node device commands to use vshCommandOptStringReq
Peter Krempa [Mon, 21 Jan 2013 16:29:14 +0000 (17:29 +0100)]
virsh-nodedev: Update node device commands to use vshCommandOptStringReq

12 years agovirsh-interface: Update interface commands to use vshCommandOptStringReq
Peter Krempa [Mon, 21 Jan 2013 16:25:05 +0000 (17:25 +0100)]
virsh-interface: Update interface commands to use vshCommandOptStringReq

12 years agovirsh-network: Update network commands to use vshCommandOptStringReq
Peter Krempa [Mon, 21 Jan 2013 16:22:17 +0000 (17:22 +0100)]
virsh-network: Update network commands to use vshCommandOptStringReq

12 years agovirsh-host: Update host commands to use vshCommandOptStringReq
Peter Krempa [Mon, 21 Jan 2013 16:17:19 +0000 (17:17 +0100)]
virsh-host: Update host commands to use vshCommandOptStringReq

12 years agovirsh-domain: Update domain commands to use vshCommandOptStringReq
Peter Krempa [Mon, 21 Jan 2013 14:39:18 +0000 (15:39 +0100)]
virsh-domain: Update domain commands to use vshCommandOptStringReq

12 years agovirsh-domain-monitor: Update domain commands to use vshCommandOptStringReq
Peter Krempa [Mon, 14 Jan 2013 14:09:41 +0000 (15:09 +0100)]
virsh-domain-monitor: Update domain commands to use vshCommandOptStringReq

12 years agovirsh-volume: Update volume commands to use vshCommandOptStringReq
Peter Krempa [Fri, 18 Jan 2013 15:40:08 +0000 (16:40 +0100)]
virsh-volume: Update volume commands to use vshCommandOptStringReq

12 years agovirsh-pool: Update pool commands to use vshCommandOptStringReq
Peter Krempa [Mon, 21 Jan 2013 14:15:01 +0000 (15:15 +0100)]
virsh-pool: Update pool commands to use vshCommandOptStringReq

Rework most of option string retrievals to the new helper.

12 years agovirsh: Add helper to request string arguments with error reporting
Peter Krempa [Mon, 14 Jan 2013 13:38:38 +0000 (14:38 +0100)]
virsh: Add helper to request string arguments with error reporting

This patch adds a helper function with similar semantics to
vshCommandOptString that requests a string argument, but does some error
reporting without the need to do it in the functions themselves.

The error reporting also provides information about the parameter whose
retrieval failed.

12 years agovirsh-pool: Rename helper function buildPoolXML to vshBuildPoolXML
Peter Krempa [Mon, 21 Jan 2013 14:11:12 +0000 (15:11 +0100)]
virsh-pool: Rename helper function buildPoolXML to vshBuildPoolXML

12 years agovirsh-volume: Rename helper function makeCloneXML to vshMakeCloneXML
Peter Krempa [Fri, 18 Jan 2013 15:33:34 +0000 (16:33 +0100)]
virsh-volume: Rename helper function makeCloneXML to vshMakeCloneXML

12 years agovirsh-snapshot: Fix coding style and remove dead code
Peter Krempa [Mon, 21 Jan 2013 16:48:26 +0000 (17:48 +0100)]
virsh-snapshot: Fix coding style and remove dead code

buffer won't be NULL in any case when reaching the check and the first
block of the if statement was lacking parentheses

12 years agohyperv: Simplify hypervPrivate pointer handling in hypervOpen
Matthias Bolte [Thu, 10 Jan 2013 21:39:43 +0000 (22:39 +0100)]
hyperv: Simplify hypervPrivate pointer handling in hypervOpen

12 years agoesx: Simplify esxPrivate pointer handling in esxOpen
Matthias Bolte [Thu, 10 Jan 2013 21:32:13 +0000 (22:32 +0100)]
esx: Simplify esxPrivate pointer handling in esxOpen

Commit 4445e16bfa8056980ac643fabf17186f9e685925 changed the signature
of esxConnectToHost and esxConnectToVCenter by replacing the esxPrivate
pointer with virConnectPtr. The esxPrivate pointer was then retrieved
again from virConnectPtr's privateData. This resulted in a NULL pointer
dereference, because the privateData pointer was not yet initialized at
the point where esxConnectToHost and esxConnectToVCenter are called.

This was fixed in commit b126715a48cd0cbe32ec6468c267cd8cf2961c55 that
moved the initialization of privateData before the problematic calls.

Simplify the logic by making the call to esxFreePrivate unconditional and
changing esxConnectToHost and esxConnectToVCenter back to take a esxPrivate
pointer directly. This allows to assign esxPrivate to the virConnectPtr's
privateData pointer as one of the last steps in esxOpen making it more
obvious that it is not initialized during the earlier steps of esxOpen.

12 years agodocs: don't ignore virEvent API
Eric Blake [Fri, 1 Feb 2013 22:50:34 +0000 (15:50 -0700)]
docs: don't ignore virEvent API

Commit 6094ad7b (0.9.3 release) promoted several functions from
internal to public, but forgot to fix the documentation generator
to provide details about those functions.

For an example of what this fixes, look at:
file:///path/to/libvirt/docs/html/libvirt-libvirt.html#virEventAddHandle
before and after the patch.

* docs/apibuild.py (ignored_functions): Don't ignore functions
that were turned into official API.
* src/util/virevent.c: Fix comments to pass through parser.

12 years agomaint: update to latest gnulib
Eric Blake [Sat, 26 Jan 2013 20:41:31 +0000 (13:41 -0700)]
maint: update to latest gnulib

CVE-2013-0242 in glibc's regex() can cause a DoS in any daemon
that runs a regex search on user input while in a multibyte locale.
I'm not sure how hard it would be to trigger such a setup for
libvirtd, but rather than risk things, we can avoid the issue:
gnulib has worked around the problem, and by updating to the latest
gnulib, we can avoid the bug even on platforms where glibc has yet
to be patched.

* .gnulib: Update to latest, for various fixes, including regex.
* bootstrap: Resync from upstream.

12 years agodocs: use div, not table, for notices on opaque types
Claudio Bley [Tue, 22 Jan 2013 10:11:11 +0000 (11:11 +0100)]
docs: use div, not table, for notices on opaque types

It's simpler to render and it prevents wrapping the line too early
because of the table spacing, border et cetera.

12 years agodocs: abort when missing return or argument documentation
Claudio Bley [Tue, 29 Jan 2013 14:35:28 +0000 (15:35 +0100)]
docs: abort when missing return or argument documentation

When a function has no associated information to one of its
arguments or its return type we report it and stop with an error.

12 years agolibvirt.h.in: document virConnectDomainEventCallback's return value
Claudio Bley [Wed, 30 Jan 2013 13:47:53 +0000 (14:47 +0100)]
libvirt.h.in: document virConnectDomainEventCallback's return value

12 years agolibvirt.h.in: add missing return doc for virEventRemoveHandleFunc
Claudio Bley [Wed, 30 Jan 2013 08:25:16 +0000 (09:25 +0100)]
libvirt.h.in: add missing return doc for virEventRemoveHandleFunc

12 years agolibvirt.h.in: fix documentation for virConnectDomainEventBlockJobCallback
Claudio Bley [Wed, 30 Jan 2013 07:38:25 +0000 (08:38 +0100)]
libvirt.h.in: fix documentation for virConnectDomainEventBlockJobCallback

In commit 3ac26e2645e6456389a918455213d7e3824f63f9 parameter "path" was
renamed to "disk" but this change was not reflected in the documentation.

Additionally, documentation of the "opaque" parameter was missing.

12 years agolibvirt.h.in: add missing documentation for virConnectCloseFunc
Claudio Bley [Wed, 30 Jan 2013 07:35:38 +0000 (08:35 +0100)]
libvirt.h.in: add missing documentation for virConnectCloseFunc

12 years agoAdd support for QEMU -add-fd support detection
Stefan Berger [Tue, 29 Jan 2013 16:52:17 +0000 (11:52 -0500)]
Add support for QEMU -add-fd support detection

Add support for QEMU -add-fd command line parameter detection.
This intentionally rejects qemu 1.2, where 'add-fd' QMP did
not allow full control of set ids, and where there was no command
line counterpart, but accepts qemu 1.3.

Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agoqemu: expose qemu 1.3 add-fd monitor command
Eric Blake [Thu, 31 Jan 2013 00:18:44 +0000 (17:18 -0700)]
qemu: expose qemu 1.3 add-fd monitor command

Add entry points for calling the qemu 'add-fd' and 'remove-fd'
monitor commands.  There is no entry point for 'query-fdsets';
the assumption is that a developer can use
 virsh qemu-monitor-command domain '{"execute":"query-fdsets"}'
when debugging issues, and that meanwhile, libvirt is responsible
enough to remember what fds it associated with what fdsets.
Likewise, on the 'add-fd' command, it is assumed that libvirt
will always pass a set id, rather than letting qemu autogenerate
the next available id number.

* src/qemu/qemu_monitor.c (qemuMonitorAddFd, qemuMonitorRemoveFd):
New functions.
* src/qemu/qemu_monitor.h (qemuMonitorAddFd, qemuMonitorRemoveFd):
New prototypes.
* src/qemu/qemu_monitor_json.c (qemuMonitorJSONAddFd)
(qemuMonitorJSONRemoveFd): New functions.
* src/qemu/qemu_monitor_json.h (qemuMonitorJSONAddFd)
(qemuMonitorJSONRemoveFd): New prototypes.

12 years agotests: add a comment about our fake qmp
Eric Blake [Thu, 31 Jan 2013 01:50:09 +0000 (18:50 -0700)]
tests: add a comment about our fake qmp

While testing QMP, I used a simple qemu session of
'qemu-kvm -M none -nodefaults -nographic -qmp stdio'
for some experiments.  But it took me far too long to remember
the magic invocation to unlock QMP into accepting normal commands.
While I was able to grep libvirt sources and easily find where
libvirt expects the normal "QMP" greeting, I could not find the
proper reply to that greeting nearby.

Reading the testsuite didn't help either, since there we don't
emulate the mandatory handshake.  But since my grep hit the
testsuite, adding a bit of documentation will make it much easier
to jog my memory in the future.

* tests/qemumonitortestutils.c (QEMU_JSON_GREETING): Mention that
the normal counterpart reply is skipped.

12 years agospec: Avoid using makeinstall relic
Jiri Denemark [Thu, 31 Jan 2013 14:31:37 +0000 (15:31 +0100)]
spec: Avoid using makeinstall relic

The macro was made to help installing broken packages that did not use
DESTDIR correctly by overriding individual path variables (prefix,
sysconfdir, ...). Newer rpm provides fixed make_install macro that calls
make install with just the correct DESTDIR, however it is not available
everywhere (e.g., RHEL 5 does not have it). On the other hand the
make_install macro is simple and straightforward enough for us to use
its expansion directly.

12 years agocomplete virterror->virerror name change
Serge Hallyn [Thu, 31 Jan 2013 03:05:45 +0000 (21:05 -0600)]
complete virterror->virerror name change

Without these two string changes in generator.py, the
virGetLastError wrapper does not get created in
/usr/share/pyshared/libvirt.py.  Noticed when running
tests with virt-install.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
12 years agotests: Don't build securityselinuxlabeltest without qemu
Jiri Denemark [Wed, 30 Jan 2013 15:44:06 +0000 (16:44 +0100)]
tests: Don't build securityselinuxlabeltest without qemu

Sources for securityselinuxlabeltest are only defined if qemu driver is
enabled so we should not try to build the test if qemu driver is
disabled.

12 years agoapibuild.py: fix TypeError raised in except clause
Claudio Bley [Wed, 30 Jan 2013 08:33:36 +0000 (09:33 +0100)]
apibuild.py: fix TypeError raised in except clause

When an exception happened inside the try clause in serialize_function,
a new exception was raised in the except clause subsequently:

Traceback (most recent call last):
  File "./apibuild.py", line 2529, in <module>
    rebuild("libvirt")
  File "./apibuild.py", line 2513, in rebuild
    builder.serialize()
  File "./apibuild.py", line 2467, in serialize
    self.serialize_function(output, function)
  File "./apibuild.py", line 2208, in serialize_function
    self.warning("Failed to save function %s info: " % name, `id.info`)
TypeError: warning() takes exactly 2 arguments (3 given)

Use the correct number of arguments for self.warning and print the
original exception to stderr.

12 years agoEnforce return check on virAsprintf() calls
John Ferlan [Wed, 30 Jan 2013 20:43:39 +0000 (15:43 -0500)]
Enforce return check on virAsprintf() calls

Way back when I started making changes for Coverity messages my first set
were to a bunch of CHECKED_RETURN errors.  In particular virAsprintf() had
a few callers that Coverity noted didn't check their return (although some
did check if the buffer being printed to was NULL or not).

It was suggested at the time as a further patch an ATTRIBUTE_RETURN_CHECK
should be added to virAsprintf(), see:

https://www.redhat.com/archives/libvir-list/2013-January/msg00120.html

This patch does that and fixes a few more instances not found by Coverity
that failed the check.

12 years agoutil: Fix mask for 172.16.0.0 private address range
Jiri Denemark [Wed, 30 Jan 2013 11:01:01 +0000 (12:01 +0100)]
util: Fix mask for 172.16.0.0 private address range

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

Only the first 12 bits should be set in the mask for this range. All
addresses between 172.16.0.0 and 172.31.255.255 are private.

12 years agosnapshot: Mention disk-only snapshots in error message
Peter Krempa [Fri, 25 Jan 2013 10:50:43 +0000 (11:50 +0100)]
snapshot: Mention disk-only snapshots in error message

When a disk-only snapshot is requested the domain is treated as if it
was offline. This forbids to mix memory checkpoints with the DISK_ONLY
flag.

This patch improves the error message and mentions the restriction in
the virsh man page.

12 years agoSync HACKING and hacking.html.in
Martin Kletzander [Wed, 30 Jan 2013 10:01:31 +0000 (11:01 +0100)]
Sync HACKING and hacking.html.in

After one last-minute change, only HACKING was updated and not
hacking.html.in, so this patch synchronizes that.

12 years agoRelease of libvirt-1.0.2
Daniel Veillard [Wed, 30 Jan 2013 09:42:05 +0000 (10:42 +0100)]
Release of libvirt-1.0.2

* configure.ac docs/news.html.in libvirt.spec.in: update for the release
* po/*.po*: updated localizations

12 years agoIgnore '.trs' files
Martin Kletzander [Mon, 28 Jan 2013 14:19:14 +0000 (15:19 +0100)]
Ignore '.trs' files

When doing checks with automake, there are '<testname>.trs' files left
behind, that might or might not be usable, however these show up in
'git status' even though we definitely don't want them to be tracked
in the repository'.  Automake adds the '--trs-files' option by default
since commit 0c81b43f711fb861f04227ced8dba889596d9c43 [1], which
consequently (from 1.13 in my case) started leaving these files behind
along with '<testname>.log' files as well (which we already ignore).

[1] http://git.savannah.gnu.org/gitweb/?p=automake.git;a=commitdiff;h=0c81b43

12 years agodocs: aesthetical cleanups
Martin Kletzander [Mon, 17 Dec 2012 15:03:23 +0000 (16:03 +0100)]
docs: aesthetical cleanups

Adding dots inside "exempli gratia" where missing.  While on that, I
took the liberty of changing it where found with simple grep.

12 years agoconf: Don't format cputune element when not needed
Martin Kletzander [Mon, 17 Dec 2012 15:03:01 +0000 (16:03 +0100)]
conf: Don't format cputune element when not needed

Commit 60b176c3d0f0d5037acfa5e27c7753f657833a0b introduced a bug that
when editing an XML with cputune similar to this:

...
  <vcpu placement='static' current='1'>2</vcpu>
  <cputune>
    <vcpupin vcpu="1" cpuset="0"/>
  </cputune>
...

results in formatted XML that looks like this:

...
  <vcpu placement='static' current='1'>2</vcpu>
  <cputune>
  </cputune>
...

That is caused by a condition depending on def->cputune.vcpupin being
set rather than checking def->cputune.nvcpupin.  Notice that nvcpupin
can be 0 and vcpupin can still be allocated since it's a pointer to an
array, so no harm done there.

I also changed it on other places in the code where it depended on the
wrong variable.

12 years agodocs: fix missed documentation for virterror functions
Claudio Bley [Tue, 29 Jan 2013 15:24:35 +0000 (16:24 +0100)]
docs: fix missed documentation for virterror functions

Commit f24404a3244b50c1d6d3a735445b02450ac40981 renamed virterror.c to
virerror.c but forgot to change the reference in this file.

12 years agovirlog: remove old code comment
Doug Goldstein [Sun, 27 Jan 2013 00:22:41 +0000 (18:22 -0600)]
virlog: remove old code comment

Setting the log output prefix to 0 is not supported and in fact results
in the following message:
warning : virLogParseOutputs:1021 : Ignoring invalid log output setting.

12 years agobuild: Regenerate man pages on version bump
Jiri Denemark [Tue, 29 Jan 2013 10:32:41 +0000 (11:32 +0100)]
build: Regenerate man pages on version bump

Whenever libvirt version changes in configure.ac, we need to regenerate
man pages so that they contain correct version info.

12 years agoconf: Fix cpumask leak in virDomainDefFree
Ján Tomko [Fri, 25 Jan 2013 15:00:47 +0000 (16:00 +0100)]
conf: Fix cpumask leak in virDomainDefFree

def->cpumask is a bitmap and needs to be freed by virBitmapFree.

12 years agoqemu: Destroy domain on decompression binary error
Michal Privoznik [Mon, 28 Jan 2013 14:13:27 +0000 (15:13 +0100)]
qemu: Destroy domain on decompression binary error

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

Currently, if qemuProcessStart() succeeds, but it's decompression
binary that returns nonzero status, we don't kill the qemu process,
but remove it from internal domain list, leaving the qemu process
hanging around totally uncontrolled.

12 years agorpc: Fix crash on error paths of message dispatching
Peter Krempa [Fri, 4 Jan 2013 15:15:04 +0000 (16:15 +0100)]
rpc: Fix crash on error paths of message dispatching

This patch resolves CVE-2013-0170:
https://bugzilla.redhat.com/show_bug.cgi?id=893450

When reading and dispatching of a message failed the message was freed
but wasn't removed from the message queue.

After that when the connection was about to be closed the pointer for
the message was still present in the queue and it was passed to
virNetMessageFree which tried to call the callback function from an
uninitialized pointer.

This patch removes the message from the queue before it's freed.

* rpc/virnetserverclient.c: virNetServerClientDispatchRead:
    - avoid use after free of RPC messages

12 years agorng: Change the datatype for volume name for common use
Osier Yang [Wed, 23 Jan 2013 11:04:34 +0000 (19:04 +0800)]
rng: Change the datatype for volume name for common use

The "volName" will be used by later patch.

12 years agoeng: Remove the duplicate definition
Osier Yang [Wed, 23 Jan 2013 11:04:33 +0000 (19:04 +0800)]
eng: Remove the duplicate definition

The RE for data type "name" storagepool.rng uses is same with
"genericName" in basictypes.rng.

12 years agoqemu_hotplug: Rework media changing process
Michal Privoznik [Thu, 24 Jan 2013 14:14:14 +0000 (15:14 +0100)]
qemu_hotplug: Rework media changing process

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

It seems like with new udev within guest OS, the tray is locked,
so we need to:
- 'eject'
- wait for tray to open
- 'change'

Moreover, even when doing bare 'eject', we should check for
'tray_open' as guest may have locked the tray. However, the
waiting phase shouldn't be unbounded, so I've chosen 10 retries
maximum, each per 500ms. This should give enough time for guest
to eject a media and open the tray.

12 years agomaint: one missed syms file
Eric Blake [Sat, 26 Jan 2013 16:59:12 +0000 (09:59 -0700)]
maint: one missed syms file

Commit f0aa493 missed a file.

* src/libvirt_driver_modules.syms: Add editor hint.

12 years agovbox: Adjust the UTF FREE macros
John Ferlan [Thu, 24 Jan 2013 00:34:48 +0000 (19:34 -0500)]
vbox: Adjust the UTF FREE macros

Adjust the macros to free memory allocated during various calls to
perform the check if parameter is NULL prior to really freeing and to
set the pointer to NULL after done freeing.

12 years agovbox: Address false positive for NULL dereference
John Ferlan [Thu, 24 Jan 2013 00:34:47 +0000 (19:34 -0500)]
vbox: Address false positive for NULL dereference

Resolve a false positive from 'vboxIIDFromUUID_v2_x()'. The code sets
'iid->value = &iid->backing' unconditionally prior to calling 'nsIDFromChar()'.
The 'vboxIIDUnalloc_v2_x()' checks iid->value to not be &iid->backing. The
iid->backing is a static buffer within the initialized structure.

12 years agoMake sure we only abort without libcurl if $with_esx = yes
Guido Günther [Fri, 25 Jan 2013 21:06:53 +0000 (22:06 +0100)]
Make sure we only abort without libcurl if $with_esx = yes

12 years agovirsh: Add --print-xml flag for attach-disk command
Peter Krempa [Fri, 25 Jan 2013 12:21:23 +0000 (13:21 +0100)]
virsh: Add --print-xml flag for attach-disk command

The flag causes the XML of the disk that would be attached to be printed
instead.

12 years agolibxl: Domain event handler improvements
Jim Fehlig [Mon, 21 Jan 2013 17:36:03 +0000 (10:36 -0700)]
libxl: Domain event handler improvements

Since libxl provides the domain ID in the event handler callback,
find the domain object based on the ID.  This approach prevents
processing the callback on a domain that has already been reaped.

Also, similar to the xl implementation, ignore the SUSPEND shutdown
reason.  By calling libxl_domain_suspend(), we know a shutdown
event with SUSPEND reason will be generated, but it can be safely
ignored since any subsequent cleanup will be done by the callers.

12 years agolibxl: Fix removing non-persistent domain after save
Jim Fehlig [Mon, 21 Jan 2013 17:32:34 +0000 (10:32 -0700)]
libxl: Fix removing non-persistent domain after save

libxlDoDomainSave() was removing non-persistent domains, but
required callers to have the virDomainObj locked.  Callers could
potentially unlock an already freed virDomainObj.  Move this
logic to the callers of libxlDoDomainSave().

12 years agolibxl: Explicitly remove timeouts
Jim Fehlig [Mon, 21 Jan 2013 17:30:29 +0000 (10:30 -0700)]
libxl: Explicitly remove timeouts

I've noticed that libxl can invoke timeout reregister/modify hooks
after returning from libxl_ctx_free.  Explicitly remove the
timeouts before freeing the libxl ctx to avoid executing hooks on
stale objects.

12 years agolibxl: Fix race between destruction of objects
Jim Fehlig [Mon, 21 Jan 2013 17:22:07 +0000 (10:22 -0700)]
libxl: Fix race between destruction of objects

It is possible to destroy and cleanup a VM, resulting in freeing the
libxlDomainObjPrivate object and associated libxl ctx, before all fds and
timeouts have been deregistered and destroyed.

Fix this race by incrementing the reference count on libxlDomainObjPrivate
for each fd and timeout registration.  Only when all fds and timeouts are
deregistered and destroyed will the libxlDomainObjPrivate be destroyed.

12 years agolibxl: Fix races in libxl event code
Jim Fehlig [Mon, 21 Jan 2013 17:09:05 +0000 (10:09 -0700)]
libxl: Fix races in libxl event code

The libxl driver is racy in it's interactions with libxl and libvirt's
event loop.  The event loop can invoke callbacks after libxl has
deregistered the event, and possibly access freed data associated with
the event.

This patch fixes the race by converting libxlDomainObjPrivate to a
virObjectLockable, and locking it while executing libxl upcalls and
libvirt event loop callbacks.

Note that using the virDomainObj lock is not satisfactory since it may
be desirable to hold the virDomainObj lock even when libxl events such
as reading and writing to xenstore need processed.

12 years agolibxl: Fix handling of timeouts
Jim Fehlig [Mon, 21 Jan 2013 16:59:28 +0000 (09:59 -0700)]
libxl: Fix handling of timeouts

xen-unstable changeset 26469 makes changes wrt modifying and deregistering
timeouts.

First, timeout modify callbacks will only be invoked with an
abs_t of {0,0}, i.e. make the timeout fire immediately.  Prior to this
commit, timeout modify callbacks were never invoked.

Second, timeout deregister hooks will no longer be called.

This patch makes changes in the libvirt libxl driver that should be
compatible before and after changeset 26469.

While at it, fix a potential overflow in the timeout register callback.

12 years agoconf: avoid NULL deref for pmsuspended domain state
Eric Blake [Thu, 24 Jan 2013 00:06:06 +0000 (17:06 -0700)]
conf: avoid NULL deref for pmsuspended domain state

While working with a pmsuspend vs. snapshot issue, I noticed that
the state file in /var/run/libvirt/qemu/dom.xml contained a rather
suspicious "(null)" string, which does not round-trip well through
a libvirtd restart.  Had I been on a platform other than glibc
where printf("%s",NULL) crashes instead of printing (null), we might
have noticed the problem much sooner.

And in fixing that problem, I also noticed that we had several
missing states, because we were #defining several *_LAST names
to a value _different_ than what they were already given as enums
in libvirt.h.  Yuck.  I got rid of default: labels in the case
statements, because they get in the way of gcc's -Wswitch helping
us ensure we cover all enum values.

* src/conf/domain_conf.c (virDomainStateReasonToString)
(virDomainStateReasonFromString): Fill in missing domain states;
rewrite case statement to let compiler enforce checking.
(VIR_DOMAIN_NOSTATE_LAST, VIR_DOMAIN_RUNNING_LAST)
(VIR_DOMAIN_BLOCKED_LAST, VIR_DOMAIN_PAUSED_LAST)
(VIR_DOMAIN_SHUTDOWN_LAST, VIR_DOMAIN_SHUTOFF_LAST)
(VIR_DOMAIN_CRASHED_LAST): Drop dead defines.
(VIR_DOMAIN_PMSUSPENDED_LAST): Drop dead define.
(virDomainPMSuspendedReason): Add missing enum function.
(virDomainRunningReason, virDomainPausedReason): Add missing enum
value.
* src/conf/domain_conf.h (virDomainPMSuspendedReason): Declare
missing functions.
* src/libvirt_private.syms (domain_conf.h): Export them.

12 years agomaint: make it easier to sort syms files
Eric Blake [Thu, 24 Jan 2013 01:20:01 +0000 (18:20 -0700)]
maint: make it easier to sort syms files

I got bit by 'make check' complaining that the sort order I got
by emacs' sort-lines function differed from expectations.

* src/libvirt_private.syms: Add emacs trailer.
* src/libvirt_atomic.syms: Likewise.
* src/libvirt_daemon.syms: Likewise.
* src/libvirt_esx.syms: Likewise.
* src/libvirt_libssh2.syms: Likewise.
* src/libvirt_linux.syms: Likewise.
* src/libvirt_openvz.syms: Likewise.
* src/libvirt_sasl.syms: Likewise.
* src/libvirt_vmx.syms: Likewise.
* src/libvirt_xenxs.syms: Likewise.

12 years agoqemu_monitor: Fix tray-open attribute in query-block
Michal Privoznik [Fri, 25 Jan 2013 11:56:48 +0000 (12:56 +0100)]
qemu_monitor: Fix tray-open attribute in query-block

With our code, we fail to query for tray-open attribute currently.
That's because in HMP it is 'tray-open' and in QMP it's 'tray_open'.
It always has been. However, we got it exactly the opposite.

12 years agoFix bogus reporting of KVM support for non-native emulators
Daniel P. Berrange [Fri, 25 Jan 2013 10:46:49 +0000 (10:46 +0000)]
Fix bogus reporting of KVM support for non-native emulators

A logic bug meant we reported KVM was possible for every
architecture, merely based on whether the query-kvm command
exists. We should instead have been doing it based on whether
the query-kvm command returns 'present: 1'

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoMove QEMU capabilities initialization later in QEMU startup
Daniel P. Berrange [Thu, 24 Jan 2013 18:32:31 +0000 (18:32 +0000)]
Move QEMU capabilities initialization later in QEMU startup

Currently QEMU capabilities are initialized before the QEMU driver
sets ownership on its various directories. The upshot is that if
you change the user/group in the qemu.conf file, libvirtd will fail
to probe QEMU the first time it is run after the config change.
Moving QEMU capabilities initialization to after the chown() calls
fixes this

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix performance & reliabilty of QMP probing
Daniel P. Berrange [Thu, 24 Jan 2013 18:21:23 +0000 (18:21 +0000)]
Fix performance & reliabilty of QMP probing

This previous commit

  commit 1a50ba2cb07d8bb2aa724062889deb9efd7ad9e9
  Author: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
  Date:   Mon Nov 26 15:17:13 2012 +0100

    qemu: Fix QMP Capabability Probing Failure

which attempted to make sure the QEMU process used for probing
ran as the right user id, caused serious performance regression
and unreliability in probing. The -daemonize switch in QEMU
guarantees that the monitor socket is present before the parent
process exits. This means libvirtd is guaranteed to be able to
connect immediately. By switching from -daemonize to the
virCommandDaemonize API libvirtd was no longer synchronized with
QEMU's startup process. The result was that the QEMU monitor
failed to open and went into its 200ms sleep loop. This happened
for all 25 binaries resulting in 5 seconds worth of sleeping
at libvirtd startup. In addition sometimes when libvirt connected,
QEMU would be partially initialized and crash causing total
failure to probe that binary.

This commit reverts the previous change, ensuring we do use the
-daemonize flag to QEMU. Startup delay is cut from 7 seconds
to 2 seconds on my machine, which is on a par with what it was
prior to the capabilities rewrite.

To deal with the fact that QEMU needs to be able to create the
pidfile, we switch pidfile location fron runDir to libDir, which
QEMU is guaranteed to be able to write to.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoqemuDomainSendKey: Relax the qemu driver locking
Michal Privoznik [Thu, 24 Jan 2013 09:39:06 +0000 (10:39 +0100)]
qemuDomainSendKey: Relax the qemu driver locking

Currently, there is no reason to hold qemu driver locked
throughout whole API execution. Moreover, we can use the
new qemuDomObjFromDomain() internal API to lookup domain then.

12 years agonode_memory: Add '\n' to help message
Satoru Moriya [Thu, 24 Jan 2013 19:40:51 +0000 (19:40 +0000)]
node_memory: Add '\n' to help message

Linefeed is missed in the help of node-memory-tune.
This patch just adds '\n' to get a correct help message.

Signed-off-by: Satoru Moriya <satoru.moriya@hds.com>
12 years agoqemu: escape ipv6 for rbd network disk hosts
Josh Durgin [Fri, 25 Jan 2013 02:45:31 +0000 (18:45 -0800)]
qemu: escape ipv6 for rbd network disk hosts

Hosts for rbd are ceph monitor daemons. These have fixed IP addresses,
so they are often referenced by IP rather than hostname for
convenience, or to avoid relying on DNS. Using IPv4 addresses as the
host name works already, but IPv6 addresses require rbd-specific
escaping because the colon is used as an option separator in the
string passed to qemu.

Escape these colons, and enclose the IPv6 address in square brackets
so it is distinguished from the port, which is currently mandatory.

Acked-by: Osier Yang <jyang@redhat.com>
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
12 years agosnapshot: fix state after external snapshot of S3 domain
Eric Blake [Wed, 9 Jan 2013 04:54:45 +0000 (21:54 -0700)]
snapshot: fix state after external snapshot of S3 domain

https://bugzilla.redhat.com/show_bug.cgi?id=876829 complains that
if a guest is put into S3 state (such as via virsh dompmsuspend)
and then an external snapshot is taken, qemu forcefully transitions
the domain to paused, but libvirt doesn't reflect that change
internally.  Thus, a user has to use 'virsh suspend' to get libvirt
back in sync with qemu state, and if the user doesn't know this
trick, then the guest appears hung.

* src/qemu/qemu_driver.c (qemuDomainSnapshotCreateActiveExternal):
Track fact that qemu wakes up a suspended domain on migration.

12 years agolocking: use virStrcpyStatic instead of memcpy
John Ferlan [Fri, 18 Jan 2013 13:50:37 +0000 (08:50 -0500)]
locking: use virStrcpyStatic instead of memcpy

12 years agopython: Fix bindings for virDomainSnapshotGet{Domain,Connect}
Jiri Denemark [Wed, 23 Jan 2013 11:14:57 +0000 (12:14 +0100)]
python: Fix bindings for virDomainSnapshotGet{Domain,Connect}

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

virDomainSnapshot.getDomain() and virDomainSnapshot.getConnect()
wrappers around virDomainSnapshotGet{Domain,Connect} were not supposed
to be ever implemented. The class should contain proper domain() and
connect() accessors that fetch python objects stored internally within
the class. While domain() was already provided, connect() was missing.

This patch adds connect() method to virDomainSnapshot class and
reimplements getDomain() and getConnect() methods as aliases to domain()
and connect() for backward compatibility.

12 years agoFix crash free'ing securityDriverNames in QEMU driver
Daniel P. Berrange [Thu, 24 Jan 2013 18:36:04 +0000 (18:36 +0000)]
Fix crash free'ing securityDriverNames in QEMU driver

The previous fix to avoid leaking securityDriverNames forgot to
handle the case of securityDriverNames being NULL, leading to
a crash

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoMake python objects inherit from 'object' base class
Daniel P. Berrange [Thu, 24 Jan 2013 13:15:06 +0000 (13:15 +0000)]
Make python objects inherit from 'object' base class

As of python >= 2.2, it is recommended that all objects inherit
from the 'object' base class. We already require python >= 2.3
for libvirt for thread macro support, so we should follow this
best practice.

See also

  http://stackoverflow.com/questions/4015417/python-class-inherits-object

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix leak of securityDriverNames
Daniel P. Berrange [Wed, 23 Jan 2013 17:42:15 +0000 (17:42 +0000)]
Fix leak of securityDriverNames

When shutting down, the QEMU driver forgot to free the
securityDriverNames string list

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoAvoid use of free'd memory in auto destroy callback
Daniel P. Berrange [Wed, 23 Jan 2013 17:22:27 +0000 (17:22 +0000)]
Avoid use of free'd memory in auto destroy callback

The autodestroy callback code has the following function
called from a hash iterator

  qemuDriverCloseCallbackRun(void *payload,
                             const void *name,
                             void *opaque)
  {
    ...
    char *uuidstr = name
    ...

    dom = closeDef->cb(data->driver, dom, data->conn);
    if (dom)
        virObjectUnlock(dom);

    virHashRemoveEntry(data->driver->closeCallbacks, uuidstr);
  }

The closeDef->cb function may well cause the current callback
to be removed, if it shuts down 'dom'. As such the use of
'uuidstr' in virHashRemoveEntry is accessing free'd memory.
We must make a copy of the uuid str before invoking the
callback to be safe.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoEnsure nodeinfo struct is initialized to zero
Daniel P. Berrange [Wed, 23 Jan 2013 15:43:21 +0000 (15:43 +0000)]
Ensure nodeinfo struct is initialized to zero

When linuxNodeInfoCPUPopulate() method triggered use of an
uninitialize value, since it did not initialize the 'sockets'
field in the virNodeInfoPtr struct:

==30020== Conditional jump or move depends on uninitialised value(s)
==30020==    at 0x5125DBD: linuxNodeInfoCPUPopulate (nodeinfo.c:513)
==30020==    by 0x51261A0: nodeGetInfo (nodeinfo.c:884)
==30020==    by 0x149B9B10: qemuCapsInit (qemu_capabilities.c:846)
==30020==    by 0x14A11B25: qemuCreateCapabilities (qemu_driver.c:424)
==30020==    by 0x14A12426: qemuStartup (qemu_driver.c:874)
==30020==    by 0x512A7AF: virStateInitialize (libvirt.c:822)
==30020==    by 0x40DE04: daemonRunStateInit (libvirtd.c:877)
==30020==    by 0x50ADCE5: virThreadHelper (virthreadpthread.c:161)
==30020==    by 0x328CA07D14: start_thread (pthread_create.c:308)
==30020==    by 0x328C6F246C: clone (clone.S:114)
(happened twice)

        if (socks > nodeinfo->sockets)    <--- here
            nodeinfo->sockets = socks;

Rather than doing this for each field, just make the caller memset
the entire struct to zero.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoselinux: Properly indent preprocessor directives
Jiri Denemark [Thu, 24 Jan 2013 13:10:50 +0000 (14:10 +0100)]
selinux: Properly indent preprocessor directives

12 years agoapparmor: Avoid freeing uninitialized pointer
Jiri Denemark [Thu, 24 Jan 2013 12:53:22 +0000 (13:53 +0100)]
apparmor: Avoid freeing uninitialized pointer

12 years agoxen: Actually fix the uninitialized variable
Peter Krempa [Thu, 24 Jan 2013 13:02:49 +0000 (14:02 +0100)]
xen: Actually fix the uninitialized variable

0eedb1d9bff672b24d6957dfaa0a8b42d9e851a7 fixed the wrong variable

12 years agoxen: Initialize variable before using
Peter Krempa [Thu, 24 Jan 2013 12:57:14 +0000 (13:57 +0100)]
xen: Initialize variable before using

Commit 87b4c10c6cf02251dd8c29b5b895bebc6ec297f9 added code that may call
the virCapabilitiesClearHostNUMACellCPUTopology function with
uninitialized second argument. Although the value wouldn't be used some
compilers whine about that.

12 years agoselinux: Only create the selabel_handle once.
Richard W.M. Jones [Wed, 23 Jan 2013 20:09:04 +0000 (20:09 +0000)]
selinux: Only create the selabel_handle once.

According to Eric Paris this is slightly more efficient because it
only loads the regular expressions in libselinux once.

12 years agoparallels_utils: Check return status properly from virCommandRun()
John Ferlan [Wed, 23 Jan 2013 22:04:48 +0000 (17:04 -0500)]
parallels_utils: Check return status properly from virCommandRun()

12 years agoutil: Need to add virCommandFree()
John Ferlan [Wed, 23 Jan 2013 22:04:47 +0000 (17:04 -0500)]
util: Need to add virCommandFree()

12 years agostorage: Need to add virCommandFree()
John Ferlan [Wed, 23 Jan 2013 22:04:46 +0000 (17:04 -0500)]
storage: Need to add virCommandFree()

12 years agosecurity: Need to add virCommandFree()
John Ferlan [Wed, 23 Jan 2013 22:04:45 +0000 (17:04 -0500)]
security: Need to add virCommandFree()

12 years agoparallels: Resolve some resource leaks
John Ferlan [Wed, 23 Jan 2013 22:04:44 +0000 (17:04 -0500)]
parallels: Resolve some resource leaks

Be sure to VIR_FREE(accel) and moved virDomainVideoDefFree() within no_memory
label to be consistent

Resolve resource leak in parallelsApplyIfaceParams() when the 'oldnet' is
allocated locally. Also virCommandFree(cmd) as necessary.

12 years agotest: Add support for thread and core information for the test driver
Peter Krempa [Tue, 22 Jan 2013 21:18:19 +0000 (22:18 +0100)]
test: Add support for thread and core information for the test driver

This patch adds demo processor topology information for the test driver.

12 years agocapabilities: Add additional data to the NUMA topology info
Peter Krempa [Fri, 18 Jan 2013 22:06:55 +0000 (23:06 +0100)]
capabilities: Add additional data to the NUMA topology info

This patch adds data gathering to the NUMA gathering files and adds
support for outputting the data. The test driver and xend driver need to
be adapted to fill sensible data to the structure in a future patch.

12 years agocapabilities: Switch CPU data in NUMA topology to a struct
Peter Krempa [Tue, 22 Jan 2013 17:42:08 +0000 (18:42 +0100)]
capabilities: Switch CPU data in NUMA topology to a struct

This will allow storing additional topology data in the NUMA topology
definition.

This patch changes the storage type and fixes fallout of the change
across the drivers using it.

This patch also changes semantics of adding new NUMA cell information.
Until now the data were re-allocated and copied to the topology
definition. This patch changes the addition function to steal the
pointer to a pre-allocated structure to simplify the code.