]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
13 years agoxen: Don't crash when we fail to init caps
Guido Günther [Fri, 20 Jan 2012 07:56:39 +0000 (08:56 +0100)]
xen: Don't crash when we fail to init caps

by dereferencing a NULL pointer in the call to
virNodeSuspendGetTargetMask.

13 years agoxen: properly report out of memory when hvm_type is too small
Guido Günther [Fri, 20 Jan 2012 16:27:08 +0000 (17:27 +0100)]
xen: properly report out of memory when hvm_type is too small

13 years agovirsh: let domif-{get,set}link take target name
Taku Izumi [Fri, 20 Jan 2012 06:30:47 +0000 (15:30 +0900)]
virsh: let domif-{get,set}link take target name

Other virsh domifXXX commands can accept target name
as a parameter to specify interface. From viewpoint of
consistency, virsh domif-getlink command should accept
target name as a parameter. This patch achieves this.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
13 years agomaint: cleanup qemu capabilities
Eric Blake [Fri, 20 Jan 2012 23:30:44 +0000 (16:30 -0700)]
maint: cleanup qemu capabilities

Fix inconsistent whitespace and long lines.

* src/qemu/qemu_capabilities.h (qemuCapsFlags): Improve formatting.

13 years agomaint: enforce use of _LAST marker
Eric Blake [Fri, 20 Jan 2012 21:00:58 +0000 (14:00 -0700)]
maint: enforce use of _LAST marker

When converting a linear enum to a string, we have checks in
place in the VIR_ENUM_IMPL macro to ensure that there is one
string for every value, which lets us quickly flag if a user
added a value but forgot to add a counterpart string.  However,
this only works if we use the _LAST marker.

* cfg.mk (sc_require_enum_last_marker): New syntax check.
* src/conf/domain_conf.h (virDomainSnapshotState): Add new marker.
* src/conf/domain_conf.c (virDomainSnapshotState): Fix offender.
* src/qemu/qemu_monitor_json.c (qemuMonitorWatchdogAction)
(qemuMonitorIOErrorAction, qemuMonitorGraphicsAddressFamily):
Likewise.
* src/util/virtypedparam.c (virTypedParameter): Likewise.

13 years agoAPI: make declaration of _LAST enum values conditional
Eric Blake [Fri, 20 Jan 2012 18:43:28 +0000 (11:43 -0700)]
API: make declaration of _LAST enum values conditional

Although this is a public API break, it only affects users that
were compiling against *_LAST values, and can be trivially
worked around without impacting compilation against older
headers, by the user defining VIR_ENUM_SENTINELS before using
libvirt.h.  It is not an ABI break, since enum values do not
appear as .so entry points.  Meanwhile, it prevents users from
using non-stable enum values without explicitly acknowledging
the risk of doing so.

See this list discussion:
https://www.redhat.com/archives/libvir-list/2012-January/msg00804.html

* include/libvirt/libvirt.h.in: Hide all sentinels behind
LIBVIRT_ENUM_SENTINELS, and add missing sentinels.
* src/internal.h (VIR_DEPRECATED): Allow inclusion after
libvirt.h.
(LIBVIRT_ENUM_SENTINELS): Expose sentinels internally.
* daemon/libvirtd.h: Use the sentinels.
* src/remote/remote_protocol.x (includes): Don't expose sentinels.
* python/generator.py (enum): Likewise.
* tests/cputest.c (cpuTestCompResStr): Silence compiler warning.
* tools/virsh.c (vshDomainStateReasonToString)
(vshDomainControlStateToString): Likewise.

13 years agoerror: drop old-style error reporting
Eric Blake [Mon, 28 Nov 2011 23:13:40 +0000 (16:13 -0700)]
error: drop old-style error reporting

While we still don't want to enable gcc's new -Wformat-literal
warning, I found a rather easy case where the warning could be
reduced, by getting rid of obsolete error-reporting practices.
This is the last place where we were passing the (unused) net
and conn arguments for constructing an error.

* src/util/virterror_internal.h (virErrorMsg): Delete prototype.
(virReportError): Delete macro.
* src/util/virterror.c (virErrorMsg): Make static.
* src/libvirt_private.syms (virterror_internal.h): Drop export.
* src/util/conf.c (virConfError): Convert to macro.
(virConfErrorHelper): New function, and adjust error calls.
* src/xen/xen_hypervisor.c (virXenErrorFunc): Delete.
(xenHypervisorGetSchedulerType)
(xenHypervisorGetSchedulerParameters)
(xenHypervisorSetSchedulerParameters)
(xenHypervisorDomainBlockStats)
(xenHypervisorDomainInterfaceStats)
(xenHypervisorDomainGetOSType)
(xenHypervisorNodeGetCellsFreeMemory, xenHypervisorGetVcpus):
Update callers.

13 years agoutil: use new virTypedParameter helpers
Eric Blake [Sat, 7 Jan 2012 12:47:43 +0000 (05:47 -0700)]
util: use new virTypedParameter helpers

Reusing common code makes things smaller; it also buys us some
additional safety, such as now rejecting duplicate parameters
during a set operation.

* src/qemu/qemu_driver.c (qemuDomainSetBlkioParameters)
(qemuDomainSetMemoryParameters, qemuDomainSetNumaParameters)
(qemuSetSchedulerParametersFlags)
(qemuDomainSetInterfaceParameters, qemuDomainSetBlockIoTune)
(qemuDomainGetBlkioParameters, qemuDomainGetMemoryParameters)
(qemuDomainGetNumaParameters, qemuGetSchedulerParametersFlags)
(qemuDomainBlockStatsFlags, qemuDomainGetInterfaceParameters)
(qemuDomainGetBlockIoTune): Use new helpers.
* src/esx/esx_driver.c (esxDomainSetSchedulerParametersFlags)
(esxDomainSetMemoryParameters)
(esxDomainGetSchedulerParametersFlags)
(esxDomainGetMemoryParameters): Likewise.
* src/libxl/libxl_driver.c
(libxlDomainSetSchedulerParametersFlags)
(libxlDomainGetSchedulerParametersFlags): Likewise.
* src/lxc/lxc_driver.c (lxcDomainSetMemoryParameters)
(lxcSetSchedulerParametersFlags, lxcDomainSetBlkioParameters)
(lxcDomainGetMemoryParameters, lxcGetSchedulerParametersFlags)
(lxcDomainGetBlkioParameters): Likewise.
* src/test/test_driver.c (testDomainSetSchedulerParamsFlags)
(testDomainGetSchedulerParamsFlags): Likewise.
* src/xen/xen_hypervisor.c (xenHypervisorSetSchedulerParameters)
(xenHypervisorGetSchedulerParameters): Likewise.

13 years agoutil: add new file for virTypedParameter utils
Eric Blake [Mon, 2 Jan 2012 22:03:19 +0000 (15:03 -0700)]
util: add new file for virTypedParameter utils

Preparation for another patch that refactors common patterns
into the new file for fewer lines of code overall.

* src/util/util.h (virTypedParameterArrayClear): Move...
* src/util/virtypedparam.h: ...to new file.
(virTypedParameterArrayValidate, virTypedParameterAssign): New
prototypes.
* src/util/util.c (virTypedParameterArrayClear): Likewise.
* src/util/virtypedparam.c: New file.
* po/POTFILES.in: Mark file for translation.
* src/Makefile.am (UTIL_SOURCES): Build it.
* src/libvirt_private.syms (util.h): Split...
(virtypedparam.h): to new section.
(virkeycode.h): Sort.
* daemon/remote.c: Adjust callers.
* tools/virsh.c: Likewise.

13 years agolxc: use live/config helper
Eric Blake [Sat, 7 Jan 2012 12:36:46 +0000 (05:36 -0700)]
lxc: use live/config helper

Based on qemu changes made in commits ae523427 and 659ded58.

* src/lxc/lxc_driver.c (lxcSetSchedulerParametersFlags)
(lxcGetSchedulerParametersFlags, lxcDomainSetBlkioParameters)
(lxcDomainGetBlkioParameters): Use helpers.
(lxcDomainSetBlkioParameters): Allow setting live and config at
once.

13 years agobuild: silence some compiler warnings from gnulib
Eric Blake [Thu, 12 Jan 2012 21:14:44 +0000 (14:14 -0700)]
build: silence some compiler warnings from gnulib

Gnulib claims that there are some classes of warnings that are
worth enabling during development, but where silencing those
warnings causes code bloat that is not necessary in an optimized
build.  The code bloat to silence the warnings is only enabled
by -Dlint.  Follow the lead of coreutils in setting up -Dlint
whenever full warnings are requested.

* m4/virt-compile-warnings.m4 (LIBVIRT_COMPILE_WARNINGS): Add
-Dlint, and move _FORTIFY_SOURCE to config.h instead of CFLAGS.

13 years agothreads: check for failure to set thread-local value
Eric Blake [Tue, 20 Dec 2011 22:06:47 +0000 (15:06 -0700)]
threads: check for failure to set thread-local value

We had a memory leak on a very arcane OOM situation (unlikely to ever
hit in practice, but who knows if libvirt.so would ever be linked
into some other program that exhausts all thread-local storage keys?).
I found it by code inspection, while analyzing a valgrind report
generated by Alex Jia.

* src/util/threads.h (virThreadLocalSet): Alter signature.
* src/util/threads-pthread.c (virThreadHelper): Reduce allocation
lifetime.
(virThreadLocalSet): Detect failure.
* src/util/threads-win32.c (virThreadLocalSet): Likewise.
(virCondWait): Fix caller.
* src/util/virterror.c (virLastErrorObject): Likewise.

13 years agoFix rpc generator to anchor matches for method names
Daniel P. Berrange [Thu, 19 Jan 2012 14:19:42 +0000 (14:19 +0000)]
Fix rpc generator to anchor matches for method names

The RPC generator transforms methods matching certain
patterns like 'id' or 'uuid', etc but does not anchor
its matches to the end of the word. So if a method
contains 'id' in the middle (eg virIdentity) then the
RPC generator munges that.

* src/rpc/gendispatch.pl: Anchor matches

13 years agoRename APIs for fetching UNIX socket credentials
Daniel P. Berrange [Wed, 18 Jan 2012 17:41:36 +0000 (17:41 +0000)]
Rename APIs for fetching UNIX socket credentials

To avoid a namespace clash with forthcoming identity APIs,
rename the virNet*GetLocalIdentity() APIs to have the form
virNet*GetUNIXIdentity()

* daemon/remote.c, src/libvirt_private.syms: Update
  for renamed APIs
* src/rpc/virnetserverclient.c, src/rpc/virnetserverclient.h,
  src/rpc/virnetsocket.c, src/rpc/virnetsocket.h: s/LocalIdentity/UNIXIdentity/

13 years agoAdd virGetGroupName to convert from GID to group name
Daniel P. Berrange [Fri, 16 Dec 2011 00:55:19 +0000 (00:55 +0000)]
Add virGetGroupName to convert from GID to group name

13 years agoRemove duplicate call to virNetSASLSessionGetIdentity
Daniel P. Berrange [Fri, 16 Dec 2011 00:19:30 +0000 (00:19 +0000)]
Remove duplicate call to virNetSASLSessionGetIdentity

* daemon/remote.c: remoteSASLFinish called the method
  virNetSASLSessionGetIdentity twice, remove second call

13 years agoAlso retrieve GID from SO_PEERCRED
Daniel P. Berrange [Fri, 16 Dec 2011 00:18:22 +0000 (00:18 +0000)]
Also retrieve GID from SO_PEERCRED

* daemon/remote.c, src/rpc/virnetserverclient.c,
  src/rpc/virnetserverclient.h, src/rpc/virnetsocket.c,
  src/rpc/virnetsocket.h: Add gid parameter

13 years agoAdded capability checking for block <iotune> setting.
Martin Kletzander [Wed, 18 Jan 2012 16:42:33 +0000 (17:42 +0100)]
Added capability checking for block <iotune> setting.

There was missing capability for blkiotune and thus specifying these
settings caused libvirt to run qemu with invalid parameters and then
reporting qemu error instead of the standard libvirt one. The support
for blkiotune setting was added in upstream qemu repo under commit
0563e191516289c9d2f282a8c50f2eecef2fa773.

13 years agoFix startup of LXC containers with filesystems containing symlinks
Daniel P. Berrange [Tue, 17 Jan 2012 21:33:02 +0000 (21:33 +0000)]
Fix startup of LXC containers with filesystems containing symlinks

Given an LXC guest with a root filesystem path of

  /export/lxc/roots/helloworld/root

During startup, we will pivot the root filesystem to end up
at

  /.oldroot/export/lxc/roots/helloworld/root

We then try to open

  /.oldroot/export/lxc/roots/helloworld/root/dev/pts

Now consider if '/export/lxc' is an absolute symlink pointing
to '/media/lxc'. The kernel will try to open

  /media/lxc/roots/helloworld/root/dev/pts

whereas it should be trying to open

  /.oldroot//media/lxc/roots/helloworld/root/dev/pts

To deal with the fact that the root filesystem can be moved,
we need to resolve symlinks in *any* part of the filesystem
source path.

* src/libvirt_private.syms, src/util/util.c,
  src/util/util.h: Add virFileResolveAllLinks to resolve
  all symlinks in a path
* src/lxc/lxc_container.c: Resolve all symlinks in filesystem
  paths during startup

13 years agoqemu: Prohibit reattaching node device if it is in use
Osier Yang [Tue, 17 Jan 2012 20:31:34 +0000 (04:31 +0800)]
qemu: Prohibit reattaching node device if it is in use

It doesn't make sense to reattach a device to host while it's
still in use, e.g, by a domain.

13 years agoqemu: Introduce inactive PCI device list
Osier Yang [Tue, 17 Jan 2012 20:02:05 +0000 (04:02 +0800)]
qemu: Introduce inactive PCI device list

pciTrySecondaryBusReset checks if there is active device on the
same bus, however, qemu driver doesn't maintain an effective
list for the inactive devices, and it passes meaningless argument
for parameter "inactiveDevs". e.g. (qemuPrepareHostdevPCIDevices)

if (!(pcidevs = qemuGetPciHostDeviceList(hostdevs, nhostdevs)))
    return -1;

..skipped...

if (pciResetDevice(dev, driver->activePciHostdevs, pcidevs) < 0)
    goto reattachdevs;

NB, the "pcidevs" used above are extracted from domain def, and
thus one won't be able to attach a device of which bus has other
device even detached from host (nodedev-detach). To see more
details of the problem:

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

This patch is to resolve the problem by introducing an inactive
PCI device list (just like qemu_driver->activePciHostdevs), and
the whole logic is:

  * Add the device to inactive list during nodedev-dettach
  * Remove the device from inactive list during nodedev-reattach
  * Remove the device from inactive list during attach-device
    (for non-managed device)
  * Add the device to inactive list after detach-device, only
    if the device is not managed

With the above, we have a sufficient inactive PCI device list, and thus
we can use it for pciResetDevice. e.g.(qemuPrepareHostdevPCIDevices)

if (pciResetDevice(dev, driver->activePciHostdevs,
                   driver->inactivePciHostdevs) < 0)
    goto reattachdevs;

13 years agoPermission change for systemtap examples.
Martin Kletzander [Tue, 17 Jan 2012 14:57:41 +0000 (15:57 +0100)]
Permission change for systemtap examples.

Execute bit on *.stp files in examples/systemtap/ caused dependency when
building RPM packages. Disabling execute permission should help the auto
dependency resolver to see that systemtap is not needed.

13 years agoAdd new attribute wrpolicy to <driver> element
Deepak C Shetty [Tue, 17 Jan 2012 12:44:18 +0000 (18:14 +0530)]
Add new attribute wrpolicy to <driver> element

This introduces new attribute wrpolicy with only supported
value as immediate. This will be an optional
attribute with no defaults. This helps specify whether
to skip the host page cache.

When wrpolicy is specified, meaning when wrpolicy=immediate
a writeback is explicitly initiated for the dirty pages in
the host page cache as part of the guest file write operation.

Usage:
<filesystem type='mount' accessmode='passthrough'>
  <driver type='path' wrpolicy='immediate'/>
  <source dir='/export/to/guest'/>
  <target dir='mount_tag'/>
</filesystem>

Currently this only works with type='mount' for the QEMU/KVM driver.

Signed-off-by: Deepak C Shetty <deepakcs@linux.vnet.ibm.com>
13 years agoqemu: Don't break domain with 0:0:2.0 assigned to anything but VGA
Jiri Denemark [Tue, 17 Jan 2012 15:21:38 +0000 (16:21 +0100)]
qemu: Don't break domain with 0:0:2.0 assigned to anything but VGA

In the past we didn't reserve 0:0:2.0 PCI address if there was no video
device assigned to a domain, which made it impossible to add a video
device later on. So we fixed it (commit v0.9.0-37-g7b2cac1) by always
reserving that address. However, that breaks existing domains without
video devices that already have another device assigned to the
problematic address.

This patch reserves address 0:0:2.0 only in case it was not explicitly
assigned to another device, which means libvirt will try to keep this
address free and will not automatically assign it new devices. But
existing domains for which older libvirt already assigned the address to
a non-video device will keep working as they used to work before 0.9.1.
Moreover, users who want to create a domain without a video device and
use its address for another device may do so by explicitly configuring
the PCI address in domain XML.

13 years agotests: avoid dirname in tests
Eric Blake [Tue, 17 Jan 2012 19:09:51 +0000 (12:09 -0700)]
tests: avoid dirname in tests

qemuxml2argvtest sanitizes PATH to just /bin, but on at least
Fedora 16, dirname lives in /usr/bin instead.  Regression
introduced in commit e7201afd.

* tests/qemuxml2argvdata/qemu.sh: Avoid forking a dirname call,
since dirname might not be in PATH after test sanitization.
* tests/qemuxml2argvdata/qemu-supported-cpus.sh: Likewise.
Diagnosed by Michal Privoznik.

13 years agoFixed dumpxml of <iotune> parameters
Martin Kletzander [Tue, 17 Jan 2012 14:55:57 +0000 (15:55 +0100)]
Fixed dumpxml of <iotune> parameters

The output of dumpxml for <iotune> settings was misformatted, this
patch just adds missing newlines.

13 years agonwfilter: fix typing error in filter
Stefan Berger [Tue, 17 Jan 2012 17:47:41 +0000 (12:47 -0500)]
nwfilter: fix typing error in filter

Fix a typing error in the no-ip-spoofing filter.
Return DHCP request packets passing through this filter. Have
the user use another filter to actually allow DHCP requests to be
sent (action='accept').

13 years agoRemove dmidecode dependancy outside PC arches
Daniel Veillard [Tue, 17 Jan 2012 15:41:28 +0000 (23:41 +0800)]
Remove dmidecode dependancy outside PC arches

The new dependancy is only available on ix86, x86_64 and ia64

13 years agoqemu: Add support for host CPU modes
Jiri Denemark [Wed, 21 Dec 2011 12:47:17 +0000 (13:47 +0100)]
qemu: Add support for host CPU modes

This adds support for host-model and host-passthrough CPU modes to qemu
driver. The host-passthrough mode is mapped to -cpu host.

13 years agoTaint domains configured with cpu mode=host-passthrough
Jiri Denemark [Thu, 18 Aug 2011 10:56:56 +0000 (12:56 +0200)]
Taint domains configured with cpu mode=host-passthrough

There are several reasons for doing this:

- the CPU specification is out of libvirt's control so we cannot
  guarantee stable guest ABI
- not every feature of a CPU may actually work as expected when
  advertised directly to a guest
- migration between two machines with exactly the same CPU may work but
  no guarantees can be made
- this mode is not supported and its use is at one's own risk

13 years agocpu: Update guest CPU in host-* mode
Jiri Denemark [Mon, 19 Dec 2011 14:41:16 +0000 (15:41 +0100)]
cpu: Update guest CPU in host-* mode

VIR_DOMAIN_XML_UPDATE_CPU flag for virDomainGetXMLDesc may be used to
get updated custom mode guest CPU definition in case it depends on host
CPU. This patch implements the same behavior for host-model and
host-passthrough CPU modes.

13 years agoAdd support for cpu mode attribute
Jiri Denemark [Thu, 18 Aug 2011 10:14:36 +0000 (12:14 +0200)]
Add support for cpu mode attribute

The mode can be either of "custom" (default), "host-model",
"host-passthrough". The semantics of each mode is described in the
following examples:

- guest CPU is a default model with specified topology:
    <cpu>
      <topology sockets='1' cores='2' threads='1'/>
    </cpu>

- guest CPU matches selected model:
    <cpu mode='custom' match='exact'>
      <model>core2duo</model>
    </cpu>

- guest CPU should be a copy of host CPU as advertised by capabilities
  XML (this is a short cut for manually copying host CPU specification
  from capabilities to domain XML):
    <cpu mode='host-model'/>

  In case a hypervisor does not support the exact host model, libvirt
  automatically falls back to a closest supported CPU model and
  removes/adds features to match host. This behavior can be disabled by
    <cpu mode='host-model'>
      <model fallback='forbid'/>
    </cpu>

- the same as previous returned by virDomainGetXMLDesc with
  VIR_DOMAIN_XML_UPDATE_CPU flag:
    <cpu mode='host-model' match='exact'>
      <model fallback='allow'>Penryn</model>       --+
      <vendor>Intel</vendor>                         |
      <topology sockets='2' cores='4' threads='1'/>  + copied from
      <feature policy='require' name='dca'/>         | capabilities XML
      <feature policy='require' name='xtpr'/>        |
      ...                                          --+
    </cpu>

- guest CPU should be exactly the same as host CPU even in the aspects
  libvirt doesn't model (such domain cannot be migrated unless both
  hosts contain exactly the same CPUs):
    <cpu mode='host-passthrough'/>

- the same as previous returned by virDomainGetXMLDesc with
  VIR_DOMAIN_XML_UPDATE_CPU flag:
    <cpu mode='host-passthrough' match='minimal'>
      <model>Penryn</model>                        --+ copied from caps
      <vendor>Intel</vendor>                         | XML but doesn't
      <topology sockets='2' cores='4' threads='1'/>  | describe all
      <feature policy='require' name='dca'/>         | aspects of the
      <feature policy='require' name='xtpr'/>        | actual guest CPU
      ...                                          --+
    </cpu>

13 years agocpu: Optionally forbid fallback CPU models
Jiri Denemark [Wed, 21 Dec 2011 13:27:16 +0000 (14:27 +0100)]
cpu: Optionally forbid fallback CPU models

In case a hypervisor doesn't support the exact CPU model requested by a
domain XML, we automatically fallback to a closest CPU model the
hypervisor supports (and make sure we add/remove any additional features
if needed). This patch adds 'fallback' attribute to model element, which
can be used to disable this automatic fallback.

13 years agotests: Print XML file name in verbose CPU test
Jiri Denemark [Wed, 4 Jan 2012 13:23:20 +0000 (14:23 +0100)]
tests: Print XML file name in verbose CPU test

It's not totally obvious that a failure in

    CPU guest data(x86): host/guest (models, pref="qemu64")

test means one needs to fix

    x86-host+guest,models,qemu64-result.xml

where the expected XML is stored. Better to provide a nice hint in
verbose mode for failed tests.

13 years agoClarify semantics of virDomainMigrate{,ToURI}2
Jiri Denemark [Mon, 16 Jan 2012 09:24:42 +0000 (10:24 +0100)]
Clarify semantics of virDomainMigrate{,ToURI}2

Commit 5d784bd6d7b19314b0908aec6b46bfe377aeba42 was a nice attempt to
clarify the semantics by requiring domain name from dxml to either match
original name or dname. However, setting dxml domain name to dname
doesn't really work since destination host needs to know the original
domain name to be able to use it in migration cookies. This patch
requires domain name in dxml to match the original domain name. The
change should be safe and backward compatible since migration would fail
just a bit later in the process.

13 years agodocs: Add missed RNG schema for interface
Osier Yang [Mon, 16 Jan 2012 14:08:07 +0000 (22:08 +0800)]
docs: Add missed RNG schema for interface

We support <interface> of type "mcast", "server", and "client",
but the RNG schema for them are missed. Attribute "address" is
optional for "server" type. And these 3 types support
<mac address='MAC'/>, too.

13 years agobuild: fix bootstrap on fresh clone
Eric Blake [Mon, 16 Jan 2012 17:23:32 +0000 (10:23 -0700)]
build: fix bootstrap on fresh clone

Commit 29db7a0 picked up a gnulib bug, where a change in
bootstrap meant that it would fail to run libtoolize on
projects, like libvirt, that used the older spelling
AM_PROG_LIBTOOL instead of LT_INIT for the sake of building
on RHEL 5.  Now that gnulib is fixed, we should pick up that
fix.

* .gnulib: Update to latest, for bootstrap fix.
* bootstrap: Resync from gnulib.

13 years agodocs: Expose alias tag in domain RNG schema
Osier Yang [Mon, 16 Jan 2012 09:28:51 +0000 (17:28 +0800)]
docs: Expose alias tag in domain RNG schema

Though <alias> is ignored when defining a domain, it can cause
failure if one validates (e.g. virt-xml-validate) the XML dumped
from a running domain. This patch expose it in domain RNG schema
for all the devices which support it.

13 years agodocs: Add readonly to filesystem RNG schema
Osier Yang [Mon, 16 Jan 2012 09:17:26 +0000 (17:17 +0800)]
docs: Add readonly to filesystem RNG schema

"<readonly/>" is supported by filesystem XML, and also documented.

13 years agoconf: Remove do-nothing validation functions
Michael Ellerman [Fri, 13 Jan 2012 03:39:26 +0000 (14:39 +1100)]
conf: Remove do-nothing validation functions

There are three address validation routines that do nothing:
  virDomainDeviceDriveAddressIsValid()
  virDomainDeviceUSBAddressIsValid()
  virDomainDeviceVirtioSerialAddressIsValid()

Remove them, and replace their call sites with "1" which is what they
currently return. In some cases this means we can remove an entire
if block.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
13 years agotests: Add qemuxml2argv tests for PPC64 pseries machine
Michael Ellerman [Fri, 13 Jan 2012 03:39:25 +0000 (14:39 +1100)]
tests: Add qemuxml2argv tests for PPC64 pseries machine

Add four tests of the XML -> argv handling for the PPC64 pseries machine.

The first is just a basic test of a bare bones machine.

The three others test various aspects of the spapr-vio address handling.

It seems that currently we can't include network devices, doing so leads
to a segfault because the network driverState is not initialised. Working
around that leads us to the problem that the 'default' network doesn't
exist. So for now just leave network devices out.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
13 years agotests: Teach qemuxml2argvtest about spapr-vio addresses
Michael Ellerman [Fri, 13 Jan 2012 03:39:24 +0000 (14:39 +1100)]
tests: Teach qemuxml2argvtest about spapr-vio addresses

We can't call qemuCapsExtractVersionInfo() from test code, because it
expects to be able to call the emulator, and for testing we have fake
emulators that can't be executed. For that reason qemuxml2argvtest.c
doesn't call qemuDomainAssignPCIAddresses(), instead it open codes its
own version.

That means we can't call qemuDomainAssignAddresses() from the test code,
instead we need to manually call qemuDomainAssignSpaprVioAddresses().

Also add logic to cope with qemuDomainAssignSpaprVioAddresses() failing,
so that we can write a test that checks for a known failure in there.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
13 years agoMake drive unit attribute optional in the XML schema
Michael Ellerman [Fri, 13 Jan 2012 03:39:23 +0000 (14:39 +1100)]
Make drive unit attribute optional in the XML schema

The "unit" attribute of a drive address is optional in the code, so should
also be in the XML schema.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
13 years agoqemu: add virtio-scsi controller model
Paolo Bonzini [Fri, 13 Jan 2012 12:23:56 +0000 (13:23 +0100)]
qemu: add virtio-scsi controller model

Adding a new model for virtio-scsi roughly follows the same scheme
as the previous patch.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
13 years agoqemu: add ibmvscsi controller model
Paolo Bonzini [Fri, 13 Jan 2012 12:23:55 +0000 (13:23 +0100)]
qemu: add ibmvscsi controller model

KVM will be able to use a PCI SCSI controller even on POWER.  Let
the user specify the vSCSI controller by other means than a default.

After this patch, the QEMU driver will actually look at the model
and reject anything but auto, lsilogic and ibmvscsi.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
13 years agoevents: Return the correct number of registered events
Adam Litke [Fri, 13 Jan 2012 20:44:42 +0000 (14:44 -0600)]
events: Return the correct number of registered events

Commit d09f6ba5feb655925175dc80122ca2a1e14db2b9 introduced a regression in event
registration.  virDomainEventCallbackListAddID() will only return a positive
integer if the type of event being registered is VIR_DOMAIN_EVENT_ID_LIFECYCLE.
For other event types, 0 is always returned on success.  This has the
unfortunate side effect of not enabling remote event callbacks because
remoteDomainEventRegisterAny() uses the return value from the local call to
determine if an event callback needs to be registered on the remote end.

Make sure virDomainEventCallbackListAddID() returns the callback count for the
eventID being registered.

Signed-off-by: Adam Litke <agl@us.ibm.com>
13 years agovirsh domiflist: change output
Taku Izumi [Fri, 13 Jan 2012 10:41:52 +0000 (19:41 +0900)]
virsh domiflist: change output

When using "virsh domifstat" command or "virsh domiftune" command,
we pass an interface name as a parameter, so interface name is
important.

"virsh domiflist" output should display interface names
on the first row.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
13 years agoexport virNetDevGetVirtualFunctions as a private symbol
Paolo Bonzini [Fri, 13 Jan 2012 12:08:10 +0000 (13:08 +0100)]
export virNetDevGetVirtualFunctions as a private symbol

This avoids a linking error.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
13 years agovirsh: Two new fields for command domblklist
Osier Yang [Fri, 13 Jan 2012 10:03:12 +0000 (18:03 +0800)]
virsh: Two new fields for command domblklist

Disk "type" and "device" are generally interesting stuff the
user may want to known, too. To not break any scripts which
parsed the output field, a new option "--details" is introduced
to output the two introduced fields.

13 years agoqemu: Support copy on read for disk
Osier Yang [Thu, 12 Jan 2012 09:31:14 +0000 (17:31 +0800)]
qemu: Support copy on read for disk

The new introduced optional attribute "copy_on_read</code> controls
whether to copy read backing file into the image file. The value can
be either "on" or "off". Copy-on-read avoids accessing the same backing
file sectors repeatedly and is useful when the backing file is over a
slow network. By default copy-on-read is off.

13 years agoAdded check for maximum number of vcpus exceeding topology limit
Martin Kletzander [Thu, 12 Jan 2012 10:11:33 +0000 (11:11 +0100)]
Added check for maximum number of vcpus exceeding topology limit

Earlier, when the number of vcpus was greater than the topology allowed,
libvirt didn't raise an error and continued, resulting in running qemu
with parameters making no sense. Even though qemu did not report any
error itself, the number of vcpus was set to maximum allowed by the
topology.

13 years agobuild: update to latest gnulib
Eric Blake [Thu, 12 Jan 2012 00:19:01 +0000 (17:19 -0700)]
build: update to latest gnulib

Pick up recent gnulib improvements.

* .gnulib: Update to latest.
* bootstrap: Resync.
* bootstrap.conf (gnulib_tool_option_extras): Adjust to bootstrap
changes.
* gnulib/lib/Makefile.am: Likewise.

13 years agouuid: fix off-by-one
Eric Blake [Thu, 12 Jan 2012 00:44:49 +0000 (17:44 -0700)]
uuid: fix off-by-one

Detected by Coverity.  Although unlikely, if we are ever started
with stdin closed, we could reach a situation where we open a
uuid file but then fail to close it, making that file the new
stdin for the rest of the process.

* src/util/uuid.c (getDMISystemUUID): Allow for stdin.

13 years agobuild: fix virsh reformat fallout
Eric Blake [Thu, 12 Jan 2012 22:16:40 +0000 (15:16 -0700)]
build: fix virsh reformat fallout

Commit 69f0b446 failed to update the expected test output.

* tests/virshtest.c (testCompareListDefault)
(testCompareListCustom): Adjust to recent code change.

13 years agoRsync keymaps.csv file with GTK-VNC
Daniel P. Berrange [Thu, 12 Jan 2012 20:44:55 +0000 (20:44 +0000)]
Rsync keymaps.csv file with GTK-VNC

13 years agoRe-write LXC controller end-of-file I/O handling yet again
Daniel P. Berrange [Thu, 12 Jan 2012 17:03:03 +0000 (17:03 +0000)]
Re-write LXC controller end-of-file I/O handling yet again

Currently the LXC controller attempts to deal with EOF on a
tty by spawning a thread to do an edge triggered epoll_wait().
This avoids the normal event loop spinning on POLLHUP. There
is a subtle mistake though - even after seeing POLLHUP on a
master PTY, it is still perfectly possible & valid to write
data to the PTY. There is a buffer that can be filled with
data, even when no client is present.

The second mistake is that the epoll_wait() thread was not
looking for the EPOLLOUT condition, so when a new client
connects to the LXC console, it had to explicitly send a
character before any queued output would appear.

Finally, there was in fact no need to spawn a new thread to
deal with epoll_wait(). The epoll file descriptor itself
can be poll()'d on normally.

This patch attempts to deal with all these problems.

 - The blocking epoll_wait() thread is replaced by a poll
   on the epoll file descriptor which then does a non-blocking
   epoll_wait() to handle events
 - Even if POLLHUP is seen, we continue trying to write
   any pending output until getting EAGAIN from write.
 - Once write returns EAGAIN, we modify the epoll event
   mask to also look for EPOLLOUT

* src/lxc/lxc_controller.c: Avoid stalled I/O upon
  connected to an LXC console

13 years agoAllow 10 chars for domain IDs & 30 chars for names in virsh list
Daniel P. Berrange [Thu, 12 Jan 2012 11:47:28 +0000 (11:47 +0000)]
Allow 10 chars for domain IDs & 30 chars for names in virsh list

Domain IDs are at least 16 bits for most hypervisors, theoretically
event 32-bits.  3 characters is clearly too small an alignment.
Increase alignment to 5 characters to allow 16-bit domain IDs to
display cleanly. Commonly seen with LXC where domain IDs are the
process IDs by default.  Also increase the 'name' field from 20
to 30 characters to cope with longer guest names which are quite
common

13 years agostream: Check for stream EOF
Michal Privoznik [Tue, 10 Jan 2012 15:57:30 +0000 (16:57 +0100)]
stream: Check for stream EOF

If client stream does not have any data to sink and neither received
EOF, a dummy packet is sent to the daemon signalising client is ready to
sink some data. However, after we added event loop to client a race may
occur:

Thread 1 calls virNetClientStreamRecvPacket and since no data are cached
nor stream has EOF, it decides to send dummy packet to server which will
sent some data in turn. However, during this decision and actual message
exchange with server -

Thread 2 receives last stream data from server. Therefore an EOF is set
on stream and if there is a call waiting (which is not yet) it is woken
up. However, Thread 1 haven't sent anything so far, so there is no call
to be woken up. So this thread sent dummy packet to daemon, which
ignores that as no stream is associated with such packet and therefore
no reply will ever come.

This race causes client to hang indefinitely.

13 years agovirsh: New command print summary of all virtual interfaces
Osier Yang [Wed, 11 Jan 2012 12:45:31 +0000 (20:45 +0800)]
virsh: New command print summary of all virtual interfaces

Just like command "domblklist", the command extracts "type",
"source", "target", "model", and "MAC" of all virtual interfaces
from domain XML (live or persistent).

13 years agoDo not generate security_model when fs driver is anything but 'path'
Deepak C Shetty [Tue, 10 Jan 2012 12:53:31 +0000 (18:23 +0530)]
Do not generate security_model when fs driver is anything but 'path'

QEMU does not support security_model for anything but 'path' fs driver type.
Currently in libvirt, when security_model ( accessmode attribute) is not
specified it auto-generates it irrespective of the fs driver type, which
can result in a qemu error for drivers other than path. This patch ensures
that the qemu cmdline is correctly generated by taking into account the
fs driver type.

Signed-off-by: Deepak C Shetty <deepakcs@linux.vnet.ibm.com>
13 years agoAdded new option to virsh net-dumpxml called --inactive
Shradha Shah [Wed, 14 Dec 2011 10:50:40 +0000 (10:50 +0000)]
Added new option to virsh net-dumpxml called --inactive

The above option helps to differentiate between implicit and explicit
interface pools.

13 years agoFunctionality to implicitly get interface pool from SR-IOV PF.
Shradha Shah [Wed, 14 Dec 2011 10:50:30 +0000 (10:50 +0000)]
Functionality to implicitly get interface pool from SR-IOV PF.

If a system has 64 or more VF's, it is quite tedious to mention each VF
in the interface pool.
The following modification will implicitly create an interface pool from
the SR-IOV PF.

13 years agoAdding the element pf to network xml.
Shradha Shah [Wed, 14 Dec 2011 10:50:23 +0000 (10:50 +0000)]
Adding the element pf to network xml.

This element will help the user to just specify the SR-IOV physical
function in order to access all the Virtual functions attached to it.

13 years agoAdded Function virNetDevGetVirtualFunctions
Shradha Shah [Wed, 14 Dec 2011 10:50:14 +0000 (10:50 +0000)]
Added Function virNetDevGetVirtualFunctions

This functions enables us to get the Virtual Functions attached to
a Physical function given the name of a SR-IOV physical functio.

In order to accomplish the task, added a getter function pciGetDeviceAddrString
to get the BDF of the Virtual Function in a char array.

13 years agoAdded function pciSysfsFile to enable access to the PCI SYSFS files.
Shradha Shah [Wed, 14 Dec 2011 10:50:01 +0000 (10:50 +0000)]
Added function pciSysfsFile to enable access to the PCI SYSFS files.

13 years agoDisable netcf if building without libvirtd
Daniel P. Berrange [Wed, 11 Jan 2012 14:09:03 +0000 (14:09 +0000)]
Disable netcf if building without libvirtd

Although the netcf interface driver can in theory be used by
the stateless drivers, in practice none of them want to use
it because they have different ways of dealing with interfaces.

Furthermore, if you have mingw32-netcf installed, then the
libvirt mingw32 build will fail with

  ../../src/interface/netcf_driver.c:644:5: error: unknown field 'close_used_without_including_unistd_h' specified in initializer

 * configure.ac: disable netcf if built without libvirtd

13 years agobuild: fix build on mingw with netcf available
Eric Blake [Wed, 11 Jan 2012 13:48:14 +0000 (06:48 -0700)]
build: fix build on mingw with netcf available

The autobuilder pointed out an odd failure on mingw:
../../src/interface/netcf_driver.c:644:5: error: unknown field 'close_used_without_including_unistd_h' specified in initializer
cc1: warnings being treated as errors

This is because the gnulib headers #define close to different strings,
according to which headers are included, in order to work around some
odd mingw problems with close(), and these defines happen to also
affect field members declared with a name of struct foo.close. As long
as all headers are included before both the definition and use of the
struct, the various #define doesn't matter, but the netcf file hit
an instance where things were included in a different order.  Fix this
for all clients that use a struct member named 'close'.

* src/driver.h: Include <unistd.h> before using 'close'.

13 years agobuild: avoid spurious compiler warning
Eric Blake [Wed, 11 Jan 2012 13:32:52 +0000 (06:32 -0700)]
build: avoid spurious compiler warning

For some weird reason, i686-pc-mingw32-gcc version 4.6.1 at -O2 complained:
../../src/conf/nwfilter_params.c: In function 'virNWFilterVarCombIterCreate':
../../src/conf/nwfilter_params.c:346:23: error: 'minValue' may be used uninitialized in this function [-Werror=uninitialized]
../../src/conf/nwfilter_params.c:319:28: note: 'minValue' was declared here
../../src/conf/nwfilter_params.c:344:23: error: 'maxValue' may be used uninitialized in this function [-Werror=uninitialized]
../../src/conf/nwfilter_params.c:319:18: note: 'maxValue' was declared here
cc1: all warnings being treated as errors

even though all paths of the preceding switch statement either
assign the variables or return.

* src/conf/nwfilter_params.c (virNWFilterVarCombIterAddVariable):
Initialize variables.

13 years agoAdd documentation new ways to access members of variables
Stefan Berger [Wed, 11 Jan 2012 11:42:37 +0000 (06:42 -0500)]
Add documentation new ways to access members of variables

This patch adds documentation about the new 'ways' that users can
access the contents of variables in filters:

- access via index: $TEST[2]
- access via iterators $TEST[@1]

13 years agoAdd test cases for new ways to access variables in filters
Stefan Berger [Wed, 11 Jan 2012 11:42:37 +0000 (06:42 -0500)]
Add test cases for new ways to access variables in filters

This patch adds a couple of XML parser / schema validator test cases
for the new 'ways' to access variables via index or iterator.

13 years agoAddress side effects of accessing vars via index
Stefan Berger [Wed, 11 Jan 2012 11:42:37 +0000 (06:42 -0500)]
Address side effects of accessing vars via index

Address side effect of accessing a variable via an index: Filters
accessing a variable where an element is accessed that is beyond the
size of the list (for example $TEST[10] and only 2 elements are available)
cannot instantiate that filter. Test for this and report proper error
to user.

13 years agoAdd access to elements of variables via index
Stefan Berger [Wed, 11 Jan 2012 11:42:37 +0000 (06:42 -0500)]
Add access to elements of variables via index

This patch adds access to single elements of variables via index. Example:

  <rule action='accept' direction='in' priority='500'>
    <tcp srcipaddr='$ADDR[1]' srcportstart='$B[2]'/>
  </rule>

13 years agoIntroduce possibility to have an iterator per variable
Stefan Berger [Wed, 11 Jan 2012 11:42:37 +0000 (06:42 -0500)]
Introduce possibility to have an iterator per variable

This patch introduces the capability to use a different iterator per
variable.

The currently supported notation of variables in a filtering rule like

  <rule action='accept' direction='out'>
     <tcp  srcipaddr='$A' srcportstart='$B'/>
  </rule>

processes the two lists 'A' and 'B' in parallel. This means that A and B
must have the same number of 'N' elements and that 'N' rules will be
instantiated (assuming all tuples from A and B are unique).

In this patch we now introduce the assignment of variables to different
iterators. Therefore a rule like

  <rule action='accept' direction='out'>
     <tcp  srcipaddr='$A[@1]' srcportstart='$B[@2]'/>
  </rule>

will now create every combination of elements in A with elements in B since
A has been assigned to an iterator with Id '1' and B has been assigned to an
iterator with Id '2', thus processing their value independently.

The first rule has an equivalent notation of

  <rule action='accept' direction='out'>
     <tcp  srcipaddr='$A[@0]' srcportstart='$B[@0]'/>
  </rule>

13 years agoOptimize the elements the iterator visits.
Stefan Berger [Wed, 11 Jan 2012 11:42:37 +0000 (06:42 -0500)]
Optimize the elements the iterator visits.

In this patch we introduce testing whether the iterator points to a
unique set of entries that have not been seen before at one of the previous
iterations. The point is to eliminate duplicates and with that unnecessary
filtering rules by preventing identical filtering rules from being
instantiated.
Example with two lists:

list1 = [1,2,1]
list2 = [1,3,1]

The 1st iteration would take the 1st items of each list -> 1,1
The 2nd iteration would take the 2nd items of each list -> 2,3
The 3rd iteration would take the 3rd items of each list -> 1,1 but
skip them since this same pair has already been encountered in the 1st
iteration

Implementation-wise this is solved by taking the n-th element of list1 and
comparing it against elements 1..n-1. If no equivalent is found, then there
is no possibility of this being a duplicate. In case an equivalent element
is found at position i, then the n-th element in the 2nd list is compared
against the i-th element in the 2nd list and if that is not the same, then
this is a unique pair, otherwise it is not unique and we may need to do
the same comparison on the 3rd list.

13 years agoapparmor: Mark pid parameter as unused
Jiri Denemark [Wed, 11 Jan 2012 11:27:02 +0000 (12:27 +0100)]
apparmor: Mark pid parameter as unused

13 years agovirsh: improve doMigrate function docs
Alex Jia [Wed, 11 Jan 2012 08:23:03 +0000 (16:23 +0800)]
virsh: improve doMigrate function docs

When running virsh migrate with --xml option and actual xml file doesn't
exist, virsh hasn't output any error information, although return value
is 1.

* tools/virsh.c: Raising a appropriate error information when operation fails.

* How to reproduce?
% virsh migrate <domain> --live qemu+ssh://<target host>/system --xml non-existent.xml
% echo $?

* Fixed result:
error: file 'non-existent.xml' doesn't exist

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agoChange security driver APIs to use virDomainDefPtr instead of virDomainObjPtr
Daniel P. Berrange [Thu, 14 Jul 2011 13:32:06 +0000 (14:32 +0100)]
Change security driver APIs to use virDomainDefPtr instead of virDomainObjPtr

When sVirt is integrated with the LXC driver, it will be neccessary
to invoke the security driver APIs using only a virDomainDefPtr
since the lxc_container.c code has no virDomainObjPtr available.
Aside from two functions which want obj->pid, every bit of the
security driver code only touches obj->def. So we don't need to
pass a virDomainObjPtr into the security drivers, a virDomainDefPtr
is sufficient. Two functions also gain a 'pid_t pid' argument.

* src/qemu/qemu_driver.c, src/qemu/qemu_hotplug.c,
  src/qemu/qemu_migration.c, src/qemu/qemu_process.c,
  src/security/security_apparmor.c,
  src/security/security_dac.c,
  src/security/security_driver.h,
  src/security/security_manager.c,
  src/security/security_manager.h,
  src/security/security_nop.c,
  src/security/security_selinux.c,
  src/security/security_stack.c: Change all security APIs to use a
  virDomainDefPtr instead of virDomainObjPtr

13 years agosnapshot: allow reuse of existing files in disk snapshot
Eric Blake [Mon, 9 Jan 2012 18:57:46 +0000 (11:57 -0700)]
snapshot: allow reuse of existing files in disk snapshot

When disk snapshots were first implemented, libvirt blindly refused
to allow an external snapshot destination that already exists, since
qemu will blindly overwrite the contents of that file during the
snapshot_blkdev monitor command, and we don't like a default of
data loss by default.  But VDSM has a scenario where NFS permissions
are intentionally set so that the destination file can only be
created by the management machine, and not the machine where the
guest is running, so that libvirt will necessarily see the destination
file already existing; adding a flag will allow VDSM to force the file
reuse without libvirt complaining of possible data loss.

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

* include/libvirt/libvirt.h.in (virDomainSnapshotCreateFlags): Add
VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT.
* src/libvirt.c (virDomainSnapshotCreateXML): Document it.  Add
note about partial failure.
* tools/virsh.c (cmdSnapshotCreate, cmdSnapshotCreateAs): Add new
flag.
* tools/virsh.pod (snapshot-create, snapshot-create-as): Document
it.
* src/qemu/qemu_driver.c (qemuDomainSnapshotDiskPrepare)
(qemuDomainSnapshotCreateXML): Implement the new flag.

13 years agodocs: standardize description of flags
Eric Blake [Mon, 9 Jan 2012 20:56:42 +0000 (13:56 -0700)]
docs: standardize description of flags

We had loads of different styles in describing the @flags parameter
for various APIs, as well as several APIs that didn't list which
enums provided the bit values valid for the flags.

The end result is one of two formats:
@flags: bitwise-OR of vir...Flags
@flags: extra flags; not used yet, so callers should always pass 0

* src/libvirt.c: Use common sentences for flags.  Also,
(virDomainGetBlockIoTune): Mention virTypedParameterFlags.
(virConnectOpenAuth): Mention virConnectFlags.
(virDomainMigrate, virDomainMigrate2, virDomainMigrateToURI)
(virDomainMigrateToURI2): Mention virDomainMigrateFlags.
(virDomainMemoryPeek): Mention virDomainMemoryFlags.
(virStoragePoolBuild): Mention virStoragePoolBuildFlags.
(virStoragePoolDelete): Mention virStoragePoolDeleteFlags.
(virStreamNew): Mention virStreamFlags.
(virDomainOpenGraphics): Mention virDomainOpenGraphicsFlags.

13 years agoqemu: check for kvm availability before starting kvm guests
Laine Stump [Mon, 9 Jan 2012 19:54:14 +0000 (14:54 -0500)]
qemu: check for kvm availability before starting kvm guests

This *kind of* addresses:

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

(it doesn't eliminate the failure to start, but causes libvirt to give
a better idea about the cause of the failure).

If a guest uses a kvm emulator (e.g. /usr/bin/qemu-kvm) and the guest
is started when kvm isn't available (either because virtualization is
unavailable / has been disabled in the BIOS, or the kvm modules
haven't been loaded for some reason), a semi-cryptic error message is
logged:

  libvirtError: internal error Child process (LC_ALL=C
  PATH=/sbin:/usr/sbin:/bin:/usr/bin /usr/bin/qemu-kvm -device ? -device
  pci-assign,? -device virtio-blk-pci,? -device virtio-net-pci,?) status
  unexpected: exit status 1

This patch notices at process start that a guest needs kvm, and checks
for the presence of /dev/kvm (a reasonable indicator that kvm is
available) before trying to execute the qemu binary. If kvm isn't
available, a more useful (too verbose??) error is logged.

13 years agoqemu: fix a typo on qemuDomainSetBlkioParameters
Alex Jia [Tue, 10 Jan 2012 09:55:01 +0000 (17:55 +0800)]
qemu: fix a typo on qemuDomainSetBlkioParameters

It should be a copy-paste error, the result is programming will result in an
infinite loop again due to without iterating 'j' variable.

* src/qemu/qemu_driver.c: fix a typo on qemuDomainSetBlkioParameters.

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

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agoDocs: Document Android application using libvirt
Michal Privoznik [Mon, 9 Jan 2012 10:41:30 +0000 (11:41 +0100)]
Docs: Document Android application using libvirt

This is actually a patch for VM Manager for Android.

https://www.redhat.com/archives/libvirt-users/2011-November/msg00076.html

13 years agoPolicyKit: Check auth before asking client to obtain it
Jim Fehlig [Tue, 3 Jan 2012 18:35:06 +0000 (11:35 -0700)]
PolicyKit: Check auth before asking client to obtain it

I previously mentioned [1] a PolicyKit issue where libvirt would
proceed with authentication even though polkit-auth failed:

testusr xen134:~> virsh list --all
Attempting to obtain authorization for org.libvirt.unix.manage.
polkit-grant-helper: given auth type (8 -> yes) is bogus
Failed to obtain authorization for org.libvirt.unix.manage.
 Id Name                 State
----------------------------------
  0 Domain-0             running
  - sles11sp1-pv         shut off

AFAICT, libvirt attempts to obtain a privilege it already has,
causing polkit-auth to fail with above message.  Instead of calling
obtain and then checking auth, IMO the workflow should be for the
server to check auth first, and if that fails ask the client to
obtain it and check again.  This workflow also allows for checking
only successful exit of polkit-auth in virConnectAuthGainPolkit().

[1] https://www.redhat.com/archives/libvir-list/2011-December/msg00837.html

13 years agoqemu: add new disk device='lun' for bus='virtio' & type='block'
Laine Stump [Thu, 5 Jan 2012 03:48:38 +0000 (22:48 -0500)]
qemu: add new disk device='lun' for bus='virtio' & type='block'

In the past, generic SCSI commands issued from a guest to a virtio
disk were always passed through to the underlying disk by qemu, and
the kernel would also pass them on.

As a result of CVE-2011-4127 (see:
http://seclists.org/oss-sec/2011/q4/536), qemu now honors its
scsi=on|off device option for virtio-blk-pci (which enables/disables
passthrough of generic SCSI commands), and the kernel will only allow
the commands for physical devices (not for partitions or logical
volumes). The default behavior of qemu is still to allow sending
generic SCSI commands to physical disks that are presented to a guest
as virtio-blk-pci devices, but libvirt prefers to disable those
commands in the standard virtio block devices, enabling it only when
specifically requested (hopefully indicating that the requester
understands what they're asking for). For this purpose, a new libvirt
disk device type (device='lun') has been created.

device='lun' is identical to the default device='disk', except that:

1) It is only allowed if bus='virtio', type='block', and the qemu
   version is "new enough" to support it ("new enough" == qemu 0.11 or
   better), otherwise the domain will fail to start and a
   CONFIG_UNSUPPORTED error will be logged).

2) The option "scsi=on" will be added to the -device arg to allow
   SG_IO commands (if device !='lun', "scsi=off" will be added to the
   -device arg so that SG_IO commands are specifically forbidden).

Guests which continue to use disk device='disk' (the default) will no
longer be able to use SG_IO commands on the disk; those that have
their disk device changed to device='lun' will still be able to use SG_IO
commands.

*docs/formatdomain.html.in - document the new device attribute value.
*docs/schemas/domaincommon.rng - allow it in the RNG
*tests/* - update the args of several existing tests to add scsi=off, and
 add one new test that will test scsi=on.
*src/conf/domain_conf.c - update domain XML parser and formatter

*src/qemu/qemu_(command|driver|hotplug).c - treat
 VIR_DOMAIN_DISK_DEVICE_LUN *almost* identically to
 VIR_DOMAIN_DISK_DEVICE_DISK, except as indicated above.

Note that no support for this new device value was added to any
hypervisor drivers other than qemu, because it's unclear what it might
mean (if anything) to those drivers.

13 years agoqemu: add capabilities flags related to SG_IO
Laine Stump [Tue, 29 Nov 2011 18:37:27 +0000 (13:37 -0500)]
qemu: add capabilities flags related to SG_IO

This patch adds two capabilities flags to deal with various aspects
of supporting SG_IO commands on virtio-blk-pci devices:

  QEMU_CAPS_VIRTIO_BLK_SCSI
    set if -device virtio-blk-pci accepts the scsi="on|off" option
    When present, this is on by default, but can be set to off to disable
    SG_IO functions.

  QEMU_CAPS_VIRTIO_BLK_SG_IO
    set if SG_IO commands are supported in the virtio-blk-pci driver
    (present since qemu 0.11 according to a qemu developer, if I
     understood correctly)

13 years agoconfig: report error when script given for inappropriate interface type
Laine Stump [Fri, 6 Jan 2012 17:59:47 +0000 (12:59 -0500)]
config: report error when script given for inappropriate interface type

This fixes https://bugzilla.redhat.com/show_bug.cgi?id=638633

Although scripts are not used by interfaces of type other than
"ethernet" in qemu, due to the fact that the parser stores the script
name in a union that is only valid when type is ethernet or bridge,
there is no way for anyone except the parser itself to catch the
problem of specifying an interface script for an inappropriate
interface type (by the time the parsed data gets back to the code that
called the parser, all evidence that a script was specified is
forgotten).

Since the parser itself should be agnostic to which type of interface
allows scripts (an example of why: a script specified for an interface
of type bridge is valid for xen domains, but not for qemu domains),
the solution here is to move the script out of the union(s) in the
DomainNetDef, always populate it when specified (regardless of
interface type), and let the driver decide whether or not it is
appropriate.

Currently the qemu, xen, libxml, and uml drivers recognize the script
parameter and do something with it (the uml driver only to report that
it isn't supported). Those drivers have been updated to log a
CONFIG_UNSUPPORTED error when a script is specified for an interface
type that's inappropriate for that particular hypervisor.

(NB: There was earlier discussion of solving this problem by adding a
VALIDATE flag to all libvirt APIs that accept XML, which would cause
the XML to be validated against the RNG files. One statement during
that discussion was that the RNG shouldn't contain hypervisor-specific
things, though, and a proper solution to this problem would require
that (again, because a script for an interface of type "bridge" is
accepted by xen, but not by qemu).

13 years agoqemu: one more client to live/config helper
Eric Blake [Mon, 2 Jan 2012 23:29:57 +0000 (16:29 -0700)]
qemu: one more client to live/config helper

Commit ae523427 missed one pair of functions that could use
the helper routine.

* src/qemu/qemu_driver.c (qemuSetSchedulerParametersFlags)
(qemuGetSchedulerParametersFlags): Simplify.

13 years agoRelease of libvirt-0.9.9
Daniel Veillard [Sat, 7 Jan 2012 04:18:06 +0000 (12:18 +0800)]
Release of libvirt-0.9.9

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

13 years agotests: work around pdwtags 1.9 failure
Eric Blake [Fri, 6 Jan 2012 23:07:34 +0000 (16:07 -0700)]
tests: work around pdwtags 1.9 failure

On rawhide, gcc is new enough to output new DWARF information that
pdwtags has not yet learned, but the resulting 'make check' output
was rather confusing:

$ make -C src check
...
  GEN    virkeepaliveprotocol-structs
die__process_function: DW_TAG_INVALID (0x4109) @ <0x58c> not handled!
WARNING: your pdwtags program is too old
WARNING: skipping the virkeepaliveprotocol-structs test
WARNING: install dwarves-1.3 or newer
...
$ pdwtags --version
v1.9

I've filed the pdwtags deficiency as
https://bugzilla.redhat.com/show_bug.cgi?id=772358

* src/Makefile.am (PDWTAGS): Don't leave -t file behind on version
mismatch.  Soften warning message, since 1.9 is newer than 1.3.
Don't leak stderr from broken version.

13 years agobuild: fix mingw virCommand build
Eric Blake [Sat, 7 Jan 2012 00:32:39 +0000 (17:32 -0700)]
build: fix mingw virCommand build

Commit db371a2 mistakenly added new functions inside a #ifndef WIN32
guard, even though they are needed on all platforms.

* src/util/command.c (virCommandFDSet): Move outside WIN32
conditional.

13 years agotests: avoid test failure on rawhide gnutls
Eric Blake [Fri, 6 Jan 2012 21:07:23 +0000 (14:07 -0700)]
tests: avoid test failure on rawhide gnutls

I hit a VERY weird testsuite failure on rawhide, which included
_binary_ output to stderr, followed by a hang waiting for me
to type something! (Here, using ^@ for NUL):

$ ./commandtest
TEST: commandtest
      WARNING: gnome-keyring:: couldn't send data: Bad file descriptor
.WARNING: gnome-keyring:: couldn't send data: Bad file descriptor
.WARNING: gnome-keyring:: couldn't send data: Bad file descriptor
WARNING: gnome-keyring:: couldn't send data: Bad file descriptor
.8^@^@^@8^@^@^@^A^@^@^@^Bay^A^@^@^@)PRIVATE-GNOME-KEYRING-PKCS11-PROTOCOL-V-1

I finally traced it to the fact that gnome-keyring, called via
gnutls_global_init which is turn called by virNetTLSInit, opens
an internal fd that it expects to communicate to via a
pthread_atfork handler (never mind that it violates POSIX by
using non-async-signal-safe functions in that handler:
https://bugzilla.redhat.com/show_bug.cgi?id=772320).

Our problem stems from the fact that we pulled the rug out from
under the library's expectations by closing an fd that it had
just opened.  While we aren't responsible for fixing the bugs
in that pthread_atfork handler, we can at least avoid the bugs
by not closing the fd in the first place.

* tests/commandtest.c (mymain): Avoid closing fds that were opened
by virInitialize.

13 years agoqemu: Avoid memory leaks on qemuParseRBDString
Alex Jia [Fri, 6 Jan 2012 06:36:34 +0000 (14:36 +0800)]
qemu: Avoid memory leaks on qemuParseRBDString

Detected by valgrind. Leak introduced in commit 5745dc1.

* src/qemu/qemu_command.c: fix memory leak on failure and successful path.

* How to reproduce?
% valgrind -v --leak-check=full ./qemuargv2xmltest

* Actual result:

==2196== 80 bytes in 1 blocks are definitely lost in loss record 3 of 4
==2196==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==2196==    by 0x39CF07F6E1: strdup (in /lib64/libc-2.12.so)
==2196==    by 0x419823: qemuParseRBDString (qemu_command.c:1657)
==2196==    by 0x4221ED: qemuParseCommandLine (qemu_command.c:5934)
==2196==    by 0x422AFB: qemuParseCommandLineString (qemu_command.c:7561)
==2196==    by 0x416864: testCompareXMLToArgvHelper (qemuargv2xmltest.c:48)
==2196==    by 0x417DB1: virtTestRun (testutils.c:141)
==2196==    by 0x415CAF: mymain (qemuargv2xmltest.c:175)
==2196==    by 0x4174A7: virtTestMain (testutils.c:696)
==2196==    by 0x39CF01ECDC: (below main) (in /lib64/libc-2.12.so)
==2196==
==2196== LEAK SUMMARY:
==2196==    definitely lost: 80 bytes in 1 blocks

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agobuild: drop check for ANSI compiler
Eric Blake [Thu, 5 Jan 2012 21:21:11 +0000 (14:21 -0700)]
build: drop check for ANSI compiler

Using automake.git (will become 1.12 someday), I got this error:

configure.ac:90: error: automatic de-ANSI-fication support has been removed
/usr/local/share/aclocal-1.11a/protos.m4:13: AM_C_PROTOTYPES is expanded from...
configure.ac:90: the top level
autom4te: /usr/bin/m4 failed with exit status: 1

In short, pre-C89 compilers are no longer a viable portability
target.  Besides, our code base already requires C99, so worrying
about pre-C89 seems pointless.

* configure.ac (AM_C_PROTOTYPES): Drop, since newer automake no
longer provides it.

13 years agoqemu: fix a bug in numatune
Hu Tao [Wed, 4 Jan 2012 09:41:43 +0000 (17:41 +0800)]
qemu: fix a bug in numatune

When setting numa nodeset for a domain which has no nodeset set
before, libvirtd crashes by dereferencing the pointer to the old
nodemask which is null in that case.

13 years agoqemu: fix use-after-free regression
Eric Blake [Thu, 5 Jan 2012 17:21:34 +0000 (10:21 -0700)]
qemu: fix use-after-free regression

Commit baade4d fixed a memory leak on failure, but in the process,
introduced a use-after-free on success, which can be triggered with:

1. set bandwidth with --live
2. query bandwidth
3. set bandwidth with --live

* src/qemu/qemu_driver.c (qemuDomainSetInterfaceParameters): Don't
free newBandwidth on success.
Reported by Hu Tao.

13 years agoseclabel: fix regression in libvirtd restart
Eric Blake [Wed, 4 Jan 2012 23:01:24 +0000 (16:01 -0700)]
seclabel: fix regression in libvirtd restart

Commit b434329 has a logic bug: seclabel overrides don't set
def->type, but the default value is 0 (aka static).  Restarting
libvirtd would thus reject the XML for any domain with an
override of <seclabel relabel='no'/> (which happens quite
easily if a disk image lives on NFS), with a message:

2012-01-04 22:29:40.949+0000: 6769: error : virSecurityLabelDefParseXMLHelper:2593 : XML error: security label is missing

Fix the logic to never read from an override's def->type, and
to allow a missing <label> subelement when relabel is no.  There's
a lot of stupid double-negatives in the code (!norelabel) because
of the way that we want the zero-initialized defaults to behave.

* src/conf/domain_conf.c (virSecurityLabelDefParseXMLHelper): Use
type field from correct location.

13 years agocommand: Discard FD_SETSIZE limit for opened files
Michal Privoznik [Tue, 3 Jan 2012 10:29:07 +0000 (11:29 +0100)]
command: Discard FD_SETSIZE limit for opened files

Currently, virCommand implementation uses FD_ macros from
sys/select.h. However, those cannot handle more opened files
than FD_SETSIZE. Therefore switch to generalized implementation
based on array of integers.

13 years agoSupport Xen domctl v8
Jim Fehlig [Wed, 4 Jan 2012 15:47:37 +0000 (08:47 -0700)]
Support Xen domctl v8

xen-unstable c/s 23874:651aed73b39c added another member to
xen_domctl_getdomaininfo struct and bumped domctl version to 8.
Add a corresponding domctl v8 struct in xen hypervisor sub-driver
and detect domctl v8 during initialization.

13 years agoFix xenstore serial console path for HVM guests
Jim Fehlig [Tue, 3 Jan 2012 22:39:59 +0000 (15:39 -0700)]
Fix xenstore serial console path for HVM guests

The console path in xenstore is /local/domain/<id>/console/tty
for PV guests (PV console) and /local/domain/<id>/serial/0/tty
(serial console) for HVM guests.  Similar to Xen's in-tree console
client, read the correct path for PV vs HVM.

13 years agoschemas: Allow '.' in CPU feature name
Jiri Denemark [Tue, 3 Jan 2012 20:59:51 +0000 (21:59 +0100)]
schemas: Allow '.' in CPU feature name

We already support CPU features with '.' in their name (e.g., sse4.1) so
we should not forbid that in the schema.