Skip to contentSkip to conversation

vhost-net: Move asserts to after check for end < start

PATCH In review Bruce Rogers 3 participants 3 messages Dec 16, 2011 – Apr 1, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vhost-net: Move asserts to after check for end < start

When migrating a vm using vhost-net we hit the following assertion:

qemu-kvm: /usr/src/packages/BUILD/qemu-kvm-0.15.1/hw/vhost.c:30:
vhost_dev_sync_region: Assertion `start / (0x1000 * (8 * sizeof(vhost_log_chunk_t))) < dev->log_size' failed.

The cases which the end < start check is intended to catch, such as for vga video memory, will also likely trigger the assertion. Reorder the code to handle this correctly.

---
 hw/vhost.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
hw/vhost.c +2 -2
index 0870cb7..7309f71 100644
@@ -26,11 +26,11 @@ static void vhost_dev_sync_region(struct vhost_dev *dev,
     vhost_log_chunk_t *to = dev->log + end / VHOST_LOG_CHUNK + 1;
     uint64_t addr = (start / VHOST_LOG_CHUNK) * VHOST_LOG_CHUNK;
 
-    assert(end / VHOST_LOG_CHUNK < dev->log_size);
-    assert(start / VHOST_LOG_CHUNK < dev->log_size);
     if (end < start) {
         return;
     }
+    assert(end / VHOST_LOG_CHUNK < dev->log_size);
+    assert(start / VHOST_LOG_CHUNK < dev->log_size);
     for (;from < to; ++from) {
         vhost_log_chunk_t log;
         int bit;
Signature · 1 line
1.7.7
#1 lore raw
Quoted 5 lines · Bruce Rogers

When migrating a vm using vhost-net we hit the following assertion:

qemu-kvm: /usr/src/packages/BUILD/qemu-kvm-0.15.1/hw/vhost.c:30:
vhost_dev_sync_region: Assertion `start / (0x1000 * (8 * sizeof(vhost_log_chunk_t)))< dev->log_size' failed.

I consistently hit this assert while testing live migration with qemu 1.0.1 and the master branch. Applying this patch allowed live migration to complete successfully. Maybe it could be reviewed and merged?

Quoted 27 lines

The cases which the end< start check is intended to catch, such as for vga video memory, will also likely trigger the assertion. Reorder the code to handle this correctly.

---
  hw/vhost.c |    4 ++--
  1 files changed, 2 insertions(+), 2 deletions(-)
hw/vhost.c +2 -2
index 0870cb7..7309f71 100644
@@ -26,11 +26,11 @@ static void vhost_dev_sync_region(struct vhost_dev *dev,
      vhost_log_chunk_t *to = dev->log + end / VHOST_LOG_CHUNK + 1;
      uint64_t addr = (start / VHOST_LOG_CHUNK) * VHOST_LOG_CHUNK;
 
-    assert(end / VHOST_LOG_CHUNK<  dev->log_size);
-    assert(start / VHOST_LOG_CHUNK<  dev->log_size);
      if (end<  start) {
          return;
      }
+    assert(end / VHOST_LOG_CHUNK<  dev->log_size);
+    assert(start / VHOST_LOG_CHUNK<  dev->log_size);
      for (;from<  to; ++from) {
          vhost_log_chunk_t log;
          int bit;
#2 lore raw
Quoted 11 lines · Josh Durgin
Quoted 5 lines · Bruce Rogers

When migrating a vm using vhost-net we hit the following assertion:

qemu-kvm: /usr/src/packages/BUILD/qemu-kvm-0.15.1/hw/vhost.c:30:
vhost_dev_sync_region: Assertion `start / (0x1000 * (8 * sizeof(vhost_log_chunk_t)))< dev->log_size' failed.

I consistently hit this assert while testing live migration with qemu 1.0.1 and the master branch. Applying this patch allowed live migration to complete successfully. Maybe it could be reviewed and merged?

Yes, thanks for the reminder. I've applied a patch by Alex Williamson that addresses this and other crashes.

Quoted 27 lines
Quoted 27 lines

The cases which the end< start check is intended to catch, such as for vga video memory, will also likely trigger the assertion. Reorder the code to handle this correctly.

---
 hw/vhost.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
hw/vhost.c +2 -2
index 0870cb7..7309f71 100644
@@ -26,11 +26,11 @@ static void vhost_dev_sync_region(struct vhost_dev *dev,
     vhost_log_chunk_t *to = dev->log + end / VHOST_LOG_CHUNK + 1;
     uint64_t addr = (start / VHOST_LOG_CHUNK) * VHOST_LOG_CHUNK;
 
-    assert(end / VHOST_LOG_CHUNK<  dev->log_size);
-    assert(start / VHOST_LOG_CHUNK<  dev->log_size);
     if (end<  start) {
         return;
     }
+    assert(end / VHOST_LOG_CHUNK<  dev->log_size);
+    assert(start / VHOST_LOG_CHUNK<  dev->log_size);
     for (;from<  to; ++from) {
         vhost_log_chunk_t log;
         int bit;