于 2011年10月18日 22:52, Eric Blake 写道:
On 10/18/2011 03:30 AM, Xu He Jie wrote:
When using the xml as below:
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04'
function='0x0'/>
</memballoon>
</devices>
-----------------------------
Then can't statup qemu, the error message as below:
qemu-system-x86_64: -device
virtio-balloon-pci,id=balloon0,bus=pci.0,multifunction=on,addr=0x3.0x0:
Device 'virtio-balloon-pci' could not be initialized
The XML doesn't match the error message (slot 4 vs. slot 3); are you
sure you got this right?
Sorry, I pasted wrong log. the right one as below:
configuration:
------------------------------------------------------
<devices>
<emulator>/home/soulxu/data/work-code/qemu-kvm/x86_64-softmmu/qemu-system-x86_64</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/home/soulxu/data/VM/images/linux.img'/>
<target dev='vda' bus='virtio'/>
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='-1' autoport='yes'/>
<video>
<model type='cirrus' vram='9216' heads='1'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</video>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</memballoon>
</devices>
------------------------------------------------------
error message:
virsh # start test-vm
error: Failed to start domain test-vm
error: internal error process exited while connecting to monitor:
qemu-system-x86_64: -device
virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3: PCI: slot 3 function
0 not available for virtio-balloon-pci, in use by virtio-blk-pci
qemu-system-x86_64: -device
virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3: Device
'virtio-balloon-pci' could not be initialized
Adding check for bus type and address type. Only the address of pci
type support by virtio bus.
Signed-off-by: Xu He Jie<xuhj@xxxxxxxxxxxxxxxxxx>
---
src/conf/domain_conf.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 5959593..b8aa1a2 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2644,6 +2644,14 @@ virDomainDiskDefParseXML(virCapsPtr caps,
} else {
if (virDomainDeviceInfoParseXML(node,&def->info, flags)< 0)
goto error;
+
+ if ((def->bus == VIR_DOMAIN_DISK_BUS_VIRTIO)&&
+ (def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)&&
+ (def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)) {
+ virDomainReportError(VIR_ERR_INTERNAL_ERROR,
+ _("virtio only support device address type 'PCI' "));
+ goto error;
+ }
This feels like the wrong place for the fix. I think the check should
be in the qemu layer, not in the generic domain_conf, as there might
be hypervisor drivers that support virtio on other buses.
Hmm, you are right. domain_conf didn't separate with different layer. So
I found another place that in the qemu layer for the fix. The patch as
below:
Signed-off-by: Xu He Jie <xuhj@xxxxxxxxxxxxxxxxxx>
---
src/qemu/qemu_command.c | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 30c0be6..7c4bc0a 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1321,13 +1321,17 @@ qemuAssignDevicePCISlots(virDomainDefPtr def,
qemuDomainPCIAddressSetPtr addrs)
/* Disks (VirtIO only for now */
for (i = 0; i < def->ndisks ; i++) {
- if (def->disks[i]->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
- continue;
-
/* Only VirtIO disks use PCI addrs */
if (def->disks[i]->bus != VIR_DOMAIN_DISK_BUS_VIRTIO)
continue;
+ if ((def->disks[i]->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) &&
+ (def->disks[i]->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)) {
+ qemuReportError(VIR_ERR_INTERNAL_ERROR,
+ _("virtio only support device address type 'PCI' "));
+ goto error;
+ }
+
if (qemuDomainPCIAddressSetNextAddr(addrs, &def->disks[i]->info) < 0)
goto error;
}
--
1.7.4.1
--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list