Bug 1377212
Summary: | libvirt: SCSI: hostdev / controller host-plug related fixes | ||||||
---|---|---|---|---|---|---|---|
Product: | Red Hat Enterprise Linux 7 | Reporter: | Kashyap Chamarthy <kchamart> | ||||
Component: | libvirt | Assignee: | Ján Tomko <jtomko> | ||||
Status: | CLOSED ERRATA | QA Contact: | Virtualization Bugs <virt-bugs> | ||||
Severity: | unspecified | Docs Contact: | |||||
Priority: | high | ||||||
Version: | 7.3 | CC: | dyuan, jdenemar, jherrman, jtomko, lmiksik, rbalakri, xuzhang, yisun | ||||
Target Milestone: | rc | Keywords: | ZStream | ||||
Target Release: | --- | ||||||
Hardware: | Unspecified | ||||||
OS: | Unspecified | ||||||
Whiteboard: | |||||||
Fixed In Version: | libvirt-2.0.0-1.el7 | Doc Type: | Bug Fix | ||||
Doc Text: |
Previously, hot plugging a SCSI device to a guest with no usable SCSI controller failed. This update ensures that the automatic addition of the SCSI controller is performed in the correct order, and the SCSI hot plug now works properly in the described circumstances.
|
Story Points: | --- | ||||
Clone Of: | |||||||
: | 1380309 (view as bug list) | Environment: | |||||
Last Closed: | 2016-11-03 18:54:47 UTC | Type: | Bug | ||||
Regression: | --- | Mount Type: | --- | ||||
Documentation: | --- | CRM: | |||||
Verified Versions: | Category: | --- | |||||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||
Cloudforms Team: | --- | Target Upstream Version: | |||||
Embargoed: | |||||||
Bug Depends On: | |||||||
Bug Blocks: | 1380309 | ||||||
Attachments: |
|
Description
Kashyap Chamarthy
2016-09-19 08:32:44 UTC
A related fix (that was submitted as part of a patch series[1] upstream, along with the patch "qemu: SCSI hostdev hot-plug: Fix automatic creation of SCSI controllers") commit 696ab0a1256a2c6a726005e30ea9f1ee4536334e Author: Marc Hartmayer <mhartmay.ibm.com> Date: Mon Jun 27 16:43:46 2016 +0200 qemu: hot-plug: Fix broken SCSI disk hot-plug The commit "qemu: hot-plug: Assume support for -device in qemuDomainAttachSCSIDisk" dropped the code for the automatic SCSI controller creation used in SCSI disk hot-plugging. If we are hot-plugging a SCSI disk to a domain and there is no proper SCSI controller defined, it results in an "error: internal error: Could not find scsi controller with index X required for device" error. For that reason reverting a hunk of the commit d4d32005d6e8b2cc0a2f26b483ca1de10171db6d. This patch also adds an extra comment to the code to clarify the loop. [1] http://www.redhat.com/archives/libvir-list/2016-June/msg02053.html Description of the problem -------------------------- When you hot-plug SCSI disks on a second SCSI controller, attaching the the SCSI disks will fail, because the controllers with smaller indices (1 and 0) are not auto-generated. With these patches, it will succeed. Steps to reproduce the issue ---------------------------- I attached the test script, which can be used to test with and without these patches. (I've tested from Git Master, here's the result.) (1) Start and ensure the guest is running: $ sudo ./run ./tools/virsh start cvm1 $ sudo ./run ./tools/virsh list Id Name State ---------------------------------------------------- 6 cvm1 running (2) Enumerate the current block device in use: $ sudo ./run ./tools/virsh domblklist cvm1 Target Source ------------------------------------------------ vda /export/vmimages/sn1.qcow2 (3) Check for existing SCSI controller devices for the guest (there are none): $ sudo ./run ./tools/virsh dumpxml cvm1 | grep controller.*scsi $ echo $? 1 (4) Run the script attached (which attaches two SCSI disks on SCSI controller '2') $ ./attach-scsi-device.bash With a libvirt _without_ these patches, step (4) will fail with: error: Failed to attach device error: internal error: Could not find scsi controller with index X required for device * * * With the fixes mentioned in the description of the bug, step (4) will succeed. And, you can verify that with: (5) Now, again, numerate the block devices in use by the guest: $ sudo ./run ./tools/virsh domblklist cvm1 Target Source ------------------------------------------------ vda /export/vmimages/sn1.qcow2 sdb /export/vmimages/b.raw sdc /export/vmimages/c.raw (6) Verify the existence of SCSI controller devices (now you see, SCSI controller indexes, 0,1,2): $ sudo ./run ./tools/virsh dumpxml cvm1 | grep controller.*scsi <controller type='scsi' index='0'> <controller type='scsi' index='1'> <controller type='scsi' index='2'> (7) Verify that SCSI controller the two disks ('sdb', and 'sdc') are indeed attached to SCSI controller '2': $ sudo ./run ./tools/virsh dumpxml cvm1 | grep scsi <target dev='sdb' bus='scsi'/> <alias name='scsi2-0-2'/> <target dev='sdc' bus='scsi'/> <alias name='scsi2-0-3'/> <controller type='scsi' index='0'> <alias name='scsi0'/> <controller type='scsi' index='1'> <alias name='scsi1'/> <controller type='scsi' index='2'> <alias name='scsi2'/> Created attachment 1202473 [details]
Attach two SCSI disks to a SCSI controller '2'. The smaller controller indices '1' and '0' should be automatically created.
Fixed upstream for SCSI disk by: commit 105794cd434d815e483f87732f2084f55ae62c42 Author: Boris Fiuczynski <fiuczy.ibm.com> CommitDate: 2015-12-04 13:50:06 -0500 qemu: Automatic SCSI controller creation in SCSI disk hotplug broken git describe: v1.3.0-rc1-12-g105794c contains: v1.3.0-rc2~1 And for SCSI hostdevs by: commit 12ec22b68befce0ae8020635e7fd71d783b1d716 Author: Marc Hartmayer <mhartmay.ibm.com> CommitDate: 2016-06-30 12:48:51 +0200 qemu: SCSI hostdev hot-plug: Fix automatic creation of SCSI controllers Ensure that the given controller and all controllers with a smaller index exist; there must not be any missing index in between. Reviewed-by: Boris Fiuczynski <fiuczy.ibm.com> Reviewed-by: Bjoern Walk <bwalk.ibm.com> Signed-off-by: Marc Hartmayer <mhartmay.ibm.com> git describe: v2.0.0-rc2-5-g12ec22b contains: v2.0.0~6 Verified on libvirt-2.0.0-9.el7.x86_64 test with test script with tiny modification: cat test.sh #!/bin/bash # Purpose: Attach two SCSI disks to a SCSI controller '2'. The smaller # controller indices '1' and '0' should be automatically created. set -x image_dir="/var/lib/libvirt/images" vm_name="virtlab_test_copy" disk_scsi_index="2" # Create three raw disk images function create_disk() { for i in {b..c}; do qemu-img create -f raw $image_dir/$i.raw 512M; done } # This is incrementing the 'unit' (a "2-digit unit number on a bus") # attribute, for the 'address' sub-element, which describes where the # device is placed on the virtual bus presented to the guest. # http://libvirt.org/formatdomain.html#elementsAddress virsh dumpxml $vm_name | grep scsi j=1 # Construct a guest XML by attaching two SCSI disks onto the *second* controller # (and manually increment the 'unit' number) function attach_device() { for i in {b..c}; do j=$(expr $j + 1) cat << EOF > disk-$i.xml <disk type='file' device='disk'> <source file='$image_dir/$i.raw'/> <target dev='sd$i' bus='scsi'/> <address type='drive' controller='$disk_scsi_index' model='virtio-scsi' bus='0' target='0' unit='$j'/> </disk> EOF # Attach the device; it takes effect on next boot virsh attach-device $vm_name disk-$i.xml --live virsh dumpxml $vm_name | grep scsi done } create_disk attach_device =============set disk_scsi_index="2" in script========= result expected with scsi controller 0, 1 and 2 automatically generated: [root@localhost 1377212]# virsh destroy virtlab_test_copy Domain virtlab_test_copy destroyed [root@localhost 1377212]# virsh start virtlab_test_copy Domain virtlab_test_copy started [root@localhost 1377212]# sh test.sh + image_dir=/var/lib/libvirt/images + vm_name=virtlab_test_copy + disk_scsi_index=2 + virsh dumpxml virtlab_test_copy + grep scsi + j=1 + create_disk + for i in '{b..c}' + qemu-img create -f raw /var/lib/libvirt/images/b.raw 512M Formatting '/var/lib/libvirt/images/b.raw', fmt=raw size=536870912 + for i in '{b..c}' + qemu-img create -f raw /var/lib/libvirt/images/c.raw 512M Formatting '/var/lib/libvirt/images/c.raw', fmt=raw size=536870912 + attach_device + for i in '{b..c}' ++ expr 1 + 1 + j=2 + cat + virsh attach-device virtlab_test_copy disk-b.xml --live Device attached successfully + virsh dumpxml virtlab_test_copy + grep scsi <target dev='sdb' bus='scsi'/> <alias name='scsi2-0-0-2'/> <controller type='scsi' index='0'> <alias name='scsi0'/> <controller type='scsi' index='1'> <alias name='scsi1'/> <controller type='scsi' index='2'> <alias name='scsi2'/> + for i in '{b..c}' ++ expr 2 + 1 + j=3 + cat + virsh attach-device virtlab_test_copy disk-c.xml --live Device attached successfully + virsh dumpxml virtlab_test_copy + grep scsi <target dev='sdb' bus='scsi'/> <alias name='scsi2-0-0-2'/> <target dev='sdc' bus='scsi'/> <alias name='scsi2-0-0-3'/> <controller type='scsi' index='0'> <alias name='scsi0'/> <controller type='scsi' index='1'> <alias name='scsi1'/> <controller type='scsi' index='2'> <alias name='scsi2'/> =============set disk_scsi_index="10" in script========= result expected with scsi controller 0..10 automatically generated: [root@localhost 1377212]# virsh destroy virtlab_test_copy Domain virtlab_test_copy destroyed [root@localhost 1377212]# virsh start virtlab_test_copy Domain virtlab_test_copy started [root@localhost 1377212]# sh test.sh + image_dir=/var/lib/libvirt/images + vm_name=virtlab_test_copy + disk_scsi_index=10 + virsh dumpxml virtlab_test_copy + grep scsi + j=1 + create_disk + for i in '{b..c}' + qemu-img create -f raw /var/lib/libvirt/images/b.raw 512M Formatting '/var/lib/libvirt/images/b.raw', fmt=raw size=536870912 + for i in '{b..c}' + qemu-img create -f raw /var/lib/libvirt/images/c.raw 512M Formatting '/var/lib/libvirt/images/c.raw', fmt=raw size=536870912 + attach_device + for i in '{b..c}' ++ expr 1 + 1 + j=2 + cat + virsh attach-device virtlab_test_copy disk-b.xml --live Device attached successfully + virsh dumpxml virtlab_test_copy + grep scsi <target dev='sdb' bus='scsi'/> <alias name='scsi10-0-0-2'/> <controller type='scsi' index='0'> <alias name='scsi0'/> <controller type='scsi' index='1'> <alias name='scsi1'/> <controller type='scsi' index='2'> <alias name='scsi2'/> <controller type='scsi' index='3'> <alias name='scsi3'/> <controller type='scsi' index='4'> <alias name='scsi4'/> <controller type='scsi' index='5'> <alias name='scsi5'/> <controller type='scsi' index='6'> <alias name='scsi6'/> <controller type='scsi' index='7'> <alias name='scsi7'/> <controller type='scsi' index='8'> <alias name='scsi8'/> <controller type='scsi' index='9'> <alias name='scsi9'/> <controller type='scsi' index='10'> <alias name='scsi10'/> + for i in '{b..c}' ++ expr 2 + 1 + j=3 + cat + virsh attach-device virtlab_test_copy disk-c.xml --live Device attached successfully + virsh dumpxml virtlab_test_copy + grep scsi <target dev='sdb' bus='scsi'/> <alias name='scsi10-0-0-2'/> <target dev='sdc' bus='scsi'/> <alias name='scsi10-0-0-3'/> <controller type='scsi' index='0'> <alias name='scsi0'/> <controller type='scsi' index='1'> <alias name='scsi1'/> <controller type='scsi' index='2'> <alias name='scsi2'/> <controller type='scsi' index='3'> <alias name='scsi3'/> <controller type='scsi' index='4'> <alias name='scsi4'/> <controller type='scsi' index='5'> <alias name='scsi5'/> <controller type='scsi' index='6'> <alias name='scsi6'/> <controller type='scsi' index='7'> <alias name='scsi7'/> <controller type='scsi' index='8'> <alias name='scsi8'/> <controller type='scsi' index='9'> <alias name='scsi9'/> <controller type='scsi' index='10'> <alias name='scsi10'/> Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://rhn.redhat.com/errata/RHSA-2016-2577.html |