Skip to contentSkip to conversation

balloon: Do not save VM state wrt asynchronous virtio operations

PATCH Applied Adam Litke 3 participants 3 messages Mar 9, 2010 – Mar 17, 2010

lore
Share & tools
lore

Adam Litke

author
#0 lore raw

PATCH 1/1 balloon: Do not save VM state wrt asynchronous virtio operations

When working with the VM state (for loadvm/savevm and migration), it is not valid to load and store pointers since the validity of those pointers cannot be assured in the new qemu address space. Therefore, virtio_balloon_save() and virtio_balloon_load() must not handle the stats-related fields in struct VirtIOBalloon.

If a memory stats request is in-flight at the time of a migration or savevm, the request will not complete and should be resubmitted once migration or loadvm completes. Note that this extremely small race window can only be triggered using QMP so it is not possible to hang the user monitor.

hw/virtio-balloon.c +0 -9
index 086d9d1..6d12024 100644
@@ -261,10 +261,6 @@ static void virtio_balloon_save(QEMUFile *f, void *opaque)
 
     qemu_put_be32(f, s->num_pages);
     qemu_put_be32(f, s->actual);
-    qemu_put_buffer(f, (uint8_t *)&s->stats_vq_elem, sizeof(VirtQueueElement));
-    qemu_put_buffer(f, (uint8_t *)&s->stats_vq_offset, sizeof(size_t));
-    qemu_put_buffer(f, (uint8_t *)&s->stats_callback, sizeof(MonitorCompletion));
-    qemu_put_buffer(f, (uint8_t *)&s->stats_opaque_callback_data, sizeof(void));
 }
 
 static int virtio_balloon_load(QEMUFile *f, void *opaque, int version_id)
@@ -278,11 +274,6 @@ static int virtio_balloon_load(QEMUFile *f, void *opaque, int version_id)
 
     s->num_pages = qemu_get_be32(f);
     s->actual = qemu_get_be32(f);
-    qemu_get_buffer(f, (uint8_t *)&s->stats_vq_elem, sizeof(VirtQueueElement));
-    qemu_get_buffer(f, (uint8_t *)&s->stats_vq_offset, sizeof(size_t));
-    qemu_get_buffer(f, (uint8_t *)&s->stats_callback, sizeof(MonitorCompletion));
-    qemu_get_buffer(f, (uint8_t *)&s->stats_opaque_callback_data, sizeof(void));
-
     return 0;
 }
 
Signature · 2 lines
Thanks,
Adam
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Adam Litke

When working with the VM state (for loadvm/savevm and migration), it is not valid to load and store pointers since the validity of those pointers cannot be assured in the new qemu address space. Therefore, virtio_balloon_save() and virtio_balloon_load() must not handle the stats-related fields in struct VirtIOBalloon.

Quoted 6 lines

If a memory stats request is in-flight at the time of a migration or savevm, the request will not complete and should be resubmitted once migration or loadvm completes. Note that this extremely small race window can only be triggered using QMP so it is not possible to hang the user monitor.

#2 lore raw
In reply to Adam Litke
Quoted 6 lines · Adam Litke

When working with the VM state (for loadvm/savevm and migration), it is not valid to load and store pointers since the validity of those pointers cannot be assured in the new qemu address space. Therefore, virtio_balloon_save() and virtio_balloon_load() must not handle the stats-related fields in struct VirtIOBalloon.

Quoted 7 lines

If a memory stats request is in-flight at the time of a migration or savevm, the request will not complete and should be resubmitted once migration or loadvm completes. Note that this extremely small race window can only be triggered using QMP so it is not possible to hang the user monitor.

Applied. Thanks.

Regards,

Anthony Liguori

Quoted 30 lines
hw/virtio-balloon.c +0 -9
index 086d9d1..6d12024 100644
@@ -261,10 +261,6 @@ static void virtio_balloon_save(QEMUFile *f, void *opaque)
 
      qemu_put_be32(f, s->num_pages);
      qemu_put_be32(f, s->actual);
-    qemu_put_buffer(f, (uint8_t *)&s->stats_vq_elem, sizeof(VirtQueueElement));
-    qemu_put_buffer(f, (uint8_t *)&s->stats_vq_offset, sizeof(size_t));
-    qemu_put_buffer(f, (uint8_t *)&s->stats_callback, sizeof(MonitorCompletion));
-    qemu_put_buffer(f, (uint8_t *)&s->stats_opaque_callback_data, sizeof(void));
  }
 
  static int virtio_balloon_load(QEMUFile *f, void *opaque, int version_id)
@@ -278,11 +274,6 @@ static int virtio_balloon_load(QEMUFile *f, void *opaque, int version_id)
 
      s->num_pages = qemu_get_be32(f);
      s->actual = qemu_get_be32(f);
-    qemu_get_buffer(f, (uint8_t *)&s->stats_vq_elem, sizeof(VirtQueueElement));
-    qemu_get_buffer(f, (uint8_t *)&s->stats_vq_offset, sizeof(size_t));
-    qemu_get_buffer(f, (uint8_t *)&s->stats_callback, sizeof(MonitorCompletion));
-    qemu_get_buffer(f, (uint8_t *)&s->stats_opaque_callback_data, sizeof(void));
-
      return 0;
  }