diff mbox

[RFC,10/17] hw/pci: removed 'rootbus nr is 0' assumption from qmp_pci_query

Message ID 1421956363-23502-11-git-send-email-marcel@redhat.com
State New
Headers show

Commit Message

Marcel Apfelbaum Jan. 22, 2015, 7:52 p.m. UTC
From: Marcel Apfelbaum <marcel.a@redhat.com>

Use the newer pci_bus_num to correctly get the root bus number.

Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
---
 hw/pci/pci.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Michael S. Tsirkin Jan. 23, 2015, 7:57 a.m. UTC | #1
On Thu, Jan 22, 2015 at 09:52:36PM +0200, Marcel Apfelbaum wrote:
> From: Marcel Apfelbaum <marcel.a@redhat.com>
> 
> Use the newer pci_bus_num to correctly get the root bus number.
> 
> Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>


OK for now, but really bus numbers are a wrong thing to
use for QMP. In particular they are often guest-assigned.

> ---
>  hw/pci/pci.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> index dccb3d1..bf31168 100644
> --- a/hw/pci/pci.c
> +++ b/hw/pci/pci.c
> @@ -1251,7 +1251,8 @@ PciInfoList *qmp_query_pci(Error **errp)
>  
>      QLIST_FOREACH(host_bridge, &pci_host_bridges, next) {
>          info = g_malloc0(sizeof(*info));
> -        info->value = qmp_query_pci_bus(host_bridge->bus, 0);
> +        info->value = qmp_query_pci_bus(host_bridge->bus,
> +                                        pci_bus_num(host_bridge->bus));
>  
>          /* XXX: waiting for the qapi to support GSList */
>          if (!cur_item) {
> -- 
> 2.1.0
Marcel Apfelbaum Jan. 23, 2015, 8:28 a.m. UTC | #2
On 01/23/2015 09:57 AM, Michael S. Tsirkin wrote:
> On Thu, Jan 22, 2015 at 09:52:36PM +0200, Marcel Apfelbaum wrote:
>> From: Marcel Apfelbaum <marcel.a@redhat.com>
>>
>> Use the newer pci_bus_num to correctly get the root bus number.
>>
>> Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
>
>
> OK for now, but really bus numbers are a wrong thing to
> use for QMP. In particular they are often guest-assigned.
Hi Michael,
Thank you for the review.

This implementation requires user to input the bus number for host bridge's bus.
     -pxb-device,bus_nr=<x>,...

Thank you,
Marcel

>
>> ---
>>   hw/pci/pci.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
>> index dccb3d1..bf31168 100644
>> --- a/hw/pci/pci.c
>> +++ b/hw/pci/pci.c
>> @@ -1251,7 +1251,8 @@ PciInfoList *qmp_query_pci(Error **errp)
>>
>>       QLIST_FOREACH(host_bridge, &pci_host_bridges, next) {
>>           info = g_malloc0(sizeof(*info));
>> -        info->value = qmp_query_pci_bus(host_bridge->bus, 0);
>> +        info->value = qmp_query_pci_bus(host_bridge->bus,
>> +                                        pci_bus_num(host_bridge->bus));
>>
>>           /* XXX: waiting for the qapi to support GSList */
>>           if (!cur_item) {
>> --
>> 2.1.0
Michael S. Tsirkin Jan. 23, 2015, 9:15 a.m. UTC | #3
On Fri, Jan 23, 2015 at 10:28:39AM +0200, Marcel Apfelbaum wrote:
> On 01/23/2015 09:57 AM, Michael S. Tsirkin wrote:
> >On Thu, Jan 22, 2015 at 09:52:36PM +0200, Marcel Apfelbaum wrote:
> >>From: Marcel Apfelbaum <marcel.a@redhat.com>
> >>
> >>Use the newer pci_bus_num to correctly get the root bus number.
> >>
> >>Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
> >
> >
> >OK for now, but really bus numbers are a wrong thing to
> >use for QMP. In particular they are often guest-assigned.
> Hi Michael,
> Thank you for the review.
> 
> This implementation requires user to input the bus number for host bridge's bus.
>     -pxb-device,bus_nr=<x>,...
> 
> Thank you,
> Marcel

That is fine since this device does not have a way for guest to set the
number, but later queries should always use names.

> >
> >>---
> >>  hw/pci/pci.c | 3 ++-
> >>  1 file changed, 2 insertions(+), 1 deletion(-)
> >>
> >>diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> >>index dccb3d1..bf31168 100644
> >>--- a/hw/pci/pci.c
> >>+++ b/hw/pci/pci.c
> >>@@ -1251,7 +1251,8 @@ PciInfoList *qmp_query_pci(Error **errp)
> >>
> >>      QLIST_FOREACH(host_bridge, &pci_host_bridges, next) {
> >>          info = g_malloc0(sizeof(*info));
> >>-        info->value = qmp_query_pci_bus(host_bridge->bus, 0);
> >>+        info->value = qmp_query_pci_bus(host_bridge->bus,
> >>+                                        pci_bus_num(host_bridge->bus));
> >>
> >>          /* XXX: waiting for the qapi to support GSList */
> >>          if (!cur_item) {
> >>--
> >>2.1.0
diff mbox

Patch

diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index dccb3d1..bf31168 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -1251,7 +1251,8 @@  PciInfoList *qmp_query_pci(Error **errp)
 
     QLIST_FOREACH(host_bridge, &pci_host_bridges, next) {
         info = g_malloc0(sizeof(*info));
-        info->value = qmp_query_pci_bus(host_bridge->bus, 0);
+        info->value = qmp_query_pci_bus(host_bridge->bus,
+                                        pci_bus_num(host_bridge->bus));
 
         /* XXX: waiting for the qapi to support GSList */
         if (!cur_item) {