Bug 1302171

Summary: [blockcopy] unknown error while virtlockd is on
Product: Red Hat Enterprise Linux 7 Reporter: Han Han <hhan>
Component: libvirtAssignee: Peter Krempa <pkrempa>
Status: CLOSED ERRATA QA Contact: yisun
Severity: medium Docs Contact:
Priority: unspecified    
Version: 7.2CC: dyuan, jdenemar, rbalakri, xuzhang, yanyang
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-3.0.0-1.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-01 17:09:12 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:
Attachments:
Description Flags
logs none

Description Han Han 2016-01-27 02:10:50 UTC
Created attachment 1118647 [details]
logs

Description of problem:
When virtlockd is on, do blockcopy to a unprivileged dir or from a nfs dir will cause unknown error.

Version-Release number of selected component (if applicable):
libvirt-1.2.17-13.el7_2.2.x86_64
qemu-kvm-rhev-2.3.0-31.el7_2.7.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Setup virtlockd env
# cat /etc/libvirt/qemu-lockd.conf
auto_disk_leases = 1
require_lease_for_disks = 1
file_lockspace_dir = "/var/lib/libvirt/lockd/files"

# cat /etc/libvirt/qemu.conf
lock_manager = "lockd"

# systemctl restart virtlockd && systemctl restart libvirtd


2. blockcopy for a transient running guest whose os image based on nfs.
# setsebool virt_use_nfs 1

# df -h |grep hhan
xx.xx.xx.xx:/xx/xx/hhan  975G  513G  463G  53% /nfs

#virsh blockcopy n3 vda /var/lib/libvirt/images/n3.cpy --wait --verbose                                         
error: An error occurred, but the cause is unknown


3. Prepare a local transient running guest, do blockcopy to /root dir
# virsh blockcopy n2 vda /root/n2.cpy --wait --verbose
error: An error occurred, but the cause is unknown

Actual results:
As step2&3 shows.


Expected results:
Step2 should finish blockcopy successfully. 
Step3 should be the error:
error: internal error: unable to execute QEMU command 'drive-mirror': Could not create file: Permission denied

Additional info:
Because the step2 and step3 are both unknown error in virtlockd&blockcopy environment, report them as one bug. Pls split to two bugs if necessary.

Comment 2 Peter Krempa 2016-12-19 16:30:04 UTC
Fixed upstream:

commit 8551d39f4fbdb56551882ad3b48feb172da42ed6
Author: Peter Krempa <pkrempa>
Date:   Thu Dec 15 15:09:47 2016 +0100

    qemu: blockcopy: Save monitor error prior to calling into lock manager
    
    The error would be overwritten otherwise producing a meaningless error
    message.

Comment 4 yisun 2017-02-27 03:19:29 UTC
Verified on libvirt-3.0.0-2.el7.x86_64 & qemu-kvm-rhev-2.8.0-4.el7.x86_64

============= scenario 1: blockcopy to a nfs dir =============
## cat /etc/libvirt/qemu-lockd.conf
auto_disk_leases = 1
require_lease_for_disks = 1
file_lockspace_dir = "/var/lib/libvirt/lockd/files"

## cat /etc/libvirt/qemu.conf
lock_manager = "lockd"

## systemctl restart virtlockd && systemctl restart libvirtd

## mount | grep /tt
localhost:/home/nfs on /tt type nfs (rw,relatime,vers=3,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=localhost,mountvers=3,mountport=20048,mountproto=udp,local_lock=none,addr=localhost)

## setsebool virt_use_nfs 1

## virsh create ~/vm1
Domain vm1 created from /root/vm1

## virsh blockcopy vm1 vda /var/lib/libvirt/images/vm1.cpy --wait --verbose                                         
Block Copy: [100 %]
Now in mirroring phase
<=== expected completion

## virsh dumpxml vm1 | grep disk -a10
...
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/RHEL-7.3-latest.img'/>
      <backingStore/>
      <mirror type='file' file='/var/lib/libvirt/images/vm1.cpy' format='qcow2' job='copy' ready='yes'>
        <format type='qcow2'/>
        <source file='/var/lib/libvirt/images/vm1.cpy'/>
      </mirror>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </disk>
...

============= scenario 2: blockcopy to root dir =============
## virsh create ~/vm1
Domain vm1 created from /root/vm1

## virsh blockcopy vm1 vda /root/vm1.cpy --wait --verbose
error: internal error: unable to execute QEMU command 'drive-mirror': Could not create file: Permission denied
<=== expected with clear error message


## virsh dumpxml vm1 | grep disk -a10
...
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/RHEL-7.3-latest.img'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </disk>
...

Comment 5 errata-xmlrpc 2017-08-01 17:09:12 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/RHEA-2017:1846

Comment 6 errata-xmlrpc 2017-08-01 23:51:16 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/RHEA-2017:1846