9pfs: drop v9fs_register_transport()
PATCH 1/1 9pfs: drop v9fs_register_transport()
No good reasons to do this outside of v9fs_device_realize_common().
Signed-off-by Greg Kurz <[email protected]>
--- hw/9pfs/9p.c | 6 +++++- hw/9pfs/9p.h | 10 ++-------- hw/9pfs/virtio-9p-device.c | 8 ++------ hw/9pfs/xen-9p-backend.c | 3 +-- 4 files changed, 10 insertions(+), 17 deletions(-)
hw/9pfs/9p.c +5 -1
@@ -3502,7 +3502,8 @@ void pdu_submit(V9fsPDU *pdu, P9MsgHeader *hdr) }/* Returns 0 on success, 1 on failure. */ -int v9fs_device_realize_common (V9fsState *s,Error **errp) +int v9fs_device_realize_common (V9fsState *s,const V9fsTransport *t, +Error **errp) {int i, len;struct stat stat;
@@ -3510,6 +3511,9 @@ int v9fs_device_realize_common(V9fsState *s, Error **errp)V9fsPath path;int rc =1 ; +assert (!s->transport); + s->transport = t; +/* initialize pdu allocator */ QLIST_INIT (&s->free_list);QLIST_INIT (&s->active_list);
hw/9pfs/9p.h +2 -8
@@ -346,7 +346,8 @@ void v9fs_path_sprintf(V9fsPath *path, const char *fmt, ...);void v9fs_path_copy (V9fsPath *lhs,V9fsPath *rhs);int v9fs_name_to_path (V9fsState *s,V9fsPath *dirpath,const char *name,V9fsPath *path); -int v9fs_device_realize_common (V9fsState *s,Error **errp); +int v9fs_device_realize_common (V9fsState *s,const V9fsTransport *t, +Error **errp);void v9fs_device_unrealize_common (V9fsState *s,Error **errp);V9fsPDU *pdu_alloc (V9fsState *s);
@@ -366,11 +367,4 @@ struct V9fsTransport { void (*pdu_complete)(V9fsPDU *pdu, bool discard); }; -static inline int v9fs_register_transport (V9fsState *s,const V9fsTransport *t) -{ -assert (!s->transport); - s->transport = t; -return 0 ; -} -#endif
hw/9pfs/virtio-9p-device.c +2 -6
@@ -201,17 +201,13 @@ static void virtio_9p_device_realize(DeviceState *dev, Error **errp)V9fsVirtioState *v =VIRTIO_9P (dev);V9fsState *s = &v->state; -if (v9fs_device_realize_common (s, errp)) { - goto out; +if (v9fs_device_realize_common (s, &virtio_9p_transport, errp)) { +return ; } v->config_size =sizeof (struct virtio_9p_config ) +strlen (s->fsconf.tag);virtio_init (vdev,"virtio-9p" ,VIRTIO_ID_9P , v->config_size); v->vq =virtio_add_queue (vdev,MAX_REQ , handle_9p_output); -v9fs_register_transport (s, &virtio_9p_transport); - -out: -return ; }static void virtio_9p_device_unrealize (DeviceState *dev,Error **errp)
hw/9pfs/xen-9p-backend.c +1 -2
@@ -448,7 +448,6 @@ static int xen_9pfs_connect(struct XenDevice *xendev) xen_9pdev->id = s->fsconf.fsdev_id =g_strdup_printf ("xen9p%d" , xendev->dev); xen_9pdev->tag = s->fsconf.tag =xenstore_read_fe_str (xendev,"tag" ); -v9fs_register_transport (s, &xen_9p_transport); fsdev =qemu_opts_create (qemu_find_opts ("fsdev" ), s->fsconf.tag,1 ,NULL );
@@ -457,7 +456,7 @@ static int xen_9pfs_connect(struct XenDevice *xendev)qemu_opt_set (fsdev,"security_model" , xen_9pdev->security_model,NULL );qemu_opts_set_id (fsdev, s->fsconf.fsdev_id);qemu_fsdev_add (fsdev); -v9fs_device_realize_common (s,NULL ); +v9fs_device_realize_common (s, &xen_9p_transport,NULL );return 0 ;
Stefano, can you ack/nack this one ?
Quoted 106 lines · On Wed, 20 Dec 2017 20:42:54 +0100 Greg Kurz <[email protected]> wrote:
No good reasons to do this outside of
v9fs_device_realize_common().Signed-off-by Greg Kurz <[email protected]>--- hw/9pfs/9p.c | 6 +++++- hw/9pfs/9p.h | 10 ++-------- hw/9pfs/virtio-9p-device.c | 8 ++------ hw/9pfs/xen-9p-backend.c | 3 +-- 4 files changed, 10 insertions(+), 17 deletions(-)hw/9pfs/9p.c +5
-1@@ -3502,7 +3502,8 @@ void pdu_submit(V9fsPDU *pdu, P9MsgHeader *hdr) }/* Returns 0 on success, 1 on failure. */ -int v9fs_device_realize_common (V9fsState *s,Error **errp) +int v9fs_device_realize_common (V9fsState *s,const V9fsTransport *t, +Error **errp) {int i, len;struct stat stat;@@ -3510,6 +3511,9 @@ int v9fs_device_realize_common(V9fsState *s, Error **errp)V9fsPath path;int rc =1 ; +assert (!s->transport); + s->transport = t; +/* initialize pdu allocator */ QLIST_INIT (&s->free_list);QLIST_INIT (&s->active_list);hw/9pfs/9p.h +2
-8@@ -346,7 +346,8 @@ void v9fs_path_sprintf(V9fsPath *path, const char *fmt, ...);void v9fs_path_copy (V9fsPath *lhs,V9fsPath *rhs);int v9fs_name_to_path (V9fsState *s,V9fsPath *dirpath,const char *name,V9fsPath *path); -int v9fs_device_realize_common (V9fsState *s,Error **errp); +int v9fs_device_realize_common (V9fsState *s,const V9fsTransport *t, +Error **errp);void v9fs_device_unrealize_common (V9fsState *s,Error **errp);V9fsPDU *pdu_alloc (V9fsState *s);@@ -366,11 +367,4 @@ struct V9fsTransport { void (*pdu_complete)(V9fsPDU *pdu, bool discard); }; -static inline int v9fs_register_transport (V9fsState *s,const V9fsTransport *t) -{ -assert (!s->transport); - s->transport = t; -return 0 ; -} -#endif hw/9pfs/virtio-9p-device.c +2
-6@@ -201,17 +201,13 @@ static void virtio_9p_device_realize(DeviceState *dev, Error **errp)V9fsVirtioState *v =VIRTIO_9P (dev);V9fsState *s = &v->state; -if (v9fs_device_realize_common (s, errp)) { - goto out; +if (v9fs_device_realize_common (s, &virtio_9p_transport, errp)) { +return ; } v->config_size =sizeof (struct virtio_9p_config ) +strlen (s->fsconf.tag);virtio_init (vdev,"virtio-9p" ,VIRTIO_ID_9P , v->config_size); v->vq =virtio_add_queue (vdev,MAX_REQ , handle_9p_output); -v9fs_register_transport (s, &virtio_9p_transport); - -out: -return ; }static void virtio_9p_device_unrealize (DeviceState *dev,Error **errp)hw/9pfs/xen-9p-backend.c +1
-2@@ -448,7 +448,6 @@ static int xen_9pfs_connect(struct XenDevice *xendev) xen_9pdev->id = s->fsconf.fsdev_id =g_strdup_printf ("xen9p%d" , xendev->dev); xen_9pdev->tag = s->fsconf.tag =xenstore_read_fe_str (xendev,"tag" ); -v9fs_register_transport (s, &xen_9p_transport); fsdev =qemu_opts_create (qemu_find_opts ("fsdev" ), s->fsconf.tag,1 ,NULL );@@ -457,7 +456,7 @@ static int xen_9pfs_connect(struct XenDevice *xendev)qemu_opt_set (fsdev,"security_model" , xen_9pdev->security_model,NULL );qemu_opts_set_id (fsdev, s->fsconf.fsdev_id);qemu_fsdev_add (fsdev); -v9fs_device_realize_common (s,NULL ); +v9fs_device_realize_common (s, &xen_9p_transport,NULL );return 0 ;
Stefano Stabellini
Reviewed-byQuoted 8 lines · Greg Kurz
Stefano, can you ack/nack this one ?
Quoted 3 lines · On Wed, 20 Dec 2017 20:42:54 +0100 Greg Kurz <[email protected]> wrote:
No good reasons to do this outside of
v9fs_device_realize_common().Signed-off-by Greg Kurz <[email protected]>
Reviewed-by Stefano Stabellini <[email protected]>
Quoted 105 lines
Quoted 103 lines
--- hw/9pfs/9p.c | 6 +++++- hw/9pfs/9p.h | 10 ++-------- hw/9pfs/virtio-9p-device.c | 8 ++------ hw/9pfs/xen-9p-backend.c | 3 +-- 4 files changed, 10 insertions(+), 17 deletions(-)hw/9pfs/9p.c +5
-1@@ -3502,7 +3502,8 @@ void pdu_submit(V9fsPDU *pdu, P9MsgHeader *hdr) }/* Returns 0 on success, 1 on failure. */ -int v9fs_device_realize_common (V9fsState *s,Error **errp) +int v9fs_device_realize_common (V9fsState *s,const V9fsTransport *t, +Error **errp) {int i, len;struct stat stat;@@ -3510,6 +3511,9 @@ int v9fs_device_realize_common(V9fsState *s, Error **errp)V9fsPath path;int rc =1 ; +assert (!s->transport); + s->transport = t; +/* initialize pdu allocator */ QLIST_INIT (&s->free_list);QLIST_INIT (&s->active_list);hw/9pfs/9p.h +2
-8@@ -346,7 +346,8 @@ void v9fs_path_sprintf(V9fsPath *path, const char *fmt, ...);void v9fs_path_copy (V9fsPath *lhs,V9fsPath *rhs);int v9fs_name_to_path (V9fsState *s,V9fsPath *dirpath,const char *name,V9fsPath *path); -int v9fs_device_realize_common (V9fsState *s,Error **errp); +int v9fs_device_realize_common (V9fsState *s,const V9fsTransport *t, +Error **errp);void v9fs_device_unrealize_common (V9fsState *s,Error **errp);V9fsPDU *pdu_alloc (V9fsState *s);@@ -366,11 +367,4 @@ struct V9fsTransport { void (*pdu_complete)(V9fsPDU *pdu, bool discard); }; -static inline int v9fs_register_transport (V9fsState *s,const V9fsTransport *t) -{ -assert (!s->transport); - s->transport = t; -return 0 ; -} -#endif hw/9pfs/virtio-9p-device.c +2
-6@@ -201,17 +201,13 @@ static void virtio_9p_device_realize(DeviceState *dev, Error **errp)V9fsVirtioState *v =VIRTIO_9P (dev);V9fsState *s = &v->state; -if (v9fs_device_realize_common (s, errp)) { - goto out; +if (v9fs_device_realize_common (s, &virtio_9p_transport, errp)) { +return ; } v->config_size =sizeof (struct virtio_9p_config ) +strlen (s->fsconf.tag);virtio_init (vdev,"virtio-9p" ,VIRTIO_ID_9P , v->config_size); v->vq =virtio_add_queue (vdev,MAX_REQ , handle_9p_output); -v9fs_register_transport (s, &virtio_9p_transport); - -out: -return ; }static void virtio_9p_device_unrealize (DeviceState *dev,Error **errp)hw/9pfs/xen-9p-backend.c +1
-2@@ -448,7 +448,6 @@ static int xen_9pfs_connect(struct XenDevice *xendev) xen_9pdev->id = s->fsconf.fsdev_id =g_strdup_printf ("xen9p%d" , xendev->dev); xen_9pdev->tag = s->fsconf.tag =xenstore_read_fe_str (xendev,"tag" ); -v9fs_register_transport (s, &xen_9p_transport); fsdev =qemu_opts_create (qemu_find_opts ("fsdev" ), s->fsconf.tag,1 ,NULL );@@ -457,7 +456,7 @@ static int xen_9pfs_connect(struct XenDevice *xendev)qemu_opt_set (fsdev,"security_model" , xen_9pdev->security_model,NULL );qemu_opts_set_id (fsdev, s->fsconf.fsdev_id);qemu_fsdev_add (fsdev); -v9fs_device_realize_common (s,NULL ); +v9fs_device_realize_common (s, &xen_9p_transport,NULL );return 0 ;