From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NFto3-00041T-WF for qemu-devel@nongnu.org; Wed, 02 Dec 2009 13:20:04 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NFtnz-0003uj-TB for qemu-devel@nongnu.org; Wed, 02 Dec 2009 13:20:03 -0500 Received: from [199.232.76.173] (port=48637 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NFtnz-0003tq-9w for qemu-devel@nongnu.org; Wed, 02 Dec 2009 13:19:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57084) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NFtny-0004iB-Bc for qemu-devel@nongnu.org; Wed, 02 Dec 2009 13:19:58 -0500 From: Juan Quintela In-Reply-To: <20091202134153.GC18193@redhat.com> (Michael S. Tsirkin's message of "Wed, 2 Dec 2009 15:41:53 +0200") References: <20091202134153.GC18193@redhat.com> Date: Wed, 02 Dec 2009 19:19:17 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: [Qemu-devel] Re: [PATCH 06/41] virtio: Use DO_UPCAST instead of a cast List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: qemu-devel@nongnu.org "Michael S. Tsirkin" wrote: > On Wed, Dec 02, 2009 at 01:04:04PM +0100, Juan Quintela wrote: >> virtio_common_init() creates a struct with the right size, DO_UPCAST >> is the appropiate thing here >> >> Signed-off-by: Juan Quintela > > BTW why not container_of? That one does not require > field to be at the beginning of structure. VirtIO devices (and PCIDevices) are declared in this way: typedef struct VirtIOBalloon { VirtIODevice vdev; VirtQueue *ivq, *dvq; uint32_t num_pages; uint32_t actual; } VirtIOBalloon; I.e. the virtioDevice is always the 1st element, otherwise things don't work. There are code that requires it to be the 1st element. Later, Juan.