public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Cyrill Gorcunov <gorcunov@gmail.com>
To: Pekka Enberg <penberg@kernel.org>
Cc: Ingo Molnar <mingo@elte.hu>, Asias He <asias.hejun@gmail.com>,
	Sasha Levin <levinsasha928@gmail.com>,
	Prasad Joshi <prasadjoshi124@gmail.com>,
	kvm-vger <kvm@vger.kernel.org>
Subject: [PATCH] kvm tools: PCI -- Make PCI device numbers being unique
Date: Sun, 08 May 2011 22:29:37 +0400	[thread overview]
Message-ID: <4DC6E111.805@gmail.com> (raw)

PCI device numbers must be unique on a bus (as a part
of Bus/Device/Function tuple). Make it so. Note the patch
is rather a fast fix since we need a bit more smart pci device
manager (in particular multiple virtio block devices most
probably should lay on a separate pci bus).

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
 tools/kvm/include/kvm/virtio-pci-dev.h |    5 +++++
 tools/kvm/virtio/blk.c                 |    2 +-
 tools/kvm/virtio/console.c             |    2 +-
 tools/kvm/virtio/net.c                 |    2 +-
 tools/kvm/virtio/rng.c                 |    2 +-
 5 files changed, 9 insertions(+), 4 deletions(-)

Index: linux-2.6.git/tools/kvm/include/kvm/virtio-pci-dev.h
=====================================================================
--- linux-2.6.git.orig/tools/kvm/include/kvm/virtio-pci-dev.h
+++ linux-2.6.git/tools/kvm/include/kvm/virtio-pci-dev.h
@@ -16,4 +16,9 @@
 #define PCI_SUBSYSTEM_ID_VIRTIO_CONSOLE		0x0003
 #define PCI_SUBSYSTEM_ID_VIRTIO_RNG		0x0004

+#define PCI_DEVICE_VIRTIO_NET			0x2
+#define PCI_DEVICE_VIRTIO_BLK			0x1
+#define PCI_DEVICE_VIRTIO_CONSOLE		0x3
+#define PCI_DEVICE_VIRTIO_RNG			0x4
+
 #endif /* VIRTIO_PCI_DEV_H_ */
Index: linux-2.6.git/tools/kvm/virtio/blk.c
=====================================================================
--- linux-2.6.git.orig/tools/kvm/virtio/blk.c
+++ linux-2.6.git/tools/kvm/virtio/blk.c
@@ -295,7 +295,7 @@ void virtio_blk__init(struct kvm *self,
 		},
 	};

-	if (irq__register_device(PCI_DEVICE_ID_VIRTIO_BLK, &dev, &pin, &line) < 0)
+	if (irq__register_device(PCI_DEVICE_VIRTIO_BLK, &dev, &pin, &line) < 0)
 		return;

 	bdev->pci_hdr.irq_pin	= pin;
Index: linux-2.6.git/tools/kvm/virtio/console.c
=====================================================================
--- linux-2.6.git.orig/tools/kvm/virtio/console.c
+++ linux-2.6.git/tools/kvm/virtio/console.c
@@ -238,7 +238,7 @@ void virtio_console__init(struct kvm *se
 {
 	u8 dev, line, pin;

-	if (irq__register_device(PCI_DEVICE_ID_VIRTIO_CONSOLE, &dev, &pin, &line) < 0)
+	if (irq__register_device(PCI_DEVICE_VIRTIO_CONSOLE, &dev, &pin, &line) < 0)
 		return;

 	virtio_console_pci_device.irq_pin	= pin;
Index: linux-2.6.git/tools/kvm/virtio/net.c
=====================================================================
--- linux-2.6.git.orig/tools/kvm/virtio/net.c
+++ linux-2.6.git/tools/kvm/virtio/net.c
@@ -385,7 +385,7 @@ void virtio_net__init(const struct virti
 	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(PCI_DEVICE_VIRTIO_NET, &dev, &pin, &line) < 0)
 			return;

 		virtio_net_pci_device.irq_pin	= pin;
Index: linux-2.6.git/tools/kvm/virtio/rng.c
=====================================================================
--- linux-2.6.git.orig/tools/kvm/virtio/rng.c
+++ linux-2.6.git/tools/kvm/virtio/rng.c
@@ -178,5 +178,5 @@ void virtio_rng__init(struct kvm *kvm)
 	virtio_rng_pci_device.irq_line	= line;
 	pci__register(&virtio_rng_pci_device, dev);

-	ioport__register(IOPORT_VIRTIO_RNG, &virtio_rng_io_ops, IOPORT_VIRTIO_RNG_SIZE);
+	ioport__register(PCI_DEVICE_VIRTIO_RNG, &virtio_rng_io_ops, IOPORT_VIRTIO_RNG_SIZE);
 }

             reply	other threads:[~2011-05-08 18:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-08 18:29 Cyrill Gorcunov [this message]
2011-05-08 18:48 ` [PATCH] kvm tools: PCI -- Make PCI device numbers being unique Sasha Levin
2011-05-08 18:54   ` Cyrill Gorcunov
2011-05-08 19:03     ` Cyrill Gorcunov
2011-05-09 19:53       ` Pekka Enberg
2011-05-09 20:10         ` Cyrill Gorcunov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4DC6E111.805@gmail.com \
    --to=gorcunov@gmail.com \
    --cc=asias.hejun@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=levinsasha928@gmail.com \
    --cc=mingo@elte.hu \
    --cc=penberg@kernel.org \
    --cc=prasadjoshi124@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox