]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
9 years agoZFS: Support sparse volumes
Richard Laager [Thu, 24 Mar 2016 05:11:11 +0000 (00:11 -0500)]
ZFS: Support sparse volumes

By default, `zfs create -V ...` reserves space for the entire volsize,
plus some extra (which attempts to account for overhead).

If `zfs create -s -V ...` is used instead, zvols are (fully) sparse.

A middle ground (partial allocation) can be achieved with
`zfs create -s -o refreservation=... -V ...`.  Both libvirt and ZFS
support this approach, so the ZFS storage backend should support it.

Signed-off-by: Richard Laager <rlaager@wiktel.com>
9 years agoResolve a couple of memory leaks
John Ferlan [Thu, 14 Apr 2016 14:21:27 +0000 (10:21 -0400)]
Resolve a couple of memory leaks

Commit id '4b75237f' seems to have triggered Coverity into finding
at least one memory leak in xen_xl.c for error path for cleanup where
the listenAddr would be leaked. Reviewing other callers, it seems that
qemu_parse_command.c would have the same issue, so just it too.

9 years agotools: Fix memory leak
John Ferlan [Thu, 14 Apr 2016 13:55:21 +0000 (09:55 -0400)]
tools: Fix memory leak

Coverity found that commit id 'c661b675f' needed to create a cleanup
path to handle the closing of 'fp' if the virBitmapNewQuiet failed.

9 years agoqemu: Fix qemuBuildCommandLine prototype
John Ferlan [Thu, 14 Apr 2016 13:51:38 +0000 (09:51 -0400)]
qemu: Fix qemuBuildCommandLine prototype

Commit id '0da965c5e' removed the 11th parameter, but neglected to
remove the ATTRIBUTE_NONNULL for it and adjust the 17th and 18th.

9 years agolibxl: use LIBXL_API_VERSION 0x040200
Jim Fehlig [Thu, 14 Apr 2016 22:10:32 +0000 (16:10 -0600)]
libxl: use LIBXL_API_VERSION 0x040200

To ensure the libvirt libxl driver will build with future versions
of Xen where the libxl API may change in incompatible ways,
explicitly use LIBXL_API_VERSION 0x040200. The libxl driver
does use new libxl APIs that have been added since Xen 4.2, but
currently it does not make use of any changes made to existing
APIs such as libxl_domain_create_restore or libxl_set_vcpuaffinity.
The version can be bumped if/when the libxl driver consumes the
changed APIs.

Further details can be found in the following discussion thread

https://www.redhat.com/archives/libvir-list/2016-April/msg00178.html
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agoqemu: Label master key file
Martin Kletzander [Wed, 13 Apr 2016 15:17:35 +0000 (17:17 +0200)]
qemu: Label master key file

When creating the master key, we used mode 0600 (which we should) but
because we were creating it as root, the file is not readable by any
qemu running as non-root.  Fortunately, it's just a matter of labelling
the file.  We are generating the file path few times already, so let's
label it in the same function that has access to the path already.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoploop: Fix build with gluster
Jiri Denemark [Fri, 15 Apr 2016 16:05:37 +0000 (18:05 +0200)]
ploop: Fix build with gluster

Recent patches addiing support for ploop volumes did not properly update
gluster backend.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoAdd functions for handling exponential backoff loops.
Richard W.M. Jones [Fri, 8 Apr 2016 11:11:10 +0000 (12:11 +0100)]
Add functions for handling exponential backoff loops.

In a few places in libvirt we busy-wait for events, for example qemu
creating a monitor socket.  This is problematic because:

 - We need to choose a sufficiently small polling period so that
   libvirt doesn't add unnecessary delays.

 - We need to choose a sufficiently large polling period so that
   the effect of busy-waiting doesn't affect the system.

The solution to this conflict is to use an exponential backoff.

This patch adds two functions to hide the details, and modifies a few
places where we currently busy-wait.

Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
9 years agostorage: dir: adapt .uploadVol .dowloadVol for ploop volume
Olga Krishtal [Mon, 11 Apr 2016 16:16:25 +0000 (19:16 +0300)]
storage: dir: adapt .uploadVol .dowloadVol for ploop volume

In case of ploop volume, target path of the volume is the path to the
directory that contains image file named root.hds and DiskDescriptor.xml.
While using uploadVol and downloadVol callbacks we need to open root.hds
itself.
Upload or download operations with ploop volume are only allowed when
images do not have snapshots. Otherwise operation fails.

Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
9 years agostorage: dir: adapt .refreshVol and .refreshPool for ploop volumes
Olga Krishtal [Mon, 11 Apr 2016 16:16:24 +0000 (19:16 +0300)]
storage: dir: adapt .refreshVol and .refreshPool for ploop volumes

Refreshes meta-information such as allocation, capacity, format, etc.
Ploop volumes differ from other volume types. Path to volume is the path
to directory with image file root.hds and DiskDescriptor.xml.
https://openvz.org/Ploop/format
Due to this fact, operations of opening the volume have to be done once
again. get the information.

To decide whether the given volume is ploops one, it is necessary to check
the presence of root.hds and DiskDescriptor.xml files in volumes' directory.
Only in this case the volume can be manipulated as the ploops one.
Such strategy helps us to resolve problems that might occure, when we
upload some other volume type from ploop source.

Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
9 years agostorage: dir: .wipeVol is left unsupported for ploop volume
Olga Krishtal [Mon, 11 Apr 2016 16:16:23 +0000 (19:16 +0300)]
storage: dir: .wipeVol is left unsupported for ploop volume

Returns error in case of vol-wipe cmd for a ploop volume

Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com>
9 years agostorage: dir: .resizeVol callback for ploop volume
Olga Krishtal [Mon, 11 Apr 2016 16:16:22 +0000 (19:16 +0300)]
storage: dir: .resizeVol callback for ploop volume

Changes the size of given ploop volume via ploop resize tool.

Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com>
9 years agostorage: dir: .deleteVol callback for ploop volume
Olga Krishtal [Mon, 11 Apr 2016 16:16:21 +0000 (19:16 +0300)]
storage: dir: .deleteVol callback for ploop volume

Recursively deletes whole directory of a ploop volume.
To delete ploop image it has to be unmounted.

Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com>
9 years agostorage: dir: .buildVol and .buildVolFrom callbacks for ploop
Olga Krishtal [Mon, 11 Apr 2016 16:16:20 +0000 (19:16 +0300)]
storage: dir: .buildVol and .buildVolFrom callbacks for ploop

These callbacks let us to create ploop volumes in dir, fs and etc. pools.
If a ploop volume was created via buildVol callback, then this volume
is an empty ploop device with DiskDescriptor.xml.
If the volume was created via .buildFrom - then its content is similar to
input volume content.

Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
9 years agostorage: add ploop volume type
Olga Krishtal [Mon, 11 Apr 2016 16:16:19 +0000 (19:16 +0300)]
storage: add ploop volume type

Ploop image consists of directory with two files: ploop image itself,
called root.hds and DiskDescriptor.xml that contains information about
ploop device: https://openvz.org/Ploop/format.
Such volume are difficult to manipulate in terms of existing volume types
because they are neither a single files nor a directory.
This patch introduces new volume type - ploop. This volume type is used
by ploop volume's exclusively.

Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
9 years agocfg.mk: Get rid of quotation tricks
Andrea Bolognani [Mon, 11 Apr 2016 15:00:26 +0000 (17:00 +0200)]
cfg.mk: Get rid of quotation tricks

To prevent the error messages in cfg.mk from triggering the very
same rules they're supposed to explain, we split the message in
the middle of a symbol name, ending up with stuff like

  'I am a me'ssage

Instead of relying on these quotation tricks, simply exclude
cfg.mk from the relevant checks.

9 years agoReturn error when --start <number> in cpu-stats is invalid.
Nitesh Konkar [Fri, 15 Apr 2016 07:28:53 +0000 (03:28 -0400)]
Return error when --start <number> in cpu-stats is invalid.

Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
9 years agoqemu: hotplug: Properly recalculate/reload balloon size after hot(un)plug
Peter Krempa [Wed, 6 Apr 2016 13:57:57 +0000 (15:57 +0200)]
qemu: hotplug: Properly recalculate/reload balloon size after hot(un)plug

Rather than trying some magic calculations on our side query the monitor
for the current size of the memory balloon both on hotplug and
hotunplug.

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

9 years agoqemu: process: Simplify condition in qemuProcessRefreshBalloonState
Peter Krempa [Wed, 6 Apr 2016 13:43:40 +0000 (15:43 +0200)]
qemu: process: Simplify condition in qemuProcessRefreshBalloonState

No need to store failure and re-check right away.

9 years agoqemu: driver: Reuse qemuDomainGetMonitor in qemuDomainMemoryStats
Peter Krempa [Wed, 6 Apr 2016 13:05:10 +0000 (15:05 +0200)]
qemu: driver: Reuse qemuDomainGetMonitor in qemuDomainMemoryStats

9 years agodomain: Add helper to determine presence of memory baloon
Peter Krempa [Wed, 6 Apr 2016 13:02:31 +0000 (15:02 +0200)]
domain: Add helper to determine presence of memory baloon

9 years agoqemu: command: Refactor memballoon command line formatting
Peter Krempa [Wed, 6 Apr 2016 11:41:31 +0000 (13:41 +0200)]
qemu: command: Refactor memballoon command line formatting

Now that there is just one format of the memory balloon command line
used the code can be merged into a single function.

Additionally with some tweaks to the control flow the code is easier to
read.

9 years agoqemu: command: Drop obsolete comment
Peter Krempa [Wed, 6 Apr 2016 12:34:05 +0000 (14:34 +0200)]
qemu: command: Drop obsolete comment

The change that made qemu not add the memballoon by default happened
prior to 0.12.0. Additionaly the comment was misleading due to the code
that was added below. Since we always need to add a balloon on the
commandline drop the comment.

9 years agoqemu: caps: Deprecate QEMU_CAPS_BALLOON
Peter Krempa [Wed, 6 Apr 2016 12:29:26 +0000 (14:29 +0200)]
qemu: caps: Deprecate QEMU_CAPS_BALLOON

The flag is now unused and all qemus supported by libvirt already
support it.

9 years agoqemu: command: Assume QEMU_CAPS_DEVICE when building memballoon args
Peter Krempa [Wed, 6 Apr 2016 12:24:39 +0000 (14:24 +0200)]
qemu: command: Assume QEMU_CAPS_DEVICE when building memballoon args

9 years agospec: Only pull in API docs with -devel package
Cole Robinson [Wed, 13 Apr 2016 14:37:42 +0000 (10:37 -0400)]
spec: Only pull in API docs with -devel package

Move some API specific documentation out of -docs package and into
-devel, and some end user docs out of -devel and into -docs, then
drop the -devel dep on -docs. This is more in line with the suggested
Fedora guidelines.

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

9 years agoqemu: migration: Drop dead VNC cookie handling
Cole Robinson [Wed, 13 Apr 2016 15:06:42 +0000 (11:06 -0400)]
qemu: migration: Drop dead VNC cookie handling

The only caller of this code is:

    for (i = 0; i < dom->def->ngraphics; i++) {
       if (dom->def->graphics[i]->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
           if (!(mig->graphics =
                 qemuMigrationCookieGraphicsAlloc(driver, dom->def->graphics[i])))
               return -1;
           mig->flags |= QEMU_MIGRATION_COOKIE_GRAPHICS;
           break;
       }
    }

So this is never triggered for VNC, and in fact VNC has no support for
seamless migration anyways so that seems correct. Drop the dead VNC
handling.

9 years agomakefile: Move include/Makefile.am to include/libvirt/Makefile.am
Erik Skultety [Tue, 5 Apr 2016 19:04:06 +0000 (21:04 +0200)]
makefile: Move include/Makefile.am to include/libvirt/Makefile.am

The reason for this is to fix the automatic rebuild of libvirt-common.h.in.
All *.in files should be automatically rebuilt each time they're modified.
It works well for makefiles and pkgconfig files, since they do have a valid
dependency in the top-level Makefile. However, with libvirt-common.h.in
there is no dependency in the top-level Makefile and there's no need for it
either, so this rule

include/libvirt/libvirt-common.h: $(top_builddir)/config.status \
        $(top_srcdir)/include/libvirt/libvirt-common.h.in
    cd $(top_builddir) && $(SHELL) ./config.status $@

is never hit and should be moved to include/Makefile, but that's automake's
job. According to GNU automake docs:

"Files created by AC_CONFIG_FILES, be they
Automake Makefiles or not, are all removed by ‘make distclean’. Their inputs
are automatically distributed, unless they are the output of prior
AC_CONFIG_FILES commands. Finally, rebuild rules are generated in the Automake
Makefile existing in the subdirectory of the output file, if there is one, or
in the top-level Makefile otherwise."

Which means that if we want to have the rule for libvirt-common.h automatically
generated by automake, the include/Makefile.am needs to be moved into libvirt/
subdirectory and $SUBDIRS in the top-level Makefile need to be adjusted as
well. This patch moves Makefile.am from include/ to include/libvirt, adjusting
the prefixes accordingly as well as updates the top-level Makefile $SUBDIRS to
properly hint automake to generate all rules at proper places.

Best way to see the changes, use -M with 'git show'.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
9 years agovz: make it possible to use shared drivers API with vz driver connection
Maxim Nestratov [Thu, 14 Apr 2016 14:52:32 +0000 (17:52 +0300)]
vz: make it possible to use shared drivers API with vz driver connection

Since vz driver is now lives as a part of daemon we can benefit from
this fact and allow vz clients to use shared drivers API like storage,
network, nwfilter etc.

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
9 years agoqemu: support new pci controller model "pcie-expander-bus"
Laine Stump [Wed, 23 Mar 2016 19:49:29 +0000 (15:49 -0400)]
qemu: support new pci controller model "pcie-expander-bus"

This is backed by the qemu device pxb-pcie, which will be available in
qemu 2.6.0.

As with pci-expander-bus (which uses qemu's pxb device), the busNr
attribute and <node> subelement of <target> are used to set the bus_nr
and numa_node options.

During post-parse we validate that the domain's machinetype is
q35-based (since the device shows up for 440fx-based machinetypes, but
is unusable), as well as checking that <node> specifies a node that is
actually configured on the guest.

9 years agoconf: new pci controller model pcie-expander-bus
Laine Stump [Wed, 16 Mar 2016 17:37:14 +0000 (13:37 -0400)]
conf: new pci controller model pcie-expander-bus

This controller provides a single PCIe port on a new root. It is
similar to pci-expander-bus, intended to provide a bus that can be
associated with a guest-identifiable NUMA node, but is for
machinetypes with PCIe rather than PCI (e.g. q35-based machinetypes).

Aside from PCIe vs. PCI, the other main difference is that a
pci-expander-bus has a companion pci-bridge that is automatically
attached along with it, but pcie-expander-bus has only a single port,
and that port will only connect to a pcie-root-port, or to a
pcie-switch-upstream-port. In order for the bus to be of any use in
the guest, it must have either a pcie-root-port or a
pcie-switch-upstream-port attached (and one or more
pcie-switch-downstream-ports attached to the
pcie-switch-upstream-port).

9 years agoqemu: add capabilities bit for device "pxb-pcie"
Laine Stump [Tue, 8 Mar 2016 21:25:22 +0000 (16:25 -0500)]
qemu: add capabilities bit for device "pxb-pcie"

    The pxb device is a PCIe expander bus that can be added to any
    Q35-based machinetype. A single PCIe port (*not* hotpluggable) is
    provided; if more than one device is desired, or if hotplug
    support is needed, either a pcie-root-port, or some combination of
    pcie-switch-upstream-port and pcie-swith-downstream-ports must be
    added to it. It can have a NUMA node number associated with it, as
    well as a bus number.

9 years agoqemu: support new pci controller model "pci-expander-bus"
Laine Stump [Fri, 4 Mar 2016 19:35:20 +0000 (14:35 -0500)]
qemu: support new pci controller model "pci-expander-bus"

This is backed by the qemu device "pxb".

The pxb device always includes a pci-bridge that is at the bus number
of the pxb + 1.

busNr and <node> from the <target> subelement are used to set the
bus_nr and numa_node options for pxb.

During post-parse we validate that the domain's machinetype is
440fx-based (since the pxb device only works on 440fx-based machines),
and <node> also gets a sanity check to assure that the NUMA node
specified for the pxb (if any - it's optional) actually exists on the
guest.

9 years agoconf: new pci controller model pci-expander-bus
Laine Stump [Fri, 4 Mar 2016 15:26:23 +0000 (10:26 -0500)]
conf: new pci controller model pci-expander-bus

This is a standard PCI root bus (not a bridge) that can be added to a
440fx-based domain. Although it uses a PCI slot, this is *not* how it
is connected into the PCI bus hierarchy, but is only used for
control. Each pci-expander-bus provides 32 slots (0-31) that can
accept hotplug of standard PCI devices.

The usefulness of pci-expander-bus relative to a pci-bridge is that
the NUMA node of the bus can be specified with the <node> subelement
of <target>. This gives guest-side visibility to the NUMA node of
attached devices (presuming that management apps only assign a device
to a bus that has a NUMA node number matching the node number of the
device on the host).

Each pci-expander-bus also has a "busNr" attribute. The expander-bus
itself will take the busNr specified, and all buses that are connected
to this bus (including the pci-bridge that is automatically added to
any expander bus of model "pxb" (see the next commit)) will use
busNr+1, busNr+2, etc, and the pci-root (or the expander-bus with next
lower busNr) will use bus numbers lower than busNr.

9 years agoqemu: add capabilities bit for device "pxb"
Laine Stump [Wed, 24 Feb 2016 21:40:49 +0000 (16:40 -0500)]
qemu: add capabilities bit for device "pxb"

The pxb device is a PCI expander bus that can be added to any
440fx-based machinetype. The PCI bus that is created has 32 standard
PCI slots (hotpluggable). It can have a NUMA node number associated
with it, as well as a bus number.

9 years agoqemu: set PCI controller default modelName in a separate function
Laine Stump [Wed, 16 Mar 2016 19:14:03 +0000 (15:14 -0400)]
qemu: set PCI controller default modelName in a separate function

Since every PCI controller model has to have a default model name set,
put it in a separate function to clean up qemuDomainAssignPCIAddresses
a bit.

9 years agoconf: utility function to convert PCI controller model into connect type
Laine Stump [Wed, 16 Mar 2016 18:20:52 +0000 (14:20 -0400)]
conf: utility function to convert PCI controller model into connect type

There are two places in qemu_domain_address.c where we have a switch
statement to convert PCI controller models
(VIR_DOMAIN_CONTROLLER_MODEL_PCI*) into the connection type flag that
is matched when looking for an upstream connection for that model of
controller (VIR_PCI_CONNECT_TYPE_*). This patch makes a utility
function in conf/domain_addr.c to do that, so that when a new PCI
controller is added, we only need to add the new model-->connect-type
in a single place.

9 years agoconf/qemu: change the way VIR_PCI_CONNECT_TYPE_* flags work
Laine Stump [Tue, 15 Mar 2016 19:49:22 +0000 (15:49 -0400)]
conf/qemu: change the way VIR_PCI_CONNECT_TYPE_* flags work

The flags used to determine which devices could be plugged into which
controllers were quite confusing, as they tried to create classes of
connections, then put particular devices into possibly multiple
classes, while sometimes setting multiple flags for the controllers
themselves. The attempt to have a single flag indicate, e.g. that a
root-port or a switch-downstream-port could connect was not only
confusing, it was leading to a situation where it would be impossible
to specify exactly the right combinations for a new controller.

The solution is for the VIR_PCI_CONNECT_TYPE_* flags to have a 1:1
correspondence with each type of PCI controller, plus a flag for a PCI
endpoint device and another for a PCIe endpoint device (the only
exception to this is that pci-bridge and pcie-expander-bus controllers
have their upstream connection classified as
VIR_PCI_CONNECT_TYPE_PCI_DEVICE since they can be plugged into
*exactly* the same ports as any endpoint device).  Each device then
has a single flag for connect type (plus the HOTPLUG flag if that
device can e hotplugged), and each controller sets the CONNECT bits
for all controllers that can be plugged into it, as well as for either
type of endpoint device that can be plugged in (and the HOTPLUG flag
if it can accept hotplugged devices).

With this change, it is *slightly* easier to understand the matching
of connections (as long as you remember that the flag for a
device/upstream-facing connection of a controller is the same as that
device's type, while the flags for a controller's downstream
connections is the OR of all device types that can be plugged into
that controller). More importantly, it will be possible to correctly
specify what can be plugged into a pcie-switch-expander-bus, when
support for it is added.

9 years agoconf: allow use of slot 0 in a dmi-to-pci-bridge
Laine Stump [Wed, 2 Mar 2016 20:29:33 +0000 (15:29 -0500)]
conf: allow use of slot 0 in a dmi-to-pci-bridge

When support for dmi-to-pci-bridge was added, it was assumed that,
just as with the pci-root bus, slot 0 was reserved. This is not the
case - it can be used to connect a device just like any other slot, so
remove the restriction and update the test cases that auto-assign an
address on a dmi-to-pci-bridge.

9 years agoconf: use #define instead of literal for highest slot in upstream port
Laine Stump [Wed, 2 Mar 2016 20:31:02 +0000 (15:31 -0500)]
conf: use #define instead of literal for highest slot in upstream port

Every other maxSlot was either set to 0 or to
VIR_PCI_ADDRESS_SLOT_LAST, but this one was for some reason set to the
literal value 31 (which is the same as VIR_PCI_ADDRESS_SLOT_LAST).
This makes them all consistent.

9 years agoschema: allow pci address attributes to be in decimal
Laine Stump [Tue, 22 Mar 2016 16:24:08 +0000 (12:24 -0400)]
schema: allow pci address attributes to be in decimal

This is especially useful for "bus", since the bus of a device's pci
address is matched to the "index" of a controller to determine which
bus it will be connected to, and "index" is always specified in
decimal - being able to specify both in decimal at least makes it
easier to assure a device is being assigned to the correct bus when it
is added. For the other attributes, it is just a convenience.

(MB: the parser already allows for any of these attributes to be given
in decimal, and there are even examples floating around on the
internet that give them in decimal rather than hex (written in the
days before virsh did schema validation on all XML). This only updates
the schema to match the parser.)

9 years agoschema: new basic type - uint16
Laine Stump [Tue, 22 Mar 2016 16:10:16 +0000 (12:10 -0400)]
schema: new basic type - uint16

This is a number between 0 and 65535 (or 0x0000 - 0xffff if specified
in hexadecimal).

9 years agoschema: rename uint8range/uint24range to uint8/uint24
Laine Stump [Tue, 22 Mar 2016 16:00:40 +0000 (12:00 -0400)]
schema: rename uint8range/uint24range to uint8/uint24

nwfilter.rng defines uint16range and uint32range, but in a different
manner (it also allows a variable name as the value, rather than just
a decimal or hex number). I wanted to add uint16range to
basictypes.rng, but my desired definition was parallel to those for
uint8range and uint24range which are defined in basictypes.rng - they
*don't* allow a variable name for the value.

The simplest path to make everyone happy is to make the "plain"
versions in basictypes.rng have simpler names - "uint8", "uint16", and
"uint24". This patch renames uint8range and uint24range to uint8 and
uint24, while the next patch will add uint16.

9 years agoschema: make pci slot and function optional
Laine Stump [Tue, 22 Mar 2016 15:38:53 +0000 (11:38 -0400)]
schema: make pci slot and function optional

The pcie-switch-downstream-port and pcie-root-port controllers have
only a single slot, numbered 0, and the greate majority of all guest
PCI devices are plugged into function 0 of whatever slot they're
using. The parser makes these optional, setting them to 0 when not
specified, and it's logical for the schema to also make them optional.

9 years agoutil: Add virGettextInitialize, convert the code
Cole Robinson [Tue, 12 Apr 2016 22:29:52 +0000 (18:29 -0400)]
util: Add virGettextInitialize, convert the code

Take setlocale/gettext error handling pattern from tools/virsh-*
and use it for all standalone binaries via a new shared
virGettextInitialize routine. The virsh* pattern differed slightly
from other callers. All users now consistently:

* Ignore setlocale errors. virsh has done this forever, presumably for
  good reason. This has been partially responsible for some bug reports:

  https://bugzilla.redhat.com/show_bug.cgi?id=1312688
  https://bugzilla.redhat.com/show_bug.cgi?id=1026514
  https://bugzilla.redhat.com/show_bug.cgi?id=1016158

* Report the failed function name
* Report strerror

9 years agoman: virsh: Document lxc-enter-namespace --noseclabel
Cole Robinson [Mon, 11 Apr 2016 21:02:25 +0000 (17:02 -0400)]
man: virsh: Document lxc-enter-namespace --noseclabel

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

9 years agodocs: formatdomain: document versions for video acceleration
Cole Robinson [Mon, 11 Apr 2016 20:51:51 +0000 (16:51 -0400)]
docs: formatdomain: document versions for video acceleration

clarify what version initial support was added, and when libvirt
started supporting it for the qemu driver

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

9 years agodocs: domain: document blkiotune {read, write}_{bytes, iops}_sec
Cole Robinson [Wed, 13 Apr 2016 20:37:17 +0000 (16:37 -0400)]
docs: domain: document blkiotune {read, write}_{bytes, iops}_sec

Added with commit 3b431929 in v1.2.2 but never documented

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

9 years agostorage: mpath: Don't error on target_type=NULL
Cole Robinson [Wed, 13 Apr 2016 21:29:59 +0000 (17:29 -0400)]
storage: mpath: Don't error on target_type=NULL

We use device-mapper to enumerate all dm devices, and filter out
the list of multipath devices by checking the target_type string
name. The code however cancels all scanning if we encounter
target_type=NULL

I don't know how to reproduce that situation, but a user was hitting
it in their setup, and inspecting the lvm2/device-mapper code shows
many places where !target_type is explicitly ignored and processing
continues on to the next device. So I think we should do the same

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

9 years agoqemu: command: don't overwrite watchdog dump action
Cole Robinson [Wed, 13 Apr 2016 15:20:19 +0000 (11:20 -0400)]
qemu: command: don't overwrite watchdog dump action

The watchdog cli refactoring in 4666b762 dropped the temporary variable
we use to convert to action=dump to action=pause for the qemu cli, and
stored the converted value in the domain structure. Our other watchdog
handling code then treated it as though the user requested action=pause,
which broke action=dump handling.

Revive the temporary variable to fix things.

9 years agotest: genericxml2xml: test graphics listen= compat
Cole Robinson [Fri, 8 Apr 2016 17:16:12 +0000 (13:16 -0400)]
test: genericxml2xml: test graphics listen= compat

* Add a test for listen=XXX and <listen address=YYY/> collision error
* Add an explicit test for listen=XXX duplicated to <listen address=XXX/>
  We implicitly test it elsewhere but I figure it's better to be explicit,
  and this test case can be extended in the future for additional listen
  back compat if/when we support <listen type='socket'/> syntax

9 years agotests: Enable failure testing with CompareDomXML2XML
Cole Robinson [Fri, 8 Apr 2016 16:04:10 +0000 (12:04 -0400)]
tests: Enable failure testing with CompareDomXML2XML

This allows tests to check for specific failure scenarios

9 years agotests: do not overwrite return value when filling qemuCapsCache
Ján Tomko [Thu, 14 Apr 2016 11:48:57 +0000 (13:48 +0200)]
tests: do not overwrite return value when filling qemuCapsCache

In qemuHotplugCreateObjects, the ret variable was filled by
the value returned by qemuTestCapsCacheInsert.

If any of the functions after this assignment failed, we would still
return success.

Also adjust testCompareXMLToArgvHelper, where this change is just
cosmetic, because the value was overwritten right away.

9 years agovirsh: add compression options for migration
ShaoHe Feng [Thu, 14 Apr 2016 10:33:52 +0000 (13:33 +0300)]
virsh: add compression options for migration

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agoqemu: migration: support setting compession parameters
Nikolay Shirokovskiy [Thu, 14 Apr 2016 10:33:51 +0000 (13:33 +0300)]
qemu: migration: support setting compession parameters

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agoqemumonitorjsontest: add test for getting multithread compress params
Eli Qiao [Thu, 14 Apr 2016 10:33:50 +0000 (13:33 +0300)]
qemumonitorjsontest: add test for getting multithread compress params

Signed-off-by: Eli Qiao <liyong.qiao@intel.com>
Signed-off-by: ShaoHe Feng <shaohe.feng@intel.com>
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agoqemu: monitor: add migration parameters accessors
ShaoHe Feng [Thu, 14 Apr 2016 10:33:49 +0000 (13:33 +0300)]
qemu: monitor: add migration parameters accessors

Signed-off-by: ShaoHe Feng <shaohe.feng@intel.com>
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agomigration: qemu: add option to select compression methods
Nikolay Shirokovskiy [Thu, 14 Apr 2016 10:33:48 +0000 (13:33 +0300)]
migration: qemu: add option to select compression methods

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agovirsh: support up to 64 migration options for command
Nikolay Shirokovskiy [Thu, 31 Mar 2016 12:41:52 +0000 (15:41 +0300)]
virsh: support up to 64 migration options for command

Upcoming compression options for migration command patch
series hits current limit of 32 possible options for a command.
Lets take one step further and support 64 possible options.

And all it takes is moving from 32 bit integers to 64 bit ones.
The only less then trivial change i found is moving from
'ffs' to 'ffsl'.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agoFix various shadowed declarations
Martin Kletzander [Tue, 12 Apr 2016 13:41:28 +0000 (15:41 +0200)]
Fix various shadowed declarations

I tried compiling libvirt with older gcc and probably because I used
different configure options I got some shadowed declarations.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agolibxl: support creating domain with VF assignment from a pool
Chunyan Liu [Thu, 7 Apr 2016 10:09:19 +0000 (18:09 +0800)]
libxl: support creating domain with VF assignment from a pool

Add codes to support creating domain with network defition of assigning
SRIOV VF from a pool.

Signed-off-by: Chunyan Liu <cyliu@suse.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agofix build by correcting functions order and src/Makefile.am
Maxim Nestratov [Wed, 13 Apr 2016 23:05:08 +0000 (02:05 +0300)]
fix build by correcting functions order and src/Makefile.am

commit 30c61901 added new functions to libvirt_private.syms
not alpabetically sorted and erroneously added vz sources to
STATEFUL_DRIVER_SOURCE_FILES, which triggered check-aclrules
running while vz driver isn't ready for it yet.

Pushing under build-breaker rule.

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
9 years agovz: simplify getting strings from vzsdk
Nikolay Shirokovskiy [Wed, 13 Apr 2016 16:05:43 +0000 (19:05 +0300)]
vz: simplify getting strings from vzsdk

SDK does not allocate memory when getting strings thus we
need to call every function that returns string twice.
First to obtain string length, second to obtain string
itself. It is tedious so let's create helper functions
for cases when we know length of the result beforehand
and we are not.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agovz: minor cleanup
Maxim Nestratov [Tue, 29 Mar 2016 07:36:54 +0000 (10:36 +0300)]
vz: minor cleanup

remove unnecessary vzConnectClose prototype and make
local structure vzDomainDefParserConfig be static

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
9 years agovz: remove vzDriverLock/Unlock function
Maxim Nestratov [Thu, 7 Apr 2016 18:53:27 +0000 (21:53 +0300)]
vz: remove vzDriverLock/Unlock function

We don't need them anymore as all pointers within vzDriver structure
are not changed during the time it exists.
Where we still need to synchronize we use virObjectLock/Unlock as far
as vzDriver is lockable object.

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
9 years agovz: implement connectGetSysinfo hypervisor callback
Maxim Nestratov [Thu, 7 Apr 2016 18:52:43 +0000 (21:52 +0300)]
vz: implement connectGetSysinfo hypervisor callback

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
9 years agovz: fix possible vzDomainDefineXMLFlags and prlsdkNewDomainByHandle race
Maxim Nestratov [Tue, 12 Apr 2016 17:30:57 +0000 (20:30 +0300)]
vz: fix possible vzDomainDefineXMLFlags and prlsdkNewDomainByHandle race

Lock driver when a new domain is created in prlsdkNewDomainByHandle
and try to find it in the list under lock again because it can race
with vzDomainDefineXMLFlags when a domain with the same uuid is added
via vz dispatcher directly and libvirt define.

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
9 years agovz: introduce new vzDriver lockable structure and use it
Maxim Nestratov [Mon, 28 Mar 2016 19:11:30 +0000 (22:11 +0300)]
vz: introduce new vzDriver lockable structure and use it

This patch introduces a new 'vzDriver' lockable object and provides
helper functions to allocate/destroy it and we pass it to prlsdkXxx
functions instead of virConnectPtr.
Now we store domain related objects such as domain list, capabitilies
etc. within a single vz_driver vzDriver structure, which is shared by
all driver connections. It is allocated during daemon initialization or
in a lazy manner when a new connection to 'vz' driver is established.
When a connection to vz daemon drops, vzDestroyConnection is called,
which in turn relays disconnect event to all connection to 'vz' driver.

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
9 years agovz: build driver as module and don't register it on client's side
Maxim Nestratov [Mon, 28 Mar 2016 13:03:00 +0000 (16:03 +0300)]
vz: build driver as module and don't register it on client's side

Make it possible to build vz driver as a module and don't link it with
libvirt.so statically.
Remove registering it on client's side as far as we start relying on daemon

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
9 years agobuild: fix build on RHEL-6
Pavel Hrdina [Wed, 13 Apr 2016 15:26:17 +0000 (17:26 +0200)]
build: fix build on RHEL-6

GCC in RHEL-6 complains about listen:

../../src/conf/domain_conf.c:23718: error: declaration of 'listen' shadows a global declaration [-Wshadow]
/usr/include/sys/socket.h:204: error: shadowed declaration is here [-Wshadow]

This renames all the listen to gListen.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agovz: correct iomode check
Mikhail Feoktistov [Tue, 12 Apr 2016 13:57:56 +0000 (09:57 -0400)]
vz: correct iomode check

Virtuozzo hypervisor supports native iomode.
So we should allow to add disk with iomode "native" or "default".

9 years agorpc: daemon: Fix virtlog/virtlock daemon reload
Cole Robinson [Wed, 13 Apr 2016 14:13:12 +0000 (10:13 -0400)]
rpc: daemon: Fix virtlog/virtlock daemon reload

Trying to reload/SIGUSR1 virtlogd or virtlockd fails with:

error : virNetDaemonRun:747 : internal error: Not all servers restored, cannot run server

Commit 252610f7 changed the daemon state json to allow tracking
multiple servers. However it missed clearing dmn->srvObject after
the json is empty, like the previous code paths handled.  Later on in
virNewDaemonRun, dmn->srvObject is expected to be empty otherwise we
throw the above error.

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

9 years agoqemuxml2argvtest: do not mock virCommand
Ján Tomko [Wed, 13 Apr 2016 08:36:00 +0000 (10:36 +0200)]
qemuxml2argvtest: do not mock virCommand

Mock virNetDevRunEthernetScript instead.

This restores the VIR_TEST_REGENERATE_OUTPUT functionality.

9 years agoqemuExecuteEthernetScript: move to util
Ján Tomko [Wed, 13 Apr 2016 08:33:36 +0000 (10:33 +0200)]
qemuExecuteEthernetScript: move to util

This is just a wrapper for virCommand that takes two strings
and runs them.

Move it to virnetdev.c for easier mocking.

9 years agoqemu: process: Wire up ACPI OST events to notify users of failed memory unplug
Peter Krempa [Fri, 1 Apr 2016 15:48:20 +0000 (17:48 +0200)]
qemu: process: Wire up ACPI OST events to notify users of failed memory unplug

Since qemu is now able to notify us that the guest rejected the memory
unplug operation we can relay this to the user and make the API fail
right away.

Additionally document the possible values from the ACPI docs for future
reference.

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

9 years agoqemu: monitor: Add support for ACPI_DEVICE_OST event handling
Peter Krempa [Fri, 1 Apr 2016 14:41:08 +0000 (16:41 +0200)]
qemu: monitor: Add support for ACPI_DEVICE_OST event handling

The event is emitted on ACPI OSPM Status Indication events.

ACPI standard documentation describes the method as:

This object is an optional control method that is invoked by OSPM to
indicate processing status to the platform. During device ejection,
device hot add, or other event processing, OSPM may need to perform
specific handshaking with the platform. OSPM may also need to indicate
to the platform its inability to complete a requested operation; for
example, when a user presses an ejection button for a device that is
currently in use or is otherwise currently incapable of being ejected.
In this case, the processing of the ACPI Eject Request notification by
OSPM fails. OSPM may indicate this failure to the platform through the
invocation of the _OST control method. As a result of the status
notification indicating ejection failure, the platform may take certain
action including reissuing the notification or perhaps turning on an
appropriate indicator light to signal the failure to the user.

9 years agoAdd VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_FAILED event
Peter Krempa [Wed, 30 Mar 2016 16:09:45 +0000 (18:09 +0200)]
Add VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_FAILED event

Since we didn't opt to use one single event for device lifecycle for a
VM we are missing one last event if the device removal failed. This
event will be emitted once we asked to eject the device but for some
reason it is not possible.

9 years agoqemu: hotplug: Add support for signalling device unplug failure
Peter Krempa [Mon, 4 Apr 2016 15:17:43 +0000 (17:17 +0200)]
qemu: hotplug: Add support for signalling device unplug failure

Similarly to the DEVICE_DELETED event we will be able to tell when
unplug of certain device types will be rejected by the guest OS. Wire up
the device deletion signalling code to allow handling this.

9 years agoqemu: Use domain condition for device removal signaling
Peter Krempa [Mon, 4 Apr 2016 11:59:48 +0000 (13:59 +0200)]
qemu: Use domain condition for device removal signaling

No need to keep two separate conditions. A slight juggling of return
values is needed to accomodate virDomainObjWaitUntil.

9 years agoqemu: hotplug: Refactor semantics of qemuDomainWaitForDeviceRemoval
Peter Krempa [Mon, 4 Apr 2016 13:08:40 +0000 (15:08 +0200)]
qemu: hotplug: Refactor semantics of qemuDomainWaitForDeviceRemoval

Neither of the callers cares whether the DEVICE_DELETED event isn't
supported or the event was received. Simplify the code and callers by
unifying the two values and changing the return value constants so that
a temporary variable can be omitted.

9 years agoqemu: hotplug: Properly handle errors in qemuDomainWaitForDeviceRemoval
Peter Krempa [Mon, 4 Apr 2016 13:27:25 +0000 (15:27 +0200)]
qemu: hotplug: Properly handle errors in qemuDomainWaitForDeviceRemoval

Callers ignore if this function returns -1 and continue as though the
DEVICE_DELETED event was not received. Since we can't be sure that the
event was not received we should behave as if the event was not
supported and remove the device definition right away. The error
fortunately won't really happen here.

9 years agoqemu: assign addresses before aliases
Ján Tomko [Wed, 13 Apr 2016 07:38:29 +0000 (09:38 +0200)]
qemu: assign addresses before aliases

The address assigning code might add new pci bridges.
We need them to have an alias when building the command line.

In real word usage, this is not a problem because all the code
paths already call qemuDomainAssignAddresses. However moving
this call lets us remove one extra call from qemuxml2argvtest.

9 years agoqemuxml2argvtest: drop FLAG_EXPECT_ERROR
Ján Tomko [Wed, 13 Apr 2016 06:21:42 +0000 (08:21 +0200)]
qemuxml2argvtest: drop FLAG_EXPECT_ERROR

It is only used for failed address allocation
Since we already have FLAG_EXPECT_FAILURE, use that instead.

Also unify the output to print the whole log buffer instead
of just the last error message.

9 years agotests: clean up includes
Ján Tomko [Wed, 13 Apr 2016 06:12:47 +0000 (08:12 +0200)]
tests: clean up includes

After removing qemuBuildCommandLineCallbacks, testutilsqemu.h does not
need to include qemu_command.h.

Include just qemu_conf.h here and qemu_domain_address.h in files that
need it.

9 years agodrop qemuBuildCommandLineCallbacks
Ján Tomko [Wed, 13 Apr 2016 06:10:24 +0000 (08:10 +0200)]
drop qemuBuildCommandLineCallbacks

Essentially revert commit 3a6204c which added these to allow the test
suite to pass without depending on the host system state.

Since commit 4b527c1 we already mock virSCSIDeviceGetSgName, so these
callbacks are useless.

9 years agodomain_conf: call ...ListensParseXML only for appropriate graphics
Pavel Hrdina [Thu, 7 Apr 2016 11:08:58 +0000 (13:08 +0200)]
domain_conf: call ...ListensParseXML only for appropriate graphics

Instead of calling the virDomainGraphicsListensParseXML function for all
graphics types and ignore the wrong ones move the call only to graphics
types where we supports listen elements.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agodomain_conf: remove unused virDomainGraphicsListenGet*
Pavel Hrdina [Sun, 10 Apr 2016 17:00:01 +0000 (19:00 +0200)]
domain_conf: remove unused virDomainGraphicsListenGet*

Those are the last two places that uses the getter functions.  Use a
direct access instead and remove those getters.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agouse virDomainGraphicsGetListen instead of the other getters
Pavel Hrdina [Wed, 23 Mar 2016 08:27:56 +0000 (09:27 +0100)]
use virDomainGraphicsGetListen instead of the other getters

There is no point the use two different getters on the same listen
structure few lines apart.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agodomain_conf: cleanup virDomainGraphicsGetListen
Pavel Hrdina [Sun, 10 Apr 2016 16:57:12 +0000 (18:57 +0200)]
domain_conf: cleanup virDomainGraphicsGetListen

Removes the check for graphics type, it's not a public API and developer
know what he's doing and this check makes no sense.  It also removes
the ability to allocate a new array if there is none.  This was used by
the virDomainGraphicsListenAdd* functions and isn't used anymore.

This is now a simple getter with simple check for listens array presence
and whether the index in out of bounds.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agodomain_conf: remove unused virDomainGraphicsListenSetType
Pavel Hrdina [Wed, 23 Mar 2016 08:09:16 +0000 (09:09 +0100)]
domain_conf: remove unused virDomainGraphicsListenSetType

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agodomain_conf: remove virDomainGraphicsListenSetNetwork
Pavel Hrdina [Sun, 10 Apr 2016 16:54:40 +0000 (18:54 +0200)]
domain_conf: remove virDomainGraphicsListenSetNetwork

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agodomain_conf: introduce virDomainGraphicsListenAppendAddress
Pavel Hrdina [Wed, 23 Mar 2016 07:55:46 +0000 (08:55 +0100)]
domain_conf: introduce virDomainGraphicsListenAppendAddress

This effectively removes virDomainGraphicsListenSetAddress which was
used only to change the address of listen structure and possible change
the listen type.  The new function will auto-expand the listens array
and append a new listen.

The old function was used on pre-allocated array of listens and in most
cases it only "add" a new listen.  The two remaining uses can access the
listen structure directly.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agoconfigure: Make virt-host-validate optional
Andrea Bolognani [Fri, 8 Apr 2016 15:14:13 +0000 (17:14 +0200)]
configure: Make virt-host-validate optional

virt-host-validate, just like virt-login-shell, doesn't make sense
on Windows, so we should avoid building it.

Make the tool optional and build it by default on all platforms
except Windows, erroring out if the user attempts to build it
anyway.

9 years agotools: Reorganize conditional bits
Andrea Bolognani [Fri, 8 Apr 2016 15:23:10 +0000 (17:23 +0200)]
tools: Reorganize conditional bits

Instead of having separate handling for programs and man pages,
deal with both in the same place.

9 years agoconf: extract disk geometry parsing code
Peter Krempa [Tue, 12 Apr 2016 13:48:40 +0000 (15:48 +0200)]
conf: extract disk geometry parsing code

9 years agoconf: Refactor virDomainDiskDefMirrorParse
Peter Krempa [Tue, 12 Apr 2016 13:39:38 +0000 (15:39 +0200)]
conf: Refactor virDomainDiskDefMirrorParse

Now that the mirror parsing code is not crammed in the main disk parser
we can employ better coding style.

9 years agoconf: disk: Split out parsing of disk mirror data
Peter Krempa [Tue, 12 Apr 2016 13:27:50 +0000 (15:27 +0200)]
conf: disk: Split out parsing of disk mirror data

Changes are indentation and 'cleanup' label instead of 'error'.

9 years agoconf: virDomainDiskDefIotuneParse: Report malformed number errors
Peter Krempa [Tue, 12 Apr 2016 13:03:19 +0000 (15:03 +0200)]
conf: virDomainDiskDefIotuneParse: Report malformed number errors

Rest of the fields of the iotune data structure did not check for
malformed integers. Use the previously defined macro to extract them
which will simplify the code and add error reporting.

9 years agoconf: virDomainDiskDefIotuneParse: simplify parsing
Peter Krempa [Tue, 12 Apr 2016 12:49:47 +0000 (14:49 +0200)]
conf: virDomainDiskDefIotuneParse: simplify parsing

Since the structure was pre-initialized to 0 we don't need to set every
single member to 0 if it's not present in the XML. Additionally if we
put the name of the field into the error message the code can be
simplified using a macro to parse the members.

9 years agoconf: disk: Remove error label from virDomainDiskDefIotuneParse
Peter Krempa [Tue, 12 Apr 2016 12:25:44 +0000 (14:25 +0200)]
conf: disk: Remove error label from virDomainDiskDefIotuneParse

Since this function isn't doing any cleanup, the label is not necessary.