Skip to contentSkip to conversation

Do not abort on log-start/stop errors

PATCH In review Hanna Czenczek 5 participants 10 messages Jul 24, 2025 – Aug 2, 2025

lore
Share & tools
lore
#0 lore raw

cover Do not abort on log-start/stop errors

Hi,

vhost_log_global_start() and vhost_log_global_stop() abort the whole qemu process on error. Not least because vhost devices are generally outside of qemu (i.e. use a foreign code base), that is not great, as we can basically be forced to abort because of bugs (or maybe even properly behaving, just unexpectedly so) in other code bases.

In case of vhost_log_global_start(), the solution is simple: Ever since commit 3688fec8923 ("memory: Add Error** argument to .log_global_start() handler"), it can just return proper errors, so do that instead of aborting.

In case of vhost_log_global_stop(), we cannot return errors; but we can just ignore them. In the worst case, some other process will keep logging into shared memory we have already unmapped. That's fine.

Hanna Czenczek (2):
vhost: Do not abort on log-start error
vhost: Do not abort on log-stop error

 hw/virtio/vhost.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
Signature · 1 line
2.50.1
#1 lore raw

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

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.

---
 hw/virtio/vhost.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/virtio/vhost.c +2 -1
index c30ea1156e..05ad5de629 100644
@@ -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;
 }
Signature · 1 line
2.50.1
Reviewed-by on v1 1/2
#2 lore raw

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

Quoted 32 lines · Hanna Czenczek

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.

---
 hw/virtio/vhost.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/virtio/vhost.c +2 -2
index c30ea1156e..05ad5de629 100644
@@ -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;
 }
--
Quoted 3 lines

2.50.1

Reviewed-by on v1 1/2
#3 lore raw

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

In reply to Hanna Czenczek
Quoted 9 lines · Hanna Czenczek

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.

Quoted 6 lines

---
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!

Quoted 18 lines
hw/virtio/vhost.c +2 -1
index c30ea1156e..05ad5de629 100644
@@ -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;
 }
Signature · 1 line
2.50.1
#4 lore raw

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

Quoted 10 lines · Stefano Garzarella
Quoted 9 lines · Hanna Czenczek

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.

Quoted 8 lines
Quoted 6 lines

---
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.

Quoted 3 lines

Anyway, it LGTM!

Thanks!

Hanna

Quoted 21 lines
Quoted 20 lines
hw/virtio/vhost.c +2 -1
index c30ea1156e..05ad5de629 100644
@@ -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;

}

Signature · 1 line
2.50.1
#5 lore raw

PATCH 2/2 vhost: Do not abort on log-stop error

In reply to Hanna Czenczek

Failing to stop logging in a vhost device is not exactly fatal. We can log such an error, but there is no need to abort the whole qemu process because of it.

---
 hw/virtio/vhost.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/virtio/vhost.c +2 -1
index 05ad5de629..6557c58d12 100644
@@ -1122,7 +1122,8 @@ static void vhost_log_global_stop(MemoryListener *listener)
 
     r = vhost_migration_log(listener, false);
     if (r < 0) {
-        abort();
+        /* Not fatal, so report it, but take no further action */
+        warn_report("vhost: Failed to stop logging");
     }
 }
 
Signature · 1 line
2.50.1
Reviewed-by on v1 2/2
#6 lore raw

Re: [PATCH 2/2] vhost: Do not abort on log-stop error

Quoted 25 lines · Hanna Czenczek

Failing to stop logging in a vhost device is not exactly fatal. We can log such an error, but there is no need to abort the whole qemu process because of it.

---
 hw/virtio/vhost.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/virtio/vhost.c +2 -2
index 05ad5de629..6557c58d12 100644
@@ -1122,7 +1122,8 @@ static void vhost_log_global_stop(MemoryListener *listener)
 
     r = vhost_migration_log(listener, false);
     if (r < 0) {
-        abort();
+        /* Not fatal, so report it, but take no further action */
+        warn_report("vhost: Failed to stop logging");
     }
 }
 
--
Quoted 3 lines

2.50.1

Signature · 2 lines
Manos Pitsidianakis
Emulation and Virtualization Engineer at Linaro Ltd
Reviewed-by on v1 2/2
#7 lore raw

Re: [PATCH 2/2] vhost: Do not abort on log-stop error

In reply to Hanna Czenczek
Quoted 8 lines · Hanna Czenczek

Failing to stop logging in a vhost device is not exactly fatal. We can log such an error, but there is no need to abort the whole qemu process because of it.

---
hw/virtio/vhost.c | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)

Ditto about stable here as well.

Quoted 18 lines
hw/virtio/vhost.c +2 -1
index 05ad5de629..6557c58d12 100644
@@ -1122,7 +1122,8 @@ static void vhost_log_global_stop(MemoryListener *listener)
 
    r = vhost_migration_log(listener, false);
    if (r < 0) {
-        abort();
+        /* Not fatal, so report it, but take no further action */
+        warn_report("vhost: Failed to stop logging");
    }
 }
 
Signature · 1 line
2.50.1
Tested-by on the v1 series
#8 lore raw
In reply to Hanna Czenczek

Tested this series of patches with vhost-net regression tests, everything works fine.

Quoted 30 lines · Hanna Czenczek

Hi,

vhost_log_global_start() and vhost_log_global_stop() abort the whole qemu process on error. Not least because vhost devices are generally outside of qemu (i.e. use a foreign code base), that is not great, as we can basically be forced to abort because of bugs (or maybe even properly behaving, just unexpectedly so) in other code bases.

In case of vhost_log_global_start(), the solution is simple: Ever since commit 3688fec8923 ("memory: Add Error** argument to .log_global_start() handler"), it can just return proper errors, so do that instead of aborting.

In case of vhost_log_global_stop(), we cannot return errors; but we can just ignore them. In the worst case, some other process will keep logging into shared memory we have already unmapped. That's fine.

Hanna Czenczek (2):
vhost: Do not abort on log-start error
vhost: Do not abort on log-stop error

 hw/virtio/vhost.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

--
2.50.1

#9 lore raw
In reply to Hanna Czenczek
Quoted 13 lines · Hanna Czenczek

Hi,

vhost_log_global_start() and vhost_log_global_stop() abort the whole qemu process on error. Not least because vhost devices are generally outside of qemu (i.e. use a foreign code base), that is not great, as we can basically be forced to abort because of bugs (or maybe even properly behaving, just unexpectedly so) in other code bases.

In case of vhost_log_global_start(), the solution is simple: Ever since commit 3688fec8923 ("memory: Add Error** argument to .log_global_start() handler"), it can just return proper errors, so do that instead of aborting.

Quoted 8 lines

In case of vhost_log_global_stop(), we cannot return errors; but we can just ignore them. In the worst case, some other process will keep logging into shared memory we have already unmapped. That's fine.

Hanna Czenczek (2):
vhost: Do not abort on log-start error
vhost: Do not abort on log-stop error

I'm picking this up for qemu 10.0.x stable series, as simple bugfixes. Please let me know if I should not.

Thanks,

/mjt