Message ID | 20210126074254.3225-3-lulu@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | vhost-vdpa: add support for configure interrupt | expand |
On 2021/1/26 下午3:42, Cindy Lu wrote: > While peer is vhost vdpa, setup the configure interrupt function > vhost_net_start and release the resource when vhost_net_stop > > Signed-off-by: Cindy Lu <lulu@redhat.com> > --- > hw/net/vhost_net.c | 19 ++++++++++++++++++- > 1 file changed, 18 insertions(+), 1 deletion(-) > > diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c > index 24d555e764..0660da474a 100644 > --- a/hw/net/vhost_net.c > +++ b/hw/net/vhost_net.c > @@ -345,6 +345,15 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs, > error_report("Error binding guest notifier: %d", -r); > goto err; > } > + if (ncs->peer && ncs->peer->info->type == NET_CLIENT_DRIVER_VHOST_VDPA) { > + if (k->set_config_notifiers) { > + r = k->set_config_notifiers(qbus->parent, true); > + if (r < 0) { > + error_report("Error binding config notifier: %d", -r); > + goto err; > + } > + } > + } > > for (i = 0; i < total_queues; i++) { > peer = qemu_get_peer(ncs, i); > @@ -391,7 +400,15 @@ void vhost_net_stop(VirtIODevice *dev, NetClientState *ncs, > for (i = 0; i < total_queues; i++) { > vhost_net_stop_one(get_vhost_net(ncs[i].peer), dev); > } > - > + if (ncs->peer && ncs->peer->info->type == NET_CLIENT_DRIVER_VHOST_VDPA) { > + if (k->set_config_notifiers) { It looks to me that checking k->set_config_notifier is sufficient here. Thanks > + r = k->set_config_notifiers(qbus->parent, false); > + if (r < 0) { > + error_report("Error unbinding config notifier: %d", -r); > + } > + assert(r >= 0); > + } > + } > r = k->set_guest_notifiers(qbus->parent, total_queues * 2, false); > if (r < 0) { > fprintf(stderr, "vhost guest notifier cleanup failed: %d\n", r);
On Wed, Jan 27, 2021 at 1:38 PM Jason Wang <jasowang@redhat.com> wrote: > > > On 2021/1/26 下午3:42, Cindy Lu wrote: > > While peer is vhost vdpa, setup the configure interrupt function > > vhost_net_start and release the resource when vhost_net_stop > > > > Signed-off-by: Cindy Lu <lulu@redhat.com> > > --- > > hw/net/vhost_net.c | 19 ++++++++++++++++++- > > 1 file changed, 18 insertions(+), 1 deletion(-) > > > > diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c > > index 24d555e764..0660da474a 100644 > > --- a/hw/net/vhost_net.c > > +++ b/hw/net/vhost_net.c > > @@ -345,6 +345,15 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs, > > error_report("Error binding guest notifier: %d", -r); > > goto err; > > } > > + if (ncs->peer && ncs->peer->info->type == NET_CLIENT_DRIVER_VHOST_VDPA) { > > + if (k->set_config_notifiers) { > > + r = k->set_config_notifiers(qbus->parent, true); > > + if (r < 0) { > > + error_report("Error binding config notifier: %d", -r); > > + goto err; > > + } > > + } > > + } > > > > for (i = 0; i < total_queues; i++) { > > peer = qemu_get_peer(ncs, i); > > @@ -391,7 +400,15 @@ void vhost_net_stop(VirtIODevice *dev, NetClientState *ncs, > > for (i = 0; i < total_queues; i++) { > > vhost_net_stop_one(get_vhost_net(ncs[i].peer), dev); > > } > > - > > + if (ncs->peer && ncs->peer->info->type == NET_CLIENT_DRIVER_VHOST_VDPA) { > > + if (k->set_config_notifiers) { > > > It looks to me that checking k->set_config_notifier is sufficient here. > > Thanks > > sure will fix this > > + r = k->set_config_notifiers(qbus->parent, false); > > + if (r < 0) { > > + error_report("Error unbinding config notifier: %d", -r); > > + } > > + assert(r >= 0); > > + } > > + } > > r = k->set_guest_notifiers(qbus->parent, total_queues * 2, false); > > if (r < 0) { > > fprintf(stderr, "vhost guest notifier cleanup failed: %d\n", r); >
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 24d555e764..0660da474a 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -345,6 +345,15 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs, error_report("Error binding guest notifier: %d", -r); goto err; } + if (ncs->peer && ncs->peer->info->type == NET_CLIENT_DRIVER_VHOST_VDPA) { + if (k->set_config_notifiers) { + r = k->set_config_notifiers(qbus->parent, true); + if (r < 0) { + error_report("Error binding config notifier: %d", -r); + goto err; + } + } + } for (i = 0; i < total_queues; i++) { peer = qemu_get_peer(ncs, i); @@ -391,7 +400,15 @@ void vhost_net_stop(VirtIODevice *dev, NetClientState *ncs, for (i = 0; i < total_queues; i++) { vhost_net_stop_one(get_vhost_net(ncs[i].peer), dev); } - + if (ncs->peer && ncs->peer->info->type == NET_CLIENT_DRIVER_VHOST_VDPA) { + if (k->set_config_notifiers) { + r = k->set_config_notifiers(qbus->parent, false); + if (r < 0) { + error_report("Error unbinding config notifier: %d", -r); + } + assert(r >= 0); + } + } r = k->set_guest_notifiers(qbus->parent, total_queues * 2, false); if (r < 0) { fprintf(stderr, "vhost guest notifier cleanup failed: %d\n", r);
While peer is vhost vdpa, setup the configure interrupt function vhost_net_start and release the resource when vhost_net_stop Signed-off-by: Cindy Lu <lulu@redhat.com> --- hw/net/vhost_net.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)