Commit Graph

25812 Commits

Author SHA1 Message Date
Martin Kletzander
d2d1dec1f5 util: Fix naming in util/virnodesuspend
That file has only two exported files and each one of them has
different naming.  virNode is what all the other files use, so let's
use it.  It wasn't used before because the clash with public API
naming, so let's fix that by shortening the name (there is no other
private variant of it anyway).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-03-27 13:13:29 +02:00
Martin Kletzander
26ae4e482a Remove src/nodeinfo
There is no "node driver" as there was before, drivers have to do
their own ACL checking anyway, so they all specify their functions and
nodeinfo is basically just extending conf/capablities.  Hence moving
the code to src/conf/ is the right way to go.

Also that way we can de-duplicate some code that is in virsysfs and/or
virhostcpu that got duplicated during the virhostcpu.c split.  And
Some cleanup is done throughout the changes, like adding the vir*
prefix etc.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-03-27 13:13:29 +02:00
Martin Kletzander
bdcb199532 Move src/fdstream to src/util/virfdstream
There is no reason for it not to be in the utils, all global symbols
under that file already have prefix vir* and there is no reason for it
to be part of DRIVER_SOURCES because that is just a leftover from
older days (pre-driver modules era, I believe).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-03-27 13:13:29 +02:00
Martin Kletzander
c67e04e25f util: Adapt virhostcpu to the new virsysfs
While on that, drop support for kernels from RHEL-5 era (missing
cpu/present file).  Also add some useful functions and export them.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-03-27 13:13:29 +02:00
Martin Kletzander
a7b902c082 util: Add virsysfs for handling sysfs files
By using this we are able to easily switch the sysfs path being
used (fake it).  This will not only help tests in the future but can
be also used from files where the code is duplicated currently.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-03-27 13:13:29 +02:00
Martin Kletzander
15b5e46364 tests: Add cpu/{online,present} files for old tests
The functionality these tests partially relied on (scanning the cpu
directory for cpu[0-9]+ subdirectories) is going to be removed, so we
need additional files that are present on all non-medieval systems.
Removing all these tests would be an option but we would lose the
ability to test the topologies.  Even though we just extract number of
sockets/cores/threads from all these directory trees.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-03-27 13:13:29 +02:00
Martin Kletzander
9fdd077de7 virfile: Add helpers for reading simple values
These helpers are doing just a read and covert the value, but they
properly size the read limit, handle additional whitespace characters,
and unify error reporting.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-03-27 13:13:29 +02:00
Martin Kletzander
5b5fee00fd tests: Remove some unneeded files
We are not using them at all and the directories are missing bunch of
files already.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-03-27 13:13:29 +02:00
Martin Kletzander
9fff1fa334 openvz: Ditch openvzGetNodeCPUs
There is particular function for this, there is no need to build whole
nodeinfo for it.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-03-27 13:13:29 +02:00
Martin Kletzander
3c2b3a6f31 Separate syms based on files they are defined in
Commits eaf18f4c2b and 86dd9fac0f separated util/host{cpu,mem}
stuff from nodeinfo, but did not adjust the syms file.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-03-27 13:13:29 +02:00
Martin Kletzander
ffb3f69448 vz: Do not use magic constants when building capabilities
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-03-27 13:13:29 +02:00
Martin Kletzander
4c818e76aa tests: Fix indentation in virhostcputest
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-03-27 13:13:29 +02:00
Martin Kletzander
ce0bb3cb64 syms: Add one newline to make things consistent
It is everywhere else.  I even remember one of our scripts failing if
the newline is missing, but it doesn't happen currently.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-03-27 13:13:29 +02:00
Martin Kletzander
86d4a558d8 cpu: Don't use prefixes for no reason
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-03-27 13:13:29 +02:00
Martin Kletzander
97a84a9344 vmware: Fix some initialization problems
Don't leak guest if adding it to virCapabilities fails.  Also return
NULL and not pointer to free'd object with zero references in such
case.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-03-27 13:13:29 +02:00
Martin Kletzander
e8e9a7e9f7 Expose virCapabilitiesFreeGuest
Guests are handled in callers, but if something goes wrong (when it
cannot be added to virCapabilities, for example), there's no way for
them to free it properly.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-03-27 13:13:29 +02:00
Martin Kletzander
272d78a5ef Introduce virCPUProbeHost
Both QEMU and bhyve are using the same function for setting up the CPU
in virCapabilities, so de-duplicate it, save code and time, and help
other drivers adopt it.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-03-27 13:13:29 +02:00
Martin Kletzander
532788a840 Add virNumaGetNodeCPUs to private syms
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-03-27 13:13:29 +02:00
Martin Kletzander
eec3b255d2 Fix build with GCC's static analysis
STREQ_NULLABLE returns true if both parameters are NULL.  And that's
not what we want here.  We just want to skop comparing source nodes
that don't have that info set.  The function wouldn't make much sense
with nodeName == NULL, so we don't need to check that.  Moreover, the
function's declaration uses ATTRIBUDE_NONNULL for nodeName, which not
only means that function expects the parameter not to be NULL, but
actually tells the compiler that it can optimize out the NULL checks.
That way it could end up calling strcmp on NULL (either nodeformat or
nodebacking).  GCC figures this out if libvirt is compiled with
lv_cv_static_analysis=yes, unfortunately not everyone uses that.

Caused by cbc6d53513.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-03-27 13:12:23 +02:00
Peter Krempa
91c3d430c9 qemu: stats: Display the block threshold size in bulk stats
Management tools may want to check whether the threshold is still set if
they missed an event. Add the data to the bulk stats API where they can
also query the current backing size at the same time.
2017-03-27 10:35:20 +02:00
Peter Krempa
51c4b744d8 qemu: block: Add code to fetch block node data by node name
To allow updating stats based on the node name, add a helper function
that will fetch the required data from 'query-named-block-nodes' and
return it in hash table for easy lookup.
2017-03-27 10:35:19 +02:00
Peter Krempa
86e51d68f9 util: json: Make function to free JSON values in virHash universal
Move the helper that frees JSON entries put into hash tables into the
JSON module so that it does not have to be reimplemented.
2017-03-27 10:35:19 +02:00
Peter Krempa
0feebab2c4 qemu: block: Add code to detect node names when necessary
Detect the node names when setting block threshold and when reconnecting
or when they are cleared when a block job finishes. This operation will
become a no-op once we fully support node names.
2017-03-27 10:35:19 +02:00
Peter Krempa
2780bcd9f8 qemu: monitor: Extract the top level format node when querying disks
To allow matching the node names gathered via 'query-named-block-nodes'
we need to query and then use the top level nodes from 'query-block'.
Add the data to the structure returned by qemuMonitorGetBlockInfo.
2017-03-27 10:35:19 +02:00
Peter Krempa
b0aa088fad tests: qemumonitorjson: Test node name detection on networked storage 2017-03-27 10:35:19 +02:00
Peter Krempa
2a50c18fc0 tests: qemumonitorjson: Add relative image names for node name detection
oVirt uses relative names with directories in them. Test such
configuration. Also tests a snapshot done with _REUSE_EXTERNAL and a
relative backing file pre-specified in the qcow2 metadata.
2017-03-27 10:35:19 +02:00
Peter Krempa
b6c5a3f09b tests: qemumonitorjson: Add case for two disks sharing a backing image
Since we have to match the images by filename a common backing image
will break the detection process. Add a test case to see that the code
correctly did not continue the detection process.
2017-03-27 10:35:19 +02:00
Peter Krempa
aece275043 tests: qemumonitorjson: Add long backing chain test case for node name detection 2017-03-27 10:35:19 +02:00
Peter Krempa
217484bdbd tests: qemumonitorjson: Add test case for node name detection code
The code is rather magic so a test case will help making sure that
everything works well. The first case is a simple backing chain.
2017-03-27 10:35:19 +02:00
Peter Krempa
dbad8f8aee qemu: block: Add code to allow detection of auto-allocated node names
qemu for some time already sets node names automatically for the block
nodes. This patch adds code that attempts a best-effort detection of the
node names for the backing chain from the output of
'query-named-block-nodes'. The only drawback is that the data provided
by qemu needs to be matched by the filename as seen by qemu and thus
if two disks share a single backing store file the detection won't work.

This will allow us to use qemu commands such as
'block-set-write-threshold' which only accepts node names.

In this patch only the detection code is added, it will be used later.
2017-03-27 10:35:19 +02:00
Peter Krempa
d92d7f6b52 qemu: monitor: Add monitor infrastructure for query-named-block-nodes
Add monitor tooling for calling query-named-block-nodes. The monitor
returns the data as the raw JSON array that is returned from the
monitor.

Unfortunately the logic to extract the node names for a complete backing
chain will be so complex that I won't be able to extract any meaningful
subset of the data in the monitor code.
2017-03-27 10:35:19 +02:00
Peter Krempa
e2b05c9a8d qemu: capabilities: add capability for query-named-block-nodes qmp cmd 2017-03-27 10:35:19 +02:00
Peter Krempa
c6f4acc4cb qemu: implement qemuDomainSetBlockThreshold
Add code to call the appropriate monitor command and code to lookup the
given disk backing chain member.
2017-03-27 10:32:35 +02:00
Peter Krempa
9b93c4c264 qemu: domain: Add helper to look up disk soruce by the backing store string 2017-03-27 10:18:16 +02:00
Peter Krempa
97148962b5 virsh: Implement 'domblkthreshold' command to call virDomainSetBlockThreshold
Add a simple wrapper which will allow to set the threshold for
delivering the event.
2017-03-27 10:15:55 +02:00
Peter Krempa
bb09798fbe lib: Add API for setting the threshold size for VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD
The new API can be used to configure the threshold when
VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD should be fired.
2017-03-27 10:09:49 +02:00
Peter Krempa
e96130dcc8 qemu: process: Wire up firing of the VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD event
Bind it to qemu's BLOCK_WRITE_THRESHOLD event. Look up the disk by
nodename and construct the string to return.
2017-03-27 09:29:57 +02:00
Peter Krempa
4e1618ce72 qemu: domain: Add helper to generate indexed backing store names
The code is currently simple, but if we later add node names, it will be
necessary to generate the names based on the node name. Add a helper so
that there's a central point to fix once we add self-generated node
names.
2017-03-27 09:29:57 +02:00
Peter Krempa
1a5e2a8098 qemu: domain: Add helper to lookup disk by node name
Looks up a disk and its corresponding backing chain element by node
name.
2017-03-27 09:29:57 +02:00
Peter Krempa
73d4b32427 qemu: monitor: Add support for BLOCK_WRITE_THRESHOLD event
The event is fired when a given block backend node (identified by the
node name) experiences a write beyond the bound set via
block-set-write-threshold QMP command. This wires up the monitor code to
extract the data and allow us receiving the events and the capability.
2017-03-27 09:29:57 +02:00
Peter Krempa
085e794a86 lib: Introduce event for tracking disk backing file write threshold
When using thin provisioning, management tools need to resize the disk
in certain cases. To avoid having them to poll disk usage introduce an
event which will be fired when a given offset of the storage is written
by the hypervisor. Together with the API which will be added later, it
will allow registering thresholds for given storage backing volumes and
this event will then notify management if the threshold is exceeded.
2017-03-27 09:29:57 +02:00
Peter Krempa
cbc6d53513 util: storage: Add variables for node names into virStorageSource
'nodeformat' should be used for strings which describe the storage
format object, and 'nodebacking' for the actual storage object itself.
2017-03-27 09:29:57 +02:00
Peter Krempa
ad36f3853b util: storage: Split out useful bits of virStorageFileParseChainIndex
The function has very specific semantics. Split out the part that parses
the backing store specification string into a separate helper so that it
can be reused later while keeping the wrapper with existing semantics.

Note that virStorageFileParseChainIndex is pretty well covered by the
test suite.
2017-03-27 09:29:57 +02:00
Peter Krempa
91e7862c15 util: buffer: Add API to set indentation level to a given value
It will be useful to set indentation level to 0 after formatting a
nested structure rather than having to track the depth.
2017-03-27 09:29:57 +02:00
Peter Krempa
ff9ed72bf1 qemu: driver: Don't call qemuDomainDetermineDiskChain on block jobs
Our code calls it when starting or re-starting the domain or when
hotplugging the disk so there's nothing to be detected.
2017-03-27 09:29:57 +02:00
Roman Bogorodskiy
daecaea038 bhyve: add xhci tablet support
Along with video and VNC support, bhyve has introduced USB tablet
support as an input device. This tablet is exposed to a guest
as a device on an XHCI controller.

At present, tablet is the only supported device on the XHCI controller
in bhyve, so to make things simple, it's allowed to only have a
single XHCI controller with a single tablet device.

In detail, this commit:

 - Introduces a new capability bit for XHCI support in bhyve
 - Adds an XHCI controller and tabled support with 1:1 mapping
   between them
 - Adds a couple of unit tests
2017-03-26 19:22:30 +04:00
Roman Bogorodskiy
9bf6b9dfa3 bhyve: helper function to probe hypervisor caps
There are a number of functions in bhyve_capabilities.c that probe
hypervisor capabilities by executing the bhyve(1) binary with the
specific device arugment, checking error message (if any) and setting
proper capability bit. As those are extremely similar, move this logic
into a helper function and convert existing functions to use that.
2017-03-26 19:12:10 +04:00
Roman Bogorodskiy
74cfb5bb85 domaincapstest: add bhyve caps test
* Extract filling bhyve capabilities from virBhyveDomainCapsBuild()
   into a new function virBhyveDomainCapsFill() to make testing
   easier by not having to mock firmware directory listing and
   hypervisor capabilities probing
 * Also, just presence of the firmware files is not sufficient
   to enable os.loader.supported, hypervisor should support UEFI
   boot too
 * Add tests to domaincapstest for the main caps possible flows:
    - when UEFI bootrom is supported
    - when video (fbus) is supported
    - neither of above is supported
2017-03-26 18:44:46 +04:00
Roman Bogorodskiy
c27aa64786 schema: domaincaps: make machine element optional
Commit df769041c made the 'machine' element in domaincaps
optional. Update the schema to reflect that.
2017-03-26 18:35:14 +04:00
Roman Bogorodskiy
4035baebb7 qemu: fix build with clang
qemuMigrationResetTLS() does not initialize 'ret' by default,
so when it jumps to 'cleanup' on error, the 'ret' variable will be
uninitialized, which clang complains about.

Set it to '-1' by default.
2017-03-26 08:43:36 +04:00