[PATCH 2/2] tools/kvm/9p: Add error handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



return error via RERROR message

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@xxxxxxxxxxxxxxxxxx>
---
 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,
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux