Daniel Krajnik
2023-Sep-15 01:41 UTC
virtio-mem with virt-install to share memory between guest and host on-demand
Hi I'm trying to Passthrough a GPU to a VM and have it still share its free memory with the host (just like it would with virtio-balloon). Is this something virtio-mem is capable of? I've tried to run it, but it immediately took over 9GB of memory: virt-install --name test --cpu cell0.cpus=0,cell0.memory=4194304,cell1.cpus=1,cell1.memory=4194304 --memory maxMemory=65536,maxMemory.slots=8 --memdev model=virtio-mem,target.node=0,target.block=2048,target.size=1000 --disk size=400 --network network=ai --location=/tmp/debian-12.1.0-amd64-netinst.iso --os-variant=debian11 --graphics none --extra-args "console=ttyS0 Best wishes, Daniel -------------- next part -------------- A non-text attachment was scrubbed... Name: OpenPGP_0xCFC60FFCAAEC3A7D.asc Type: application/pgp-keys Size: 1310 bytes Desc: OpenPGP public key URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20230915/ca2933a3/attachment.bin> -------------- next part -------------- A non-text attachment was scrubbed... Name: OpenPGP_signature.asc Type: application/pgp-signature Size: 228 bytes Desc: OpenPGP digital signature URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20230915/ca2933a3/attachment.sig>
Daniel P. Berrangé
2023-Sep-20 15:59 UTC
virtio-mem with virt-install to share memory between guest and host on-demand
On Fri, Sep 15, 2023 at 02:41:50AM +0100, Daniel Krajnik wrote:> Hi > > I'm trying to Passthrough a GPU to a VM and have it still share its free > memory with the host (just like it would with virtio-balloon). Is this > something virtio-mem is capable of? I've tried to run it, but it immediately > took over 9GB of memory: > > virt-install --name test --cpu > cell0.cpus=0,cell0.memory=4194304,cell1.cpus=1,cell1.memory=4194304 --memory > maxMemory=65536,maxMemory.slots=8 --memdev > model=virtio-mem,target.node=0,target.block=2048,target.size=1000 --disk > size=400 --network network=ai > --location=/tmp/debian-12.1.0-amd64-netinst.iso --os-variant=debian11 > --graphics none --extra-args "console=ttyS0When using PCI device assignment, the VFIO driver requires that libvit pin guest memory into RAM https://gitlab.com/libvirt/libvirt/-/blob/19484ccac5cb1586f9d10d3e6eb9b93ee82885c6/src/qemu/qemu_domain.c#L9567 so that's why you'll see the immediate memory usage. I dont' think there's any way to workaround this limitation automatically. Closest you can get is to actually hot-unplug the RAM your guest isn't using, but that needs manual work to re-hot-plug it if the guest later needs more RAM, so that's not very friendly. With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|