Commit Graph

36241 Commits

Author SHA1 Message Date
Peter Krempa
3c5c90ca19 virsh: secret: Print warning that passing secret on command-line is insecure
Print a warning if users pass in secrets as command line arguments and
mention it in the man page.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2020-01-28 18:09:57 +01:00
Peter Krempa
dbbc74e4ce virsh: secret: Add --file 'filename' support for secret-set-value
The necessity to specify the secret value as command argument is
insecure. Allow reading the secret from a file.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2020-01-28 18:09:57 +01:00
Peter Krempa
5611795b2b virsh: secret: Add --plain flag for secret-get-value
Users might want to get the raw value instead of dealing with base64
encoding. This might be useful for redirection to file and also for
simple human-readable secrets.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2020-01-28 18:09:57 +01:00
Peter Krempa
1a552eccf1 virsh: secret: Refactor cleanup in cmdSecretGetValue
Automatically clean the secret object and get rid of the cleanup label
and 'ret' valiable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2020-01-28 18:09:57 +01:00
Peter Krempa
66770bc6f5 virsh: secret: Refactor cleanup in cmdSecretSetValue
Automatically clean the secret object and get rid of the cleanup label
and 'ret' valiable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2020-01-28 18:09:57 +01:00
Peter Krempa
7e8ed7d782 virsh: Work around virSecretFree quirks
Similarly to other libvirt object freeing APIs the function resets the
libvirt error when called and doesn't take NULL gracefully. Install the
workaround and g_autoptr handlers similarly to the 'virshDomain' type.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2020-01-28 18:09:57 +01:00
Ján Tomko
374908e481 vz: fix typos of 'explicitly'
Also add a space before ending a comment.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-01-28 13:32:28 +01:00
Ján Tomko
c727638b4b include: add a space before ending a comment
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-01-28 13:32:28 +01:00
Ján Tomko
930f6e05b9 conf: unmark xmlopt as unused in virDomainDeviceInfoParseXML
It is used by the user-alias handling code.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-01-28 13:32:28 +01:00
Ján Tomko
31375a0842 conf: remove outdated comments
Some *ParseXML functions have comments stating what kind of device
they parse with an outdated list of parameters, with the exception
of virDomainFSDefParseXML which claims to parse a disk.

Remove them, assuming the function names are descriptive enough.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-01-28 13:32:28 +01:00
Ján Tomko
d5256cbd55 qemu: eliminate ret in qemuExtDevicesStart
All the callees return either 0 or -1 so there is no need
for propagating the value. And we bail on the first error.

Remove the variable to make the function simpler.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-01-28 13:32:27 +01:00
Ján Tomko
e2ca6eb087 qemu: use def instead of vm->def in qemuExtDevicesStart
We have a helper variable to make the code more concise,
use it consistently.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-01-28 13:32:27 +01:00
Ján Tomko
f84c7c67d5 qemu: eliminate ret variable in qemuExtTPMStart
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-01-28 13:32:27 +01:00
Ján Tomko
06160f6708 qemu: eliminate ret variable in qemuExtTPMStartEmulator
Now that the cleanup section is empty, eliminate the cleanup
label as well as the 'ret' variable.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-01-28 13:32:27 +01:00
Ján Tomko
ebe9c31f41 qemu: use g_auto in qemuExtTPMStartEmulator
Use the g_auto macros wherever possible to eliminate the cleanup
section.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-01-28 13:32:27 +01:00
Ján Tomko
3efdbae5bf conf: use virXMLFormatElement in virDomainFSDefFormat
Use the virXMLFormatElement helper to format the driver element
to simplify adding further sub-elements.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-01-28 10:31:41 +01:00
Andrea Bolognani
3a3a85c529 gitdm: Add missing entries
A few new companies and individuals contributed to libvirt since
the last time the gitdm configuration was updated.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2020-01-27 18:04:06 +01:00
Andrea Bolognani
c8a3a5d79b qemu_shim: Update temporary directory template
The template still references libvirt-qemu-shim, which was at one
point the name used to refer to what we now know as virt-qemu-run.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2020-01-27 17:57:43 +01:00
Andrea Bolognani
7dca28e229 qemu_shim: Fix typos
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2020-01-27 17:57:08 +01:00
Andrea Bolognani
761163fbda docs: Fix link to virt-qemu-run(1)
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2020-01-27 17:57:02 +01:00
Ján Tomko
c07ef7c563 qemu: snapshot: go through cleanup on error
A recent commit added an error check for too-nested backing chains
followed by a return, even though errors above jump to cleanup.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: b168fa88b8
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2020-01-27 17:36:05 +01:00
Ján Tomko
26a42e7315 qemu_shim: cosmetic fixes
Remove bogus G_GNUC_UNUSED attribute and add a missing space.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: d600667278
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2020-01-27 17:36:05 +01:00
Ján Tomko
fe8921c27b docs: fix since version in driver documentation
Also one stray angle bracket.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: 068efae5b1
Fixes: 3e9076e777
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2020-01-27 17:36:05 +01:00
Ján Tomko
b0b94a8d32 docs: fix virt-qemu-run man page
Fix a documentation generation error:
System Message: WARNING/2 (<stdin>, line 15); backlink
Inline literal start-string without end-string.

As well as the 'independant' typo.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: d600667278
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2020-01-27 17:36:05 +01:00
Peter Krempa
d9dfc1f7de qemu: checkpoint: Extract calculation of bitmap merging for checkpoint deletion
This will allow some testing before refactoring.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-01-27 15:28:49 +01:00
Peter Krempa
6796194a28 qemu: checkpoint: Introduce helper to find checkpoint disk definition in parents
The algorithm is used in two places to find the parent checkpoint object
which contains given disk and then uses data from the disk. Additionally
the code is written in a very non-obvious way. Factor out the lookup of
the disk into a function which also simplifies the callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-01-27 15:28:49 +01:00
Peter Krempa
180b3422e9 qemu: domain: Remove unused qemuDomainDiskNodeFormatLookup
The function has no users now and there's no need for it as the common
pattern is to look up the whole disk object anyways.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-01-27 15:28:49 +01:00
Peter Krempa
f19248a139 qemu: checkpoint: tolerate missing disks on checkpoint deletion
If a disk is unplugged and then the user tries to delete a checkpoint
the code would try to use NULL node name as it was not checked.

Fix this by fetching the whole disk definition object and verifying it
was found.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-01-27 15:28:49 +01:00
Peter Krempa
7973f7d792 qemu: checkpoint: Use disk definition directly when creating checkpoint
Lookup the whole disk definition rather than just the node name.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-01-27 15:28:49 +01:00
Peter Krempa
f3e0a45a00 qemu: checkpoint: rename disk->chkdisk in qemuCheckpointAddActions
Upcoming patches will also use the domain disk definition. Rename disk
to chkdisk for clarity.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-01-27 15:28:49 +01:00
Peter Krempa
a303e8ea47 qemu: checkpoint: rename disk->chkdisk in qemuCheckpointDiscardBitmaps
Upcoming patches will also use the domain disk definition. Rename disk
to chkdisk for clarity.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-01-27 15:28:49 +01:00
Peter Krempa
44e1b85717 qemu: checkpoint: split out checkpoint deletion bitmaps
qemuCheckpointDiscard is a massive function that can be separated into
smaller bits. Extract the part that actually modifies the disk from the
metadata handling.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-01-27 15:28:49 +01:00
Peter Krempa
606dc66b09 qemu: checkpoint: Store whether deleted checkpoint is current in a variable
Avoid two computations by using a boolean.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-01-27 15:28:49 +01:00
Peter Krempa
99eebcfe48 tests: qemu: Remove prehistoric machine types from faked data tests
qemu-5.0 will drop pre pc-1.0 machine types. Remove them from our
faked capabilities test suite. If a feature depends on a machine type it
shall be tested with real data and not with this hack.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-01-27 14:55:03 +01:00
Peter Krempa
f6a36dffc2 tests: qemuxml2xml: Remove prehistoric machine types from legacy tests
None of the tests depend on anything that the machine type would
influence. This will allow us to drop the very old machine type from the
non-real-data tests. If something depends on the machine type it should
be tested with real data rather than this hack.

Note that these tests are run only in the XML->XML suite because the
XML->argv suite doesn't work with the network driver.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-01-27 14:55:03 +01:00
Peter Krempa
de723a29a3 tests: qemuxml: Remove prehistoric machine types from legacy tests
None of the tests depend on anything that the machine type would
influence. This will allow us to drop the very old machine type from the
non-real-data tests. If something depends on the machine type it should
be tested with real data rather than this hack.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-01-27 14:55:03 +01:00
Peter Krempa
0f73d707ea tests: Add caps for upcoming qemu-5.0
Based on upstream commit 3e08b2b9cb64. This version already dropped the
pre-historic machine types and supports only machine types starting from
'pc-1.0'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-01-27 14:55:03 +01:00
Peter Krempa
30518a3b6a tests: qemuxml: Purge prehistoric machine type 'pc-0.13' from "latest" tests
Remove the old machine type which will be dropped in the upcomming
qemu-5.0 release from tests used against the most recent capabilities
data.

None of the modified tests really cares about the actual machine type.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-01-27 14:55:03 +01:00
Peter Krempa
ec0db69c86 tests: qemu: Don't add fake machine types when testing with real data
Skip the step of adding all of the fake machine types which are required
for the legacy tests in case when we are testing with real capabilities.

Faking any data in the real capabilities undermines the point of testing
with real capabilities.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-01-27 14:55:03 +01:00
Peter Krempa
60b580b949 qemu: capabilities: Add accessor to qemu caps machine types presence
Test code will need to know whether the virQEMUCaps object contains any
machine types already. Add a helper and expose it via 'qemu_capspriv.h'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-01-27 14:55:03 +01:00
Peter Krempa
3b8feb4793 qemu: capabilities: Replace aliased machine type by copy of the canonical machine
The previous approac of just purging the alias combined with the fact
that we filled in fake machine types in the test data meant that if a
test case used an alias machine type such as 'pc' or 'q35' it would not
properly resolve to the actual data returned by qemu.

This started to be a problem since the CPU driver now looks at the
default CPU reported with the machine type.

This patch replaces the original approach of just removing the alias by
replacing it with a copy of the machine type data which the type would
alias to. This means that we are using the real data while we don't
modify the test output after every qemu upgrade.

Additionally this change will allow us to drop adding the fake machine
types later.

The test fallout is from actually excercising the CPU driver with
actual data.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-01-27 14:55:03 +01:00
Peter Krempa
bb61230992 qemu: capabilities: Extract code from virQEMUCapsStripMachineAliases
Separate out the internals as they will become more complex soon.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-01-27 14:55:03 +01:00
Peter Krempa
0b9d1a8073 qemu: domain: Validate that machine type is supported by qemu
Every supported qemu is able to return the list of machine types it
supports so we can start validating it against that list. The advantage
is a better error message, and the change will also prevent having stale
test data.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-01-27 14:55:03 +01:00
Peter Krempa
cb5a89c115 tests: qemu: Add machine types used by the test code to fake capabilities
Enumerate all missing machine types for all missing architectures for
the fake capabilities used in many existing tests. This will allow
stricter validation whether qemu actually supports given machine type
since we already have some behaviour dependant on the actual machine
type.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-01-27 14:55:03 +01:00
Peter Krempa
6d9caaaef5 tests: qemuxml: Use existing machine type in 'iothreads-virtio-scsi-ccw' case
Use the 's390-ccw-virtio' machine type which is actually supported by
the qemu we gathered the test data from.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-01-27 14:55:03 +01:00
Peter Krempa
9517890f7c tests: qemuxml2argv: Use proper replacement for 'pc-i440fx-wily' machine
This machine type comes from downstream ubuntu 15.10. Replace it with a
somewhat equivalent qemu-2.3 machine type as we do have test data for
that.

The change allows the CPU code to pick a proper default CPU in the
'-latest' cases.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-01-27 14:55:03 +01:00
Peter Krempa
ccd4231149 tests: qemuxml2argv: Use existing non-virt machine in 'aarch64-gic-not-virt'
Use 'versatilepb' instead of a fake 'non-virt' machine type.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-01-27 14:55:03 +01:00
Peter Krempa
f9bb79ff41 tests: qemuxml2argv: Remove downstream machine type in 'controller-order' case
Use 'pc' instead of ancient 'rhel-6.1'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-01-27 14:55:03 +01:00
Peter Krempa
99dcdf505e tests: qemuxml2argv: Use existing machine type for 'numatune-distances' case
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-01-27 14:55:03 +01:00
Peter Krempa
d29ee7c124 tests: qemu: Unify fake machine types filled in for KVM and TCG caps of x86_64
For testing with synthetic capabilities we pre-fill the qemu
capabilities with some machine types. Historically there were two arrays
for KVM and TCG but that's not necessary. Make both instances of x86_64
data share the same array as the other architectures do.

This will later on simplify filling in all the other machine types which
are required for the test suite.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-01-27 14:55:03 +01:00