RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 957292 - support more attributes for SCSI passthrough devices
Summary: support more attributes for SCSI passthrough devices
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: John Ferlan
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On: 877527 959428 966883
Blocks: 1072736
TreeView+ depends on / blocked
 
Reported: 2013-04-26 21:49 UTC by Paolo Bonzini
Modified: 2019-03-22 07:05 UTC (History)
13 users (show)

Fixed In Version: libvirt-1.1.1-28.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 959428 (view as bug list)
Environment:
Last Closed: 2014-06-13 13:04:29 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
backtrace (9.51 KB, text/plain)
2014-03-03 10:24 UTC, Xuesong Zhang
no flags Details

Description Paolo Bonzini 2013-04-26 21:49:09 UTC
The following <disk> attributes should also be supported for <hostdev mode='subsystem' type='scsi'>:

- <shareable/>

- sgio='filtered'

Comment 2 Osier Yang 2013-05-17 11:33:17 UTC
Patch 14/25 - patch 25/25 of https://www.redhat.com/archives/libvir-list/2013-May/msg00332.html are pushed into upstream. Move to POST.

Comment 3 Paolo Bonzini 2013-05-21 16:52:29 UTC
Osier, what is the status of sgio='filtered' since non-disk devices do not expose it in sysfs?  Does it work only for disks?  I guess we need a separate BZ in that case, plus a kernel BZ that would block it.

Comment 4 Osier Yang 2013-05-22 02:36:20 UTC
(In reply to Paolo Bonzini from comment #3)
> Osier, what is the status of sgio='filtered' since non-disk devices do not
> expose it in sysfs?  Does it work only for disks?  I guess we need a
> separate BZ in that case, plus a kernel BZ that would block it.

It works for disk and scsi-generic device (also refers to the disks
unpriv_sgio actually). So, it's right, it doesn't work if the device doesn't
have unpriv_sgio exposed in sysfs anyway.

Comment 5 Xuesong Zhang 2013-11-22 10:24:45 UTC
testing with the latest libvirt package, but there is some issue, the 2nd guest can't be start up while use "<shareable/>" element. 
Needinfo the developer, the issue is in step 10. I think the guest in step 10 should be started up.

version:
kernel-3.10.0-51.el7.x86_64
qemu-kvm-1.5.3-19.el7.x86_64
libvirt-1.1.1-12.el7.x86_64

steps:
1. modprobe sg module
# modprobe sg
2. find one host contains 2 disk devices, make sure there are scsi generic devices.
# virsh nodedev-list --tree
......
 pci_0000_00_1f_2
  |   |
  |   +- scsi_host0
  |   |   |
  |   |   +- scsi_target0_0_0
  |   |       |
  |   |       +- scsi_0_0_0_0
  |   |           |
  |   |           +- block_sda_SAMSUNG_HD502IJ_S1W3J9FZ101727
  |   |           +- scsi_generic_sg0
  |   |             
  |   +- scsi_host1
  |   |   |
  |   |   +- scsi_target1_0_0
  |   |       |
  |   |       +- scsi_1_0_0_0
  |   |           |
  |   |           +- block_sr0_hp_DDVDW_TS_H653R_R0626GAZ11057400
  |   |           +- scsi_generic_sg1
  |   |             
  |   +- scsi_host2
  |   |   |
  |   |   +- scsi_target2_0_0
  |   |       |
  |   |       +- scsi_2_0_0_0
  |   |           |
  |   |           +- block_sdb_ST3500418AS_9VMGHLCY
  |   |           +- scsi_generic_sg2
......

3. add the following xml to two guests "a" and "b".
<hostdev mode='subsystem' type='scsi' managed='no'>
      <source>
        <adapter name='scsi_host0'/>
        <address bus='0' target='0' unit='0'/>
      </source>
    </hostdev>
4. start 1st guest "a".
# virsh start a
Domain a started

5. login the guest "a"
In guest:
5.1 make sure the disk is passthrough to the guest now.
# fdisk -l
......
Disk /dev/sdb: 500.1 GB, 500107862016 bytes
171 heads, 40 sectors/track, 142803 cylinders
Units = cylinders of 6840 * 512 = 3502080 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xe9d80297

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         307     1048576   83  Linux
......

5.2 make sure the we can write to the passthrough disk.
# mount /dev/sdb1 /mnt/
# touch /mnt/test123
# ls /mnt/
lost+found test123

6. back to the Host, start the 2nd guest "b".
# virsh start b
error: Failed to start domain b
error: Requested operation is not valid: SCSI device 0:0:0:0 is in use by domain a

7. destroy the 1st guest "a".
# virsh destroy a
Domain a destroyed

8. add element "<shareable/>" in the 2 guests, the xml like the following one:
<hostdev mode='subsystem' type='scsi' managed='no'>
      <source>
        <adapter name='scsi_host0'/>
        <address bus='0' target='0' unit='0'/>
      </source>
      <shareable/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </hostdev>

9. start 1st guest "a".
# virsh start a
Domain a started

10. start 2nd guest "b", it should be started up if we add "<shareable>" element, but seems not.
# virsh start b
error: Failed to start domain b
error: Requested operation is not valid: SCSI device 0:0:0:0 is in use by domain a

Comment 6 Xuesong Zhang 2013-12-25 03:26:59 UTC
As for the attributes "sgio='filtered'", it depends on one libvirt bug 877527, after bug 877527 is fixed, we can test the attributes "sgio='filtered'".

Due to the issues in step 10 of comment 5, change the bug status back to "assign".

Comment 7 Xuesong Zhang 2013-12-25 05:54:15 UTC
(In reply to Zhang Xuesong from comment #6)
> As for the attributes "sgio='filtered'", it depends on one libvirt bug
> 877527, after bug 877527 is fixed, we can test the attributes
> "sgio='filtered'".

The root reason is kernel bug 966883 block to test this attribute.

> 
> Due to the issues in step 10 of comment 5, change the bug status back to
> "assign".

Comment 8 Xuesong Zhang 2014-01-07 05:25:24 UTC
There are other 3 test points in patch: https://www.redhat.com/archives/libvir-list/2013-May/msg00332.html

Tested the following version:
libvirt-1.1.1-17.el7.x86_64
qemu-kvm-rhev-1.5.3-30.el7.x86_64
kernel-3.10.0-65.el7.x86_64

Scenario1:
Test "<readonly/>"
Test sec label of the SCSI device

1. add the following xml to the guest:
  <hostdev mode='subsystem' type='scsi' managed='no'>
      <source>
        <adapter name='scsi_host0'/>
        <address bus='0' target='0' unit='0'/>
      </source>
      <readonly/>
      <alias name='hostdev0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </hostdev>
2. check the sec label of the SCSI devices
# ls -Z /dev/sg*
crw-rw----. root root  system_u:object_r:scsi_generic_device_t:s0 /dev/sg0

3. start the guest
# virsh start a
Domain a started

4. check the sec label of the SCSI devices again, make sure it is changed.
# ls -Z /dev/sg*
crw-rw----. qemu qemu  system_u:object_r:svirt_image_t:s0:c616,c842 /dev/sg0

5. login the guest
In guest:
5.1 make sure the SCSI deivce is in the guest:
# fdisk -l
......
Disk /dev/sdb: 500.1 GB, 500107862016 bytes
139 heads, 49 sectors/track, 143411 cylinders
Units = cylinders of 6811 * 512 = 3487232 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x29781cf9

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        3080    10485760   83  Linux
......
5.2 touch one file in the passthrough SCSI device------------------------the result is not as expected, it should be readonly, can't be wrote.
# mount /dev/sdb1 /mnt/
# ls /mnt/
lost+found
# touch /mnt/new
# ls /mnt/
lost+found  new

Scenario2:
test the "boot order"
1. add the following xml to the guest:
 <hostdev mode='subsystem' type='scsi' managed='no'>
      <source>
        <adapter name='scsi_host9'/>
        <address bus='0' target='0' unit='0'/>
      </source>
      <boot order='1'/>
      <alias name='hostdev0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </hostdev>
2. delete the the following config in the guest xml:
<boot dev='hd'/>
3. start the guest:
# virsh start a
Domain a started
4. the guest start from the SCSI device os.
5. edit the guest xml like the following one:
# virsh dumpxml a 
......
 <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' cache='none'/>
      <source file='/var/lib/libvirt/images/kvm-rhel6.4-x86_64-qcow2.img'/>
      <target dev='hda' bus='ide'/>
      <boot order='1'/>
      <alias name='ide0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
......
    <hostdev mode='subsystem' type='scsi' managed='no'>
      <source>
        <adapter name='scsi_host9'/>
        <address bus='0' target='0' unit='0'/>
      </source>
      <shareable/>
      <boot order='2'/>
      <alias name='hostdev0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </hostdev>
......

6. start the guest
7. the guest will be booted up from the device, which the number is more smaller.


Summary:
There are 5 test points in this bug, some are failed, some are blocked, some are pass, following is the summary of these 5 scenarios testing:
1) test <shareable/> ---------------------- Fail, details see comments 5
2) test <sgio='filtered'> ----------------- Blocked by kernel bug 966883
3) test <readonly/> ----------------------- FAIL
4) test sec label of the SCSI device ------ PASS
5) test boot index of the SCSI device ----- PASS

Comment 16 Jiri Denemark 2014-02-06 15:28:32 UTC
The tests don't work on s390:

TEST: virscsitest
 1) test1  ... OK
 2) test2  ... libvirt:  error : SCSI device '1:0:0:0': could not access /builddir/build/BUILD/libvirt-1.1.1/tests/virscsidata/sg8: No such file or directory
FAILED

Comment 18 Xuesong Zhang 2014-03-03 08:08:10 UTC
There are 4 test points in the bug, and 1 test point is blocked by kernel bug 966883. And the kernel bug is just fixed on 26th Feb, this kernel patch is included too late, blocked us to test this bug for a long time. so start to verify this libvirt bug.
The verify result summary is following:
1) test <shareable/> ---------------------- Fail, libvirtd crashed due to kernel started to support "sgio". This kernel patch is included too late. Details see step 11 in test point 1.
2) test <sgio='filtered'> ----------------- Fail, the unpriv_sgio vale is not as expected, details see the step 4 of test point 2.
4) test sec label of the SCSI device ------ PASS
5) test boot index of the SCSI device ----- PASS


Since there are 2 test points are failed, so change the bug status back to "ASSIGN".



Package version:
libvirt-1.1.1-25.el7.x86_64
qemu-kvm-rhev-1.5.3-50.el7.x86_64
kernel-3.10.0-98.el7.x86_64

Test point 1: -- test <shareable/> --- Fail
1. modprobe sg module
# modprobe sg
2. find one host contains 2 disk devices, make sure there are scsi generic devices.
# virsh nodedev-list --tree
......
 pci_0000_00_1f_2
  |   |
  |   +- scsi_host0
  |   |   |
  |   |   +- scsi_target0_0_0
  |   |       |
  |   |       +- scsi_0_0_0_0
  |   |           |
  |   |           +- block_sda_SAMSUNG_HD502IJ_S1W3J9FZ101727
  |   |           +- scsi_generic_sg0
  |   |             
  |   +- scsi_host1
  |   |   |
  |   |   +- scsi_target1_0_0
  |   |       |
  |   |       +- scsi_1_0_0_0
  |   |           |
  |   |           +- block_sr0_hp_DDVDW_TS_H653R_R0626GAZ11057400
  |   |           +- scsi_generic_sg1
  |   |             
  |   +- scsi_host2
  |   |   |
  |   |   +- scsi_target2_0_0
  |   |       |
  |   |       +- scsi_2_0_0_0
  |   |           |
  |   |           +- block_sdb_ST3500418AS_9VMGHLCY
  |   |           +- scsi_generic_sg2
......

3. add the following xml to two guests "a" and "b".
<hostdev mode='subsystem' type='scsi' managed='no'>
      <source>
        <adapter name='scsi_host0'/>
        <address bus='0' target='0' unit='0'/>
      </source>
    </hostdev>
4. start 1st guest "a".
# virsh start a
Domain a started

5. login the guest "a"
In guest:
5.1 make sure the disk is passthrough to the guest now.
# fdisk -l
......
Disk /dev/sdb: 500.1 GB, 500107862016 bytes
171 heads, 40 sectors/track, 142803 cylinders
Units = cylinders of 6840 * 512 = 3502080 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xe9d80297

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         307     1048576   83  Linux
......

5.2 make sure the we can write to the passthrough disk.
# mount /dev/sdb1 /mnt/
# touch /mnt/test123
# ls /mnt/
lost+found test123

6. back to the Host, start the 2nd guest "b".
# virsh start b
error: Failed to start domain b
error: Requested operation is not valid: SCSI device 0:0:0:0 is already in use by other domain(s) as 'non-shareable'

7. destroy the 1st guest "a".
# virsh destroy a
Domain a destroyed

8. add element "<shareable/>" in guest a, the xml like the following one:
<hostdev mode='subsystem' type='scsi' managed='no'>
      <source>
        <adapter name='scsi_host0'/>
        <address bus='0' target='0' unit='0'/>
      </source>
      <shareable/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </hostdev>

9. start 1st guest "a".
# virsh start a
Domain a started

10. start 2nd guest "b", it will report the error like following. Should the guest start? since the 
# virsh start b
error: Failed to start domain b
error: Requested operation is not valid: SCSI device 0:0:0:0 is already in use by other domain(s) as 'shareable'

11. add element "<shareable/>" in guest b, then start it, libvirtd crashed.
# virsh start r7-1125
error: Failed to start domain r7-1125
error: End of file while reading data: Input/output error
error: One or more references were leaked after disconnect from the hypervisor
error: Failed to reconnect to the hypervisor

Test point 2: 
1. test with lbpu
#  modprobe scsi_debug dev_size_mb=1024 lbpu=1 
# lsscsi|grep scsi_debug
[6:0:0:0]    disk    Linux    scsi_debug       0004  /dev/sdc
# ls -alt /dev/sdc
brw-rw----. 1 root disk 8, 32 Mar  3 15:05 /dev/sdc

2. make sure the guest contains the following scsi controller:
# virsh dumpxml b|grep scsi -A2
    <controller type='scsi' index='0' model='virtio-scsi'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
    </controller>

3. add the scsi device to the guest:
 <hostdev mode='subsystem' type='scsi' managed='no' sgio='unfiltered'>
      <source>
        <adapter name='scsi_host6'/>
        <address bus='0' target='0' unit='0'/>
      </source>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </hostdev>

4. start the guest, then check the unpriv_sgio vaule
# cat /sys/dev/block/8\:32/queue/unpriv_sgio 
0

5. destroy the guest, and change the sgio to "filtered"
 <hostdev mode='subsystem' type='scsi' managed='no' sgio='filtered'>
      <source>
        <adapter name='scsi_host6'/>
        <address bus='0' target='0' unit='0'/>
      </source>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </hostdev>
6. start the guest, check the unpriv_sgio value
# cat /sys/dev/block/8\:32/queue/unpriv_sgio 
0

7. destroy the guest, and delete the sgio
 <hostdev mode='subsystem' type='scsi' managed='no' sgio='filtered'>
      <source>
        <adapter name='scsi_host6'/>
        <address bus='0' target='0' unit='0'/>
      </source>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </hostdev>

8. start the guest, check the unpriv_sgio vule
# cat /sys/dev/block/8\:32/queue/unpriv_sgio 
0

9. test with lbpws
# modprobe scsi_debug dev_size_mb=1024 lbpws=1
# lsscsi |grep scsi_debug
[7:0:0:0]    disk    Linux    scsi_debug       0004  /dev/sdc 

10. retest the step 2 to step 8

Test point 3:--- test sec lable --- PASS
1. add scsi device like following to one shutoff guest:
 <hostdev mode='subsystem' type='scsi' managed='no'>
      <source>
        <adapter name='scsi_host6'/>
        <address bus='0' target='0' unit='0'/>
      </source>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </hostdev>
2. check sec label first:
# ll -Z /dev/sg*
crw-rw----. root root  system_u:object_r:scsi_generic_device_t:s0 /dev/sg3

3. start the guest
# virsh start a
Domain a started

4. check the sec label of the SCSI devices again, make sure it is changed as expected.
# ll -Z /dev/sg*
crw-rw----. qemu qemu  system_u:object_r:svirt_image_t:s0:c559,c628 /dev/sg3

Test point 4: test the "boot order" ---- PASS
1. add the following xml to the guest:
 <hostdev mode='subsystem' type='scsi' managed='no'>
      <source>
        <adapter name='scsi_host9'/>
        <address bus='0' target='0' unit='0'/>
      </source>
      <boot order='1'/>
      <alias name='hostdev0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </hostdev>
2. delete the the following config in the guest xml:
<boot dev='hd'/>
3. start the guest:
# virsh start a
Domain a started
4. the guest start from the SCSI device os.
5. edit the guest xml like the following one:
# virsh dumpxml a 
......
 <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' cache='none'/>
      <source file='/var/lib/libvirt/images/kvm-rhel6.4-x86_64-qcow2.img'/>
      <target dev='hda' bus='ide'/>
      <boot order='1'/>
      <alias name='ide0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
......
    <hostdev mode='subsystem' type='scsi' managed='no'>
      <source>
        <adapter name='scsi_host9'/>
        <address bus='0' target='0' unit='0'/>
      </source>
      <shareable/>
      <boot order='2'/>
      <alias name='hostdev0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </hostdev>
......

6. start the guest
7. the guest will be booted up from the device, which the number is more smaller.

Comment 19 Xuesong Zhang 2014-03-03 10:24:37 UTC
Created attachment 869876 [details]
backtrace

Add the libvirtd crashed backtrace

Comment 21 Xuesong Zhang 2014-03-05 06:03:05 UTC
As for the test point 2 "support <sgio> attribute", the reason is kernel didn't support sgio for sg device after debugging.
So, file 2 bugs to tracking this feature in rhel7.1.0, one is kernel RFE bug, and cloned another one bug for libvirt tracking.

Bug 1072734 - [RFE]support unpriv_sgio for the SCSI generic device  (kernel component, filed in rhel7.1.0)
Bug 1072736 - [RFE]support unpriv_sgio for the SCSI generic device  (libvirt component, filed in rhel7.1.0)

Comment 22 Paolo Bonzini 2014-03-05 13:25:37 UTC
Correct. I don't think this will be fixed in 7.1 though.  Also, it shouldn't block verification of this bug.

Comment 24 Jiri Denemark 2014-03-07 12:40:51 UTC
Osier, you said you created a patch and a scratch build to fix the crash. How did the testing go? Do we have a fix ready?

Comment 25 Xuesong Zhang 2014-03-07 14:47:47 UTC
Tested with the scratch libvirt build, this crashed issue is fixed.
And the 4 test points are all PASS now, we will go on to test some other functional testing about this feature later.

Package version:
Scratch libvirt build version:
https://brewweb.devel.redhat.com/taskinfo?taskID=7150768

qemu-kvm-rhev-1.5.3-52.el7.x86_64
kernel-3.10.0-105.el7.x86_64

Test point 1: -- test <shareable/> --- PASS
1. modprobe sg module
# modprobe sg
2. find one host contains 2 disk devices, make sure there are scsi generic devices.
# virsh nodedev-list --tree
......
 pci_0000_00_1f_2
  |   |
  |   +- scsi_host0
  |   |   |
  |   |   +- scsi_target0_0_0
  |   |       |
  |   |       +- scsi_0_0_0_0
  |   |           |
  |   |           +- block_sda_SAMSUNG_HD502IJ_S1W3J9FZ101727
  |   |           +- scsi_generic_sg0
  |   |             
  |   +- scsi_host1
  |   |   |
  |   |   +- scsi_target1_0_0
  |   |       |
  |   |       +- scsi_1_0_0_0
  |   |           |
  |   |           +- block_sr0_hp_DDVDW_TS_H653R_R0626GAZ11057400
  |   |           +- scsi_generic_sg1
  |   |             
  |   +- scsi_host2
  |   |   |
  |   |   +- scsi_target2_0_0
  |   |       |
  |   |       +- scsi_2_0_0_0
  |   |           |
  |   |           +- block_sdb_ST3500418AS_9VMGHLCY
  |   |           +- scsi_generic_sg2
......

3. add the following xml to two guests "a" and "b".
<hostdev mode='subsystem' type='scsi' managed='no'>
      <source>
        <adapter name='scsi_host0'/>
        <address bus='0' target='0' unit='0'/>
      </source>
    </hostdev>
4. start 1st guest "a".
# virsh start a
Domain a started

5. login the guest "a"
In guest:
5.1 make sure the disk is passthrough to the guest now.
# fdisk -l
......
Disk /dev/sdb: 500.1 GB, 500107862016 bytes
171 heads, 40 sectors/track, 142803 cylinders
Units = cylinders of 6840 * 512 = 3502080 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xe9d80297

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         307     1048576   83  Linux
......

5.2 make sure the we can write to the passthrough disk.
# mount /dev/sdb1 /mnt/
# touch /mnt/test123
# ls /mnt/
lost+found test123

6. back to the Host, start the 2nd guest "b".
# virsh start b
error: Failed to start domain b
error: Requested operation is not valid: SCSI device 0:0:0:0 is already in use by other domain(s) as 'non-shareable'

7. destroy the 1st guest "a".
# virsh destroy a
Domain a destroyed

8. add element "<shareable/>" in guest a, the xml like the following one:
<hostdev mode='subsystem' type='scsi' managed='no'>
      <source>
        <adapter name='scsi_host0'/>
        <address bus='0' target='0' unit='0'/>
      </source>
      <shareable/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </hostdev>

9. start 1st guest "a".
# virsh start a
Domain a started

10. start 2nd guest "b", it will report the error like following. Should the guest start? since the 
# virsh start b
error: Failed to start domain b
error: Requested operation is not valid: SCSI device 0:0:0:0 is already in use by other domain(s) as 'shareable'

11. add element "<shareable/>" in guest b, then start it, no crash now.
# virsh start b
Domain b started


Test point 2: ---- test <sgio> --- PASS
1. add the following xml to the guest, note add sgio attribute.
   <hostdev mode='subsystem' type='scsi' managed='no' sgio='filtered'>
      <source>
        <adapter name='scsi_host0'/>
        <address bus='0' target='0' unit='0'/>
      </source>
      <shareable/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </hostdev>

2. start the guest, will get the error as expected.
# virsh start rhel7-2
error: Failed to start domain rhel7-2
error: internal error: 'sgio' is not supported for SCSIgeneric device yet 

3. change the sgio to "unfiltered"
 <hostdev mode='subsystem' type='scsi' managed='no' sgio='unfiltered'>
      <source>
        <adapter name='scsi_host0'/>
        <address bus='0' target='0' unit='0'/>
      </source>
      <shareable/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </hostdev>

4. start the guest again, will get the error as expected also.
virsh start rhel7-2
error: Failed to start domain rhel7-2
error: internal error: 'sgio' is not supported for SCSIgeneric device yet 


Test point 3:--- test sec lable --- PASS
1. add scsi device like following to one shutoff guest:
 <hostdev mode='subsystem' type='scsi' managed='no'>
      <source>
        <adapter name='scsi_host6'/>
        <address bus='0' target='0' unit='0'/>
      </source>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </hostdev>
2. check sec label first:
# ll -Z /dev/sg*
crw-rw----. root root  system_u:object_r:scsi_generic_device_t:s0 /dev/sg3

3. start the guest
# virsh start a
Domain a started

4. check the sec label of the SCSI devices again, make sure it is changed as expected.
# ll -Z /dev/sg*
crw-rw----. qemu qemu  system_u:object_r:svirt_image_t:s0:c559,c628 /dev/sg3

Test point 4: test the "boot order" ---- PASS
1. add the following xml to the guest:
 <hostdev mode='subsystem' type='scsi' managed='no'>
      <source>
        <adapter name='scsi_host9'/>
        <address bus='0' target='0' unit='0'/>
      </source>
      <boot order='1'/>
      <alias name='hostdev0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </hostdev>
2. delete the the following config in the guest xml:
<boot dev='hd'/>
3. start the guest:
# virsh start a
Domain a started
4. the guest start from the SCSI device os.
5. edit the guest xml like the following one:
# virsh dumpxml a 
......
 <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' cache='none'/>
      <source file='/var/lib/libvirt/images/kvm-rhel6.4-x86_64-qcow2.img'/>
      <target dev='hda' bus='ide'/>
      <boot order='1'/>
      <alias name='ide0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
......
    <hostdev mode='subsystem' type='scsi' managed='no'>
      <source>
        <adapter name='scsi_host9'/>
        <address bus='0' target='0' unit='0'/>
      </source>
      <shareable/>
      <boot order='2'/>
      <alias name='hostdev0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </hostdev>
......

6. start the guest
7. the guest will be booted up from the device, which the number is more smaller.

Comment 26 Osier Yang 2014-03-07 14:54:47 UTC
(In reply to Jiri Denemark from comment #24)
> Osier, you said you created a patch and a scratch build to fix the crash.
> How did the testing go? Do we have a fix ready?

Upstream patch (from testing passed && lasted scratch build):

http://www.redhat.com/archives/libvir-list/2014-March/msg00481.html

Comment 27 Xuesong Zhang 2014-03-11 03:37:56 UTC
The scratch build in comment 25 block the PCI assignment.
Such as add the following xml to one shutoff guest
 <hostdev mode='subsystem' type='pci' managed='yes'>
       <source>
        <address domain='0x0000' bus='0x03' slot='0x11' function='0x4'/>
       </source>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
     </hostdev>

Note that, there isn't any sgio setting in the guest dumpxml.
Then start the guest, will see the following error:
# virsh start rhel7-2
error: Failed to start domain rhel7-2
error: internal error: 'sgio' is not supported for SCSIgeneric device yet 


Osier fixed this issue yesterday, test the following new scratch build:
http://brewweb.devel.redhat.com/brew/taskinfo?taskID=7174414

All the test point in comment 25 are PASS;
Assign PCI device to guest are working well also.

So, the new scratch build are PASS.

Comment 31 Xuesong Zhang 2014-03-19 03:20:43 UTC
Test with the following build, this bug is fixed.

package version:
libvirt-1.1.1-28.el7.x86_64
qemu-kvm-rhev-1.5.3-53.el7.x86_64
kernel-3.10.0-112.el7.x86_64

The details steps and result is same with comment 25

Comment 33 Ludek Smid 2014-06-13 13:04:29 UTC
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.


Note You need to log in before you can comment on or make changes to this bug.