]> xenbits.xensource.com Git - people/dariof/libvirt.git/log
people/dariof/libvirt.git
11 years agolibxl: implement virDomainGetNumaParameters libxl-numa-v1
Dario Faggioli [Fri, 14 Jun 2013 10:25:55 +0000 (12:25 +0200)]
libxl: implement virDomainGetNumaParameters

Although, having it depending on Xen >= 4.3 (by using the proper
libxl feature flag).

Xen currently implements a NUMA placement policy which is basically
the same as the 'interleaved' policy of `numactl', although it can
be applied on a subset of the available nodes. We therefore hardcode
"interleave" as 'numa_mode', and we use the newly introduced libxl
interface to figure out what nodes a domain spans ('numa_nodeset').

With this change, it is now possible to query the NUMA node
affinity of a running domain:

[raistlin@Zhaman ~]$ sudo virsh --connect xen:/// list
 Id    Name                           State
----------------------------------------------------
 23    F18_x64                        running

[raistlin@Zhaman ~]$ sudo virsh --connect xen:/// numatune 23
numa_mode      : interleave
numa_nodeset   : 1

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
11 years agolibxl: advertise the support for VIR_TYPED_PARAM_STRING
Dario Faggioli [Fri, 28 Jun 2013 05:22:34 +0000 (07:22 +0200)]
libxl: advertise the support for VIR_TYPED_PARAM_STRING

domainGetNumaParameters has a string typed parameter, hence it
is necessary for the libxl driver to support this.

This change implements the connectSupportsFeature hook for the
libxl driver, advertising that VIR_DRV_FEATURE_TYPED_PARAM_STRING
is something good to go.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Cc: Eric Blake <eblake@redhat.com>
11 years agolibxl: implement per NUMA node free memory reporting
Dario Faggioli [Wed, 19 Jun 2013 12:44:59 +0000 (14:44 +0200)]
libxl: implement per NUMA node free memory reporting

By providing the implementation of nodeGetCellsFreeMemory for
the driver. This is all just a matter of properly formatting, in
a way that libvirt like, what Xen provides via libxl_get_numainfo().

[raistlin@Zhaman ~]$ sudo virsh --connect xen:/// freecell --all
    0:      25004 KiB
    1:     105848 KiB
--------------------
Total:     130852 KiB

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
11 years agolibxl: implement NUMA capabilities reporting
Dario Faggioli [Fri, 14 Jun 2013 10:24:15 +0000 (12:24 +0200)]
libxl: implement NUMA capabilities reporting

Starting from Xen 4.2, libxl has all the bits and pieces are in
place for retrieving an adequate amount of information about the
host NUMA topology. It is therefore possible, after a bit of
shuffling, to arrange those information in the way libvirt wants
to present them to the outside world.

Therefore, with this patch, the <topology> section of the host
capabilities is properly populated, when running on Xen, so that
we can figure out whether or not we're running on a NUMA host,
and what its characteristics are.

[raistlin@Zhaman ~]$ sudo virsh --connect xen:/// capabilities
<capabilities>
  <host>
    <cpu>
    ....
    <topology>
      <cells num='2'>
        <cell id='0'>
          <memory unit='KiB'>6291456</memory>
          <cpus num='8'>
            <cpu id='0' socket_id='1' core_id='0' siblings='0-1'/>
            <cpu id='1' socket_id='1' core_id='0' siblings='0-1'/>
            <cpu id='2' socket_id='1' core_id='1' siblings='2-3'/>
            <cpu id='3' socket_id='1' core_id='1' siblings='2-3'/>
            <cpu id='4' socket_id='1' core_id='9' siblings='4-5'/>
            <cpu id='5' socket_id='1' core_id='9' siblings='4-5'/>
            <cpu id='6' socket_id='1' core_id='10' siblings='6-7'/>
            <cpu id='7' socket_id='1' core_id='10' siblings='6-7'/>
          </cpus>
        </cell>
        <cell id='1'>
          <memory unit='KiB'>6881280</memory>
          <cpus num='8'>
            <cpu id='8' socket_id='0' core_id='0' siblings='8-9'/>
            <cpu id='9' socket_id='0' core_id='0' siblings='8-9'/>
            <cpu id='10' socket_id='0' core_id='1' siblings='10-11'/>
            <cpu id='11' socket_id='0' core_id='1' siblings='10-11'/>
            <cpu id='12' socket_id='0' core_id='9' siblings='12-13'/>
            <cpu id='13' socket_id='0' core_id='9' siblings='12-13'/>
            <cpu id='14' socket_id='0' core_id='10' siblings='14-15'/>
            <cpu id='15' socket_id='0' core_id='10' siblings='14-15'/>
          </cpus>
        </cell>
      </cells>
    </topology>
  </host>
  ....

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
11 years agoReplace use of 'in_addr_t' with 'struct in_addr'
Daniel P. Berrange [Fri, 28 Jun 2013 11:43:39 +0000 (12:43 +0100)]
Replace use of 'in_addr_t' with 'struct in_addr'

The 'in_addr_t' typedef is not present in Mingw64 headers.
Instead we can use the more portable 'struct in_addr' and
then access its 's_addr' field.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAllow RO connections to interface udev backend
Doug Goldstein [Fri, 28 Jun 2013 01:43:00 +0000 (20:43 -0500)]
Allow RO connections to interface udev backend

The udev based interface backend did not allow querying data over a
read-only connection which is different than how the netcf backend
operates. This brings the behavior inline with the default, netcf
backend.

11 years agobuild: Fix VPATH build for access/*
Viktor Mihajlovski [Thu, 27 Jun 2013 16:24:16 +0000 (18:24 +0200)]
build: Fix VPATH build for access/*

VPATH build failed for the generated access driver files.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
11 years agoFix vPort management: FC vHBA creation
Dennis Chen [Fri, 28 Jun 2013 09:59:51 +0000 (11:59 +0200)]
Fix vPort management: FC vHBA creation

When creating a virtual FC HBA with virsh/libvirt API, an error message
will be returned: "error: Node device not found",
also the 'nodedev-dumpxml' shows wrong information of wwpn & wwnn
for the new created device.

Signed-off-by: xschen@tnsoft.com.cn
This reverts f90af69 which switched wwpn & wwwn in the wrong place.

https://www.kernel.org/doc/Documentation/scsi/scsi_fc_transport.txt

11 years agoutil: fix build error on non-Linux systems
Laine Stump [Fri, 28 Jun 2013 08:00:54 +0000 (04:00 -0400)]
util: fix build error on non-Linux systems

Building on FreeBSD had this linker error:

/work/a/ports/devel/libvirt/work/libvirt-1.1.0/src/.libs/libvirt.so:
   undefined reference to `virPCIDeviceAddressParse'

This was caused by the new use of virPCIDeviceAddressParse in a
portion of virpci.c that wasn't linux-only (in commit 72c029d8). The
problem was that virPCIDeviceAddressParse had originally been defined
inside #ifdef _linux (because it was only used by another function
that was inside the same ifdef).

The solution is to move it out to the part of virpci.c that is
compiled on all platforms.

(Because the portion that was "moved" was 40-50 lines, but only moved
up by 15 lines, the diff for the patch is less than non-informative -
rather than showing that part that I moved, it shows the bit that was
previously before the moved part, and now sits *after* it.)

11 years agoconf: Swap order of AddImplicitControllers and DomainDefPostParse
Viktor Mihajlovski [Mon, 17 Jun 2013 14:17:37 +0000 (16:17 +0200)]
conf: Swap order of AddImplicitControllers and DomainDefPostParse

Implicit controllers may be dependent on device definitions altered
in a post-parse callback. Specifically, if a console device is
defined without the target type, the type will be set in QEMU's
callback. In the case of s390, this is virtio, which requires
an implicit virtio-serial controller.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
11 years agoS390: Testcase for console default target type (virtio)
Viktor Mihajlovski [Mon, 17 Jun 2013 14:17:36 +0000 (16:17 +0200)]
S390: Testcase for console default target type (virtio)

For s390 the default console target type is virtio. This also requires
that an implicit virtio-serial controller is instantiated.
This testcase verifies that the target type of virtio is correctly set
in the generated XML if no target element was given and that the
corresponding virtio-serial element is generated too.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
11 years agovirsh: Add parenthesis into virsh nodedev-detach help
xuzhang [Thu, 27 Jun 2013 11:21:07 +0000 (19:21 +0800)]
virsh: Add parenthesis into virsh nodedev-detach help

11 years agobridge: don't crash on bandwidth unplug with no bandwidth
Ján Tomko [Fri, 21 Jun 2013 17:20:31 +0000 (19:20 +0200)]
bridge: don't crash on bandwidth unplug with no bandwidth

If networkUnplugBandwidth is called on a network which has
no bandwidth defined, print a warning instead of crashing.

This can happen when destroying a domain with bandwidth if
bandwidth was removed from the network after the domain was
started.

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

11 years agonodedev: add iommuGroup to node device object
Laine Stump [Sun, 23 Jun 2013 18:01:00 +0000 (14:01 -0400)]
nodedev: add iommuGroup to node device object

This includes adding it to the nodedev parser and formatter, docs, and
test.

An example of the new iommuGroup element that is a part of the output
from "virsh nodedev-dumpxml" (virNodeDeviceGetXMLDesc()):

  <device>
    <name>pci_0000_02_00_1</name>
    <capability type='pci'>
    ...
      <iommuGroup number='12'>
        <address domain='0x0000' bus='0x02' slot='0x00' function='0x0'/>
        <address domain='0x0000' bus='0x02' slot='0x00' function='0x1'/>
      </iommuGroup>
    </capability>
  </device>

11 years agopci: new iommu_group functions
Laine Stump [Sun, 23 Jun 2013 18:47:57 +0000 (14:47 -0400)]
pci: new iommu_group functions

Any device which belongs to an "IOMMU group" (used by vfio) will
have links to all devices of its group listed in
/sys/bus/pci/$device/iommu_group/devices;
/sys/bus/pci/$device/iommu_group is actually a link to
/sys/kernel/iommu_groups/$n, where $n is the group number (there
will be a corresponding device node at /dev/vfio/$n once the
devices are bound to the vfio-pci driver)

The following functions are added:

virPCIDeviceGetIOMMUGroupList

  Gets a virPCIDeviceList with one virPCIDeviceList for each device
  in the same IOMMU group as the provided virPCIDevice (a copy of the
  original device object is included in the list.

virPCIDeviceAddressIOMMUGroupIterate

  Calls the function @actor once for each device in the group that
  contains the given virPCIDeviceAddress.

virPCIDeviceAddressGetIOMMUGroupAddresses

  Fills in a virPCIDeviceAddressPtr * with an array of
  virPCIDeviceAddress, one for each device in the iommu group of the
  provided virPCIDeviceAddress (including a copy of the original).

virPCIDeviceAddressGetIOMMUGroupNum

  Returns the group number as an int (a valid group number will always
  be 0 or greater).  If there is no iommu_group link in the device's
  directory (usually indicating that vfio isn't loaded), -2 will be
  returned. On any real error, -1 will be returned.

11 years agoPlug leak in virCgroupMoveTask
Ján Tomko [Wed, 26 Jun 2013 12:55:27 +0000 (14:55 +0200)]
Plug leak in virCgroupMoveTask

We only break out of the while loop if *content is an empty string.
However the buffer has been allocated to BUFSIZ + 1 (8193 in my case),
but it gets overwritten in the next for iteration.

Move VIR_FREE right before we overwrite it to avoid the leak.

==5777== 16,386 bytes in 2 blocks are definitely lost in loss record 1,022 of 1,027
==5777==    by 0x5296E28: virReallocN (viralloc.c:184)
==5777==    by 0x52B0C66: virFileReadLimFD (virfile.c:1137)
==5777==    by 0x52B0E1A: virFileReadAll (virfile.c:1199)
==5777==    by 0x529B092: virCgroupGetValueStr (vircgroup.c:534)
==5777==    by 0x529AF64: virCgroupMoveTask (vircgroup.c:1079)

Introduced by 83e4c77.

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

11 years agoFix invalid read in virCgroupGetValueStr
Ján Tomko [Wed, 26 Jun 2013 11:07:24 +0000 (13:07 +0200)]
Fix invalid read in virCgroupGetValueStr

Don't check for '\n' at the end of file if zero bytes were read.

Found by valgrind:
==404== Invalid read of size 1
==404==    at 0x529B09F: virCgroupGetValueStr (vircgroup.c:540)
==404==    by 0x529AF64: virCgroupMoveTask (vircgroup.c:1079)
==404==    by 0x1EB475: qemuSetupCgroupForEmulator (qemu_cgroup.c:1061)
==404==    by 0x1D9489: qemuProcessStart (qemu_process.c:3801)
==404==    by 0x18557E: qemuDomainObjStart (qemu_driver.c:5787)
==404==    by 0x190FA4: qemuDomainCreateWithFlags (qemu_driver.c:5839)

Introduced by 0d0b409.

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

11 years agoFix sample TPM XML
Stefan Berger [Wed, 26 Jun 2013 12:29:08 +0000 (08:29 -0400)]
Fix sample TPM XML

Fix an error in the sample TPM XML.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
11 years agonetwork: allow <vlan> in type='hostdev' networks
Laine Stump [Tue, 25 Jun 2013 23:32:07 +0000 (19:32 -0400)]
network: allow <vlan> in type='hostdev' networks

Although SRIOV network cards support setting a vlan tag on their
virtual functions, and although setting this vlan tag via a <vlan>
element in a domain's <interface> works, setting a vlan tag for these
devices in a <network> definition, or in a network <portgroup>
definition is also supposed to work (and the comment that validates
<vlan> usage even says that!). However, the check to allow it only
checked for an openvswitch network, so attempts to add <vlan> to a
network of type='hostdev' would fail.

11 years agodocs: correct and update network vlan example
Laine Stump [Wed, 26 Jun 2013 06:13:45 +0000 (02:13 -0400)]
docs: correct and update network vlan example

Somehow I put an example of a domain interface with a <vlan> element
into the network documentation.

This patch replaces that with an example of a network definition that
has a vlan element with trunk='yes', multiple tags, and even the new
nativeMode attribute. It also includes a <portgroup> that has a vlan
defined.

11 years agotest: include qemuhotplugtest data files in source rpm
Laine Stump [Wed, 26 Jun 2013 05:45:43 +0000 (01:45 -0400)]
test: include qemuhotplugtest data files in source rpm

commit 0fc12bca added a new test called qemuhotplugtest which has
several data files in tests/qemuhotplugtestdata, but didn't add that
directory to EXTRA_DIST in the tests Makefile.am, so the make check
done during a make rpm was failing due to missing data files.

11 years agoqemu: fix infinite loop in OOM error path
Laine Stump [Tue, 25 Jun 2013 02:42:35 +0000 (22:42 -0400)]
qemu: fix infinite loop in OOM error path

A loop in qemuPrepareHostdevPCIDevices() intended to cycle through all
the objects on the list pcidevs was doing "while (listcount > 0)", but
nothing in the body of the loop was reducing the size of the list - it
was instead removing items from a *different* list. It has now been
safely changed to a for() loop.

11 years agopci: fix dangling pointer in qemuDomainReAttachHostdevDevices
Laine Stump [Tue, 25 Jun 2013 02:04:43 +0000 (22:04 -0400)]
pci: fix dangling pointer in qemuDomainReAttachHostdevDevices

(This isn't as bad as it sounds - it's only a problem in case of an
OOM error.)

qemuGetActivePciHostDeviceList() had been creating a list that
contained pointers to objects that were also on the activePciHostdevs
list. In case of an OOM error, this newly created list would be
virObjectUnref'ed, which would cause everything on the list to be
freed. But all of those objects would still be on the
activePciHostdevs list, which could have very bad consequences if that
list was ever again accessed.

The solution used here is to populate the new list with *copies* of
the objects from the original list. It turns out that on return from
qemuGetActivePciHostDeviceList(), the caller would almost immediately
go through all the device objects and "steal" them (i.e. remove the
pointer from the list but not delete it) all from either one list or
the other; we now instead just *delete* (remove from the list and
free) each device from one list or the other, so in the end we have
the same state.

11 years agopci: eliminate leak in OOM condition
Laine Stump [Tue, 25 Jun 2013 01:30:55 +0000 (21:30 -0400)]
pci: eliminate leak in OOM condition

The "fix" I pushed a few commits ago would still leak a virPCIDevice
in case of an OOM error. Although it's inconsequential in practice,
this patch satisfies my OCD.

11 years agopci: virPCIDeviceListAddCopy API
Laine Stump [Tue, 25 Jun 2013 01:27:52 +0000 (21:27 -0400)]
pci: virPCIDeviceListAddCopy API

Make a copy of the device and add the copy to the
list. (virPCIDeviceListAdd() adds the original object to the list
instead).

11 years agopci: update stubDriver name in virPCIDeviceBindToStub
Laine Stump [Mon, 3 Jun 2013 17:50:42 +0000 (13:50 -0400)]
pci: update stubDriver name in virPCIDeviceBindToStub

If the device is bound to a stub driver different from what is saved
in the virPCIDevice's stubDriver attribute, update it.

11 years agopci: eliminate repetitive path constructions in virPCIDeviceBindToStub
Laine Stump [Mon, 3 Jun 2013 16:55:09 +0000 (12:55 -0400)]
pci: eliminate repetitive path constructions in virPCIDeviceBindToStub

The same strings were being re-created multiple times just to save
declaring a new variable. In the meantime, the use of the generic
variable names led to confusion when trying to follow the code. This
patch creates strings for:

 stubDriverName  (was called "driver" in original args)
 stubDriverPath  ("/sys/bus/pci/drivers/${stubDriverName}")
 driverLink      ("${device}/driver")
 oldDriverName   (the final component of path linked to by
                  "${device}/driver")
 oldDriverPath   ("/sys/bus/pci/drivers/${oldDriverName}")

then re-uses them as necessary.

11 years agopci: rename virPCIParseDeviceAddress and make it public
Laine Stump [Mon, 17 Jun 2013 15:57:19 +0000 (11:57 -0400)]
pci: rename virPCIParseDeviceAddress and make it public

This function has utility outside of virpci.c, so make it public.

Also the name didn't fit convention, so change it to
virPCIDeviceAddressParse.

11 years agopci: rename virPCIDeviceGetVFIOGroupDev to virPCIDeviceGetIOMMUGroupDev
Laine Stump [Fri, 14 Jun 2013 20:18:44 +0000 (16:18 -0400)]
pci: rename virPCIDeviceGetVFIOGroupDev to virPCIDeviceGetIOMMUGroupDev

I realized after the fact that it's probably better in the long run to
give this function a name that matches the name of the link used in
sysfs to hold the group (iommu_group).

I'm changing it now because I'm about to add several more functions
that deal with iommu groups.

11 years agopci: eliminate unused driver arg from virPCIDeviceDetach
Laine Stump [Thu, 30 May 2013 18:14:46 +0000 (14:14 -0400)]
pci: eliminate unused driver arg from virPCIDeviceDetach

The driver arg to virPCIDeviceDetach is no longer used (the name of the stub driver is now set in the virPCIDevice object, and virPCIDeviceDetach retrieves it from there). Remove it.

11 years agoutil: fix bug found by Coverity
Laine Stump [Tue, 25 Jun 2013 15:42:13 +0000 (11:42 -0400)]
util: fix bug found by Coverity

Commit 861d40565 added code (my personal change to "clean up" the
submitter's code, *not* the fault of the submitter) that dereferenced
virtVlan without first checking for NULL. This patch fixes that and,
as part of the fix, cleans up some unnecessary obtuseness.

11 years agotests: Introduce qemuhotplugtest
Michal Privoznik [Fri, 21 Jun 2013 14:27:59 +0000 (16:27 +0200)]
tests: Introduce qemuhotplugtest

As my punishment for the break in 7f15ebc7 (fixed in 752596b5dd) I'm
introducing this test to make sure it won't happen again. Currently,
only test for <graphics/> is supported.

11 years agoqemu: Implement support for VIR_MIGRATE_PARAM_GRAPHICS_URI
Jiri Denemark [Tue, 18 Jun 2013 10:17:18 +0000 (12:17 +0200)]
qemu: Implement support for VIR_MIGRATE_PARAM_GRAPHICS_URI

11 years agoImplement extensible migration APIs in qemu driver
Jiri Denemark [Tue, 25 Jun 2013 13:49:21 +0000 (15:49 +0200)]
Implement extensible migration APIs in qemu driver

11 years agoqemu: Move internals of Confirm phase to qemu_migration.c
Jiri Denemark [Tue, 25 Jun 2013 12:55:10 +0000 (14:55 +0200)]
qemu: Move internals of Confirm phase to qemu_migration.c

11 years agoqemu: Move common parts of Prepare phase to qemu_migration.c
Jiri Denemark [Tue, 25 Jun 2013 12:38:05 +0000 (14:38 +0200)]
qemu: Move common parts of Prepare phase to qemu_migration.c

11 years agoqemu: Move internals of Begin phase to qemu_migration.c
Jiri Denemark [Tue, 25 Jun 2013 07:44:14 +0000 (09:44 +0200)]
qemu: Move internals of Begin phase to qemu_migration.c

11 years agoFix possible NULL dereference during migration
Jiri Denemark [Tue, 25 Jun 2013 14:10:09 +0000 (16:10 +0200)]
Fix possible NULL dereference during migration

11 years agoUse 1.1.0 everywhere in the documentation
Ján Tomko [Tue, 25 Jun 2013 13:25:29 +0000 (15:25 +0200)]
Use 1.1.0 everywhere in the documentation

Since we already have the v1.1.0-rc1 tag in git.

11 years agovirsh: edit: don't leak XML string on reedit or redefine
Ján Tomko [Tue, 25 Jun 2013 13:10:27 +0000 (15:10 +0200)]
virsh: edit: don't leak XML string on reedit or redefine

Free the old XML strings before overwriting them if the user
has chosen to reedit the file or force the redefinition.

Found by Alex Jia trying to reproduce another bug:
https://bugzilla.redhat.com/show_bug.cgi?id=977430#c3

11 years agoFix units in virNetDevBridgeSetSTPDelay on BSD
Roman Bogorodskiy [Tue, 25 Jun 2013 10:49:34 +0000 (11:49 +0100)]
Fix units in virNetDevBridgeSetSTPDelay on BSD

virNetDevBridgeSetSTPDelay accepts delay in milliseconds,
but BSD implementation was expecting seconds. Therefore,
it was working correctly only with delay == 0.

11 years agoAdd polkit policy for API checks to rpm spec
Daniel Veillard [Tue, 25 Jun 2013 11:44:47 +0000 (13:44 +0200)]
Add polkit policy for API checks to rpm spec

11 years agoConfigure native vlan modes on Open vSwitch ports
james robson [Thu, 23 May 2013 17:12:10 +0000 (18:12 +0100)]
Configure native vlan modes on Open vSwitch ports

This patch adds functionality to allow libvirt to configure the
'native-tagged' and 'native-untagged' modes on openvswitch networks.

Signed-off-by: Laine Stump <laine@redhat.com>
11 years agoqemu: don't reset PCI devices being assigned with VFIO
Laine Stump [Mon, 24 Jun 2013 16:00:51 +0000 (12:00 -0400)]
qemu: don't reset PCI devices being assigned with VFIO

I just learned that VFIO resets PCI devices when they are assigned to
guests / returned to the host, so it is redundant for libvirt to reset
the devices. This patch inhibits calling virPCIDeviceReset to devices
that will be/were assigned using VFIO.

11 years agoIntroduce VIR_MIGRATE_PARAM_GRAPHICS_URI parameter
Jiri Denemark [Tue, 18 Jun 2013 07:46:49 +0000 (09:46 +0200)]
Introduce VIR_MIGRATE_PARAM_GRAPHICS_URI parameter

The parameter specifies connection parameters to use for migrating
client's connection to domain's graphical console.

11 years agovirsh: Use extensible migration APIs
Jiri Denemark [Mon, 17 Jun 2013 08:49:27 +0000 (10:49 +0200)]
virsh: Use extensible migration APIs

11 years agopython: Add bindings for extensible migration APIs
Jiri Denemark [Fri, 14 Jun 2013 09:20:54 +0000 (11:20 +0200)]
python: Add bindings for extensible migration APIs

The patch implements wrappers for virDomainMigrate3 and
virDomainMigrateToURI3.

11 years agoExtensible migration APIs
Jiri Denemark [Tue, 7 May 2013 12:29:19 +0000 (14:29 +0200)]
Extensible migration APIs

This patch introduces two new APIs virDomainMigrate3 and
virDomainMigrateToURI3 that may be used in place of their older
variants. These new APIs take optional migration parameters (such as
bandwidth, domain XML, ...) in an array of virTypedParameters, which
makes adding new parameters easier as there's no need to introduce new
APIs whenever a new migration parameter needs to be added. Both APIs are
backward compatible and will automatically use older migration calls in
case the new calls are not supported as long as the typed parameters
array does not contain any parameter which was not supported by the
older calls.

11 years agoAdapt virDomainMigratePeer2Peer for extensible migration APIs
Jiri Denemark [Wed, 12 Jun 2013 10:22:21 +0000 (12:22 +0200)]
Adapt virDomainMigratePeer2Peer for extensible migration APIs

11 years agoAdapt virDomainMigrateVersion3 for extensible migration APIs
Jiri Denemark [Mon, 13 May 2013 16:30:09 +0000 (18:30 +0200)]
Adapt virDomainMigrateVersion3 for extensible migration APIs

11 years agoImplement extensible migration APIs in remote driver
Jiri Denemark [Wed, 29 May 2013 07:47:13 +0000 (09:47 +0200)]
Implement extensible migration APIs in remote driver

11 years agoNew internal migration APIs with extensible parameters
Jiri Denemark [Mon, 20 May 2013 14:59:08 +0000 (16:59 +0200)]
New internal migration APIs with extensible parameters

This patch implements extensible variants of all internal migration APIs
used for v3 migration.

11 years agoIntroduce migration parameters
Jiri Denemark [Tue, 7 May 2013 12:28:45 +0000 (14:28 +0200)]
Introduce migration parameters

To be used by new migration APIs with extensible set of parameters.

11 years agoIntroduce virTypedParamsCopy internal API
Jiri Denemark [Fri, 7 Jun 2013 14:34:13 +0000 (16:34 +0200)]
Introduce virTypedParamsCopy internal API

11 years agoLog input type parameters in API entry points
Jiri Denemark [Thu, 6 Jun 2013 18:05:33 +0000 (20:05 +0200)]
Log input type parameters in API entry points

11 years agoIntroduce VIR_TYPED_PARAMS_DEBUG macro for dumping typed params
Jiri Denemark [Thu, 6 Jun 2013 16:54:48 +0000 (18:54 +0200)]
Introduce VIR_TYPED_PARAMS_DEBUG macro for dumping typed params

All APIs that take typed parameters are only using params address in
their entry point debug messages. With the new VIR_TYPED_PARAMS_DEBUG
macro, all functions can easily log all individual typed parameters
passed to them.

11 years agoIntroduce virTypedParamsReplaceString internal API
Jiri Denemark [Tue, 21 May 2013 13:11:56 +0000 (15:11 +0200)]
Introduce virTypedParamsReplaceString internal API

11 years agoIntroduce virTypedParamsCheck internal API
Jiri Denemark [Mon, 6 May 2013 10:04:06 +0000 (12:04 +0200)]
Introduce virTypedParamsCheck internal API

This API is useful for checking whether only a specific subset of
supported typed parameters were passed.

11 years agoutil: Emit proper error code in virTypedParamsValidate
Jiri Denemark [Tue, 18 Jun 2013 07:24:57 +0000 (09:24 +0200)]
util: Emit proper error code in virTypedParamsValidate

When unsupported parameter is passed to virTypedParamsValidate,
VIR_ERR_ARGUMENT_UNSUPPORTED should be returned rather than
VIR_ERR_INVALID_ARG, which is more appropriate for supported parameters
used incorrectly.

11 years agoRename virTypedParameterArrayValidate as virTypedParamsValidate
Jiri Denemark [Fri, 3 May 2013 13:34:10 +0000 (15:34 +0200)]
Rename virTypedParameterArrayValidate as virTypedParamsValidate

11 years agobuild: Fix check-aclrules in VPATH build
Jiri Denemark [Mon, 24 Jun 2013 22:03:05 +0000 (00:03 +0200)]
build: Fix check-aclrules in VPATH build

11 years agopci: make virPCIDeviceDetach consistent in behavior
Laine Stump [Tue, 4 Jun 2013 19:54:45 +0000 (15:54 -0400)]
pci: make virPCIDeviceDetach consistent in behavior

virPCIDeviceDetach would previously sometimes consume the input device
object (to put it on the inactive list) and sometimes not. Avoiding
memory leaks required checking beforehand to see if the device was
already on the list, and freeing the device object in the caller only
if there wasn't already an identical object on the inactive list.

This patch makes it consistent - virPCIDeviceDetach will *never*
consume the input virPCIDevice object; if it needs to put one on the
inactive list, it will create a copy and put *that* on the list. This
way the caller knows that it is always their responsibility to free
the device object they created.

11 years agopci: eliminate memory leak in virPCIDeviceReattach
Laine Stump [Tue, 4 Jun 2013 20:02:33 +0000 (16:02 -0400)]
pci: eliminate memory leak in virPCIDeviceReattach

virPCIDeviceReattach was making the assumption that the dev object
given to it was one and the same with the dev object on the
inactiveDevs list. If that had been the case, it would not need to
free the dev object it removed from the inactive list, because the
caller of virPCIDeviceReattach always frees the dev object that it
passes in. Since the dev object passed in is *never* the same object
that's on the list (it is a different object with the same name and
attributes, created just for the purpose of searching for the actual
object), simply doing a "ListSteal" to remove the object from the list
results in one leaked object; we need to actually free the object
after removing it from the list.

11 years agopci: new utility functions
Laine Stump [Fri, 31 May 2013 15:06:32 +0000 (11:06 -0400)]
pci: new utility functions

* virPCIDeviceFindByIDs - find a device on a list w/o creating an object
    This makes searching for an existing device on a list lighter weight.

* virPCIDeviceCopy - make a copy of an existing virPCIDevice object.

* virPCIDeviceGetDriverPathAndName - construct new strings containing
    1) the name of the driver bound to this device.
    2) the full path to the sysfs config for that driver.
    (This code was lifted from virPCIDeviceUnbindFromStub, and replaced
    there with a call to this new function).

11 years agopci: change stubDriver from const char* to char*
Laine Stump [Fri, 31 May 2013 18:26:56 +0000 (14:26 -0400)]
pci: change stubDriver from const char* to char*

Previously stubDriver was always set from a string literal, so it was
okay to use a const char * that wasn't freed when the virPCIDevice was
freed. This will not be the case in the near future, so it is now a
char* that is allocated in virPCIDeviceSetStubDriver() and freed
during virPCIDeviceFree().

11 years agosyntax: virPCIDeviceFree is also a NOP for NULL args
Laine Stump [Tue, 4 Jun 2013 20:00:46 +0000 (16:00 -0400)]
syntax: virPCIDeviceFree is also a NOP for NULL args

add it to the syntax-check list and fix the one offending caller.

11 years agolibxl: support qdisk backend
Jim Fehlig [Mon, 13 May 2013 18:14:21 +0000 (12:14 -0600)]
libxl: support qdisk backend

libxl supports the LIBXL_DISK_BACKEND_QDISK disk backend, where qemu
is used to provide the disk backend.  This patch simply maps the
existing <driver name='qemu'/> to LIBXL_DISK_BACKEND_QDISK.

11 years agolibxl: Fix disk format error message
Jim Fehlig [Mon, 13 May 2013 18:14:20 +0000 (12:14 -0600)]
libxl: Fix disk format error message

Specifying an unsupported disk format with the tap driver resulted in
a less than helpful error message

error: Failed to start domain test-hvm
error: internal error libxenlight does not support disk driver qed

Change the message to state that the qed format is not supported by
the tap driver, e.g.

error: Failed to start domain test-hvm
error: internal error libxenlight does not support disk format qed
with disk driver tap

While at it, check for unsupported formats in the other driver
backends.

11 years agoAdd validation that all APIs contain ACL checks
Daniel P. Berrange [Mon, 29 Apr 2013 15:37:07 +0000 (16:37 +0100)]
Add validation that all APIs contain ACL checks

Add a script which parses the driver API code and validates
that every API registered in a virNNNDriverPtr table contains
an ACL check matching the API name.

NB this currently whitelists a few xen driver functions
which are temporarily lacking in access control checks.
The xen driver is considered insecure until these are
fixed.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoSet process ID in system identity
Daniel P. Berrange [Mon, 24 Jun 2013 13:47:31 +0000 (14:47 +0100)]
Set process ID in system identity

When creating a virIdentityPtr for the system identity, include
the current process ID as an attribute.

11 years agoAdd ACL checks into the secrets driver
Daniel P. Berrange [Tue, 23 Apr 2013 10:56:22 +0000 (11:56 +0100)]
Add ACL checks into the secrets driver

Insert calls to the ACL checking APIs in all secrets driver
entrypoints.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd ACL checks into the nwfilter driver
Daniel P. Berrange [Tue, 23 Apr 2013 10:56:22 +0000 (11:56 +0100)]
Add ACL checks into the nwfilter driver

Insert calls to the ACL checking APIs in all nwfilter driver
entrypoints.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd ACL checks into the node device driver
Daniel P. Berrange [Tue, 23 Apr 2013 10:56:22 +0000 (11:56 +0100)]
Add ACL checks into the node device driver

Insert calls to the ACL checking APIs in all node device
driver entrypoints.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd ACL checks into the interface driver
Daniel P. Berrange [Tue, 23 Apr 2013 10:56:22 +0000 (11:56 +0100)]
Add ACL checks into the interface driver

Insert calls to the ACL checking APIs in all interface
driver entrypoints.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd ACL checks into the network driver
Daniel P. Berrange [Tue, 23 Apr 2013 10:56:22 +0000 (11:56 +0100)]
Add ACL checks into the network driver

Insert calls to the ACL checking APIs in all network driver
entrypoints.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd ACL checks into the storage driver
Daniel P. Berrange [Tue, 23 Apr 2013 10:56:22 +0000 (11:56 +0100)]
Add ACL checks into the storage driver

Insert calls to the ACL checking APIs in all storage driver
entrypoints.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd ACL checks into the libxl driver
Daniel P. Berrange [Tue, 23 Apr 2013 10:56:22 +0000 (11:56 +0100)]
Add ACL checks into the libxl driver

Insert calls to the ACL checking APIs in all libxl driver
entrypoints.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd ACL checks into the Xen driver
Daniel P. Berrange [Tue, 23 Apr 2013 10:56:22 +0000 (11:56 +0100)]
Add ACL checks into the Xen driver

Insert calls to the ACL checking APIs in all Xen driver
entrypoints.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd ACL checks into the UML driver
Daniel P. Berrange [Tue, 23 Apr 2013 10:56:22 +0000 (11:56 +0100)]
Add ACL checks into the UML driver

Insert calls to the ACL checking APIs in all UML driver
entrypoints.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd ACL checks into the LXC driver
Daniel P. Berrange [Tue, 23 Apr 2013 10:56:22 +0000 (11:56 +0100)]
Add ACL checks into the LXC driver

Insert calls to the ACL checking APIs in all LXC driver
entrypoints.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd ACL checks into the QEMU driver
Daniel P. Berrange [Mon, 22 Apr 2013 11:09:55 +0000 (12:09 +0100)]
Add ACL checks into the QEMU driver

Insert calls to the ACL checking APIs in all QEMU driver
entrypoints.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAuto-generate helpers for checking access control rules
Daniel P. Berrange [Thu, 18 Apr 2013 16:49:41 +0000 (17:49 +0100)]
Auto-generate helpers for checking access control rules

Extend the 'gendispatch.pl' script to be able to generate
three new types of file.

- 'aclheader' - defines signatures of helper APIs for
  doing authorization checks. There is one helper API
  for each API requiring an auth check. Any @acl
  annotations result in a method being generated with
  a suffix of 'EnsureACL'. If the ACL check requires
  examination of flags, an extra 'flags' param will be
  present. Some examples

  extern int virConnectBaselineCPUEnsureACL(void);
  extern int virConnectDomainEventDeregisterEnsureACL(virDomainDefPtr domain);
  extern int virDomainAttachDeviceFlagsEnsureACL(virDomainDefPtr domain, unsigned int flags);

  Any @aclfilter annotations resuilt in a method being
  generated with a suffix of 'CheckACL'.

  extern int virConnectListAllDomainsCheckACL(virDomainDefPtr domain);

  These are used for filtering individual objects from APIs
  which return a list of objects

- 'aclbody' - defines the actual implementation of the
  methods described above. This calls into the access
  manager APIs. A complex example:

    /* Returns: -1 on error (denied==error), 0 on allowed */
    int virDomainAttachDeviceFlagsEnsureACL(virConnectPtr conn,
                                            virDomainDefPtr domain,
                                            unsigned int flags)
    {
        virAccessManagerPtr mgr;
        int rv;

        if (!(mgr = virAccessManagerGetDefault()))
            return -1;

        if ((rv = virAccessManagerCheckDomain(mgr,
                                              conn->driver->name,
                                              domain,
                                              VIR_ACCESS_PERM_DOMAIN_WRITE)) <= 0) {
            virObjectUnref(mgr);
            if (rv == 0)
                virReportError(VIR_ERR_ACCESS_DENIED, NULL);
            return -1;
        }
        if (((flags & (VIR_DOMAIN_AFFECT_CONFIG|VIR_DOMAIN_AFFECT_LIVE)) == 0) &&
            (rv = virAccessManagerCheckDomain(mgr,
                                              conn->driver->name,
                                              domain,
                                              VIR_ACCESS_PERM_DOMAIN_SAVE)) <= 0) {
            virObjectUnref(mgr);
            if (rv == 0)
                virReportError(VIR_ERR_ACCESS_DENIED, NULL);
            return -1;
        }
        if (((flags & (VIR_DOMAIN_AFFECT_CONFIG)) == (VIR_DOMAIN_AFFECT_CONFIG)) &&
            (rv = virAccessManagerCheckDomain(mgr,
                                              conn->driver->name,
                                              domain,
                                              VIR_ACCESS_PERM_DOMAIN_SAVE)) <= 0) {
            virObjectUnref(mgr);
            if (rv == 0)
                virReportError(VIR_ERR_ACCESS_DENIED, NULL);
            return -1;
        }
        virObjectUnref(mgr);
        return 0;
    }

- 'aclsyms' - generates a linker script to export the
   APIs to drivers. Some examples

  virConnectBaselineCPUEnsureACL;
  virConnectCompareCPUEnsureACL;

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd ACL annotations to all RPC messages
Daniel P. Berrange [Thu, 18 Apr 2013 11:08:47 +0000 (12:08 +0100)]
Add ACL annotations to all RPC messages

Introduce annotations to all RPC messages to declare what
access control checks are required. There are two new
annotations defined:

 @acl: <object>:<permission>
 @acl: <object>:<permission>:<flagname>

  Declare the access control requirements for the API. May be repeated
  multiple times, if multiple rules are required.

    <object> is one of 'connect', 'domain', 'network', 'storagepool',
             'interface', 'nodedev', 'secret'.
    <permission> is one of the permissions in access/viraccessperm.h
    <flagname> indicates the rule only applies if the named flag
    is set in the API call

 @aclfilter: <object>:<permission>

  Declare an access control filter that will be applied to a list
  of objects being returned by an API. This allows the returned
  list to be filtered to only show those the user has permissions
  against

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd a policy kit access control driver
Daniel P. Berrange [Mon, 23 Jan 2012 15:12:57 +0000 (15:12 +0000)]
Add a policy kit access control driver

Add an access control driver that uses the pkcheck command
to check authorization requests. This is fairly inefficient,
particularly for cases where an API returns a list of objects
and needs to check permission for each object.

It would be desirable to use the polkit API but this links
to glib with abort-on-OOM behaviour, so can't be used. The
other alternative is to speak to dbus directly

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoSetup default access control manager in libvirtd
Daniel P. Berrange [Wed, 17 Apr 2013 11:01:24 +0000 (12:01 +0100)]
Setup default access control manager in libvirtd

Add a new 'access_drivers' config parameter to the libvirtd.conf
configuration file. This allows admins to setup the default
access control drivers to use for API authorization. The same
driver is to be used by all internal drivers & APIs

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoSet conn->driver before running driver connectOpen method
Daniel P. Berrange [Thu, 2 May 2013 15:55:52 +0000 (16:55 +0100)]
Set conn->driver before running driver connectOpen method

The access control checks in the 'connectOpen' driver method
will require 'conn->driver' to be non-NULL. Set this before
running the 'connectOpen' method and NULL-ify it again on
failure.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoDefine basic internal API for access control
Daniel P. Berrange [Fri, 20 Jan 2012 18:02:55 +0000 (18:02 +0000)]
Define basic internal API for access control

This patch introduces the virAccessManagerPtr class as the
interface between virtualization drivers and the access
control drivers. The viraccessperm.h file defines the
various permissions that will be used for each type of object
libvirt manages

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoqemu: check if block I/O limits fit into long long
Ján Tomko [Mon, 24 Jun 2013 12:18:14 +0000 (14:18 +0200)]
qemu: check if block I/O limits fit into long long

We can only pass values up to LLONG_MAX through JSON
and QEMU checks if the int64_t number is not negative
at startup since 1.5.0.

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

11 years agoGet rid of useless VIR_STORAGE_FILE_FEATURE_NONE
Ján Tomko [Mon, 24 Jun 2013 06:35:59 +0000 (08:35 +0200)]
Get rid of useless VIR_STORAGE_FILE_FEATURE_NONE

It's not used anywhere except for the switch in
virStorageBackendCreateQemuImgOpts, where leaving it in causes
a dead code coverity warning and omitting it breaks compilation
because of unhandled enum value.

Introduced by 6298f74.

11 years agonetdev: accept NULL in virNetDevSetupControl
Ján Tomko [Fri, 21 Jun 2013 16:57:12 +0000 (18:57 +0200)]
netdev: accept NULL in virNetDevSetupControl

Commit b9c6b073 dropped the version of virNetDevSetupControl
that didn't check for NULL arguments, but we call it like that
in virNetDevBridgeDelete.

11 years agoxen: Implement virConnectGetSysinfo
Jim Fehlig [Wed, 12 Jun 2013 17:21:21 +0000 (11:21 -0600)]
xen: Implement virConnectGetSysinfo

virConnectGetSysinfo was never implemented in the legacy xen driver.
This patch provides an implementation based on the qemu driver.

11 years agolibxl: Implement virConnectGetSysinfo
Jim Fehlig [Wed, 12 Jun 2013 15:49:27 +0000 (09:49 -0600)]
libxl: Implement virConnectGetSysinfo

virConnectGetSysinfo was never implemented in the libxl driver.
This patch provides an implementation based on the qemu driver.

11 years agolibxl: Allow libxl to set NIC devid
Jim Fehlig [Thu, 20 Jun 2013 17:38:37 +0000 (11:38 -0600)]
libxl: Allow libxl to set NIC devid

libxl contains logic to determine an appropriate devid for new devices
that do not specify one in their configuration.  For all device types
except NICs, the libxl driver allows libxl to determine devid.  Do the
same for NICs.

11 years agostorage: add support for creating qcow2 images with extensions
Ján Tomko [Thu, 16 May 2013 10:40:45 +0000 (12:40 +0200)]
storage: add support for creating qcow2 images with extensions

Add -o compat= and -o lazy_refcounts options for qemu-img.

11 years agoconf: add features to volume target XML
Ján Tomko [Thu, 16 May 2013 10:38:26 +0000 (12:38 +0200)]
conf: add features to volume target XML

Add <features> and <compat> elements to volume target XML.

<compat> is a string which for qcow2 represents the QEMU version
it should be compatible with. Valid values are 0.10 and 1.1.
1.1 is implicit if the <features> element is present, otherwise
qemu-img default is used. 0.10 can be specified to explicitly
create older images after the qemu-img default changes.

<features> contains optional features, so far
<lazy_refcounts/> is available, which enables caching of reference
counters, improving performance for snapshots.

11 years agoutil: add support for qcow2v3 image detection
Ján Tomko [Tue, 7 May 2013 15:27:43 +0000 (17:27 +0200)]
util: add support for qcow2v3 image detection

Detect qcow2 images with version 3 in the image header as
VIR_STORAGE_FILE_QCOW2.

These images have a feature bitfield, with just one feature supported
so far: lazy_refcounts.

The header length changed too, moving the location of the backing
format name.

11 years agoqemu: add hv_vapic and hv_spinlocks support
Ján Tomko [Fri, 21 Jun 2013 10:22:18 +0000 (12:22 +0200)]
qemu: add hv_vapic and hv_spinlocks support

XML:
<features>
  <hyperv>
    <vapic state='on'/>
    <spinlocks state='on' retries='4096'/>
  </hyperv>
</features>

results in the following QEMU command line:
qemu -cpu <cpu_model>,hv_vapic,hv_spinlocks=0x1000

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

11 years agoconf: add vapic and spinlocks to hyperv features
Ján Tomko [Fri, 21 Jun 2013 10:20:12 +0000 (12:20 +0200)]
conf: add vapic and spinlocks to hyperv features

Add new CPU features for HyperV:
vapic for virtual APIC support
spinlocks for setting spinlock support

<features>
  <hyperv>
    <vapic state='on'/>
    <spinlocks state='on' retries='4096'/>
  </hyperv>
</features>

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

11 years agoBSD: implement bridge add/remove port and set STP
Roman Bogorodskiy [Wed, 19 Jun 2013 16:47:31 +0000 (20:47 +0400)]
BSD: implement bridge add/remove port and set STP

11 years agoBSD: implement virNetDevBridgeCreate() and virNetDevBridgeDelete()
Roman Bogorodskiy [Wed, 19 Jun 2013 16:47:30 +0000 (20:47 +0400)]
BSD: implement virNetDevBridgeCreate() and virNetDevBridgeDelete()

Implementation uses SIOCIFCREATE2 and SIOCIFDESTROY ioctls.
Also, drop static virNetDevSetupControl() as we have
public one avialable now.