- 积分
- 16844
在线时间 小时
最后登录1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?开始注册
x
virsh 在线添加设备cdrom或者iso镜像+ F9 M/ D& D& U) }7 f8 D5 Q, G
virsh domblklist Windows2019_x86 / P9 t5 f5 \' L6 P) V
Target Source
# `% d# r0 A9 V$ s& C----------------------------------------------------------------
) @! S$ p, s. q# ]1 R" M V/ ~+ S& W vda /usr/src/Windows2019-x86.qcow2
: Y' B/ R/ V1 I; w+ B8 ^( Y sda /usr/src/cn_windows_server_2019_x64_dvd_2d80e042.iso
3 s% u1 {! [' w1 j5 Z& P8 y) U9 L! k$ W: c3 o3 u7 n
3 O0 V# q% z& I" I. ]% {) {# f/ w7 r9 L9 v
virsh attach-disk Windows2019_x86 --target sdb --type cdrom /usr/src/virtio-win-0.1.225.iso --mode readonly
: k2 `6 O6 i2 u! o- F- a: a' ?error: Failed to attach disk
/ ~1 _1 @% o6 s* Cerror: Operation not supported: cdrom/floppy device hotplug isn't supported7 x# L8 g: A; L7 |0 d' @
; W8 {/ f; M5 D5 P' B9 J5 M, I8 v n$ w
9 r/ Y& E: B4 w# b8 _# k3 f) groot@compute01:/usr/src# virsh attach-disk Windows2019_x86 /usr/src/virtio-win-0.1.225.iso sdb --cache none --subdriver cdrom --config --persistent # x# C& |0 C* d0 @5 X
error: Failed to attach disk
! @5 [& Q: @& B& \0 herror: unsupported configuration: unknown driver format value 'cdrom') o/ u- \ A1 L% |; x4 j
- k% R/ @. E$ p6 }1 h9 n9 |' 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 5 \( L( L" u- X$ x W
error: Failed to attach disk6 _7 E7 F( k6 P' h+ L$ g
error: internal error: No more available PCI slots5 K$ g+ t# _- f+ D" p: E
. G' ?; l- J! w3 s. g
root@compute01:/usr/src# virsh attach-disk Windows2019_x86 /usr/src/virtio-win-0.1.225.iso vdc --cache none --subdriver qcow2 --config --persistent
0 I; Z* i5 V6 ?1 B; |9 Zerror: Failed to attach disk4 [8 f: M$ n9 [- k0 v
error: internal error: unable to execute QEMU command 'blockdev-add': Image is not in qcow2 format: Q6 A; p5 i# y C, \$ X0 h
. t- ^, D$ R z/ l( ~- h# \root@compute01:/usr/src# virsh attach-disk Windows2019_x86 /usr/src/virtio-win-0.1.225.iso vdc --cache none --subdriver raw --config --persistent 4 \. s/ w, E2 |# M5 @# j6 D# L
Disk attached successfully3 l1 [% J& q$ K2 u5 M5 Y
: H$ m# o9 \' P* k; A( D L
" d; _2 K6 B* U* p4 t
& \$ F+ }. b. u6 _! s- p/ z; oroot@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=cdrom5 Z' L3 x' Q& R" h8 r' p: T) G
) h* l, P/ [% K+ H8 T9 xStarting install...
?; H4 k& Q; @3 k9 L* {; |ERROR Cannot get interface MTU on 'br0': No such device
0 X/ O$ x' x1 a7 e% oDomain installation does not appear to have been successful.- x. J4 q0 t$ L; f3 b8 G
If it was, you can restart your domain by running:
% `' a0 b& B; a5 c! K9 p) d; @& r virsh --connect qemu:///system start Windows2019_x86
' H" p" S0 }4 g* S$ `- h) j+ motherwise, please restart your installation.
" j$ _5 v) ~" f% y& J- x$ `root@compute01:/usr/src# 3 r3 A2 q0 P2 a+ q
root@compute01:/usr/src#
/ B+ u G& j1 @root@compute01:/usr/src# netplan apply . \, Y a8 D% j* i
# z0 O C, s: O( m: {6 g" x B1 t5 Q- `** (generate:8799): WARNING **: 13:35:59.651: `gateway4` has been deprecated, use default routes instead.
' |' p5 G2 O& e n: A4 o+ \See the 'Default routes' section of the documentation for more details.
. T, c/ N* R; J# u- v% k
; R, p1 Y: o {( T1 i- C' t# x** (process:8797): WARNING **: 13:36:01.040: `gateway4` has been deprecated, use default routes instead.! {: m c# i2 Y) B4 y6 s: F
See the 'Default routes' section of the documentation for more details.2 j" _9 I: r O; Y! O" f6 H
) n' D9 A$ V5 R9 x** (process:8797): WARNING **: 13:36:01.052: `gateway4` has been deprecated, use default routes instead.
7 ~# F4 f! }! ?* S9 p$ iSee the 'Default routes' section of the documentation for more details.0 a; v) x/ } U# ?
& f0 d$ J# ?+ p0 D- L
** (process:8797): WARNING **: 13:36:01.589: `gateway4` has been deprecated, use default routes instead." y# e- h8 P% g9 W+ J
See the 'Default routes' section of the documentation for more details.
2 ^4 Y& ~8 F" s1 D' h
8 l/ ^' _/ @6 O0 N) {5 N** (process:8797): WARNING **: 13:36:01.589: `gateway4` has been deprecated, use default routes instead.% N7 S+ S a' b9 G- r, `
See the 'Default routes' section of the documentation for more details.
6 D2 |& T* w l) C; v* Lroot@compute01:/usr/src# $ ]: T8 r7 n8 o- v
root@compute01:/usr/src#
% U1 @ W' w/ ?1 o" b- u* w8 y: vroot@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=cdrom2 y S7 ?' z4 x* i6 A ]% k
# k8 S9 L9 U- _. _. b
Starting install...# L/ }' Z* j Z
Creating domain... | 0 B 00:00:00
x+ j$ |! s7 B. A
! N) Z& D R" J8 p5 iDomain is still running. Installation may be in progress.
. L9 o; \; d1 KYou can reconnect to the console to complete the installation process., Q9 D7 _2 }9 |5 |1 t- B4 B) {
root@compute01:/usr/src# - ~, @ Y# Z3 N1 o- B! p
, K/ W3 }: h' c7 N
在线添加光盘7 ?! P- l! L: q3 g
virsh attach-disk Windows2019_x86 /usr/src/virtio-win-0.1.225.iso/ vdd
5 l# e1 D9 L2 R
: W* W8 M$ c, Y( D2 q其他方法:/ f) M* _4 @2 n3 C
4 I. `8 d7 i/ [* Q, J. N+ k5 O7 _
6 `3 u' |. @8 B, {: r/ d) c再次使用 virsh dumpxml sles12-sp3 可以看到iso文件加载:
: b$ [* {8 r8 }7 p0 g6 g/ {" c8 \; Y3 K
<disk type='file' device='cdrom'>
8 R9 P" C* n9 H8 T1 I. P <driver name='qemu' type='raw'/>- A4 d; t+ `: v6 n
<source file='/var/lib/libvirt/images/SLE-12-SP3-Server-DVD-x86_64-GM-DVD1.iso' index='3'/>- E3 l$ ^3 e+ R ?$ b* `
<backingStore/>
3 f( [6 @4 n& D# O <target dev='sda' bus='sata'/>& t+ [0 d+ I( w; \
<readonly/># d5 V( L2 J/ f# D q
<alias name='sata0-0-0'/>% L+ ~- t" m: c4 r
<address type='drive' controller='0' bus='0' target='0' unit='0'/>4 \8 h% K/ Y% g& f+ s9 G
</disk>
9 J6 a, |# O$ J' K, P如果要卸载这个iso文件,则创建一个相同结构的xml文件 detach_iso.xml ,但是保持 <source/> 行删除:
8 J6 s, I% C, p9 _% ]0 J( f7 j6 u0 U$ s( o1 m3 [
<disk type='file' device='cdrom'>
8 P+ v, @' h4 @0 R, N6 \ <driver name='qemu' type='raw'/>1 i) P I2 E+ n
<backingStore/>
% F; M4 Z& D, t- C3 R% ]5 i <target dev='sda' bus='sata'/>4 L% X- K# a2 S4 q5 P$ K
<readonly/>( D4 X0 G' G; A
<alias name='sata0-0-0'/>
! f2 {1 J* U, C( o3 x <address type='drive' controller='0' bus='0' target='0' unit='0'/>0 N) Y# O! S7 _6 p4 s+ h
</disk>7 O! L- D( d" z6 n7 t' @( \
然后执行设备更新:9 ^" {/ m1 p( R) n* g
$ L5 \4 d* q8 v3 k) o
virsh update-device sles12-sp3 detach_iso.xml* b# Y5 n% I$ x$ h( L% ?2 C9 I# V
此时提示:5 Y; F6 R- ]' q" k
( h" r1 Y* U2 Q/ O' k5 ^; IDevice updated successfully/ v5 }+ }( i3 j7 `0 x4 v
再检查虚拟机配置,就看到iso文件已经卸载了。
' H+ Q6 H1 G$ z/ M4 \% Y7 o$ q2 E
/ |9 U9 d9 Q1 ?: b/ Y% l* V |
|