-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Required information
- Distribution: Ubuntu
- Distribution version: 22.04
- snap: latest/edge
- LXC version: 5.21.1 LTS
- LXD version: 5.21.1 LTS
Issue description
When adding a disk with a long name(longer than 27 bytes) to a running VM, it fails with Error: Failed to start device "device-with-long-name-to-produce-error": Failed to add the virtiofs device: tag property must be 36 bytes or less. This happens when attaching filesystem volumes or adding a drive directory share, but not with block devices. That happens because the tag property that is passed over to qemu can't have more than 36 bytes. This property is being created by appending the device name to lxd_, as seen here. Adding a device to a stopped VM doesn't result in the same error but it fail to start and qemu-system-x86_64:/var/snap/lxd/common/lxd/logs/test-vm/qemu.conf:267: tag property must be 36 bytes or less will be shown in qemu.log.
There are many way to handle this, my suggestion for what should be done is changing the logic for creating the tag property since limiting the device name to 32 bytes is too restrictive. This could be done through a hash(or partial hash) of the device name (eg. using a SHA1 hash encoded in base64 as lxd_ENCODED_NAME_HASH would satisfy the lenght limit).
Steps to reproduce
mkdir -p $HOME/shared_fslxc launch ubuntu:22.04 test-vm --vmlxc config device add test-vm device-with-long-name-to-produce-error disk source=$HOME/shared_fs path=/mnt/test-disk