From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:51984) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RVwqp-00024M-VO for qemu-devel@nongnu.org; Wed, 30 Nov 2011 21:58:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RVwqp-0004NQ-1d for qemu-devel@nongnu.org; Wed, 30 Nov 2011 21:58:19 -0500 Received: from e23smtp04.au.ibm.com ([202.81.31.146]:54305) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RVwqo-0004NE-Gd for qemu-devel@nongnu.org; Wed, 30 Nov 2011 21:58:19 -0500 Received: from /spool/local by e23smtp04.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 1 Dec 2011 02:45:32 +1000 Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id pB12sRAj3166462 for ; Thu, 1 Dec 2011 13:54:29 +1100 Received: from d23av01.au.ibm.com (loopback [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id pB12vr9r022268 for ; Thu, 1 Dec 2011 13:57:54 +1100 From: "Aneesh Kumar K.V" Date: Thu, 1 Dec 2011 08:27:49 +0530 Message-Id: <1322708269-3689-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH -V2] hw/9pfs: Reset server state during TVERSION List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Deepak C Shetty , aliguori@us.ibm.com, "Aneesh Kumar K.V" From: Deepak C Shetty As per the 9p rfc, during TVERSION its necessary to clean all the active fids, so that we start the session from a clean state. Its also needed in scenarios where the guest is booting off 9p, and boot fails, and client restarts, without any knowledge of the past, it will issue a TVERSION again so this ensures that we always start from a clean state. Signed-off-by: Deepak C Shetty Signed-off-by: Aneesh Kumar K.V --- Changes from V1: Since we haven't yet decided on TDETACH opeation move TVERSION Change before. Reset during TVERSION is needed as per 9p hw/9pfs/virtio-9p.c | 26 ++++++++++++++++++++++++++ 1 files changed, 26 insertions(+), 0 deletions(-) diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c index 32b98dd..dd43209 100644 --- a/hw/9pfs/virtio-9p.c +++ b/hw/9pfs/virtio-9p.c @@ -523,6 +523,30 @@ static int v9fs_mark_fids_unreclaim(V9fsPDU *pdu, V9fsPath *path) return 0; } +static void virtfs_reset(V9fsPDU *pdu) +{ + V9fsState *s = pdu->s; + V9fsFidState *fidp = NULL; + + /* Free all fids */ + while (s->fid_list) { + fidp = s->fid_list; + s->fid_list = fidp->next; + + if (fidp->ref) { + fidp->clunked = 1; + } else { + free_fid(pdu, fidp); + } + } + if (fidp) { + /* One or more unclunked fids found... */ + error_report("9pfs:%s: One or more uncluncked fids " + "found during reset", __func__); + } + return; +} + #define P9_QID_TYPE_DIR 0x80 #define P9_QID_TYPE_SYMLINK 0x02 @@ -1196,6 +1220,8 @@ static void v9fs_version(void *opaque) pdu_unmarshal(pdu, offset, "ds", &s->msize, &version); trace_v9fs_version(pdu->tag, pdu->id, s->msize, version.data); + virtfs_reset(pdu); + if (!strcmp(version.data, "9P2000.u")) { s->proto_version = V9FS_PROTO_2000U; } else if (!strcmp(version.data, "9P2000.L")) { -- 1.7.5.4