Commit Graph

1580 Commits

Author SHA1 Message Date
Andrea Bolognani
1d0c6f59b6 conf: Rename virDomainHostdevDefAlloc() to virDomainHostdevDefNew()
All other virDomain*Def follow this naming convention for
their allocation function.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2017-07-21 17:03:43 +02:00
Peter Krempa
a908e9e45e util: bitmap: Modify virBitmapSubtract to virBitmapIntersect
Since virBitmapSubtract is unused modify it to perform bitmap
intersection.
2017-07-20 16:14:50 +02:00
Antoine Millet
e484cb3eca Handle hotplug change on VLAN configuration using OVS
A new function virNetDevOpenvswitchUpdateVlan has been created to instruct
OVS of the changes. qemuDomainChangeNet has been modified to handle the
update of the VLAN configuration for a running guest and rely on
virNetDevOpenvswitchUpdateVlan to do the actual update if needed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-07-20 15:15:03 +02:00
John Ferlan
dae23ec345 nodedev: Convert virNodeDeviceObj to use virObjectLockable
Now that we have a bit more control, let's convert our object into
a lockable object and let that magic handle the create and lock/unlock.

This also involves creating a virNodeDeviceEndAPI in order to handle
the object cleanup for API's that use the Add or Find API's in order
to get a locked/reffed object. The EndAPI will unlock and unref the
object returning NULL to indicate to the caller to not use the obj.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-07-17 10:40:24 -04:00
John Ferlan
1c7bc64ef3 nodedev: Introduce virNodeDeviceObjListFindSCSIHostByWWNs
In an overall effort to privatize access to virNodeDeviceObj and
virNodeDeviceObjList into the virnodedeviceobj module, move the
object list parsing from node_device_driver and replace with a
call to a virnodedeviceobj helper. This follows other similar
APIs/helpers which peruse the object list looking for some specific
data in order to get/return an @device (virNodeDevice) object to
the caller.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-07-17 10:40:24 -04:00
John Ferlan
12fa16eb98 nodedev: Introduce virNodeDeviceGetSCSIHostCaps
We're about to move the call to nodeDeviceSysfsGetSCSIHostCaps from
node_device_driver into virnodedeviceobj, so move the guts of the code
from the driver specific node_device_linux_sysfs into its own API
since virnodedeviceobj cannot callback into the driver.

Nothing in the code deals with sysfs anyway, as that's hidden by the
various virSCSIHost* and virVHBA* utility function calls.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-07-17 10:40:24 -04:00
John Ferlan
881a486a7d nodedev: Alter node device obj list function names
Ensure that any function that walks the node device object list is prefixed
by virNodeDeviceObjList.

Also, modify the @filter param name for virNodeDeviceObjListExport to
be @aclfilter.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-07-17 10:40:24 -04:00
John Ferlan
9c5d98fd83 nodedev: Introduce virNodeDeviceObjListNew
In preparation to make things private, make the ->devs be pointers to a
virNodeDeviceObjList and then manage everything inside virnodedeviceobj

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-07-17 10:40:24 -04:00
John Ferlan
87e50c9cea nodedev: Alter virNodeDeviceObjRemove
Rather than passing the object to be removed by reference, pass by value
and then let the caller decide whether or not the object should be free'd
and how to handle the logic afterwards. This includes free'ing the object
and/or setting the local variable to NULL to prevent subsequent unexpected
usage (via something like virNodeDeviceObjRemove in testNodeDeviceDestroy).

For now this function will just handle the remove of the object from the
list for which it was placed during virNodeDeviceObjAssignDef.

This essentially reverts logic from commit id '61148074' that free'd the
device entry on list, set *dev = NULL and returned. Thus fixing a bug in
node_device_hal.c/dev_refresh() which would never call dev_create(udi)
since @dev would have been set to NULL.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-07-17 10:40:24 -04:00
John Ferlan
8a75cc4fcc nwfilter: Introduce virNWFilterObjListFindInstantiateFilter
Create a common API to handle the instantiation path filter lookup.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-07-15 23:00:30 -04:00
Andrea Bolognani
6e42d83f7c qemu: Automatically pick target index and model for pci-root controllers
pSeries guests will soon need the new information; luckily,
we can figure it out automatically most of the time, so
users won't have to worry about it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
2017-07-15 14:50:42 +02:00
Andrea Bolognani
c7af505ace conf: Make virDomainPCIAddressFlagsCompatible() private
There are no external users.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
2017-07-15 14:50:42 +02:00
Andrea Bolognani
03776fe0d6 conf: Make virDomainPCIAddressSetGrow() private
There are no external users.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
2017-07-15 14:50:42 +02:00
Andrea Bolognani
c79f97c83c conf: Move virDomainPCIAddressBusIsFullyReserved()
This function was private to the QEMU driver and was,
accordingly, called qemuDomainPCIBusFullyReserved().

However the function is really not QEMU-specific at
all, so it makes sense to move it closer to the
virDomainPCIAddressBus struct it operates on.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
2017-07-15 14:50:42 +02:00
Peter Krempa
9756884d14 conf: Pre-fill default ports when parsing network disk sources
Fill them in right away rather than having to figure out at runtime
whether they are necessary or not.

virStorageSourceNetworkDefaultPort does not need to be exported any
more.
2017-07-14 16:05:46 +02:00
Peter Krempa
34ffc2ff41 util: Extract helper to retrieve default port for network protocol
Make the stuff hardcoded in qemu a global helper so that other parts of
the code can determine the default port too.
2017-07-14 16:05:46 +02:00
Michal Privoznik
37ef8763c4 conf: Rename and expose virDomainChrSourceDefPath
It comes very handy to have source path for chardevs. We already
have such function: virDomainAuditChardevPath() but it's static
and has name not suitable for exposing. Moreover, while exposing
it change its name slightly to virDomainChrSourceDefGetPath.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-07-11 14:45:15 +02:00
Peter Krempa
de75de7c97 util: Move JSON object deflattening code to json utility file
The code will become more universal so it makes more sense for it to
live with the rest of the JSON functions.
2017-07-11 14:02:28 +02:00
Peter Krempa
cadd96b3ea util: json: Add virJSONValueIsObject
Allows testing whether a virJSONValue is an object.
2017-07-11 14:02:28 +02:00
Roman Bogorodskiy
78fc843c7b bhyve: add vga configuration for video driver
Add support for vgaconf driver configuration. In domain xml it looks like
this:

  <video>
    <driver vgaconf='io|on|off'>
    <model .../>
  </video>

It was added with bhyve gop video in mind to allow users control how the
video device is exposed to the guest, specifically, how VGA I/O is
handled.

One can refer to the bhyve manual page to get more detailed description
of the possible VGA configuration options:

https://www.freebsd.org/cgi/man.cgi?query=bhyve&manpath=FreeBSD+12-current

The relevant part could be found using the 'vgaconf' keyword.

Also, add some tests for this new feature.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-06-27 17:44:27 +04:00
Peter Krempa
e4c3eff70e util: storage: Export virStorageIsRelative 2017-06-20 13:25:55 +02:00
Pavel Hrdina
9fd816ed33 Revert "util: virqemu: introduce virQEMUBuildBufferEscape"
This reverts commit 22b02f4492.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2017-06-12 12:45:42 +02:00
Jiri Denemark
ea6d898311 qemu: Remember CPU def from domain start
When starting a domain we update the guest CPU definition to match what
QEMU actually provided (since it is allowed to add or removed some
features unless check='full' is specified). Let's store the original CPU
in domain private data so that we can use it to provide a backward
compatible domain XML.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-06-07 13:36:02 +02:00
Jiri Denemark
25af7e950a conf: Add save cookie callbacks to xmlopt
virDomainXMLOption gains driver specific callbacks for parsing and
formatting save cookies.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-06-07 13:36:01 +02:00
Jiri Denemark
e37daa1fb6 conf: Introduce virSaveCookie
The code will be used by snapshots and domain save/restore code to store
additional data for a saved running domain. It is analogous to migration
cookies, but simple and one way only.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-06-07 13:36:01 +02:00
John Ferlan
46f5eca4b2 interface: Convert virInterfaceObj to use virObjectLockable
Now that we have a bit more control, let's convert our object into
a lockable object and let that magic handle the create and lock/unlock.

This commit also introduces virInterfaceObjEndAPI in order to handle the
lock unlock and object unref in one call for consumers returning a NULL
obj upon return. This removes the need for virInterfaceObj{Lock|Unlock}
external API's.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-06-06 12:05:00 -04:00
Michal Privoznik
7b4e9b2c55 virQEMUDriverDomainABIStability: Check for memoryBacking
https://bugzilla.redhat.com/show_bug.cgi?id=1450349

Problem is, qemu fails to load guest memory image if these
attribute change on migration/restore from an image.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-06-05 09:18:34 +02:00
John Ferlan
922af89e44 nodedev: Introduce virNodeDeviceObjGetDef
In preparation for privatizing the virNodeDeviceObj - create an accessor
for the @def field and then use it for various callers.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-06-03 08:34:35 -04:00
John Ferlan
e2f3e6c38e interface: Rename some virInterfaceObj* API's
Prefix should have been virInterfaceObjList since the API is operating
on the list of interfaces.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-06-02 15:50:14 -04:00
John Ferlan
5374a1ca80 interface: Make _virInterfaceObjList struct private
Move the structs into virinterfaceobj.c, create necessary accessors, and
initializers.

This also includes reworking virInterfaceObjListClone to handle receiving
a source interfaces list pointer, creating the destination interfaces object,
and copying everything from source into dest.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-06-02 15:50:14 -04:00
John Ferlan
3b6de6c0cb interface: Make _virInterfaceObj struct private
Move the struct into virinterfaceobj.c, create necessary accessors, and
initializers.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-06-02 15:50:14 -04:00
Bjoern Walk
c47a3b130d util: helper functions for fibre channel devices
We will need some convenient helper functions for managing sysfs-entries
for fibre channel-backed devices. Let's implement them and make them
available in the private API.

Signed-off-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
2017-05-26 10:44:05 -04:00
Erik Skultety
500cbc066a nodedev: Introduce the mdev capability to a PCI parent device
The parent device needs to report the generic stuff about the supported
mediated devices types, like device API, available instances, type name,
etc. Therefore this patch introduces a new nested capability element of
type 'mdev_types' with the resulting XML of the following format:

<device>
  ...
  <capability type='pci'>
    ...
    <capability type='mdev_types'>
      <type id='vendor_supplied_id'>
        <name>optional_vendor_supplied_codename</name>
        <deviceAPI>vfio-pci</deviceAPI>
        <availableInstances>NUM</availableInstances>
      </type>
        ...
      <type>
        ...
      </type>
    </capability>
  </capability>
  ...
</device>

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

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2017-05-18 12:21:33 +02:00
Michal Privoznik
84b5079232 Introduce virStreamInData
This is just an internal API, that calls corresponding function
in stream driver. This function will set @data = 1 if the
underlying file is in data section, or @data = 0 if it is in a
hole. At any rate, @length is set to number of bytes remaining in
the section the file currently is.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-05-18 07:42:13 +02:00
Michal Privoznik
b928d140f4 util: Introduce virFileInData
This function takes a FD and determines whether the current
position is in data section or in a hole. In addition to that,
it also determines how much bytes are there remaining till the
current section ends.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-05-18 07:42:13 +02:00
Pavel Hrdina
0918b84968 util: introduce virBufferEscapeRegex
Add a helper to escape all possible meta-characters used for
POSIX extended regular expressions.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-05-12 16:54:33 +02:00
Pavel Hrdina
f15f155403 util: introduce virStringMatch
Simply tries to match the provided regex on a string and returns
the result.  Useful if caller don't care about the matched substring
and want to just test if some pattern patches a string.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-05-12 16:51:18 +02:00
Daniel P. Berrange
1a77b97c7f Don't inline virStringTrimOptionalNewline
GCC complains that inlining virStringTrimOptionalNewline is not
likely on some platforms:

  cc1: warnings being treated as errors
  ../../src/util/virfile.c: In function 'virFileReadValueBitmap':
  ../../src/util/virstring.h:292: error: inlining failed in call to 'virStringTrimOptionalNewline': call is unlikely and code size would grow [-Winline]
  ../../src/util/virfile.c:3987: error: called from here [-Winline]

Inlining this function is not going to be a measurable performance
benefit either, since the time required to execute it is going to
be dominated by running of strlen() over the string, not by the
function call overhead.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2017-05-10 09:25:45 +01:00
Martin Kletzander
4ad6a73bfc Add host cache information in capabilities
We're only adding only info about L3 caches, we can add more
later (just by changing one line), but for now that's more than enough
without overwhelming anyone.

XML snippet of how this should look like (also seen as part of the commit):

  <cache>
    <bank id='0' level='3' type='both' size='8192' unit='KiB' cpus='0-7'/>
  </cache>

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-05-09 13:12:40 +02:00
Martin Kletzander
7008e10869 util: Remove virsysfs and instead enhance virFileReadValue* functions
It is no longer needed thanks to the great virfilewrapper.c.  And this
way we don't have to add a new set of functions for each prefixed
path.

While on that, add two functions that weren't there before, string and
scaled integer reading ones.  Also increase the length of the string
being read by one to accompany for the optional newline at the
end (i.e. change INT_STRLEN_BOUND to INT_BUFSIZE_BOUND).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-05-09 13:12:40 +02:00
Jiri Denemark
a646a6016a Add support for CPU cache specification
This patch introduces

    <cache level='N' mode='emulate'/>
    <cache mode='passthrough'/>
    <cache mode='disable'/>

sub element of /domain/cpu. Currently only a single <cache> element is
allowed.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-04-27 22:07:14 +02:00
John Ferlan
119a6b3071 nwfilter: Replace virNWFilterSaveDef with virNWFilterSaveConfig
Essentially virNWFilterSaveDef executed in a different order the same
sequence of calls, so let's just make one point of reference.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-04-26 13:13:18 -04:00
John Ferlan
6181e404d9 nwfilter: Make _virNWFilterObjList private
Move from virnwfilterobj.h to virnwfilterobj.c.

Create the virNWFilterObjListNew() API in order to allocate.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-04-26 13:13:18 -04:00
John Ferlan
5ebe530e09 nwfilter: Rename some virNWFilterObj* API's
Prefix should have been virNWFilterObjList since the API is operating on
the list of filters.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-04-26 13:13:18 -04:00
John Ferlan
4b6264508f nwfilter: Make _virNWFilterObjPtr private
Move the structure to virnwfilterobj.c and create necessary accessor API's
for the various fields.

Also make virNWFilterObjFree static since there's no external callers.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-04-26 13:13:18 -04:00
Martin Kletzander
652ef9bc8c util: Add virNetDevSetCoalesce function
That function is able to configure coalesce settings for an interface,
similarly to 'ethtool -C'.  This function also updates back the
structure so that it contains actual data on the device (if the device
doesn't support some settings kernel might just return 0 and not set
whatever is not supported), so this way we'll have up-to-date
information in the live domain XML.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-04-21 13:29:39 +02:00
Jiri Denemark
bf1a881715 cpu: Introduce virCPUGetHostIsSupported
Sometimes we want to call virCPUGetHost only when it is implemented for
a given architecture to avoid logging expected and possibly misleading
errors. The new virCPUGetHostIsSupported API may be used to guard such
calls to virCPUGetHost.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-04-19 16:36:38 +02:00
John Ferlan
bd13b26da2 network: Use consistent function name prefixes for virnetworkobj
Use "virNetworkObj" as a prefix for any external API in virnetworkobj.

Also a couple of functions were local to virnetworkobj.c, so remove their
external defs in virnetworkobj.h.
2017-04-18 20:25:38 -04:00
John Ferlan
4726020bc0 network: Rename virNetworkObjAssignDef to virNetworkObjUpdateAssignDef
Rename the API to be a better description of what it does. Besides, a
subsequent patch will rename virNetworkAssignDef to virNetworkObjAssignDef
so rather than make that patch confusing we'll take the intermittent step
in this patch.
2017-04-18 20:25:35 -04:00
John Ferlan
bddbda99df network: Introduce virnetworkobj
Move all the virNetworkObj related API/data structures into their own
modules virnetworkobj.{c,h} from the network_conf.{c,h}

Purely code motion at this point plus adjustments to cleanly build
2017-04-18 20:25:18 -04:00