qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 00/13] 9p: reconcile virtfs with unlinked files


From: Greg Kurz
Subject: [Qemu-devel] [PATCH 00/13] 9p: reconcile virtfs with unlinked files
Date: Mon, 27 Jun 2016 11:40:55 +0200
User-agent: StGit/0.17.1-dirty

This series addresses a long standing issue in 9p, where most syscalls
accessing file attributes out of file descriptor stop to work in the
guest when the file gets unlinked:

open("./test.txt", O_RDWR|O_CREAT, 0666) = 4
unlink("./test.txt")                    = 0
fstat(4, 0x3fffc22108d0)                = -1 ENOENT (No such file or directory)
ftruncate(4, 0)                         = -1 ENOENT (No such file or directory)
utimensat(4, NULL, NULL, 0)             = -1 ENOENT (No such file or directory)
fgetxattr(4, "user.greg", NULL, 0)      = -1 ENOENT (No such file or directory)
flistxattr(4, NULL, 0)                  = -1 ENOENT (No such file or directory)
fchmod(4, 0)                            = -1 ENOENT (No such file or directory)
fchown(4, -1, -1)                       = -1 ENOENT (No such file or directory)

There is also another case where ftruncate() unexpectedly fails:

open("./test.txt", O_RDWR|O_CREAT, 0666) = 4
chmod("./test.txt", 0)                  = 0
ftruncate(4, 0)                         = -1 EACCES (Permission denied)

Since the open+unlink sequence is widely used in applications, these
failures are really a problem, and does not encourage people to using
9p mounts.

The root cause for all these errors is that QEMU uses path based syscalls to
implement 9p operations on file attributes, even if the fid has an open fd.

This series adds new file ops to the internal fsdev API, following the example
of already existing fstat, so that backends can access the fid file descriptor
and pass it to ftruncate(), fchmod() and friends.

This can be tested with a linux guest, provided the 9p client in the kernel is
fixed with the following patches, to ensure it passes open fids (fid associated
to a valid file descriptor) to the 9p server in QEMU.

https://sourceforge.net/p/v9fs/mailman/message/35175775/

With this series and the patched guest kernel, all the failures mentionned
above no longer occur.

---

Greg Kurz (13):
      9p: synth: drop v9fs_ prefix
      9p: factour out duplicate code from local_fstat() and local_lstat()
      9p: introduce the v9fs_get_fd_fid() helper
      9p: getattr: use fstat if we have a fd
      9p: introduce ftruncate file op
      oslib: support futimens() if available
      9p: introduce futimens file op
      9p: add a fd argument to xattr helpers
      9p: introduce fchown file op
      9p: introduce fchmod file op
      9p: xattr fid to reference file fid
      9p: introduce fgetxattr file op
      9p: introduce flistxattr file op


 fsdev/file-op-9p.h        |    9 ++
 hw/9pfs/9p-handle.c       |   85 ++++++++++++---
 hw/9pfs/9p-local.c        |  213 ++++++++++++++++++++++++++++----------
 hw/9pfs/9p-posix-acl.c    |   80 ++++++++++----
 hw/9pfs/9p-proxy.c        |   78 ++++++++++++--
 hw/9pfs/9p-synth.c        |  249 +++++++++++++++++++++++++++------------------
 hw/9pfs/9p-xattr-user.c   |   41 +++++--
 hw/9pfs/9p-xattr.c        |   35 ++++--
 hw/9pfs/9p-xattr.h        |   67 +++++++-----
 hw/9pfs/9p.c              |  189 +++++++++++++++++++++++++++++-----
 hw/9pfs/9p.h              |    3 +
 hw/9pfs/cofs.c            |   79 ++++++++++++++
 hw/9pfs/coth.h            |    7 +
 hw/9pfs/coxattr.c         |   42 ++++++++
 include/sysemu/os-posix.h |    1 
 util/oslib-posix.c        |   10 ++
 16 files changed, 896 insertions(+), 292 deletions(-)

--
Greg




reply via email to

[Prev in Thread] Current Thread [Next in Thread]