From patchwork Thu Aug 1 02:17:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 263864 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 99C712C00AF for ; Thu, 1 Aug 2013 12:20:28 +1000 (EST) Received: from localhost ([::1]:36767 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V4iV8-0006bi-B9 for incoming@patchwork.ozlabs.org; Wed, 31 Jul 2013 22:20:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47181) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V4iSl-0003Pp-Oy for qemu-devel@nongnu.org; Wed, 31 Jul 2013 22:18:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V4iSe-0006Gw-Ay for qemu-devel@nongnu.org; Wed, 31 Jul 2013 22:17:59 -0400 Received: from cantor2.suse.de ([195.135.220.15]:60971 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V4iSe-0006Gn-52 for qemu-devel@nongnu.org; Wed, 31 Jul 2013 22:17:52 -0400 Received: from relay1.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 818C2A51FF; Thu, 1 Aug 2013 04:17:51 +0200 (CEST) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Thu, 1 Aug 2013 04:17:26 +0200 Message-Id: <1375323463-32747-6-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1375323463-32747-1-git-send-email-afaerber@suse.de> References: <1375323463-32747-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 195.135.220.15 Cc: Anthony Liguori , =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [Qemu-devel] [PATCH for-next v2 05/22] virtio: Allow NULL VirtioDeviceClass::init hook X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This is a temporary measure to allow mixing VirtioDeviceClass::init with DeviceClass::realize. Clean up variable naming in preparation for QOM realize. Signed-off-by: Andreas Färber --- hw/virtio/virtio.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 09f62c6..c00c224 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -1139,13 +1139,15 @@ void virtio_device_set_child_bus_name(VirtIODevice *vdev, char *bus_name) } } -static int virtio_device_init(DeviceState *qdev) +static int virtio_device_init(DeviceState *dev) { - VirtIODevice *vdev = VIRTIO_DEVICE(qdev); - VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(qdev); - assert(k->init != NULL); - if (k->init(vdev) < 0) { - return -1; + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(dev); + + if (vdc->init != NULL) { + if (vdc->init(vdev) < 0) { + return -1; + } } virtio_bus_plug_device(vdev); return 0;