]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/log
people/liuw/libxenctrl-split/libvirt.git
13 years agoblockjob: add 'blockcopy' to virsh
Eric Blake [Thu, 12 Apr 2012 20:31:52 +0000 (14:31 -0600)]
blockjob: add 'blockcopy' to virsh

Rather than further overloading 'blockpull', I decided to create a
new virsh command to expose the new flags of virDomainBlockRebase.

Blocking until the command completes naturally is pointless, since
the block copy job is intended to run indefinitely.  Instead, I
made the command support three --wait modes: by default, it runs until
mirroring is started; with --pivot, it pivots as soon as mirroring
is started; and with --finish, it aborts (for a clean copy) as
soon as mirroring is started.

* tools/virsh.c (VSH_CMD_BLOCK_JOB_COPY): New mode.
(blockJobImpl): Support new flags.
(cmdBlockCopy): New command.
(cmdBlockJob): Support new job info, new abort flag.
* tools/virsh.pod (blockcopy, blockjob): Document the new command
and flags.

13 years agoblockjob: add new API flags
Eric Blake [Mon, 2 Apr 2012 22:56:07 +0000 (16:56 -0600)]
blockjob: add new API flags

This patch introduces a new block job, useful for live storage
migration using pre-copy streaming.  Justification for including
this under virDomainBlockRebase rather than adding a new command
includes: 1) there are now two possible block jobs in qemu, with
virDomainBlockRebase starting either type of command, and
virDomainBlockJobInfo and virDomainBlockJobAbort working to end
either type; 2) reusing this command allows distros to backport
this feature to the libvirt 0.9.10 API without a .so bump.

Note that a future patch may add a more powerful interface named
virDomainBlockJobCopy, dedicated to just the block copy job, in
order to expose even more options (such as setting an arbitrary
format type for the destination without having to probe it from a
pre-existing destination file); adding a new command for targetting
just block copy would be similar to how we already have
virDomainBlockPull for targetting just the block pull job.

Using a live VM with the backing chain:
  base <- snap1 <- snap2
as the starting point, we have:

- virDomainBlockRebase(dom, disk, "/path/to/copy", 0,
    VIR_DOMAIN_BLOCK_REBASE_COPY)
creates /path/to/copy with the same format as snap2, with no backing
file, so entire chain is copied and flattened

- virDomainBlockRebase(dom, disk, "/path/to/copy", 0,
    VIR_DOMAIN_BLOCK_REBASE_COPY|VIR_DOMAIN_BLOCK_REBASE_COPY_RAW)
creates /path/to/copy as a raw file, so entire chain is copied and
flattened

- virDomainBlockRebase(dom, disk, "/path/to/copy", 0,
    VIR_DOMAIN_BLOCK_REBASE_COPY|VIR_DOMAIN_BLOCK_REBASE_SHALLOW)
creates /path/to/copy with the same format as snap2, but with snap1 as
a backing file, so only snap2 is copied.

- virDomainBlockRebase(dom, disk, "/path/to/copy", 0,
    VIR_DOMAIN_BLOCK_REBASE_COPY|VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT)
reuse existing /path/to/copy (must have empty contents, and format is
probed[*] from the metadata), and copy the full chain

- virDomainBlockRebase(dom, disk, "/path/to/copy", 0,
    VIR_DOMAIN_BLOCK_REBASE_COPY|VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT|
    VIR_DOMAIN_BLOCK_REBASE_SHALLOW)
reuse existing /path/to/copy (contents must be identical to snap1,
and format is probed[*] from the metadata), and copy only the contents
of snap2

- virDomainBlockRebase(dom, disk, "/path/to/copy", 0,
    VIR_DOMAIN_BLOCK_REBASE_COPY|VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT|
    VIR_DOMAIN_BLOCK_REBASE_SHALLOW|VIR_DOMAIN_BLOCK_REBASE_COPY_RAW)
reuse existing /path/to/copy (must be raw volume with contents
identical to snap1), and copy only the contents of snap2

Less useful combinations:

- virDomainBlockRebase(dom, disk, "/path/to/copy", 0,
    VIR_DOMAIN_BLOCK_REBASE_COPY|VIR_DOMAIN_BLOCK_REBASE_SHALLOW|
    VIR_DOMAIN_BLOCK_REBASE_COPY_RAW)
fail if source is not raw, otherwise create /path/to/copy as raw and
the single file is copied (no chain involved)

- virDomainBlockRebase(dom, disk, "/path/to/copy", 0,
    VIR_DOMAIN_BLOCK_REBASE_COPY|VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT|
    VIR_DOMAIN_BLOCK_REBASE_COPY_RAW)
makes little sense: the destination must be raw but have no contents,
meaning that it is an empty file, so there is nothing to reuse

The other three flags are rejected without VIR_DOMAIN_BLOCK_COPY.

[*] Note that probing an existing file for its format can be a security
risk _if_ there is a possibility that the existing file is 'raw', in
which case the guest can manipulate the file to appear like some other
format.  But, by virtue of the VIR_DOMAIN_BLOCK_REBASE_COPY_RAW flag,
it is possible to avoid probing of raw files, at which point, probing
of any remaining file type is no longer a security risk.

It would be nice if we could issue an event when pivoting from phase 1
to phase 2, but qemu hasn't implemented that, and we would have to poll
in order to synthesize it ourselves.  Meanwhile, qemu will give us a
distinct job info and completion event when we either cancel or pivot
to end the job.  Pivoting is accomplished via the new:

virDomainBlockJobAbort(dom, disk, VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT)

Management applications can pre-create the copy with a relative
backing file name, and use the VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT
flag to have qemu reuse the metadata; if the management application
also copies the backing files to a new location, this can be used
to perform live storage migration of an entire backing chain.

* include/libvirt/libvirt.h.in (VIR_DOMAIN_BLOCK_JOB_TYPE_COPY):
New block job type.
(virDomainBlockJobAbortFlags, virDomainBlockRebaseFlags): New enums.
* src/libvirt.c (virDomainBlockRebase): Document the new flags,
and implement general restrictions on flag combinations.
(virDomainBlockJobAbort): Document the new flag.
(virDomainSaveFlags, virDomainSnapshotCreateXML)
(virDomainRevertToSnapshot, virDomainDetachDeviceFlags): Document
restrictions.
* include/libvirt/virterror.h (VIR_ERR_BLOCK_COPY_ACTIVE): New
error.
* src/util/virterror.c (virErrorMsg): Define it.

13 years agocpu: Improve error reporting on incompatible CPUs
Peter Krempa [Tue, 17 Apr 2012 13:24:47 +0000 (15:24 +0200)]
cpu: Improve error reporting on incompatible CPUs

This patch modifies the CPU comparrison function to report the
incompatibilities in more detail to ease identification of problems.

* src/cpu/cpu.h:
    cpuGuestData(): Add argument to return detailed error message.
* src/cpu/cpu.c:
    cpuGuestData(): Add passthrough for error argument.
* src/cpu/cpu_x86.c
    x86FeatureNames(): Add function to convert a CPU definition to flag
                       names.
    x86Compute(): - Add error message parameter
                  - Add macro for reporting detailed error messages.
                  - Improve error reporting.
                  - Simplify calculation of forbidden flags.
    x86DataIteratorInit():
    x86cpuidMatchAny(): Remove functions that are no longer needed.
* src/qemu/qemu_command.c:
    qemuBuildCpuArgStr(): - Modify for new function prototype
                          - Add detailed error reports
                          - Change error code on incompatible processors
                            to VIR_ERR_CONFIG_UNSUPPORTED instead of
                            internal error
* tests/cputest.c:
    cpuTestGuestData(): Modify for new function prototype

13 years agobuilding: remove libvirt_dbus.syms from EXTRA_DIST
Wen Congyang [Fri, 20 Apr 2012 03:05:13 +0000 (11:05 +0800)]
building: remove libvirt_dbus.syms from EXTRA_DIST

commit 2223ea98 removes src/libvirt_dbus.syms, but it forgets
to remove it from EXTRA_DIST. It will cause 'make dist' failed.

13 years agowin32: Properly handle TlsGetValue returning NULL
Matthias Bolte [Sat, 21 Apr 2012 17:03:08 +0000 (19:03 +0200)]
win32: Properly handle TlsGetValue returning NULL

virThreadSelf tries to access the virThreadPtr stored in TLS for the
current thread via TlsGetValue. When virThreadSelf is called on a thread
that was not created via virThreadCreate (e.g. the main thread) then
TlsGetValue returns NULL as TlsAlloc initializes TLS slots to NULL.

virThreadSelf can be called on the main thread via this call chain from
virsh

vshDeinit
virEventAddTimeout
virEventPollAddTimeout
virEventPollInterruptLocked
virThreadIsSelf

triggering a segfault as virThreadSelf unconditionally dereferences the
return value of TlsGetValue.

Fix this by making virThreadSelf check the TLS slot value for NULL and
setting the given virThreadPtr accordingly.

Reported by Marcel Müller.

13 years agoesx: Fix segfault in esxConnectToHost
Ryan Woodsmall [Sat, 21 Apr 2012 12:13:02 +0000 (14:13 +0200)]
esx: Fix segfault in esxConnectToHost

Caused by commit 4445e16bfa8056980ac643fabf17186f9e685925 that
made the code used the connection private data pointer before
it was initialized.

13 years agoopenvz: wire up getHostname
Guido Günther [Mon, 16 Apr 2012 08:50:33 +0000 (10:50 +0200)]
openvz: wire up getHostname

13 years agovirnetserver: handle sigaction correctly
Eric Blake [Fri, 20 Apr 2012 03:41:27 +0000 (21:41 -0600)]
virnetserver: handle sigaction correctly

POSIX says that sa_sigaction is only safe to use if sa_flags
includes SA_SIGINFO; conversely, sa_handler is only safe to
use when flags excludes that bit.  Gnulib doesn't guarantee
an implementation of SA_SIGINFO, but does guarantee that
if SA_SIGINFO is undefined, we can safely define it to 0 as
long as we don't dereference the 2nd or 3rd argument of
any handler otherwise registered via sa_sigaction.

Based on a report by Wen Congyang.

* src/rpc/virnetserver.c (SA_SIGINFO): Stub for mingw.
(virNetServerSignalHandler): Avoid bogus dereference.
(virNetServerFatalSignal, virNetServerNew): Set flags properly.
(virNetServerAddSignalHandler): Drop unneeded #ifdef.

13 years agoconf: remove redundant ()
Eric Blake [Thu, 19 Apr 2012 20:18:38 +0000 (14:18 -0600)]
conf: remove redundant ()

I almost copied-and-pasted some redundant () into my new code,
and figured a general cleanup prereq patch would be better instead.

No semantic change.

* src/conf/domain_conf.c (virDomainLeaseDefParseXML)
(virDomainDiskDefParseXML, virDomainFSDefParseXML)
(virDomainActualNetDefParseXML, virDomainNetDefParseXML)
(virDomainGraphicsDefParseXML, virDomainVideoAccelDefParseXML)
(virDomainVideoDefParseXML, virDomainHostdevFind)
(virDomainControllerInsertPreAlloced, virDomainDefParseXML)
(virDomainObjParseXML, virDomainCpuSetFormat)
(virDomainCpuSetParse, virDomainDiskDefFormat)
(virDomainActualNetDefFormat, virDomainNetDefFormat)
(virDomainTimerDefFormat, virDomainGraphicsListenDefFormat)
(virDomainDefFormatInternal, virDomainNetGetActualHostdev)
(virDomainNetGetActualBandwidth, virDomainGraphicsGetListen):
Reduce extra ().

13 years agobuild: avoid strtol and strtod
Eric Blake [Thu, 19 Apr 2012 00:06:59 +0000 (18:06 -0600)]
build: avoid strtol and strtod

Ensure we don't introduce any more lousy integer parsing in new
code, while avoiding a scrub-down of existing legacy code.

Note that we also need to enable sc_prohibit_atoi_atof (see cfg.mk
local-checks-to-skip) before we are bulletproof, but that also
entails scrubbing I'm not ready to do at the moment.

* src/util/util.c (virStrToLong_i, virStrToLong_ui)
(virStrToLong_l, virStrToLong_ul, virStrToLong_ll)
(virStrToLong_ull, virStrToDouble): Mark exemptions.
* src/util/virmacaddr.c (virMacAddrParse): Likewise.
* cfg.mk (sc_prohibit_strtol): New syntax check.
(exclude_file_name_regexp--sc_prohibit_strtol): Ignore files that
I'm not willing to fix yet.
(local-checks-to-skip): Re-enable sc_prohibit_atoi_atof.

13 years agoconf: tighten up XML integer parsing
Eric Blake [Wed, 18 Apr 2012 23:58:44 +0000 (17:58 -0600)]
conf: tighten up XML integer parsing

https://bugzilla.redhat.com/show_bug.cgi?id=617711 reported that
even with my recent patched to allow <memory unit='G'>1</memory>,
people can still get away with trying <memory>1G</memory> and
silently get <memory unit='KiB'>1</memory> instead.  While
virt-xml-validate catches the error, our C parser did not.

Not to mention that it's always fun to fix bugs while reducing
lines of code.  :)

* src/conf/domain_conf.c (virDomainParseMemory): Check for parse error.
(virDomainDefParseXML): Avoid strtoll.
* src/conf/storage_conf.c (virStorageDefParsePerms): Likewise.
* src/util/xml.c (virXPathLongBase, virXPathULongBase)
(virXPathULongLong, virXPathLongLong): Likewise.

13 years agovirsh: avoid strtol
Eric Blake [Wed, 18 Apr 2012 23:26:17 +0000 (17:26 -0600)]
virsh: avoid strtol

We were forgetting to check errno for overflow.

* tools/virsh.c (get_integer_keycode, vshCommandOptInt)
(vshCommandOptUInt, vshCommandOptUL, vshCommandOptLongLong)
(vshCommandOptULongLong): Rewrite to be safer.

13 years agobuild: avoid type-punning in vbox
Eric Blake [Thu, 19 Apr 2012 23:19:32 +0000 (17:19 -0600)]
build: avoid type-punning in vbox

Commit 78345c68 makes at least gcc 4.1.2 on RHEL 5 complain:

cc1: warnings being treated as errors
In file included from vbox/vbox_V4_0.c:13:
vbox/vbox_tmpl.c: In function 'vboxDomainUndefineFlags':
vbox/vbox_tmpl.c:5298: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]

* src/vbox/vbox_tmpl.c (vboxDomainUndefineFlags): Use union to
avoid compiler warning.

13 years agobuild: fix fresh checkout on RHEL5
Eric Blake [Thu, 19 Apr 2012 23:04:00 +0000 (17:04 -0600)]
build: fix fresh checkout on RHEL5

Building a fresh checkout on RHEL 5 has been broken since commit
29db7a00, due to a gnulib regression in the bootstrap script
(incremental builds from a checkout earlier than that point were
okay, though).

* .gnulib: Update to latest, for bootstrap fixes.
* bootstrap: Resync from gnulib.
* gnulib/local/top/maint.mk.diff: Drop patch that was added
upstream in the meantime.

13 years agovirsh: avoid uninitialized memory usage
Eric Blake [Thu, 19 Apr 2012 08:51:11 +0000 (16:51 +0800)]
virsh: avoid uninitialized memory usage

Detected by valgrind, via Alex Jia.  Caused by imcomplete
copy-and-paste from vshWatchJob in commit 3b96a892.

* tools/virsh.c (cmdBlockPull): fix uninitialized memory usage.

* How to reproduce?
$ qemu-img create /var/lib/libvirt/images/test 1M
$ cat > /tmp/test.xml <<EOF
<domain type='qemu'>
  <name>test</name>
  <memory>219200</memory>
  <vcpu>1</vcpu>
  <os>
    <type arch='x86_64'>hvm</type>
    <boot dev='hd'/>
  </os>
  <devices>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/test'/>
      <target dev='vda' bus='virtio'/>
    </disk>
    <input type='mouse' bus='ps2'/>
    <graphics type='spice' autoport='yes' listen='0.0.0.0'/>
  </devices>
</domain>
EOF
$ virsh define /tmp/test.xml
$ valgrind -v virsh blockpull test /var/lib/libvirt/images/test --wait

actual result:

==10906== 1 errors in context 1 of 1:
==10906== Syscall param rt_sigaction(act->sa_flags) points to uninitialised byte(s)
==10906==    at 0x39CF80F5BE: __libc_sigaction (sigaction.c:67)
==10906==    by 0x43016C: cmdBlockPull (virsh.c:7638)
==10906==    by 0x4150D4: vshCommandRun (virsh.c:18574)
==10906==    by 0x425E73: main (virsh.c:20178)
==10906==  Address 0x7fefffae8 is on thread 1's stack

13 years agoThe policy kit and HAL node device drivers both require a
Daniel P. Berrange [Thu, 19 Apr 2012 14:34:35 +0000 (15:34 +0100)]
The policy kit and HAL node device drivers both require a
DBus connection. The HAL device code further requires that
the DBus connection is integrated with the event loop and
provides such glue logic itself.

The forthcoming FirewallD integration also requires a
dbus connection with event loop integration. Thus we need
to pull the current event loop glue out of the HAL driver.

Thus we create src/util/virdbus.{c,h} files. This contains
just one method virDBusGetSystemBus() which obtains a handle
to the single shared system bus instance, with event glue
automagically setup.

13 years agonwfilter: Fix support for trusted DHCP servers
Stefan Berger [Thu, 19 Apr 2012 14:21:43 +0000 (10:21 -0400)]
nwfilter: Fix support for trusted DHCP servers

Fix the support for trusted DHCP server in the ebtables code's
hard-coded function applying DHCP only filtering rules:
Rather than using a char * use the more flexible
virNWFilterVarValuePtr that contains the trusted DHCP server(s)
IP address. Process all entries.

Since all callers so far provided NULL as parameter, no changes
are necessary in any other code.

13 years agoSupport for atomic operations on integers
Stefan Berger [Thu, 19 Apr 2012 14:21:43 +0000 (10:21 -0400)]
Support for atomic operations on integers

For threading support, add atomic add and sub operations working on
integers. Base this on locking support provided by virMutex.

13 years agoImplement virHashRemoveAll function
Stefan Berger [Thu, 19 Apr 2012 14:21:43 +0000 (10:21 -0400)]
Implement virHashRemoveAll function

Implement function to remove all entries of a hash table.

13 years agovirsh: Fix and clarify the --title flag for the list command in man page
Peter Krempa [Thu, 19 Apr 2012 08:33:05 +0000 (10:33 +0200)]
virsh: Fix and clarify the --title flag for the list command in man page

13 years agoutil: remove dead casts
Eric Blake [Wed, 18 Apr 2012 23:16:29 +0000 (17:16 -0600)]
util: remove dead casts

The sequence:
  long long val;
  if ((long long) val != val)
is dead code.

* src/util/util.c (virStrToLong_ll, virStrToLong_ull): Remove
useless cast.

13 years agoutil: only register callbacks for CREATE operations in virnetdevmacvlan.c
D. Herrendoerfer [Fri, 13 Apr 2012 12:41:16 +0000 (14:41 +0200)]
util: only register callbacks for CREATE operations in virnetdevmacvlan.c

Currently upon a migration a callback is created when a 802.1qbg link
is set to PREASSOCIATE, this should not happen because this is a no-op
on most switches, and does not lead to an ASSOCIATE state.  This patch
only creates callbacks when CREATE or RESTORE is requested.  Migration
and libvirtd restart scenarios are already handled elsewhere.

Signed-off-by: D. Herrendoerfer <d.herrendoerfer@herrendoerfer.name>
13 years agoFix a memory leak
Stefan Berger [Tue, 17 Apr 2012 19:13:33 +0000 (15:13 -0400)]
Fix a memory leak

The below patch fixes the following memory leak.

==20624== 24 bytes in 2 blocks are definitely lost in loss record 532 of 1,867
==20624==    at 0x4A05E46: malloc (vg_replace_malloc.c:195)
==20624==    by 0x38EC27FC01: strdup (strdup.c:43)
==20624==    by 0x4EB6BA3: virDomainChrSourceDefCopy (domain_conf.c:1122)
==20624==    by 0x495D76: qemuProcessFindCharDevicePTYs (qemu_process.c:1497)
==20624==    by 0x498321: qemuProcessWaitForMonitor (qemu_process.c:1258)
==20624==    by 0x49B5F9: qemuProcessStart (qemu_process.c:3652)
==20624==    by 0x468B5C: qemuDomainObjStart (qemu_driver.c:4753)
==20624==    by 0x469171: qemuDomainStartWithFlags (qemu_driver.c:4810)
==20624==    by 0x4F21735: virDomainCreate (libvirt.c:8153)
==20624==    by 0x4302BF: remoteDispatchDomainCreateHelper (remote_dispatch.h:852)
==20624==    by 0x4F72C14: virNetServerProgramDispatch (virnetserverprogram.c:416)
==20624==    by 0x4F6D690: virNetServerHandleJob (virnetserver.c:164)
==20624==    by 0x4E8F43D: virThreadPoolWorker (threadpool.c:144)
==20624==    by 0x4E8EAB5: virThreadHelper (threads-pthread.c:161)
==20624==    by 0x38EC606CCA: start_thread (pthread_create.c:301)
==20624==    by 0x38EC2E0C2C: clone (clone.S:115)

13 years agoblockjob: add virsh blockpull --wait
Eric Blake [Thu, 12 Apr 2012 19:12:21 +0000 (13:12 -0600)]
blockjob: add virsh blockpull --wait

I'm tired of shell-scripting to wait for completion of a block pull,
when virsh can be taught to do the same.  I couldn't quite reuse
vshWatchJob, as this is not a case of a long-running command where
a second thread must be used to probe job status (at least, not unless
I make virsh start doing blocking waits for an event to fire), but it
served as inspiration for my simpler single-threaded loop.  There is
up to a half-second delay between sending SIGINT and the job being
aborted, but I didn't think it worth the complexity of a second thread
and use of poll() just to minimize that delay.

* tools/virsh.c (cmdBlockPull): Add new options to wait for
completion.
(blockJobImpl): Add argument.
(cmdBlockJob): Adjust caller.
* tools/virsh.pod (blockjob): Document new mode.

13 years agoqemu: use consistent error when qemu binary is too old
Eric Blake [Tue, 17 Apr 2012 04:16:04 +0000 (22:16 -0600)]
qemu: use consistent error when qemu binary is too old

Most of our errors complaining about an inability to support a
particular action due to qemu limitations used CONFIG_UNSUPPORTED,
but we had a few outliers.  Reported by Jiri Denemark.

* src/qemu/qemu_command.c (qemuBuildDriveDevStr): Prefer
CONFIG_UNSUPPORTED.
* src/qemu/qemu_driver.c (qemuDomainReboot)
(qemuDomainBlockJobImpl): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainAttachPciControllerDevice):
Likewise.
* src/qemu/qemu_monitor.c (qemuMonitorTransaction)
(qemuMonitorBlockJob, qemuMonitorSystemWakeup): Likewise.

13 years agovirsh: minor syntactic cleanups
Eric Blake [Sat, 14 Apr 2012 22:35:22 +0000 (16:35 -0600)]
virsh: minor syntactic cleanups

No semantic change.

* tools/virsh.c: Fix some spacing issues, {} usage, long lines,
and redundant ().

13 years agovbox: avoid provoking assertions in VBoxSVC
Jean-Baptiste Rouault [Fri, 13 Apr 2012 13:04:14 +0000 (15:04 +0200)]
vbox: avoid provoking assertions in VBoxSVC

Passing a NULL pointer to IMachine::delete virtualbox API
causes VBoxSVC to raise an assertion. This patch passes
an empty array instead.

13 years agodocs: Improve the schema for fs device
Osier Yang [Tue, 17 Apr 2012 09:50:41 +0000 (17:50 +0800)]
docs: Improve the schema for fs device

<filesystemtgt> is redundant, as every group uses it; <address>
shouldn't be in <filesystemtgt> in case of the meaning could be
"filesystemtarget"; The elements <address>, <alias>, <target>,
... should be interleaved.

13 years agoconf: Do not parse cpuset only if the placement is auto
Osier Yang [Tue, 17 Apr 2012 14:57:01 +0000 (22:57 +0800)]
conf: Do not parse cpuset only if the placement is auto

So that a domain xml which doesn't have "placement" specified, but
"cpuset" is specified, could be parsed. And in this case, the
"placement" mode will be set as "static".

13 years agotests: Update read-bufsiz to delete the UUID of vm XML
Osier Yang [Tue, 17 Apr 2012 14:56:18 +0000 (22:56 +0800)]
tests: Update read-bufsiz to delete the UUID of vm XML

Since now we have fixed domain UUID for test driver, defining
a domain with different name but same UUID doesn't work any
more. This patch delete the UUID from the dumped XML so that
it could be generated.

13 years agotest: Set the fixed uuid for the default XMLs
Osier Yang [Tue, 17 Apr 2012 14:53:51 +0000 (22:53 +0800)]
test: Set the fixed uuid for the default XMLs

The objects (domain, pool, network, etc) for testing are defined/
started each time when opening a connect to test driver, and thus
the UUID for the objects will be generated each time, with different
values. e.g.

% for i in {1..3}; do ./tools/virsh --connect \
  test:///default dumpxml test | grep uuid; done
  <uuid>a1b6ee1f-97de-f0ee-617a-0cdb74947df5</uuid>
  <uuid>ee68d7d2-3eb9-593e-2769-797ce1f4c4aa</uuid>
  <uuid>fecb1d3a-918a-8412-e534-76192cf32b18</uuid>

It's the potential bug which can cause operations like below to fail:

$ virsh -c test:///default dumpxml test > test.xml

[ Some modificatons, though it's not supported, but it should work ]

$ virsh -c test:///default define test.xml

This patch set fixed UUID for objects which support it. (domain,
pool, network).

13 years agoqemu: Split ide-drive into ide-cd and ide-hd
Osier Yang [Tue, 17 Apr 2012 09:16:52 +0000 (17:16 +0800)]
qemu: Split ide-drive into ide-cd and ide-hd

A "ide-drive" device can be either a hard disk or a CD-ROM,
if there is ",media=cdrom" specified for the backend, it's
a CD-ROM, otherwise it's a hard disk.

Upstream qemu splitted "ide-drive" into "ide-hd" and "ide-cd"
since commit 1f56e32, and ",media=cdrom" is not required for
ide-cd anymore. "ide-drive" is still supported for backwards
compatibility, but no doubt we should go foward.

13 years agoqemu: Split scsi-disk into into scsi-hd and scsi-cd
Osier Yang [Tue, 17 Apr 2012 09:08:05 +0000 (17:08 +0800)]
qemu: Split scsi-disk into into scsi-hd and scsi-cd

A "scsi-disk" device can be either a hard disk or a CD-ROM,
if there is ",media=cdrom" specified for the backend, it's
a CD-ROM, otherwise it's a hard disk.

But upstream qemu splitted "scsi-disk" into "scsi-hd" and
"scsi-cd" since commit b443ae, and ",media=cdrom" is not
required for scsi-cd anymore. "scsi-disk" is still supported
for backwards compatibility, but no doubt we should go
foward.

13 years agoDo not enforce source type of console[0]
Jan Kiszka [Tue, 13 Mar 2012 15:48:27 +0000 (16:48 +0100)]
Do not enforce source type of console[0]

If console[0] is an alias for serial[0], do not enforce the former to
have a PTY source type. This breaks serial consoles on stdio and makes
no sense.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
13 years agoxen: do not use ioemu type for any emulated NIC
Stefan Bader [Fri, 13 Apr 2012 13:14:56 +0000 (15:14 +0200)]
xen: do not use ioemu type for any emulated NIC

When using the xm/xend stack to manage instances there is a bug
that causes the emulated interfaces to be unusable when the vif
config contains type=ioemu.

The current code already has a special quirk to not use this
keyword if no specific model is given for the emulated NIC
(defaulting to rtl8139).
Essentially it works because regardless of the type argument,i
the Xen stack always creates emulated and paravirt interfaces and
lets the guest decide which one to use. So neither xl nor xm stack
actually require the type keyword for emulated NICs.

Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
13 years agoopenvz: Correct the comments for new node APIs
Osier Yang [Tue, 17 Apr 2012 02:08:53 +0000 (10:08 +0800)]
openvz: Correct the comments for new node APIs

It should be 0.9.12 instead of 0.9.11

13 years agodocs: fix 'omitted' typo in <cputune> doc
Christophe Fergeau [Mon, 16 Apr 2012 16:41:25 +0000 (18:41 +0200)]
docs: fix 'omitted' typo in <cputune> doc

'omitted' was mispelt 'commited' twice. One of the sentences with
the typo was also missing an 'is' ('each VCPU *is* pinned to all...')
which I added in this commit while I was at it.

13 years agodocs: add missing </span> in <vcpu placement> doc
Christophe Fergeau [Mon, 16 Apr 2012 16:40:44 +0000 (18:40 +0200)]
docs: add missing </span> in <vcpu placement> doc

13 years agoqemuProcessStart: Switch to flags instead of bunch booleans
Michal Privoznik [Thu, 8 Mar 2012 13:20:19 +0000 (14:20 +0100)]
qemuProcessStart: Switch to flags instead of bunch booleans

Currently, we have 3 boolean arguments we have to pass
to qemuProcessStart(). As libvirt grows it is harder and harder
to remember them and their position. Therefore we should
switch to flags instead.

13 years agodocs: fix path to openvz network configuration file
Guido Günther [Mon, 16 Apr 2012 14:18:29 +0000 (16:18 +0200)]
docs: fix path to openvz network configuration file

It's vznet.conf not vznetctl.conf, see e.g.:

http://git.openvz.org/?p=vzctl;a=blob;f=bin/vznetcfg.in;h=e91f5c4a0744c1ea149e1b8c241b666052e10b12;hb=HEAD

13 years agostorage: lvm: use correct lv* command parameters
Cole Robinson [Fri, 13 Apr 2012 11:34:41 +0000 (07:34 -0400)]
storage: lvm: use correct lv* command parameters

lvcreate want's the parent pool's name, not the pool path
lvchange and lvremove want lv specified as $vgname/$lvname

This largely worked before because these commands strip off a
starting /dev. But https://bugzilla.redhat.com/show_bug.cgi?id=714986
is from a user using a 'nested VG' that was having problems.

I couldn't find any info on nested LVM and the reporter never responded,
but I reproduced with XML that specified a valid source name, and
set target path to a symlink.

13 years agoqemu: Avoid the memory allocation and freeing
Osier Yang [Wed, 11 Apr 2012 14:40:34 +0000 (22:40 +0800)]
qemu: Avoid the memory allocation and freeing

13 years agonumad: Ignore cpuset if placement is auto
Osier Yang [Wed, 11 Apr 2012 14:40:33 +0000 (22:40 +0800)]
numad: Ignore cpuset if placement is auto

As explained in previous patch, numad will balance the affinity
dynamically, so reflecting the cpuset from numad at the first
time doesn't make much case, and may just could cause confusion.

13 years agonumad: Convert node list to cpumap before setting affinity
Osier Yang [Mon, 16 Apr 2012 10:04:27 +0000 (18:04 +0800)]
numad: Convert node list to cpumap before setting affinity

Instead of returning a CPUs list, numad returns NUMA node
list instead, this patch is to convert the node list to
cpumap before affinity setting. Otherwise, the domain
processes will be pinned only to CPU[$numa_cell_num],
which will cause significiant performance losses.

Also because numad will balance the affinity dynamically,
reflecting the cpuset from numad back doesn't make much
sense then, and it may just could produce confusion for
the users. Thus the better way is not to reflect it back
to XML. And in this case, it's better to ignore the cpuset
when parsing XML.

The codes to update the cpuset is removed in this patch
incidentally, and there will be a follow up patch to ignore
the manually specified "cpuset" if "placement" is "auto",
and document will be updated too.

13 years agoSet Martin Kletzander as a commiter
Daniel Veillard [Mon, 16 Apr 2012 08:57:06 +0000 (16:57 +0800)]
Set Martin Kletzander as a commiter

13 years agoopenvz: wire up more node information functions
Guido Günther [Sat, 14 Apr 2012 20:17:48 +0000 (22:17 +0200)]
openvz: wire up more node information functions

in detail nodeGetCPUStats, nodeGetMemoryStats, nodeGetCellsFreeMemory
and nodeGetFreeMemory

13 years agoFix macvtap detection by also checking for IFLA_VF_MAX
Guido Günther [Sat, 14 Apr 2012 17:18:03 +0000 (19:18 +0200)]
Fix macvtap detection by also checking for IFLA_VF_MAX

since this isn't available on older kernels such as Debian Squeeze's
2.6.32. This make --with-macvtap=check work as expected.

13 years agovirnetdev: Check for defined IFLA_VF_*
Philipp Hahn [Fri, 13 Apr 2012 13:43:58 +0000 (15:43 +0200)]
virnetdev: Check for defined IFLA_VF_*

The linux-2.6.32 kernel header does not yet define IFLA_VF_MAX and others,
which breaks compiling a new libvirt on old systems like Debian Squeeze.

(I also have to add --without-macvtap --disable-werror --without-virtualport to
 ./configure to get it to compile.)

Signed-off-by: Philipp Hahn <hahn@univention.de>
13 years agoWeb placeholder for pending patches on the web site
Daniel Veillard [Fri, 13 Apr 2012 14:52:03 +0000 (22:52 +0800)]
Web placeholder for pending patches on the web site

This is based on recent developments on patch checker and the
goal is to keep a list of pending patches needing review on the
project web site. The page template in git just holds a pointer
to the web page.

13 years agogitignore: Reorder alphabetically
Michal Privoznik [Fri, 13 Apr 2012 08:55:15 +0000 (10:55 +0200)]
gitignore: Reorder alphabetically

Recent git reorders .gitignore alphabetically. However, changes are
not committed and I am tired of discarding these changes from
my patches.

13 years agoconf: Avoid double assignment in virDomainDiskRemove
Michal Privoznik [Fri, 13 Apr 2012 09:19:29 +0000 (11:19 +0200)]
conf: Avoid double assignment in virDomainDiskRemove

Although it should be harmless to do:
    disk = disk = def->disks[i]
some not-so-wise compilers may fool around.
Besides, such assignment is useless here.

13 years agoqemu: Fix mem leak in qemuProcessInitCpuAffinity
Michal Privoznik [Fri, 13 Apr 2012 08:53:17 +0000 (10:53 +0200)]
qemu: Fix mem leak in qemuProcessInitCpuAffinity

If placement mode is AUTO, on some return paths char *cpumap or
char *nodeset are leaked.

13 years agoxend_internal: Use domain/status for shutdown check
Stefan Bader [Thu, 12 Apr 2012 13:42:37 +0000 (15:42 +0200)]
xend_internal: Use domain/status for shutdown check

On newer xend (v3.x and after) there is no state and domid reported
for inactive domains. When initially creating connections this is
handled in various places by assigning domain->id = -1.
But once an instance has been running, the id is set to the current
domain id. And it does not change when the instance is shut down.
So when querying the domain info, the hypervisor driver, which gets
asked first will indicate it cannot find information, then the
xend driver is asked and will set the status to NOSTATE because it
checks for the -1 domain id.
Checking domain/status for 0 seems to be more reliable for that.

One note: I am not sure whether the domain->id also should get set
back to -1 whenever any sub-driver thinks the instance is no longer
running.

BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=746007
BugLink: http://bugs.launchpad.net/bugs/929626
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
13 years agoqemu,util: fix netlink callback registration for migration
D. Herrendoerfer [Thu, 29 Mar 2012 11:15:00 +0000 (13:15 +0200)]
qemu,util: fix netlink callback registration for migration

This patch adds a netlink callback when migrating a VEPA enabled
virtual machine.  It fixes a Bug where a VM would not request a port
association when it was cleared by lldpad.

This patch requires the latest git version of lldpad to work.

Signed-off-by: D. Herrendoerfer <d.herrendoerfer@herrendoerfer.name>
13 years agoqemuOpenFile: Don't force chown on NFS
Michal Privoznik [Wed, 11 Apr 2012 09:13:40 +0000 (11:13 +0200)]
qemuOpenFile: Don't force chown on NFS

If dynamic_ownership is off and we are creating a file on NFS
we force chown. This will fail as chown/chmod are not supported
on NFS. However, with no dynamic_ownership we are not required
to do any chown.

13 years agodaemon: Plug memory leaks
Alex Jia [Thu, 12 Apr 2012 09:10:42 +0000 (17:10 +0800)]
daemon: Plug memory leaks

* daemon/libvirtd-config.c (daemonConfigFree): fix memory leaks.

How to reproduce?

% make && make -C tests check TESTS=libvirtdconftest
% cd tests && valgrind -v --leak-check=full ./libvirtdconftest

actual result:

==11008== 185 bytes in 5 blocks are definitely lost in loss record 3 of 5
==11008==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==11008==    by 0x39CF07F6E1: strdup (strdup.c:43)
==11008==    by 0x406626: daemonConfigLoadOptions (libvirtd-config.c:438)
==11008==    by 0x406800: daemonConfigLoadData (libvirtd-config.c:492)
==11008==    by 0x403CCF: testCorrupt (libvirtdconftest.c:110)
==11008==    by 0x404FAD: virtTestRun (testutils.c:145)
==11008==    by 0x403A34: mymain (libvirtdconftest.c:219)
==11008==    by 0x404687: virtTestMain (testutils.c:700)
==11008==    by 0x39CF01ECDC: (below main) (libc-start.c:226)
==11008==
==11008== LEAK SUMMARY:
==11008==    definitely lost: 185 bytes in 5 blocks

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agoblockjob: allow for fast-finishing job
Eric Blake [Wed, 11 Apr 2012 22:28:35 +0000 (16:28 -0600)]
blockjob: allow for fast-finishing job

In my testing, I was able to provoke an odd block pull failure:

$ virsh blockpull dom vda --bandwidth 10000
error: Requested operation is not valid: No active operation on device: drive-virtio-disk0

merely by using gdb to artifically wait to do the block job set speed
until after the pull had already finished.  But in reality, that should
be a success, since the pull finished before we had a chance to set
speed.  Furthermore, using a double job lock is not only annoying, but
a bug in itself - if you do parallel virDomainBlockRebase, and hit
the race window just right, the first call grabs the VM job to start
a fast block job, then the second call grabs the VM job to start
a long-running job with unspecified speed, then the first call finally
regrabs the VM job and sets the speed, which ends up running the
second job under the speed from the first call.  By consolidating
things into a single job, we avoid opening that race, as well as reduce
the time between starting the job and changing the speed, for less
likelihood of the speed change happening after block job completion
in the first place.

* src/qemu/qemu_monitor.h (BLOCK_JOB_CMD): Add new mode.
* src/qemu/qemu_driver.c (qemuDomainBlockRebase): Move secondary
job call...
(qemuDomainBlockJobImpl): ...here, for fewer locks.
* src/qemu/qemu_monitor_json.c (qemuMonitorJSONBlockJob): Change
return value on new internal mode.

13 years agoblockjob: wire up qemu async virDomainBlockJobAbort
Eric Blake [Wed, 11 Apr 2012 22:17:36 +0000 (16:17 -0600)]
blockjob: wire up qemu async virDomainBlockJobAbort

Without the VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC flag, libvirt will internally
poll using qemu's "query-block-jobs" API and will not return until the
operation has been completed.  API users are advised that this operation
is unbounded and further interaction with the domain during this period
may block.  Future patches may refactor things to allow other queries in
parallel with this polling.  For older qemu, we synthesize the cancellation
event, since qemu won't generate it.

The choice of polling duration copies from the code in qemu_migration.c.

Signed-off-by: Adam Litke <agl@us.ibm.com>
Cc: Stefan Hajnoczi <stefanha@gmail.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agoblockjob: optimize JSON event handler lookup
Eric Blake [Wed, 11 Apr 2012 14:58:09 +0000 (08:58 -0600)]
blockjob: optimize JSON event handler lookup

Probably in the noise, but this will let us scale more efficiently
as we learn to recognize even more qemu events.

* src/qemu/qemu_monitor_json.c (eventHandlers): Sort.
(qemuMonitorEventCompare): New helper function.
(qemuMonitorJSONIOProcessEvent): Optimize event lookup.

13 years agoblockjob: add API for async virDomainBlockJobAbort
Adam Litke [Fri, 13 Jan 2012 20:51:23 +0000 (14:51 -0600)]
blockjob: add API for async virDomainBlockJobAbort

Block job cancellation can take a while.  Now that upstream qemu 1.1
has asynchronous block cancellation, we want to expose that to the user.
Therefore, the following updates are made to the virDomainBlockJob API:

A new block job event type VIR_DOMAIN_BLOCK_JOB_CANCELED is managed by
libvirt.  Regardless of the flags used with virDomainBlockJobAbort, this
event will be raised: 1. when using synchronous block_job_cancel (the
event will be synthesized by libvirt), and 2. whenever it is received
from qemu (via asynchronous block-job-cancel).  Note that the event
may be detected by libvirt even before the virDomainBlockJobAbort
completes (always true when it is synthesized, but also possible if
cancellation was fast).

A new extension flag VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC is added to the
virDomainBlockJobAbort API.  When enabled, this function will allow
(but not require) asynchronous operation (ie, it returns as soon as
possible, which might be before the job has actually been canceled).
When the API is used in this mode, it is the responsibility of the
caller to wait for a VIR_DOMAIN_BLOCK_JOB_CANCELED event or poll via
the virDomainGetBlockJobInfo API to check the cancellation status.

This patch also exposes the new flag through virsh, and makes virsh
slightly easier to use (--async implies --abort, and lack of any options
implies --info), although it leaves the qemu implementation for later
patches.

Signed-off-by: Adam Litke <agl@us.ibm.com>
Cc: Stefan Hajnoczi <stefanha@gmail.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agoblockjob: add qemu capabilities related to block pull jobs
Eric Blake [Wed, 11 Apr 2012 21:40:16 +0000 (15:40 -0600)]
blockjob: add qemu capabilities related to block pull jobs

RHEL 6.2 was released with an early version of block jobs, which only
worked on the qed file format, where the commands were spelled with
underscore (contrary to QMP style), and where 'block_job_cancel' was
synchronous and did not trigger an event.

The upcoming qemu 1.1 release has fixed these short-comings [1][2]:
the commands now work on multiple file types, are spelled with dash,
and 'block-job-cancel' is asynchronous and emits an event upon conclusion.

[1]qemu commit 370521a1d6f5537ea7271c119f3fbb7b0fa57063
[2]https://lists.gnu.org/archive/html/qemu-devel/2012-04/msg01248.html

This patch recognizes the new spellings, and fixes virDomainBlockRebase
to give a graceful error when talking to a too-old qemu on a partial
rebase attempt.  Fixes for the new semantics will come later.  This
patch also removes a bogus ATTRIBUTE_NONNULL mistakenly added in
commit 10ec36e2.

* src/qemu/qemu_capabilities.h (QEMU_CAPS_BLOCKJOB_SYNC)
(QEMU_CAPS_BLOCKJOB_ASYNC): New bits.
* src/qemu/qemu_capabilities.c (qemuCaps): Name them.
* src/qemu/qemu_monitor_json.c (qemuMonitorJSONCheckCommands): Set
them.
(qemuMonitorJSONBlockJob): Manage both command names.
(qemuMonitorJSONDiskSnapshot): Minor formatting fix.
* src/qemu/qemu_monitor.h (qemuMonitorBlockJob): Alter signature.
* src/qemu/qemu_monitor_json.h (qemuMonitorJSONBlockJob): Likewise.
* src/qemu/qemu_monitor.c (qemuMonitorBlockJob): Pass through
capability bit.
* src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Update callers.

13 years agoqemu: Fix deadlock when qemuDomainOpenConsole cleans up a connection
Peter Krempa [Tue, 10 Apr 2012 09:56:21 +0000 (11:56 +0200)]
qemu: Fix deadlock when qemuDomainOpenConsole cleans up a connection

The new safe console handling introduced a possibility to deadlock the
qemu driver when a new console connection forcibly disconnects a
previous console stream that belongs to an already closed connection.

The virStreamFree function calls subsequently a the virReleaseConnect
function that tries to lock the driver while discarding the connection,
but the driver was already locked in qemuDomainOpenConsole.

Backtrace of the deadlocked thread:
0  0x00007f66e5aa7f14 in __lll_lock_wait () from /lib64/libpthread.so.0
1  0x00007f66e5aa3411 in _L_lock_500 () from /lib64/libpthread.so.0
2  0x00007f66e5aa322a in pthread_mutex_lock () from/lib64/libpthread.so.0
3  0x0000000000462bbd in qemudClose ()
4  0x00007f66e6e178eb in virReleaseConnect () from/usr/lib64/libvirt.so.0
5  0x00007f66e6e19c8c in virUnrefStream () from /usr/lib64/libvirt.so.0
6  0x00007f66e6e3d1de in virStreamFree () from /usr/lib64/libvirt.so.0
7  0x00007f66e6e09a5d in virConsoleHashEntryFree () from/usr/lib64/libvirt.so.0
8  0x00007f66e6db7282 in virHashRemoveEntry () from/usr/lib64/libvirt.so.0
9  0x00007f66e6e09c4e in virConsoleOpen () from /usr/lib64/libvirt.so.0
10 0x00000000004526e9 in qemuDomainOpenConsole ()
11 0x00007f66e6e421f1 in virDomainOpenConsole () from/usr/lib64/libvirt.so.0
12 0x00000000004361e4 in remoteDispatchDomainOpenConsoleHelper ()
13 0x00007f66e6e80375 in virNetServerProgramDispatch () from/usr/lib64/libvirt.so.0
14 0x00007f66e6e7ae11 in virNetServerHandleJob () from/usr/lib64/libvirt.so.0
15 0x00007f66e6da897d in virThreadPoolWorker () from/usr/lib64/libvirt.so.0
16 0x00007f66e6da7ff6 in virThreadHelper () from/usr/lib64/libvirt.so.0
17 0x00007f66e5aa0c5c in start_thread () from /lib64/libpthread.so.0
18 0x00007f66e57e7fcd in clone () from /lib64/libc.so.6

* src/qemu/qemu_driver.c: qemuDomainOpenConsole()
        -- unlock the qemu driver right after acquiring the domain
        object

13 years agoqemu: Warn on possibly incorrect usage of EnterMonitor*
Jiri Denemark [Tue, 10 Apr 2012 14:39:33 +0000 (16:39 +0200)]
qemu: Warn on possibly incorrect usage of EnterMonitor*

qemuDomainObjEnterMonitor{,WithDriver} should not be called from async
jobs, only EnterMonitorAsync variant is allowed.

13 years agoqemu: Track job owner for better debugging
Jiri Denemark [Fri, 6 Apr 2012 16:55:46 +0000 (18:55 +0200)]
qemu: Track job owner for better debugging

In case an API fails with "cannot acquire state change lock", searching
for the API that possibly forgot to end its job is not always easy.
Let's keep track of the job owner and print it out for easier
identification.

13 years agoqemu: Avoid excessive calls to qemuDomainObjSaveJob()
Jiri Denemark [Fri, 6 Apr 2012 17:42:34 +0000 (19:42 +0200)]
qemu: Avoid excessive calls to qemuDomainObjSaveJob()

As reported by Daniel Berrangé, we have a huge performance regression
for virDomainGetInfo() due to the change which makes virDomainEndJob()
save the XML status file every time it is called. Previous to that
change, 2000 calls to virDomainGetInfo() took ~2.5 seconds. After that
change, 2000 calls to virDomainGetInfo() take 2 *minutes* 45 secs.

We made the change to be able to recover from libvirtd restart in the
middle of a job. However, only destroy and async jobs are taken care of.
Thus it makes more sense to only save domain state XML when these jobs
are started/stopped.

13 years agotests: Fix libvirtdconftest in VPATH build
Jiri Denemark [Tue, 10 Apr 2012 12:03:46 +0000 (14:03 +0200)]
tests: Fix libvirtdconftest in VPATH build

Without this, libvirtdconftest fails to build with "fatal error:
daemon/libvirtd-config.h: No such file or directory"

13 years agodaemon: Add libvirtd-config.c to the list of files to translate
Jiri Denemark [Tue, 10 Apr 2012 13:42:47 +0000 (15:42 +0200)]
daemon: Add libvirtd-config.c to the list of files to translate

13 years agobuild: avoid s390 compiler warnings
Eric Blake [Tue, 10 Apr 2012 15:46:01 +0000 (09:46 -0600)]
build: avoid s390 compiler warnings

I noticed these compiler warnings when building for the s390 architecture.

* src/node_device/node_device_udev.c (udevDeviceMonitorStartup):
Mark unused variable.
* src/nodeinfo.c (linuxNodeInfoCPUPopulate): Avoid unused variable.

13 years agoWire up <loader> to set the QEMU BIOS path
Daniel P. Berrange [Tue, 10 Apr 2012 14:02:13 +0000 (15:02 +0100)]
Wire up <loader> to set the QEMU BIOS path

* src/qemu/qemu_command.c: Wire up -bios with <loader>
* tests/qemuxml2argvdata/qemuxml2argv-bios.args,
  tests/qemuxml2argvdata/qemuxml2argv-bios.xml: Expand
  existing BIOS test case to cover <loader>

13 years agovirsh: Clean up usage of boolean flag variables
Peter Krempa [Tue, 10 Apr 2012 11:14:23 +0000 (13:14 +0200)]
virsh: Clean up usage of boolean flag variables

This patch cleans up variables used to store boolean command flags that
are inquired by vshCommandOptBool to use the bool data type instead of
an integer.

Additionally this patch cleans up flag variables that are inferred from
existing flags.

13 years agovirsh: Clarify use of the --managed-save flag for the list command
Peter Krempa [Tue, 10 Apr 2012 10:21:03 +0000 (12:21 +0200)]
virsh: Clarify use of the --managed-save flag for the list command

The documentation for the flag doesn't clearly state that the flag only
enhances the output and the user needs to specify other flags to list
inactive domains, that are enhanced by this flag.

13 years agoFix comment about GNUTLS initialization/cleanup
Daniel P. Berrange [Tue, 10 Apr 2012 11:15:46 +0000 (12:15 +0100)]
Fix comment about GNUTLS initialization/cleanup

13 years agoFix compilation error on 32bit
Stefan Berger [Tue, 10 Apr 2012 10:24:03 +0000 (06:24 -0400)]
Fix compilation error on 32bit

Below code failed to compile on a 32 bit machine with error

typewrappers.c: In function 'libvirt_intUnwrap':
typewrappers.c:135:5: error: logical 'and' of mutually exclusive tests is always false [-Werror=logical-op]
cc1: all warnings being treated as errors

The patch fixes this error.

13 years agoReplace daemon-conf test script with a proper test case
Daniel P. Berrange [Wed, 4 Apr 2012 14:01:46 +0000 (15:01 +0100)]
Replace daemon-conf test script with a proper test case

The daemon-conf test script continues to be very fragile to
changes in libvirt. It currently fails 1 time in 3/4 due
to race conditions in startup/shutdown of the test script.

Replace it with a proper test case tailored to the code
being tested

* tests/Makefile.am: Remove daemon-conf, add libvirtdconftest
* tests/daemon-conf: Delete obsolete test
* tests/libvirtdconftest.c: Test config file handling

13 years agoSwitch libvirtd config loading code to use error APIs
Daniel P. Berrange [Wed, 4 Apr 2012 14:00:17 +0000 (15:00 +0100)]
Switch libvirtd config loading code to use error APIs

Using VIR_ERROR means the test suite can't catch error messages
easily. Use the proper error reporting APIs instead

13 years agoAdd API for loading daemon config from in-memory blob
Daniel P. Berrange [Wed, 4 Apr 2012 12:14:19 +0000 (13:14 +0100)]
Add API for loading daemon config from in-memory blob

Rename existing daemonConfigLoad API to daemonConfigLoadFile and
add an alternative daemonConfigLoadData

* daemon/libvirtd-config.c, daemon/libvirtd-config.h: Add
  daemonConfigLoadData and rename daemonConfigLoad to
  daemonConfigLoadFile
* daemon/libvirtd.c: Update for renamed API

13 years agoSplit libvirtd config file loading out into separate files
Daniel P. Berrange [Wed, 4 Apr 2012 12:09:09 +0000 (13:09 +0100)]
Split libvirtd config file loading out into separate files

To enable creation of unit tests, split the libvirtd config file
loading code out into separate files.

* daemon/libvirtd.c: Delete config loading code / structs
* daemon/libvirtd-config.c, daemon/libvirtd-config.h: Config
  file loading APIs

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
13 years agoUML: fix iteration over consoles
MATSUDA, Daiki [Mon, 9 Apr 2012 03:40:52 +0000 (12:40 +0900)]
UML: fix iteration over consoles

I found typo in UML driver.

MATSUDA Daiki

13 years agosnapshot: fix memory leak on error
Eric Blake [Thu, 5 Apr 2012 19:15:03 +0000 (13:15 -0600)]
snapshot: fix memory leak on error

Leak introduced in commit 0436d32.  If we allocate an actions array,
but fail early enough to never consume it with the qemu monitor
transaction call, we leaked memory.

But our semantics of making the transaction command free the caller's
memory is awkward; avoiding the memory leak requires making every
intermediate function in the call chain check for error.  It is much
easier to fix things so that the function that allocates also frees,
while the call chain leaves the caller's data intact.  To do that,
I had to hack our JSON data structure to make it easy to protect a
portion of an arbitrary JSON tree from being freed.

* src/util/json.h (virJSONType): Name the enum.
(_virJSONValue): New field.
* src/util/json.c (virJSONValueFree): Use it to protect a portion
of an array.
* src/qemu/qemu_monitor_json.c (qemuMonitorJSONTransaction): Avoid
freeing caller's data.
* src/qemu/qemu_driver.c (qemuDomainSnapshotCreateDiskActive):
Free actions array on failure.

13 years agoqemu_ga: Don't overwrite errors on FSThaw
Michal Privoznik [Fri, 6 Apr 2012 10:33:48 +0000 (12:33 +0200)]
qemu_ga: Don't overwrite errors on FSThaw

We can tell qemuDomainSnapshotFSThaw if we want it to report errors or
not. However, if we don't want to and an error has been already set by
previous qemuReportError() we must keep copy of that error not just a
pointer to it. Otherwise, it get overwritten if FSThaw reports an error.

13 years agoxen config: No vfb in HVM guest configuration
Stefan Bader [Thu, 5 Apr 2012 16:44:35 +0000 (18:44 +0200)]
xen config: No vfb in HVM guest configuration

This causes an implicit vkbd device to be added which takes
6min to finally fail being initialized in the guest.

http://lists.xen.org/archives/html/xen-devel/2012-04/msg00409.html

Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
13 years agotests: avoid compiler warnings
Eric Blake [Fri, 6 Apr 2012 02:04:23 +0000 (20:04 -0600)]
tests: avoid compiler warnings

gcc 4.7 warns about uninitialized struct members

* tests/testutilsqemu.c (testQemuCapsInit): Populate new members.
* tests/viruritest.c (mymain): Likewise.

13 years agotest: fix build errors with gcc 4.7.0 and -O0
Laine Stump [Thu, 5 Apr 2012 20:31:36 +0000 (16:31 -0400)]
test: fix build errors with gcc 4.7.0 and -O0

When building on Fedora 17 (which uses gcc 4.7.0) with -O0 in CFLAGS,
three of the tests failed to compile.

cputest.c and qemuxml2argvtest.c had non-static structs defined
inside the macro that was being repeatedly invoked. Due to some so-far
unidentified change in gcc, the stack space used by variables defined
inside { } is not recovered/re-used when the block ends, so all these
structs have become additive (this is the same problem worked around
in commit cf57d345b). Fortunately, these two files could be fixed with
a single line addition of "static" to the struct definition in the
macro.

virnettlscontexttest.c was a bit different, though. The problem structs
in the do/while loop of macros had non-constant initializers, so it
took a bit more work and piecemeal initialization instead of member
initialization to get things to be happy.

In an ideal world, none of these changes should be necessary, but not
knowing how long it will be until the gcc regressions are fixed, and
since the code is just as correct after this patch as before, it makes
sense to fix libvirt's build for -O0 while also reporting the gcc
problem.

13 years agovirURIParse: don't forget to copy the user part
Guido Günther [Thu, 5 Apr 2012 15:52:42 +0000 (17:52 +0200)]
virURIParse: don't forget to copy the user part

This got dropped with 300e60e15b22387dda41ed5985a9ebadfd86dd25

Cheers,
 -- Guido

13 years agotest: fix segfault in networkxml2argvtest
Laine Stump [Thu, 5 Apr 2012 07:18:33 +0000 (03:18 -0400)]
test: fix segfault in networkxml2argvtest

This bug resolves https://bugzilla.redhat.com/show_bug.cgi?id=810100

rpm builds for i686 were failing with a segfault in
networkxml2argvtest. Running under valgrind showed that a region of
memory was being referenced after it had been freed (as the result of
realloc - see the valgrind report in the BZ).

The problem (in replaceTokens() - added in commit 22ec60, meaning this
bug was in 0.9.10 and 0.9.11) was that the pointers token_start and
token_end were being computed based on the value of *buf, then *buf
was being realloc'ed (potentially moving it), then token_start and
token_end were used without recomputing them to account for movement
of *buf.

The solution is to change the code so that token_start and token_end
are offsets into *buf rather than pointers. This way there is only a
single pointer to the buffer, and nothing needs readjusting after a
realloc. (You may note that some uses of token_start/token_end didn't
need to be changed to add in "*buf +" - that's because there ended up
being a +*buf and -*buf which canceled each other out).

DV gets the credit for finding this bug and pointing out the valgrind
report.

13 years agoconf: Plug memory leaks on virDomainDiskDefParseXML
Alex Jia [Thu, 5 Apr 2012 09:12:12 +0000 (17:12 +0800)]
conf: Plug memory leaks on virDomainDiskDefParseXML

Detected by valgrind. Leaks are introduced in commit b22eaa7.

* src/conf/domain_conf.c (virDomainDiskDefParseXML): fix memory leaks.

How to reproduce?

% make && make -C tests check TESTS=qemuxml2argvtest
% cd tests && valgrind -v --leak-check=full ./qemuxml2argvtest

actual result:

==2143== 12 bytes in 2 blocks are definitely lost in loss record 74 of 179
==2143==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==2143==    by 0x39D90A67DD: xmlStrndup (xmlstring.c:45)
==2143==    by 0x4F5EC0: virDomainDiskDefParseXML (domain_conf.c:3438)
==2143==    by 0x502F00: virDomainDefParseXML (domain_conf.c:8304)
==2143==    by 0x505FE3: virDomainDefParseNode (domain_conf.c:9080)
==2143==    by 0x5069AE: virDomainDefParse (domain_conf.c:9030)
==2143==    by 0x41CBF4: testCompareXMLToArgvHelper (qemuxml2argvtest.c:105)
==2143==    by 0x41E5DD: virtTestRun (testutils.c:145)
==2143==    by 0x416FA3: mymain (qemuxml2argvtest.c:399)
==2143==    by 0x41DCB7: virtTestMain (testutils.c:700)
==2143==    by 0x39CF01ECDC: (below main) (libc-start.c:226)

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agoopenvz: support vzctl 3.1
Ilja Livenson [Wed, 4 Apr 2012 20:30:43 +0000 (14:30 -0600)]
openvz: support vzctl 3.1

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

Basically, openvz dropped strict version numbering (3.1 vs 3.1.0),
which caused parsing to fail.

13 years agoDon't install sysctl file on non-Linux hosts
Daniel P. Berrange [Wed, 4 Apr 2012 10:16:34 +0000 (11:16 +0100)]
Don't install sysctl file on non-Linux hosts

* configure.ac: Set WITH_SYSCTL only on Linux hosts
* daemon/Makefile.am: Conditionalize install-sysctl using WITH_SYSCTL

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Cc: Jason Helfman <jhelfman@e-e.com>
13 years agoFix parallel build in docs/ directory
Daniel P. Berrange [Wed, 4 Apr 2012 11:26:04 +0000 (12:26 +0100)]
Fix parallel build in docs/ directory

Every now & then, with parallel builds, we get a failure to
validate hvsupport.html.in.  I eventually noticed that this
is because we get 2 instances of the generator running at
once.

We already list hvsupport.html.in in BUILT_SOURCES but this
was not working. It turns out the flaw is that we were
adding deps to the 'all:' target instead of the 'all-am:'
target. BUILT_SOURCES is a dep of 'all', so any custom
targets written in Makefile.am must use 'all-am:' so that
they don't get run until BUILT_SOURCES are completely
generated

* docs/Makefile.am: s/all/all-am/

13 years agoPull in GNULIB regex module for benefit of test suite on Win32
Daniel P. Berrange [Wed, 4 Apr 2012 10:56:04 +0000 (11:56 +0100)]
Pull in GNULIB regex module for benefit of test suite on Win32

13 years agoAdd linuxNodeInfoCPUPopulate to src/libvirt_linux.syms
Daniel P. Berrange [Wed, 4 Apr 2012 10:54:27 +0000 (11:54 +0100)]
Add linuxNodeInfoCPUPopulate to src/libvirt_linux.syms

This symbol is used in the test suites

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
13 years agoFix format specifiers in test cases on Win32
Daniel P. Berrange [Thu, 29 Mar 2012 09:41:37 +0000 (10:41 +0100)]
Fix format specifiers in test cases on Win32

Some of the test suites use fprintf with format specifiers
that are not supported on Win32 and are not fixed by gnulib.

The mingw32 compiler also has trouble detecting ssize_t
correctly, complaining that 'ssize_t' does not match
'signed size_t' (which it expects for %zd). Force the
cast to size_t to avoid this problem

* tests/testutils.c, tests/testutils.h: Fix printf
  annotation on virTestResult. Use virVasprintf
  instead of vfprintf
* tests/virhashtest.c: Use VIR_WARN instead of fprintf(stderr).
  Cast to size_t to avoid mingw32 compiler bug

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
13 years agoqemu: Build activeUsbHostdevs list on process reconnect
Michal Privoznik [Mon, 26 Mar 2012 14:44:19 +0000 (16:44 +0200)]
qemu: Build activeUsbHostdevs list on process reconnect

If the daemon is restarted it will lose list of active
USB devices assigned to active domains. Therefore we need
to rebuild this list on qemuProcessReconnect().

13 years agoqemu: Delete USB devices used by domain on stop
Michal Privoznik [Mon, 26 Mar 2012 14:40:01 +0000 (16:40 +0200)]
qemu: Delete USB devices used by domain on stop

To prevent assigning one USB device to two domains,
we keep a list of assigned USB devices. On domain
startup - qemuProcessStart() - we insert devices
used by domain into the list but remove them only
on detach-device. Devices are, however, released
on qemuProcessStop() as well.

13 years agoqemu: Don't leak temporary list of USB devices
Michal Privoznik [Mon, 26 Mar 2012 14:33:58 +0000 (16:33 +0200)]
qemu: Don't leak temporary list of USB devices

and add debug message when adding USB device
to the list of active devices.

13 years agoFix initial hypervisor conditionals
Daniel P. Berrange [Tue, 3 Apr 2012 11:05:32 +0000 (12:05 +0100)]
Fix initial hypervisor conditionals

The openvz, virtualbox and vmware drivers do not run inside
libvirtd, therefore they should be grouped with the other
client side drivers

13 years agoRemove bogus xen-devel dep from libvirt-devel RPM
Daniel P. Berrange [Tue, 3 Apr 2012 11:02:49 +0000 (12:02 +0100)]
Remove bogus xen-devel dep from libvirt-devel RPM

The public libvirt API does not have any application visible
dependency on Xen libraries. The xen-devel dependency is thus
bogus

13 years agoIntroduce per-hypervisor virtual RPMs
Daniel P. Berrange [Tue, 3 Apr 2012 10:54:27 +0000 (11:54 +0100)]
Introduce per-hypervisor virtual RPMs

Introduce a set sub-RPMs, one per hypervisor, which can be used
as dependency targets by applications wishing to pull in the
full stack of packages required for a specific hypervisor. This
avoids the application needing to know what the hypervisor specific
package set is.

ie, applications should not need to know that using the libvirt
Xen hypervisor requires the 'xen' RPM - libvirt should take care
of that knowledge. All the application wants is 'libvirt-daemon-xen'

There are 5 sub-RPMs:

  libvirt-daemon-qemu - non-native TCG based emulators
  libvirt-daemon-kvm  - native KVM hypervisor
  libvirt-daemon-uml  - User Mode linux
  libvirt-daemon-xen  - Xen, either via XenD or libxl
  libvirt-daemon-lxc  - Linux native containers

When driver modules get turned on, these sub-RPMs will also
gain dependencies on the appropriate driver module .so files

13 years agoSplit config files & daemon off from main daemon RPM
Daniel P. Berrange [Tue, 3 Apr 2012 10:44:59 +0000 (11:44 +0100)]
Split config files & daemon off from main daemon RPM

Take the libvirt RPM and split it into three pieces

 - libvirt-daemon - libvirtd & other mandatory bits for its operation
 - libvirt-daemon-config-network - the virbr0 config definition
 - libvirt-daemon-config-nwfilter - the firewall config rules

For backwards compatibility with existing installs / application RPM
deps, the 'libvirt' RPM is retained, but will have a dependency on
the 3 new RPMs.

13 years agoRemove API XML files from libvirt RPM
Daniel P. Berrange [Tue, 3 Apr 2012 10:24:42 +0000 (11:24 +0100)]
Remove API XML files from libvirt RPM

The API XML files are now formally installed as part of the
libvirt-devel RPM. Thus there is no need to include them as
%doc in the main libvirt RPM