[Kimchi-devel] [PATCH V2] Enhancement: PCI Device information enhancement

Zhou Zheng Sheng zhshzhou at linux.vnet.ibm.com
Tue Oct 28 08:12:56 UTC 2014


Hi Wen,

It's a great patch, I tested it. I have just one inline comments.

on 2014/10/27 15:42, Wen Wang wrote:
> From: Wen Wang <wenwang at linux.vnet.ibm.com>
> 
> V1 -> V2:
> 1) Changed the API name to "getPCIDeviceCompanion".
> 2) Changed for a more specific way of detecting the related devices.
> 3) Added the "Affected devices" to the tip with aligned format.
> 4) tip will when the pointer hang over any section of the affected line.
> 
> This patch provide the way that shows more specific PCI device
> information by hanging the mouse on top of device name.
> 
> Signed-off-by: Wen Wang <wenwang at linux.vnet.ibm.com>
> ---
>  ui/js/src/kimchi.api.js             |   14 ++++++++++++++
>  ui/js/src/kimchi.guest_edit_main.js |   25 +++++++++++++++++++++++++
>  2 files changed, 39 insertions(+), 0 deletions(-)
> 
> diff --git a/ui/js/src/kimchi.api.js b/ui/js/src/kimchi.api.js
> index 8a6e416..ebf826b 100644
> --- a/ui/js/src/kimchi.api.js
> +++ b/ui/js/src/kimchi.api.js
> @@ -1129,6 +1129,20 @@ var kimchi = {
>          });
>      },
> 
> +    getPCIDeviceCompanions : function(pcidev, suc, err) {
> +        kimchi.requestJSON({
> +            url : kimchi.url + 'host/devices?_passthrough_affected_by=' + pcidev,
> +            type : 'GET',
> +            contentType : 'application/json',
> +            dataType : 'json',
> +            resend : true,
> +            success : suc,
> +            error : err ? err : function(data) {
> +                kimchi.message.error(data.responseJSON.reason);
> +            }
> +        });
> +    },
> +
>      getISCSITargets : function(server, port, suc, err) {
>          server = encodeURIComponent(server);
>          port = port ? '&_server_port='+encodeURIComponent(port) : '';
> diff --git a/ui/js/src/kimchi.guest_edit_main.js b/ui/js/src/kimchi.guest_edit_main.js
> index 030e112..2a9c1ab 100644
> --- a/ui/js/src/kimchi.guest_edit_main.js
> +++ b/ui/js/src/kimchi.guest_edit_main.js
> @@ -407,6 +407,31 @@ kimchi.guest_edit_main = function() {
>                                  });
>                              }
>                          });
> +                        kimchi.getPCIDeviceCompanions(hostPCIs[i].name, function(infoData) {
> +                            var pciTitle = "";
> +                            if(infoData.length>0) {

I suggest that we move 'pciTitle += "Affected devices:\n";' here, and
delete other occurrences of it in the for loop.

If we put it in the for loop, we will get

Affected devices
    dev1
Affected devices
    dev2
Affected devices
    dev3

If we put it outside the for loop, we will get

Affected devices
    dev1
    dev2
    dev3

Maybe the latter way is better.

> +                                for(var p=0; p<infoData.length; p++) {
> +                                    if(infoData[p].device_type === "net") {
> +                                        pciTitle += "Affected devices:\n";
> +                                        pciTitle += infoData[p].name + "\n";
> +                                        pciTitle += "    " + "interface: " + infoData[p].interface;
> +                                        pciTitle += ", address: " + infoData[p].address;
> +                                        pciTitle += ", link_type: " + infoData[p].link_type + "\n";
> +                                    } else if(infoData[p].device_type === "storage") {
> +                                        pciTitle += "Affected devices:\n";
> +                                        pciTitle += infoData[p].name + "\n";
> +                                        pciTitle += "    " + "block: " + infoData[p].block;
> +                                        pciTitle += ", drive_type: " + infoData[p].drive_type;
> +                                        pciTitle += ", model: " + infoData[p].model + "\n";
> +                                    }
> +                                }
> +                                for(var q=0; q<infoData.length; q++) {
> +                                    pciTitle === "" || $(".name", "#" + infoData[q].parent).attr("title", pciTitle);
> +                                    pciTitle === "" || $(".product", "#" + infoData[q].parent).attr("title", pciTitle);
> +                                    pciTitle === "" || $(".vendor", "#" + infoData[q].parent).attr("title", pciTitle);
> +                                }
> +                            }
> +                        });
>                      }
>                  });
>              });
> 


-- 
Zhou Zheng Sheng / 周征晟
E-mail: zhshzhou at linux.vnet.ibm.com
Telephone: 86-10-82454397




More information about the Kimchi-devel mailing list