Bug 1461301 - unknown error occurred when attach a disk with a pci address already occupied in guest while virtlockd is enabled
unknown error occurred when attach a disk with a pci address already occupied...
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt (Show other bugs)
7.4
x86_64 Linux
unspecified Severity unspecified
: rc
: ---
Assigned To: Peter Krempa
Han Han
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2017-06-14 03:25 EDT by yafu
Modified: 2018-04-10 06:50 EDT (History)
8 users (show)

See Also:
Fixed In Version: libvirt-3.8.0-1.el7
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2018-04-10 06:48:37 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHEA-2018:0704 None None None 2018-04-10 06:50 EDT

  None (edit)
Description yafu 2017-06-14 03:25:07 EDT
Description of problem:
unknown error occurred when attach a disk with a pci address already occupied in guest while virtlockd is enabled

Version-Release number of selected component (if applicable):
libvirt-3.2.0-9.virtcov.el7.x86_64
qemu-kvm-rhev-2.9.0-10.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1.Set lock_manageer as 'lockd' and restart libvirtd service:
#cat /etc/libvirt/qemu.conf
lock_manager = 'lockd'
#systemctl restart libvirtd

2.Start a guest:
#virsh start full-73

3.Prepare a disk with pci address aleardy occupied in guest:
#cat disk.xml
  <disk type='file' device='disk'>
       <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/test.qcow2'/>
      <target dev='vdb' bus='virtio'/>
      ****<address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>***
    </disk>

4.Hotplug the disk to the guest:
#virsh attach-device full-73 disk.xml
error: Failed to attach device from disk.xml
error: An error occurred, but the cause is unknown

Actual results:
unknown error occurred when attach a disk with a pci address already occupied in guest while virtlockd is enabled

Expected results:
Should report clear error as follows:
# virsh attach-device full-73 disk.xml
error: Failed to attach device from disk.xml
error: XML error: Attempted double use of PCI Address 0000:00:0a.0
Comment 2 Han Han 2017-06-14 04:01:58 EDT
Confirmed regression:
It works on libvirt-2.0.0-10.el7_3.9.x86_64 of RHEL7.3.z

1. Set lock_manager = "lockd" in /etc/libvirt/qemu.conf
2. Restart virtlockd and libvirtd
3. Start a VM:
# virsh list 
 Id    Name                           State
----------------------------------------------------
 1     avocado-vt-vm1                 running

4. Attach a disk with pci address then detach it:
# virsh attach-disk avocado-vt-vm1 /tmp/raw vdb  --address pci:0000.00.a.0
Disk attached successfully

# virsh detach-disk avocado-vt-vm1 vdb                                    
Disk detached successfully
Comment 3 Han Han 2017-06-14 04:39:57 EDT
Sorry for the mistake in comment2. Actually it is not a regression, in other words, it can be reproduced on libvirt-2.0.0-10.el7_3.9.x86_64

One more scenario:
It can be reproduce when attach to an unreachable pci address:
# virsh attach-disk avocado-vt-vm1 /tmp/raw vdb  --address pci:000a.00.6.0
error: Failed to attach disk
error: An error occurred, but the cause is unknown
Comment 4 Peter Krempa 2017-09-14 23:40:19 EDT
Fixed upstream:

commit a823d0a62e858a62a585a78599b6d859c5b4dcac 
Author: Peter Krempa <pkrempa@redhat.com>
Date:   Mon Sep 11 15:28:15 2017 +0200

    qemu: Restore errors when rolling back disk image state
    
    Some operations done to rollback disk image labelling and locking might
    overwrite (or clear) the actual error. Remember the original error when
    tearing down disk access so that it's not obscured.
Comment 6 Han Han 2017-11-06 21:38:53 EST
Verified on libvirt-3.9.0-1.el7.x86_64:
1. Setup virtlockd env:
In qemu.conf:
lock_manager = "lockd"

# systemctl restart virtlockd
# systemctl restart libvirtd

2. Start an VM. Attach two disks to the same pci address
# virsh attach-disk V /tmp/a vdb --address pci:0000.00.a.0
Disk attached successfully

# virsh attach-disk V /tmp/b vdc --address pci:0000.00.a.0
error: Failed to attach disk
error: XML error: Attempted double use of PCI Address 0000:00:0a.0

Libvirt gives clear error message when attaching to duplicate pci address.
Bug fixed.
Comment 10 errata-xmlrpc 2018-04-10 06:48:37 EDT
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/RHEA-2018:0704

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