|
|
virsh 在线添加设备cdrom或者iso镜像8 _3 `4 E1 ?: N, R: j
virsh domblklist Windows2019_x86 " C& R6 K! d! ?
Target Source
. Q# [, w- m! q6 e T3 `----------------------------------------------------------------
0 J3 e( A' H8 z- |: M vda /usr/src/Windows2019-x86.qcow2; L1 w) `) c" t$ d S' R; ~/ Q
sda /usr/src/cn_windows_server_2019_x64_dvd_2d80e042.iso
$ t" `" S& h& [0 `" i3 M- c
8 F. o4 e, o- N, b+ c; o) t- R, R" b+ H _: \1 e; U$ n
5 N5 h b# K* C$ H9 k1 b8 B5 N
virsh attach-disk Windows2019_x86 --target sdb --type cdrom /usr/src/virtio-win-0.1.225.iso --mode readonly
" }8 r* _2 c0 _5 ~error: Failed to attach disk8 A/ y& L8 R$ l& _& a
error: Operation not supported: cdrom/floppy device hotplug isn't supported7 p# @3 S$ r0 x. _! {. Y
+ Z$ G8 e& m1 d/ [! C% E# \
3 |6 V. ~- X1 }2 \7 E1 p; F* x/ G7 _
root@compute01:/usr/src# virsh attach-disk Windows2019_x86 /usr/src/virtio-win-0.1.225.iso sdb --cache none --subdriver cdrom --config --persistent
8 }, e( w6 C! u) h" Herror: Failed to attach disk
, c/ e' \7 n* t& Serror: unsupported configuration: unknown driver format value 'cdrom'
# ]! R8 X5 z" ^! @8 H1 F1 O! `
8 H" d$ V6 {. x' N, \' [root@compute01:/usr/src# virsh attach-disk Windows2019_x86 /usr/src/virtio-win-0.1.225.iso sdb --cache none --subdriver qcow2 --config --persistent
# `3 L9 S( B% L# @% S% Ferror: Failed to attach disk
+ n8 U3 V2 s5 m0 ^error: internal error: No more available PCI slots
* `& p9 l" l/ E# U3 p* J0 V* y; g$ K
root@compute01:/usr/src# virsh attach-disk Windows2019_x86 /usr/src/virtio-win-0.1.225.iso vdc --cache none --subdriver qcow2 --config --persistent % x+ V$ i9 R4 d
error: Failed to attach disk5 c- g, l5 v9 q
error: internal error: unable to execute QEMU command 'blockdev-add': Image is not in qcow2 format. \6 l' O: ?% m& v6 }0 O3 z
4 I! x& G% p. A1 ^; g: broot@compute01:/usr/src# virsh attach-disk Windows2019_x86 /usr/src/virtio-win-0.1.225.iso vdc --cache none --subdriver raw --config --persistent
0 L' I- h0 L/ F! Q2 c0 JDisk attached successfully9 }6 ~0 P; C+ H! p& w. c7 U, R
, @* e8 s9 k. u9 M
6 y- I1 h2 a0 o' M9 e, N# G! l! L$ \
+ W" b9 ~' g6 Y' L$ aroot@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
4 q9 J1 w5 W# e6 L
9 s$ l P- C* z6 g8 S9 p: L2 RStarting install...
% G, X2 t5 Q- @8 l: ZERROR Cannot get interface MTU on 'br0': No such device/ }% ?$ {1 s" i" F1 y: x( h& f" j
Domain installation does not appear to have been successful.
! y+ Y8 _/ h# v% p' e8 p$ C, k# RIf it was, you can restart your domain by running:5 n) Q5 i$ Q/ F; _
virsh --connect qemu:///system start Windows2019_x86
0 h6 @; S5 p) c7 xotherwise, please restart your installation.
& Y7 p& c. W, w9 p0 g0 G7 vroot@compute01:/usr/src#
. @6 K. E1 ^+ B1 N9 A/ l+ c- V( jroot@compute01:/usr/src#
$ ]2 G4 p I2 Y* m: \! Oroot@compute01:/usr/src# netplan apply
7 }# R: j# {* i) r: E0 O/ O. \) p, K+ X; i! C
** (generate:8799): WARNING **: 13:35:59.651: `gateway4` has been deprecated, use default routes instead.2 g( z4 a) c. W& f( j" m
See the 'Default routes' section of the documentation for more details.$ r4 ?; b$ {; p/ F2 b B
! T& D1 Y: W3 X8 h$ E" r8 Z
** (process:8797): WARNING **: 13:36:01.040: `gateway4` has been deprecated, use default routes instead.
# B4 {/ `9 d6 t6 ~- R- sSee the 'Default routes' section of the documentation for more details.
9 f% ?! \3 W0 ~! n( v2 ~7 ]% H2 B, n# {
** (process:8797): WARNING **: 13:36:01.052: `gateway4` has been deprecated, use default routes instead.* S1 \; L% V; \2 P
See the 'Default routes' section of the documentation for more details.
. r' _$ w8 r4 B2 x! b; o O& M6 k4 `$ h0 j; S
: V t$ X9 n9 Y9 t** (process:8797): WARNING **: 13:36:01.589: `gateway4` has been deprecated, use default routes instead.4 F1 g$ g. r% U( Z
See the 'Default routes' section of the documentation for more details.
8 P q6 k! G. L, _& C3 C$ ]2 H# G" j W& x- c% d: r4 F
** (process:8797): WARNING **: 13:36:01.589: `gateway4` has been deprecated, use default routes instead.
8 n8 J4 i( f) |4 ISee the 'Default routes' section of the documentation for more details.
' r% m$ j$ x, j- l/ Aroot@compute01:/usr/src#
; v. Y2 u- a5 [4 Z$ Q' {: vroot@compute01:/usr/src# / f9 A0 J7 d6 y0 @3 t
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+ Q: C% {- @7 Q6 }. i
3 m9 X: g9 V1 P) \& W8 @6 U: U& S
Starting install...
6 L M$ y3 k5 O% d) \& \Creating domain... | 0 B 00:00:00 - l- j6 W; X! W( W/ V
$ L% E% C1 N% h3 y, C1 K8 a) a' gDomain is still running. Installation may be in progress.' M y2 U1 J9 Y5 `! n/ Z9 J
You can reconnect to the console to complete the installation process.! G. @' c& Y! B# a% X' D3 g/ N
root@compute01:/usr/src# 4 ~/ S" m8 z @/ s- h/ Z( _! m8 X
$ S6 b2 L; T- \" ]0 A: \$ }9 {) v/ Q1 K在线添加光盘& s% n5 W$ V k# y: ^2 C! K
virsh attach-disk Windows2019_x86 /usr/src/virtio-win-0.1.225.iso/ vdd# v5 m& L" C n# w& S; L% e2 I
( H7 D# z% h& \# G+ k8 ^
其他方法:
7 \, ?9 s/ b. W( v7 x1 h) @7 N
$ n9 z* g) z1 u: j2 ^, Q6 K. L3 R: d" ^0 T, T8 `3 ]
再次使用 virsh dumpxml sles12-sp3 可以看到iso文件加载:6 U5 a. b1 m& Z: l
$ z1 a% h( q: q" l3 Q. F6 N<disk type='file' device='cdrom'>
! i9 O3 B* F+ O. i, A+ R$ E9 p <driver name='qemu' type='raw'/>+ p: h, ^" O% `) K
<source file='/var/lib/libvirt/images/SLE-12-SP3-Server-DVD-x86_64-GM-DVD1.iso' index='3'/>
. r+ ?; P4 g: _. i <backingStore/>4 b0 d$ T3 v: B$ F
<target dev='sda' bus='sata'/>
5 L0 ` C1 H- U5 W. | <readonly/>
' J1 P, k* t; o+ r( H/ r <alias name='sata0-0-0'/>
5 n) r: J o' j% t! m6 c f <address type='drive' controller='0' bus='0' target='0' unit='0'/>1 k8 k' J' D+ A' ^$ M4 q/ e
</disk>
3 q! r6 |3 i1 t {3 W; a9 ^2 ^如果要卸载这个iso文件,则创建一个相同结构的xml文件 detach_iso.xml ,但是保持 <source/> 行删除:/ Q( P c& |" ]
' I' F$ E+ Y4 B! M, `% A<disk type='file' device='cdrom'>
! i* \# r4 D1 M <driver name='qemu' type='raw'/>
% O4 y3 }2 A: O) F- n# T' M! R <backingStore/>4 k( M) g) ~4 l" r$ {
<target dev='sda' bus='sata'/>& J. Y) x! J; O2 {* d) t
<readonly/>! |" _" V# V9 _( q- b S7 N
<alias name='sata0-0-0'/>
7 R- x2 T6 J5 a$ Z( l# V: T$ B, V <address type='drive' controller='0' bus='0' target='0' unit='0'/>
7 P( z0 A# z! o G: |. r# M' X</disk>
/ D# W7 m7 m. a* [ k3 _( P% T然后执行设备更新:
* d' r& G, _; M$ ?' J
7 @) C8 L4 y- t& t5 q7 d7 a* Svirsh update-device sles12-sp3 detach_iso.xml
/ l. O$ q0 C2 w, D9 Y" w6 h此时提示:
* f0 d, }# g4 G. H7 C, n
( R4 b! Q! U7 C) B( K( \Device updated successfully
# O" k0 x' L& E. d4 H) h再检查虚拟机配置,就看到iso文件已经卸载了。
3 Q3 B' [& ^1 o) o1 Z, k" u3 g; q4 L% o- W3 M2 v) C& c
|
|