All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH-V4 00/26] Consolidated VirtFS work
@ 2010-08-29 19:02 Venkateswararao Jujjuri (JV)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 01/26] qemu: virtio-9p: Recognize 9P2000.L protocol Venkateswararao Jujjuri (JV)
                   ` (25 more replies)
  0 siblings, 26 replies; 27+ messages in thread
From: Venkateswararao Jujjuri (JV) @ 2010-08-29 19:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, Venkateswararao Jujjuri

This patch series is a consolidated view of various VirtFS patches on the 
Mailing List.  None of these patches are new in this series.
For sometime all these patches were on the mainling list individually.

Changes from V3:
- Rebased to latest master.

Changes from V2:
- Couple of formatting issues
- Fixed fid_type checks in BUG_ON()

Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>

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

* [Qemu-devel] [PATCH -V4 01/26] qemu: virtio-9p: Recognize 9P2000.L protocol
  2010-08-29 19:02 [Qemu-devel] [PATCH-V4 00/26] Consolidated VirtFS work Venkateswararao Jujjuri (JV)
@ 2010-08-29 19:02 ` Venkateswararao Jujjuri (JV)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 02/26] qemu: virtio-9p: Implement statfs support in server Venkateswararao Jujjuri (JV)
                   ` (24 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Venkateswararao Jujjuri (JV) @ 2010-08-29 19:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, M. Mohan Kumar, Venkateswararao Jujjuri

From: M. Mohan Kumar <mohan@in.ibm.com>

Make 9P server recognize 9P2000.L protocol version

Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
---
 hw/virtio-9p.c |    6 +++++-
 hw/virtio-9p.h |    6 ++++++
 2 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index 047c7ea..107a66c 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -1025,7 +1025,11 @@ static void v9fs_version(V9fsState *s, V9fsPDU *pdu)
 
     pdu_unmarshal(pdu, offset, "ds", &msize, &version);
 
-    if (strcmp(version.data, "9P2000.u")) {
+    if (!strcmp(version.data, "9P2000.u")) {
+        s->proto_version = V9FS_PROTO_2000U;
+    } else if (!strcmp(version.data, "9P2000.L")) {
+        s->proto_version = V9FS_PROTO_2000L;
+    } else {
         v9fs_string_sprintf(&version, "unknown");
     }
 
diff --git a/hw/virtio-9p.h b/hw/virtio-9p.h
index 67f8087..9286f59 100644
--- a/hw/virtio-9p.h
+++ b/hw/virtio-9p.h
@@ -57,6 +57,11 @@ enum {
     P9_QTFILE = 0x00,
 };
 
+enum p9_proto_version {
+    V9FS_PROTO_2000U = 0x01,
+    V9FS_PROTO_2000L = 0x02,
+};
+
 #define P9_NOTAG    (u16)(~0)
 #define P9_NOFID    (u32)(~0)
 #define P9_MAXWELEM 16
@@ -144,6 +149,7 @@ typedef struct V9fsState
     uint16_t tag_len;
     uint8_t *tag;
     size_t config_size;
+    enum p9_proto_version proto_version;
 } V9fsState;
 
 typedef struct V9fsCreateState {
-- 
1.6.5.2

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

* [Qemu-devel] [PATCH -V4 02/26] qemu: virtio-9p: Implement statfs support in server
  2010-08-29 19:02 [Qemu-devel] [PATCH-V4 00/26] Consolidated VirtFS work Venkateswararao Jujjuri (JV)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 01/26] qemu: virtio-9p: Recognize 9P2000.L protocol Venkateswararao Jujjuri (JV)
@ 2010-08-29 19:02 ` Venkateswararao Jujjuri (JV)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 03/26] virtio-9p: Return correct error from v9fs_remove Venkateswararao Jujjuri (JV)
                   ` (23 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Venkateswararao Jujjuri (JV) @ 2010-08-29 19:02 UTC (permalink / raw)
  To: qemu-devel
  Cc: Sripathi Kodi, aliguori, M. Mohan Kumar, Venkateswararao Jujjuri

From: M. Mohan Kumar <mohan@in.ibm.com>

Implement statfs support in qemu server based on Sripathi's
initial statfs patch.

Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
Signed-off-by: Sripathi Kodi <sripathik@in.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
---
 hw/file-op-9p.h      |    1 +
 hw/virtio-9p-local.c |    6 ++++
 hw/virtio-9p.c       |   63 ++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/virtio-9p.h       |   24 +++++++++++++++++++
 4 files changed, 94 insertions(+), 0 deletions(-)

diff --git a/hw/file-op-9p.h b/hw/file-op-9p.h
index a741c93..dd82ac7 100644
--- a/hw/file-op-9p.h
+++ b/hw/file-op-9p.h
@@ -74,6 +74,7 @@ typedef struct FileOperations
     int (*rename)(FsContext *, const char *, const char *);
     int (*truncate)(FsContext *, const char *, off_t);
     int (*fsync)(FsContext *, int);
+    int (*statfs)(FsContext *s, const char *path, struct statfs *stbuf);
     void *opaque;
 } FileOperations;
 #endif
diff --git a/hw/virtio-9p-local.c b/hw/virtio-9p-local.c
index 43c03c1..82f41c6 100644
--- a/hw/virtio-9p-local.c
+++ b/hw/virtio-9p-local.c
@@ -466,6 +466,11 @@ static int local_fsync(FsContext *ctx, int fd)
     return fsync(fd);
 }
 
+static int local_statfs(FsContext *s, const char *path, struct statfs *stbuf)
+{
+   return statfs(rpath(s, path), stbuf);
+}
+
 FileOperations local_ops = {
     .lstat = local_lstat,
     .readlink = local_readlink,
@@ -493,4 +498,5 @@ FileOperations local_ops = {
     .utime = local_utime,
     .remove = local_remove,
     .fsync = local_fsync,
+    .statfs = local_statfs,
 };
diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index 107a66c..f385183 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -2144,9 +2144,72 @@ out:
     qemu_free(vs);
 }
 
+static int v9fs_do_statfs(V9fsState *s, V9fsString *path, struct statfs *stbuf)
+{
+    return s->ops->statfs(&s->ctx, path->data, stbuf);
+}
+
+static void v9fs_statfs_post_statfs(V9fsState *s, V9fsStatfsState *vs, int err)
+{
+    if (err) {
+        err = -errno;
+        goto out;
+    }
+
+    vs->v9statfs.f_type = vs->stbuf.f_type;
+    vs->v9statfs.f_bsize = vs->stbuf.f_bsize;
+    vs->v9statfs.f_blocks = vs->stbuf.f_blocks;
+    vs->v9statfs.f_bfree = vs->stbuf.f_bfree;
+    vs->v9statfs.f_bavail = vs->stbuf.f_bavail;
+    vs->v9statfs.f_files = vs->stbuf.f_files;
+    vs->v9statfs.f_ffree = vs->stbuf.f_ffree;
+    vs->v9statfs.fsid_val = (unsigned int) vs->stbuf.f_fsid.__val[0] |
+			(unsigned long long)vs->stbuf.f_fsid.__val[1] << 32;
+    vs->v9statfs.f_namelen = vs->stbuf.f_namelen;
+
+    vs->offset += pdu_marshal(vs->pdu, vs->offset, "ddqqqqqqd",
+         vs->v9statfs.f_type, vs->v9statfs.f_bsize, vs->v9statfs.f_blocks,
+         vs->v9statfs.f_bfree, vs->v9statfs.f_bavail, vs->v9statfs.f_files,
+         vs->v9statfs.f_ffree, vs->v9statfs.fsid_val,
+         vs->v9statfs.f_namelen);
+
+out:
+    complete_pdu(s, vs->pdu, vs->offset);
+    qemu_free(vs);
+}
+
+static void v9fs_statfs(V9fsState *s, V9fsPDU *pdu)
+{
+    V9fsStatfsState *vs;
+    ssize_t err = 0;
+
+    vs = qemu_malloc(sizeof(*vs));
+    vs->pdu = pdu;
+    vs->offset = 7;
+
+    memset(&vs->v9statfs, 0, sizeof(vs->v9statfs));
+
+    pdu_unmarshal(vs->pdu, vs->offset, "d", &vs->fid);
+
+    vs->fidp = lookup_fid(s, vs->fid);
+    if (vs->fidp == NULL) {
+        err = -ENOENT;
+        goto out;
+    }
+
+    err = v9fs_do_statfs(s, &vs->fidp->path, &vs->stbuf);
+    v9fs_statfs_post_statfs(s, vs, err);
+    return;
+
+out:
+    complete_pdu(s, vs->pdu, err);
+    qemu_free(vs);
+}
+
 typedef void (pdu_handler_t)(V9fsState *s, V9fsPDU *pdu);
 
 static pdu_handler_t *pdu_handlers[] = {
+    [P9_TSTATFS] = v9fs_statfs,
     [P9_TVERSION] = v9fs_version,
     [P9_TATTACH] = v9fs_attach,
     [P9_TSTAT] = v9fs_stat,
diff --git a/hw/virtio-9p.h b/hw/virtio-9p.h
index 9286f59..992c765 100644
--- a/hw/virtio-9p.h
+++ b/hw/virtio-9p.h
@@ -13,6 +13,8 @@
 #define VIRTIO_9P_MOUNT_TAG 0
 
 enum {
+    P9_TSTATFS = 8,
+    P9_RSTATFS,
     P9_TVERSION = 100,
     P9_RVERSION,
     P9_TAUTH = 102,
@@ -252,6 +254,28 @@ struct virtio_9p_config
     uint8_t tag[0];
 } __attribute__((packed));
 
+typedef struct V9fsStatfs
+{
+    uint32_t f_type;
+    uint32_t f_bsize;
+    uint64_t f_blocks;
+    uint64_t f_bfree;
+    uint64_t f_bavail;
+    uint64_t f_files;
+    uint64_t f_ffree;
+    uint64_t fsid_val;
+    uint32_t f_namelen;
+} V9fsStatfs;
+
+typedef struct V9fsStatfsState {
+    V9fsPDU *pdu;
+    size_t offset;
+    int32_t fid;
+    V9fsStatfs v9statfs;
+    V9fsFidState *fidp;
+    struct statfs stbuf;
+} V9fsStatfsState;
+
 extern size_t pdu_packunpack(void *addr, struct iovec *sg, int sg_count,
                             size_t offset, size_t size, int pack);
 
-- 
1.6.5.2

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

* [Qemu-devel] [PATCH -V4 03/26] virtio-9p: Return correct error from v9fs_remove
  2010-08-29 19:02 [Qemu-devel] [PATCH-V4 00/26] Consolidated VirtFS work Venkateswararao Jujjuri (JV)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 01/26] qemu: virtio-9p: Recognize 9P2000.L protocol Venkateswararao Jujjuri (JV)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 02/26] qemu: virtio-9p: Implement statfs support in server Venkateswararao Jujjuri (JV)
@ 2010-08-29 19:02 ` Venkateswararao Jujjuri (JV)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 04/26] [V4] virtio-9p: readdir implementation for 9p2000.L Venkateswararao Jujjuri (JV)
                   ` (22 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Venkateswararao Jujjuri (JV) @ 2010-08-29 19:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, Sripathi Kodi, Venkateswararao Jujjuri

From: Sripathi Kodi <sripathik@in.ibm.com>

Signed-off-by: Sripathi Kodi <sripathik@in.ibm.com>

In v9fs_remove_post_remove() we currently ignore the error returned by
the previous call to remove() and return an error only if freeing the
fid fails. However, the client expects to see the error from remove().
Currently the client falsely thinks that the remove call has always
succeeded. For example, doing rmdir on a non-empty directory does
not return ENOTEMPTY.

With this patch we ignore the error from free_fid(). The client cannot
use this error value anyway.

Signed-off-by: Sripathi Kodi <sripathik@in.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
---
 hw/virtio-9p.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index f385183..cea3935 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -1877,14 +1877,15 @@ static void v9fs_flush(V9fsState *s, V9fsPDU *pdu)
 static void v9fs_remove_post_remove(V9fsState *s, V9fsRemoveState *vs,
                                                                 int err)
 {
-    /* For TREMOVE we need to clunk the fid even on failed remove */
-    err = free_fid(s, vs->fidp->fid);
     if (err < 0) {
-        goto out;
+        err = -errno;
+    } else {
+        err = vs->offset;
     }
 
-    err = vs->offset;
-out:
+    /* For TREMOVE we need to clunk the fid even on failed remove */
+    free_fid(s, vs->fidp->fid);
+
     complete_pdu(s, vs->pdu, err);
     qemu_free(vs);
 }
-- 
1.6.5.2

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

* [Qemu-devel] [PATCH -V4 04/26] [V4] virtio-9p: readdir implementation for 9p2000.L
  2010-08-29 19:02 [Qemu-devel] [PATCH-V4 00/26] Consolidated VirtFS work Venkateswararao Jujjuri (JV)
                   ` (2 preceding siblings ...)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 03/26] virtio-9p: Return correct error from v9fs_remove Venkateswararao Jujjuri (JV)
@ 2010-08-29 19:02 ` Venkateswararao Jujjuri (JV)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 05/26] virtio-9p: Compute iounit based on host filesystem block size Venkateswararao Jujjuri (JV)
                   ` (21 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Venkateswararao Jujjuri (JV) @ 2010-08-29 19:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, Sripathi Kodi, Venkateswararao Jujjuri

From: Sripathi Kodi <sripathik@in.ibm.com>

This patch implements the server part of readdir() implementation for
9p2000.L

    SYNOPSIS

    size[4] Treaddir tag[2] fid[4] offset[8] count[4]
    size[4] Rreaddir tag[2] count[4] data[count]

    DESCRIPTION

    The readdir request asks the server to read the directory specified by 'fid'
    at an offset specified by 'offset' and return as many dirent structures as
    possible that fit into count bytes. Each dirent structure is laid out as
    follows.

            qid.type[1]
              the type of the file (directory, etc.), represented as a bit
              vector corresponding to the high 8 bits of the file's mode
              word.

            qid.vers[4]
              version number for given path

            qid.path[8]
              the file server's unique identification for the file

            offset[8]
              offset into the next dirent.

            type[1]
              type of this directory entry.

            name[256]
              name of this directory entry.

Signed-off-by: Sripathi Kodi <sripathik@in.ibm.com>
Reviewed-by: M. Mohan Kumar <mohan@in.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
---
 hw/virtio-9p-debug.c |   13 +++++
 hw/virtio-9p.c       |  122 ++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/virtio-9p.h       |    2 +
 3 files changed, 137 insertions(+), 0 deletions(-)

diff --git a/hw/virtio-9p-debug.c b/hw/virtio-9p-debug.c
index c1b0e6f..240bec8 100644
--- a/hw/virtio-9p-debug.c
+++ b/hw/virtio-9p-debug.c
@@ -330,6 +330,19 @@ void pprint_pdu(V9fsPDU *pdu)
     BUG_ON(!llogfile);
 
     switch (pdu->id) {
+    case P9_TREADDIR:
+        fprintf(llogfile, "TREADDIR: (");
+        pprint_int32(pdu, 0, &offset, "fid");
+        pprint_int64(pdu, 0, &offset, ", initial offset");
+        pprint_int32(pdu, 0, &offset, ", max count");
+        break;
+    case P9_RREADDIR:
+        fprintf(llogfile, "RREADDIR: (");
+        pprint_int32(pdu, 1, &offset, "count");
+#ifdef DEBUG_DATA
+        pprint_data(pdu, 1, &offset, ", data");
+#endif
+        break;
     case P9_TVERSION:
         fprintf(llogfile, "TVERSION: (");
         pprint_int32(pdu, 0, &offset, "msize");
diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index cea3935..78387b8 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -1577,6 +1577,127 @@ out:
     qemu_free(vs);
 }
 
+typedef struct V9fsReadDirState {
+    V9fsPDU *pdu;
+    V9fsFidState *fidp;
+    V9fsQID qid;
+    off_t saved_dir_pos;
+    struct dirent *dent;
+    int32_t count;
+    int32_t max_count;
+    size_t offset;
+    int64_t initial_offset;
+    V9fsString name;
+} V9fsReadDirState;
+
+static void v9fs_readdir_post_seekdir(V9fsState *s, V9fsReadDirState *vs)
+{
+    vs->offset += pdu_marshal(vs->pdu, vs->offset, "d", vs->count);
+    vs->offset += vs->count;
+    complete_pdu(s, vs->pdu, vs->offset);
+    qemu_free(vs);
+    return;
+}
+
+/* Size of each dirent on the wire: size of qid (13) + size of offset (8)
+ * size of type (1) + size of name.size (2) + strlen(name.data)
+ */
+#define V9_READDIR_DATA_SZ (24 + strlen(vs->name.data))
+
+static void v9fs_readdir_post_readdir(V9fsState *s, V9fsReadDirState *vs)
+{
+    int len;
+    size_t size;
+
+    if (vs->dent) {
+        v9fs_string_init(&vs->name);
+        v9fs_string_sprintf(&vs->name, "%s", vs->dent->d_name);
+
+        if ((vs->count + V9_READDIR_DATA_SZ) > vs->max_count) {
+            /* Ran out of buffer. Set dir back to old position and return */
+            v9fs_do_seekdir(s, vs->fidp->dir, vs->saved_dir_pos);
+            v9fs_readdir_post_seekdir(s, vs);
+            return;
+        }
+
+        /* Fill up just the path field of qid because the client uses
+         * only that. To fill the entire qid structure we will have
+         * to stat each dirent found, which is expensive
+         */
+        size = MIN(sizeof(vs->dent->d_ino), sizeof(vs->qid.path));
+        memcpy(&vs->qid.path, &vs->dent->d_ino, size);
+        /* Fill the other fields with dummy values */
+        vs->qid.type = 0;
+        vs->qid.version = 0;
+
+        len = pdu_marshal(vs->pdu, vs->offset+4+vs->count, "Qqbs",
+                              &vs->qid, vs->dent->d_off,
+                              vs->dent->d_type, &vs->name);
+        vs->count += len;
+        v9fs_string_free(&vs->name);
+        vs->saved_dir_pos = vs->dent->d_off;
+        vs->dent = v9fs_do_readdir(s, vs->fidp->dir);
+        v9fs_readdir_post_readdir(s, vs);
+        return;
+    }
+
+    vs->offset += pdu_marshal(vs->pdu, vs->offset, "d", vs->count);
+    vs->offset += vs->count;
+    complete_pdu(s, vs->pdu, vs->offset);
+    qemu_free(vs);
+    return;
+}
+
+static void v9fs_readdir_post_telldir(V9fsState *s, V9fsReadDirState *vs)
+{
+    vs->dent = v9fs_do_readdir(s, vs->fidp->dir);
+    v9fs_readdir_post_readdir(s, vs);
+    return;
+}
+
+static void v9fs_readdir_post_setdir(V9fsState *s, V9fsReadDirState *vs)
+{
+    vs->saved_dir_pos = v9fs_do_telldir(s, vs->fidp->dir);
+    v9fs_readdir_post_telldir(s, vs);
+    return;
+}
+
+static void v9fs_readdir(V9fsState *s, V9fsPDU *pdu)
+{
+    int32_t fid;
+    V9fsReadDirState *vs;
+    ssize_t err = 0;
+    size_t offset = 7;
+
+    vs = qemu_malloc(sizeof(*vs));
+    vs->pdu = pdu;
+    vs->offset = 7;
+    vs->count = 0;
+
+    pdu_unmarshal(vs->pdu, offset, "dqd", &fid, &vs->initial_offset,
+                                                        &vs->max_count);
+
+    vs->fidp = lookup_fid(s, fid);
+    if (vs->fidp == NULL || !(vs->fidp->dir)) {
+        err = -EINVAL;
+        goto out;
+    }
+
+    if (vs->initial_offset == 0) {
+        v9fs_do_rewinddir(s, vs->fidp->dir);
+    } else {
+        v9fs_do_seekdir(s, vs->fidp->dir, vs->initial_offset);
+    }
+
+    v9fs_readdir_post_setdir(s, vs);
+    return;
+
+out:
+    complete_pdu(s, pdu, err);
+    qemu_free(vs);
+    return;
+}
+
 static void v9fs_write_post_writev(V9fsState *s, V9fsWriteState *vs,
                                    ssize_t err)
 {
@@ -2210,6 +2331,7 @@ out:
 typedef void (pdu_handler_t)(V9fsState *s, V9fsPDU *pdu);
 
 static pdu_handler_t *pdu_handlers[] = {
+    [P9_TREADDIR] = v9fs_readdir,
     [P9_TSTATFS] = v9fs_statfs,
     [P9_TVERSION] = v9fs_version,
     [P9_TATTACH] = v9fs_attach,
diff --git a/hw/virtio-9p.h b/hw/virtio-9p.h
index 992c765..9773659 100644
--- a/hw/virtio-9p.h
+++ b/hw/virtio-9p.h
@@ -15,6 +15,8 @@
 enum {
     P9_TSTATFS = 8,
     P9_RSTATFS,
+    P9_TREADDIR = 40,
+    P9_RREADDIR,
     P9_TVERSION = 100,
     P9_RVERSION,
     P9_TAUTH = 102,
-- 
1.6.5.2

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

* [Qemu-devel] [PATCH -V4 05/26] virtio-9p: Compute iounit based on host filesystem block size
  2010-08-29 19:02 [Qemu-devel] [PATCH-V4 00/26] Consolidated VirtFS work Venkateswararao Jujjuri (JV)
                   ` (3 preceding siblings ...)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 04/26] [V4] virtio-9p: readdir implementation for 9p2000.L Venkateswararao Jujjuri (JV)
@ 2010-08-29 19:02 ` Venkateswararao Jujjuri (JV)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 06/26] virtio-9p: getattr server implementation for 9P2000.L protocol Venkateswararao Jujjuri (JV)
                   ` (20 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Venkateswararao Jujjuri (JV) @ 2010-08-29 19:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, M. Mohan Kumar, Venkateswararao Jujjuri

From: M. Mohan Kumar <mohan@in.ibm.com>

Compute iounit based on the host filesystem block size and pass it to
client with open/create response. Also return iounit as statfs's f_bsize
for optimal block size transfers.

Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
Reviewd-by: Sripathi Kodi <sripathik@in.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
---
 hw/virtio-9p.c |   96 +++++++++++++++++++++++++++++++++++++++++++++-----------
 hw/virtio-9p.h |    9 +++++
 2 files changed, 86 insertions(+), 19 deletions(-)

diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index 78387b8..f6eb0f3 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -253,6 +253,11 @@ static int v9fs_do_fsync(V9fsState *s, int fd)
     return s->ops->fsync(&s->ctx, fd);
 }
 
+static int v9fs_do_statfs(V9fsState *s, V9fsString *path, struct statfs *stbuf)
+{
+    return s->ops->statfs(&s->ctx, path->data, stbuf);
+}
+
 static void v9fs_string_init(V9fsString *str)
 {
     str->data = NULL;
@@ -1019,11 +1024,10 @@ static void v9fs_fix_path(V9fsString *dst, V9fsString *src, int len)
 
 static void v9fs_version(V9fsState *s, V9fsPDU *pdu)
 {
-    int32_t msize;
     V9fsString version;
     size_t offset = 7;
 
-    pdu_unmarshal(pdu, offset, "ds", &msize, &version);
+    pdu_unmarshal(pdu, offset, "ds", &s->msize, &version);
 
     if (!strcmp(version.data, "9P2000.u")) {
         s->proto_version = V9FS_PROTO_2000U;
@@ -1033,7 +1037,7 @@ static void v9fs_version(V9fsState *s, V9fsPDU *pdu)
         v9fs_string_sprintf(&version, "unknown");
     }
 
-    offset += pdu_marshal(pdu, offset, "ds", msize, &version);
+    offset += pdu_marshal(pdu, offset, "ds", s->msize, &version);
     complete_pdu(s, pdu, offset);
 
     v9fs_string_free(&version);
@@ -1288,6 +1292,26 @@ out:
     v9fs_walk_complete(s, vs, err);
 }
 
+static int32_t get_iounit(V9fsState *s, V9fsString *name)
+{
+    struct statfs stbuf;
+    int32_t iounit = 0;
+
+    /*
+     * iounit should be multiples of f_bsize (host filesystem block size
+     * and as well as less than (client msize - P9_IOHDRSZ))
+     */
+    if (!v9fs_do_statfs(s, name, &stbuf)) {
+        iounit = stbuf.f_bsize;
+        iounit *= (s->msize - P9_IOHDRSZ)/stbuf.f_bsize;
+    }
+
+    if (!iounit) {
+        iounit = s->msize - P9_IOHDRSZ;
+    }
+    return iounit;
+}
+
 static void v9fs_open_post_opendir(V9fsState *s, V9fsOpenState *vs, int err)
 {
     if (vs->fidp->dir == NULL) {
@@ -1303,6 +1327,15 @@ out:
 
 }
 
+static void v9fs_open_post_getiounit(V9fsState *s, V9fsOpenState *vs)
+{
+    int err;
+    vs->offset += pdu_marshal(vs->pdu, vs->offset, "Qd", &vs->qid, vs->iounit);
+    err = vs->offset;
+    complete_pdu(s, vs->pdu, err);
+    qemu_free(vs);
+}
+
 static void v9fs_open_post_open(V9fsState *s, V9fsOpenState *vs, int err)
 {
     if (vs->fidp->fd == -1) {
@@ -1310,8 +1343,9 @@ static void v9fs_open_post_open(V9fsState *s, V9fsOpenState *vs, int err)
         goto out;
     }
 
-    vs->offset += pdu_marshal(vs->pdu, vs->offset, "Qd", &vs->qid, 0);
-    err = vs->offset;
+    vs->iounit = get_iounit(s, &vs->fidp->path);
+    v9fs_open_post_getiounit(s, vs);
+    return;
 out:
     complete_pdu(s, vs->pdu, err);
     qemu_free(vs);
@@ -1794,15 +1828,28 @@ out:
     qemu_free(vs);
 }
 
-static void v9fs_post_create(V9fsState *s, V9fsCreateState *vs, int err)
+static void v9fs_create_post_getiounit(V9fsState *s, V9fsCreateState *vs)
 {
-    if (err == 0) {
-        v9fs_string_copy(&vs->fidp->path, &vs->fullname);
-        stat_to_qid(&vs->stbuf, &vs->qid);
+    int err;
+    v9fs_string_copy(&vs->fidp->path, &vs->fullname);
+    stat_to_qid(&vs->stbuf, &vs->qid);
 
-        vs->offset += pdu_marshal(vs->pdu, vs->offset, "Qd", &vs->qid, 0);
+    vs->offset += pdu_marshal(vs->pdu, vs->offset, "Qd", &vs->qid, vs->iounit);
+    err = vs->offset;
 
-        err = vs->offset;
+    complete_pdu(s, vs->pdu, err);
+    v9fs_string_free(&vs->name);
+    v9fs_string_free(&vs->extension);
+    v9fs_string_free(&vs->fullname);
+    qemu_free(vs);
+}
+
+static void v9fs_post_create(V9fsState *s, V9fsCreateState *vs, int err)
+{
+    if (err == 0) {
+        vs->iounit = get_iounit(s, &vs->fidp->path);
+        v9fs_create_post_getiounit(s, vs);
+        return;
     }
 
     complete_pdu(s, vs->pdu, err);
@@ -2266,23 +2313,34 @@ out:
     qemu_free(vs);
 }
 
-static int v9fs_do_statfs(V9fsState *s, V9fsString *path, struct statfs *stbuf)
-{
-    return s->ops->statfs(&s->ctx, path->data, stbuf);
-}
-
 static void v9fs_statfs_post_statfs(V9fsState *s, V9fsStatfsState *vs, int err)
 {
+    int32_t bsize_factor;
+
     if (err) {
         err = -errno;
         goto out;
     }
 
+    /*
+     * compute bsize factor based on host file system block size
+     * and client msize
+     */
+    bsize_factor = (s->msize - P9_IOHDRSZ)/vs->stbuf.f_bsize;
+    if (!bsize_factor) {
+        bsize_factor = 1;
+    }
     vs->v9statfs.f_type = vs->stbuf.f_type;
     vs->v9statfs.f_bsize = vs->stbuf.f_bsize;
-    vs->v9statfs.f_blocks = vs->stbuf.f_blocks;
-    vs->v9statfs.f_bfree = vs->stbuf.f_bfree;
-    vs->v9statfs.f_bavail = vs->stbuf.f_bavail;
+    vs->v9statfs.f_bsize *= bsize_factor;
+    /*
+     * f_bsize is adjusted(multiplied) by bsize factor, so we need to
+     * adjust(divide) the number of blocks, free blocks and available
+     * blocks by bsize factor
+     */
+    vs->v9statfs.f_blocks = vs->stbuf.f_blocks/bsize_factor;
+    vs->v9statfs.f_bfree = vs->stbuf.f_bfree/bsize_factor;
+    vs->v9statfs.f_bavail = vs->stbuf.f_bavail/bsize_factor;
     vs->v9statfs.f_files = vs->stbuf.f_files;
     vs->v9statfs.f_ffree = vs->stbuf.f_ffree;
     vs->v9statfs.fsid_val = (unsigned int) vs->stbuf.f_fsid.__val[0] |
diff --git a/hw/virtio-9p.h b/hw/virtio-9p.h
index 9773659..4ee3830 100644
--- a/hw/virtio-9p.h
+++ b/hw/virtio-9p.h
@@ -70,6 +70,12 @@ enum p9_proto_version {
 #define P9_NOFID    (u32)(~0)
 #define P9_MAXWELEM 16
 
+/*
+ * ample room for Twrite/Rread header
+ * size[4] Tread/Twrite tag[2] fid[4] offset[8] count[4]
+ */
+#define P9_IOHDRSZ 24
+
 typedef struct V9fsPDU V9fsPDU;
 
 struct V9fsPDU
@@ -154,6 +160,7 @@ typedef struct V9fsState
     uint8_t *tag;
     size_t config_size;
     enum p9_proto_version proto_version;
+    int32_t msize;
 } V9fsState;
 
 typedef struct V9fsCreateState {
@@ -167,6 +174,7 @@ typedef struct V9fsCreateState {
     V9fsString name;
     V9fsString extension;
     V9fsString fullname;
+    int iounit;
 } V9fsCreateState;
 
 typedef struct V9fsStatState {
@@ -197,6 +205,7 @@ typedef struct V9fsOpenState {
     V9fsFidState *fidp;
     V9fsQID qid;
     struct stat stbuf;
+    int iounit;
 } V9fsOpenState;
 
 typedef struct V9fsReadState {
-- 
1.6.5.2

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

* [Qemu-devel] [PATCH -V4 06/26] virtio-9p: getattr server implementation for 9P2000.L protocol.
  2010-08-29 19:02 [Qemu-devel] [PATCH-V4 00/26] Consolidated VirtFS work Venkateswararao Jujjuri (JV)
                   ` (4 preceding siblings ...)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 05/26] virtio-9p: Compute iounit based on host filesystem block size Venkateswararao Jujjuri (JV)
@ 2010-08-29 19:02 ` Venkateswararao Jujjuri (JV)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 07/26] virtio-9p: Do not reset atime Venkateswararao Jujjuri (JV)
                   ` (19 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Venkateswararao Jujjuri (JV) @ 2010-08-29 19:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, Sripathi Kodi

From: Sripathi Kodi <sripathi@sripathi.in.ibm.com>

           SYNOPSIS

              size[4] Tgetattr tag[2] fid[4] request_mask[8]

              size[4] Rgetattr tag[2] lstat[n]

           DESCRIPTION

              The getattr transaction inquires about the file identified by fid.
              request_mask is a bit mask that specifies which fields of the
              stat structure is the client interested in.

              The reply will contain a machine-independent directory entry,
              laid out as follows:

                 st_result_mask[8]
                    Bit mask that indicates which fields in the stat structure
                    have been populated by the server

                 qid.type[1]
                    the type of the file (directory, etc.), represented as a bit
                    vector corresponding to the high 8 bits of the file's mode
                    word.

                 qid.vers[4]
                    version number for given path

                 qid.path[8]
                    the file server's unique identification for the file

                 st_mode[4]
                    Permission and flags

                 st_uid[4]
                    User id of owner

                 st_gid[4]
                    Group ID of owner

                 st_nlink[8]
                    Number of hard links

                 st_rdev[8]
                    Device ID (if special file)

                 st_size[8]
                    Size, in bytes

                 st_blksize[8]
                    Block size for file system IO

                 st_blocks[8]
                    Number of file system blocks allocated

                 st_atime_sec[8]
                    Time of last access, seconds

                 st_atime_nsec[8]
                    Time of last access, nanoseconds

                 st_mtime_sec[8]
                    Time of last modification, seconds

                 st_mtime_nsec[8]
                    Time of last modification, nanoseconds

                 st_ctime_sec[8]
                    Time of last status change, seconds

                 st_ctime_nsec[8]
                    Time of last status change, nanoseconds

                 st_btime_sec[8]
                    Time of creation (birth) of file, seconds

                 st_btime_nsec[8]
                    Time of creation (birth) of file, nanoseconds

                 st_gen[8]
                    Inode generation

                 st_data_version[8]
                    Data version number

              request_mask and result_mask bit masks contain the following bits
                 #define P9_STATS_MODE          0x00000001ULL
                 #define P9_STATS_NLINK         0x00000002ULL
                 #define P9_STATS_UID           0x00000004ULL
                 #define P9_STATS_GID           0x00000008ULL
                 #define P9_STATS_RDEV          0x00000010ULL
                 #define P9_STATS_ATIME         0x00000020ULL
                 #define P9_STATS_MTIME         0x00000040ULL
                 #define P9_STATS_CTIME         0x00000080ULL
                 #define P9_STATS_INO           0x00000100ULL
                 #define P9_STATS_SIZE          0x00000200ULL
                 #define P9_STATS_BLOCKS        0x00000400ULL

                 #define P9_STATS_BTIME         0x00000800ULL
                 #define P9_STATS_GEN           0x00001000ULL
                 #define P9_STATS_DATA_VERSION  0x00002000ULL

                 #define P9_STATS_BASIC         0x000007ffULL
                 #define P9_STATS_ALL           0x00003fffULL

        This patch implements the client side of getattr implementation for 9P2000.L.
        It introduces a new structure p9_stat_dotl for getting Linux stat information
        along with QID. The data layout is similar to stat structure in Linux user
        space with the following major differences:

        inode (st_ino) is not part of data. Instead qid is.

        device (st_dev) is not part of data because this doesn't make sense on the
        client.

        All time variables are 64 bit wide on the wire. The kernel seems to use
        32 bit variables for these variables. However, some of the architectures
        have used 64 bit variables and glibc exposes 64 bit variables to user
        space on some architectures. Hence to be on the safer side we have made
        these 64 bit in the protocol. Refer to the comments in
        include/asm-generic/stat.h

        There are some additional fields: st_btime_sec, st_btime_nsec, st_gen,
        st_data_version apart from the bitmask, st_result_mask. The bit mask
        is filled by the server to indicate which stat fields have been
        populated by the server. Currently there is no clean way for the
        server to obtain these additional fields, so it sends back just the
        basic fields.

        Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
        Signed-off-by: Sripathi Kodi <sripathik@in.ibm.com>
---
 hw/virtio-9p-debug.c |   32 ++++++++++++++
 hw/virtio-9p.c       |  112 ++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/virtio-9p.h       |   33 +++++++++++++++
 3 files changed, 177 insertions(+), 0 deletions(-)

diff --git a/hw/virtio-9p-debug.c b/hw/virtio-9p-debug.c
index 240bec8..a880b13 100644
--- a/hw/virtio-9p-debug.c
+++ b/hw/virtio-9p-debug.c
@@ -178,6 +178,30 @@ static void pprint_stat(V9fsPDU *pdu, int rx, size_t *offsetp, const char *name)
     fprintf(llogfile, "}");
 }
 
+static void pprint_stat_dotl(V9fsPDU *pdu, int rx, size_t *offsetp,
+                                                  const char *name)
+{
+    fprintf(llogfile, "%s={", name);
+    pprint_qid(pdu, rx, offsetp, "qid");
+    pprint_int32(pdu, rx, offsetp, ", st_mode");
+    pprint_int64(pdu, rx, offsetp, ", st_nlink");
+    pprint_int32(pdu, rx, offsetp, ", st_uid");
+    pprint_int32(pdu, rx, offsetp, ", st_gid");
+    pprint_int64(pdu, rx, offsetp, ", st_rdev");
+    pprint_int64(pdu, rx, offsetp, ", st_size");
+    pprint_int64(pdu, rx, offsetp, ", st_blksize");
+    pprint_int64(pdu, rx, offsetp, ", st_blocks");
+    pprint_int64(pdu, rx, offsetp, ", atime");
+    pprint_int64(pdu, rx, offsetp, ", atime_nsec");
+    pprint_int64(pdu, rx, offsetp, ", mtime");
+    pprint_int64(pdu, rx, offsetp, ", mtime_nsec");
+    pprint_int64(pdu, rx, offsetp, ", ctime");
+    pprint_int64(pdu, rx, offsetp, ", ctime_nsec");
+    fprintf(llogfile, "}");
+}
+
+
+
 static void pprint_strs(V9fsPDU *pdu, int rx, size_t *offsetp, const char *name)
 {
     int sg_count = get_sg_count(pdu, rx);
@@ -353,6 +377,14 @@ void pprint_pdu(V9fsPDU *pdu)
         pprint_int32(pdu, 1, &offset, "msize");
         pprint_str(pdu, 1, &offset, ", version");
         break;
+    case P9_TGETATTR:
+        fprintf(llogfile, "TGETATTR: (");
+        pprint_int32(pdu, 0, &offset, "fid");
+        break;
+    case P9_RGETATTR:
+        fprintf(llogfile, "RGETATTR: (");
+        pprint_stat_dotl(pdu, 1, &offset, "getattr");
+        break;
     case P9_TAUTH:
         fprintf(llogfile, "TAUTH: (");
         pprint_int32(pdu, 0, &offset, "afid");
diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index f6eb0f3..a8f1735 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -736,6 +736,21 @@ static size_t pdu_marshal(V9fsPDU *pdu, size_t offset, const char *fmt, ...)
                         statp->n_gid, statp->n_muid);
             break;
         }
+        case 'A': {
+            V9fsStatDotl *statp = va_arg(ap, V9fsStatDotl *);
+            offset += pdu_marshal(pdu, offset, "qQdddqqqqqqqqqqqqqqq",
+                        statp->st_result_mask,
+                        &statp->qid, statp->st_mode,
+                        statp->st_uid, statp->st_gid,
+                        statp->st_nlink, statp->st_rdev,
+                        statp->st_size, statp->st_blksize, statp->st_blocks,
+                        statp->st_atime_sec, statp->st_atime_nsec,
+                        statp->st_mtime_sec, statp->st_mtime_nsec,
+                        statp->st_ctime_sec, statp->st_ctime_nsec,
+                        statp->st_btime_sec, statp->st_btime_nsec,
+                        statp->st_gen, statp->st_data_version);
+            break;
+        }
         default:
             break;
         }
@@ -963,6 +978,51 @@ static int stat_to_v9stat(V9fsState *s, V9fsString *name,
     return 0;
 }
 
+#define P9_STATS_MODE          0x00000001ULL
+#define P9_STATS_NLINK         0x00000002ULL
+#define P9_STATS_UID           0x00000004ULL
+#define P9_STATS_GID           0x00000008ULL
+#define P9_STATS_RDEV          0x00000010ULL
+#define P9_STATS_ATIME         0x00000020ULL
+#define P9_STATS_MTIME         0x00000040ULL
+#define P9_STATS_CTIME         0x00000080ULL
+#define P9_STATS_INO           0x00000100ULL
+#define P9_STATS_SIZE          0x00000200ULL
+#define P9_STATS_BLOCKS        0x00000400ULL
+
+#define P9_STATS_BTIME         0x00000800ULL
+#define P9_STATS_GEN           0x00001000ULL
+#define P9_STATS_DATA_VERSION  0x00002000ULL
+
+#define P9_STATS_BASIC         0x000007ffULL /* Mask for fields up to BLOCKS */
+#define P9_STATS_ALL           0x00003fffULL /* Mask for All fields above */
+
+
+static void stat_to_v9stat_dotl(V9fsState *s, const struct stat *stbuf,
+                            V9fsStatDotl *v9lstat)
+{
+    memset(v9lstat, 0, sizeof(*v9lstat));
+
+    v9lstat->st_mode = stbuf->st_mode;
+    v9lstat->st_nlink = stbuf->st_nlink;
+    v9lstat->st_uid = stbuf->st_uid;
+    v9lstat->st_gid = stbuf->st_gid;
+    v9lstat->st_rdev = stbuf->st_rdev;
+    v9lstat->st_size = stbuf->st_size;
+    v9lstat->st_blksize = stbuf->st_blksize;
+    v9lstat->st_blocks = stbuf->st_blocks;
+    v9lstat->st_atime_sec = stbuf->st_atime;
+    v9lstat->st_atime_nsec = stbuf->st_atim.tv_nsec;
+    v9lstat->st_mtime_sec = stbuf->st_mtime;
+    v9lstat->st_mtime_nsec = stbuf->st_mtim.tv_nsec;
+    v9lstat->st_ctime_sec = stbuf->st_ctime;
+    v9lstat->st_ctime_nsec = stbuf->st_ctim.tv_nsec;
+    /* Currently we only support BASIC fields in stat */
+    v9lstat->st_result_mask = P9_STATS_BASIC;
+
+    stat_to_qid(stbuf, &v9lstat->qid);
+}
+
 static struct iovec *adjust_sg(struct iovec *sg, int len, int *iovcnt)
 {
     while (len && *iovcnt) {
@@ -1129,6 +1189,57 @@ out:
     qemu_free(vs);
 }
 
+static void v9fs_getattr_post_lstat(V9fsState *s, V9fsStatStateDotl *vs,
+                                                                int err)
+{
+    if (err == -1) {
+        err = -errno;
+        goto out;
+    }
+
+    stat_to_v9stat_dotl(s, &vs->stbuf, &vs->v9stat_dotl);
+    vs->offset += pdu_marshal(vs->pdu, vs->offset, "A", &vs->v9stat_dotl);
+    err = vs->offset;
+
+out:
+    complete_pdu(s, vs->pdu, err);
+    qemu_free(vs);
+}
+
+static void v9fs_getattr(V9fsState *s, V9fsPDU *pdu)
+{
+    int32_t fid;
+    V9fsStatStateDotl *vs;
+    ssize_t err = 0;
+    V9fsFidState *fidp;
+    uint64_t request_mask;
+
+    vs = qemu_malloc(sizeof(*vs));
+    vs->pdu = pdu;
+    vs->offset = 7;
+
+    memset(&vs->v9stat_dotl, 0, sizeof(vs->v9stat_dotl));
+
+    pdu_unmarshal(vs->pdu, vs->offset, "dq", &fid, &request_mask);
+
+    fidp = lookup_fid(s, fid);
+    if (fidp == NULL) {
+        err = -ENOENT;
+        goto out;
+    }
+
+    /* Currently we only support BASIC fields in stat, so there is no
+     * need to look at request_mask.
+     */
+    err = v9fs_do_lstat(s, &fidp->path, &vs->stbuf);
+    v9fs_getattr_post_lstat(s, vs, err);
+    return;
+
+out:
+    complete_pdu(s, vs->pdu, err);
+    qemu_free(vs);
+}
+
 static void v9fs_walk_complete(V9fsState *s, V9fsWalkState *vs, int err)
 {
     complete_pdu(s, vs->pdu, err);
@@ -2391,6 +2502,7 @@ typedef void (pdu_handler_t)(V9fsState *s, V9fsPDU *pdu);
 static pdu_handler_t *pdu_handlers[] = {
     [P9_TREADDIR] = v9fs_readdir,
     [P9_TSTATFS] = v9fs_statfs,
+    [P9_TGETATTR] = v9fs_getattr,
     [P9_TVERSION] = v9fs_version,
     [P9_TATTACH] = v9fs_attach,
     [P9_TSTAT] = v9fs_stat,
diff --git a/hw/virtio-9p.h b/hw/virtio-9p.h
index 4ee3830..1feed82 100644
--- a/hw/virtio-9p.h
+++ b/hw/virtio-9p.h
@@ -15,6 +15,8 @@
 enum {
     P9_TSTATFS = 8,
     P9_RSTATFS,
+    P9_TGETATTR = 24,
+    P9_RGETATTR,
     P9_TREADDIR = 40,
     P9_RREADDIR,
     P9_TVERSION = 100,
@@ -185,6 +187,37 @@ typedef struct V9fsStatState {
     struct stat stbuf;
 } V9fsStatState;
 
+typedef struct V9fsStatDotl {
+    uint64_t st_result_mask;
+    V9fsQID qid;
+    uint32_t st_mode;
+    uint32_t st_uid;
+    uint32_t st_gid;
+    uint64_t st_nlink;
+    uint64_t st_rdev;
+    uint64_t st_size;
+    uint64_t st_blksize;
+    uint64_t st_blocks;
+    uint64_t st_atime_sec;
+    uint64_t st_atime_nsec;
+    uint64_t st_mtime_sec;
+    uint64_t st_mtime_nsec;
+    uint64_t st_ctime_sec;
+    uint64_t st_ctime_nsec;
+    uint64_t st_btime_sec;
+    uint64_t st_btime_nsec;
+    uint64_t st_gen;
+    uint64_t st_data_version;
+} V9fsStatDotl;
+
+typedef struct V9fsStatStateDotl {
+    V9fsPDU *pdu;
+    size_t offset;
+    V9fsStatDotl v9stat_dotl;
+    struct stat stbuf;
+} V9fsStatStateDotl;
+
+
 typedef struct V9fsWalkState {
     V9fsPDU *pdu;
     size_t offset;
-- 
1.6.5.2

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

* [Qemu-devel] [PATCH -V4 07/26] virtio-9p: Do not reset atime
  2010-08-29 19:02 [Qemu-devel] [PATCH-V4 00/26] Consolidated VirtFS work Venkateswararao Jujjuri (JV)
                   ` (5 preceding siblings ...)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 06/26] virtio-9p: getattr server implementation for 9P2000.L protocol Venkateswararao Jujjuri (JV)
@ 2010-08-29 19:02 ` Venkateswararao Jujjuri (JV)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 08/26] [virtio-9p] Make v9fs_do_utimensat accept timespec structures instead of v9stat Venkateswararao Jujjuri (JV)
                   ` (18 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Venkateswararao Jujjuri (JV) @ 2010-08-29 19:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, M. Mohan Kumar, Venkateswararao Jujjuri

From: M. Mohan Kumar <mohan@in.ibm.com>

    Current code resets file's atime to 0 when there is a change in mtime.
    This results in resetting the atime to "1970-01-01 05:30:00". For
    example, truncate -s 0 filename results in changing the mtime to the
    truncate time, but resets the atime to "1970-01-01 05:30:00". utime
    system call does not have any provision to set only mtime or atime. So
    change v9fs_wstat_post_chmod function to use utimensat function to change
    the atime and mtime fields. If tv_nsec field is set to the special value
    "UTIME_OMIT", corresponding file time stamp is not updated.

Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
---
 hw/file-op-9p.h      |    2 +-
 hw/virtio-9p-local.c |    8 ++++----
 hw/virtio-9p.c       |   28 ++++++++++++++++++++--------
 3 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/hw/file-op-9p.h b/hw/file-op-9p.h
index dd82ac7..120c803 100644
--- a/hw/file-op-9p.h
+++ b/hw/file-op-9p.h
@@ -52,7 +52,7 @@ typedef struct FileOperations
     int (*chmod)(FsContext *, const char *, FsCred *);
     int (*chown)(FsContext *, const char *, FsCred *);
     int (*mknod)(FsContext *, const char *, FsCred *);
-    int (*utime)(FsContext *, const char *, const struct utimbuf *);
+    int (*utimensat)(FsContext *, const char *, const struct timespec *);
     int (*remove)(FsContext *, const char *);
     int (*symlink)(FsContext *, const char *, const char *, FsCred *);
     int (*link)(FsContext *, const char *, const char *);
diff --git a/hw/virtio-9p-local.c b/hw/virtio-9p-local.c
index 82f41c6..dd7277b 100644
--- a/hw/virtio-9p-local.c
+++ b/hw/virtio-9p-local.c
@@ -450,10 +450,10 @@ static int local_chown(FsContext *fs_ctx, const char *path, FsCred *credp)
     return -1;
 }
 
-static int local_utime(FsContext *ctx, const char *path,
-                        const struct utimbuf *buf)
+static int local_utimensat(FsContext *s, const char *path,
+		       const struct timespec *buf)
 {
-    return utime(rpath(ctx, path), buf);
+    return utimensat(AT_FDCWD, rpath(s, path), buf, AT_SYMLINK_NOFOLLOW);
 }
 
 static int local_remove(FsContext *ctx, const char *path)
@@ -495,7 +495,7 @@ FileOperations local_ops = {
     .truncate = local_truncate,
     .rename = local_rename,
     .chown = local_chown,
-    .utime = local_utime,
+    .utimensat = local_utimensat,
     .remove = local_remove,
     .fsync = local_fsync,
     .statfs = local_statfs,
diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index a8f1735..bd6cba9 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -237,10 +237,25 @@ static int v9fs_do_chown(V9fsState *s, V9fsString *path, uid_t uid, gid_t gid)
     return s->ops->chown(&s->ctx, path->data, &cred);
 }
 
-static int v9fs_do_utime(V9fsState *s, V9fsString *path,
-                            const struct utimbuf *buf)
+static int v9fs_do_utimensat(V9fsState *s, V9fsString *path, V9fsStat v9stat)
 {
-    return s->ops->utime(&s->ctx, path->data, buf);
+    struct timespec ts[2];
+
+    if (v9stat.atime != -1) {
+        ts[0].tv_sec = v9stat.atime;
+        ts[0].tv_nsec = 0;
+    } else {
+        ts[0].tv_nsec = UTIME_OMIT;
+    }
+
+    if (v9stat.mtime != -1) {
+        ts[1].tv_sec = v9stat.mtime;
+        ts[1].tv_nsec = 0;
+    } else {
+        ts[1].tv_nsec = UTIME_OMIT;
+    }
+
+    return s->ops->utimensat(&s->ctx, path->data, ts);
 }
 
 static int v9fs_do_remove(V9fsState *s, V9fsString *path)
@@ -2325,11 +2340,8 @@ static void v9fs_wstat_post_chmod(V9fsState *s, V9fsWstatState *vs, int err)
         goto out;
     }
 
-    if (vs->v9stat.mtime != -1) {
-        struct utimbuf tb;
-        tb.actime = 0;
-        tb.modtime = vs->v9stat.mtime;
-        if (v9fs_do_utime(s, &vs->fidp->path, &tb)) {
+    if (vs->v9stat.mtime != -1 || vs->v9stat.atime != -1) {
+        if (v9fs_do_utimensat(s, &vs->fidp->path, vs->v9stat)) {
             err = -errno;
         }
     }
-- 
1.6.5.2

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

* [Qemu-devel] [PATCH -V4 08/26] [virtio-9p] Make v9fs_do_utimensat accept timespec structures instead of v9stat.
  2010-08-29 19:02 [Qemu-devel] [PATCH-V4 00/26] Consolidated VirtFS work Venkateswararao Jujjuri (JV)
                   ` (6 preceding siblings ...)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 07/26] virtio-9p: Do not reset atime Venkateswararao Jujjuri (JV)
@ 2010-08-29 19:02 ` Venkateswararao Jujjuri (JV)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 09/26] virtio-9p: Implement server side of setattr for 9P2000.L protocol Venkateswararao Jujjuri (JV)
                   ` (17 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Venkateswararao Jujjuri (JV) @ 2010-08-29 19:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, Sripathi Kodi, Venkateswararao Jujjuri

From: Sripathi Kodi <sripathik@in.ibm.com>

Currently v9fs_do_utimensat takes a V9fsStat argument and builds
timespec structures. It sets tv_nsec values to 0 by default. Instead
of this it should take struct timespec[2] and pass it down to the
system directly. This will make it more generic and useful
elsewhere.

Signed-off-by: Sripathi Kodi <sripathik@in.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
---
 hw/virtio-9p.c |   37 ++++++++++++++++++-------------------
 1 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index bd6cba9..687f63d 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -237,25 +237,10 @@ static int v9fs_do_chown(V9fsState *s, V9fsString *path, uid_t uid, gid_t gid)
     return s->ops->chown(&s->ctx, path->data, &cred);
 }
 
-static int v9fs_do_utimensat(V9fsState *s, V9fsString *path, V9fsStat v9stat)
+static int v9fs_do_utimensat(V9fsState *s, V9fsString *path,
+                                           const struct timespec times[2])
 {
-    struct timespec ts[2];
-
-    if (v9stat.atime != -1) {
-        ts[0].tv_sec = v9stat.atime;
-        ts[0].tv_nsec = 0;
-    } else {
-        ts[0].tv_nsec = UTIME_OMIT;
-    }
-
-    if (v9stat.mtime != -1) {
-        ts[1].tv_sec = v9stat.mtime;
-        ts[1].tv_nsec = 0;
-    } else {
-        ts[1].tv_nsec = UTIME_OMIT;
-    }
-
-    return s->ops->utimensat(&s->ctx, path->data, ts);
+    return s->ops->utimensat(&s->ctx, path->data, times);
 }
 
 static int v9fs_do_remove(V9fsState *s, V9fsString *path)
@@ -2341,7 +2326,21 @@ static void v9fs_wstat_post_chmod(V9fsState *s, V9fsWstatState *vs, int err)
     }
 
     if (vs->v9stat.mtime != -1 || vs->v9stat.atime != -1) {
-        if (v9fs_do_utimensat(s, &vs->fidp->path, vs->v9stat)) {
+        struct timespec times[2];
+        if (vs->v9stat.atime != -1) {
+            times[0].tv_sec = vs->v9stat.atime;
+            times[0].tv_nsec = 0;
+        } else {
+            times[0].tv_nsec = UTIME_OMIT;
+        }
+        if (vs->v9stat.mtime != -1) {
+            times[1].tv_sec = vs->v9stat.mtime;
+            times[1].tv_nsec = 0;
+        } else {
+            times[1].tv_nsec = UTIME_OMIT;
+        }
+
+        if (v9fs_do_utimensat(s, &vs->fidp->path, times)) {
             err = -errno;
         }
     }
-- 
1.6.5.2

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

* [Qemu-devel] [PATCH -V4 09/26] virtio-9p: Implement server side of setattr for 9P2000.L protocol.
  2010-08-29 19:02 [Qemu-devel] [PATCH-V4 00/26] Consolidated VirtFS work Venkateswararao Jujjuri (JV)
                   ` (7 preceding siblings ...)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 08/26] [virtio-9p] Make v9fs_do_utimensat accept timespec structures instead of v9stat Venkateswararao Jujjuri (JV)
@ 2010-08-29 19:02 ` Venkateswararao Jujjuri (JV)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 10/26] [virtio-9p] Implement TLINK for 9P2000.L Venkateswararao Jujjuri (JV)
                   ` (16 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Venkateswararao Jujjuri (JV) @ 2010-08-29 19:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, Sripathi Kodi, Venkateswararao Jujjuri

From: Sripathi Kodi <sripathik@in.ibm.com>

SYNOPSIS

      size[4] Tsetattr tag[2] attr[n]

      size[4] Rsetattr tag[2]

   DESCRIPTION

      The setattr command changes some of the file status information.
      attr resembles the iattr structure used in Linux kernel. It
      specifies which status parameter is to be changed and to what
      value. It is laid out as follows:

         valid[4]
            specifies which status information is to be changed. Possible
            values are:
            ATTR_MODE       (1 << 0)
            ATTR_UID        (1 << 1)
            ATTR_GID        (1 << 2)
            ATTR_SIZE       (1 << 3)
            ATTR_ATIME      (1 << 4)
            ATTR_MTIME      (1 << 5)
            ATTR_CTIME      (1 << 5)
            ATTR_ATIME_SET  (1 << 7)
            ATTR_MTIME_SET  (1 << 8)

            The last two bits represent whether the time information
            is being sent by the client's user space. In the absense
            of these bits the server always uses server's time.

         mode[4]
            File permission bits

         uid[4]
            Owner id of file

         gid[4]
            Group id of the file

         size[8]
            File size

         atime_sec[8]
            Time of last file access, seconds

         atime_nsec[8]
            Time of last file access, nanoseconds

         mtime_sec[8]
            Time of last file modification, seconds

         mtime_nsec[8]
            Time of last file modification, nanoseconds

Explanation of the patches:
--------------------------

*) The kernel just copies relevent contents of iattr structure to p9_iattr_dotl
   structure and passes it down to the client. The only check it has is calling
   inode_change_ok()
*) The p9_iattr_dotl structure does not have ctime and ia_file parameters because
   I don't think these are needed in our case. The client user space can request
   updating just ctime by calling chown(fd, -1, -1). This is handled on server
   side without a need for putting ctime on the wire.
*) The server currently supports changing mode, time, ownership and size of the
   file.
*) 9P RFC says "Either all the changes in wstat request happen, or none of them
   does: if the request succeeds, all changes were made; if it fails, none were."
   I have not done anything to implement this specifically because I don't see
   a reason.

[jvrao@linux.vnet.ibm.com: Parts of code for handling chown(-1,-1)

Signed-off-by: Sripathi Kodi <sripathik@in.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
---
 hw/virtio-9p-local.c |    5 +-
 hw/virtio-9p.c       |  155 ++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/virtio-9p.h       |   23 ++++++++
 3 files changed, 182 insertions(+), 1 deletions(-)

diff --git a/hw/virtio-9p-local.c b/hw/virtio-9p-local.c
index dd7277b..269fc62 100644
--- a/hw/virtio-9p-local.c
+++ b/hw/virtio-9p-local.c
@@ -442,7 +442,10 @@ static int local_rename(FsContext *ctx, const char *oldpath,
 
 static int local_chown(FsContext *fs_ctx, const char *path, FsCred *credp)
 {
-    if (fs_ctx->fs_sm == SM_MAPPED) {
+    if ((credp->fc_uid == -1 && credp->fc_gid == -1) ||
+            (fs_ctx->fs_sm == SM_PASSTHROUGH)) {
+        return lchown(rpath(fs_ctx, path), credp->fc_uid, credp->fc_gid);
+    } else if (fs_ctx->fs_sm == SM_MAPPED) {
         return local_set_xattr(rpath(fs_ctx, path), credp);
     } else if (fs_ctx->fs_sm == SM_PASSTHROUGH) {
         return lchown(rpath(fs_ctx, path), credp->fc_uid, credp->fc_gid);
diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index 687f63d..39e63cb 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -665,6 +665,15 @@ static size_t pdu_unmarshal(V9fsPDU *pdu, size_t offset, const char *fmt, ...)
                         &statp->n_muid);
             break;
         }
+        case 'I': {
+            V9fsIattr *iattr = va_arg(ap, V9fsIattr *);
+            offset += pdu_unmarshal(pdu, offset, "ddddqqqqq",
+                        &iattr->valid, &iattr->mode,
+                        &iattr->uid, &iattr->gid, &iattr->size,
+                        &iattr->atime_sec, &iattr->atime_nsec,
+                        &iattr->mtime_sec, &iattr->mtime_nsec);
+            break;
+        }
         default:
             break;
         }
@@ -1240,6 +1249,151 @@ out:
     qemu_free(vs);
 }
 
+/* From Linux kernel code */
+#define ATTR_MODE    (1 << 0)
+#define ATTR_UID     (1 << 1)
+#define ATTR_GID     (1 << 2)
+#define ATTR_SIZE    (1 << 3)
+#define ATTR_ATIME   (1 << 4)
+#define ATTR_MTIME   (1 << 5)
+#define ATTR_CTIME   (1 << 6)
+#define ATTR_MASK    127
+#define ATTR_ATIME_SET  (1 << 7)
+#define ATTR_MTIME_SET  (1 << 8)
+
+static void v9fs_setattr_post_truncate(V9fsState *s, V9fsSetattrState *vs,
+                                                                  int err)
+{
+    if (err == -1) {
+        err = -errno;
+        goto out;
+    }
+    err = vs->offset;
+
+out:
+    complete_pdu(s, vs->pdu, err);
+    qemu_free(vs);
+}
+
+static void v9fs_setattr_post_chown(V9fsState *s, V9fsSetattrState *vs, int err)
+{
+    if (err == -1) {
+        err = -errno;
+        goto out;
+    }
+
+    if (vs->v9iattr.valid & (ATTR_SIZE)) {
+        err = v9fs_do_truncate(s, &vs->fidp->path, vs->v9iattr.size);
+    }
+    v9fs_setattr_post_truncate(s, vs, err);
+    return;
+
+out:
+    complete_pdu(s, vs->pdu, err);
+    qemu_free(vs);
+}
+
+static void v9fs_setattr_post_utimensat(V9fsState *s, V9fsSetattrState *vs,
+                                                                   int err)
+{
+    if (err == -1) {
+        err = -errno;
+        goto out;
+    }
+
+    /* If the only valid entry in iattr is ctime we can call
+     * chown(-1,-1) to update the ctime of the file
+     */
+    if ((vs->v9iattr.valid & (ATTR_UID | ATTR_GID)) ||
+            ((vs->v9iattr.valid & ATTR_CTIME)
+            && !((vs->v9iattr.valid & ATTR_MASK) & ~ATTR_CTIME))) {
+        if (!(vs->v9iattr.valid & ATTR_UID)) {
+            vs->v9iattr.uid = -1;
+        }
+        if (!(vs->v9iattr.valid & ATTR_GID)) {
+            vs->v9iattr.gid = -1;
+        }
+        err = v9fs_do_chown(s, &vs->fidp->path, vs->v9iattr.uid,
+                                                vs->v9iattr.gid);
+    }
+    v9fs_setattr_post_chown(s, vs, err);
+    return;
+
+out:
+    complete_pdu(s, vs->pdu, err);
+    qemu_free(vs);
+}
+
+static void v9fs_setattr_post_chmod(V9fsState *s, V9fsSetattrState *vs, int err)
+{
+    if (err == -1) {
+        err = -errno;
+        goto out;
+    }
+
+    if (vs->v9iattr.valid & (ATTR_ATIME | ATTR_MTIME)) {
+        struct timespec times[2];
+        if (vs->v9iattr.valid & ATTR_ATIME) {
+            if (vs->v9iattr.valid & ATTR_ATIME_SET) {
+                times[0].tv_sec = vs->v9iattr.atime_sec;
+                times[0].tv_nsec = vs->v9iattr.atime_nsec;
+            } else {
+                times[0].tv_nsec = UTIME_NOW;
+            }
+        } else {
+            times[0].tv_nsec = UTIME_OMIT;
+        }
+
+        if (vs->v9iattr.valid & ATTR_MTIME) {
+            if (vs->v9iattr.valid & ATTR_MTIME_SET) {
+                times[1].tv_sec = vs->v9iattr.mtime_sec;
+                times[1].tv_nsec = vs->v9iattr.mtime_nsec;
+            } else {
+                times[1].tv_nsec = UTIME_NOW;
+            }
+        } else {
+            times[1].tv_nsec = UTIME_OMIT;
+        }
+        err = v9fs_do_utimensat(s, &vs->fidp->path, times);
+    }
+    v9fs_setattr_post_utimensat(s, vs, err);
+    return;
+
+out:
+    complete_pdu(s, vs->pdu, err);
+    qemu_free(vs);
+}
+
+static void v9fs_setattr(V9fsState *s, V9fsPDU *pdu)
+{
+    int32_t fid;
+    V9fsSetattrState *vs;
+    int err = 0;
+
+    vs = qemu_malloc(sizeof(*vs));
+    vs->pdu = pdu;
+    vs->offset = 7;
+
+    pdu_unmarshal(pdu, vs->offset, "dI", &fid, &vs->v9iattr);
+
+    vs->fidp = lookup_fid(s, fid);
+    if (vs->fidp == NULL) {
+        err = -EINVAL;
+        goto out;
+    }
+
+    if (vs->v9iattr.valid & ATTR_MODE) {
+        err = v9fs_do_chmod(s, &vs->fidp->path, vs->v9iattr.mode);
+    }
+
+    v9fs_setattr_post_chmod(s, vs, err);
+    return;
+
+out:
+    complete_pdu(s, vs->pdu, err);
+    qemu_free(vs);
+}
+
 static void v9fs_walk_complete(V9fsState *s, V9fsWalkState *vs, int err)
 {
     complete_pdu(s, vs->pdu, err);
@@ -2514,6 +2668,7 @@ static pdu_handler_t *pdu_handlers[] = {
     [P9_TREADDIR] = v9fs_readdir,
     [P9_TSTATFS] = v9fs_statfs,
     [P9_TGETATTR] = v9fs_getattr,
+    [P9_TSETATTR] = v9fs_setattr,
     [P9_TVERSION] = v9fs_version,
     [P9_TATTACH] = v9fs_attach,
     [P9_TSTAT] = v9fs_stat,
diff --git a/hw/virtio-9p.h b/hw/virtio-9p.h
index 1feed82..ebf44a7 100644
--- a/hw/virtio-9p.h
+++ b/hw/virtio-9p.h
@@ -17,6 +17,8 @@ enum {
     P9_RSTATFS,
     P9_TGETATTR = 24,
     P9_RGETATTR,
+    P9_TSETATTR = 26,
+    P9_RSETATTR,
     P9_TREADDIR = 40,
     P9_RREADDIR,
     P9_TVERSION = 100,
@@ -290,6 +292,27 @@ typedef struct V9fsWstatState
     V9fsString nname;
 } V9fsWstatState;
 
+typedef struct V9fsIattr
+{
+    int32_t valid;
+    int32_t mode;
+    int32_t uid;
+    int32_t gid;
+    int64_t size;
+    int64_t atime_sec;
+    int64_t atime_nsec;
+    int64_t mtime_sec;
+    int64_t mtime_nsec;
+} V9fsIattr;
+
+typedef struct V9fsSetattrState
+{
+    V9fsPDU *pdu;
+    size_t offset;
+    V9fsIattr v9iattr;
+    V9fsFidState *fidp;
+} V9fsSetattrState;
+
 struct virtio_9p_config
 {
     /* number of characters in tag */
-- 
1.6.5.2

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

* [Qemu-devel] [PATCH -V4 10/26] [virtio-9p] Implement TLINK for 9P2000.L
  2010-08-29 19:02 [Qemu-devel] [PATCH-V4 00/26] Consolidated VirtFS work Venkateswararao Jujjuri (JV)
                   ` (8 preceding siblings ...)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 09/26] virtio-9p: Implement server side of setattr for 9P2000.L protocol Venkateswararao Jujjuri (JV)
@ 2010-08-29 19:02 ` Venkateswararao Jujjuri (JV)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 11/26] [virtio-9p] Define and implement TSYMLINK " Venkateswararao Jujjuri (JV)
                   ` (15 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Venkateswararao Jujjuri (JV) @ 2010-08-29 19:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, Venkateswararao Jujjuri (JV)

Create a Hardlink.

SYNOPSIS

size[4] Tlink tag[2] dfid[4] oldfid[4] newpath[s]

size[4] Rlink tag[2]

DESCRIPTION

Create a link 'newpath' in directory pointed by dfid linking to oldfid path.

Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
---
 hw/virtio-9p-debug.c |    9 +++++++++
 hw/virtio-9p.c       |   38 ++++++++++++++++++++++++++++++++++++++
 hw/virtio-9p.h       |    2 ++
 3 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/hw/virtio-9p-debug.c b/hw/virtio-9p-debug.c
index a880b13..2e61e9d 100644
--- a/hw/virtio-9p-debug.c
+++ b/hw/virtio-9p-debug.c
@@ -497,6 +497,15 @@ void pprint_pdu(V9fsPDU *pdu)
     case P9_RCLUNK:
         fprintf(llogfile, "RCLUNK: (");
         break;
+    case P9_TLINK:
+        fprintf(llogfile, "TLINK: (");
+        pprint_int32(pdu, 0, &offset, "fid");
+        pprint_str(pdu, 0, &offset, ", oldpath");
+        pprint_str(pdu, 0, &offset, ", newpath");
+        break;
+    case P9_RLINK:
+        fprintf(llogfile, "RLINK: (");
+        break;
     case P9_TREMOVE:
         fprintf(llogfile, "TREMOVE: (");
         pprint_int32(pdu, 0, &offset, "fid");
diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index 39e63cb..d1c3cf8 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -2307,6 +2307,43 @@ static void v9fs_flush(V9fsState *s, V9fsPDU *pdu)
     complete_pdu(s, pdu, 7);
 }
 
+static void v9fs_link(V9fsState *s, V9fsPDU *pdu)
+{
+    int32_t dfid, oldfid;
+    V9fsFidState *dfidp, *oldfidp;
+    V9fsString name, fullname;
+    size_t offset = 7;
+    int err = 0;
+
+    v9fs_string_init(&fullname);
+
+    pdu_unmarshal(pdu, offset, "dds", &dfid, &oldfid, &name);
+
+    dfidp = lookup_fid(s, dfid);
+    if (dfidp == NULL) {
+        err = -errno;
+        goto out;
+    }
+
+    oldfidp = lookup_fid(s, oldfid);
+    if (oldfidp == NULL) {
+        err = -errno;
+        goto out;
+    }
+
+    v9fs_string_sprintf(&fullname, "%s/%s", dfidp->path.data, name.data);
+    err = offset;
+    err = v9fs_do_link(s, &oldfidp->path, &fullname);
+    if (err) {
+        err = -errno;
+    }
+    v9fs_string_free(&fullname);
+
+out:
+    v9fs_string_free(&name);
+    complete_pdu(s, pdu, err);
+}
+
 static void v9fs_remove_post_remove(V9fsState *s, V9fsRemoveState *vs,
                                                                 int err)
 {
@@ -2680,6 +2717,7 @@ static pdu_handler_t *pdu_handlers[] = {
     [P9_TAUTH] = v9fs_auth,
 #endif
     [P9_TFLUSH] = v9fs_flush,
+    [P9_TLINK] = v9fs_link,
     [P9_TCREATE] = v9fs_create,
     [P9_TWRITE] = v9fs_write,
     [P9_TWSTAT] = v9fs_wstat,
diff --git a/hw/virtio-9p.h b/hw/virtio-9p.h
index ebf44a7..d48776f 100644
--- a/hw/virtio-9p.h
+++ b/hw/virtio-9p.h
@@ -21,6 +21,8 @@ enum {
     P9_RSETATTR,
     P9_TREADDIR = 40,
     P9_RREADDIR,
+    P9_TLINK = 70,
+    P9_RLINK,
     P9_TVERSION = 100,
     P9_RVERSION,
     P9_TAUTH = 102,
-- 
1.6.5.2

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

* [Qemu-devel] [PATCH -V4 11/26] [virtio-9p] Define and implement TSYMLINK for 9P2000.L
  2010-08-29 19:02 [Qemu-devel] [PATCH-V4 00/26] Consolidated VirtFS work Venkateswararao Jujjuri (JV)
                   ` (9 preceding siblings ...)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 10/26] [virtio-9p] Implement TLINK for 9P2000.L Venkateswararao Jujjuri (JV)
@ 2010-08-29 19:02 ` Venkateswararao Jujjuri (JV)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 12/26] [virtio-9p] This patch implements TLCREATE for 9p2000.L protocol Venkateswararao Jujjuri (JV)
                   ` (14 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Venkateswararao Jujjuri (JV) @ 2010-08-29 19:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, Venkateswararao Jujjuri (JV)

This patch implements creating a symlink for TSYMLINK request
and responds with RSYMLINK. In the case of error, we return RERROR.

SYNOPSIS

    size[4] Tsymlink tag[2] fid[4] name[s] symtgt[s] gid[4]

    size[4] Rsymlink tag[2] qid[13]

    DESCRIPTION

    Create a symbolic link named 'name' pointing to 'symtgt'.
    gid represents the effective group id of the caller.
    The  permissions of a symbolic link are irrelevant hence it is omitted
    from the protocol.

Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
---
 hw/virtio-9p-debug.c |   11 +++++++
 hw/virtio-9p.c       |   78 ++++++++++++++++++++++++++++++++++++++++++++++----
 hw/virtio-9p.h       |   14 +++++++++
 3 files changed, 97 insertions(+), 6 deletions(-)

diff --git a/hw/virtio-9p-debug.c b/hw/virtio-9p-debug.c
index 2e61e9d..54179aa 100644
--- a/hw/virtio-9p-debug.c
+++ b/hw/virtio-9p-debug.c
@@ -464,6 +464,17 @@ void pprint_pdu(V9fsPDU *pdu)
         pprint_qid(pdu, 1, &offset, "qid");
         pprint_int32(pdu, 1, &offset, ", iounit");
         break;
+    case P9_TSYMLINK:
+        fprintf(llogfile, "TSYMLINK: (");
+        pprint_int32(pdu, 0, &offset, "fid");
+        pprint_str(pdu, 0, &offset, ", name");
+        pprint_str(pdu, 0, &offset, ", symname");
+        pprint_int32(pdu, 0, &offset, ", gid");
+        break;
+    case P9_RSYMLINK:
+        fprintf(llogfile, "RSYMLINK: (");
+        pprint_qid(pdu, 1, &offset, "qid");
+        break;
     case P9_TREAD:
         fprintf(llogfile, "TREAD: (");
         pprint_int32(pdu, 0, &offset, "fid");
diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index d1c3cf8..1036b49 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -200,15 +200,16 @@ static int v9fs_do_open2(V9fsState *s, V9fsCreateState *vs)
     return s->ops->open2(&s->ctx, vs->fullname.data, flags, &cred);
 }
 
-static int v9fs_do_symlink(V9fsState *s, V9fsCreateState *vs)
+static int v9fs_do_symlink(V9fsState *s, V9fsFidState *fidp,
+        const char *oldpath, const char *newpath, gid_t gid)
 {
     FsCred cred;
     cred_init(&cred);
-    cred.fc_uid = vs->fidp->uid;
-    cred.fc_mode = vs->perm | 0777;
+    cred.fc_uid = fidp->uid;
+    cred.fc_gid = gid;
+    cred.fc_mode = 0777;
 
-    return s->ops->symlink(&s->ctx, vs->extension.data, vs->fullname.data,
-            &cred);
+    return s->ops->symlink(&s->ctx, oldpath, newpath, &cred);
 }
 
 static int v9fs_do_link(V9fsState *s, V9fsString *oldpath, V9fsString *newpath)
@@ -2212,7 +2213,8 @@ static void v9fs_create_post_lstat(V9fsState *s, V9fsCreateState *vs, int err)
         err = v9fs_do_mkdir(s, vs);
         v9fs_create_post_mkdir(s, vs, err);
     } else if (vs->perm & P9_STAT_MODE_SYMLINK) {
-        err = v9fs_do_symlink(s, vs);
+        err = v9fs_do_symlink(s, vs->fidp, vs->extension.data,
+                vs->fullname.data, -1);
         v9fs_create_post_perms(s, vs, err);
     } else if (vs->perm & P9_STAT_MODE_LINK) {
         int32_t nfid = atoi(vs->extension.data);
@@ -2301,6 +2303,69 @@ out:
     qemu_free(vs);
 }
 
+static void v9fs_post_symlink(V9fsState *s, V9fsSymlinkState *vs, int err)
+{
+    if (err == 0) {
+        stat_to_qid(&vs->stbuf, &vs->qid);
+        vs->offset += pdu_marshal(vs->pdu, vs->offset, "Q", &vs->qid);
+        err = vs->offset;
+    } else {
+        err = -errno;
+    }
+    complete_pdu(s, vs->pdu, err);
+    v9fs_string_free(&vs->name);
+    v9fs_string_free(&vs->symname);
+    v9fs_string_free(&vs->fullname);
+    qemu_free(vs);
+}
+
+static void v9fs_symlink_post_do_symlink(V9fsState *s, V9fsSymlinkState *vs,
+        int err)
+{
+    if (err) {
+        goto out;
+    }
+    err = v9fs_do_lstat(s, &vs->fullname, &vs->stbuf);
+out:
+    v9fs_post_symlink(s, vs, err);
+}
+
+static void v9fs_symlink(V9fsState *s, V9fsPDU *pdu)
+{
+    int32_t dfid;
+    V9fsSymlinkState *vs;
+    int err = 0;
+    gid_t gid;
+
+    vs = qemu_malloc(sizeof(*vs));
+    vs->pdu = pdu;
+    vs->offset = 7;
+
+    v9fs_string_init(&vs->fullname);
+
+    pdu_unmarshal(vs->pdu, vs->offset, "dssd", &dfid, &vs->name,
+            &vs->symname, &gid);
+
+    vs->dfidp = lookup_fid(s, dfid);
+    if (vs->dfidp == NULL) {
+        err = -EINVAL;
+        goto out;
+    }
+
+    v9fs_string_sprintf(&vs->fullname, "%s/%s", vs->dfidp->path.data,
+            vs->name.data);
+    err = v9fs_do_symlink(s, vs->dfidp, vs->symname.data,
+            vs->fullname.data, gid);
+    v9fs_symlink_post_do_symlink(s, vs, err);
+    return;
+
+out:
+    complete_pdu(s, vs->pdu, err);
+    v9fs_string_free(&vs->name);
+    v9fs_string_free(&vs->symname);
+    qemu_free(vs);
+}
+
 static void v9fs_flush(V9fsState *s, V9fsPDU *pdu)
 {
     /* A nop call with no return */
@@ -2718,6 +2783,7 @@ static pdu_handler_t *pdu_handlers[] = {
 #endif
     [P9_TFLUSH] = v9fs_flush,
     [P9_TLINK] = v9fs_link,
+    [P9_TSYMLINK] = v9fs_symlink,
     [P9_TCREATE] = v9fs_create,
     [P9_TWRITE] = v9fs_write,
     [P9_TWSTAT] = v9fs_wstat,
diff --git a/hw/virtio-9p.h b/hw/virtio-9p.h
index d48776f..3671863 100644
--- a/hw/virtio-9p.h
+++ b/hw/virtio-9p.h
@@ -15,6 +15,8 @@
 enum {
     P9_TSTATFS = 8,
     P9_RSTATFS,
+    P9_TSYMLINK = 16,
+    P9_RSYMLINK,
     P9_TGETATTR = 24,
     P9_RGETATTR,
     P9_TSETATTR = 26,
@@ -294,6 +296,18 @@ typedef struct V9fsWstatState
     V9fsString nname;
 } V9fsWstatState;
 
+typedef struct V9fsSymlinkState
+{
+    V9fsPDU *pdu;
+    size_t offset;
+    V9fsString name;
+    V9fsString symname;
+    V9fsString fullname;
+    V9fsFidState *dfidp;
+    V9fsQID qid;
+    struct stat stbuf;
+} V9fsSymlinkState;
+
 typedef struct V9fsIattr
 {
     int32_t valid;
-- 
1.6.5.2

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

* [Qemu-devel] [PATCH -V4 12/26] [virtio-9p] This patch implements TLCREATE for 9p2000.L protocol.
  2010-08-29 19:02 [Qemu-devel] [PATCH-V4 00/26] Consolidated VirtFS work Venkateswararao Jujjuri (JV)
                   ` (10 preceding siblings ...)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 11/26] [virtio-9p] Define and implement TSYMLINK " Venkateswararao Jujjuri (JV)
@ 2010-08-29 19:02 ` Venkateswararao Jujjuri (JV)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 13/26] qemu: virtio-9p: Implement TMKNOD Venkateswararao Jujjuri (JV)
                   ` (13 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Venkateswararao Jujjuri (JV) @ 2010-08-29 19:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, Venkateswararao Jujjuri (JV)

SYNOPSIS

    size[4] Tlcreate tag[2] fid[4] name[s] flags[4] mode[4] gid[4]

    size[4] Rlcreate tag[2] qid[13] iounit[4]

DESCRIPTION

The Tlreate request asks the file server to create a new regular file with the
name supplied, in the directory (dir) represented by fid.
The mode argument specifies the permissions to use. New file is created with
the uid if the fid and with supplied gid.

The flags argument represent Linux access mode flags with which the caller
is requesting to open the file with. Protocol allows all the Linux access
modes but it is upto the server to allow/disallow any of these acess modes.
If the server doesn't support any of the access mode, it is expected to
return error.

To start with we will not restricit/limit any Linux flags on this server.
If needed, We can start restricting as we move forward with various use cases.

Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
---
 hw/virtio-9p-debug.c |   13 ++++++
 hw/virtio-9p.c       |  100 ++++++++++++++++++++++++++++++++++++++++++++++---
 hw/virtio-9p.h       |   13 ++++++
 3 files changed, 119 insertions(+), 7 deletions(-)

diff --git a/hw/virtio-9p-debug.c b/hw/virtio-9p-debug.c
index 54179aa..a8abdd2 100644
--- a/hw/virtio-9p-debug.c
+++ b/hw/virtio-9p-debug.c
@@ -475,6 +475,19 @@ void pprint_pdu(V9fsPDU *pdu)
         fprintf(llogfile, "RSYMLINK: (");
         pprint_qid(pdu, 1, &offset, "qid");
         break;
+    case P9_TLCREATE:
+        fprintf(llogfile, "TLCREATE: (");
+        pprint_int32(pdu, 0, &offset, "dfid");
+        pprint_str(pdu, 0, &offset, ", name");
+        pprint_int32(pdu, 0, &offset, ", flags");
+        pprint_int32(pdu, 0, &offset, ", mode");
+        pprint_int32(pdu, 0, &offset, ", gid");
+        break;
+    case P9_RLCREATE:
+        fprintf(llogfile, "RLCREATE: (");
+        pprint_qid(pdu, 1, &offset, "qid");
+        pprint_int32(pdu, 1, &offset, ", iounit");
+        break;
     case P9_TREAD:
         fprintf(llogfile, "TREAD: (");
         pprint_int32(pdu, 0, &offset, "fid");
diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index 1036b49..39f7071 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -187,17 +187,18 @@ static int v9fs_do_fstat(V9fsState *s, int fd, struct stat *stbuf)
     return s->ops->fstat(&s->ctx, fd, stbuf);
 }
 
-static int v9fs_do_open2(V9fsState *s, V9fsCreateState *vs)
+static int v9fs_do_open2(V9fsState *s, char *fullname, uid_t uid, gid_t gid,
+        int flags, int mode)
 {
     FsCred cred;
-    int flags;
 
     cred_init(&cred);
-    cred.fc_uid = vs->fidp->uid;
-    cred.fc_mode = vs->perm & 0777;
-    flags = omode_to_uflags(vs->mode) | O_CREAT;
+    cred.fc_uid = uid;
+    cred.fc_gid = gid;
+    cred.fc_mode = mode & 07777;
+    flags = flags;
 
-    return s->ops->open2(&s->ctx, vs->fullname.data, flags, &cred);
+    return s->ops->open2(&s->ctx, fullname, flags, &cred);
 }
 
 static int v9fs_do_symlink(V9fsState *s, V9fsFidState *fidp,
@@ -1671,6 +1672,88 @@ out:
     qemu_free(vs);
 }
 
+static void v9fs_post_lcreate(V9fsState *s, V9fsLcreateState *vs, int err)
+{
+    if (err == 0) {
+        v9fs_string_copy(&vs->fidp->path, &vs->fullname);
+        stat_to_qid(&vs->stbuf, &vs->qid);
+        vs->offset += pdu_marshal(vs->pdu, vs->offset, "Qd", &vs->qid,
+                &vs->iounit);
+        err = vs->offset;
+    } else {
+        err = -errno;
+    }
+
+    complete_pdu(s, vs->pdu, err);
+    v9fs_string_free(&vs->name);
+    v9fs_string_free(&vs->fullname);
+    qemu_free(vs);
+}
+
+static void v9fs_lcreate_post_get_iounit(V9fsState *s, V9fsLcreateState *vs,
+        int err)
+{
+    if (err) {
+        err = -errno;
+        goto out;
+    }
+    err = v9fs_do_lstat(s, &vs->fullname, &vs->stbuf);
+
+out:
+    v9fs_post_lcreate(s, vs, err);
+}
+
+static void v9fs_lcreate_post_do_open2(V9fsState *s, V9fsLcreateState *vs,
+        int err)
+{
+    if (vs->fidp->fd == -1) {
+        err = -errno;
+        goto out;
+    }
+    vs->iounit =  get_iounit(s, &vs->fullname);
+    v9fs_lcreate_post_get_iounit(s, vs, err);
+    return;
+
+out:
+    v9fs_post_lcreate(s, vs, err);
+}
+
+static void v9fs_lcreate(V9fsState *s, V9fsPDU *pdu)
+{
+    int32_t dfid, flags, mode;
+    gid_t gid;
+    V9fsLcreateState *vs;
+    ssize_t err = 0;
+
+    vs = qemu_malloc(sizeof(*vs));
+    vs->pdu = pdu;
+    vs->offset = 7;
+
+    v9fs_string_init(&vs->fullname);
+
+    pdu_unmarshal(vs->pdu, vs->offset, "dsddd", &dfid, &vs->name, &flags,
+            &mode, &gid);
+
+    vs->fidp = lookup_fid(s, dfid);
+    if (vs->fidp == NULL) {
+        err = -ENOENT;
+        goto out;
+    }
+
+    v9fs_string_sprintf(&vs->fullname, "%s/%s", vs->fidp->path.data,
+             vs->name.data);
+
+    vs->fidp->fd = v9fs_do_open2(s, vs->fullname.data, vs->fidp->uid,
+            gid, flags, mode);
+    v9fs_lcreate_post_do_open2(s, vs, err);
+    return;
+
+out:
+    complete_pdu(s, vs->pdu, err);
+    v9fs_string_free(&vs->name);
+    qemu_free(vs);
+}
+
 static void v9fs_clunk(V9fsState *s, V9fsPDU *pdu)
 {
     int32_t fid;
@@ -2258,7 +2341,9 @@ static void v9fs_create_post_lstat(V9fsState *s, V9fsCreateState *vs, int err)
         err = v9fs_do_mknod(s, vs, S_IFSOCK | (vs->perm & 0777), 0);
         v9fs_post_create(s, vs, err);
     } else {
-        vs->fidp->fd = v9fs_do_open2(s, vs);
+        vs->fidp->fd = v9fs_do_open2(s, vs->fullname.data, vs->fidp->uid,
+                -1, omode_to_uflags(vs->mode)|O_CREAT, vs->perm);
+
         v9fs_create_post_open2(s, vs, err);
     }
 
@@ -2785,6 +2870,7 @@ static pdu_handler_t *pdu_handlers[] = {
     [P9_TLINK] = v9fs_link,
     [P9_TSYMLINK] = v9fs_symlink,
     [P9_TCREATE] = v9fs_create,
+    [P9_TLCREATE] = v9fs_lcreate,
     [P9_TWRITE] = v9fs_write,
     [P9_TWSTAT] = v9fs_wstat,
     [P9_TREMOVE] = v9fs_remove,
diff --git a/hw/virtio-9p.h b/hw/virtio-9p.h
index 3671863..ad4d216 100644
--- a/hw/virtio-9p.h
+++ b/hw/virtio-9p.h
@@ -15,6 +15,8 @@
 enum {
     P9_TSTATFS = 8,
     P9_RSTATFS,
+    P9_TLCREATE = 14,
+    P9_RLCREATE,
     P9_TSYMLINK = 16,
     P9_RSYMLINK,
     P9_TGETATTR = 24,
@@ -185,6 +187,17 @@ typedef struct V9fsCreateState {
     int iounit;
 } V9fsCreateState;
 
+typedef struct V9fsLcreateState {
+    V9fsPDU *pdu;
+    size_t offset;
+    V9fsFidState *fidp;
+    V9fsQID qid;
+    int32_t iounit;
+    struct stat stbuf;
+    V9fsString name;
+    V9fsString fullname;
+} V9fsLcreateState;
+
 typedef struct V9fsStatState {
     V9fsPDU *pdu;
     size_t offset;
-- 
1.6.5.2

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

* [Qemu-devel] [PATCH -V4 13/26] qemu: virtio-9p: Implement TMKNOD
  2010-08-29 19:02 [Qemu-devel] [PATCH-V4 00/26] Consolidated VirtFS work Venkateswararao Jujjuri (JV)
                   ` (11 preceding siblings ...)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 12/26] [virtio-9p] This patch implements TLCREATE for 9p2000.L protocol Venkateswararao Jujjuri (JV)
@ 2010-08-29 19:02 ` Venkateswararao Jujjuri (JV)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 14/26] qemu: virtio-9p: Implement TMKDIR Venkateswararao Jujjuri (JV)
                   ` (12 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Venkateswararao Jujjuri (JV) @ 2010-08-29 19:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, M. Mohan Kumar, Venkateswararao Jujjuri

From: M. Mohan Kumar <mohan@in.ibm.com>

Implement TMKNOD as part of 2000.L Work

Synopsis

    size[4] Tmknod tag[2] fid[4] name[s] mode[4] major[4] minor[4] gid[4]

    size[4] Rmknod tag[2] qid[13]

Description

    mknod asks the file server to create a device node with given device
    type, mode and gid. The qid for the new device node is returned with
    the mknod reply message.

Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
---
 hw/virtio-9p-debug.c |   13 +++++++
 hw/virtio-9p.c       |   90 ++++++++++++++++++++++++++++++++++++++++++++++----
 hw/virtio-9p.h       |   11 ++++++
 3 files changed, 107 insertions(+), 7 deletions(-)

diff --git a/hw/virtio-9p-debug.c b/hw/virtio-9p-debug.c
index a8abdd2..6a527ce 100644
--- a/hw/virtio-9p-debug.c
+++ b/hw/virtio-9p-debug.c
@@ -488,6 +488,19 @@ void pprint_pdu(V9fsPDU *pdu)
         pprint_qid(pdu, 1, &offset, "qid");
         pprint_int32(pdu, 1, &offset, ", iounit");
         break;
+    case P9_TMKNOD:
+	fprintf(llogfile, "TMKNOD: (");
+        pprint_int32(pdu, 0, &offset, "fid");
+        pprint_str(pdu, 0, &offset, "name");
+        pprint_int32(pdu, 0, &offset, "mode");
+        pprint_int32(pdu, 0, &offset, "major");
+        pprint_int32(pdu, 0, &offset, "minor");
+        pprint_int32(pdu, 0, &offset, "gid");
+        break;
+    case P9_RMKNOD:
+        fprintf(llogfile, "RMKNOD: )");
+        pprint_qid(pdu, 0, &offset, "qid");
+        break;
     case P9_TREAD:
         fprintf(llogfile, "TREAD: (");
         pprint_int32(pdu, 0, &offset, "fid");
diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index 39f7071..41be585 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -160,15 +160,16 @@ static int v9fs_do_chmod(V9fsState *s, V9fsString *path, mode_t mode)
     return s->ops->chmod(&s->ctx, path->data, &cred);
 }
 
-static int v9fs_do_mknod(V9fsState *s, V9fsCreateState *vs, mode_t mode,
-        dev_t dev)
+static int v9fs_do_mknod(V9fsState *s, char *name,
+        mode_t mode, dev_t dev, uid_t uid, gid_t gid)
 {
     FsCred cred;
     cred_init(&cred);
-    cred.fc_uid = vs->fidp->uid;
+    cred.fc_uid = uid;
+    cred.fc_gid = gid;
     cred.fc_mode = mode;
     cred.fc_rdev = dev;
-    return s->ops->mknod(&s->ctx, vs->fullname.data, &cred);
+    return s->ops->mknod(&s->ctx, name, &cred);
 }
 
 static int v9fs_do_mkdir(V9fsState *s, V9fsCreateState *vs)
@@ -2332,13 +2333,16 @@ static void v9fs_create_post_lstat(V9fsState *s, V9fsCreateState *vs, int err)
         }
 
         nmode |= vs->perm & 0777;
-        err = v9fs_do_mknod(s, vs, nmode, makedev(major, minor));
+        err = v9fs_do_mknod(s, vs->fullname.data, nmode,
+                makedev(major, minor), vs->fidp->uid, -1);
         v9fs_create_post_perms(s, vs, err);
     } else if (vs->perm & P9_STAT_MODE_NAMED_PIPE) {
-        err = v9fs_do_mknod(s, vs, S_IFIFO | (vs->perm & 0777), 0);
+        err = v9fs_do_mknod(s, vs->fullname.data, S_IFIFO | (vs->perm & 0777),
+                0, vs->fidp->uid, -1);
         v9fs_post_create(s, vs, err);
     } else if (vs->perm & P9_STAT_MODE_SOCKET) {
-        err = v9fs_do_mknod(s, vs, S_IFSOCK | (vs->perm & 0777), 0);
+        err = v9fs_do_mknod(s, vs->fullname.data, S_IFSOCK | (vs->perm & 0777),
+                0, vs->fidp->uid, -1);
         v9fs_post_create(s, vs, err);
     } else {
         vs->fidp->fd = v9fs_do_open2(s, vs->fullname.data, vs->fidp->uid,
@@ -2849,6 +2853,77 @@ out:
     qemu_free(vs);
 }
 
+static void v9fs_mknod_post_lstat(V9fsState *s, V9fsMkState *vs, int err)
+{
+    if (err == -1) {
+        err = -errno;
+        goto out;
+    }
+
+    stat_to_qid(&vs->stbuf, &vs->qid);
+    vs->offset += pdu_marshal(vs->pdu, vs->offset, "Q", &vs->qid);
+    err = vs->offset;
+out:
+    complete_pdu(s, vs->pdu, err);
+    v9fs_string_free(&vs->fullname);
+    v9fs_string_free(&vs->name);
+    qemu_free(vs);
+}
+
+static void v9fs_mknod_post_mknod(V9fsState *s, V9fsMkState *vs, int err)
+{
+    if (err == -1) {
+        err = -errno;
+        goto out;
+    }
+
+    err = v9fs_do_lstat(s, &vs->fullname, &vs->stbuf);
+    v9fs_mknod_post_lstat(s, vs, err);
+    return;
+out:
+    complete_pdu(s, vs->pdu, err);
+    v9fs_string_free(&vs->fullname);
+    v9fs_string_free(&vs->name);
+    qemu_free(vs);
+}
+
+static void v9fs_mknod(V9fsState *s, V9fsPDU *pdu)
+{
+    int32_t fid;
+    V9fsMkState *vs;
+    int err = 0;
+    V9fsFidState *fidp;
+    gid_t gid;
+    int mode;
+    int major, minor;
+
+    vs = qemu_malloc(sizeof(*vs));
+    vs->pdu = pdu;
+    vs->offset = 7;
+
+    v9fs_string_init(&vs->fullname);
+    pdu_unmarshal(vs->pdu, vs->offset, "dsdddd", &fid, &vs->name, &mode,
+        &major, &minor, &gid);
+
+    fidp = lookup_fid(s, fid);
+    if (fidp == NULL) {
+        err = -ENOENT;
+        goto out;
+    }
+
+    v9fs_string_sprintf(&vs->fullname, "%s/%s", fidp->path.data, vs->name.data);
+    err = v9fs_do_mknod(s, vs->fullname.data, mode, makedev(major, minor),
+        fidp->uid, gid);
+    v9fs_mknod_post_mknod(s, vs, err);
+    return;
+
+out:
+    complete_pdu(s, vs->pdu, err);
+    v9fs_string_free(&vs->fullname);
+    v9fs_string_free(&vs->name);
+    qemu_free(vs);
+}
+
 typedef void (pdu_handler_t)(V9fsState *s, V9fsPDU *pdu);
 
 static pdu_handler_t *pdu_handlers[] = {
@@ -2856,6 +2931,7 @@ static pdu_handler_t *pdu_handlers[] = {
     [P9_TSTATFS] = v9fs_statfs,
     [P9_TGETATTR] = v9fs_getattr,
     [P9_TSETATTR] = v9fs_setattr,
+    [P9_TMKNOD] = v9fs_mknod,
     [P9_TVERSION] = v9fs_version,
     [P9_TATTACH] = v9fs_attach,
     [P9_TSTAT] = v9fs_stat,
diff --git a/hw/virtio-9p.h b/hw/virtio-9p.h
index ad4d216..8ba45ac 100644
--- a/hw/virtio-9p.h
+++ b/hw/virtio-9p.h
@@ -19,6 +19,8 @@ enum {
     P9_RLCREATE,
     P9_TSYMLINK = 16,
     P9_RSYMLINK,
+    P9_TMKNOD = 18,
+    P9_RMKNOD,
     P9_TGETATTR = 24,
     P9_RGETATTR,
     P9_TSETATTR = 26,
@@ -372,6 +374,15 @@ typedef struct V9fsStatfsState {
     struct statfs stbuf;
 } V9fsStatfsState;
 
+typedef struct V9fsMkState {
+    V9fsPDU *pdu;
+    size_t offset;
+    V9fsQID qid;
+    struct stat stbuf;
+    V9fsString name;
+    V9fsString fullname;
+} V9fsMkState;
+
 extern size_t pdu_packunpack(void *addr, struct iovec *sg, int sg_count,
                             size_t offset, size_t size, int pack);
 
-- 
1.6.5.2

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

* [Qemu-devel] [PATCH -V4 14/26] qemu: virtio-9p: Implement TMKDIR
  2010-08-29 19:02 [Qemu-devel] [PATCH-V4 00/26] Consolidated VirtFS work Venkateswararao Jujjuri (JV)
                   ` (12 preceding siblings ...)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 13/26] qemu: virtio-9p: Implement TMKNOD Venkateswararao Jujjuri (JV)
@ 2010-08-29 19:02 ` Venkateswararao Jujjuri (JV)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 15/26] rename - change name of file or directory Venkateswararao Jujjuri (JV)
                   ` (11 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Venkateswararao Jujjuri (JV) @ 2010-08-29 19:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, M. Mohan Kumar, Venkateswararao Jujjuri

From: M. Mohan Kumar <mohan@in.ibm.com>

Synopsis

    size[4] Tmkdir tag[2] fid[4] name[s] mode[4] gid[4]

    size[4] Rmkdir tag[2] qid[13]

Description

    mkdir asks the file server to create a directory with given name,
    mode and gid. The qid for the new directory is returned with
    the mkdir reply message.

Note: 72 is selected as the opcode for TMKDIR from the reserved list.

Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
[jvrao@linux.vnet.ibm.com: Fix perm handling when creating directory]

Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
---
 hw/virtio-9p-debug.c |   11 ++++++
 hw/virtio-9p.c       |   83 +++++++++++++++++++++++++++++++++++++++++++++++---
 hw/virtio-9p.h       |    2 +
 3 files changed, 91 insertions(+), 5 deletions(-)

diff --git a/hw/virtio-9p-debug.c b/hw/virtio-9p-debug.c
index 6a527ce..949a4bf 100644
--- a/hw/virtio-9p-debug.c
+++ b/hw/virtio-9p-debug.c
@@ -367,6 +367,17 @@ void pprint_pdu(V9fsPDU *pdu)
         pprint_data(pdu, 1, &offset, ", data");
 #endif
         break;
+    case P9_TMKDIR:
+        fprintf(llogfile, "TMKDIR: (");
+        pprint_int32(pdu, 0, &offset, "fid");
+        pprint_str(pdu, 0, &offset, "name");
+        pprint_int32(pdu, 0, &offset, "mode");
+        pprint_int32(pdu, 0, &offset, "gid");
+        break;
+    case P9_RMKDIR:
+        fprintf(llogfile, "RMKDIR: (");
+        pprint_qid(pdu, 0, &offset, "qid");
+        break;
     case P9_TVERSION:
         fprintf(llogfile, "TVERSION: (");
         pprint_int32(pdu, 0, &offset, "msize");
diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index 41be585..7ea0e96 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -172,15 +172,17 @@ static int v9fs_do_mknod(V9fsState *s, char *name,
     return s->ops->mknod(&s->ctx, name, &cred);
 }
 
-static int v9fs_do_mkdir(V9fsState *s, V9fsCreateState *vs)
+static int v9fs_do_mkdir(V9fsState *s, char *name, mode_t mode,
+                uid_t uid, gid_t gid)
 {
     FsCred cred;
 
     cred_init(&cred);
-    cred.fc_uid = vs->fidp->uid;
-    cred.fc_mode = vs->perm & 0777;
+    cred.fc_uid = uid;
+    cred.fc_gid = gid;
+    cred.fc_mode = mode;
 
-    return s->ops->mkdir(&s->ctx, vs->fullname.data, &cred);
+    return s->ops->mkdir(&s->ctx, name, &cred);
 }
 
 static int v9fs_do_fstat(V9fsState *s, int fd, struct stat *stbuf)
@@ -2294,7 +2296,8 @@ static void v9fs_create_post_lstat(V9fsState *s, V9fsCreateState *vs, int err)
     }
 
     if (vs->perm & P9_STAT_MODE_DIR) {
-        err = v9fs_do_mkdir(s, vs);
+        err = v9fs_do_mkdir(s, vs->fullname.data, vs->perm & 0777,
+                vs->fidp->uid, -1);
         v9fs_create_post_mkdir(s, vs, err);
     } else if (vs->perm & P9_STAT_MODE_SYMLINK) {
         err = v9fs_do_symlink(s, vs->fidp, vs->extension.data,
@@ -2924,6 +2927,75 @@ out:
     qemu_free(vs);
 }
 
+static void v9fs_mkdir_post_lstat(V9fsState *s, V9fsMkState *vs, int err)
+{
+    if (err == -1) {
+        err = -errno;
+        goto out;
+    }
+
+    stat_to_qid(&vs->stbuf, &vs->qid);
+    vs->offset += pdu_marshal(vs->pdu, vs->offset, "Q", &vs->qid);
+    err = vs->offset;
+out:
+    complete_pdu(s, vs->pdu, err);
+    v9fs_string_free(&vs->fullname);
+    v9fs_string_free(&vs->name);
+    qemu_free(vs);
+}
+
+static void v9fs_mkdir_post_mkdir(V9fsState *s, V9fsMkState *vs, int err)
+{
+    if (err == -1) {
+        err = -errno;
+        goto out;
+    }
+
+    err = v9fs_do_lstat(s, &vs->fullname, &vs->stbuf);
+    v9fs_mkdir_post_lstat(s, vs, err);
+    return;
+out:
+    complete_pdu(s, vs->pdu, err);
+    v9fs_string_free(&vs->fullname);
+    v9fs_string_free(&vs->name);
+    qemu_free(vs);
+}
+
+static void v9fs_mkdir(V9fsState *s, V9fsPDU *pdu)
+{
+    int32_t fid;
+    V9fsMkState *vs;
+    int err = 0;
+    V9fsFidState *fidp;
+    gid_t gid;
+    int mode;
+
+    vs = qemu_malloc(sizeof(*vs));
+    vs->pdu = pdu;
+    vs->offset = 7;
+
+    v9fs_string_init(&vs->fullname);
+    pdu_unmarshal(vs->pdu, vs->offset, "dsdd", &fid, &vs->name, &mode,
+        &gid);
+
+    fidp = lookup_fid(s, fid);
+    if (fidp == NULL) {
+        err = -ENOENT;
+        goto out;
+    }
+
+    v9fs_string_sprintf(&vs->fullname, "%s/%s", fidp->path.data, vs->name.data);
+    err = v9fs_do_mkdir(s, vs->fullname.data, mode, fidp->uid, gid);
+    v9fs_mkdir_post_mkdir(s, vs, err);
+    return;
+
+out:
+    complete_pdu(s, vs->pdu, err);
+    v9fs_string_free(&vs->fullname);
+    v9fs_string_free(&vs->name);
+    qemu_free(vs);
+}
+
 typedef void (pdu_handler_t)(V9fsState *s, V9fsPDU *pdu);
 
 static pdu_handler_t *pdu_handlers[] = {
@@ -2932,6 +3004,7 @@ static pdu_handler_t *pdu_handlers[] = {
     [P9_TGETATTR] = v9fs_getattr,
     [P9_TSETATTR] = v9fs_setattr,
     [P9_TMKNOD] = v9fs_mknod,
+    [P9_TMKDIR] = v9fs_mkdir,
     [P9_TVERSION] = v9fs_version,
     [P9_TATTACH] = v9fs_attach,
     [P9_TSTAT] = v9fs_stat,
diff --git a/hw/virtio-9p.h b/hw/virtio-9p.h
index 8ba45ac..91cc0ae 100644
--- a/hw/virtio-9p.h
+++ b/hw/virtio-9p.h
@@ -29,6 +29,8 @@ enum {
     P9_RREADDIR,
     P9_TLINK = 70,
     P9_RLINK,
+    P9_TMKDIR = 72,
+    P9_RMKDIR,
     P9_TVERSION = 100,
     P9_RVERSION,
     P9_TAUTH = 102,
-- 
1.6.5.2

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

* [Qemu-devel] [PATCH -V4 15/26] rename - change name of file or directory
  2010-08-29 19:02 [Qemu-devel] [PATCH-V4 00/26] Consolidated VirtFS work Venkateswararao Jujjuri (JV)
                   ` (13 preceding siblings ...)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 14/26] qemu: virtio-9p: Implement TMKDIR Venkateswararao Jujjuri (JV)
@ 2010-08-29 19:02 ` Venkateswararao Jujjuri (JV)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 16/26] [virtio-9p] qemu: virtio-9p: Implement LOPEN Venkateswararao Jujjuri (JV)
                   ` (10 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Venkateswararao Jujjuri (JV) @ 2010-08-29 19:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, M. Mohan Kumar, Venkateswararao Jujjuri

From: M. Mohan Kumar <mohan@in.ibm.com>

size[4] Trename tag[2] fid[4] newdirfid[4] name[s]
size[4] Rrename tag[2]

Implement the 2000.L rename operation. A new function
v9fs_complete_rename is introduced that acts as a common entry point
for 2000.L rename operation and 2000.U rename opearation (via wstat).
As part of this change the field 'nname' (used only for rename) is
removed from the structure V9fsWstatState. Instead a new structure
V9fsRenameState is used for rename operations both by 2000.U and 2000.L
code paths. Both 2000.U and 2000.L rename code paths construct the
V9fsRenameState structure and passes that to v9fs_complete_rename
function.

Changes from previous version:
 Use qemu_mallocz to initialize
 Use strcpy,strcat functions instead of memcpy
 Changed the variable name to newdirfid
 Introduced post rename function
 Error checking
 Removed nname field from V9fsWstatState

Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
---
 hw/virtio-9p.c |  156 ++++++++++++++++++++++++++++++++++++++++---------------
 hw/virtio-9p.h |   11 ++++-
 2 files changed, 123 insertions(+), 44 deletions(-)

diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index 7ea0e96..88dd496 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -2563,11 +2563,6 @@ static void v9fs_wstat_post_rename(V9fsState *s, V9fsWstatState *vs, int err)
     if (err < 0) {
         goto out;
     }
-
-    if (vs->v9stat.name.size != 0) {
-        v9fs_string_free(&vs->nname);
-    }
-
     if (vs->v9stat.length != -1) {
         if (v9fs_do_truncate(s, &vs->fidp->path, vs->v9stat.length) < 0) {
             err = -errno;
@@ -2582,17 +2577,30 @@ out:
     qemu_free(vs);
 }
 
-static void v9fs_wstat_post_chown(V9fsState *s, V9fsWstatState *vs, int err)
+static int v9fs_complete_rename(V9fsState *s, V9fsRenameState *vs)
 {
-    V9fsFidState *fidp;
-    if (err < 0) {
-        goto out;
-    }
+    int err = 0;
+    char *old_name, *new_name;
+    char *end;
 
-    if (vs->v9stat.name.size != 0) {
-        char *old_name, *new_name;
-        char *end;
+    if (vs->newdirfid != -1) {
+        V9fsFidState *dirfidp;
+        dirfidp = lookup_fid(s, vs->newdirfid);
+
+        if (dirfidp == NULL) {
+            err = -ENOENT;
+            goto out;
+        }
+
+        BUG_ON(dirfidp->fd != -1);
+        BUG_ON(dirfidp->dir);
 
+        new_name = qemu_mallocz(dirfidp->path.size + vs->name.size + 2);
+
+        strcpy(new_name, dirfidp->path.data);
+        strcat(new_name, "/");
+        strcat(new_name + dirfidp->path.size, vs->name.data);
+    } else {
         old_name = vs->fidp->path.data;
         end = strrchr(old_name, '/');
         if (end) {
@@ -2600,43 +2608,75 @@ static void v9fs_wstat_post_chown(V9fsState *s, V9fsWstatState *vs, int err)
         } else {
             end = old_name;
         }
+        new_name = qemu_mallocz(end - old_name + vs->name.size + 1);
 
-        new_name = qemu_mallocz(end - old_name + vs->v9stat.name.size + 1);
+        strncat(new_name, old_name, end - old_name);
+        strncat(new_name + (end - old_name), vs->name.data, vs->name.size);
+    }
 
-        memcpy(new_name, old_name, end - old_name);
-        memcpy(new_name + (end - old_name), vs->v9stat.name.data,
-                vs->v9stat.name.size);
-        vs->nname.data = new_name;
-        vs->nname.size = strlen(new_name);
+    v9fs_string_free(&vs->name);
+    vs->name.data = qemu_strdup(new_name);
+    vs->name.size = strlen(new_name);
 
-        if (strcmp(new_name, vs->fidp->path.data) != 0) {
-            if (v9fs_do_rename(s, &vs->fidp->path, &vs->nname)) {
-                err = -errno;
-            } else {
-                /*
-                 * Fixup fid's pointing to the old name to
-                 * start pointing to the new name
-                 */
-                for (fidp = s->fid_list; fidp; fidp = fidp->next) {
-
-                    if (vs->fidp == fidp) {
-                        /*
-                         * we replace name of this fid towards the end
-                         * so that our below strcmp will work
-                         */
-                        continue;
-                    }
-                    if (!strncmp(vs->fidp->path.data, fidp->path.data,
-                                 strlen(vs->fidp->path.data))) {
-                        /* replace the name */
-                        v9fs_fix_path(&fidp->path, &vs->nname,
-                                      strlen(vs->fidp->path.data));
-                    }
+    if (strcmp(new_name, vs->fidp->path.data) != 0) {
+        if (v9fs_do_rename(s, &vs->fidp->path, &vs->name)) {
+            err = -errno;
+        } else {
+            V9fsFidState *fidp;
+            /*
+            * Fixup fid's pointing to the old name to
+            * start pointing to the new name
+            */
+            for (fidp = s->fid_list; fidp; fidp = fidp->next) {
+                if (vs->fidp == fidp) {
+                    /*
+                    * we replace name of this fid towards the end
+                    * so that our below strcmp will work
+                    */
+                    continue;
+                }
+                if (!strncmp(vs->fidp->path.data, fidp->path.data,
+                    strlen(vs->fidp->path.data))) {
+                    /* replace the name */
+                    v9fs_fix_path(&fidp->path, &vs->name,
+                                  strlen(vs->fidp->path.data));
                 }
-                v9fs_string_copy(&vs->fidp->path, &vs->nname);
             }
+            v9fs_string_copy(&vs->fidp->path, &vs->name);
         }
     }
+out:
+    v9fs_string_free(&vs->name);
+    return err;
+}
+
+static void v9fs_rename_post_rename(V9fsState *s, V9fsRenameState *vs, int err)
+{
+    complete_pdu(s, vs->pdu, err);
+    qemu_free(vs);
+}
+
+static void v9fs_wstat_post_chown(V9fsState *s, V9fsWstatState *vs, int err)
+{
+    if (err < 0) {
+        goto out;
+    }
+
+    if (vs->v9stat.name.size != 0) {
+        V9fsRenameState *vr;
+
+        vr = qemu_malloc(sizeof(V9fsRenameState));
+        memset(vr, sizeof(*vr), 0);
+        vr->newdirfid = -1;
+        vr->pdu = vs->pdu;
+        vr->fidp = vs->fidp;
+        vr->offset = vs->offset;
+        vr->name.size = vs->v9stat.name.size;
+        vr->name.data = qemu_strdup(vs->v9stat.name.data);
+
+        err = v9fs_complete_rename(s, vr);
+        qemu_free(vr);
+    }
     v9fs_wstat_post_rename(s, vs, err);
     return;
 
@@ -2646,6 +2686,35 @@ out:
     qemu_free(vs);
 }
 
+static void v9fs_rename(V9fsState *s, V9fsPDU *pdu)
+{
+    int32_t fid;
+    V9fsRenameState *vs;
+    ssize_t err = 0;
+
+    vs = qemu_malloc(sizeof(*vs));
+    vs->pdu = pdu;
+    vs->offset = 7;
+
+    pdu_unmarshal(vs->pdu, vs->offset, "dds", &fid, &vs->newdirfid, &vs->name);
+
+    vs->fidp = lookup_fid(s, fid);
+    if (vs->fidp == NULL) {
+        err = -ENOENT;
+        goto out;
+    }
+
+    BUG_ON(vs->fidp->fd != -1);
+    BUG_ON(vs->fidp->dir);
+
+    err = v9fs_complete_rename(s, vs);
+    v9fs_rename_post_rename(s, vs, err);
+    return;
+out:
+    complete_pdu(s, vs->pdu, err);
+    qemu_free(vs);
+}
+
 static void v9fs_wstat_post_utime(V9fsState *s, V9fsWstatState *vs, int err)
 {
     if (err < 0) {
@@ -3004,6 +3073,7 @@ static pdu_handler_t *pdu_handlers[] = {
     [P9_TGETATTR] = v9fs_getattr,
     [P9_TSETATTR] = v9fs_setattr,
     [P9_TMKNOD] = v9fs_mknod,
+    [P9_TRENAME] = v9fs_rename,
     [P9_TMKDIR] = v9fs_mkdir,
     [P9_TVERSION] = v9fs_version,
     [P9_TATTACH] = v9fs_attach,
diff --git a/hw/virtio-9p.h b/hw/virtio-9p.h
index 91cc0ae..4d179b7 100644
--- a/hw/virtio-9p.h
+++ b/hw/virtio-9p.h
@@ -21,6 +21,8 @@ enum {
     P9_RSYMLINK,
     P9_TMKNOD = 18,
     P9_RMKNOD,
+    P9_TRENAME = 20,
+    P9_RRENAME,
     P9_TGETATTR = 24,
     P9_RGETATTR,
     P9_TSETATTR = 26,
@@ -310,7 +312,6 @@ typedef struct V9fsWstatState
     V9fsStat v9stat;
     V9fsFidState *fidp;
     struct stat stbuf;
-    V9fsString nname;
 } V9fsWstatState;
 
 typedef struct V9fsSymlinkState
@@ -385,6 +386,14 @@ typedef struct V9fsMkState {
     V9fsString fullname;
 } V9fsMkState;
 
+typedef struct V9fsRenameState {
+    V9fsPDU *pdu;
+    V9fsFidState *fidp;
+    size_t offset;
+    int32_t newdirfid;
+    V9fsString name;
+} V9fsRenameState;
+
 extern size_t pdu_packunpack(void *addr, struct iovec *sg, int sg_count,
                             size_t offset, size_t size, int pack);
 
-- 
1.6.5.2

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

* [Qemu-devel] [PATCH -V4 16/26] [virtio-9p] qemu: virtio-9p: Implement LOPEN
  2010-08-29 19:02 [Qemu-devel] [PATCH-V4 00/26] Consolidated VirtFS work Venkateswararao Jujjuri (JV)
                   ` (14 preceding siblings ...)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 15/26] rename - change name of file or directory Venkateswararao Jujjuri (JV)
@ 2010-08-29 19:02 ` Venkateswararao Jujjuri (JV)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 17/26] virtio-9p: Add fidtype so that we can do type specific operation Venkateswararao Jujjuri (JV)
                   ` (9 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Venkateswararao Jujjuri (JV) @ 2010-08-29 19:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, M. Mohan Kumar, Venkateswararao Jujjuri

From: M. Mohan Kumar <mohan@in.ibm.com>

Implement 9p2000.L version of open(LOPEN) interface in qemu 9p server.

For LOPEN, no need to convert the flags to and from 9p mode to VFS mode.

Synopsis:

    size[4] Tlopen tag[2] fid[4] mode[4]

    size[4] Rlopen tag[2] qid[13] iounit[4]

Current qemu 9p server does not support following flags:
    O_NOCTTY, O_NONBLOCK, O_ASYNC & O_CLOEXEC

[Fix mode format - jvrao@linux.vnet.ibm.com]

Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
---
 hw/virtio-9p.c |   32 ++++++++++++++++++++++++++++----
 hw/virtio-9p.h |    4 +++-
 2 files changed, 31 insertions(+), 5 deletions(-)

diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index 88dd496..deeacbd 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -1621,8 +1621,19 @@ out:
     qemu_free(vs);
 }
 
+static inline int valid_flags(int flag)
+{
+    if (flag & O_NOCTTY || flag & O_NONBLOCK || flag & O_ASYNC ||
+            flag & O_CLOEXEC)
+        return 0;
+    else
+        return 1;
+}
+
 static void v9fs_open_post_lstat(V9fsState *s, V9fsOpenState *vs, int err)
 {
+    int flags;
+
     if (err) {
         err = -errno;
         goto out;
@@ -1634,8 +1645,16 @@ static void v9fs_open_post_lstat(V9fsState *s, V9fsOpenState *vs, int err)
         vs->fidp->dir = v9fs_do_opendir(s, &vs->fidp->path);
         v9fs_open_post_opendir(s, vs, err);
     } else {
-        vs->fidp->fd = v9fs_do_open(s, &vs->fidp->path,
-                                    omode_to_uflags(vs->mode));
+        if (s->proto_version == V9FS_PROTO_2000L) {
+            if (!valid_flags(vs->mode)) {
+                err = -EINVAL;
+                goto out;
+            }
+            flags = vs->mode;
+        } else {
+            flags = omode_to_uflags(vs->mode);
+        }
+        vs->fidp->fd = v9fs_do_open(s, &vs->fidp->path, flags);
         v9fs_open_post_open(s, vs, err);
     }
     return;
@@ -1650,12 +1669,16 @@ static void v9fs_open(V9fsState *s, V9fsPDU *pdu)
     V9fsOpenState *vs;
     ssize_t err = 0;
 
-
     vs = qemu_malloc(sizeof(*vs));
     vs->pdu = pdu;
     vs->offset = 7;
+    vs->mode = 0;
 
-    pdu_unmarshal(vs->pdu, vs->offset, "db", &fid, &vs->mode);
+    if (s->proto_version == V9FS_PROTO_2000L) {
+        pdu_unmarshal(vs->pdu, vs->offset, "dd", &fid, &vs->mode);
+    } else {
+        pdu_unmarshal(vs->pdu, vs->offset, "db", &fid, &vs->mode);
+    }
 
     vs->fidp = lookup_fid(s, fid);
     if (vs->fidp == NULL) {
@@ -3076,6 +3099,7 @@ static pdu_handler_t *pdu_handlers[] = {
     [P9_TRENAME] = v9fs_rename,
     [P9_TMKDIR] = v9fs_mkdir,
     [P9_TVERSION] = v9fs_version,
+    [P9_TLOPEN] = v9fs_open,
     [P9_TATTACH] = v9fs_attach,
     [P9_TSTAT] = v9fs_stat,
     [P9_TWALK] = v9fs_walk,
diff --git a/hw/virtio-9p.h b/hw/virtio-9p.h
index 4d179b7..cd7c67e 100644
--- a/hw/virtio-9p.h
+++ b/hw/virtio-9p.h
@@ -15,6 +15,8 @@
 enum {
     P9_TSTATFS = 8,
     P9_RSTATFS,
+    P9_TLOPEN = 12,
+    P9_RLOPEN,
     P9_TLCREATE = 14,
     P9_RLCREATE,
     P9_TSYMLINK = 16,
@@ -259,7 +261,7 @@ typedef struct V9fsWalkState {
 typedef struct V9fsOpenState {
     V9fsPDU *pdu;
     size_t offset;
-    int8_t mode;
+    int32_t mode;
     V9fsFidState *fidp;
     V9fsQID qid;
     struct stat stbuf;
-- 
1.6.5.2

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

* [Qemu-devel] [PATCH -V4 17/26] virtio-9p: Add fidtype so that we can do type specific operation
  2010-08-29 19:02 [Qemu-devel] [PATCH-V4 00/26] Consolidated VirtFS work Venkateswararao Jujjuri (JV)
                   ` (15 preceding siblings ...)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 16/26] [virtio-9p] qemu: virtio-9p: Implement LOPEN Venkateswararao Jujjuri (JV)
@ 2010-08-29 19:02 ` Venkateswararao Jujjuri (JV)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 18/26] virtio-9p: Implement TXATTRWALK Venkateswararao Jujjuri (JV)
                   ` (8 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Venkateswararao Jujjuri (JV) @ 2010-08-29 19:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, Aneesh Kumar K.V

From: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>

We want to add type specific operation during read/write

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 hw/virtio-9p.c |  110 ++++++++++++++++++++++++++++---------------------------
 hw/virtio-9p.h |   24 +++++++++++-
 2 files changed, 78 insertions(+), 56 deletions(-)

diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index deeacbd..cb97f4c 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -408,8 +408,7 @@ static V9fsFidState *alloc_fid(V9fsState *s, int32_t fid)
     f = qemu_mallocz(sizeof(V9fsFidState));
 
     f->fid = fid;
-    f->fd = -1;
-    f->dir = NULL;
+    f->fid_type = P9_FID_NONE;
 
     f->next = s->fid_list;
     s->fid_list = f;
@@ -434,11 +433,14 @@ static int free_fid(V9fsState *s, int32_t fid)
     fidp = *fidpp;
     *fidpp = fidp->next;
 
-    if (fidp->fd != -1) {
-        v9fs_do_close(s, fidp->fd);
-    }
-    if (fidp->dir) {
-        v9fs_do_closedir(s, fidp->dir);
+    if (fidp->fid_type == P9_FID_FILE) {
+        v9fs_do_close(s, fidp->fs.fd);
+    } else if (fidp->fid_type == P9_FID_DIR) {
+        v9fs_do_closedir(s, fidp->fs.dir);
+    } else if (fidp->fid_type == P9_FID_XATTR) {
+	if (fidp->fs.xattr.value) {
+	    qemu_free(fidp->fs.xattr.value);
+	}
     }
     v9fs_string_free(&fidp->path);
     qemu_free(fidp);
@@ -1519,8 +1521,7 @@ static void v9fs_walk(V9fsState *s, V9fsPDU *pdu)
     /* FIXME: is this really valid? */
     if (fid == newfid) {
 
-        BUG_ON(vs->fidp->fd != -1);
-        BUG_ON(vs->fidp->dir);
+        BUG_ON(vs->fidp->fid_type != P9_FID_NONE);
         v9fs_string_init(&vs->path);
         vs->name_idx = 0;
 
@@ -1584,11 +1585,11 @@ static int32_t get_iounit(V9fsState *s, V9fsString *name)
 
 static void v9fs_open_post_opendir(V9fsState *s, V9fsOpenState *vs, int err)
 {
-    if (vs->fidp->dir == NULL) {
+    if (vs->fidp->fs.dir == NULL) {
         err = -errno;
         goto out;
     }
-
+    vs->fidp->fid_type = P9_FID_DIR;
     vs->offset += pdu_marshal(vs->pdu, vs->offset, "Qd", &vs->qid, 0);
     err = vs->offset;
 out:
@@ -1608,11 +1609,11 @@ static void v9fs_open_post_getiounit(V9fsState *s, V9fsOpenState *vs)
 
 static void v9fs_open_post_open(V9fsState *s, V9fsOpenState *vs, int err)
 {
-    if (vs->fidp->fd == -1) {
+    if (vs->fidp->fs.fd == -1) {
         err = -errno;
         goto out;
     }
-
+    vs->fidp->fid_type = P9_FID_FILE;
     vs->iounit = get_iounit(s, &vs->fidp->path);
     v9fs_open_post_getiounit(s, vs);
     return;
@@ -1642,7 +1643,7 @@ static void v9fs_open_post_lstat(V9fsState *s, V9fsOpenState *vs, int err)
     stat_to_qid(&vs->stbuf, &vs->qid);
 
     if (S_ISDIR(vs->stbuf.st_mode)) {
-        vs->fidp->dir = v9fs_do_opendir(s, &vs->fidp->path);
+        vs->fidp->fs.dir = v9fs_do_opendir(s, &vs->fidp->path);
         v9fs_open_post_opendir(s, vs, err);
     } else {
         if (s->proto_version == V9FS_PROTO_2000L) {
@@ -1654,7 +1655,7 @@ static void v9fs_open_post_lstat(V9fsState *s, V9fsOpenState *vs, int err)
         } else {
             flags = omode_to_uflags(vs->mode);
         }
-        vs->fidp->fd = v9fs_do_open(s, &vs->fidp->path, flags);
+        vs->fidp->fs.fd = v9fs_do_open(s, &vs->fidp->path, flags);
         v9fs_open_post_open(s, vs, err);
     }
     return;
@@ -1686,8 +1687,7 @@ static void v9fs_open(V9fsState *s, V9fsPDU *pdu)
         goto out;
     }
 
-    BUG_ON(vs->fidp->fd != -1);
-    BUG_ON(vs->fidp->dir);
+    BUG_ON(vs->fidp->fid_type != P9_FID_NONE);
 
     err = v9fs_do_lstat(s, &vs->fidp->path, &vs->stbuf);
 
@@ -1707,6 +1707,8 @@ static void v9fs_post_lcreate(V9fsState *s, V9fsLcreateState *vs, int err)
                 &vs->iounit);
         err = vs->offset;
     } else {
+        vs->fidp->fid_type = P9_FID_NONE;
+        close(vs->fidp->fs.fd);
         err = -errno;
     }
 
@@ -1732,10 +1734,11 @@ out:
 static void v9fs_lcreate_post_do_open2(V9fsState *s, V9fsLcreateState *vs,
         int err)
 {
-    if (vs->fidp->fd == -1) {
+    if (vs->fidp->fs.fd == -1) {
         err = -errno;
         goto out;
     }
+    vs->fidp->fid_type = P9_FID_FILE;
     vs->iounit =  get_iounit(s, &vs->fullname);
     v9fs_lcreate_post_get_iounit(s, vs, err);
     return;
@@ -1769,7 +1772,7 @@ static void v9fs_lcreate(V9fsState *s, V9fsPDU *pdu)
     v9fs_string_sprintf(&vs->fullname, "%s/%s", vs->fidp->path.data,
              vs->name.data);
 
-    vs->fidp->fd = v9fs_do_open2(s, vs->fullname.data, vs->fidp->uid,
+    vs->fidp->fs.fd = v9fs_do_open2(s, vs->fullname.data, vs->fidp->uid,
             gid, flags, mode);
     v9fs_lcreate_post_do_open2(s, vs, err);
     return;
@@ -1833,7 +1836,7 @@ static void v9fs_read_post_dir_lstat(V9fsState *s, V9fsReadState *vs,
                             &vs->v9stat);
     if ((vs->len != (vs->v9stat.size + 2)) ||
             ((vs->count + vs->len) > vs->max_count)) {
-        v9fs_do_seekdir(s, vs->fidp->dir, vs->dir_pos);
+        v9fs_do_seekdir(s, vs->fidp->fs.dir, vs->dir_pos);
         v9fs_read_post_seekdir(s, vs, err);
         return;
     }
@@ -1841,11 +1844,11 @@ static void v9fs_read_post_dir_lstat(V9fsState *s, V9fsReadState *vs,
     v9fs_stat_free(&vs->v9stat);
     v9fs_string_free(&vs->name);
     vs->dir_pos = vs->dent->d_off;
-    vs->dent = v9fs_do_readdir(s, vs->fidp->dir);
+    vs->dent = v9fs_do_readdir(s, vs->fidp->fs.dir);
     v9fs_read_post_readdir(s, vs, err);
     return;
 out:
-    v9fs_do_seekdir(s, vs->fidp->dir, vs->dir_pos);
+    v9fs_do_seekdir(s, vs->fidp->fs.dir, vs->dir_pos);
     v9fs_read_post_seekdir(s, vs, err);
     return;
 
@@ -1873,7 +1876,7 @@ static void v9fs_read_post_readdir(V9fsState *s, V9fsReadState *vs, ssize_t err)
 
 static void v9fs_read_post_telldir(V9fsState *s, V9fsReadState *vs, ssize_t err)
 {
-    vs->dent = v9fs_do_readdir(s, vs->fidp->dir);
+    vs->dent = v9fs_do_readdir(s, vs->fidp->fs.dir);
     v9fs_read_post_readdir(s, vs, err);
     return;
 }
@@ -1881,7 +1884,7 @@ static void v9fs_read_post_telldir(V9fsState *s, V9fsReadState *vs, ssize_t err)
 static void v9fs_read_post_rewinddir(V9fsState *s, V9fsReadState *vs,
                                        ssize_t err)
 {
-    vs->dir_pos = v9fs_do_telldir(s, vs->fidp->dir);
+    vs->dir_pos = v9fs_do_telldir(s, vs->fidp->fs.dir);
     v9fs_read_post_telldir(s, vs, err);
     return;
 }
@@ -1900,7 +1903,7 @@ static void v9fs_read_post_readv(V9fsState *s, V9fsReadState *vs, ssize_t err)
             if (0) {
                 print_sg(vs->sg, vs->cnt);
             }
-            vs->len = v9fs_do_readv(s, vs->fidp->fd, vs->sg, vs->cnt);
+            vs->len = v9fs_do_readv(s, vs->fidp->fs.fd, vs->sg, vs->cnt);
         } while (vs->len == -1 && errno == EINTR);
         if (vs->len == -1) {
             err  = -errno;
@@ -1930,7 +1933,7 @@ static void v9fs_read_post_lseek(V9fsState *s, V9fsReadState *vs, ssize_t err)
             if (0) {
                 print_sg(vs->sg, vs->cnt);
             }
-            vs->len = v9fs_do_readv(s, vs->fidp->fd, vs->sg, vs->cnt);
+            vs->len = v9fs_do_readv(s, vs->fidp->fs.fd, vs->sg, vs->cnt);
         } while (vs->len == -1 && errno == EINTR);
         if (vs->len == -1) {
             err  = -errno;
@@ -1964,18 +1967,18 @@ static void v9fs_read(V9fsState *s, V9fsPDU *pdu)
         goto out;
     }
 
-    if (vs->fidp->dir) {
+    if (vs->fidp->fs.dir) {
         vs->max_count = vs->count;
         vs->count = 0;
         if (vs->off == 0) {
-            v9fs_do_rewinddir(s, vs->fidp->dir);
+            v9fs_do_rewinddir(s, vs->fidp->fs.dir);
         }
         v9fs_read_post_rewinddir(s, vs, err);
         return;
-    } else if (vs->fidp->fd != -1) {
+    } else if (vs->fidp->fs.fd != -1) {
         vs->sg = vs->iov;
         pdu_marshal(vs->pdu, vs->offset + 4, "v", vs->sg, &vs->cnt);
-        err = v9fs_do_lseek(s, vs->fidp->fd, vs->off, SEEK_SET);
+        err = v9fs_do_lseek(s, vs->fidp->fs.fd, vs->off, SEEK_SET);
         v9fs_read_post_lseek(s, vs, err);
         return;
     } else {
@@ -2024,7 +2027,7 @@ static void v9fs_readdir_post_readdir(V9fsState *s, V9fsReadDirState *vs)
 
         if ((vs->count + V9_READDIR_DATA_SZ) > vs->max_count) {
             /* Ran out of buffer. Set dir back to old position and return */
-            v9fs_do_seekdir(s, vs->fidp->dir, vs->saved_dir_pos);
+            v9fs_do_seekdir(s, vs->fidp->fs.dir, vs->saved_dir_pos);
             v9fs_readdir_post_seekdir(s, vs);
             return;
         }
@@ -2045,7 +2048,7 @@ static void v9fs_readdir_post_readdir(V9fsState *s, V9fsReadDirState *vs)
         vs->count += len;
         v9fs_string_free(&vs->name);
         vs->saved_dir_pos = vs->dent->d_off;
-        vs->dent = v9fs_do_readdir(s, vs->fidp->dir);
+        vs->dent = v9fs_do_readdir(s, vs->fidp->fs.dir);
         v9fs_readdir_post_readdir(s, vs);
         return;
     }
@@ -2059,14 +2062,14 @@ static void v9fs_readdir_post_readdir(V9fsState *s, V9fsReadDirState *vs)
 
 static void v9fs_readdir_post_telldir(V9fsState *s, V9fsReadDirState *vs)
 {
-    vs->dent = v9fs_do_readdir(s, vs->fidp->dir);
+    vs->dent = v9fs_do_readdir(s, vs->fidp->fs.dir);
     v9fs_readdir_post_readdir(s, vs);
     return;
 }
 
 static void v9fs_readdir_post_setdir(V9fsState *s, V9fsReadDirState *vs)
 {
-    vs->saved_dir_pos = v9fs_do_telldir(s, vs->fidp->dir);
+    vs->saved_dir_pos = v9fs_do_telldir(s, vs->fidp->fs.dir);
     v9fs_readdir_post_telldir(s, vs);
     return;
 }
@@ -2087,15 +2090,15 @@ static void v9fs_readdir(V9fsState *s, V9fsPDU *pdu)
                                                         &vs->max_count);
 
     vs->fidp = lookup_fid(s, fid);
-    if (vs->fidp == NULL || !(vs->fidp->dir)) {
+    if (vs->fidp == NULL || !(vs->fidp->fs.dir)) {
         err = -EINVAL;
         goto out;
     }
 
     if (vs->initial_offset == 0) {
-        v9fs_do_rewinddir(s, vs->fidp->dir);
+        v9fs_do_rewinddir(s, vs->fidp->fs.dir);
     } else {
-        v9fs_do_seekdir(s, vs->fidp->dir, vs->initial_offset);
+        v9fs_do_seekdir(s, vs->fidp->fs.dir, vs->initial_offset);
     }
 
     v9fs_readdir_post_setdir(s, vs);
@@ -2122,7 +2125,7 @@ static void v9fs_write_post_writev(V9fsState *s, V9fsWriteState *vs,
             if (0) {
                 print_sg(vs->sg, vs->cnt);
             }
-            vs->len =  v9fs_do_writev(s, vs->fidp->fd, vs->sg, vs->cnt);
+            vs->len =  v9fs_do_writev(s, vs->fidp->fs.fd, vs->sg, vs->cnt);
         } while (vs->len == -1 && errno == EINTR);
         if (vs->len == -1) {
             err  = -errno;
@@ -2151,7 +2154,7 @@ static void v9fs_write_post_lseek(V9fsState *s, V9fsWriteState *vs, ssize_t err)
             if (0) {
                 print_sg(vs->sg, vs->cnt);
             }
-            vs->len = v9fs_do_writev(s, vs->fidp->fd, vs->sg, vs->cnt);
+            vs->len = v9fs_do_writev(s, vs->fidp->fs.fd, vs->sg, vs->cnt);
         } while (vs->len == -1 && errno == EINTR);
         if (vs->len == -1) {
             err  = -errno;
@@ -2188,12 +2191,12 @@ static void v9fs_write(V9fsState *s, V9fsPDU *pdu)
         goto out;
     }
 
-    if (vs->fidp->fd == -1) {
+    if (vs->fidp->fs.fd == -1) {
         err = -EINVAL;
         goto out;
     }
 
-    err = v9fs_do_lseek(s, vs->fidp->fd, vs->off, SEEK_SET);
+    err = v9fs_do_lseek(s, vs->fidp->fs.fd, vs->off, SEEK_SET);
 
     v9fs_write_post_lseek(s, vs, err);
     return;
@@ -2245,9 +2248,10 @@ static void v9fs_create_post_perms(V9fsState *s, V9fsCreateState *vs, int err)
 static void v9fs_create_post_opendir(V9fsState *s, V9fsCreateState *vs,
                                                                     int err)
 {
-    if (!vs->fidp->dir) {
+    if (!vs->fidp->fs.dir) {
         err = -errno;
     }
+    vs->fidp->fid_type = P9_FID_DIR;
     v9fs_post_create(s, vs, err);
 }
 
@@ -2259,7 +2263,7 @@ static void v9fs_create_post_dir_lstat(V9fsState *s, V9fsCreateState *vs,
         goto out;
     }
 
-    vs->fidp->dir = v9fs_do_opendir(s, &vs->fullname);
+    vs->fidp->fs.dir = v9fs_do_opendir(s, &vs->fullname);
     v9fs_create_post_opendir(s, vs, err);
     return;
 
@@ -2285,22 +2289,22 @@ out:
 static void v9fs_create_post_fstat(V9fsState *s, V9fsCreateState *vs, int err)
 {
     if (err) {
-        vs->fidp->fd = -1;
+        vs->fidp->fid_type = P9_FID_NONE;
+        close(vs->fidp->fs.fd);
         err = -errno;
     }
-
     v9fs_post_create(s, vs, err);
     return;
 }
 
 static void v9fs_create_post_open2(V9fsState *s, V9fsCreateState *vs, int err)
 {
-    if (vs->fidp->fd == -1) {
+    if (vs->fidp->fs.fd == -1) {
         err = -errno;
         goto out;
     }
-
-    err = v9fs_do_fstat(s, vs->fidp->fd, &vs->stbuf);
+    vs->fidp->fid_type = P9_FID_FILE;
+    err = v9fs_do_fstat(s, vs->fidp->fs.fd, &vs->stbuf);
     v9fs_create_post_fstat(s, vs, err);
 
     return;
@@ -2371,7 +2375,7 @@ static void v9fs_create_post_lstat(V9fsState *s, V9fsCreateState *vs, int err)
                 0, vs->fidp->uid, -1);
         v9fs_post_create(s, vs, err);
     } else {
-        vs->fidp->fd = v9fs_do_open2(s, vs->fullname.data, vs->fidp->uid,
+        vs->fidp->fs.fd = v9fs_do_open2(s, vs->fullname.data, vs->fidp->uid,
                 -1, omode_to_uflags(vs->mode)|O_CREAT, vs->perm);
 
         v9fs_create_post_open2(s, vs, err);
@@ -2615,8 +2619,7 @@ static int v9fs_complete_rename(V9fsState *s, V9fsRenameState *vs)
             goto out;
         }
 
-        BUG_ON(dirfidp->fd != -1);
-        BUG_ON(dirfidp->dir);
+        BUG_ON(dirfidp->fid_type != P9_FID_NONE);
 
         new_name = qemu_mallocz(dirfidp->path.size + vs->name.size + 2);
 
@@ -2727,8 +2730,7 @@ static void v9fs_rename(V9fsState *s, V9fsPDU *pdu)
         goto out;
     }
 
-    BUG_ON(vs->fidp->fd != -1);
-    BUG_ON(vs->fidp->dir);
+    BUG_ON(vs->fidp->fid_type != P9_FID_NONE);
 
     err = v9fs_complete_rename(s, vs);
     v9fs_rename_post_rename(s, vs, err);
@@ -2855,7 +2857,7 @@ static void v9fs_wstat(V9fsState *s, V9fsPDU *pdu)
 
     /* do we need to sync the file? */
     if (donttouch_stat(&vs->v9stat)) {
-        err = v9fs_do_fsync(s, vs->fidp->fd);
+        err = v9fs_do_fsync(s, vs->fidp->fs.fd);
         v9fs_wstat_post_fsync(s, vs, err);
         return;
     }
diff --git a/hw/virtio-9p.h b/hw/virtio-9p.h
index cd7c67e..faca6b2 100644
--- a/hw/virtio-9p.h
+++ b/hw/virtio-9p.h
@@ -155,12 +155,32 @@ typedef struct V9fsStat
     int32_t n_muid;
 } V9fsStat;
 
+enum {
+    P9_FID_NONE = 0,
+    P9_FID_FILE,
+    P9_FID_DIR,
+    P9_FID_XATTR,
+};
+
+typedef struct V9fsXattr
+{
+    int64_t copied_len;
+    int64_t len;
+    void *value;
+    V9fsString name;
+    int flags;
+} V9fsXattr;
+
 struct V9fsFidState
 {
+    int fid_type;
     int32_t fid;
     V9fsString path;
-    int fd;
-    DIR *dir;
+    union {
+	int fd;
+	DIR *dir;
+	V9fsXattr xattr;
+    } fs;
     uid_t uid;
     V9fsFidState *next;
 };
-- 
1.6.5.2

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

* [Qemu-devel] [PATCH -V4 18/26] virtio-9p: Implement TXATTRWALK
  2010-08-29 19:02 [Qemu-devel] [PATCH-V4 00/26] Consolidated VirtFS work Venkateswararao Jujjuri (JV)
                   ` (16 preceding siblings ...)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 17/26] virtio-9p: Add fidtype so that we can do type specific operation Venkateswararao Jujjuri (JV)
@ 2010-08-29 19:02 ` Venkateswararao Jujjuri (JV)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 19/26] virtio-9p: Implement TXATTRCREATE Venkateswararao Jujjuri (JV)
                   ` (7 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Venkateswararao Jujjuri (JV) @ 2010-08-29 19:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, Venkateswararao Jujjuri, Aneesh Kumar K.V

From: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>

TXATTRWALK: Descend a ATTR namespace

 size[4] TXATTRWALK tag[2] fid[4] newfid[4] name[s]
 size[4] RXATTRWALK tag[2] size[8]

txattrwalk gets a fid pointing to xattr. This fid can later be
used to get read the xattr value. If name is NULL the fid returned
can be used to get the list of extended attribute associated to
the file system object.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
---
 hw/file-op-9p.h      |    3 +
 hw/virtio-9p-debug.c |   10 +++
 hw/virtio-9p-local.c |   15 ++++
 hw/virtio-9p.c       |  191 +++++++++++++++++++++++++++++++++++++++++++++++++-
 hw/virtio-9p.h       |   14 ++++
 5 files changed, 231 insertions(+), 2 deletions(-)

diff --git a/hw/file-op-9p.h b/hw/file-op-9p.h
index 120c803..989266f 100644
--- a/hw/file-op-9p.h
+++ b/hw/file-op-9p.h
@@ -75,6 +75,9 @@ typedef struct FileOperations
     int (*truncate)(FsContext *, const char *, off_t);
     int (*fsync)(FsContext *, int);
     int (*statfs)(FsContext *s, const char *path, struct statfs *stbuf);
+    ssize_t (*lgetxattr)(FsContext *, const char *, const char *, void *,
+                                                                     size_t);
+    ssize_t (*llistxattr)(FsContext *, const char *, void *, size_t);
     void *opaque;
 } FileOperations;
 #endif
diff --git a/hw/virtio-9p-debug.c b/hw/virtio-9p-debug.c
index 949a4bf..4554eb6 100644
--- a/hw/virtio-9p-debug.c
+++ b/hw/virtio-9p-debug.c
@@ -579,6 +579,16 @@ void pprint_pdu(V9fsPDU *pdu)
     case P9_RWSTAT:
         fprintf(llogfile, "RWSTAT: (");
         break;
+    case P9_TXATTRWALK:
+        fprintf(llogfile, "TXATTRWALK: (");
+        pprint_int32(pdu, 0, &offset, "fid");
+        pprint_int32(pdu, 0, &offset, ", newfid");
+        pprint_str(pdu, 0, &offset, ", xattr name");
+        break;
+    case P9_RXATTRWALK:
+        fprintf(llogfile, "RXATTRWALK: (");
+        pprint_int64(pdu, 1, &offset, "xattrsize");
+        break;
     default:
         fprintf(llogfile, "unknown(%d): (", pdu->id);
         break;
diff --git a/hw/virtio-9p-local.c b/hw/virtio-9p-local.c
index 269fc62..902ca79 100644
--- a/hw/virtio-9p-local.c
+++ b/hw/virtio-9p-local.c
@@ -474,6 +474,19 @@ static int local_statfs(FsContext *s, const char *path, struct statfs *stbuf)
    return statfs(rpath(s, path), stbuf);
 }
 
+static ssize_t local_lgetxattr(FsContext *ctx, const char *path,
+                                const char *name,
+                               void *value, size_t size)
+{
+    return lgetxattr(rpath(ctx, path), name, value, size);
+}
+
+static ssize_t local_llistxattr(FsContext *ctx, const char *path,
+                                void *value, size_t size)
+{
+    return llistxattr(rpath(ctx, path), value, size);
+}
+
 FileOperations local_ops = {
     .lstat = local_lstat,
     .readlink = local_readlink,
@@ -502,4 +515,6 @@ FileOperations local_ops = {
     .remove = local_remove,
     .fsync = local_fsync,
     .statfs = local_statfs,
+    .lgetxattr = local_lgetxattr,
+    .llistxattr = local_llistxattr,
 };
diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index cb97f4c..e2811ae 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -263,6 +263,21 @@ static int v9fs_do_statfs(V9fsState *s, V9fsString *path, struct statfs *stbuf)
     return s->ops->statfs(&s->ctx, path->data, stbuf);
 }
 
+static ssize_t v9fs_do_lgetxattr(V9fsState *s, V9fsString *path,
+                             V9fsString *xattr_name,
+                             void *value, size_t size)
+{
+    return s->ops->lgetxattr(&s->ctx, path->data,
+                             xattr_name->data, value, size);
+}
+
+static ssize_t v9fs_do_llistxattr(V9fsState *s, V9fsString *path,
+                              void *value, size_t size)
+{
+    return s->ops->llistxattr(&s->ctx, path->data,
+                              value, size);
+}
+
 static void v9fs_string_init(V9fsString *str)
 {
     str->data = NULL;
@@ -1946,6 +1961,31 @@ out:
     qemu_free(vs);
 }
 
+static void v9fs_xattr_read(V9fsState *s, V9fsReadState *vs)
+{
+    ssize_t err = 0;
+    int read_count;
+    int64_t xattr_len;
+
+    xattr_len = vs->fidp->fs.xattr.len;
+    read_count = xattr_len - vs->off;
+    if (read_count > vs->count) {
+	read_count = vs->count;
+    } else if (read_count < 0) {
+	/*
+	 * read beyond XATTR value
+	 */
+	read_count = 0;
+    }
+    vs->offset += pdu_marshal(vs->pdu, vs->offset, "d", read_count);
+    vs->offset += pdu_pack(vs->pdu, vs->offset,
+			   ((char *)vs->fidp->fs.xattr.value) + vs->off,
+			   read_count);
+    err = vs->offset;
+    complete_pdu(s, vs->pdu, err);
+    qemu_free(vs);
+}
+
 static void v9fs_read(V9fsState *s, V9fsPDU *pdu)
 {
     int32_t fid;
@@ -1967,7 +2007,7 @@ static void v9fs_read(V9fsState *s, V9fsPDU *pdu)
         goto out;
     }
 
-    if (vs->fidp->fs.dir) {
+    if (vs->fidp->fid_type == P9_FID_DIR) {
         vs->max_count = vs->count;
         vs->count = 0;
         if (vs->off == 0) {
@@ -1975,12 +2015,15 @@ static void v9fs_read(V9fsState *s, V9fsPDU *pdu)
         }
         v9fs_read_post_rewinddir(s, vs, err);
         return;
-    } else if (vs->fidp->fs.fd != -1) {
+    } else if (vs->fidp->fid_type == P9_FID_FILE) {
         vs->sg = vs->iov;
         pdu_marshal(vs->pdu, vs->offset + 4, "v", vs->sg, &vs->cnt);
         err = v9fs_do_lseek(s, vs->fidp->fs.fd, vs->off, SEEK_SET);
         v9fs_read_post_lseek(s, vs, err);
         return;
+    } else if (vs->fidp->fid_type == P9_FID_XATTR) {
+	v9fs_xattr_read(s, vs);
+	return;
     } else {
         err = -EINVAL;
     }
@@ -3090,6 +3133,149 @@ out:
     qemu_free(vs);
 }
 
+static void v9fs_post_xattr_getvalue(V9fsState *s, V9fsXattrState *vs, int err)
+{
+
+    if (err < 0) {
+	err = -errno;
+        free_fid(s, vs->xattr_fidp->fid);
+        goto out;
+    }
+    vs->offset += pdu_marshal(vs->pdu, vs->offset, "q", vs->size);
+    err = vs->offset;
+out:
+    complete_pdu(s, vs->pdu, err);
+    v9fs_string_free(&vs->name);
+    qemu_free(vs);
+    return;
+}
+
+static void v9fs_post_xattr_check(V9fsState *s, V9fsXattrState *vs, ssize_t err)
+{
+    if (err < 0) {
+	err = -errno;
+        free_fid(s, vs->xattr_fidp->fid);
+        goto out;
+    }
+    /*
+     * Read the xattr value
+     */
+    vs->xattr_fidp->fs.xattr.len = vs->size;
+    vs->xattr_fidp->fid_type = P9_FID_XATTR;
+    vs->xattr_fidp->fs.xattr.copied_len = -1;
+    if (vs->size) {
+        vs->xattr_fidp->fs.xattr.value = qemu_malloc(vs->size);
+        err = v9fs_do_lgetxattr(s, &vs->xattr_fidp->path,
+                                &vs->name, vs->xattr_fidp->fs.xattr.value,
+                                vs->xattr_fidp->fs.xattr.len);
+    }
+    v9fs_post_xattr_getvalue(s, vs, err);
+    return;
+out:
+    complete_pdu(s, vs->pdu, err);
+    v9fs_string_free(&vs->name);
+    qemu_free(vs);
+}
+
+static void v9fs_post_lxattr_getvalue(V9fsState *s, V9fsXattrState *vs, int err)
+{
+    if (err < 0) {
+	err = -errno;
+        free_fid(s, vs->xattr_fidp->fid);
+        goto out;
+    }
+    vs->offset += pdu_marshal(vs->pdu, vs->offset, "q", vs->size);
+    err = vs->offset;
+out:
+    complete_pdu(s, vs->pdu, err);
+    v9fs_string_free(&vs->name);
+    qemu_free(vs);
+    return;
+}
+
+static void v9fs_post_lxattr_check(V9fsState *s, V9fsXattrState *vs,
+                                                            ssize_t err)
+{
+    if (err < 0) {
+	err = -errno;
+        free_fid(s, vs->xattr_fidp->fid);
+        goto out;
+    }
+    /*
+     * Read the xattr value
+     */
+    vs->xattr_fidp->fs.xattr.len = vs->size;
+    vs->xattr_fidp->fid_type = P9_FID_XATTR;
+    vs->xattr_fidp->fs.xattr.copied_len = -1;
+    if (vs->size) {
+        vs->xattr_fidp->fs.xattr.value = qemu_malloc(vs->size);
+        err = v9fs_do_llistxattr(s, &vs->xattr_fidp->path,
+                                 vs->xattr_fidp->fs.xattr.value,
+                                 vs->xattr_fidp->fs.xattr.len);
+    }
+    v9fs_post_lxattr_getvalue(s, vs, err);
+    return;
+out:
+    complete_pdu(s, vs->pdu, err);
+    v9fs_string_free(&vs->name);
+    qemu_free(vs);
+}
+
+static void v9fs_xattrwalk(V9fsState *s, V9fsPDU *pdu)
+{
+    ssize_t err = 0;
+    V9fsXattrState *vs;
+    int32_t fid, newfid;
+
+    vs = qemu_malloc(sizeof(*vs));
+    vs->pdu = pdu;
+    vs->offset = 7;
+
+    pdu_unmarshal(vs->pdu, vs->offset, "dds", &fid, &newfid, &vs->name);
+    vs->file_fidp = lookup_fid(s, fid);
+    if (vs->file_fidp == NULL) {
+        err = -ENOENT;
+        goto out;
+    }
+
+    vs->xattr_fidp = alloc_fid(s, newfid);
+    if (vs->xattr_fidp == NULL) {
+	err = -EINVAL;
+	goto out;
+    }
+
+    v9fs_string_copy(&vs->xattr_fidp->path, &vs->file_fidp->path);
+    if (vs->name.data[0] == 0) {
+	/*
+	 * listxattr request. Get the size first
+	 */
+	vs->size = v9fs_do_llistxattr(s, &vs->xattr_fidp->path,
+				      NULL, 0);
+	if (vs->size < 0) {
+	    err = vs->size;
+	}
+	v9fs_post_lxattr_check(s, vs, err);
+	return;
+    } else {
+	/*
+	 * specific xattr fid. We check for xattr
+	 * presence also collect the xattr size
+	 */
+	vs->size = v9fs_do_lgetxattr(s, &vs->xattr_fidp->path,
+				     &vs->name, NULL, 0);
+	if (vs->size < 0) {
+	    err = vs->size;
+	}
+	v9fs_post_xattr_check(s, vs, err);
+	return;
+    }
+out:
+    complete_pdu(s, vs->pdu, err);
+    v9fs_string_free(&vs->name);
+    qemu_free(vs);
+}
+
+
 typedef void (pdu_handler_t)(V9fsState *s, V9fsPDU *pdu);
 
 static pdu_handler_t *pdu_handlers[] = {
@@ -3097,6 +3283,7 @@ static pdu_handler_t *pdu_handlers[] = {
     [P9_TSTATFS] = v9fs_statfs,
     [P9_TGETATTR] = v9fs_getattr,
     [P9_TSETATTR] = v9fs_setattr,
+    [P9_TXATTRWALK] = v9fs_xattrwalk,
     [P9_TMKNOD] = v9fs_mknod,
     [P9_TRENAME] = v9fs_rename,
     [P9_TMKDIR] = v9fs_mkdir,
diff --git a/hw/virtio-9p.h b/hw/virtio-9p.h
index faca6b2..005df49 100644
--- a/hw/virtio-9p.h
+++ b/hw/virtio-9p.h
@@ -29,6 +29,8 @@ enum {
     P9_RGETATTR,
     P9_TSETATTR = 26,
     P9_RSETATTR,
+    P9_TXATTRWALK = 30,
+    P9_RXATTRWALK,
     P9_TREADDIR = 40,
     P9_RREADDIR,
     P9_TLINK = 70,
@@ -416,6 +418,18 @@ typedef struct V9fsRenameState {
     V9fsString name;
 } V9fsRenameState;
 
+typedef struct V9fsXattrState
+{
+    V9fsPDU *pdu;
+    size_t offset;
+    V9fsFidState *file_fidp;
+    V9fsFidState *xattr_fidp;
+    V9fsString name;
+    int64_t size;
+    int flags;
+    void *value;
+} V9fsXattrState;
+
 extern size_t pdu_packunpack(void *addr, struct iovec *sg, int sg_count,
                             size_t offset, size_t size, int pack);
 
-- 
1.6.5.2

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

* [Qemu-devel] [PATCH -V4 19/26] virtio-9p: Implement TXATTRCREATE
  2010-08-29 19:02 [Qemu-devel] [PATCH-V4 00/26] Consolidated VirtFS work Venkateswararao Jujjuri (JV)
                   ` (17 preceding siblings ...)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 18/26] virtio-9p: Implement TXATTRWALK Venkateswararao Jujjuri (JV)
@ 2010-08-29 19:02 ` Venkateswararao Jujjuri (JV)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 20/26] virtio-9p: Hide user.virtfs xattr in case of mapped security Venkateswararao Jujjuri (JV)
                   ` (6 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Venkateswararao Jujjuri (JV) @ 2010-08-29 19:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, Venkateswararao Jujjuri, Aneesh Kumar K.V

From: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>

TXATTRCREATE:  Prepare a fid for setting xattr value on a file system object.

 size[4] TXATTRCREATE tag[2] fid[4] name[s] attr_size[8] flags[4]
 size[4] RXATTRWALK tag[2]

txattrcreate gets a fid pointing to xattr. This fid can later be
used to get set the xattr value.

flag value is derived from set Linux setxattr. The manpage says
"The flags parameter can be used to refine the semantics of the operation.
XATTR_CREATE specifies a pure create, which fails if the named attribute
exists already. XATTR_REPLACE specifies a pure replace operation, which
fails if the named attribute does not already exist. By default (no flags),
the extended attribute will be created if need be, or will simply replace
the value if the attribute exists."

The actual setxattr operation happens when the fid is clunked. At that point
the written byte count and the attr_size specified in TXATTRCREATE should be
same otherwise an error will be returned.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
---
 hw/file-op-9p.h      |    2 +
 hw/virtio-9p-debug.c |    9 +++
 hw/virtio-9p-local.c |    7 +++
 hw/virtio-9p.c       |  143 ++++++++++++++++++++++++++++++++++++++++++++++---
 hw/virtio-9p.h       |    2 +
 5 files changed, 154 insertions(+), 9 deletions(-)

diff --git a/hw/file-op-9p.h b/hw/file-op-9p.h
index 989266f..e9e6657 100644
--- a/hw/file-op-9p.h
+++ b/hw/file-op-9p.h
@@ -78,6 +78,8 @@ typedef struct FileOperations
     ssize_t (*lgetxattr)(FsContext *, const char *, const char *, void *,
                                                                      size_t);
     ssize_t (*llistxattr)(FsContext *, const char *, void *, size_t);
+    int (*lsetxattr)(FsContext *, const char *, const char *, void *, size_t,
+									  int);
     void *opaque;
 } FileOperations;
 #endif
diff --git a/hw/virtio-9p-debug.c b/hw/virtio-9p-debug.c
index 4554eb6..ad68054 100644
--- a/hw/virtio-9p-debug.c
+++ b/hw/virtio-9p-debug.c
@@ -588,6 +588,15 @@ void pprint_pdu(V9fsPDU *pdu)
     case P9_RXATTRWALK:
         fprintf(llogfile, "RXATTRWALK: (");
         pprint_int64(pdu, 1, &offset, "xattrsize");
+    case P9_TXATTRCREATE:
+        fprintf(llogfile, "TXATTRCREATE: (");
+        pprint_int32(pdu, 0, &offset, "fid");
+        pprint_str(pdu, 0, &offset, ", name");
+        pprint_int64(pdu, 0, &offset, ", xattrsize");
+        pprint_int32(pdu, 0, &offset, ", flags");
+        break;
+    case P9_RXATTRCREATE:
+        fprintf(llogfile, "RXATTRCREATE: (");
         break;
     default:
         fprintf(llogfile, "unknown(%d): (", pdu->id);
diff --git a/hw/virtio-9p-local.c b/hw/virtio-9p-local.c
index 902ca79..461701a 100644
--- a/hw/virtio-9p-local.c
+++ b/hw/virtio-9p-local.c
@@ -487,6 +487,12 @@ static ssize_t local_llistxattr(FsContext *ctx, const char *path,
     return llistxattr(rpath(ctx, path), value, size);
 }
 
+static int local_lsetxattr(FsContext *ctx, const char *path, const char *name,
+			   void *value, size_t size, int flags)
+{
+    return lsetxattr(rpath(ctx, path), name, value, size, flags);
+}
+
 FileOperations local_ops = {
     .lstat = local_lstat,
     .readlink = local_readlink,
@@ -517,4 +523,5 @@ FileOperations local_ops = {
     .statfs = local_statfs,
     .lgetxattr = local_lgetxattr,
     .llistxattr = local_llistxattr,
+    .lsetxattr = local_lsetxattr,
 };
diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index e2811ae..13ab735 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -278,6 +278,14 @@ static ssize_t v9fs_do_llistxattr(V9fsState *s, V9fsString *path,
                               value, size);
 }
 
+static int v9fs_do_lsetxattr(V9fsState *s, V9fsString *path,
+                             V9fsString *xattr_name,
+                             void *value, size_t size, int flags)
+{
+    return s->ops->lsetxattr(&s->ctx, path->data,
+                             xattr_name->data, value, size, flags);
+}
+
 static void v9fs_string_init(V9fsString *str)
 {
     str->data = NULL;
@@ -431,8 +439,39 @@ static V9fsFidState *alloc_fid(V9fsState *s, int32_t fid)
     return f;
 }
 
+static int v9fs_xattr_fid_clunk(V9fsState *s, V9fsFidState *fidp)
+{
+    int retval = 0;
+
+    if (fidp->fs.xattr.copied_len == -1) {
+	/* getxattr/listxattr fid */
+	goto free_value;
+    }
+    /*
+     * if this is fid for setxattr. clunk should
+     * result in setxattr localcall
+     */
+    if (fidp->fs.xattr.len != fidp->fs.xattr.copied_len) {
+	/* clunk after partial write */
+	retval = -EINVAL;
+	goto free_out;
+    }
+    retval = v9fs_do_lsetxattr(s, &fidp->path, &fidp->fs.xattr.name,
+			       fidp->fs.xattr.value,
+			       fidp->fs.xattr.len,
+			       fidp->fs.xattr.flags);
+free_out:
+    v9fs_string_free(&fidp->fs.xattr.name);
+free_value:
+    if (fidp->fs.xattr.value) {
+	qemu_free(fidp->fs.xattr.value);
+    }
+    return retval;
+}
+
 static int free_fid(V9fsState *s, int32_t fid)
 {
+    int retval = 0;
     V9fsFidState **fidpp, *fidp;
 
     for (fidpp = &s->fid_list; *fidpp; fidpp = &(*fidpp)->next) {
@@ -453,14 +492,12 @@ static int free_fid(V9fsState *s, int32_t fid)
     } else if (fidp->fid_type == P9_FID_DIR) {
         v9fs_do_closedir(s, fidp->fs.dir);
     } else if (fidp->fid_type == P9_FID_XATTR) {
-	if (fidp->fs.xattr.value) {
-	    qemu_free(fidp->fs.xattr.value);
-	}
+	retval = v9fs_xattr_fid_clunk(s, fidp);
     }
     v9fs_string_free(&fidp->path);
     qemu_free(fidp);
 
-    return 0;
+    return retval;
 }
 
 #define P9_QID_TYPE_DIR         0x80
@@ -2211,6 +2248,48 @@ out:
     qemu_free(vs);
 }
 
+static void v9fs_xattr_write(V9fsState *s, V9fsWriteState *vs)
+{
+    int i, to_copy;
+    ssize_t err = 0;
+    int write_count;
+    int64_t xattr_len;
+
+    xattr_len = vs->fidp->fs.xattr.len;
+    write_count = xattr_len - vs->off;
+    if (write_count > vs->count) {
+	write_count = vs->count;
+    } else if (write_count < 0) {
+	/*
+	 * write beyond XATTR value len specified in
+	 * xattrcreate
+	 */
+	err = -ENOSPC;
+	goto out;
+    }
+    vs->offset += pdu_marshal(vs->pdu, vs->offset, "d", write_count);
+    err = vs->offset;
+    vs->fidp->fs.xattr.copied_len += write_count;
+    /*
+     * Now copy the content from sg list
+     */
+    for (i = 0; i < vs->cnt; i++) {
+	if (write_count > vs->sg[i].iov_len) {
+	    to_copy = vs->sg[i].iov_len;
+	} else {
+	    to_copy = write_count;
+	}
+	memcpy((char *)vs->fidp->fs.xattr.value + vs->off,
+	       vs->sg[i].iov_base, to_copy);
+	/* updating vs->off since we are not using below */
+	vs->off += to_copy;
+	write_count -= to_copy;
+    }
+out:
+    complete_pdu(s, vs->pdu, err);
+    qemu_free(vs);
+}
+
 static void v9fs_write(V9fsState *s, V9fsPDU *pdu)
 {
     int32_t fid;
@@ -2226,7 +2305,7 @@ static void v9fs_write(V9fsState *s, V9fsPDU *pdu)
     vs->len = 0;
 
     pdu_unmarshal(vs->pdu, vs->offset, "dqdv", &fid, &vs->off, &vs->count,
-                    vs->sg, &vs->cnt);
+                  vs->sg, &vs->cnt);
 
     vs->fidp = lookup_fid(s, fid);
     if (vs->fidp == NULL) {
@@ -2234,11 +2313,21 @@ static void v9fs_write(V9fsState *s, V9fsPDU *pdu)
         goto out;
     }
 
-    if (vs->fidp->fs.fd == -1) {
-        err = -EINVAL;
-        goto out;
+    if (vs->fidp->fid_type == P9_FID_FILE) {
+	if (vs->fidp->fs.fd == -1) {
+	    err = -EINVAL;
+	    goto out;
+	}
+    } else if (vs->fidp->fid_type == P9_FID_XATTR) {
+	/*
+	 * setxattr operation
+	 */
+	v9fs_xattr_write(s, vs);
+	return;
+    } else {
+	err = -EINVAL;
+	goto out;
     }
-
     err = v9fs_do_lseek(s, vs->fidp->fs.fd, vs->off, SEEK_SET);
 
     v9fs_write_post_lseek(s, vs, err);
@@ -3275,6 +3364,41 @@ out:
     qemu_free(vs);
 }
 
+static void v9fs_xattrcreate(V9fsState *s, V9fsPDU *pdu)
+{
+    int flags;
+    int32_t fid;
+    ssize_t err = 0;
+    V9fsXattrState *vs;
+
+    vs = qemu_malloc(sizeof(*vs));
+    vs->pdu = pdu;
+    vs->offset = 7;
+
+    pdu_unmarshal(vs->pdu, vs->offset, "dsqd",
+		  &fid, &vs->name, &vs->size, &flags);
+
+    vs->file_fidp = lookup_fid(s, fid);
+    if (vs->file_fidp == NULL) {
+        err = -EINVAL;
+        goto out;
+    }
+
+    /* Make the file fid point to xattr */
+    vs->xattr_fidp = vs->file_fidp;
+    vs->xattr_fidp->fid_type = P9_FID_XATTR;
+    vs->xattr_fidp->fs.xattr.copied_len = 0;
+    vs->xattr_fidp->fs.xattr.len = vs->size;
+    vs->xattr_fidp->fs.xattr.flags = flags;
+    v9fs_string_init(&vs->xattr_fidp->fs.xattr.name);
+    v9fs_string_copy(&vs->xattr_fidp->fs.xattr.name, &vs->name);
+    vs->xattr_fidp->fs.xattr.value = qemu_malloc(vs->size);
+
+out:
+    complete_pdu(s, vs->pdu, err);
+    v9fs_string_free(&vs->name);
+    qemu_free(vs);
+}
 
 typedef void (pdu_handler_t)(V9fsState *s, V9fsPDU *pdu);
 
@@ -3284,6 +3408,7 @@ static pdu_handler_t *pdu_handlers[] = {
     [P9_TGETATTR] = v9fs_getattr,
     [P9_TSETATTR] = v9fs_setattr,
     [P9_TXATTRWALK] = v9fs_xattrwalk,
+    [P9_TXATTRCREATE] = v9fs_xattrcreate,
     [P9_TMKNOD] = v9fs_mknod,
     [P9_TRENAME] = v9fs_rename,
     [P9_TMKDIR] = v9fs_mkdir,
diff --git a/hw/virtio-9p.h b/hw/virtio-9p.h
index 005df49..016ba1d 100644
--- a/hw/virtio-9p.h
+++ b/hw/virtio-9p.h
@@ -31,6 +31,8 @@ enum {
     P9_RSETATTR,
     P9_TXATTRWALK = 30,
     P9_RXATTRWALK,
+    P9_TXATTRCREATE = 32,
+    P9_RXATTRCREATE,
     P9_TREADDIR = 40,
     P9_RREADDIR,
     P9_TLINK = 70,
-- 
1.6.5.2

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

* [Qemu-devel] [PATCH -V4 20/26] virtio-9p: Hide user.virtfs xattr in case of mapped security.
  2010-08-29 19:02 [Qemu-devel] [PATCH-V4 00/26] Consolidated VirtFS work Venkateswararao Jujjuri (JV)
                   ` (18 preceding siblings ...)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 19/26] virtio-9p: Implement TXATTRCREATE Venkateswararao Jujjuri (JV)
@ 2010-08-29 19:02 ` Venkateswararao Jujjuri (JV)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 21/26] virtio-9p: Add SM_NONE security model Venkateswararao Jujjuri (JV)
                   ` (5 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Venkateswararao Jujjuri (JV) @ 2010-08-29 19:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, Venkateswararao Jujjuri, Aneesh Kumar K.V

From: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>

With mapped security mode we use "user.virtfs" namespace is used
to store the virtFs related attributes. So hide it from user.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
---
 hw/virtio-9p-local.c |   75 ++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 72 insertions(+), 3 deletions(-)

diff --git a/hw/virtio-9p-local.c b/hw/virtio-9p-local.c
index 461701a..7f847c6 100644
--- a/hw/virtio-9p-local.c
+++ b/hw/virtio-9p-local.c
@@ -478,18 +478,87 @@ static ssize_t local_lgetxattr(FsContext *ctx, const char *path,
                                 const char *name,
                                void *value, size_t size)
 {
+    if ((ctx->fs_sm == SM_MAPPED) &&
+        (strncmp(name, "user.virtfs.", 12) == 0)) {
+        /*
+         * Don't allow fetch of user.virtfs namesapce
+         * in case of mapped security
+         */
+        errno = ENOATTR;
+        return -1;
+    }
+
     return lgetxattr(rpath(ctx, path), name, value, size);
 }
 
 static ssize_t local_llistxattr(FsContext *ctx, const char *path,
                                 void *value, size_t size)
 {
-    return llistxattr(rpath(ctx, path), value, size);
+    ssize_t retval;
+    ssize_t actual_len = 0;
+    char *orig_value, *orig_value_start;
+    char *temp_value, *temp_value_start;
+    ssize_t xattr_len, parsed_len = 0, attr_len;
+
+    if (ctx->fs_sm != SM_MAPPED) {
+        return llistxattr(rpath(ctx, path), value, size);
+    }
+
+    /* Get the actual len */
+    xattr_len = llistxattr(rpath(ctx, path), value, 0);
+
+    /* Now fetch the xattr and find the actual size */
+    orig_value = qemu_malloc(xattr_len);
+    xattr_len = llistxattr(rpath(ctx, path), orig_value, xattr_len);
+
+    /*
+     * For mapped security model drop user.virtfs namespace
+     * from the list
+     */
+    temp_value = qemu_mallocz(xattr_len);
+    temp_value_start = temp_value;
+    orig_value_start = orig_value;
+    while (xattr_len > parsed_len) {
+        attr_len = strlen(orig_value) + 1;
+        if (strncmp(orig_value, "user.virtfs.", 12) != 0) {
+            /* Copy this entry */
+            strcat(temp_value, orig_value);
+            temp_value  += attr_len;
+            actual_len += attr_len;
+        }
+        parsed_len += attr_len;
+        orig_value += attr_len;
+    }
+    if (!size) {
+        retval = actual_len;
+        goto out;
+    } else if (size >= actual_len) {
+        /* now copy the parsed attribute list back */
+        memset(value, 0, size);
+        memcpy(value, temp_value_start, actual_len);
+        retval = actual_len;
+        goto out;
+    }
+    errno = ERANGE;
+    retval = -1;
+out:
+    qemu_free(orig_value_start);
+    qemu_free(temp_value_start);
+    return retval;
 }
 
 static int local_lsetxattr(FsContext *ctx, const char *path, const char *name,
-			   void *value, size_t size, int flags)
-{
+                            void *value, size_t size, int flags)
+{
+    if ((ctx->fs_sm == SM_MAPPED) &&
+        (strncmp(name, "user.virtfs.", 12) == 0)) {
+        /*
+         * Don't allow fetch of user.virtfs namesapce
+         * in case of mapped security
+         */
+        errno = EACCES;
+        return -1;
+    }
     return lsetxattr(rpath(ctx, path), name, value, size, flags);
 }
 
-- 
1.6.5.2

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

* [Qemu-devel] [PATCH -V4 21/26] virtio-9p: Add SM_NONE security model
  2010-08-29 19:02 [Qemu-devel] [PATCH-V4 00/26] Consolidated VirtFS work Venkateswararao Jujjuri (JV)
                   ` (19 preceding siblings ...)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 20/26] virtio-9p: Hide user.virtfs xattr in case of mapped security Venkateswararao Jujjuri (JV)
@ 2010-08-29 19:02 ` Venkateswararao Jujjuri (JV)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 22/26] virtio-9p: Use lchown which won't follow symlink Venkateswararao Jujjuri (JV)
                   ` (4 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Venkateswararao Jujjuri (JV) @ 2010-08-29 19:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, Venkateswararao Jujjuri, Aneesh Kumar K.V

From: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>

This is equivalent to SM_PASSTHROUGH security model.
The only exception is, failure of privilige operation like chown
are ignored. This makes a passthrough like security model usable
for people who runs kvm as non root

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
---
 hw/file-op-9p.h      |   15 +++++++++++++--
 hw/virtio-9p-local.c |   40 ++++++++++++++++++++++++++++++----------
 hw/virtio-9p.c       |   13 ++++++++++---
 qemu-options.hx      |    4 ++--
 vl.c                 |    2 +-
 5 files changed, 56 insertions(+), 18 deletions(-)

diff --git a/hw/file-op-9p.h b/hw/file-op-9p.h
index e9e6657..6ed7937 100644
--- a/hw/file-op-9p.h
+++ b/hw/file-op-9p.h
@@ -24,8 +24,19 @@
 
 typedef enum
 {
-    SM_PASSTHROUGH = 1, /* uid/gid set on fileserver files */
-    SM_MAPPED,  /* uid/gid part of xattr */
+    /*
+     * Server will try to set uid/gid.
+     * On failure ignore the error.
+     */
+    SM_NONE = 0,
+    /*
+     * uid/gid set on fileserver files
+     */
+    SM_PASSTHROUGH = 1,
+    /*
+     * uid/gid part of xattr
+     */
+    SM_MAPPED,
 } SecModel;
 
 typedef struct FsCred
diff --git a/hw/virtio-9p-local.c b/hw/virtio-9p-local.c
index 7f847c6..6a2108c 100644
--- a/hw/virtio-9p-local.c
+++ b/hw/virtio-9p-local.c
@@ -102,7 +102,13 @@ static int local_post_create_passthrough(FsContext *fs_ctx, const char *path,
         return -1;
     }
     if (chown(rpath(fs_ctx, path), credp->fc_uid, credp->fc_gid) < 0) {
-        return -1;
+        /*
+         * If we fail to change ownership and if we are
+         * using security model none. Ignore the error
+         */
+        if (fs_ctx->fs_sm != SM_NONE) {
+            return -1;
+        }
     }
     return 0;
 }
@@ -122,7 +128,8 @@ static ssize_t local_readlink(FsContext *fs_ctx, const char *path,
         } while (tsize == -1 && errno == EINTR);
         close(fd);
         return tsize;
-    } else if (fs_ctx->fs_sm == SM_PASSTHROUGH) {
+    } else if ((fs_ctx->fs_sm == SM_PASSTHROUGH) ||
+               (fs_ctx->fs_sm == SM_NONE)) {
         tsize = readlink(rpath(fs_ctx, path), buf, bufsz);
     }
     return tsize;
@@ -189,7 +196,8 @@ static int local_chmod(FsContext *fs_ctx, const char *path, FsCred *credp)
 {
     if (fs_ctx->fs_sm == SM_MAPPED) {
         return local_set_xattr(rpath(fs_ctx, path), credp);
-    } else if (fs_ctx->fs_sm == SM_PASSTHROUGH) {
+    } else if ((fs_ctx->fs_sm == SM_PASSTHROUGH) ||
+               (fs_ctx->fs_sm == SM_NONE)) {
         return chmod(rpath(fs_ctx, path), credp->fc_mode);
     }
     return -1;
@@ -211,7 +219,8 @@ static int local_mknod(FsContext *fs_ctx, const char *path, FsCred *credp)
             serrno = errno;
             goto err_end;
         }
-    } else if (fs_ctx->fs_sm == SM_PASSTHROUGH) {
+    } else if ((fs_ctx->fs_sm == SM_PASSTHROUGH) ||
+               (fs_ctx->fs_sm == SM_NONE)) {
         err = mknod(rpath(fs_ctx, path), credp->fc_mode, credp->fc_rdev);
         if (err == -1) {
             return err;
@@ -247,7 +256,8 @@ static int local_mkdir(FsContext *fs_ctx, const char *path, FsCred *credp)
             serrno = errno;
             goto err_end;
         }
-    } else if (fs_ctx->fs_sm == SM_PASSTHROUGH) {
+    } else if ((fs_ctx->fs_sm == SM_PASSTHROUGH) ||
+               (fs_ctx->fs_sm == SM_NONE)) {
         err = mkdir(rpath(fs_ctx, path), credp->fc_mode);
         if (err == -1) {
             return err;
@@ -316,7 +326,8 @@ static int local_open2(FsContext *fs_ctx, const char *path, int flags,
             serrno = errno;
             goto err_end;
         }
-    } else if (fs_ctx->fs_sm == SM_PASSTHROUGH) {
+    } else if ((fs_ctx->fs_sm == SM_PASSTHROUGH) ||
+               (fs_ctx->fs_sm == SM_NONE)) {
         fd = open(rpath(fs_ctx, path), flags, credp->fc_mode);
         if (fd == -1) {
             return fd;
@@ -372,15 +383,23 @@ static int local_symlink(FsContext *fs_ctx, const char *oldpath,
             serrno = errno;
             goto err_end;
         }
-    } else if (fs_ctx->fs_sm == SM_PASSTHROUGH) {
+    } else if ((fs_ctx->fs_sm == SM_PASSTHROUGH) ||
+               (fs_ctx->fs_sm == SM_NONE)) {
         err = symlink(oldpath, rpath(fs_ctx, newpath));
         if (err) {
             return err;
         }
         err = lchown(rpath(fs_ctx, newpath), credp->fc_uid, credp->fc_gid);
         if (err == -1) {
-            serrno = errno;
-            goto err_end;
+            /*
+             * If we fail to change ownership and if we are
+             * using security model none. Ignore the error
+             */
+            if (fs_ctx->fs_sm != SM_NONE) {
+                serrno = errno;
+                goto err_end;
+            } else
+                err = 0;
         }
     }
     return err;
@@ -447,7 +466,8 @@ static int local_chown(FsContext *fs_ctx, const char *path, FsCred *credp)
         return lchown(rpath(fs_ctx, path), credp->fc_uid, credp->fc_gid);
     } else if (fs_ctx->fs_sm == SM_MAPPED) {
         return local_set_xattr(rpath(fs_ctx, path), credp);
-    } else if (fs_ctx->fs_sm == SM_PASSTHROUGH) {
+    } else if ((fs_ctx->fs_sm == SM_PASSTHROUGH) ||
+               (fs_ctx->fs_sm == SM_NONE)) {
         return lchown(rpath(fs_ctx, path), credp->fc_uid, credp->fc_gid);
     }
     return -1;
diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index 13ab735..c154bac 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -3545,12 +3545,19 @@ VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf)
          * Client user credentials are saved in extended attributes.
          */
         s->ctx.fs_sm = SM_MAPPED;
+    } else if (!strcmp(fse->security_model, "none")) {
+        /* Files on the fileserver are set to QEMU credentials.
+         * Client user credentials are saved in extended attributes.
+         */
+        s->ctx.fs_sm = SM_NONE;
+
     } else {
-        /* user haven't specified a correct security option */
-        fprintf(stderr, "one of the following must be specified as the"
+        /* Default so SM_NONE option which was the default before */
+        fprintf(stderr, "Default to security_mode=none. You may want"
+                " enable advanced security model using "
                 "security option:\n\t security_model=passthrough \n\t "
                 "security_model=mapped\n");
-        return NULL;
+        s->ctx.fs_sm = SM_MAPPED;
     }
 
     if (lstat(fse->path, &stat)) {
diff --git a/qemu-options.hx b/qemu-options.hx
index 453f129..368bf96 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -485,7 +485,7 @@ ETEXI
 DEFHEADING(File system options:)
 
 DEF("fsdev", HAS_ARG, QEMU_OPTION_fsdev,
-    "-fsdev local,id=id,path=path,security_model=[mapped|passthrough]\n",
+    "-fsdev local,id=id,path=path,security_model=[mapped|passthrough|none]\n",
     QEMU_ARCH_ALL)
 
 STEXI
@@ -518,7 +518,7 @@ ETEXI
 DEFHEADING(Virtual File system pass-through options:)
 
 DEF("virtfs", HAS_ARG, QEMU_OPTION_virtfs,
-    "-virtfs local,path=path,mount_tag=tag,security_model=[mapped|passthrough]\n",
+    "-virtfs local,path=path,mount_tag=tag,security_model=[mapped|passthrough|none]\n",
     QEMU_ARCH_ALL)
 
 STEXI
diff --git a/vl.c b/vl.c
index 91d1684..ade582b 100644
--- a/vl.c
+++ b/vl.c
@@ -2320,7 +2320,7 @@ int main(int argc, char **argv, char **envp)
                         qemu_opt_get(opts, "path") == NULL ||
                         qemu_opt_get(opts, "security_model") == NULL) {
                     fprintf(stderr, "Usage: -virtfs fstype,path=/share_path/,"
-                            "security_model=[mapped|passthrough],"
+                            "security_model=[mapped|passthrough|none],"
                             "mnt_tag=tag.\n");
                     exit(1);
                 }
-- 
1.6.5.2

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

* [Qemu-devel] [PATCH -V4 22/26] virtio-9p: Use lchown which won't follow symlink
  2010-08-29 19:02 [Qemu-devel] [PATCH-V4 00/26] Consolidated VirtFS work Venkateswararao Jujjuri (JV)
                   ` (20 preceding siblings ...)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 21/26] virtio-9p: Add SM_NONE security model Venkateswararao Jujjuri (JV)
@ 2010-08-29 19:02 ` Venkateswararao Jujjuri (JV)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 23/26] virtio-9p: Fix the memset usage Venkateswararao Jujjuri (JV)
                   ` (3 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Venkateswararao Jujjuri (JV) @ 2010-08-29 19:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, Venkateswararao Jujjuri, Aneesh Kumar K.V

From: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>

We should always use functions which don't follow
symlink on the server

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
---
 hw/virtio-9p-local.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/hw/virtio-9p-local.c b/hw/virtio-9p-local.c
index 6a2108c..eb4797b 100644
--- a/hw/virtio-9p-local.c
+++ b/hw/virtio-9p-local.c
@@ -101,7 +101,7 @@ static int local_post_create_passthrough(FsContext *fs_ctx, const char *path,
     if (chmod(rpath(fs_ctx, path), credp->fc_mode & 07777) < 0) {
         return -1;
     }
-    if (chown(rpath(fs_ctx, path), credp->fc_uid, credp->fc_gid) < 0) {
+    if (lchown(rpath(fs_ctx, path), credp->fc_uid, credp->fc_gid) < 0) {
         /*
          * If we fail to change ownership and if we are
          * using security model none. Ignore the error
-- 
1.6.5.2

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

* [Qemu-devel] [PATCH -V4 23/26] virtio-9p: Fix the memset usage
  2010-08-29 19:02 [Qemu-devel] [PATCH-V4 00/26] Consolidated VirtFS work Venkateswararao Jujjuri (JV)
                   ` (21 preceding siblings ...)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 22/26] virtio-9p: Use lchown which won't follow symlink Venkateswararao Jujjuri (JV)
@ 2010-08-29 19:02 ` Venkateswararao Jujjuri (JV)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 24/26] [virtio-9p] Remove all instances of unnecessary dotu variable Venkateswararao Jujjuri (JV)
                   ` (2 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Venkateswararao Jujjuri (JV) @ 2010-08-29 19:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, Venkateswararao Jujjuri, Aneesh Kumar K.V

From: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>

The arguments are wrong. Use qemu_mallocz directly

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
---
 hw/virtio-9p.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index c154bac..eb44c86 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -2823,8 +2823,7 @@ static void v9fs_wstat_post_chown(V9fsState *s, V9fsWstatState *vs, int err)
     if (vs->v9stat.name.size != 0) {
         V9fsRenameState *vr;
 
-        vr = qemu_malloc(sizeof(V9fsRenameState));
-        memset(vr, sizeof(*vr), 0);
+        vr = qemu_mallocz(sizeof(V9fsRenameState));
         vr->newdirfid = -1;
         vr->pdu = vs->pdu;
         vr->fidp = vs->fidp;
-- 
1.6.5.2

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

* [Qemu-devel] [PATCH -V4 24/26] [virtio-9p] Remove all instances of unnecessary dotu variable.
  2010-08-29 19:02 [Qemu-devel] [PATCH-V4 00/26] Consolidated VirtFS work Venkateswararao Jujjuri (JV)
                   ` (22 preceding siblings ...)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 23/26] virtio-9p: Fix the memset usage Venkateswararao Jujjuri (JV)
@ 2010-08-29 19:02 ` Venkateswararao Jujjuri (JV)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 25/26] [virtio-9p] This patch implements TLERROR/RLERROR on the qemu 9P server Venkateswararao Jujjuri (JV)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 26/26] virtio-9p: Change handling of flags in open() path for 9P2000.L Venkateswararao Jujjuri (JV)
  25 siblings, 0 replies; 27+ messages in thread
From: Venkateswararao Jujjuri (JV) @ 2010-08-29 19:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Arun R Bharadwaj, aliguori, Venkateswararao Jujjuri

From: Arun R Bharadwaj <arun@linux.vnet.ibm.com>

Signed-off-by: Arun R Bharadwaj <arun@linux.vnet.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
---
 hw/virtio-9p-debug.c |   26 ++++--------
 hw/virtio-9p-debug.h |    1 -
 hw/virtio-9p.c       |  115 +++++++++++++++++++++++---------------------------
 3 files changed, 61 insertions(+), 81 deletions(-)

diff --git a/hw/virtio-9p-debug.c b/hw/virtio-9p-debug.c
index ad68054..6f6a0ec 100644
--- a/hw/virtio-9p-debug.c
+++ b/hw/virtio-9p-debug.c
@@ -169,12 +169,10 @@ static void pprint_stat(V9fsPDU *pdu, int rx, size_t *offsetp, const char *name)
     pprint_str(pdu, rx, offsetp, ", uid");
     pprint_str(pdu, rx, offsetp, ", gid");
     pprint_str(pdu, rx, offsetp, ", muid");
-    if (dotu) {
-        pprint_str(pdu, rx, offsetp, ", extension");
-        pprint_int32(pdu, rx, offsetp, ", uid");
-        pprint_int32(pdu, rx, offsetp, ", gid");
-        pprint_int32(pdu, rx, offsetp, ", muid");
-    }
+    pprint_str(pdu, rx, offsetp, ", extension");
+    pprint_int32(pdu, rx, offsetp, ", uid");
+    pprint_int32(pdu, rx, offsetp, ", gid");
+    pprint_int32(pdu, rx, offsetp, ", muid");
     fprintf(llogfile, "}");
 }
 
@@ -401,9 +399,7 @@ void pprint_pdu(V9fsPDU *pdu)
         pprint_int32(pdu, 0, &offset, "afid");
         pprint_str(pdu, 0, &offset, ", uname");
         pprint_str(pdu, 0, &offset, ", aname");
-        if (dotu) {
-            pprint_int32(pdu, 0, &offset, ", n_uname");
-        }
+        pprint_int32(pdu, 0, &offset, ", n_uname");
         break;
     case P9_RAUTH:
         fprintf(llogfile, "RAUTH: (");
@@ -415,9 +411,7 @@ void pprint_pdu(V9fsPDU *pdu)
         pprint_int32(pdu, 0, &offset, ", afid");
         pprint_str(pdu, 0, &offset, ", uname");
         pprint_str(pdu, 0, &offset, ", aname");
-        if (dotu) {
-            pprint_int32(pdu, 0, &offset, ", n_uname");
-        }
+        pprint_int32(pdu, 0, &offset, ", n_uname");
         break;
     case P9_RATTACH:
         fprintf(llogfile, "RATTACH: (");
@@ -429,9 +423,7 @@ void pprint_pdu(V9fsPDU *pdu)
     case P9_RERROR:
         fprintf(llogfile, "RERROR: (");
         pprint_str(pdu, 1, &offset, "ename");
-        if (dotu) {
-            pprint_int32(pdu, 1, &offset, ", ecode");
-        }
+        pprint_int32(pdu, 1, &offset, ", ecode");
         break;
     case P9_TFLUSH:
         fprintf(llogfile, "TFLUSH: (");
@@ -466,9 +458,7 @@ void pprint_pdu(V9fsPDU *pdu)
         pprint_str(pdu, 0, &offset, ", name");
         pprint_int32(pdu, 0, &offset, ", perm");
         pprint_int8(pdu, 0, &offset, ", mode");
-        if (dotu) {
-            pprint_str(pdu, 0, &offset, ", extension");
-        }
+        pprint_str(pdu, 0, &offset, ", extension");
         break;
     case P9_RCREATE:
         fprintf(llogfile, "RCREATE: (");
diff --git a/hw/virtio-9p-debug.h b/hw/virtio-9p-debug.h
index 0104be5..d9a2491 100644
--- a/hw/virtio-9p-debug.h
+++ b/hw/virtio-9p-debug.h
@@ -1,7 +1,6 @@
 #ifndef _QEMU_VIRTIO_9P_DEBUG_H
 #define _QEMU_VIRTIO_9P_DEBUG_H
 
-extern int dotu;
 void pprint_pdu(V9fsPDU *pdu);
 
 #endif
diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index eb44c86..94dff78 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -18,7 +18,6 @@
 #include "fsdev/qemu-fsdev.h"
 #include "virtio-9p-debug.h"
 
-int dotu = 1;
 int debug_9p_pdu;
 
 enum {
@@ -841,9 +840,7 @@ static void complete_pdu(V9fsState *s, V9fsPDU *pdu, ssize_t len)
 
         len = 7;
         len += pdu_marshal(pdu, len, "s", &str);
-        if (dotu) {
-            len += pdu_marshal(pdu, len, "d", err);
-        }
+        len += pdu_marshal(pdu, len, "d", err);
 
         id = P9_RERROR;
     }
@@ -873,22 +870,20 @@ static mode_t v9mode_to_mode(uint32_t mode, V9fsString *extension)
         ret |= S_IFDIR;
     }
 
-    if (dotu) {
-        if (mode & P9_STAT_MODE_SYMLINK) {
-            ret |= S_IFLNK;
-        }
-        if (mode & P9_STAT_MODE_SOCKET) {
-            ret |= S_IFSOCK;
-        }
-        if (mode & P9_STAT_MODE_NAMED_PIPE) {
-            ret |= S_IFIFO;
-        }
-        if (mode & P9_STAT_MODE_DEVICE) {
-            if (extension && extension->data[0] == 'c') {
-                ret |= S_IFCHR;
-            } else {
-                ret |= S_IFBLK;
-            }
+    if (mode & P9_STAT_MODE_SYMLINK) {
+        ret |= S_IFLNK;
+    }
+    if (mode & P9_STAT_MODE_SOCKET) {
+        ret |= S_IFSOCK;
+    }
+    if (mode & P9_STAT_MODE_NAMED_PIPE) {
+        ret |= S_IFIFO;
+    }
+    if (mode & P9_STAT_MODE_DEVICE) {
+        if (extension && extension->data[0] == 'c') {
+            ret |= S_IFCHR;
+        } else {
+            ret |= S_IFBLK;
         }
     }
 
@@ -951,34 +946,32 @@ static uint32_t stat_to_v9mode(const struct stat *stbuf)
         mode |= P9_STAT_MODE_DIR;
     }
 
-    if (dotu) {
-        if (S_ISLNK(stbuf->st_mode)) {
-            mode |= P9_STAT_MODE_SYMLINK;
-        }
+    if (S_ISLNK(stbuf->st_mode)) {
+        mode |= P9_STAT_MODE_SYMLINK;
+    }
 
-        if (S_ISSOCK(stbuf->st_mode)) {
-            mode |= P9_STAT_MODE_SOCKET;
-        }
+    if (S_ISSOCK(stbuf->st_mode)) {
+        mode |= P9_STAT_MODE_SOCKET;
+    }
 
-        if (S_ISFIFO(stbuf->st_mode)) {
-            mode |= P9_STAT_MODE_NAMED_PIPE;
-        }
+    if (S_ISFIFO(stbuf->st_mode)) {
+        mode |= P9_STAT_MODE_NAMED_PIPE;
+    }
 
-        if (S_ISBLK(stbuf->st_mode) || S_ISCHR(stbuf->st_mode)) {
-            mode |= P9_STAT_MODE_DEVICE;
-        }
+    if (S_ISBLK(stbuf->st_mode) || S_ISCHR(stbuf->st_mode)) {
+        mode |= P9_STAT_MODE_DEVICE;
+    }
 
-        if (stbuf->st_mode & S_ISUID) {
-            mode |= P9_STAT_MODE_SETUID;
-        }
+    if (stbuf->st_mode & S_ISUID) {
+        mode |= P9_STAT_MODE_SETUID;
+    }
 
-        if (stbuf->st_mode & S_ISGID) {
-            mode |= P9_STAT_MODE_SETGID;
-        }
+    if (stbuf->st_mode & S_ISGID) {
+        mode |= P9_STAT_MODE_SETGID;
+    }
 
-        if (stbuf->st_mode & S_ISVTX) {
-            mode |= P9_STAT_MODE_SETVTX;
-        }
+    if (stbuf->st_mode & S_ISVTX) {
+        mode |= P9_STAT_MODE_SETVTX;
     }
 
     return mode;
@@ -1003,29 +996,27 @@ static int stat_to_v9stat(V9fsState *s, V9fsString *name,
     v9fs_string_null(&v9stat->gid);
     v9fs_string_null(&v9stat->muid);
 
-    if (dotu) {
-        v9stat->n_uid = stbuf->st_uid;
-        v9stat->n_gid = stbuf->st_gid;
-        v9stat->n_muid = 0;
+    v9stat->n_uid = stbuf->st_uid;
+    v9stat->n_gid = stbuf->st_gid;
+    v9stat->n_muid = 0;
 
-        v9fs_string_null(&v9stat->extension);
+    v9fs_string_null(&v9stat->extension);
 
-        if (v9stat->mode & P9_STAT_MODE_SYMLINK) {
-            err = v9fs_do_readlink(s, name, &v9stat->extension);
-            if (err == -1) {
-                err = -errno;
-                return err;
-            }
-            v9stat->extension.data[err] = 0;
-            v9stat->extension.size = err;
-        } else if (v9stat->mode & P9_STAT_MODE_DEVICE) {
-            v9fs_string_sprintf(&v9stat->extension, "%c %u %u",
-                    S_ISCHR(stbuf->st_mode) ? 'c' : 'b',
-                    major(stbuf->st_rdev), minor(stbuf->st_rdev));
-        } else if (S_ISDIR(stbuf->st_mode) || S_ISREG(stbuf->st_mode)) {
-            v9fs_string_sprintf(&v9stat->extension, "%s %u",
-                    "HARDLINKCOUNT", stbuf->st_nlink);
-        }
+    if (v9stat->mode & P9_STAT_MODE_SYMLINK) {
+        err = v9fs_do_readlink(s, name, &v9stat->extension);
+        if (err == -1) {
+            err = -errno;
+            return err;
+        }
+        v9stat->extension.data[err] = 0;
+        v9stat->extension.size = err;
+    } else if (v9stat->mode & P9_STAT_MODE_DEVICE) {
+        v9fs_string_sprintf(&v9stat->extension, "%c %u %u",
+                S_ISCHR(stbuf->st_mode) ? 'c' : 'b',
+                major(stbuf->st_rdev), minor(stbuf->st_rdev));
+    } else if (S_ISDIR(stbuf->st_mode) || S_ISREG(stbuf->st_mode)) {
+        v9fs_string_sprintf(&v9stat->extension, "%s %u",
+                "HARDLINKCOUNT", stbuf->st_nlink);
     }
 
     str = strrchr(name->data, '/');
-- 
1.6.5.2

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

* [Qemu-devel] [PATCH -V4 25/26] [virtio-9p] This patch implements TLERROR/RLERROR on the qemu 9P server.
  2010-08-29 19:02 [Qemu-devel] [PATCH-V4 00/26] Consolidated VirtFS work Venkateswararao Jujjuri (JV)
                   ` (23 preceding siblings ...)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 24/26] [virtio-9p] Remove all instances of unnecessary dotu variable Venkateswararao Jujjuri (JV)
@ 2010-08-29 19:02 ` Venkateswararao Jujjuri (JV)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 26/26] virtio-9p: Change handling of flags in open() path for 9P2000.L Venkateswararao Jujjuri (JV)
  25 siblings, 0 replies; 27+ messages in thread
From: Venkateswararao Jujjuri (JV) @ 2010-08-29 19:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Arun R Bharadwaj, aliguori, Venkateswararao Jujjuri

From: Arun R Bharadwaj <arun@linux.vnet.ibm.com>

Signed-off-by: Arun R Bharadwaj <arun@linux.vnet.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
---
 hw/virtio-9p.c |   19 +++++++++++++------
 hw/virtio-9p.h |    2 ++
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index 94dff78..b6cbbbb 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -832,17 +832,24 @@ static void complete_pdu(V9fsState *s, V9fsPDU *pdu, ssize_t len)
     int8_t id = pdu->id + 1; /* Response */
 
     if (len < 0) {
-        V9fsString str;
         int err = -len;
+        len = 7;
 
-        str.data = strerror(err);
-        str.size = strlen(str.data);
+        if (s->proto_version != V9FS_PROTO_2000L) {
+            V9fsString str;
+
+            str.data = strerror(err);
+            str.size = strlen(str.data);
+
+            len += pdu_marshal(pdu, len, "s", &str);
+            id = P9_RERROR;
+        }
 
-        len = 7;
-        len += pdu_marshal(pdu, len, "s", &str);
         len += pdu_marshal(pdu, len, "d", err);
 
-        id = P9_RERROR;
+        if (s->proto_version == V9FS_PROTO_2000L) {
+            id = P9_RLERROR;
+        }
     }
 
     /* fill out the header */
diff --git a/hw/virtio-9p.h b/hw/virtio-9p.h
index 016ba1d..0816ad6 100644
--- a/hw/virtio-9p.h
+++ b/hw/virtio-9p.h
@@ -13,6 +13,8 @@
 #define VIRTIO_9P_MOUNT_TAG 0
 
 enum {
+    P9_TLERROR = 6,
+    P9_RLERROR,
     P9_TSTATFS = 8,
     P9_RSTATFS,
     P9_TLOPEN = 12,
-- 
1.6.5.2

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

* [Qemu-devel] [PATCH -V4 26/26] virtio-9p: Change handling of flags in open() path for 9P2000.L
  2010-08-29 19:02 [Qemu-devel] [PATCH-V4 00/26] Consolidated VirtFS work Venkateswararao Jujjuri (JV)
                   ` (24 preceding siblings ...)
  2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 25/26] [virtio-9p] This patch implements TLERROR/RLERROR on the qemu 9P server Venkateswararao Jujjuri (JV)
@ 2010-08-29 19:02 ` Venkateswararao Jujjuri (JV)
  25 siblings, 0 replies; 27+ messages in thread
From: Venkateswararao Jujjuri (JV) @ 2010-08-29 19:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, Sripathi Kodi, Venkateswararao Jujjuri

From: Sripathi Kodi <sripathik@in.ibm.com>

This patch applies on top of 9P2000.L patches that we have on the list.
I took a look at how 9P server is handling open() flags in 9P2000.L path.
I think we can do away with the valid_flags() function and simplify the
code. The reasoning is as follows:

O_NOCTTY: (If the file is a terminal, don't make it the controlling
terminal of the process even though the process does not have a controlling
terminal) By the time the control reaches 9P client it is clear that what
we have is not a terminal device. Hence it does not matter what we do with
this flag. In any case 9P server can filter this flag out before making the
syscall.

O_NONBLOCK: (Don't block if i) Can't read/write to the file ii) Can't get
locks) This has an impact on FIFOs, but also on file locks. Hence we can
pass it down to the system call.

O_ASYNC: From the manpage:

   O_ASYNC
          Enable signal-driven I/O: generate a signal (SIGIO by default,  but
          this  can be changed via fcntl(2)) when input or output becomes pos-
          sible on this file descriptor.  This feature is only available  for
          terminals,  pseudo-terminals,  sockets,  and (since Linux 2.6) pipes
          and FIFOs.  See fcntl(2) for further details.

Again, this does not make any impact on regular files handled by 9P. Also,
we don't want 9P server to receive SIGIO. Hence I think 9P server can
filter this flag out before making the syscall.

O_CLOEXEC: This flag makes sense only on the client. If guest user space
sets this flag the guest VFS will take care of calling close() on the fd if
an exec() happens. Hence 9P client need not be bothered with this flag.
Also I think QEMU will not do an exec, but if it does, it makes sense to
close these fds. Hence we can pass this flag down to the syscall.

O_CREAT: Since we are in open() path it means we have confirmed that the file
exists. Hence there is no need to pass O_CREAT flag down to the system. In fact
on some versions of glibc this causes problems, because we pass O_CREAT flag,
but don't have permission bits. Hence we can just mask this flag out.

So in summary:

Mask out:
O_NOCTTY
O_ASYNC
O_CREAT

Pass-through:
O_NONBLOCK
O_CLOEXEC

Signed-off-by: Sripathi Kodi <sripathik@in.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
---
 hw/virtio-9p.c |   14 +-------------
 1 files changed, 1 insertions(+), 13 deletions(-)

diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index b6cbbbb..5347961 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -1672,15 +1672,6 @@ out:
     qemu_free(vs);
 }
 
-static inline int valid_flags(int flag)
-{
-    if (flag & O_NOCTTY || flag & O_NONBLOCK || flag & O_ASYNC ||
-            flag & O_CLOEXEC)
-        return 0;
-    else
-        return 1;
-}
-
 static void v9fs_open_post_lstat(V9fsState *s, V9fsOpenState *vs, int err)
 {
     int flags;
@@ -1697,11 +1688,8 @@ static void v9fs_open_post_lstat(V9fsState *s, V9fsOpenState *vs, int err)
         v9fs_open_post_opendir(s, vs, err);
     } else {
         if (s->proto_version == V9FS_PROTO_2000L) {
-            if (!valid_flags(vs->mode)) {
-                err = -EINVAL;
-                goto out;
-            }
             flags = vs->mode;
+            flags &= ~(O_NOCTTY | O_ASYNC | O_CREAT);
         } else {
             flags = omode_to_uflags(vs->mode);
         }
-- 
1.6.5.2

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

end of thread, other threads:[~2010-08-29 19:01 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-29 19:02 [Qemu-devel] [PATCH-V4 00/26] Consolidated VirtFS work Venkateswararao Jujjuri (JV)
2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 01/26] qemu: virtio-9p: Recognize 9P2000.L protocol Venkateswararao Jujjuri (JV)
2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 02/26] qemu: virtio-9p: Implement statfs support in server Venkateswararao Jujjuri (JV)
2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 03/26] virtio-9p: Return correct error from v9fs_remove Venkateswararao Jujjuri (JV)
2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 04/26] [V4] virtio-9p: readdir implementation for 9p2000.L Venkateswararao Jujjuri (JV)
2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 05/26] virtio-9p: Compute iounit based on host filesystem block size Venkateswararao Jujjuri (JV)
2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 06/26] virtio-9p: getattr server implementation for 9P2000.L protocol Venkateswararao Jujjuri (JV)
2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 07/26] virtio-9p: Do not reset atime Venkateswararao Jujjuri (JV)
2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 08/26] [virtio-9p] Make v9fs_do_utimensat accept timespec structures instead of v9stat Venkateswararao Jujjuri (JV)
2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 09/26] virtio-9p: Implement server side of setattr for 9P2000.L protocol Venkateswararao Jujjuri (JV)
2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 10/26] [virtio-9p] Implement TLINK for 9P2000.L Venkateswararao Jujjuri (JV)
2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 11/26] [virtio-9p] Define and implement TSYMLINK " Venkateswararao Jujjuri (JV)
2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 12/26] [virtio-9p] This patch implements TLCREATE for 9p2000.L protocol Venkateswararao Jujjuri (JV)
2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 13/26] qemu: virtio-9p: Implement TMKNOD Venkateswararao Jujjuri (JV)
2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 14/26] qemu: virtio-9p: Implement TMKDIR Venkateswararao Jujjuri (JV)
2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 15/26] rename - change name of file or directory Venkateswararao Jujjuri (JV)
2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 16/26] [virtio-9p] qemu: virtio-9p: Implement LOPEN Venkateswararao Jujjuri (JV)
2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 17/26] virtio-9p: Add fidtype so that we can do type specific operation Venkateswararao Jujjuri (JV)
2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 18/26] virtio-9p: Implement TXATTRWALK Venkateswararao Jujjuri (JV)
2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 19/26] virtio-9p: Implement TXATTRCREATE Venkateswararao Jujjuri (JV)
2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 20/26] virtio-9p: Hide user.virtfs xattr in case of mapped security Venkateswararao Jujjuri (JV)
2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 21/26] virtio-9p: Add SM_NONE security model Venkateswararao Jujjuri (JV)
2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 22/26] virtio-9p: Use lchown which won't follow symlink Venkateswararao Jujjuri (JV)
2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 23/26] virtio-9p: Fix the memset usage Venkateswararao Jujjuri (JV)
2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 24/26] [virtio-9p] Remove all instances of unnecessary dotu variable Venkateswararao Jujjuri (JV)
2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 25/26] [virtio-9p] This patch implements TLERROR/RLERROR on the qemu 9P server Venkateswararao Jujjuri (JV)
2010-08-29 19:02 ` [Qemu-devel] [PATCH -V4 26/26] virtio-9p: Change handling of flags in open() path for 9P2000.L Venkateswararao Jujjuri (JV)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.