Message ID | 54278334564d9e9f8d2eb3ff884260ac90da44e5.1645079934.git.jag.raman@oracle.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | vfio-user server in QEMU | expand |
On Thu, Feb 17, 2022 at 02:49:05AM -0500, Jagannathan Raman wrote: > Adds handler to reset a remote device > > Signed-off-by: Elena Ufimtseva <elena.ufimtseva@oracle.com> > Signed-off-by: John G Johnson <john.g.johnson@oracle.com> > Signed-off-by: Jagannathan Raman <jag.raman@oracle.com> > --- > hw/remote/vfio-user-obj.c | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) > > diff --git a/hw/remote/vfio-user-obj.c b/hw/remote/vfio-user-obj.c > index 2304643003..55f1bf5e0f 100644 > --- a/hw/remote/vfio-user-obj.c > +++ b/hw/remote/vfio-user-obj.c > @@ -989,6 +989,19 @@ static bool vfu_object_migratable(VfuObject *o) > return dc->vmsd && !dc->vmsd->unmigratable; > } > > +static int vfu_object_device_reset(vfu_ctx_t *vfu_ctx, vfu_reset_type_t type) > +{ > + VfuObject *o = vfu_get_private(vfu_ctx); > + > + if (type == VFU_RESET_LOST_CONN) { > + return 0; > + } Why is a lost connection ignored? Should there be a QMP monitor event? > + > + qdev_reset_all(DEVICE(o->pci_dev)); > + > + return 0; > +} > + > /* > * TYPE_VFU_OBJECT depends on the availability of the 'socket' and 'device' > * properties. It also depends on devices instantiated in QEMU. These > @@ -1105,6 +1118,12 @@ static void vfu_object_init_ctx(VfuObject *o, Error **errp) > goto fail; > } > > + ret = vfu_setup_device_reset_cb(o->vfu_ctx, &vfu_object_device_reset); > + if (ret < 0) { > + error_setg(errp, "vfu: Failed to setup reset callback"); > + goto fail; > + } > + > if (!vfu_object_migratable(o)) { > goto realize_ctx; > } > -- > 2.20.1 >
> On Mar 7, 2022, at 6:36 AM, Stefan Hajnoczi <stefanha@redhat.com> wrote: > > On Thu, Feb 17, 2022 at 02:49:05AM -0500, Jagannathan Raman wrote: >> Adds handler to reset a remote device >> >> Signed-off-by: Elena Ufimtseva <elena.ufimtseva@oracle.com> >> Signed-off-by: John G Johnson <john.g.johnson@oracle.com> >> Signed-off-by: Jagannathan Raman <jag.raman@oracle.com> >> --- >> hw/remote/vfio-user-obj.c | 19 +++++++++++++++++++ >> 1 file changed, 19 insertions(+) >> >> diff --git a/hw/remote/vfio-user-obj.c b/hw/remote/vfio-user-obj.c >> index 2304643003..55f1bf5e0f 100644 >> --- a/hw/remote/vfio-user-obj.c >> +++ b/hw/remote/vfio-user-obj.c >> @@ -989,6 +989,19 @@ static bool vfu_object_migratable(VfuObject *o) >> return dc->vmsd && !dc->vmsd->unmigratable; >> } >> >> +static int vfu_object_device_reset(vfu_ctx_t *vfu_ctx, vfu_reset_type_t type) >> +{ >> + VfuObject *o = vfu_get_private(vfu_ctx); >> + >> + if (type == VFU_RESET_LOST_CONN) { >> + return 0; >> + } > > Why is a lost connection ignored? Should there be a QMP monitor event? We handle the lost connection case in vfu_object_ctx_run(), which is in PATCH 5 of this series. We are sending a QMP monitor event in this case. Thank you! -- Jag > >> + >> + qdev_reset_all(DEVICE(o->pci_dev)); >> + >> + return 0; >> +} >> + >> /* >> * TYPE_VFU_OBJECT depends on the availability of the 'socket' and 'device' >> * properties. It also depends on devices instantiated in QEMU. These >> @@ -1105,6 +1118,12 @@ static void vfu_object_init_ctx(VfuObject *o, Error **errp) >> goto fail; >> } >> >> + ret = vfu_setup_device_reset_cb(o->vfu_ctx, &vfu_object_device_reset); >> + if (ret < 0) { >> + error_setg(errp, "vfu: Failed to setup reset callback"); >> + goto fail; >> + } >> + >> if (!vfu_object_migratable(o)) { >> goto realize_ctx; >> } >> -- >> 2.20.1 >>
On Mon, Mar 07, 2022 at 03:37:51PM +0000, Jag Raman wrote: > > > > On Mar 7, 2022, at 6:36 AM, Stefan Hajnoczi <stefanha@redhat.com> wrote: > > > > On Thu, Feb 17, 2022 at 02:49:05AM -0500, Jagannathan Raman wrote: > >> Adds handler to reset a remote device > >> > >> Signed-off-by: Elena Ufimtseva <elena.ufimtseva@oracle.com> > >> Signed-off-by: John G Johnson <john.g.johnson@oracle.com> > >> Signed-off-by: Jagannathan Raman <jag.raman@oracle.com> > >> --- > >> hw/remote/vfio-user-obj.c | 19 +++++++++++++++++++ > >> 1 file changed, 19 insertions(+) > >> > >> diff --git a/hw/remote/vfio-user-obj.c b/hw/remote/vfio-user-obj.c > >> index 2304643003..55f1bf5e0f 100644 > >> --- a/hw/remote/vfio-user-obj.c > >> +++ b/hw/remote/vfio-user-obj.c > >> @@ -989,6 +989,19 @@ static bool vfu_object_migratable(VfuObject *o) > >> return dc->vmsd && !dc->vmsd->unmigratable; > >> } > >> > >> +static int vfu_object_device_reset(vfu_ctx_t *vfu_ctx, vfu_reset_type_t type) > >> +{ > >> + VfuObject *o = vfu_get_private(vfu_ctx); > >> + > >> + if (type == VFU_RESET_LOST_CONN) { > >> + return 0; > >> + } > > > > Why is a lost connection ignored? Should there be a QMP monitor event? > > We handle the lost connection case in vfu_object_ctx_run(), which is in > PATCH 5 of this series. We are sending a QMP monitor event in this case. Great, please add a comment here. Stefan
diff --git a/hw/remote/vfio-user-obj.c b/hw/remote/vfio-user-obj.c index 2304643003..55f1bf5e0f 100644 --- a/hw/remote/vfio-user-obj.c +++ b/hw/remote/vfio-user-obj.c @@ -989,6 +989,19 @@ static bool vfu_object_migratable(VfuObject *o) return dc->vmsd && !dc->vmsd->unmigratable; } +static int vfu_object_device_reset(vfu_ctx_t *vfu_ctx, vfu_reset_type_t type) +{ + VfuObject *o = vfu_get_private(vfu_ctx); + + if (type == VFU_RESET_LOST_CONN) { + return 0; + } + + qdev_reset_all(DEVICE(o->pci_dev)); + + return 0; +} + /* * TYPE_VFU_OBJECT depends on the availability of the 'socket' and 'device' * properties. It also depends on devices instantiated in QEMU. These @@ -1105,6 +1118,12 @@ static void vfu_object_init_ctx(VfuObject *o, Error **errp) goto fail; } + ret = vfu_setup_device_reset_cb(o->vfu_ctx, &vfu_object_device_reset); + if (ret < 0) { + error_setg(errp, "vfu: Failed to setup reset callback"); + goto fail; + } + if (!vfu_object_migratable(o)) { goto realize_ctx; }