]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
11 years agoDon't clobber 'ret' in LXC XML test case
Daniel P. Berrange [Wed, 25 Sep 2013 08:35:29 +0000 (09:35 +0100)]
Don't clobber 'ret' in LXC XML test case

The testCompareXMLToXMLHelper method clobbered the 'ret' variable
in several places leading to a failure to report OOM errors from
the test suite.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix crash on OOM in virDomainSnapshotDefParse
Daniel P. Berrange [Wed, 25 Sep 2013 08:34:25 +0000 (09:34 +0100)]
Fix crash on OOM in virDomainSnapshotDefParse

The virDomainSnapshotDefParse method assigned to def->ndisks
before allocating def->disks. Thus if an OOM occurred, the
cleanup code would access out of bounds.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoDon't clobber return value in virInterfaceDefParseProtoIPv6
Daniel P. Berrange [Wed, 25 Sep 2013 08:33:12 +0000 (09:33 +0100)]
Don't clobber return value in virInterfaceDefParseProtoIPv6

Several places in virInterfaceDefParseProtoIPv6 clobber the
default 'ret' return value. So when jumping to cleanup on
error, 'ret' may mistakenly be set to 0 instead of -1. This
caused failure to report OOM errors, meaning data was silently
lost during parsing.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix handling of OOM when getting Xen dom ID
Daniel P. Berrange [Wed, 25 Sep 2013 08:31:30 +0000 (09:31 +0100)]
Fix handling of OOM when getting Xen dom ID

The methods for obtaining the Xen dom ID cannot distinguish
between returning -1 due to an error and returning -1 due to
the domain being shutoff. Change them to return the dom ID
via an output parameter.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix crash on OOM in xenParseSxpr
Daniel P. Berrange [Wed, 25 Sep 2013 08:30:20 +0000 (09:30 +0100)]
Fix crash on OOM in xenParseSxpr

The xenParseSxpr method sets def->nconsoles to 1 before allocating
the def->consoles array. If the allocation fails due to OOM the
cleanup code will thus crash accessing out of bounds.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agovirsh-domain: Add a missing check and fix leak in cmdScreenshot
Hongwei Bi [Wed, 25 Sep 2013 14:54:24 +0000 (22:54 +0800)]
virsh-domain: Add a missing check and fix leak in cmdScreenshot

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoFix leak of serial value in xenFormatXM on OOM
Daniel P. Berrange [Tue, 24 Sep 2013 15:46:44 +0000 (16:46 +0100)]
Fix leak of serial value in xenFormatXM on OOM

If an OOM occurs in xenFormatXM when formatting to the
serial device value, the value is leaked.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix broken formatting on OOM in xenFormatXM
Daniel P. Berrange [Tue, 24 Sep 2013 15:45:58 +0000 (16:45 +0100)]
Fix broken formatting on OOM in xenFormatXM

If an OOM occurs when xenFormatXM is setting the 'hpet'
variable it is silently ignored. Fix it to propagate
to the callers.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix crash on OOM in xenParseXM handling consoles
Daniel P. Berrange [Tue, 24 Sep 2013 15:45:09 +0000 (16:45 +0100)]
Fix crash on OOM in xenParseXM handling consoles

The xenParseXM sets def->nconsoles to 1 before claling
VIR_REALLOC_N on def->consoles. So if the alloc fails
due to OOM, the cleanup code will crash accessing a
console that does not exist.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix leak of char device in xenParseXM
Daniel P. Berrange [Tue, 24 Sep 2013 15:44:26 +0000 (16:44 +0100)]
Fix leak of char device in xenParseXM

If an OOM occurs in xenParseXM, a virDomainChrDef may be
leaked.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix leak of command line args in qemuParseCommandLine
Daniel P. Berrange [Tue, 24 Sep 2013 15:38:26 +0000 (16:38 +0100)]
Fix leak of command line args in qemuParseCommandLine

If qemuParseCommandLine finds an arg it does not understand
it adds it to the QEMU passthrough custom arg list. If the
qemuParseCommandLine method hits an error for any reason
though, it just does 'VIR_FREE(cmd)' on the custom arg list.
This means all actual args / env vars are leaked. Introduce
a qemuDomainCmdlineDefFree method to be used for cleanup.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix leak in qemuParseCommandLine on OOM
Daniel P. Berrange [Tue, 24 Sep 2013 15:37:24 +0000 (16:37 +0100)]
Fix leak in qemuParseCommandLine on OOM

If the call to virDomainControllerInsert fails in
qemuParseCommandLine, the controller struct is leaked.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix leak in qemuStringToArgvEnv upon OOM
Daniel P. Berrange [Tue, 24 Sep 2013 15:34:06 +0000 (16:34 +0100)]
Fix leak in qemuStringToArgvEnv upon OOM

The 'qemuStringToArgvEnv' method splits up a string of command
line env/args to an 'arglist' array. It then copies env vars
to a 'progenv' array and args to a 'progargv' array. When
copyin the env vars, it NULL-ifies the element in 'arglist'
that is copied.

Upon OOM the 'virStringListFree' is called on progenv and
arglist. Unfortunately, because the elements in 'arglist'
related to env vars have been set to NULL, the call to
virStringListFree(arglist) doesn't free anything, even
though some non-NULL args vars still exist later in the
array.

To fix this leak, stop NULL-ifying the 'arglist' elements,
and change the cleanup code to only free elements in the
'arglist' array, not 'progenv'.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix missing jump to error cleanup in qemuParseCommandLineDisk
Daniel P. Berrange [Tue, 24 Sep 2013 15:28:22 +0000 (16:28 +0100)]
Fix missing jump to error cleanup in qemuParseCommandLineDisk

In a number of places in qemuParseCommandLineDisk, an error
is reported, but no 'goto error' jump is used. This causes
failure to report OOM conditions to the caller.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix leak in qemuParseCommandLineDisk on OOM
Daniel P. Berrange [Tue, 24 Sep 2013 15:27:32 +0000 (16:27 +0100)]
Fix leak in qemuParseCommandLineDisk on OOM

If OOM occurs in qemuParseCommandLineDisk some intermediate
variables will be leaked when parsing Sheepdog or RBD disks.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix leak on OOM in qemuBuildCommandLine dealing with sound card
Daniel P. Berrange [Tue, 24 Sep 2013 15:26:18 +0000 (16:26 +0100)]
Fix leak on OOM in qemuBuildCommandLine dealing with sound card

The qemuBuildCommandLine code for parsing sound cards will leak
an intermediate variable if an OOM occurs. Move the free'ing of
the variable earlier to avoid the leak.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix failure to honour OOM status in qemuParseNBDString
Daniel P. Berrange [Tue, 24 Sep 2013 15:25:16 +0000 (16:25 +0100)]
Fix failure to honour OOM status in qemuParseNBDString

In qemuParseNBDString, if the virURIParse fails, the
error is not reported to the caller. Instead execution
falls through to the non-URI codepath causing memory
leaks later on.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAvoid leak in qemuParseRBDString on failure of qemuAddRBDHost
Daniel P. Berrange [Tue, 24 Sep 2013 15:24:06 +0000 (16:24 +0100)]
Avoid leak in qemuParseRBDString on failure of qemuAddRBDHost

If qemuAddRBDHost fails due to parsing problems or OOM, then
qemuParseRBDString cleanup is skipped causing a memory leak.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix leak of address string in qemuDomainPCIAddressGetNextSlot
Daniel P. Berrange [Tue, 24 Sep 2013 15:13:44 +0000 (16:13 +0100)]
Fix leak of address string in qemuDomainPCIAddressGetNextSlot

qemuDomainPCIAddressGetNextSlot has a loop for finding
compatible PCI buses. In the loop body it creates a
PCI address string, but never frees this. This causes
a leak if the loop executes more than one iteration,
or if a call in the loop body fails.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix leak in virDomainDefParseXML parsing vcpupin
Daniel P. Berrange [Tue, 24 Sep 2013 15:12:47 +0000 (16:12 +0100)]
Fix leak in virDomainDefParseXML parsing vcpupin

If virBitmapNew fails due to OOM, the 'vcpupin' variable
is leaked.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix leak in virDomainVcpuPinDefParseXML parsing cpumask
Daniel P. Berrange [Tue, 24 Sep 2013 15:11:39 +0000 (16:11 +0100)]
Fix leak in virDomainVcpuPinDefParseXML parsing cpumask

If the virBitmapParse method fails due to OOM, we leak
the 'tmp' variable string.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAvoid leak if virDomainSoundCodecDefParseXML return error
Daniel P. Berrange [Tue, 24 Sep 2013 15:10:49 +0000 (16:10 +0100)]
Avoid leak if virDomainSoundCodecDefParseXML return error

If virDomainSoundCodecDefParseXML returns an error (eg due
to OOM), then the xml nodeset codecNodes is leaked.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix leak in virDomainVcpuPinDefArrayFree
Daniel P. Berrange [Tue, 24 Sep 2013 15:09:36 +0000 (16:09 +0100)]
Fix leak in virDomainVcpuPinDefArrayFree

If virDomainVcpuPinDefArrayFree is called with def != NULL,
but nvcpupin == 0, then it leaks memory for 'def'. This is
an unusual scenario, but it hits when cleaning up after an
OOM during parsing of XML.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoqemu: prefer to put a Q35 machine's dmi-to-pci-bridge at 00:1E.0
Laine Stump [Wed, 25 Sep 2013 12:02:19 +0000 (08:02 -0400)]
qemu: prefer to put a Q35 machine's dmi-to-pci-bridge at 00:1E.0

This resolves one of the issues listed in:

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

00:1E.0 is the location of this controller on at least some actual Q35
hardware, so we try to replicate the placement. The bridge should work
just as well in any other location though, so if 00:1E.0 isn't
available, just allow it to be auto-assigned anywhere appropriate.

11 years agoqemu: turn if into switch in qemuDomainValidateDevicePCISlotsQ35
Laine Stump [Wed, 25 Sep 2013 10:59:46 +0000 (06:59 -0400)]
qemu: turn if into switch in qemuDomainValidateDevicePCISlotsQ35

This will make it simpler to add checks for other types of
controllers.

This is a prerequisite for patches to resolve:

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

11 years agoqemu: support ich9-intel-hda audio device
Laine Stump [Tue, 24 Sep 2013 14:17:38 +0000 (10:17 -0400)]
qemu: support ich9-intel-hda audio device

This resolves one of the issues in:

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

This device is identical to qemu's "intel-hda" device (known as "ich6"
in libvirt), but has a different PCI device ID (which matches the ID
of the hda audio built into the ich9 chipset, of course). It's not
supported in earlier versions of qemu, so it requires a capability
bit.

11 years agoqemu: replace multiple strcmps with a switch on an enum
Laine Stump [Tue, 24 Sep 2013 13:38:32 +0000 (09:38 -0400)]
qemu: replace multiple strcmps with a switch on an enum

I'm not sure why this code was written to compare the strings that it
had just retrieved from an enum->string conversion, rather than just
look at the original enum values, but this yields the same results,
and is much more efficient (especially as you add more devices).

This is a prerequisite for patches to resolve:

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

11 years agoqemu: allow some PCI devices to be attached to PCIe slots
Laine Stump [Tue, 24 Sep 2013 13:16:25 +0000 (09:16 -0400)]
qemu: allow some PCI devices to be attached to PCIe slots

Part of the resolution to:

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

Although most devices available in qemu area defined as PCI devices,
and strictly speaking should only be attached via a PCI slot, in
practice qemu allows them to be attached to a PCIe slot and sometimes
this makes sense.

For example, The UHCI and EHCI USB controllers are usually attached
directly to the PCIe "root complex" (i.e. PCIe slots) on real
hardware, so that should be possible for a Q35-based qemu virtual
machine as well.

We still want to prefer a standard PCI slot when auto-assigning
addresses, though, and in general to disallow attaching PCI devices
via PCIe slots.

This patch makes that possible by adding a new
QEMU_PCI_CONNECT_TYPE_EITHER_IF_CONFIG flag. Three things are done
with this flag:

1) It is set for the "pcie-root" controller

2) qemuCollectPCIAddress() now has a set of nested switches that set
this "EITHER" flag for devices that we want to allow connecting to
pcie-root when specifically requested in the config.

3) qemuDomainPCIAddressFlagsCompatible() adds this new flag to the
"flagsMatchMask" if the address being checked came from config rather
than being newly auto-allocated by libvirt (this knowledge is
conveniently already available in the "fromConfig" arg).

Now any device having the EITHER flag set can be connected to
pcie-root if explicitly requested, but auto-allocated addresses for
those devices will still be standard PCI slots instead.

This patch only loosens the restrictions on devices that have been
specifically requested, but the setup is such that it should be fairly
easy to add new devices.

11 years agoqemu: eliminate redundant if clauses in qemuCollectPCIAddress
Laine Stump [Tue, 24 Sep 2013 10:49:26 +0000 (06:49 -0400)]
qemu: eliminate redundant if clauses in qemuCollectPCIAddress

Replace them with switch cases. This will make it more efficient when
we add exceptions for more controller types, and other device types.

This is a prerequisite for patches to resolve:

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

11 years agobridge driver: don't masquerade local subnet broadcast/multicast packets
Laszlo Ersek [Wed, 25 Sep 2013 10:45:26 +0000 (12:45 +0200)]
bridge driver: don't masquerade local subnet broadcast/multicast packets

Packets sent by guests on virbrN, *or* by dnsmasq on the same, to
- 255.255.255.255/32 (netmask-independent local network broadcast
  address), or to
- 224.0.0.0/24 (local subnetwork multicast range)
are never forwarded, hence it is not necessary to masquerade them.

In fact we must not masquerade them: translating their source addresses or
source ports (where applicable) may confuse receivers on virbrN.

One example is the DHCP client in OVMF (= UEFI firmware for virtual
machines):

  http://thread.gmane.org/gmane.comp.bios.tianocore.devel/1506/focus=2640

It expects DHCP replies to arrive from remote source port 67. Even though
dnsmasq conforms to that, the destination address (255.255.255.255) and
the source address (eg. 192.168.122.1) in the reply allow the UDP
masquerading rule to match, which rewrites the source port to or above
1024. This prevents the DHCP client in OVMF from accepting the packet.

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

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
11 years agoutil/viriptables: add/remove rules that short-circuit masquerading
Laszlo Ersek [Wed, 25 Sep 2013 10:45:25 +0000 (12:45 +0200)]
util/viriptables: add/remove rules that short-circuit masquerading

The functions
- iptablesAddForwardDontMasquerade(),
- iptablesRemoveForwardDontMasquerade
handle exceptions in the masquerading implemented in the POSTROUTING chain
of the "nat" table. Such exceptions should be added as chronologically
latest, logically top-most rules.

The bridge driver will call these functions beginning with the next patch:
some special destination IP addresses always refer to the local
subnetwork, even though they don't match any practical subnetwork's
netmask. Packets from virbrN targeting such IP addresses are never routed
outwards, but the current rules treat them as non-virbrN-destined packets
and masquerade them. This causes problems for some receivers on virbrN.

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
11 years agoqemu: Wire up better early error reporting
Peter Krempa [Wed, 18 Sep 2013 14:23:14 +0000 (16:23 +0200)]
qemu: Wire up better early error reporting

The previous patches added infrastructure to report better errors from
monitor in some cases. This patch finalizes this "feature" by enabling
this enhanced error reporting on early phases of VM startup. In these
phases the possibility of qemu producing a useful error message is
really high compared to running it during the whole life cycle. After
the start up is complete, the feature is disabled to provide the usual
error messages so that users are not confused by possibly irrelevant
messages that may be in the domain log.

The original motivation to do this enhancement is to capture errors when
using VFIO device passthrough, where qemu reports errors after the
monitor is initialized and the existing error catching code couldn't
catch this producing a unhelpful message:

 # virsh start test
 error: Failed to start domain test
 error: Unable to read from monitor: Connection reset by peer

With this change, the message is changed to:

 # virsh start test
 error: Failed to start domain test
 error: internal error: early end of file from monitor: possible problem:
 qemu-system-x86_64: -device vfio-pci,host=00:1a.0,id=hostdev0,bus=pci.0,addr=0x5: vfio: error, group 8 is not viable, please ensure all devices within the iommu_group are bound to their vfio bus driver.
 qemu-system-x86_64: -device vfio-pci,host=00:1a.0,id=hostdev0,bus=pci.0,addr=0x5: vfio: failed to get group 8
 qemu-system-x86_64: -device vfio-pci,host=00:1a.0,id=hostdev0,bus=pci.0,addr=0x5: Device 'vfio-pci' could not be initialized

11 years agoqemu: monitor: Produce better errors on monitor hangup
Peter Krempa [Wed, 18 Sep 2013 14:17:39 +0000 (16:17 +0200)]
qemu: monitor: Produce better errors on monitor hangup

Change the monitor error code to add the ability to access the qemu log
file using a file descriptor so that we can dig in it for a more useful
error message. The error is now logged on monitor hangups and overwrites
a possible lesser error. A hangup on the monitor usualy means that qemu
has crashed and there's a significant chance it produced a useful error
message.

The functionality will be latent until the next patch.

11 years agoqemu: monitor: Add infrastructure to access VM logs for better err msgs
Peter Krempa [Wed, 18 Sep 2013 14:12:17 +0000 (16:12 +0200)]
qemu: monitor: Add infrastructure to access VM logs for better err msgs

Early VM startup errors usually produce a better error message in the
machine log file. Currently we were accessing it only when the process
exited during certain phases of startup. This will help adding a more
comprehensive error extraction for early qemu startup phases.

This patch adds infrastructure to keep a file descriptor for the machine
log file that will be used in case an error happens.

11 years agoqemu_process: Make qemuProcessReadLog() more versatile and reusable
Peter Krempa [Wed, 18 Sep 2013 12:43:52 +0000 (14:43 +0200)]
qemu_process: Make qemuProcessReadLog() more versatile and reusable

Teach the function to skip character device definitions printed by qemu
at startup in addition to libvirt log messages and make it usable from
outside of qemu_process.c. Also add documentation about the func.

11 years agoCheck return value of virDomainControllerInsert when parsing QEMU args
Daniel P. Berrange [Mon, 23 Sep 2013 16:44:49 +0000 (17:44 +0100)]
Check return value of virDomainControllerInsert when parsing QEMU args

The parsing of '-usb' did not check for failure of the
virDomainControllerInsert method. As a result on OOM, the
parser mistakenly attached USB disks to the IDE controller.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoHonour error returned by virBitmapFormat
Daniel P. Berrange [Mon, 23 Sep 2013 16:43:47 +0000 (17:43 +0100)]
Honour error returned by virBitmapFormat

The code formatting NUMA args was ignoring the return value
of virBitmapFormat, so on OOM, it would silently drop the
NUMA cpumask arg.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd missing check for OOM when building boot menu args
Daniel P. Berrange [Mon, 23 Sep 2013 14:11:19 +0000 (15:11 +0100)]
Add missing check for OOM when building boot menu args

When building boot menu args, if OOM occurred the CLI args
would end up containing  'order=(null)' due to a missing
call to 'virBufferError'.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix format specifier for OOM test fprintfs
Daniel P. Berrange [Tue, 24 Sep 2013 15:56:53 +0000 (16:56 +0100)]
Fix format specifier for OOM test fprintfs

The testutils.c file had some fprintfs which had not been
converted from %d to %zu, when 'testCounter' change to be
a size_t. This was a build breaker if --enable-test-oom
was enabled

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agomaint: update to latest gnulib
Eric Blake [Tue, 24 Sep 2013 12:49:10 +0000 (06:49 -0600)]
maint: update to latest gnulib

Since we're about to freeze, it's time to pick up the latest
upstream gnulib.  Among other changes, gnulib now guarantees the
use of some -f flags that we were previously manually adding.

* .gnulib: Update to latest, in part for warning improvements.
* m4/virt-compile-warnings.m4 (LIBVIRT_COMPILE_WARNINGS): Drop
flags that are now guaranteed by gnulib.
* bootstrap: Resync to gnulib.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoAlways open files in binary mode in virFDStreamOpenFileInternal
Claudio Bley [Tue, 24 Sep 2013 09:57:38 +0000 (11:57 +0200)]
Always open files in binary mode in virFDStreamOpenFileInternal

On win32, using text mode for binary files might result in short
reads since ASCII character 0x1A is interpreted as EOF. Also, it
could lead to problems using the seek functions because of the \r
handling.

Signed-off-by: Claudio Bley <cbley@av-test.de>
11 years agotest: fix call to virFDStreamOpenFile in testDomainScreenshot
Claudio Bley [Tue, 24 Sep 2013 09:57:37 +0000 (11:57 +0200)]
test: fix call to virFDStreamOpenFile in testDomainScreenshot

N.B.  This had no ill effects as long as O_RDONLY is defined to
      to be 0, such that the expression (O_RDONLY < 0) yielded 0
      again.

Signed-off-by: Claudio Bley <cbley@av-test.de>
11 years agoDon't ignore allocation failure in virCommandAddEnvPassCommon
Daniel P. Berrange [Mon, 23 Sep 2013 13:20:37 +0000 (14:20 +0100)]
Don't ignore allocation failure in virCommandAddEnvPassCommon

The virCommandAddEnvPassCommon method ignored the failure to
pre-allocate the env variable array with VIR_RESIZE_N. While
this is harmless, it confuses the test harness which is trying
to validate OOM handling of every individual allocation call.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix reporting of errors in OOM injection code
Daniel P. Berrange [Mon, 23 Sep 2013 13:19:25 +0000 (14:19 +0100)]
Fix reporting of errors in OOM injection code

When the various viralloc.c functions were changed to use the
normal error reporting code, the OOM injection code paths
were not updated to report errors.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix missing OOM check in qemuParseCommandLine when splitting strings
Daniel P. Berrange [Mon, 23 Sep 2013 13:18:04 +0000 (14:18 +0100)]
Fix missing OOM check in qemuParseCommandLine when splitting strings

The qemuParseCommandLine method did not check the return value of
virStringSplit to see if OOM had occurred. This lead to dereference
of a NULL pointer on OOM.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix error checking of qemuParseKeywords return status
Daniel P. Berrange [Mon, 23 Sep 2013 13:16:09 +0000 (14:16 +0100)]
Fix error checking of qemuParseKeywords return status

Most callers of qemuParseKeywords were assigning its return
value to a 'size_t' variable. Then then also checked '< 0'
for error condition, but this will never be true with the
unsigned size_t variable. Rather than using 'ssize_t', change
qemuParseKeywords so that the element count is returned via
an output parameter, leaving the return value solely as an
error indicator.

This avoids a crash accessing beyond the end of an error
upon OOM.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix allocation of arglist in qemuStringToArgvEnv
Daniel P. Berrange [Mon, 23 Sep 2013 13:14:04 +0000 (14:14 +0100)]
Fix allocation of arglist in qemuStringToArgvEnv

In

  commit 41b550567918790cb304378f39c3ba369bcca28e
  Author: Eric Blake <eblake@redhat.com>
  Date:   Wed Aug 28 15:01:23 2013 -0600

    qemu: simplify list cleanup

The qemuStringToArgvEnv method was changed to use virStringFreeList
to free the 'arglist' array. This method assumes the string list
array is NULL terminated, however, qemuStringToArgvEnv was not
ensuring this when populating 'arglist'. This caused an out of
bounds access by virStringFreeList when OOM occured in the initial
loop of qemuStringToArgvEnv

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix crash on OOM in qemuAddRBDHost
Daniel P. Berrange [Mon, 23 Sep 2013 13:11:34 +0000 (14:11 +0100)]
Fix crash on OOM in qemuAddRBDHost

When parsing the RBD hosts, it increments the 'nhosts' counter
before increasing the 'hosts' array allocation. If an OOM then
occurs when increasing the array allocation, the cleanup block
will attempt to access beyond the end of the array. Switch
to using VIR_EXPAND_N instead of VIR_REALLOC_N to protect against
this mistake

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix crash on OOM in qemuDomainCCWAddressSetCreate()
Daniel P. Berrange [Mon, 23 Sep 2013 13:10:35 +0000 (14:10 +0100)]
Fix crash on OOM in qemuDomainCCWAddressSetCreate()

If OOM occurs in qemuDomainCCWAddressSetCreate, it jumps to
a cleanup block and frees the partially initialized object.
It then mistakenly returns the address of the just free'd
pointer instead of NULL.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix crash if OOM occurs when creating virConnectPtr
Daniel P. Berrange [Mon, 23 Sep 2013 13:09:19 +0000 (14:09 +0100)]
Fix crash if OOM occurs when creating virConnectPtr

If a OOM error occurs in virGetConnect, this may cause the
virConnectDispose method to de-reference a NULL pointer,
since the close callback will not have been initialized.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix crash on OOM in parsing CPU mask in domain XML
Daniel P. Berrange [Mon, 23 Sep 2013 13:08:35 +0000 (14:08 +0100)]
Fix crash on OOM in parsing CPU mask in domain XML

The virDomainDefParseXML method did not check the return value
of the virBitmapNew API call for NULL. This lead to a crash on
OOM

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix crash on OOM when parsing disk security label
Daniel P. Berrange [Mon, 23 Sep 2013 13:07:51 +0000 (14:07 +0100)]
Fix crash on OOM when parsing disk security label

If an OOM error occurs in virSecurityDeviceLabelDefParseXML the
cleanup code may free an uninitialized pointer, causing a crash

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoconf: Fix virNetworkAssignDef's comment.
lawrancejing [Tue, 24 Sep 2013 02:05:37 +0000 (10:05 +0800)]
conf: Fix virNetworkAssignDef's comment.

11 years agoAdd test case for virNetServerClient object identity code
Daniel P. Berrange [Mon, 23 Sep 2013 11:39:19 +0000 (12:39 +0100)]
Add test case for virNetServerClient object identity code

Start a test case for the virNetServerClient object, which
initially checks the creation of a virIdentityPtr object.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd a virNetSocketNewConnectSockFD method
Daniel P. Berrange [Mon, 23 Sep 2013 10:58:26 +0000 (11:58 +0100)]
Add a virNetSocketNewConnectSockFD method

To allow creation of a virNetSocketPtr instance from a pre-opened
socketpair FD, add a virNetSocketNewConnectSockFD method.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agopython: add bindings for virConnectGetCPUModelNames
Giuseppe Scrivano [Mon, 23 Sep 2013 09:46:04 +0000 (11:46 +0200)]
python: add bindings for virConnectGetCPUModelNames

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agovirsh: add function to get the CPU models for an arch
Giuseppe Scrivano [Mon, 23 Sep 2013 09:46:03 +0000 (11:46 +0200)]
virsh: add function to get the CPU models for an arch

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agovirConnectGetCPUModelNames: add the support for the test protocol
Giuseppe Scrivano [Mon, 23 Sep 2013 09:46:02 +0000 (11:46 +0200)]
virConnectGetCPUModelNames: add the support for the test protocol

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agovirConnectGetCPUModelNames: add the support for qemu
Giuseppe Scrivano [Mon, 23 Sep 2013 09:46:01 +0000 (11:46 +0200)]
virConnectGetCPUModelNames: add the support for qemu

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agovirConnectGetCPUModelNames: implement the remote protocol
Giuseppe Scrivano [Mon, 23 Sep 2013 09:46:00 +0000 (11:46 +0200)]
virConnectGetCPUModelNames: implement the remote protocol

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agocpu: add function to get the models for an arch
Giuseppe Scrivano [Mon, 23 Sep 2013 09:45:59 +0000 (11:45 +0200)]
cpu: add function to get the models for an arch

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agolibvirt: add new public API virConnectGetCPUModelNames
Giuseppe Scrivano [Mon, 23 Sep 2013 09:45:58 +0000 (11:45 +0200)]
libvirt: add new public API virConnectGetCPUModelNames

The new function virConnectGetCPUModelNames allows to retrieve the list
of CPU models known by the hypervisor for a specific architecture.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: ensure 'make check' sees up-to-date config.h
Eric Blake [Wed, 18 Sep 2013 22:11:25 +0000 (16:11 -0600)]
build: ensure 'make check' sees up-to-date config.h

Nehal J. Wani reported on IRC a rather interesting build failure:

In file included from util/virnetdevbridge.c:53:0:
/usr/include/linux/in6.h:30:8: error: redefinition of 'struct in6_addr'
 struct in6_addr {
        ^

I traced it to the fact that he ran 'git pull; make check' across
commit e62e0094.  What happened is that the configure changes
result in a new variable that was set to be defined on his system,
but config.h was not regenerated to contain the value of that
variable.  Running 'make' instead of 'make check' cleaned up the
problem.  A bit more investigation, and I see that in Makefile.am,
automake sticks rules that rebuild config.h as part of 'make all',
and that we also had a dependency 'check-local: all'; BUT the
rule for check-local is run only at the point when the top-level
directory is visited.  Automake documents that SUBDIRS should
contain an explicit '.' at the point the top-level should be
visited (defaulting to last, if it doesn't appear).  Sure enough,
with this patch, 'make check' now does the top-level 'all' rules,
which regenerates 'config.h' BEFORE compiling any code that might
depend on changed content of that file.

* Makefile.am (SUBDIRS): Put '.' first, not last.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoFix typo in identity code which is pre-requisite for CVE-2013-4311
Daniel P. Berrange [Mon, 23 Sep 2013 11:46:25 +0000 (12:46 +0100)]
Fix typo in identity code which is pre-requisite for CVE-2013-4311

The fix for CVE-2013-4311 had a pre-requisite enhancement
to the identity code

  commit db7a5688c05f3fd60d9d2b74c72427eb9ee9c176
  Author: Daniel P. Berrange <berrange@redhat.com>
  Date:   Thu Aug 22 16:00:01 2013 +0100

    Also store user & group ID values in virIdentity

This had a typo which caused the group ID to overwrite the
user ID string. This meant any checks using this would have
the wrong ID value. This only affected the ACL code, not the
initial polkit auth. It also leaked memory.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agodocs: Load libvirt_access*.xml from build dir
Jiri Denemark [Fri, 20 Sep 2013 09:47:39 +0000 (11:47 +0200)]
docs: Load libvirt_access*.xml from build dir

The xml files are generated in build directory and thus docs/newapi.xsl
was not able to find them in a VPATH build.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agoLXC: Check the existence of dir before resolving symlinks
Chen Hanxiao [Mon, 23 Sep 2013 10:22:17 +0000 (11:22 +0100)]
LXC: Check the existence of dir before resolving symlinks

If a dir does not exist, raise an immediate error in logs
rather than letting virFileResolveAllLinks fail, since this
gives better error reporting to the user.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
11 years agoLXC: follow the unit style of /proc/meminfo
Chen Hanxiao [Mon, 23 Sep 2013 10:01:07 +0000 (11:01 +0100)]
LXC: follow the unit style of /proc/meminfo

When FUSE is enabled, the LXC container is setup with
a custom /proc/meminfo file. This file uses "KB" as a
suffix, rather than "kB" which is the kernel's style.
Fix this inconsistency to avoid confusing apps.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
11 years agoconf: Do better job when comparing features ABI compatibility
Peter Krempa [Fri, 20 Sep 2013 13:03:43 +0000 (15:03 +0200)]
conf: Do better job when comparing features ABI compatibility

The ABI compatibility check for domain features didn't check the
expanded HyperV and APIC EOI values, thus possibly allowing change in
guest ABI.

Add the check and use typecasted switch statement to warn developers
when adding a new HyperV feature.

11 years agoFix potential use of uninitialized value in virDomainGetVcpuPinInfo
Daniel P. Berrange [Fri, 20 Sep 2013 12:54:13 +0000 (13:54 +0100)]
Fix potential use of uninitialized value in virDomainGetVcpuPinInfo

The virDomainGetVcpuPinInfo python wrapper had a potential use of
uninitialized values

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoqemu: Fix seamless SPICE migration
Martin Kletzander [Fri, 20 Sep 2013 14:40:20 +0000 (16:40 +0200)]
qemu: Fix seamless SPICE migration

Since the wait is done during migration (still inside
QEMU_ASYNC_JOB_MIGRATION_OUT), the code should enter the monitor as such
in order to prohibit all other jobs from interfering in the meantime.
This patch fixes bug #1009886 in which qemuDomainGetBlockInfo was
waiting on the monitor condition and after GetSpiceMigrationStatus
mangled its internal data, the daemon crashed.

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

11 years agoVMware: Make version parsing testable and add tests
Doug Goldstein [Wed, 18 Sep 2013 14:30:35 +0000 (09:30 -0500)]
VMware: Make version parsing testable and add tests

This splits up the version parsing code into a callable API like QEMU
help/version string parsing so that we can test it as we need to add
additional patterns for newer versions/products.

11 years agoVMware: Store vmrun binary's path in the driver
Doug Goldstein [Sun, 15 Sep 2013 04:28:20 +0000 (23:28 -0500)]
VMware: Store vmrun binary's path in the driver

Rather than looking up the path to vmrun each time we call it, look it
up once and save it. This sets up the ability for us to detect where the
path is on Mac OS X and not have to look it up each time we execute it.

11 years agoVMware: Convert driver type defines to enum
Doug Goldstein [Sat, 14 Sep 2013 04:28:30 +0000 (23:28 -0500)]
VMware: Convert driver type defines to enum

The VMware driver supports multiple backends for the VMware Player and
VMware Workstation, convert this logic into enum and use VIR_ENUM_IMPL()
to provide conversions to and from strings.

11 years agoDon't dereference NULL in qemumonitorjsontest
Ján Tomko [Fri, 20 Sep 2013 11:02:43 +0000 (13:02 +0200)]
Don't dereference NULL in qemumonitorjsontest

In case of an error, qemuMonitorTestNewSimple returns NULL.
Error out instead of dereferencing it.

Found by Coverity, reported by John Ferlan.

11 years agoAdd checking of dbus_message_iter_append_basic return value
Daniel P. Berrange [Fri, 20 Sep 2013 10:47:33 +0000 (11:47 +0100)]
Add checking of dbus_message_iter_append_basic return value

Coverity complains that the test suite did not check the
return value of dbus_message_iter_append_basic() as we did
in most other places.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoqemu: use "ide" as device name for implicit SATA controller on Q35
Laine Stump [Fri, 20 Sep 2013 10:00:48 +0000 (06:00 -0400)]
qemu: use "ide" as device name for implicit SATA controller on Q35

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

The Q35 machinetype has an implicit SATA controller at 00:1F.2 which
isn't given the "expected" id of ahci0 by qemu when it's created. The
original suggested solution to this problem was to not specify any
controller for the disks that use the default controller and just
specify "unit=n" instead; qemu should then use the first IDE or SATA
controller for the disk.

Unfortunately, this "solution" is ignorant of the fact that in the
case of SATA disks, the "unit" attribute in the disk XML is actually
*not* being used for the unit, but is instead used to specify the
"bus" number; each SATA controller has 6 buses, and each bus only
allows a single unit. This makes it nonsensical to specify unit='n'
where n is anything other than 0. It also means that the only way to
connect more than a single device to the implicit SATA controller is
to explicitly give the bus names, which happen to be "ide.$n", where
$n can be replaced by the disk's "unit" number.

11 years agodaemon: Avoid dead code in polkit auth
Jiri Denemark [Thu, 19 Sep 2013 12:55:38 +0000 (14:55 +0200)]
daemon: Avoid dead code in polkit auth

11 years agovirsh: add missing "async" option in opts_block_commit
Simone Gotti [Thu, 19 Sep 2013 13:08:29 +0000 (15:08 +0200)]
virsh: add missing "async" option in opts_block_commit

After commit 8aecd351266a66efa59b7f7be77bf66693d99ce0 it'll detect
that a required option is not defined and it will assert and exit with:

virsh.c:1364: vshCommandOpt: Assertion `valid->name' failed.

Problem has been latent since commit ed23b106.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoqemumonitorjsontest: Introduce DO_TEST_SIMPLE
Michal Privoznik [Wed, 18 Sep 2013 15:28:31 +0000 (17:28 +0200)]
qemumonitorjsontest: Introduce DO_TEST_SIMPLE

This macro is there to test the simplest monitor functions we have,
those in the form of: int ( *func) (qemuMonitorPtr). So far, we have
seven such functions.

11 years agoqemumonitorjsontest: Test CPU state handling code
Michal Privoznik [Wed, 18 Sep 2013 13:11:06 +0000 (15:11 +0200)]
qemumonitorjsontest: Test CPU state handling code

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agodaemon: Remove more hardcoded paths from help output
Christophe Fergeau [Wed, 18 Sep 2013 14:45:14 +0000 (16:45 +0200)]
daemon: Remove more hardcoded paths from help output

A previous patch used existing #define for the various files in /etc/pki
instead of hardcoding them in the help output. However I missed that
remote_driver.h contains #define for more paths that are present
in the daemon help output.
This commit uses the existing constants for the path to the
configuration file and to the libvirt sockets.

11 years agoFix LIBVIRTD_CONFIGURATION_FILE constant
Christophe Fergeau [Wed, 18 Sep 2013 14:44:26 +0000 (16:44 +0200)]
Fix LIBVIRTD_CONFIGURATION_FILE constant

It's not used anywhere, but should be pointing to
$sysconfdir/libvirt/libvirtd.conf, not $sysconfdir/libvirtd.conf

11 years agodocs: fix virEventAddHandle return details
Jonathan Lebon [Wed, 18 Sep 2013 18:56:01 +0000 (14:56 -0400)]
docs: fix virEventAddHandle return details

In commit 6d41cb8, the interface for virEventAddHandleFunc was changed.
This patch updates the documentation for virEventAddHandle to reflect
the new significance of the return value. Also, both functions now
mention -1 for failure.

11 years agoFix crash in remoteDispatchDomainMemoryStats (CVE-2013-4296)
Daniel P. Berrange [Tue, 3 Sep 2013 15:52:06 +0000 (16:52 +0100)]
Fix crash in remoteDispatchDomainMemoryStats (CVE-2013-4296)

The 'stats' variable was not initialized to NULL, so if some
early validation of the RPC call fails, it is possible to jump
to the 'cleanup' label and VIR_FREE an uninitialized pointer.
This is a security flaw, since the API can be called from a
readonly connection which can trigger the validation checks.

This was introduced in release v0.9.1 onwards by

  commit 158ba8730e44b7dd07a21ab90499996c5dec080a
  Author: Daniel P. Berrange <berrange@redhat.com>
  Date:   Wed Apr 13 16:21:35 2011 +0100

    Merge all returns paths from dispatcher into single path

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agodoc: fix XML for the RNG device example
Giuseppe Scrivano [Wed, 18 Sep 2013 15:12:18 +0000 (17:12 +0200)]
doc: fix XML for the RNG device example

Add a missing '/' to close the "source" element.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
11 years agoAdd support for using 3-arg pkcheck syntax for process (CVE-2013-4311)
Daniel P. Berrange [Wed, 28 Aug 2013 14:25:40 +0000 (15:25 +0100)]
Add support for using 3-arg pkcheck syntax for process (CVE-2013-4311)

With the existing pkcheck (pid, start time) tuple for identifying
the process, there is a race condition, where a process can make
a libvirt RPC call and in another thread exec a setuid application,
causing it to change to effective UID 0. This in turn causes polkit
to do its permission check based on the wrong UID.

To address this, libvirt must get the UID the caller had at time
of connect() (from SO_PEERCRED) and pass a (pid, start time, uid)
triple to the pkcheck program.

This fix requires that libvirt is re-built against a version of
polkit that has the fix for its CVE-2013-4288, so that libvirt
can see 'pkg-config --variable pkcheck_supports_uid polkit-gobject-1'

Signed-off-by: Colin Walters <walters@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoEnsure system identity includes process start time
Daniel P. Berrange [Wed, 28 Aug 2013 14:22:05 +0000 (15:22 +0100)]
Ensure system identity includes process start time

The polkit access driver will want to use the process start
time field. This was already set for network identities, but
not for the system identity.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAlso store user & group ID values in virIdentity
Daniel P. Berrange [Thu, 22 Aug 2013 15:00:01 +0000 (16:00 +0100)]
Also store user & group ID values in virIdentity

Future improvements to the polkit code will require access to
the numeric user ID, not merely user name.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agodaemon: Don't hardcode pki paths in help output
Christophe Fergeau [Wed, 18 Sep 2013 12:01:27 +0000 (14:01 +0200)]
daemon: Don't hardcode pki paths in help output

There are constants for these paths in remote_driver.h so we can
use these rather than duplicating them in the help output.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agodaemon: Fix 'caert.pem' typo in privileged help output
Christophe Fergeau [Wed, 18 Sep 2013 12:01:26 +0000 (14:01 +0200)]
daemon: Fix 'caert.pem' typo in privileged help output

The help message indicates that the CA certificate is
$sysconfdir/pki/CA/caert.pem while the actual path is
$sysconfdir/pki/CA/cacert.pem

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoqemu: Avoid dangling job in qemuDomainSetBlockIoTune
Jiri Denemark [Wed, 18 Sep 2013 08:37:48 +0000 (10:37 +0200)]
qemu: Avoid dangling job in qemuDomainSetBlockIoTune

virDomainSetBlockIoTuneEnsureACL was incorrectly called after we already
started a job. As a result of this, the job was not cleaned up when an
access driver had forbidden the action.

11 years agovirsh: Add vshCompleter to each option
Tomas Meszaros [Tue, 10 Sep 2013 15:54:26 +0000 (17:54 +0200)]
virsh: Add vshCompleter to each option

completer and completer_flags added to the _vshCmdOptDef
structure so it will be possible for completion generators to
conveniently call option completer functions with desired flags.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoAdd forwarder attribute to <dns/> element
Diego Woitasen [Fri, 13 Sep 2013 16:31:07 +0000 (13:31 -0300)]
Add forwarder attribute to <dns/> element

Useful to set custom forwarders instead of using the contents of
/etc/resolv.conf. It helps me to setup dnsmasq as local nameserver to
resolve VM domain names from domain 0, when domain option is used.

Signed-off-by: Diego Woitasen <diego.woitasen@vhgroup.net>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoVMX: Add a VMWare Fusion 5 configuration for tests
Doug Goldstein [Tue, 13 Aug 2013 15:56:56 +0000 (10:56 -0500)]
VMX: Add a VMWare Fusion 5 configuration for tests

A user was having an issue with this specific VMWare Fusion config and
he gave me permission to add it as part of our test suite to further
expand our VMX test coverage. Unfortunately our VMX parser and
generator does not support many features contained within and just
silently ignores fields it does not understand so they had to
be removed out in the xml2vmx test. The original unmodified version
exists in the vmx2xml test.

11 years agoVMX: Add support for 'auto detect' fileNames
Doug Goldstein [Tue, 13 Aug 2013 15:56:01 +0000 (10:56 -0500)]
VMX: Add support for 'auto detect' fileNames

VMWare Fusion 5 can set the CD-ROM's device name to be 'auto detect' when
using the physical drive via 'cdrom-raw' device type. VMWare will then
connect to first available host CD-ROM to the virtual machine upon start
up according to VMWare documentation. If no device is available, it
appears that the device will remain disconnected.

To better model this a CD-ROM that is marked as "auto detect" when in
the off state would be modeled as the following with this patch:
  <disk type='block' device='lun'>
    <source startupPolicy='optional'/>
    <target dev='hda' bus='ide'/>
    <address type='drive' controller='0' bus='0' target='0' unit='0'/>
  </disk>

Once the domain transitions to the powered on state, libvirt can
populate the remaining source data with what is connected, if anything.
However future power cycles, the domain may not always start with that
device attached.

11 years agoAllow <source> for type=block to have no dev
Doug Goldstein [Mon, 9 Sep 2013 02:08:06 +0000 (21:08 -0500)]
Allow <source> for type=block to have no dev

Currently the XML parser already allows the following syntax:
  <disk type='block' device='cdrom'>
    <source startupPolicy='optional'/>
    <target dev='hda' bus='ide'/>
    <address type='drive' controller='0' bus='0' target='0' unit='0'/>
  </disk>

But it if the dev value is NULL then it would not have the leading
"<source ", resulting in invalid XML.

11 years agobuild: skip ld_preload tests on non-Linux systems
Eric Blake [Tue, 17 Sep 2013 17:11:25 +0000 (11:11 -0600)]
build: skip ld_preload tests on non-Linux systems

A cross build to mingw fails with:

  CC       virsystemdtest-virsystemdtest.o
../../tests/virsystemdtest.c: In function 'testCreateNoSystemd':
../../tests/virsystemdtest.c:97:9: error: implicit declaration of function 'unsetenv' [-Werror=implicit-function-declaration]
         unsetenv("FAIL_NO_SERVICE");
         ^
../../tests/virsystemdtest.c:97:9: error: nested extern declaration of 'unsetenv' [-Werror=nested-externs]

We could cop out and pull in the gnulib unsetenv module.  But when
you stop and think about it, this test requires LD_PRELOAD to work,
and systemd is a Linux-only concept anyways, both of which mean
the test could never work on mingw in the first place.  Simpler is
to just fix the test to behave like our other LD_PRELOAD tests.

* tests/virsystemdtest.c: Provide non-Linux implementation.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: hoist system-specific checks before library checks
Eric Blake [Tue, 17 Sep 2013 16:25:42 +0000 (10:25 -0600)]
build: hoist system-specific checks before library checks

Commit f92c7e3 fixed a regression for native builds, but introduced
a regression for cross-compilation builds; in particular,
./autobuild.sh on a Fedora system with mingw cross-compiler fails
with:

checking for qemu-kvm... /usr/bin/qemu-kvm
checking for yajl_parse_complete in -lyajl... no
checking for yajl_tree_parse in -lyajl... no
configure: error: You must install the libyajl library & headers to compile libvirt

Since we default $with_qemu to 'yes' rather than 'check', and then
flip that default based on platform-specific checks, those platform
specifics need to come prior to any library checks that depend on
the value of $with_qemu.

* configure.ac: Ensure system defaults are sane before checking
for things that make decisions based on system default.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agomaint: ignore recently-added test
Eric Blake [Tue, 17 Sep 2013 16:24:41 +0000 (10:24 -0600)]
maint: ignore recently-added test

* .gitignore: Ignore metadatatest.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agotests: metadatatest: Quiesce errors on expected paths
Peter Krempa [Tue, 17 Sep 2013 13:22:42 +0000 (15:22 +0200)]
tests: metadatatest: Quiesce errors on expected paths

Use the helper added in previous patch to quiesce errors from this test
that was spamming logs on normal test runs.