From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sasha Levin Subject: [PATCH 1/2] kvm tools: Add missing 9p remove handler Date: Mon, 7 Nov 2011 17:19:48 +0200 Message-ID: <1320679189-4123-1-git-send-email-levinsasha928@gmail.com> Cc: kvm@vger.kernel.org, mingo@elte.hu, asias.hejun@gmail.com, gorcunov@gmail.com, Sasha Levin To: penberg@cs.helsinki.fi Return-path: Received: from mail-ww0-f44.google.com ([74.125.82.44]:44491 "EHLO mail-ww0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751060Ab1KGPV5 (ORCPT ); Mon, 7 Nov 2011 10:21:57 -0500 Received: by wwi36 with SMTP id 36so6858001wwi.1 for ; Mon, 07 Nov 2011 07:21:56 -0800 (PST) Sender: kvm-owner@vger.kernel.org List-ID: Signed-off-by: Sasha Levin --- tools/kvm/virtio/9p.c | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-) diff --git a/tools/kvm/virtio/9p.c b/tools/kvm/virtio/9p.c index 1569bb2..08b1be7 100644 --- a/tools/kvm/virtio/9p.c +++ b/tools/kvm/virtio/9p.c @@ -677,6 +677,30 @@ err_out: return; } +static void virtio_p9_remove(struct p9_dev *p9dev, + struct p9_pdu *pdu, u32 *outlen) +{ + int ret; + u32 fid_val; + struct p9_fid *fid; + char full_path[PATH_MAX]; + + virtio_p9_pdu_readf(pdu, "d", &fid_val); + fid = &p9dev->fids[fid_val]; + + sprintf(full_path, "%s", fid->abs_path); + ret = remove(full_path); + if (ret < 0) + goto err_out; + *outlen = pdu->write_offset; + virtio_p9_set_reply_header(pdu, *outlen); + return; + +err_out: + virtio_p9_error_reply(p9dev, pdu, errno, outlen); + return; +} + static void virtio_p9_readlink(struct p9_dev *p9dev, struct p9_pdu *pdu, u32 *outlen) { @@ -1048,6 +1072,7 @@ static p9_handler *virtio_9p_dotl_handler [] = { [P9_TSYMLINK] = virtio_p9_symlink, [P9_TLCREATE] = virtio_p9_create, [P9_TWRITE] = virtio_p9_write, + [P9_TREMOVE] = virtio_p9_remove, }; static struct p9_pdu *virtio_p9_pdu_init(struct kvm *kvm, struct virt_queue *vq) -- 1.7.7.2