Received: from eggs.gnu.org ([2001:4830:134:3::10]:38011) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aK3hd-0004BQ-Rv for qemu-devel@nongnu.org; Fri, 15 Jan 2016 07:42:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aK3ha-0005Zm-PK for qemu-devel@nongnu.org; Fri, 15 Jan 2016 07:42:05 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45035) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aK3ha-0005Zi-KZ for qemu-devel@nongnu.org; Fri, 15 Jan 2016 07:42:02 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 453EF8F028 for ; Fri, 15 Jan 2016 12:42:02 +0000 (UTC) From: Paolo Bonzini Date: Fri, 15 Jan 2016 13:41:49 +0100 Message-Id: <1452861718-25806-2-git-send-email-pbonzini@redhat.com> In-Reply-To: <1452861718-25806-1-git-send-email-pbonzini@redhat.com> References: <1452861718-25806-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 01/10] virtio: move VirtQueueElement at the beginning of the structs List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: mst@redhat.com The next patch will make virtqueue_pop/vring_pop allocate memory for a "subclass" of VirtQueueElement. For this to work, VirtQueueElement must be the first field in the containing struct. Signed-off-by: Paolo Bonzini --- hw/scsi/virtio-scsi.c | 3 +-- include/hw/virtio/virtio-blk.h | 2 +- include/hw/virtio/virtio-scsi.h | 13 ++++++------- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index 3a4f520..1567da8 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -44,8 +44,7 @@ VirtIOSCSIReq *virtio_scsi_init_req(VirtIOSCSI *s, VirtQueue *vq) { VirtIOSCSIReq *req; VirtIOSCSICommon *vs = (VirtIOSCSICommon *)s; - const size_t zero_skip = offsetof(VirtIOSCSIReq, elem) - + sizeof(VirtQueueElement); + const size_t zero_skip = offsetof(VirtIOSCSIReq, vring); req = g_malloc(sizeof(*req) + vs->cdb_size); req->vq = vq; diff --git a/include/hw/virtio/virtio-blk.h b/include/hw/virtio/virtio-blk.h index ae11a63..403ab86 100644 --- a/include/hw/virtio/virtio-blk.h +++ b/include/hw/virtio/virtio-blk.h @@ -60,9 +60,9 @@ typedef struct VirtIOBlock { } VirtIOBlock; typedef struct VirtIOBlockReq { + VirtQueueElement elem; int64_t sector_num; VirtIOBlock *dev; - VirtQueueElement elem; struct virtio_blk_inhdr *in; struct virtio_blk_outhdr out; QEMUIOVector qiov; diff --git a/include/hw/virtio/virtio-scsi.h b/include/hw/virtio/virtio-scsi.h index 088fe9f..63f5b51 100644 --- a/include/hw/virtio/virtio-scsi.h +++ b/include/hw/virtio/virtio-scsi.h @@ -102,18 +102,17 @@ typedef struct VirtIOSCSI { } VirtIOSCSI; typedef struct VirtIOSCSIReq { + /* Note: + * - fields up to resp_iov are initialized by virtio_scsi_init_req; + * - fields starting at vring are zeroed by virtio_scsi_init_req. + * */ + VirtQueueElement elem; + VirtIOSCSI *dev; VirtQueue *vq; QEMUSGList qsgl; QEMUIOVector resp_iov; - /* Note: - * - fields before elem are initialized by virtio_scsi_init_req; - * - elem is uninitialized at the time of allocation. - * - fields after elem are zeroed by virtio_scsi_init_req. - * */ - - VirtQueueElement elem; /* Set by dataplane code. */ VirtIOSCSIVring *vring; -- 2.5.0