<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>body { line-height: 1.5; }blockquote { margin-top: 0px; margin-bottom: 0px; margin-left: 0.5em; }p { margin-top: 0px; margin-bottom: 0px; }div.foxdiv20170321102844985552 { }body { font-size: 10.5pt; font-family: 微软雅黑; color: rgb(0, 0, 0); line-height: 1.5; }</style>
</head>
<body>
<div><span></span>Rich,</div>
<div>Thanks for your feedback. </div>
<div><span style="font-size: 10.5pt; line-height: 1.5; background-color: window;">Adding sync didn't fix it either. </span><span style="font-size: 10.5pt; line-height: 1.5; background-color: window;">Since I'm working on an urgent project right now, i'll just
 try the easiest possible fix which is to migrate the service to a higher version of OS and use a newer libguestfs for now.</span></div>
<div>Once I have time, i'll debug the older version and let you know if there's a bug.</div>
<div><br>
</div>
<blockquote style="margin-top: 0px; margin-bottom: 0px; margin-left: 0.5em;">
<div> </div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<div style="PADDING-RIGHT: 8px; PADDING-LEFT: 8px; FONT-SIZE: 12px;FONT-FAMILY:tahoma;COLOR:#000000; BACKGROUND: #efefef; PADDING-BOTTOM: 8px; PADDING-TOP: 8px">
<div><b>From:</b> <a href="mailto:rjones@redhat.com">Richard W.M. Jones</a></div>
<div><b>Date:</b> 2017-03-20 17:12</div>
<div><b>To:</b> <a href="mailto:zhangqiang@meizu.com">张强</a></div>
<div><b>CC:</b> <a href="mailto:libguestfs@redhat.com">libguestfs</a>; <a href="mailto:dotslash.lu@gmail.com">
dotslash.lu</a></div>
<div><b>Subject:</b> Re: [Libguestfs] Guestmount seems not to sync changes</div>
</div>
</div>
<div>
<div class="FoxDiv20170321102844985552"><!-- Converted from text/plain format -->
<p><font size="2">On Mon, Mar 20, 2017 at 07:40:18AM +0000, 张强 wrote:<br>
> Hi all,<br>
><br>
> It seems guestmount always fails to flush changes to the mounted qcow2 snapshot.<br>
><br>
> To reproduce this problem:<br>
> 1. take an external snapshot for a qcow2<br>
> 2. guestmount the snapshot<br>
> 3. do some changes, for example: `echo 123 > /test; cat /test`, right now /test can be seen created and containing the right content<br>
> 4. fusermount -u {mount-point}<br>
> 5. virt-cat changed file, for the example above, sometimes /test doesn't exist, sometimes /test does exist but has no content<br>
><br>
> My libguestfs version is 1.20.11, and it's running on CentOS 6.6.<br>
<br>
This is a very old version of libguestfs and CentOS.<br>
<br>
> I tried several ways to work this around, but none of them worked.<br>
><br>
> I suspect it's a cache problem, so I tried to wait a while before umounting the image, sometimes this way works, sometimes it doesn't.<br>
><br>
> I also looked into the documentation for syncing and caching options, I tried to mount the image with fuse options like:<br>
> guestmount -o direct_io -o sync -o sync_read -o big_writes -w<br>
> no luck either.<br>
><br>
> What could be the cause? Is mounting a snapshot a problem?<br>
<br>
It should definitely work.<br>
<br>
Does it work if you add the 'sync' command after fusermount?  There<br>
was a bug in handling the Linux (host) kernel page cache which was<br>
fixed a long time ago, but might still affect that very old version of<br>
libguestfs.<br>
<br>
You could also see if qemu is segfaulting (try enabling core dumps).<br>
In all modern versions of libguestfs, this should be caught and<br>
flagged as an error, but maybe you are missing the error because<br>
guestmount runs in the background.<br>
<br>
You can also try debugging guestmount (with --trace --verbose), which<br>
will show the libguestfs API calls being made.  Check in particular<br>
that the "/test" file gets created through the API, and that the<br>
libguestfs shutdown API is called and there is no error.<br>
<br>
Rich.<br>
<br>
--<br>
Richard Jones, Virtualization Group, Red Hat <a href="http://people.redhat.com/~rjones">
http://people.redhat.com/~rjones</a><br>
Read my programming and virtualization blog: <a href="http://rwmj.wordpress.com">
http://rwmj.wordpress.com</a><br>
virt-top is 'top' for virtual machines.  Tiny program with many<br>
powerful monitoring features, net stats, disk stats, logging, etc.<br>
<a href="http://people.redhat.com/~rjones/virt-top">http://people.redhat.com/~rjones/virt-top</a><br>
</font></p>
</div>
</div>
</blockquote>
</body>
</html>