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 1656360 - when <shareable/> removed from scsi hostdev xml, related chardev's unpriv_sgio not set back to zero.
Summary: when <shareable/> removed from scsi hostdev xml, related chardev's unpriv_sgi...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.6
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: John Ferlan
QA Contact: yisun
URL:
Whiteboard:
Depends On: 1072736 1631733
Blocks: 1656362
TreeView+ depends on / blocked
 
Reported: 2018-12-05 10:34 UTC by yisun
Modified: 2019-08-06 13:14 UTC (History)
6 users (show)

Fixed In Version: libvirt-4.5.0-11.el7
Doc Type: Bug Fix
Doc Text:
Cause: Flawed logic Consequence: Removing the <shareable/> element from a <hostdev...> will not reset the kernel unpriv sgio setting to 0 if previously set. Fix: Altered the code to ensure that the value is written as 1 only when the shareable element is provided and to write a 0 if the file exists regardless of whether the value was 0 previously. Result: Properly set unprivileged sgio setting
Clone Of: 1631733
: 1656362 (view as bug list)
Environment:
Last Closed: 2019-08-06 13:14:02 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2019:2294 0 None None None 2019-08-06 13:14:45 UTC

Description yisun 2018-12-05 10:34:22 UTC
Description of problem:
when <shareable/> removed from scsi hostdev xml, related chardev's unpriv_sgio not set back to zero.

Version-Release number of selected component (if applicable):
libvirt-4.5.0-10.virtcov.el7.x86_64
qemu-kvm-rhev-2.12.0-17.el7.x86_64


How reproducible:
100%

---- From John Ferlan ----
> Going back to the problem statement and the dump of the hostdev:
> So, I think this particular issue can be set as notabug; however, there is
> an interesting gotcha that I did find in the code. Because the code returns
> 0 early, if unpriv_sgio was previously set, then someone removes the
> <shareable/> element from the domain, the sysfs value won't get changed.
> 
> ...
>     } else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
>         hostdev = dev->data.hostdev;
> 
>         if (!qemuIsSharedHostdev(hostdev))
>             return 0;
> 
>         if (!(hostdev_path = qemuGetHostdevPath(hostdev)))
>             goto cleanup;
> 
>         path = hostdev_path;
>     } else {
> ...
> 
> Note the quiet return 0 if not shared.
> 
> But that's a "different" bug/issue... Present in existing code and fix-able
> in a "future" revision.  It's not that big a deal anyway.
> 
> I did test that I could fix it though... Using the /home/libvirt-rhel
> repository that I built with the /home/libvirt-rhel/amend.patch, you can
> "service libvirtd stop", then "setenforce 0", "/home/libvirt-rhel/run
> /home/libvirt-rhel/src/libvirtd", and then see that when the <shareable/> is
> removed from the domain that a previously set value of 1 is returned to 0.
> And then restore things by quitting the libvirtd, resetting "setenforce
> enforcing", and restarting libvirt "service libvirtd start".
> 
> I've left the system essentially the same way I found it with avocado-vt-vm1
> running *without* the <shareable/> set on the hostdev. You can test that at
> least by adding <shareable/> and restarting the domain that you get what's
> expected.


So the reproduce steps could be as follow:
1. start a vm with following xml (you can prepare a iscsi lun to be used, here is 89:0:0:0)
    <hostdev mode='subsystem' type='scsi' managed='no' sgio='unfiltered'>
      <source>
        <adapter name='scsi_host89'/>
        <address bus='0' target='0' unit='0'/>
      </source>
      <shareable/>
      <alias name='hostdev0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </hostdev>

# virsh start avocado-vt-vm1
Domain avocado-vt-vm1 started

2. check the scsi device's unpriv_sgio value on host
# cat /sys/dev/block/*/device/unpriv_sgio
0
1 <==== here is changed from 0 to 1

3. destroy and edit vm's hostdev xml, remove the <shareable/>
    <hostdev mode='subsystem' type='scsi' managed='no' sgio='unfiltered'>
      <source>
        <adapter name='scsi_host89'/>
        <address bus='0' target='0' unit='0'/>
      </source>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </hostdev>

4. start the vm again
# virsh start avocado-vt-vm1
Domain avocado-vt-vm1 started

5. check the unpriv_sgio value
[root@ibm-x3650m3-08 ~]# cat /sys/dev/block/*/device/unpriv_sgio
0
1 <==== it's still 1, not changed back to 0

Actual result:
as step 5

Expected result:
if remove shareable tag from hostdev, its unpriv_sgio value should be changed back to 0

Comment 4 yisun 2019-04-26 03:18:38 UTC
test with libvirt-4.5.0-15.virtcov.el7.x86_64
and PASSED

1. Having a scsi fun
[root@dell-per740-08 ~]# lsscsi
...
[76:0:0:0]   disk    LIO-ORG  device.logical-  4.0   /dev/sdb

2. add following xml to vm:
[root@dell-per730-58 device]# virsh dumpxml avocado-vt-vm1 | grep hostdev -A10
    <hostdev mode='subsystem' type='scsi' managed='no' sgio='unfiltered'>
      <source>
        <adapter name='scsi_host76'/>
        <address bus='0' target='0' unit='0'/>
      </source>
      <shareable/>
      <alias name='hostdev0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </hostdev>


3. Start the vm and check the unpriv_sgio value
[root@dell-per740-08 device]# virsh start avocado-vt-vm1
Domain avocado-vt-vm1 started

[root@dell-per740-08 device]# cd /sys/block/sdb/device
[root@dell-per740-08 device]# cat unpriv_sgio
1

4. Edit the domain xml and remove the <sharebale/> tag from hostdev
[root@dell-per740-08 device]# virsh edit avocado-vt-vm1
Domain avocado-vt-vm1 XML configuration edited.

5. Restart the vm and check the unpriv_sgio value again
[root@dell-per740-08 device]# virsh destroy avocado-vt-vm1; virsh start avocado-vt-vm1
Domain avocado-vt-vm1 destroyed

Domain avocado-vt-vm1 started

[root@dell-per740-08 device]# cat unpriv_sgio
0

Comment 7 errata-xmlrpc 2019-08-06 13:14:02 UTC
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://access.redhat.com/errata/RHSA-2019:2294


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