qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [RFC 0/3] tests/vhost-user-fs-test: add vhost-user-fs test case
@ 2019-10-25 10:01 Stefan Hajnoczi
  2019-10-25 10:01 ` [RFC 1/3] WIP virtiofsd: import Linux <fuse.h> header file Stefan Hajnoczi
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Stefan Hajnoczi @ 2019-10-25 10:01 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Thomas Huth, Michael S. Tsirkin, Cornelia Huck,
	Dr. David Alan Gilbert, virtio-fs, Stefan Hajnoczi,
	Paolo Bonzini, vgoyal

This patch series adds an automated test for the vhost-user-fs device using
virtiofsd.  This makes low-level testing of FUSE messages and even VIRTIO
possible.  These things can be hard to do inside a normal guest environment
where such tests require building kernel modules and can result in kernel
panics.

To get a feel for how vhost-user-fs-test.c test cases work, here is an example:

  /* Create file on host and check its contents and metadata in guest */
  static void test_file_from_host(void *parent, void *arg, QGuestAllocator *alloc)
  {
      g_autofree gchar *filename = g_strdup_printf("%s/%s", shared_dir, "foo");
      const char *str = "This is a test\n";
      char buf[strlen(str)];
      QVirtioFS *vfs = parent;
      struct fuse_entry_out entry;
      int32_t error;
      uint64_t nodeid;
      uint64_t fh;
      ssize_t nread;
      gboolean ok;

      SKIP_TEST_IF_CROSS_ENDIAN();

      /* Create the test file in the shared directory */
      ok = g_file_set_contents(filename, str, strlen(str), NULL);
      g_assert(ok);

      fuse_init(vfs);

      error = fuse_lookup(vfs, FUSE_ROOT_ID, "foo", &entry);
      g_assert_cmpint(error, ==, 0);
      g_assert_cmpint(guest64(entry.attr.size), ==, strlen(str));
      nodeid = guest64(entry.nodeid);

      error = fuse_open(vfs, nodeid, O_RDONLY, &fh);
      g_assert_cmpint(error, ==, 0);

      nread = fuse_read(vfs, fh, 0, buf, sizeof(buf));
      g_assert_cmpint(nread, ==, sizeof(buf));
      g_assert_cmpint(memcmp(buf, str, sizeof(buf)), ==, 0);

      fuse_release(vfs, fh);
      fuse_forget(vfs, nodeid);
  }

This patch series is based on "[PATCH v4 00/16] libqos: add VIRTIO PCI 1.0
support" and the https://gitlab.com/virtio-fs/qemu virtio-fs-dev branch.  I
expect conflicts and will resend again once these dependencies have landed in
qemu.git/master.

Stefan Hajnoczi (3):
  WIP virtiofsd: import Linux <fuse.h> header file
  qgraph: add an "after" test callback function
  tests/vhost-user-fs-test: add vhost-user-fs test case

 tests/Makefile.include                        |   8 +-
 contrib/virtiofsd/fuse_lowlevel.h             |   2 +-
 .../standard-headers/linux/fuse.h             |   0
 tests/libqos/qgraph.h                         |   2 +
 tests/libqos/qgraph_internal.h                |   1 +
 tests/libqos/virtio-fs.h                      |  46 ++
 contrib/virtiofsd/fuse_loop_mt.c              |   2 +-
 contrib/virtiofsd/fuse_lowlevel.c             |   2 +-
 contrib/virtiofsd/fuse_virtio.c               |   2 +-
 tests/libqos/qgraph.c                         |   1 +
 tests/libqos/virtio-fs.c                      | 104 +++
 tests/qos-test.c                              |   6 +
 tests/vhost-user-fs-test.c                    | 660 ++++++++++++++++++
 scripts/update-linux-headers.sh               |   3 +-
 14 files changed, 832 insertions(+), 7 deletions(-)
 rename contrib/virtiofsd/fuse_kernel.h => include/standard-headers/linux/fuse.h (100%)
 create mode 100644 tests/libqos/virtio-fs.h
 create mode 100644 tests/libqos/virtio-fs.c
 create mode 100644 tests/vhost-user-fs-test.c

-- 
2.21.0



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-06-01 15:56 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-25 10:01 [RFC 0/3] tests/vhost-user-fs-test: add vhost-user-fs test case Stefan Hajnoczi
2019-10-25 10:01 ` [RFC 1/3] WIP virtiofsd: import Linux <fuse.h> header file Stefan Hajnoczi
2019-10-26 21:49   ` Michael S. Tsirkin
2019-10-27 12:36     ` Stefan Hajnoczi
2020-06-01 10:28       ` Alex Bennée
2020-06-01 15:55         ` Stefan Hajnoczi
2019-10-25 10:01 ` [RFC 2/3] qgraph: add an "after" test callback function Stefan Hajnoczi
2019-10-25 10:01 ` [RFC 3/3] tests/vhost-user-fs-test: add vhost-user-fs test case Stefan Hajnoczi
2019-10-29  0:36   ` Dr. David Alan Gilbert
2019-11-05 16:02     ` Stefan Hajnoczi
2019-11-07 12:26       ` Dr. David Alan Gilbert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).