* [Virtio-fs] [PULL 07/55] hw/virtio: move vm_running check to virtio_device_started [not found] <20221010172813.204597-1-mst@redhat.com> @ 2022-10-10 17:29 ` Michael S. Tsirkin 2022-10-14 7:30 ` [Virtio-fs] Regression save/restore of vsock: (was [PULL 07/55] hw/virtio: move vm_running check to virtio_device_started) Christian Borntraeger 2022-11-05 16:45 ` [Virtio-fs] [PULL 07/55] hw/virtio: move vm_running check to virtio_device_started Michael S. Tsirkin 2022-10-10 17:29 ` [Virtio-fs] [PULL 08/55] hw/virtio: move vhd->started check into helper and add FIXME Michael S. Tsirkin 1 sibling, 2 replies; 10+ messages in thread From: Michael S. Tsirkin @ 2022-10-10 17:29 UTC (permalink / raw) To: qemu-devel Cc: Peter Maydell, Alex Bennée, Dr. David Alan Gilbert, Stefan Hajnoczi, Mathieu Poirier, virtio-fs From: Alex Bennée <alex.bennee@linaro.org> All the boilerplate virtio code does the same thing (or should at least) of checking to see if the VM is running before attempting to start VirtIO. Push the logic up to the common function to avoid getting a copy and paste wrong. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20220802095010.3330793-11-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> --- include/hw/virtio/virtio.h | 5 +++++ hw/virtio/vhost-user-fs.c | 6 +----- hw/virtio/vhost-user-i2c.c | 6 +----- hw/virtio/vhost-user-rng.c | 6 +----- hw/virtio/vhost-user-vsock.c | 6 +----- hw/virtio/vhost-vsock.c | 6 +----- 6 files changed, 10 insertions(+), 25 deletions(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 9bb2485415..74e7ad5a92 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -100,6 +100,7 @@ struct VirtIODevice VirtQueue *vq; MemoryListener listener; uint16_t device_id; + /* @vm_running: current VM running state via virtio_vmstate_change() */ bool vm_running; bool broken; /* device in invalid state, needs reset */ bool use_disabled_flag; /* allow use of 'disable' flag when needed */ @@ -376,6 +377,10 @@ static inline bool virtio_device_started(VirtIODevice *vdev, uint8_t status) return vdev->started; } + if (!vdev->vm_running) { + return false; + } + return status & VIRTIO_CONFIG_S_DRIVER_OK; } diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c index e513e4fdda..d2bebba785 100644 --- a/hw/virtio/vhost-user-fs.c +++ b/hw/virtio/vhost-user-fs.c @@ -122,11 +122,7 @@ static void vuf_stop(VirtIODevice *vdev) static void vuf_set_status(VirtIODevice *vdev, uint8_t status) { VHostUserFS *fs = VHOST_USER_FS(vdev); - bool should_start = status & VIRTIO_CONFIG_S_DRIVER_OK; - - if (!vdev->vm_running) { - should_start = false; - } + bool should_start = virtio_device_started(vdev, status); if (fs->vhost_dev.started == should_start) { return; diff --git a/hw/virtio/vhost-user-i2c.c b/hw/virtio/vhost-user-i2c.c index 6020eee093..b930cf6d5e 100644 --- a/hw/virtio/vhost-user-i2c.c +++ b/hw/virtio/vhost-user-i2c.c @@ -93,11 +93,7 @@ static void vu_i2c_stop(VirtIODevice *vdev) static void vu_i2c_set_status(VirtIODevice *vdev, uint8_t status) { VHostUserI2C *i2c = VHOST_USER_I2C(vdev); - bool should_start = status & VIRTIO_CONFIG_S_DRIVER_OK; - - if (!vdev->vm_running) { - should_start = false; - } + bool should_start = virtio_device_started(vdev, status); if (i2c->vhost_dev.started == should_start) { return; diff --git a/hw/virtio/vhost-user-rng.c b/hw/virtio/vhost-user-rng.c index 3a7bf8e32d..a9c1c4bc79 100644 --- a/hw/virtio/vhost-user-rng.c +++ b/hw/virtio/vhost-user-rng.c @@ -90,11 +90,7 @@ static void vu_rng_stop(VirtIODevice *vdev) static void vu_rng_set_status(VirtIODevice *vdev, uint8_t status) { VHostUserRNG *rng = VHOST_USER_RNG(vdev); - bool should_start = status & VIRTIO_CONFIG_S_DRIVER_OK; - - if (!vdev->vm_running) { - should_start = false; - } + bool should_start = virtio_device_started(vdev, status); if (rng->vhost_dev.started == should_start) { return; diff --git a/hw/virtio/vhost-user-vsock.c b/hw/virtio/vhost-user-vsock.c index 0f8ff99f85..22c1616ebd 100644 --- a/hw/virtio/vhost-user-vsock.c +++ b/hw/virtio/vhost-user-vsock.c @@ -55,11 +55,7 @@ const VhostDevConfigOps vsock_ops = { static void vuv_set_status(VirtIODevice *vdev, uint8_t status) { VHostVSockCommon *vvc = VHOST_VSOCK_COMMON(vdev); - bool should_start = status & VIRTIO_CONFIG_S_DRIVER_OK; - - if (!vdev->vm_running) { - should_start = false; - } + bool should_start = virtio_device_started(vdev, status); if (vvc->vhost_dev.started == should_start) { return; diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c index 0338de892f..8031c164a5 100644 --- a/hw/virtio/vhost-vsock.c +++ b/hw/virtio/vhost-vsock.c @@ -70,13 +70,9 @@ static int vhost_vsock_set_running(VirtIODevice *vdev, int start) static void vhost_vsock_set_status(VirtIODevice *vdev, uint8_t status) { VHostVSockCommon *vvc = VHOST_VSOCK_COMMON(vdev); - bool should_start = status & VIRTIO_CONFIG_S_DRIVER_OK; + bool should_start = virtio_device_started(vdev, status); int ret; - if (!vdev->vm_running) { - should_start = false; - } - if (vvc->vhost_dev.started == should_start) { return; } -- MST ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Virtio-fs] Regression save/restore of vsock: (was [PULL 07/55] hw/virtio: move vm_running check to virtio_device_started) 2022-10-10 17:29 ` [Virtio-fs] [PULL 07/55] hw/virtio: move vm_running check to virtio_device_started Michael S. Tsirkin @ 2022-10-14 7:30 ` Christian Borntraeger 2022-10-14 8:31 ` Christian Borntraeger 2022-10-14 8:37 ` Alex Bennée 2022-11-05 16:45 ` [Virtio-fs] [PULL 07/55] hw/virtio: move vm_running check to virtio_device_started Michael S. Tsirkin 1 sibling, 2 replies; 10+ messages in thread From: Christian Borntraeger @ 2022-10-14 7:30 UTC (permalink / raw) To: Michael S. Tsirkin, qemu-devel Cc: Peter Maydell, Alex Bennée, Dr. David Alan Gilbert, Stefan Hajnoczi, Mathieu Poirier, virtio-fs Am 10.10.22 um 19:29 schrieb Michael S. Tsirkin: > From: Alex Bennée <alex.bennee@linaro.org> > > All the boilerplate virtio code does the same thing (or should at > least) of checking to see if the VM is running before attempting to > start VirtIO. Push the logic up to the common function to avoid > getting a copy and paste wrong. > > Signed-off-by: Alex Bennée <alex.bennee@linaro.org> > Message-Id: <20220802095010.3330793-11-alex.bennee@linaro.org> > Reviewed-by: Michael S. Tsirkin <mst@redhat.com> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com> This results in a regression for our s390x CI when doing save/restore of guests with vsock: #1 0x000003ff9a248580 raise (libc.so.6 + 0x48580) #2 0x000003ff9a22b5c0 abort (libc.so.6 + 0x2b5c0) #3 0x000003ff9a2409da __assert_fail_base (libc.so.6 + 0x409da) #4 0x000003ff9a240a4e __assert_fail (libc.so.6 + 0x40a4e) #5 0x000002aa2d69a066 vhost_vsock_common_pre_save (qemu-system-s390x + 0x39a066) #6 0x000002aa2d55570e vmstate_save_state_v (qemu-system-s390x + 0x25570e) #7 0x000002aa2d556218 vmstate_save_state (qemu-system-s390x + 0x256218) #8 0x000002aa2d570ba4 qemu_savevm_state_complete_precopy_non_iterable (qemu-system-s390x + 0x270ba4) #9 0x000002aa2d5710b6 qemu_savevm_state_complete_precopy (qemu-system-s390x + 0x2710b6) #10 0x000002aa2d564d0e migration_completion (qemu-system-s390x + 0x264d0e) #11 0x000002aa2d8db25c qemu_thread_start (qemu-system-s390x + 0x5db25c) #12 0x000003ff9a296248 start_thread (libc.so.6 + 0x96248) #13 0x000003ff9a31183e thread_start (libc.so.6 + 0x11183e) ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Virtio-fs] Regression save/restore of vsock: (was [PULL 07/55] hw/virtio: move vm_running check to virtio_device_started) 2022-10-14 7:30 ` [Virtio-fs] Regression save/restore of vsock: (was [PULL 07/55] hw/virtio: move vm_running check to virtio_device_started) Christian Borntraeger @ 2022-10-14 8:31 ` Christian Borntraeger 2022-10-14 11:07 ` Alex Bennée 2022-10-14 8:37 ` Alex Bennée 1 sibling, 1 reply; 10+ messages in thread From: Christian Borntraeger @ 2022-10-14 8:31 UTC (permalink / raw) To: Michael S. Tsirkin, qemu-devel Cc: Peter Maydell, Alex Bennée, Dr. David Alan Gilbert, Stefan Hajnoczi, Mathieu Poirier, virtio-fs Am 14.10.22 um 09:30 schrieb Christian Borntraeger: > Am 10.10.22 um 19:29 schrieb Michael S. Tsirkin: >> From: Alex Bennée <alex.bennee@linaro.org> >> >> All the boilerplate virtio code does the same thing (or should at >> least) of checking to see if the VM is running before attempting to >> start VirtIO. Push the logic up to the common function to avoid >> getting a copy and paste wrong. >> >> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> >> Message-Id: <20220802095010.3330793-11-alex.bennee@linaro.org> >> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> >> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> > > This results in a regression for our s390x CI when doing save/restore of guests with vsock: > > > #1 0x000003ff9a248580 raise (libc.so.6 + 0x48580) > #2 0x000003ff9a22b5c0 abort (libc.so.6 + 0x2b5c0) > #3 0x000003ff9a2409da __assert_fail_base (libc.so.6 + 0x409da) > #4 0x000003ff9a240a4e __assert_fail (libc.so.6 + 0x40a4e) > #5 0x000002aa2d69a066 vhost_vsock_common_pre_save (qemu-system-s390x + 0x39a066) > #6 0x000002aa2d55570e vmstate_save_state_v (qemu-system-s390x + 0x25570e) > #7 0x000002aa2d556218 vmstate_save_state (qemu-system-s390x + 0x256218) > #8 0x000002aa2d570ba4 qemu_savevm_state_complete_precopy_non_iterable (qemu-system-s390x + 0x270ba4) > #9 0x000002aa2d5710b6 qemu_savevm_state_complete_precopy (qemu-system-s390x + 0x2710b6) > #10 0x000002aa2d564d0e migration_completion (qemu-system-s390x + 0x264d0e) > #11 0x000002aa2d8db25c qemu_thread_start (qemu-system-s390x + 0x5db25c) > #12 0x000003ff9a296248 start_thread (libc.so.6 + 0x96248) > #13 0x000003ff9a31183e thread_start (libc.so.6 + 0x11183e) > Something like diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c index 7dc3c7393122..b4d056ae6f01 100644 --- a/hw/virtio/vhost-vsock.c +++ b/hw/virtio/vhost-vsock.c @@ -73,6 +73,10 @@ static void vhost_vsock_set_status(VirtIODevice *vdev, uint8_t status) bool should_start = virtio_device_started(vdev, status); int ret; + if (!vdev->vm_running) { + should_start = false; + } + if (vhost_dev_is_started(&vvc->vhost_dev) == should_start) { return; } helps. The problem seems to be that virtio_device_started does ignore vm_running when use_start is set. ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [Virtio-fs] Regression save/restore of vsock: (was [PULL 07/55] hw/virtio: move vm_running check to virtio_device_started) 2022-10-14 8:31 ` Christian Borntraeger @ 2022-10-14 11:07 ` Alex Bennée 2022-10-14 11:58 ` Christian Borntraeger 0 siblings, 1 reply; 10+ messages in thread From: Alex Bennée @ 2022-10-14 11:07 UTC (permalink / raw) To: Christian Borntraeger Cc: Michael S. Tsirkin, qemu-devel, Peter Maydell, Dr. David Alan Gilbert, Stefan Hajnoczi, Mathieu Poirier, virtio-fs Christian Borntraeger <borntraeger@linux.ibm.com> writes: > Am 14.10.22 um 09:30 schrieb Christian Borntraeger: >> Am 10.10.22 um 19:29 schrieb Michael S. Tsirkin: >>> From: Alex Bennée <alex.bennee@linaro.org> >>> >>> All the boilerplate virtio code does the same thing (or should at >>> least) of checking to see if the VM is running before attempting to >>> start VirtIO. Push the logic up to the common function to avoid >>> getting a copy and paste wrong. >>> >>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> >>> Message-Id: <20220802095010.3330793-11-alex.bennee@linaro.org> >>> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> >>> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> >> This results in a regression for our s390x CI when doing >> save/restore of guests with vsock: >> #1 0x000003ff9a248580 raise (libc.so.6 + 0x48580) >> #2 0x000003ff9a22b5c0 abort (libc.so.6 + 0x2b5c0) >> #3 0x000003ff9a2409da __assert_fail_base (libc.so.6 + 0x409da) >> #4 0x000003ff9a240a4e __assert_fail (libc.so.6 + 0x40a4e) >> #5 0x000002aa2d69a066 vhost_vsock_common_pre_save (qemu-system-s390x + 0x39a066) >> #6 0x000002aa2d55570e vmstate_save_state_v (qemu-system-s390x + 0x25570e) >> #7 0x000002aa2d556218 vmstate_save_state (qemu-system-s390x + 0x256218) >> #8 0x000002aa2d570ba4 >> qemu_savevm_state_complete_precopy_non_iterable (qemu-system-s390x + >> 0x270ba4) >> #9 0x000002aa2d5710b6 qemu_savevm_state_complete_precopy (qemu-system-s390x + 0x2710b6) >> #10 0x000002aa2d564d0e migration_completion (qemu-system-s390x + 0x264d0e) >> #11 0x000002aa2d8db25c qemu_thread_start (qemu-system-s390x + 0x5db25c) >> #12 0x000003ff9a296248 start_thread (libc.so.6 + 0x96248) >> #13 0x000003ff9a31183e thread_start (libc.so.6 + 0x11183e) >> > > > Something like > diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c > index 7dc3c7393122..b4d056ae6f01 100644 > --- a/hw/virtio/vhost-vsock.c > +++ b/hw/virtio/vhost-vsock.c > @@ -73,6 +73,10 @@ static void vhost_vsock_set_status(VirtIODevice *vdev, uint8_t status) > bool should_start = virtio_device_started(vdev, status); > int ret; > + if (!vdev->vm_running) { > + should_start = false; > + } > + > if (vhost_dev_is_started(&vvc->vhost_dev) == should_start) { > return; > } > > helps. > > The problem seems to be that virtio_device_started does ignore > vm_running when use_start is set. Wouldn't it make more sense to re-order the check there, something like: static inline bool virtio_device_started(VirtIODevice *vdev, uint8_t status) { if (!vdev->vm_running) { return false; } if (vdev->use_started) { return vdev->started; } return status & VIRTIO_CONFIG_S_DRIVER_OK; } Is the problem that vdev->started gets filled during the migration but because the VM isn't running yet we can never actually run? -- Alex Bennée ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Virtio-fs] Regression save/restore of vsock: (was [PULL 07/55] hw/virtio: move vm_running check to virtio_device_started) 2022-10-14 11:07 ` Alex Bennée @ 2022-10-14 11:58 ` Christian Borntraeger 0 siblings, 0 replies; 10+ messages in thread From: Christian Borntraeger @ 2022-10-14 11:58 UTC (permalink / raw) To: Alex Bennée Cc: Michael S. Tsirkin, qemu-devel, Peter Maydell, Dr. David Alan Gilbert, Stefan Hajnoczi, Mathieu Poirier, virtio-fs Am 14.10.22 um 13:07 schrieb Alex Bennée: > > Christian Borntraeger <borntraeger@linux.ibm.com> writes: > >> Am 14.10.22 um 09:30 schrieb Christian Borntraeger: >>> Am 10.10.22 um 19:29 schrieb Michael S. Tsirkin: >>>> From: Alex Bennée <alex.bennee@linaro.org> >>>> >>>> All the boilerplate virtio code does the same thing (or should at >>>> least) of checking to see if the VM is running before attempting to >>>> start VirtIO. Push the logic up to the common function to avoid >>>> getting a copy and paste wrong. >>>> >>>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> >>>> Message-Id: <20220802095010.3330793-11-alex.bennee@linaro.org> >>>> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> >>>> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> >>> This results in a regression for our s390x CI when doing >>> save/restore of guests with vsock: >>> #1 0x000003ff9a248580 raise (libc.so.6 + 0x48580) >>> #2 0x000003ff9a22b5c0 abort (libc.so.6 + 0x2b5c0) >>> #3 0x000003ff9a2409da __assert_fail_base (libc.so.6 + 0x409da) >>> #4 0x000003ff9a240a4e __assert_fail (libc.so.6 + 0x40a4e) >>> #5 0x000002aa2d69a066 vhost_vsock_common_pre_save (qemu-system-s390x + 0x39a066) >>> #6 0x000002aa2d55570e vmstate_save_state_v (qemu-system-s390x + 0x25570e) >>> #7 0x000002aa2d556218 vmstate_save_state (qemu-system-s390x + 0x256218) >>> #8 0x000002aa2d570ba4 >>> qemu_savevm_state_complete_precopy_non_iterable (qemu-system-s390x + >>> 0x270ba4) >>> #9 0x000002aa2d5710b6 qemu_savevm_state_complete_precopy (qemu-system-s390x + 0x2710b6) >>> #10 0x000002aa2d564d0e migration_completion (qemu-system-s390x + 0x264d0e) >>> #11 0x000002aa2d8db25c qemu_thread_start (qemu-system-s390x + 0x5db25c) >>> #12 0x000003ff9a296248 start_thread (libc.so.6 + 0x96248) >>> #13 0x000003ff9a31183e thread_start (libc.so.6 + 0x11183e) >>> >> >> >> Something like >> diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c >> index 7dc3c7393122..b4d056ae6f01 100644 >> --- a/hw/virtio/vhost-vsock.c >> +++ b/hw/virtio/vhost-vsock.c >> @@ -73,6 +73,10 @@ static void vhost_vsock_set_status(VirtIODevice *vdev, uint8_t status) >> bool should_start = virtio_device_started(vdev, status); >> int ret; >> + if (!vdev->vm_running) { >> + should_start = false; >> + } >> + >> if (vhost_dev_is_started(&vvc->vhost_dev) == should_start) { >> return; >> } >> >> helps. >> >> The problem seems to be that virtio_device_started does ignore >> vm_running when use_start is set. > > Wouldn't it make more sense to re-order the check there, something like: > > static inline bool virtio_device_started(VirtIODevice *vdev, uint8_t status) > { > if (!vdev->vm_running) { > return false; > } > > if (vdev->use_started) { > return vdev->started; > } > > return status & VIRTIO_CONFIG_S_DRIVER_OK; > } That does work as well. (and it restores the original ordering so that makes sense). > > Is the problem that vdev->started gets filled during the migration but > because the VM isn't running yet we can never actually run? I dont know. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Virtio-fs] Regression save/restore of vsock: (was [PULL 07/55] hw/virtio: move vm_running check to virtio_device_started) 2022-10-14 7:30 ` [Virtio-fs] Regression save/restore of vsock: (was [PULL 07/55] hw/virtio: move vm_running check to virtio_device_started) Christian Borntraeger 2022-10-14 8:31 ` Christian Borntraeger @ 2022-10-14 8:37 ` Alex Bennée 2022-10-14 8:44 ` Christian Borntraeger 1 sibling, 1 reply; 10+ messages in thread From: Alex Bennée @ 2022-10-14 8:37 UTC (permalink / raw) To: Christian Borntraeger Cc: Michael S. Tsirkin, qemu-devel, Peter Maydell, Dr. David Alan Gilbert, Stefan Hajnoczi, Mathieu Poirier, virtio-fs Christian Borntraeger <borntraeger@linux.ibm.com> writes: > Am 10.10.22 um 19:29 schrieb Michael S. Tsirkin: >> From: Alex Bennée <alex.bennee@linaro.org> >> All the boilerplate virtio code does the same thing (or should at >> least) of checking to see if the VM is running before attempting to >> start VirtIO. Push the logic up to the common function to avoid >> getting a copy and paste wrong. >> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> >> Message-Id: <20220802095010.3330793-11-alex.bennee@linaro.org> >> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> >> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> > > This results in a regression for our s390x CI when doing save/restore of guests with vsock: > > > #1 0x000003ff9a248580 raise (libc.so.6 + 0x48580) > #2 0x000003ff9a22b5c0 abort (libc.so.6 + 0x2b5c0) > #3 0x000003ff9a2409da __assert_fail_base (libc.so.6 + 0x409da) > #4 0x000003ff9a240a4e __assert_fail (libc.so.6 + 0x40a4e) > #5 0x000002aa2d69a066 vhost_vsock_common_pre_save (qemu-system-s390x + 0x39a066) > #6 0x000002aa2d55570e vmstate_save_state_v (qemu-system-s390x + 0x25570e) > #7 0x000002aa2d556218 vmstate_save_state (qemu-system-s390x + 0x256218) > #8 0x000002aa2d570ba4 > qemu_savevm_state_complete_precopy_non_iterable (qemu-system-s390x + > 0x270ba4) > #9 0x000002aa2d5710b6 qemu_savevm_state_complete_precopy (qemu-system-s390x + 0x2710b6) > #10 0x000002aa2d564d0e migration_completion (qemu-system-s390x + 0x264d0e) > #11 0x000002aa2d8db25c qemu_thread_start (qemu-system-s390x + 0x5db25c) > #12 0x000003ff9a296248 start_thread (libc.so.6 + 0x96248) > #13 0x000003ff9a31183e thread_start (libc.so.6 + 0x11183e) Which test does this break? Looking at the change the only thing I can think of is there is a subtle change in the order of checks because if the device is set as use_started we return the result regardless of vm or config state: if (vdev->use_started) { return vdev->started; } Could some printfs confirm that? -- Alex Bennée ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Virtio-fs] Regression save/restore of vsock: (was [PULL 07/55] hw/virtio: move vm_running check to virtio_device_started) 2022-10-14 8:37 ` Alex Bennée @ 2022-10-14 8:44 ` Christian Borntraeger 0 siblings, 0 replies; 10+ messages in thread From: Christian Borntraeger @ 2022-10-14 8:44 UTC (permalink / raw) To: Alex Bennée Cc: Michael S. Tsirkin, qemu-devel, Peter Maydell, Dr. David Alan Gilbert, Stefan Hajnoczi, Mathieu Poirier, virtio-fs Am 14.10.22 um 10:37 schrieb Alex Bennée: > > Christian Borntraeger <borntraeger@linux.ibm.com> writes: > >> Am 10.10.22 um 19:29 schrieb Michael S. Tsirkin: >>> From: Alex Bennée <alex.bennee@linaro.org> >>> All the boilerplate virtio code does the same thing (or should at >>> least) of checking to see if the VM is running before attempting to >>> start VirtIO. Push the logic up to the common function to avoid >>> getting a copy and paste wrong. >>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> >>> Message-Id: <20220802095010.3330793-11-alex.bennee@linaro.org> >>> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> >>> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> >> >> This results in a regression for our s390x CI when doing save/restore of guests with vsock: >> >> >> #1 0x000003ff9a248580 raise (libc.so.6 + 0x48580) >> #2 0x000003ff9a22b5c0 abort (libc.so.6 + 0x2b5c0) >> #3 0x000003ff9a2409da __assert_fail_base (libc.so.6 + 0x409da) >> #4 0x000003ff9a240a4e __assert_fail (libc.so.6 + 0x40a4e) >> #5 0x000002aa2d69a066 vhost_vsock_common_pre_save (qemu-system-s390x + 0x39a066) >> #6 0x000002aa2d55570e vmstate_save_state_v (qemu-system-s390x + 0x25570e) >> #7 0x000002aa2d556218 vmstate_save_state (qemu-system-s390x + 0x256218) >> #8 0x000002aa2d570ba4 >> qemu_savevm_state_complete_precopy_non_iterable (qemu-system-s390x + >> 0x270ba4) >> #9 0x000002aa2d5710b6 qemu_savevm_state_complete_precopy (qemu-system-s390x + 0x2710b6) >> #10 0x000002aa2d564d0e migration_completion (qemu-system-s390x + 0x264d0e) >> #11 0x000002aa2d8db25c qemu_thread_start (qemu-system-s390x + 0x5db25c) >> #12 0x000003ff9a296248 start_thread (libc.so.6 + 0x96248) >> #13 0x000003ff9a31183e thread_start (libc.so.6 + 0x11183e) > > Which test does this break? migrate to file and restore. > > Looking at the change the only thing I can think of is there is a subtle > change in the order of checks because if the device is set as > use_started we return the result regardless of vm or config state: > > if (vdev->use_started) { > return vdev->started; > } > > Could some printfs confirm that? Right. The problem is we now ignore the vm state and thus run into the assertion in vhost_vsock_common_pre_save. Removing the asserting then results in virtio errors, which really indicates that the device must not be started. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Virtio-fs] [PULL 07/55] hw/virtio: move vm_running check to virtio_device_started 2022-10-10 17:29 ` [Virtio-fs] [PULL 07/55] hw/virtio: move vm_running check to virtio_device_started Michael S. Tsirkin 2022-10-14 7:30 ` [Virtio-fs] Regression save/restore of vsock: (was [PULL 07/55] hw/virtio: move vm_running check to virtio_device_started) Christian Borntraeger @ 2022-11-05 16:45 ` Michael S. Tsirkin 2022-11-07 9:21 ` Alex Bennée 1 sibling, 1 reply; 10+ messages in thread From: Michael S. Tsirkin @ 2022-11-05 16:45 UTC (permalink / raw) To: qemu-devel Cc: Peter Maydell, Alex Bennée, Dr. David Alan Gilbert, Stefan Hajnoczi, Mathieu Poirier, virtio-fs, Viresh Kumar On Mon, Oct 10, 2022 at 01:29:10PM -0400, Michael S. Tsirkin wrote: > From: Alex Bennée <alex.bennee@linaro.org> > > All the boilerplate virtio code does the same thing (or should at > least) of checking to see if the VM is running before attempting to > start VirtIO. Push the logic up to the common function to avoid > getting a copy and paste wrong. > > Signed-off-by: Alex Bennée <alex.bennee@linaro.org> > Message-Id: <20220802095010.3330793-11-alex.bennee@linaro.org> > Reviewed-by: Michael S. Tsirkin <mst@redhat.com> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com> So, looking at the resulting code, I missed the fact that this function is also used in virtio core. So this patch does not do what it's saying it does (just refactor code). Instead it completely changes the meaning for virtio core. I thunk we should revert upstream, however, gpio has grown a dependency on this since then. Alex, could you take a look please? > --- > include/hw/virtio/virtio.h | 5 +++++ > hw/virtio/vhost-user-fs.c | 6 +----- > hw/virtio/vhost-user-i2c.c | 6 +----- > hw/virtio/vhost-user-rng.c | 6 +----- > hw/virtio/vhost-user-vsock.c | 6 +----- > hw/virtio/vhost-vsock.c | 6 +----- > 6 files changed, 10 insertions(+), 25 deletions(-) > > diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h > index 9bb2485415..74e7ad5a92 100644 > --- a/include/hw/virtio/virtio.h > +++ b/include/hw/virtio/virtio.h > @@ -100,6 +100,7 @@ struct VirtIODevice > VirtQueue *vq; > MemoryListener listener; > uint16_t device_id; > + /* @vm_running: current VM running state via virtio_vmstate_change() */ > bool vm_running; > bool broken; /* device in invalid state, needs reset */ > bool use_disabled_flag; /* allow use of 'disable' flag when needed */ > @@ -376,6 +377,10 @@ static inline bool virtio_device_started(VirtIODevice *vdev, uint8_t status) > return vdev->started; > } > > + if (!vdev->vm_running) { > + return false; > + } > + > return status & VIRTIO_CONFIG_S_DRIVER_OK; > } > > diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c > index e513e4fdda..d2bebba785 100644 > --- a/hw/virtio/vhost-user-fs.c > +++ b/hw/virtio/vhost-user-fs.c > @@ -122,11 +122,7 @@ static void vuf_stop(VirtIODevice *vdev) > static void vuf_set_status(VirtIODevice *vdev, uint8_t status) > { > VHostUserFS *fs = VHOST_USER_FS(vdev); > - bool should_start = status & VIRTIO_CONFIG_S_DRIVER_OK; > - > - if (!vdev->vm_running) { > - should_start = false; > - } > + bool should_start = virtio_device_started(vdev, status); > > if (fs->vhost_dev.started == should_start) { > return; > diff --git a/hw/virtio/vhost-user-i2c.c b/hw/virtio/vhost-user-i2c.c > index 6020eee093..b930cf6d5e 100644 > --- a/hw/virtio/vhost-user-i2c.c > +++ b/hw/virtio/vhost-user-i2c.c > @@ -93,11 +93,7 @@ static void vu_i2c_stop(VirtIODevice *vdev) > static void vu_i2c_set_status(VirtIODevice *vdev, uint8_t status) > { > VHostUserI2C *i2c = VHOST_USER_I2C(vdev); > - bool should_start = status & VIRTIO_CONFIG_S_DRIVER_OK; > - > - if (!vdev->vm_running) { > - should_start = false; > - } > + bool should_start = virtio_device_started(vdev, status); > > if (i2c->vhost_dev.started == should_start) { > return; > diff --git a/hw/virtio/vhost-user-rng.c b/hw/virtio/vhost-user-rng.c > index 3a7bf8e32d..a9c1c4bc79 100644 > --- a/hw/virtio/vhost-user-rng.c > +++ b/hw/virtio/vhost-user-rng.c > @@ -90,11 +90,7 @@ static void vu_rng_stop(VirtIODevice *vdev) > static void vu_rng_set_status(VirtIODevice *vdev, uint8_t status) > { > VHostUserRNG *rng = VHOST_USER_RNG(vdev); > - bool should_start = status & VIRTIO_CONFIG_S_DRIVER_OK; > - > - if (!vdev->vm_running) { > - should_start = false; > - } > + bool should_start = virtio_device_started(vdev, status); > > if (rng->vhost_dev.started == should_start) { > return; > diff --git a/hw/virtio/vhost-user-vsock.c b/hw/virtio/vhost-user-vsock.c > index 0f8ff99f85..22c1616ebd 100644 > --- a/hw/virtio/vhost-user-vsock.c > +++ b/hw/virtio/vhost-user-vsock.c > @@ -55,11 +55,7 @@ const VhostDevConfigOps vsock_ops = { > static void vuv_set_status(VirtIODevice *vdev, uint8_t status) > { > VHostVSockCommon *vvc = VHOST_VSOCK_COMMON(vdev); > - bool should_start = status & VIRTIO_CONFIG_S_DRIVER_OK; > - > - if (!vdev->vm_running) { > - should_start = false; > - } > + bool should_start = virtio_device_started(vdev, status); > > if (vvc->vhost_dev.started == should_start) { > return; > diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c > index 0338de892f..8031c164a5 100644 > --- a/hw/virtio/vhost-vsock.c > +++ b/hw/virtio/vhost-vsock.c > @@ -70,13 +70,9 @@ static int vhost_vsock_set_running(VirtIODevice *vdev, int start) > static void vhost_vsock_set_status(VirtIODevice *vdev, uint8_t status) > { > VHostVSockCommon *vvc = VHOST_VSOCK_COMMON(vdev); > - bool should_start = status & VIRTIO_CONFIG_S_DRIVER_OK; > + bool should_start = virtio_device_started(vdev, status); > int ret; > > - if (!vdev->vm_running) { > - should_start = false; > - } > - > if (vvc->vhost_dev.started == should_start) { > return; > } > -- > MST > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Virtio-fs] [PULL 07/55] hw/virtio: move vm_running check to virtio_device_started 2022-11-05 16:45 ` [Virtio-fs] [PULL 07/55] hw/virtio: move vm_running check to virtio_device_started Michael S. Tsirkin @ 2022-11-07 9:21 ` Alex Bennée 0 siblings, 0 replies; 10+ messages in thread From: Alex Bennée @ 2022-11-07 9:21 UTC (permalink / raw) To: Michael S. Tsirkin Cc: qemu-devel, Peter Maydell, Dr. David Alan Gilbert, Stefan Hajnoczi, Mathieu Poirier, virtio-fs, Viresh Kumar "Michael S. Tsirkin" <mst@redhat.com> writes: > On Mon, Oct 10, 2022 at 01:29:10PM -0400, Michael S. Tsirkin wrote: >> From: Alex Bennée <alex.bennee@linaro.org> >> >> All the boilerplate virtio code does the same thing (or should at >> least) of checking to see if the VM is running before attempting to >> start VirtIO. Push the logic up to the common function to avoid >> getting a copy and paste wrong. >> >> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> >> Message-Id: <20220802095010.3330793-11-alex.bennee@linaro.org> >> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> >> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> > > So, looking at the resulting code, I missed the fact that this function > is also used in virtio core. So this patch does not do what it's saying > it does (just refactor code). > Instead it completely changes the meaning for virtio core. > I thunk we should revert upstream, however, gpio has grown a > dependency on this since then. > Alex, could you take a look please? So I guess we have three choices: new function for use by backends new function for use by core parameterise virtio_device_started to ignore vm state I'll add some usage doc comments whichever way. Do you have a preference? > >> --- >> include/hw/virtio/virtio.h | 5 +++++ >> hw/virtio/vhost-user-fs.c | 6 +----- >> hw/virtio/vhost-user-i2c.c | 6 +----- >> hw/virtio/vhost-user-rng.c | 6 +----- >> hw/virtio/vhost-user-vsock.c | 6 +----- >> hw/virtio/vhost-vsock.c | 6 +----- >> 6 files changed, 10 insertions(+), 25 deletions(-) >> >> diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h >> index 9bb2485415..74e7ad5a92 100644 >> --- a/include/hw/virtio/virtio.h >> +++ b/include/hw/virtio/virtio.h >> @@ -100,6 +100,7 @@ struct VirtIODevice >> VirtQueue *vq; >> MemoryListener listener; >> uint16_t device_id; >> + /* @vm_running: current VM running state via virtio_vmstate_change() */ >> bool vm_running; >> bool broken; /* device in invalid state, needs reset */ >> bool use_disabled_flag; /* allow use of 'disable' flag when needed */ >> @@ -376,6 +377,10 @@ static inline bool virtio_device_started(VirtIODevice *vdev, uint8_t status) >> return vdev->started; >> } >> >> + if (!vdev->vm_running) { >> + return false; >> + } >> + >> return status & VIRTIO_CONFIG_S_DRIVER_OK; >> } >> >> diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c >> index e513e4fdda..d2bebba785 100644 >> --- a/hw/virtio/vhost-user-fs.c >> +++ b/hw/virtio/vhost-user-fs.c >> @@ -122,11 +122,7 @@ static void vuf_stop(VirtIODevice *vdev) >> static void vuf_set_status(VirtIODevice *vdev, uint8_t status) >> { >> VHostUserFS *fs = VHOST_USER_FS(vdev); >> - bool should_start = status & VIRTIO_CONFIG_S_DRIVER_OK; >> - >> - if (!vdev->vm_running) { >> - should_start = false; >> - } >> + bool should_start = virtio_device_started(vdev, status); >> >> if (fs->vhost_dev.started == should_start) { >> return; >> diff --git a/hw/virtio/vhost-user-i2c.c b/hw/virtio/vhost-user-i2c.c >> index 6020eee093..b930cf6d5e 100644 >> --- a/hw/virtio/vhost-user-i2c.c >> +++ b/hw/virtio/vhost-user-i2c.c >> @@ -93,11 +93,7 @@ static void vu_i2c_stop(VirtIODevice *vdev) >> static void vu_i2c_set_status(VirtIODevice *vdev, uint8_t status) >> { >> VHostUserI2C *i2c = VHOST_USER_I2C(vdev); >> - bool should_start = status & VIRTIO_CONFIG_S_DRIVER_OK; >> - >> - if (!vdev->vm_running) { >> - should_start = false; >> - } >> + bool should_start = virtio_device_started(vdev, status); >> >> if (i2c->vhost_dev.started == should_start) { >> return; >> diff --git a/hw/virtio/vhost-user-rng.c b/hw/virtio/vhost-user-rng.c >> index 3a7bf8e32d..a9c1c4bc79 100644 >> --- a/hw/virtio/vhost-user-rng.c >> +++ b/hw/virtio/vhost-user-rng.c >> @@ -90,11 +90,7 @@ static void vu_rng_stop(VirtIODevice *vdev) >> static void vu_rng_set_status(VirtIODevice *vdev, uint8_t status) >> { >> VHostUserRNG *rng = VHOST_USER_RNG(vdev); >> - bool should_start = status & VIRTIO_CONFIG_S_DRIVER_OK; >> - >> - if (!vdev->vm_running) { >> - should_start = false; >> - } >> + bool should_start = virtio_device_started(vdev, status); >> >> if (rng->vhost_dev.started == should_start) { >> return; >> diff --git a/hw/virtio/vhost-user-vsock.c b/hw/virtio/vhost-user-vsock.c >> index 0f8ff99f85..22c1616ebd 100644 >> --- a/hw/virtio/vhost-user-vsock.c >> +++ b/hw/virtio/vhost-user-vsock.c >> @@ -55,11 +55,7 @@ const VhostDevConfigOps vsock_ops = { >> static void vuv_set_status(VirtIODevice *vdev, uint8_t status) >> { >> VHostVSockCommon *vvc = VHOST_VSOCK_COMMON(vdev); >> - bool should_start = status & VIRTIO_CONFIG_S_DRIVER_OK; >> - >> - if (!vdev->vm_running) { >> - should_start = false; >> - } >> + bool should_start = virtio_device_started(vdev, status); >> >> if (vvc->vhost_dev.started == should_start) { >> return; >> diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c >> index 0338de892f..8031c164a5 100644 >> --- a/hw/virtio/vhost-vsock.c >> +++ b/hw/virtio/vhost-vsock.c >> @@ -70,13 +70,9 @@ static int vhost_vsock_set_running(VirtIODevice *vdev, int start) >> static void vhost_vsock_set_status(VirtIODevice *vdev, uint8_t status) >> { >> VHostVSockCommon *vvc = VHOST_VSOCK_COMMON(vdev); >> - bool should_start = status & VIRTIO_CONFIG_S_DRIVER_OK; >> + bool should_start = virtio_device_started(vdev, status); >> int ret; >> >> - if (!vdev->vm_running) { >> - should_start = false; >> - } >> - >> if (vvc->vhost_dev.started == should_start) { >> return; >> } >> -- >> MST >> -- Alex Bennée ^ permalink raw reply [flat|nested] 10+ messages in thread
* [Virtio-fs] [PULL 08/55] hw/virtio: move vhd->started check into helper and add FIXME [not found] <20221010172813.204597-1-mst@redhat.com> 2022-10-10 17:29 ` [Virtio-fs] [PULL 07/55] hw/virtio: move vm_running check to virtio_device_started Michael S. Tsirkin @ 2022-10-10 17:29 ` Michael S. Tsirkin 1 sibling, 0 replies; 10+ messages in thread From: Michael S. Tsirkin @ 2022-10-10 17:29 UTC (permalink / raw) To: qemu-devel Cc: Peter Maydell, Alex Bennée, Raphael Norwitz, Raphael Norwitz, Kevin Wolf, Hanna Reitz, Paolo Bonzini, Fam Zheng, Dr. David Alan Gilbert, Stefan Hajnoczi, Mathieu Poirier, qemu-block, virtio-fs From: Alex Bennée <alex.bennee@linaro.org> The `started` field is manipulated internally within the vhost code except for one place, vhost-user-blk via f5b22d06fb (vhost: recheck dev state in the vhost_migration_log routine). Mark that as a FIXME because it introduces a potential race. I think the referenced fix should be tracking its state locally. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20220802095010.3330793-12-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Raphael Norwitz <raphael.norwittz@nutanix.com> --- include/hw/virtio/vhost.h | 12 ++++++++++++ hw/block/vhost-user-blk.c | 10 ++++++++-- hw/scsi/vhost-scsi.c | 4 ++-- hw/scsi/vhost-user-scsi.c | 2 +- hw/virtio/vhost-user-fs.c | 3 ++- hw/virtio/vhost-user-i2c.c | 4 ++-- hw/virtio/vhost-user-rng.c | 4 ++-- hw/virtio/vhost-user-vsock.c | 2 +- hw/virtio/vhost-vsock-common.c | 3 ++- hw/virtio/vhost-vsock.c | 2 +- 10 files changed, 33 insertions(+), 13 deletions(-) diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 586c5457e2..61b957e927 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -94,6 +94,7 @@ struct vhost_dev { uint64_t protocol_features; uint64_t max_queues; uint64_t backend_cap; + /* @started: is the vhost device started? */ bool started; bool log_enabled; uint64_t log_size; @@ -165,6 +166,17 @@ int vhost_dev_enable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev); */ void vhost_dev_disable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev); +/** + * vhost_dev_is_started() - report status of vhost device + * @hdev: common vhost_dev structure + * + * Return the started status of the vhost device + */ +static inline bool vhost_dev_is_started(struct vhost_dev *hdev) +{ + return hdev->started; +} + /** * vhost_dev_start() - start the vhost device * @hdev: common vhost_dev structure diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 9117222456..2bba42478d 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -229,7 +229,7 @@ static void vhost_user_blk_set_status(VirtIODevice *vdev, uint8_t status) return; } - if (s->dev.started == should_start) { + if (vhost_dev_is_started(&s->dev) == should_start) { return; } @@ -286,7 +286,7 @@ static void vhost_user_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq) return; } - if (s->dev.started) { + if (vhost_dev_is_started(&s->dev)) { return; } @@ -415,6 +415,12 @@ static void vhost_user_blk_event(void *opaque, QEMUChrEvent event) * the vhost migration code. If disconnect was caught there is an * option for the general vhost code to get the dev state without * knowing its type (in this case vhost-user). + * + * FIXME: this is sketchy to be reaching into vhost_dev + * now because we are forcing something that implies we + * have executed vhost_dev_stop() but that won't happen + * until vhost_user_blk_stop() gets called from the bh. + * Really this state check should be tracked locally. */ s->dev.started = false; } diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index 3059068175..bdf337a7a2 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -120,7 +120,7 @@ static void vhost_scsi_set_status(VirtIODevice *vdev, uint8_t val) start = false; } - if (vsc->dev.started == start) { + if (vhost_dev_is_started(&vsc->dev) == start) { return; } @@ -147,7 +147,7 @@ static int vhost_scsi_pre_save(void *opaque) /* At this point, backend must be stopped, otherwise * it might keep writing to memory. */ - assert(!vsc->dev.started); + assert(!vhost_dev_is_started(&vsc->dev)); return 0; } diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c index 1b2f7eed98..bc37317d55 100644 --- a/hw/scsi/vhost-user-scsi.c +++ b/hw/scsi/vhost-user-scsi.c @@ -49,7 +49,7 @@ static void vhost_user_scsi_set_status(VirtIODevice *vdev, uint8_t status) VHostSCSICommon *vsc = VHOST_SCSI_COMMON(s); bool start = (status & VIRTIO_CONFIG_S_DRIVER_OK) && vdev->vm_running; - if (vsc->dev.started == start) { + if (vhost_dev_is_started(&vsc->dev) == start) { return; } diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c index d2bebba785..ad0f91c607 100644 --- a/hw/virtio/vhost-user-fs.c +++ b/hw/virtio/vhost-user-fs.c @@ -20,6 +20,7 @@ #include "hw/virtio/virtio-bus.h" #include "hw/virtio/virtio-access.h" #include "qemu/error-report.h" +#include "hw/virtio/vhost.h" #include "hw/virtio/vhost-user-fs.h" #include "monitor/monitor.h" #include "sysemu/sysemu.h" @@ -124,7 +125,7 @@ static void vuf_set_status(VirtIODevice *vdev, uint8_t status) VHostUserFS *fs = VHOST_USER_FS(vdev); bool should_start = virtio_device_started(vdev, status); - if (fs->vhost_dev.started == should_start) { + if (vhost_dev_is_started(&fs->vhost_dev) == should_start) { return; } diff --git a/hw/virtio/vhost-user-i2c.c b/hw/virtio/vhost-user-i2c.c index b930cf6d5e..bc58b6c0d1 100644 --- a/hw/virtio/vhost-user-i2c.c +++ b/hw/virtio/vhost-user-i2c.c @@ -95,7 +95,7 @@ static void vu_i2c_set_status(VirtIODevice *vdev, uint8_t status) VHostUserI2C *i2c = VHOST_USER_I2C(vdev); bool should_start = virtio_device_started(vdev, status); - if (i2c->vhost_dev.started == should_start) { + if (vhost_dev_is_started(&i2c->vhost_dev) == should_start) { return; } @@ -174,7 +174,7 @@ static void vu_i2c_disconnect(DeviceState *dev) } i2c->connected = false; - if (i2c->vhost_dev.started) { + if (vhost_dev_is_started(&i2c->vhost_dev)) { vu_i2c_stop(vdev); } } diff --git a/hw/virtio/vhost-user-rng.c b/hw/virtio/vhost-user-rng.c index a9c1c4bc79..bc1f36c5ac 100644 --- a/hw/virtio/vhost-user-rng.c +++ b/hw/virtio/vhost-user-rng.c @@ -92,7 +92,7 @@ static void vu_rng_set_status(VirtIODevice *vdev, uint8_t status) VHostUserRNG *rng = VHOST_USER_RNG(vdev); bool should_start = virtio_device_started(vdev, status); - if (rng->vhost_dev.started == should_start) { + if (vhost_dev_is_started(&rng->vhost_dev) == should_start) { return; } @@ -160,7 +160,7 @@ static void vu_rng_disconnect(DeviceState *dev) rng->connected = false; - if (rng->vhost_dev.started) { + if (vhost_dev_is_started(&rng->vhost_dev)) { vu_rng_stop(vdev); } } diff --git a/hw/virtio/vhost-user-vsock.c b/hw/virtio/vhost-user-vsock.c index 22c1616ebd..7b67e29d83 100644 --- a/hw/virtio/vhost-user-vsock.c +++ b/hw/virtio/vhost-user-vsock.c @@ -57,7 +57,7 @@ static void vuv_set_status(VirtIODevice *vdev, uint8_t status) VHostVSockCommon *vvc = VHOST_VSOCK_COMMON(vdev); bool should_start = virtio_device_started(vdev, status); - if (vvc->vhost_dev.started == should_start) { + if (vhost_dev_is_started(&vvc->vhost_dev) == should_start) { return; } diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c index 7394818e00..29b9ab4f72 100644 --- a/hw/virtio/vhost-vsock-common.c +++ b/hw/virtio/vhost-vsock-common.c @@ -14,6 +14,7 @@ #include "hw/virtio/virtio-access.h" #include "qemu/error-report.h" #include "hw/qdev-properties.h" +#include "hw/virtio/vhost.h" #include "hw/virtio/vhost-vsock.h" #include "qemu/iov.h" #include "monitor/monitor.h" @@ -199,7 +200,7 @@ int vhost_vsock_common_pre_save(void *opaque) * At this point, backend must be stopped, otherwise * it might keep writing to memory. */ - assert(!vvc->vhost_dev.started); + assert(!vhost_dev_is_started(&vvc->vhost_dev)); return 0; } diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c index 8031c164a5..7dc3c73931 100644 --- a/hw/virtio/vhost-vsock.c +++ b/hw/virtio/vhost-vsock.c @@ -73,7 +73,7 @@ static void vhost_vsock_set_status(VirtIODevice *vdev, uint8_t status) bool should_start = virtio_device_started(vdev, status); int ret; - if (vvc->vhost_dev.started == should_start) { + if (vhost_dev_is_started(&vvc->vhost_dev) == should_start) { return; } -- MST ^ permalink raw reply related [flat|nested] 10+ messages in thread
end of thread, other threads:[~2022-11-07 9:21 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20221010172813.204597-1-mst@redhat.com>
2022-10-10 17:29 ` [Virtio-fs] [PULL 07/55] hw/virtio: move vm_running check to virtio_device_started Michael S. Tsirkin
2022-10-14 7:30 ` [Virtio-fs] Regression save/restore of vsock: (was [PULL 07/55] hw/virtio: move vm_running check to virtio_device_started) Christian Borntraeger
2022-10-14 8:31 ` Christian Borntraeger
2022-10-14 11:07 ` Alex Bennée
2022-10-14 11:58 ` Christian Borntraeger
2022-10-14 8:37 ` Alex Bennée
2022-10-14 8:44 ` Christian Borntraeger
2022-11-05 16:45 ` [Virtio-fs] [PULL 07/55] hw/virtio: move vm_running check to virtio_device_started Michael S. Tsirkin
2022-11-07 9:21 ` Alex Bennée
2022-10-10 17:29 ` [Virtio-fs] [PULL 08/55] hw/virtio: move vhd->started check into helper and add FIXME Michael S. Tsirkin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox