]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
8 years agoqemu: capabilities: add capability for query-named-block-nodes qmp cmd
Peter Krempa [Wed, 15 Mar 2017 16:21:48 +0000 (17:21 +0100)]
qemu: capabilities: add capability for query-named-block-nodes qmp cmd

8 years agoqemu: implement qemuDomainSetBlockThreshold
Peter Krempa [Thu, 23 Feb 2017 12:50:24 +0000 (13:50 +0100)]
qemu: implement qemuDomainSetBlockThreshold

Add code to call the appropriate monitor command and code to lookup the
given disk backing chain member.

8 years agoqemu: domain: Add helper to look up disk soruce by the backing store string
Peter Krempa [Thu, 23 Feb 2017 18:14:47 +0000 (19:14 +0100)]
qemu: domain: Add helper to look up disk soruce by the backing store string

8 years agovirsh: Implement 'domblkthreshold' command to call virDomainSetBlockThreshold
Peter Krempa [Thu, 23 Feb 2017 12:27:18 +0000 (13:27 +0100)]
virsh: Implement 'domblkthreshold' command to call virDomainSetBlockThreshold

Add a simple wrapper which will allow to set the threshold for
delivering the event.

8 years agolib: Add API for setting the threshold size for VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD
Peter Krempa [Thu, 23 Feb 2017 12:09:12 +0000 (13:09 +0100)]
lib: Add API for setting the threshold size for VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD

The new API can be used to configure the threshold when
VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD should be fired.

8 years agoqemu: process: Wire up firing of the VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD event
Peter Krempa [Wed, 22 Feb 2017 16:51:26 +0000 (17:51 +0100)]
qemu: process: Wire up firing of the VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD event

Bind it to qemu's BLOCK_WRITE_THRESHOLD event. Look up the disk by
nodename and construct the string to return.

8 years agoqemu: domain: Add helper to generate indexed backing store names
Peter Krempa [Thu, 23 Feb 2017 17:13:02 +0000 (18:13 +0100)]
qemu: domain: Add helper to generate indexed backing store names

The code is currently simple, but if we later add node names, it will be
necessary to generate the names based on the node name. Add a helper so
that there's a central point to fix once we add self-generated node
names.

8 years agoqemu: domain: Add helper to lookup disk by node name
Peter Krempa [Wed, 22 Feb 2017 16:51:05 +0000 (17:51 +0100)]
qemu: domain: Add helper to lookup disk by node name

Looks up a disk and its corresponding backing chain element by node
name.

8 years agoqemu: monitor: Add support for BLOCK_WRITE_THRESHOLD event
Peter Krempa [Wed, 22 Feb 2017 15:52:22 +0000 (16:52 +0100)]
qemu: monitor: Add support for BLOCK_WRITE_THRESHOLD event

The event is fired when a given block backend node (identified by the
node name) experiences a write beyond the bound set via
block-set-write-threshold QMP command. This wires up the monitor code to
extract the data and allow us receiving the events and the capability.

8 years agolib: Introduce event for tracking disk backing file write threshold
Peter Krempa [Tue, 21 Feb 2017 14:03:07 +0000 (15:03 +0100)]
lib: Introduce event for tracking disk backing file write threshold

When using thin provisioning, management tools need to resize the disk
in certain cases. To avoid having them to poll disk usage introduce an
event which will be fired when a given offset of the storage is written
by the hypervisor. Together with the API which will be added later, it
will allow registering thresholds for given storage backing volumes and
this event will then notify management if the threshold is exceeded.

8 years agoutil: storage: Add variables for node names into virStorageSource
Peter Krempa [Wed, 22 Feb 2017 15:20:00 +0000 (16:20 +0100)]
util: storage: Add variables for node names into virStorageSource

'nodeformat' should be used for strings which describe the storage
format object, and 'nodebacking' for the actual storage object itself.

8 years agoutil: storage: Split out useful bits of virStorageFileParseChainIndex
Peter Krempa [Thu, 23 Feb 2017 16:10:43 +0000 (17:10 +0100)]
util: storage: Split out useful bits of virStorageFileParseChainIndex

The function has very specific semantics. Split out the part that parses
the backing store specification string into a separate helper so that it
can be reused later while keeping the wrapper with existing semantics.

Note that virStorageFileParseChainIndex is pretty well covered by the
test suite.

8 years agoutil: buffer: Add API to set indentation level to a given value
Peter Krempa [Thu, 9 Mar 2017 16:02:19 +0000 (17:02 +0100)]
util: buffer: Add API to set indentation level to a given value

It will be useful to set indentation level to 0 after formatting a
nested structure rather than having to track the depth.

8 years agoqemu: driver: Don't call qemuDomainDetermineDiskChain on block jobs
Peter Krempa [Wed, 15 Mar 2017 16:10:41 +0000 (17:10 +0100)]
qemu: driver: Don't call qemuDomainDetermineDiskChain on block jobs

Our code calls it when starting or re-starting the domain or when
hotplugging the disk so there's nothing to be detected.

8 years agobhyve: add xhci tablet support
Roman Bogorodskiy [Mon, 20 Mar 2017 13:58:51 +0000 (17:58 +0400)]
bhyve: add xhci tablet support

Along with video and VNC support, bhyve has introduced USB tablet
support as an input device. This tablet is exposed to a guest
as a device on an XHCI controller.

At present, tablet is the only supported device on the XHCI controller
in bhyve, so to make things simple, it's allowed to only have a
single XHCI controller with a single tablet device.

In detail, this commit:

 - Introduces a new capability bit for XHCI support in bhyve
 - Adds an XHCI controller and tabled support with 1:1 mapping
   between them
 - Adds a couple of unit tests

8 years agobhyve: helper function to probe hypervisor caps
Roman Bogorodskiy [Sun, 19 Mar 2017 13:40:52 +0000 (17:40 +0400)]
bhyve: helper function to probe hypervisor caps

There are a number of functions in bhyve_capabilities.c that probe
hypervisor capabilities by executing the bhyve(1) binary with the
specific device arugment, checking error message (if any) and setting
proper capability bit. As those are extremely similar, move this logic
into a helper function and convert existing functions to use that.

8 years agodomaincapstest: add bhyve caps test
Roman Bogorodskiy [Sat, 18 Mar 2017 20:17:13 +0000 (00:17 +0400)]
domaincapstest: add bhyve caps test

 * Extract filling bhyve capabilities from virBhyveDomainCapsBuild()
   into a new function virBhyveDomainCapsFill() to make testing
   easier by not having to mock firmware directory listing and
   hypervisor capabilities probing
 * Also, just presence of the firmware files is not sufficient
   to enable os.loader.supported, hypervisor should support UEFI
   boot too
 * Add tests to domaincapstest for the main caps possible flows:
    - when UEFI bootrom is supported
    - when video (fbus) is supported
    - neither of above is supported

8 years agoschema: domaincaps: make machine element optional
Roman Bogorodskiy [Sun, 26 Mar 2017 14:35:14 +0000 (18:35 +0400)]
schema: domaincaps: make machine element optional

Commit df769041c made the 'machine' element in domaincaps
optional. Update the schema to reflect that.

8 years agoqemu: fix build with clang
Roman Bogorodskiy [Sun, 26 Mar 2017 04:29:49 +0000 (08:29 +0400)]
qemu: fix build with clang

qemuMigrationResetTLS() does not initialize 'ret' by default,
so when it jumps to 'cleanup' on error, the 'ret' variable will be
uninitialized, which clang complains about.

Set it to '-1' by default.

8 years agovirpci: fix build on non-Linux
Roman Bogorodskiy [Sat, 25 Mar 2017 13:12:42 +0000 (17:12 +0400)]
virpci: fix build on non-Linux

virPCIGetDeviceAddressFromSysfsLink() should return
virPCIDeviceAddressPtr, so return NULL in the stub instead of "-1".

8 years agodocs: Add news entry for Migration using TLS
John Ferlan [Sat, 18 Mar 2017 13:44:23 +0000 (09:44 -0400)]
docs: Add news entry for Migration using TLS

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoqemu: Set up the migration TLS objects for source
John Ferlan [Thu, 16 Feb 2017 20:56:10 +0000 (15:56 -0500)]
qemu: Set up the migration TLS objects for source

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

If the migration flags indicate this migration will be using TLS,
then while we have connection in the Begin phase check and setup the
TLS environment that will be used by virMigrationRun during the Perform
phase for the source to configure TLS.

Processing adds an "-object tls-creds-x509,endpoint=client,..." and
possibly an "-object secret,..." to handle the passphrase response.

Then it sets the 'tls-creds' and possibly 'tls-hostname' migration
parameters.

The qemuMigrateCancel will clean up and reset the environment as it
was originally found.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoqemu: Set up the migration TLS objects for target
John Ferlan [Fri, 3 Mar 2017 12:22:16 +0000 (07:22 -0500)]
qemu: Set up the migration TLS objects for target

If the migration flags indicate this migration will be using TLS,
then set up the destination during the prepare phase once the target
domain has been started to add the TLS objects to perform the migration.

This will create at least an "-object tls-creds-x509,endpoint=server,..."
for TLS credentials and potentially an "-object secret,..." to handle the
passphrase response to access the TLS credentials. The alias/id used for
the TLS objects will contain "libvirt_migrate".

Once the objects are created, the code will set the "tls-creds" and
"tls-hostname" migration parameters to signify usage of TLS.

During the Finish phase we'll be sure to attempt to clear the
migration parameters and delete those objects (whether or not they
were created). We'll also perform the same reset during recovery
if we've reached FINISH3.

If the migration isn't using TLS, then be sure to check if the
migration parameters exist and clear them if so.

8 years agoqemu: Add job for qemuDomain{Add|Del}TLSObjects
John Ferlan [Thu, 9 Mar 2017 14:20:27 +0000 (09:20 -0500)]
qemu: Add job for qemuDomain{Add|Del}TLSObjects

Add an asyncJob argument for add/delete TLS Objects. A future patch will
add/delete TLS objects from a migration which may have a job to join.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoqemu: Add TLS params to _qemuMonitorMigrationParams
John Ferlan [Thu, 16 Feb 2017 23:33:22 +0000 (18:33 -0500)]
qemu: Add TLS params to _qemuMonitorMigrationParams

Add the fields to support setting tls-creds and tls-hostname during
a migration (either source or target). Modify the query migration
function to check for the presence and set the field for future
consumers to determine which of 3 conditions is being met (NULL,
present and set to "", or present and sent to something). These
correspond to qemu commit id '4af245dc3' which added support to
default the value to "" and allow setting (or resetting) to ""
in order to disable. This reset option allows libvirt to properly
use the tls-creds and tls-hostname parameters.

Modify code paths that either allocate or use stack space in order
to call qemuMigrationParamsClear or qemuMigrationParamsFree for cleanup.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoAdd new migration flag VIR_MIGRATE_TLS
John Ferlan [Wed, 15 Feb 2017 13:58:46 +0000 (08:58 -0500)]
Add new migration flag VIR_MIGRATE_TLS

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoqemu: Update the TLS client verify descriptions for vnc and chardev
John Ferlan [Thu, 23 Mar 2017 19:11:51 +0000 (15:11 -0400)]
qemu: Update the TLS client verify descriptions for vnc and chardev

Update the descriptions to match the migrate option.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Introduce migrate_tls_x509_cert_dir
John Ferlan [Fri, 24 Feb 2017 21:44:32 +0000 (16:44 -0500)]
conf: Introduce migrate_tls_x509_cert_dir

Add a new TLS X.509 certificate type - "migrate". This will handle the
creation of a TLS certificate capability (and possibly repository) to
be used for migrations. Similar to chardev's, credentials will be handled
via a libvirt secrets; however, unlike chardev's enablement and usage
will be via a CLI flag instead of a conf flag and a domain XML attribute.

The migrations using the *x509_verify flag require the client-cert.pem
and client-key.pem files to be present in the TLS directory - so let's
also be sure to note that in the qemu.conf file.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoqemu: Replace macro usage of (false); with just (0)
John Ferlan [Thu, 23 Mar 2017 19:00:54 +0000 (15:00 -0400)]
qemu: Replace macro usage of (false); with just (0)

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoqemu: Create #define for TLS configuration setup.
John Ferlan [Sun, 12 Feb 2017 14:54:48 +0000 (09:54 -0500)]
qemu: Create #define for TLS configuration setup.

Create GET_CONFIG_TLS_CERT to set up the TLS for 'chardev' TLS setting.
Soon to be reused.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoutil: fix build on non-Linux
Roman Bogorodskiy [Sat, 25 Mar 2017 04:24:21 +0000 (08:24 +0400)]
util: fix build on non-Linux

Fix typo in virNetDevPFGetVF() stub:

  ATTRUBUTE_UNUSED -> ATTRIBUTE_UNUSED.

While here, use common indent style for arguments in
virNetDevGetVirtualFunctionIndex() stub.

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>