]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
11 years agospec: move driver-specific files to driver subpackages
Jim Fehlig [Thu, 5 Dec 2013 23:15:55 +0000 (16:15 -0700)]
spec: move driver-specific files to driver subpackages

The libvirt-daemon package contains several driver-specific files,
directories, and script, which can be problematic when building the
package with multiple hypervisor support, e.g. both QEMU and Xen.

E.g. installing a QEMU+Xen enabled libvirt-daemon on a Xen-only system
will result in the creation of qemu and kvm groups and a qemu user.

Move the driver-specific files, directories, and script to the
respective driver subpackages.

11 years agospec: Define hypervisor-specific files together
Jim Fehlig [Thu, 5 Dec 2013 22:18:57 +0000 (15:18 -0700)]
spec: Define hypervisor-specific files together

Collapse the various {with_<hypervisor>} conditionals in the
libvirt-daemon package files section into a single {with_<hypervisor>}
conditional

11 years agospec: Conditionally specify some hypervisor-specific files
Jim Fehlig [Thu, 5 Dec 2013 22:08:24 +0000 (15:08 -0700)]
spec: Conditionally specify some hypervisor-specific files

Move some hypervisor-specific files in the libvirt-daemon subpackage
within conditionals for those hypervisors.

11 years agospec: Fix files list when building without driver modules
Jim Fehlig [Thu, 5 Dec 2013 21:56:06 +0000 (14:56 -0700)]
spec: Fix files list when building without driver modules

The daemon-config-{network,nwfilter} subpackages are built regardless
of whether or not with_driver_modules is defined, therefore don't
conditionally define their files list.

11 years agospec: Only add libvirt-daemon pre install script if building with qemu
Jim Fehlig [Thu, 5 Dec 2013 21:49:48 +0000 (14:49 -0700)]
spec: Only add libvirt-daemon pre install script if building with qemu

The %pre script in libvirt-daemon is specific to qemu, so only include
it if building with qemu support.

11 years agospec: Fix unconditional references of nwfilter
Jim Fehlig [Thu, 5 Dec 2013 21:43:28 +0000 (14:43 -0700)]
spec: Fix unconditional references of nwfilter

Ensure nwfilter files lists and dependencies are conditional upon
with_nwfilter being defined.

11 years agolxcContainerMountFSDevPTS: Unify @ret usage pattern
Chen Hanxiao [Fri, 6 Dec 2013 06:20:21 +0000 (14:20 +0800)]
lxcContainerMountFSDevPTS: Unify @ret usage pattern

Currently, if virFileMakePath() fails, the @ret is left initialized from
virAsprintf() just a few lines above leading to a wrong return value of
zero whereas -1 should be returned.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoCgroup: Replace 'newpath' with 'newPath'
Zhou Yimin [Fri, 6 Dec 2013 03:38:14 +0000 (11:38 +0800)]
Cgroup: Replace 'newpath' with 'newPath'

Unifying codding style, replace 'newpath' with 'newPath'.

From: Zhou Yimin <zhouyimin@huawei.com>

11 years agoAdd qxl ram size to ABI stability check
Ján Tomko [Wed, 4 Dec 2013 12:11:39 +0000 (13:11 +0100)]
Add qxl ram size to ABI stability check

55bfd02 added a 'ram' attribute for qxl video devices
but didn't update the ABI check.

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

11 years agoqemu: Improve error when setting invalid count of vcpus via agent
Peter Krempa [Thu, 5 Dec 2013 16:47:14 +0000 (17:47 +0100)]
qemu: Improve error when setting invalid count of vcpus via agent

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

When attempting to enable more vCPUs in the guest than is currently
enabled in the guest but less than the maximum count for the VM we
currently reported an unhelpful message:

 error: internal error: guest agent reports less cpu than requested

This patch changes it to:

 error: invalid argument: requested vcpu count is greater than the count
 of enabled vcpus in the domain: 3 > 2

11 years agoconf: Fix XML formatting of RNG device info
Peter Krempa [Thu, 5 Dec 2013 17:33:01 +0000 (18:33 +0100)]
conf: Fix XML formatting of RNG device info

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

When outputting the XML for the RNG device, the code didn't format the
PCI address info. Additionally the schema wasn't expecting the info
although it was being parsed and used internally. Fix those mistakes and
add test for the PCI info section.

11 years agoqemu: snapshot: Fix incorrect disk type for auto-generated disks
Peter Krempa [Thu, 5 Dec 2013 14:58:31 +0000 (15:58 +0100)]
qemu: snapshot: Fix incorrect disk type for auto-generated disks

When changing the parsing and formatting functions in commit
43f2ccdc73090bd03f64de4d58d46ffa0134d705 I forgot to update the qemu
disk alignment function for snapshots that automatically adds snapshot
configs for disks that were not mentioned in the XML. The function
allocated a new disk snapshot definition but did not correctly
initialize the snapshot disk source type variable. This resulted into
the disks considered as block devices and invalid XML was generated.

Reported by John Ferlan.

11 years agoqemu: hotplug: Mark 2 private functions as static
Cole Robinson [Thu, 5 Dec 2013 18:09:04 +0000 (13:09 -0500)]
qemu: hotplug: Mark 2 private functions as static

They aren't used outside of qemu_hotplug.c

11 years agodocs: fix double articles bug
Wang Yufei [Mon, 25 Nov 2013 11:41:27 +0000 (11:41 +0000)]
docs: fix double articles bug

Delete the extra article 'the'.

Signed-off-by: Wang Yufei <james.wangyufei@huawei.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agovirThreadPoolFree: Set n(Prio)Workers after the pool is locked
Michal Privoznik [Thu, 5 Dec 2013 13:39:52 +0000 (14:39 +0100)]
virThreadPoolFree: Set n(Prio)Workers after the pool is locked

In 78839da I am trying to join the worker threads. However, I can't
sipmly reuse pool->nWorkers (same applies for pool->nPrioWorkers),
because of the following flow that is currently implemented:

1) the main thread executing virThreadPoolFree sets pool->quit = true,
wakes up all the workers and wait on pool->quit_cond.

2) A worker is woken up and see quit request. It immediately jumps of
the while() loop and decrements pool->nWorkers (or pool->nPrioWorkers in
case of priority worker). The last thread signalizes pool->quit_cond.

3) Main thread is woken up, with both pool->nWorkers and
pool->nPrioWorkers being zero.

So there's a need to copy the original value of worker thread counts
into local variables. However, these need to set *after* the check for
pool being NULL (dereferencing a NULL is no no). And for safety they can
be set right after the pool is locked.

Reported-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoqemu: Fix indentation in qemuTranslateDiskSourcePool
Peter Krempa [Thu, 5 Dec 2013 10:09:03 +0000 (11:09 +0100)]
qemu: Fix indentation in qemuTranslateDiskSourcePool

Commit e1a4d08baf9a8cc86c8b5ca27da9aeedb34b5908 was pushed with bad
indentation the iSCSI pool translation code.

11 years agodomainsnapshotxml2xmltest: Add test case for empty driver element
Peter Krempa [Tue, 3 Dec 2013 11:04:43 +0000 (12:04 +0100)]
domainsnapshotxml2xmltest: Add test case for empty driver element

Commit 5a66c667ff5cae61c2ad2e646c8eb3eedc67f925 fixed a NULL dereference
if the disk driver element was empty. Add a test for this case.

11 years agodomainsnapshotxml2xmltest: Add existing files as new tests
Peter Krempa [Wed, 4 Dec 2013 17:31:39 +0000 (18:31 +0100)]
domainsnapshotxml2xmltest: Add existing files as new tests

There were plenty snapshot XMLs in the tests/domainsnapshotxml2xmlin
directory that actually weren't used in XML testing. The upgraded
domainsnapshotxml2xml test now allows us to use them.

11 years agodomainsnapshotxml2xml: Move files with conflicting names
Peter Krempa [Wed, 4 Dec 2013 17:25:56 +0000 (18:25 +0100)]
domainsnapshotxml2xml: Move files with conflicting names

The new tests that will be added later would collide with files of
existing tests. Move and rename those files.

11 years agodomainsnapshotxml2xmltest: Allow for better testing of snapshots
Peter Krempa [Wed, 4 Dec 2013 13:53:24 +0000 (14:53 +0100)]
domainsnapshotxml2xmltest: Allow for better testing of snapshots

Until now the test was only testing redefinition of snapshot XMLs stored
in tests/domainsnapshotxml2xmlout. This patch adds new infrastructure to
allow testing of files that may differ and will allow to utilize files
in tests/domainsnapshotxml2xmlin as new tests too.

11 years agodomainsnapshotxml2xmltest: Clean up labels and use bool instead of int
Peter Krempa [Wed, 4 Dec 2013 12:49:40 +0000 (13:49 +0100)]
domainsnapshotxml2xmltest: Clean up labels and use bool instead of int

The 'internal' variable holds only two states; convert it to a boolean
and the 'fail' label should be called 'cleanup'. This patch also fixes a
minor memory leak of driver capabilities in case the XML config object
can't be allocated.

11 years agoconfigure: Resolve compile issue in configure.ac
Adam Walters [Thu, 5 Dec 2013 04:09:14 +0000 (23:09 -0500)]
configure: Resolve compile issue in configure.ac

This patch resolves a compile issue caused by the
removal of examples/domsuspend code in commit
5eb4b04211ea379c58f735dee6c2852c8b80da89. This issue
is only seen in a fresh checkout, but causes the build
and configure to fail.

11 years agoqemuAgentDispose: Reset lastError
Wangyufei (James) [Tue, 3 Dec 2013 02:59:00 +0000 (02:59 +0000)]
qemuAgentDispose: Reset lastError

When an error occurred in qemuAgentIO, it will be saved in mon->lastError,
but it will not be freed at the end.  Present since commit c160ce33;
and compare to commit 9cc8a5af fixing the same problem in qemu_monitor.c.

==22219== 54 bytes in 1 blocks are definitely lost in loss record 982 of 1,379
==22219==    at 0x4C26B9B: malloc (vg_replace_malloc.c:263)
==22219==    by 0x8520521: strdup (in /lib64/libc-2.11.3.so)
==22219==    by 0x52E99CB: virStrdup (virstring.c:554)
==22219==    by 0x52B44C4: virCopyError (virerror.c:195)
==22219==    by 0x52B5123: virCopyLastError (virerror.c:312)
==22219==    by 0x10905877: qemuAgentIO (qemu_agent.c:660)
==22219==    by 0x52B6122: virEventPollDispatchHandles (vireventpoll.c:501)
==22219==    by 0x52B7AEA: virEventPollRunOnce (vireventpoll.c:647)
==22219==    by 0x52B5C1B: virEventRunDefaultImpl (virevent.c:274)
==22219==    by 0x54181FD: virNetServerRun (virnetserver.c:1112)
==22219==    by 0x11EF4D: main (libvirtd.c:1513)

Signed-off-by: Zhou Yimin <zhouyimin@huawei.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoFix memory leak in qemuBuildDriveStr()
Nehal J Wani [Wed, 4 Dec 2013 21:15:03 +0000 (02:45 +0530)]
Fix memory leak in qemuBuildDriveStr()

This patch fixes memory leaks reported by valgrind on running
qemuxml2argvtest; introduced in commit 0df53f04.

Most of them are of the form:

==24777== 15 bytes in 1 blocks are definitely lost in loss record 39 of 129
==24777==    at 0x4A0887C: malloc (vg_replace_malloc.c:270)
==24777==    by 0x341F485E21: strdup (strdup.c:42)
==24777==    by 0x4CADE5F: virStrdup (virstring.c:554)
==24777==    by 0x4362B6: qemuBuildDriveStr (qemu_command.c:3848)
==24777==    by 0x43EF73: qemuBuildCommandLine (qemu_command.c:8500)
==24777==    by 0x426670: testCompareXMLToArgvHelper (qemuxml2argvtest.c:350)
==24777==    by 0x427C01: virtTestRun (testutils.c:138)
==24777==    by 0x41DDB5: mymain (qemuxml2argvtest.c:658)
==24777==    by 0x4282A2: virtTestMain (testutils.c:593)
==24777==    by 0x341F421A04: (below main) (libc-start.c:225)
==24777==

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agomaint: Kill usage of atoi()
Peter Krempa [Thu, 14 Nov 2013 16:14:26 +0000 (17:14 +0100)]
maint: Kill usage of atoi()

Kill the use of atoi() and introduce syntax check to forbid it and it's
friends (atol, atoll, atof, atoq).

Also fix a typo in variable name holding the cylinders count of a disk
pool (apparently unused).

examples/domsuspend/suspend.c will need a larger scale refactor as the
whole example file is broken thus it will be exempted from the syntax
check for now.

11 years agoexamples: Remove broken bad example
Peter Krempa [Wed, 4 Dec 2013 09:43:43 +0000 (10:43 +0100)]
examples: Remove broken bad example

The domsuspend example code is a really old and bad exmample of (how not
to use) the libvirt API. Remove it as it's apparent that nobody tried to
use it. It was broken and nobody complained.

11 years agoDon't overwrite errors from virConfReadFile
Daniel P. Berrange [Wed, 4 Dec 2013 15:23:11 +0000 (15:23 +0000)]
Don't overwrite errors from virConfReadFile

The SELinux security driver would overwrite errors from the
virConfReadFile function.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agovirThreadPoolFree: Join worker threads
Michal Privoznik [Wed, 13 Nov 2013 13:40:12 +0000 (14:40 +0100)]
virThreadPoolFree: Join worker threads

Even though currently we are freeing the pool of worker threads at the
daemon very end, nothing holds us back in joining the worker threads.
Moreover, we avoid leaks like this:

==26697== 1,680 bytes in 5 blocks are possibly lost in loss record 913 of 942
==26697==    at 0x4C2BDE4: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==26697==    by 0x4011131: allocate_dtv (in /lib64/ld-2.16.so)
==26697==    by 0x401176D: _dl_allocate_tls (in /lib64/ld-2.16.so)
==26697==    by 0x8499602: pthread_create@@GLIBC_2.2.5 (in /lib64/libpthread-2.16.so)
==26697==    by 0x52F53E9: virThreadCreate (virthreadpthread.c:188)
==26697==    by 0x52F5D4F: virThreadPoolNew (virthreadpool.c:221)
==26697==    by 0x53F30DB: virNetServerNew (virnetserver.c:377)
==26697==    by 0x11C6ED: main (libvirtd.c:1366)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoqemu: fix live pinning to memory node on NUMA system
Shivaprasad G Bhat [Tue, 3 Dec 2013 11:30:26 +0000 (06:30 -0500)]
qemu: fix live pinning to memory node on NUMA system

Ever since the subcpusets(vcpu,emulator) were introduced, the parent
cpuset cannot be modified to remove the nodes that are in use by the
subcpusets.
The fix is to break the memory node modification into three steps:
 1. assign new nodes into the parent,
 2. change the nodes in the child nodes,
 3. remove the old nodes on the parent node.

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

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agostorage_driver: Resolve Coverity CHECKED_RETURN warning
John Ferlan [Mon, 2 Dec 2013 20:31:42 +0000 (15:31 -0500)]
storage_driver: Resolve Coverity CHECKED_RETURN warning

The storageRegister() didn't check the return from the
virRegisterStorageDriver() like other callers did, so Coverity
flagged it.  Just check the return and handle.

11 years agobridge_driver: Resolve Coverity CHECKED_RETURN warning
John Ferlan [Mon, 2 Dec 2013 20:29:41 +0000 (15:29 -0500)]
bridge_driver: Resolve Coverity CHECKED_RETURN warning

The networkRegister() didn't check the return status of the
virRegisterNetworkDriver() call like other callers, so just
check and handle here as well.

11 years agovirnetserverclient: Fix conditional change HAVE_SASL to WITH_SASL
John Ferlan [Mon, 2 Dec 2013 19:49:34 +0000 (14:49 -0500)]
virnetserverclient: Fix conditional change HAVE_SASL to WITH_SASL

11 years agovirnetserverclient: Remove Coverity DEADCODE warning
John Ferlan [Mon, 2 Dec 2013 19:47:09 +0000 (14:47 -0500)]
virnetserverclient: Remove Coverity DEADCODE warning

The x509dname is only set inside a WITH_GNUTLS conditional, so
when used/check later on for NULL, Coverity detects this is not
possible.  Added WITH_GNUTLS around uses to remove message

11 years agonwfilter: Remove Coverity DEADCODE warning
John Ferlan [Mon, 2 Dec 2013 19:36:51 +0000 (14:36 -0500)]
nwfilter: Remove Coverity DEADCODE warning

The nwfilterStateInitialize() would only assign sysbus inside
a WITH_DBUS conditional, thus leaving a subsequent check for sysbus
and nwfilterDriverInstallDBusMatches() as a no-op

Rather than try to add WITH_DBUS conditions which ended up conflicting
with the usage of HAVE_FIREWALLD conditionals, just remove the WITH_DBUS
since virdbus.c has entry points for with and without conditions.

11 years agosrc: Align make output
Michal Privoznik [Tue, 3 Dec 2013 17:55:35 +0000 (18:55 +0100)]
src: Align make output

The make inserts six spaces instead of four:

  GEN      access/viraccessapichecklxc.h
  GEN    hyperv/hyperv_wmi.generated.h
  GEN      access/viraccessapichecklxc.c
  GEN    hyperv/hyperv_wmi.generated.c
  GEN    hyperv/hyperv_wmi_classes.generated.typedef
  GEN    hyperv/hyperv_wmi_classes.generated.h
  GEN    hyperv/hyperv_wmi_classes.generated.c
  GEN      libvirt_access_qemu.xml
  GEN      libvirt_access.syms
  GEN      libvirt_access_lxc.xml
  GEN      libvirt_access_qemu.syms
  GEN      libvirt_access_lxc.syms
  GEN      libvirt_qemu.def
  GEN    esx/esx_vi_types.generated.typedef
  GEN    esx/esx_vi_types.generated.typeenum
  GEN    esx/esx_vi_types.generated.typetostring
  GEN    esx/esx_vi_types.generated.typefromstring
  GEN    esx/esx_vi_types.generated.h
  GEN    esx/esx_vi_types.generated.c
  GEN    esx/esx_vi_methods.generated.h
  GEN    esx/esx_vi_methods.generated.c
  GEN    esx/esx_vi_methods.generated.macro
  GEN    esx/esx_vi.generated.h
  GEN    esx/esx_vi.generated.c
  GEN      libvirt_lxc.def

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoqemu: report error on attempt to live change virtio-net queues
Laine Stump [Tue, 3 Dec 2013 10:40:38 +0000 (12:40 +0200)]
qemu: report error on attempt to live change virtio-net queues

This resolves:

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

The BZ asked for the capability to change the number of queues used by
a virtio-net device while the device is in use. Because the number of
queues can only be set at the time the device is created, that isn't
possible. However, libvirt also shouldn't be silently reporting
success when someone tries to change the number of queues. So this
patch flags that as an error (just as attempts to change any of the
other virtio-specific parameters already do).

11 years agodaemon: Run virStateCleanup conditionally
Michal Privoznik [Tue, 3 Dec 2013 10:27:22 +0000 (11:27 +0100)]
daemon: Run virStateCleanup conditionally

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

Currently, initialization of drivers is done in a separate thread. This
is done for several reasons: a driver that is initialized may require
running event loop, it may take ages to initialize driver (e.g. due to
autostarting domains). While the thread is spawn and run, the main()
continues its execution. However, if something goes bad, or the event
loop is just exited (e.g. due to a --timeout or SIGINT) we try to
cleanup all the drivers. So we have two threads running Initialize() and
Cleanup() concurrently. This may result in accessing stale pointers -
e.g. netcf driver will free() itself in stateCleanup callback, while the
init thread may come, open a dummy connection in order to autostart some
domains and voilà: do_open() iterates over interface drivers and
accesses stale netcf driver.

The fix consists in not running stateCleanup if the init thread is still
running.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agotests: add forgotten boot-strict test files
Laine Stump [Tue, 3 Dec 2013 10:58:50 +0000 (12:58 +0200)]
tests: add forgotten boot-strict test files

These *should* have been pushed in commit
96fddee322c7d39a57cfdc5e7be71326d597d30a.

11 years agoqemu: add "-boot strict" to commandline whenever possible
Laine Stump [Mon, 2 Dec 2013 12:07:12 +0000 (14:07 +0200)]
qemu: add "-boot strict" to commandline whenever possible

This resolves:

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

(which was already closed as CANTFIX because the qemu "-boot strict"
commandline option wasn't available at the time).

Problem: you couldn't have a domain that used PXE to boot, but also
had an un-bootable disk device *even if that disk wasn't listed in the
boot order*, because if PXE timed out (e.g. due to the bridge
forwarding delay), the BIOS would move on to the next target, which
would be the unbootable disk device (again - even though it wasn't
given a boot order), and get stuck at a "BOOT DISK FAILURE, PRESS ANY
KEY" message until a user intervened.

The solution available since sometime around QEMU 1.5, is to add
"-boot strict=on" to *every* qemu command. When this is done, if any
devices have a boot order specified, then QEMU will *only* attempt to
boot from those devices that have an explicit boot order, ignoring the
rest.

11 years agoqemu: default to vfio for nodedev-detach
Laine Stump [Fri, 29 Nov 2013 11:19:26 +0000 (13:19 +0200)]
qemu: default to vfio for nodedev-detach

This patch resolves:

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

Commit f094aaac48a6 changed the PCI device assignment in qemu domains
to default to using VFIO rather than legacy KVM device assignment
(when VFIO is available). It didn't change which driver was used by
default for virNodeDeviceDetachFlags(), though, so that API (and the
virsh nodedev-detach command) was still binding to the pci-stub
driver, used by legacy KVM assignment, by default.

This patch publicizes (only within the qemu module, though, so no
additions to the symbol exports are needed) the functions that check
for presence of KVM and VFIO device assignment, then uses those
functions to decide what to do when no driver is specified for
virNodeDeviceDetachFlags(); if the vfio driver is loaded, the device
will be bound to vfio-pci, or if legacy KVM assignment is supported on
this system, the device will be bound to pci-stub; if neither method
is available, the detach will fail.

11 years agoqemu: snapshots: Declare supported and unsupported snapshot configs
Peter Krempa [Mon, 25 Nov 2013 16:51:04 +0000 (17:51 +0100)]
qemu: snapshots: Declare supported and unsupported snapshot configs

Currently the snapshot code did not check if it actually supports
snapshots on various disk backends for domains. To avoid future problems
add checkers that whitelist the supported configurations.

11 years agoqemu: Clear old translated pool source
Peter Krempa [Mon, 25 Nov 2013 15:12:54 +0000 (16:12 +0100)]
qemu: Clear old translated pool source

Clear the old data to avoid leaking it when attempting to re-translate a
pool on the same domain object.

11 years agoqemu: Refactor disk source string formatting
Peter Krempa [Thu, 21 Nov 2013 17:43:59 +0000 (18:43 +0100)]
qemu: Refactor disk source string formatting

This patch adds function qemuGetDriveSourceString to produce
qemu-compatible disk source strings that will enable to reuse the code
and refactors building of the qemu commandline of disks to use this new
helper.

11 years agoqemu: Unify formatting of RBD sources
Peter Krempa [Mon, 18 Nov 2013 19:03:12 +0000 (20:03 +0100)]
qemu: Unify formatting of RBD sources

11 years agoqemu: Split out NBD command generation
Peter Krempa [Mon, 18 Nov 2013 17:02:30 +0000 (18:02 +0100)]
qemu: Split out NBD command generation

11 years agoqemu: Migrate sheepdog source generation into common function
Peter Krempa [Mon, 18 Nov 2013 16:34:49 +0000 (17:34 +0100)]
qemu: Migrate sheepdog source generation into common function

11 years agoqemu: Use qemuBuildNetworkDriveURI to handle http/ftp and friends
Peter Krempa [Mon, 18 Nov 2013 16:12:59 +0000 (17:12 +0100)]
qemu: Use qemuBuildNetworkDriveURI to handle http/ftp and friends

Prepare the function to integrate other protocols and start folding
other network protocols into a common place.

11 years agoqemu: Simplify call pattern of qemuBuildDriveURIString
Peter Krempa [Mon, 18 Nov 2013 14:25:03 +0000 (15:25 +0100)]
qemu: Simplify call pattern of qemuBuildDriveURIString

Automatically assign secret type from the disk source definition and
pull in adding of the comma. Then update callers to keep generated
output the same.

11 years agoqemu: Split out formatting of network disk source URI
Peter Krempa [Fri, 15 Nov 2013 15:29:35 +0000 (16:29 +0100)]
qemu: Split out formatting of network disk source URI

The snapshot code will need to use qemu-style formatted URIs of network
disks. Split out the code to avoid duplication.

11 years agoqemu: Refactor qemuTranslateDiskSourcePool
Peter Krempa [Wed, 20 Nov 2013 09:37:31 +0000 (10:37 +0100)]
qemu: Refactor qemuTranslateDiskSourcePool

Before this patch, the translation function still needs a second ugly
helper function to actually format the command line for qemu. But if we
do the right stuff in the translation function, we don't have to bother
with the second function any more.

This patch removes the messy qemuBuildVolumeString function and changes
qemuTranslateDiskSourcePool to set stuff up correctly so that the
regular code paths meant for volumes can be used to format the command
line correctly.

For this purpose a new helper "qemuDiskGetActualType()" is introduced to
return the type of the volume in a pool.

As a part of the refactor the qemuTranslateDiskSourcePool function is
fixed to do decisions based on the pool type instead of the volume type.
This allows to separate pool-type-specific stuff more clearly and will
ease addition of other pool types that will require certain other
operations to get the correct pool source.

The previously fixed tests should make sure that we don't break stuff
that was working before.

11 years agoDoc: Explicitly declaring that nodedev-destroy only works for vHBA
Osier Yang [Fri, 22 Nov 2013 12:55:25 +0000 (20:55 +0800)]
Doc: Explicitly declaring that nodedev-destroy only works for vHBA

Though trying to destroy a physical HBA doesn't make sense at all,
it's still a bit misleading with saying "only works for HBA".

Signed-off-by: Osier Yang <jyang@redhat.com>
11 years agovirsh: improve grammar in error message
Eric Blake [Mon, 2 Dec 2013 21:40:15 +0000 (14:40 -0700)]
virsh: improve grammar in error message

Based on a suggestion from Mauricio Tavares.

* tools/virsh-domain.c (cmdDetachInterface, vshFindDisk): Improve
wording.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agodocs: fix some typos
Eric Blake [Mon, 2 Dec 2013 18:59:18 +0000 (11:59 -0700)]
docs: fix some typos

* docs/auditlog.html.in: Spelling fixes.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agodocs: fix typo in previous patch
Eric Blake [Mon, 2 Dec 2013 18:25:41 +0000 (11:25 -0700)]
docs: fix typo in previous patch

Avoid a nested comment compilation error, caused by me editing
Chen's patch.

* include/libvirt/libvirt.h.in: Fix typo.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoEnsure to zero out the virDomainBlockJobInfo arg
Daniel P. Berrange [Mon, 2 Dec 2013 16:56:16 +0000 (16:56 +0000)]
Ensure to zero out the virDomainBlockJobInfo arg

The virDomainGetBlockJobInfo method did not zero out the
virDomainBlockJobInfo pointer arg, so when block jobs were
not active it would return garbage for the bandwidth/cur/end
fields.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agodocs: fix typos in libvirt.h.in
Chen Hanxiao [Thu, 28 Nov 2013 12:01:55 +0000 (20:01 +0800)]
docs: fix typos in libvirt.h.in

s/causes/cause/

Each event callback has a single detail parameter, and can
thus only report a single cause.  Also, make all the sub-event
documentation use similar wording.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoqemu: snapshot: Add functions similar to disk source pool translation
Peter Krempa [Mon, 25 Nov 2013 16:26:02 +0000 (17:26 +0100)]
qemu: snapshot: Add functions similar to disk source pool translation

To avoid future pain, add placeholder functions to get the actual
snapshot disk type.

11 years agoqemu: snapshot: Touch up error message
Peter Krempa [Mon, 25 Nov 2013 18:16:16 +0000 (19:16 +0100)]
qemu: snapshot: Touch up error message

11 years agoconf: Add helper do clear disk source authentication struct
Peter Krempa [Mon, 25 Nov 2013 14:53:46 +0000 (15:53 +0100)]
conf: Add helper do clear disk source authentication struct

Add virDomainDiskAuthClear to help cleaning out the struct in other
places too.

11 years agoqemu: snapshot: Detect internal snapshots also for sheepdog and RBD
Peter Krempa [Mon, 25 Nov 2013 13:51:25 +0000 (14:51 +0100)]
qemu: snapshot: Detect internal snapshots also for sheepdog and RBD

When doing an internal snapshot on a VM with sheepdog or RBD disks we
would not set a flag to mark the domain is using internal snapshots and
might end up creating a mixed snapshot. Move the setting of the variable
to avoid this problem.

11 years agoconf: Add functions to copy and free network disk source definitions
Peter Krempa [Fri, 15 Nov 2013 15:34:07 +0000 (16:34 +0100)]
conf: Add functions to copy and free network disk source definitions

To simplify operations on virDomainDiskHostDef arrays we will need deep
copy and freeing functions. Add and properly export them.

11 years agosnapshot: conf: Fix NULL dereference when <driver> element is empty
Peter Krempa [Wed, 13 Nov 2013 10:56:47 +0000 (11:56 +0100)]
snapshot: conf: Fix NULL dereference when <driver> element is empty

Consider the following valid snapshot XML as the <driver> element is
allowed to be empty in the domainsnapshot.rng schema:

$ cat snap.xml
<domainsnapshot>
  <disks>
    <disk name='vda' snapshot='external'>
      <source file='/tmp/foo'/>
      <driver/>
    </disk>
  </disks>
</domainsnapshot>

produces the following error:

$ virsh snapshot-create domain snap.xml
error: internal error: unknown disk snapshot driver '(null)'

The driver type is parsed as NULL from the XML as the attribute is not
present and then directly used to produce the error message.

With this patch the attempt to parse the driver type is skipped if not
present to avoid changing the schema to forbid the empty driver element.

11 years agosnapshot: conf: Use common parsing and formatting functions for source
Peter Krempa [Tue, 12 Nov 2013 10:37:04 +0000 (11:37 +0100)]
snapshot: conf: Use common parsing and formatting functions for source

Disk source elements for snapshots were using separate code from our
config parser. As snapshots can be stored on more than just regular
files, we will need the universal parser to allow us to expose a variety
of snapshot disk targets. This patch reuses the config parsers and
formatters to do the job.

This initial support only changes the code without any visible XML
change.

11 years agoconf: Export disk source formatter and parser
Peter Krempa [Tue, 12 Nov 2013 10:32:30 +0000 (11:32 +0100)]
conf: Export disk source formatter and parser

This code will be reused in the snapshot disk definition parser.

11 years agoconf: Split out seclabel formating code for disk source
Peter Krempa [Thu, 7 Nov 2013 15:25:59 +0000 (16:25 +0100)]
conf: Split out seclabel formating code for disk source

The code is common for all the various disk types. Split it out to a
common function.

11 years agoconf: Clean up virDomainDiskSourceDefFormatInternal
Peter Krempa [Thu, 7 Nov 2013 15:03:03 +0000 (16:03 +0100)]
conf: Clean up virDomainDiskSourceDefFormatInternal

Avoid if statements when used with virBufferEscapeString which
automaticaly omits the whole string. Also add some line breaks to
visualy separate the code.

11 years agoconf: Support disk source formatting without needing a virDomainDiskDefPtr
Peter Krempa [Thu, 7 Nov 2013 14:41:30 +0000 (15:41 +0100)]
conf: Support disk source formatting without needing a virDomainDiskDefPtr

The <source> element formatting function was expecting a
virDomainDiskDefPtr to store the data. As snapshots are not using this
data structure to hold the data, we need to add an internal function
which splits out individual fields separately.

11 years agotests: Fix comment for fake storage pool driver
Peter Krempa [Mon, 2 Dec 2013 12:25:01 +0000 (13:25 +0100)]
tests: Fix comment for fake storage pool driver

Commit bae124e40ff2b9d4de75d44510619db2c08d548a was accidentaly pushed
without review feedback worked in. Fix it up.

11 years agoqemuxml2argv: Add test for disk type='volume' with iSCSI pools
Peter Krempa [Thu, 21 Nov 2013 10:04:50 +0000 (11:04 +0100)]
qemuxml2argv: Add test for disk type='volume' with iSCSI pools

Tweak the existing file so that it can be tested for command line
corectness.

11 years agoqemuxml2argv: Add test to verify correct usage of disk type="volume"
Peter Krempa [Thu, 21 Nov 2013 08:12:07 +0000 (09:12 +0100)]
qemuxml2argv: Add test to verify correct usage of disk type="volume"

Tweak the existing file to test command line generator too.

11 years agotest: Implement fake storage pool driver in qemuxml2argv test
Peter Krempa [Wed, 20 Nov 2013 15:04:10 +0000 (16:04 +0100)]
test: Implement fake storage pool driver in qemuxml2argv test

To support testing of "volume" disk backing, we need to implement a few
disk driver backend functions.

The fake storage driver uses files in storagepoolxml2xmlout/POOLNAME.xml
as XML files for pool definitions and volume names are in format
"VOL_TYPE+VOL_PATH". By default type "block" is assumed (for iSCSI test
compatibility).

The choice of this approach along with implemented functions was made so
that <disk type='volume'> can be tested in the xml2argv test.

11 years agoRelease of libvirt-1.2.0
Daniel Veillard [Mon, 2 Dec 2013 04:17:51 +0000 (12:17 +0800)]
Release of libvirt-1.2.0

* configure.ac docs/news.html.in libvirt.spec.in: update for release
* po/*.po*: update and merge localizations from transifex

11 years agovbox: handle errors of virDomainHostdevDefAlloc correctly
Ryota Ozaki [Sun, 1 Dec 2013 14:46:06 +0000 (23:46 +0900)]
vbox: handle errors of virDomainHostdevDefAlloc correctly

The original code ignored errors of virDomainHostdevDefAlloc,
however, we should properly do error return from the function
if it occurs.

The fix pulls out virDomainHostdevDefAlloc from the loop and
executes it all together before the loop. So we can easily
return on errors without the notion of other memory allocations
in the loop.

The deallocation code is separated from the allocation code
because it will be used by a further patch for fixing other error
handlings.

Reported-by: Laine Stump <laine@laine.org>
Signed-off-by: Ryota Ozaki <ozaki.ryota@gmail.com>
11 years agovbox: fix incorrect loop condition in vboxHostDeviceGetXMLDesc
Ryota Ozaki [Sun, 1 Dec 2013 14:46:05 +0000 (23:46 +0900)]
vbox: fix incorrect loop condition in vboxHostDeviceGetXMLDesc

The fixed loop used logical OR to combine two conditions, however,
it is apparently incorrect and logical AND is correct.

We can fix it by replacing OR with AND, but this patch instead
fixes the problem by getting rid of the first conditional
statement: USBFilterCount < def->nhostdevs. It isn't needed
because USBFilterCount will never be greater than or equal to
def->nhostdevs.

def->nhostdevs is calculated in the following code
above the loop in question like this:

    for (i = 0; i < deviceFilters.count; i++) {
        PRBool active = PR_FALSE;
        IUSBDeviceFilter *deviceFilter = deviceFilters.items[i];

        deviceFilter->vtbl->GetActive(deviceFilter, &active);
        if (active) {
            def->nhostdevs++;
        }
    }

And the loop is constructed as like this:

    for (i = 0; (USBFilterCount < def->nhostdevs) || (i < deviceFilters.count); i++) {
        PRBool active                  = PR_FALSE;
(snip)
        deviceFilter->vtbl->GetActive(deviceFilter, &active);
        if (!active)
            continue;
(snip)
        USBFilterCount++;
    }

So def->nhostdevs is the number of active device filters and
USBFilterCount is counted up only when a device filter is active.
Thus, we can remove USBFilterCount < def->nhostdevs safely.

Reported-by: Laine Stump <laine@laine.org>
Signed-off-by: Ryota Ozaki <ozaki.ryota@gmail.com>
11 years agodocs: fix typos in libvirt.h.in
Chen Hanxiao [Mon, 2 Dec 2013 02:36:16 +0000 (10:36 +0800)]
docs: fix typos in libvirt.h.in

s/caused/causes

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
11 years agoLink libvirt-sandbox from apps page
Daniel P. Berrange [Fri, 29 Nov 2013 16:27:42 +0000 (16:27 +0000)]
Link libvirt-sandbox from apps page

Add a link to the http://sandbox.libvirt.org sub-site from the
list of libraries related to libvirt. Also fix formatting for
the ruby libvirt binding.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd docs about audit subsystem logging
Daniel P. Berrange [Fri, 29 Nov 2013 16:23:42 +0000 (16:23 +0000)]
Add docs about audit subsystem logging

Adds a new page to the website "Deployment" section describing
what data is sent to the audit logs and how to configure libvirtd
audit settings.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix memory leak in virNWFilterDefParseXML()
Nehal J Wani [Fri, 29 Nov 2013 15:28:51 +0000 (20:58 +0530)]
Fix memory leak in virNWFilterDefParseXML()

While running nwfilterxml2xmltest, it was found that valgrind pointed out the
following error...

==7466== 16 bytes in 1 blocks are definitely lost in loss record 26 of 90
==7466==    at 0x4A06B6F: calloc (vg_replace_malloc.c:593)
    ==7466==    by 0x4C651AD: virAlloc (viralloc.c:142)
    ==7466==    by 0x4D0450D: virNWFilterDefParseNode (nwfilter_conf.c:2575)
    ==7466==    by 0x4D05D84: virNWFilterDefParse (nwfilter_conf.c:2647)
    ==7466==    by 0x401FDE: testCompareXMLToXMLHelper (nwfilterxml2xmltest.c:39)
    ==7466==    by 0x402DE1: virtTestRun (testutils.c:138)
    ==7466==    by 0x4018E9: mymain (nwfilterxml2xmltest.c:111)
    ==7466==    by 0x403482: virtTestMain (testutils.c:593)
    ==7466==    by 0x341F421A04: (below main) (libc-start.c:225)

...21 times, which are related to 21 tests in nwfilterxml2xmltest.c which sent
EXPECT_WARN = false. There were two scenarios in virNWFilterDefParseXML(),
when the variable 'entry' was malloc'ed, but not freed.

11 years agoFix memory leak in virDomainDefParseXML()
Nehal J Wani [Mon, 2 Dec 2013 02:32:12 +0000 (10:32 +0800)]
Fix memory leak in virDomainDefParseXML()

This patch fixes the memory leaks found while running qemuxml2argvtest

==8260== 3 bytes in 1 blocks are definitely lost in loss record 1 of
129
==8260==    at 0x4A0887C: malloc (vg_replace_malloc.c:270)
==8260==    by 0x341F485E21: strdup (strdup.c:42)
==8260==    by 0x4CADCFF: virStrdup (virstring.c:554)
==8260==    by 0x4CBB839: virXPathString (virxml.c:90)
==8260==    by 0x4CE753A: virDomainDefParseXML (domain_conf.c:11478)
==8260==    by 0x4CEB4FE: virDomainDefParseNode (domain_conf.c:12742)
==8260==    by 0x4CEB675: virDomainDefParse (domain_conf.c:12684)
==8260==    by 0x425958: testCompareXMLToArgvHelper (qemuxml2argvtest.c:107)
==8260==    by 0x427111: virtTestRun (testutils.c:138)
==8260==    by 0x41D3FE: mymain (qemuxml2argvtest.c:452)
==8260==    by 0x4277B2: virtTestMain (testutils.c:593)
==8260==    by 0x341F421A04: (below main) (libc-start.c:225)
==8260==
==8260== 4 bytes in 1 blocks are definitely lost in loss record 5 of
129
==8260==    at 0x4A0887C: malloc (vg_replace_malloc.c:270)
==8260==    by 0x341F485E21: strdup (strdup.c:42)
==8260==    by 0x4CADCFF: virStrdup (virstring.c:554)
==8260==    by 0x4CBB839: virXPathString (virxml.c:90)
==8260==    by 0x4CE753A: virDomainDefParseXML (domain_conf.c:11478)
==8260==    by 0x4CEB4FE: virDomainDefParseNode (domain_conf.c:12742)
==8260==    by 0x4CEB675: virDomainDefParse (domain_conf.c:12684)
==8260==    by 0x425958: testCompareXMLToArgvHelper (qemuxml2argvtest.c:107)
==8260==    by 0x427111: virtTestRun (testutils.c:138)
==8260==    by 0x41D39A: mymain (qemuxml2argvtest.c:451)
==8260==    by 0x4277B2: virtTestMain (testutils.c:593)
==8260==    by 0x341F421A04: (below main) (libc-start.c:225)
==8260==

11 years agovirsh: fix doc typos
Nehal J Wani [Sat, 30 Nov 2013 06:33:17 +0000 (12:03 +0530)]
virsh: fix doc typos

Fix 6 minor spelling errors in virsh doc

11 years agoFix typos in various docs
Nehal J Wani [Sat, 30 Nov 2013 18:27:15 +0000 (23:57 +0530)]
Fix typos in various docs

Fix 8 minor spelling errors in docs/*.html.in

11 years agoLXC: Ensure security context is set when mounting images
Daniel P. Berrange [Fri, 29 Nov 2013 12:19:37 +0000 (12:19 +0000)]
LXC: Ensure security context is set when mounting images

When setting up filesystems backed by block devices or file
images, the SELinux mount options must be used to ensure the
correct context is set

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agonetwork: properly update iptables rules during net-update
Laine Stump [Wed, 27 Nov 2013 15:07:34 +0000 (17:07 +0200)]
network: properly update iptables rules during net-update

This patch resolves:

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

The basic problem is that during a network update, the required
iptables rules sometimes change, and this was being handled by simply
removing and re-adding the rules. However, the removal of the old
rules was done based on the *new* state of the network, which would
mean that some of the rules would not match those currently in the
system, so the old rules wouldn't be removed.

This patch removes the old rules prior to updating the network
definition then adds the new rules as soon as the definition is
updated. Note that this could lead to a stray packet or two during the
interim, but that was already a problem before (the period of limbo is
now just slightly longer).

While moving the location for the rules, I added a few more sections
that should result in the iptables rules being redone:

DHCP_RANGE and DHCP_HOST - these are needed because adding/removing a dhcp
host entry could lead to the dhcp service being started/stopped, which
would require that the mangle rule that fixes up dhcp response
checksums sould need to be added/removed, and this wasn't being done.

11 years agoFix bug in identifying sub-mounts
Daniel P. Berrange [Wed, 27 Nov 2013 15:21:41 +0000 (15:21 +0000)]
Fix bug in identifying sub-mounts

The code for extracting sub-mounts would just do a STRPREFIX
check on the mount. This was flawed because if there were
the following mounts

 /etc/aliases
 /etc/aliases.db

and '/etc/aliases' was asked for, it would return both even
though the latter isn't a sub-mount.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoPull lxcContainerGetSubtree out into shared virfile module
Daniel P. Berrange [Wed, 27 Nov 2013 15:19:49 +0000 (15:19 +0000)]
Pull lxcContainerGetSubtree out into shared virfile module

Move the code for lxcContainerGetSubtree into the virfile
module creating 2 new functions

  int virFileGetMountSubtree(const char *mtabpath,
                             const char *prefix,
                             char ***mountsret,
                             size_t *nmountsret);
  int virFileGetMountReverseSubtree(const char *mtabpath,
                                    const char *prefix,
                                    char ***mountsret,
                                    size_t *nmountsret);

Add a new virfiletest.c test case to validate the new code.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoIntroduce standard methods for sorting strings with qsort
Daniel P. Berrange [Thu, 28 Nov 2013 11:14:59 +0000 (11:14 +0000)]
Introduce standard methods for sorting strings with qsort

Add virStringSortCompare and virStringSortRevCompare as
standard functions to use with qsort.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agotests: fix virpcitest with read-only srcdir
Eric Blake [Wed, 27 Nov 2013 21:59:52 +0000 (14:59 -0700)]
tests: fix virpcitest with read-only srcdir

'make distcheck' has been broken since commit 21685c9; basically,
it emulates the case of a read-only $(srcdir) (such as building
from a tarball exploded onto a CD-ROM), but we were creating our
fake pci device as a symlink into $(srcdir) and failing when that
requires opening the config file for writing:

 3) testVirPCIDeviceReset                                             ... libvirt:  error : Failed to open config space file '/sys/bus/pci/devices/0000:00:01.0/config': Permission denied

Fix it by copying rather than symlinking.

* tests/virpcimock.c (make_file): Add parameter to allow binary
creation; adjust all callers.
(pci_device_new_from_stub): Copy rather than symlink.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agotests: guarantee abs_srcdir in all C tests
Eric Blake [Wed, 27 Nov 2013 21:31:53 +0000 (14:31 -0700)]
tests: guarantee abs_srcdir in all C tests

While trying to debug a failure of virpcitest during 'make distcheck',
I noticed that with a VPATH build, 'cd tests; ./virpcitest' fails for
an entirely different reason.  To reproduce the distcheck failure, I
had to run 'cd tests; abs_srcdir=/path/to/src ./virpcitest'.  But we
document in HACKING that all of our tests are supposed to be runnable
without requiring extra environment variables.

The solution: hardcode the location of srcdir into the just-built
binaries, rather than requiring make to prepopulate environment
variables.  With this, './virpcitest' passes even in a VPATH build
(provided that $(srcdir) is writable; a followup patch will fix the
conditions required by 'make distcheck').  [Note: the makefile must
still pass on directory variables to the test environment of shell
scripts, since those aren't compiled.  So while this solves the case
of a compiled test, it still requires environment variables to pass
a VPATH build of any shell script test case that relies on srcdir.]

* tests/Makefile.am (AM_CFLAGS): Define abs_srcdir in all compiled
tests.
* tests/testutils.h (abs_srcdir): Quit declaring.
* tests/testutils.c (virtTestMain): Rely on define rather than
environment variable.
* tests/virpcimock.c (pci_device_new_from_stub): Rely on define.
* tests/cputest.c (mymain): Adjust abs_top_srcdir default.
* tests/qemuxml2argvtest.c (mymain): Likewise.
* tests/qemuxmlnstest.c (mymain): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoconf: Export virStorageVolType enum helper functions
Peter Krempa [Wed, 20 Nov 2013 15:02:00 +0000 (16:02 +0100)]
conf: Export virStorageVolType enum helper functions

Export string conversion from and to the virStorageVolType enum.

11 years agostorage: skip selinux cleanup when fd not available
Eric Blake [Wed, 27 Nov 2013 03:57:05 +0000 (20:57 -0700)]
storage: skip selinux cleanup when fd not available

When attempting to backport gluster pools to an older versoin
where there is no VIR_STRDUP, I got a crash from calling
strdup(,NULL). Rather than relying on the current else branch
safely doing nothing when there is no fd, it is easier to just
skip it. While at it, there's no need to explicitly set
perms.label to NULL after a VIR_FREE().

* src/storage/storage_backend.c
(virStorageBackendUpdateVolTargetInfoFD): Minor optimization.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoqemu: preserve netdev MAC address during 'domxml-to-native'
Bing Bu Cao [Wed, 27 Nov 2013 10:52:12 +0000 (18:52 +0800)]
qemu: preserve netdev MAC address during 'domxml-to-native'

The virsh command 'domxml-to-native' (virConnectDomainXMLToNative())
converts all network devices to "type='ethernet'" in order to make it
more likely that the generated command could be run directly from a
shell (other libvirt network device types end up referencing file
descriptors for tap devices assumed to have been created by libvirt,
which can't be done in this case).

During this conversion, all of the netdev parameters are cleared out,
then specific items are filled in after changing the type. The MAC
address was not one of these preserved items, and the result was that
mac addresses in the generated commandlines were always
00:00:00:00:00:00.

This patch saves the mac address before the conversion, then
repopulates it afterwards, so the proper mac addresses show up in the
commandline.

Signed-off-by: Bing Bu Cao <mars@linux.vnet.ibm.com>
Signed-off-by: Laine Stump <laine@laine.org>
11 years agolook for numad in /usr/sbin
Jim Fehlig [Wed, 27 Nov 2013 04:32:43 +0000 (21:32 -0700)]
look for numad in /usr/sbin

When looking for numad with AC_PATH_PROG, include /usr/sbin in
the search path.

11 years agostorage: don't read storage volumes in nonblock mode
Eric Blake [Mon, 25 Nov 2013 21:38:22 +0000 (14:38 -0700)]
storage: don't read storage volumes in nonblock mode

Commit 348b4e2 introduced a potential problem (thankfully not
in any release): we are attempting to use virFileReadHeaderFD()
on a file that was opened with O_NONBLOCK.  While this
shouldn't be a problem in practice (because O_NONBLOCK
typically doesn't affect regular or block files, and fifos and
sockets cannot be storage volumes), it's better to play it safe
to avoid races from opening an unexpected file type while also
avoiding problems with having to handle EAGAIN while read()ing.

Based on a report by Dan Berrange.

* src/storage/storage_backend.c
(virStorageBackendVolOpenCheckMode): Fix up fd after avoiding race.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoLXC: add securetty related note in Device nodes
Gao feng [Mon, 25 Nov 2013 06:47:53 +0000 (14:47 +0800)]
LXC: add securetty related note in Device nodes

Tell user how to resolve the problem that fail to log in
the container.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
11 years agoLXC: don't unmount mounts for shared root
Gao feng [Wed, 20 Nov 2013 02:11:09 +0000 (10:11 +0800)]
LXC: don't unmount mounts for shared root

Also after commit 5ff9d8a65ce80efb509ce4e8051394e9ed2cd942
vfs: Lock in place mounts from more privileged users,

unprivileged user has no rights to umount the mounts that
inherited from parent mountns.

right now, I have no good idea to fix this problem, we need
to do more research. this patch just skip unmounting these
mounts for shared root.

BTW, I think when libvirt lxc enables user namespace, the
configuation that shares root with host is very rara.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
11 years agoLXC: fix the problem that libvirt lxc fail to start on latest kernel
Gao feng [Wed, 20 Nov 2013 02:11:08 +0000 (10:11 +0800)]
LXC: fix the problem that libvirt lxc fail to start on latest kernel

After kernel commit 5ff9d8a65ce80efb509ce4e8051394e9ed2cd942
vfs: Lock in place mounts from more privileged users,

unprivileged user has no rights to move the mounts that
inherited from parent mountns. we use this feature to move
the /stateDir/domain-name.{dev, devpts} to the /dev/ and
/dev/pts directroy of container. this commit breaks libvirt lxc.

this patch changes the behavior to bind these mounts when
user namespace is enabled and move these mounts when user
namespace is disabled.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
11 years agosasl: Replace 'restep' label with 'continue'
Christophe Fergeau [Tue, 26 Nov 2013 10:34:46 +0000 (11:34 +0100)]
sasl: Replace 'restep' label with 'continue'

Since the label is at the beginning of the loop, this has the same effect.

11 years agosasl: Fix authentication when using PLAIN mechanism
Christophe Fergeau [Thu, 21 Nov 2013 17:40:52 +0000 (18:40 +0100)]
sasl: Fix authentication when using PLAIN mechanism

With some authentication mechanism (PLAIN for example), sasl_client_start()
can return SASL_OK, which translates to virNetSASLSessionClientStart()
returning VIR_NET_SASL_COMPLETE.
cyrus-sasl documentation is a bit vague as to what to do in such situation,
but upstream clarified this a bit in
http://asg.andrew.cmu.edu/archive/message.php?mailbox=archive.cyrus-sasl&msg=10104

When we got VIR_NET_SASL_COMPLETE after virNetSASLSessionClientStart() and
if the remote also tells us that authentication is complete, then we should
end the authentication procedure rather than forcing a call to
virNetSASLSessionClientStep(). Without this patch, when trying to use SASL
PLAIN, I get:
error :authentication failed : Failed to step SASL negotiation: -1
(SASL(-1): generic failure: Unable to find a callback: 32775)

This patch is based on a spice-gtk patch by Dietmar Maurer.

11 years agoFix invalid read in virNetSASLSessionClientStep debug log
Christophe Fergeau [Fri, 22 Nov 2013 16:54:53 +0000 (17:54 +0100)]
Fix invalid read in virNetSASLSessionClientStep debug log

virNetSASLSessionClientStep logs the data that is going to be passed to
sasl_client_step as input data. However, it tries to log it as a string,
while there is no guarantee that this data is going to be nul-terminated.
This leads to this valgrind log:

==20938== Invalid read of size 1
==20938==    at 0x8BDB08F: vfprintf (vfprintf.c:1635)
==20938==    by 0x8C06DF2: vasprintf (vasprintf.c:62)
==20938==    by 0x4CCEDF9: virVasprintfInternal (virstring.c:337)
==20938==    by 0x4CA9516: virLogVMessage (virlog.c:842)
==20938==    by 0x4CA939A: virLogMessage (virlog.c:778)
==20938==    by 0x4E21E0D: virNetSASLSessionClientStep (virnetsaslcontext.c:458)
==20938==    by 0x4DE47B8: remoteAuthSASL (remote_driver.c:4136)
==20938==    by 0x4DE33AE: remoteAuthenticate (remote_driver.c:3635)
==20938==    by 0x4DDBFAA: doRemoteOpen (remote_driver.c:832)
==20938==    by 0x4DDC8BA: remoteConnectOpen (remote_driver.c:1027)
==20938==    by 0x4D8595F: do_open (libvirt.c:1239)
==20938==    by 0x4D863F3: virConnectOpenAuth (libvirt.c:1481)
==20938==    by 0x12762B: vshReconnect (virsh.c:337)
==20938==    by 0x12C9B0: vshInit (virsh.c:2470)
==20938==    by 0x12E9A5: main (virsh.c:3338)
==20938==  Address 0xe329ccd is 0 bytes after a block of size 141 alloc'd
==20938==    at 0x4A081D4: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==20938==    by 0x8CB91B4: xdr_array (xdr_array.c:94)
==20938==    by 0x4E039C2: xdr_remote_auth_sasl_start_ret (remote_protocol.c:3134)
==20938==    by 0x4E1F8AA: virNetMessageDecodePayload (virnetmessage.c:405)
==20938==    by 0x4E119F5: virNetClientProgramCall (virnetclientprogram.c:377)
==20938==    by 0x4DF8141: callFull (remote_driver.c:5794)
==20938==    by 0x4DF821A: call (remote_driver.c:5816)
==20938==    by 0x4DE46CF: remoteAuthSASL (remote_driver.c:4112)
==20938==    by 0x4DE33AE: remoteAuthenticate (remote_driver.c:3635)
==20938==    by 0x4DDBFAA: doRemoteOpen (remote_driver.c:832)
==20938==    by 0x4DDC8BA: remoteConnectOpen (remote_driver.c:1027)
==20938==    by 0x4D8595F: do_open (libvirt.c:1239)
==20938==    by 0x4D863F3: virConnectOpenAuth (libvirt.c:1481)
==20938==    by 0x12762B: vshReconnect (virsh.c:337)
==20938==    by 0x12C9B0: vshInit (virsh.c:2470)
==20938==    by 0x12E9A5: main (virsh.c:3338)

11 years agoTie SASL callbacks lifecycle to virNetSessionSASLContext
Christophe Fergeau [Fri, 22 Nov 2013 16:27:21 +0000 (17:27 +0100)]
Tie SASL callbacks lifecycle to virNetSessionSASLContext

The array of sasl_callback_t callbacks which is passed to sasl_client_new()
must be kept alive as long as the created sasl_conn_t object is alive as
cyrus-sasl uses this structure internally for things like logging, so
the memory used for callbacks must only be freed after sasl_dispose() has
been called.

During testing of successful SASL logins with
virsh -c qemu+tls:///system list --all
I've been getting invalid read reports from valgrind

==9237== Invalid read of size 8
==9237==    at 0x6E93B6F: _sasl_getcallback (common.c:1745)
==9237==    by 0x6E95430: _sasl_log (common.c:1850)
==9237==    by 0x16593D87: digestmd5_client_mech_dispose (digestmd5.c:4580)
==9237==    by 0x6E91653: client_dispose (client.c:332)
==9237==    by 0x6E9476A: sasl_dispose (common.c:851)
==9237==    by 0x4E225A1: virNetSASLSessionDispose (virnetsaslcontext.c:678)
==9237==    by 0x4CBC551: virObjectUnref (virobject.c:262)
==9237==    by 0x4E254D1: virNetSocketDispose (virnetsocket.c:1042)
==9237==    by 0x4CBC551: virObjectUnref (virobject.c:262)
==9237==    by 0x4E2701C: virNetSocketEventFree (virnetsocket.c:1794)
==9237==    by 0x4C965D3: virEventPollCleanupHandles (vireventpoll.c:583)
==9237==    by 0x4C96987: virEventPollRunOnce (vireventpoll.c:652)
==9237==    by 0x4C94730: virEventRunDefaultImpl (virevent.c:274)
==9237==    by 0x12C7BA: vshEventLoop (virsh.c:2407)
==9237==    by 0x4CD3D04: virThreadHelper (virthreadpthread.c:161)
==9237==    by 0x7DAEF32: start_thread (pthread_create.c:309)
==9237==    by 0x8C86EAC: clone (clone.S:111)
==9237==  Address 0xe2d61b0 is 0 bytes inside a block of size 168 free'd
==9237==    at 0x4A07577: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==9237==    by 0x4C73827: virFree (viralloc.c:580)
==9237==    by 0x4DE4BC7: remoteAuthSASL (remote_driver.c:4219)
==9237==    by 0x4DE33D0: remoteAuthenticate (remote_driver.c:3639)
==9237==    by 0x4DDBFAA: doRemoteOpen (remote_driver.c:832)
==9237==    by 0x4DDC8DC: remoteConnectOpen (remote_driver.c:1031)
==9237==    by 0x4D8595F: do_open (libvirt.c:1239)
==9237==    by 0x4D863F3: virConnectOpenAuth (libvirt.c:1481)
==9237==    by 0x12762B: vshReconnect (virsh.c:337)
==9237==    by 0x12C9B0: vshInit (virsh.c:2470)
==9237==    by 0x12E9A5: main (virsh.c:3338)

This commit changes virNetSASLSessionNewClient() to take ownership of the SASL
callbacks. Then we can free them in virNetSASLSessionDispose() after the corresponding
sasl_conn_t has been freed.