Message ID | 1452196584-17259-22-git-send-email-wei.liu2@citrix.com |
---|---|
State | New |
Headers | show |
Wei Liu <wei.liu2@citrix.com> writes: > The new function resides in virtio specific file. > > Signed-off-by: Wei Liu <wei.liu2@citrix.com> > --- > v2: new, part of original "9pfs: break out generic code from > virtio-9p.{c,h}" > --- > hw/9pfs/virtio-9p-device.c | 11 +++++++++++ > hw/9pfs/virtio-9p.c | 8 +------- > hw/9pfs/virtio-9p.h | 2 ++ > 3 files changed, 14 insertions(+), 7 deletions(-) > > diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c > index 5cad654..cfad13a 100644 > --- a/hw/9pfs/virtio-9p-device.c > +++ b/hw/9pfs/virtio-9p-device.c > @@ -20,6 +20,17 @@ > #include "coth.h" > #include "hw/virtio/virtio-access.h" > > +void virtio_9p_push_and_notify(V9fsPDU *pdu) > +{ > + V9fsState *s = pdu->s; > + > + /* push onto queue and notify */ > + virtqueue_push(s->vq, &pdu->elem, pdu->size); > + > + /* FIXME: we should batch these completions */ > + virtio_notify(VIRTIO_DEVICE(s), s->vq); > +} > + > static uint64_t virtio_9p_get_features(VirtIODevice *vdev, uint64_t features, > Error **errp) > { > diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c > index 3c39247..0ba2312 100644 > --- a/hw/9pfs/virtio-9p.c > +++ b/hw/9pfs/virtio-9p.c > @@ -65,13 +65,7 @@ ssize_t pdu_unmarshal(V9fsPDU *pdu, size_t offset, const char *fmt, ...) > > static void pdu_push_and_notify(V9fsPDU *pdu) > { > - V9fsState *s = pdu->s; > - > - /* push onto queue and notify */ > - virtqueue_push(s->vq, &pdu->elem, pdu->size); > - > - /* FIXME: we should batch these completions */ > - virtio_notify(VIRTIO_DEVICE(s), s->vq); > + virtio_9p_push_and_notify(pdu); > } > > static int omode_to_uflags(int8_t mode) > diff --git a/hw/9pfs/virtio-9p.h b/hw/9pfs/virtio-9p.h > index b4d344a..a1ac398 100644 > --- a/hw/9pfs/virtio-9p.h > +++ b/hw/9pfs/virtio-9p.h > @@ -6,6 +6,8 @@ > #include "9p.h" > > extern void handle_9p_output(VirtIODevice *vdev, VirtQueue *vq); > +extern void virtio_9p_push_and_notify(V9fsPDU *pdu); > + > ssize_t virtio_pdu_vmarshal(V9fsPDU *pdu, size_t offset, > const char *fmt, va_list ap); > ssize_t virtio_pdu_vunmarshal(V9fsPDU *pdu, size_t offset, > -- > 2.1.4 How is this different from pdu_push_notify added by [PATCH 18/27] -aneesh
On Fri, Jan 08, 2016 at 03:27:49PM +0530, Aneesh Kumar K.V wrote: [...] > > How is this different from pdu_push_notify added by [PATCH 18/27] > #18 is encapsulating functionality into pdu_* function family. This patch is encapsulating virtio specific code into virtio specific function. The two patches reflect the process of code refactoring. There is no functional change. This patch just moves the code to virito specific file and gives it a proper name. Then the virtio_ function is called from pdu_ function. Wei. > -aneesh > >
diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c index 5cad654..cfad13a 100644 --- a/hw/9pfs/virtio-9p-device.c +++ b/hw/9pfs/virtio-9p-device.c @@ -20,6 +20,17 @@ #include "coth.h" #include "hw/virtio/virtio-access.h" +void virtio_9p_push_and_notify(V9fsPDU *pdu) +{ + V9fsState *s = pdu->s; + + /* push onto queue and notify */ + virtqueue_push(s->vq, &pdu->elem, pdu->size); + + /* FIXME: we should batch these completions */ + virtio_notify(VIRTIO_DEVICE(s), s->vq); +} + static uint64_t virtio_9p_get_features(VirtIODevice *vdev, uint64_t features, Error **errp) { diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c index 3c39247..0ba2312 100644 --- a/hw/9pfs/virtio-9p.c +++ b/hw/9pfs/virtio-9p.c @@ -65,13 +65,7 @@ ssize_t pdu_unmarshal(V9fsPDU *pdu, size_t offset, const char *fmt, ...) static void pdu_push_and_notify(V9fsPDU *pdu) { - V9fsState *s = pdu->s; - - /* push onto queue and notify */ - virtqueue_push(s->vq, &pdu->elem, pdu->size); - - /* FIXME: we should batch these completions */ - virtio_notify(VIRTIO_DEVICE(s), s->vq); + virtio_9p_push_and_notify(pdu); } static int omode_to_uflags(int8_t mode) diff --git a/hw/9pfs/virtio-9p.h b/hw/9pfs/virtio-9p.h index b4d344a..a1ac398 100644 --- a/hw/9pfs/virtio-9p.h +++ b/hw/9pfs/virtio-9p.h @@ -6,6 +6,8 @@ #include "9p.h" extern void handle_9p_output(VirtIODevice *vdev, VirtQueue *vq); +extern void virtio_9p_push_and_notify(V9fsPDU *pdu); + ssize_t virtio_pdu_vmarshal(V9fsPDU *pdu, size_t offset, const char *fmt, va_list ap); ssize_t virtio_pdu_vunmarshal(V9fsPDU *pdu, size_t offset,
The new function resides in virtio specific file. Signed-off-by: Wei Liu <wei.liu2@citrix.com> --- v2: new, part of original "9pfs: break out generic code from virtio-9p.{c,h}" --- hw/9pfs/virtio-9p-device.c | 11 +++++++++++ hw/9pfs/virtio-9p.c | 8 +------- hw/9pfs/virtio-9p.h | 2 ++ 3 files changed, 14 insertions(+), 7 deletions(-)