Skip to content

Unraid, Ubuntu, 9P/virtio and memory issues

Host environment

  • Operating system: Unraid
  • OS/kernel version: Linux stardustunraid 6.1.49-Unraid #1 SMP PREEMPT_DYNAMIC Wed Aug 30 09:42:35 PDT 2023 x86_64 Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz GenuineIntel GNU/Linux
  • Architecture: x86
  • QEMU flavor: qemu-system-x86_64
  • QEMU version: QEMU emulator version 7.1.0
  • QEMU command line:

/usr/local/sbin/qemu
-name guest=UbuntuUnraid,debug-threads=on
-S
-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain-1-UbuntuUnraid/master-key.aes"}'
-blockdev '{"driver":"file","filename":"/usr/share/qemu/ovmf-x64/OVMF_CODE-pure-efi.fd","node-name":"libvirt-pflash0-storage","auto-read-only":true,"discard":"unmap"}'
-blockdev '{"node-name":"libvirt-pflash0-format","read-only":true,"driver":"raw","file":"libvirt-pflash0-storage"}'
-blockdev '{"driver":"file","filename":"/etc/libvirt/qemu/nvram/f45faaaa-aaaa-aaaa-aaaa-aaaaaaaab579_VARS-pure-efi.fd","node-name":"libvirt-pflash1-storage","auto-read-only":true,"discard":"unmap"}'
-blockdev '{"node-name":"libvirt-pflash1-format","read-only":false,"driver":"raw","file":"libvirt-pflash1-storage"}'
-machine pc-q35-7.1,usb=off,dump-guest-core=off,mem-merge=off,memory-backend=pc.ram,pflash0=libvirt-pflash0-format,pflash1=libvirt-pflash1-format
-accel kvm
-cpu host,migratable=on,host-cache-info=on,l3-cache=off
-m 4096
-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":4294967296}'
-overcommit mem-lock=off
-smp 4,sockets=1,dies=1,cores=2,threads=2
-uuid f45faaaa-aaaa-aaaa-aaaa-aaaaaaaab579
-no-user-config
-nodefaults
-chardev socket,id=charmonitor,fd=36,server=on,wait=off
-mon chardev=charmonitor,id=monitor,mode=control
-rtc base=utc,driftfix=slew
-global kvm-pit.lost_tick_policy=delay
-no-hpet
-no-shutdown
-boot strict=on
-device '{"driver":"pcie-root-port","port":16,"chassis":1,"id":"pci.1","bus":"pcie.0","multifunction":true,"addr":"0x2"}'
-device '{"driver":"pcie-root-port","port":17,"chassis":2,"id":"pci.2","bus":"pcie.0","addr":"0x2.0x1"}'
-device '{"driver":"pcie-root-port","port":18,"chassis":3,"id":"pci.3","bus":"pcie.0","addr":"0x2.0x2"}'
-device '{"driver":"pcie-root-port","port":19,"chassis":4,"id":"pci.4","bus":"pcie.0","addr":"0x2.0x3"}'
-device '{"driver":"pcie-root-port","port":20,"chassis":5,"id":"pci.5","bus":"pcie.0","addr":"0x2.0x4"}'
-device '{"driver":"pcie-root-port","port":21,"chassis":6,"id":"pci.6","bus":"pcie.0","addr":"0x2.0x5"}'
-device '{"driver":"pcie-root-port","port":22,"chassis":7,"id":"pci.7","bus":"pcie.0","addr":"0x2.0x6"}'
-device '{"driver":"pcie-root-port","port":23,"chassis":8,"id":"pci.8","bus":"pcie.0","addr":"0x2.0x7"}'
-device '{"driver":"pcie-root-port","port":24,"chassis":9,"id":"pci.9","bus":"pcie.0","multifunction":true,"addr":"0x3"}'
-device '{"driver":"pcie-root-port","port":25,"chassis":10,"id":"pci.10","bus":"pcie.0","addr":"0x3.0x1"}'
-device '{"driver":"ich9-usb-ehci1","id":"usb","bus":"pcie.0","addr":"0x7.0x7"}'
-device '{"driver":"ich9-usb-uhci1","masterbus":"usb.0","firstport":0,"bus":"pcie.0","multifunction":true,"addr":"0x7"}'
-device '{"driver":"ich9-usb-uhci2","masterbus":"usb.0","firstport":2,"bus":"pcie.0","addr":"0x7.0x1"}'
-device '{"driver":"ich9-usb-uhci3","masterbus":"usb.0","firstport":4,"bus":"pcie.0","addr":"0x7.0x2"}'
-device '{"driver":"virtio-serial-pci","id":"virtio-serial0","bus":"pci.3","addr":"0x0"}'
-blockdev '{"driver":"file","filename":"/mnt/user/domains/UbuntuUnraid/vdisk1.img","node-name":"libvirt-3-storage","cache":{"direct":false,"no-flush":false},"auto-read-only":true,"discard":"unmap"}'
-blockdev '{"node-name":"libvirt-3-format","read-only":false,"cache":{"direct":false,"no-flush":false},"driver":"raw","file":"libvirt-3-storage"}'
-device '{"driver":"virtio-blk-pci","bus":"pci.9","addr":"0x0","drive":"libvirt-3-format","id":"virtio-disk2","bootindex":1,"write-cache":"on","serial":"vdisk1"}'
-blockdev '{"driver":"host_device","filename":"/dev/sdb","node-name":"libvirt-2-storage","cache":{"direct":false,"no-flush":false},"auto-read-only":true,"discard":"unmap"}'
-blockdev '{"node-name":"libvirt-2-format","read-only":false,"cache":{"direct":false,"no-flush":false},"driver":"raw","file":"libvirt-2-storage"}'
-device '{"driver":"virtio-blk-pci","bus":"pci.10","addr":"0x0","drive":"libvirt-2-format","id":"virtio-disk3","write-cache":"on","serial":"vdisk2"}'
-blockdev '{"driver":"file","filename":"/mnt/user/isos/ubuntu-22.04.2-live-server-amd64.iso","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}'
-blockdev '{"node-name":"libvirt-1-format","read-only":true,"driver":"raw","file":"libvirt-1-storage"}'
-device '{"driver":"ide-cd","bus":"ide.0","drive":"libvirt-1-format","id":"sata0-0-0","bootindex":2}'
-fsdev local,security_model=passthrough,id=fsdev-fs0,path=/mnt/user/backup
-device '{"driver":"virtio-9p-pci","id":"fs0","fsdev":"fsdev-fs0","mount_tag":"backup","bus":"pci.1","addr":"0x0"}'
-fsdev local,security_model=passthrough,id=fsdev-fs1,path=/mnt/user/documents
-device '{"driver":"virtio-9p-pci","id":"fs1","fsdev":"fsdev-fs1","mount_tag":"documents","bus":"pci.2","addr":"0x0"}'
-fsdev local,security_model=passthrough,id=fsdev-fs2,path=/mnt/user/music
-device '{"driver":"virtio-9p-pci","id":"fs2","fsdev":"fsdev-fs2","mount_tag":"music","bus":"pci.4","addr":"0x0"}'
-fsdev local,security_model=passthrough,id=fsdev-fs3,path=/mnt/user/pictures
-device '{"driver":"virtio-9p-pci","id":"fs3","fsdev":"fsdev-fs3","mount_tag":"pictures","bus":"pci.6","addr":"0x0"}'
-fsdev local,security_model=passthrough,id=fsdev-fs4,path=/mnt/user/video
-device '{"driver":"virtio-9p-pci","id":"fs4","fsdev":"fsdev-fs4","mount_tag":"video","bus":"pci.7","addr":"0x0"}'
-netdev tap,fd=37,id=hostnet0
-device '{"driver":"virtio-net","netdev":"hostnet0","id":"net0","mac":"52:54:00:5c:d2:b0","bus":"pci.8","addr":"0x0"}'
-chardev pty,id=charserial0
-device '{"driver":"isa-serial","chardev":"charserial0","id":"serial0","index":0}'
-chardev socket,id=charchannel0,fd=35,server=on,wait=off
-device '{"driver":"virtserialport","bus":"virtio-serial0.0","nr":1,"chardev":"charchannel0","id":"channel0","name":"org.qemu.guest_agent.0"}'
-device '{"driver":"usb-tablet","id":"input0","bus":"usb.0","port":"1"}'
-audiodev '{"id":"audio1","driver":"none"}'
-vnc 0.0.0.0:0,websocket=5700,audiodev=audio1
-k no
-device '{"driver":"qxl-vga","id":"video0","max_outputs":1,"ram_size":67108864,"vram_size":67108864,"vram64_size_mb":0,"vgamem_mb":16,"bus":"pcie.0","addr":"0x1"}'
-device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.5","addr":"0x0"}'
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny
-msg timestamp=on

Emulated/Virtualized environment

  • Operating system: Ubuntu
  • OS/kernel version: Linux ubuntuunraid 5.15.0-89-generic #99 (closed)-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
  • Architecture: x86

Description of problem

I am running an Ubuntu VM on Unraid - which is using Qemu. I am exposing my shares through "9p Mode" to the VM.

The logs shows: -fsdev local,security_model=passthrough,id=fsdev-fs0,path=/mnt/user/backup
-device '{"driver":"virtio-9p-pci","id":"fs0","fsdev":"fsdev-fs0","mount_tag":"backup","bus":"pci.1","addr":"0x0"}' \

Inside Ubuntu, I mount the exposed shares like this:

sudo mount -t 9p -o trans=virtio "backup" /media/share/backup

I have a script that uses rsync to sync the files from these mounted shares onto an internal disk drive.

The issues that I am facing, is that rsync sometimes reports "cannot allocate memory":

rsync: [sender] readdir("/media/share/backup/myfolder"): Cannot allocate memory (12)

There are "ten thousands" of files in that folder hierarchy, but there are plenty of memory available on the VM (many GBs), so that is no issue. The next time I run the job, it might go through as normal. But I would like to get rid of these issues.

The question is: Is there some kind of memory allocation/limit to the virtio/9p as well? If yes - is there some way to increase it to avoid these errors?

Steps to reproduce

  1. Mount as shown
  2. Run rsync on folder with lots of files
  3. See error

Additional information

N/A

Edited by steinrr
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information