mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemuDomainAttachHostPciDevice: Fall back to mem balloon if there's no hard_limit
If there's no hard_limit set and domain uses VFIO we still must lock the guest memory (prerequisite from qemu). Hence, we should compute the amount to be locked from max_balloon.
This commit is contained in:
parent
b02fd24f18
commit
a45ec678e9
@ -1143,6 +1143,8 @@ int qemuDomainAttachHostPciDevice(virQEMUDriverPtr driver,
|
|||||||
|
|
||||||
if (hostdev->source.subsys.u.pci.backend
|
if (hostdev->source.subsys.u.pci.backend
|
||||||
== VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) {
|
== VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) {
|
||||||
|
unsigned long long memKB;
|
||||||
|
|
||||||
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) {
|
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("VFIO PCI device assignment is not "
|
_("VFIO PCI device assignment is not "
|
||||||
@ -1155,8 +1157,9 @@ int qemuDomainAttachHostPciDevice(virQEMUDriverPtr driver,
|
|||||||
* doesn't hurt to "change" the limit to the same value.
|
* doesn't hurt to "change" the limit to the same value.
|
||||||
*/
|
*/
|
||||||
vm->def->hostdevs[vm->def->nhostdevs++] = hostdev;
|
vm->def->hostdevs[vm->def->nhostdevs++] = hostdev;
|
||||||
virProcessSetMaxMemLock(vm->pid,
|
memKB = vm->def->mem.hard_limit ?
|
||||||
vm->def->mem.hard_limit * 1024);
|
vm->def->mem.hard_limit : vm->def->mem.max_balloon + 1024 * 1024;
|
||||||
|
virProcessSetMaxMemLock(vm->pid, memKB);
|
||||||
vm->def->hostdevs[vm->def->nhostdevs--] = NULL;
|
vm->def->hostdevs[vm->def->nhostdevs--] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user