From nobody Wed Nov 5 16:38:13 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1535543869946979.3232853375933; Wed, 29 Aug 2018 04:57:49 -0700 (PDT) Received: from localhost ([::1]:42522 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fuz6a-0002RZ-MW for importer@patchew.org; Wed, 29 Aug 2018 07:57:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42929) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fuyqt-0001kp-Bj for qemu-devel@nongnu.org; Wed, 29 Aug 2018 07:41:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fuynJ-0007N5-NO for qemu-devel@nongnu.org; Wed, 29 Aug 2018 07:37:55 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:51490 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fuynJ-0007Mx-HO for qemu-devel@nongnu.org; Wed, 29 Aug 2018 07:37:53 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 381A68077102 for ; Wed, 29 Aug 2018 11:37:53 +0000 (UTC) Received: from secure.mitica (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id F11982026D6D; Wed, 29 Aug 2018 11:37:51 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 29 Aug 2018 13:37:19 +0200 Message-Id: <20180829113730.14992-6-quintela@redhat.com> In-Reply-To: <20180829113730.14992-1-quintela@redhat.com> References: <20180829113730.14992-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 29 Aug 2018 11:37:53 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 29 Aug 2018 11:37:53 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'quintela@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 05/16] virtio: split virtio balloon bits from virtio-pci X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com, mst@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Juan Quintela Reviewed-by: Thomas Huth Signed-off-by: Juan Quintela --- hw/virtio/Makefile.objs | 1 + hw/virtio/virtio-balloon-pci.c | 94 ++++++++++++++++++++++++++++++++++ hw/virtio/virtio-pci.c | 58 --------------------- hw/virtio/virtio-pci.h | 14 ----- tests/Makefile.include | 4 +- 5 files changed, 97 insertions(+), 74 deletions(-) create mode 100644 hw/virtio/virtio-balloon-pci.c diff --git a/hw/virtio/Makefile.objs b/hw/virtio/Makefile.objs index 2efa544a2d..0f0b846a45 100644 --- a/hw/virtio/Makefile.objs +++ b/hw/virtio/Makefile.objs @@ -14,6 +14,7 @@ obj-$(CONFIG_VHOST_VSOCK) +=3D vhost-vsock.o vhost-vsock-= pci.o obj-$(CONFIG_VIRTIO_INPUT_HOST) +=3D virtio-input-host-pci.o obj-$(CONFIG_VIRTIO_INPUT) +=3D virtio-input-pci.o obj-$(CONFIG_VIRTIO_RNG) +=3D virtio-rng-pci.o +obj-$(CONFIG_VIRTIO_BALLOON) +=3D virtio-balloon-pci.o endif =20 common-obj-$(call lnot,$(call land,$(CONFIG_VIRTIO),$(CONFIG_LINUX))) +=3D= vhost-stub.o diff --git a/hw/virtio/virtio-balloon-pci.c b/hw/virtio/virtio-balloon-pci.c new file mode 100644 index 0000000000..2e9d92990b --- /dev/null +++ b/hw/virtio/virtio-balloon-pci.c @@ -0,0 +1,94 @@ +/* + * Virtio balloon PCI Bindings + * + * Copyright IBM, Corp. 2007 + * Copyright (c) 2009 CodeSourcery + * + * Authors: + * Anthony Liguori + * Paul Brook + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. + */ + +#include "qemu/osdep.h" + +#include "virtio-pci.h" +#include "hw/virtio/virtio-balloon.h" +#include "qapi/error.h" + +typedef struct VirtIOBalloonPCI VirtIOBalloonPCI; + +/* + * virtio-balloon-pci: This extends VirtioPCIProxy. + */ +#define TYPE_VIRTIO_BALLOON_PCI "virtio-balloon-pci" +#define VIRTIO_BALLOON_PCI(obj) \ + OBJECT_CHECK(VirtIOBalloonPCI, (obj), TYPE_VIRTIO_BALLOON_PCI) + +struct VirtIOBalloonPCI { + VirtIOPCIProxy parent_obj; + VirtIOBalloon vdev; +}; + +static Property virtio_balloon_pci_properties[] =3D { + DEFINE_PROP_UINT32("class", VirtIOPCIProxy, class_code, 0), + DEFINE_PROP_END_OF_LIST(), +}; + +static void virtio_balloon_pci_realize(VirtIOPCIProxy *vpci_dev, Error **e= rrp) +{ + VirtIOBalloonPCI *dev =3D VIRTIO_BALLOON_PCI(vpci_dev); + DeviceState *vdev =3D DEVICE(&dev->vdev); + + if (vpci_dev->class_code !=3D PCI_CLASS_OTHERS && + vpci_dev->class_code !=3D PCI_CLASS_MEMORY_RAM) { /* qemu < 1.1 */ + vpci_dev->class_code =3D PCI_CLASS_OTHERS; + } + + qdev_set_parent_bus(vdev, BUS(&vpci_dev->bus)); + object_property_set_bool(OBJECT(vdev), true, "realized", errp); +} + +static void virtio_balloon_pci_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + VirtioPCIClass *k =3D VIRTIO_PCI_CLASS(klass); + PCIDeviceClass *pcidev_k =3D PCI_DEVICE_CLASS(klass); + k->realize =3D virtio_balloon_pci_realize; + set_bit(DEVICE_CATEGORY_MISC, dc->categories); + dc->props =3D virtio_balloon_pci_properties; + pcidev_k->vendor_id =3D PCI_VENDOR_ID_REDHAT_QUMRANET; + pcidev_k->device_id =3D PCI_DEVICE_ID_VIRTIO_BALLOON; + pcidev_k->revision =3D VIRTIO_PCI_ABI_VERSION; + pcidev_k->class_id =3D PCI_CLASS_OTHERS; +} + +static void virtio_balloon_pci_instance_init(Object *obj) +{ + VirtIOBalloonPCI *dev =3D VIRTIO_BALLOON_PCI(obj); + + virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), + TYPE_VIRTIO_BALLOON); + object_property_add_alias(obj, "guest-stats", OBJECT(&dev->vdev), + "guest-stats", &error_abort); + object_property_add_alias(obj, "guest-stats-polling-interval", + OBJECT(&dev->vdev), + "guest-stats-polling-interval", &error_abort= ); +} + +static const TypeInfo virtio_balloon_pci_info =3D { + .name =3D TYPE_VIRTIO_BALLOON_PCI, + .parent =3D TYPE_VIRTIO_PCI, + .instance_size =3D sizeof(VirtIOBalloonPCI), + .instance_init =3D virtio_balloon_pci_instance_init, + .class_init =3D virtio_balloon_pci_class_init, +}; + +static void virtio_balloon_pci_register(void) +{ + type_register_static(&virtio_balloon_pci_info); +} + +type_init(virtio_balloon_pci_register) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 63700f5548..4bb2a5aab2 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -23,7 +23,6 @@ #include "hw/virtio/virtio-net.h" #include "hw/virtio/virtio-serial.h" #include "hw/virtio/virtio-scsi.h" -#include "hw/virtio/virtio-balloon.h" #include "hw/pci/pci.h" #include "qapi/error.h" #include "qemu/error-report.h" @@ -2237,62 +2236,6 @@ static const TypeInfo vhost_user_scsi_pci_info =3D { }; #endif =20 -/* virtio-balloon-pci */ - -static Property virtio_balloon_pci_properties[] =3D { - DEFINE_PROP_UINT32("class", VirtIOPCIProxy, class_code, 0), - DEFINE_PROP_END_OF_LIST(), -}; - -static void virtio_balloon_pci_realize(VirtIOPCIProxy *vpci_dev, Error **e= rrp) -{ - VirtIOBalloonPCI *dev =3D VIRTIO_BALLOON_PCI(vpci_dev); - DeviceState *vdev =3D DEVICE(&dev->vdev); - - if (vpci_dev->class_code !=3D PCI_CLASS_OTHERS && - vpci_dev->class_code !=3D PCI_CLASS_MEMORY_RAM) { /* qemu < 1.1 */ - vpci_dev->class_code =3D PCI_CLASS_OTHERS; - } - - qdev_set_parent_bus(vdev, BUS(&vpci_dev->bus)); - object_property_set_bool(OBJECT(vdev), true, "realized", errp); -} - -static void virtio_balloon_pci_class_init(ObjectClass *klass, void *data) -{ - DeviceClass *dc =3D DEVICE_CLASS(klass); - VirtioPCIClass *k =3D VIRTIO_PCI_CLASS(klass); - PCIDeviceClass *pcidev_k =3D PCI_DEVICE_CLASS(klass); - k->realize =3D virtio_balloon_pci_realize; - set_bit(DEVICE_CATEGORY_MISC, dc->categories); - dc->props =3D virtio_balloon_pci_properties; - pcidev_k->vendor_id =3D PCI_VENDOR_ID_REDHAT_QUMRANET; - pcidev_k->device_id =3D PCI_DEVICE_ID_VIRTIO_BALLOON; - pcidev_k->revision =3D VIRTIO_PCI_ABI_VERSION; - pcidev_k->class_id =3D PCI_CLASS_OTHERS; -} - -static void virtio_balloon_pci_instance_init(Object *obj) -{ - VirtIOBalloonPCI *dev =3D VIRTIO_BALLOON_PCI(obj); - - virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), - TYPE_VIRTIO_BALLOON); - object_property_add_alias(obj, "guest-stats", OBJECT(&dev->vdev), - "guest-stats", &error_abort); - object_property_add_alias(obj, "guest-stats-polling-interval", - OBJECT(&dev->vdev), - "guest-stats-polling-interval", &error_abort= ); -} - -static const TypeInfo virtio_balloon_pci_info =3D { - .name =3D TYPE_VIRTIO_BALLOON_PCI, - .parent =3D TYPE_VIRTIO_PCI, - .instance_size =3D sizeof(VirtIOBalloonPCI), - .instance_init =3D virtio_balloon_pci_instance_init, - .class_init =3D virtio_balloon_pci_class_init, -}; - /* virtio-serial-pci */ =20 static void virtio_serial_pci_realize(VirtIOPCIProxy *vpci_dev, Error **er= rp) @@ -2478,7 +2421,6 @@ static void virtio_pci_register_types(void) type_register_static(&vhost_user_blk_pci_info); #endif type_register_static(&virtio_scsi_pci_info); - type_register_static(&virtio_balloon_pci_info); type_register_static(&virtio_serial_pci_info); type_register_static(&virtio_net_pci_info); #ifdef CONFIG_VHOST_SCSI diff --git a/hw/virtio/virtio-pci.h b/hw/virtio/virtio-pci.h index 2415eb6a4d..093fde7f4f 100644 --- a/hw/virtio/virtio-pci.h +++ b/hw/virtio/virtio-pci.h @@ -20,7 +20,6 @@ #include "hw/virtio/virtio-net.h" #include "hw/virtio/virtio-serial.h" #include "hw/virtio/virtio-scsi.h" -#include "hw/virtio/virtio-balloon.h" #include "hw/virtio/virtio-bus.h" #include "hw/virtio/virtio-gpu.h" #include "hw/virtio/virtio-crypto.h" @@ -39,7 +38,6 @@ typedef struct VirtIOPCIProxy VirtIOPCIProxy; typedef struct VirtIOBlkPCI VirtIOBlkPCI; typedef struct VirtIOSCSIPCI VirtIOSCSIPCI; -typedef struct VirtIOBalloonPCI VirtIOBalloonPCI; typedef struct VirtIOSerialPCI VirtIOSerialPCI; typedef struct VirtIONetPCI VirtIONetPCI; typedef struct VHostSCSIPCI VHostSCSIPCI; @@ -264,18 +262,6 @@ struct VirtIOBlkPCI { VirtIOBlock vdev; }; =20 -/* - * virtio-balloon-pci: This extends VirtioPCIProxy. - */ -#define TYPE_VIRTIO_BALLOON_PCI "virtio-balloon-pci" -#define VIRTIO_BALLOON_PCI(obj) \ - OBJECT_CHECK(VirtIOBalloonPCI, (obj), TYPE_VIRTIO_BALLOON_PCI) - -struct VirtIOBalloonPCI { - VirtIOPCIProxy parent_obj; - VirtIOBalloon vdev; -}; - /* * virtio-serial-pci: This extends VirtioPCIProxy. */ diff --git a/tests/Makefile.include b/tests/Makefile.include index 739124b540..8c23270d4c 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -199,8 +199,8 @@ gcov-files-virtioserial-y +=3D hw/char/virtio-console.c gcov-files-virtio-y +=3D i386-softmmu/hw/virtio/virtio.c check-qtest-virtio-y +=3D tests/virtio-net-test$(EXESUF) gcov-files-virtio-y +=3D i386-softmmu/hw/net/virtio-net.c -check-qtest-virtio-y +=3D tests/virtio-balloon-test$(EXESUF) -gcov-files-virtio-y +=3D i386-softmmu/hw/virtio/virtio-balloon.c +check-qtest-virtio-$(CONFIG_VIRTIO_BALLOON) +=3D tests/virtio-balloon-test= $(EXESUF) +gcov-files-virtio-$(CONFIG_VIRTIO_BALLOON) +=3D i386-softmmu/hw/virtio/vir= tio-balloon.c check-qtest-virtio-y +=3D tests/virtio-blk-test$(EXESUF) gcov-files-virtio-y +=3D i386-softmmu/hw/block/virtio-blk.c check-qtest-virtio-$(CONFIG_VIRTIO_RNG) +=3D tests/virtio-rng-test$(EXESUF) --=20 2.17.1