From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37988) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxCeJ-0003w7-PM for qemu-devel@nongnu.org; Wed, 18 Jun 2014 05:59:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WxCeE-0003Mg-Cd for qemu-devel@nongnu.org; Wed, 18 Jun 2014 05:59:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:65454) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxCeE-0003MW-3h for qemu-devel@nongnu.org; Wed, 18 Jun 2014 05:59:18 -0400 From: Stefan Hajnoczi Date: Wed, 18 Jun 2014 17:58:29 +0800 Message-Id: <1403085516-10340-3-git-send-email-stefanha@redhat.com> In-Reply-To: <1403085516-10340-1-git-send-email-stefanha@redhat.com> References: <1403085516-10340-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PATCH v4 2/9] virtio-blk: avoid qdev property definition duplication List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: cornelia.huck@de.ibm.com, Paolo Bonzini , peter.crosthwaite@xilinx.com, Andreas Faerber , Stefan Hajnoczi It becomes unwiedly to duplicate all virtio-blk qdev property definitions due to an #ifdef. The C preprocessor syntax makes it a little hard to resolve this cleanly but we can extract the #ifdef and call a macro it defines later. Avoiding duplication is important since it will only get worse when we move the x-data-plane qdev property here too. We'd have a combinatorial explosion since x-data-plane has its own #ifdef. Suggested-by: Peter Crosthwaite Signed-off-by: Stefan Hajnoczi Reviewed-by: Peter Crosthwaite --- include/hw/virtio/virtio-blk.h | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/include/hw/virtio/virtio-blk.h b/include/hw/virtio/virtio-blk.h index 4bc9b54..7bafad5 100644 --- a/include/hw/virtio/virtio-blk.h +++ b/include/hw/virtio/virtio-blk.h @@ -137,21 +137,19 @@ typedef struct VirtIOBlock { DEFINE_VIRTIO_COMMON_FEATURES(_state, _field) #ifdef __linux__ -#define DEFINE_VIRTIO_BLK_PROPERTIES(_state, _field) \ - DEFINE_BLOCK_PROPERTIES(_state, _field.conf), \ - DEFINE_BLOCK_CHS_PROPERTIES(_state, _field.conf), \ - DEFINE_PROP_STRING("serial", _state, _field.serial), \ - DEFINE_PROP_BIT("config-wce", _state, _field.config_wce, 0, true), \ - DEFINE_PROP_BIT("scsi", _state, _field.scsi, 0, true), \ - DEFINE_PROP_IOTHREAD("x-iothread", _state, _field.iothread) +#define DEFINE_VIRTIO_BLK_PROPERTIES_LINUX(_state, _field) \ + DEFINE_PROP_BIT("scsi", _state, _field.scsi, 0, true), #else +#define DEFINE_VIRTIO_BLK_PROPERTIES_LINUX(_state, _field) +#endif + #define DEFINE_VIRTIO_BLK_PROPERTIES(_state, _field) \ + DEFINE_VIRTIO_BLK_PROPERTIES_LINUX(_state, _field) \ DEFINE_BLOCK_PROPERTIES(_state, _field.conf), \ DEFINE_BLOCK_CHS_PROPERTIES(_state, _field.conf), \ DEFINE_PROP_STRING("serial", _state, _field.serial), \ DEFINE_PROP_BIT("config-wce", _state, _field.config_wce, 0, true), \ DEFINE_PROP_IOTHREAD("x-iothread", _state, _field.iothread) -#endif /* __linux__ */ void virtio_blk_set_conf(DeviceState *dev, VirtIOBlkConf *blk); -- 1.9.3