|
|
首先安装usb
* }& n: z) p& q6 D# A: r; rrpm -ivh usbutils-007-5.el7.x86_64.rpm 9 }. O0 A: U) j8 J
使用lsusb命令查看:
! O: q- R/ d9 G% L5 |, n(nova-libvirt)[root@compute07 /]# lsusb -v
( ]% e9 I3 k1 Q& M1 }, W' }, ]$ [
4 H+ Y- `1 _) v8 |Bus 002 Device 003: ID 0781:5588 SanDisk Corp. ' f. z; P' ]. O( D
Device Descriptor:+ i$ N# o! P$ M" |
bLength 18
% ^7 {3 P- V5 Y bDescriptorType 1
$ Z+ c: m/ A1 K# s bcdUSB 2.103 h1 X; S8 ^0 l. [
bDeviceClass 0 (Defined at Interface level)* K0 D% n9 J: H$ L- _
bDeviceSubClass 0 2 E& S+ u& M( c/ H8 n
bDeviceProtocol 0 / M2 Y' y/ P1 R4 U; W
bMaxPacketSize0 64' o) R) J/ a8 t
idVendor 0x0781 SanDisk Corp.0 |/ ]! ~" ^; M3 `) L
idProduct 0x5588
. V$ \$ x6 M8 s7 b# m+ H bcdDevice 1.001 U4 Q, y0 O, w8 i/ f
iManufacturer 2 SanDisk# C8 E, B' C% J5 \# ~) i* D
iProduct 3 USB Extreme Pro
! [. g/ h. \* g/ h$ t5 t3 ~ iSerial 1 00000000000000000000
+ J5 i) Z* ^: v& @4 d1 S# m0 Y bNumConfigurations 1
" a( I- u; B$ v* i$ v1 n6 L" s" R Configuration Descriptor:
8 q: p# S& c1 p8 |3 M2 H6 D bLength 9
+ J8 X2 `, R1 g1 T bDescriptorType 2
* G! ~% H/ t* g, X6 S wTotalLength 32
+ w, j3 X; X/ Q8 X* l bNumInterfaces 17 I Y9 |2 Y r* I% j
bConfigurationValue 1
: v' \* K6 ?; K$ u iConfiguration 0 + ?. R7 ~! X! Q1 N& o) a
bmAttributes 0xc0 |4 f- R3 O' R& T# A4 G/ T. _
Self Powered# i( u3 G6 F/ f2 {5 k# ^+ s5 W) ~4 j8 o
MaxPower 0mA4 i9 Y$ }0 g) ]% F7 V0 v2 j
Interface Descriptor:
. C5 S( z3 O' V/ u ~( I4 ~ bLength 9( u z: a% s3 t G2 d
bDescriptorType 41 a3 E$ s/ I2 k; |+ @
bInterfaceNumber 0. n& r2 D- a8 @* v; a
bAlternateSetting 0$ V; u6 d% i+ y$ X: n9 h
bNumEndpoints 2
( c" W, U9 E) u; Q) k! o' |8 E bInterfaceClass 8 Mass Storage
! [* m. L# \6 Q0 w- h! x3 ?5 Y5 K bInterfaceSubClass 6 SCSI
; b$ j8 Z+ f' b: m0 H: o bInterfaceProtocol 80 Bulk-Only
- K1 k% I( r5 ~- y iInterface 0 ! Y C6 Y# ?6 F5 _" |
Endpoint Descriptor:
+ d2 F1 Z% ~' a/ z8 i bLength 7
4 L$ C, | @7 }2 ~' R q% e bDescriptorType 5+ Q( A2 s6 S) q/ C+ j
bEndpointAddress 0x81 EP 1 IN
" ]3 K* x& P- @# {7 z7 h/ A( k bmAttributes 2
: k0 @* o. K8 f Transfer Type Bulk
[9 s5 O- v& k3 p Synch Type None
9 l/ B3 o: ^$ w z! K! J& n Usage Type Data2 d' V; V+ d; v9 H
wMaxPacketSize 0x0200 1x 512 bytes
$ ^& U" l0 t0 g; v, ~ K bInterval 0
) [: u, V% e8 ]* u5 w: T- f- I5 _0 ^ Endpoint Descriptor:7 z8 S z, q' z* o6 D/ |7 V$ s4 R" s4 ?
bLength 77 U0 n& ]/ f: C# j0 K# I0 c
bDescriptorType 5
5 S6 t9 D* ~, M& L. ^+ V bEndpointAddress 0x02 EP 2 OUT7 v5 Y3 a0 r9 w$ R
bmAttributes 2
o% l+ ^( p7 o2 k' [ Transfer Type Bulk: f; d1 y1 ~/ T, L2 d( g1 i
Synch Type None
% w: ]9 E# J# L4 s Usage Type Data
( B( B1 v, ]( m. i& V wMaxPacketSize 0x0200 1x 512 bytes
7 n( `) |0 [ x/ k4 W# v7 Z bInterval 0, i0 l! |& `+ ~1 J8 H
Binary Object Store Descriptor:$ b. {7 y' l9 ~4 r0 {# t( W# j+ R5 o
bLength 5
' f0 h* R5 s3 T/ G u* T2 P bDescriptorType 155 A \4 _6 P$ J* Y3 `4 Y
wTotalLength 22$ l; |, J6 t! \/ _
bNumDeviceCaps 2
/ }. c# P" |4 g" {* c- x USB 2.0 Extension Device Capability:7 W) F* l. D) R; ^* T: M
bLength 70 V6 C- W8 _/ d+ B! P0 l
bDescriptorType 16
6 j# `/ D, `- B* P bDevCapabilityType 2- X, u/ f) J' c) I6 F; r! o
bmAttributes 0x0000f41e
. k8 ]$ @) s$ n4 L; C( { Link Power Management (LPM) Supported
0 o! @$ k, E: l5 N' G, z6 q$ s b SuperSpeed USB Device Capability:
2 D2 V, K% j: Z0 h( w bLength 10( C G8 s+ J! O# T% X. ]- l2 K
bDescriptorType 16" V( v7 N* x2 ]9 T# ~ |$ m
bDevCapabilityType 3
& a# X0 D. C, A; f( }) r8 @4 m) d bmAttributes 0x00
% M: I; ?- `. h* ^9 X ^, I wSpeedsSupported 0x000e1 l( \' e1 E6 j
Device can operate at Full Speed (12Mbps); c/ l$ h/ M' t. V% C
Device can operate at High Speed (480Mbps)
# U. g5 {! P. K9 A {, r Device can operate at SuperSpeed (5Gbps)6 d) O/ {; D" a7 B' M
bFunctionalitySupport 1+ R9 W* v+ { v" X3 r+ A7 Z
Lowest fully-functional device speed is Full Speed (12Mbps)
; ` b a) d& q6 \" }! A bU1DevExitLat 10 micro seconds6 |0 v7 h+ D! k9 z
bU2DevExitLat 2047 micro seconds& t; u# J; J/ N0 S+ z) s
Device Status: 0x0001
+ s1 d/ O5 W7 I2 e Self Powered
. S* Z. j d. P! T0 @1 `
# L6 H5 N/ t7 A1 k0 j" g' d编辑xml文件:3 ^' a" B- R- A7 Z6 v* R+ y
3 Z. ~/ Q& @6 W/ i' A
(nova-libvirt)[root@compute07 /]# vim usb.xml " ]; m I) ^( S d- S6 G9 m1 D$ s! Y
<hostdev mode='subsystem' type='usb'>
" z* P8 f& d* z" @- Z( u: T& x<source startupPolicy='optional'>6 n! H; ~! U' x5 O @0 {/ O
<vendor id='0x0781'/>) a: H# I# q2 O% B0 A
<product id='0x5588'/>/ z" U2 ^' H% j4 G e* q* W
</source>; H3 [9 s6 ~. H7 S
</hostdev> Y- Q4 t- {7 c/ b# s# \0 j
2 I5 M: g5 y' \! ~4 Z) s N. ]- \3 F
添加usb到虚机
# B" F0 J1 X: w
+ f8 T9 Y/ ^1 B v8 \" N* v# {(nova-libvirt)[root@compute07 /]# virsh attach-device instance-00000162 usb.xml
j' c* @: X7 {6 N$ F5 PDevice attached successfully; \; y; I( k1 V( g1 D
. @* M. U1 n- C* }. `- N
(nova-libvirt)[root@compute07 /]# virsh detach-device instance-00000162 usb.xml & O6 N( U8 ^( X& i4 y$ u
Device detached successfully
3 \' A8 T& r$ w( Y0 x
; G4 x7 g0 j+ b1 f/ n, x+ _! H1 w. Q1 {9 x: X# w; }. L
1 G+ S) S/ ?8 P
4 B2 ^) E3 R, J2 K
" T0 V- ^) Z- E6 n( w$ i9 J- ?. @
9 @8 a L1 _7 `- o- r |
|