Received: from eggs.gnu.org ([140.186.70.92]:52032) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QJi5e-0004cH-JF for qemu-devel@nongnu.org; Tue, 10 May 2011 04:14:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QJi5d-0008Ks-Bb for qemu-devel@nongnu.org; Tue, 10 May 2011 04:14:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50954) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QJi5d-0008Kl-1J for qemu-devel@nongnu.org; Tue, 10 May 2011 04:14:45 -0400 From: Markus Armbruster References: <1304934694-13432-1-git-send-email-armbru@redhat.com> <1304934694-13432-2-git-send-email-armbru@redhat.com> <4DC7D70F.3030103@redhat.com> Date: Tue, 10 May 2011 10:14:40 +0200 In-Reply-To: <4DC7D70F.3030103@redhat.com> (Gerd Hoffmann's message of "Mon, 09 May 2011 13:59:11 +0200") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [PATCH v2 1/5] ide: Split qdev "ide-drive" into "ide-hd" and "ide-cd" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: kwolf@redhat.com, qemu-devel@nongnu.org, hch@lst.de Gerd Hoffmann writes: > Hi, > >> +#define DEFINE_IDE_DEV_PROPERTIES() \ >> + DEFINE_PROP_UINT32("unit", IDEDrive, dev.unit, -1), \ >> + DEFINE_BLOCK_PROPERTIES(IDEDrive, dev.conf), \ >> + DEFINE_PROP_STRING("ver", IDEDrive, dev.version), \ >> + DEFINE_PROP_STRING("serial", IDEDrive, dev.serial) > > This can also be done this way: > > static Property ide_properties[] = { > DEFINE_PROP_UINT32("unit", IDEDrive, dev.unit, -1), > [ ... ] > DEFINE_PROP_END_OF_LIST(), > }; > >> +static IDEDeviceInfo ide_dev_info[] = { >> + { >> + .qdev.name = "ide-hd", >> + .qdev.fw_name = "drive", >> + .qdev.desc = "virtual IDE disk", >> + .qdev.size = sizeof(IDEDrive), >> + .init = ide_hd_initfn, > > .qdev.props = ide_properties, > > Works only as long as all devices have exactly the same set (i.e. for > scsi it wouldn't work as not all devices have the "removable" > property). > > I tend to like this more than the #define. YMMV, matter of taste. In general, I prefer shared variables rather to duplication via #define, too. But in this case, I went with #define anyway, so we don't have to change from variable to #define when a device-specific property comes along, and for consistency with scsi-disk.c (whatever that's worth).