|
|
virsh 在线添加设备cdrom或者iso镜像/ P+ F) a+ Y) c8 r! }
virsh domblklist Windows2019_x86 ; i# u- ]; l+ C6 G2 c+ M
Target Source
M/ _) |* f( X: ~- b* }. f! g----------------------------------------------------------------+ [+ G! [$ O$ a: r' G
vda /usr/src/Windows2019-x86.qcow22 i/ m. U& }& D' t9 }. B' V. `
sda /usr/src/cn_windows_server_2019_x64_dvd_2d80e042.iso2 y& b0 j) ]0 J" E, x& e
3 i0 s2 ~) [& _, y, B3 t
9 f3 ?- b! K, h3 ?( u9 O2 E2 K
( H: w! c. @" {* z5 X& f2 mvirsh attach-disk Windows2019_x86 --target sdb --type cdrom /usr/src/virtio-win-0.1.225.iso --mode readonly " x, r9 f: w @# w2 B
error: Failed to attach disk$ P7 a. m. {) k' |
error: Operation not supported: cdrom/floppy device hotplug isn't supported
7 m! {6 k7 `! v3 s, e2 o' j+ }3 l: Y% c3 |1 n
" d) h- i$ u; V: B8 {' f
: ?; j. X- H8 r$ E5 Droot@compute01:/usr/src# virsh attach-disk Windows2019_x86 /usr/src/virtio-win-0.1.225.iso sdb --cache none --subdriver cdrom --config --persistent
" y4 f% L, n$ o, g4 terror: Failed to attach disk
% [5 Q `; ?" ]0 Y* o, kerror: unsupported configuration: unknown driver format value 'cdrom'5 U$ F( e0 P- q/ N5 Z) N
! j% \! g! U) k7 F/ l( \
root@compute01:/usr/src# virsh attach-disk Windows2019_x86 /usr/src/virtio-win-0.1.225.iso sdb --cache none --subdriver qcow2 --config --persistent
1 I5 s; P x/ q8 O' G; K" j0 v* m4 Jerror: Failed to attach disk
$ ~" Z' U! z- X5 p* w; z3 w4 }$ f+ Eerror: internal error: No more available PCI slots
4 o7 @# t- S0 W. Y3 j' p, t% f/ ?% I% i) Z! o( c* m/ i! z4 p
root@compute01:/usr/src# virsh attach-disk Windows2019_x86 /usr/src/virtio-win-0.1.225.iso vdc --cache none --subdriver qcow2 --config --persistent
' m7 v% R- d4 j# K9 _% D) V% }1 o: jerror: Failed to attach disk8 P3 S9 `6 e ~. F
error: internal error: unable to execute QEMU command 'blockdev-add': Image is not in qcow2 format
6 Y e* _! y! l+ z$ h* V! w1 d v" ]# P) z: R; j
root@compute01:/usr/src# virsh attach-disk Windows2019_x86 /usr/src/virtio-win-0.1.225.iso vdc --cache none --subdriver raw --config --persistent
: X; f* [5 Y# U# A+ l0 pDisk attached successfully" O9 |( X9 R) R( `5 P! r: q9 C
% c" R+ D+ ?5 H) q) c
% Z' U0 r) L1 _* ^/ T0 d
% J2 X. v, w/ M( ?% o. Rroot@compute01:/usr/src# virt-install --name=Windows2019_x86 --ram 8192 --vcpus=4 --disk path=/usr/src/Windows2019-x86.qcow2,format=qcow2,size=15,bus=virtio --accelerate --cdrom /usr/src/cn_windows_server_2019_x64_dvd_2d80e042.iso --vnc --vncport=5906 --vnclisten=0.0.0.0 --network bridge=br0,model=virtio --noautoconsole --disk path=/usr/src/virtio-win-0.1.225.iso,device=cdrom
) W/ B T- _3 p( r5 M
& f5 V0 Z+ P+ CStarting install.../ n& a l; B; F6 n1 L" P |$ z
ERROR Cannot get interface MTU on 'br0': No such device
" b9 ^0 T# I m7 bDomain installation does not appear to have been successful.
/ W# q: U& X7 F- UIf it was, you can restart your domain by running:& g4 c: H) J! m7 ?
virsh --connect qemu:///system start Windows2019_x86
" x5 z. ~' o9 p" |# [/ ?) F+ ]otherwise, please restart your installation.
: n% }8 Z n+ m3 [* M6 C: F3 oroot@compute01:/usr/src#
# G# q* @( `$ S* `root@compute01:/usr/src#
- t7 B3 x" [; @! broot@compute01:/usr/src# netplan apply
' ]" k" C& h, a9 r4 D8 Y
( ~: I- j& e: Y4 l# L** (generate:8799): WARNING **: 13:35:59.651: `gateway4` has been deprecated, use default routes instead.+ Y6 }2 l1 X; B s
See the 'Default routes' section of the documentation for more details.
% C% @* \2 L# k! b" ^
" x" K: B3 h C. B( _** (process:8797): WARNING **: 13:36:01.040: `gateway4` has been deprecated, use default routes instead.
6 N3 i0 O+ T9 f* ?( Z$ mSee the 'Default routes' section of the documentation for more details.
; C6 E) r9 k( {' J5 w0 w
, @# ]7 V9 ?# N& |4 b3 a+ y** (process:8797): WARNING **: 13:36:01.052: `gateway4` has been deprecated, use default routes instead.$ H6 j; e* c5 x2 w1 {1 p* S& }
See the 'Default routes' section of the documentation for more details.
% ^* _$ \# q! v) f4 X
- r, }' [. ~# f: p% ?& w* @** (process:8797): WARNING **: 13:36:01.589: `gateway4` has been deprecated, use default routes instead.0 J, U4 n' `5 s9 a
See the 'Default routes' section of the documentation for more details.8 t# x; v2 L4 K9 c2 p% H+ o
8 Q6 k6 l* C B" c- w% d9 w** (process:8797): WARNING **: 13:36:01.589: `gateway4` has been deprecated, use default routes instead.9 Z" R: `9 O0 U( x
See the 'Default routes' section of the documentation for more details.4 i& W! \) C$ t4 P7 B
root@compute01:/usr/src# 4 o! V* c( y- m
root@compute01:/usr/src#
7 R7 a k4 S8 n7 a* I1 ^root@compute01:/usr/src# virt-install --name=Windows2019_x86 --ram 8192 --vcpus=4 --disk path=/usr/src/Windows2019-x86.qcow2,format=qcow2,size=15,bus=virtio --accelerate --cdrom /usr/src/cn_windows_server_2019_x64_dvd_2d80e042.iso --vnc --vncport=5906 --vnclisten=0.0.0.0 --network bridge=br0,model=virtio --noautoconsole --disk path=/usr/src/virtio-win-0.1.225.iso,device=cdrom
* k2 i( F# }& [' J! ^" g% r' g U% P
Starting install...' k0 f! m1 d9 Z$ U+ ~
Creating domain... | 0 B 00:00:00 % u' U4 I* Y: P/ W; l1 J
/ C1 W7 V9 ]6 c. F! Q+ D% K
Domain is still running. Installation may be in progress.4 L, H0 o* O/ B; h9 L- e$ s7 w
You can reconnect to the console to complete the installation process.
$ ~# |9 ?/ F0 O2 I, K* F7 y9 m) Proot@compute01:/usr/src#
6 w* D& r9 x* F2 v+ o. k5 I
' m3 n) G5 o) C# W% G$ @; D在线添加光盘
) x9 z* t* H+ _6 Z9 qvirsh attach-disk Windows2019_x86 /usr/src/virtio-win-0.1.225.iso/ vdd# K5 m3 [+ S( `4 L
3 X2 ?+ L: D2 B! k/ G4 x+ I: U7 A& L2 ^其他方法:
) X7 A J1 Y% |$ P& J7 T1 u, s0 b6 K
- N) O9 W3 `( u" m
再次使用 virsh dumpxml sles12-sp3 可以看到iso文件加载:5 D9 ~ N. R8 Z; G1 A5 p% X
& O3 c) s* D+ d+ l' D
<disk type='file' device='cdrom'>
; Q9 }3 i4 v1 W <driver name='qemu' type='raw'/>4 i. Y1 k# P* \+ n2 b
<source file='/var/lib/libvirt/images/SLE-12-SP3-Server-DVD-x86_64-GM-DVD1.iso' index='3'/>& p. \8 E3 n$ w! x: @
<backingStore/>. K" P% F8 G P) B {7 e
<target dev='sda' bus='sata'/>
* B* C# r3 ]4 a <readonly/>5 n5 P! W, W+ X: U- e2 e0 j
<alias name='sata0-0-0'/>
* I$ S6 Y& t' v8 r v <address type='drive' controller='0' bus='0' target='0' unit='0'/>
2 k: N" [* v# x) b</disk>6 K' R& J/ t" o& f. @
如果要卸载这个iso文件,则创建一个相同结构的xml文件 detach_iso.xml ,但是保持 <source/> 行删除:
5 L b5 S2 J# o8 Z5 M3 ~- K1 k" u4 G3 O) p9 V0 g7 g& {: f2 H
<disk type='file' device='cdrom'>4 j) `* h* B: W7 l5 c* Q
<driver name='qemu' type='raw'/>, J1 F# {- C7 t1 [' J$ P6 _8 M' Z, `
<backingStore/>( _$ {( M: N6 N
<target dev='sda' bus='sata'/>
: V" L4 ?0 b1 G" n% E- Y <readonly/>
2 X4 k5 i: @6 C; c4 x <alias name='sata0-0-0'/>% t8 O' H7 H. @+ ^
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
- k: \5 P/ |4 E8 l8 i</disk>& M5 h: L, Q; N. p- ~
然后执行设备更新:
: e0 L) P5 S3 G! }1 q+ t+ a4 X9 X+ U7 B: z" R
virsh update-device sles12-sp3 detach_iso.xml' g4 m4 X; D$ [; R. O
此时提示:
5 a7 [4 E- R$ O c4 H/ G9 y. @3 l; l
; q& H- {) ~0 w# Q5 q3 H2 [$ dDevice updated successfully
$ H& N+ J. X \4 Q# d1 B) c再检查虚拟机配置,就看到iso文件已经卸载了。
+ z! W+ j+ Q* m0 B( ~- q7 X# L) J8 b0 U) F
|
|