From patchwork Sun Jun 19 10:24:04 2011 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: 894512 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5JAPAU9027998 for ; Sun, 19 Jun 2011 10:25:11 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753362Ab1FSKY6 (ORCPT ); Sun, 19 Jun 2011 06:24:58 -0400 Received: from e23smtp09.au.ibm.com ([202.81.31.142]:58107 "EHLO e23smtp09.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753342Ab1FSKY6 (ORCPT ); Sun, 19 Jun 2011 06:24:58 -0400 Received: from d23relay05.au.ibm.com (d23relay05.au.ibm.com [202.81.31.247]) by e23smtp09.au.ibm.com (8.14.4/8.13.1) with ESMTP id p5JAOpo6009969 for ; Sun, 19 Jun 2011 20:24:51 +1000 Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p5JANjps1114294 for ; Sun, 19 Jun 2011 20:23:45 +1000 Received: from d23av04.au.ibm.com (loopback [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p5JAOoIr005806 for ; Sun, 19 Jun 2011 20:24:51 +1000 Received: from skywalker.in.ibm.com ([9.124.209.131]) by d23av04.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p5JAOkSP005592; Sun, 19 Jun 2011 20:24:49 +1000 From: "Aneesh Kumar K.V" To: penberg@kernel.org, levinsasha928@gmail.com Cc: kvm@vger.kernel.org, "Aneesh Kumar K.V" Subject: [PATCH 2/2] tools/kvm/9p: Add error handling Date: Sun, 19 Jun 2011 15:54:04 +0530 Message-Id: <1308479044-14465-2-git-send-email-aneesh.kumar@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1308479044-14465-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> References: <1308479044-14465-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Sun, 19 Jun 2011 10:25:11 +0000 (UTC) return error via RERROR message Signed-off-by: Aneesh Kumar K.V --- tools/kvm/virtio/9p.c | 23 ++++++++++++++++------- 1 files changed, 16 insertions(+), 7 deletions(-) diff --git a/tools/kvm/virtio/9p.c b/tools/kvm/virtio/9p.c index 8067e8a..453b34b 100644 --- a/tools/kvm/virtio/9p.c +++ b/tools/kvm/virtio/9p.c @@ -324,13 +324,15 @@ static void virtio_p9_create(struct p9_dev *p9dev, } if (lstat(fid->abs_path, &st) < 0) - return; + goto err_out; st2qid(&st, &rcreate->qid); *outlen = VIRTIO_P9_HDR_LEN + sizeof(*rcreate); set_p9msg_hdr(inmsg, *outlen, P9_RCREATE, outmsg->tag); - + return; +err_out: + virtio_p9_error_reply(p9dev, pdu, errno, outlen); return; } @@ -360,7 +362,7 @@ static void virtio_p9_walk(struct p9_dev *p9dev, str->len, (char *)&str->str); if (lstat(rel_to_abs(p9dev, tmp, full_path), &st) < 0) - break; + goto err_out; st2qid(&st, &rwalk->wqids[i]); new_fid->is_dir = S_ISDIR(st.st_mode); @@ -377,7 +379,9 @@ static void virtio_p9_walk(struct p9_dev *p9dev, *outlen = VIRTIO_P9_HDR_LEN + sizeof(u16) + sizeof(struct p9_qid)*rwalk->nwqid; set_p9msg_hdr(inmsg, *outlen, P9_RWALK, outmsg->tag); - + return; +err_out: + virtio_p9_error_reply(p9dev, pdu, errno, outlen); return; } @@ -397,7 +401,7 @@ static void virtio_p9_attach(struct p9_dev *p9dev, p9dev->fids[i].fid = P9_NOFID; if (lstat(p9dev->root_dir, &st) < 0) - return; + goto err_out; st2qid(&st, &rattach->qid); @@ -408,7 +412,9 @@ static void virtio_p9_attach(struct p9_dev *p9dev, *outlen = VIRTIO_P9_HDR_LEN + sizeof(*rattach); set_p9msg_hdr(inmsg, *outlen, P9_RATTACH, outmsg->tag); - + return; +err_out: + virtio_p9_error_reply(p9dev, pdu, errno, outlen); return; } @@ -510,13 +516,16 @@ static void virtio_p9_stat(struct p9_dev *p9dev, struct p9_fid *fid = &p9dev->fids[tstat->fid]; if (lstat(fid->abs_path, &st) < 0) - return; + goto err_out; ret = virtio_p9_fill_stat(p9dev, fid->path, &st, rstat); *outlen = VIRTIO_P9_HDR_LEN + ret + sizeof(u16); set_p9msg_hdr(inmsg, *outlen, P9_RSTAT, outmsg->tag); return; +err_out: + virtio_p9_error_reply(p9dev, pdu, errno, outlen); + return; } static void virtio_p9_wstat(struct p9_dev *p9dev,