Commit Graph

10335 Commits

Author SHA1 Message Date
Fangge Jin
4e66123f89 qemu.conf: Re-word the description for *_tls_x509_verify
The original descirption for *_tls_x509_verify is a little misleading
by saying that "Enabling this option will reject any client who does
not have a ca-cert.pem certificate".

Signed-off-by: Fangge Jin <fjin@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-09 10:18:45 +02:00
Michal Privoznik
0c8ab47847 qemu: Don't generate '-machine memory-backend' and '-numa memdev'
In 88957116c9 I've switched to -machine memory-backend=ID and
-object memory-backend-* because QEMU is obsoleting -mem-path
and -mem-prealloc. However, what I did not foresee was that using
-machine memory-backend in combination with -numa is not allowed
in QEMU. This was reported upstream and fortunately not released
yet.

The problem is that if domain has NUMA nodes then we will
generate memory-backend-* objects for NUMA nodes (because if QEMU
is new enough to expose default RAM ID it also supports -numa
memdev=) and adding non-NUMA memory backend is wrong.

Reported-by: Masayoshi Mizuma <msys.mizuma@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-10-08 12:55:10 +02:00
Ján Tomko
6ddb1f803e qemu: agent: split out qemuAgentGetAllInterfaceAddresses
Remove more logic from qemuAgentGetInterfaces.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-10-08 11:16:08 +02:00
Ján Tomko
031514e022 qemuAgentGetInterfaceOneAddress: check for errors early
For readability, and to ensure we do allocation when
returning 0.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-10-08 11:16:08 +02:00
Ján Tomko
cac5cf33b2 qemu: agent: rename tmp_iface to iface_obj
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-10-08 11:16:08 +02:00
Ján Tomko
3b9432fa28 qemuAgentGetInterfaceAddresses: turn ifname into char*
We only care about the first part of the 'ifname' string,
splitting it is overkill.

Instead, just replace the ':' with a '\0' in a copy of the string.
This reduces the count of the varaibles containing some form
of the interface name to two.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-10-08 11:16:08 +02:00
Ján Tomko
ddc2e51767 qemu: agent: remove cleanup in qemuAgentGetInterfaces
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-10-08 11:16:08 +02:00
Ján Tomko
00311ef603 qemu: agent: use g_auto in qemuAgentGetInterfaces
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-10-08 11:16:08 +02:00
Ján Tomko
9e48b02840 qemu: agent: use GetArray to remove a check
The error check for ValueObjectGet("return") is redundant,
qemuAgentCommand already checked for us that the reply contains
a "return" object.

It does not guarantee, that it is an array.

Use virJSONValueObjectGetArray that combines getting the object
with checking for its type and return the more helpful of
the two error messages.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-10-08 11:16:08 +02:00
Ján Tomko
67e744cb57 qemu: agent: split out qemuAgentGetInterfaceAddresses
Convert one interface from the "return" array returned by
"guest-network-get-interfaces" to virDomainInterface.

Due to the functionality of squashing interface aliases together,
this is not a pure function - it either:
* Adds the interface to ifaces_ret, incrementing ifaces_count
  and adds a pointer to it into the ifaces_store hash table.
* Adds the additional IP addresses from the interface alias
  to the existing interface entry, found through the hash table.
  This does not increment ifaces_count or extend the array.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-10-08 11:16:08 +02:00
Ján Tomko
aa61f7f9c9 qemu: agent: simplify access to ifaces_ret
We have a local 'iface' variable that contains the same value
eventually. Initialize it early instead of indexing two more
times.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-10-08 11:16:08 +02:00
Ján Tomko
40b4f68d2d qemu: agent: use virHashNew
We're passing 'ifaces_count' to virHashCreate as the initial
hash table size just after we've initialized it to zero.
This translates to a default of 256 inside virHashCreateFull.

Instead of this obfuscation, use virHashNew (default of 32),
to make it obvious we don't care about the initial hash size.

Also remove the error handling, since neither of the functions
return any errors after switching to g_new0.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-10-08 11:16:08 +02:00
Ján Tomko
196ff56834 qemu: agent: use g_auto for ifname
This lets us conveniently reduce its scope to the outer loop.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-10-08 11:16:08 +02:00
Ján Tomko
89b43c3e25 qemu: agent: expand addrs upfront
qemuAgentGetInterfaceOneAddress returns exactly one address
for every iteration of the loop (and we error out if not).

Instead of expanding the addrs by one on every iteration,
do it upfront since we know how many times the loop will
execute.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-10-08 11:16:08 +02:00
Ján Tomko
269af9f692 qemu: agent: reduce scope of addrs_count
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-10-08 11:16:08 +02:00
Ján Tomko
b5c281e81b qemu: agent: remove impossible errors
For both 'ip_addr_arr' and 'ret_array', we:
1) already checked that they are arrays
2) only iterate up to the array size

Remove the duplicate checks.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-10-08 11:16:07 +02:00
Ján Tomko
33fd3cbeb6 qemu: agent: split out qemuAgentGetInterfaceOneAddress
A function that takes one entry from the "ip-addresses" array
returned by "guest-network-get-interfaces" and converts it
into virDomainIPAddress.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-10-08 11:16:07 +02:00
Ján Tomko
f08349247c qemu: agent: remove redundant checks
virJSONValueObjectGetArray returns NULL if the object with
the supplied key is not an array.

Calling virJSONValueIsArray right after is redundant.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-10-08 11:16:07 +02:00
Tim Wiederhake
4c3ed3b84e cpu: Wire in XML validation
This adds a new value to virConnectCompareCPUFlags,
"VIR_CONNECT_CPU_VALIDATE_XML", that governs XML document validation in
virCPUDefParseXML.

In src/conf/cpu_conf.c, include configmake.h for PKGDATADIR and
virfile.h for virFileFindResource.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-10-07 11:26:27 +02:00
Ján Tomko
37043008b7 Fix incorrect g_new0 conversions
I left in a 'return' or 'goto cleanup' in a few places
where I did the conversion manually.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reported-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2020-10-06 14:26:43 +02:00
Ján Tomko
7d77fdb90f qemu: use g_new0
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2020-10-05 16:44:06 +02:00
Ján Tomko
73f7b6a0ef qemu: firmware: use g_new0
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2020-10-05 16:44:06 +02:00
Ján Tomko
7195877348 qemu: command: use g_new0
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2020-10-05 16:44:06 +02:00
Ján Tomko
cc3190cc4c qemu: process: use g_new0
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2020-10-05 16:44:06 +02:00
Ján Tomko
aad03a0970 qemu: monitor: json: use g_new0
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2020-10-05 16:44:06 +02:00
Ján Tomko
c1cb299e12 qemu: driver: use g_new0
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2020-10-05 16:44:06 +02:00
Ján Tomko
0ac810b225 qemu: domain: use g_new0
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2020-10-05 16:44:06 +02:00
Ján Tomko
f655a603dd qemu: capabilities: use g_new0
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2020-10-05 16:44:06 +02:00
Ján Tomko
868c350752 qemu: separate out VIR_ALLOC calls
Move them to separate conditions to reduce churn
in following patches.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2020-10-05 16:44:06 +02:00
Cole Robinson
0fa5c23865 qemu: Taint cpu host-passthrough only after migration
From a discussion last year[1], Dan recommended libvirt drop the tain
flag for cpu host-passthrough, unless the VM has been migrated.

This repurposes the existing host-cpu taint flag to do just that.

[1]: https://www.redhat.com/archives/virt-tools-list/2019-February/msg00041.html

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

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2020-10-05 10:08:26 -04:00
Peter Krempa
c96eba3d03 qemu: migration_cookie: s/VIR_FREE/g_free/
Previous refactors allow us to plainly replace all VIR_FREE by g_free to
finish the modernization of the file.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-05 15:58:53 +02:00
Peter Krempa
49530d5277 qemuMigrationCookieXMLParse: Avoid VIR_FREE when parsing lockstate
Restructure the control-flow a bit using an temporary variable to avoid
the need to use VIR_FREE.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-05 15:58:53 +02:00
Peter Krempa
78d330bde1 qemuMigrationCookieAddCaps: Use 'g_new0' instead of VIR_ALLOC
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-05 15:58:53 +02:00
Peter Krempa
83434e5acd qemuMigrationCookieCapsXMLParse: Refactor memory handling
Use modern allocators, automatic memory feeing, and decrease the scope
of some variables to remove the 'cleanup' label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-05 15:58:53 +02:00
Peter Krempa
9d7ca30ece qemuMigrationCookieNBDXMLParse: Refactor memory handling
Use modern allocators, automatic memory feeing, and decrease the scope
of some variables to remove the 'error' and 'cleanup' labels.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-05 15:58:53 +02:00
Peter Krempa
abfb033ddb qemuMigrationCookieNetworkXMLParse: Refactor memory handling
Use modern allocators, automatic memory feeing, and decrease the scope
of some variables to remove the 'error' label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-05 15:58:53 +02:00
Peter Krempa
7dce147544 qemuMigrationCookieXMLFormat: Refactor memory handling
Use automatic memory freeing to get rid of the 'error' label. Since the
'tmp' variable was used only in one instance, rename it appropriately.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-05 15:58:53 +02:00
Peter Krempa
dc03248181 qemuMigrationCookieNetworkAlloc: Refactor memory handling
Use modern memory handling approach to simplify the code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-05 15:58:53 +02:00
Peter Krempa
f3e087ac9c qemuMigrationCookieGraphicsSpiceAlloc: Refactor memory handling
Use modern memory handling approach to simplify the code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-05 15:58:53 +02:00
Peter Krempa
85d6d515ed qemu: migration_cookie: Register 'autoptr' functions for internal types
Register the the cleanup functions for 'qemuMigrationCookieGraphics',
'qemuMigrationCookieNetwork', 'qemuMigrationCookieNBD', and
'qemuMigrationCookieCaps'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-05 15:58:53 +02:00
Peter Krempa
a09cf33adf qemuDomainExtractTLSSubject: Refactor memory handling
Switch to automatic memory cleaning, use g_new0 for allocation and get
rid of the 'error' label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-05 15:58:53 +02:00
Peter Krempa
518be41aaa qemuMigrationCookieXMLFormat: Extract formatting of NBD
Move the code into 'qemuMigrationCookieNBDXMLFormat' and use modern XML
formatting code patterns.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-05 15:58:52 +02:00
Peter Krempa
84589ac004 qemuMigrationCookieNetworkXMLFormat: Refactor XML formatting
Use 'virXMLFormatElement' both for formating the whole <network> element
but also for formatting the <interface> subelements. This alows to
remove the crazy logic which was determining which element was already
formatted.

Additional simplification is achieved by switching to skipping the loop
using 'continue' rather than putting everything in a giant block.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-05 15:58:52 +02:00
Peter Krempa
592a9a859a qemuMigrationCookieGraphicsXMLFormat: Use 'virXMLFormatElement'
Switch to the two buffer approach to simplify the logic for terminating
the element.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-05 15:58:52 +02:00
Peter Krempa
600c1b5202 qemuMigrationCookieXMLParse: Remove 'error' label
Now it only returns -1 so we can do that directly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-05 15:58:52 +02:00
Peter Krempa
8c3f86e290 qemuMigrationCookieXMLParse: Remove comment mentioning that error was already set
Most of our functions report errors so there's no need to mention it
here again.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-05 15:58:52 +02:00
Peter Krempa
a9b4e523d7 qemuMigrationCookieXMLParse: Decrease scope of 'nodes' and use automatic freeing
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-05 15:58:52 +02:00
Peter Krempa
25b944e067 qemuMigrationCookieXMLParse: Check domain element count more defensively
Make sure that 'virXPathNodeSet' returns '1' as the only expected value
rather than relying on the fact that the previous check for the number
of elements ensures success of the subsequent call.

The error message no longer mentions the number of <domain> elements in
the cookie, but this is a very unlikely internal error anyways.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-05 15:58:52 +02:00
Peter Krempa
4a7dd2780c qemuMigrationCookieXMLParse: Switch to single-purpose temporary variables
Don't reuse 'tmp' over and over, but switch to single use automaticaly
freed variables instead.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-05 15:58:52 +02:00
Peter Krempa
dd6f669d2c qemu: migration_cookie: Extract parsing/validation of mandatory features
Move the code into 'qemuMigrationCookieXMLParseMandatoryFeatures' to
simplify 'qemuMigrationCookieXMLParse'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-05 15:58:52 +02:00