[libvirt] [PATCH 6/7] virsh: Fix a bug of nodedev-list

Peter Krempa pkrempa at redhat.com
Thu Sep 6 21:43:13 UTC 2012


On 09/05/12 07:34, Osier Yang wrote:
> output of commands like '%virsh nodedev-list --tree --cap pci'
> could be empty. Remove the useless checking.
> ---
>   tools/virsh-nodedev.c |    5 ++---
>   1 files changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c
> index e784af1..cd88538 100644
> --- a/tools/virsh-nodedev.c
> +++ b/tools/virsh-nodedev.c
> @@ -197,9 +197,8 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
>               virNodeDeviceFree(dev);
>           }
>           for (i = 0 ; i < num_devices ; i++) {
> -            if (parents[i] == NULL &&

This check here is done so that the tree printing function prints just 
the root nodes of the tree and not every subtree in the tree. If you 
remove this check you get something like this most of the times:

virsh # nodedev-list --tree

<snip>
pci_0000_00_1f_2
   |
   +- scsi_host0
   |   |
   |   +- scsi_target0_0_0
   |       |
   |       +- scsi_0_0_0_0
   |           |
   |           +- block_sda_ST320LT007_9ZV142_W0Q3DQF8
   |
   +- scsi_host1
   +- scsi_host2
   +- scsi_host3
   +- scsi_host4
   +- scsi_host5

pci_0000_00_1f_3

pci_0000_03_00_0
   |
   +- net_wlan0_10_0b_a9_c6_f1_20

pci_0000_0d_00_0

pci_0000_0e_00_0
   |
   +- usb_usb3
   |   |
   |   +- usb_3_0_1_0
   |
   +- usb_usb4
       |
       +- usb_4_0_1_0

scsi_0_0_0_0
   |
   +- block_sda_ST320LT007_9ZV142_W0Q3DQF8

scsi_host0
   |
   +- scsi_target0_0_0
       |
       +- scsi_0_0_0_0
           |
           +- block_sda_ST320LT007_9ZV142_W0Q3DQF8
</snip>

(the output is severely truncated).


The bug you described is a problem but this solution is not right.

You need to modify the root-finding code for other posibilities.

> -                vshTreePrint(ctl, vshNodeListLookup, &arrays, num_devices,
> -                             i) < 0)
> +            if (vshTreePrint(ctl, vshNodeListLookup,
> +                             &arrays, num_devices, i) < 0)
>                   ret = false;
>           }
>           for (i = 0 ; i < num_devices ; i++) {
>

NACK to this patch as it breaks the output.

Peter




More information about the libvir-list mailing list