<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
</div>
<blockquote style="border-left: 3px solid rgb(200, 200, 200); border-top-color: rgb(200, 200, 200); border-right-color: rgb(200, 200, 200); border-bottom-color: rgb(200, 200, 200); padding-left: 1ex; margin-left: 0.8ex; color: rgb(102, 102, 102);">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Vivek Goyal <vgoyal@redhat.com><br>
<b>Sent:</b> Monday, May 18, 2020 15:37<br>
<b>To:</b> Fotis Xenakis <foxen@windowslive.com><br>
<b>Cc:</b> bo.liu@linux.alibaba.com <bo.liu@linux.alibaba.com>; virtio-fs@redhat.com <virtio-fs@redhat.com><br>
<b>Subject:</b> Re: [Virtio-fs] [PATCH] Fix file descriptor passed for setupmapping</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="PlainText">On Fri, May 15, 2020 at 04:50:31PM +0000, Fotis Xenakis wrote:<br>
> From: Liu Bo <bo.liu@linux.alibaba.com><br>
> Sent: Friday, May 15, 2020 06:48<br>
> To: Fotis Xenakis <foxen@windowslive.com><br>
> Cc: virtio-fs@redhat.com <virtio-fs@redhat.com><br>
> Subject: Re: [Virtio-fs] [PATCH] Fix file descriptor passed for setupmapping<br>
> <br>
> On Wed, May 13, 2020 at 07:33:56PM +0300, Fotis Xenakis wrote:<br>
> > Currently, during FUSE_SETUPMAPPING, virtiofsd passes the wrong file<br>
> > descriptor for the file to mmap() to QEMU (specifically, it passes the<br>
> > file handle as requested from the guest).<br>
> ><br>
> > This fixes it, using lo_fi_fd() to map the file handle to the right file<br>
> > descriptor on the host.<br>
> ><br>
> <br>
> Looks good, guest has been setting fi as NULL though.<br>
> As far as I can see, this function is only called from [1], which passes fi as NULL only when the file handle passed from the guest is (uint64_t)-1. In my testing this was never the case though.<br>
<br>
Hi Fotis,<br>
<br>
Do you know what's different about your setup. This has been working for<br>
me so clearly I am seeing fi as NULL. <br>
</div>
</span></font></div>
</blockquote>
<div>
<div style=""><span style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">Hello,</span><br>
<br>
<span style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">This was on my mind as well: if others were affected by this bug, it wouldn't have gone unnoticed. Yet, I can't say I know what's different in my setup.</span></div>
<div style=""><br>
</div>
<div style=""><span style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">Unfortunately, I have a less-than-basic understanding of virtiofsd, but as far as I can see:</span></div>
<div style=""><span style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">​- virtiofsd differentiates on the file handler passed by the guest [1]. In my case fh </span><span style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">!=
 (uint64_t)-1 (which makes sense tbh). fh is whatever FUSE_OPEN returned.</span><br>
<div>
<div style=""><span style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">​- Guest-side, the open() flags are passed through to FUSE_OPEN [2]. In my case that's O_RDONLY.</span><br>
</div>
</div>
<div style=""><span style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">- The only flag set for FUS</span><span style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">E_INIT is </span><span style="display: inline !important; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">FUSE_MAP_ALIGNMENT
 [3].</span></div>
<div style="">
<div><span style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">​-</span><span style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">​ For what it's worth, virtiofsd runs with "</span><span style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">-o
 cache=always".</span><br>
</div>
<span style="display: inline !important;"></span></div>
</div>
<div style=""><br>
</div>
<div style=""><span style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">References:</span><br>
<span style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">[1] </span><a href="https://gitlab.com/virtio-fs/qemu/-/blob/21336c0f3d05a97f5c409bbc894c19d87259655c/tools/virtiofsd/fuse_lowlevel.c#L1910"><span style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">https://gitlab.com/virtio-fs/qemu/-/blob/21336c0f3d05a97f5c409bbc894c19d87259655c/tools/virtiofsd/fuse_lowlevel.c#L1910</span></a></div>
<div style=""><span style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">[2] </span><a href="https://github.com/foxeng/osv/blob/46255086015a4c801baaf61d431e3aa7eda9e64b/fs/virtiofs/virtiofs_vnops.cc#L111" id="LPNoLP392386"><span style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">https://github.com/foxeng/osv/blob/46255086015a4c801baaf61d431e3aa7eda9e64b/fs/virtiofs/virtiofs_vnops.cc#L111</span></a></div>
<div style=""><span style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">[3] </span><a href="https://github.com/foxeng/osv/blob/46255086015a4c801baaf61d431e3aa7eda9e64b/fs/virtiofs/virtiofs_vfsops.cc#L91" id="LPNoLP215697" style=""><span style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">https://github.com/foxeng/osv/blob/46255086015a4c801baaf61d431e3aa7eda9e64b/fs/virtiofs/virtiofs_vfsops.cc#L91</span></a></div>
<font size="2">
<div class="PlainText" style="font-size: 11pt;">
<blockquote style="border-left: 3px solid rgb(200, 200, 200); border-top-color: rgb(200, 200, 200); border-right-color: rgb(200, 200, 200); border-bottom-color: rgb(200, 200, 200); padding-left: 1ex; margin-left: 0.8ex; color: rgb(102, 102, 102);">
Vivek<br>
</blockquote>
<br>
</div>
</font></div>
</body>
</html>