Re: [PATCH v2 03/11] vhost: Make vhost a separate module
On Sun, Jul 07, 2013 at 05:40:51PM +0300, Michael S. Tsirkin wrote: > On Sun, Jul 07, 2013 at 02:37:10PM +0300, Michael S. Tsirkin wrote: > > On Mon, May 06, 2013 at 08:10:03PM +0800, Asias He wrote: > > > On Mon, May 06, 2013 at 01:03:42PM +0300, Michael S. Tsirkin wrote: > > > > On Mon, May 06, 2013 at 04:38:21PM +0800, Asias He wrote: > > > > > Currently, vhost-net and vhost-scsi are sharing the vhost core code. > > > > > However, vhost-scsi shares the code by including the vhost.c file > > > > > directly. > > > > > > > > > > Making vhost a separate module makes it is easier to share code with > > > > > other vhost devices. > > > > > > > > > > Signed-off-by: Asias He > > > > > > > > Also this will break test.c, right? Let's fix it in the same > > > > commit too. > > > > > > I will fix it up and remove the useless 'return'. > > > > Don't see v3 anywhere? The fix for vhost/test.c was inflight, see '[PATCH v2] vhost-test: Make vhost/test.c work'. > I did these tweaks, you can see the result on the vhost > branch in my tree. Thanks! /me just come back from vacation. > > > > > --- > > > > > drivers/vhost/Kconfig | 8 > > > > > drivers/vhost/Makefile | 3 ++- > > > > > drivers/vhost/scsi.c | 1 - > > > > > drivers/vhost/vhost.c | 51 > > > > > +- > > > > > drivers/vhost/vhost.h | 2 ++ > > > > > 5 files changed, 62 insertions(+), 3 deletions(-) > > > > > > > > > > diff --git a/drivers/vhost/Kconfig b/drivers/vhost/Kconfig > > > > > index 8b9226d..017a1e8 100644 > > > > > --- a/drivers/vhost/Kconfig > > > > > +++ b/drivers/vhost/Kconfig > > > > > @@ -1,6 +1,7 @@ > > > > > config VHOST_NET > > > > > tristate "Host kernel accelerator for virtio net" > > > > > depends on NET && EVENTFD && (TUN || !TUN) && (MACVTAP || > > > > > !MACVTAP) > > > > > + select VHOST > > > > > select VHOST_RING > > > > > ---help--- > > > > > This kernel module can be loaded in host kernel to accelerate > > > > > @@ -13,6 +14,7 @@ config VHOST_NET > > > > > config VHOST_SCSI > > > > > tristate "VHOST_SCSI TCM fabric driver" > > > > > depends on TARGET_CORE && EVENTFD && m > > > > > + select VHOST > > > > > select VHOST_RING > > > > > default n > > > > > ---help--- > > > > > @@ -24,3 +26,9 @@ config VHOST_RING > > > > > ---help--- > > > > > This option is selected by any driver which needs to access > > > > > the host side of a virtio ring. > > > > > + > > > > > +config VHOST > > > > > + tristate > > > > > + ---help--- > > > > > + This option is selected by any driver which needs to access > > > > > + the core of vhost. > > > > > diff --git a/drivers/vhost/Makefile b/drivers/vhost/Makefile > > > > > index 654e9afb..e0441c3 100644 > > > > > --- a/drivers/vhost/Makefile > > > > > +++ b/drivers/vhost/Makefile > > > > > @@ -1,7 +1,8 @@ > > > > > obj-$(CONFIG_VHOST_NET) += vhost_net.o > > > > > -vhost_net-y := vhost.o net.o > > > > > +vhost_net-y := net.o > > > > > > > > > > obj-$(CONFIG_VHOST_SCSI) += vhost_scsi.o > > > > > vhost_scsi-y := scsi.o > > > > > > > > > > obj-$(CONFIG_VHOST_RING) += vringh.o > > > > > +obj-$(CONFIG_VHOST) += vhost.o > > > > > diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c > > > > > index 5179f7a..2dcb94a 100644 > > > > > --- a/drivers/vhost/scsi.c > > > > > +++ b/drivers/vhost/scsi.c > > > > > @@ -49,7 +49,6 @@ > > > > > #include > > > > > #include > > > > > > > > > > -#include "vhost.c" > > > > > #include "vhost.h" > > > > > > > > > > #define TCM_VHOST_VERSION "v0.1" > > > > > diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c > > > > > index de9441a..e406d5f 100644 > > > > > --- a/drivers/vhost/vhost.c > > > > > +++ b/drivers/vhost/vhost.c > > > > > @@ -25,6 +25,7 @@ > > > > > #include > > > > > #include > > > > > #include > > > > > +#include > > > > > > > > > > #include "vhost.h" > > > > > > > > > > @@ -66,6 +67,7 @@ void vhost_work_init(struct vhost_work *work, > > > > > vhost_work_fn_t fn) > > > > > work->flushing = 0; > > > > > work->queue_seq = work->done_seq = 0; > > > > > } > > > > > +EXPORT_SYMBOL_GPL(vhost_work_init); > > > > > > > > > > /* Init poll structure */ > > > > > void vhost_poll_init(struct vhost_poll *poll, vhost_work_fn_t fn, > > > > > @@ -79,6 +81,7 @@ void vhost_poll_init(struct vhost_poll *poll, > > > > > vhost_work_fn_t fn, > > > > > > > > > > vhost_work_init(&poll->work, fn); > > > > > } > > > > > +EXPORT_SYMBOL_GPL(vhost_poll_init); > > > > > > > > > > /* Start polling a file. We add ourselves to file's wait queue. The > > > > > caller must > > > > > * keep a reference to a file until after vhost_poll_stop is called. > > > > > */ > > > > > @@ -101,6 +104,7 @@ int vhost_poll_start(struct vhost_poll *poll, > > > > > struct file *file) > > > > > > > > > > return ret; > > > > > } > > > > > +EXPORT_SYMBOL_G
Re: [PATCH v2 03/11] vhost: Make vhost a separate module
On Sun, Jul 07, 2013 at 02:37:10PM +0300, Michael S. Tsirkin wrote: > On Mon, May 06, 2013 at 08:10:03PM +0800, Asias He wrote: > > On Mon, May 06, 2013 at 01:03:42PM +0300, Michael S. Tsirkin wrote: > > > On Mon, May 06, 2013 at 04:38:21PM +0800, Asias He wrote: > > > > Currently, vhost-net and vhost-scsi are sharing the vhost core code. > > > > However, vhost-scsi shares the code by including the vhost.c file > > > > directly. > > > > > > > > Making vhost a separate module makes it is easier to share code with > > > > other vhost devices. > > > > > > > > Signed-off-by: Asias He > > > > > > Also this will break test.c, right? Let's fix it in the same > > > commit too. > > > > I will fix it up and remove the useless 'return'. > > Don't see v3 anywhere? I did these tweaks, you can see the result on the vhost branch in my tree. > > > > --- > > > > drivers/vhost/Kconfig | 8 > > > > drivers/vhost/Makefile | 3 ++- > > > > drivers/vhost/scsi.c | 1 - > > > > drivers/vhost/vhost.c | 51 > > > > +- > > > > drivers/vhost/vhost.h | 2 ++ > > > > 5 files changed, 62 insertions(+), 3 deletions(-) > > > > > > > > diff --git a/drivers/vhost/Kconfig b/drivers/vhost/Kconfig > > > > index 8b9226d..017a1e8 100644 > > > > --- a/drivers/vhost/Kconfig > > > > +++ b/drivers/vhost/Kconfig > > > > @@ -1,6 +1,7 @@ > > > > config VHOST_NET > > > > tristate "Host kernel accelerator for virtio net" > > > > depends on NET && EVENTFD && (TUN || !TUN) && (MACVTAP || > > > > !MACVTAP) > > > > + select VHOST > > > > select VHOST_RING > > > > ---help--- > > > > This kernel module can be loaded in host kernel to accelerate > > > > @@ -13,6 +14,7 @@ config VHOST_NET > > > > config VHOST_SCSI > > > > tristate "VHOST_SCSI TCM fabric driver" > > > > depends on TARGET_CORE && EVENTFD && m > > > > + select VHOST > > > > select VHOST_RING > > > > default n > > > > ---help--- > > > > @@ -24,3 +26,9 @@ config VHOST_RING > > > > ---help--- > > > > This option is selected by any driver which needs to access > > > > the host side of a virtio ring. > > > > + > > > > +config VHOST > > > > + tristate > > > > + ---help--- > > > > + This option is selected by any driver which needs to access > > > > + the core of vhost. > > > > diff --git a/drivers/vhost/Makefile b/drivers/vhost/Makefile > > > > index 654e9afb..e0441c3 100644 > > > > --- a/drivers/vhost/Makefile > > > > +++ b/drivers/vhost/Makefile > > > > @@ -1,7 +1,8 @@ > > > > obj-$(CONFIG_VHOST_NET) += vhost_net.o > > > > -vhost_net-y := vhost.o net.o > > > > +vhost_net-y := net.o > > > > > > > > obj-$(CONFIG_VHOST_SCSI) += vhost_scsi.o > > > > vhost_scsi-y := scsi.o > > > > > > > > obj-$(CONFIG_VHOST_RING) += vringh.o > > > > +obj-$(CONFIG_VHOST)+= vhost.o > > > > diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c > > > > index 5179f7a..2dcb94a 100644 > > > > --- a/drivers/vhost/scsi.c > > > > +++ b/drivers/vhost/scsi.c > > > > @@ -49,7 +49,6 @@ > > > > #include > > > > #include > > > > > > > > -#include "vhost.c" > > > > #include "vhost.h" > > > > > > > > #define TCM_VHOST_VERSION "v0.1" > > > > diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c > > > > index de9441a..e406d5f 100644 > > > > --- a/drivers/vhost/vhost.c > > > > +++ b/drivers/vhost/vhost.c > > > > @@ -25,6 +25,7 @@ > > > > #include > > > > #include > > > > #include > > > > +#include > > > > > > > > #include "vhost.h" > > > > > > > > @@ -66,6 +67,7 @@ void vhost_work_init(struct vhost_work *work, > > > > vhost_work_fn_t fn) > > > > work->flushing = 0; > > > > work->queue_seq = work->done_seq = 0; > > > > } > > > > +EXPORT_SYMBOL_GPL(vhost_work_init); > > > > > > > > /* Init poll structure */ > > > > void vhost_poll_init(struct vhost_poll *poll, vhost_work_fn_t fn, > > > > @@ -79,6 +81,7 @@ void vhost_poll_init(struct vhost_poll *poll, > > > > vhost_work_fn_t fn, > > > > > > > > vhost_work_init(&poll->work, fn); > > > > } > > > > +EXPORT_SYMBOL_GPL(vhost_poll_init); > > > > > > > > /* Start polling a file. We add ourselves to file's wait queue. The > > > > caller must > > > > * keep a reference to a file until after vhost_poll_stop is called. */ > > > > @@ -101,6 +104,7 @@ int vhost_poll_start(struct vhost_poll *poll, > > > > struct file *file) > > > > > > > > return ret; > > > > } > > > > +EXPORT_SYMBOL_GPL(vhost_poll_start); > > > > > > > > /* Stop polling a file. After this function returns, it becomes safe > > > > to drop the > > > > * file reference. You must also flush afterwards. */ > > > > @@ -111,6 +115,7 @@ void vhost_poll_stop(struct vhost_poll *poll) > > > > poll->wqh = NULL; > > > > } > > > > } > > > > +EXPORT_SYMBOL_GPL(vhost_poll_stop); > > > > > > > > static bool
Re: [PATCH v2 03/11] vhost: Make vhost a separate module
On Mon, May 06, 2013 at 08:10:03PM +0800, Asias He wrote: > On Mon, May 06, 2013 at 01:03:42PM +0300, Michael S. Tsirkin wrote: > > On Mon, May 06, 2013 at 04:38:21PM +0800, Asias He wrote: > > > Currently, vhost-net and vhost-scsi are sharing the vhost core code. > > > However, vhost-scsi shares the code by including the vhost.c file > > > directly. > > > > > > Making vhost a separate module makes it is easier to share code with > > > other vhost devices. > > > > > > Signed-off-by: Asias He > > > > Also this will break test.c, right? Let's fix it in the same > > commit too. > > I will fix it up and remove the useless 'return'. Don't see v3 anywhere? > > > --- > > > drivers/vhost/Kconfig | 8 > > > drivers/vhost/Makefile | 3 ++- > > > drivers/vhost/scsi.c | 1 - > > > drivers/vhost/vhost.c | 51 > > > +- > > > drivers/vhost/vhost.h | 2 ++ > > > 5 files changed, 62 insertions(+), 3 deletions(-) > > > > > > diff --git a/drivers/vhost/Kconfig b/drivers/vhost/Kconfig > > > index 8b9226d..017a1e8 100644 > > > --- a/drivers/vhost/Kconfig > > > +++ b/drivers/vhost/Kconfig > > > @@ -1,6 +1,7 @@ > > > config VHOST_NET > > > tristate "Host kernel accelerator for virtio net" > > > depends on NET && EVENTFD && (TUN || !TUN) && (MACVTAP || !MACVTAP) > > > + select VHOST > > > select VHOST_RING > > > ---help--- > > > This kernel module can be loaded in host kernel to accelerate > > > @@ -13,6 +14,7 @@ config VHOST_NET > > > config VHOST_SCSI > > > tristate "VHOST_SCSI TCM fabric driver" > > > depends on TARGET_CORE && EVENTFD && m > > > + select VHOST > > > select VHOST_RING > > > default n > > > ---help--- > > > @@ -24,3 +26,9 @@ config VHOST_RING > > > ---help--- > > > This option is selected by any driver which needs to access > > > the host side of a virtio ring. > > > + > > > +config VHOST > > > + tristate > > > + ---help--- > > > + This option is selected by any driver which needs to access > > > + the core of vhost. > > > diff --git a/drivers/vhost/Makefile b/drivers/vhost/Makefile > > > index 654e9afb..e0441c3 100644 > > > --- a/drivers/vhost/Makefile > > > +++ b/drivers/vhost/Makefile > > > @@ -1,7 +1,8 @@ > > > obj-$(CONFIG_VHOST_NET) += vhost_net.o > > > -vhost_net-y := vhost.o net.o > > > +vhost_net-y := net.o > > > > > > obj-$(CONFIG_VHOST_SCSI) += vhost_scsi.o > > > vhost_scsi-y := scsi.o > > > > > > obj-$(CONFIG_VHOST_RING) += vringh.o > > > +obj-$(CONFIG_VHOST) += vhost.o > > > diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c > > > index 5179f7a..2dcb94a 100644 > > > --- a/drivers/vhost/scsi.c > > > +++ b/drivers/vhost/scsi.c > > > @@ -49,7 +49,6 @@ > > > #include > > > #include > > > > > > -#include "vhost.c" > > > #include "vhost.h" > > > > > > #define TCM_VHOST_VERSION "v0.1" > > > diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c > > > index de9441a..e406d5f 100644 > > > --- a/drivers/vhost/vhost.c > > > +++ b/drivers/vhost/vhost.c > > > @@ -25,6 +25,7 @@ > > > #include > > > #include > > > #include > > > +#include > > > > > > #include "vhost.h" > > > > > > @@ -66,6 +67,7 @@ void vhost_work_init(struct vhost_work *work, > > > vhost_work_fn_t fn) > > > work->flushing = 0; > > > work->queue_seq = work->done_seq = 0; > > > } > > > +EXPORT_SYMBOL_GPL(vhost_work_init); > > > > > > /* Init poll structure */ > > > void vhost_poll_init(struct vhost_poll *poll, vhost_work_fn_t fn, > > > @@ -79,6 +81,7 @@ void vhost_poll_init(struct vhost_poll *poll, > > > vhost_work_fn_t fn, > > > > > > vhost_work_init(&poll->work, fn); > > > } > > > +EXPORT_SYMBOL_GPL(vhost_poll_init); > > > > > > /* Start polling a file. We add ourselves to file's wait queue. The > > > caller must > > > * keep a reference to a file until after vhost_poll_stop is called. */ > > > @@ -101,6 +104,7 @@ int vhost_poll_start(struct vhost_poll *poll, struct > > > file *file) > > > > > > return ret; > > > } > > > +EXPORT_SYMBOL_GPL(vhost_poll_start); > > > > > > /* Stop polling a file. After this function returns, it becomes safe to > > > drop the > > > * file reference. You must also flush afterwards. */ > > > @@ -111,6 +115,7 @@ void vhost_poll_stop(struct vhost_poll *poll) > > > poll->wqh = NULL; > > > } > > > } > > > +EXPORT_SYMBOL_GPL(vhost_poll_stop); > > > > > > static bool vhost_work_seq_done(struct vhost_dev *dev, struct vhost_work > > > *work, > > > unsigned seq) > > > @@ -123,7 +128,7 @@ static bool vhost_work_seq_done(struct vhost_dev > > > *dev, struct vhost_work *work, > > > return left <= 0; > > > } > > > > > > -static void vhost_work_flush(struct vhost_dev *dev, struct vhost_work > > > *work) > > > +void vhost_work_flush(struct vhost_dev *dev, struct vhost_work *work) > > > { > > > unsigned seq; > > > int flushing; > > > @@ -138,6 +143,7 @@ static void vhost_work_flush(struct vho
Re: [PATCH v2 03/11] vhost: Make vhost a separate module
On Mon, May 06, 2013 at 01:03:42PM +0300, Michael S. Tsirkin wrote: > On Mon, May 06, 2013 at 04:38:21PM +0800, Asias He wrote: > > Currently, vhost-net and vhost-scsi are sharing the vhost core code. > > However, vhost-scsi shares the code by including the vhost.c file > > directly. > > > > Making vhost a separate module makes it is easier to share code with > > other vhost devices. > > > > Signed-off-by: Asias He > > Also this will break test.c, right? Let's fix it in the same > commit too. I will fix it up and remove the useless 'return'. > > --- > > drivers/vhost/Kconfig | 8 > > drivers/vhost/Makefile | 3 ++- > > drivers/vhost/scsi.c | 1 - > > drivers/vhost/vhost.c | 51 > > +- > > drivers/vhost/vhost.h | 2 ++ > > 5 files changed, 62 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/vhost/Kconfig b/drivers/vhost/Kconfig > > index 8b9226d..017a1e8 100644 > > --- a/drivers/vhost/Kconfig > > +++ b/drivers/vhost/Kconfig > > @@ -1,6 +1,7 @@ > > config VHOST_NET > > tristate "Host kernel accelerator for virtio net" > > depends on NET && EVENTFD && (TUN || !TUN) && (MACVTAP || !MACVTAP) > > + select VHOST > > select VHOST_RING > > ---help--- > > This kernel module can be loaded in host kernel to accelerate > > @@ -13,6 +14,7 @@ config VHOST_NET > > config VHOST_SCSI > > tristate "VHOST_SCSI TCM fabric driver" > > depends on TARGET_CORE && EVENTFD && m > > + select VHOST > > select VHOST_RING > > default n > > ---help--- > > @@ -24,3 +26,9 @@ config VHOST_RING > > ---help--- > > This option is selected by any driver which needs to access > > the host side of a virtio ring. > > + > > +config VHOST > > + tristate > > + ---help--- > > + This option is selected by any driver which needs to access > > + the core of vhost. > > diff --git a/drivers/vhost/Makefile b/drivers/vhost/Makefile > > index 654e9afb..e0441c3 100644 > > --- a/drivers/vhost/Makefile > > +++ b/drivers/vhost/Makefile > > @@ -1,7 +1,8 @@ > > obj-$(CONFIG_VHOST_NET) += vhost_net.o > > -vhost_net-y := vhost.o net.o > > +vhost_net-y := net.o > > > > obj-$(CONFIG_VHOST_SCSI) += vhost_scsi.o > > vhost_scsi-y := scsi.o > > > > obj-$(CONFIG_VHOST_RING) += vringh.o > > +obj-$(CONFIG_VHOST)+= vhost.o > > diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c > > index 5179f7a..2dcb94a 100644 > > --- a/drivers/vhost/scsi.c > > +++ b/drivers/vhost/scsi.c > > @@ -49,7 +49,6 @@ > > #include > > #include > > > > -#include "vhost.c" > > #include "vhost.h" > > > > #define TCM_VHOST_VERSION "v0.1" > > diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c > > index de9441a..e406d5f 100644 > > --- a/drivers/vhost/vhost.c > > +++ b/drivers/vhost/vhost.c > > @@ -25,6 +25,7 @@ > > #include > > #include > > #include > > +#include > > > > #include "vhost.h" > > > > @@ -66,6 +67,7 @@ void vhost_work_init(struct vhost_work *work, > > vhost_work_fn_t fn) > > work->flushing = 0; > > work->queue_seq = work->done_seq = 0; > > } > > +EXPORT_SYMBOL_GPL(vhost_work_init); > > > > /* Init poll structure */ > > void vhost_poll_init(struct vhost_poll *poll, vhost_work_fn_t fn, > > @@ -79,6 +81,7 @@ void vhost_poll_init(struct vhost_poll *poll, > > vhost_work_fn_t fn, > > > > vhost_work_init(&poll->work, fn); > > } > > +EXPORT_SYMBOL_GPL(vhost_poll_init); > > > > /* Start polling a file. We add ourselves to file's wait queue. The caller > > must > > * keep a reference to a file until after vhost_poll_stop is called. */ > > @@ -101,6 +104,7 @@ int vhost_poll_start(struct vhost_poll *poll, struct > > file *file) > > > > return ret; > > } > > +EXPORT_SYMBOL_GPL(vhost_poll_start); > > > > /* Stop polling a file. After this function returns, it becomes safe to > > drop the > > * file reference. You must also flush afterwards. */ > > @@ -111,6 +115,7 @@ void vhost_poll_stop(struct vhost_poll *poll) > > poll->wqh = NULL; > > } > > } > > +EXPORT_SYMBOL_GPL(vhost_poll_stop); > > > > static bool vhost_work_seq_done(struct vhost_dev *dev, struct vhost_work > > *work, > > unsigned seq) > > @@ -123,7 +128,7 @@ static bool vhost_work_seq_done(struct vhost_dev *dev, > > struct vhost_work *work, > > return left <= 0; > > } > > > > -static void vhost_work_flush(struct vhost_dev *dev, struct vhost_work > > *work) > > +void vhost_work_flush(struct vhost_dev *dev, struct vhost_work *work) > > { > > unsigned seq; > > int flushing; > > @@ -138,6 +143,7 @@ static void vhost_work_flush(struct vhost_dev *dev, > > struct vhost_work *work) > > spin_unlock_irq(&dev->work_lock); > > BUG_ON(flushing < 0); > > } > > +EXPORT_SYMBOL_GPL(vhost_work_flush); > > > > /* Flush any work that has been scheduled. When calling this, don't hold > > any > > * locks that are also used by the callback.
Re: [PATCH v2 03/11] vhost: Make vhost a separate module
On Mon, May 06, 2013 at 04:38:21PM +0800, Asias He wrote: > Currently, vhost-net and vhost-scsi are sharing the vhost core code. > However, vhost-scsi shares the code by including the vhost.c file > directly. > > Making vhost a separate module makes it is easier to share code with > other vhost devices. > > Signed-off-by: Asias He Also this will break test.c, right? Let's fix it in the same commit too. > --- > drivers/vhost/Kconfig | 8 > drivers/vhost/Makefile | 3 ++- > drivers/vhost/scsi.c | 1 - > drivers/vhost/vhost.c | 51 > +- > drivers/vhost/vhost.h | 2 ++ > 5 files changed, 62 insertions(+), 3 deletions(-) > > diff --git a/drivers/vhost/Kconfig b/drivers/vhost/Kconfig > index 8b9226d..017a1e8 100644 > --- a/drivers/vhost/Kconfig > +++ b/drivers/vhost/Kconfig > @@ -1,6 +1,7 @@ > config VHOST_NET > tristate "Host kernel accelerator for virtio net" > depends on NET && EVENTFD && (TUN || !TUN) && (MACVTAP || !MACVTAP) > + select VHOST > select VHOST_RING > ---help--- > This kernel module can be loaded in host kernel to accelerate > @@ -13,6 +14,7 @@ config VHOST_NET > config VHOST_SCSI > tristate "VHOST_SCSI TCM fabric driver" > depends on TARGET_CORE && EVENTFD && m > + select VHOST > select VHOST_RING > default n > ---help--- > @@ -24,3 +26,9 @@ config VHOST_RING > ---help--- > This option is selected by any driver which needs to access > the host side of a virtio ring. > + > +config VHOST > + tristate > + ---help--- > + This option is selected by any driver which needs to access > + the core of vhost. > diff --git a/drivers/vhost/Makefile b/drivers/vhost/Makefile > index 654e9afb..e0441c3 100644 > --- a/drivers/vhost/Makefile > +++ b/drivers/vhost/Makefile > @@ -1,7 +1,8 @@ > obj-$(CONFIG_VHOST_NET) += vhost_net.o > -vhost_net-y := vhost.o net.o > +vhost_net-y := net.o > > obj-$(CONFIG_VHOST_SCSI) += vhost_scsi.o > vhost_scsi-y := scsi.o > > obj-$(CONFIG_VHOST_RING) += vringh.o > +obj-$(CONFIG_VHOST) += vhost.o > diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c > index 5179f7a..2dcb94a 100644 > --- a/drivers/vhost/scsi.c > +++ b/drivers/vhost/scsi.c > @@ -49,7 +49,6 @@ > #include > #include > > -#include "vhost.c" > #include "vhost.h" > > #define TCM_VHOST_VERSION "v0.1" > diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c > index de9441a..e406d5f 100644 > --- a/drivers/vhost/vhost.c > +++ b/drivers/vhost/vhost.c > @@ -25,6 +25,7 @@ > #include > #include > #include > +#include > > #include "vhost.h" > > @@ -66,6 +67,7 @@ void vhost_work_init(struct vhost_work *work, > vhost_work_fn_t fn) > work->flushing = 0; > work->queue_seq = work->done_seq = 0; > } > +EXPORT_SYMBOL_GPL(vhost_work_init); > > /* Init poll structure */ > void vhost_poll_init(struct vhost_poll *poll, vhost_work_fn_t fn, > @@ -79,6 +81,7 @@ void vhost_poll_init(struct vhost_poll *poll, > vhost_work_fn_t fn, > > vhost_work_init(&poll->work, fn); > } > +EXPORT_SYMBOL_GPL(vhost_poll_init); > > /* Start polling a file. We add ourselves to file's wait queue. The caller > must > * keep a reference to a file until after vhost_poll_stop is called. */ > @@ -101,6 +104,7 @@ int vhost_poll_start(struct vhost_poll *poll, struct file > *file) > > return ret; > } > +EXPORT_SYMBOL_GPL(vhost_poll_start); > > /* Stop polling a file. After this function returns, it becomes safe to drop > the > * file reference. You must also flush afterwards. */ > @@ -111,6 +115,7 @@ void vhost_poll_stop(struct vhost_poll *poll) > poll->wqh = NULL; > } > } > +EXPORT_SYMBOL_GPL(vhost_poll_stop); > > static bool vhost_work_seq_done(struct vhost_dev *dev, struct vhost_work > *work, > unsigned seq) > @@ -123,7 +128,7 @@ static bool vhost_work_seq_done(struct vhost_dev *dev, > struct vhost_work *work, > return left <= 0; > } > > -static void vhost_work_flush(struct vhost_dev *dev, struct vhost_work *work) > +void vhost_work_flush(struct vhost_dev *dev, struct vhost_work *work) > { > unsigned seq; > int flushing; > @@ -138,6 +143,7 @@ static void vhost_work_flush(struct vhost_dev *dev, > struct vhost_work *work) > spin_unlock_irq(&dev->work_lock); > BUG_ON(flushing < 0); > } > +EXPORT_SYMBOL_GPL(vhost_work_flush); > > /* Flush any work that has been scheduled. When calling this, don't hold any > * locks that are also used by the callback. */ > @@ -145,6 +151,7 @@ void vhost_poll_flush(struct vhost_poll *poll) > { > vhost_work_flush(poll->dev, &poll->work); > } > +EXPORT_SYMBOL_GPL(vhost_poll_flush); > > void vhost_work_queue(struct vhost_dev *dev, struct vhost_work *work) > { > @@ -158,11 +165,13 @@ void vhost_work_queue(struct vhost_dev *dev, struct > vhost_work *work) > } >
Re: [PATCH v2 03/11] vhost: Make vhost a separate module
On Mon, May 06, 2013 at 04:38:21PM +0800, Asias He wrote: > Currently, vhost-net and vhost-scsi are sharing the vhost core code. > However, vhost-scsi shares the code by including the vhost.c file > directly. > > Making vhost a separate module makes it is easier to share code with > other vhost devices. > > Signed-off-by: Asias He > --- > drivers/vhost/Kconfig | 8 > drivers/vhost/Makefile | 3 ++- > drivers/vhost/scsi.c | 1 - > drivers/vhost/vhost.c | 51 > +- > drivers/vhost/vhost.h | 2 ++ > 5 files changed, 62 insertions(+), 3 deletions(-) > > diff --git a/drivers/vhost/Kconfig b/drivers/vhost/Kconfig > index 8b9226d..017a1e8 100644 > --- a/drivers/vhost/Kconfig > +++ b/drivers/vhost/Kconfig > @@ -1,6 +1,7 @@ > config VHOST_NET > tristate "Host kernel accelerator for virtio net" > depends on NET && EVENTFD && (TUN || !TUN) && (MACVTAP || !MACVTAP) > + select VHOST > select VHOST_RING > ---help--- > This kernel module can be loaded in host kernel to accelerate > @@ -13,6 +14,7 @@ config VHOST_NET > config VHOST_SCSI > tristate "VHOST_SCSI TCM fabric driver" > depends on TARGET_CORE && EVENTFD && m > + select VHOST > select VHOST_RING > default n > ---help--- > @@ -24,3 +26,9 @@ config VHOST_RING > ---help--- > This option is selected by any driver which needs to access > the host side of a virtio ring. > + > +config VHOST > + tristate > + ---help--- > + This option is selected by any driver which needs to access > + the core of vhost. > diff --git a/drivers/vhost/Makefile b/drivers/vhost/Makefile > index 654e9afb..e0441c3 100644 > --- a/drivers/vhost/Makefile > +++ b/drivers/vhost/Makefile > @@ -1,7 +1,8 @@ > obj-$(CONFIG_VHOST_NET) += vhost_net.o > -vhost_net-y := vhost.o net.o > +vhost_net-y := net.o > > obj-$(CONFIG_VHOST_SCSI) += vhost_scsi.o > vhost_scsi-y := scsi.o > > obj-$(CONFIG_VHOST_RING) += vringh.o > +obj-$(CONFIG_VHOST) += vhost.o > diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c > index 5179f7a..2dcb94a 100644 > --- a/drivers/vhost/scsi.c > +++ b/drivers/vhost/scsi.c > @@ -49,7 +49,6 @@ > #include > #include > > -#include "vhost.c" > #include "vhost.h" > > #define TCM_VHOST_VERSION "v0.1" > diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c > index de9441a..e406d5f 100644 > --- a/drivers/vhost/vhost.c > +++ b/drivers/vhost/vhost.c > @@ -25,6 +25,7 @@ > #include > #include > #include > +#include > > #include "vhost.h" > > @@ -66,6 +67,7 @@ void vhost_work_init(struct vhost_work *work, > vhost_work_fn_t fn) > work->flushing = 0; > work->queue_seq = work->done_seq = 0; > } > +EXPORT_SYMBOL_GPL(vhost_work_init); > > /* Init poll structure */ > void vhost_poll_init(struct vhost_poll *poll, vhost_work_fn_t fn, > @@ -79,6 +81,7 @@ void vhost_poll_init(struct vhost_poll *poll, > vhost_work_fn_t fn, > > vhost_work_init(&poll->work, fn); > } > +EXPORT_SYMBOL_GPL(vhost_poll_init); > > /* Start polling a file. We add ourselves to file's wait queue. The caller > must > * keep a reference to a file until after vhost_poll_stop is called. */ > @@ -101,6 +104,7 @@ int vhost_poll_start(struct vhost_poll *poll, struct file > *file) > > return ret; > } > +EXPORT_SYMBOL_GPL(vhost_poll_start); > > /* Stop polling a file. After this function returns, it becomes safe to drop > the > * file reference. You must also flush afterwards. */ > @@ -111,6 +115,7 @@ void vhost_poll_stop(struct vhost_poll *poll) > poll->wqh = NULL; > } > } > +EXPORT_SYMBOL_GPL(vhost_poll_stop); > > static bool vhost_work_seq_done(struct vhost_dev *dev, struct vhost_work > *work, > unsigned seq) > @@ -123,7 +128,7 @@ static bool vhost_work_seq_done(struct vhost_dev *dev, > struct vhost_work *work, > return left <= 0; > } > > -static void vhost_work_flush(struct vhost_dev *dev, struct vhost_work *work) > +void vhost_work_flush(struct vhost_dev *dev, struct vhost_work *work) > { > unsigned seq; > int flushing; > @@ -138,6 +143,7 @@ static void vhost_work_flush(struct vhost_dev *dev, > struct vhost_work *work) > spin_unlock_irq(&dev->work_lock); > BUG_ON(flushing < 0); > } > +EXPORT_SYMBOL_GPL(vhost_work_flush); > > /* Flush any work that has been scheduled. When calling this, don't hold any > * locks that are also used by the callback. */ > @@ -145,6 +151,7 @@ void vhost_poll_flush(struct vhost_poll *poll) > { > vhost_work_flush(poll->dev, &poll->work); > } > +EXPORT_SYMBOL_GPL(vhost_poll_flush); > > void vhost_work_queue(struct vhost_dev *dev, struct vhost_work *work) > { > @@ -158,11 +165,13 @@ void vhost_work_queue(struct vhost_dev *dev, struct > vhost_work *work) > } > spin_unlock_irqrestore(&dev->work_lock, flags); > } > +EXPORT_SYMBOL_
[PATCH v2 03/11] vhost: Make vhost a separate module
Currently, vhost-net and vhost-scsi are sharing the vhost core code. However, vhost-scsi shares the code by including the vhost.c file directly. Making vhost a separate module makes it is easier to share code with other vhost devices. Signed-off-by: Asias He --- drivers/vhost/Kconfig | 8 drivers/vhost/Makefile | 3 ++- drivers/vhost/scsi.c | 1 - drivers/vhost/vhost.c | 51 +- drivers/vhost/vhost.h | 2 ++ 5 files changed, 62 insertions(+), 3 deletions(-) diff --git a/drivers/vhost/Kconfig b/drivers/vhost/Kconfig index 8b9226d..017a1e8 100644 --- a/drivers/vhost/Kconfig +++ b/drivers/vhost/Kconfig @@ -1,6 +1,7 @@ config VHOST_NET tristate "Host kernel accelerator for virtio net" depends on NET && EVENTFD && (TUN || !TUN) && (MACVTAP || !MACVTAP) + select VHOST select VHOST_RING ---help--- This kernel module can be loaded in host kernel to accelerate @@ -13,6 +14,7 @@ config VHOST_NET config VHOST_SCSI tristate "VHOST_SCSI TCM fabric driver" depends on TARGET_CORE && EVENTFD && m + select VHOST select VHOST_RING default n ---help--- @@ -24,3 +26,9 @@ config VHOST_RING ---help--- This option is selected by any driver which needs to access the host side of a virtio ring. + +config VHOST + tristate + ---help--- + This option is selected by any driver which needs to access + the core of vhost. diff --git a/drivers/vhost/Makefile b/drivers/vhost/Makefile index 654e9afb..e0441c3 100644 --- a/drivers/vhost/Makefile +++ b/drivers/vhost/Makefile @@ -1,7 +1,8 @@ obj-$(CONFIG_VHOST_NET) += vhost_net.o -vhost_net-y := vhost.o net.o +vhost_net-y := net.o obj-$(CONFIG_VHOST_SCSI) += vhost_scsi.o vhost_scsi-y := scsi.o obj-$(CONFIG_VHOST_RING) += vringh.o +obj-$(CONFIG_VHOST)+= vhost.o diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c index 5179f7a..2dcb94a 100644 --- a/drivers/vhost/scsi.c +++ b/drivers/vhost/scsi.c @@ -49,7 +49,6 @@ #include #include -#include "vhost.c" #include "vhost.h" #define TCM_VHOST_VERSION "v0.1" diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index de9441a..e406d5f 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "vhost.h" @@ -66,6 +67,7 @@ void vhost_work_init(struct vhost_work *work, vhost_work_fn_t fn) work->flushing = 0; work->queue_seq = work->done_seq = 0; } +EXPORT_SYMBOL_GPL(vhost_work_init); /* Init poll structure */ void vhost_poll_init(struct vhost_poll *poll, vhost_work_fn_t fn, @@ -79,6 +81,7 @@ void vhost_poll_init(struct vhost_poll *poll, vhost_work_fn_t fn, vhost_work_init(&poll->work, fn); } +EXPORT_SYMBOL_GPL(vhost_poll_init); /* Start polling a file. We add ourselves to file's wait queue. The caller must * keep a reference to a file until after vhost_poll_stop is called. */ @@ -101,6 +104,7 @@ int vhost_poll_start(struct vhost_poll *poll, struct file *file) return ret; } +EXPORT_SYMBOL_GPL(vhost_poll_start); /* Stop polling a file. After this function returns, it becomes safe to drop the * file reference. You must also flush afterwards. */ @@ -111,6 +115,7 @@ void vhost_poll_stop(struct vhost_poll *poll) poll->wqh = NULL; } } +EXPORT_SYMBOL_GPL(vhost_poll_stop); static bool vhost_work_seq_done(struct vhost_dev *dev, struct vhost_work *work, unsigned seq) @@ -123,7 +128,7 @@ static bool vhost_work_seq_done(struct vhost_dev *dev, struct vhost_work *work, return left <= 0; } -static void vhost_work_flush(struct vhost_dev *dev, struct vhost_work *work) +void vhost_work_flush(struct vhost_dev *dev, struct vhost_work *work) { unsigned seq; int flushing; @@ -138,6 +143,7 @@ static void vhost_work_flush(struct vhost_dev *dev, struct vhost_work *work) spin_unlock_irq(&dev->work_lock); BUG_ON(flushing < 0); } +EXPORT_SYMBOL_GPL(vhost_work_flush); /* Flush any work that has been scheduled. When calling this, don't hold any * locks that are also used by the callback. */ @@ -145,6 +151,7 @@ void vhost_poll_flush(struct vhost_poll *poll) { vhost_work_flush(poll->dev, &poll->work); } +EXPORT_SYMBOL_GPL(vhost_poll_flush); void vhost_work_queue(struct vhost_dev *dev, struct vhost_work *work) { @@ -158,11 +165,13 @@ void vhost_work_queue(struct vhost_dev *dev, struct vhost_work *work) } spin_unlock_irqrestore(&dev->work_lock, flags); } +EXPORT_SYMBOL_GPL(vhost_work_queue); void vhost_poll_queue(struct vhost_poll *poll) { vhost_work_queue(poll->dev, &poll->work); } +EXPORT_SYMBOL_GPL(vhost_poll_queue); static void vhost_vq_reset(struct vhost_dev *dev, struct vhost_virtqueue *vq) @@ -310,6 +319,7 @@ long vho