[PATCH 1/2] vhost: Do not abort on log-start error

Hanna Czenczek posted 2 patches 3 months, 3 weeks ago
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>, Stefano Garzarella <sgarzare@redhat.com>
[PATCH 1/2] vhost: Do not abort on log-start error
Posted by Hanna Czenczek 3 months, 3 weeks ago
Commit 3688fec8923 ("memory: Add Error** argument to .log_global_start()
handler") enabled vhost_log_global_start() to return a proper error, but
did not change it to do so; instead, it still aborts the whole process
on error.

This crash can be reproduced by e.g. killing a virtiofsd daemon before
initiating migration.  In such a case, qemu should not crash, but just
make the attempted migration fail.

Buglink: https://issues.redhat.com/browse/RHEL-94534
Reported-by: Tingting Mao <timao@redhat.com>
Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
---
 hw/virtio/vhost.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index c30ea1156e..05ad5de629 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -1110,7 +1110,8 @@ static bool vhost_log_global_start(MemoryListener *listener, Error **errp)
 
     r = vhost_migration_log(listener, true);
     if (r < 0) {
-        abort();
+        error_setg_errno(errp, -r, "vhost: Failed to start logging");
+        return false;
     }
     return true;
 }
-- 
2.50.1
Re: [PATCH 1/2] vhost: Do not abort on log-start error
Posted by Stefano Garzarella 3 months, 3 weeks ago
On Thu, Jul 24, 2025 at 02:59:27PM +0200, Hanna Czenczek wrote:
>Commit 3688fec8923 ("memory: Add Error** argument to .log_global_start()
>handler") enabled vhost_log_global_start() to return a proper error, but
>did not change it to do so; instead, it still aborts the whole process
>on error.
>
>This crash can be reproduced by e.g. killing a virtiofsd daemon before
>initiating migration.  In such a case, qemu should not crash, but just
>make the attempted migration fail.
>
>Buglink: https://issues.redhat.com/browse/RHEL-94534
>Reported-by: Tingting Mao <timao@redhat.com>
>Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
>---
> hw/virtio/vhost.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)

IIUC we always had the problem, so it's not a regression, but should we 
queue the patch in stable as well?

Anyway, it LGTM!

Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>

>
>diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
>index c30ea1156e..05ad5de629 100644
>--- a/hw/virtio/vhost.c
>+++ b/hw/virtio/vhost.c
>@@ -1110,7 +1110,8 @@ static bool vhost_log_global_start(MemoryListener *listener, Error **errp)
>
>     r = vhost_migration_log(listener, true);
>     if (r < 0) {
>-        abort();
>+        error_setg_errno(errp, -r, "vhost: Failed to start logging");
>+        return false;
>     }
>     return true;
> }
>-- 
>2.50.1
>
Re: [PATCH 1/2] vhost: Do not abort on log-start error
Posted by Hanna Czenczek 3 months, 3 weeks ago
On 24.07.25 16:24, Stefano Garzarella wrote:
> On Thu, Jul 24, 2025 at 02:59:27PM +0200, Hanna Czenczek wrote:
>> Commit 3688fec8923 ("memory: Add Error** argument to .log_global_start()
>> handler") enabled vhost_log_global_start() to return a proper error, but
>> did not change it to do so; instead, it still aborts the whole process
>> on error.
>>
>> This crash can be reproduced by e.g. killing a virtiofsd daemon before
>> initiating migration.  In such a case, qemu should not crash, but just
>> make the attempted migration fail.
>>
>> Buglink: https://issues.redhat.com/browse/RHEL-94534
>> Reported-by: Tingting Mao <timao@redhat.com>
>> Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
>> ---
>> hw/virtio/vhost.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> IIUC we always had the problem, so it's not a regression, but should 
> we queue the patch in stable as well?

That’s my impression as well.  I think it fits and makes sense for 
stable, but it isn’t absolutely necessary; it’s not a regression, and 
abort()-ing is not a critical problem.

> Anyway, it LGTM!
>
> Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>

Thanks!

Hanna

>
>>
>> diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
>> index c30ea1156e..05ad5de629 100644
>> --- a/hw/virtio/vhost.c
>> +++ b/hw/virtio/vhost.c
>> @@ -1110,7 +1110,8 @@ static bool 
>> vhost_log_global_start(MemoryListener *listener, Error **errp)
>>
>>     r = vhost_migration_log(listener, true);
>>     if (r < 0) {
>> -        abort();
>> +        error_setg_errno(errp, -r, "vhost: Failed to start logging");
>> +        return false;
>>     }
>>     return true;
>> }
>> -- 
>> 2.50.1
>>
>


Re: [PATCH 1/2] vhost: Do not abort on log-start error
Posted by Manos Pitsidianakis 3 months, 3 weeks ago
On Thu, Jul 24, 2025 at 4:00 PM Hanna Czenczek <hreitz@redhat.com> wrote:
>
> Commit 3688fec8923 ("memory: Add Error** argument to .log_global_start()
> handler") enabled vhost_log_global_start() to return a proper error, but
> did not change it to do so; instead, it still aborts the whole process
> on error.
>
> This crash can be reproduced by e.g. killing a virtiofsd daemon before
> initiating migration.  In such a case, qemu should not crash, but just
> make the attempted migration fail.
>
> Buglink: https://issues.redhat.com/browse/RHEL-94534
> Reported-by: Tingting Mao <timao@redhat.com>
> Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
> ---
>  hw/virtio/vhost.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
> index c30ea1156e..05ad5de629 100644
> --- a/hw/virtio/vhost.c
> +++ b/hw/virtio/vhost.c
> @@ -1110,7 +1110,8 @@ static bool vhost_log_global_start(MemoryListener *listener, Error **errp)
>
>      r = vhost_migration_log(listener, true);
>      if (r < 0) {
> -        abort();
> +        error_setg_errno(errp, -r, "vhost: Failed to start logging");
> +        return false;
>      }
>      return true;
>  }
> --
> 2.50.1
>
>

Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>