From patchwork Tue May 19 10:44:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 473814 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 036781400B7 for ; Tue, 19 May 2015 20:46:46 +1000 (AEST) Received: from localhost ([::1]:44928 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yuf2q-0007dN-8I for incoming@patchwork.ozlabs.org; Tue, 19 May 2015 06:46:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47847) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yuf1H-0004w8-6Q for qemu-devel@nongnu.org; Tue, 19 May 2015 06:45:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yuf1B-0004eG-Eg for qemu-devel@nongnu.org; Tue, 19 May 2015 06:45:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53009) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yuf1B-0004ba-7S for qemu-devel@nongnu.org; Tue, 19 May 2015 06:45:01 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id CFC2B6C; Tue, 19 May 2015 10:45:00 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-19.ams2.redhat.com [10.36.116.19]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t4JAixSn020038; Tue, 19 May 2015 06:44:59 -0400 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id DBD64833BF; Tue, 19 May 2015 12:44:58 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 19 May 2015 12:44:56 +0200 Message-Id: <1432032297-10005-3-git-send-email-kraxel@redhat.com> In-Reply-To: <1432032297-10005-1-git-send-email-kraxel@redhat.com> References: <1432032297-10005-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Gonglei , Gerd Hoffmann Subject: [Qemu-devel] [PULL 2/3] qxl: QOMify 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 From: Gonglei Signed-off-by: Gonglei Signed-off-by: Gerd Hoffmann --- hw/display/qxl.c | 44 ++++++++++++++++++++++++++------------------ hw/display/qxl.h | 3 +++ 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/hw/display/qxl.c b/hw/display/qxl.c index 0cd314c..8f40dfb 100644 --- a/hw/display/qxl.c +++ b/hw/display/qxl.c @@ -1181,7 +1181,7 @@ static void qxl_hard_reset(PCIQXLDevice *d, int loadvm) static void qxl_reset_handler(DeviceState *dev) { - PCIQXLDevice *d = DO_UPCAST(PCIQXLDevice, pci.qdev, dev); + PCIQXLDevice *d = PCI_QXL(PCI_DEVICE(dev)); qxl_hard_reset(d, 0); } @@ -2026,7 +2026,7 @@ static void qxl_realize_common(PCIQXLDevice *qxl, Error **errp) static void qxl_realize_primary(PCIDevice *dev, Error **errp) { - PCIQXLDevice *qxl = DO_UPCAST(PCIQXLDevice, pci, dev); + PCIQXLDevice *qxl = PCI_QXL(dev); VGACommonState *vga = &qxl->vga; Error *local_err = NULL; @@ -2059,7 +2059,7 @@ static void qxl_realize_primary(PCIDevice *dev, Error **errp) static void qxl_realize_secondary(PCIDevice *dev, Error **errp) { static int device_id = 1; - PCIQXLDevice *qxl = DO_UPCAST(PCIQXLDevice, pci, dev); + PCIQXLDevice *qxl = PCI_QXL(dev); qxl->id = device_id++; qxl_init_ramsize(qxl); @@ -2277,28 +2277,42 @@ static Property qxl_properties[] = { DEFINE_PROP_END_OF_LIST(), }; -static void qxl_primary_class_init(ObjectClass *klass, void *data) +static void qxl_pci_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); - k->realize = qxl_realize_primary; - k->romfile = "vgabios-qxl.bin"; k->vendor_id = REDHAT_PCI_VENDOR_ID; k->device_id = QXL_DEVICE_ID_STABLE; - k->class_id = PCI_CLASS_DISPLAY_VGA; set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories); - dc->desc = "Spice QXL GPU (primary, vga compatible)"; dc->reset = qxl_reset_handler; dc->vmsd = &qxl_vmstate; dc->props = qxl_properties; +} + +static const TypeInfo qxl_pci_type_info = { + .name = TYPE_PCI_QXL, + .parent = TYPE_PCI_DEVICE, + .instance_size = sizeof(PCIQXLDevice), + .abstract = true, + .class_init = qxl_pci_class_init, +}; + +static void qxl_primary_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); + + k->realize = qxl_realize_primary; + k->romfile = "vgabios-qxl.bin"; + k->class_id = PCI_CLASS_DISPLAY_VGA; + dc->desc = "Spice QXL GPU (primary, vga compatible)"; dc->hotpluggable = false; } static const TypeInfo qxl_primary_info = { .name = "qxl-vga", - .parent = TYPE_PCI_DEVICE, - .instance_size = sizeof(PCIQXLDevice), + .parent = TYPE_PCI_QXL, .class_init = qxl_primary_class_init, }; @@ -2308,25 +2322,19 @@ static void qxl_secondary_class_init(ObjectClass *klass, void *data) PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); k->realize = qxl_realize_secondary; - k->vendor_id = REDHAT_PCI_VENDOR_ID; - k->device_id = QXL_DEVICE_ID_STABLE; k->class_id = PCI_CLASS_DISPLAY_OTHER; - set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories); dc->desc = "Spice QXL GPU (secondary)"; - dc->reset = qxl_reset_handler; - dc->vmsd = &qxl_vmstate; - dc->props = qxl_properties; } static const TypeInfo qxl_secondary_info = { .name = "qxl", - .parent = TYPE_PCI_DEVICE, - .instance_size = sizeof(PCIQXLDevice), + .parent = TYPE_PCI_QXL, .class_init = qxl_secondary_class_init, }; static void qxl_register_types(void) { + type_register_static(&qxl_pci_type_info); type_register_static(&qxl_primary_info); type_register_static(&qxl_secondary_info); } diff --git a/hw/display/qxl.h b/hw/display/qxl.h index 412e346..deddd54 100644 --- a/hw/display/qxl.h +++ b/hw/display/qxl.h @@ -122,6 +122,9 @@ typedef struct PCIQXLDevice { QEMUBH *update_area_bh; } PCIQXLDevice; +#define TYPE_PCI_QXL "pci-qxl" +#define PCI_QXL(obj) OBJECT_CHECK(PCIQXLDevice, (obj), TYPE_PCI_QXL) + #define PANIC_ON(x) if ((x)) { \ printf("%s: PANIC %s failed\n", __FUNCTION__, #x); \ abort(); \