On Tue, 31 Oct 2023 at 13:18, Kevin Wolf <[email protected]> wrote: > > Am 17.10.2023 um 16:01 hat Philippe Mathieu-Daudé geschrieben: > > Access QOM parent with the proper QOM VIRTIO_SCSI_COMMON() macro. > > > > Signed-off-by: Philippe Mathieu-Daudé <[email protected]> > > --- > > hw/scsi/virtio-scsi.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c > > index 45b95ea070..fa53f0902c 100644 > > --- a/hw/scsi/virtio-scsi.c > > +++ b/hw/scsi/virtio-scsi.c > > @@ -761,7 +761,7 @@ static void virtio_scsi_fail_cmd_req(VirtIOSCSIReq *req) > > > > static int virtio_scsi_handle_cmd_req_prepare(VirtIOSCSI *s, VirtIOSCSIReq > > *req) > > { > > - VirtIOSCSICommon *vs = &s->parent_obj; > > + VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s); > > SCSIDevice *d; > > int rc; > > Why is a dynamic cast more "proper" than a static type-safe access, even > more so in a hot I/O path?
I dunno, but it is absolutely the standard QOM style to use the cast macro to do the downcast, rather than fishing about in the struct for the parent_obj field. If QOM casts are getting too expensive we should ideally fix them rather than adding more and more code that takes some side route around them... thanks -- PMM
