<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi Everyone, <br>
<br>
There are lack of information how to use 9p on KVM. I finally made
it work! Here is how:<br>
<br>
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
<div style="background-color: transparent; "><b
id="internal-source-marker_0.6342440925072879"
style="font-weight: normal;">
<h1 dir="ltr"><span style="font-size: 24px; font-family: Arial;
color: rgb(0, 0, 0); background-color: transparent;
font-weight: bold; font-style: normal; font-variant: normal;
text-decoration: none; vertical-align: baseline;
white-space: pre-wrap; ">On host: </span></h1>
<span style="font-size: 15px; font-family: Arial; color: rgb(0,
0, 0); background-color: transparent; font-weight: normal;
font-style: normal; font-variant: normal; text-decoration:
none; vertical-align: baseline; white-space: pre-wrap; ">1.
modify /etc/libvirt/qemu.conf change owner and group to which
will be used for starting KVM. The description how to use
user/group at the end. </span><br>
<span style="font-size: 15px; font-family: Arial; color: rgb(0,
0, 0); background-color: transparent; font-weight: normal;
font-style: normal; font-variant: normal; text-decoration:
none; vertical-align: baseline; white-space: pre-wrap; ">in my
case I used oneadmin:cloud</span><br>
<span style="font-size: 15px; font-family: Arial; color: rgb(0,
0, 0); background-color: rgb(255, 255, 255); font-weight:
normal; font-style: normal; font-variant: normal;
text-decoration: none; vertical-align: baseline; white-space:
pre-wrap; ">and change security_driver to "none"</span><br>
<span style="font-size: 15px; font-family: Arial; color: rgb(0,
0, 0); background-color: transparent; font-weight: normal;
font-style: normal; font-variant: normal; text-decoration:
none; vertical-align: baseline; white-space: pre-wrap; "><br>
2. sudo touch /etc/apparmor.d/disable/usr.sbin.libvirtd</span><br>
<span style="font-size: 15px; font-family: Arial; color: rgb(0,
0, 0); background-color: transparent; font-weight: normal;
font-style: normal; font-variant: normal; text-decoration:
none; vertical-align: baseline; white-space: pre-wrap; "></span><br>
<span style="font-size: 15px; font-family: Arial; color: rgb(0,
0, 0); background-color: transparent; font-weight: normal;
font-style: normal; font-variant: normal; text-decoration:
none; vertical-align: baseline; white-space: pre-wrap; ">I was
not able to modify apparmor. in theory need to add lines like:
</span><br>
<span style="font-size: 12px; font-family: Arial; color: rgb(0,
0, 0); background-color: rgb(255, 255, 255); font-weight:
normal; font-style: normal; font-variant: normal;
text-decoration: none; vertical-align: baseline; white-space:
pre-wrap; ">/path/to/media/ rw,<br class="kix-line-break">
/path/to/media/** rw,</span><br>
<span style="font-size: 15px; font-family: Arial; color: rgb(0,
0, 0); background-color: transparent; font-weight: normal;
font-style: normal; font-variant: normal; text-decoration:
none; vertical-align: baseline; white-space: pre-wrap; ">to
file: </span><span style="font-size: 12px; font-family:
Verdana; color: rgb(0, 0, 0); background-color: rgb(255, 255,
255); font-weight: normal; font-style: normal; font-variant:
normal; text-decoration: none; vertical-align: baseline;
white-space: pre-wrap; "> /etc/apparmor.d/abstractions/libvirt-qemu
</span><span style="font-size: 15px; font-family: Arial; color:
rgb(0, 0, 0); background-color: transparent; font-weight:
normal; font-style: normal; font-variant: normal;
text-decoration: none; vertical-align: baseline; white-space:
pre-wrap; "></span><br>
<span style="font-size: 15px; font-family: Arial; color: rgb(0,
0, 0); background-color: transparent; font-weight: normal;
font-style: normal; font-variant: normal; text-decoration:
none; vertical-align: baseline; white-space: pre-wrap; ">but
it doesn’t work in my case. I will be happy if someone will
give an advice how to setup apparmor. </span><br>
<span style="font-size: 15px; font-family: Arial; color: rgb(0,
0, 0); background-color: transparent; font-weight: normal;
font-style: normal; font-variant: normal; text-decoration:
none; vertical-align: baseline; white-space: pre-wrap; "></span><br>
<span style="font-size: 15px; font-family: Arial; color: rgb(0,
0, 0); background-color: transparent; font-weight: normal;
font-style: normal; font-variant: normal; text-decoration:
none; vertical-align: baseline; white-space: pre-wrap; ">3. in
OpenNebula Template add: </span><br>
<span style="font-size: 15px; font-family: Arial; color: rgb(0,
0, 0); background-color: transparent; font-weight: normal;
font-style: normal; font-variant: normal; text-decoration:
none; vertical-align: baseline; white-space: pre-wrap; ">RAW=[</span><br>
<span style="font-size: 15px; font-family: Arial; color: rgb(0,
0, 0); background-color: transparent; font-weight: normal;
font-style: normal; font-variant: normal; text-decoration:
none; vertical-align: baseline; white-space: pre-wrap;">
DATA=" <devices><filesystem type='mount'
accessmode='mapped'> <source dir=</span></b><b
id="internal-source-marker_0.6342440925072879"
style="font-weight: normal; "><span style="font-size: 15px;
font-family: Arial; color: rgb(0, 0, 0); background-color:
transparent; font-weight: normal; font-style: normal;
font-variant: normal; text-decoration: none; vertical-align:
baseline; white-space: pre-wrap; ">/path/to/media/on/host</span></b><b
id="internal-source-marker_0.6342440925072879"
style="font-weight: normal;"><span style="font-size: 15px;
font-family: Arial; color: rgb(0, 0, 0); background-color:
transparent; font-weight: normal; font-style: normal;
font-variant: normal; text-decoration: none; vertical-align:
baseline; white-space: pre-wrap; ">'/> <target dir='</span><span
style="font-size: 15px; font-family: Arial; color: rgb(0, 0,
0); background-color: rgb(255, 0, 0); font-weight: bold;
font-style: normal; font-variant: normal; text-decoration:
none; vertical-align: baseline; white-space: pre-wrap; ">VirtFS</span><span
style="font-size: 15px; font-family: Arial; color: rgb(0, 0,
0); background-color: transparent; font-weight: normal;
font-style: normal; font-variant: normal; text-decoration:
none; vertical-align: baseline; white-space: pre-wrap; ">'/>
</filesystem> </devices>",</span><br>
<span style="font-size: 15px; font-family: Arial; color: rgb(0,
0, 0); background-color: transparent; font-weight: normal;
font-style: normal; font-variant: normal; text-decoration:
none; vertical-align: baseline; white-space: pre-wrap; ">
TYPE=kvm ]</span><br>
<span style="font-size: 15px; font-family: Arial; color: rgb(0,
0, 0); background-color: transparent; font-weight: normal;
font-style: normal; font-variant: normal; text-decoration:
none; vertical-align: baseline; white-space: pre-wrap; "></span></b><b
id="internal-source-marker_0.6342440925072879"
style="font-weight: normal; "><span style="font-size: 15px;
font-family: Arial; color: rgb(0, 0, 0); background-color:
transparent; font-weight: normal; font-style: normal;
font-variant: normal; text-decoration: none; vertical-align:
baseline; white-space: pre-wrap; "></span></b><br>
<b id="internal-source-marker_0.6342440925072879"
style="font-weight: normal;"><span style="font-size: 15px;
font-family: Arial; color: rgb(0, 0, 0); background-color:
transparent; font-weight: normal; font-style: normal;
font-variant: normal; text-decoration: none; vertical-align:
baseline; white-space: pre-wrap; ">"target dir"</span><span
style="font-size: 15px; font-family: Arial; color: rgb(0, 0,
0); background-color: rgb(255, 0, 0); font-weight: bold;
font-style: normal; font-variant: normal; text-decoration:
none; vertical-align: baseline; white-space: pre-wrap; "></span><span
style="font-size: 15px; font-family: Arial; color: rgb(0, 0,
0); background-color: transparent; font-weight: normal;
font-style: normal; font-variant: normal; text-decoration:
none; vertical-align: baseline; white-space: pre-wrap; "></span></b>
is anything which will be used for mounting. In this example
"VirtFS"<br>
<b id="internal-source-marker_0.6342440925072879"
style="font-weight: normal;"><span style="font-size: 15px;
font-family: Arial; color: rgb(0, 0, 0); background-color:
transparent; font-weight: normal; font-style: normal;
font-variant: normal; text-decoration: none; vertical-align:
baseline; white-space: pre-wrap; "></span><br>
4. change user/group for shared folder: <br>
sudo chown -R </b><b
id="internal-source-marker_0.6342440925072879"
style="font-weight: normal;"><span style="font-size: 15px;
font-family: Arial; color: rgb(0, 0, 0); background-color:
transparent; font-weight: normal; font-style: normal;
font-variant: normal; text-decoration: none; vertical-align:
baseline; white-space: pre-wrap;">oneadmin:cloud </span></b><b
id="internal-source-marker_0.6342440925072879"
style="font-weight: normal; "><span style="font-size: 15px;
font-family: Arial; color: rgb(0, 0, 0); background-color:
transparent; font-weight: normal; font-style: normal;
font-variant: normal; text-decoration: none; vertical-align:
baseline; white-space: pre-wrap; ">/path/to/media/on/host</span></b><b
id="internal-source-marker_0.6342440925072879"
style="font-weight: normal; ">
<h1 dir="ltr"><span style="font-size: 24px; font-family: Arial;
color: rgb(0, 0, 0); background-color: transparent;
font-weight: bold; font-style: normal; font-variant: normal;
text-decoration: none; vertical-align: baseline;
white-space: pre-wrap; ">in VM’s</span></h1>
<span style="font-size: 15px; font-family: Arial; color: rgb(0,
0, 0); background-color: transparent; font-weight: normal;
font-style: normal; font-variant: normal; text-decoration:
none; vertical-align: baseline; white-space: pre-wrap; ">1.
sudo apt-get install linux-image-extra-virtual</span><span
style="font-size: 15px; font-family: Arial; color: rgb(0, 0,
0); background-color: transparent; font-weight: normal;
font-style: normal; font-variant: normal; text-decoration:
none; vertical-align: baseline; white-space: pre-wrap; "></span><br>
2. create folder and setup correct user/group<br>
sudo mkdir /srv/vfs<br>
sudo chown -R max:maxgroup /srv/vfs<br>
<br>
<span style="font-size: 15px; font-family: Arial; color: rgb(0,
0, 0); background-color: transparent; font-weight: normal;
font-style: normal; font-variant: normal; text-decoration:
none; vertical-align: baseline; white-space: pre-wrap; ">3.
and add line to /etc/fstab</span><br>
<span style="font-size: 15px; font-family: Arial; color: rgb(0,
0, 0); background-color: transparent; font-weight: normal;
font-style: normal; font-variant: normal; text-decoration:
none; vertical-align: baseline; white-space: pre-wrap; ">VirtFS<span
class="Apple-tab-span" style="white-space: pre; "> </span><span
class="Apple-tab-span" style="white-space: pre; "> </span>/srv/data<span
class="Apple-tab-span" style="white-space: pre; "> </span>9p<span
class="Apple-tab-span" style="white-space: pre; "> </span>trans=virtio,version=9p2000.L<span
class="Apple-tab-span" style="white-space: pre; "> </span>0<span
class="Apple-tab-span" style="white-space: pre; "> </span>0<br
class="kix-line-break">
</span><br>
<span style="font-size: 15px; font-family: Arial; color: rgb(0,
0, 0); background-color: transparent; font-weight: normal;
font-style: normal; font-variant: normal; text-decoration:
none; vertical-align: baseline; white-space: pre-wrap; ">4.
you can mount manually </span><br>
<span style="font-size: 15px; font-family: Arial; color: rgb(0,
0, 0); background-color: transparent; font-weight: normal;
font-style: normal; font-variant: normal; text-decoration:
none; vertical-align: baseline; white-space: pre-wrap; "> sudo
mount -t 9p -otrans=virtio,version=9p2000.L </span><span
style="font-size: 15px; font-family: Arial; color: rgb(0, 0,
0); background-color: rgb(255, 0, 0); font-weight: bold;
font-style: normal; font-variant: normal; text-decoration:
none; vertical-align: baseline; white-space: pre-wrap; ">VirtFS</span><span
style="font-size: 15px; font-family: Arial; color: rgb(0, 0,
0); background-color: transparent; font-weight: normal;
font-style: normal; font-variant: normal; text-decoration:
none; vertical-align: baseline; white-space: pre-wrap; ">
/srv/vfs<br class="kix-line-break">
</span><br>
<span style="font-size: 15px; font-family: Arial; color: rgb(0,
0, 0); background-color: transparent; font-weight: normal;
font-style: normal; font-variant: normal; text-decoration:
none; vertical-align: baseline; white-space: pre-wrap; "></span></b></div>
How it is works: <br>
After mounting the system will map user/group which used for
mounting point (here is <b
id="internal-source-marker_0.6342440925072879" style="font-weight:
normal; ">max:maxgroup) with user/group for kvm process
(oneadmin:cloud). <br>
<br>
Inside VM user oneadmin (from host) will be shown as max, similar
conversion with groups. All other groups will not be changed <br>
<br>
Hope it will be helpful. <br>
Max<br>
<br>
</b>
</body>
</html>