Bug 1969232 - Should fail to validate XML if adding externally launched virtiofsd device without target dir
Summary: Should fail to validate XML if adding externally launched virtiofsd device wi...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux Advanced Virtualization
Classification: Red Hat
Component: libvirt
Version: 8.5
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: 8.5
Assignee: Ján Tomko
QA Contact: Lili Zhu
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-06-08 03:12 UTC by yafu
Modified: 2021-11-16 08:44 UTC (History)
5 users (show)

Fixed In Version: libvirt-7.5.0-1.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-11-16 07:53:43 UTC
Type: Bug
Target Upstream Version: 7.5.0
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2021:4684 0 None None None 2021-11-16 07:54:43 UTC

Description yafu 2021-06-08 03:12:15 UTC
Description of problem:
Should fail to validate XML if adding external virtiofs device without target dir


Version-Release number of selected component (if applicable):
libvirt-daemon-7.4.0-1.module+el8.5.0+11218+83343022.x86_64


How reproducible:
100%

Steps to Reproduce:
1.Edit guest with external virtiofs device without target dir and save xml:
#virsh edit vm1
...
 <filesystem type='mount'>
      <driver type='virtiofs' queue='1024'/>
      <source socket='/var/run/vm001-vhost-fs.sock'/>
      <address type='pci' domain='0x0000' bus='0x0a' slot='0x00' function='0x0'/>
    </filesystem>
...

2.Prepare externally launched virtiofsd:
#/usr/libexec/virtiofsd --socket-path=/var/run/vm001-vhost-fs.sock -o source=/var/lib/fs/vm001
#chown qemu:qemu /var/run/vm001-vhost-fs.sock
#setenfore 0

3.Start guest:
# virsh start vm1
error: Failed to start domain 'vm1'
error: internal error: qemu unexpectedly closed the monitor: 2021-06-08T03:08:38.108264Z qemu-kvm: -device vhost-user-fs-pci,chardev=chr-vu-fs0,queue-size=1024,tag=,bus=pci.10,addr=0x0: tag property cannot be empty


4.

Actual results:
Guest can not start successfully without target dir for virtiofsd device.

Expected results:
Should fail to validate XML if adding externally launched virtiofsd  device without target dir.


Additional info:

Comment 1 Ján Tomko 2021-06-17 11:29:46 UTC
Pushed upstream as:
commit e8863b91fb98f077d4c44a11bd7ea84c5e6b29ef
Author:     Ján Tomko <jtomko>
CommitDate: 2021-06-17 10:51:24 +0200

    conf: require target for external virtiofsd
    
    When adding support for externally launched virtiofsd,
    I was too liberal and did not require a target.
    
    But the target is required, because it's passed to the
    QEMU device, not to virtiofsd.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1969232
    
    Fixes: 12967c3e1333a6e106110f449ccb1e96279b9527
    Fixes: 56dcdec1ac8104f94371c210585bab91eb36395d
    Signed-off-by: Ján Tomko <jtomko>
    Reviewed-by: Peter Krempa <pkrempa>

git describe: v7.4.0-193-ge8863b91fb

Comment 5 Lili Zhu 2021-07-23 14:19:36 UTC
Tested this bug with:
libvirt-7.5.0-1.module+el8.5.0+11664+59f87560.x86_64

1.Edit guest with external virtiofs device without target dir and save xml:
#virsh edit vm1
...
 <filesystem type='mount'>
      <driver type='virtiofs' queue='1024'/>
      <source socket='/var/run/vm001-vhost-fs.sock'/>
      <address type='pci' domain='0x0000' bus='0x0a' slot='0x00' function='0x0'/>
    </filesystem>
...
error: missing target information for device /var/run/vm001-vhost-fs.sock
Failed. Try again? [y,n,i,f,?]: 

1. prepare a xml file fs.xml with the above xml snippet, attach it to the guest
# virsh attach-device RHEL-8.5 fs.xml --config 
error: Failed to attach device from fs.xml
error: missing target information for device /var/run/vm001-vhost-fs.sock

Comment 6 Lili Zhu 2021-07-23 14:29:52 UTC
1. try to validate the guest xml with:
...
 <filesystem type='mount'>
      <driver type='virtiofs' queue='1024'/>
      <source socket='/var/run/vm001-vhost-fs.sock'/>
      <address type='pci' domain='0x0000' bus='0x0a' slot='0x00' function='0x0'/>
    </filesystem>
...

# virt-xml-validate RHEL-8.5.xml 
RHEL-8.5.xml validates

2. delete the line with source element
...
 <filesystem type='mount'>
      <driver type='virtiofs' queue='1024'/>
      <address type='pci' domain='0x0000' bus='0x0a' slot='0x00' function='0x0'/>
    </filesystem>
...

# virt-xml-validate RHEL-8.5.xml 
Relax-NG validity error : Extra element devices in interleave
RHEL-8.5.xml:57: element devices: Relax-NG validity error : Element domain failed to validate content
RHEL-8.5.xml fails to validate

Validate guest xml without source element failed as expected, but without target dir will not.
Please help to check. Thanks.

Comment 7 Ján Tomko 2021-07-27 11:17:10 UTC
I forgot to remove the <optional> tag from the RNG schema. Patch sent upstream:
https://listman.redhat.com/archives/libvir-list/2021-July/msg00802.html

The validation done after 'virsh edit' as shown in comment 5 should be sufficient.
It also gives a more user-friendly error message.

Comment 8 Ján Tomko 2021-07-27 13:33:40 UTC
( the patch from the previous comment was pushed upstream as v7.5.0-271-g5f1a7b2491 )

Comment 9 Lili Zhu 2021-08-04 13:35:33 UTC
Retest this bug with:
libvirt-daemon-7.6.0-1.module+el8.5.0+12097+2c77910b.x86_64

1.Edit guest with external virtiofs device without target dir and save xml:
#virsh edit vm1
...
 <filesystem type='mount'>
      <driver type='virtiofs' queue='1024'/>
      <source socket='/var/run/vm001-vhost-fs.sock'/>
      <address type='pci' domain='0x0000' bus='0x0a' slot='0x00' function='0x0'/>
    </filesystem>
...
error: XML document failed to validate against schema: Unable to validate doc against /usr/share/libvirt/schemas/domain.rng
Extra element devices in interleave
Element domain failed to validate content

Failed. Try again? [y,n,i,f,?]: 

2. prepare a xml file fs.xml with the above xml snippet, attach it to the guest
# virsh attach-device rhel xml --config
error: Failed to attach device from xml
error: missing target information for device /var/run/vm001-vhost-fs.sock


3. try to validate the guest xml with:
...
 <filesystem type='mount'>
      <driver type='virtiofs' queue='1024'/>
      <source socket='/var/run/vm001-vhost-fs.sock'/>
      <address type='pci' domain='0x0000' bus='0x0a' slot='0x00' function='0x0'/>
    </filesystem>
...

# virt-xml-validate rhel.xml 
Relax-NG validity error : Extra element devices in interleave
rhel.xml:32: element devices: Relax-NG validity error : Element domain failed to validate content
rhel.xml fails to validate

As the testing result matches with expected result, mark the bug as verified.

Comment 11 errata-xmlrpc 2021-11-16 07:53:43 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (virt:av bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2021:4684


Note You need to log in before you can comment on or make changes to this bug.