Bug 1031079

Summary: Wrong SCSI adapter name results in uninitialized valued to be used
Product: Red Hat Enterprise Linux 7 Reporter: Jiri Denemark <jdenemar>
Component: libvirtAssignee: Jiri Denemark <jdenemar>
Status: CLOSED CURRENTRELEASE QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.0CC: acathrow, dyuan, gsun, honzhang, mzhan, xuzhang
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-1.1.1-13.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-06-13 09:29:19 EDT Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Description Jiri Denemark 2013-11-15 10:02:21 EST
Description of problem:

When SCSI hostdev XML contains wrong adapter name (i.e., other than scsi_host[0-9]+), libvirt fails to parse it but rather than reporting an error, it uses an uninitialized value as host adapter ID.

Version-Release number of selected component (if applicable):

libvirt-1.1.1-12.el7.x86_64

How reproducible:

100%

Steps to Reproduce:
1. define a domain with wrong SCSI adapter name (see scsi.xml below)
2. try to start it

Actual results:

error: Failed to start domain scsi
error: internal error: Failed to open /sys/bus/scsi/devices/32742:0:0:0/scsi_generic

Expected results:

Cannot parse adapter 'scsi_foo'

Additional info:

scsi.xml:

<domain type='kvm'>
  <name>scsi</name>
  <memory unit='KiB'>262144</memory>
  <vcpu placement='static'>1</vcpu>
  <os>
    <type arch='x86_64' machine='pc-i440fx-rhel7.0.0'>hvm</type>
  </os>
  <features>
    <acpi/>
    <apic/>
    <pae/>
  </features>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
    <emulator>/usr/libexec/qemu-kvm</emulator>
    <controller type='scsi' index='0'/>
    <hostdev mode='subsystem' type='scsi' managed='no'>
      <source>
        <adapter name='scsi_foo'/>
        <address bus='0' target='0' unit='0'/>
      </source>
      <readonly/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </hostdev>
    <memballoon model='none'/>
  </devices>
</domain>
Comment 1 Jiri Denemark 2013-11-15 10:04:47 EST
This is fixed upstream by v1.1.3-rc2-6-g11d9dd7:

commit 11d9dd7ba099c59bc3cb785ab574a84bdb255168
Author: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Date:   Mon Sep 30 14:23:17 2013 +0200

    virscsi: hostdev SCSI AdapterId retrieval fix
    
    Fixed the retrieval of the AdapterId from the AdapterName of the
    hostdev source so it does return an error instead of leaving the
    adapter_id uninitialized.
    
    Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
    Reviewed-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Comment 4 Xuesong Zhang 2013-11-27 03:51:00 EST
Verified with the latest libvirt build libvirt-1.1.1-13.el7.x86_64, this bug is passed.

Steps:
1. add the following scsi device to the guest xml.
<hostdev mode='subsystem' type='scsi' managed='no'>
      <source>
        <adapter name='scsi_hostfoo'/>
        <address bus='0' target='0' unit='0'/>
      </source>
      <readonly/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </hostdev>

2. start the guest.
# virsh start r7-1121
error: Failed to start domain r7-1121
error: internal error: Cannot parse adapter 'scsi_hostfool'

3. change the adapter name to "scsi_host2", the host only have "scsi_host0" and "scsi_host1", didn't have "scsi_host2". Then start the guest again, the error message is as expected.
# virsh start r7-1121
error: Failed to start domain r7-1121
error: internal error: Failed to open /sys/bus/scsi/devices/2:0:0:0/scsi_generic
Comment 5 Ludek Smid 2014-06-13 09:29:19 EDT
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.