|
|
(One intermediate revision by the same user not shown) |
Line 5: |
Line 5: |
| I'm also maintaining the 9p based VirtFS implementation, to share files between host and guest. | | I'm also maintaining the 9p based VirtFS implementation, to share files between host and guest. |
|
| |
|
| 1. Download the latest kernel code (2.6.36.rc4 or newer) from http://www.kernel.org to build the kernel image for the guest.
| | == Contact == |
| | |
| 2. Ensure the following 9P options are enabled in the kernel configuration.
| |
| CONFIG_NET_9P=y
| |
| CONFIG_NET_9P_VIRTIO=y
| |
| CONFIG_NET_9P_DEBUG=y (Optional)
| |
| CONFIG_9P_FS=y
| |
| CONFIG_9P_FS_POSIX_ACL=y
| |
| CONFIG_PCI=y
| |
| CONFIG_VIRTIO_PCI=y
| |
| | |
| and these PCI and virtio options:
| |
| CONFIG_PCI=y
| |
| CONFIG_VIRTIO_PCI=y
| |
| CONFIG_PCI_HOST_GENERIC=y (only needed for the QEMU Arm 'virt' board)
| |
| | |
| 3. Get the latest git repository from http://git.qemu.org/ or http://repo.or.cz/w/qemu.git.
| |
| | |
| 4. Configure QEMU for the desired target. Note that if the configuration step prompts ATTR/XATTR as 'no' then you need to install ''libattr'' & ''libattr-dev'' first.
| |
| | |
| For debian based systems install packages ''libattr1'' & ''libattr1-dev'' and for rpm based systems install ''libattr'' & ''libattr-devel''. Proceed to configure and build QEMU.
| |
| | |
| 5. Setup the guest OS image and ensure kvm modules are loaded.
| |
| | |
| == Starting the Guest directly ==
| |
| To start the guest add the following options to enable 9P sharing in QEMU
| |
| -fsdev fsdriver,id=[id],path=[path to share],security_model=[mapped|passthrough|none][,writeout=writeout][,readonly]
| |
| [,socket=socket|sock_fd=sock_fd] -device virtio-9p-pci,fsdev=[id],mount_tag=[mount tag]
| |
|
| |
| You can instead use the following also, which is just a short-cut of the above command.
| |
| -virtfs fsdriver,id=[id],path=[path to share],security_model=[mapped|passthrough|none][,writeout=writeout][,readonly]
| |
| [,socket=socket|sock_fd=sock_fd],mount_tag=[mount tag]
| |
| | |
| Options:
| |
| | |
| * fsdriver: This option specifies the fs driver backend to use. Currently only "local","handle" and "proxy" file system drivers are supported. In future we plan on adding various types of network and cluster filesystems here.
| |
|
| |
| * id: Identifier used to refer to this fsdev.
| |
|
| |
| * path: The path on the host that is identified by this fsdev.
| |
| | |
| * security_model: Valid options are mapped, passthrough & none.No need to specify security_model with "proxy" file system drivers.
| |
| * writeout=writeout: This is an optional argument. The only supported value is "immediate".
| |
| * readonly: Enables exporting 9p share as a readonly mount for guests. By default read-write access is given.
| |
| * socket=socket: Enables proxy filesystem driver to use passed socket file for communicating with virtfs-proxy-helper
| |
| * sock_fd=sock_fd: Enables proxy filesystem driver to use passed socket descriptor for communicating with virtfs-proxy-helper. Usually a helper like libvirt will create socketpair and pass one of the fds as sock_fd
| |
|
| |
| # mapped: Files are created with Qemu user credentials and the client-user's credentials are saved in extended attributes.
| |
| # passthrough: Files on the filesystem are directly created with client-user's credentials.
| |
| # none: It is equivalent to passthrough security model; the only exception is, failure of priviliged operation like chown are ignored. This makes a passthrough like security model usable for people who run kvm as non root.
| |
| * fsdev option is used along with -device driver "virtio-9p-pci".
| |
| * Options for virtio-9p-pci driver are:
| |
| * fsdev=id: Specifies the id value specified along with -fsdev option
| |
| * mount_tag: A tag which acts as a hint to the guest OS and is used to mount this exported path.
| |
| | |
| == Starting the Guest using libvirt ==
| |
| | |
| If using libvirt for management of QEMU/KVM virtual machines, the <filesystem> element can be used to setup 9p sharing for guests
| |
| | |
| <filesystem type='mount' accessmode='$security_model'>
| |
| <source dir='$hostpath'/>
| |
| <target dir='$mount_tag'/>
| |
| </filesystem>
| |
| | |
| In the above XML, the source directory will contain the host path that is to be exported. The target directory should be filled with the mount tag for the device, which despite its name, does not have to actually be a directory path - any string 32 characters or less can be used. The accessmode attribute determines the sharing mode, one of 'passthrough', 'mapped' or 'squashed'.
| |
| | |
| There is no equivalent of the QEMU 'id' attribute, since that is automatically filled in by libvirt. Libvirt will also automatically assign a PCI address for the 9p device, though that can be overridden if desired.
| |
| | |
| == Mounting the shared path ==
| |
| You can mount the shared folder using
| |
| mount -t 9p -o trans=virtio [mount tag] [mount point] -oversion=9p2000.L
| |
| | |
| * mount tag: As specified in Qemu commandline.
| |
| * mount point: Path to mount point.
| |
| * trans: Transport method (here virtio for using 9P over virtio)
| |
| * version: Protocol version. By default it is 9p2000.u .
| |
| == <span id="msize">Contact</span> ==
| |
|
| |
|
| * irc: groug | | * irc: groug |
| * email: groug@kaod.org | | * email: groug@kaod.org |