← Prev in month ← Prev in thread

virtio_scsi_cmd_req_cmd alignment

From
Michael S. Tsirkin
Date
2014-04-07T09:33:00+00:00
ID
Thread
virtio_scsi_cmd_req_cmd alignment
I just noticed that without a pack directive, the following is likely to cause compiler to add padding:  struct virtio_scsi_req_cmd {
// Device-readable part
u8 lun[8];
le64 id;
u8 task_attr;
u8 prio;
u8 crn;
u8 cdb[cdb_size];
u8 dataout[];
// Device-writable part
le32 sense_len;
le32 residual;
le16 status_qualifier;
u8 status;
u8 response;
u8 sense[sense_size];
u8 datain[]; };
if cdb_size is 32 and sense_size is 96 as spec suggests, and with no dataout and datain, padding will be added at the tail of structure unless suppressed e.g. using the packed directive.  In practice this is pseudo-code, but implementations might copy bits of this.  That's unfortunate, I really assumed balloon is the only instance where structure fields aren't naturally aligned. Should we do something with it for 1.0? Or is an implementation note in the spec enough?

--
MST
← Prev in month ← Prev in thread