Jump to: navigation, search

Difference between revisions of "Main Page/cobbler"

Line 1: Line 1:
 +
..
 +
This work is licensed under a Creative Commons Attribution 3.0 Unported
 +
License.
  
sqlalchemy和sqlalchemy-migrate在openstack的应用介绍
+
http://creativecommons.org/licenses/by/3.0/legalcode
  
sqlalchemy
+
====================================================
简介:
+
Support passthrough of USB device
提供ORM(对象关系映射)能力的python库,类似hibernate技术,支持postgresql、mysql等主流关系数据;用户只需定义DB对应的类,通过操作类实例,即可通过sqlalchemy引擎转换成标准sql语句,对DB进行操作
+
====================================================
  
Openstack中的应用:
+
We provide VDI(Virtual Desktop) and server virtualization solutions for customers,
openstack各项目涉及关系数据库的DB driver,基本都是使用sqlalchemy库。
+
our customers have strong requirements for using USB devices.
table对应class定义:\nova\db\sqlalchemy\models.py中,例如class Instance(BASE, NovaBase)
 
db操作API:\nova\db\sqlalchemy\api.py,调用sqlalchemy相关库函数操作DB,数据实体使用models.py定义的class
 
  
sqlalchemy-migrate
+
The typical use cases and our solutions are described as below:
简介:
+
1.In VDI solution, customers want to use local USB printers or USB scanners with
基于sqlalchemy库,提供数据库版本管控能力的python库。
+
TC(Thin-Client), because remote desktop protocol like ICA have already support
 +
USB-redirection, so customers only need to attach USB device to TC, the protocol
 +
can map USB device to VM.
 +
 
 +
2. In virtualization solution, when starting or restarting some business-critical
 +
applications, a connected USB-KEY is needed for authentication, some applications
 +
even need a daily authentication by USB-KEY. we suggest the following solutions:
 +
(1) Using physical 'USB-HUB' box and technology of USB-redirection over TCP/IP.
 +
Customers need to buy USB-HUB and install software in guest os, the software helps
 +
redirecting USB device to VM.
 +
 
 +
(2) Using USB-Passthrough functions provided by our virtualization software.
 +
The end users(normally application or system administrators) insert USB devices
 +
to host that containing the VM, then  can see USB device list in portal and choose
 +
USB device to attach.
 +
 
 +
This solution has advantages that
 +
 
 +
1. It doesn't need additional physical devices.
 +
 
 +
2. It doesn't need a special server to run spice client for USB-Redirection.
 +
 
 +
3. Business-critical applications commonly need stable and long-standing USB-KEY
 +
to attach, USB-Passthrough maybe more stable than USB-Redirection over TCP/IP or
 +
remote desktop protocol.
 +
 
 +
As described above, I think USB-Passthrough is valuable in Openstack.
 +
 
 +
This BP is focus on how to provide USB-Passthrough function in Openstack.
 +
 
 +
 
 +
Problem description
 +
===================
 +
 
 +
Use cases:
 +
 
 +
In private cloud, a end user wants to create a VM to run ERP software which needs
 +
a USB-KEY for authentication, he proposes request to system administrator, they
 +
perform the following steps:
 +
 
 +
1. The administrator goes to the machine room and chooses a host to insert USB-KEY
 +
to.
 +
 
 +
2. The administrator adds some configuration(like white-list with USB-KEY's product
 +
and vendor information) to nova-compute, restart nova-compute to trigger it to
 +
discovery new devices and save them to DB.
 +
 
 +
3. The administrator queries USB-KEY information from API or portal
 +
 
 +
4. The administrator creates a flavor with USB-KEY information queried by above.
 +
 
 +
5. The end user creates a VM with above flavor, the system chooses the host which
 +
contains the USB-KEY to run VM and attach USB-KEY to it.
 +
 
 +
Proposed change
 +
===============
 +
 
 +
The idea of how to implement this function can reference to pci-passthrough.
 +
 
 +
We should add the following functions to nova:
 +
 
 +
1. Nova should support to auto-discover usb devices and save them in DB.
 +
 
 +
2. Nova should support to create a flavor which contains usb device information.
 +
 
 +
3. Nova should support to create VM with a flavor which contains usb device
 +
information.
 +
 
 +
Alternatives
 +
------------
 +
 
 +
None
 +
 
 +
Data model impact
 +
-----------------
 +
 
 +
The idea of how to implement this function can reference to pci-passthrough.
 +
 
 +
1. In libvirt driver layer, add function to discover USB devices. A white-list
 +
maybe needed here to filter proper devices.
 +
 
 +
2. In DB layer, (1) add a new table 'usb_devices' to store USB device information.
 +
(2) add a key-value pair to instance_system_metadata table to store USB device
 +
information which have been assigned to the VM.
 +
 
 +
3. In scheduler layer, add a filter to find host which contains the usb devices.
 +
 
 +
4. The schema of flavor which contains USB device information may like this:
 +
{"usb_devices":[{"id": 5}]}
 +
 
 +
 
 +
REST API impact
 +
---------------
 +
 
 +
None
 +
 
 +
Security impact
 +
---------------
 +
 
 +
None
 +
 
 +
Notifications impact
 +
--------------------
 +
 
 +
None
 +
 
 +
Other end user impact
 +
---------------------
 +
 
 +
This new function may have some impacts to other exist functions, I recognise the
 +
followings by now:
 +
 
 +
1. A VM with USB device doesn't support to do migration(live-migration, with shared
 +
storage or not).
 +
 
 +
2. It maybe necessary for the user of USB device to pop-up USB device in guest os
 +
before detach it from VM. The hazard of not pop-up USB device is just as detach
 +
a USB device from physical server.
 +
 
 +
3. It maybe necessary to detach USB device before snapshot a VM and then attach USB
 +
device after that.
 +
 
 +
4. The physical information of USB device like bus id, device id maybe changed every
 +
time the host been restarted. If this problem happens, the user need to detach the
 +
old invalid USB device and re-attach the USB device by the new bus id, device id.
 +
 
 +
5. When delete a VM with USB device, the USB device should be detached and the USB
 +
device usage information should be updated.
 +
 
 +
6. We plan to provide this function in KVM/libvirt environment but not support it
 +
in xen.
 +
 
 +
 
 +
Performance Impact
 +
------------------
 +
 
 +
None
 +
 
 +
 
 +
Other deployer impact
 +
---------------------
 +
 
 +
None
 +
 
 +
 
 +
Developer impact
 +
----------------
 +
 
 +
How to distinguish USB devices is important because user wants to specify
 +
which USB device to which VM. I think this function can reference to idea of
 +
pci-passthrough.
 +
 
 +
1. The key information of USB device which are supported by libvirt by now are
 +
vendor id, product id, bus and device. Bellow is a example:
 +
 
 +
<hostdev mode='subsystem' type='usb'>
 +
<source>
 +
<vendor id='0x136b'/>
 +
<product id='0x0003'/>
 +
<address bus='2' device='3'/>
 +
</source>
 +
</hostdev>
 +
 
 +
Different USB devices may have the same vendor id and product id, so they are not
 +
appropriate.
 +
 
 +
The bus+device maybe a good choice to distinguish USB devices, but device id may
 +
change every time the host restart.
 +
 
 +
The physical controller 'port id' which USB device attach to maybe the best choice,
 +
but libvirt doesn't support it by now.
 +
 
 +
So I think bus+device maybe the best choice by now.
 +
 
 +
2. Add a white-list to nova.conf for nova-compute to discovery USB device. The
 +
schema may like:
 +
usb_passthrough_whitelist =  [{"bus": "2", "device": "2"}]
 +
 
 +
Implementation
 +
==============
 +
 
 +
Assignee(s)
 +
-----------
 +
 
 +
Primary assignee:
 +
  <Jing Yuan>
 +
 
 +
 
 +
Work Items
 +
----------
 +
Step 1: Implement function of discover usb device in libvirt driver.
 +
 
 +
Step 2: Implement function of periodically update USB device information from
 +
nova-compute to DB.
 +
 
 +
Step 3: Implement function of create VM with USB device.
 +
 
 +
Step 4: Make changes to other functions which are affected by this new function.
 +
 
 +
Dependencies
 +
============
 +
 
 +
None
 +
 
 +
 
 +
Testing
 +
=======
 +
 
 +
It is necessary to add tempest for this new function.
 +
 
 +
 
 +
Documentation Impact
 +
====================
 +
 
 +
It is necessary to add doc for how to use this new function.
 +
 
 +
 
 +
References
 +
==========
 +
 
 +
None
 +
 
 +
yuanjing
 +
..
 +
This work is licensed under a Creative Commons Attribution 3.0 Unported
 +
License.
 +
 
 +
http://creativecommons.org/licenses/by/3.0/legalcode
 +
 
 +
====================================================
 +
Add support for USB controller
 +
====================================================
 +
 
 +
Users have requirement of using USB devices, the detailed information can reference
 +
the bp of https://blueprints.launchpad.net/nova/+spec/usb-passthrough.
 +
 
 +
If not specify appropriate type of USB controller for USB device, USB device will
 +
use the default piix3-usb-uhci, the default USB device's speed may mismatch with
 +
USB device. This result in the following problems.
 +
 
 +
1. The low speed of USB device.
 +
 
 +
2. If use spice client to redirect USB device to VM, the mismatched speed may prevent
 +
the connection.
 +
 
 +
As described above, I think specify USB controller for USB-passthrough is valuable
 +
in Openstack.
 +
 
 +
 
 +
Problem description
 +
===================
 +
 
 +
Use cases:
 +
 
 +
1. The administrator creates a VM with flavor which contains USB device information
 +
and USB controller information.
 +
 
 +
2. The system creates VM with USB controller specified in flavor above, it also
 +
attach USB device to the created USB controller but not the default piix3-usb-uhci.
 +
 
 +
 
 +
Proposed change
 +
===============
 +
 
 +
We should add the following functions to nova:
 +
1. When create flavor with USB device, specify the USB controller type for USB
 +
device.
 +
 
 +
2. Nova should support to attach USB device to specified USB controller when create
 +
VM.
 +
 
 +
Alternatives
 +
------------
 +
 
 +
None
 +
 
 +
Data model impact
 +
-----------------
 +
 
 +
1. The schema of flavor which contains USB device information and USB controller
 +
information may like this:
 +
{"usb_devices":[{"id": 5, "usb_controller_type": "ehci"}]}
 +
 
 +
2. In libvirt driver layer, add function to specify USB controller for USB device.
 +
Bellow is a example:
 +
 
 +
<hostdev mode='subsystem' type='usb'>
 +
<source>
 +
<address bus='2' device='3'/>
 +
</source>
 +
<address type='usb' bus='1' port='2'/>
 +
</hostdev>
 +
 
 +
System should select not duplicate port for USB device to attach.
 +
 
 +
3. In DB layer, add USB controller type parameter to USB device information which
 +
have been assigned to the VM.
 +
 
 +
 
 +
REST API impact
 +
---------------
 +
 
 +
NULL
 +
 
 +
Security impact
 +
---------------
 +
 
 +
None
 +
 
 +
Notifications impact
 +
--------------------
 +
 
 +
None
 +
 
 +
Other end user impact
 +
---------------------
 +
 
 +
None
 +
 
 +
Performance Impact
 +
------------------
 +
 
 +
None
 +
 
 +
Other deployer impact
 +
---------------------
 +
 
 +
None
 +
 
 +
Developer impact
 +
----------------
 +
 
 +
None
 +
 
 +
Implementation
 +
==============
 +
 
 +
Assignee(s)
 +
-----------
 +
 
 +
Primary assignee:
 +
  <Jing Yuan>
 +
 
 +
 
 +
Work Items
 +
----------
 +
Step 1: Add USB controller type to USB device data model in libvirt driver.
 +
 
 +
Step 2: Implement function of choose USB controller port for USB device.
 +
 
 +
Dependencies
 +
============
 +
 
 +
NULL
 +
 
 +
 
 +
Testing
 +
=======
 +
 
 +
It is necessary to add tempest for this new function.
 +
 
 +
Documentation Impact
 +
====================
  
Openstack中的应用:
+
It is necessary to add doc for how to use this new function.
版本升级能力是openstack当前能力较缺失的一块,但是从DB升级的角度看,由于引入了sqlalchemy-migrate框架,openstack各项目比较容易管理DB的变化,例如新增加一张table,新增加一个字段等。
 
sqlalchemy-migrate在2011年发布了0.7.2版本后,就已经停止更新了,也不接受bugfix。因此openstack考虑引入Alembic(同样由sqlalchemy-migrate的开发者)替代sqlalchemy-migrate
 
sqlalchemy-migrate提供upgrade(升级)、downgrade(降级)、db_version(查看最新版本)等接口
 
  
应用举例:
 
在H版本代码基础上nova项目提供USB设备管理能力,故在DB Layper需增加一张table存放USB设备信息。
 
  
1. 在/nova/db/sqlalchemy/migrate_repo/versions增加一个217_add_usb_devices.py(H版本version号到216,故新增文件命令以217开头)
+
References
#定义升级函数,本例升级即创建一张新table
+
==========
def upgrade(migrate_engine):
 
    meta = MetaData(bind=migrate_engine)
 
  
    usb_devices_uc_name = 'uniq_usb_devices0compute_node_id0address0deleted'
+
https://blueprints.launchpad.net/nova/+spec/usb-passthrough
    usb_devices = Table('usb_devices', meta,
 
                        Column('created_at', DateTime(timezone=False)),
 
                        ...
 
#定义升级回退函数,本例回退即删除创建的table
 
def downgrade(migrate_engine):
 
    meta = MetaData(bind=migrate_engine)
 
  
    try:
+
https://blueprints.launchpad.net/nova/+spec/usb-passthrough
        usb_device = Table('usb_devices', meta, autoload=True)
 
        usb_device.drop()
 
        ...
 
2. 执行nova-manage db sync命令,对nova DB进行升级。结果是在数据库中即可见到产生的usb_devices表
 
3. 执行nova-manage db sync 216命令,对nova DB进行升级。结果是usb_devices表被删除
 
  
系统内部流程简介:
+
yuanjing
(1)在DB的migrate_version中存放了nova的DB版本信息,如下所示:
+
..
mysql> select * from migrate_version;
+
This work is licensed under a Creative Commons Attribution 3.0 Unported
+---------------+------------------------------------------------------------------+---------+
+
License.
| repository_id | repository_path                                                  | version |
 
+---------------+------------------------------------------------------------------+---------+
 
| nova          | /usr/lib/python2.6/site-packages/nova/db/sqlalchemy/migrate_repo |    216 |
 
+---------------+------------------------------------------------------------------+---------+
 
1 row in set (0.00 sec)
 
(2)执行nova-manage db sync命令,调用/nova/db/sqlalchemy/migration.py的db_sync函数
 
        此函数检查当前版本号和API传入的版本号,如果API不指定版本号(见上面例子)、或者指定的版本号大于当前版本号,则进入升级流程,否则进入降级流程
 
(3)最终进入migrate/versioning/api.py的_migrate函数
 
        此函数检查是否有变更点,如果没有变更点则结束流程,如果有变更点(例如上例新增加了217_xx),则执行变更(即执行217_add_usb_devices.py中的upgrade函数),产生新DB
 
  
相关参考:
+
http://creativecommons.org/licenses/by/3.0/legalcode
http://blog.csdn.net/tpiperatgod/article/details/17560005
 
http://www.sqlalchemy.org/
 
http://www.cnblogs.com/willier/archive/2013/05/16/3081475.html
 
http://www.ustack.com/blog/sqlalchemy-migrate-and-alembic/
 
  
 +
====================================================
 +
Add support for USB controller
 +
====================================================
  
We provide VDI(Virtual Desktop) and server virtualization solutions for customers, our customers have strong requirements for using USB devices.  
+
Users have requirement of using USB devices, the detailed information can reference
 +
the bp of https://blueprints.launchpad.net/nova/+spec/usb-passthrough.
  
The typical use cases and our solutions are described as below:
+
If not specify appropriate type of USB controller for USB device, USB device will
1.In VDI solution, customers want to use local USB printers or USB scanners with TC(Thin-Client), because remote desktop protocol like ICA have already support USB-redirection,  
+
use the default piix3-usb-uhci, the default USB controller's speed may mismatch
so customers only need to attach USB device to TC, the protocol can map USB device to VM.
+
with USB device. This result in the following problems.
 +
 
 +
1. The low speed of USB device.
 +
 
 +
2. If use spice client to redirect USB device to VM, the mismatched speed may prevent
 +
the connection.
  
2. In virtualization solution, when starting or restarting some business-critical applications, a connected USB-KEY is needed for authentication,
+
As described above, I think USB controller is valuable in Openstack.
some applications even need a daily authentication by USB-KEY. we suggest the following solutions:
 
(1) Using physical 'USB-HUB' box and technology of USB-redirection over TCP/IP.Customers need to buy USB-HUB and install software in guest os, the software helps 
 
redirecting USB device to VM.
 
  
(2) Using USB-Passthrough and USB hot-plug functions provided by our virtualization software.
 
The end users(normally application or system administrators)  insert USB devices to host that containing the VM, then  can see USB device list in portal and choose USB device to attach.
 
This solution has advantages that
 
1. It dosen’t need additional physical devices
 
2. It dosen't need a special server to run spice client for USB-Redirection
 
3. Business-critical applications commonly need stable and long-standing USB-KEY to attach, USB-Passthrough maybe more stable than USB-Redirection over TCP/IP or remote desktop protocol.
 
  
As described above, I think USB-Passthrough/USB hot-plug is valuable in Openstack.
+
Problem description
This BP is focus on how to provide USB-Passthrough/USB hot-plug function in Openstack.
+
===================
  
 
Use cases:
 
Use cases:
In private cloud, a end user wants to run a ERP software in VM which needs a USB-KEY for authentication, he proposes request to system administor, they perform the following steps:
 
1. The administrator finds the host which runs the VM with ERP software by portal or API.
 
2. The administrator goes to the machine room and insert USB-KEY to host.
 
3. The administrator adds some configuration(like white-list with USB-KEY's product and vendor informations) to nova-compute, restart nova-compute to trigger to discovery USB-KEY and save to DB.
 
4. The end user queries USB-KEY by host id.
 
5. The end user attaches USB-KEY to VM.
 
  
In private cloud, a end user wants to create a VM to run ERP software which needs a USB-KEY for authentication, he proposes request to system administor, they perform the following steps:
+
1. The administrator creates a flavor with USB controller information, the key
1. The administrator goes to the machine room and chooses a host to insert USB-KEY to.
+
parameter is type like ehci.
2. The administrator adds some configuration(like white-list with USB-KEY's product and vendor informations) to nova-compute, restart nova-compute to trigger to discovery new devices and save to DB.
+
 
3. The administrator queries USB-KEY information(the information should be able to  distinguish USB-KEY,  for example using uuid genereated by system)  from system, and then creates a flavor with USB-KEY information.
+
2. The administrator creates a VM with flavor created above, the system creates
4. The end user creates a VM with above flavor, the system chooses the host which contains the USB-KEY to create VM and attach USB-KEY to it.
+
USB controller for the VM.
 +
 
  
Data model impact:
+
Proposed change
The new function has some impactions on other functions and the operations of user which I can identify by now.
+
===============
1. When migrate a VM with USB device, it may be failed, so it is necessary to make some restriction on migration procedure.
+
 
2. It may be unsafe to suspend a VM with USB device, so it is necessary to add procedure of detach/re-attach USB device  to procedure of suspending VM.  
+
We should add the following functions to nova:
3. For user it is more safe to pop-up USB device in guest os before detach USB device from VM.
+
1. When create flavor, specify a key-value for USB controller, the schema may like:
4. After reboot host and restart VM, the VM may can't find the USB device because the physical information like device id have been change(which is the linux system's mechanism), so we need to find appropriate physical identifier to distinguish USB devices.
+
{"usb_controllers":[{"type":"ehci"}]}
5. When rebuild a VM with USB device, it is necessary to re-attach USB device to the VM.
+
 
 +
2. Nova should support to create USB controller in libvirt driver when create
 +
VM.
 +
 
 +
Alternatives
 +
------------
 +
 
 +
None
 +
 
 +
Data model impact
 +
-----------------
 +
 
 +
We should add USB controller data model in libvirt driver for constructing USB
 +
controller xml when create VM.
 +
 
 +
 
 +
REST API impact
 +
---------------
 +
 
 +
None
 +
 
 +
Security impact
 +
---------------
 +
 
 +
None
 +
 
 +
Notifications impact
 +
--------------------
 +
 
 +
None
 +
 
 +
Other end user impact
 +
---------------------
 +
 
 +
None
 +
 
 +
Performance Impact
 +
------------------
 +
 
 +
None
 +
 
 +
Other deployer impact
 +
---------------------
 +
 
 +
None
  
 
Developer impact
 
Developer impact
 +
----------------
 +
 +
None
 +
 +
Implementation
 +
==============
 +
 +
Assignee(s)
 +
-----------
  
 +
Primary assignee:
 +
  <Jing Yuan>
  
  
 
Work Items
 
Work Items
Step 1: Add function to discover usb device.
+
----------
Step 2: Add function to store USB device information.
+
Step 1: Implement function of construct USB controller xml in libvirt driver.
Step 3: Add function to create VM with USB device.
+
 
Step 4: Add function to hot-plug/unplug usb device to/from VM.
+
Step 2: Implement function of create USB controller when create VM.
Step 5: Add changes to other exist functions which have been affected by the new function.
+
 
Step 6: Add function to specify USB controller.
+
Dependencies
 +
============
 +
 
 +
None
  
  
 
Testing
 
Testing
Add test cases to test the related functions.
+
=======
  
 +
It is necessary to add tempest for this new function.
  
  
 
Documentation Impact
 
Documentation Impact
Add doc about how to use this function.
+
====================
 +
 
 +
None
 +
 
 +
 
 +
References
 +
==========
 +
 
 +
https://blueprints.launchpad.net/nova/+spec/usb-passthrough

Revision as of 10:19, 17 April 2014

..

This work is licensed under a Creative Commons Attribution 3.0 Unported
License.
http://creativecommons.org/licenses/by/3.0/legalcode
========================================

Support passthrough of USB device

========================================

We provide VDI(Virtual Desktop) and server virtualization solutions for customers, our customers have strong requirements for using USB devices.

The typical use cases and our solutions are described as below: 1.In VDI solution, customers want to use local USB printers or USB scanners with TC(Thin-Client), because remote desktop protocol like ICA have already support USB-redirection, so customers only need to attach USB device to TC, the protocol can map USB device to VM.

2. In virtualization solution, when starting or restarting some business-critical applications, a connected USB-KEY is needed for authentication, some applications even need a daily authentication by USB-KEY. we suggest the following solutions: (1) Using physical 'USB-HUB' box and technology of USB-redirection over TCP/IP. Customers need to buy USB-HUB and install software in guest os, the software helps redirecting USB device to VM.

(2) Using USB-Passthrough functions provided by our virtualization software. The end users(normally application or system administrators) insert USB devices to host that containing the VM, then can see USB device list in portal and choose USB device to attach.

This solution has advantages that

1. It doesn't need additional physical devices.

2. It doesn't need a special server to run spice client for USB-Redirection.

3. Business-critical applications commonly need stable and long-standing USB-KEY to attach, USB-Passthrough maybe more stable than USB-Redirection over TCP/IP or remote desktop protocol.

As described above, I think USB-Passthrough is valuable in Openstack.

This BP is focus on how to provide USB-Passthrough function in Openstack.


Problem description

=======

Use cases:

In private cloud, a end user wants to create a VM to run ERP software which needs a USB-KEY for authentication, he proposes request to system administrator, they perform the following steps:

1. The administrator goes to the machine room and chooses a host to insert USB-KEY to.

2. The administrator adds some configuration(like white-list with USB-KEY's product and vendor information) to nova-compute, restart nova-compute to trigger it to discovery new devices and save them to DB.

3. The administrator queries USB-KEY information from API or portal

4. The administrator creates a flavor with USB-KEY information queried by above.

5. The end user creates a VM with above flavor, the system chooses the host which contains the USB-KEY to run VM and attach USB-KEY to it.

Proposed change

===

The idea of how to implement this function can reference to pci-passthrough.

We should add the following functions to nova:

1. Nova should support to auto-discover usb devices and save them in DB.

2. Nova should support to create a flavor which contains usb device information.

3. Nova should support to create VM with a flavor which contains usb device information.

Alternatives


None

Data model impact


The idea of how to implement this function can reference to pci-passthrough.

1. In libvirt driver layer, add function to discover USB devices. A white-list maybe needed here to filter proper devices.

2. In DB layer, (1) add a new table 'usb_devices' to store USB device information. (2) add a key-value pair to instance_system_metadata table to store USB device information which have been assigned to the VM.

3. In scheduler layer, add a filter to find host which contains the usb devices.

4. The schema of flavor which contains USB device information may like this: {"usb_devices":[{"id": 5}]}


REST API impact


None

Security impact


None

Notifications impact


None

Other end user impact


This new function may have some impacts to other exist functions, I recognise the followings by now:

1. A VM with USB device doesn't support to do migration(live-migration, with shared storage or not).

2. It maybe necessary for the user of USB device to pop-up USB device in guest os before detach it from VM. The hazard of not pop-up USB device is just as detach a USB device from physical server.

3. It maybe necessary to detach USB device before snapshot a VM and then attach USB device after that.

4. The physical information of USB device like bus id, device id maybe changed every time the host been restarted. If this problem happens, the user need to detach the old invalid USB device and re-attach the USB device by the new bus id, device id.

5. When delete a VM with USB device, the USB device should be detached and the USB device usage information should be updated.

6. We plan to provide this function in KVM/libvirt environment but not support it in xen.


Performance Impact


None


Other deployer impact


None


Developer impact


How to distinguish USB devices is important because user wants to specify which USB device to which VM. I think this function can reference to idea of pci-passthrough.

1. The key information of USB device which are supported by libvirt by now are vendor id, product id, bus and device. Bellow is a example:

<hostdev mode='subsystem' type='usb'>

<vendor id='0x136b'/>
<product id='0x0003'/>
<address bus='2' device='3'/>

</hostdev>

Different USB devices may have the same vendor id and product id, so they are not appropriate.

The bus+device maybe a good choice to distinguish USB devices, but device id may change every time the host restart.

The physical controller 'port id' which USB device attach to maybe the best choice, but libvirt doesn't support it by now.

So I think bus+device maybe the best choice by now.

2. Add a white-list to nova.conf for nova-compute to discovery USB device. The schema may like: usb_passthrough_whitelist = [{"bus": "2", "device": "2"}]

Implementation

==

Assignee(s)


Primary assignee:

 <Jing Yuan>


Work Items


Step 1: Implement function of discover usb device in libvirt driver.

Step 2: Implement function of periodically update USB device information from nova-compute to DB.

Step 3: Implement function of create VM with USB device.

Step 4: Make changes to other functions which are affected by this new function.

Dependencies

==

None


Testing

=

It is necessary to add tempest for this new function.


Documentation Impact

========

It is necessary to add doc for how to use this new function.


References

==

None

yuanjing ..

This work is licensed under a Creative Commons Attribution 3.0 Unported
License.
http://creativecommons.org/licenses/by/3.0/legalcode
========================================

Add support for USB controller

========================================

Users have requirement of using USB devices, the detailed information can reference the bp of https://blueprints.launchpad.net/nova/+spec/usb-passthrough.

If not specify appropriate type of USB controller for USB device, USB device will use the default piix3-usb-uhci, the default USB device's speed may mismatch with USB device. This result in the following problems.

1. The low speed of USB device.

2. If use spice client to redirect USB device to VM, the mismatched speed may prevent the connection.

As described above, I think specify USB controller for USB-passthrough is valuable in Openstack.


Problem description

=======

Use cases:

1. The administrator creates a VM with flavor which contains USB device information and USB controller information.

2. The system creates VM with USB controller specified in flavor above, it also attach USB device to the created USB controller but not the default piix3-usb-uhci.


Proposed change

===

We should add the following functions to nova: 1. When create flavor with USB device, specify the USB controller type for USB device.

2. Nova should support to attach USB device to specified USB controller when create VM.

Alternatives


None

Data model impact


1. The schema of flavor which contains USB device information and USB controller information may like this: {"usb_devices":[{"id": 5, "usb_controller_type": "ehci"}]}

2. In libvirt driver layer, add function to specify USB controller for USB device. Bellow is a example:

<hostdev mode='subsystem' type='usb'>

<address bus='2' device='3'/>

<address type='usb' bus='1' port='2'/> </hostdev>

System should select not duplicate port for USB device to attach.

3. In DB layer, add USB controller type parameter to USB device information which have been assigned to the VM.


REST API impact


NULL

Security impact


None

Notifications impact


None

Other end user impact


None

Performance Impact


None

Other deployer impact


None

Developer impact


None

Implementation

==

Assignee(s)


Primary assignee:

 <Jing Yuan>


Work Items


Step 1: Add USB controller type to USB device data model in libvirt driver.

Step 2: Implement function of choose USB controller port for USB device.

Dependencies

==

NULL


Testing

=

It is necessary to add tempest for this new function.

Documentation Impact

========

It is necessary to add doc for how to use this new function.


References

==

https://blueprints.launchpad.net/nova/+spec/usb-passthrough

https://blueprints.launchpad.net/nova/+spec/usb-passthrough

yuanjing ..

This work is licensed under a Creative Commons Attribution 3.0 Unported
License.
http://creativecommons.org/licenses/by/3.0/legalcode
========================================

Add support for USB controller

========================================

Users have requirement of using USB devices, the detailed information can reference the bp of https://blueprints.launchpad.net/nova/+spec/usb-passthrough.

If not specify appropriate type of USB controller for USB device, USB device will use the default piix3-usb-uhci, the default USB controller's speed may mismatch with USB device. This result in the following problems.

1. The low speed of USB device.

2. If use spice client to redirect USB device to VM, the mismatched speed may prevent the connection.

As described above, I think USB controller is valuable in Openstack.


Problem description

=======

Use cases:

1. The administrator creates a flavor with USB controller information, the key parameter is type like ehci.

2. The administrator creates a VM with flavor created above, the system creates USB controller for the VM.


Proposed change

===

We should add the following functions to nova: 1. When create flavor, specify a key-value for USB controller, the schema may like: {"usb_controllers":[{"type":"ehci"}]}

2. Nova should support to create USB controller in libvirt driver when create VM.

Alternatives


None

Data model impact


We should add USB controller data model in libvirt driver for constructing USB controller xml when create VM.


REST API impact


None

Security impact


None

Notifications impact


None

Other end user impact


None

Performance Impact


None

Other deployer impact


None

Developer impact


None

Implementation

==

Assignee(s)


Primary assignee:

 <Jing Yuan>


Work Items


Step 1: Implement function of construct USB controller xml in libvirt driver.

Step 2: Implement function of create USB controller when create VM.

Dependencies

==

None


Testing

=

It is necessary to add tempest for this new function.


Documentation Impact

========

None


References

==

https://blueprints.launchpad.net/nova/+spec/usb-passthrough