|
|
virsh 在线添加设备cdrom或者iso镜像0 A3 u& {' ?' o# R" D
virsh domblklist Windows2019_x86
" A6 @# ]! a" n ]/ M2 l/ E Target Source
& X; T+ t4 }6 r* G5 I----------------------------------------------------------------. d$ O) `( ^7 M# M5 Z
vda /usr/src/Windows2019-x86.qcow2
9 \5 m8 u5 M/ @: r# ]! N Z sda /usr/src/cn_windows_server_2019_x64_dvd_2d80e042.iso5 E& C6 w' ?4 R; B
6 D0 E) q- t D: |) Z
$ }3 p4 j: \, I* H1 S! m6 v! D
0 y4 C6 f" s4 h& y- ]" @virsh attach-disk Windows2019_x86 --target sdb --type cdrom /usr/src/virtio-win-0.1.225.iso --mode readonly
t" l+ r$ _5 @. r! y; H! ferror: Failed to attach disk
3 U! s; l* ?* _: i/ ~7 M$ Herror: Operation not supported: cdrom/floppy device hotplug isn't supported
2 J% Z5 X' s1 m, y% q8 O3 b& ^: P; Q g' ^( D
$ l# ?9 x! X; L4 |
7 n2 {; r0 p" O4 V1 w2 [8 Yroot@compute01:/usr/src# virsh attach-disk Windows2019_x86 /usr/src/virtio-win-0.1.225.iso sdb --cache none --subdriver cdrom --config --persistent
$ ^) D1 |: ]- N s2 p& g ]( a3 uerror: Failed to attach disk
9 O7 y6 A( o5 v X4 O# oerror: unsupported configuration: unknown driver format value 'cdrom'
0 P. b* W( k. i6 M) ]$ z3 E# O) ]
root@compute01:/usr/src# virsh attach-disk Windows2019_x86 /usr/src/virtio-win-0.1.225.iso sdb --cache none --subdriver qcow2 --config --persistent + y5 ]0 G' g( k# m
error: Failed to attach disk
0 }! z3 X* Q6 [8 e+ }: Yerror: internal error: No more available PCI slots. b/ o+ v7 n1 l& k
1 q8 G: {$ k: u+ `7 S
root@compute01:/usr/src# virsh attach-disk Windows2019_x86 /usr/src/virtio-win-0.1.225.iso vdc --cache none --subdriver qcow2 --config --persistent - N7 Q" r" a; @$ e1 {2 n
error: Failed to attach disk/ K+ }4 [# M. H5 T; v/ G1 @
error: internal error: unable to execute QEMU command 'blockdev-add': Image is not in qcow2 format
- a0 K B3 K" P" d
+ S' j7 t: M, p( H) d# @2 d% Xroot@compute01:/usr/src# virsh attach-disk Windows2019_x86 /usr/src/virtio-win-0.1.225.iso vdc --cache none --subdriver raw --config --persistent 1 w+ X# L4 Z! V" Y3 H
Disk attached successfully1 V3 O& L# }( j9 b6 h
+ }% V9 E6 E, A( t- g
) |' M$ P: C4 ~4 d+ c$ F* O, p" [$ J* B0 T" F) s
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=cdrom0 u6 T* ], G5 J, T& }; M
$ s$ f" V4 a4 q" a5 O
Starting install...
5 M- Z$ J" ^" Y- @ERROR Cannot get interface MTU on 'br0': No such device
% M0 j! }% \: H' s# p6 [Domain installation does not appear to have been successful.
; |( p. o+ v- ^8 V$ pIf it was, you can restart your domain by running:, Q; p* G9 l, d4 s
virsh --connect qemu:///system start Windows2019_x865 x& R, T' z+ d9 s1 |
otherwise, please restart your installation.: O* d0 ?9 i2 S
root@compute01:/usr/src# ' s' ], @/ K0 G/ w1 o
root@compute01:/usr/src#
' K9 n: {, U- e% v% o' Froot@compute01:/usr/src# netplan apply
) ~+ P+ ~+ {& ]& F0 b6 [! L# T/ x* X' M: E) \0 d
** (generate:8799): WARNING **: 13:35:59.651: `gateway4` has been deprecated, use default routes instead.( N' G. A; ^, k: n
See the 'Default routes' section of the documentation for more details./ W! W4 k5 x2 I5 P9 U8 T: z0 e
. B# t% n; }3 A1 }, d& I** (process:8797): WARNING **: 13:36:01.040: `gateway4` has been deprecated, use default routes instead.- _$ S) C: [. T$ w
See the 'Default routes' section of the documentation for more details.9 {" m* P3 a+ ?% {9 z
. Q# p% j3 A0 j% E. W: P, Q
** (process:8797): WARNING **: 13:36:01.052: `gateway4` has been deprecated, use default routes instead.5 O8 N! r( Z j: J, Y& Z5 \
See the 'Default routes' section of the documentation for more details.
; P1 q9 K o5 {1 ~' f( F7 T9 J
** (process:8797): WARNING **: 13:36:01.589: `gateway4` has been deprecated, use default routes instead.
1 b W0 J5 b% I+ RSee the 'Default routes' section of the documentation for more details.1 o7 C: e2 a% U; L: D1 \
, C+ e K5 A& ?0 I# E
** (process:8797): WARNING **: 13:36:01.589: `gateway4` has been deprecated, use default routes instead. r G4 }* D7 y0 f( \
See the 'Default routes' section of the documentation for more details.
+ |2 R& n) V. P- Iroot@compute01:/usr/src# / |* j$ M5 e9 W* o7 b
root@compute01:/usr/src# " J& {& l, ~: R2 p e/ Y( y
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' M; R" o2 i* X: Y) |% G- i( m
" I v5 n0 E/ Y4 R7 O& O
Starting install...! ?* y) }/ Z! U. V) {: J: o& F& Q
Creating domain... | 0 B 00:00:00 7 `9 R# E" m5 a0 C" K; u
& @% y: k/ N' w x! o1 HDomain is still running. Installation may be in progress.
: f% F' }( Y% w8 RYou can reconnect to the console to complete the installation process.4 [1 k* W6 B @: e4 Z7 p
root@compute01:/usr/src# 9 \& x2 A& [1 k9 ]
1 Q8 A; ~; v+ a
在线添加光盘5 a* ?" y/ `& z. A+ |' x
virsh attach-disk Windows2019_x86 /usr/src/virtio-win-0.1.225.iso/ vdd8 g' F, z( ~4 ?* U
# z, w2 O3 V6 b% p
其他方法:
. I8 O' `4 a9 G% x1 u; x6 ]' p* B1 ?2 h5 s1 v' _
6 I6 D: _6 ]* ~6 x' Y再次使用 virsh dumpxml sles12-sp3 可以看到iso文件加载:
0 ` B1 t- Y/ p q# J5 W: F9 A2 R& n! w6 M _& i
<disk type='file' device='cdrom'>
# n+ s6 g, w* t; B( r <driver name='qemu' type='raw'/>
* [, i1 l: \$ [7 t <source file='/var/lib/libvirt/images/SLE-12-SP3-Server-DVD-x86_64-GM-DVD1.iso' index='3'/>: M( d6 l9 F6 i! f% A
<backingStore/>- | s8 o# N- F& E* p0 d i2 K
<target dev='sda' bus='sata'/>
; m* B) M5 a) o* m# }( X <readonly/>, O2 \, v- ?/ z- w4 u% V6 X
<alias name='sata0-0-0'/>8 N% _/ \5 j# [: ^; V
<address type='drive' controller='0' bus='0' target='0' unit='0'/>2 w3 s4 S, }$ W4 M
</disk>
8 x1 R7 g! `# T9 [' P: c如果要卸载这个iso文件,则创建一个相同结构的xml文件 detach_iso.xml ,但是保持 <source/> 行删除:
( w- e z9 g4 E0 w2 B* m8 g8 B$ A1 Z. b2 R+ N# ~4 t: ]
<disk type='file' device='cdrom'># _8 f( k5 Z1 } l& }4 z
<driver name='qemu' type='raw'/>: E7 y$ S% Q. e1 \
<backingStore/>/ c* o! e( M6 a; J% q
<target dev='sda' bus='sata'/>
7 `; L) X$ s3 w2 P1 ` <readonly/>* @5 D4 D9 Z4 X [- F. v
<alias name='sata0-0-0'/>: G n. B( @0 M& Y0 E- t: ^
<address type='drive' controller='0' bus='0' target='0' unit='0'/>0 B3 A- }' s+ b4 l& l! n/ I/ y
</disk>
1 q# { U+ F( W c9 m然后执行设备更新:
* E! w n8 w7 Q1 [# n% {
0 z. z: y& S% V3 H+ @virsh update-device sles12-sp3 detach_iso.xml/ v9 e' K9 G0 P5 o5 b! x
此时提示:
! K0 O2 X9 T, u+ @) l$ H" L
* x8 v8 w' ?+ ^* z9 |0 BDevice updated successfully
1 m" @2 C1 g( L再检查虚拟机配置,就看到iso文件已经卸载了。
; T' I- O5 v2 ^$ c+ S7 Q* {) V- j+ V9 F4 ?0 p
|
|