[PATCH v2] virQEMUDriverGetDomainCapabilities: Validate arguments

Martin Kletzander mkletzan at redhat.com
Thu Jan 5 11:57:35 UTC 2023


On Thu, Dec 22, 2022 at 01:00:06PM +0100, Michal Privoznik wrote:
>When calling virConnectGetDomainCapabilities() (exposed as virsh
>domcapabilities) users have option to specify whatever sub-set of
>{ emulatorbin, arch, machine, virttype } they want. Then we have
>a logic (hidden in virQEMUCapsCacheLookupDefault()) that picks
>qemuCaps that satisfy values passed by user. And whatever was not
>specified is then set to the default value as specified by picked
>qemuCaps. For instance: if no machine type was provided but
>emulatorbin was, then the machine type is set to the default one
>as defined by the emulatorbin.
>
>Or, when just virttype was set then the remaining three values
>are set to their respective defaults. Except, we have a crasher
>in this case:
>
>  # virsh domcapabilities --virttype hvf
>  error: Disconnected from qemu:///system due to end of file
>  error: failed to get emulator capabilities
>  error: End of file while reading data: Input/output error
>
>This is because for 'hvf' virttype (at least my) QEMU does not
>have any machine type. Therefore, @machine is set to NULL and the
>rest of the code does not expect that.
>
>What we can do about this is to validate all arguments. Well,
>except for the emulatorbin which is obtained from passed
>qemuCaps. This also fixes the issue when domcapabilities for a
>virttype of a different driver are requested, or a different
>arch.
>
>Signed-off-by: Michal Privoznik <mprivozn at redhat.com>

Reviewed-by: Martin Kletzander <mkletzan at redhat.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20230105/c775e767/attachment.sig>


More information about the libvir-list mailing list