Hi, > @@ -287,6 +287,12 @@ static void > virtio_gpu_resource_create_2d(VirtIOGPU *g, > struct virtio_gpu_resource_create_2d c2d; > > VIRTIO_GPU_FILL_CMD(c2d); > + > + c2d.resource_id = le32_to_cpu(c2d.resource_id); > + c2d.format = le32_to_cpu(c2d.format); > + c2d.width = le32_to_cpu(c2d.width); > + c2d.height = le32_to_cpu(c2d.height); > +
Please move this to a helper function, maybe by updating the VIRTIO_GPU_FILL_CMD macro. The header fields should be byteswapped too. As most structs have 32bit fields only (with the exception of hdr.fence_id) you should be able to create a generic byteswap function which only needs the struct size as argument and handles all structs without addresses/offsets (which are 64bit fields). The conversion looks incomplete, at least virtio_gpu_ctrl_response will need adaptions too. It probably works by luck because the guest driver uses fences only in virgl (3d) mode. cheers, Gerd