[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/3] vhost: don't exit on memory errors
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PATCH 2/3] vhost: don't exit on memory errors |
Date: |
Mon, 28 Mar 2011 23:14:22 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
When memory including one of the VQs
goes away, handle that as a guest error
instead of exiting qemu.
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
hw/vhost.c | 8 +++++---
hw/vhost.h | 1 +
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/hw/vhost.c b/hw/vhost.c
index 97a1299..c17a831 100644
--- a/hw/vhost.c
+++ b/hw/vhost.c
@@ -287,11 +287,11 @@ static int vhost_verify_ring_mappings(struct vhost_dev
*dev,
l = vq->ring_size;
p = cpu_physical_memory_map(vq->ring_phys, &l, 1);
if (!p || l != vq->ring_size) {
- fprintf(stderr, "Unable to map ring buffer for ring %d\n", i);
+ virtio_error(dev->vdev, "Unable to map ring buffer for ring %d\n",
i);
return -ENOMEM;
}
if (p != vq->ring) {
- fprintf(stderr, "Ring buffer relocated for ring %d\n", i);
+ virtio_error(dev->vdev, "Ring buffer relocated for ring %d\n", i);
return -EBUSY;
}
cpu_physical_memory_unmap(p, l, 0, 0);
@@ -330,7 +330,9 @@ static void vhost_client_set_memory(CPUPhysMemoryClient
*client,
if (dev->started) {
r = vhost_verify_ring_mappings(dev, start_addr, size);
- assert(r >= 0);
+ if (r < 0) {
+ return;
+ }
}
if (!dev->log_enabled) {
diff --git a/hw/vhost.h b/hw/vhost.h
index c8c595a..90b5bc8 100644
--- a/hw/vhost.h
+++ b/hw/vhost.h
@@ -39,6 +39,7 @@ struct vhost_dev {
vhost_log_chunk_t *log;
unsigned long long log_size;
bool force;
+ VirtIODevice *vdev;
};
int vhost_dev_init(struct vhost_dev *hdev, int devfd, bool force);
--
1.7.3.2.91.g446ac