tests: acpi: add pvpanic-isa: testcase
[qemu.git] / hw / virtio / virtio-balloon-pci.c
blobce2645ba7187b01b344ab27330a8b6d5a28a8ec3
1 /*
2 * Virtio balloon PCI Bindings
4 * Copyright IBM, Corp. 2007
5 * Copyright (c) 2009 CodeSourcery
7 * Authors:
8 * Anthony Liguori <aliguori@us.ibm.com>
9 * Paul Brook <paul@codesourcery.com>
11 * Contributions after 2012-01-13 are licensed under the terms of the
12 * GNU GPL, version 2 or (at your option) any later version.
15 #include "qemu/osdep.h"
17 #include "hw/virtio/virtio-pci.h"
18 #include "hw/qdev-properties.h"
19 #include "hw/virtio/virtio-balloon.h"
20 #include "qapi/error.h"
21 #include "qemu/module.h"
22 #include "qom/object.h"
24 typedef struct VirtIOBalloonPCI VirtIOBalloonPCI;
27 * virtio-balloon-pci: This extends VirtioPCIProxy.
29 #define TYPE_VIRTIO_BALLOON_PCI "virtio-balloon-pci-base"
30 DECLARE_INSTANCE_CHECKER(VirtIOBalloonPCI, VIRTIO_BALLOON_PCI,
31 TYPE_VIRTIO_BALLOON_PCI)
33 struct VirtIOBalloonPCI {
34 VirtIOPCIProxy parent_obj;
35 VirtIOBalloon vdev;
38 static void virtio_balloon_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
40 VirtIOBalloonPCI *dev = VIRTIO_BALLOON_PCI(vpci_dev);
41 DeviceState *vdev = DEVICE(&dev->vdev);
43 vpci_dev->class_code = PCI_CLASS_OTHERS;
44 qdev_realize(vdev, BUS(&vpci_dev->bus), errp);
47 static void virtio_balloon_pci_class_init(ObjectClass *klass, void *data)
49 DeviceClass *dc = DEVICE_CLASS(klass);
50 VirtioPCIClass *k = VIRTIO_PCI_CLASS(klass);
51 PCIDeviceClass *pcidev_k = PCI_DEVICE_CLASS(klass);
52 k->realize = virtio_balloon_pci_realize;
53 set_bit(DEVICE_CATEGORY_MISC, dc->categories);
54 pcidev_k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET;
55 pcidev_k->device_id = PCI_DEVICE_ID_VIRTIO_BALLOON;
56 pcidev_k->revision = VIRTIO_PCI_ABI_VERSION;
57 pcidev_k->class_id = PCI_CLASS_OTHERS;
60 static void virtio_balloon_pci_instance_init(Object *obj)
62 VirtIOBalloonPCI *dev = VIRTIO_BALLOON_PCI(obj);
64 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
65 TYPE_VIRTIO_BALLOON);
66 object_property_add_alias(obj, "guest-stats", OBJECT(&dev->vdev),
67 "guest-stats");
68 object_property_add_alias(obj, "guest-stats-polling-interval",
69 OBJECT(&dev->vdev),
70 "guest-stats-polling-interval");
73 static const VirtioPCIDeviceTypeInfo virtio_balloon_pci_info = {
74 .base_name = TYPE_VIRTIO_BALLOON_PCI,
75 .generic_name = "virtio-balloon-pci",
76 .transitional_name = "virtio-balloon-pci-transitional",
77 .non_transitional_name = "virtio-balloon-pci-non-transitional",
78 .instance_size = sizeof(VirtIOBalloonPCI),
79 .instance_init = virtio_balloon_pci_instance_init,
80 .class_init = virtio_balloon_pci_class_init,
83 static void virtio_balloon_pci_register(void)
85 virtio_pci_types_register(&virtio_balloon_pci_info);
88 type_init(virtio_balloon_pci_register)