]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
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>
8 years agoconf: Convert virStoragePoolSourceAdapter to virStorageAdapter
John Ferlan [Tue, 28 Feb 2017 12:38:12 +0000 (07:38 -0500)]
conf: Convert virStoragePoolSourceAdapter to virStorageAdapter

Move the virStoragePoolSourceAdapter from storage_conf.h and rename
to virStorageAdapter.

Continue with code realignment for brevity and flow.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agostorage: Rework createVport and deleteVport
John Ferlan [Fri, 10 Mar 2017 16:43:11 +0000 (11:43 -0500)]
storage: Rework createVport and deleteVport

Rework the code to use the new FCHost specific adapter structures.

Also rework the parameters to only pass what's need and leave logic in
the caller for the adapter type and the need to call the helpers.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agostorage: Rework getAdapterName to use adapter specific typedefs
John Ferlan [Fri, 10 Mar 2017 16:28:35 +0000 (11:28 -0500)]
storage: Rework getAdapterName to use adapter specific typedefs

Use the FCHost and SCSIHost adapter specific typedefs

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Rework storage_conf to use adapter specific typedefs
John Ferlan [Fri, 10 Mar 2017 18:03:38 +0000 (13:03 -0500)]
conf: Rework storage_conf to use adapter specific typedefs

Rework the helpers/APIs to use the FCHost and SCSIHost adapter types.
Continue to realign the code for shorter lines.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Rework storage_adapter_conf to use adapter specific typedefs
John Ferlan [Fri, 10 Mar 2017 17:08:46 +0000 (12:08 -0500)]
conf: Rework storage_adapter_conf to use adapter specific typedefs

Rework the helpers/APIs to use the FCHost and SCSIHost adapter types.
Continue to realign the code for shorter lines.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Split up virStoragePoolSourceAdapter
John Ferlan [Fri, 10 Mar 2017 16:21:12 +0000 (11:21 -0500)]
conf: Split up virStoragePoolSourceAdapter

Create typedef'd substructures and rework typedef to utilize.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Extract SCSI adapter type processing into their own helpers
John Ferlan [Fri, 10 Mar 2017 14:29:57 +0000 (09:29 -0500)]
conf: Extract SCSI adapter type processing into their own helpers

Rather than have lots of ugly inline code, create helpers to try and
make things more readable. While creating the helpers realign the code
as necessary.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Extract FCHost adapter type processing into their own helpers
John Ferlan [Fri, 10 Mar 2017 14:05:09 +0000 (09:05 -0500)]
conf: Extract FCHost adapter type processing into their own helpers

Rather than have lots of ugly inline code, create helpers to try and
make things more readable. While creating the helpers realign the code
as necessary.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Rename API's in storage_adapter_conf
John Ferlan [Fri, 10 Mar 2017 18:24:56 +0000 (13:24 -0500)]
conf: Rename API's in storage_adapter_conf

Rename the API's to remove the storage pool source pieces

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Introduce storage_adapter_conf
John Ferlan [Fri, 10 Mar 2017 12:32:46 +0000 (07:32 -0500)]
conf: Introduce storage_adapter_conf

Move code from storage_conf into storage_adapter_conf

Pure code motion

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Rework parsing in virStoragePoolDefParseSourceAdapter
John Ferlan [Fri, 10 Mar 2017 13:18:48 +0000 (08:18 -0500)]
conf: Rework parsing in virStoragePoolDefParseSourceAdapter

Rather than use virXPathString, pass along an virXPathNode and alter
the parsing to use virXMLPropString.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Split out storage pool source adapter helpers
John Ferlan [Fri, 10 Mar 2017 12:06:22 +0000 (07:06 -0500)]
conf: Split out storage pool source adapter helpers

Split out the code that munges through the storage pool adapter into
helpers - it's about to be moved into it's own source file.

This is purely code motion at this point.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Add missing validate for fchost search fields
John Ferlan [Fri, 10 Mar 2017 15:04:20 +0000 (10:04 -0500)]
conf: Add missing validate for fchost search fields

Commit id 'bb74a7ffe' added some new fields to search for a fchost by
parent wwnn/wwpn or parent_fabric_name, but neglected to validate that
the data within the fields was valid at parse time. This could lead to
eventual failure at run time, so rather than have the failure then, let's
validate now.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Ensure both parent_wwnn/parent_wwpn provided
John Ferlan [Fri, 10 Mar 2017 15:29:32 +0000 (10:29 -0500)]
conf: Ensure both parent_wwnn/parent_wwpn provided

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

Commit id 'bb74a7ffe' neglected to check that both the parent_wwnn
parent_wwpn are in the XML if one or the other is similar to how
the node device code checked (commit id '2b13361bc').

If only one is provided, the "default" is to use a vHBA capable
adapter (see commit id '78be2e8b'), so the vHBA could start, but
perhaps not on the expected adapter.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoSwitch to GSSAPI (kerberos) instead of the insecure DIGEST-MD5
Daniel P. Berrange [Mon, 13 Mar 2017 12:15:57 +0000 (12:15 +0000)]
Switch to GSSAPI (kerberos) instead of the insecure DIGEST-MD5

RFC 6331 documents a number of serious security weaknesses in
the SASL DIGEST-MD5 mechanism. As such, libvirtd should not
by using it as a default mechanism. GSSAPI is the only other
viable SASL mechanism that can provide secure session encryption
so enable that by defalt as the replacement.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoqemu: Namespaces for NVDIMM
Michal Privoznik [Wed, 22 Feb 2017 16:37:39 +0000 (17:37 +0100)]
qemu: Namespaces for NVDIMM

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemu: Allow nvdimm in devices CGroups
Michal Privoznik [Wed, 22 Feb 2017 15:33:12 +0000 (16:33 +0100)]
qemu: Allow nvdimm in devices CGroups

Some users might want to pass a blockdev or a chardev as a
backend for NVDIMM. In fact, this is expected to be the mostly
used configuration. Therefore libvirt should allow the device in
devices CGroup then.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemu_hotplug: Relabel memdev
Michal Privoznik [Thu, 4 Aug 2016 13:26:09 +0000 (15:26 +0200)]
qemu_hotplug: Relabel memdev

Now that we have APIs for relabel memdevs on hotplug, fill in the
missing implementation in qemu hotplug code.

The qemuSecurity wrappers might look like overkill for now,
because qemu namespace code does not deal with the nvdimms yet.
Nor does our cgroup code.  But hey, there's cgroup_device_acl
variable in qemu.conf. If users add their /dev/pmem* device in
there, the device is allowed in cgroups and created in the
namespace so they can successfully passthrough it to the domain.
It doesn't look like overkill after all, does it?

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agosecdrivers: Implement memdev relabel APIs
Michal Privoznik [Thu, 4 Aug 2016 12:55:16 +0000 (14:55 +0200)]
secdrivers: Implement memdev relabel APIs

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agosecurity: Introduce internal APIs for memdev labelling
Michal Privoznik [Thu, 4 Aug 2016 12:48:15 +0000 (14:48 +0200)]
security: Introduce internal APIs for memdev labelling

These APIs will be used whenever we are hot (un-)plugging a
memdev.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agosecurity_selinux: Label host side of NVDIMM
Michal Privoznik [Thu, 4 Aug 2016 12:04:38 +0000 (14:04 +0200)]
security_selinux: Label host side of NVDIMM

When domain is being started up, we ought to relabel the host
side of NVDIMM so qemu has access to it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agosecurity_dac: Label host side of NVDIMM
Michal Privoznik [Thu, 4 Aug 2016 10:01:38 +0000 (12:01 +0200)]
security_dac: Label host side of NVDIMM

When domain is being started up, we ought to relabel the host
side of NVDIMM so qemu has access to it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemu: Introduce label-size for NVDIMMs
Michal Privoznik [Mon, 27 Feb 2017 10:20:26 +0000 (11:20 +0100)]
qemu: Introduce label-size for NVDIMMs

For NVDIMM devices it is optionally possible to specify the size
of internal storage for namespaces. Namespaces are a feature that
allows users to partition the NVDIMM for different uses.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemu: Implement @access for <memory/> banks
Michal Privoznik [Mon, 1 Aug 2016 13:49:35 +0000 (15:49 +0200)]
qemu: Implement @access for <memory/> banks

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoconf: Introduce @access to <memory/>
Michal Privoznik [Mon, 1 Aug 2016 12:59:38 +0000 (14:59 +0200)]
conf: Introduce @access to <memory/>

Now that NVDIMM has found its way into libvirt, users might want
to fine tune some settings for each module separately. One such
setting is 'share=on|off' for the memory-backend-file object.
This setting - just like its name suggest already - enables
sharing the nvdimm module with other applications. Under the hood
it controls whether qemu mmaps() the file as MAP_PRIVATE or
MAP_SHARED.

Yet again, we have such config knob in domain XML, but it's just
an attribute to numa <cell/>. This does not give fine enough
tuning on per-memdevice basis so we need to have the attribute
for each device too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemu: Implement NVDIMM
Michal Privoznik [Fri, 29 Jul 2016 09:02:25 +0000 (11:02 +0200)]
qemu: Implement NVDIMM

So, majority of the code is just ready as-is. Well, with one
slight change: differentiate between dimm and nvdimm in places
like device alias generation, generating the command line and so
on.

Speaking of the command line, we also need to append 'nvdimm=on'
to the '-machine' argument so that the nvdimm feature is
advertised in the ACPI tables properly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemu: Introduce QEMU_CAPS_DEVICE_NVDIMM
Michal Privoznik [Fri, 29 Jul 2016 06:17:42 +0000 (08:17 +0200)]
qemu: Introduce QEMU_CAPS_DEVICE_NVDIMM

Introduce a qemu capability for -device nvdimm.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoIntroduce NVDIMM memory model
Michal Privoznik [Thu, 28 Jul 2016 16:54:18 +0000 (18:54 +0200)]
Introduce NVDIMM memory model

NVDIMM is new type of memory introduced into QEMU 2.6. The idea
is that we have a Non-Volatile memory module that keeps the data
persistent across domain reboots.

At the domain XML level, we already have some representation of
'dimm' modules. Long story short, NVDIMM will utilize the
existing <memory/> element that lives under <devices/> by adding
a new attribute 'nvdimm' to the existing @model and introduce a
new <path/> element for <source/> while reusing other fields. The
resulting XML would appear as:

    <memory model='nvdimm'>
      <source>
        <path>/tmp/nvdimm</path>
      </source>
      <target>
        <size unit='KiB'>523264</size>
        <node>0</node>
      </target>
      <address type='dimm' slot='0'/>
    </memory>

So far, this is just a XML parser/formatter extension. QEMU
driver implementation is in the next commit.

For more info on NVDIMM visit the following web page:

    http://pmem.io/

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemuBuildMemoryBackendStr: Reorder args and update comment
Michal Privoznik [Thu, 16 Feb 2017 14:17:47 +0000 (15:17 +0100)]
qemuBuildMemoryBackendStr: Reorder args and update comment

Frankly, this function is one big mess. A lot of arguments,
complicated behaviour. It's really surprising that arguments were
in random order (input and output arguments were mixed together),
the documentation was outdated, the description of return values
was bogus.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemuBuildMemoryBackendStr: Pass virDomainMemoryDefPtr
Michal Privoznik [Wed, 8 Mar 2017 15:56:23 +0000 (16:56 +0100)]
qemuBuildMemoryBackendStr: Pass virDomainMemoryDefPtr

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemuBuildMemoryBackendStr: Check for @memAccess properly
Michal Privoznik [Wed, 8 Mar 2017 14:58:26 +0000 (15:58 +0100)]
qemuBuildMemoryBackendStr: Check for @memAccess properly

Even though this variable contains just values from an enum where
zero has the usual meaning, it's enum after all and we should
check it as such.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemuBuildMemoryBackendStr: Don't overwrite @force
Michal Privoznik [Wed, 8 Mar 2017 14:56:36 +0000 (15:56 +0100)]
qemuBuildMemoryBackendStr: Don't overwrite @force

This is an input argument. We should not overwrite it.

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