virtio-console: Prevent abort()s in case of host chardev close
A host chardev could close just before the guest sends some data to be written. This will cause an -EPIPE error. This shouldn't be propagated to virtio-serial-bus. Ideally we should close the port once -EPIPE is received, but since the chardev interface doesn't return such meaningful values to its users, all we get is -1 for any kind of error. Just return 0 for now and wait for chardevs to return better error messages to act better on the return messages. Signed-off-by: Amit Shah <amit.shah@redhat.com>
This commit is contained in:
		
							parent
							
								
									95c9cde2df
								
							
						
					
					
						commit
						0219d73283
					
				| 
						 | 
				
			
			@ -28,8 +28,22 @@ static ssize_t flush_buf(VirtIOSerialPort *port, const uint8_t *buf, size_t len)
 | 
			
		|||
    ssize_t ret;
 | 
			
		||||
 | 
			
		||||
    ret = qemu_chr_write(vcon->chr, buf, len);
 | 
			
		||||
 | 
			
		||||
    trace_virtio_console_flush_buf(port->id, len, ret);
 | 
			
		||||
 | 
			
		||||
    if (ret < 0) {
 | 
			
		||||
        /*
 | 
			
		||||
         * Ideally we'd get a better error code than just -1, but
 | 
			
		||||
         * that's what the chardev interface gives us right now.  If
 | 
			
		||||
         * we had a finer-grained message, like -EPIPE, we could close
 | 
			
		||||
         * this connection.  Absent such error messages, the most we
 | 
			
		||||
         * can do is to return 0 here.
 | 
			
		||||
         *
 | 
			
		||||
         * This will prevent stray -1 values to go to
 | 
			
		||||
         * virtio-serial-bus.c and cause abort()s in
 | 
			
		||||
         * do_flush_queued_data().
 | 
			
		||||
         */
 | 
			
		||||
        ret = 0;
 | 
			
		||||
    }
 | 
			
		||||
    return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue