qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v1 11/13] util: vfio-helpers: Implement ram_block_resized()


From: David Hildenbrand
Subject: [PATCH v1 11/13] util: vfio-helpers: Implement ram_block_resized()
Date: Mon, 3 Feb 2020 19:31:23 +0100

Let's implement ram_block_resized().

Note: Resizing is currently only allowed during reboot or when migration
starts.

Cc: "Dr. David Alan Gilbert" <address@hidden>
Cc: Paolo Bonzini <address@hidden>
Cc: Markus Armbruster <address@hidden>
Cc: Alex Williamson <address@hidden>
Signed-off-by: David Hildenbrand <address@hidden>
---
 util/vfio-helpers.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c
index 71e02e7f35..57d77e9480 100644
--- a/util/vfio-helpers.c
+++ b/util/vfio-helpers.c
@@ -395,11 +395,24 @@ static void qemu_vfio_ram_block_removed(RAMBlockNotifier 
*n,
     }
 }
 
+static void qemu_vfio_ram_block_resized(RAMBlockNotifier *n, void *host,
+                                        size_t oldsize, size_t newsize)
+{
+    QEMUVFIOState *s = container_of(n, QEMUVFIOState, ram_notifier);
+    if (host) {
+        trace_qemu_vfio_ram_block_resized(s, host, oldsize, newsize);
+        /* Note: Not atomic - we need a new ioctl for that. */
+        qemu_vfio_ram_block_removed(n, host, oldsize);
+        qemu_vfio_ram_block_added(n, host, newsize);
+    }
+}
+
 static void qemu_vfio_open_common(QEMUVFIOState *s)
 {
     qemu_mutex_init(&s->lock);
     s->ram_notifier.ram_block_added = qemu_vfio_ram_block_added;
     s->ram_notifier.ram_block_removed = qemu_vfio_ram_block_removed;
+    s->ram_notifier.ram_block_resized = qemu_vfio_ram_block_resized;
     s->low_water_mark = QEMU_VFIO_IOVA_MIN;
     s->high_water_mark = QEMU_VFIO_IOVA_MAX;
     ram_block_notifier_add(&s->ram_notifier);
-- 
2.24.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]