On 03.02.20 19:31, David Hildenbrand wrote:
> Let's implement ram_block_resized().
> 
> Note: Resizing is currently only allowed during reboot or when migration
> starts.
> 
> Cc: "Dr. David Alan Gilbert" <dgilb...@redhat.com>
> Cc: Paolo Bonzini <pbonz...@redhat.com>
> Cc: Markus Armbruster <arm...@redhat.com>
> Cc: Alex Williamson <alex.william...@redhat.com>
> Signed-off-by: David Hildenbrand <da...@redhat.com>
> ---
>  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);
> 

I'll most probably change the handling, to reserve the IOVA for max_size
of the ram block, but only map the usable size. Addresses in the IOVA
won't be reused.

If I am not wrong, hotplugging+unplugging DIMMs a couple of times can
easily eat up the whole IOVA. Same would be true on every resize.

At this point, I really detest ram block notifiers. :)

-- 
Thanks,

David / dhildenb


Reply via email to