summaryrefslogtreecommitdiff
path: root/hw/9pfs/virtio-9p.c
diff options
context:
space:
mode:
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>2011-05-07 17:21:38 +0530
committerAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>2011-08-22 09:18:58 +0530
commite4e414a427e0d7ff799e1b3ae9413c82f99b923f (patch)
treeabbede7c5197ce9e86fc3c4da34851c7da692620 /hw/9pfs/virtio-9p.c
parent0c27bf2a45d8b25119f65890d78a71415fbb0911 (diff)
downloadqemu-e4e414a427e0d7ff799e1b3ae9413c82f99b923f.tar.gz
hw/9pfs: Update v9fs_getlock to use coroutines
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Diffstat (limited to 'hw/9pfs/virtio-9p.c')
-rw-r--r--hw/9pfs/virtio-9p.c42
1 files changed, 19 insertions, 23 deletions
diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c
index 13e7c30fb6..10312c9a0a 100644
--- a/hw/9pfs/virtio-9p.c
+++ b/hw/9pfs/virtio-9p.c
@@ -3049,42 +3049,38 @@ out:
* When a TGETLOCK request comes, always return success because all lock
* handling is done by client's VFS layer.
*/
-
static void v9fs_getlock(void *opaque)
{
+ size_t offset = 7;
+ struct stat stbuf;
+ V9fsFidState *fidp;
+ V9fsGetlock *glock;
+ int32_t fid, err = 0;
V9fsPDU *pdu = opaque;
V9fsState *s = pdu->s;
- int32_t fid, err = 0;
- V9fsGetlockState *vs;
- vs = g_malloc0(sizeof(*vs));
- vs->pdu = pdu;
- vs->offset = 7;
-
- vs->glock = g_malloc(sizeof(*vs->glock));
- pdu_unmarshal(vs->pdu, vs->offset, "dbqqds", &fid, &vs->glock->type,
- &vs->glock->start, &vs->glock->length, &vs->glock->proc_id,
- &vs->glock->client_id);
+ glock = g_malloc(sizeof(*glock));
+ pdu_unmarshal(pdu, offset, "dbqqds", &fid, &glock->type,
+ &glock->start, &glock->length, &glock->proc_id,
+ &glock->client_id);
- vs->fidp = lookup_fid(s, fid);
- if (vs->fidp == NULL) {
+ fidp = lookup_fid(s, fid);
+ if (fidp == NULL) {
err = -ENOENT;
goto out;
}
-
- err = v9fs_do_fstat(s, vs->fidp->fs.fd, &vs->stbuf);
+ err = v9fs_co_fstat(s, fidp->fs.fd, &stbuf);
if (err < 0) {
- err = -errno;
goto out;
}
- vs->glock->type = F_UNLCK;
- vs->offset += pdu_marshal(vs->pdu, vs->offset, "bqqds", vs->glock->type,
- vs->glock->start, vs->glock->length, vs->glock->proc_id,
- &vs->glock->client_id);
+ glock->type = F_UNLCK;
+ offset += pdu_marshal(pdu, offset, "bqqds", glock->type,
+ glock->start, glock->length, glock->proc_id,
+ &glock->client_id);
+ err = offset;
out:
- complete_pdu(s, vs->pdu, err);
- g_free(vs->glock);
- g_free(vs);
+ complete_pdu(s, pdu, err);
+ g_free(glock);
}
static void v9fs_mkdir(void *opaque)