Re: [PATCH v3 12/15] util: vfio-helpers: Implement ram_block_resized()

2020-03-02 Thread David Hildenbrand
On 28.02.20 22:01, Peter Xu wrote: > On Fri, Feb 28, 2020 at 09:16:28PM +0100, David Hildenbrand wrote: >> > > [...] > @@ -631,7 +658,7 @@ int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, size_t size, qemu_vfio_remove_mapping(s, mapping); go

Re: [PATCH v3 12/15] util: vfio-helpers: Implement ram_block_resized()

2020-02-28 Thread Peter Xu
On Fri, Feb 28, 2020 at 09:16:28PM +0100, David Hildenbrand wrote: > [...] > >> @@ -631,7 +658,7 @@ int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, > >> size_t size, > >> qemu_vfio_remove_mapping(s, mapping); > >> goto out; > >> } > >> -

Re: [PATCH v3 12/15] util: vfio-helpers: Implement ram_block_resized()

2020-02-28 Thread David Hildenbrand
> Am 28.02.2020 um 21:49 schrieb Peter Xu : > > On Fri, Feb 28, 2020 at 03:19:45PM -0500, David Hildenbrand wrote: >> >> Am 28.02.2020 um 20:55 schrieb Peter Xu : >>> >>> On Thu, Feb 27, 2020 at 11:12:02AM +0100, David Hildenbrand wrote: +static void qemu_vfio_dma_map_resize(QEMU

Re: [PATCH v3 12/15] util: vfio-helpers: Implement ram_block_resized()

2020-02-28 Thread Peter Xu
On Fri, Feb 28, 2020 at 03:19:45PM -0500, David Hildenbrand wrote: > > > > Am 28.02.2020 um 20:55 schrieb Peter Xu : > > > > On Thu, Feb 27, 2020 at 11:12:02AM +0100, David Hildenbrand wrote: > >> +static void qemu_vfio_dma_map_resize(QEMUVFIOState *s, void *host, > >> +

Re: [PATCH v3 12/15] util: vfio-helpers: Implement ram_block_resized()

2020-02-28 Thread David Hildenbrand
> Am 28.02.2020 um 20:55 schrieb Peter Xu : > > On Thu, Feb 27, 2020 at 11:12:02AM +0100, David Hildenbrand wrote: >> +static void qemu_vfio_dma_map_resize(QEMUVFIOState *s, void *host, >> + size_t old_size, size_t new_size) >> +{ >> +IOVAMapping *m; >> +

Re: [PATCH v3 12/15] util: vfio-helpers: Implement ram_block_resized()

2020-02-28 Thread David Hildenbrand
> Am 28.02.2020 um 20:43 schrieb Peter Xu : > > On Thu, Feb 27, 2020 at 11:12:02AM +0100, David Hildenbrand wrote: >> Let's implement ram_block_resized(), allowing resizeable mappings. >> >> For resizeable mappings, we reserve $max_size IOVA address space, but only >> map $size of it. When re

Re: [PATCH v3 12/15] util: vfio-helpers: Implement ram_block_resized()

2020-02-28 Thread Peter Xu
On Thu, Feb 27, 2020 at 11:12:02AM +0100, David Hildenbrand wrote: > +static void qemu_vfio_dma_map_resize(QEMUVFIOState *s, void *host, > + size_t old_size, size_t new_size) > +{ > +IOVAMapping *m; > +int index = 0; > + > +qemu_mutex_lock(&s->lock);

Re: [PATCH v3 12/15] util: vfio-helpers: Implement ram_block_resized()

2020-02-28 Thread Peter Xu
On Thu, Feb 27, 2020 at 11:12:02AM +0100, David Hildenbrand wrote: > Let's implement ram_block_resized(), allowing resizeable mappings. > > For resizeable mappings, we reserve $max_size IOVA address space, but only > map $size of it. When resizing, unmap the old part and remap the new > part. We'l

[PATCH v3 12/15] util: vfio-helpers: Implement ram_block_resized()

2020-02-27 Thread David Hildenbrand
Let's implement ram_block_resized(), allowing resizeable mappings. For resizeable mappings, we reserve $max_size IOVA address space, but only map $size of it. When resizing, unmap the old part and remap the new part. We'll need a new ioctl to do this atomically (e.g., to resize while the guest is