From patchwork Thu Apr 29 12:14:52 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aneesh Kumar K.V" X-Patchwork-Id: 51282 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4F137B7D17 for ; Thu, 29 Apr 2010 22:41:44 +1000 (EST) Received: from localhost ([127.0.0.1]:58952 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O7T3l-0004VH-GS for incoming@patchwork.ozlabs.org; Thu, 29 Apr 2010 08:41:41 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O7Seo-0005k5-Kl for qemu-devel@nongnu.org; Thu, 29 Apr 2010 08:15:54 -0400 Received: from [140.186.70.92] (port=45877 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O7Sei-0005hA-0U for qemu-devel@nongnu.org; Thu, 29 Apr 2010 08:15:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O7Sef-0006tG-B4 for qemu-devel@nongnu.org; Thu, 29 Apr 2010 08:15:47 -0400 Received: from e23smtp08.au.ibm.com ([202.81.31.141]:50255) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O7See-0006st-ON for qemu-devel@nongnu.org; Thu, 29 Apr 2010 08:15:45 -0400 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [202.81.31.246]) by e23smtp08.au.ibm.com (8.14.3/8.13.1) with ESMTP id o3TCFugc022307 for ; Thu, 29 Apr 2010 22:15:56 +1000 Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o3TC8vbN1396912 for ; Thu, 29 Apr 2010 22:08:57 +1000 Received: from d23av04.au.ibm.com (loopback [127.0.0.1]) by d23av04.au.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id o3TCFgUt020491 for ; Thu, 29 Apr 2010 22:15:43 +1000 Received: from skywalker.in.ibm.com ([9.124.222.113]) by d23av04.au.ibm.com (8.14.3/8.13.1/NCO v10.0 AVin) with ESMTP id o3TCF897018931; Thu, 29 Apr 2010 22:15:40 +1000 From: "Aneesh Kumar K.V" To: qemu-devel@nongnu.org Date: Thu, 29 Apr 2010 17:44:52 +0530 Message-Id: <1272543303-9830-11-git-send-email-aneesh.kumar@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.0.4.360.g11766c In-Reply-To: <1272543303-9830-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> References: <1272543303-9830-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Cc: ericvh@gmail.com, aliguori@us.ibm.com, jvrao@linux.vnet.ibm.com, aneesh.kumar@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH -V6 10/21] virtio-9p: Add P9_TATTACH support. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 c1c7723..48b5e83 100644 --- a/hw/virtio-9p.c +++ b/hw/virtio-9p.c @@ -861,9 +861,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)