Commit Graph

20 Commits

Author SHA1 Message Date
Daniel P. Berrangé
568a417224 Enforce a standard header file guard symbol name
Require that all headers are guarded by a symbol named

  LIBVIRT_$FILENAME

where $FILENAME is the uppercased filename, with all characters
outside a-z changed into '_'.

Note we do not use a leading __ because that is technically a
namespace reserved for the toolchain.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-12-14 10:47:13 +00:00
Peter Krempa
9843f22c2a qemu: block: Add generator for the 'copy-on-read' blockdev driver
The copy on read functionality is done using a separate layer in the
backing chain. Add function to generate properties for it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-08-21 15:46:06 +02:00
Peter Krempa
bed681d7b5 qemu: block: Create helper for creating data for legacy snapshots
With 'transaction' support we don't need to keep around the multipurpose
code which would create the snapshot if 'transaction' is not supported.

To simplify this add a new helper that just wraps the arguments for
'blockdev-snapshot-sync' operation in 'transaction' and use it instead
of qemuBlockSnapshotAddLegacy.

Additionally this allows to format the arguments prior to creating the
file for simpler cleanup.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-20 13:39:44 +02:00
Peter Krempa
99239432d3 qemu: hotplug: Extract hotplug of TLS into qemuBlockStorageSourceAttachApply
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:14:01 +02:00
Peter Krempa
191780e856 qemu: hotplug: Extract hotplug of secrets into qemuBlockStorageSourceAttachApply
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:14:01 +02:00
Peter Krempa
1990a01e6e qemu: hotplug: Extract hotplug of PR into qemuBlockStorageSourceAttachApply
Introduce a new setup function for all the related configuration and
move the setup and attachment of the PR code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:14:00 +02:00
Peter Krempa
ca174424ba qemu: Reuse qemuBlockStorageSourceAttachApply in disk hotplug
Create a new "Prepare" function and move the drive add code into the new
helpers. This will eventually allow to simplify and unify the attaching
code for use with blockdev at the same time as providing compatibility
with older qemus.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:14:00 +02:00
Peter Krempa
ceb151b24b qemu: block: Add helpers for hot-adding virStorageSource via blockdev
These helpers add infrastructure which simplifies adding and rolling
back virStorageSources to a running qemu instance. Using of the helper
structure and separate functions allows for a much cleaner code in the
section dealing with the monitor.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-23 13:18:25 +02:00
Peter Krempa
e17193acd2 qemu: block: Add support for creating 'format' layer for blockdev-add
When using blockdev-add and friends, libvirt will need to create also
properties for the qcow2/raw/... format handler in qemu. This patch adds
the infrastructure and implements all formats known to libvirt including
all properties which are expressed at the format level in qemu.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-07 15:38:03 +02:00
Peter Krempa
d94aa38ffb qemu: block: Propagate 'legacy' parameter when formatting disk backing
The gluster protocol in qemu uses two styles, one of which is legacy and
not covered by the QAPI schema.

To allow using of the new style in the blockdev-add code, add a
parameter for qemuBlockStorageSourceGetBackendProps which will switch
between the two modes.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-07 15:31:48 +02:00
Peter Krempa
1fc3cd8731 qemu: block: Add function to check if storage source allows concurrent access
Storage source format backing a shared device (e.g. running a cluster
filesystem) needs to support the sharing so that metadata are not
corrupted. Add a central function for checking this.
2017-11-23 18:26:25 +01:00
Peter Krempa
1ee7d4d972 qemu: process: Split out useful parts from qemuBuildNetworkDriveURI
Extract the part formatting the basic URI part so that it can be reused
to format JSON backing definitions. Parts specific to the command line
format will remain in qemuBuildNetworkDriveURI. The new function is
called qemuBlockStorageSourceGetURI.
2017-11-07 14:57:58 +01:00
Peter Krempa
c03e52af57 qemu: block: store and test driver names for detected storage nodes
Store the 'drv' field both for the storage node and for the format node
and format them in the test case.

Reviewed-by: Eric Blake <eblake@redhat.com>
2017-07-27 09:56:41 +02:00
Peter Krempa
0175dc6ea0 qemu: block: Refactor node name detection code
Remove the complex and unreliable code which inferred the node name
hierarchy only from data returned by 'query-named-block-nodes'. It turns
out that query-blockstats contain the full hierarchy of nodes as
perceived by qemu so the inference code is not necessary.

In query blockstats, the 'parent' object corresponds to the storage
behind a storage volume and 'backing' corresponds to the lower level of
backing chain. Since all have node names this data can be really easily
used to detect node names.

In addition to the code refactoring the one remaining test case needed
to be fixed along.

Reviewed-by: Eric Blake <eblake@redhat.com>
2017-07-27 09:47:40 +02:00
Peter Krempa
bb8ebe69dd qemu: block: Refactor and rename qemuGetDriveSourceProps
Rename it to qemuBlockStorageSourceGetBackendProps and refactor it to
return the JSON object instead of filling a pointer since now it's
always expected to return data.
2017-07-14 16:05:46 +02:00
Peter Krempa
7677f8a7d9 qemu: Move qemuGetDriveSourceProps to qemu_block
Pure code movement except for the tweaks necessary for cross-usage.
2017-07-14 16:05:46 +02:00
Nikolay Shirokovskiy
dd8e40790b qemu: take current async job into account in qemuBlockNodeNamesDetect
Becase it can be called during migration out (namely on cancelling
blockjobs).

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-04-27 14:38:29 +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
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
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