Do not abort on log-start/stop errors
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
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
@@ -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
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") enabledvhost_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.
Reported-by Tingting Mao <[email protected]>Signed-off-by Hanna Czenczek <[email protected]>--- hw/virtio/vhost.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)hw/virtio/vhost.c +2
-2@@ -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
Re: [PATCH 1/2] vhost: Do not abort on log-start error
In reply to Hanna CzenczekQuoted 9 lines · Hanna Czenczek
Commit
3688fec8923("memory: Add Error** argument to .log_global_start() handler") enabledvhost_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
Reported-by Tingting Mao <[email protected]>Signed-off-by Hanna Czenczek <[email protected]>---
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@@ -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
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") enabledvhost_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
Reported-by Tingting Mao <[email protected]>Signed-off-by Hanna Czenczek <[email protected]>---
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!
Reviewed-by Stefano Garzarella <[email protected]>
Thanks!
Hanna
Quoted 21 lines
Quoted 20 lines
hw/virtio/vhost.c +2
-1@@ -1110,7 +1110,8 @@ static boolvhost_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
PATCH 2/2 vhost: Do not abort on log-stop error
In reply to Hanna CzenczekFailing 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
@@ -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
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.
Signed-off-by Hanna Czenczek <[email protected]>--- hw/virtio/vhost.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)hw/virtio/vhost.c +2
-2@@ -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
Re: [PATCH 2/2] vhost: Do not abort on log-stop error
In reply to Hanna CzenczekQuoted 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.
Signed-off-by Hanna Czenczek <[email protected]>---
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@@ -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 this series of patches with vhost-net regression tests, everything works fine.
Quoted 30 lines · Hanna Czenczek
Hi,
vhost_log_global_start()andvhost_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 commit3688fec8923("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 errorhw/virtio/vhost.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)--
2.50.1
Quoted 13 lines · Hanna Czenczek
Hi,
vhost_log_global_start()andvhost_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 commit3688fec8923("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