]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
8 years agoqemu: snapshot: Forbid internal snapshots with pflash firmware
Peter Krempa [Wed, 1 Mar 2017 08:15:33 +0000 (09:15 +0100)]
qemu: snapshot: Forbid internal snapshots with pflash firmware

If the variable store (<nvram>) file is raw qemu can't do a snapshot of
it and thus the snapshot fails. QEMU rejects such snapshot by a message
which would not be properly interpreted as an error by libvirt.

Additionally allowing to use a qcow2 variable store backing file would
solve this issue but then it would become eligible to become target of
the memory dump.

Offline internal snapshot would be incomplete too with either storage
format since libvirt does not handle the pflash file in this case.

Forbid such snapshot so that we can avoid problems.

8 years agonetwork: only check for IPv6 RA routes when the network has an IPv6 address
Laine Stump [Fri, 24 Mar 2017 00:18:25 +0000 (20:18 -0400)]
network: only check for IPv6 RA routes when the network has an IPv6 address

commit 00d28a78 added a check to see if there were any IPv6 routes
added by RA (Router Advertisement) via an interface that had accept_ra
set to something other than "2". The check was being done
unconditionally, but it's only relevant if IPv6 forwarding is going to
be turned on, and that will only happen if the network has an IPv6
address.

8 years agoRevert "qemu: forbid migration with an IOMMU device"
Ján Tomko [Fri, 24 Mar 2017 11:52:07 +0000 (12:52 +0100)]
Revert "qemu: forbid migration with an IOMMU device"

This reverts commit b7118623ad5a8e6ea75d693881c08873eefa3e28.

Migration was implemented by QEMU commit:
commit 8cdcf3c1e58d04b6811956d7608efeb66c42d719
Author: Peter Xu <peterx@redhat.com>
Date:   Fri Jan 6 12:06:13 2017 +0800

    intel_iommu: allow migration

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

8 years agoutil: new function virNetDevPFGetVF()
Laine Stump [Thu, 2 Mar 2017 19:55:01 +0000 (14:55 -0500)]
util: new function virNetDevPFGetVF()

Given an SRIOV PF netdev name (e.g. "enp2s0f0") and VF#, this new
function returns the netdev name of the referenced VF device
(e.g. "enp2s11f6"), or NULL if the device isn't bound to a net driver.

8 years agoutil: new internal function to permit silent failure of virNetDevSetMAC()
Laine Stump [Thu, 9 Mar 2017 19:04:16 +0000 (14:04 -0500)]
util: new internal function to permit silent failure of virNetDevSetMAC()

We will want to allow silent failure of virNetDevSetMAC() in the case
that the SIOSIFHWADDR ioctl fails with errno == EADDRNOTAVAIL. (Yes,
that is very specific, but we really *do* want a logged failure in all
other circumstances, and don't want to duplicate code in the caller
for the other possibilities).

This patch renames the 3 different virNetDevSetMAC() functions to
virNetDevSetMACInternal(), adding a 3rd arg called "quiet" and making
them static (because this extra control will only be needed within
virnetdev.c). A new global virNetDevSetMAC() is defined that calls
whichever of the three *Internal() functions gets compiled with quiet
= false. Callers in virnetdev.c that want to notice a failure with
errno == EADDRNOTAVAIL and retry with a different strategy rather than
immediately failing, can call virNetDevSetMACInternal(..., true).

8 years agoutil: new function virPCIDeviceRebind()
Laine Stump [Tue, 7 Mar 2017 17:58:15 +0000 (12:58 -0500)]
util: new function virPCIDeviceRebind()

This function unbinds a device from its driver, then immediately
rebinds it to its driver again. The code for this new function is just
the 2nd half of virPCIDeviceBindWithDriverOverride(), so that
function's 2nd half is replaced with a call to virPCIDeviceRebind().

8 years agoutil: make virPCIGetDeviceAddressFromSysfsLink() public
Laine Stump [Tue, 7 Mar 2017 19:23:01 +0000 (14:23 -0500)]
util: make virPCIGetDeviceAddressFromSysfsLink() public

This function will be useful in virnetdev.c, so promote it from static.

8 years agoutil: change virPCIGetNetName() to not return error if device has no net name
Laine Stump [Fri, 3 Mar 2017 16:54:59 +0000 (11:54 -0500)]
util: change virPCIGetNetName() to not return error if device has no net name

...and cleanup the callers to report it when it *is* an error.

In many cases It's useful for virPCIGetNetName() to not log an error
and simply return a NULL pointer when the given device isn't bound to
a net driver (e.g. we're looking at a VF that is permanently bound to
vfio-pci). The existing code would silently return an error in this
case, which could eventually lead to the dreaded "An error occurred
but the cause is unknown" log message.

This patch changes virPCIGetNetName() to still return success if the
device simply isn't bound to a net driver, and adjusts all the callers
that require a non-null netname to check for that condition and log an
error when it happens.

8 years agoutil: make virMacAddrParse more versatile
Laine Stump [Wed, 8 Mar 2017 20:27:05 +0000 (15:27 -0500)]
util: make virMacAddrParse more versatile

Previously the MAC address text was required to be terminated with a
NULL. After this, it can be terminated with a space or any control
character.

8 years agoutil: eliminate useless local variable
Laine Stump [Sun, 5 Mar 2017 22:32:15 +0000 (17:32 -0500)]
util: eliminate useless local variable

vf in virNetDevMacVLanDeleteWithVPortProfile() is initialized to -1
and never set. It's not set for a good reason - because it doesn't
make sense during macvtap device setup to refer to a VF device as
"PF:VF#". This patch replaces the two uses of "vf" with "-1", and
removes the local variable, so that it's more clear we are always
calling the utility functions with vf set to -1.

8 years agoutil: use cleanup label consistently in virHostdevNetConfigReplace()
Laine Stump [Sun, 26 Feb 2017 18:27:48 +0000 (13:27 -0500)]
util: use cleanup label consistently in virHostdevNetConfigReplace()

This will make an upcoming functional change more straightforward.

8 years agoutil: remove unused args from virNetDevSetVfConfig()
Laine Stump [Mon, 20 Feb 2017 03:06:33 +0000 (22:06 -0500)]
util: remove unused args from virNetDevSetVfConfig()

This function is only called in two places, and the ifindex,
nltarget_kernel, and getPidFunc args are never used (and never will
be).

ifindex - we always know the name of the device, and never know the
ifindex - if we really did need the ifindex we would have to get it
from the name using virNetDevGetIndex(). In practice, we just send -1
to virNetDevSetVfConfig(), which doesn't bother to learn the real
ifindex (you only need a name *or* an ifindex for the netlink command
to succeed, not both).

nltarget_kernel - messages to set the config of an SRIOV VF will
always go to netlink in the kernel, not to another user process, so
this arg is always true (there are other uses of netlink messages
where the message might need to go to another user process, but never
in the case of RTM_SETLINK for SRIOV).

getPidFunc - this arg is only used if nltarget_kernel is false, and it
never is.

None of this has any functional effect, it just makes it easier to
follow what's happening when virNetDevSetVfConfig() is called.

8 years agoutil: permit querying a VF MAC address or VLAN tag by itself
Laine Stump [Fri, 17 Feb 2017 19:28:55 +0000 (14:28 -0500)]
util: permit querying a VF MAC address or VLAN tag by itself

virNetDevParseVfConfig() assumed that both the MAC address and VLAN
tag pointers were valid, so even if you only wanted one or the other,
you would need a variable to hold the returned value for both. This
patch checks each for a NULL pointer before filling it in.

8 years agoqemu: forbid migration with an IOMMU device
Ján Tomko [Thu, 23 Mar 2017 10:14:42 +0000 (11:14 +0100)]
qemu: forbid migration with an IOMMU device

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

8 years agoqemu: Fix typo in __QEMU_CAPSPRIV_H_ALLOW__
Andrea Bolognani [Wed, 22 Mar 2017 15:22:15 +0000 (16:22 +0100)]
qemu: Fix typo in __QEMU_CAPSPRIV_H_ALLOW__

8 years agoutil: fix build on non-Linux
Roman Bogorodskiy [Thu, 23 Mar 2017 03:45:29 +0000 (07:45 +0400)]
util: fix build on non-Linux

Decorate unused arguments of the virNetDevGetMaster() stub
with ATTRIBUTE_UNUSED to fix build on systems where this
stub is used.

8 years agocpu: Remove NONNULL(1) for cpuBaseline
John Ferlan [Wed, 22 Mar 2017 12:38:40 +0000 (08:38 -0400)]
cpu: Remove NONNULL(1) for cpuBaseline

Since the code checks and handles a NULL 'cpus' anyway, so no need
for the NONNULL.

8 years agoutil: Remove NONNULL(1) for virNetDevMacVLanDeleteWithVPortProfile
John Ferlan [Wed, 22 Mar 2017 12:07:44 +0000 (08:07 -0400)]
util: Remove NONNULL(1) for virNetDevMacVLanDeleteWithVPortProfile

Since the source code checks 'ifname' for NULL before using, the prototype
doesn't need the NONNULL

8 years agoutil: Remove NONNULL's for virNetDevVPortProfile[Associate|Disassociate]
John Ferlan [Wed, 22 Mar 2017 11:58:05 +0000 (07:58 -0400)]
util: Remove NONNULL's for virNetDevVPortProfile[Associate|Disassociate]

The source code will check for NULL arguments for 'macvtap_macaddr' and
'vmuuid', so no need for the NONNULL in the prototypes. Following the stack
for both arguments to virNetDevVPortProfileOpSetLink also shows called
functions would handle a NULL value.

Additionally, modified the prototype to use the same 'macvtap_macaddr'
name as the source code for consistency.

8 years agoutil: Remove NONNULL(1) for virNetDevOpenvswitchGetVhostuserIfname
John Ferlan [Wed, 22 Mar 2017 11:25:32 +0000 (07:25 -0400)]
util: Remove NONNULL(1) for virNetDevOpenvswitchGetVhostuserIfname

Since the code checks and handles a NULL 'path', no need for the NONNULL

8 years agoutil: Remove NONNULL(2) for virNetDevBandwidthPlug
John Ferlan [Tue, 21 Mar 2017 18:56:03 +0000 (14:56 -0400)]
util: Remove NONNULL(2) for virNetDevBandwidthPlug

Since the code checks and handles a NULL 'net_bandwidth' parameter,
so no need for NONNNULL.

8 years agoutil: Remove NONNULL(1,3,4) from virTypedParamsFilter
John Ferlan [Tue, 21 Mar 2017 18:41:53 +0000 (14:41 -0400)]
util: Remove NONNULL(1,3,4) from virTypedParamsFilter

The API checks each parameter for NULL anyway and would error, so need
to add NONNULL on prototype.

8 years agoutil: Remove NONNULL(1) for virNetDevOpenvswitchSetMigrateData
John Ferlan [Tue, 21 Mar 2017 18:40:13 +0000 (14:40 -0400)]
util: Remove NONNULL(1) for virNetDevOpenvswitchSetMigrateData

The code checks and handles a NULL 'migrate', so no need for NONNULL

8 years agoutil: Remove NONNULL(1) for virHostdevReAttachDomainDevices
John Ferlan [Wed, 22 Mar 2017 12:30:15 +0000 (08:30 -0400)]
util: Remove NONNULL(1) for virHostdevReAttachDomainDevices

Since the function handles a NULL 'mgr' condition, no need for the NONNULL

8 years agoutil: Remove NONNULL(1) for virHostdevPrepareDomainDevices
John Ferlan [Tue, 21 Mar 2017 18:32:01 +0000 (14:32 -0400)]
util: Remove NONNULL(1) for virHostdevPrepareDomainDevices

Since the code checks 'mgr == NULL' anyway, no need for the prototype
to have the NONNULL arg check.  Also add an error message to indicate what
the failure is so that there isn't a failed for some reason error.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoutil: Remove NONNULL(2,3) for virHostdevReAttachSCSIVHostDevices
John Ferlan [Wed, 22 Mar 2017 11:23:46 +0000 (07:23 -0400)]
util: Remove NONNULL(2,3) for virHostdevReAttachSCSIVHostDevices

The comparison code used STREQ_NULLABLE anyway for both 'drv_name' and
'dom_name', so no need. Add a NULLSTR on the 'dom_name' too.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoutil: Remove NONNULL(2,3) for virHostdevReAttachUSBDevices
John Ferlan [Tue, 21 Mar 2017 18:25:43 +0000 (14:25 -0400)]
util: Remove NONNULL(2,3) for virHostdevReAttachUSBDevices

The comparison code used STREQ_NULLABLE anyway for both 'drv_name' and
'dom_name', so no need. Add a NULLSTR on the 'dom_name' too.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoutil: Remove NONNULL(2,3) for virHostdevReAttachPCIDevices
John Ferlan [Tue, 21 Mar 2017 18:23:11 +0000 (14:23 -0400)]
util: Remove NONNULL(2,3) for virHostdevReAttachPCIDevices

The called function uses a STRNEQ_NULLABLE anyway for both 'drv_name' and
'dom_name', so no need.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoutil: Remove NONNULL(1) for virBitmapParseUnlimited
John Ferlan [Tue, 21 Mar 2017 17:51:11 +0000 (13:51 -0400)]
util: Remove NONNULL(1) for virBitmapParseUnlimited

The code checks and handles a NULL 'str', so just remove the NONNULL.

Update the error message to add the NULLSTR() around 'str' also.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoutil: Change return argument for virBitmapParseUnlimited
John Ferlan [Wed, 22 Mar 2017 13:39:53 +0000 (09:39 -0400)]
util: Change return argument for virBitmapParseUnlimited

Rather than returning an int and a *bitmap pointer, just return and
check a NULL bitmap pointer

8 years agoqemu: Remove NONNULL(1) for qemu_monitor prototypes
John Ferlan [Tue, 21 Mar 2017 17:39:18 +0000 (13:39 -0400)]
qemu: Remove NONNULL(1) for qemu_monitor prototypes

The 'mon' argument validity is checked in the QEMU_CHECK_MONITOR for the
following functions, so they don't need the NONNULL on their prototype:

qemuMonitorUpdateVideoMemorySize
qemuMonitorUpdateVideoVram64Size
qemuMonitorGetAllBlockStatsInfo
qemuMonitorBlockStatsUpdateCapacity

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoqemu: Remove non null 'vm' check from qemuMonitorOpen
John Ferlan [Tue, 21 Mar 2017 17:37:05 +0000 (13:37 -0400)]
qemu: Remove non null 'vm' check from qemuMonitorOpen

The prototype requires not passing a NULL in the parameter and the callers
all would fail far before this code would fail if 'vm' was NULL, so just
remove the check.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agonetwork: Remove null newBandwidth check from networkBandwidthUpdate
John Ferlan [Tue, 21 Mar 2017 17:33:17 +0000 (13:33 -0400)]
network: Remove null newBandwidth check from networkBandwidthUpdate

The prototype requires a NONNULL argument and the only caller passes in
a non-null parameter. Besides the "else if" condition would deref it anyway.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Remove NONNULL(1) for virDomainNumaGetNodeCount
John Ferlan [Tue, 21 Mar 2017 17:24:36 +0000 (13:24 -0400)]
conf: Remove NONNULL(1) for virDomainNumaGetNodeCount

Since the code checks and handles a NULL 'numa' parameter, remove the NONNULL
from the prototype.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Remove NONNULL(1,2) for virNetDevBandwidthFormat
John Ferlan [Tue, 21 Mar 2017 17:22:23 +0000 (13:22 -0400)]
conf: Remove NONNULL(1,2) for virNetDevBandwidthFormat

Since the code checks and handles NULL parameters, remove the NONNULL
from the prototype.

Also fix the comment in the source to reference the right name.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Remove NONNULL(2) for virNetDevBandwidthParse
John Ferlan [Tue, 21 Mar 2017 17:09:52 +0000 (13:09 -0400)]
conf: Remove NONNULL(2) for virNetDevBandwidthParse

Since the code checks and handles a NULL 'node' before proceeding
there's no need for the prototype with the NONNULL(2).

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoutil: Remove NONNULL(1) for virNetDevGetName
John Ferlan [Wed, 22 Mar 2017 12:55:13 +0000 (08:55 -0400)]
util: Remove NONNULL(1) for virNetDevGetName

The 'ifindex' argument is not a pointer, so no need for NONNULL in prototype

8 years agoqemu: Always format formatStr for blockdev-snapshot-sync
John Ferlan [Tue, 21 Mar 2017 16:53:49 +0000 (12:53 -0400)]
qemu: Always format formatStr for blockdev-snapshot-sync

The qemuDomainSnapshotPrepare should always set a > 0 format value anyway,
so remove the check.

Found by Coverity.

8 years agonetwork: reconnect tap devices during networkNotifyActualDevice
Laine Stump [Tue, 21 Mar 2017 15:24:08 +0000 (11:24 -0400)]
network: reconnect tap devices during networkNotifyActualDevice

If a network is destroyed and restarted, or its bridge is changed, any
tap devices that had previously been connected to the bridge will no
longer be connected. As a first step in automating a reconnection of
all tap devices when this happens, this patch modifies
networkNotifyActualDevice() (which is called once for every
<interface> of every active domain whenever libvirtd is restarted) to
reconnect any tap devices that it finds disconnected.

With this patch in place, you will need to restart libvirtd to
reconnect all the taps to their proper bridges. A future patch will
add a callback that hypervisor drivers can register with the network
driver to that the network driver can trigger this behavior
automatically whenever a network is started.

8 years agoutil: new function virNetDevTapAttachBridge()
Laine Stump [Sat, 18 Mar 2017 18:03:20 +0000 (14:03 -0400)]
util: new function virNetDevTapAttachBridge()

This patch splits out the part of virNetDevTapCreateInBridgePort()
that would need to be re-done if an existing tap device had to be
re-attached to a bridge, and puts it into a separate function. This
can be used both when an existing domain interface config is updated
to change its connection, and also to re-attach to the "same" bridge
when a network has been stopped and restarted. So far it is used for
nothing.

8 years agoutil: new function virNetDevGetMaster()
Laine Stump [Sat, 18 Mar 2017 00:57:18 +0000 (20:57 -0400)]
util: new function virNetDevGetMaster()

This function provides the bridge/bond device that the given network
device is attached to. The return value is 0 or -1, and the master
device is a char** argument to the function - this is needed in order
to allow for a "success" return from a device that has no master.

8 years agonetwork: remove unused typedef for networkDnsmasqLeaseFileNameFunc
Laine Stump [Sat, 18 Mar 2017 01:50:40 +0000 (21:50 -0400)]
network: remove unused typedef for networkDnsmasqLeaseFileNameFunc

8 years agoutil: allow retrieving ethtool features when unprivileged
Laine Stump [Fri, 17 Mar 2017 21:49:45 +0000 (17:49 -0400)]
util: allow retrieving ethtool features when unprivileged

The only reason that the ethtool features weren't being retrieved in
an unprivileged libvirtd was because they required ioctl(), and the
ioctl was using an AF_PACKET socket, which requires root. Now that we
are using AF_UNIX for ioctl(), this restriction can be removed.

8 years agoutil: use AF_UNIX family (not AF_PACKET) for ioctl sockets
Laine Stump [Fri, 17 Mar 2017 21:33:42 +0000 (17:33 -0400)]
util: use AF_UNIX family (not AF_PACKET) for ioctl sockets

The exact family of the socket created for the fd used by ioctl(7)
doesn't matter, it just needs to be a socket and not a file. But for
some reason when macvtap support was added, it used
AF_PACKET/SOCK_DGRAM sockets for its ioctls; we later used the same
AF_PACKET/SOCK_DGRAM socket for new ioctls we added, and eventually
modified the other pre-existing ioctl sockets (for creating/deleting
bridges) to also use AF_PACKET/SOCK_DGRAM (that code originally used
AF_UNIX/SOCK_STREAM).

The problem with using AF_PACKET (intended for sending/receiving "raw"
packets, i.e. packets that can be some protocol other than TCP or UDP)
is that it requires root privileges. This meant that none of the
ioctls in virnetdev.c or virnetdevip.c would work when running
libvirtd unprivileged.

This packet solves that problem by changing the family to AF_UNIX when
creating the socket used for any ioctl().

8 years agodomain_capabilities: Don't report machine type for bhyve
Michal Privoznik [Tue, 21 Mar 2017 14:23:35 +0000 (15:23 +0100)]
domain_capabilities: Don't report machine type for bhyve

For some drivers the domain's machine type makes no sense. They
just don't use it. A great example is bhyve driver. Therefore it
makes very less sense to report machine in domain capabilities
XML.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agonetwork: check accept_ra before enabling ipv6 forwarding
Cédric Bosdonnat [Fri, 3 Mar 2017 13:14:51 +0000 (14:14 +0100)]
network: check accept_ra before enabling ipv6 forwarding

When enabling IPv6 on all interfaces, we may get the host Router
Advertisement routes discarded. To avoid this, the user needs to set
accept_ra to 2 for the interfaces with such routes.

See https://www.kernel.org/doc/Documentation/networking/ip-sysctl.txt
on this topic.

To avoid user mistakenly losing routes on their hosts, check
accept_ra values before enabling IPv6 forwarding. If a RA route is
detected, but neither the corresponding device nor global accept_ra
is set to 2, the network will fail to start.

8 years agoutil: add virNetDevGetName() function
Cédric Bosdonnat [Wed, 15 Mar 2017 13:46:56 +0000 (14:46 +0100)]
util: add virNetDevGetName() function

Add a function getting the name of a network interface out of its index.

8 years agobridge_driver.c: more uses of SYSCTL_PATH
Cédric Bosdonnat [Fri, 3 Mar 2017 13:13:49 +0000 (14:13 +0100)]
bridge_driver.c: more uses of SYSCTL_PATH

Replace a few occurences of /proc/sys by the corresponding macro
defined a few lines after: SYSCTL_PATH

8 years agoutil: add virNetlinkDumpCommand()
Cédric Bosdonnat [Fri, 3 Mar 2017 11:22:50 +0000 (12:22 +0100)]
util: add virNetlinkDumpCommand()

virNetlinkCommand() processes only one response message, while some
netlink commands, like route dumping, need to process several.
Add virNetlinkDumpCommand() as a virNetlinkCommand() sister.

8 years agoutil: extract the request sending code from virNetlinkCommand()
Cédric Bosdonnat [Fri, 3 Mar 2017 11:16:32 +0000 (12:16 +0100)]
util: extract the request sending code from virNetlinkCommand()

Allow to reuse as much as possible from virNetlinkCommand(). This
comment prepares for the introduction of virNetlinkDumpCommand()
only differing by how it handles the responses.

8 years agoqemu: Fix qemuMonitorOpen prototype
John Ferlan [Tue, 21 Mar 2017 16:43:56 +0000 (12:43 -0400)]
qemu: Fix qemuMonitorOpen prototype

Commit id '85af0b8' added a 'timeout' as the 4th parameter to
qemuMonitorOpen, but neglected to update the ATTRIBUTE_NONNULL(4)
to be (5) for the cb parameter.

8 years agonetwork: don't add "no-resolv" if we still need DNS servers from resolv.conf
Laine Stump [Fri, 17 Mar 2017 16:25:43 +0000 (12:25 -0400)]
network: don't add "no-resolv" if we still need DNS servers from resolv.conf

It was pointed out here:

  https://bugzilla.redhat.com/show_bug.cgi?id=1331796#c4

that we shouldn't be adding a "no-resolv" to the dnsmasq.conf file for
a network if there isn't any <forwarder> element that specifies an IP
address but no qualifying domain. If there is such an element, it will
handle all DNS requests that weren't otherwise handled by one of the
forwarder entries with a matching domain attribute. If not, then DNS
requests that don't match the domain of any <forwarder> would not be
resolved if we added no-resolv.

So, only add "no-resolv" when there is at least one <forwarder>
element that specifies an IP address but no qualifying domain.

8 years agocleanup: qemu_capabilities: remove redundant error messages
Chen Hanxiao [Tue, 21 Mar 2017 11:58:27 +0000 (19:58 +0800)]
cleanup: qemu_capabilities: remove redundant error messages

We reported error in caller virQEMUCapsCacheLookupByArch.
So the same error messages in qemuConnectGetDomainCapabilities
is useless.

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
8 years agotests: update QEMU 2.9.0 caps data
Pavel Hrdina [Tue, 21 Mar 2017 11:45:00 +0000 (12:45 +0100)]
tests: update QEMU 2.9.0 caps data

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agonews: Document "Enforce guest CPU specification" series
Jiri Denemark [Mon, 20 Mar 2017 18:52:40 +0000 (19:52 +0100)]
news: Document "Enforce guest CPU specification" series

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Don't try to update undefined guest CPU
Jiri Denemark [Mon, 20 Mar 2017 08:03:58 +0000 (09:03 +0100)]
qemu: Don't try to update undefined guest CPU

Calling virCPUUpdateLive on a domain with no guest CPU configuration
does not make sense. Especially when doing so would crash libvirtd.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoconf: Use consistent function name prefixes for virstorageobj
John Ferlan [Tue, 7 Mar 2017 21:10:38 +0000 (16:10 -0500)]
conf: Use consistent function name prefixes for virstorageobj

Use "virStoragePoolObj" as a prefix for any external API in virstorageobj.

Also a couple of functions were local to virstorageobj.c, so remove their
external defs iin virstorageobj.h.

NB: The virStorageVolDef* API's won't change.
Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Alter coding style of storage conf function prototypes
John Ferlan [Tue, 7 Mar 2017 20:44:41 +0000 (15:44 -0500)]
conf: Alter coding style of storage conf function prototypes

In an effort to be consistent with the source module, alter the function
prototypes to follow the similar style of source with the "type" on one
line followed by the function name and arguments on subsequent lines with
with argument getting it's own line.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Adjust coding style for storage conf sources
John Ferlan [Tue, 7 Mar 2017 20:28:27 +0000 (15:28 -0500)]
conf: Adjust coding style for storage conf sources

Alter the format of the code to follow more recent style guidelines of
two empty lines between functions, function decls with "[static] type"
on one line followed by function name with arguments to functions each
on one line.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Introduce virstorageobj
John Ferlan [Tue, 7 Mar 2017 20:18:01 +0000 (15:18 -0500)]
conf: Introduce virstorageobj

Move all the StoragePoolObj related API's into their own module
virstorageobj from the storage_conf

Purely code motion at this point, plus adjustments to cleanly build

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years ago(log|lock)daemon: Don't spam logs with IO error messages after client disconnects
Peter Krempa [Fri, 17 Mar 2017 15:38:47 +0000 (16:38 +0100)]
(log|lock)daemon: Don't spam logs with IO error messages after client disconnects

The log and lock protocol don't have an extra handshake to close the
connection. Instead they just close the socket. Unfortunately that
resulted into a lot of spurious garbage logged to the system log files:

2017-03-17 14:00:09.730+0000: 4714: error : virNetSocketReadWire:1800 : End of file while reading data: Input/output error

or in the journal as:

Mar 13 16:19:33 xxxx virtlogd[32360]: End of file while reading data: Input/output error

Use the new facility in the netserverclient to suppress the IO error
report from the virNetSocket layer.

8 years agorpc: serverclient: Add option to suppress errors on EOF
Peter Krempa [Fri, 17 Mar 2017 15:18:08 +0000 (16:18 +0100)]
rpc: serverclient: Add option to suppress errors on EOF

The protocol may not use an explicit API to close the connection and
just close the socket instead. Add option to suppress errors in such
case.

8 years agorpc: socket: Add possibility to suppress errors on read hangup
Peter Krempa [Fri, 17 Mar 2017 15:01:45 +0000 (16:01 +0100)]
rpc: socket: Add possibility to suppress errors on read hangup

In some cases a read error due to connection hangup is expected. This
patch adds a flag that removes the logging of a virError in such case.

8 years agoqemu: Enforce guest CPU specification
Jiri Denemark [Tue, 14 Mar 2017 14:05:02 +0000 (15:05 +0100)]
qemu: Enforce guest CPU specification

When guest CPU definition uses VIR_CPU_CHECK_FULL checks, we need to
make sure QEMU does not add or remove any features.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Update CPU definition according to QEMU
Jiri Denemark [Mon, 13 Mar 2017 11:32:02 +0000 (12:32 +0100)]
qemu: Update CPU definition according to QEMU

When starting a domain with custom guest CPU specification QEMU may add
or remove some CPU features. There are several reasons for this, e.g.,
QEMU/KVM does not support some requested features or the definition of
the requested CPU model in libvirt's cpu_map.xml differs from the one
QEMU is using. We can't really avoid this because CPU models are allowed
to change with machine types and libvirt doesn't know (and probably
doesn't even want to know) about such changes.

Thus when we want to make sure guest ABI doesn't change when a domain
gets migrated to another host, we need to update our live CPU definition
according to the CPU QEMU created. Once updated, we will change CPU
checking to VIR_CPU_CHECK_FULL to make sure the virtual CPU created
after migration exactly matches the one on the source.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Ask QEMU for filtered CPU features
Jiri Denemark [Mon, 13 Mar 2017 10:00:48 +0000 (11:00 +0100)]
qemu: Ask QEMU for filtered CPU features

qemuMonitorGetGuestCPU can now optionally create CPU data from
filtered-features in addition to feature-words.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Use ARCH_IS_X86 in qemuMonitorJSONGetGuestCPU
Jiri Denemark [Mon, 13 Mar 2017 09:23:37 +0000 (10:23 +0100)]
qemu: Use ARCH_IS_X86 in qemuMonitorJSONGetGuestCPU

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Refactor qemuProcessVerifyGuestCPU
Jiri Denemark [Fri, 10 Mar 2017 23:45:37 +0000 (00:45 +0100)]
qemu: Refactor qemuProcessVerifyGuestCPU

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Refactor CPU features check
Jiri Denemark [Fri, 10 Mar 2017 23:36:55 +0000 (00:36 +0100)]
qemu: Refactor CPU features check

The checks are now in a dedicated qemuProcessVerifyCPUFeatures function.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Refactor KVM features check
Jiri Denemark [Fri, 10 Mar 2017 23:10:56 +0000 (00:10 +0100)]
qemu: Refactor KVM features check

The checks are now in a dedicated qemuProcessVerifyKVMFeatures function.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Refactor Hyper-V features check
Jiri Denemark [Fri, 10 Mar 2017 22:55:59 +0000 (23:55 +0100)]
qemu: Refactor Hyper-V features check

The checks are now in a dedicated qemuProcessVerifyHypervFeatures
function.

In addition to moving the code this patch also fixes a few bugs: the
original code was leaking cpuFeature and the return value of
virCPUDataCheckFeature was not checked properly.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Set default values for CPU check attribute
Jiri Denemark [Wed, 1 Mar 2017 15:12:07 +0000 (16:12 +0100)]
qemu: Set default values for CPU check attribute

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoIntroduce /domain/cpu/@check XML attribute
Jiri Denemark [Wed, 1 Mar 2017 14:18:22 +0000 (15:18 +0100)]
Introduce /domain/cpu/@check XML attribute

The attribute can be used to request a specific way of checking whether
the virtual CPU matches created by the hypervisor matches the
specification in domain XML.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agodocs: Clarify /domain/cpu/@match description
Jiri Denemark [Thu, 2 Mar 2017 13:53:18 +0000 (14:53 +0100)]
docs: Clarify /domain/cpu/@match description

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agotests: Switch to sparse initialization of virCPUDef
Jiri Denemark [Wed, 1 Mar 2017 13:54:53 +0000 (14:54 +0100)]
tests: Switch to sparse initialization of virCPUDef

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: command: Don't allow setting 'group_name' alone
Peter Krempa [Fri, 17 Mar 2017 08:26:17 +0000 (09:26 +0100)]
qemu: command: Don't allow setting 'group_name' alone

The disk tuning group parameter is ignored by qemu if no other
throttling options are set. Reject such configuration, since the name
would not be honored after setting parameters via the live tuning API.

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

8 years agoqemu: command: Extract tests for subsets of blkdeviotune settings
Peter Krempa [Fri, 17 Mar 2017 08:23:54 +0000 (09:23 +0100)]
qemu: command: Extract tests for subsets of blkdeviotune settings

When checking capabilities for qemu we need to check whether subsets of
the disk throttling settings are supported. Extract the checks into a
separate functions as they will be reused in next patch.

8 years agoqemu: command: Extract blkdeviotune checks into a separate function
Peter Krempa [Fri, 17 Mar 2017 08:11:20 +0000 (09:11 +0100)]
qemu: command: Extract blkdeviotune checks into a separate function

qemuBuildDriveStr grew into 'megamoth' proportions. Cut out some parts.

8 years agoqemu: Don't steal pointers from 'persistentDef' in qemuDomainGetBlockIoTune
Peter Krempa [Fri, 17 Mar 2017 07:43:27 +0000 (08:43 +0100)]
qemu: Don't steal pointers from 'persistentDef' in qemuDomainGetBlockIoTune

While the code path that queries the monitor allocates a separate copy
of the 'group_name' string the path querying the config would not copy
it. The call to virTypedParameterAssign would then steal the pointer
(without clearing it) and the RPC layer freed it. Any subsequent call
resulted into a crash.

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

8 years agoqemu: skip QMP probing of CPU definitions when missing
Guido Günther [Thu, 16 Mar 2017 08:19:02 +0000 (09:19 +0100)]
qemu: skip QMP probing of CPU definitions when missing

This unbreaks emulators that don't support this command such as
qemu-system-mips*.

Reference: http://bugs.debian.org/854125

8 years agoperf: remote: Compare perf nparams against the correct constant
Nitesh Konkar [Thu, 16 Mar 2017 11:55:15 +0000 (17:25 +0530)]
perf: remote: Compare perf nparams against the correct constant

Currently 'virsh perf domain' errors out as the perf nparams is
incorrectly compared against REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX
instead of REMOTE_DOMAIN_PERF_EVENTS_MAX.

Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
8 years agonews: Document support for generic PCIe Root Ports
Andrea Bolognani [Tue, 14 Mar 2017 16:39:29 +0000 (17:39 +0100)]
news: Document support for generic PCIe Root Ports

8 years agotests: Test generic PCIe Root Ports
Andrea Bolognani [Thu, 16 Mar 2017 16:41:21 +0000 (17:41 +0100)]
tests: Test generic PCIe Root Ports

We want pcie-root-ports to be used when available in QEMU,
but at the same time we need to ensure that hosts running
older QEMU releases keep working and that the user can
override the default at any time.

Add a comment for the original pcie-root-port test cases
to make it clear how these new test cases are different.

8 years agoqemu: Use generic PCIe Root Ports by default when available
Andrea Bolognani [Tue, 14 Mar 2017 13:42:51 +0000 (14:42 +0100)]
qemu: Use generic PCIe Root Ports by default when available

ioh3420 is emulated Intel hardware, so it always looked
quite out of place in aarch64/virt guests. Even for x86/q35
guests, the recently-introduced pcie-root-port is a better
choice because, unlike ioh3420, it doesn't require IO space
(a fairly constrained resource) to work.

If pcie-root-port is available in QEMU, use it; ioh3420 is
still used as fallback for when pcie-root-port is not
available.

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

8 years agoqemu: Add support for generic PCIe Root Ports
Andrea Bolognani [Mon, 16 Jan 2017 12:28:20 +0000 (13:28 +0100)]
qemu: Add support for generic PCIe Root Ports

QEMU 2.9 introduces the pcie-root-port device, which is
a generic version of the existing ioh3420 device.

Make the new device available to libvirt users.

8 years agoapparmor: allow /usr/lib/qemu/qemu-bridge-helper
Guido Günther [Fri, 17 Mar 2017 08:59:42 +0000 (09:59 +0100)]
apparmor: allow /usr/lib/qemu/qemu-bridge-helper

This is where e.g. Debian puts it.

8 years agodocs: Document NVDIMM
Michal Privoznik [Thu, 16 Mar 2017 10:16:50 +0000 (11:16 +0100)]
docs: Document NVDIMM

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoReport what TLS priority string we use for a session
Daniel P. Berrange [Wed, 15 Mar 2017 18:04:36 +0000 (18:04 +0000)]
Report what TLS priority string we use for a session

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoShort circuit SASL auth when no mechanisms are available
Daniel P. Berrange [Wed, 15 Mar 2017 18:03:37 +0000 (18:03 +0000)]
Short circuit SASL auth when no mechanisms are available

If the SASL config does not have any mechanisms we currently
just report an empty list to the client which will then
fail to identify a usable mechanism. This is a server config
error, so we should fail immediately on the server side.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoSanity check explicit TLS file paths
Daniel P. Berrange [Wed, 15 Mar 2017 18:02:40 +0000 (18:02 +0000)]
Sanity check explicit TLS file paths

When providing explicit x509 cert/key paths in libvirtd.conf,
the user must provide all three. If one or more is missed,
this leads to obscure errors at runtime when negotiating
the TLS session

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoIncrease default file handle limits for daemons
Daniel P. Berrange [Wed, 15 Mar 2017 16:51:51 +0000 (16:51 +0000)]
Increase default file handle limits for daemons

Linux still defaults to a 1024 open file handle limit. This causes
scalability problems for libvirtd / virtlockd / virtlogd on large
hosts which might want > 1024 guest to be running. In fact if each
guest needs > 1 FD, we can't even get to 500 guests. This is not
good enough when we see machines with 100's of physical cores and
TBs of RAM.

In comparison to other memory requirements of libvirtd & related
daemons, the resource usage associated with open file handles
is essentially line noise. It is thus reasonable to increase the
limits unconditionally for all installs.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agolibxl: fix typo in debug message
Guido Günther [Thu, 16 Mar 2017 07:39:32 +0000 (08:39 +0100)]
libxl: fix typo in debug message

8 years agodocs: Document adaptive timeout for qemu monitor
Michal Privoznik [Wed, 15 Mar 2017 12:03:15 +0000 (13:03 +0100)]
docs: Document adaptive timeout for qemu monitor

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemu: Adaptive timeout for connecting to monitor
Michal Privoznik [Sat, 11 Mar 2017 06:23:42 +0000 (07:23 +0100)]
qemu: Adaptive timeout for connecting to monitor

There were couple of reports on the list (e.g. [1]) that guests
with huge amounts of RAM are unable to start because libvirt
kills qemu in the initialization phase. The problem is that if
guest is configured to use hugepages kernel has to zero them all
out before handing over to qemu process. For instance, 402GiB
worth of 1GiB pages took around 105 seconds (~3.8GiB/s). Since we
do not want to make the timeout for connecting to monitor
configurable, we have to teach libvirt to count with this
fact. This commit implements "1s per each 1GiB of RAM" approach
as suggested here [2].

1: https://www.redhat.com/archives/libvir-list/2017-March/msg00373.html
2: https://www.redhat.com/archives/libvir-list/2017-March/msg00405.html

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agovirTimeBackOffWait: Avoid long periods of sleep
Michal Privoznik [Mon, 13 Mar 2017 10:05:08 +0000 (11:05 +0100)]
virTimeBackOffWait: Avoid long periods of sleep

While connecting to qemu monitor, the first thing we do is wait
for it to show up. However, we are doing it with some timeout to
avoid indefinite waits (e.g. when qemu doesn't create the monitor
socket at all). After beaa447a29 we are using exponential back
off timeout meaning, after the first connection attempt we wait
1ms, then 2ms, then 4 and so on.  This allows us to bring down
wait time for small domains where qemu initializes quickly.
However, on the other end of this scale are some domains with
huge amounts of guest memory. Now imagine that we've gotten up to
wait time of 15 seconds. The next one is going to be 30 seconds,
and the one after that whole minute. Well, okay - with current
code we are not going to wait longer than 30 seconds in total,
but this is going to change in the next commit.

The exponential back off is usable only for first few iterations.
Then it needs to be caped (one second was chosen as the limit)
and switch to constant wait time.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agotest: Don't assume a configFile exists for Storage Pool tests
John Ferlan [Wed, 15 Mar 2017 19:09:35 +0000 (15:09 -0400)]
test: Don't assume a configFile exists for Storage Pool tests

Fix a "bug" in the storage pool test driver code which "assumed"
testStoragePoolObjSetDefaults should fill in the configFile for
both the Define/Create (persistent) and CreateXML (transient) pools
by just VIR_FREE()'ing it during CreateXML.  Because the configFile
was filled in, during Destroy the pool wouldn't be free'd which
could cause issues for future patches which add tests to validate
vHBA creation for the storage pool using the same name.

8 years agoconf: Alter error message for vHBA creation using parent wwnn/wwpn
John Ferlan [Wed, 15 Mar 2017 19:07:21 +0000 (15:07 -0400)]
conf: Alter error message for vHBA creation using parent wwnn/wwpn

Commit id 'bb74a7ffe' added a fairly non specific message when providing
only the <parent wwnn='xxx'/> or <parent wwpn='xxx'/> instead of providing
both wwnn and wwpn. This patch just modifies the message to be more specific
about which was missing.

8 years agoconf: Return the vHBA name from virNodeDeviceCreateVport
John Ferlan [Fri, 27 Jan 2017 23:50:57 +0000 (18:50 -0500)]
conf: Return the vHBA name from virNodeDeviceCreateVport

Rather than returning true/false and having the caller check if the
vHBA was actually created, let's do that check within the CreateVport
function. That way the caller can faithfully assume success based
on a name start the thread looking for the LUNs. Prior to this change
it's possible that the vHBA wasn't really created (e.g if the call to
virVHBAGetHostByWWN returned NULL), we'd claim success, but in reality
there'd be no vHBA for the pool. This also fixes a second yet seen
issue that if the nodedev was present, but the parent by name wasn't
provided (perhaps parent by wwnn/wwpn or by fabric_name), then a failure
would be returned. For this path it shouldn't be an error - we should
just be happy that something else is managing the device and we don't
have to create/delete it.

The end result is that the createVport code can now just start the
refresh thread once it gets a non NULL name back.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Move/Rename createVport and deleteVport
John Ferlan [Wed, 15 Mar 2017 14:56:26 +0000 (10:56 -0400)]
conf: Move/Rename createVport and deleteVport

Move the bulk of createVport and rename to virNodeDeviceCreateVport.

Remove the deleteVport entirely and replace with virNodeDeviceDeleteVport

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoutil: Rename virFileWaitForDevices
John Ferlan [Mon, 20 Feb 2017 12:00:51 +0000 (07:00 -0500)]
util: Rename virFileWaitForDevices

The function is actually in virutil.c, but prototyped in virfile.h.
This patch fixes that by renaming the function to virWaitForDevices,
adding the prototype in virutil.h and libvirt_private.syms, and then
changing the callers to use the new name.

Signed-off-by: John Ferlan <jferlan@redhat.com>