From patchwork Fri Apr 9 11:43:13 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [-V4,10/21] virtio-9p: Add P9_TATTACH support. Date: Fri, 09 Apr 2010 01:43:13 -0000 From: "Aneesh Kumar K.V" X-Patchwork-Id: 49830 Message-Id: <1270813404-23004-11-git-send-email-aneesh.kumar@linux.vnet.ibm.com> To: qemu-devel@nongnu.org Cc: ericvh@gmail.com, aliguori@us.ibm.com, aneesh.kumar@linux.vnet.ibm.com From: Anthony Liguori Implement P9_TATTACH support. Signed-off-by: Anthony Liguori Signed-off-by: Aneesh Kumar K.V --- hw/virtio-9p.c | 33 +++++++++++++++++++++++++++++++-- 1 files changed, 31 insertions(+), 2 deletions(-) diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c index ccc45a3..4ab4f9a 100644 --- a/hw/virtio-9p.c +++ b/hw/virtio-9p.c @@ -863,9 +863,38 @@ static void v9fs_version(V9fsState *s, V9fsPDU *pdu) static void v9fs_attach(V9fsState *s, V9fsPDU *pdu) { - if (debug_9p_pdu) { - pprint_pdu(pdu); + int32_t fid, afid, n_uname; + V9fsString uname, aname; + V9fsFidState *fidp; + V9fsQID qid; + size_t offset = 7; + ssize_t err; + + pdu_unmarshal(pdu, offset, "ddssd", &fid, &afid, &uname, &aname, &n_uname); + + fidp = alloc_fid(s, fid); + if (fidp == NULL) { + err = -EINVAL; + goto out; } + + fidp->uid = n_uname; + + v9fs_string_sprintf(&fidp->path, "%s", "/"); + err = fid_to_qid(s, fidp, &qid); + if (err) { + err = -EINVAL; + free_fid(s, fid); + goto out; + } + + offset += pdu_marshal(pdu, offset, "Q", &qid); + + err = offset; +out: + complete_pdu(s, pdu, err); + v9fs_string_free(&uname); + v9fs_string_free(&aname); } static void v9fs_stat(V9fsState *s, V9fsPDU *pdu)