Hi Nick,
On 25/9/25 04:32, Houqi (Nick) Zuo wrote:
When QEMU creates a tap device automatically and the tap device is
manually removed from the host while the guest is running, the tap
device file descriptor becomes invalid. Later, when the guest executes
shutdown, the tap_fd_set_vnet_hdr_len() function may be called and
abort QEMU with a core dump when attempting to use the invalid fd.
This patch removes many abort() calls in this file. If the fd is found
to be in a bad state (e.g., EBADFD or ENODEV), the related function
will print an error message.
The expected behavior for this negative test case is that QEMU should
report an error but continue running rather than aborting.
Fixes: 0caed25cd171c611781589b5402161d27d57229c ("virtio: Call set_features during
reset")
Signed-off-by: Houqi (Nick) Zuo <[email protected]>
---
net/tap-linux.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/net/tap-linux.c b/net/tap-linux.c
index e832810665..24e63a0b54 100644
--- a/net/tap-linux.c
+++ b/net/tap-linux.c
@@ -206,15 +206,16 @@ void tap_fd_set_vnet_hdr_len(int fd, int len)
if (ioctl(fd, TUNSETVNETHDRSZ, &len) == -1) {
fprintf(stderr, "TUNSETVNETHDRSZ ioctl() failed: %s. Exiting.\n",
strerror(errno));
Remove "Exiting".
While here, can you replace fprintf() -> error_report()?
- abort();
If we don't exit anymore, this function should return some value
indicating the failure, and the callers should check it.
}
}
Regards,
Phil.