]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
8 years agonetwork: restart dnsmasq after adding/removing txt and srv records
Laine Stump [Tue, 31 May 2016 15:51:29 +0000 (11:51 -0400)]
network: restart dnsmasq after adding/removing txt and srv records

Although dns host records are stored in a separate configuration file
that is reread by dnsmasq when it receives a SIGHUP, the txt and srv
records are directly in the dnsmasq .conf file which can't be reread
after initial dnsmasq startup. This means that if an srv or txt record
is modified in a network config, libvirt needs to restart the dnsmasq
process rather than just sending a SIGHUP.

This was pointed out in a question in
https://bugzilla.redhat.com/show_bug.cgi?id=988718 , but no separate
BZ was filed.

8 years agoQXL: fix reloading of vram64 attribute
Pavel Hrdina [Wed, 13 Apr 2016 08:13:16 +0000 (10:13 +0200)]
QXL: fix reloading of vram64 attribute

Commit b4a5fd95 introduced vram64 attribute for QXL video device but
there were two issues.  Only function
qemuMonitorJSONUpdateVideoVram64Size should update the vram64 attribute
and also the value is in MiB, not in B.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoesxStorageVolGetXMLDesc: Lookup SCSI lun properly
Michal Privoznik [Tue, 31 May 2016 10:12:13 +0000 (12:12 +0200)]
esxStorageVolGetXMLDesc: Lookup SCSI lun properly

So the idea is as follows: firstly we obtain a list of all the
luns, then iterate over it trying to find the one we want to work
with and after all the iterations we detect whether we have found
something. Now, the last check is broken, because it compares a
value form previous iteration, not the one we've just been
through.

Then, when computing md5 sum of lun's UUID, we use wrong variable
again. Well, @hostScsiDisk which is type of esxVI_HostScsiDisk
extends esxVI_ScsiLun type so they both have the uuid member, but
it just doesn't feel right to access the data via two different
variables in one function call.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemuMonitorTextGetAllBlockStatsInfo: Fix line validation
Michal Privoznik [Tue, 31 May 2016 10:23:24 +0000 (12:23 +0200)]
qemuMonitorTextGetAllBlockStatsInfo: Fix line validation

There's a bug in the function. We expect the following format for
the data we are parsing here:

  key: value

So we use strchr() to find ':' and then see if it is followed by
space. But the check that does just that is slightly incorrect.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agovirSocketAddrIsPrivate: Work on 32bits platforms
Michal Privoznik [Mon, 30 May 2016 13:45:19 +0000 (15:45 +0200)]
virSocketAddrIsPrivate: Work on 32bits platforms

Yet another one of those where signed int (or long int) is not
enough. And useless to as we're aiming at unsigned anyway.

../../src/util/virsocketaddr.c: In function 'virSocketAddrIsPrivate':
../../src/util/virsocketaddr.c:289:45: error: result of '192l << 24' requires 33 bits to represent, but 'long int' only has 32 bits [-Werror=shift-overflow=]
        return ((val & 0xFFFF0000) == ((192L << 24) + (168 << 16)) ||
                                             ^~
../../src/util/virsocketaddr.c:290:45: error: result of '172l << 24' requires 33 bits to represent, but 'long int' only has 32 bits [-Werror=shift-overflow=]
                (val & 0xFFF00000) == ((172L << 24) + (16  << 16)) ||
                                             ^~
cc1: all warnings being treated as errors

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoapibuild: Substitute only pure number tokens
Michal Privoznik [Mon, 30 May 2016 13:38:07 +0000 (15:38 +0200)]
apibuild: Substitute only pure number tokens

In 38df47c9af1 I've tried to prepare our apibuild.py script for
change made in 0628f3498ce (1U << 31). What I've done in the
former commit was to replace \d+U in parsed tokens with \d.
Problem was, my regular expression there was not quite right as
it also translated VIR_123U_VAL into VIR_123_VAL.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agobuild: use gnulib's unsetenv
Michal Privoznik [Sat, 28 May 2016 21:13:26 +0000 (23:13 +0200)]
build: use gnulib's unsetenv

Now that gnulib has lifted it's licensing of unsetenv, we should
use it. Just like we use its counterpart - setenv, already.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoTurn 1<<31 into 1U<<31
Michal Privoznik [Sat, 28 May 2016 11:38:46 +0000 (13:38 +0200)]
Turn 1<<31 into 1U<<31

Apparently, 1 << 31 is signed which in turn does not fit into
a signed integer variable:

../../include/libvirt/libvirt-domain.h:1881:57: error: result of '1 << 31' requires 33 bits to represent, but 'int' only has 32 bits [-Werror=shift-overflow=]
     VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS = 1 << 31, /* enforce requested stats */
                                                         ^~
cc1: all warnings being treated as errors

The solution is to make it an unsigned value. I've found only two
such occurrences in our code base.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agodocs: Teach apibuild to deal with (1U << 31) too
Michal Privoznik [Sat, 28 May 2016 11:21:43 +0000 (13:21 +0200)]
docs: Teach apibuild to deal with (1U << 31) too

The apibuild script is a terrifying beast that parses some source
files of ours and produces an XML representation of them. When it
comes to parsing enums we have in some header files, it tries to
be clever and detect a value that an enum member has (or if it is
an alias for a different member). Whilst doing that it has to
deal with values we give to the members in many formats. At some
places we just pass the value in decimal:

    VIR_DOMAIN_BLOCK_JOB_TYPE_PULL = 1,

in other places, we use the aliasing:

    VIR_CONNECT_GET_ALL_DOMAINS_STATS_ACTIVE = VIR_CONNECT_LIST_DOMAINS_ACTIVE,

and in other places bitwise shifts are used:

    VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS = 1 << 31, /* enforce requested stats */

The script tries to parse all of these resulting in the following
tokens: "1", "VIR_CONNECT_LIST_DOMAINS_ACTIVE", "1<<31"; Then, the
script tries to turn these into integers using python's eval()
function. This function succeeds on the first and the last
tokens. But, if we were to modify the last example so that it's
of the following form:

    VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS = 1U << 31, /* enforce requested stats */

the token representing enum's member value will then be "1U<<31".
So our parsing is good. Unfortunately, python is not aware of the
difference between signed and unsigned C types, therefore eval()
fails over this token and the parser falls back thinking it's an
alias to another enum member. Well it's not.

The solution is to transform [0-9]U into [0-9] as for our
purposes here it's the same thing.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agomaint: update to latest gnulib
Eric Blake [Mon, 4 Jan 2016 20:45:51 +0000 (13:45 -0700)]
maint: update to latest gnulib

Fix a regression in checking for realpath (which caused link
failures regarding duplicate rpl_canonicalize_file_name), and
fix the mingw build regarding unsetenv.

* .gnulib: Update to latest.

Signed-off-by: Eric Blake <eblake@redhat.com>
8 years agospec: Advertise nvram paths of official fedora edk2 builds
Cole Robinson [Fri, 20 May 2016 19:50:16 +0000 (15:50 -0400)]
spec: Advertise nvram paths of official fedora edk2 builds

Fedora now ships edk2 firmware in its official repos, so adapt
the nvram path list to match. Eventually we can remove the nightly
links as well once some integration kinks have been worked out,
and documentation updated.

Move the macro building into the %build target, which lets us
build up a shell variable and make things a bit more readable

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

8 years agolxc: Fix virLXCDomainObjBeginJob position in lxcDomainSetMemoryParameters
Katerina Koukiou [Fri, 27 May 2016 09:23:20 +0000 (12:23 +0300)]
lxc: Fix virLXCDomainObjBeginJob position in lxcDomainSetMemoryParameters

Adjust the code to perform the virLXCDomainObjBeginJob first
and then the call virDomainLiveConfigHelperMethod.
As Ján Tomko pointed out, in virDomainLiveConfigHelperMethod,
there is a check to see if the domain is active when AFFECT_LIVE is set.
Since virLXCDomainObjBeginJob unlocks the virDomainObjPtr lock,
the domain could possibly be destroyed while we wait for the job
and the check results would no longer be valid.

Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com>
8 years agomaint: update to latest gnulib
Eric Blake [Mon, 4 Jan 2016 20:45:51 +0000 (13:45 -0700)]
maint: update to latest gnulib

Pulls in several portability fixes, including the fact that gnulib
now only works on platforms with two's complement signed integers.
Also makes for a smaller delta on the next update (we are waiting
on a license change to unsetenv for the sake of mingw).

* .gnulib: Update to latest.
* bootstrap: Resync from upstream.
* tests/virstringtest.c: Drop use of obsolete probes of integer
properties.

Signed-off-by: Eric Blake <eblake@redhat.com>
8 years agoesx: do not store escaped password in esxVI_Context.
Dawid Zamirski [Thu, 26 May 2016 15:30:11 +0000 (11:30 -0400)]
esx: do not store escaped password in esxVI_Context.

This patch fixes an issue where screenshot API call was failing when
the esx/vcenter password contains special characters such as
apostrophee. The reason for failures was that passwords were escaped
for XML and stored in esxVI_Context which was then passed to raw CURL
API calls where the password must be passed in original form to
authenticate successfully. So this patch addresses this by storing
original passwords in the esxVI_Context struct and escape only for
esxVI_Login call.

8 years agoqemu: Fix error message when PCI bridge has index <= bus
Andrea Bolognani [Mon, 23 May 2016 16:00:36 +0000 (18:00 +0200)]
qemu: Fix error message when PCI bridge has index <= bus

Commit ff2126225df0 changed the error message to be more
detailed about the failure at hand; however, while the new
error message claims that "bus must be <= index", the error
message is displayed if "idx <= addr->bus", ie. when bus
is larger than or *equal to* index.

Change the error message to report the correct constraint,
and format it in a way that mirrors the check exactly to
make it clearer to people reading the code. The new error
message reads "index must be larger than bus".

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

8 years agodaemon: cleanup state drivers in order reverse to init order
Nikolay Shirokovskiy [Tue, 17 May 2016 11:44:46 +0000 (14:44 +0300)]
daemon: cleanup state drivers in order reverse to init order

This patch aims to fix observed crash on daemon shutdown. Main thread is in
the process of state drivers cleanup, network driver is cleaned up and
qemu driver is not yet. Meanwhile eof event from qemu process triggers
qemuProcessStop -> networkReleaseActualDevice and crash happens as
network driver is already cleaned up.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agoesx: use newer virtualHW version for 5.1+ hosts
Dawid Zamirski [Mon, 23 May 2016 21:22:55 +0000 (17:22 -0400)]
esx: use newer virtualHW version for 5.1+ hosts

This is because there's a known issue where ESX will refuse to attach
drives bigger than 4TB when virtualHW < 9. Therefore, to avoid that
use the higher virtualHW for hosts that support it.

https://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2054952

8 years agoesx: Add VMCI device for virtualHW >= 7
Dawid Zamirski [Mon, 23 May 2016 21:22:54 +0000 (17:22 -0400)]
esx: Add VMCI device for virtualHW >= 7

This patch fixes an issue where vMotion fails when VMCI device is not
present in the vmx file.

8 years agoesx: add pciBridge devices when SCSI is used
Dawid Zamirski [Mon, 23 May 2016 21:22:53 +0000 (17:22 -0400)]
esx: add pciBridge devices when SCSI is used

When a SCSI controller is present, ESX adds several pciBridge devices
to vmx file. This fixes an error message where it refuses to create VM
due to not enough PCI devices available. This applies only to virtualHW
version >= 7.

8 years agoconf: permit auto-assignment of controller indexes
Laine Stump [Tue, 10 May 2016 17:14:32 +0000 (13:14 -0400)]
conf: permit auto-assignment of controller indexes

Hand-entering indexes for 20 PCI controllers is not as tedious as
manually determining and entering their PCI addresses, but it's still
annoying, and the algorithm for determining the proper index is
incredibly simple (in all cases except one) - just pick the lowest
unused index.

The one exception is USB2 controllers because multiple controllers in
the same group have the same index. For these we look to see if 1) the
most recently added USB controller is also a USB2 controller, and 2)
the group *that* controller belongs to doesn't yet have a controller
of the exact model we're just now adding - if both are true, the new
controller gets the same index, but in all other cases we just assign
the lowest unused index.

With this patch in place and combined with the automatic PCI address
assignment, we can define a PCIe switch with several ports like this:

  <controller type='pci' model='pcie-root-port'/>
  <controller type='pci' model='pcie-switch-upstream-port'/>
  <controller type='pci' model='pcie-switch-downstream-port'/>
  <controller type='pci' model='pcie-switch-downstream-port'/>
  <controller type='pci' model='pcie-switch-downstream-port'/>
  <controller type='pci' model='pcie-switch-downstream-port'/>
  <controller type='pci' model='pcie-switch-downstream-port'/>
  ...

These will each get a unique index, and PCI addresses that connect
them together appropriately with no pesky numbers required.

8 years agoconf: make virDomainControllerFindUnusedIndex() more generally usable
Laine Stump [Sun, 8 May 2016 20:28:40 +0000 (16:28 -0400)]
conf: make virDomainControllerFindUnusedIndex() more generally usable

Make virDomainControllerFindUnusedIndex() a global function so that it
can be used outside domain_conf.c (as well as higher up in
domain_conf.c itself)/ Also make its DomainDef arg a const* so that
functions which only have a const* to the domain can use it.

8 years agoconf/qemu: make IS_USB2_CONTROLLER globally available
Laine Stump [Sun, 8 May 2016 19:56:23 +0000 (15:56 -0400)]
conf/qemu: make IS_USB2_CONTROLLER globally available

IS_USB2_CONTROLLER() is useful in more places aside from just when
assigning PCI addresses in QEMU, and is checking for enum values that
are all defined in conf/domain_conf.h anyway, so define it there
instead.

8 years agolibxl: add .domainInterfaceAddresses
Chunyan Liu [Fri, 13 May 2016 06:21:23 +0000 (14:21 +0800)]
libxl: add .domainInterfaceAddresses

Add .domainInterfaceAddresses so that user can have a way to
get domain interface address by 'virsh domifaddr'. Currently
it only supports '--source lease'.

Signed-off: Chunyan Liu <cyliu@suse.com>

8 years agosecurity: label the slic_table
Ján Tomko [Fri, 13 May 2016 14:16:55 +0000 (16:16 +0200)]
security: label the slic_table

Add support for the slic_table to the security drivers.

8 years agoqemu: format SLIC ACPI table command line
Ján Tomko [Thu, 12 May 2016 11:21:01 +0000 (13:21 +0200)]
qemu: format SLIC ACPI table command line

<os>
  <acpi>
    <table type="slic">/path/to/acpi/table/file</table>
  </acpi>
</os>

will result in:

-acpitable sig=SLIC,file=/path/to/acpi/table/file

This option was introduced by QEMU commit 8a92ea2 in 2009.

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

8 years agoconf: add <acpi><table> to <os>
Ján Tomko [Mon, 18 Apr 2016 15:13:02 +0000 (17:13 +0200)]
conf: add <acpi><table> to <os>

Add a new element to <domain> XML:
<os>
  <acpi>
    <table type="slic">/path/to/acpi/table/file</table>
  </acpi>
</os>

To supply a path to a SLIC (Software Licensing) ACPI
table blob.

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

8 years agoqemucapstest: replace caps-1.6.50 with updated caps-1.7.0
Pavel Hrdina [Tue, 24 May 2016 13:54:54 +0000 (15:54 +0200)]
qemucapstest: replace caps-1.6.50 with updated caps-1.7.0

The qemu-1.6.50 is a beta before the new minor version, let's replace it with
the release qemu-1.7.0.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemu: Remove virDomainLiveConfigHelperMethod from qemuDomainSetSchedulerParametersFlags
Peter Krempa [Wed, 25 May 2016 10:56:11 +0000 (12:56 +0200)]
qemu: Remove virDomainLiveConfigHelperMethod from qemuDomainSetSchedulerParametersFlags

This refactor also makes a distinction between the pointer to the
original definition and copied one to prevent mixups.

8 years agoqemu: Remove virDomainLiveConfigHelperMethod from qemuDomainSetBlockIoTune
Peter Krempa [Wed, 25 May 2016 10:43:08 +0000 (12:43 +0200)]
qemu: Remove virDomainLiveConfigHelperMethod from qemuDomainSetBlockIoTune

8 years agoqemu: Refactor qemuDomainGetSchedulerParametersFlags
Peter Krempa [Wed, 25 May 2016 10:36:54 +0000 (12:36 +0200)]
qemu: Refactor qemuDomainGetSchedulerParametersFlags

Use virDomainCputune struct to store the data rather than exploding the
fields and use macros to fill the typed params.

8 years agoconf: Change virDomainCputune member 'shares' to unsigned long long
Peter Krempa [Wed, 25 May 2016 10:14:00 +0000 (12:14 +0200)]
conf: Change virDomainCputune member 'shares' to unsigned long long

cgroup functions set and get the longer type so use it everywhere

8 years agoqemu: Remove virDomainLiveConfigHelperMethod from qemuDomainGetSchedulerParametersFlags
Peter Krempa [Wed, 25 May 2016 08:38:11 +0000 (10:38 +0200)]
qemu: Remove virDomainLiveConfigHelperMethod from qemuDomainGetSchedulerParametersFlags

8 years agoqemu: Refactor qemuDomainGetBlkioParameters
Peter Krempa [Wed, 25 May 2016 07:50:06 +0000 (09:50 +0200)]
qemu: Refactor qemuDomainGetBlkioParameters

Get rid of lots of duplicated code.

8 years agoqemu: Remove virDomainLiveConfigHelperMethod from qemuDomainGetBlkioParameters
Peter Krempa [Wed, 25 May 2016 07:11:52 +0000 (09:11 +0200)]
qemu: Remove virDomainLiveConfigHelperMethod from qemuDomainGetBlkioParameters

8 years agoqemu: Remove virDomainLiveConfigHelperMethod from qemuDomainSetMemoryParameters
Peter Krempa [Wed, 25 May 2016 06:28:39 +0000 (08:28 +0200)]
qemu: Remove virDomainLiveConfigHelperMethod from qemuDomainSetMemoryParameters

8 years agoqemu: Refactor typed params assignment in qemuDomainGetBlockIoTune
Peter Krempa [Fri, 20 May 2016 08:42:41 +0000 (10:42 +0200)]
qemu: Refactor typed params assignment in qemuDomainGetBlockIoTune

Introduce a macro to assign the parameters to avoid the for loop and
shuffle around various checks for a simpler and saner function.

8 years agoqemu: Replace virDomainLiveConfigHelperMethod in qemuDomainGetBlockIoTune
Peter Krempa [Fri, 20 May 2016 06:59:18 +0000 (08:59 +0200)]
qemu: Replace virDomainLiveConfigHelperMethod in qemuDomainGetBlockIoTune

Use virDomainObjGetDefs since the API guarantees that both live and
config are never set together.

8 years agoqemu: monitor: Remove 'supportMaxOptions' argument from qemuMonitorGetBlockIoThrottle
Peter Krempa [Fri, 20 May 2016 06:30:45 +0000 (08:30 +0200)]
qemu: monitor: Remove 'supportMaxOptions' argument from qemuMonitorGetBlockIoThrottle

The caller is already aware that the params are missing and the
extractor is ignoring the missing ones so the parameter isn't necessary.

8 years agoesx: use lsilogic adapter type in vol create.
Dawid Zamirski [Mon, 23 May 2016 21:31:57 +0000 (17:31 -0400)]
esx: use lsilogic adapter type in vol create.

ESX will refuse to attach VMDKS that have buslogic adatper type to 64bit
VMs whereas lsilogic works fine both 32bit and 64bit VMs.

8 years agolibxl: default to qemu driver for network disks
Jim Fehlig [Mon, 23 May 2016 21:56:01 +0000 (15:56 -0600)]
libxl: default to qemu driver for network disks

Xen only supports network-based disks with the qemu (aka qdisk) driver.
Set the driverName to 'qemu' in libxlDomainDeviceDefPostParse() if
not already set. When starting a domain with network-based disks,
ensure the driverName is 'qemu'.

Resolves: https://bugzilla.opensuse.org/show_bug.cgi?id=981094

8 years agoqemu: driver: Allow disk update of startupPolicy/snapshot for all disks
Peter Krempa [Mon, 23 May 2016 14:08:19 +0000 (16:08 +0200)]
qemu: driver: Allow disk update of startupPolicy/snapshot for all disks

The libvirt internal bits can be changed for disks that don't otherwise
support changing media. Remove the switch statement and allow changes of
non-source data for all disks.

8 years agoqemu: driver: Move around code to avoid need to rollback
Peter Krempa [Mon, 23 May 2016 13:54:11 +0000 (15:54 +0200)]
qemu: driver: Move around code to avoid need to rollback

qemuDomainChangeDiskLive rolled back few changes to the disk definition
if changing of the media failed. This can be avoided by moving some code
around.

8 years agoCall qemuDomainObjEndJob when qemuCaps is null during hotplug
Shivaprasad G Bhat [Wed, 25 May 2016 09:18:57 +0000 (04:18 -0500)]
Call qemuDomainObjEndJob when qemuCaps is null during hotplug

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
8 years agoUnref the cfg in qemuDomainAttachHostPCIDevice()
Shivaprasad G Bhat [Wed, 25 May 2016 08:47:12 +0000 (03:47 -0500)]
Unref the cfg in qemuDomainAttachHostPCIDevice()

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
8 years agolxc: Fix lxcDomainDestroyFlags endjob processing
John Ferlan [Fri, 20 May 2016 12:42:29 +0000 (08:42 -0400)]
lxc: Fix lxcDomainDestroyFlags endjob processing

Commit id '15ccb0dbf' added job functions for the lxc driver; however,
for shutdown and nonpersistent path, the vm was removed from the domain
object list and the vm pointer cleared before the endjob.

Adjust the code to perform the endjob first and then perform the
ObjListRemove as long as the vm wasn't NULL. This follows more closely
models from qemu and libxl

Found by Coverity (FORWARD_NULL)

8 years agoqemu: Remove unused persistentAddrs
John Ferlan [Tue, 24 May 2016 22:40:22 +0000 (18:40 -0400)]
qemu: Remove unused persistentAddrs

Based on some digital archaeology performed by jtomko, it's been determined
that the persistentAddrs variable is no longer necessary...

The variable was added by:
commit 141dea6bc7222107c2357acb68066baea5b26df3
CommitDate: 2010-02-12 17:25:52 +0000
    Add persistence of PCI addresses to QEMU

Where it was set to 0 on domain startup if qemu did not support the
QEMUD_CMD_FLAG_DEVICE capability, to clear the addresses at shutdown,
because QEMU might make up different ones next time.

As of commit f5dd58a6088cfc6e8bd354b693d399807a8ec395
CommitDate: 2012-07-11 11:19:05 +0200
    qemu: Extended qemuDomainAssignAddresses to be callable from
    everywhere.

this was broken, when the persistentAddrs = 0 assignment was moved
inside qemuDomainAssignPCIAddresses and while it pretends to check
for !QEMU_CAPS_DEVICE, its parent qemuDomainAssignAddresses is only
called if QEMU_CAPS_DEVICE is present.

8 years agoqemu: Remove dead code
John Ferlan [Fri, 20 May 2016 11:41:09 +0000 (07:41 -0400)]
qemu: Remove dead code

Since commit id '20a0fa8e' removed the QEMU_CAPS_DEVICE, Coverity notes
that it's no longer possible to have 'addrs' be NULL when checking for
a live domain since qemuDomainPCIAddressSetCreate would have jumped to
cleanup if addrs was NULL.

8 years agoconf: nodedev: Set PCI_PHYSICAL_FUNCTION flag more carefully
Andrea Bolognani [Mon, 23 May 2016 09:54:44 +0000 (11:54 +0200)]
conf: nodedev: Set PCI_PHYSICAL_FUNCTION flag more carefully

Instead of setting the flag before parsing the PCI address, set
it afterwards. This ensure we can never end up in a situation
where the flag has been set but pci_dev.physical_function has
not been filled in.

8 years agopci: Fix virPCIGetPhysicalFunction()'s callers
Andrea Bolognani [Wed, 25 May 2016 08:01:58 +0000 (10:01 +0200)]
pci: Fix virPCIGetPhysicalFunction()'s callers

Commit c8b1a83605e4 changed the function, making it
impossible for callers to be able to tell whether a
non-negative return value means "physical function
address found and parsed correctly" or "couldn't find
corresponding physical function".

The important difference between the two being that,
in the latter case, the returned pointer is NULL and
should never, ever be dereferenced.

In order to cope with these changes, the callers
have to be updated.

8 years agopci: Document virPCIGetPhysicalFunction()
Andrea Bolognani [Wed, 25 May 2016 08:27:29 +0000 (10:27 +0200)]
pci: Document virPCIGetPhysicalFunction()

8 years agopci: Initialize return location in virPCIGetPhysicalFunction()
Andrea Bolognani [Wed, 25 May 2016 08:27:12 +0000 (10:27 +0200)]
pci: Initialize return location in virPCIGetPhysicalFunction()

Just an extra precaution in case the function returns early
due to an OOM error.

8 years agoqemu: hotplug: wait for the tray to eject only for drives with a tray
Peter Krempa [Thu, 19 May 2016 13:30:12 +0000 (15:30 +0200)]
qemu: hotplug: wait for the tray to eject only for drives with a tray

Use the detected tray presence flag to trigger the tray waiting code
only if the given storage device in qemu reports to have a tray.

This is necessary as the floppy device lost it's tray as of qemu commit:

commit abb3e55b5b718d6392441f56ba0729a62105ac56
Author: Max Reitz <mreitz@redhat.com>
Date:   Fri Jan 29 20:49:12 2016 +0100

    Revert "hw/block/fdc: Implement tray status"

8 years agoqemu: hotplug: Fix error reported when cdrom tray is locked
Peter Krempa [Mon, 23 May 2016 14:32:06 +0000 (16:32 +0200)]
qemu: hotplug: Fix error reported when cdrom tray is locked

Commit 1fad65d49aae364576bd91352a001249510f8d4e used a really big hammer
and overwrote the error message that might be reported by qemu if the
tray is locked. Fix it by reporting the error only if no error is
currently set.

Error after commit mentioned above:
error: internal error: timed out waiting for disk tray status update

New error:
error: internal error: unable to execute QEMU command 'eject': Tray of
device 'drive-ide0-0-0' is not open

8 years agoqemu: hotplug: Extract code for waiting for tray eject
Peter Krempa [Mon, 23 May 2016 12:50:17 +0000 (14:50 +0200)]
qemu: hotplug: Extract code for waiting for tray eject

The code grew rather convoluted. Extract it to a separate function.

8 years agoqemu: process: Fix and improve disk data extraction
Peter Krempa [Thu, 19 May 2016 13:29:02 +0000 (15:29 +0200)]
qemu: process: Fix and improve disk data extraction

Extract information for all disks and update tray state and source only
for removable drives. Additionally store whether a drive is removable
and whether it has a tray.

8 years agoqemu: Move and rename qemuDomainCheckEjectableMedia to qemuProcessRefreshDisks
Peter Krempa [Mon, 23 May 2016 12:00:35 +0000 (14:00 +0200)]
qemu: Move and rename qemuDomainCheckEjectableMedia to qemuProcessRefreshDisks

Move it to a more sane place since it's refreshing data about disks.

8 years agoqemu: Extract more information about qemu drives
Peter Krempa [Thu, 19 May 2016 12:57:41 +0000 (14:57 +0200)]
qemu: Extract more information about qemu drives

Extract whether a given drive has a tray and whether there is no image
inserted.

Negative logic for the image insertion is chosen so that the flag is set
only if we are certain of the fact.

8 years agoqemu: Move struct qemuDomainDiskInfo to qemu_domain.h
Peter Krempa [Fri, 20 May 2016 05:21:04 +0000 (07:21 +0200)]
qemu: Move struct qemuDomainDiskInfo to qemu_domain.h

8 years agoxenconfig: xm: check for driver on disk format
Joao Martins [Tue, 24 May 2016 10:56:08 +0000 (11:56 +0100)]
xenconfig: xm: check for driver on disk format

When reviewing libxl vif typename series[0] I found a bug
on xen-xm formatter where "virsh domxml-to-native xen-xm file.xml"
can lead to a NULL dereference if the disk driver isn't specified.
Fix this by checking for driver before writing/testing it down.

[0] https://www.redhat.com/archives/libvir-list/2016-April/msg01434.html

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
8 years agolxc: support <interface type='ethernet'>
Laine Stump [Fri, 13 May 2016 17:20:54 +0000 (13:20 -0400)]
lxc: support <interface type='ethernet'>

This is identical to type='bridge', but without the "connect to a
bridge" part, so it can be handled by using the same functions (and
often even the same cases in switch statements), after renaming
virLXCProcessSetupInterfaceBridged() to virLXCProcessInterfaceTap()
and enhancing it to skip bridge-related items when brname == NULL.

To be truly useful, we need to support setting the ip address on the
host side veth as well as guest side veth (already supported for
type='bridge'), as well as setting the peer address for both.

The <script> element (supported by type='ethernet' in qemu) isn't
supported in this patch. An error is logged at domain start time if it
is encountered. This may be changed in a later patch.

8 years agolxc: completely rework reference counting
Katerina Koukiou [Fri, 20 May 2016 15:17:01 +0000 (18:17 +0300)]
lxc: completely rework reference counting

This patch follows the pattern used in qemu driver regarding
reference counting.
It changes lxcDomObjFromDomain() to ref the domain (using
virDomainObjListFindByUUIDRef()) and adds virDomainObjEndAPI() which
should be the only function in which the return value of
virObjectUnref() is checked.  This makes all reference counting
deterministic and makes the code a bit clearer.

Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com>
8 years agolxc: use job functions in lxcDomainLxcOpenNamespace & lxcDomainSendProcessSignal
Katerina Koukiou [Fri, 20 May 2016 15:15:01 +0000 (18:15 +0300)]
lxc: use job functions in lxcDomainLxcOpenNamespace & lxcDomainSendProcessSignal

Use the recently added job functions in lxcDomainLxcOpenNamespace,
lxcDomainSendProcessSignal.

Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com>
8 years agoqemucapstest: update caps for qemu-2.6.0
Pavel Hrdina [Sun, 22 May 2016 21:24:25 +0000 (23:24 +0200)]
qemucapstest: update caps for qemu-2.6.0

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemucapstest: update caps for qemu-2.5.0
Pavel Hrdina [Sun, 22 May 2016 21:24:07 +0000 (23:24 +0200)]
qemucapstest: update caps for qemu-2.5.0

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemucapstest: update caps for qemu-2.4.0
Pavel Hrdina [Sun, 22 May 2016 21:23:47 +0000 (23:23 +0200)]
qemucapstest: update caps for qemu-2.4.0

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemucapstest: update caps for qemu-2.1.1
Pavel Hrdina [Sun, 22 May 2016 21:23:11 +0000 (23:23 +0200)]
qemucapstest: update caps for qemu-2.1.1

8 years agoqemucapstest: update caps for qemu-1.6.0
Pavel Hrdina [Sun, 22 May 2016 21:22:50 +0000 (23:22 +0200)]
qemucapstest: update caps for qemu-1.6.0

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemucapstest: update caps for qemu-1.5.3
Pavel Hrdina [Sun, 22 May 2016 21:22:18 +0000 (23:22 +0200)]
qemucapstest: update caps for qemu-1.5.3

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemucapstest: update caps for qemu-1.4.2
Pavel Hrdina [Sun, 22 May 2016 21:21:39 +0000 (23:21 +0200)]
qemucapstest: update caps for qemu-1.4.2

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemucapstest: update caps for qemu-1.3.1
Pavel Hrdina [Sun, 22 May 2016 21:21:09 +0000 (23:21 +0200)]
qemucapstest: update caps for qemu-1.3.1

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemucapstest: update caps for qemu-1.2.2
Pavel Hrdina [Sun, 22 May 2016 21:19:51 +0000 (23:19 +0200)]
qemucapstest: update caps for qemu-1.2.2

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agonwfilter: fix lock order deadlock
Maxim Nestratov [Sat, 9 Apr 2016 16:14:30 +0000 (19:14 +0300)]
nwfilter: fix lock order deadlock

Below is backtraces of two deadlocked threads:

thread #1:
 virDomainConfVMNWFilterTeardown
   virNWFilterTeardownFilter
       lock updateMutex <------------
       _virNWFilterTeardownFilter
            try to lock interface <----------

thread #2:
 learnIPAddressThread
    lock interface <-------
    virNWFilterInstantiateFilterLate
        try to lock updateMutex <----------

The problem is fixed by unlocking interface before calling
virNWFilterInstantiateFilterLate to avoid updateMutex and interface ordering
deadlocks. Otherwise we are going to instantiate the filter while holding
interface lock, which will try to lock updateMutex, and if some other thread
instantiating a filter in parallel is holding updateMutex and is trying to
lock interface, both will deadlock.
Also it is safe to unlock interface before virNWFilterInstantiateFilterLate
because learnIPAddressThread stopped capturing packets and applied necessary
rules on the interface, while instantiating a new filter doesn't require a
locked interface.

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
8 years agomaint: fix syntax-check sc_prohibit_int_ijk exclude rule
Pavel Hrdina [Mon, 23 May 2016 23:00:07 +0000 (01:00 +0200)]
maint: fix syntax-check sc_prohibit_int_ijk exclude rule

Fix the regex for excluding files for this syntax-rule.  The rule "include/"
will not work, because we are matching the whole line like this
"^(...|include/|...)$ so we need to use "include/libvirt/libvirt.+".  The second
issue is that we are using only one '$' but there should be two of those at the
end.  The last small adjustment is to escape dots '.' so it match only dot.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agomakefile: fix build on systems where gnutls is not in /usr/include
Pavel Hrdina [Sun, 22 May 2016 13:23:08 +0000 (15:23 +0200)]
makefile: fix build on systems where gnutls is not in /usr/include

We need to append GNUTLS_CFLAGS while building utils because virtcrypto
is using it.  This fixes build on freebsd where gnutuls is in
/usr/local/include.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemuxml2argvtest: skip test that depends on gnutls_cipher_encrypt()
Pavel Hrdina [Sun, 22 May 2016 13:20:39 +0000 (15:20 +0200)]
qemuxml2argvtest: skip test that depends on gnutls_cipher_encrypt()

Test disk-drive-network-rbd-auth-AES depends on existence of
gnutls_cipher_encrypt() function which was introduced in gnutls 2.10.0.
On systems without this function we should skip this test.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agostorage: Replace VIR_ERROR with standard vir*Error in state driver init
Jovanka Gulicoska [Mon, 23 May 2016 18:36:01 +0000 (20:36 +0200)]
storage: Replace VIR_ERROR with standard vir*Error in state driver init

Replace VIR_ERROR with virReportError and virReportSystemError

8 years agonwfilter: Replace VIR_ERROR with standard vir*Error in state driver init
Jovanka Gulicoska [Mon, 23 May 2016 18:35:59 +0000 (20:35 +0200)]
nwfilter: Replace VIR_ERROR with standard vir*Error in state driver init

Replace VIR_ERROR with virReportError

8 years agolibxl: Replace VIR_ERROR with standard vir*Error in state driver init
Jovanka Gulicoska [Mon, 23 May 2016 18:35:57 +0000 (20:35 +0200)]
libxl: Replace VIR_ERROR with standard vir*Error in state driver init

Replace VIR_ERROR with virReportError

8 years agobhyve: Replace VIR_ERROR with standard vir*Error in state driver init
Jovanka Gulicoska [Mon, 23 May 2016 18:35:56 +0000 (20:35 +0200)]
bhyve: Replace VIR_ERROR with standard vir*Error in state driver init

Replace VIR_ERROR with virReportError

8 years agoqemu: simplify addition of USB controller in qemuParseCommandLine
Laine Stump [Tue, 10 May 2016 16:07:54 +0000 (12:07 -0400)]
qemu: simplify addition of USB controller in qemuParseCommandLine

virDomainDefAddUSBController() does everything that the multiple lines
of code were doing.

8 years agovz: add error code for case if vm is already stopped
Mikhail Feoktistov [Sat, 21 May 2016 14:33:32 +0000 (10:33 -0400)]
vz: add error code for case if vm is already stopped

If try to stop VM or container which is already stopped than
Virtuozzo 7 returns code PRL_ERR_INVALID_ACTION_REQUESTED.
Error code PRL_ERR_DISP_VM_IS_NOT_STARTED is used in Virtuozzo 6

8 years agoRevert "qemu_cgroup: allow access to /dev/dri for virtio-vga"
Ján Tomko [Thu, 19 May 2016 09:29:54 +0000 (11:29 +0200)]
Revert "qemu_cgroup: allow access to /dev/dri for virtio-vga"

This reverts commit 3943bdd60c7ff1de00e73f66d907664b74a88a3f.

8 years agostorage: do not clear vols before volume upload
Ján Tomko [Fri, 20 May 2016 09:42:56 +0000 (11:42 +0200)]
storage: do not clear vols before volume upload

Commit 5e54361c added virStoragePoolObjClearVols before refreshPool
to prevent duplicate volume entries.

However it is not needed here because we're not refreshing the pool yet,
just checking for the existence of the refresh callback.

The actual refresh is done via virStorageVolFDStreamCloseCb
in virStorageVolPoolRefreshThread, which already calls
virStoragePoolObjClearVols.

8 years agoDeprecate QEMU_CAPS_PCIDEVICE
Ján Tomko [Fri, 20 May 2016 12:41:49 +0000 (14:41 +0200)]
Deprecate QEMU_CAPS_PCIDEVICE

Before removal of QEMU_CAPS_DEVICE, its only usage was
or'd with QEMU_CAPS_DEVICE.

Now it's unused.

8 years agoDeprecate QEMU_CAPS_DEVICE
Ján Tomko [Fri, 20 May 2016 12:33:58 +0000 (14:33 +0200)]
Deprecate QEMU_CAPS_DEVICE

We support qemu version 0.12.0+, which has it.

8 years agoDeprecate QEMU_CAPS_DRIVE_READONLY
Ján Tomko [Fri, 20 May 2016 12:25:22 +0000 (14:25 +0200)]
Deprecate QEMU_CAPS_DRIVE_READONLY

We have been assuming its support if qemu supports -device,
which all the supported versions do.

8 years agoqemu: always assume QEMU_CAPS_DRIVE_READONLY
Ján Tomko [Fri, 20 May 2016 11:29:54 +0000 (13:29 +0200)]
qemu: always assume QEMU_CAPS_DRIVE_READONLY

We have been always setting the capability on if qemu has
QEMU_CAPS_DEVICE.

8 years agotests: always assume QEMU_CAPS_DRIVE_READONLY
Ján Tomko [Fri, 20 May 2016 11:49:15 +0000 (13:49 +0200)]
tests: always assume QEMU_CAPS_DRIVE_READONLY

8 years agotests: remove <readonly/> from IDE disks
Ján Tomko [Fri, 20 May 2016 11:50:40 +0000 (13:50 +0200)]
tests: remove <readonly/> from IDE disks

Read-only IDE disks are not supported, but the error
is raised only when QEMU_CAPS_DRIVE_READONLY is set.

8 years agotests: remove disk-drive-fat test
Ján Tomko [Fri, 20 May 2016 12:02:55 +0000 (14:02 +0200)]
tests: remove disk-drive-fat test

This test requests a read-only virtual FAT drive on the IDE bus.
Read-only IDE drives are unsupported, but libvirt only displays
the error if it has the QEMU_CAPS_DRIVE_READONLY capability.
Read-write FAT drives are also unsupported.

8 years agoqemu: assume QEMU_CAPS_DEVICE almost everywhere
Ján Tomko [Fri, 20 May 2016 11:22:26 +0000 (13:22 +0200)]
qemu: assume QEMU_CAPS_DEVICE almost everywhere

Remove more checks that are no longer necessary.

8 years agoqemu_command: assume QEMU_CAPS_DEVICE
Ján Tomko [Fri, 20 May 2016 11:08:45 +0000 (13:08 +0200)]
qemu_command: assume QEMU_CAPS_DEVICE

Drop some checks that are no longer necessary as well as
-usbdevice -pcidevice and -soundhw support.

8 years agoutil: fix build without GNUTLS
Mikhail Feoktistov [Sat, 21 May 2016 14:22:06 +0000 (10:22 -0400)]
util: fix build without GNUTLS

8 years agotests: qemu: test <address type='pci'/> with aarch64
Cole Robinson [Sun, 15 May 2016 19:11:29 +0000 (15:11 -0400)]
tests: qemu: test <address type='pci'/> with aarch64

This is an interesting test case since PCI isn't the default for
aarch64.

8 years agoqemu: auto-assign addresses when <address type='pci'/> is specified
Laine Stump [Tue, 17 May 2016 18:08:13 +0000 (14:08 -0400)]
qemu: auto-assign addresses when <address type='pci'/> is specified

Rather than only assigning a PCI address when no address is given at
all, also do it when the config says that the address type is 'pci',
but it gives no address (virDeviceInfoPCIAddressWanted()).

There are also several places after parsing but prior to address
assignment where code previously expected that any info with address
type='pci' would have a *valid* PCI address, which isn't always the
case - now we check not only for type='pci', but also for a valid
address (virDeviceInfoPCIAddressPresent()).

The test case added in this patch was directly copied from Cole's patch titled:

    qemu: Wire up address type=pci auto_allocate

8 years agobhyve: auto-assign addresses when <address type='pci'/> is specified
Laine Stump [Tue, 17 May 2016 18:06:36 +0000 (14:06 -0400)]
bhyve: auto-assign addresses when <address type='pci'/> is specified

Rather than only assigning a PCI address when no address is given at
all, also do it when the config says that the address type is 'pci',
but it gives no address.

8 years agoconf: allow type='pci' addresses with no address attributes specified
Laine Stump [Tue, 17 May 2016 18:03:00 +0000 (14:03 -0400)]
conf: allow type='pci' addresses with no address attributes specified

Prior to this, <address type='pci'/> wasn't allowed when parsing
(domain+bus+slot+function needed to be a "valid" PCI address, meaning
that at least one of domain/bus/slot had to be non-0), the RNG
required bus to be specified, and if type was set to PCI when
formatting, domain+bus+slot+function would always be output.

This makes all the address attributes optional during parse and RNG
validation, and suppresses domain+bus+slot+function if domain+bus+slot
are all 0 (NB: if d+b+s are all 0, any value for function is
nonsensical as that will never happen in the real world, and after
the next patch we will always assign a real working address to any
empty PCI address before it is ever output to anywhere).

Note that explicitly setting all attributes to 0 is equivalent to
setting none of them, which is okay, since 0000:00:00 is reserved in
any PCI bus setup, and can't be used anyway.

8 years agoconf: new functions to check if PCI address is wanted/present
Laine Stump [Wed, 18 May 2016 16:04:42 +0000 (12:04 -0400)]
conf: new functions to check if PCI address is wanted/present

In order to allow <address type='pci'/> with no other attributes to
mean "I want a PCI address, but any PCI address will do" (just as
having no <address> at all usually indicates), we will need to change
several places in the code from a simple "info->type == (or !=)
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_(PCI|NONE)" into something slightly
more complex, this patch adds to new functions that take a
virDomainDeviceInfoPtr and return true/false depending on 1) whether
the current state of the info indicates that we "want" a PCI address
for this device (virDeviceInfoPCIAddressWanted()) and 2) whether this
device already has a valid PCI address
(virDeviceInfoPCIAddressPresent()).

Both of these functions required the simpler check for whether a pci
address is "empty" (i.e. all of its attributes are 0, which can never
happen in a real PCI address, since slot 0 of bus 0 of domain 0 is
always reserved), so that function is also added.

8 years agoconf: move virDomainDeviceInfo definition from domain_conf.h to device_conf.h
Laine Stump [Tue, 17 May 2016 17:55:02 +0000 (13:55 -0400)]
conf: move virDomainDeviceInfo definition from domain_conf.h to device_conf.h

Also moves all the subordinate structs. This is necessary due to a new
inline function that will be defined in device_conf.h, and also makes
sense, because it is the *device* info that's in the struct. (Actually
a lot more stuff from domain_conf.h could move to this newer file, but
I didn't want to disturb any more than necessary).

8 years agotests: Link virtestmock with probes
Michal Privoznik [Wed, 18 May 2016 13:31:54 +0000 (15:31 +0200)]
tests: Link virtestmock with probes

I've encountered this error while trying out this feature on some
systems:

  $ VIR_TEST_FILE_ACCESS=1 ./virhashtest \
 libvirt.git/tests/.libs/lt-virhashtest: \
symbol lookup error: libvirt.git/tests/.libs/virtestmock.so: \
undefined symbol: libvirt_event_poll_purge_timeout_semaphore

Problem is, linking just libvirt_utils to virmock.la is not
enough. We might need to link libvirt_probes.lo too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>