@@ -1,6 +1,8 @@
#ifndef VIRTIO_PCI_DEV_H_
#define VIRTIO_PCI_DEV_H_
+#include <linux/virtio_ids.h>
+
/*
* Virtio PCI device constants and resources
* they do use (such as irqs and pins).
@@ -11,11 +13,6 @@
#define PCI_DEVICE_ID_VIRTIO_CONSOLE 0x1003
#define PCI_DEVICE_ID_VIRTIO_RNG 0x1004
-#define PCI_SUBSYSTEM_ID_VIRTIO_NET 0x0001
-#define PCI_SUBSYSTEM_ID_VIRTIO_BLK 0x0002
-#define PCI_SUBSYSTEM_ID_VIRTIO_CONSOLE 0x0003
-#define PCI_SUBSYSTEM_ID_VIRTIO_RNG 0x0004
-
#define PCI_VENDOR_ID_REDHAT_QUMRANET 0x1af4
#define PCI_SUBSYSTEM_VENDOR_ID_REDHAT_QUMRANET 0x1af4
@@ -299,7 +299,7 @@ void virtio_blk__init(struct kvm *kvm, struct disk_image *disk)
.revision_id = 0,
.class = 0x010000,
.subsys_vendor_id = PCI_SUBSYSTEM_VENDOR_ID_REDHAT_QUMRANET,
- .subsys_id = PCI_SUBSYSTEM_ID_VIRTIO_BLK,
+ .subsys_id = VIRTIO_ID_BLOCK,
.bar[0] = blk_dev_base_addr | PCI_BASE_ADDRESS_SPACE_IO,
},
/*
@@ -310,7 +310,7 @@ void virtio_blk__init(struct kvm *kvm, struct disk_image *disk)
.host_features = (1UL << VIRTIO_BLK_F_SEG_MAX | 1UL << VIRTIO_BLK_F_FLUSH),
};
- if (irq__register_device(PCI_DEVICE_ID_VIRTIO_BLK, &dev, &pin, &line) < 0)
+ if (irq__register_device(VIRTIO_ID_BLOCK, &dev, &pin, &line) < 0)
return;
bdev->pci_hdr.irq_pin = pin;
@@ -35,7 +35,7 @@ static struct pci_device_header virtio_console_pci_device = {
.revision_id = 0,
.class = 0x078000,
.subsys_vendor_id = PCI_SUBSYSTEM_VENDOR_ID_REDHAT_QUMRANET,
- .subsys_id = PCI_SUBSYSTEM_ID_VIRTIO_CONSOLE,
+ .subsys_id = VIRTIO_ID_CONSOLE,
.bar[0] = IOPORT_VIRTIO_CONSOLE | PCI_BASE_ADDRESS_SPACE_IO,
};
@@ -244,7 +244,7 @@ void virtio_console__init(struct kvm *kvm)
{
u8 dev, line, pin;
- if (irq__register_device(PCI_DEVICE_ID_VIRTIO_CONSOLE, &dev, &pin, &line) < 0)
+ if (irq__register_device(VIRTIO_ID_CONSOLE, &dev, &pin, &line) < 0)
return;
virtio_console_pci_device.irq_pin = pin;
@@ -36,7 +36,7 @@ static struct pci_device_header pci_header = {
.revision_id = 0,
.class = 0x020000,
.subsys_vendor_id = PCI_SUBSYSTEM_VENDOR_ID_REDHAT_QUMRANET,
- .subsys_id = PCI_SUBSYSTEM_ID_VIRTIO_NET,
+ .subsys_id = VIRTIO_ID_NET,
.bar[0] = IOPORT_VIRTIO_NET | PCI_BASE_ADDRESS_SPACE_IO,
};
@@ -388,7 +388,7 @@ void virtio_net__init(const struct virtio_net_parameters *params)
if (virtio_net__tap_init(params)) {
u8 dev, line, pin;
- if (irq__register_device(PCI_DEVICE_ID_VIRTIO_NET, &dev, &pin, &line) < 0)
+ if (irq__register_device(VIRTIO_ID_NET, &dev, &pin, &line) < 0)
return;
pci_header.irq_pin = pin;
@@ -30,7 +30,7 @@ static struct pci_device_header virtio_rng_pci_device = {
.revision_id = 0,
.class = 0x010000,
.subsys_vendor_id = PCI_SUBSYSTEM_VENDOR_ID_REDHAT_QUMRANET,
- .subsys_id = PCI_SUBSYSTEM_ID_VIRTIO_RNG,
+ .subsys_id = VIRTIO_ID_RNG,
.bar[0] = IOPORT_VIRTIO_RNG | PCI_BASE_ADDRESS_SPACE_IO,
};
@@ -172,7 +172,7 @@ void virtio_rng__init(struct kvm *kvm)
if (rdev.fd < 0)
die("Failed initializing RNG");
- if (irq__register_device(PCI_DEVICE_ID_VIRTIO_RNG, &dev, &pin, &line) < 0)
+ if (irq__register_device(VIRTIO_ID_RNG, &dev, &pin, &line) < 0)
return;
virtio_rng_pci_device.irq_pin = pin;
Instead of redefining virtio IDs in our headers, use IDs defined in <linux/virtio_ids.h>. Signed-off-by: Sasha Levin <levinsasha928@gmail.com> --- tools/kvm/include/kvm/virtio-pci-dev.h | 7 ++----- tools/kvm/virtio/blk.c | 4 ++-- tools/kvm/virtio/console.c | 4 ++-- tools/kvm/virtio/net.c | 4 ++-- tools/kvm/virtio/rng.c | 4 ++-- 5 files changed, 10 insertions(+), 13 deletions(-)