Hide Forgot
Description of problem: upstream commit cdbba1c4960a22b5f8c034dd9257bec2d5fa38d6 Author: Hu Tao <hutao.com> Date: Thu Jan 27 15:21:42 2011 +0800 qemu: Report more accurate error on failure to attach device. When attaching device from a xml file and the device is mis-configured, virsh gives mis-leading message "out of memory". This patch fixes this. Signed-off-by: Eric Blake <eblake> Version-Release number of selected component (if applicable): libvirt-0.8.7-4.el6 How reproducible: 100% Steps to Reproduce: 1. Not quite sure how Hu reproduced it, but probably by creating xml with a <controller> type set to 'ide' Actual results: out of memory error when the code path detects the bad controller type Expected results: proper message about the unknown type Additional info:
Move to POST: http://post-office.corp.redhat.com/archives/rhvirt-patches/2011-February/msg00431.html
Hi Eric, I tried to verify this bug in libvirt-0.8.7-6.el6. But I am not sure if your updated code was covered. Please check the following steps. Steps: 1.Start a guest # virsh start rhel6 2.Create a device with 'ide' controller and attach it to guest # cat c1.xml <controller type='ide' index='0'> <alias name='ide0'/> </controller> # virsh attach-device rhel6 c1.xml error: Failed to attach device from c1.xml error: unsupported configuration: disk controller bus 'ide' cannot be hotplugged. 3.Recreate a device with the invaild controller and attach it to guest # cat c2.xml <controller type='fdsfside' index='0'> <alias name='ide0'/> </controller> # virsh attach-device rhel6 c1.xml error: Failed to attach device from c2.xml error: internal error Unknown controller type 'fdsfside' ** In step3, ("Unknown controller type: %s") error message can be shown. Unfortunately, the same error message (in step3) also can be shown in libvirt-0.8.7-4.el6. Would you please give some suggestions on this bugs? Thanks, Chun Cui
(In reply to comment #4) > I tried to verify this bug in libvirt-0.8.7-6.el6. > But I am not sure if your updated code was covered. Please check the following > steps. I've asked the original reporter, Hu Tao, for how he tested his upstream patch. Meanwhile, note that: > 3.Recreate a device with the invaild controller and attach it to guest > # cat c2.xml > <controller type='fdsfside' index='0'> > <alias name='ide0'/> > </controller> > > # virsh attach-device rhel6 c1.xml > error: Failed to attach device from c2.xml > error: internal error Unknown controller type 'fdsfside' There are two different error messages: src/conf/domain_conf.c: _("Unknown controller type '%s'"), type); src/qemu/qemu_command.c: _("Unknown controller type: %s"), You hit the pre-existing one in domain_conf.c (no colon), not the new message in qemu_command.c (with a colon), so this test did not tickle the changed code path. So I think it has to be a known existing controller type to get past the parsing in domain_conf.c, which leaves 'ide', 'fdc', 'scsi', 'sata', 'virtio-serial', and 'ccid'. Then, in qemu_command.c, the new message can only be triggered if you hit the 'ide' or default: case label; your testing showed that 'ide' got filtered early, and the switch statement covers 'scsi', 'virtio-serial', and 'ccid', but that leaves 'fdc' and 'sata'. So maybe trying your step 2, but with 'sata' or 'fdc' instead of 'ide', will trigger things?
Have a try with this xml: <controller type='scsi' index='1'> <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x1'/> </controller> where slot 0x09 is an unused slot, you can specify any unused slot. With commit cdbba1c4960a2 the error message is: error: internal error Only PCI device addresses with function=0 are supported Without commit cdbba1c4960a2 the error message is: error: out of memory
Tried the xml mentioned in comment6. The error message is same with first error (commit cdbba1c4960a2 the error message) Test environment: libvirt-0.8.7-6.el6 qemu-kvm-0.12.1.2-2.144.el6 kernel-2.6.32-113.el6 cat c3.xml <controller type='scsi' index='1'> <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x1'/> </controller> # virsh attach-device rhel6 c3.xml error: Failed to attach device from c3.xml error: internal error Only PCI device addresses with function=0 are supported
That error message should be fine. Have you tried the xml with commit cdbba1c4960a2 reverted? If you do not use git, you can manually edit c source file to remove changes introduced by commit cdbba1c4960a2 then rebuild libvirt-0.8.7-6.el6 then repeat steps in comment 7. If you get 'error: out of memory', then commit cdbba1c4960a2 is in effect. Because we're not actually out of memory, but don't support PCI device addresses with function=1.
(In reply to comment #8) > That error message should be fine. > > Have you tried the xml with commit cdbba1c4960a2 reverted? If you do not use > git, you can manually edit c source file to remove changes introduced by commit > cdbba1c4960a2 then rebuild libvirt-0.8.7-6.el6 then repeat steps in comment 7. > If you get 'error: out of memory', then commit cdbba1c4960a2 is in effect. > Because we're not actually out of memory, but don't support PCI device > addresses with function=1. Yes, I have checked on libvirt-0.8.7-4.el6.x86_64 without commit cdbba1c4960a2 and get "error: out of memory". ------- # virsh attach-device rhel6 c3.xml error: Failed to attach device from c3.xml error: out of memory ------ So this bug is fixed. Can I change it's status?
Fine. Thanks for your verification.
Thanks for Hu Tao's great help. Changed it to verified status.
Adding the following xml to a shutoff guest xml, then start the guest will causes 'out of memory' error. For this issue, I report a separate bug 698197 <controller type='scsi' index='1'> <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x1'/> </controller>
An advisory has been issued which should help the problem described in this bug report. This report is therefore being closed with a resolution of ERRATA. For more information on therefore solution and/or where to find the updated files, please follow the link below. You may reopen this bug report if the solution does not work for you. http://rhn.redhat.com/errata/RHBA-2011-0596.html