Commit Graph

1092 Commits

Author SHA1 Message Date
John Ferlan
bb0bf87b24 Remove virDomainIOThreadsPinDel
This one is no longer necessary since the Vcpu and IOThreads API's share
2015-03-16 11:54:57 -04:00
John Ferlan
4985dde0f5 Replace virDomainVcpuPinDel with virDomainPinDel
Since both Vcpu and IOThreads code use the same API's, alter the naming
of the API's to remove the "Vcpu" specific reference
2015-03-16 11:54:57 -04:00
John Ferlan
01c8f66275 Replace virDomainIOThreadsPinAdd with virDomainPinAdd
This one is no longer necessary since the Vcpu and IOThreads API's share
2015-03-16 11:54:57 -04:00
John Ferlan
cacf27f212 Replace virDomainVcpuPinAdd with virDomainPinAdd
Since both Vcpu and IOThreads code use the same API's, alter the naming
of the API's to remove the "Vcpu" specific reference
2015-03-16 11:54:57 -04:00
John Ferlan
a8a89270ef Convert virDomainVcpuPinFindByVcpu into virDomainPinFindByVcpu
Since both Vcpu and IOThreads code use the same API's, alter the naming
of the API's to remove the "Vcpu" specific reference
2015-03-16 11:54:57 -04:00
John Ferlan
8cf80b517e Convert virDomainVcpuPinIsDuplicate into virDomainPinIsDuplicate
Since both Vcpu and IOThreads code use the same API's, alter the naming
of the API's to remove the "Vcpu" specific reference
2015-03-16 11:54:57 -04:00
John Ferlan
c16723f606 Convert virDomainVcpuPinDefCopy into virDomainPinDefCopy
Since both Vcpu and IOThreads code use the same API's, alter the naming
of the API's to remove the "Vcpu" specific reference
2015-03-16 11:54:57 -04:00
John Ferlan
24b15ea90d Convert virDomainVcpuPinDefArrayFree to virDomainPinDefArrayFree
Since both Vcpu and IOThreads code use the same API's, alter the naming
of the API's to remove the "Vcpu" specific reference
2015-03-16 11:54:57 -04:00
John Ferlan
0a06a1812d Convert virDomainVcpuPinDefFree to virDomainPinDefFree
Since both Vcpu and IOThreads code use the same API's, alter the naming
of the API's to remove the "Vcpu" specific reference
2015-03-16 11:54:57 -04:00
Peter Krempa
4f9907cd11 conf: Replace access to def->mem.max_balloon with accessor functions
As there are two possible approaches to define a domain's memory size -
one used with legacy, non-NUMA VMs configured in the <memory> element
and per-node based approach on NUMA machines - the user needs to make
sure that both are specified correctly in the NUMA case.

To avoid this burden on the user I'd like to replace the NUMA case with
automatic totaling of the memory size. To achieve this I need to replace
direct access to the virDomainMemtune's 'max_balloon' field with
two separate getters depending on the desired size.

The two sizes are needed as:
1) Startup memory size doesn't include memory modules in some
hypervisors.
2) After startup these count as the usable memory size.

Note that the comments for the functions are future aware and document
state that will be present after a few later patches.
2015-03-16 14:26:51 +01:00
Marek Marczykowski-Górecki
ed4db85a55 conf: add virDomainHasNet
virDomainNetFindIdx no longer returns info whether device was not found,
or there was multiple matches. Additionally it already handle error
reporting. Introduce virDomainHasNet which does a simple task, without
implicit error reporting.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
2015-03-13 12:00:50 -06:00
Ján Tomko
22fd3ac38f Introduce virBitmapIsBitSet
A helper that never returns an error and treats bits out of bitmap range
as false.

Use it everywhere we use ignore_value on virBitmapGetBit, or loop over
the bitmap size.
2015-03-13 15:31:33 +01:00
John Ferlan
e878719117 domain: Introduce virDomainIOThreadsPin{Add|Del}
https://bugzilla.redhat.com/show_bug.cgi?id=1135491

More or less a virtual copy of the existing virDomainVcpuPin{Add|Del} API's.

NB: The IOThreads implementation "reused" the virDomainVcpuPinDefPtr
since it provided everything necessary - an "id" and a "map" for each
thread id configured.
2015-03-11 12:23:33 -04:00
Michal Privoznik
3aa3e072bd network_conf: Introduce locked versions of lookup functions
This is going to be needed later, when some functions already
have the virNetworkObjList object already locked and need to
lookup a object to work on. As an example of such function is
virNetworkAssignDef(). The other use case might be in
virNetworkObjListForEach() callback.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-11 16:58:48 +01:00
Michal Privoznik
aa7c7f880e network_conf: Introduce virNetworkObjEndAPI
This is practically copy of qemuDomObjEndAPI. The reason why is
it so widely available is to avoid code duplication, since the
function is going to be called from our bridge driver, test
driver and parallels driver too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-11 16:58:48 +01:00
Michal Privoznik
ea57049156 network_conf: Make virNetworkObj actually virObject
So far it's just a structure which happens to have 'Obj' in its
name, but otherwise it not related to virObject at all. No
reference counting, not virObjectLock(), nothing.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-11 16:58:48 +01:00
Michal Privoznik
88aed14f12 network_conf: Turn virNetworkObjList into virObject
Well, one day this will be self-locking object, but not today.
But lets prepare the code for that! Moreover,
virNetworkObjListFree() is no longer needed, so turn it into
virNetworkObjListDispose().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-09 14:03:30 +01:00
Michal Privoznik
292acd202f network_conf: Introduce virNetworkObjListPrune
The API will iterate over the list of network object and remove
desired ones from it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-09 14:03:30 +01:00
Michal Privoznik
0ae7def635 network_conf: Introduce virNetworkObjListNumOfNetworks
An accessor following pattern laid out by virDomainObjList* APIs.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-09 14:03:30 +01:00
Michal Privoznik
5a13c48b73 network_conf: Introduce virNetworkObjListGetNames
An accessor following pattern laid out by virDomainObjList* APIs.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-09 14:03:30 +01:00
Michal Privoznik
454fe219ef network_conf: Introduce virNetworkObjListForEach
This API will be used in the future to call passed callback over
each network object in the list. It's slightly different to its
virDomainObjListForEach counterpart, because virDomainObjList
uses a hash table to store domain object, while virNetworkObjList
uses an array.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-09 14:03:30 +01:00
Pavel Hrdina
cf521fc8ba memtune: change the way how we store unlimited value
There was a mess in the way how we store unlimited value for memory
limits and how we handled values provided by user.  Internally there
were two possible ways how to store unlimited value: as 0 value or as
VIR_DOMAIN_MEMORY_PARAM_UNLIMITED.  Because we chose to store memory
limits as unsigned long long, we cannot use -1 to represent unlimited.
It's much easier for us to say that everything greater than
VIR_DOMAIN_MEMORY_PARAM_UNLIMITED means unlimited and leave 0 as valid
value despite that it makes no sense to set limit to 0.

Remove unnecessary function virCompareLimitUlong.  The update of test
is to prevent the 0 to be miss-used as unlimited in future.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-03-06 11:52:24 +01:00
Pavel Hrdina
a73395ae66 virutil: introduce helper functions for memory limits
The first one is to truncate the memory limit to
VIR_DOMAIN_MEMORY_PARAM_UNLIMITED if the value is greater and the second
one is to decide whether the memory limit is set or not, unlimited means
that it's not set.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-03-06 11:52:23 +01:00
Stefan Berger
a06e9ce11d utils: Implement virCommandPassFDGetFDIndex
Implement virCommandPassFDGetFDIndex to determine the index a given
file descriptor will have when passed to the child process.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-03-05 18:57:06 -05:00
James Chapman
c9027d8f44 SRIOV NIC offload feature discovery
Adding functionality to libvirt that will allow it
query the ethtool interface for the availability
of certain NIC HW offload features

Here is an example of the feature XML definition:

<device>
<name>net_eth4_90_e2_ba_5e_a5_45</name>
  <path>/sys/devices/pci0000:00/0000:00:03.0/0000:08:00.1/net/eth4</path>
  <parent>pci_0000_08_00_1</parent>
  <capability type='net'>
    <interface>eth4</interface>
    <address>90:e2:ba:5e:a5:45</address>
    <link speed='10000' state='up'/>
    <feature name='rx'/>
    <feature name='tx'/>
    <feature name='sg'/>
    <feature name='tso'/>
    <feature name='gso'/>
    <feature name='gro'/>
    <feature name='rxvlan'/>
    <feature name='txvlan'/>
    <feature name='rxhash'/>
    <capability type='80203'/>
  </capability>
</device>

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2015-03-05 11:31:05 +01:00
Michal Privoznik
53cae19561 conf: s/virNetworkFindByName/virNetworkObjFindByName/
It's returning virNetworkObjPtr after all. And it matches the
pattern laid out by domain_conf.h.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-04 10:12:16 +01:00
Michal Privoznik
82f240ae56 conf: s/virNetworkFindByUUID/virNetworkObjFindByUUID/
It's returning virNetworkObjPtr after all. And it matches the
pattern laid out by domain_conf.h.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-04 10:11:40 +01:00
Martin Kletzander
2fd5880b3b conf: De-duplicate scheduling policy enums
Since adding the support for scheduler policy settings in commit
8680ea97, there are two enums with the same information.  That was
caused by rewriting the patch since first draft.

Find out thanks to clang, but there was no impact whatsoever.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-03-03 09:26:59 +01:00
John Ferlan
e0e290552b disk: Disallow duplicated target 'dev' values
https://bugzilla.redhat.com/show_bug.cgi?id=1142631

This patch resolves a situation where the same "<target dev='$name'...>"
can be used for multiple disks in the domain.

While the $name is "mostly" advisory regarding the expected order that
the disk is added to the domain and not guaranteed to map to the device
name in the guest OS, it still should be unique enough such that other
domblk* type operations can be performed.

Without the patch, the domblklist will list the same Target twice:

$ virsh domblklist $dom
Target     Source
------------------------------------------------
sda        /var/lib/libvirt/images/file.qcow2
sda        /var/lib/libvirt/images/file.img

Additionally, getting domblkstat, domblkerror, domblkinfo, and other block*
type calls will not be able to reference the second target.

Fortunately, hotplug disallows adding a "third" sda value:

$ qemu-img create -f raw /var/lib/libvirt/images/file2.img 10M
$ virsh attach-disk $dom /var/lib/libvirt/images/file2.img sda
error: Failed to attach disk
error: operation failed: target sda already exists

$

BUT, it since 'sdb' doesn't exist one would get the following on the same
hotplug attempt, but changing to use 'sdb' instead of 'sda'

$ virsh attach-disk $dom /var/lib/libvirt/images/file2.img sdb
error: Failed to attach disk
error: internal error: unable to execute QEMU command 'device_add': Duplicate ID 'scsi0-0-1' for device

$

Since we cannot fix this issue at parsing time, the best that can be done so
as to not "lose" a domain is to make the check prior to starting the guest
with the results as follows:

$ virsh start $dom
error: Failed to start domain $dom
error: XML error: target 'sda' duplicated for disk sources '/var/lib/libvirt/images/file.qcow2' and '/var/lib/libvirt/images/file.img'

$

Running 'make check' found a few more instances in the tests where this
duplicated target dev value was being used. These also exhibited some
duplicated 'id=' values (negating the uniqueness argument of aliases) in
the corresponding .args file and of course the *xmlout version of a few
input XML files.
2015-03-02 22:38:36 -05:00
Peter Krempa
8968c4946c conf: numa: Add helper to count total memory size configured in NUMA
The total NUMA memory consists of the sum of individual NUMA node memory
amounts.
2015-03-02 16:42:51 +01:00
Michal Privoznik
83c5467ee9 util: Introduce virBufferAddBuffer
This API joins the following two lines:

char *s = virBufferContentAndReset(buf1);
virBufferAdd(buf2, s, -1);

into one:

virBufferAddBuffer(buf2, buf1);

With one exception: there's no re-indentation applied to @buf1.
The idea is, that in general both can have different indentation
(like the test I'm adding proves)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-02-25 09:23:42 +01:00
Peter Krempa
b98596a717 conf: numa: Check ABI stability of NUMA configuration
Add helper to compare initial sizes of indivitual NUMA nodes and the map
of belonging vCPUs. Other configuration is not ABI.
2015-02-20 19:23:38 +01:00
Peter Krempa
b9ddb25822 conf: numa: Add setter/getter for NUMA node memory size
Add the helpers and refactor places where the value is accessed without
them.
2015-02-20 17:50:08 +01:00
Peter Krempa
7800d473f5 conf: numa: Add accessor to NUMA node's memory access mode 2015-02-20 17:50:08 +01:00
Peter Krempa
d9a779a36e conf: numa: Add accessor for the NUMA node cpu mask
Add virDomainNumaGetNodeCpumask() and refactor a few places that would
get the cpu mask without the helper.
2015-02-20 17:50:08 +01:00
Peter Krempa
be22d07315 conf: numa: Add helper to get guest NUMA node count and refactor users
Add an accessor so that a later refactor is simpler.
2015-02-20 17:50:07 +01:00
Peter Krempa
21008c013c conf: numa: Always allocate the NUMA config
Since our formatter now handles well if the config is allocated and not
filled we can safely always-allocate the NUMA config and remove the
ad-hoc allocation code.

This will help in later patches as the parser will be refactored to just
fill the data.
2015-02-20 17:48:48 +01:00
Peter Krempa
61e43ce9df conf: Separate helper for creating domain objects
Move the existing virDomainDefNew to virDomainDefNewFull as it's setting
a few things in the conf and re-introduce virDomainDefNew as a function
without parameters for common use.
2015-02-20 17:43:05 +01:00
Peter Krempa
6bc80fa86d conf: numa: Rename virDomainNumatune to virDomainNuma
The structure will gradually become the only place for NUMA related
config, thus rename it appropriately.
2015-02-20 17:43:04 +01:00
Peter Krempa
fcee64e73c conf: Move numatune_conf to numa_conf
For a while now there are two places that gather information about NUMA
related guest configuration. While the XML can't be changed we can at
least store the data in one place in the definition.

Rename the numatune_conf.[ch] files to numa_conf as later patches will
move the rest of the definitions from the cpu definition to this one.
2015-02-20 17:43:03 +01:00
Michal Privoznik
65c0fd9dfc numatune_conf: Expose virDomainNumatuneNodeSpecified
This function is going to be needed in the near future.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-02-17 08:38:19 +01:00
Erik Skultety
c3d9d3bbc9 security: introduce virSecurityManagerCheckAllLabel function
We do have a check for valid per-domain security model, however we still
do permit an invalid security model for a domain's device (those which
are specified with <source> element).
This patch introduces a new function virSecurityManagerCheckAllLabel
which compares user specified security model against currently
registered security drivers. That being said, it also permits 'none'
being specified as a device security model.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1165485
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2015-02-13 14:37:54 +01:00
Michal Privoznik
9993736f45 libvirt_private.syms: Expose virDomainNetTypeFromString
The enum converters are defined in the domain_conf.h (so
accessible widely across the code), but on the symbol layer, only
virDomainNetTypeToString was exposed. However, FromString variant
is going to be needed shortly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-02-13 09:33:12 +01:00
Martin Kletzander
8680ea9749 docs, schema, conf: Add support for setting scheduler parameters of guest threads
In order for QEMU vCPU (and other) threads to run with RT scheduler,
libvirt needs to take care of that so QEMU doesn't have to run privileged.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-02-11 17:30:06 +01:00
Martin Kletzander
b6a2828e53 util: Add virProcessSetScheduler() function for scheduler settings
This function uses sched_setscheduler() function so it works with
processes and threads as well (even threads not created by us, which is
what we'll need in the future).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-02-11 17:30:06 +01:00
Peter Krempa
fe6acfbd0e qemu: Implement random number generator cold (un)plug
Add support for using the attach/detach device APIs on the inactive
configuration to add RNG devices.
2015-02-10 13:05:22 +01:00
Luyao Huang
37b620059b conf: Add helpers to insert/remove/find RNG devices in domain def
The helpers will be useful when implementing hotplug and coldplug of
random number generator devices.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2015-02-10 13:05:22 +01:00
Luyao Huang
ad3e99e21b audit: export virDomainAuditRNG
Signed-off-by: Luyao Huang <lhuang@redhat.com>
2015-02-10 13:05:22 +01:00
Peter Krempa
c88b323bf5 conf: Introduce helper to find duplicate device address
When adding devices to the definition it's useful to check whether the
devices don't reside on a conflicting address. This patch adds a helper
that iterates all device info and compares the addresses with the given
info.
2015-02-10 13:05:22 +01:00
Daniel P. Berrange
b38da58423 Make tests independant of system page size
Some code paths have special logic depending on the page size
reported by sysconf, which in turn affects the test results.
We must mock this so tests always have a consistent page size.
2015-02-02 20:27:43 +00:00