Bug 714981

Summary: 'list-filesystems' does not know about virtio 9p filesystems or detect existing mounts
Product: [Community] Virtualization Tools Reporter: Daniel BerrangĂ© <berrange>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: mbooth, moli, virt-maint
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-06-22 17:01:08 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Daniel Berrangé 2011-06-21 14:08:00 UTC
Description of problem:
I have launched a QEMU guest with a virtio 9p filesystem

 -fsdev local,security_model=passthrough,id=fsdev-fs0,path=/home/berrange/export -device virtio-9p-pci,id=fs0,fsdev=fsdev-fs0,mount_tag=my-host-export-fs,bus=pci.0,addr=0x3 

This can be mounted as a filesystem inside the guest with

  mount -t 9p -o trans=virtio my-host-export-fs /mnt

I'm not sure how we can enumerate exported 9p filesystems from within the guest, but assuming we can do that, it would be desirable for 'list-filesystems' to display 9p filesystems, and to be able to mount/unmount them as with block devices.

Version-Release number of selected component (if applicable):
libguestfs-1.10.3-1.fc15.x86_64  (self-built, not Fedora builds)

How reproducible:

Steps to Reproduce:
1. Launch a guest with something like this:

domain type='kvm'>

    <type arch='x86_64'>hvm</type>
    <cmdline>console=ttyS0 init=/bin/sh vga=0x318 quiet edd=off</cmdline>
      <source dir='/'/>
      <target dir='org.kernel.root'/>
    <serial type='pty'>
    <input type='tablet' bus='usb'/>
      <model type='cirrus'/>
    <graphics type='vnc'/>
    <channel type='unix'>
      <source mode='server' path='/tmp/guestfs'/>
      <target type='virtio' name='org.libguestfs.channel.0'/>
    <interface type='user'>
      <model type='virtio'/>

(This custom initrd mounts the exported host FS as the guest's root fs)

2. Spawn  guestfsd in the guest
3. In guestfish on host
set-attach-method unix:/tmp/guestfs
ls /

Actual results:
No 9p filesystems listed
libguestfs: error: ls: ls_stub: you must call 'mount' first to mount the root filesystem

Expected results:
Should list the 9p filesystem, and also detect if any filesystems are already mounted

Additional info:

Comment 1 Daniel Berrangé 2011-06-21 14:30:51 UTC
I found a place in sysfs you can enumerate 9p filesystems. Assuming the 'virtio_9p' module has been loaded, you can iterate reading the 'mount_tag' file from the subdirectories:


Comment 2 Richard W.M. Jones 2011-06-21 14:44:18 UTC
list-filesystems is a "meta" API call.  It is implemented on
the library side (not in the daemon) and works by calling out
to various daemon functions including list-devices, list-partitions,
lvs and vfs-type.


It would therefore make sense to implement another daemon
function like "list-9ps" which would return all 9p filesystems
(by looking in the /sys directory mentioned above).  Then
extend list-filesystems to call this.  Presumably all 9p
filesystems will have the type "9p" so it won't be necessary
to call vfs-type on them.

Comment 3 Richard W.M. Jones 2011-06-21 14:46:15 UTC
Although use of mount_tag (instead of a device) is going
to cause no end of confusion throughout the rest of the API ...

Comment 4 Richard W.M. Jones 2011-06-22 12:15:02 UTC
Patches posted here:
These are not complete or tested yet.