]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
9 years agotools: Introduce new client generic module vsh
Erik Skultety [Mon, 15 Jun 2015 16:53:58 +0000 (18:53 +0200)]
tools: Introduce new client generic module vsh

In order to share as much virsh' logic as possible with upcomming
virt-admin client we need to split virsh logic into virsh specific and
client generic features.

Since majority of virsh methods should be generic enough to be used by
other clients, it's much easier to rename virsh specific data to virshX
than doing this vice versa. It moved generic virsh commands (including info
and opts structures) to generic module vsh.c.

Besides renaming methods and structures, this patch also involves introduction
of a client specific control structure being referenced as private data in the
original control structure, introduction of a new global vsh Initializer,
which currently doesn't do much, but there is a potential for added
functionality in the future.
Lastly it introduced client hooks which are especially necessary during
client connecting phase.

9 years agoqemu: Implement virDomainRename
Tomas Meszaros [Mon, 10 Aug 2015 19:59:18 +0000 (21:59 +0200)]
qemu: Implement virDomainRename

Currently supports only renaming inactive domains without snapshots.

Signed-off-by: Tomas Meszaros <exo@tty.sk>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoIntroduce new VIR_DOMAIN_EVENT_DEFINED_RENAMED event
Tomas Meszaros [Mon, 10 Aug 2015 19:59:17 +0000 (21:59 +0200)]
Introduce new VIR_DOMAIN_EVENT_DEFINED_RENAMED event

This should be emitted whenever a domain is renamed.

Signed-off-by: Tomas Meszaros <exo@tty.sk>
9 years agodomain_conf: Introducde virDomainObjListRenameAddNew() & virDomainObjListRenameRemove()
Tomas Meszaros [Mon, 10 Aug 2015 19:59:16 +0000 (21:59 +0200)]
domain_conf: Introducde virDomainObjListRenameAddNew() & virDomainObjListRenameRemove()

We just need to update the entry in the second hash table. Since commit 8728a56
we have two hash tables for the domain list so that we can do O(1) lookup
regardless of looking up by UUID or name. Since with renaming a domain UUID does
not change, we only need to update the second hash table, where domains are
referenced by their name.

We will call both functions from the qemuDomainRename().

Signed-off-by: Tomas Meszaros <exo@tty.sk>
9 years agovirsh: Implement "domrename" command
Tomas Meszaros [Mon, 10 Aug 2015 19:59:15 +0000 (21:59 +0200)]
virsh: Implement "domrename" command

This patch implements new virsh command, domrename.

Using domrename, it will be possible to rename domain from the virsh shell by
calling virRenameDomain API.

It takes two arguments, current domain name and new domain name.

Example:

virsh # list --all
 Id    Name                           State
 ----------------------------------------------------
  -     bar                            shut off

virsh # domrename bar foo
Domain successfully renamed

virsh # list --all
 Id    Name                           State
 ----------------------------------------------------
  -     foo                            shut off

virsh #

Signed-off-by: Tomas Meszaros <exo@tty.sk>
9 years agoIntroduce virDomainRename API
Tomas Meszaros [Mon, 10 Aug 2015 19:59:14 +0000 (21:59 +0200)]
Introduce virDomainRename API

Also, among with this new API new ACL that restricts rename
capability is invented too.

Signed-off-by: Tomas Meszaros <exo@tty.sk>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoDetect location of qemu-bridge-helper
Guido Günther [Thu, 13 Aug 2015 10:20:29 +0000 (12:20 +0200)]
Detect location of qemu-bridge-helper

RedHat and Debian based distros use different locations

Reference: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=790935

9 years agoCheck if qemu-bridge-helper exists and is executable
Guido Günther [Thu, 13 Aug 2015 12:19:50 +0000 (14:19 +0200)]
Check if qemu-bridge-helper exists and is executable

Otherwise the error is just

    error: Failed to create domain from test1.xml
    error: failed to retrieve file descriptor for interface: Transport endpoint is not connected

since we don't get a sensible error after the fork.

9 years agoconf: Remove 'vmdef' from virDomainHostdevDefParseXML
John Ferlan [Fri, 19 Jun 2015 19:03:50 +0000 (15:03 -0400)]
conf: Remove 'vmdef' from virDomainHostdevDefParseXML

Since it's not used, let's remove it to avoid any future usage.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Use numad information when getting pin information
Martin Kletzander [Sun, 26 Jul 2015 16:49:02 +0000 (18:49 +0200)]
qemu: Use numad information when getting pin information

Pinning information returned for emulatorpin and vcpupin calls is being
returned from our data without querying cgroups for some time.  However,
not all the data were utilized.  When automatic placement is used the
information is not returned for the calls mentioned above.  Since the
numad hint in private data is properly saved/restored, we can safely use
it to return true information.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoqemu: Keep numad hint after daemon restart
Martin Kletzander [Fri, 24 Jul 2015 14:06:33 +0000 (16:06 +0200)]
qemu: Keep numad hint after daemon restart

The numad hint stored in priv->autoNodeset is information that gets lost
during daemon restart.  And because we would like to use that
information in the future, we also need to save it in the status XML.
For the sake of tests, we need to initialize nnumaCell_max to some
value, so that the restoration doesn't fail in our test suite.  There is
no need to fill in the actual numa cell data since the recalculating
function virCapabilitiesGetCpusForNodemask() will not fail, it will just
skip filling the data in the bitmap which we don't use in tests anyway.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoconf: Pass private data to Parse function of XML options
Martin Kletzander [Fri, 24 Jul 2015 17:35:00 +0000 (19:35 +0200)]
conf: Pass private data to Parse function of XML options

This needs a reorder of XML option definitions.  It might come in handy
one day.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoqemu: Fix segfault when parsing private domain data
Martin Kletzander [Thu, 13 Aug 2015 08:03:12 +0000 (10:03 +0200)]
qemu: Fix segfault when parsing private domain data

When parsing private domain data, there are two paths that are flawed.
They are both error paths, just from different parts of the function.
One of them can call free() on an uninitialized pointer.  Initialization
to NULL is enough here.  The other one is a bit trickier to explain, but
as easy as the first one to fix.  We create capabilities, parse them and
then assign them into the private data pointer inside the domain object.
If, however, we get to fail from now on, the error path calls unrefs the
capabilities and then, when the domain object is being cleaned,
qemuDomainObjPrivateFree() tries to unref them as well.  That causes a
segfault.  Settin the pointer to NULL upon successful addition to the
private data is enough.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoconf: Check for hostdev conflicts when assign default disk address
John Ferlan [Mon, 22 Jun 2015 19:13:39 +0000 (15:13 -0400)]
conf: Check for hostdev conflicts when assign default disk address

https://bugzilla.redhat.com/show_bug.cgi?id=1210587  (completed)

When generating the default drive address for a SCSI <disk> device,
check the generated address to ensure it doesn't conflict with a SCSI
<hostdev> address. The <disk> address generation algorithm uses the
<target> "dev" name in order to determine which controller and unit
in order to place the device. Since a SCSI <hostdev> device doesn't
require a target device name, its placement on the guest SCSI address
"could" conflict.  For instance, if a SCSI <hostdev> exists at
controller=0 unit=0 and an attempt to hotplug 'sda' into the guest
made, there would be a conflict if the <hostdev> is already using
/dev/sda.

9 years agoconf: Create locals for virDomainDiskDefAssignAddress
John Ferlan [Thu, 16 Jul 2015 15:29:03 +0000 (11:29 -0400)]
conf: Create locals for virDomainDiskDefAssignAddress

Create local controller/bus variables to be used by a future patch

9 years agoconf: Add SCSI hostdev check for disk drive address already in use
John Ferlan [Wed, 12 Aug 2015 19:30:45 +0000 (15:30 -0400)]
conf: Add SCSI hostdev check for disk drive address already in use

https://bugzilla.redhat.com/show_bug.cgi?id=1210587  (partial)

If a SCSI subsystem <hostdev> element address is provided, we need to
make sure the address provided doesn't conflict with an existing or
libvirt generated address for a SCSI <disk> element. We can handle
this condition in device post processing since we're not generating an
address based on some target name - rather it's either generated based
on space or provided from the user. If the user provides one that conflicts,
then we need to disallow the change.

This will fix the issue where the domain XML provided an <address> for
the <hostdev>, but not the <disk> element where the address provided
ends up being the same address used for the <disk>. A <disk> address
is generated using it's assigned <target> 'dev' name prior to the
check/validation of the <hostdev> address value.

9 years agoDrive hot-unplug: reliable parsing of HMP results
Frank Schreuder [Mon, 10 Aug 2015 15:37:30 +0000 (17:37 +0200)]
Drive hot-unplug: reliable parsing of HMP results

Hot-unplugging a disk from a guest that supports hot-unplugging generates an error
in the libvirt log when running QEMU with the "-msg timestamp=on" flag.

2015-08-06 10:48:59.945+0000: 11662: error : qemuMonitorTextDriveDel:2594 :
operation failed: deleting drive-virtio-disk4 drive failed:
2015-08-06T10:48:59.945058Z Device 'drive-virtio-disk4' not found

This error is caused because the HMP results are getting prefixed with a timestamp.
Parsing the output is not reliable with STRPREFIX as the results can be prefixed with a timestamp.

Using strstr ensures that parsing the output works whether the results are prefixed or not.

Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Frank Schreuder <fschreuder@transip.nl>
9 years agoRevert "qemu: Allow to plug virtio-net-pci into PCIe slot"
Laine Stump [Tue, 11 Aug 2015 23:07:53 +0000 (19:07 -0400)]
Revert "qemu: Allow to plug virtio-net-pci into PCIe slot"

This reverts commit ede34470fde19c0f326cdb0dfca39fa86fd9ec16, which
was apparently written based on testing performed before commits
1e15be1 and 9a12b6 were pushed upstream. Once those two patches are in
place, commit ede34470 is redundant, and can even cause
incorrect/unexpected behavior when auto-assigning addresses for
virtio-net devices.

9 years agocmdAttachInterface: Fully implement @floor support
Michal Privoznik [Wed, 12 Aug 2015 08:38:12 +0000 (10:38 +0200)]
cmdAttachInterface: Fully implement @floor support

In my previous commit d7f5c88961b52 I tried to introduce support
for inbound.floor. But the code change was incomplete. This is
the change needed to fully enable the feature.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agonetworkBandwidthGenericChecks: Drop useless check
Michal Privoznik [Wed, 12 Aug 2015 08:34:39 +0000 (10:34 +0200)]
networkBandwidthGenericChecks: Drop useless check

There's a check right at the beginning of the function that
shortcuts if the function was called over all NULL arguments.
However, this was meant just as a fool-proof check so that we
don't crash if function is used in a bad manner. Anyway, it makes
Coverity unhappy as it then thinks any of the arguments could be
NULL. Well, with the current state of the code it can't.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agonetworkBandwidthUpdate: Don't blindly dereference pointers
Michal Privoznik [Wed, 12 Aug 2015 08:25:48 +0000 (10:25 +0200)]
networkBandwidthUpdate: Don't blindly dereference pointers

It may happen that an interface don't have any bandwidth set and
a new one is to be set. In that case, @ifaceBand will be NULL.
This will cause troubles later in the code when deciding what to
do.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirsh: Refactor parseRateStr to avoid false-positive uninitialized variable
Peter Krempa [Wed, 12 Aug 2015 05:31:33 +0000 (07:31 +0200)]
virsh: Refactor parseRateStr to avoid false-positive uninitialized variable

Commit 6983d6d2 tried to improve parseRateStr but broke the build
instead for compilers that were not able to properly introspect the for
loop indexed by the enum resulting into the following error:

virsh-domain.c: In function 'parseRateStr':
virsh-domain.c:916:13: error: 'field_name' may be used uninitialized in this function [-Werror=maybe-uninitialized]
             vshError(ctl, _("malformed %s field"), field_name);
             ^
virsh-domain.c:915:13: error: 'tmp' may be used uninitialized in this function [-Werror=maybe-uninitialized]
         if (virStrToLong_ullp(token, NULL, 10, tmp) < 0) {
             ^
Rather than trying to fix the code, refactor the function again by
reusing virStringSplit.

9 years agodomain: Fix crash if trying to live update disk <serial>
Cole Robinson [Mon, 10 Aug 2015 23:01:43 +0000 (19:01 -0400)]
domain: Fix crash if trying to live update disk <serial>

If you pass <disk><serial> XML to UpdateDevice, and the original device
didn't have a <serial> block, libvirtd crashes trying to read the original
NULL serial string.

Use _NULLABLE string comparisons to avoid the crash. A couple other
properties needed the change too.

9 years agoqemu: fix qemuDomainSupportsPCI() for ARM machines of "virt" machinetype
Laine Stump [Tue, 11 Aug 2015 18:56:21 +0000 (14:56 -0400)]
qemu: fix qemuDomainSupportsPCI() for ARM machines of "virt" machinetype

Commit e8d5517 updated the domain post-parse to automatically add
pcie-root et al for certain ARM "virt" machinetypes, but didn't update
the function qemuDomainSupportsPCI() which is called later on when we
are auto-assigning PCI addresses and default settings for the PCI
controller <model> and <target> attributes. The result was that PCI
addresses weren't assigned, and the controllers didn't have their
attribute default values set, leading to an error when the domain was
started, e.g.:

  internal error: autogenerated dmi-to-pci-bridge options not set

This patch adds the same check made in the earlier patch to
qemuDomainSupportsPCI(), so that PCI address auto-assignment and
target/model default values will be set.

9 years agovirNetSocketCheckProtocols: handle EAI_NONAME as IPv6 unavailable
Guido Günther [Tue, 11 Aug 2015 09:49:18 +0000 (11:49 +0200)]
virNetSocketCheckProtocols: handle EAI_NONAME as IPv6 unavailable

When running the test suite using "unshare -n" we might have IPv6 but no
configured addresses. Due to AI_ADDRCONFIG getaddrinfo then fails with
EAI_NONAME which we should then treat as IPv6 unavailable.

9 years agoutil: don't overwrite stack when getting ethtool gfeatures
Laine Stump [Tue, 11 Aug 2015 17:45:46 +0000 (13:45 -0400)]
util: don't overwrite stack when getting ethtool gfeatures

This fixes the crash described here:

 https://www.redhat.com/archives/libvir-list/2015-August/msg00162.html

In short, we were calling ioctl(SIOCETHTOOL) pointing to a too-short
object that was a local on the stack, resulting in the memory past the
end of the object being overwritten. This was because the struct used
by the ETHTOOL_GFEATURES command of SIOCETHTOOL ends with a 0-length
array, but we were telling ethtool that it could use 2 elements on the
array.

The fix is to allocate the necessary memory with VIR_ALLOC_VAR(),
including the extra length needed for a 2 element array at the end.

9 years agocpu: Fix segfault in the ppc64 driver
Andrea Bolognani [Tue, 11 Aug 2015 15:51:28 +0000 (17:51 +0200)]
cpu: Fix segfault in the ppc64 driver

Commit adb865d introduced some changes in ppc64DriverNodeData()
that cause libvirtd to crash on startup unless this patch is
applied as well.

9 years agoqemu: Implement VIR_DOMAIN_BANDWIDTH_IN_FLOOR
Michal Privoznik [Sat, 1 Aug 2015 07:47:46 +0000 (09:47 +0200)]
qemu: Implement VIR_DOMAIN_BANDWIDTH_IN_FLOOR

Well, there are just two places that needs adjustment:

qemuDomainGetInterfaceParameters - to report the @floor
qemuDomainSetInterfaceParameters - now that the function has been
fixed, we can allow updating @floor too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirsh: Implement VIR_DOMAIN_BANDWIDTH_IN_FLOOR
Michal Privoznik [Sat, 1 Aug 2015 07:48:04 +0000 (09:48 +0200)]
virsh: Implement VIR_DOMAIN_BANDWIDTH_IN_FLOOR

We have a function parseRateStr() that parses --inbound and
--outbound arguments to both attach-interface and domiftune.
Now that we have all virTypedParams macros needed for QoS,
lets parse even floor attribute. The extended format for the
arguments looks like this then:

  --inbound average[,peak[,burst[,floor]]]

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoIntroduce VIR_DOMAIN_BANDWIDTH_IN_FLOOR
Michal Privoznik [Sat, 1 Aug 2015 07:47:07 +0000 (09:47 +0200)]
Introduce VIR_DOMAIN_BANDWIDTH_IN_FLOOR

This macro represents the single missing field we don't expose
yet within QoS: inbound.floor.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirsh: Rework parseRateStr
Michal Privoznik [Sat, 1 Aug 2015 06:13:54 +0000 (08:13 +0200)]
virsh: Rework parseRateStr

The function is used to parse a tuple delimited by commas into
virNetDevBandwidth structure. So far only three out of fore
fields are supported: average, peak and burst. The single missing
field is floor. Well, the parsing works, but I think we can do
better. Especially when we will need to parse floor too in very
close future.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemuDomainSetInterfaceParameters: Use new functions to update bandwidth
Michal Privoznik [Fri, 31 Jul 2015 15:31:39 +0000 (17:31 +0200)]
qemuDomainSetInterfaceParameters: Use new functions to update bandwidth

As sketched in previous commits, imagine the following scenario:

  virsh # domiftune gentoo vnet0
  inbound.average: 100
  inbound.peak   : 0
  inbound.burst  : 0
  outbound.average: 100
  outbound.peak  : 0
  outbound.burst : 0

  virsh # domiftune gentoo vnet0 --inbound 0

  virsh # shutdown gentoo
  Domain gentoo is being shutdown

  virsh # list --all
  error: Failed to list domains
  error: Cannot recv data: Connection reset by peer

  Program received signal SIGSEGV, Segmentation fault.
  0x00007fffe80ea221 in networkUnplugBandwidth (net=0x7fff9400c1a0, iface=0x7fff940ea3e0) at network/bridge_driver.c:4881
  4881            net->floor_sum -= ifaceBand->in->floor;

This is rather unfortunate. We should not SIGSEGV here. The
problem is, that while in the second step the inbound QoS was
cleared out, the network part of it was not updated (moreover, we
don't report that vnet0 had inbound.floor set). Internal
structure therefore still had some fragments left (e.g.
class_id). So when qemuProcessStop() started to clean up the
environment it got to networkUnplugBandwidth(). Here, class_id is
set therefore function assumes that there is an inbound QoS. This
actually is a fair assumption to make, there's no need for a
special QoS box in network's QoS when there's no QoS to set.
Anyway, the problem is not the networkUnplugBandwidth() rather
than qemuDomainSetInterfaceParameters() which completely forgot
about QoS being disperse (some parts are set directly on
interface itself, some on bridge the interface is plugged into).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agobridge_driver: Introduce networkBandwidthUpdate
Michal Privoznik [Fri, 31 Jul 2015 15:31:20 +0000 (17:31 +0200)]
bridge_driver: Introduce networkBandwidthUpdate

So, if a domain vNIC's bandwidth has been successfully set, it's
possible that because @floor is set on network's bridge, this
part may need updating too. And that's exactly what this function
does. While the previous commit introduced a function to check if
@floor can be satisfied, this does all the hard work. In general,
there may be three, well four possibilities:

  1) No change in @floor value (either it remain unset, or its
  value hasn't changed)

  2) The @floor value has changed from a non-zero to a non-zero
  value

  3) New @floor is to be set

  4) Old @floor must be cleared out

The difference between 2), 3) and 4) is, that while in 2) the QoS
tree on the network's bridge already has a special class for the
vNIC, in 3) the class must be created from scratch. In 4) it must
be removed. Fortunately, we have helpers for all three
interesting cases.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agobridge_driver: Introduce networkBandwidthChangeAllowed
Michal Privoznik [Fri, 31 Jul 2015 15:02:10 +0000 (17:02 +0200)]
bridge_driver: Introduce networkBandwidthChangeAllowed

When a domain vNIC's bandwidth is to be changed (at runtime) it is
possible that guaranteed minimal bandwidth (@floor) will change too.
Well, so far it is, because we still don't have an implementation that
allows setting it dynamically, so it's effectively erased on:

    #virsh domiftune $dom vnet0 --inbound 0

However, that's slightly unfortunate. We do some checks on domain
startup to see if @floor can be guaranteed. We ought do the same if
QoS is changed at runtime.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirNetDevBandwidthUpdateRate: turn class_id into integer
Michal Privoznik [Fri, 31 Jul 2015 15:44:13 +0000 (17:44 +0200)]
virNetDevBandwidthUpdateRate: turn class_id into integer

This is no functional change. It's just that later in the series we
will need to pass class_id as an integer.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirNetDevParseMcast: Avoid magic constant
Michal Privoznik [Sat, 1 Aug 2015 05:43:58 +0000 (07:43 +0200)]
virNetDevParseMcast: Avoid magic constant

There is no guarantee that an enum start it mapped onto a value
of zero. However, we are guaranteed that enum items are
consecutive integers. Moreover, it's a pity to define an enum to
avoid using magical constants but then using them anyway.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoconf: Don't try formating non-existing addresses
Martin Kletzander [Tue, 11 Aug 2015 13:09:29 +0000 (15:09 +0200)]
conf: Don't try formating non-existing addresses

Commit a6f9af8292b6 added checking for address colisions between
starting and ending addresses of forwarding addresses, but forgot that
there might be no addresses set at all.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agotests: Add a bunch of cpu test case for ppc64
Andrea Bolognani [Fri, 7 Aug 2015 15:39:21 +0000 (17:39 +0200)]
tests: Add a bunch of cpu test case for ppc64

The test cases cover the cpuCompare(), cpuBaseline() and
cpuNodeData() implementation.

9 years agotests: Re-enable ppc64 cpu tests
Andrea Bolognani [Fri, 7 Aug 2015 15:39:20 +0000 (17:39 +0200)]
tests: Re-enable ppc64 cpu tests

Now that all the changes have been implemented we can run the
test cases once again, after updating them to reflect the new
behaviour.

9 years agocpu: Forbid model fallback in the ppc64 driver
Andrea Bolognani [Fri, 7 Aug 2015 15:39:19 +0000 (17:39 +0200)]
cpu: Forbid model fallback in the ppc64 driver

Unlike what happens on x86, on ppc64 you can't mix and match CPU
features to obtain the guest CPU you want regardless of the host
CPU, so the concept of model fallback doesn't apply.

Make sure CPU definitions emitted by the driver, eg. as output of
the cpuBaseline() and cpuUpdate() calls, reflect this fact.

9 years agocpu: Implement backwards compatibility in the ppc64 driver
Andrea Bolognani [Fri, 7 Aug 2015 15:39:18 +0000 (17:39 +0200)]
cpu: Implement backwards compatibility in the ppc64 driver

All previously recognized CPU models (POWER7_v2.1, POWER7_v2.3,
POWER7+_v2.1 and POWER8_v1.0) are internally converted to the
corrisponding generation name so that existing guests don't stop
working.

9 years agocpu: Add POWER8NVL information to CPU map XML
Andrea Bolognani [Fri, 7 Aug 2015 15:39:17 +0000 (17:39 +0200)]
cpu: Add POWER8NVL information to CPU map XML

This is yet another variation of POWER8. The PVR information comes
from arch/powerpc/kernel/cputable.c in the Linux kernel tree.

9 years agocpu: Parse and use PVR masks in the ppc64 driver
Andrea Bolognani [Fri, 7 Aug 2015 15:39:16 +0000 (17:39 +0200)]
cpu: Parse and use PVR masks in the ppc64 driver

Instead of relying on a hard-coded mask value, read it from the CPU
map XML and use it when looking up models by PVR.

9 years agocpu: Simplify ppc64 part of CPU map XML
Andrea Bolognani [Fri, 7 Aug 2015 15:39:15 +0000 (17:39 +0200)]
cpu: Simplify ppc64 part of CPU map XML

Use multiple PVRs per CPU model to reduce the number of models we
need to keep track of.

Remove specific CPU models (eg. POWER7+_v2.1): the corresponding
generic CPU model (eg. POWER7) should be used instead to ensure
the guest can be booted on any compatible host.

Get rid of all the entries that did not match any of the CPU
models supported by QEMU, like power8 and power8e.

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

9 years agocpu: Support multiple PVRs in the ppc64 driver
Andrea Bolognani [Fri, 7 Aug 2015 15:39:14 +0000 (17:39 +0200)]
cpu: Support multiple PVRs in the ppc64 driver

This will allow us to perform PVR matching more broadly, eg. consider
both POWER8 and POWER8E CPUs to be the same even though they have
different PVR values.

9 years agocpu: Align ppc64 CPU data with x86
Andrea Bolognani [Fri, 7 Aug 2015 15:39:13 +0000 (17:39 +0200)]
cpu: Align ppc64 CPU data with x86

Use a typedef instead of the plain struct and heap allocation. This
will make it easier to extend the ppc64 specific CPU data later on.

9 years agotests: Temporarily disable ppc64 cpu tests
Andrea Bolognani [Fri, 7 Aug 2015 15:39:12 +0000 (17:39 +0200)]
tests: Temporarily disable ppc64 cpu tests

The upcoming commits will make heavy modifications to the ppc64
driver, split so that it's easier to review the changes.

Instead of updating the test cases so that they pass, possibly
only to update them again with the following commit, disable them
for the time being.

Another commit will update them all in one go once all required
changes are in place.

9 years agocpu: Use ppc64Compute() to implement ppc64DriverCompare()
Andrea Bolognani [Fri, 7 Aug 2015 15:39:11 +0000 (17:39 +0200)]
cpu: Use ppc64Compute() to implement ppc64DriverCompare()

This ensures comparison of two CPU definitions will be consistent
regardless of the fact that it is performed using cpuCompare() or
cpuGuestData(). The x86 driver uses the same exact code.

9 years agocpu: CPU model names have to match on ppc64
Andrea Bolognani [Fri, 7 Aug 2015 15:39:10 +0000 (17:39 +0200)]
cpu: CPU model names have to match on ppc64

Limitations of the POWER architecture mean that you can't run
eg. a POWER7 guest on a POWER8 host when using KVM. This applies
to all guests, not just those using VIR_CPU_MATCH_STRICT in the
CPU definition; in fact, exact and strict CPU matching are
basically the same on ppc64.

This means, of course, that hosts using different CPUs have to be
considered incompatible as well.

Change ppc64Compute(), called by cpuGuestData(), to reflect this
fact and update test cases accordingly.

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

9 years agocpu: Never skip CPU model name check in ppc64 driver
Andrea Bolognani [Fri, 7 Aug 2015 15:39:09 +0000 (17:39 +0200)]
cpu: Never skip CPU model name check in ppc64 driver

ppc64Compute(), called by cpuNodeData(), is used not only to retrieve
the driver-specific data associated to a guest CPU definition, but
also to check whether said guest CPU is compatible with the host CPU.

If the user is not interested in the CPU data, it's perfectly fine
to pass a NULL pointer instead of a return location, and the
compatibility data returned should not be affected by this. One of
the checks, specifically the one on CPU model name, was however
only performed if the return location was non-NULL.

9 years agotests: Improve result handling in cpuTestGuestData()
Andrea Bolognani [Fri, 7 Aug 2015 15:39:08 +0000 (17:39 +0200)]
tests: Improve result handling in cpuTestGuestData()

A test is considered successful if the obtained result matches
the expected result: if that's not the case, whether because a
test that was expected to succeed failed or because a test that
was supposed to fail succeeded, then something's not right and
we want the user to know about this.

On the other hand, if a failure that's unrelated to the bits
we're testing occurs, then the user should be notified even if
the test was expected to fail.

Use different values to tell these two situations apart.

Fix a test case that was wrongly expected to fail as well.

9 years agotests: Remove unused file
Andrea Bolognani [Fri, 7 Aug 2015 15:39:07 +0000 (17:39 +0200)]
tests: Remove unused file

No functional changes.

9 years agocpu: Remove ISA information from CPU map XML
Andrea Bolognani [Fri, 7 Aug 2015 15:39:06 +0000 (17:39 +0200)]
cpu: Remove ISA information from CPU map XML

The information is not used anywhere in libvirt.

No functional changes.

9 years agocpu: Reorder functions in the ppc64 driver
Andrea Bolognani [Fri, 7 Aug 2015 15:39:05 +0000 (17:39 +0200)]
cpu: Reorder functions in the ppc64 driver

Having the functions grouped together this way will avoid further
shuffling around down the line.

No functional changes.

9 years agocpu: Simplify ppc64ModelFromCPU()
Andrea Bolognani [Fri, 7 Aug 2015 15:39:04 +0000 (17:39 +0200)]
cpu: Simplify ppc64ModelFromCPU()

9 years agocpu: Simplify NULL handling in ppc64 driver
Andrea Bolognani [Fri, 7 Aug 2015 15:39:03 +0000 (17:39 +0200)]
cpu: Simplify NULL handling in ppc64 driver

Use briefer checks, eg. (!model) instead of (model == NULL), and
avoid initializing to NULL a pointer that would be assigned in
the first line of the function anyway.

Also remove a pointless NULL assignment.

No functional changes.

9 years agocpu: Mark driver functions in ppc64 driver
Andrea Bolognani [Fri, 7 Aug 2015 15:39:02 +0000 (17:39 +0200)]
cpu: Mark driver functions in ppc64 driver

Use the ppc64Driver prefix for all functions that are used to
fill in the cpuDriverPPC64 structure, ie. those that are going
to be called by the generic CPU code.

This makes it clear which functions are exported and which are
implementation details; it also gets rid of the ambiguity that
affected the ppc64DataFree() function which, despite what the
name suggested, was not related to ppc64DataCopy() and could
not be used to release the memory allocated for a
virCPUppc64Data* instance.

No functional changes.

9 years agoadmin: Drop 'internal.h' include from libvirt-admin.h
Erik Skultety [Mon, 10 Aug 2015 12:02:32 +0000 (14:02 +0200)]
admin: Drop 'internal.h' include from libvirt-admin.h

This is a public library, it shouldn't include anything that is
internal. Including the library in it's current state to an example
application fails the preprocessor phase.

9 years agoqemu: fail on attempts to use <filterref> for non-tap network connections
Laine Stump [Mon, 10 Aug 2015 06:05:29 +0000 (02:05 -0400)]
qemu: fail on attempts to use <filterref> for non-tap network connections

nwfilter uses iptables and ebtables, which only work properly on
tap-based network connections (*not* on macvtap, for example), but we
just ignore any <filterref> elements for other types of networks,
potentially giving users a false sense of security.

This patch checks the network type and fails/logs an error if any
domain <interface> has a <filterref> when the connection isn't using a
tap device.

This resolves:

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

9 years agonetwork: validate network NAT range
Laine Stump [Sat, 8 Aug 2015 21:46:41 +0000 (17:46 -0400)]
network: validate network NAT range

This patch modifies virSocketAddrGetRange() to function properly when
the containing network/prefix of the address range isn't known, for
example in the case of the NAT range of a virtual network (since it is
a range of addresses on the *host*, not within the network itself). We
then take advantage of this new functionality to validate the NAT
range of a virtual network.

Extra test cases are also added to verify that virSocketAddrGetRange()
works properly in both positive and negative cases when the network
pointer is NULL.

This is the *real* fix for:

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

Commits 1e334a and 48e8b9 had earlier been pushed as fixes for that
bug, but I had neglected to read the report carefully, so instead of
fixing validation for the NAT range, I had fixed validation for the
DHCP range. sigh.

9 years agoqemu: Enable ioeventfd usage for virtio-scsi controllers
Martin Kletzander [Sun, 26 Jul 2015 18:41:34 +0000 (20:41 +0200)]
qemu: Enable ioeventfd usage for virtio-scsi controllers

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoconf: Add ioeventfd option for controllers
Martin Kletzander [Fri, 24 Jul 2015 13:49:35 +0000 (15:49 +0200)]
conf: Add ioeventfd option for controllers

This will be used with a virtio-scsi controller later on.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agovirNetDevBandwidthParseRate: Reject negative values
Michal Privoznik [Fri, 7 Aug 2015 15:03:12 +0000 (17:03 +0200)]
virNetDevBandwidthParseRate: Reject negative values

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

The following XML really does not make any sense:

<inbound average="-1" burst="-2" peak="-3" floor="-4"/>

There can't be a negative packet rate. Well, so far we haven't
assigned any meaning to it. So reject it unless users harm themselves,
because otherwise we turn the negative numbers into really big values.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemuMonitorOpenInternal: remove redundant code
Cao jin [Thu, 23 Jul 2015 10:16:31 +0000 (18:16 +0800)]
qemuMonitorOpenInternal: remove redundant code

There's no need to set mon->fd to a dummy value since
it's initialized to proper value just a few lines below.

Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
9 years agorpc: Remove keepalive_required option
Martin Kletzander [Mon, 20 Jul 2015 12:51:24 +0000 (14:51 +0200)]
rpc: Remove keepalive_required option

Since its introduction in 2011 (particularly in commit f4324e329275),
the option doesn't work.  It just effectively disables all incoming
connections.  That's because the client private data that contain the
'keepalive_supported' boolean, are initialized to zeroes so the bool is
false and the only other place where the bool is used is when checking
whether the client supports keepalive.  Thus, according to the server,
no client supports keepalive.

Removing this instead of fixing it is better because a) apparently
nobody ever tried it since 2011 (4 years without one month) and b) we
cannot know whether the client supports keepalive until we get a ping or
pong keepalive packet.  And that won't happen until after we dispatched
the ConnectOpen call.

Another two reasons would be c) the keepalive_required was tracked on
the server level, but keepalive_supported was in private data of the
client as well as the check that was made in the remote layer, thus
making all other instances of virNetServer miss this feature unless they
all implemented it for themselves and d) we can always add it back in
case there is a request and a use-case for it.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agofix typo in comments
Cao jin [Mon, 10 Aug 2015 07:31:45 +0000 (15:31 +0800)]
fix typo in comments

Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
9 years agovirDomainCoreDumpWithFormat: Mention enum for @dumpformat
Michal Privoznik [Sat, 8 Aug 2015 12:06:41 +0000 (14:06 +0200)]
virDomainCoreDumpWithFormat: Mention enum for @dumpformat

So the API takes @dumpformat argument. This is what makes it special
when compared to virDomainCoreDump. The argument is there so that
users can choose the format of resulting core dump file. And to ease
them the choosing process we even have an enum with supported values
across all the hypervisors. But we don't mention the enum in  the
function description anywhere. Fix it!

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agonetwork: verify proper address family in updates to <host> and <range>
Laine Stump [Mon, 19 Jan 2015 22:04:01 +0000 (17:04 -0500)]
network: verify proper address family in updates to <host> and <range>

By specifying parentIndex in a call to virNetworkUpdate(), it was
possible to direct libvirt to add a dhcp range or static host of a
non-matching address family to the <dhcp> element of an <ip>. For
example, given:

 <ip address='192.168.122.1' netmask='255.255.255.0'/>
 <ip family='ipv6' address='2001:db6:ca3:45::1' prefix='64'/>

you could provide a static host entry with an IPv4 address, and
specify that it be added to the 2nd <ip> element (index 1):

  virsh net-update default add ip-dhcp-host --parent-index 1 \
  '<host mac="52:54:00:00:00:01" ip="192.168.122.45"/>'

This would be happily added with no error (and no concern of any
possible future consequences).

This patch checks that any dhcp range or host element being added to a
network ip's <dhcp> subelement has addresses of the same family as the
ip element they are being added to.

This resolves:

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

9 years agoqemu: support new pci controller model "pcie-switch-downstream-port"
Laine Stump [Wed, 17 Jun 2015 21:48:28 +0000 (17:48 -0400)]
qemu: support new pci controller model "pcie-switch-downstream-port"

This is backed by the qemu device xio3130-downstream. It can only be
connected to a pcie-switch-upstream-port (x3130-upstream) on the
upstream side.

9 years agoconf: new pcie-controller model "pcie-switch-downstream-port"
Laine Stump [Wed, 17 Jun 2015 19:27:40 +0000 (15:27 -0400)]
conf: new pcie-controller model "pcie-switch-downstream-port"

This controller can be connected only to a port on a
pcie-switch-upstream-port. It provides a single hotpluggable port that
will accept any PCI or PCIe device, as well as any device requiring a
pcie-*-port (the only current example of such a device is the
pcie-switch-upstream-port).

9 years agoqemu: add capabilities bit for device xio3130-downstream
Laine Stump [Wed, 17 Jun 2015 18:24:29 +0000 (14:24 -0400)]
qemu: add capabilities bit for device xio3130-downstream

The downstream ports of an x3130-upstream switch can each have one of
these plugged into them (and that is the only place they can be
connected). Each xio3130-downstream provides a single PCIe port that
can have PCI or PCIe devices hotplugged into it. Apparently an entire
set of x3130-upstream + several xio3130-downstreams can be hotplugged
as a unit, but it's not clear to me yet how that would be done, since
qemu only allows attaching a single device at a time.

This device will be used to implement the
"pcie-switch-downstream-port" model of pci controller.

9 years agoqemu: support new pci controller model "pcie-switch-upstream-port"
Laine Stump [Tue, 16 Jun 2015 19:09:07 +0000 (15:09 -0400)]
qemu: support new pci controller model "pcie-switch-upstream-port"

this is backed by the qemu device x3130-upstream. It can only plug
into a pcie-root-port or pcie-switch-downstream-port.

9 years agoconf: new pci controller model "pcie-switch-upstream-port"
Laine Stump [Tue, 16 Jun 2015 19:00:44 +0000 (15:00 -0400)]
conf: new pci controller model "pcie-switch-upstream-port"

This controller can be connected only to a pcie-root-port or a
pcie-switch-downstream-port (which will be added in a later patch),
which is the reason for the new connect type
VIR_PCI_CONNECT_TYPE_PCIE_PORT. A pcie-switch-upstream-port provides
32 ports (slot=0 to slot=31) on the downstream side, which can only
have pci controllers of model "pcie-switch-downstream-port" plugged
into them, which is the reason for the other new connect type
VIR_PCI_CONNECT_TYPE_PCIE_SWITCH.

9 years agoqemu: add capabilities bit for device x3130-upstream
Laine Stump [Tue, 16 Jun 2015 18:54:21 +0000 (14:54 -0400)]
qemu: add capabilities bit for device x3130-upstream

This is the upstream part of a PCIe switch. It connects to a PCIe port
(but not PCI) on the upstream side, and can have up to 31
xio3130-downstream controllers (but no other types of devices)
connected to its downstream side.

This device will be used to implement the "pcie-switch-upstream-port"
model of pci controller.

9 years agoqemu: support new pci controller model "pcie-root-port"
Laine Stump [Wed, 17 Jun 2015 17:27:57 +0000 (13:27 -0400)]
qemu: support new pci controller model "pcie-root-port"

This is backed by the qemu device ioh3420.

chassis and port from the <target> subelement are used to store/set the
respective qemu device options for the ioh3420. Currently, chassis is
set to be the index of the controller, and port is set to
"(slot << 3) + function" (per suggestion from Alex Williamson).

9 years agoconf: new pci controller model "pcie-root-port"
Laine Stump [Wed, 17 Jun 2015 17:21:16 +0000 (13:21 -0400)]
conf: new pci controller model "pcie-root-port"

This controller can be connected (at domain startup time only - not
hotpluggable) only to a port on the pcie root complex ("pcie-root" in
libvirt config), hence the new connect type
VIR_PCI_CONNECT_TYPE_PCIE_ROOT. It provides a hotpluggable port that
will accept any PCI or PCIe device.

New attributes must be added to the controller <target> subelement for
this - chassis and port are guest-visible option values that will be
set by libvirt with values derived from the controller's index and pci
address information.

9 years agoqemu: add capabilities bit for device ioh3420
Laine Stump [Wed, 17 Jun 2015 17:13:28 +0000 (13:13 -0400)]
qemu: add capabilities bit for device ioh3420

This is a PCIE "root port". It connects only to a port of the
integrated pcie.0 bus of a Q35 machine (can't be hotplugged), and
provides a single PCIe port that can have PCI or PCIe devices
hotplugged into it.

This device will be used to implement the "pcie-root-port" model of
pci controller.

9 years agoqemu: implement <target chassisNr='n'/> subelement/attribute of <controller>
Laine Stump [Wed, 15 Jul 2015 19:16:14 +0000 (15:16 -0400)]
qemu: implement <target chassisNr='n'/> subelement/attribute of <controller>

This uses the new subelement/attribute in two ways:

1) If a "pci-bridge" pci controller has no chassisNr attribute, it
will automatically be set to the controller's index as soon as the
controller's PCI address is known (during
qemuDomainAssignPCIAddresses()).

2) when creating the commandline for a pci-bridge device, chassisNr
will be used to set qemu's chassis_nr option (rather than the previous
practice of hard-coding it to the controller's index).

9 years agoconf: add new <target> subelement with chassisNr attribute to <controller>
Laine Stump [Wed, 1 Jul 2015 16:47:55 +0000 (12:47 -0400)]
conf: add new <target> subelement with chassisNr attribute to <controller>

There are some configuration options to some types of pci controllers
that are currently automatically derived from other parts of the
controller's configuration. For example, in qemu a pci-bridge
controller has an option that is called "chassis_nr"; up until now
libvirt has always set chassis_nr to the index of the pci-bridge. So
this:

  <controller type='pci' model='pci-bridge' index='2'/>

will always result in:

  -device pci-bridge,chassis_nr=2,...

on the qemu commandline. In the future we may decide there is a better
way to derive that option, but even in that case we will need for
existing domains to retain the same chassis_nr they were using in the
past - that is something that is visible to the guest so it is part of
the guest ABI and changing it would lead to problems for migrating
guests (or just guests with very picky OSes).

The <target> subelement has been added as a place to put the new
"chassisNr" attribute that will be filled in by libvirt when it
auto-generates the chassisNr; it will be saved in the config, then
reused any time the domain is started:

  <controller type='pci' model='pci-bridge' index='2'>
    <model type='pci-bridge'/>
    <target chassisNr='2'/>
  </controller>

The one oddity of all this is that if the controller configuration
is changed (for example to change the index or the pci address
where the controller is plugged in), the items in <target> will
*not* be re-generated, which might lead to conflict. I can't
really see any way around this, but fortunately if there is a
material conflict qemu will let us know and we will pass that on
to the user.

9 years agoqemu: implement <model> subelement to <controller>
Laine Stump [Thu, 25 Jun 2015 19:37:33 +0000 (15:37 -0400)]
qemu: implement <model> subelement to <controller>

This patch provides qemu support for the contents of <model> in
<controller> for the two existing PCI controller types that need it
(i.e. the two controller types that are backed by a device that must
be specified on the qemu commandline):

1) pci-bridge - sets <model> name attribute default as "pci-bridge"

2) dmi-to-pci-bridge - sets <model> name attribute default as
   "i82801b11-bridge".

These both match current hardcoded practice.

The defaults are set at the end of qemuDomainAssignPCIAddresses().
This can't be done earlier because some of the options that will be
autogenerated need full PCI address info for the controller, and
because qemuDomainAssignPCIAddresses() might create extra controllers
which would need default settings added, and that hasn't yet been done
at the time the PostParse callbacks are being run.
qemuDomainAssignPCIAddresses() is still called prior to the XML being
written to disk, though, so the autogenerated defaults are persistent.

qemu capabilities bits aren't checked when the domain is defined, but
rather when the commandline is actually created (so the domain can
possibly be defined on a host that doesn't yet have support for the
given device, or a host different from the one where it will
eventually be run). When the commandline is being generated we compare
the modelName to known qemu device names implementing the given type
of controller, and check the capabilities bit for that device.

9 years agoconf: add new <model> subelement with name attribute to <controller>
Laine Stump [Thu, 25 Jun 2015 17:30:23 +0000 (13:30 -0400)]
conf: add new <model> subelement with name attribute to <controller>

This new subelement is used in PCI controllers: the toplevel
*attribute* "model" of a controller denotes what kind of PCI
controller is being described, e.g. a "dmi-to-pci-bridge",
"pci-bridge", or "pci-root". But in the future there will be different
implementations of some of those types of PCI controllers, which
behave similarly from libvirt's point of view (and so should have the
same model), but use a different device in qemu (and present
themselves as a different piece of hardware in the guest). In an ideal
world we (i.e. "I") would have thought of that back when the pci
controllers were added, and used some sort of type/class/model
notation (where class was used in the way we are now using model, and
model was used for the actual manufacturer's model number of a
particular family of PCI controller), but that opportunity is long
past, so as an alternative, this patch allows selecting a particular
implementation of a pci controller with the "name" attribute of the
<model> subelement, e.g.:

  <controller type='pci' model='dmi-to-pci-bridge' index='1'>
    <model name='i82801b11-bridge'/>
  </controller>

In this case, "dmi-to-pci-bridge" is the kind of controller (one that
has a single PCIe port upstream, and 32 standard PCI ports downstream,
which are not hotpluggable), and the qemu device to be used to
implement this kind of controller is named "i82801b11-bridge".

Implementing the above now will allow us in the future to add a new
kind of dmi-to-pci-bridge that doesn't use qemu's i82801b11-bridge
device, but instead uses something else (which doesn't yet exist, but
qemu people have been discussing it), all without breaking existing
configs.

(note that for the existing "pci-bridge" type of PCI controller, both
the model attribute and <model> name are 'pci-bridge'. This is just a
coincidence, since it turns out that in this case the device name in
qemu really is a generic 'pci-bridge' rather than being the name of
some real-world chip)

9 years agoconf: more useful error message when pci function is out of range
Laine Stump [Wed, 22 Jul 2015 15:59:00 +0000 (11:59 -0400)]
conf: more useful error message when pci function is out of range

If a pci address had a function number out of range, the error message
would be:

  Insufficient specification for PCI address

which is logged by virDevicePCIAddressParseXML() after
virDevicePCIAddressIsValid returns a failure.

This patch enhances virDevicePCIAddressIsValid() to optionally report
the error itself (since it is the place that decides which part of the
address is "invalid"), and uses that feature when calling from
virDevicePCIAddressParseXML(), so that the error will be more useful,
e.g.:

  Invalid PCI address function=0x8, must be <= 7

Previously, virDevicePCIAddressIsValid didn't check for the
theoretical limits of domain or bus, only for slot or function. While
adding log messages, we also correct that ommission. (The RNG for PCI
addresses already enforces this limit, which by the way means that we
can't add any negative tests for this - as far as I know our
domainschematest has no provisions for passing XML that is supposed to
fail).

Note that virDevicePCIAddressIsValid() can only check against the
absolute maximum attribute values for *any* possible PCI controller,
not for the actual maximums of the specific controller that this
device is attaching to; fortunately there is later more specific
validation for guest-side PCI addresses when building the set of
assigned PCI addresses. For host-side PCI addresses (e.g. for
<hostdev> and for network device pools), we rely on the error that
will be logged when it is found that the device doesn't actually
exist.

This resolves:

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

9 years agovirDomainDefParseXML: Check for malicious cpu ids in <numa/>
Michal Privoznik [Fri, 7 Aug 2015 14:36:38 +0000 (16:36 +0200)]
virDomainDefParseXML: Check for malicious cpu ids in <numa/>

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

Some users think this is a good idea:

      <vcpu placement='static'>4</vcpu>
      <cpu mode='host-model'>
        <model fallback='allow'/>
        <numa>
          <cell id='0' cpus='0-1' memory='1048576' unit='KiB'/>
          <cell id='1' cpus='9-10' memory='2097152' unit='KiB'/>
        </numa>
      </cpu>

It's not. Lets therefore introduce a check and discourage them in
doing so.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agonuma_conf: Introduce virDomainNumaGetMaxCPUID
Michal Privoznik [Fri, 7 Aug 2015 14:31:57 +0000 (16:31 +0200)]
numa_conf: Introduce virDomainNumaGetMaxCPUID

This function should return the greatest CPU number set in
/domain/cpu/numa/cell/@cpus. The idea is that we should compare
the returned value against /domain/vcpu value. Yes, there exist
users who think the following is a good idea:

  <vcpu placement='static'>4</vcpu>
  <cpu mode='host-model'>
    <model fallback='allow'/>
    <numa>
      <cell id='0' cpus='0-1' memory='1048576' unit='KiB'/>
      <cell id='1' cpus='9-10' memory='2097152' unit='KiB'/>
    </numa>
  </cpu>

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemu: Fix reporting of physical capacity for block devices
Peter Krempa [Fri, 7 Aug 2015 09:01:49 +0000 (11:01 +0200)]
qemu: Fix reporting of physical capacity for block devices

Qemu reports physical size 0 for block devices. As 15fa84acbb55ebfee6a4
changed the behavior of qemuDomainGetBlockInfo to just query the monitor
this created a regression since we didn't report the size correctly any
more.

This patch adds code to refresh the physical size of a block device by
opening it and seeking to the end and uses it both in
qemuDomainGetBlockInfo and also in qemuDomainGetStatsOneBlock that was
broken since it was introduced in this respect.

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

9 years agoAllow vfio hotplug of a device to the domain which owns the iommu
Shivaprasad G Bhat [Tue, 14 Jul 2015 11:56:33 +0000 (17:26 +0530)]
Allow vfio hotplug of a device to the domain which owns the iommu

The commit 7e72de4 didn't consider the hotplug scenarios. The patch addresses
the hotplug case whereby if atleast one of the pci function is owned by a
guest, the hotplug of other functions/devices in the same iommu group to the
same guest goes through successfully.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
9 years agoqemuDomainDefPostParse: Adjust indent
Michal Privoznik [Thu, 6 Aug 2015 13:33:01 +0000 (15:33 +0200)]
qemuDomainDefPostParse: Adjust indent

While reviewing e8d551725 I've noticed a few unaligned lines.
Fix this.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agobootstrap: Don't require python-config
Michal Privoznik [Mon, 29 Jun 2015 11:43:51 +0000 (13:43 +0200)]
bootstrap: Don't require python-config

We've split the python bindings a long time ago. However,
we are still requiring python-config (as an obfuscation to
python-devel). This does not make any sense. The only thing
we need is python, not python-devel.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemu: Allow to plug virtio-net-pci into PCIe slot
Pavel Fedin [Fri, 17 Jul 2015 11:27:47 +0000 (14:27 +0300)]
qemu: Allow to plug virtio-net-pci into PCIe slot

virtio-net-pci adapter is capable to use irqfd with vhost-net only in MSI-X
mode, which appears to be available only on PCIe bus, at least on ARM

Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
9 years agoqemu: Build correct command line for PCI NICs on ARM
Pavel Fedin [Fri, 17 Jul 2015 11:27:46 +0000 (14:27 +0300)]
qemu: Build correct command line for PCI NICs on ARM

Legacy -net option works correctly only with embedded device models, which
do not require any bus specification. Therefore, we should use -device for
PCI hardware

Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
9 years agoqemu: Add PCI-Express root to ARM virt machine
Pavel Fedin [Fri, 17 Jul 2015 11:27:45 +0000 (14:27 +0300)]
qemu: Add PCI-Express root to ARM virt machine

Here we assume that if qemu supports generic PCI host controller,
it is a part of virt machine and can be used for adding PCI devices.

In qemu this is actually a PCIe bus, so we also declare multibus
capability so that 0'th bus is specified to qemu correctly as 'pcie.0'

Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemu: Introduce QEMU_CAPS_OBJECT_GPEX
Pavel Fedin [Fri, 17 Jul 2015 11:27:44 +0000 (14:27 +0300)]
qemu: Introduce QEMU_CAPS_OBJECT_GPEX

This capability specifies that qemu can implement generic PCI host
controller. It is often used for virtual environments, including ARM.

Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
9 years agoqemu: Forbid image pre-creation for non-shared storage migration
Peter Krempa [Tue, 4 Aug 2015 08:12:30 +0000 (10:12 +0200)]
qemu: Forbid image pre-creation for non-shared storage migration

Libvirt doesn't reliably know the location of the backing chain when
pre-creating images for non-shared migration. This isn't a problem for
full copy, but incremental copy requires the information.

Forbid pre-creating the image in cases where incremental migration is
required. This limitation can perhaps be lifted once libvirt will fully
support loading of backing chain information from the XML.

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

9 years agocpu: Indentation changes in the ppc64 driver
Andrea Bolognani [Mon, 20 Jul 2015 13:20:20 +0000 (15:20 +0200)]
cpu: Indentation changes in the ppc64 driver

9 years agocpu: Rename {powerpc,ppc} => ppc64 (internal symbols)
Andrea Bolognani [Mon, 20 Jul 2015 13:13:02 +0000 (15:13 +0200)]
cpu: Rename {powerpc,ppc} => ppc64 (internal symbols)

Update the names of the symbols used internally by the driver.

No functional changes.

9 years agocpu: Rename {powerpc,ppc} => ppc64 (exported symbols)
Andrea Bolognani [Mon, 20 Jul 2015 12:35:22 +0000 (14:35 +0200)]
cpu: Rename {powerpc,ppc} => ppc64 (exported symbols)

Only the symbols exported by the driver have been updated;
the driver implementation itself still uses the old names
internally.

No functional changes.

9 years agocpu: Rename {powerpc,ppc} => ppc64 (filesystem)
Andrea Bolognani [Mon, 20 Jul 2015 12:17:52 +0000 (14:17 +0200)]
cpu: Rename {powerpc,ppc} => ppc64 (filesystem)

The driver only supports VIR_ARCH_PPC64 and VIR_ARCH_PPC64LE.

Just shuffling files around and updating the build system
accordingly. No functional changes.

9 years agoconf: Resolve Coverity FORWARD_NULL
John Ferlan [Tue, 4 Aug 2015 10:50:29 +0000 (06:50 -0400)]
conf: Resolve Coverity FORWARD_NULL

The recent changes to perform SCSI device address checks during the
post parse callbacks ran afoul of the Coverity checker since the changes
assumed that the 'xmlopt' parameter to virDomainDeviceDefPostParse
would be non NULL (commit id 'ca2cf74e87'); however, what was missed
is there was an "if (xmlopt &&" check being made, so Coverity believed
that it could be possible for a NULL 'xmlopt'.

Checking the various calling paths seemingly disproves that. If called
from virDomainDeviceDefParse, there were two other possible calls that
would end up dereffing, so that path could not be NULL. If called via
virDomainDefPostParseDeviceIterator via virDomainDefPostParse there
are two callers (virDomainDefParseXML and qemuParseCommandLine)
which deref xmlopt either directly or through another call.

So I'm removing the check for non-NULL xmlopt.

9 years agovirsh: fix domfsinfo output in quiet mode
Luyao Huang [Wed, 5 Aug 2015 03:17:22 +0000 (11:17 +0800)]
virsh: fix domfsinfo output in quiet mode

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

When run domfsinfo in quiet mode, we cannot get any
useful information (just get \n), this is because
we didn't use vshPrint to print useful information.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
9 years agotests: extend workaround for gnutls private key loading failure
Daniel P. Berrange [Tue, 4 Aug 2015 11:26:15 +0000 (12:26 +0100)]
tests: extend workaround for gnutls private key loading failure

In gnutls 3.4.3 there is a regression in the loading of private
keys via gnutls_x509_privkey_import. We already have a workaround
to deal with failures on older gnutls, but the error code that
the new gnutls returns is different. Extend the workaround so that
is checks for GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE too.

See also gnutls https://bugzilla.redhat.com/show_bug.cgi?id=1250020

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>