Bug 714981 - 'list-filesystems' does not know about virtio 9p filesystems or detect existing mounts
'list-filesystems' does not know about virtio 9p filesystems or detect existi...
Status: CLOSED UPSTREAM
Product: Virtualization Tools
Classification: Community
Component: libguestfs (Show other bugs)
unspecified
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Richard W.M. Jones
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2011-06-21 10:08 EDT by Daniel Berrange
Modified: 2012-03-13 06:27 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2011-06-22 13:01:08 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Daniel Berrange 2011-06-21 10:08:00 EDT
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:
Always

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

domain type='kvm'>
  <name>firefox</name>
  <memory>1000000</memory>

  <os>
    <type arch='x86_64'>hvm</type>
    <initrd>/home/berrange/initrd-2.6.35.13-91.fc14.x86_64.img</initrd>
    <kernel>/boot/vmlinuz-2.6.35.13-91.fc14.x86_64</kernel>
    <cmdline>console=ttyS0 init=/bin/sh vga=0x318 quiet edd=off</cmdline>
  </os>
  <features>
    <acpi/>
  </features>
  <devices>
  <emulator>/usr/bin/qemu-kvm</emulator>
    <filesystem>
      <source dir='/'/>
      <target dir='org.kernel.root'/>
    </filesystem>
    <serial type='pty'>
    </serial>
    <input type='tablet' bus='usb'/>
    <video>
      <model type='cirrus'/>
    </video>
    <graphics type='vnc'/>
    <channel type='unix'>
      <source mode='server' path='/tmp/guestfs'/>
      <target type='virtio' name='org.libguestfs.channel.0'/>
    </channel>
    <interface type='user'>
      <model type='virtio'/>
    </interface>
  </devices>
</domain>

(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
launch
list-filesystems
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 Berrange 2011-06-21 10:30:51 EDT
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:

  /sys/bus/virtio/drivers/9pnet_virtio/virtio*/
Comment 2 Richard W.M. Jones 2011-06-21 10:44:18 EDT
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.

http://git.annexia.org/?p=libguestfs.git;a=blob;f=src/listfs.c;hb=HEAD

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 10:46:15 EDT
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 08:15:02 EDT
Patches posted here:
https://www.redhat.com/archives/libguestfs/2011-June/msg00122.html
These are not complete or tested yet.

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