On 07/09/2014 04:01 AM, Zhou Zheng Sheng wrote:
> The URI /host/devices only presents scsi_host (particularly fc_host)
> device information. To implement host PCI pass through, we should list
> all
> types of host devices. This patch adds support for parsing various host
> devices information, and listing them on /host/devices. So the user is
> free
> to choose any listed PCI device to pass through to guest. Since the
> patch changes the device information dictionary format, the existing code
> consuming the device information is also changed accordingly.
>
> To get all types of host device, access the following URL.
>
> curl -k -u root -H "Content-Type: application/json" \
> -H "Accept: application/json" \
>
https://127.0.0.1:8001/host/devices
>
> To get only fc_host devices, change the URL to
> "https://127.0.0.1:8001/host/devices?_cap=fc_host"
>
> To get only pci device, change the URL to
> "https://127.0.0.1:8001/host/devices?_cap=pci"
>
> v1:
> Parse the node device XML using xpath.
>
> v2:
> Write a "dictize" function and parse the node device XML using
> dictize.
>
> v3:
> Fix a naming mistake.
>
> v4:
> It is observed that sometimes the parent devices is not listed by
> libvirt but the child device is listed. In previous version we catch
> this exception and ignore it. The root cause is unknown, and we failed
> to re-produce the problem. In v4 we do not catch it. It seems to be
> related to USB removable disk, and the problem is gone after we
> upgraded Linux kernel.
>
> Signed-off-by: Zhou Zheng Sheng <zhshzhou(a)linux.vnet.ibm.com>
> ---
> docs/API.md | 11 +-
> src/kimchi/hostdev.py | 205
> +++++++++++++++++++++++++++++++++
> src/kimchi/mockmodel.py | 7 +-
> src/kimchi/model/host.py | 15 +--
> src/kimchi/model/libvirtstoragepool.py | 18 +--
> src/kimchi/xmlutils.py | 26 ++++-
> tests/test_rest.py | 6 +-
> tests/test_storagepool.py | 7 +-
> 8 files changed, 258 insertions(+), 37 deletions(-)
> create mode 100644 src/kimchi/hostdev.py
>
> diff --git a/docs/API.md b/docs/API.md
> index 4f51dd0..6b7c2d4 100644
> --- a/docs/API.md
> +++ b/docs/API.md
> @@ -877,12 +877,11 @@ stats history
> * **GET**: Retrieve information of a single pci device.
> Currently only scsi_host devices are supported:
> * name: The name of the device.
> - * adapter_type: The capability type of the scsi_host device
> (fc_host).
> - Empty if pci device is not scsi_host.
> - * wwnn: The HBA Word Wide Node Name.
> - Empty if pci device is not scsi_host.
> - * wwpn: The HBA Word Wide Port Name
> - Empty if pci device is not scsi_host.
> + * path: Path of device in sysfs.
> + * adapter: Host adapter information. Empty if pci device is not
> scsi_host.
> + * type: The capability type of the scsi_host device (fc_host,
> vport_ops).
> + * wwnn: The HBA Word Wide Node Name. Empty if pci device is
> not fc_host.
> + * wwpn: The HBA Word Wide Port Name. Empty if pci device is
> not fc_host.
>
> ### Collection: Host Packages Update
>
> diff --git a/src/kimchi/hostdev.py b/src/kimchi/hostdev.py
As it is strictly related to libvirt, it should be under /src/kimchi/model
Thanks Aline. I agree.
> new file mode 100644
> index 0000000..0785802
> --- /dev/null
> +++ b/src/kimchi/hostdev.py
--
Zhou Zheng Sheng / 周征晟
E-mail: zhshzhou(a)linux.vnet.ibm.com
Telephone: 86-10-82454397