aboutsummaryrefslogtreecommitdiff
path: root/hw/virtio
diff options
context:
space:
mode:
Diffstat (limited to 'hw/virtio')
-rw-r--r--hw/virtio/virtio-mem.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
index ec0ae32..a922c21 100644
--- a/hw/virtio/virtio-mem.c
+++ b/hw/virtio/virtio-mem.c
@@ -621,20 +621,20 @@ static int virtio_mem_unplug_all(VirtIOMEM *vmem)
{
RAMBlock *rb = vmem->memdev->mr.ram_block;
- if (virtio_mem_is_busy()) {
- return -EBUSY;
- }
-
- if (ram_block_discard_range(rb, 0, qemu_ram_get_used_length(rb))) {
- return -EBUSY;
- }
- virtio_mem_notify_unplug_all(vmem);
-
- bitmap_clear(vmem->bitmap, 0, vmem->bitmap_size);
if (vmem->size) {
+ if (virtio_mem_is_busy()) {
+ return -EBUSY;
+ }
+ if (ram_block_discard_range(rb, 0, qemu_ram_get_used_length(rb))) {
+ return -EBUSY;
+ }
+ virtio_mem_notify_unplug_all(vmem);
+
+ bitmap_clear(vmem->bitmap, 0, vmem->bitmap_size);
vmem->size = 0;
notifier_list_notify(&vmem->size_change_notifiers, &vmem->size);
}
+
trace_virtio_mem_unplugged_all();
virtio_mem_resize_usable_region(vmem, vmem->requested_size, true);
return 0;