virtio-net: handle virtio_net_handle_ctrl() error
This error is caused by a buggy guest: let's switch the device to the broken state instead of terminating QEMU. Also we detach the element from the virtqueue and free it. Signed-off-by: Greg Kurz <groug@kaod.org> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
		
							parent
							
								
									20ea686a0c
								
							
						
					
					
						commit
						ba7eadb592
					
				| 
						 | 
				
			
			@ -880,6 +880,7 @@ static int virtio_net_handle_mq(VirtIONet *n, uint8_t cmd,
 | 
			
		|||
 | 
			
		||||
    return VIRTIO_NET_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void virtio_net_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
 | 
			
		||||
{
 | 
			
		||||
    VirtIONet *n = VIRTIO_NET(vdev);
 | 
			
		||||
| 
						 | 
				
			
			@ -897,8 +898,10 @@ static void virtio_net_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
 | 
			
		|||
        }
 | 
			
		||||
        if (iov_size(elem->in_sg, elem->in_num) < sizeof(status) ||
 | 
			
		||||
            iov_size(elem->out_sg, elem->out_num) < sizeof(ctrl)) {
 | 
			
		||||
            error_report("virtio-net ctrl missing headers");
 | 
			
		||||
            exit(1);
 | 
			
		||||
            virtio_error(vdev, "virtio-net ctrl missing headers");
 | 
			
		||||
            virtqueue_detach_element(vq, elem, 0);
 | 
			
		||||
            g_free(elem);
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        iov_cnt = elem->out_num;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue