From 3f1ea7820b56fdbf3679eea7a7c1299934e4cfc8 Mon Sep 17 00:00:00 2001
From: Marcel Apfelbaum <marcel.a@redhat.com>
Date: Thu, 5 Jun 2014 07:09:15 +0200
Subject: [PATCH 6/9] pci: fix info pci with host bridge.

RH-Author: Marcel Apfelbaum <marcel.a@redhat.com>
Message-id: <1401952158-29608-5-git-send-email-marcel.a@redhat.com>
Patchwork-id: 59150
O-Subject: [RHEL-6.6 qemu-kvm PATCH v5 4/7] pci: fix info pci with host bridge.
Bugzilla: 813748
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
RH-Acked-by: Luiz Capitulino <lcapitulino@redhat.com>

This patch fixes 525e05147d5a3bdc08caa422d108c1ef71b584b5.
pci host bridge doesn't have header type of bridge.
The check should be by header type, instead of pci class device.

Cc: Blue Swirl <blauwirbel@gmail.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
(cherry picked from commit b5937f297819bec5bf704dda1df9807fc7f0a766)
Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
---
 hw/pci.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Signed-off-by: jen <jen@redhat.com>
---
 hw/pci.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/pci.c b/hw/pci.c
index 9664c71..3d856d8 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -1422,7 +1422,7 @@ static QObject *pci_get_devices_list(PCIBus *bus, int bus_num);
 
 static QObject *pci_get_dev_dict(PCIDevice *dev, PCIBus *bus, int bus_num)
 {
-    int class;
+    uint8_t type;
     QObject *obj;
 
     obj = qobject_from_jsonf("{ 'bus': %d, 'slot': %d, 'function': %d,"                                       "'class_info': %p, 'id': %p, 'regions': %p,"
@@ -1438,8 +1438,8 @@ static QObject *pci_get_dev_dict(PCIDevice *dev, PCIBus *bus, int bus_num)
         qdict_put(qdict, "irq", qint_from_int(dev->config[PCI_INTERRUPT_LINE]));
     }
 
-    class = pci_get_word(dev->config + PCI_CLASS_DEVICE);
-    if (class == PCI_CLASS_BRIDGE_HOST || class == PCI_CLASS_BRIDGE_PCI) {
+    type = dev->config[PCI_HEADER_TYPE] & ~PCI_HEADER_TYPE_MULTI_FUNCTION;
+    if (type == PCI_HEADER_TYPE_BRIDGE) {
         QDict *qdict;
         QObject *pci_bridge;
 
-- 
1.7.1