Commit Graph

32641 Commits

Author SHA1 Message Date
Peter Krempa
22b83a54f5 conf: Add 'index' attribute for <disk><mirror><source>
Similarly to the disk source we need to keep the disk index (which is in
the qemu driver used for identification of the source for block jobs)
for the <mirror> element so that when it's replaced as a disk source
after pivoting all the allocated data is present.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
4e797f1af9 conf: Parse and format 'backingStore' for disk <mirror>
When the block copy operation is started with a reused external file in
incremental mode libvirt will need to open and insert the backing chain
for that file into qemu (in -blockdev mode). This means that we'll need
to track the backing chain and metadata such as node names for the full
chain of <mirror>.

This patch invokes the full backing chain formatter and parser for
<mirror> so that the chain can be kept with <mirror>.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
944d09fa3e conf: Refactor virDomainDiskDefMirrorParse
Use virDomainStorageSourceParseBase and other tricks.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
54b36c03a0 conf: Pass 'flags' to virDomainDiskSourceFormat in virDomainDiskDefFormatMirror
We have the proper flags available so we can pass them to the fomatter.
The added bonus is that private data may be formatted into the status
XML.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
86855f761f conf: use virXMLFormatElement in virDomainDiskDefFormatMirror
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
670053326b qemu: Parse NBD storage source private data by virDomainStorageSourceParse
Drop the local call in favor of passing in xmlopt.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
79e3b15ce6 qemu: Use virDomainStorageSourceParseBase in qemuDomainObjPrivateXMLParseJobNBDSource
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
ef5ed42655 qemu: Remove cleanup in qemuDomainObjPrivateXMLParseJobNBDSource
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
e1899a2490 qemu: Use VIR_AUTOFREE in qemuDomainObjPrivateXMLParseJobNBDSource
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
08c4a54ec0 conf: Modify arguments passed to virDomainDiskBackingStoreFormat
Pass in 'src' rather than the backing store of it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
d588981913 conf: Document virDomainStorageSourceParse
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
868be7ce58 conf: Use virDomainStorageSourceParseBase in virDomainDiskBackingStoreParse
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
18bc52bce0 conf: introduce virDomainStorageSourceParseBase
The helper converts the 'type', 'format' and index values to enum
values/numbers and does validation.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
dfaf170df5 conf: Replace virDomainDiskSourceParse by virDomainStorageSourceParse
virDomainDiskSourceParse was now just a thin wrapper without any extra
value. Replace all usage of it by the function it calls and remove the
function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
54fc720d8e conf: Document virDomainDiskSourceFormat
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
218c81ead0 conf: Merge virDomainStorageSourceFormat into virDomainDiskSourceFormat
There was only one caller, remove the unnecessary wrapper.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
0f13b78b20 conf: Use virXMLFormatElement in virDomainDiskBackingStoreFormat
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
945eab4060 conf: Avoid temporary variable in virDomainDiskBackingStoreFormat
Modify the check that the format is in range to be standalone and use
the convertor function directly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
eaef9b1f67 conf: Simplify control flow in virDomainDiskSourceFormat
Now that the cleanup is handled automatically it can be removed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
4bc429868e conf: Unexport virDomainStorageSourceFormat
It's not used outside of src/conf/domain_conf.c

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
0c10edadde qemu: domain: Modify <migrationSource> to look like <disk>
When adding <migrationSource> I've used a slightly unusual approach. To
allow using the disk source XML parser and formatter convert
<migrationSource> to look like <disk>. This means that <source> will be
added as a subelement of <migrationSource> rather than being formatted
inline.

Conversion from the old format in the parser is very simple as it
involves only moving the XPath context current node slightly if the new
format is found.

The status XML to XML test shows that the upgrade is done correctly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
1af846dd27 tests: qemustatusxml2xml: Add separate output for migration-out-nbd-tls
Upcomming change will modify some aspects. To allow testing upgrade path
add a separate output file so that we can see the conversion from old to
new config.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
ba3349185a tests: qemustatusxml2xml: Add another disk to migration-out-nbd-tls case
Upcomming change will modify some aspects. To allow testing upgrade path
add another disk.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
058f99d8fb tests: qemuxml2xml: Use virdeterministichashmock.so
Block job related data will be stored in a has table and formatted into
the status XML. Use the mock to guarantee stable tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
a9621831a3 conf: Export virDomainDiskSourceFormat
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
5f6f803ca1 conf: Merge virDomainDiskSourceFormatInternal into virDomainDiskSourceFormat
Remove the wrapper and fix callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
6bee0262c7 conf: Remove @seclabels from virDomainStorageSourceFormat
All callers including transitive callers through
virDomainDiskSourceFormatInternal always pass true. Remove the argument.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
da9f3cd84b conf: Format seclabels for <backingStore>
We parse the seclabels and use them internally so omitting them when
formatting would be misleading. Additionally our schema actually allows
them.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
e8e51b634f qemu: domain: Forbid copy_on_read option also for floppies
Using copy_on_read for removable disks is a hassle. It also does not
work for CDROMs at all as the image is supposed to be read-only and we
might ignore it for floppies when they are started as empty. Forbid it
for floppies completely rather than trying to support what probably
nobody is using.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
b3736febca qemu: hotplug: Disallow media change while blockjob is active
Until the block job completes we can't change the disk chain. Removal
would fail as the block job still has reference to the chain.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
0beac488e0 qemu: hotplug: Use VIR_AUTOUNREF for virQEMUDriverConfigPtr
Unref the config pointer automatically in code paths which get a local
copy.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
24fce6637c qemu: hotplug: Remove unused copies of virQEMUDriverConfigPtr
qemuDomainChangeGraphicsPasswords and qemuDomainRemoveHostDevice
don't use 'cfg' any more since commits 4327df7eee and 802c59d4b9
respectively.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
63ff670f40 qemu: domain: Use VIR_AUTOFREE in qemuDomainObjPrivateXMLParseBlockjobs
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
8f956ee71a qemu: Remove cleanup section of virQEMUCapsInitQMPMonitorTCG
There's nothing to clean up.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
e125000a88 qemu: Remove ATTRIBUTE_UNUSED from 'qemuCaps' of virQEMUCapsInitQMPMonitorTCG
It's actually used.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
de6049ccf4 qemu: caps: Remove pointless debug message in virQEMUCapsInitQMPMonitor
Failure of qemuMonitorGetVersion is fatal now that we only support QMP
based qemus. Remove the debug message since we report an error already.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
c5c8618463 qemu: caps: Remove cleanup section in virQEMUCapsInitQMPMonitor
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
78ad4c559e qemu: caps: Don't leak package name string in virQEMUCapsInitQMPMonitor
If the detected qemu version is below our required version 'package'
would be leaked.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
f7550ecce8 qemu: Decide whether to query schema in virQEMUCapsProbeQMPSchemaCapabilities
Move the check out of virQEMUCapsInitQMPMonitor similarly to other
functions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
43a8527762 qemu: Move SEV capability handling into virQEMUCapsProbeQMPSEVCapabilities
Move the code out of virQEMUCapsInitQMPMonitor similarly to other
functions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
c31b9159e6 qemu: Decide whether check GIC caps in virQEMUCapsProbeQMPGICCapabilities
Move the check out of virQEMUCapsInitQMPMonitor similarly to other
functions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
26dbc2e72a qemu: caps: Aggregate all caps post-processing into a function
Some caps are cleared according to some more advanced logic after
detection. Split all that logic out into virQEMUCapsInitProcessCaps.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-04-03 11:58:09 +02:00
Peter Krempa
87b906811b qemu: caps: Separate capabilities based on qemu version
virQEMUCapsInitQMPMonitor is massive now since it collects calls to the
various probing functions and also version based capabilities. Split
out the version based caps into a separate function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-04-03 11:58:09 +02:00
Ján Tomko
cbc6ee722b virsh-completer: introduce virshPagesizeNodeToString
A helper function that takes a XML node with a "size"
and "unit" attributes and converts it into a human-readable string.

Reduce the size and number of variables in the parent function.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 10:29:15 +02:00
Ján Tomko
b0325e07e6 virsh-completer: remove excessive labels
Now that we have a shared cleanup section everywhere,
delete all the 'error' labels which all contain just 'goto cleanup'
anyway.

Also remove all the 'cleanup' labels that only 'return ret' - we
can simply return NULL instead of jumping to that label.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 10:24:47 +02:00
Ján Tomko
d41af4b435 virsh-completer: use VIR_AUTOFREE for char* variables
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 10:24:47 +02:00
Ján Tomko
1c1393ed01 virsh-completer: use VIR_AUTOPTR for xml* variables
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 10:24:47 +02:00
Ján Tomko
ab96c35a03 virsh-completer: use VIR_AUTOFREE for xmlNodePtr* variables
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 10:24:47 +02:00
Ján Tomko
d46dd75e3a virsh-completer: use VIR_AUTOSTRINGLIST for tmp
We've been open-coding virStringListFreeCount for cleaning up
the completion list we're building. This had the advantage of
zeoring the pointer afterwards, which is no longer needed
now that we compile the list in 'tmp' instead of 'ret'.

Since all our lists are NULL-terminated anyway, switch to using
virStringListFree via the VIR_AUTOSTRINGLIST macro.

Fixes nearly impossible NULL dereferences in
  virshNWFilterBindingNameCompleter
  virshNWFilterNameCompleter
  virshNodeDeviceNameCompleter
  virshNetworkNameCompleter
  virshInterfaceNameCompleter
  virshStoragePoolNameCompleter
  virshDomainNameCompleter
which jumped on the error label after a failed allocation
and a possible one in
  virshStorageVolNameCompleter
which jumped there when we fail to fetch the list of volumes.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 10:24:06 +02:00
Ján Tomko
81723acebd virsh-completer: unify cleanup of items in name completers
Merge the cleanup of fetched items for the success and the error
paths.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 10:09:54 +02:00