Commit Graph

1491 Commits

Author SHA1 Message Date
Laine Stump
251d179bf2 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().
2017-03-24 00:38:21 -04:00
Laine Stump
9a238c16b3 util: make virPCIGetDeviceAddressFromSysfsLink() public
This function will be useful in virnetdev.c, so promote it from static.
2017-03-24 00:37:36 -04:00
Laine Stump
a454134951 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.
2017-03-22 12:16:51 -04:00
Laine Stump
e75f5bfbe8 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.
2017-03-22 12:12:52 -04:00
Cédric Bosdonnat
00d28a78b5 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.
2017-03-22 09:01:33 +01:00
Cédric Bosdonnat
5dd607059d util: add virNetDevGetName() function
Add a function getting the name of a network interface out of its index.
2017-03-22 09:01:33 +01:00
Cédric Bosdonnat
754515b7db 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.
2017-03-22 09:01:32 +01:00
John Ferlan
a6d681485f 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>
2017-03-17 14:40:09 -04:00
John Ferlan
7c151e3398 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>
2017-03-17 14:40:09 -04:00
Jiri Denemark
def9401acb 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>
2017-03-17 11:50:48 +01:00
John Ferlan
106930aaa7 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>
2017-03-15 21:17:47 -04:00
John Ferlan
97e0d3c3c9 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>
2017-03-15 21:17:47 -04:00
John Ferlan
a7ce03c736 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>
2017-03-15 21:17:47 -04:00
John Ferlan
1e21c04054 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>
2017-03-15 21:17:47 -04:00
John Ferlan
f632e017c0 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>
2017-03-15 21:17:47 -04:00
Michal Privoznik
0064c4e2bc 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>
2017-03-15 16:45:53 +01:00
Jiri Denemark
23a3f5f50c cpu: Replace cpuNodeData with virCPUGetHost
cpuNodeData has always been followed by cpuDecode as no hypervisor
driver is really interested in raw CPUID data for a host CPU. Let's
create a new CPU driver API which returns virCPUDefPtr directly.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-03-13 23:49:57 +01:00
John Ferlan
62bc956786 conf: Use consistent function name prefixes for virnwfilterobj
Use "virNWFilterObj" as a prefix for any external API in virnwfilterobj
2017-03-07 13:27:25 -05:00
John Ferlan
079747a36d conf: Introduce virnwfilterobj
Move all the NWFilterObj API's into their own module virnwfilterobj
from the nwfilter_conf

Purely code motion at this point, plus adjustments to cleanly build.
2017-03-07 13:27:25 -05:00
John Ferlan
cab7b8c276 conf: Change virNWFilterObjDeleteDef to virNWFilterDeleteDef
Rather than pass the nwfilter object, just pass the def to the function
2017-03-07 13:27:25 -05:00
John Ferlan
22426736b9 conf: Change virNWFilterObjSaveDef to virNWFilterSaveDef
There's no need to pass the driver pointer to nwfilter_conf, just
pass the configDir.
2017-03-07 13:27:24 -05:00
Peter Krempa
b38c6b6ad3 util: sysinfo: Reduce amount of conditionally compiled code
Whole implementations along with helper totalling screens of code were
conditionally compiled. That made the code totally unreadable and
untestable. Rename functions to have the architecture in the name so
that all can be compiled at the same time and introduce header to allow
testing them all.
2017-03-07 10:44:26 +01:00
Ján Tomko
f10bd740e1 Cache the presence of machine1 service
After the system has been booted, it should not change.

Cache the return value of virSystemdHasMachined.
Allow starting and terminating machines with just one
DBus call, instead of three, reducing the chance of
the call timing out.

Also introduce a small function for resetting the cache
to be used in tests.
2017-03-06 15:44:33 +01:00
John Ferlan
e858232e4d conf: Use consistent function name prefixes for virinterfaceobj
Use "virInterfaceObj" as a prefix for any external API in virinterfaceobj
2017-03-06 07:07:01 -05:00
John Ferlan
eabeff8ea3 conf: Introduce virinterfaceobj
Move all the InterfaceObj API's into their own module virinterfaceobj
from the interface_conf

Purely code motion at this point.
2017-03-06 07:07:01 -05:00
John Ferlan
0a5cc56d92 conf: Use consistent function name prefixes for virnodedeviceobj
Use "virNodeDeviceObj" as a prefix for any external API in virnodedeviceobj
2017-03-03 18:36:09 -05:00
John Ferlan
bc20200e53 conf: Introduce virnodedeviceobj
Move all the NodeDeviceObj API's into their own module virnodedeviceobj
from the node_device_conf

Purely code motion at this point, plus adjustments to cleanly build.
2017-03-03 18:36:09 -05:00
Jiri Denemark
14aeba2dfd cpu_x86: Introduce virCPUx86DataAddFeature
The API is useful for creating virCPUData in a hypervisor driver from
data we got by querying the hypervisor.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-02-24 14:10:57 +01:00
Jiri Denemark
8da3ca8419 cpu_x86: Introduce virCPUx86DataSetVendor
The API is useful for creating virCPUData in a hypervisor driver from
data we got by querying the hypervisor.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-02-24 14:10:57 +01:00
Jiri Denemark
f358a75ab3 cpu_x86: Introduce virCPUx86DataSetSignature
The API is useful for creating virCPUData in a hypervisor driver from
data we got by querying the hypervisor.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-02-24 14:10:57 +01:00
Jiri Denemark
f6d55a5f42 cpu: Rework cpuDataFree
The new API is called virCPUDataFree. Individual CPU drivers are no
longer required to implement their own freeing function unless they need
to free architecture specific data from virCPUData.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-02-24 14:10:57 +01:00
Jiri Denemark
5acdd4a6b4 cpu_x86: Make virCPUx86DataClear static
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-02-24 14:10:57 +01:00
Jiri Denemark
035d81b10a cpu_x86: Drop virCPUx86MakeData and use virCPUDataNew
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-02-24 14:10:57 +01:00
Pavel Hrdina
22b02f4492 util: virqemu: introduce virQEMUBuildBufferEscape
This will eventually replace virQEMUBuildBufferEscapeComma, however
it's not possible right now.  Some parts of the code that uses the
old function needs to be refactored.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-02-24 12:58:48 +01:00
Pavel Hrdina
726403461b util: virbuffer: introduce virBufferEscapeN
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-02-24 12:58:23 +01:00
Jiri Denemark
4cd9545d89 cpu: Introduce virCPUDataNew
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-02-22 12:09:00 +01:00
John Ferlan
7ad479d0bd nodedev: Rework virNodeDeviceGetParentHost
Rework the code to perform the various searches by parent, parent_wwnn/
parent_wwpn, parent_fabric_wwn, or vport capable in order to return the
'parent_host' number that is vHBA capable.

The former virNodeDeviceGetParentHost is renamed to add the ByParent
on it fixes an issue where if no parent was supplied in the XML to
create the vHBA, then virNodeDeviceFindByName was called with a NULL
second parameter which had bad results.

The reworked code will make the various calls to fetch the NPIV host
by the passed parameter options or if none are provided find a vport
capable NPIV HBA to perform the create. If the call is from the delete
path, then this option won't be allowed.

Each of virNodeDeviceGetParentHostBy* functions is now static, so
remove them external definitions.

A secondary benefit of this is the test_driver now can make use of
the new API to add some new tests to test the various creation options.
2017-02-19 06:45:09 -05:00
John Ferlan
03346def06 util: Move scsi_host specific functions from virutil
Create a virscsihost.c and place the functions there. That removes the
last #ifdef __linux__ from virutil.c.

Take the opporunity to also change the function names and in one case
the parameters slightly
2017-02-19 06:45:09 -05:00
John Ferlan
d2d74a986d util: Replace virStoragePoolGetVhbaSCSIHostParent
Use the new virNodeDeviceGetParentName instead. Modify the callers to
build the node device scsi_host# name string in order to call the new
function so that proper lookup occurs.
2017-02-19 06:45:09 -05:00
John Ferlan
aa6aa624ad nodedev: Introduce virNodeDeviceGetParentName
Create a function which takes a node device "name" entry to lookup
and returns a string containing the parent name for the node device.
2017-02-19 06:45:09 -05:00
John Ferlan
16416816c1 util: Create a new virvhba module and move/rename API's
Rather than have them mixed in with the virutil apis, create a separate
virvhba.c module and move the vHBA related calls into there. Soon there
will be more added.

Also modify the names of the functions and some arguments to be more
indicative of what is really happening. Adjust the callers respectively.

While I was changing fchosttest, rather than the non-descriptive names
test1...test6, rename them to match what the test is doing.
2017-02-19 06:45:09 -05:00
Erik Skultety
875894245a util: Introduce virFileComparePaths
So rather than comparing 2 paths (strings) as they are, which can very
easily lead to unnecessary errors (e.g. in storage driver) that the paths
are not the same when in fact they'd be e.g. just symlinks to the same
location, we should put our best effort into resolving any symlinks and
canonicalizing the path and only then compare the 2 paths for equality.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2017-02-10 17:01:12 +01:00
Boris Fiuczynski
f4d06ca8fd network: allow to specify timeout for openvswitch calls
This patchs allows to set the timeout value used for all
openvswitch calls. The default timeout value remains as
before at 5 seconds.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-02-09 14:34:08 +01:00
Michal Privoznik
6094169b83 util: Introduce virFileReadLink
We will need to traverse the symlinks one step at the time.
Therefore we need to see where a symlink is pointing to.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-02-07 10:40:53 +01:00
Martin Kletzander
eae7cfd42d conf: Add virDomainDiskSetBlockIOTune
That function sets disk->blkdeviotune sensibly.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-01-31 20:19:35 +01:00
Michal Privoznik
57b5e27d3d qemu: set default vhost-user ifname
Based on work of Mehdi Abaakouk <sileht@sileht.net>.

When parsing vhost-user interface XML and no ifname is found we
can try to fill it in in post parse callback. The way this works
is we try to make up interface name from given socket path and
then ask openvswitch whether it knows the interface.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-01-20 15:42:12 +01:00
Peter Krempa
15727562a6 util: json: Add helper to reformat JSON strings
For use in test cases it will be helpful to allow reformatting JSON
strings. Add a wrapper on top of the parser and formatter to achieve
this.
2017-01-18 09:57:06 +01:00
Michal Privoznik
41816751a7 util: Introduce virFileMoveMount
This is a simple wrapper over mount(). However, not every system
out there is capable of moving a mount point. Therefore, instead
of having to deal with this fact in all the places of our code we
can have a simple wrapper and deal with this fact at just one
place.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-01-11 18:06:30 +01:00
Michal Privoznik
083fcd06d3 lxc: Move lxcContainerAvailable to virprocess
Other drivers (like qemu) would like to know if the namespaces
are available therefore it makes sense to move this function to
a shared module.

At the same time, this function had some default namespaces that
are checked with every call. It is not necessary - let callers
pass just those namespaces they are interested in.

With the move the function is renamed to
virProcessNamespaceAvailable.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-01-11 18:02:35 +01:00
Laine Stump
5949b53aec conf: eliminate virDomainPCIAddressReleaseSlot() in favor of ...Addr()
Surprisingly there was a virDomainPCIAddressReleaseAddr() function
already, but it was completely unused. Since we don't reserve entire
slots at once any more, there is no need to release entire slots
either, so we just replace the single call to
virDomainPCIAddressReleaseSlot() with a call to
virDomainPCIAddressReleaseAddr() and remove the now unused function.

The keen observer may be concerned that ...Addr() doesn't call
virDomainPCIAddressValidate(), as ...Slot() did. But really the
validation was pointless anyway - if the device hadn't been suitable
to be connected at that address, it would have failed validation
before every being reserved in the first place, so by definition it
will pass validation when it is being unplugged. (And anyway, even if
something "bad" happened and we managed to have a device incorrectly
at the given address, we would still want to be able to free it up for
use by a device that *did* validate properly).
2017-01-11 05:00:34 -05:00