Re: [PATCH RFC 12/15] hw/virtio/vhost-user: send isolation regions to device
Connor Kite <[email protected]>
| Newsgroups | dev.linux.lists.virtio-fs,org.nongnu.qemu-devel |
|---|---|
| Message-ID | <CA+spn3q+mgPhnHYmge7BOoZYrKnBQk-fjOx-woF4LsNPy_70Qw@mail.gmail.com> |
On Tue, Jul 28, 2026 at 12:16 PM Stefan Hajnoczi <[email protected]> wrote: > > > > > -__attribute__((unused)) > > +struct iova_tree_traversal_args { > > QEMU coding style: > > typedef struct { > ... > } IOVATreeTraversalArgs; > ... Got it! This is now fixed. > > + VhostUserMsg *msg; > > + struct vhost_user *u; > > + int *fds; > > + size_t *fd_num; > > This field is also used to index into msg->payload.memory.regions[], so > "fd_num" is a misnomer. I suggest something like "region_idx" or just > "idx". > I'll rename it to idx since it acts as an index to multiple arrays. > > +}; > > + > > +static gboolean vhost_user_iova_tree_traverse_funct(gpointer key, > > + gpointer value, > > + gpointer data) > > +{ > > + struct iova_tree_traversal_args *args = data; > > + struct vhost_memory_region msg_region; > > + VhostUserMemoryRegion region_buffer; > > + DMAMap *map = key; > > + args->fds[*args->fd_num] = args->u->iso_memory.iso_fd; > > + > > + msg_region.guest_phys_addr = map->iova; > > + msg_region.memory_size = map->size + 1; > > + msg_region.userspace_addr = map->iova; > > + vhost_user_fill_msg_region_iso(®ion_buffer, args->u, &msg_region); > > + args->msg->payload.memory.regions[*args->fd_num] = region_buffer; > > I'm confused by this code. VhostUserMemoryRegion region_buffer is the > vhost-user protocol struct that is being filled in, but there is also a > struct vhost_memory_region msg_region from the Linux kernel headers? > > msg_region and vhost_user_fill_msg_region_iso() make it harder to see > what is going on. Can you open code the region_buffer struct field > assignments instead? > I've consolidated this code significantly now. Will delete vhost_user_fill_msg_region_iso as it's logic has been incorporated in the traversal callback.