From patchwork Mon Jun 6 17:49:13 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: 99041 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A6FDFB6F7F for ; Tue, 7 Jun 2011 07:09:50 +1000 (EST) Received: from localhost ([::1]:59689 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QTh3S-0001TH-Dy for incoming@patchwork.ozlabs.org; Mon, 06 Jun 2011 17:09:46 -0400 Received: from eggs.gnu.org ([140.186.70.92]:56271) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QTdve-0000OJ-1B for qemu-devel@nongnu.org; Mon, 06 Jun 2011 13:49:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QTdva-0003iB-FP for qemu-devel@nongnu.org; Mon, 06 Jun 2011 13:49:29 -0400 Received: from e23smtp04.au.ibm.com ([202.81.31.146]:52479) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QTdvZ-0003i2-NG for qemu-devel@nongnu.org; Mon, 06 Jun 2011 13:49:26 -0400 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [202.81.31.246]) by e23smtp04.au.ibm.com (8.14.4/8.13.1) with ESMTP id p56HhLGu032181 for ; Tue, 7 Jun 2011 03:43:21 +1000 Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p56HmiEV1237144 for ; Tue, 7 Jun 2011 03:48:44 +1000 Received: from d23av02.au.ibm.com (loopback [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p56HnNF4010138 for ; Tue, 7 Jun 2011 03:49:23 +1000 Received: from skywalker.in.ibm.com ([9.79.216.200]) by d23av02.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p56HnHb3010047; Tue, 7 Jun 2011 03:49:22 +1000 From: "Aneesh Kumar K.V" To: qemu-devel@nongnu.org Date: Mon, 6 Jun 2011 23:19:13 +0530 Message-Id: <1307382555-3907-3-git-send-email-aneesh.kumar@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1307382555-3907-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> References: <1307382555-3907-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) X-Received-From: 202.81.31.146 Cc: aliguori@us.ibm.com, "Aneesh Kumar K.V" Subject: [Qemu-devel] [PATCH 3/5] hw/9pfs: Add init callback to fs driver X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This call back can be used to do fs driver specific initialization. Signed-off-by: Aneesh Kumar K.V --- fsdev/file-op-9p.h | 2 ++ hw/9pfs/virtio-9p-device.c | 7 ++++++- hw/9pfs/virtio-9p-local.c | 7 ++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/fsdev/file-op-9p.h b/fsdev/file-op-9p.h index 3bab550..bd82fac 100644 --- a/fsdev/file-op-9p.h +++ b/fsdev/file-op-9p.h @@ -19,6 +19,7 @@ #include #include #include + #define SM_LOCAL_MODE_BITS 0600 #define SM_LOCAL_DIR_MODE_BITS 0700 @@ -67,6 +68,7 @@ void cred_init(FsCred *); typedef struct FileOperations { + int (*init)(struct FsContext *); int (*lstat)(FsContext *, V9fsPath *, struct stat *); ssize_t (*readlink)(FsContext *, V9fsPath *, char *, size_t); int (*chmod)(FsContext *, V9fsPath *, FsCred *); diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c index 6c8b4bc..2243943 100644 --- a/hw/9pfs/virtio-9p-device.c +++ b/hw/9pfs/virtio-9p-device.c @@ -45,7 +45,7 @@ static void virtio_9p_get_config(VirtIODevice *vdev, uint8_t *config) } VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf) - { +{ V9fsState *s; int i, len; struct stat stat; @@ -139,6 +139,11 @@ VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf) s->fid_list = NULL; qemu_co_rwlock_init(&s->rename_lock); + if (s->ops->init(&s->ctx) < 0) { + fprintf(stderr, "Virtio-9p Failed to initialize fs-driver with id:%s" + " and export path:%s\n", conf->fsdev_id, s->ctx.fs_root); + exit(1); + } if (v9fs_init_worker_threads() < 0) { fprintf(stderr, "worker thread initialization failed\n"); exit(1); diff --git a/hw/9pfs/virtio-9p-local.c b/hw/9pfs/virtio-9p-local.c index 37be2d5..494ee75 100644 --- a/hw/9pfs/virtio-9p-local.c +++ b/hw/9pfs/virtio-9p-local.c @@ -21,7 +21,6 @@ #include #include - static int local_lstat(FsContext *fs_ctx, V9fsPath *fs_path, struct stat *stbuf) { int err; @@ -646,7 +645,13 @@ static int local_unlinkat(FsContext *ctx, V9fsPath *dir, return ret; } +static int local_init(FsContext *ctx) +{ + return 0; +} + FileOperations local_ops = { + .init = local_init, .lstat = local_lstat, .readlink = local_readlink, .close = local_close,