From patchwork Sun May 8 18:29:37 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyrill Gorcunov X-Patchwork-Id: 766162 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p48ITlPo006779 for ; Sun, 8 May 2011 18:29:48 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755336Ab1EHS3o (ORCPT ); Sun, 8 May 2011 14:29:44 -0400 Received: from mail-ew0-f46.google.com ([209.85.215.46]:56667 "EHLO mail-ew0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754039Ab1EHS3n (ORCPT ); Sun, 8 May 2011 14:29:43 -0400 Received: by ewy4 with SMTP id 4so1364313ewy.19 for ; Sun, 08 May 2011 11:29:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:message-id:date:from:user-agent:mime-version:to :cc:subject:content-type:content-transfer-encoding; bh=Efi2A60KS1a9uX/TBxfKr9YJOqYpYQRzpjOqWShIktg=; b=bnKKJ3j4m6VkY9gVGlr46rg5AQ4XrhZoS8cuHFrDRRuTdYsIDvw5k/mPpqE6VCNetd b39QVXsHcbsGVgXL5DJ6yZx2edjgnUFXR/bH+DgzKSOPFjCWmEUh4GDoRB0BOXzt2ErY 8apnMIe6oyNY9sUC4nBjVhm7GUEWhgeD1OCnE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :content-type:content-transfer-encoding; b=smJAjwa5fqTI96sQhnSyiBN2fHOVPeVt9kuBOzWE7PV+5SnJiR6P1hrp+gbU3nnDVv Bn5vQ5tStAXfJxcCm/4GvjLytTKvPpvFNF5XoLz/QYjUNBfrskuokTeyUiTcaeLpJkyB zQZVfaPMoW/N4A5zCRlsSSxIoUSKF9+MAXllM= Received: by 10.14.2.65 with SMTP id 41mr1914717eee.222.1304879382616; Sun, 08 May 2011 11:29:42 -0700 (PDT) Received: from [10.10.0.150] (95-26-151-137.broadband.corbina.ru [95.26.151.137]) by mx.google.com with ESMTPS id n55sm2866683een.16.2011.05.08.11.29.39 (version=SSLv3 cipher=OTHER); Sun, 08 May 2011 11:29:40 -0700 (PDT) Message-ID: <4DC6E111.805@gmail.com> Date: Sun, 08 May 2011 22:29:37 +0400 From: Cyrill Gorcunov User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110424 Thunderbird/3.1.10 MIME-Version: 1.0 To: Pekka Enberg CC: Ingo Molnar , Asias He , Sasha Levin , Prasad Joshi , kvm-vger Subject: [PATCH] kvm tools: PCI -- Make PCI device numbers being unique Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Sun, 08 May 2011 18:29:48 +0000 (UTC) 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 --- 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(-) -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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); }