]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
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.

9 years agoconf: disk: Extract iotune parsing into a separate func
Peter Krempa [Tue, 12 Apr 2016 12:22:34 +0000 (14:22 +0200)]
conf: disk: Extract iotune parsing into a separate func

9 years agoconf: disk: Remove one unnecessary level of indentation
Peter Krempa [Mon, 11 Apr 2016 14:13:33 +0000 (16:13 +0200)]
conf: disk: Remove one unnecessary level of indentation

Also simplify the code by switching to a for loop.

9 years agoconf: disk: Don't initialize fields allocated by calloc
Peter Krempa [Mon, 11 Apr 2016 14:06:07 +0000 (16:06 +0200)]
conf: disk: Don't initialize fields allocated by calloc

All the fields were initialized to 0.

9 years agoutil: Rename and move virStrIsPrint to virStringIsPrintable
Peter Krempa [Mon, 11 Apr 2016 11:35:25 +0000 (13:35 +0200)]
util: Rename and move virStrIsPrint to virStringIsPrintable

9 years agovz: add Hypervisor prefix to vz and parallels Driver structures
Maxim Nestratov [Wed, 6 Apr 2016 08:06:18 +0000 (11:06 +0300)]
vz: add Hypervisor prefix to vz and parallels Driver structures

9 years agovz: remove drivername field from vzConn structure
Maxim Nestratov [Tue, 29 Mar 2016 08:21:17 +0000 (11:21 +0300)]
vz: remove drivername field from vzConn structure

No need to remember connection name and have corresponding
domain type to keep backward compatibility with former
'parallels' driver. It is enough to be able to accept 'parallels'
uri and domain types.

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
9 years agovz: change the order of capabilities reported
Maxim Nestratov [Mon, 28 Mar 2016 18:08:49 +0000 (21:08 +0300)]
vz: change the order of capabilities reported

'vz' goes first now to make clients like virt-manager choose 'vz'
instead of 'parallels'

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
9 years agovirsh: report when vz driver is compiled
Maxim Nestratov [Mon, 28 Mar 2016 13:20:40 +0000 (16:20 +0300)]
virsh: report when vz driver is compiled

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
9 years agotests: fix xen-related tests
Ján Tomko [Tue, 12 Apr 2016 12:58:43 +0000 (14:58 +0200)]
tests: fix xen-related tests

My commit 6879be4 moved the addition of the implicit video device
from the XML parser to the PostParse function, but did not regenerate
all the tests.

9 years agovz: fix memory leak
Nikolay Shirokovskiy [Wed, 6 Apr 2016 11:42:14 +0000 (14:42 +0300)]
vz: fix memory leak

we don't need to allocate macstr at all as it is an array
and already has the the space it needs.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agoconf: use VIR_APPEND_ELEMENT in virDomainDefAddImplicitVideo
Ján Tomko [Mon, 11 Apr 2016 13:28:29 +0000 (15:28 +0200)]
conf: use VIR_APPEND_ELEMENT in virDomainDefAddImplicitVideo

9 years agoconf: reduce indentation in virDomainDefAddImplicitVideo
Ján Tomko [Mon, 11 Apr 2016 13:26:06 +0000 (15:26 +0200)]
conf: reduce indentation in virDomainDefAddImplicitVideo

Return early if there is nothing to do.

9 years agoconf: delete useless primaryVideo variable
Ján Tomko [Mon, 11 Apr 2016 13:20:41 +0000 (15:20 +0200)]
conf: delete useless primaryVideo variable

If we encounter a video device with primary=yes, we insert it
at def->videos[0].

There is no need to record this in a separate variable,
just check if there already is a primary video at def->videos[0].

9 years agoconf: use insertAt instead of j
Ján Tomko [Mon, 11 Apr 2016 12:45:46 +0000 (14:45 +0200)]
conf: use insertAt instead of j

We call VIR_INSERT_ELEMENT_INPLACE either with 0 (for primary video)
or def->nvideos (for the rest).

Use a variable with more semantic name, since j is usually used
for iterating.

9 years agoconf: use the iterator directly when parsing video devices
Ján Tomko [Mon, 11 Apr 2016 12:43:43 +0000 (14:43 +0200)]
conf: use the iterator directly when parsing video devices

We start with both i and def->nvideos at 0 and increment both
after every successful iteration.

Use i directly, instead of passing the def->nvideos value through j.

9 years agoconf: also mark the implicit video as primary
Ján Tomko [Mon, 11 Apr 2016 12:26:06 +0000 (14:26 +0200)]
conf: also mark the implicit video as primary

Commit 119cd06 started setting the primary bool for the first
user-specified video even if user omitted the 'primary' attribute.

However this was done before the addition of the implicit device.
This broke startup of transient qemu domains with no <video>:
https://bugzilla.redhat.com/show_bug.cgi?id=1325757

Move this default to virDomainDefPostParseInternal,
after the addition of the implicit video device, to catch the implicit
video as well.

9 years agoconf: move default video addition after XML parsing
Ján Tomko [Mon, 11 Apr 2016 12:06:03 +0000 (14:06 +0200)]
conf: move default video addition after XML parsing

Separate parsing of the XML from auto-generating the device.

9 years agocfg.mk: Use single quotes wherever possible
Andrea Bolognani [Mon, 11 Apr 2016 14:45:53 +0000 (16:45 +0200)]
cfg.mk: Use single quotes wherever possible

Being consistent is nice, especially when it comes to defining our
regular expression, where using single quotes instead of double
quotes allows us to leave out a few backslashes.

Changing this required altering a few error messages.

The only remaining use of double quotes is one where they are
actually required for the check to work.

9 years agocfg.mk: Remove spurious whitespace
Andrea Bolognani [Mon, 11 Apr 2016 14:38:18 +0000 (16:38 +0200)]
cfg.mk: Remove spurious whitespace

9 years agoutil: Fix 'exempt from syntax-check' comment
Andrea Bolognani [Mon, 11 Apr 2016 14:21:59 +0000 (16:21 +0200)]
util: Fix 'exempt from syntax-check' comment

9 years agovz: implement memory setting functions
Nikolay Shirokovskiy [Fri, 8 Apr 2016 09:36:45 +0000 (12:36 +0300)]
vz: implement memory setting functions

Quite straigthforward as vz sdk memory setting function makes
just what we want to that is set "amount of physical memory
allocated to a domain".

'useflags' is introduced for non flag function implementation.
We can't just use combination of flags like "live | config" or
we fail for inactive domains. Other combinations have drawbacks
too.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agovz: factor out config update flags checks
Nikolay Shirokovskiy [Fri, 8 Apr 2016 09:36:44 +0000 (12:36 +0300)]
vz: factor out config update flags checks

Actually this is not pure refactoring. Part of common code is
replaced with virDomainObjUpdateModificationImpact and this
a good replacement. It includes removed check of inactive
domain and active flags set. Additionally we resolve
current flag in accordance with current state of domain.
Thus it becames possible to attach/detach devices for
inactive domains if this flag is set.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agodomain_conf: fix graphics parsing
Pavel Hrdina [Mon, 11 Apr 2016 11:05:42 +0000 (13:05 +0200)]
domain_conf: fix graphics parsing

Commit dc98a5bc refactored the code a lot and forget about checking if
listen attribute is specified.  This ensures that listen attribute and
first listen element are compared only if both exist.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agovirtlogd: Fix a couple minor memory leaks
Cole Robinson [Sun, 10 Apr 2016 23:19:25 +0000 (19:19 -0400)]
virtlogd: Fix a couple minor memory leaks

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

9 years agobuild: add GCC 6.0 -Wlogical-op workaround
Pavel Hrdina [Sun, 10 Apr 2016 16:22:20 +0000 (18:22 +0200)]
build: add GCC 6.0 -Wlogical-op workaround

fdstream.c: In function 'virFDStreamWrite':
fdstream.c:390:29: error: logical 'or' of equal expressions [-Werror=logical-op]
        if (errno == EAGAIN || errno == EWOULDBLOCK) {
                            ^~

Fedora rawhide now uses gcc 6.0 and there is a bug with -Wlogical-op
producing false warnings.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69602

Use GCC pragma push/pop and ignore -Wlogical-op for GCC that supports
push/pop pragma and also has this bug.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agobuild: cleanup GCC < 4.6 -Wlogical-op workaround
Pavel Hrdina [Sun, 10 Apr 2016 16:21:13 +0000 (18:21 +0200)]
build: cleanup GCC < 4.6 -Wlogical-op workaround

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agoqemu: Free priv->machineName
Martin Kletzander [Fri, 8 Apr 2016 13:29:40 +0000 (15:29 +0200)]
qemu: Free priv->machineName

Commit c3bd0019c0e3 forgot to cleanup after itself.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoqemu: agent: Fix incorrect and weird debug/warning log entries
Peter Krempa [Fri, 8 Apr 2016 08:08:37 +0000 (10:08 +0200)]
qemu: agent: Fix incorrect and weird debug/warning log entries

Replace the nonsensical debug statement by adding the expected event
code into the existing debug statement.

Since the monitor code always notifies the agent on guest
reboot/shutdown even if that was not initiated by the agent the warning
emitted later is bogus and pollutes the logs in such cases. Delete it
and keep just the original debug message where this info can be
inferred.

9 years agohost-validate: Be more careful when checking for cgroup support
Andrea Bolognani [Fri, 8 Apr 2016 12:13:10 +0000 (14:13 +0200)]
host-validate: Be more careful when checking for cgroup support

Simply checking whether the cgroup name appears somewhere inside
/proc/self/cgroup is enough most of the time, but there are some
corner cases that require a more mindful parsing.

9 years agoconfigure: Fix check for --with-login-shell on Windows
Andrea Bolognani [Fri, 8 Apr 2016 14:17:16 +0000 (16:17 +0200)]
configure: Fix check for --with-login-shell on Windows

The check is supposed to stop users from trying to compile
virt-login-shell on Windows by erroring out during the
configure phase; however, there are two flaws in it:

  * the value of "x$with_win" is compared to "yes" instead
    of "xyes" (note the "x" in the first string)

  * "test" is not being used, so the script will actually
    try to run a command called "x$with_win" instead of
    performing string comparison

This patch fixes both issues.

9 years agopo: Really fix po/POTFILES.in ordering
Erik Skultety [Sun, 10 Apr 2016 16:58:53 +0000 (18:58 +0200)]
po: Really fix po/POTFILES.in ordering

Commit e72667bd tried to fix the incorrect file ordering in po/POTFILES.in
except it didn't, since the sort was run using locale en_US instead of
using locale C which is the default in libvirt. So this patch hopefully fixes
it for good.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
9 years agopo: fix POTFILES.in file ordering
Erik Skultety [Sat, 9 Apr 2016 18:02:49 +0000 (20:02 +0200)]
po: fix POTFILES.in file ordering

When it comes to a situation that a new translatable file needs to be added
into the list of files, an automatically generated patch is proposed during
syntax-check. However, the diff was made against a sorted list of files and
the same sorted list of files + the new file that actually needs to be added
into the list. Since we do not keep POTFILES sorted, the proposed patch thus
can't be applied...most of the time - depending on the context.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
9 years agoqemu: fix build without gnutls installed
Roman Bogorodskiy [Sat, 9 Apr 2016 19:04:40 +0000 (22:04 +0300)]
qemu: fix build without gnutls installed

Move including of gnutls/gnutls.h in qemu/qemu_domain.c under the
"ifdef WITH_GNUTLS" check because otherwise it fails like this:

  CC       qemu/libvirt_driver_qemu_impl_la-qemu_domain.lo
qemu/qemu_domain.c:50:10: fatal error: 'gnutls/gnutls.h' file not found

in case if gnutls is not installed on the system.