Hi, On Monday, May 13, 2024 7:53:40 PM GMT+5:30 Eugenio Perez Martin wrote: > [...] > > I have started working on implementing packed virtqueue support in > > vhost-shadow-virtqueue.c. The changes I have made so far are very > > minimal. I have one confusion as well. > > > > In "vhost_svq_add()" [1], a structure of type "VhostShadowVirtqueue" > > is being used. My initial idea was to create a whole new structure (eg: > > VhostShadowVirtqueuePacked). But I realized that "VhostShadowVirtqueue" > > is being used in a lot of other places such as in "struct vhost_vdpa" [2] > > (in "vhost-vdpa.h"). So maybe this isn't a good idea. > > > > The problem is that "VhostShadowVirtqueue" has a member of type "struct > > vring" [3] which represents a split virtqueue [4]. My idea now is to > > instead wrap this member in a union so that the struct would look > > something like this. > > > > struct VhostShadowVirtqueue { > > union { > > struct vring vring; > > struct packed_vring vring; > > } > > ... > > } > > > > I am not entirely sure if this is a good idea. It is similar to what's > > been done in linux's "drivers/virtio/virtio_ring.c" ("struct > > vring_virtqueue" [5]). > > > > I thought I would ask this first before continuing further. > > That's right, this second option makes perfect sense. > > VhostShadowVirtqueue should abstract both split and packed. You'll see > that some members are reused, while others are only used in one > version so they are placed after a union. They should follow the same > pattern, although it is not a problem if we need to divert a little > bit from the kernel's code. >
Understood, thank you for the reply. Thanks, Sahil