On Fri, Feb 09, 2024 at 02:29:59PM -0800, Steve Sistare wrote: > Calling suspend or resume requires VIRTIO_CONFIG_S_DRIVER_OK, for all > vdpa devices. > > Suggested-by: Eugenio Perez Martin <epere...@redhat.com>" > Signed-off-by: Steve Sistare <steven.sist...@oracle.com>
I don't think failing suspend or resume makes sense though - e.g. practically failing suspend will just prevent sleeping I think - why should guest not having driver loaded prevent system suspend? there's also state such as features set which does need to be preserved. I think the thing to do is to skip invoking suspend/resume callback, and in fact checking suspend/resume altogether. > --- > drivers/vhost/vdpa.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c > index bc4a51e4638b..ce1882acfc3b 100644 > --- a/drivers/vhost/vdpa.c > +++ b/drivers/vhost/vdpa.c > @@ -598,6 +598,9 @@ static long vhost_vdpa_suspend(struct vhost_vdpa *v) > if (!ops->suspend) > return -EOPNOTSUPP; > > + if (!(ops->get_status(vdpa) & VIRTIO_CONFIG_S_DRIVER_OK)) > + return -EINVAL; > + > ret = ops->suspend(vdpa); > if (!ret) > v->suspended = true; > @@ -618,6 +621,9 @@ static long vhost_vdpa_resume(struct vhost_vdpa *v) > if (!ops->resume) > return -EOPNOTSUPP; > > + if (!(ops->get_status(vdpa) & VIRTIO_CONFIG_S_DRIVER_OK)) > + return -EINVAL; > + > ret = ops->resume(vdpa); > if (!ret) > v->suspended = false; > -- > 2.39.3