qemu 只支持一个 IDE controller,一个 IDE controller 只支持 4 个设备(hda 到 hdd)。定义两个 IDE controller 或使用 hde 都会报错。
现象
在 libvirt XML 中定义两个 IDE controller:
<controller type='ide' index='0'/>
<controller type='ide' index='1'/>
直接会报如下错误:
error: Failed to create domain from vm-example.xml
error: unsupported configuration: Only a single IDE controller is supported for this machine type
排查
默认有一个 IDE controller
默认有一个 IDE controller。
所以不定义 <controller type='ide' index='0'/>,也是有一个 IDE controller 的。
直接定义 IDE disk 的情况
<disk type="network" device="cdrom">
<driver name="qemu" type="raw"></driver>
<source protocol="http" name="/yy/img-example.iso">
<host name="qa1b01" port="8021"></host>
</source>
<target dev="hdd" bus="ide"></target> 【注意 hdd】
<readonly></readonly>
<shareable></shareable>
</disk>
直接定义了 IDE 的 disk,没有定义 IDE 的 controller。
hda 到 hdd 都可以用,但如果是 hde,就会直接报错:
error: failed to get domain 'vm-example'
error: Failed to create domain from vm-example.xml
error: internal error: Only 1 IDE controller is supported
根因
qemu 会根据 dev 名称的序号自动固定地选择 controller。
且一个 IDE controller 只支持 4 个设备(hda、hdb、hdc、hdd)。
所以:
- 定义两个 IDE controller 会报错;
- 使用 hde 及以后的设备名会报错;
- 默认有一个 IDE controller,不定义也有。
小结
- qemu 只支持一个 IDE controller;
- 一个 IDE controller 只支持 4 个设备(hda 到 hdd);
- 默认有一个 IDE controller,不定义也有;
- 定义两个 IDE controller 或使用 hde 都会报错;
- qemu 会根据 dev 名称的序号自动固定地选择 controller。