Commit Graph

1366 Commits

Author SHA1 Message Date
Jiri Denemark
46c49a3004 cpu: Rename cpuHasFeature to virCPUDataCheckFeature
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-09-22 15:40:09 +02:00
Jiri Denemark
6b159239cc cpu: Introduce virCPUTranslate
The API is supposed to make sure the provided CPU definition does not
use a CPU model which is not supported by the hypervisor (if at all
possible, of course).

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-09-22 15:40:09 +02:00
Jiri Denemark
3b6be3c0c5 cpu: Rework cpuUpdate
The reworked API is now called virCPUUpdate and it should change the
provided CPU definition into a one which can be consumed by the QEMU
command line builder:

    - host-passthrough remains unchanged
    - host-model is turned into custom CPU with a model and features
      copied from host
    - custom CPU with minimum match is converted similarly to host-model
    - optional features are updated according to host's CPU

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-09-22 15:40:09 +02:00
Jiri Denemark
8fc6e7d824 conf: Introduce virCPUDefCopyModelFilter
The function filters all CPU features through a given callback while
copying CPU model related parts of a CPU definition.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-09-22 15:40:08 +02:00
Jiri Denemark
8e240afccb conf: Introduce virCPUDefStealModel
The function moves CPU model related parts from one CPU definition to
another. It can be used to avoid unnecessary copies from a temporary CPU
definitions which will be freed anyway.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-09-22 15:40:08 +02:00
Jiri Denemark
bcf46ddb3f conf: Introduce virCPUDefCopyWithoutModel
Useful for copying a CPU definition without model related parts (i.e.,
without model name, feature list, vendor).

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-09-22 15:40:08 +02:00
Jiri Denemark
d4c007e6d5 domcaps: Add CPU usable flag
In case a hypervisor is able to tell us a list of supported CPU models
and whether each CPU models can be used on the current host, we can
propagate this to domain capabilities. This is a better alternative
to calling virConnectCompareCPU for each supported CPU model.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-09-22 15:40:08 +02:00
Jiri Denemark
33f9ccc141 domcaps: Show only CPU models supported by libvirt
Listing all CPU models supported by QEMU in domain capabilities makes
little sense when libvirt will refuse any model it doesn't know about.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-09-22 15:40:08 +02:00
Jiri Denemark
167280e7f6 domcaps: Add support for listing supported CPU models
The patch adds <cpu> element to domain capabilities XML:

    <cpu>
        <mode name='host-passthrough' supported='yes'/>
        <mode name='host-model' supported='yes'/>
        <mode name='custom' supported='yes'>
            <model>Broadwell</model>
            <model>Broadwell-noTSX</model>
            ...
        </mode>
    </cpu>

Applications can use it to inspect what CPU configuration modes are
supported for a specific combination of domain type, emulator binary,
guest architecture and machine type.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-09-22 15:40:08 +02:00
Peter Krempa
4cc65b4967 conf: Introduce virDomainObjGetOneDefState
Return whether the live or persistent definition was returned. Sometimes
it's necessary to base the decisions on this.
2016-09-21 16:32:36 +02:00
Martin Kletzander
e5568193f4 conf: Add some shmem helpers for future use
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-09-20 15:42:43 +02:00
Tomáš Ryšavý
63f388c99d virhostcpu: Expose virHostCPUStatsAssign
We will need this function shortly when implementing
nodeGetCPUStats in the test driver.

Signed-off-by: Tomáš Ryšavý <tom.rysavy.0@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-09-15 15:28:22 +02:00
Peter Krempa
77cb01bc0f numa: Rename virNumaGetHostNodeset and make it return only nodes with memory
Name it virNumaGetHostMemoryNodeset and return only NUMA nodes which
have memory installed. This is necessary as the kernel is not very happy
to set the memory cgroup setting for nodes which do not have any memory.

This would break vcpu hotplug with following message on such
configruation:

  Invalid value '0,8' for 'cpuset.mems': Invalid argument

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1375268
2016-09-14 08:41:41 +02:00
Martin Kletzander
94e2be8424 audit: Audit information about shmem devices
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1218603

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-09-12 19:41:43 +02:00
Jiri Denemark
97a87333a0 Add helper for removing transient definition
The code for replacing domain's transient definition with the persistent
one is repeated in several places and we'll need to add one more. Let's
make a nice helper for it.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-09-08 22:25:22 +02:00
Daniel P. Berrange
fa1ce97917 qemu: add a max_core setting to qemu.conf for core dump size
Currently the QEMU processes inherit their core dump rlimit
from libvirtd, which is really suboptimal. This change allows
their limit to be directly controlled from qemu.conf instead.
2016-09-06 13:08:30 +01:00
Nikolay Shirokovskiy
c62e79c8ca qemu: Filter cur_balloon ABI check for certain transactions
Since the domain lock is not held during preparation of an external XML
config, it is possible that the value can change resulting in unexpected
failures during ABI consistency checking for some save and migrate
operations.

This patch adds a new flag to skip the checking of the cur_balloon value
and then sets the destination value to the source value to ensure
subsequent checks without the skip flag will succeed.

This way it is protected from forges and is keeped up to date too.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-09-02 16:54:42 -04:00
Cédric Bosdonnat
ea46e00f12 Add virHostdevFindUSBDevice to private symbols
Finding an USB device from the vendor/device values will be needed
by libxl driver to convert from vendor/device to bus/dev addresses.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2016-09-02 17:38:09 +02:00
Peter Krempa
c84c2cb389 util: Extract and rename qemuDomainDelCgroupForThread to virCgroupDelThread 2016-08-24 15:44:47 -04:00
Jovanka Gulicoska
43a6b37b24 Introduce node device update event as top level event
This event is emitted when a nodedev XML definition is updated,
like when cdrom media is changed in a cdrom block device.

Also includes node device update event implementation for udev
backend, virsh nodedev-event support, and event-test support
2016-08-15 08:30:56 -04:00
Jovanka Gulicoska
9806ae04dd conf: add node_device_event handling
Add node device event handling infrastructure to node_device_event.[ch]
2016-08-02 09:52:00 -04:00
John Ferlan
ae65c908b7 util: Introduce virISCSINodeNew
https://bugzilla.redhat.com/show_bug.cgi?id=1356436

According to RFC 3721 (https://www.ietf.org/rfc/rfc3721.txt), there are
two ways to "discover" targets in/for the iSCSI environment. Discovery
is the process which allows the initiator to find the targets to which
it has access and at least one address at which each target may be
accessed.

The method currently implemented in libvirt using the virISCSIScanTargets
API is known as "SendTargets" discovery. This method is more useful when
the target IP Address and TCP port information are available, e.g. in
libvirt terms the "portal". It returns a list of targets for the portal.
From that list, the target can be found. This operation can also fill an
iSCSI node table into which iSCSI logins may occur. Commit id '56057900'
altered that filling by adding the "--op nonpersistent" since it was
not necessarily desired to perform that for non libvirt related targets.

The second method is "Static Configuration". This method not only needs
the IP Address and TCP port (e.g. portal), but also the iSCSI target name.
In libvirt terms this would be the device path field from the iSCSI pool
<source> XML. This patch implements the second methodology using that
required device path as the targetname.
2016-07-28 08:27:13 -04:00
Peter Krempa
f444101729 qemu: command: Add infrastructure for object specified disk sources
To allow richer definitions of disk sources add infrastructure that will
allow to register functionst generating a JSON object based definition.

This infrastructure will then convert the definition to the proper
command line syntax and use it in cases where it's necessary. This will
allow to keep legacy definitions for back-compat when possible and use
the new definitions for the configurations requiring them.
2016-07-27 13:33:10 +02:00
Peter Krempa
74df83a9eb util: qemu: Add support for numbered array members
Add support for converting objects nested in arrays with a numbering
discriminator on the command line. This syntax is used for the
object-based specification of disk source properties.
2016-07-27 13:33:10 +02:00
Peter Krempa
b7eef33df2 util: qemu: Allow for different approaches to format JSON arrays
For use with memory hotplug virQEMUBuildCommandLineJSONRecurse attempted
to format JSON arrays as bitmap on the command line. Make the formatter
function configurable so that it can be reused with different syntaxes
of arrays such as numbered arrays for use with disk sources.

This patch extracts the code and adds a parameter for the function that
will allow to plug in different formatters.
2016-07-27 09:40:07 +02:00
Peter Krempa
f0276c3489 util: qemu: Add wrapper for JSON -> commandline conversion
Refactor the command line generator by adding a wrapper (with
documentation) that will handle the outermost object iteration.

This patch also renames the functions and tweaks the error message for
nested arrays to be more universal.

The new function is then reused to simplify qemucommandutiltest.
2016-07-27 09:39:46 +02:00
Peter Krempa
4e3dbfa2a5 tests: Add testing of backing store string parser
As we already test that the extraction of the backing store string works
well additional tests for the backing store string parser can be made
simpler.

Export virStorageSourceNewFromBackingAbsolute and use it to parse the
backing store strings, format them using virDomainDiskSourceFormat and
match them against expected XMLs.
2016-07-27 09:39:33 +02:00
John Ferlan
fc0378a973 Remove unnecessary virDomainDefClearDeviceAliases
Nothing in the code path after the removed call has needs/uses the alias
anyway (as would be the case for command line building or talking to monitor).
The alias is VIR_FREE'd in virDomainDeviceInfoClear which is called for any
device that needs/uses an alias via virDomainDeviceDefFree or virDomainDefFree
as well as during virDomainDeviceInfoFree for host devices.

For persistent domains, the domain definition (including aliases) gets
freed a few screens later when it's replaced with newDef.

For transient domains, the definition is freed/unref'd along with the
virDomainObj a few moments later.
2016-07-26 20:40:49 -04:00
John Ferlan
d95f5beb79 conf: Remove CCW,PCI clear address helpers
Since commit id 'fb06350' these are no longer called, so remove them
2016-07-26 20:40:49 -04:00
Tomasz Flendrich
40c284f0a6 add virDomainVirtioSerialAddrSetCreateFromDomain
The address sets (pci, ccw, virtio serial) are currently cached
in qemu private data, but all the information required to recreate
these sets is in the domain definition. Therefore I am removing
the redundant data and adding a way to recalculate these sets.

Add a function that calculates the virtio serial address set
from the domain definition.

Credit goes to Cole Robinson.
2016-07-26 13:04:46 +02:00
Ján Tomko
815d98ac0b Auto-add one hub if there are too many USB devices
When parsing a command line with USB devices that have
no address specified, QEMU automatically adds a USB hub
if the device would fill up all the available USB ports.

To help most of the users, add one hub if there are more
USB devices than available ports. For wilder configurations,
expect the user to provide us with more hubs and/or controllers.
2016-07-21 08:30:26 +02:00
Ján Tomko
f2a781ceb0 Assign addresses on USB device hotplug
USB disks, redirected devices, host devices and serial devices
are supported.
2016-07-21 08:30:26 +02:00
Ján Tomko
bf182078d9 Assign addresses to USB devices
Automatically assign addresses to USB devices.

Just like reserving, this is only done for newly defined domains.

https://bugzilla.redhat.com/show_bug.cgi?id=1215968
2016-07-21 08:30:26 +02:00
Ján Tomko
ddd31fd7dc Reserve existing USB addresses
Check if they fit on the USB controllers the domain has,
and error out if two devices try to use the same address.
2016-07-21 08:30:26 +02:00
Ján Tomko
6b3e4e2bea Add functions for adding USB controllers to addrs
Walk through all the usb controllers in the domain definition
and create the corresponding structures in the virDomainUSBAddressSet.
2016-07-21 08:30:26 +02:00
Ján Tomko
82c142b321 Introduce virDomainUSBAddressSet
A new type to track USB addresses.

Every <controller type='usb' index='i'/> is represented by an
object of type virDomainUSBAddressHub located at buses[i].

Each of these hubs has up to 'nports' ports.
If a port is occupied, it has the corresponding bit set in
the 'ports' bitmap, e.g. port 1 would have the 0th bit set.
If there is a hub on this port, then hubs[i] will point
to this hub.
2016-07-21 08:30:26 +02:00
John Ferlan
5e46d7d6b6 storage: Add support to create a luks volume
Partially resolves:
https://bugzilla.redhat.com/show_bug.cgi?id=1301021

If the volume xml was looking to create a luks volume take the necessary
steps in order to make that happen.

The processing will be:
 1. create a temporary file (virStorageBackendCreateQemuImgSecretPath)
   1a. use the storage driver state dir path that uses the pool and
       volume name as a base.

 2. create a secret object (virStorageBackendCreateQemuImgSecretObject)
   2a. use an alias combinding the volume name and "_luks0"
   2b. add the file to the object

 3. create/add luks options to the commandline (virQEMUBuildLuksOpts)
   3a. at the very least a "key-secret=%s" using the secret object alias
   3b. if found in the XML the various "cipher" and "ivgen" options

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-07-19 09:40:01 -04:00
John Ferlan
8215aab003 qemu: Move and rename qemuBufferEscapeComma
Move to virqemu and rename to virQEMUBuildBufferEscapeComma. This can then
be shared by the storage driver when it builds the command line for qemuimg
2016-07-19 07:13:09 -04:00
Olga Krishtal
da665fbd48 filesystem: adds possibility to use storage pool as fs source
Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com>
2016-07-18 23:39:56 +03:00
Ján Tomko
f820d5bf6f Store USB port path as an array of integers
In preparation to tracking which USB addresses are occupied.
Introduce two helper functions for printing the port path
as a string and appending it to a virBuffer.
2016-07-18 10:55:35 +02:00
Ján Tomko
ea0ed35d6e Introduce <iommu> device
A device with an attribute 'model', with just one model
so far:

<devices>
  ...
  <iommu model='intel'/>
</devices>

https://bugzilla.redhat.com/show_bug.cgi?id=1235580
2016-07-12 12:36:13 +02:00
Daniel P. Berrange
6381c89f8c virconf: add typed value accessor methods
Currently many users of virConf APIs are defining the same
macros for calling virConfValue() and then doing type
checking. To remove this repeated code, add a set of
typesafe accessor methods.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-07-12 09:57:01 +01:00
Peter Krempa
f3d3be3d48 conf: Isolate virDomainLiveConfigHelperMethod to libxl only
Libxl is the last user and I don't have the toolchain prepared to
compile the libxl driver. Move it to the libxl driver to avoid having to
refactor the code.
2016-07-07 08:57:05 +02:00
Erik Skultety
18c3321b8b virlog: Introduce virLogFilterFree
Provide a separate method to free a logging filter object. This will come handy
once a method to create an individual logging filter object is introduced.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-07-04 16:44:30 +02:00
Erik Skultety
4b48541249 virlog: Introduce virLogOutputListFree
This is just a convenience method for discarding a list of outputs instead of
using a 'for' loop everywhere. It is safe to pass -1 as the number of elements
in the list as well as passing NULL as list reference.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-07-04 16:44:20 +02:00
Erik Skultety
057788c537 virlog: Introduce virLogOutputFree
Provide a separate method to free a logging output object. This will come handy
once a method to create an individual logging output object is introduced.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-07-04 16:43:48 +02:00
Laine Stump
95309424ba util: new function virNetDevIPInfoAddToDev
This patch takes the code out of
lxcContainerRenameAndEnableInterfaces() that adds all IP addresses and
IP routes to the interface, and puts it into a utility function
virNetDevIPInfoAddToDev() in virnetdevip.c so that it can be used by
anyone.

One small change in functionality -
lxcContainerRenameAndEnableInterfaces() previously would add all IP
addresses to the interface while it was still offline, then set the
interface online, and then add the routes. Because I don't want the
utility function to set the interface online, I've moved this up so
the interface is first set online, then IP addresses and routes are
added. This is the same order that the network service from
initscripts (in ifup-ether) does it, so it shouldn't pose any problem
(and hasn't, in the tests that I've run).

(This patch had been pushed earlier in commit
f1e0d0da11, but was reverted in commit
05eab47559 because it had been
accidentally pushed during the freeze for release 2.0.0)
2016-07-01 21:13:30 -04:00
Laine Stump
b874f26b8b util: new function virXMLNodeSanitizeNamespaces()
This is a generic version of virDomainDefMetadataSanitize() - the same
functionality is now needed for network metadata.
2016-07-01 13:04:49 -04:00
Ján Tomko
492b3bfda1 Introduce virDomainUSBDeviceDefForeach
A helper that will execute a callback on every USB device
in the domain definition.

With an ability to skip USB hubs, since we will want to treat
them differently in some cases.
2016-07-01 12:25:18 +02:00
Ján Tomko
05eab47559 Revert "util: new function virNetDevIPInfoAddToDev"
This reverts commit f1e0d0da11.

This feature was accidentally pushed in the feature freeze.
2016-06-27 12:54:55 +02:00