- 积分
- 16844
在线时间 小时
最后登录1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?开始注册
x
virsh 在线添加设备cdrom或者iso镜像
$ {* B+ L+ Q rvirsh domblklist Windows2019_x86 ) y7 O) ?% R& N0 i* b" S1 o( {" T# I
Target Source' M: f5 G: b0 h) |2 c
----------------------------------------------------------------
. @" w/ h% F R, {( K3 Y# N vda /usr/src/Windows2019-x86.qcow20 z) A2 n3 A# N% B& m5 s& \% g: P) _
sda /usr/src/cn_windows_server_2019_x64_dvd_2d80e042.iso6 K$ e4 M4 h+ g" U% E: Z2 k# G
9 i: Q0 I/ }: p+ e! V8 K
( _2 Q# U) W+ r: J& A0 O7 f/ A1 w4 C/ {! [* ?8 k" n* \) @
virsh attach-disk Windows2019_x86 --target sdb --type cdrom /usr/src/virtio-win-0.1.225.iso --mode readonly
6 ~; r z( y' D/ p, Y' N3 _; Oerror: Failed to attach disk
% M3 f2 }8 Y- X* t2 G, s \error: Operation not supported: cdrom/floppy device hotplug isn't supported
/ y) O3 _9 G% E/ j( g- \/ w, r& p7 s$ X# D/ w
c: u* q# n0 S/ b7 T) t% S
+ |% i$ X7 h& q; `% m0 P7 |root@compute01:/usr/src# virsh attach-disk Windows2019_x86 /usr/src/virtio-win-0.1.225.iso sdb --cache none --subdriver cdrom --config --persistent
5 }5 F1 ?& m2 x+ O7 eerror: Failed to attach disk* v5 d0 D }9 v$ {) }
error: unsupported configuration: unknown driver format value 'cdrom'. E: l+ l" T9 D
/ Q! R2 g! {+ S
root@compute01:/usr/src# virsh attach-disk Windows2019_x86 /usr/src/virtio-win-0.1.225.iso sdb --cache none --subdriver qcow2 --config --persistent 2 G, E$ f8 d. K6 W6 L& `# e6 y
error: Failed to attach disk* |9 }9 F6 K; w7 B8 G
error: internal error: No more available PCI slots$ l- f$ V4 R" b( A4 u7 g5 q
# p- Q% r3 ~/ r5 H" p2 Qroot@compute01:/usr/src# virsh attach-disk Windows2019_x86 /usr/src/virtio-win-0.1.225.iso vdc --cache none --subdriver qcow2 --config --persistent
7 ?% d! A4 X% M) P7 q) M' v D2 werror: Failed to attach disk
1 J: A, o0 N3 C6 perror: internal error: unable to execute QEMU command 'blockdev-add': Image is not in qcow2 format) F- n4 N6 k$ ~' b
6 z/ D1 N* s5 S' f
root@compute01:/usr/src# virsh attach-disk Windows2019_x86 /usr/src/virtio-win-0.1.225.iso vdc --cache none --subdriver raw --config --persistent 9 x: z% q1 J5 i$ B- C
Disk attached successfully& b/ U% ]+ h4 L% n$ _7 O
" S" N# P( A) C/ v& ?5 G# y) n" B, ]7 f0 t
! T d, D, x7 O
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=cdrom9 W+ c9 g# N2 J1 A
$ O$ i( Z3 {1 A7 T$ l& R7 f3 ^
Starting install...- {9 v) S5 `+ t$ l0 [7 L* T
ERROR Cannot get interface MTU on 'br0': No such device# B X2 j& K- d" d+ }
Domain installation does not appear to have been successful.# V7 }2 D# U$ q( `
If it was, you can restart your domain by running:0 k0 j e7 P3 h% V
virsh --connect qemu:///system start Windows2019_x86
3 U: P4 g( s4 q# kotherwise, please restart your installation.
4 Y7 T8 f$ }" rroot@compute01:/usr/src#
; r+ i' J8 U# y3 x5 c/ Aroot@compute01:/usr/src#
* \0 e* [+ P. S; \# Mroot@compute01:/usr/src# netplan apply
3 s9 z) E% X7 e3 D+ i' H
7 O! v& f! y1 _: V! z7 f, t: X** (generate:8799): WARNING **: 13:35:59.651: `gateway4` has been deprecated, use default routes instead.
, `7 Q5 z9 U* ]2 \! w1 uSee the 'Default routes' section of the documentation for more details.
1 w& o, @/ `% B! `# K3 k# x- d0 {5 P8 r# W
** (process:8797): WARNING **: 13:36:01.040: `gateway4` has been deprecated, use default routes instead.0 v: c v6 o- }7 x6 O( U3 ^: k
See the 'Default routes' section of the documentation for more details.
3 [9 u- j8 s+ n) ~, Q, K! O( }3 N+ a* o6 i
** (process:8797): WARNING **: 13:36:01.052: `gateway4` has been deprecated, use default routes instead.
% Z, J2 y% y! {( Z4 {- CSee the 'Default routes' section of the documentation for more details.2 I* `% Q8 B* M1 o
$ j$ ?( ?# K& _4 g9 M# r. l+ R
** (process:8797): WARNING **: 13:36:01.589: `gateway4` has been deprecated, use default routes instead.
8 u* l, ~; W2 f' Z+ JSee the 'Default routes' section of the documentation for more details.
5 M% X0 R- V# f! i1 W
5 k- }5 x+ n1 ?+ x** (process:8797): WARNING **: 13:36:01.589: `gateway4` has been deprecated, use default routes instead.& ~! ?% {% z' p
See the 'Default routes' section of the documentation for more details.
/ h% q# k$ w9 n2 H, A4 P7 Broot@compute01:/usr/src#
( s' l0 k5 {7 x M& Troot@compute01:/usr/src# . K8 T" f* @' V/ z2 y, 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$ x5 r( ^5 p! ?+ X0 j' h4 _( F+ h
: f( g* D0 @6 u2 ?: M1 w
Starting install...5 P6 N4 _* j; \2 ]$ H& I) }0 T: p
Creating domain... | 0 B 00:00:00
) H0 w8 L4 u4 D8 r/ a3 ^, q% S4 }5 I$ h g
Domain is still running. Installation may be in progress.( G0 o: N" h: ]9 i" n) v% C
You can reconnect to the console to complete the installation process.
+ r/ l$ }( Y. ~7 eroot@compute01:/usr/src#
8 y, W: F$ |; x* `. d/ T. D/ ]0 V0 E" n" J* E8 J
在线添加光盘$ f' r2 s$ U2 j8 \
virsh attach-disk Windows2019_x86 /usr/src/virtio-win-0.1.225.iso/ vdd& a# H1 U0 |. l% `$ O# a( \
8 o# H; n+ y+ l' {$ n
其他方法:
& w, v; V- O( w
; h/ s0 a: v( `7 s' R$ f( L+ `: l0 m) H" i/ q, u/ ^$ O& [
再次使用 virsh dumpxml sles12-sp3 可以看到iso文件加载:
4 B9 ~" F& i# h* Z2 U. Z. R; S' o7 Y/ r& [# r$ J! _
<disk type='file' device='cdrom'>- {/ w2 f8 k' F3 g- n9 \
<driver name='qemu' type='raw'/>) b+ c* `1 o8 ]$ x) h1 a" F4 A- g
<source file='/var/lib/libvirt/images/SLE-12-SP3-Server-DVD-x86_64-GM-DVD1.iso' index='3'/>
, _ i( A# }2 `' n, ? <backingStore/>; k: P1 E c# P
<target dev='sda' bus='sata'/>
0 T$ k" i8 a3 @3 B6 e <readonly/>5 V( q6 C" j3 J8 d* ^
<alias name='sata0-0-0'/>: O' |& w5 [/ e: I5 T
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
( n; Y) ?4 h& h</disk>
( m! |' _: D3 D1 N9 {( F- |如果要卸载这个iso文件,则创建一个相同结构的xml文件 detach_iso.xml ,但是保持 <source/> 行删除:. ?, U1 E% z$ A0 P% N+ g
: M* V& n; K6 h<disk type='file' device='cdrom'>' T3 m" j, |& z; a# E0 q# o6 d5 V/ }
<driver name='qemu' type='raw'/>
; o) q+ A/ j# v+ e3 j <backingStore/>
8 Y, B9 X; T4 O <target dev='sda' bus='sata'/>% U+ e$ v" F. _+ _1 o
<readonly/>
' A( M7 u5 @/ u <alias name='sata0-0-0'/>
+ \! N) E. B6 t <address type='drive' controller='0' bus='0' target='0' unit='0'/>0 W4 o9 p$ X4 j+ F9 M* Z* d
</disk>
! _1 e+ b( o9 h' [) T3 q然后执行设备更新:- k2 ^% Q6 w4 W
" e# T4 c1 ^- O/ F) L( o
virsh update-device sles12-sp3 detach_iso.xml d1 j) Z' _- E' I/ m( q( K3 ~7 [/ a
此时提示:5 R( n: K: ?4 x, U% u
i6 a0 w: h# ?! y! {+ n4 m0 ]4 ^Device updated successfully( B2 W6 M8 n; d7 p
再检查虚拟机配置,就看到iso文件已经卸载了。
3 l6 l7 U) h+ O4 `) K& W2 W) z0 J7 K. K' g- n8 L5 m- I& D) x
|
|