]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
11 years agolibxl: Check for regcomp failure
Jim Fehlig [Wed, 4 Sep 2013 06:21:42 +0000 (00:21 -0600)]
libxl: Check for regcomp failure

Change libxlGetAutoballoonConf() function to return an int
for success/failure, and fail if regcomp fails.

11 years agovirsh: fix build on mingw, which lacks termios stuff
Eric Blake [Wed, 4 Sep 2013 21:57:30 +0000 (15:57 -0600)]
virsh: fix build on mingw, which lacks termios stuff

Recent patches to fix handling of Ctrl-C when interacting with
ssh are not portable to mingw, which lacks termios handling.
The simplest solution is to just compile that code out, and
if someone ever appears that has a serious interest in getting
virsh fully functional even with ssh connections, they can
provide patches at that time.

* tools/virsh.h (_vshControl): Make termattr conditional.
* tools/virsh.c (vshTTYIsInterruptCharacter)
(vshTTYDisableInterrupt, vshTTYRestore, cfmakeraw, vshTTYMakeRaw)
(main): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agolibxl: Fix Coverity warning
Jim Fehlig [Wed, 4 Sep 2013 20:27:20 +0000 (14:27 -0600)]
libxl: Fix Coverity warning

John Ferlan reported the following Coverity warning:

In libxlDomainCoreDump() Coverity has noted a FORWARD_NULL reference:

2004      if ((flags & VIR_DUMP_CRASH) && !vm->persistent) {
2005          virDomainObjListRemove(driver->domains, vm);

(20) Event assign_zero:  Assigning: "vm" = "NULL".
Also see events:  [var_deref_model]

2006          vm = NULL;
2007      }
2008
2009      ret = 0;
2010
2011  cleanup_unpause:

(21) Event var_deref_model:  Passing null pointer "vm" to function
     "virDomainObjIsActive(virDomainObjPtr)", which dereferences it. [details]
Also see events:  [assign_zero]

2012      if (virDomainObjIsActive(vm) && paused) {
2013          if (libxl_domain_unpause(priv->ctx, dom->id) != 0) {
2014              virReportError(VIR_ERR_INTERNAL_ERROR,

Removing the vm from domain obj list and setting it to NULL can be
done in the previous 'if (flags & VIR_DUMP_CRASH)' conditional.  Fix
the Coverity warning by ensuring vm is not NULL before testing if it
is still active.

11 years agospec: default vbox according to libvirtd build
Eric Blake [Tue, 3 Sep 2013 23:08:25 +0000 (17:08 -0600)]
spec: default vbox according to libvirtd build

Commit ba5f3c7 moved virtualBox support into libvirtd, but the spec
file was still unconditionally requesting it even when not building
the server side.  Thankfully there were no ill effects for a
client_only build, as most uses of %{with_vbox} were guarded by
%{with_libvirtd}; but we might as well avoid confusion by more
closely matching the makefile.

* libvirt.spec.in (with_vbox): Hoist to server conditionals.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: avoid stranded polkit file in client-only build
Eric Blake [Wed, 4 Sep 2013 03:00:40 +0000 (21:00 -0600)]
build: avoid stranded polkit file in client-only build

daemon/Makefile.am installs a .policy file if WITH_LIBVIRTD and
WITH_POLKIT are both set.  src/Makefile.am, on the other hand,
installs a .policy file if WITH_POLKIT1 is set, but without checking
WITH_LIBVIRTD.  When running 'make rpm' with client_only manually
set, on a Fedora 19 box, that leads to a failure:

RPM build errors:
    Installed (but unpackaged) file(s) found:
   /usr/share/polkit-1/actions/org.libvirt.api.policy

Fix it by adding another conditional.

* src/Makefile.am (polkitaction_DATA): Make conditional.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: only install nwfilter examples when building nwfilter
Eric Blake [Tue, 3 Sep 2013 23:23:57 +0000 (17:23 -0600)]
build: only install nwfilter examples when building nwfilter

'make rpm' with client_local set to 1 (by manual modification,
or with RHEL 5 on s390) warns:

RPM build errors:
    Installed (but unpackaged) file(s) found:
   /etc/libvirt/nwfilter/allow-arp.xml
   /etc/libvirt/nwfilter/allow-dhcp-server.xml
   /etc/libvirt/nwfilter/allow-dhcp.xml
   /etc/libvirt/nwfilter/allow-incoming-ipv4.xml
   /etc/libvirt/nwfilter/allow-ipv4.xml
   /etc/libvirt/nwfilter/clean-traffic.xml
   /etc/libvirt/nwfilter/no-arp-ip-spoofing.xml
   /etc/libvirt/nwfilter/no-arp-mac-spoofing.xml
   /etc/libvirt/nwfilter/no-arp-spoofing.xml
   /etc/libvirt/nwfilter/no-ip-multicast.xml
   /etc/libvirt/nwfilter/no-ip-spoofing.xml
   /etc/libvirt/nwfilter/no-mac-broadcast.xml
   /etc/libvirt/nwfilter/no-mac-spoofing.xml
   /etc/libvirt/nwfilter/no-other-l2-traffic.xml
   /etc/libvirt/nwfilter/no-other-rarp-traffic.xml
   /etc/libvirt/nwfilter/qemu-announce-self-rarp.xml
   /etc/libvirt/nwfilter/qemu-announce-self.xml
   /usr/share/polkit-1/actions/org.libvirt.api.policy

The bulk of these are fixed with this patch.

* examples/xml/nwfilter/Makefile.am (install-data-local)
(uninstall-local): Make conditional.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: only run fdstreamtest when libvirtd is built
Eric Blake [Tue, 3 Sep 2013 21:55:21 +0000 (15:55 -0600)]
build: only run fdstreamtest when libvirtd is built

An rpm build with client_only set to 1 (for example, RHEL 5 on
s390, or by modifying libvirt.spec.in) failed with

TEST: fdstreamtest
 1) Stream read blocking                                              ... OK
 2) Stream read non-blocking                                          ... Unexpected EOF block 0 want 128
FAILED
 3) Stream write blocking                                             ... OK
 4) Stream write non-blocking                                         ... Failed to finish stream: internal error: libvirt:  error : cannot execute binary /home/eblake/rpmbuild/BUILD/libvirt-1.1.1/tests/../src/libvirt_iohelper: No such file or directory

Since the test depends on something that was only built for
WITH_LIBVIRTD (see src/Makefile.am), we must do the same for
the test.

* tests/Makefile.am (test_programs): Make fdstreamtest conditional.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agospec: fix rpm build when lxc disabled
Eric Blake [Tue, 3 Sep 2013 21:10:01 +0000 (15:10 -0600)]
spec: fix rpm build when lxc disabled

'make rpm' failed if ~/.rpmmacros contains '%_without_lxc 1',
which simulates the case of not having lxc available.

RPM build errors:
    File not found: /home/eblake/rpmbuild/BUILDROOT/libvirt-1.1.1-1.fc19.x86_64/etc/libvirt/virt-login-shell.conf
    File not found by glob: /home/eblake/rpmbuild/BUILDROOT/libvirt-1.1.1-1.fc19.x86_64/usr/share/man/man1/virt-login-shell.1*
    File not found: /home/eblake/rpmbuild/BUILDROOT/libvirt-1.1.1-1.fc19.x86_64/usr/bin/virt-login-shell
make: *** [rpm] Error 1

Reported by Dan Berrange.

* libvirt.spec.in: Mark virt-login-shell as conditional on lxc.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agovirGet{User,Group}Ent() don't say success on fail
Doug Goldstein [Wed, 4 Sep 2013 16:15:34 +0000 (11:15 -0500)]
virGet{User,Group}Ent() don't say success on fail

When virGetUserEnt() and virGetGroupEnt() fail due to the uid or gid not
existing on the machine they'll print a message like:

$ virsh -c vbox:///session list
error: failed to connect to the hypervisor
error: Failed to find user record for uid '32655': Success

The success at the end is a bit confusing. This changes it to:

$ virsh -c vbox:///session list
error: failed to connect to the hypervisor
error: Failed to find user record for uid '32655'

11 years agobuild: enforce makefile conditional style
Eric Blake [Wed, 4 Sep 2013 02:39:16 +0000 (20:39 -0600)]
build: enforce makefile conditional style

Automake has builtin support to prevent botched conditional nesting,
but only if you use:
if FOO
else !FOO
endif !FOO

An example error message when using the wrong name:

daemon/Makefile.am:378: error: else reminder (LIBVIRT_INIT_SCRIPT_SYSTEMD_TRUE) incompatible with current conditional: LIBVIRT_INIT_SCRIPT_SYSTEMD_FALSE
daemon/Makefile.am:381: error: endif reminder (LIBVIRT_INIT_SCRIPT_SYSTEMD_TRUE) incompatible with current conditional: LIBVIRT_INIT_SCRIPT_SYSTEMD_FALSE

As our makefiles tend to have quite a bit of nested conditionals,
it's better to take advantage of the benefits of the build system
double-checking that our conditionals are well-nested, but that
requires a syntax check to enforce our usage style.

Alas, unlike C preprocessor and spec files, we can't use indentation
to make it easier to see how deeply nesting goes.

* cfg.mk (sc_makefile_conditionals): New rule.
* daemon/Makefile.am: Enforce the style.
* gnulib/tests/Makefile.am: Likewise.
* python/Makefile.am: Likewise.
* src/Makefile.am: Likewise.
* tests/Makefile.am: Likewise.
* tools/Makefile.am: Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agodocs: Add OpenStack into references
Martin Kletzander [Wed, 4 Sep 2013 07:20:59 +0000 (09:20 +0200)]
docs: Add OpenStack into references

11 years agoDon't call VIR_ALLOC on def->uuid in parallels storage driver
Daniel P. Berrange [Tue, 3 Sep 2013 15:23:42 +0000 (16:23 +0100)]
Don't call VIR_ALLOC on def->uuid in parallels storage driver

The 'uuid' field in virDomainDefPtr is not a pointer, it is a
fixed length array. Calling VIR_ALLOC on it is thus wrong and
leaks memory.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd missing 'libvirt_lxc_api' variable in pkg-config file
Daniel P. Berrange [Tue, 3 Sep 2013 11:31:53 +0000 (12:31 +0100)]
Add missing 'libvirt_lxc_api' variable in pkg-config file

The 'libvirt_lxc_api' variable is intended to allow apps to
query the location of the API XML file for libvirt_lxc.so

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix coding style issues in daemon/remote.c
Nehal J Wani [Tue, 3 Sep 2013 20:36:20 +0000 (02:06 +0530)]
Fix coding style issues in daemon/remote.c

Fixes for argument layouts of various functions in daemon/remote.c

11 years agoconf: Remove the actual hostdev when removing a network
Peter Krempa [Tue, 3 Sep 2013 15:25:56 +0000 (17:25 +0200)]
conf: Remove the actual hostdev when removing a network

Commit 50348e6edfa reused the code to remove the hostdev portion of a
network definition on multiple places but forgot to take into account
that sometimes the "actual" network is passed and in some cases the
parent of that.

This patch uses the virDomainNetGetActualHostdev() helper to acquire the
correct pointer all the time while removing the hostdev portion from the
list.

11 years agoqemu: Make domain renaming work during migration
Jiri Denemark [Tue, 3 Sep 2013 13:17:03 +0000 (15:17 +0200)]
qemu: Make domain renaming work during migration

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

Since commit v1.0.5-56-g449e6b1 (Pull parsing of migration xml up into
QEMU driver APIs) any attempt to rename a domain during migration fails
with the following error message:

    internal error Incoming cookie data had unexpected name DOM vs DOM2

This is because migration cookies always use the original domain name
and the mentioned commit failed to propagate the name back to
qemuMigrationPrepareAny.

11 years agovirFileNBDDeviceAssociate: Avoid use of uninitialized variable
Michal Privoznik [Tue, 3 Sep 2013 16:56:06 +0000 (18:56 +0200)]
virFileNBDDeviceAssociate: Avoid use of uninitialized variable

The @qemunbd variable can be used uninitialized.

11 years agoAppArmorSetSecurityImageLabel: Avoid use of uninitialized variable
Michal Privoznik [Tue, 3 Sep 2013 16:54:58 +0000 (18:54 +0200)]
AppArmorSetSecurityImageLabel: Avoid use of uninitialized variable

The @profile_name variable can be used uninitialized.

11 years agolibxl: Use standard format for source file copyright notice
Jim Fehlig [Wed, 4 Sep 2013 05:43:00 +0000 (23:43 -0600)]
libxl: Use standard format for source file copyright notice

Change source file copyright notice to prevailing libvirt style.

11 years agolibxl: Add libxlDomObjFromDomain
Jim Fehlig [Fri, 30 Aug 2013 20:58:31 +0000 (14:58 -0600)]
libxl: Add libxlDomObjFromDomain

Similar to the QEMU and LXC drivers, add a helper function to
lookup a domain, and use it instead of much copy and paste.

11 years agolibxl: Remove unnecessary driver locking
Jim Fehlig [Fri, 30 Aug 2013 20:57:42 +0000 (14:57 -0600)]
libxl: Remove unnecessary driver locking

Now that most fields of libxlDriverPrivate struct are immutable
or self-locking, there is no need to acquire the driver lock in
much of the libxl driver.

11 years agolibxl: Move driver lock/unlock to libxl_conf
Jim Fehlig [Fri, 30 Aug 2013 20:56:40 +0000 (14:56 -0600)]
libxl: Move driver lock/unlock to libxl_conf

Move the libxl driver lock/unlock functions from libxl_driver.c
to libxl_conf.h so they can be used by other source files.

11 years agolibxl: Add comments to libxlDriverPrivate fields
Jim Fehlig [Fri, 30 Aug 2013 20:55:52 +0000 (14:55 -0600)]
libxl: Add comments to libxlDriverPrivate fields

Similar to the QEMU and LXC drivers, annotate the fields of
libxlDriverPrivate struct to indicate the locking rules for
their use.

11 years agolibxl: Use atomic ops for driver->nactive
Jim Fehlig [Fri, 30 Aug 2013 20:54:50 +0000 (14:54 -0600)]
libxl: Use atomic ops for driver->nactive

11 years agolibxl: Introduce libxlDriverConfig object
Jim Fehlig [Fri, 30 Aug 2013 20:52:14 +0000 (14:52 -0600)]
libxl: Introduce libxlDriverConfig object

The libxlDriverPrivate struct contains an variety of data with
varying access needs. Similar to the QEMU and LXC drivers,
move all the static config data into a dedicated libxlDriverConfig
object. The only locking requirement is to hold the driver lock
while obtaining an instance of libxlDriverConfig. Once a reference
is held on the config object, it can be used completely lockless
since it is immutable.

11 years agolibxl: User per-domain ctx in libxlDomainGetInfo
Jim Fehlig [Fri, 30 Aug 2013 20:36:22 +0000 (14:36 -0600)]
libxl: User per-domain ctx in libxlDomainGetInfo

libxlDomainGetInfo() uses the driver-wide libxl ctx when
it would be more appropriate to use the per-domain ctx
associated with the domain.  Switch to using the per-domain
libxl ctx.

11 years agolibxl: libxl: Use per-domain ctx in libxlMakeDomCreateInfo
Jim Fehlig [Fri, 30 Aug 2013 20:34:10 +0000 (14:34 -0600)]
libxl: libxl: Use per-domain ctx in libxlMakeDomCreateInfo

libxlMakeDomCreateInfo() uses the driver-wide libxl ctx when
it would be more appropriate to use the per-domain ctx
associated with the domain.  Switch to using the per-domain
libxl ctx.

11 years agolibxl: Add libxl_version_info to libxlDriverPrivate
Jim Fehlig [Fri, 30 Aug 2013 20:32:10 +0000 (14:32 -0600)]
libxl: Add libxl_version_info to libxlDriverPrivate

libxl version info is static data as far as the libxl driver
is concerned, so retrieve this info when the driver is initialized
and stash it in the libxlDriverPrivate object.  Subsequently use
the stashed info instead of repeatedly calling libxl_get_version_info().

11 years agolibxl: Earlier detection of not running on Xen
Jim Fehlig [Fri, 30 Aug 2013 18:34:48 +0000 (12:34 -0600)]
libxl: Earlier detection of not running on Xen

Detect early on in libxl driver initialization if the driver
should be loaded at all, avoiding needless initialization steps
that only have to be undone later.  While at it, move the
detection to a helper function to improve readability.

After detecting that the driver should be loaded, subsequent
failures such as initializing the log stream, allocating libxl
ctx, etc. should be treated as failure to initialize the driver.

11 years agolibxl: Introduce libxl_domain.[ch]
Jim Fehlig [Fri, 30 Aug 2013 17:18:31 +0000 (11:18 -0600)]
libxl: Introduce libxl_domain.[ch]

Create libxl_domain.[ch] and move all functions operating on
libxlDomainObjPrivate to these files.  This will be useful for
future patches that e.g. add job support for libxlDomainObjPrivate.

11 years agolibxl: Move detection of autoballoon to libxl_conf
Jim Fehlig [Fri, 30 Aug 2013 17:11:08 +0000 (11:11 -0600)]
libxl: Move detection of autoballoon to libxl_conf

Detecting whether or not to autoballoon is configuration related,
so move the code to libxl_conf.

11 years agobuild: fix typo that broke 'make dist'
Eric Blake [Tue, 3 Sep 2013 22:37:06 +0000 (16:37 -0600)]
build: fix typo that broke 'make dist'

Bug introduced in commit 5c6ff42; 'make dist' fails:

make[3]: Entering directory `/home/eblake/libvirt-tmp/build3/examples/python'
make[3]: *** No rule to make target `topoology.py', needed by `distdir'.  Stop.
make[3]: Leaving directory `/home/eblake/libvirt-tmp/build3/examples/python'

* examples/python/Makefile.am (EXTRA_DIST): Spell topology right.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoesx_driver: Resolve Coverity RESOURCE_LEAK on error paths
John Ferlan [Tue, 3 Sep 2013 11:20:34 +0000 (07:20 -0400)]
esx_driver: Resolve Coverity RESOURCE_LEAK on error paths

New Coverity release found a couple of error paths where memory would be
leaked in an error/goto path before being properly handled.

11 years agoesx_vi: Resolve Coverity RESOURCE_LEAK in error path
John Ferlan [Tue, 3 Sep 2013 11:16:07 +0000 (07:16 -0400)]
esx_vi: Resolve Coverity RESOURCE_LEAK in error path

New coverity installation determined that the muliple if condition for
"*Alloc" and "*AppendToList" could fail during AppendToList thus leaking
memory.

11 years agotest_virtlockd.aug.in: Use the correct file
Michal Privoznik [Tue, 3 Sep 2013 14:41:57 +0000 (16:41 +0200)]
test_virtlockd.aug.in: Use the correct file

The test should refer to Virtlockd.lns, which is the name of
the module + lens in virtlockd.aug.

11 years agoexamples: Add script to parse topology from capabilities output
Peter Krempa [Tue, 27 Aug 2013 10:27:21 +0000 (12:27 +0200)]
examples: Add script to parse topology from capabilities output

Add a demo script originally written by Amador Pahim to parse topology
of the host from data provided in the capabilities XML.

11 years agovirsh-console: Avoid using signal() in multithreaded application
Peter Krempa [Thu, 29 Aug 2013 16:30:06 +0000 (18:30 +0200)]
virsh-console: Avoid using signal() in multithreaded application

Man page for signal states:

 "The effects of signal() in a multithreaded process are unspecified."

Switch signal() to sigaction in virsh console code.

11 years agovirsh: Rename vshMakeStdinRaw to vshTTYMakeRaw and move it to virsh.c
Peter Krempa [Thu, 29 Aug 2013 16:15:07 +0000 (18:15 +0200)]
virsh: Rename vshMakeStdinRaw to vshTTYMakeRaw and move it to virsh.c

Move the function to virsh.c to the rest of the TTY managing functions
and change the code so that it mirrors the rest.

11 years agotools: rename console.[ch] to virsh-console.[ch] and fix coding style
Peter Krempa [Mon, 26 Aug 2013 09:53:43 +0000 (11:53 +0200)]
tools: rename console.[ch] to virsh-console.[ch] and fix coding style

11 years agoqemu: Handle huge number of queues correctly
Michal Privoznik [Mon, 2 Sep 2013 14:06:14 +0000 (16:06 +0200)]
qemu: Handle huge number of queues correctly

Currently, kernel supports up to 8 queues for a multiqueue tap device.
However, if user tries to enter a huge number (e.g. one million) the tap
allocation fails, as expected. But what is not expected is the log full
of warnings:

    warning : virFileClose:83 : Tried to close invalid fd 0

The problem is, upon error we iterate over an array of FDs (handlers to
queues) and VIR_FORCE_CLOSE() over each item. However, the array is
pre-filled with zeros. Hence, we repeatedly close stdin. Ouch.
But there's more. The queues allocation is done in virNetDevTapCreate()
which cleans up the FDs in case of error. Then, its caller, the
virNetDevTapCreateInBridgePort() iterates over the FD array and tries to
close them too. And so does qemuNetworkIfaceConnect() and
qemuBuildInterfaceCommandLine().

11 years agoFix leaks in python bindings
Ján Tomko [Tue, 3 Sep 2013 11:12:37 +0000 (13:12 +0200)]
Fix leaks in python bindings

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

11 years agovirsh-domain: Avoid killing ssh transport tunnels when cancelling job
Peter Krempa [Thu, 29 Aug 2013 13:18:20 +0000 (15:18 +0200)]
virsh-domain: Avoid killing ssh transport tunnels when cancelling job

The vshWatchJob function registers a SIGINT handler that is used to
abort the active job and does not terminate virsh. Unfortunately, this
breaks when using the ssh transport as SIGINT is sent to the foreground
process group including the ssh transport processes which terminate.
This breaks the connection and migration is left in a insane state.

With this patch the terminal is modified to ignore key binding that
sends SIGINT and does the handling manually.

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

11 years agovirsh: Remember terminal state when starting and add helpers
Peter Krempa [Thu, 29 Aug 2013 08:36:00 +0000 (10:36 +0200)]
virsh: Remember terminal state when starting and add helpers

This patch adds instrumentation to allow modification of config of the
terminal in virsh and successful reset of the state afterwards.

The added helpers allow to disable receiving of SIGINT when pressing the
key sequence (Ctrl+C usualy). This normally sends SIGINT to the
foreground process group which kills ssh processes used for transport of
the data.

11 years agoVMX: Add cdrom-raw dev type from VMWare Fusion
Doug Goldstein [Tue, 13 Aug 2013 01:55:57 +0000 (20:55 -0500)]
VMX: Add cdrom-raw dev type from VMWare Fusion

According to VMWare's documentation 'cdrom-raw' is an acceptable value
for deviceType for a CD-ROM drive. The documentation states that the VMX
configuration for a CD-ROM deviceType is as follows:

ide|scsi(n):(n).deviceType = "cdrom-raw|atapi-cdrom|cdrom-image"

From the documentation it appears the following is true:
- cdrom-image = Provides the ISO to the VM
- atapi-cdrom = Provides a NEC emulated ATAPI CD-ROM on top of the host
  CD-ROM
- cdrom-raw = Passthru for a host CD-ROM drive. Allows CD-R burning from
  within the guest.

A CD-ROM prior to this patch would always provide an 'atapi-cdrom' is
modeled as:
  <disk type='block' device='cdrom'>
    <source dev='/dev/scd0'/>
    <target dev='hda' bus='ide'/>
    <address type='drive' controller='0' bus='0' target='0' unit='0'/>
  </disk>

This patch allows the 'device' attribute to be set to 'lun' for a raw
acccess CD-ROM such as:
  <disk type='block' device='lun'>
    <source dev='/dev/scd0'/>
    <target dev='hda' bus='ide'/>
    <address type='drive' controller='0' bus='0' target='0' unit='0'/>
  </disk>

11 years agoVMX: Some serial ports are not actually connected
Doug Goldstein [Mon, 12 Aug 2013 22:29:40 +0000 (17:29 -0500)]
VMX: Some serial ports are not actually connected

Sometimes a serial port might not be actually wired to a device when the
user does not have the VM powered on and we should not consider this a
fatal error.

11 years agoqemu: Support virtio-mmio transport for virtio on ARM
Cole Robinson [Thu, 1 Aug 2013 01:40:35 +0000 (21:40 -0400)]
qemu: Support virtio-mmio transport for virtio on ARM

Starting with qemu 1.6, the qemu-system-arm vexpress-a9 model has a
hardcoded virtio-mmio transport which enables attaching all virtio
devices.

On the command line, we have to use virtio-XXX-device rather than
virtio-XXX-pci, thankfully s390 already set the precedent here so
it's fairly straight forward.

At the XML level, this adds a new device address type virtio-mmio.
The controller and addressing don't have any subelements at the
moment because we they aren't needed for this usecase, but could
be added later if needed.

Add a test case for an ARM guest with one of every virtio device
enabled.

11 years agoqemu: Fix networking for ARM guests
Cole Robinson [Tue, 30 Jul 2013 22:51:30 +0000 (18:51 -0400)]
qemu: Fix networking for ARM guests

Similar to the chardev bit, ARM boards depend on the old style '-net nic'
for actually instantiating net devices. But we can't block out
-netdev altogether since it's needed for upcoming virtio support.

And add tests for working ARM XML with console, disk, and networking.

11 years agodomain_conf: Add disk bus=sd, wire it up for qemu
Cole Robinson [Wed, 31 Jul 2013 13:00:26 +0000 (09:00 -0400)]
domain_conf: Add disk bus=sd, wire it up for qemu

This corresponds to '-sd' and '-drive if=sd' on the qemu command line.
Needed for many ARM boards which don't provide any other way to
pass in storage.

11 years agoqemu: Don't try to allocate PCI addresses for ARM
Cole Robinson [Tue, 30 Jul 2013 22:56:15 +0000 (18:56 -0400)]
qemu: Don't try to allocate PCI addresses for ARM

11 years agoqemu: Fix specifying char devs for ARM
Cole Robinson [Tue, 30 Jul 2013 21:49:11 +0000 (17:49 -0400)]
qemu: Fix specifying char devs for ARM

QEMU ARM boards don't give us any way to explicitly wire in
a -chardev, so use the old style -serial options.

Unfortunately this isn't as simple as just turning off the CHARDEV flag
for qemu-system-arm, as upcoming virtio support _will_ use device/chardev.

11 years agoqemu: Don't add default memballoon device on ARM
Cole Robinson [Tue, 30 Jul 2013 19:41:14 +0000 (15:41 -0400)]
qemu: Don't add default memballoon device on ARM

And add test cases for a basic working ARM guest.

11 years agodomain_conf: Add default memballoon in PostParse callbacks
Cole Robinson [Sat, 17 Aug 2013 00:33:23 +0000 (20:33 -0400)]
domain_conf: Add default memballoon in PostParse callbacks

This should be a no-op change for now.

11 years agoqemu: Set QEMU_AUDIO_DRV=none with -nographic
Cole Robinson [Sat, 17 Aug 2013 19:30:47 +0000 (15:30 -0400)]
qemu: Set QEMU_AUDIO_DRV=none with -nographic

On my machine, a guest fails to boot if it has a sound card, but not
graphical device/display is configured, because pulseaudio fails to
initialize since it can't access $HOME.

A workaround is removing the audio device, however on ARM boards there
isn't any option to do that, so -nographic always fails.

Set QEMU_AUDIO_DRV=none if no <graphics> are configured. Unfortunately
this has massive test suite fallout.

Add a qemu.conf parameter nographics_allow_host_audio, that if enabled
will pass through QEMU_AUDIO_DRV from sysconfig (similar to
vnc_allow_host_audio)

11 years agoPass AM_LDFLAGS to driver modules too
Guido Günther [Sun, 1 Sep 2013 06:50:58 +0000 (08:50 +0200)]
Pass AM_LDFLAGS to driver modules too

This gives us a RO got, otherwise Debian's lintian complains:

W: libvirt-bin: hardening-no-relro usr/lib/libvirt/connection-driver/libvirt_driver_qemu.so
W: libvirt-bin: hardening-no-relro usr/lib/libvirt/connection-driver/libvirt_driver_storage.so
W: libvirt-bin: hardening-no-relro usr/lib/libvirt/connection-driver/libvirt_driver_uml.so
W: libvirt-bin: hardening-no-relro usr/lib/libvirt/connection-driver/libvirt_driver_vbox.so
W: libvirt-bin: hardening-no-relro usr/lib/libvirt/connection-driver/libvirt_driver_xen.so
W: libvirt-bin: hardening-no-relro usr/lib/libvirt/connection-driver/libvirt_driver_nwfilter.so
W: libvirt-bin: hardening-no-relro usr/lib/libvirt/connection-driver/libvirt_driver_storage.so
W: libvirt-bin: hardening-no-relro usr/lib/libvirt/connection-driver/libvirt_driver_uml.so
W: libvirt-sanlock: hardening-no-relro usr/lib/libvirt/lock-driver/sanlock.so

11 years agoFix AM_LDFLAGS typo
Guido Günther [Sun, 1 Sep 2013 07:53:03 +0000 (09:53 +0200)]
Fix AM_LDFLAGS typo

11 years agoqemu: Support setting the 'removable' flag for USB disks
Fred A. Kemp [Fri, 23 Aug 2013 10:38:11 +0000 (12:38 +0200)]
qemu: Support setting the 'removable' flag for USB disks

Add an attribute named 'removable' to the 'target' element of disks,
which controls the removable flag. For instance, on a Linux guest it
controls the value of /sys/block/$dev/removable. This option is only
valid for USB disks (i.e. bus='usb'), and its default value is 'off',
which is the same behaviour as before.

To achieve this, 'removable=on' (or 'off') is appended to the '-device
usb-storage' parameter sent to qemu when adding a USB disk via
'-disk'. A capability flag QEMU_CAPS_USB_STORAGE_REMOVABLE was added
to keep track if this option is supported by the qemu version used.

Bug: https://bugzilla.redhat.com/show_bug.cgi?id=922495
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
11 years agoqemu: Add capability flag for usb-storage
Fred A. Kemp [Fri, 23 Aug 2013 10:38:10 +0000 (12:38 +0200)]
qemu: Add capability flag for usb-storage

Allow use of the usb-storage device only if the new capability flag
QEMU_CAPS_DEVICE_USB_STORAGE is set, which it is for qemu(-kvm)
versions >= 0.12.1.2-rhel62-beta.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
11 years agoVMX: Create virVMXFormatDisk() from HD and CD-ROM
Doug Goldstein [Wed, 28 Aug 2013 18:37:06 +0000 (13:37 -0500)]
VMX: Create virVMXFormatDisk() from HD and CD-ROM

virVMXFormatHardDisk() and virVMXFormatCDROM() duplicated a lot of code
from each other and made a lot of nested if checks to build each part of
the VMX file. This hopefully simplifies the code path while combining
the two functions with no net difference.

11 years agoRelease of libvirt-1.1.2
Daniel Veillard [Mon, 2 Sep 2013 01:47:37 +0000 (09:47 +0800)]
Release of libvirt-1.1.2

* configure.ac docs/news.html.in libvirt.spec.in: update for the release
* po/*.po*: merged new localizations and regenerated

11 years agoqemu_hotplug: Resolve DEADCODE coverity error
John Ferlan [Sat, 31 Aug 2013 11:06:38 +0000 (07:06 -0400)]
qemu_hotplug: Resolve DEADCODE coverity error

Remove unused 'cgroup' variable in qemuDomainAttachDeviceDiskLive() to
resolve coverity DEADCODE complaint

11 years agoFix memory leak in cmdAttachDisk
Hongwei Bi [Sat, 31 Aug 2013 03:39:35 +0000 (11:39 +0800)]
Fix memory leak in cmdAttachDisk

When virBufferError is ok in cmdAttachDisk, the latter
should 'goto cleanup', instead of returning a false to
prevent memory leaking.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: fix virtlockd file distribution
Eric Blake [Sat, 31 Aug 2013 02:16:06 +0000 (20:16 -0600)]
build: fix virtlockd file distribution

Since virtlockd is only built when libvirtd is built, we should
not install its auxiliary files unconditionally.  This solves
two failures.  1. 'make distcheck' complains:

rm -f Makefile
ERROR: files left in build directory after distclean:
./src/virtlockd.8

2. './autobuild.sh' complains:

Checking for unpackaged file(s): /usr/lib/rpm/check-files
/home/eblake/rpmbuild/BUILDROOT/mingw-libvirt-1.1.1-1.fc19.eblake1377879911.x86_64
error: Installed (but unpackaged) file(s) found:
   /usr/i686-w64-mingw32/sys-root/mingw/etc/libvirt/virtlockd.conf

/usr/i686-w64-mingw32/sys-root/mingw/share/augeas/lenses/tests/test_virtlockd.aug
   /usr/i686-w64-mingw32/sys-root/mingw/share/augeas/lenses/virtlockd.aug
   /usr/i686-w64-mingw32/sys-root/mingw/share/man/man8/virtlockd.8
   /usr/x86_64-w64-mingw32/sys-root/mingw/etc/libvirt/virtlockd.conf

/usr/x86_64-w64-mingw32/sys-root/mingw/share/augeas/lenses/tests/test_virtlockd.aug
   /usr/x86_64-w64-mingw32/sys-root/mingw/share/augeas/lenses/virtlockd.aug
   /usr/x86_64-w64-mingw32/sys-root/mingw/share/man/man8/virtlockd.8

* src/Makefile.am (CLEANFILES): Add virtlockd.8.
(man8_MANS, conf_DATA, augeas_DATA, augeastest_DATA): Only install
virtlockd files when daemon is built.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: shipped files must not depend on BUILT_SOURCES
Eric Blake [Fri, 30 Aug 2013 22:05:43 +0000 (16:05 -0600)]
build: shipped files must not depend on BUILT_SOURCES

'make distcheck' was failing with:
make[3]: Entering directory `/home/eblake/libvirt-tmp2/libvirt-1.1.1/_build/docs'
perl ../../docs/genaclperms.pl ../../src/access/viraccessperm.h > ../../docs/aclperms.htmlinc
/bin/sh: ../../docs/aclperms.htmlinc: Permission denied

when simulating the case of a user doing a VPATH build from a
read-only source tree.  The culprit?  BUILT_SOURCES are _always_
built, and so must NOT be built into srcdir and need not be part
of the tarball.  On the other hand, shipped files must never
depend on files in the builddir.  While it would be possible to
fix the problem by generating aclperms.htmlinc into builddir,
we then have the problem that we ship acl.html - we'd have to
rejigger a lot of things to not ship pre-built html.  So this
patch goes the other direction - we don't need BUILT_SOURCES,
but instead ensure that we have proper dependencies so that
all files in srcdir are up-to-date at the time the tarball is
created.  And because we ship html files in the tarball, that
implies we don't expect users to be able to rebuild them, so
we must not clean any files that would trigger a rebuild except
under the maintainer rules.

* docs/Makefile.am (BUILT_SOURCES): Delete.
(CLEANFILES): Downgrade aclperms.htmlinc cleanup...
(maintainer-clean-local): ...and move hvsupport.html.in...
(MAINTAINERCLEANFILES): ...to a maintainer action.
(hvsupport.html.in): Write into srcdir.
(hvsupport.html): Ensure files are built in order.
(aclperms.htmlinc): Honor silent make.
(EXTRA_DIST): Ship aclperms.htmlinc.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: fix 'make distcheck' out of the box
Eric Blake [Fri, 30 Aug 2013 21:03:52 +0000 (15:03 -0600)]
build: fix 'make distcheck' out of the box

With the 1.1.1 tarball, if a user does 'make && make distcheck',
things pass, but if they do 'make distcheck' after 'make clean',
there is an odd failure:

  GEN      ../../docs/devhelp/index.html
I/O error : Permission denied
I/O error : Permission denied
runtime error: file ../../docs/devhelp/devhelp.xsl line 43 element document
xsltDocumentElem: unable to save to ../../docs/devhelp/libvirt-virterror.html
I/O error : Permission denied
I/O error : Permission denied

This implies that the rules for 'make dist' are missing a
dependency - the generated documentation needs to be up-to-date
before creating the tarball, or else the tarball will be missing
files, where the end user will end up trying to rebuild files in
srcdir, and that fails when srcdir is read-only.

1.1.1 plus this patch now works without issues (other issues have
crept in to 1.1.2-rc1 that prevent 'make distcheck' from working,
but those will be cleaned up in later patches).

* docs/Makefile.am (dist-local): New dependency.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: only create virt-login-shell for lxc builds
Eric Blake [Fri, 30 Aug 2013 19:58:59 +0000 (13:58 -0600)]
build: only create virt-login-shell for lxc builds

I noticed from an ./autobuild.sh run that we were installing a
virt-login-shell.exe binary when cross-building for mingw,
even though such a binary is necessarily worthless since the
code depends on lxc which is a Linux-only concept.

* tools/Makefile.am (conf_DATA, bin_PROGRAMS, dist_man1_MANS):
Make virt-login-shell installation conditional.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoqemu: Only setup vhost if virtType == "kvm"
Cole Robinson [Thu, 1 Aug 2013 01:37:40 +0000 (21:37 -0400)]
qemu: Only setup vhost if virtType == "kvm"

vhost only works in KVM mode at the moment, and is infact compiled
out if the emulator is built for non-native architecture. While it
may work at some point in the future for plain qemu, for now it's
just noise on the command line (and which contributes to arm cli
breakage).

11 years agoProcess virtlockd.conf instead of libvirtd.conf
Guido Günther [Fri, 30 Aug 2013 10:58:08 +0000 (12:58 +0200)]
Process virtlockd.conf instead of libvirtd.conf

11 years agoChange way we fake dbus method calls
Daniel P. Berrange [Fri, 30 Aug 2013 13:10:52 +0000 (14:10 +0100)]
Change way we fake dbus method calls

Ubuntu libdbus.so links with -Bsymbolic-functions, which means
that we can only LD_PRELOAD functions that we directly call.
Functions which libdbus.so calls internally can not be replaced.
Thus we cannot use dbus_message_new_error or dbus_message_new_method_return

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agorandom: don't mix RAND_MAX with random_r
Eric Blake [Thu, 29 Aug 2013 23:03:34 +0000 (17:03 -0600)]
random: don't mix RAND_MAX with random_r

FreeBSD 10 recently changed their definition of RAND_MAX, to try
and cover the fact that their evenly distributed results of rand()
really are a smaller range than a full power of 2.  As a result,
I did some investigation, and learned:

1. POSIX requires random() to be evenly distributed across exactly
31 bits.  glibc also guarantees this for rand(), but the two are
unrelated, and POSIX only associates RAND_MAX with rand().
Avoiding RAND_MAX altogether thus avoids a build failure on
FreeBSD 10.

2. Concatenating random bits from a PRNG will NOT provide uniform
coverage over the larger value UNLESS the period of the original
PRNG is at least as large as the number of bits being concatenated.
Simple example: suppose that RAND_MAX were 1 with a period of 2**1
(which means that the PRNG merely alternates between 0 and 1).
Concatenating two successive rand() calls would then invariably
result in 01 or 10, which is a rather non-uniform distribution
(00 and 11 are impossible) and an even worse period (2**0, since
our second attempt will get the same number as our first attempt).
But a RAND_MAX of 1 with a period of 2**2 (alternating between
0, 1, 1, 0) provides sane coverage of all four values, if properly
tempered.  (Back-to-back calls would still only see half the values
if we don't do some tempering).  We therefore want to guarantee a
period of at least 2**64, preferably larger (as a tempering factor);
POSIX only makes this guarantee for random() with 256 bytes of info.

* src/util/virrandom.c (virRandomBits): Use constants that are
accurate for the PRNG we are using, not an unrelated PRNG.
(randomState): Ensure the period of our PRNG exceeds our usage.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agovirsh-domain: rename print_job_progress to vshPrintJobProgress
Peter Krempa [Mon, 26 Aug 2013 10:31:51 +0000 (12:31 +0200)]
virsh-domain: rename print_job_progress to vshPrintJobProgress

11 years agosecurity: provide supplemental groups even when parsing label (CVE-2013-4291)
Eric Blake [Fri, 23 Aug 2013 15:30:42 +0000 (09:30 -0600)]
security: provide supplemental groups even when parsing label (CVE-2013-4291)

Commit 29fe5d7 (released in 1.1.1) introduced a latent problem
for any caller of virSecurityManagerSetProcessLabel and where
the domain already had a uid:gid label to be parsed.  Such a
setup would collect the list of supplementary groups during
virSecurityManagerPreFork, but then ignores that information,
and thus fails to call setgroups() to adjust the supplementary
groups of the process.

Upstream does not use virSecurityManagerSetProcessLabel for
qemu (it uses virSecurityManagerSetChildProcessLabel instead),
so this problem remained latent until backporting the initial
commit into v0.10.2-maint (commit c061ff5, released in 0.10.2.7),
where virSecurityManagerSetChildProcessLabel has not been
backported.  As a result of using a different code path in the
backport, attempts to start a qemu domain that runs as qemu:qemu
will end up with supplementary groups unchanged from the libvirtd
parent process, rather than the desired supplementary groups of
the qemu user.  This can lead to failure to start a domain
(typical Fedora setup assigns user 107 'qemu' to both group 107
'qemu' and group 36 'kvm', so a disk image that is only readable
under kvm group rights is locked out).  Worse, it is a security
hole (the qemu process will inherit supplemental group rights
from the parent libvirtd process, which means it has access
rights to files owned by group 0 even when such files should
not normally be visible to user qemu).

LXC does not use the DAC security driver, so it is not vulnerable
at this time.  Still, it is better to plug the latent hole on
the master branch first, before cherry-picking it to the only
vulnerable branch v0.10.2-maint.

* src/security/security_dac.c (virSecurityDACGetIds): Always populate
groups and ngroups, rather than only when no label is parsed.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoProhibit unbounded arrays in XDR protocols
Daniel P. Berrange [Mon, 19 Aug 2013 14:17:20 +0000 (15:17 +0100)]
Prohibit unbounded arrays in XDR protocols

The use of <> is a security issue for RPC parameters, since a
malicious client can set a huge array length causing arbitrary
memory allocation in the daemon.

It is also a robustness issue for RPC return values, because if
the stream is corrupted, it can cause the client to also allocate
arbitrary memory.

Use a syntax-check rule to prohibit any use of <>

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd bounds checking on virConnectListAllSecrets RPC call
Daniel P. Berrange [Mon, 19 Aug 2013 13:49:57 +0000 (14:49 +0100)]
Add bounds checking on virConnectListAllSecrets RPC call

The return values for the virConnectListAllSecrets call were not
bounds checked. This is a robustness issue for clients if
something where to cause corruption of the RPC stream data.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd bounds checking on virConnectListAllNWFilters RPC call
Daniel P. Berrange [Mon, 19 Aug 2013 13:47:22 +0000 (14:47 +0100)]
Add bounds checking on virConnectListAllNWFilters RPC call

The return values for the virConnectListAllNWFilters call were not
bounds checked. This is a robustness issue for clients if
something where to cause corruption of the RPC stream data.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd bounds checking on virConnectListAllNodeDevices RPC call
Daniel P. Berrange [Mon, 19 Aug 2013 13:44:52 +0000 (14:44 +0100)]
Add bounds checking on virConnectListAllNodeDevices RPC call

The return values for the virConnectListAllNodeDevices call were not
bounds checked. This is a robustness issue for clients if
something where to cause corruption of the RPC stream data.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd bounds checking on virConnectListAllInterfaces RPC call
Daniel P. Berrange [Mon, 19 Aug 2013 13:41:56 +0000 (14:41 +0100)]
Add bounds checking on virConnectListAllInterfaces RPC call

The return values for the virConnectListAllInterfaces call were not
bounds checked. This is a robustness issue for clients if
something where to cause corruption of the RPC stream data.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd bounds checking on virConnectListAllNetworks RPC call
Daniel P. Berrange [Mon, 19 Aug 2013 13:37:29 +0000 (14:37 +0100)]
Add bounds checking on virConnectListAllNetworks RPC call

The return values for the virConnectListAllNetworks call were not
bounds checked. This is a robustness issue for clients if
something where to cause corruption of the RPC stream data.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd bounds checking on virStoragePoolListAllVolumes RPC call
Daniel P. Berrange [Mon, 19 Aug 2013 13:33:58 +0000 (14:33 +0100)]
Add bounds checking on virStoragePoolListAllVolumes RPC call

The return values for the virStoragePoolListAllVolumes call were not
bounds checked. This is a robustness issue for clients if
something where to cause corruption of the RPC stream data.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd bounds checking on virConnectListAllStoragePools RPC call
Daniel P. Berrange [Mon, 19 Aug 2013 13:27:56 +0000 (14:27 +0100)]
Add bounds checking on virConnectListAllStoragePools RPC call

The return values for the virConnectListAllStoragePools call were not
bounds checked. This is a robustness issue for clients if
something where to cause corruption of the RPC stream data.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd bounds checking on virConnectListAllDomains RPC call
Daniel P. Berrange [Mon, 19 Aug 2013 13:23:31 +0000 (14:23 +0100)]
Add bounds checking on virConnectListAllDomains RPC call

The return values for the virConnectListAllDomains call were not
bounds checked. This is a robustness issue for clients if
something where to cause corruption of the RPC stream data.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd bounds checking on virDomain{SnapshotListAllChildren,ListAllSnapshots} RPC calls
Daniel P. Berrange [Mon, 19 Aug 2013 11:55:53 +0000 (12:55 +0100)]
Add bounds checking on virDomain{SnapshotListAllChildren,ListAllSnapshots} RPC calls

The return values for the virDomain{SnapshotListAllChildren,ListAllSnapshots}
calls were not bounds checked. This is a robustness issue for clients if
something where to cause corruption of the RPC stream data.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd bounds checking on virDomainGetJobStats RPC call
Daniel P. Berrange [Mon, 19 Aug 2013 11:42:31 +0000 (12:42 +0100)]
Add bounds checking on virDomainGetJobStats RPC call

The return values for the virDomainGetJobStats call were not
bounds checked. This is a robustness issue for clients if
something where to cause corruption of the RPC stream data.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd bounds checking on virDomainMigrate*Params RPC calls (CVE-2013-4292)
Daniel P. Berrange [Mon, 19 Aug 2013 13:55:21 +0000 (14:55 +0100)]
Add bounds checking on virDomainMigrate*Params RPC calls (CVE-2013-4292)

The parameters for the virDomainMigrate*Params RPC calls were
not bounds checks, meaning a malicious client can cause libvirtd
to consume arbitrary memory

This issue was introduced in the 1.1.0 release of libvirt

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agopython: Fix a PyList usage mistake
Guan Qiang [Thu, 29 Aug 2013 11:02:25 +0000 (19:02 +0800)]
python: Fix a PyList usage mistake

Fix PyList usage mistake in Function libvirt_lxc_virDomainLxcOpenNamespace.

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

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoautogen.sh: Correctly detect .git as a file
Michal Privoznik [Thu, 29 Aug 2013 11:19:45 +0000 (13:19 +0200)]
autogen.sh: Correctly detect .git as a file

One of my previous patches 5cfe0d37cd0be tried to handle the case when
libvirt is a submodule of another project. In that case, the .git is
just a link to the parent .git directory (which the autogen.sh script
didn't count on). The fix was missing 'test' though.

11 years agobridge_driver: Introduce networkObjFromNetwork
Michal Privoznik [Wed, 28 Aug 2013 12:34:34 +0000 (14:34 +0200)]
bridge_driver: Introduce networkObjFromNetwork

Similarly to qemu_driver.c, we can join often repeating code of looking
up network into one function: networkObjFromNetwork.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoqemu_hotplug: Fix whitespace around addition in argument
Peter Krempa [Wed, 28 Aug 2013 12:56:21 +0000 (14:56 +0200)]
qemu_hotplug: Fix whitespace around addition in argument

11 years agoqemu: Remove hostdev entry when freeing the depending network entry
Peter Krempa [Tue, 27 Aug 2013 17:06:18 +0000 (19:06 +0200)]
qemu: Remove hostdev entry when freeing the depending network entry

When using a <interface type="network"> that points to a network with
hostdev forwarding mode a hostdev alias is created for the network. This
allias is inserted into the hostdev list, but is backed with a part of
the network object that it is connected to.

When a VM is being stopped qemuProcessStop() calls
networkReleaseActualDevice() which eventually frees the memory for the
hostdev object. Afterwards when the domain definition is being freed by
virDomainDefFree() an invalid pointer is accessed by
virDomainHostdevDefFree() and may cause a crash of the daemon.

This patch removes the entry in the hostdev list before freeing the
depending memory to avoid this issue.

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

11 years agovirsh: detect programming errors with option parsing
Eric Blake [Fri, 16 Aug 2013 22:07:31 +0000 (16:07 -0600)]
virsh: detect programming errors with option parsing

Noticed while reviewing another patch that had an accidental
mismatch due to refactoring.  An audit of the code showed that
very few callers of vshCommandOpt were expecting a return of
-2, indicating programmer error, and of those that DID check,
they just propagated that status to yet another caller that
did not check.  Fix this by making the code blatantly warn
the programmer, rather than silently ignoring it and possibly
doing the wrong thing downstream.

I know that we frown on assert()/abort() inside libvirtd
(libraries should NEVER kill the program that linked them),
but as virsh is an app rather than the library, and as this
is not the first use of assert() in virsh, I think this
approach is okay.

* tools/virsh.h (vshCommandOpt): Drop declaration.
* tools/virsh.c (vshCommandOpt): Make static, and add a
parameter.  Abort on programmer errors rather than making callers
repeat that logic.
(vshCommandOptInt, vshCommandOptUInt, vshCommandOptUL)
(vshCommandOptString, vshCommandOptStringReq)
(vshCommandOptLongLong, vshCommandOptULongLong)
(vshCommandOptBool): Adjust callers.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agovirt-sanlock-cleanup; Fix augtool usage
Jiri Denemark [Wed, 28 Aug 2013 11:50:10 +0000 (13:50 +0200)]
virt-sanlock-cleanup; Fix augtool usage

Surprisingly, augtool get (or print) returns "path = value" while we are
only interested in the value. We need to remove the "path = " part from
the augtool's output. The following is an example of the augtool command
as used in virt-sanlock-cleanup script:

$ augtool get /files/etc/libvirt/qemu-sanlock.conf/disk_lease_dir
/files/etc/libvirt/qemu-sanlock.conf/disk_lease_dir = /var/lib/libvirt/sanlock

11 years agovirsh: Fix debugging
Martin Kletzander [Tue, 27 Aug 2013 11:19:24 +0000 (13:19 +0200)]
virsh: Fix debugging

Commit a0b6a36f "fixed" what abfff210 broke (URI precedence), but
there was still one more thing missing to fix.  When using virsh
parameters to setup debugging, those weren't honored, because at the
time debugging was initializing, arguments weren't parsed yet.  To
make ewerything work as expected, we need to initialize the debugging
twice, once before debugging (so we can debug option parsing properly)
and then again after these options are parsed.

As a side effect, this patch also fixes a leak when virsh is ran with
multiple '-l' parameters.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agovirsh-pool.c: Don't jump over variable declaration
Michal Privoznik [Wed, 28 Aug 2013 07:25:59 +0000 (09:25 +0200)]
virsh-pool.c: Don't jump over variable declaration

Since 785ff34bf8 we are using the outputStr variable in cleanup label.
However, there is a possibility to jump to the label before the variable
has been declared:

virsh-pool.c: In function 'cmdPoolList':
virsh-pool.c:1121:25: error: jump skips variable initialization [-Werror=jump-misses-init]
                         goto asprintf_failure;
                         ^
virsh-pool.c:1308:1: note: label 'asprintf_failure' defined here
 asprintf_failure:
 ^
virsh-pool.c:1267:11: note: 'outputStr' declared here
     char *outputStr = NULL;

11 years agovirsh: free the caps list properly if one of them is invalid
Ján Tomko [Tue, 27 Aug 2013 11:47:57 +0000 (13:47 +0200)]
virsh: free the caps list properly if one of them is invalid

VIR_FREE(caps) is not enough to free an array allocated
by vshStringToArray.

==17== 4 bytes in 1 blocks are definitely lost in loss record 4 of 728
==17==    by 0x4EFFC44: virStrdup (virstring.c:554)
==17==    by 0x128B10: _vshStrdup (virsh.c:125)
==17==    by 0x129164: vshStringToArray (virsh.c:218)
==17==    by 0x157BB3: cmdNodeListDevices (virsh-nodedev.c:409)

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

11 years agovirsh: free the formatting string when listing pool details
Ján Tomko [Tue, 27 Aug 2013 11:34:09 +0000 (13:34 +0200)]
virsh: free the formatting string when listing pool details

==23== 41 bytes in 1 blocks are definitely lost in loss record 626 of 727
==23==    by 0x4F0099F: virAsprintfInternal (virstring.c:358)
==23==    by 0x15D2C9: cmdPoolList (virsh-pool.c:1268)

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

11 years agovirsh: free the list from ListAll APIs even for 0 items
Ján Tomko [Tue, 27 Aug 2013 11:27:50 +0000 (13:27 +0200)]
virsh: free the list from ListAll APIs even for 0 items

virsh secret-list leak when no secrets are defined:

==27== 8 bytes in 1 blocks are definitely lost in loss record 6 of 726
==27==    by 0x4E941DD: virAllocN (viralloc.c:183)
==27==    by 0x5037F1A: remoteConnectListAllSecrets (remote_driver.c:3076)
==27==    by 0x5004EC6: virConnectListAllSecrets (libvirt.c:16298)
==27==    by 0x15F813: vshSecretListCollect (virsh-secret.c:397)
==27==    by 0x15F0E1: cmdSecretList (virsh-secret.c:532)

And so do some other *-list commands.

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

11 years agovirsh: free messages after logging them to a file
Ján Tomko [Tue, 27 Aug 2013 11:07:27 +0000 (13:07 +0200)]
virsh: free messages after logging them to a file

The messages were only freed on error.

==12== 1,100 bytes in 1 blocks are definitely lost in loss record 698 of 729
==12==    by 0x4E98C22: virBufferAsprintf (virbuffer.c:294)
==12==    by 0x12C950: vshOutputLogFile (virsh.c:2440)
==12==    by 0x12880B: vshError (virsh.c:2254)
==12==    by 0x131957: vshCommandOptDomainBy (virsh-domain.c:109)
==12==    by 0x14253E: cmdStart (virsh-domain.c:3333)

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

11 years agoTest network update XML parsing
Ján Tomko [Mon, 29 Jul 2013 15:17:47 +0000 (17:17 +0200)]
Test network update XML parsing

Add checks for updating sections of network definition via
virNetworkDefUpdateSection.

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

11 years agoRemove the space before the slash in network XML
Ján Tomko [Tue, 30 Jul 2013 12:36:08 +0000 (14:36 +0200)]
Remove the space before the slash in network XML

This matches the style we use elsewhere and allows
nat-network-dns-srv-record{,-minimal}.xml to be tested in
network XML -> XML test.

11 years agoBuild QEMU command line for pcihole64
Ján Tomko [Mon, 12 Aug 2013 11:48:34 +0000 (13:48 +0200)]
Build QEMU command line for pcihole64

QEMU commit 3984890 introduced the "pci-hole64-size" property,
to i440FX-pcihost and q35-pcihost with a default setting of 2 GB.

Translate <pcihole64>x<pcihole64/> to:
-global q35-pcihost.pci-hole64-size=x for q35 machines and
-global i440FX-pcihost.pci-hole64-size=x for i440FX-based machines.

Error out on other machine types or if the size was specified
but the pcihost device lacks 'pci-hole64-size' property.

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

11 years agoAdd pcihole64 element to root PCI controllers
Ján Tomko [Mon, 12 Aug 2013 11:39:04 +0000 (13:39 +0200)]
Add pcihole64 element to root PCI controllers

<controller type='pci' index='0' model='pci-root'>
  <pcihole64 unit='KiB'>1048576</pcihole64>
</controller>

It can be used to adjust (or disable) the size of the 64-bit
PCI hole. The size attribute is in kilobytes (different unit
can be specified on input), but it gets rounded up to
the nearest GB by QEMU.

Disabling it will be needed for guests that crash with the
64-bit PCI hole (like Windows XP), see:
https://bugzilla.redhat.com/show_bug.cgi?id=990418