Description of problem: Should report error when trying to hotplug virtiofs device with the same target dir Version-Release number of selected component (if applicable): libvirt-9.0.0-6.el9.x86_64 How reproducible: 100% Steps to Reproduce: 1.Prepare two virtiofs devices with the same target dir: #cat fs1.xml <filesystem accessmode="passthrough" type="mount"> <driver queue="512" type="virtiofs" /> <source dir="/var/tmp/mount_tag1" /> **<target dir="mount_tag0" />** <binary path="/usr/libexec/virtiofsd" xattr="on"> <cache mode="none" /> <lock flock="off" posix="off" /> </binary> </filesystem> #cat fs2.xml <filesystem accessmode="passthrough" type="mount"> <driver queue="512" type="virtiofs" /> <source dir="/var/tmp/mount_tag2" /> **<target dir="mount_tag0" />** <binary path="/usr/libexec/virtiofsd" xattr="on"> <cache mode="none" /> <lock flock="off" posix="off" /> </binary> </filesystem> 2.Hotplug the virtiofs devices to the guest: #virsh attach-device test fs1.xml #virsh attach-device test fs2.xml 3.Check the xml devices in guest xml: #virsh dumpxml test --xpath //filesystem <filesystem type="mount" accessmode="passthrough"> <driver type="virtiofs" queue="512"/> <binary path="/usr/libexec/virtiofsd" xattr="on"> <cache mode="none"/> <lock posix="off" flock="off"/> </binary> <source dir="/var/tmp/mount_tag2"/> **<target dir="mount_tag0"/>** <alias name="ua-8d50d10c-719d-11ed-91f4-3a40aa736633"/> <address type="pci" domain="0x0000" bus="0x0a" slot="0x00" function="0x0"/> </filesystem> <filesystem type="mount" accessmode="passthrough"> <driver type="virtiofs" queue="512"/> <binary path="/usr/libexec/virtiofsd" xattr="on"> <cache mode="none"/> <lock posix="off" flock="off"/> </binary> <source dir="/var/tmp/mount_tag1"/> **<target dir="mount_tag0"/>** <alias name="ua-8d50d10c-719d-11ed-91f4-3a40aa736613"/> <address type="pci" domain="0x0000" bus="0x0b" slot="0x00" function="0x0"/> </filesystem> 3. Actual results: Hotplugging virtiofs devices with the same target dir can successfully, but can only mount 1 virtiofs device in the guest os. Expected results: Should report error when trying to hotplug virtiofs devices with the same target dir Additional info: 1.Will report error if edit two virtiofs devices with the same target dir: #virsh edit test error: unsupported configuration: filesystem target 'mount_tag0' specified twice Failed. Try again? [y,n,i,f,?]:
Upstream patch: https://listman.redhat.com/archives/libvir-list/2023-June/240227.html
commit a7ee9eac835324854483a231d7931b9329f259bc Author: Ján Tomko <jtomko> CommitDate: 2023-06-12 13:06:31 +0200 conf: virtiofs: validate that the target dir is unique even for hotplug https://bugzilla.redhat.com/show_bug.cgi?id=2171384 Signed-off-by: Ján Tomko <jtomko> Reviewed-by: Martin Kletzander <mkletzan> git describe: v9.4.0-58-ga7ee9eac83
Tested this bug with: libvirt-9.5.0-0rc1.1.el9.x86_64 1.Prepare two virtiofs devices with the same target dir: #cat fs1.xml <filesystem accessmode="passthrough" type="mount"> <driver queue="512" type="virtiofs" /> <source dir="/var/tmp/mount_tag1" /> **<target dir="mount_tag0" />** <binary path="/usr/libexec/virtiofsd" xattr="on"> <cache mode="none" /> <lock flock="off" posix="off" /> </binary> </filesystem> #cat fs2.xml <filesystem accessmode="passthrough" type="mount"> <driver queue="512" type="virtiofs" /> <source dir="/var/tmp/mount_tag2" /> **<target dir="mount_tag0" />** <binary path="/usr/libexec/virtiofsd" xattr="on"> <cache mode="none" /> <lock flock="off" posix="off" /> </binary> </filesystem> 2.Hotplug the virtiofs devices to the guest: #virsh attach-device rhel9.3 fs1.xml Device attached successfully 3.Attach the second virtiofs # virsh attach-device rhel9.3 fs2.xml error: Failed to attach device from fs2.xml error: unsupported configuration: filesystem target 'mount_tag0' specified twice
Verify this bug with: libvirt-9.5.0-3.el9.x86_64 SC1: 1. define a guest with two filesystems with the same target dir <filesystem accessmode="passthrough" type="mount"> <driver queue="512" type="virtiofs" /> <source dir="/var/tmp/mount_tag1" /> **<target dir="mount_tag0" />** <binary path="/usr/libexec/virtiofsd" xattr="on"> <cache mode="none" /> <lock flock="off" posix="off" /> </binary> </filesystem> <filesystem accessmode="passthrough" type="mount"> <driver queue="512" type="virtiofs" /> <source dir="/var/tmp/mount_tag2" /> **<target dir="mount_tag0" />** <binary path="/usr/libexec/virtiofsd" xattr="on"> <cache mode="none" /> <lock flock="off" posix="off" /> </binary> </filesystem> SC2: 1.Prepare two virtiofs devices with the same target dir: #cat fs1.xml <filesystem accessmode="passthrough" type="mount"> <driver queue="512" type="virtiofs" /> <source dir="/var/tmp/mount_tag1" /> **<target dir="mount_tag0" />** <binary path="/usr/libexec/virtiofsd" xattr="on"> <cache mode="none" /> <lock flock="off" posix="off" /> </binary> </filesystem> #cat fs2.xml <filesystem accessmode="passthrough" type="mount"> <driver queue="512" type="virtiofs" /> <source dir="/var/tmp/mount_tag2" /> **<target dir="mount_tag0" />** <binary path="/usr/libexec/virtiofsd" xattr="on"> <cache mode="none" /> <lock flock="off" posix="off" /> </binary> </filesystem> 2.Hotplug the virtiofs devices to the guest: #virsh attach-device rhel9.3 fs1.xml Device attached successfully 3.Attach the second virtiofs # virsh attach-device rhel9.3 fs2.xml error: Failed to attach device from fs2.xml error: unsupported configuration: filesystem target 'mount_tag0' specified twice 2. define the guest # virsh define lizhu.xml error: Failed to define domain from lizhu.xml error: unsupported configuration: filesystem target 'mount_tag0' specified twice SC3: 1. start a guest with filesystem # virsh dumpxml lizhu --xpath //filesystem <filesystem type="mount" accessmode="passthrough"> <driver type="virtiofs" queue="512"/> <binary path="/usr/libexec/virtiofsd" xattr="on"> <cache mode="none"/> <lock posix="off" flock="off"/> </binary> <source dir="/var/tmp/mount_tag1"/> <target dir="mount_tag0"/> <alias name="fs0"/> <address type="pci" domain="0x0000" bus="0x01" slot="0x00" function="0x0"/> </filesystem> 2. attach the following filesystem to the guest # cat fs2.xml <filesystem accessmode="passthrough" type="mount"> <driver queue="512" type="virtiofs" /> <source dir="/var/tmp/mount_tag2" /> <target dir="mount_tag0" /> <binary path="/usr/libexec/virtiofsd" xattr="on"> <cache mode="none" /> <lock flock="off" posix="off" /> </binary> </filesystem> 3. try to attach it # virsh attach-device lizhu fs2.xml error: Failed to attach device from fs2.xml error: unsupported configuration: filesystem target 'mount_tag0' specified twice Mark the bug as verified.