Commit Graph

1511 Commits

Author SHA1 Message Date
Mehdi Abaakouk
9b6de7c506 virstat: fix signature of virstat helper
In preparation to the code move to virnetdevtap.c, this change:

* renames virNetInterfaceStats to virNetDevTapInterfaceStats
* changes 'path' to 'ifname', to use the same vocable as other
  method in virnetdevtap.c.
* Add the attributes checker
2016-12-09 10:27:56 +01:00
Mehdi Abaakouk
013df874db Gathering vhostuser interface stats with ovs
When vhostuser interfaces are used, the interface statistics
are not available in /proc/net/dev.

This change looks at the openvswitch interfaces statistics
tables to provide this information for vhostuser interface.

Note that in openvswitch world drop/error doesn't always make sense
for some interface type. When these informations are not available we
set them to 0 on the virDomainInterfaceStats.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-12-09 10:23:09 +01:00
Michal Privoznik
ce937d3710 security: Drop virSecurityManagerSetHugepages
Since its introduction in 2012 this internal API did nothing.
Moreover we have the same API that does exactly the same:
virSecurityManagerDomainSetPathLabel.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-12-08 15:45:52 +01:00
Michal Privoznik
86980bc75c util: Introduce virMACMap module
This module will be used to track:

  <domain, mac address list>

pairs. It will be important to know these mappings without
libvirt connection (that is from a JSON file), because NSS
module will use those to provide better host name translation.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-12-06 13:33:18 +01:00
Michal Privoznik
b9b664c5a8 util: Introduce virFileRewriteStr
There are couple of places where we have a string and want to
save it to a file. Atomically. In all those places we use
virFileRewrite() but also implement the very same callback which
takes the string and write it into temp file. This makes no
sense. Unify the callbacks and move them to one place.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-12-06 13:33:18 +01:00
Michal Privoznik
b379c44c35 virstring: Introduce virStringListRemove
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-12-06 13:33:18 +01:00
Michal Privoznik
ec38d6f741 virstring: Introduce virStringListAdd
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-12-06 13:33:18 +01:00
Laine Stump
bfdc145153 util: new function virPCIDeviceGetConfigPath()
The path to the config file for a PCI device is conventiently stored
in a virPCIDevice object, but that object's contents aren't directly
visible outside of virpci.c, so we need to have an accessor function
for it if anyone needs to look at it.
2016-11-30 15:24:35 -05:00
Laine Stump
e026563f01 util: new function virFileLength()
This new function just calls fstat() (if provided with a valid fd) or
stat() (if fd is -1) and returns st_size (or -1 if there is an
error). We may decide we want this function to be more complex, and
handle things like block devices - this is a placeholder (that works)
for any more complicated function.
2016-11-30 15:18:57 -05:00
Michal Privoznik
c2a5a4e7ea virstring: Unify string list function names
We have couple of functions that operate over NULL terminated
lits of strings. However, our naming sucks:

virStringJoin
virStringFreeList
virStringFreeListCount
virStringArrayHasString
virStringGetFirstWithPrefix

We can do better:

virStringListJoin
virStringListFree
virStringListFreeCount
virStringListHasString
virStringListGetFirstWithPrefix

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-11-25 13:54:05 +01:00
Eric Farman
629544be0f util: Management routines for scsi_host devices
For a new hostdev type='scsi_host' we have a number of
required functions for managing, adding, and removing the
host device to/from guests.  Provide the basic infrastructure
for these tasks.

The name "SCSIVHost" (and its variants) is chosen to avoid
conflicts with existing code named "SCSIHost" to refer to
a hostdev type='scsi' protcol='none'.

Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
2016-11-24 12:15:26 -05:00
Marc Hartmayer
20bf8ea693 util: Add virHostdevIsSCSIDevice()
Add the function virHostdevIsSCSIDevice() which detects whether a
hostdev is a SCSI device or not.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
2016-11-22 14:37:36 +01:00
Jiri Denemark
03fa904c0c cpu: Drop cpuGuestData
The API is not used anywhere in the code.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-11-15 15:49:16 +01:00
Jiri Denemark
d73422c186 cpu: Introduce virCPUConvertLegacy API
PPC driver needs to convert POWERx_v* legacy CPU model names into POWERx
to maintain backward compatibility with existing domains. This patch
adds a new step into the guest CPU configuration work flow which CPU
drivers can use to convert legacy CPU definitions.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-11-15 15:49:16 +01:00
Jiri Denemark
53a5986ad6 cpu: Rename cpuDataFormat
The new name is virCPUDataFormat.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-11-15 15:49:15 +01:00
Jiri Denemark
be57e68954 cpu: Rename cpuDataParse
The new name is virCPUDataParse.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-11-15 15:49:15 +01:00
Jiri Denemark
b7011dfe44 cpu: Rename cpuGetModels
The new name is virCPUGetModels.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-11-15 15:49:15 +01:00
Peter Krempa
edf33d1a65 util: json: add helper to iterate and steal members of json array
Simplifies cases where JSON array members need to be transferred to a
different structure.
2016-11-09 16:47:08 +01:00
Martin Kletzander
64530a9c66 conf, qemu: Add support for shmem model
Just the default one now, new ones will be added in following commits.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-11-02 16:05:39 +01:00
Ján Tomko
dc67d00cd2 Recreate the USB address cache at reconnect
When starting a new domain, we allocate the USB addresses and keep
an address cache in the domain object's private data.

However this data is lost on libvirtd restart.

Also generate the address cache if all the addresses have been
specified, so that devices hotplugged after libvirtd restart
also get theirs assigned.

https://bugzilla.redhat.com/show_bug.cgi?id=1387666
2016-10-27 13:38:56 +02:00
Ján Tomko
ac518960a6 Introduce virDomainVirtioSerialAddrAutoAssign again
This time do not require an address cache as a parameter.

Simplify qemuDomainAttachChrDeviceAssignAddr to not generate
the virtio serial address cache for devices of other types.

Partially reverts commit 925fa4b.
2016-10-27 11:05:07 +02:00
Ján Tomko
0512dd26ee Add 'FromCache' to virDomainVirtioSerialAddrAutoAssign
Commit 19a148b dropped the cache from QEMU's private domain object.
Assume the callers do not have the cache by default and use
a longer name for the internal ones that do.

This makes the shorter 'virDomainVirtioSerialAddrAutoAssign'
name availabe for a function that will not require the cache.
2016-10-27 11:04:58 +02:00
Laine Stump
696929e67f conf: make virDomainPCIAddressGetNextSlot() a local static function
This function is no longer needed outside of domain_addr.c.
2016-10-24 13:55:49 -04:00
Laine Stump
848e7ff2b3 conf: new function virDomainPCIAddressReserveNextAddr()
There is an existing virDomainPCIAddressReserveNextSlot() which will
reserve all functions of the next available PCI slot. One place in the
qemu PCI address assignment code requires reserving a *single*
function of the next available PCI slot. This patch modifies and
renames virDomainPCIAddressReserveNextSlot() so that it can fulfill
both the original purpose and the need to reserve a single function.

(This is being done so that the abovementioned code in qemu can have
its "kind of open coded" solution replaced with a call to this new
function).
2016-10-24 13:53:24 -04:00
Sławek Kapłoński
7a2216460f virxml: Add function to check if string contains some illegal chars
This new function can be used to check if e.g. name of XML
node don't contains forbidden chars like "/" or "\n".

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-10-20 18:49:22 +08:00
Martin Kletzander
1827f2ac5d Change virDomainEventState to virObjectLockable
This way we get reference counting and we can get rid of locking
function.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-10-12 12:54:47 +02:00
Peter Krempa
da0d82d15f conf: Sanitize cpu topology numbers
Make sure that the topology results into a sane number of cpus (up to
UINT_MAX) so that it can be sanely compared to the vcpu count of the VM.

Additionally the helper added in this patch allows to fetch the total
number the topology results to so that it does not have to be
reimplemented later.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1378290
2016-10-11 13:52:09 +02:00
Erik Skultety
adda3e4f9b virlog: Remove functions that aren't used anywhere anymore
This is mainly virLogAddOutputTo* which were replaced by virLogNewOutputTo* and
the previously poorly named ones virLogParseAndDefine* functions. All of these
are unnecessary now, since all the original callers were transparently switched
to the new model of separate parsing and defining logic.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-10-10 08:27:25 +02:00
Erik Skultety
c33babfe31 virlog: Introduce virLogSetFilters
This method will eventually replace virLogParseAndDefineFilters which
currently does both parsing and defining.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-10-10 08:27:25 +02:00
Erik Skultety
6db7b8cbb5 virlog: Introduce virLogSetOutputs
This API is the entry point to output modification of the logger. Currently,
everything is done by virLogParseAndDefineOutputs. Parsing and defining will be
split into two operations both handled by this method transparently.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-10-10 08:27:25 +02:00
Erik Skultety
09d7ced8ee virlog: Introduce virLogParseFilters
Abstraction added over parsing a single filter. The method parses potentially a
set of logging filters, while adding each filter logging object to a
caller-provided array.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-10-10 08:27:25 +02:00
Erik Skultety
4b266c180b virlog: Introduce virLogParseOutputs
Another abstraction added on the top of parsing a single logging output. This
method takes and parses the whole set of outputs, adding each single output
that has already been parsed into a caller-provided array. If the user-supplied
string contained duplicate outputs, only the last occurrence is taken into
account (all the others are removed from the list), so we silently avoid
duplicate logs.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-10-10 08:27:25 +02:00
Erik Skultety
77a45f2ff0 virlog: Introduce virLogParseFilter
Same as for outputs, introduce a new method, that is basically the same as
virLogParseAndDefineFilter with the difference that it does not define the
filter. It rather returns a newly created object that needs to be inserted into
a list and then defined separately.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-10-10 08:27:24 +02:00
Erik Skultety
09b7cbb121 virlog: Introduce virLogParseOutput
Introduce a method to parse an individual logging output. The difference
compared to the virLogParseAndDefineOutput is that this method does not define
the output, instead it makes use of the virLogNewOutputTo* methods introduced
in the previous patch and just returns the virLogOutput object that has to be
added to a list of object which then can be defined as a whole via
virLogDefineOutputs. The idea remains still the same - split parsing and
defining of the logging primitives (outputs, filters).
Additionally, since virLogNewOutputTo* methods are now finally used,
ATTRIBUTE_UNUSED can be successfully removed from the methods' definitions,
since that was just to avoid compiler complaints about unused static functions.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-10-10 08:27:24 +02:00
Erik Skultety
58ab1b6f89 virlog: Introduce virLogDefineFilters
Prepare a method that only defines a set of filters. It takes a list of
filters, preferably created by virLogParseFilters. The original set of filters
is reset and replaced by the new user-provided set of filters.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-10-10 08:27:24 +02:00
Erik Skultety
d9d6b61f6d virlog: Introduce virLogDefineOutputs
Prepare a method that only defines a set of outputs. It takes a list of
outputs, preferably created by virLogParseOutputs. The original set of outputs
is reset and replaced by the new user-provided set of outputs.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-10-10 08:27:24 +02:00
Erik Skultety
b5004b09f5 virlog: Introduce virLogFindOutput
Outputs are a bit trickier than filters, since the user(config)-specified
set of outputs can contain duplicates. That would lead to logging the same
message twice. For compatibility reasons, we cannot just error out and forbid
the daemon to start if we find duplicate outputs which do not make sense.
Instead, we could silently take into account only the last occurrence of the
duplicate output and remove all the previous ones, so that the logger will not
try to use them when it is looping over all of its registered outputs.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-10-10 08:27:24 +02:00
Erik Skultety
435200cab4 virlog: Introduce virLogFilterNew
This method allocates a new filter object which it then returns back to caller.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-10-10 08:27:24 +02:00
Erik Skultety
b0f5dc9147 virlog: Introduce virLogOutputNew
In order to later split output parsing and output defining, introduce a new
function which will create a new virLogOutput object which the parser will
insert into a list with the list being eventually defined.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-10-10 08:27:24 +02:00
Erik Skultety
b8c370a96e virlog: Rename virLogParse* to virLogParseAndDefine*
Right now virLogParse* functions are doing both parsing and defining of filters
and outputs which should be two separate operations. Since the naming is
apparently a bit poor this patch renames these functions to
virLogParseAndDefine* which eventually will be replaced by virLogSet*.
Additionally, virLogParse{Filter,Output} will be later (after the split) reused,
so that these functions do exactly what the their name suggests.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-10-10 08:27:24 +02:00
Erik Skultety
1eeeb1e89b private_syms: add virLogFilterListFree to libvirt_private.syms
Commit 660468b1 forgot to add it, so let's add it now to prevent future linker
issues.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-10-06 18:13:43 +02:00
John Ferlan
ebf8b783bf util: Introduce virJSONValueObjectStealArray
Provide the Steal API for any code paths that will desire to grab the
object array and then free it afterwards rather than relying to freeing
the whole chain from the reply.
2016-10-05 11:12:02 -04:00
Peter Krempa
a88c65e490 qemu: vcpu: Clear vcpu order information rather than making it invalid
Certain operations may make the vcpu order information invalid. Since
the order is primarily used to ensure migration compatibility and has
basically no other user benefits, clear the order prior to certain
operations and document that it may be cleared.

All the operations that would clear the order can still be properly
executed by defining a new domain configuration rather than using the
helper APIs.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1370357
2016-09-30 08:25:20 +02:00
Jiri Denemark
7f127ded65 cpu: Rework cpuCompare* APIs
Both cpuCompare* APIs are renamed to virCPUCompare*. And they should now
work for any guest CPU definition, i.e., even for host-passthrough
(trivial) and host-model CPUs. The implementation in x86 driver is
enhanced to provide a hint about -noTSX Broadwell and Haswell models
when appropriate.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-09-22 15:40:09 +02:00
Jiri Denemark
c585ce920e cpu: Introduce virCPUCheckFeature
The function is similar to virCPUDataCheckFeature, but it works directly
on CPU definition rather than requiring it to be transformed into CPU
data first.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-09-22 15:40:09 +02:00
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
Laine Stump
f1e0d0da11 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).
2016-06-26 19:33:10 -04:00
Laine Stump
9911562a22 conf: single object containing list of IP addresses, list of routes
There are currently two places in the domain where this combination is
used, and there is about to be another. This patch puts them together
for brevity and uniformity.

As with the newly-renamed virNetDevIPAddr and virNetDevIPRoute
objects, the new virNetDevIPInfo object will need to be accessed by a
utility function that calls low level Netlink functions (so we don't
want it to be in the conf directory) and will be called from multiple
hypervisor drivers (so it can't be in any hypervisor directory); the
most appropriate place is thus once again the util directory.

The parse and format functions are in conf/domain_conf.c because only
the domain XML (i.e. *not* the network XML) has this exact combination
of IP addresses plus routes. Note that virDomainNetIPInfoFormat() will
end up being the only caller to virDomainNetRoutesFormat() and
virDomainNetIPsFormat(), so it will just subsume those functions in a
later patch, but we can't do that until they are no longer called.

(It would have been nice to include the interface name within the
virNetDevIPInfo object (with a slight name change), but that can't
be done cleanly, because in each case the interface name is provided
in a different place in the XML relative to the routes and IP
addresses, so putting it in this object would actually make the code
more confused rather than simpler).
2016-06-26 19:33:09 -04:00
Laine Stump
fa18e814ba util: move IP route & address object-related functions to virnetdevip.c
These functions all need to be called from a utility function that
must be located in the util directory, so we move them all into
util/virnetdevip.[ch] now that it exists.

Function and struct names were appropriately changed for the new
location, but all code is unchanged aside from motion and renaming.
2016-06-26 19:33:09 -04:00
Laine Stump
cf0568b0af util: new files virnetdevip.[ch] for IP-related netdev functions
This patch splits virnetdev.[ch] into multiple files, with the new
virnetdevip.[ch] containing all the functions related to setting and
retrieving IP-related info for a device (both addresses and routes).
2016-06-26 19:33:09 -04:00
Laine Stump
7cfbaad189 conf: new function virDomainNetDefClear
We need to clear these out without freeing the object completely.
2016-06-26 19:33:08 -04:00
Laine Stump
22a6873a98 global: consistently use IP rather than Ip in identifiers
I'm tired of mistyping this all the time, so let's do it the same all
the time (similar to how we changed all "Pci" to "PCI" awhile back).

(NB: I've left alone some things in the esx and vbox drivers because
I'm unable to compile them and they weren't obviously *not* a part of
some API. I also didn't change a couple of variables named,
e.g. "somethingIptables", because they were derived from the name of
the "iptables" command)
2016-06-26 19:33:07 -04:00
Laine Stump
638c6e5ba5 util: move virInterface(State|Link)/virNetDevFeature from conf to util
These had been declared in conf/device_conf.h, but then used in
util/virnetdev.c, meaning that we had to #include conf/device_conf.h
in virnetdev.c (which we have for a long time said shouldn't be done.

This caused a bigger problem when I tried to #include util/virnetdev.h
in a file in src/conf (which is allowed) - for some reason the
"device_conf.h: File not found" error.

The solution is to move the data types and functions used in util
sources from conf to util. Some names were adjusted during the move
("virInterface" --> "virNetDevIf", and "VIR_INTERFACE" -->
"VIR_NETDEV_IF")
2016-06-26 19:33:07 -04:00
Laine Stump
943a400c0d util: move virNetDevLinkDump to virnetlink.c
virNetDevLinkDump should have been in virnetlink.c, but that file
didn't exist yet when the function was created. It didn't really
matter until now - I found that having virnetlink.h included by
virnetdev.h caused build problems when trying to #include virnetdev.h
in a .c file in src/conf (due to missing directory in -I). Rather than
fix that to further institutionalize the incorrect placement of this
one function, this patch moves the function.
2016-06-26 19:33:07 -04:00
Nikolay Shirokovskiy
b86396dc54 vz: dump ip addresses to domain xml
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-06-25 22:56:03 +03:00
Daniel P. Berrange
0330848207 Promote storage pool refresh lifecycle event to top level event
The VIR_STORAGE_POOL_EVENT_REFRESHED constant does not
reflect any change in the lifecycle of the storage pool.

It should thus not be part of the storage pool lifecycle
event set, but rather be a top level event in its own
right. Thus we introduce VIR_STORAGE_POOL_EVENT_ID_REFRESH
to replace it.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-06-24 18:26:11 +01:00
Shivaprasad G Bhat
b95965c4f8 Rename kvmGetMaxVCPUs() to virHostCPUGetKVMMaxVCPUs()
This kvmGetMaxVCPUs() needs to be used at two different places
so move it to utils with appropriate name and mark it as private
global now.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
2016-06-24 18:52:21 +02:00
Ján Tomko
7a5df06e10 Introduce virDirOpenQuiet
A helper function that does not report any errors.
2016-06-24 14:20:57 +02:00
Ján Tomko
941ccbc174 Add virDirOpenIfExists
Just like virDirOpen, but it returns 0 without reporting an error
on ENOENT.
2016-06-24 14:20:57 +02:00
Ján Tomko
f0ced7086a Introduce virDirOpen
A helper that calls opendir and reports an error if it fails.
2016-06-24 14:20:57 +02:00
Ján Tomko
a4e6f1eb9c Introduce VIR_DIR_CLOSE
Introduce a helper that only calls closedir if DIR* is non-NULL
and sets it to NULL afterwards.
2016-06-23 21:58:33 +02:00
John Ferlan
42510c5199 util: Introduce virSecretLookupFormatSecret
Add utility to format the virSecretLookupTypeDefPtr in XML

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-06-23 12:30:28 -04:00
John Ferlan
ecd45ced0e util: Move and rename virStorageAuthDefParseSecret
Move to virsecret.c and rename to virSecretLookupParseSecret. Also convert
to usage xmlNodePtr and virXMLPropString rather than virXPathString.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-06-23 12:30:28 -04:00
John Ferlan
1eca5f6581 secret: Move virStorageSecretType and rename
Move the enum into a new src/util/virsecret.h, rename it to be
virSecretLookupType. Add a src/util/virsecret.h in order to perform
a couple of simple operations on the secret XML and virSecretLookupTypeDef
for clearing and copying.

This includes quite a bit of collateral damage, but the goal is to remove
the "virStorage*" and replace with the virSecretLookupType so that it's
easier to to add new lookups that aren't necessarily storage pool related.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-06-23 12:30:27 -04:00
Ján Tomko
dc56b3a7ce Introduce virBitmapParseUnlimited
For parsing a bitmap of an unknown size.
2016-06-20 12:09:52 +02:00
Ján Tomko
d728689d9b Introduce virBitmapParseSeparator
This will be used for the caller that needs to specify a separator.
Currently identical to virBitmapParse.

Also change one test case to use the new function.
2016-06-20 12:09:39 +02:00
Michal Privoznik
e30dbb9f98 virDomainRedirdevDef: Introduce find & remove routines
Basically, there are just two functions introduced here:
virDomainRedirdevDefFind which looks up given redirdev in domain
definition, and virDomainRedirdevDefRemove which removes the
device at given index in the array of devices.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-06-17 18:12:43 +02:00
Peter Krempa
f8d565bf86 conf: Rename virDomainDefGetMemoryActual to virDomainDefGetMemoryTotal 2016-06-17 10:39:40 +02:00
Peter Krempa
a877a1635b conf: Remove pre-calculation of initial memory size
While we need to know the difference between the total memory stored in
<memory> and the actual size not included in the possible memory modules
we can't pre-calculate it reliably. This is due to the fact that
libvirt's XML is copied via formatting and parsing the XML and the
initial memory size can be reliably calculated only when certain
conditions are met due to backwards compatibility.

This patch removes the storage of 'initial_memory' and fixes the helpers
to recalculate the initial memory size all the time from the total
memory size. This conversion is possible when we also make sure that
memory hotplug accounts properly for the update of the total memory size
and thus the helpers for inserting and removing memory devices need to
be tweaked too.

This fixes a bug where a cold-plug and cold-remove of a memory device
would increase the size reported in <memory> in the XML by the size of
the memory device. This would happen as the persistent definition is
copied before attaching the device and this would lead to the loss of
data in 'initial_memory'.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1344892
2016-06-17 10:36:41 +02:00
Jovanka Gulicoska
dc7b849a0c conf: add storage_event handling
Add storage event handling infrastructure to storage_event.[ch], following
the network_event.[ch] pattern.
2016-06-16 12:22:11 -04:00
Martin Kletzander
d3c784999d conf: Add support of zero-detection for disks
This option allows or disallows detection of zero-writes if it is set to
"on" or "off", respectively.  It can be also set to "unmap" in which
case it will try discarding that part of image based on the value of the
"discard" option.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-06-14 08:25:25 +02:00
Jim Fehlig
fda5a98e9e driver config: Introduce virFirmware object
The virQEMUDriverConfig object contains lists of
loader:nvram pairs to advertise firmwares supported by
by the driver, and qemu_conf.c contains code to populate
the lists, all of which is useful for other drivers too.

To avoid code duplication, introduce a virFirmware object
to encapsulate firmware details and switch the qemu driver
to use it.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2016-06-13 14:13:16 -06:00
Wang Yufei
9ac9450780 libxl: fix vm lock overwritten bug
In libxl driver we do virObjectRef in libxlDomainObjBeginJob,
If virCondWaitUntil failed, it goes to error, do virObjectUnref,
There's a chance that someone undefine the vm at the same time,
and refs unref to zero, vm is freed in libxlDomainObjBeginJob.
But the vm outside function is not Null, we do virObjectUnlock(vm).
That's how we overwrite the vm memory after it's freed. I fix it.

Signed-off-by: Wang Yufei <james.wangyufei@huawei.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-06-13 13:34:37 +02:00
Michal Privoznik
559b78d96a Export virDomainRedirdevDefFree
In the 162efa1a commit the function was introduced, but the
commit forgot to update livirt_private.syms accordingly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-06-10 15:16:56 +02:00
Daniel P. Berrange
235620463c util: add function for looking up the user shell
Add a virGetUserShell wrapper around virGetUserEnt, that
returns the shell field.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-06-09 18:44:52 +01:00
Daniel P. Berrange
4053350bfe nodeinfo: rename all CPU APIs to have a virHostCPU prefix
In preparation for moving all the CPU related APIs out of
the nodeinfo file, give them a virHostCPU name prefix.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-06-09 18:08:15 +01:00
Daniel P. Berrange
dcfe37e682 nodeinfo: rename all memory APIs to have a virHostMem prefix
In preparation for moving all the memory related APIs out of
the nodeinfo file, give them a virHostMem name prefix.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-06-09 18:07:00 +01:00
Pavel Hrdina
b6465e1aa4 graphics: introduce new listen type 'socket'
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-06-09 14:24:00 +02:00
Jiri Denemark
9ea32aecb4 cpu_x86: Avoid unnecessary pointers to virCPUx86Data
virCPUData, virCPUx86Feature, and virCPUx86Model all contained a pointer
to virCPUx86Data, which was not very nice since the real CPUID data were
accessible by yet another pointer from virCPUx86Data. Moreover, using
virCPUx86Data directly will make static definitions of internal CPU
features a bit easier.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-06-09 09:47:56 +02:00
Ján Tomko
32e6339c19 Export virDomainGetBlkioParametersAssignFromDef
Move qemuDomainGetBlkioParametersAssignFromDef into domain_conf
and export it, to allow reuse in the LXC driver.
2016-06-08 15:23:44 +02:00
Ján Tomko
4702687cfb Introduce virXMLValidatorValidate
Split out the code for XML validation into a new function.
2016-06-08 09:58:54 +02:00
Ján Tomko
87ae612de9 Introduce virXMLValidatorInit
Split out all the code initializing the validator
to a separate function.
2016-06-08 09:58:54 +02:00
Ján Tomko
8657c7a12f Introduce virXMLValidatorFree
Split out the code cleaning up the validator.
2016-06-08 09:58:54 +02:00
Peter Krempa
78b9b85c06 log: daemon: Add remote protocol handling for the log appending API
Implement the RPC dispatcher and caller for the new API.
2016-06-07 18:10:29 +02:00
Peter Krempa
05eab1bf9a conf: Move disk info validator to the domain conf validator
Since it will not be called from outside of conf we can unexport it too
if we move it to the appropriate place.

Test suite change is necessary since the error will be reported sooner
now.
2016-06-07 13:02:20 +02:00
Peter Krempa
b394af162a conf: Add infrastructure for adding configuration validation
Until now we weren't able to add checks that would reject configuration
once accepted by the parser. This patch adds a new callback and
infrastructure to add such checks. In this patch all the places where
rejecting a now-invalid configuration wouldn't be a good idea are marked
with a new parser flag.
2016-06-07 13:02:20 +02:00
John Ferlan
1b5f1884a2 qemu: Move and rename qemuBuildObjectCommandlineFromJSON
Move the module from qemu_command.c to a new module virqemu.c and
rename the API to virQEMUBuildObjectCommandline.

This API will then be shareable with qemu-img and the need to build
a security object for luks support.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-06-06 13:44:51 -04:00
Michal Privoznik
89ef1589a2 Drop virPerfGetEventFd
This function is not used anywhere. Moreover, the code that would
use lives in virperf.c and therefore has access to the FD anyway.
Well, for instance virPerfReadEvent is doing just that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-06-03 10:52:16 +02:00
Laine Stump
808e16ff13 conf: make virDomainControllerFindUnusedIndex() more generally usable
Make virDomainControllerFindUnusedIndex() a global function so that it
can be used outside domain_conf.c (as well as higher up in
domain_conf.c itself)/ Also make its DomainDef arg a const* so that
functions which only have a const* to the domain can use it.
2016-05-25 15:00:25 -04:00
John Ferlan
238032505f util: Introduce virCryptoGenerateRandom
Move the logic from qemuDomainGenerateRandomKey into this new
function, altering the comments, variable names, and error messages
to keep things more generic.

NB: Although perhaps more reasonable to add soemthing to virrandom.c.
    The virrandom.c was included in the setuid_rpc_client, so I chose
    placement in vircrypto.
2016-05-20 11:09:05 -04:00
John Ferlan
1ce9c08ab3 util: Introduce encryption APIs
Introduce virCryptoHaveCipher and virCryptoEncryptData to handle
performing encryption.

 virCryptoHaveCipher:
   Boolean function to determine whether the requested cipher algorithm
   is available. It's expected this API will be called prior to
   virCryptoEncryptdata. It will return true/false.

 virCryptoEncryptData:
   Based on the requested cipher type, call the specific encryption
   API to encrypt the data.

Currently the only algorithm support is the AES 256 CBC encryption.

Adjust tests for the API's
2016-05-20 11:09:01 -04:00
Nikolay Shirokovskiy
abc85b2cab vz: add domain snapshots functionality
This solution does not keep snapshots cache because vz sdk lacks good support
for snapshot related events.

Libvirt and vz sdk has different approach to snapshot ids. vz sdk always
auto generate them while libvirt has ability to specify id by user.
Thus I have no other choice rather than simply ignore ids set by user
or generated by libvirt.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
2016-05-18 18:14:58 +03:00
Jiri Denemark
d8d4b9d957 Remove virDomainRNGInsert
It was just a useless wrapper around VIR_APPEND_ELEMENT*.
2016-05-18 09:36:23 +02:00
John Ferlan
1cf5af40b9 util: string: Introduce helper to determine whether a byte buffer is printable
Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-05-16 12:58:48 +02:00
Peter Krempa
cb2e3e50ee util: string: Introduce virStringEncodeBase64
Add a new helper that sanitizes error semantics of base64_encode_alloc.
2016-05-16 12:58:48 +02:00
Peter Krempa
eb2116fd9a util: alloc: Introduce freeing helpers that clear the memory before freeing
For a few cases where we handle secret information it's good to clear
the buffers containing sensitive data before freeing them.

Introduce VIR_DISPOSE, VIR_DISPOSE_N and VIR_DISPOSE_STRING that allow
simple clearing fo the buffers holding sensitive information on cleanup
paths.
2016-05-16 12:58:48 +02:00
Michal Privoznik
7fccf12482 virfile: Introduce virFileRemoveLastComponent
Move some parts of virStorageFileRemoveLastPathComponent
into a separate function so they can be reused.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-05-13 14:17:15 +02:00
Laine Stump
b3f2c7cae8 conf: make virDomainDefAddController() public
This will be needed by the qemu driver in an upcoming patch.
2016-05-10 17:03:11 -04:00
Peter Krempa
1f880b5f22 conf: Kill now unused virDomainDiskSourceIsBlockType 2016-05-09 13:16:26 +02:00
Peter Krempa
3ec7bb354a util: Replace virDomainDiskSourceIsBlockType with a new helper
For disks sources described by a libvirt volume we don't need to do a
complicated check since virStorageTranslateDiskSourcePool already
correctly determines the actual disk type.

Replace the checks using a new accessor that does not open-code the
whole logic.
2016-05-09 12:36:52 +02:00
Nikolay Shirokovskiy
3506ad7f0a util: factor out reading file into preallocated buffer
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-05-03 08:58:30 -04:00