s/domin/domain/ in $SUBJ On Tue, May 09, 2023 at 04:38:52PM +0200, Michal Privoznik wrote:
During hotplug of a NVMe disk we need to adjust the memlock limit. The computation of the limit is handled by qemuDomainGetMemLockLimitBytes() which looks at given domain definition and accounts for various device types (as different types require different amounts). But during disk hotplug the disk is not added to domain definition until the very last moment. Therefore, qemuDomainGetMemLockLimitBytes() has this @forceVFIO argument which tells it to assume VFIO even if there are no signs of VFIO in domain definition. And this kind of works, until the amount needed for NVMe disks changed (in v9.3.0-rc1~52). What's missing in the commit is making @forceVFIO behave the same as if there was an NVMe disk present in the domain definition. But, we can do even better - just mimic whatever we're doing for hostdevs. IOW - introduce qemuDomainAdjustMaxMemLockNVMe() that behaves the same as qemuDomainAdjustMaxMemLockHostdev().
This paragraph sums it up nicely I think, the rest threw me off.
There are subtle differences though: 1) qemuDomainAdjustMaxMemLockHostdev() can afford placing hostdev right at the end of vm->def->hostdevs, because the array was already reallocated (at the beginning of qemuDomainAttachHostPCIDevice()). But qemuDomainAdjustMaxMemLockNVMe() doesn't have that luxury. 2) qemuDomainAdjustMaxMemLockHostdev() places a virDomainHostdevDef pointer into domain definition, while qemuDomainStorageSourceAccessModifyNVMe() (which calls qemuDomainAdjustMaxMemLock()) sees a virStorageSource pointer but domain definition contains virDomainDiskDef. But that
s/that/that's/ maybe?
okay, we can create a dummy disk definition and append it into the domain definition. After this, qemuDomainAdjustMaxMemLock() can be called with @forceVFIO = false, as the disk is now part of domain definition (when computing the new limit). Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2014030#c28 Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
Reviewed-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
Attachment:
signature.asc
Description: PGP signature