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 1206406 - blockcopy to a gluster volume calls drive-mirror with wrong parameters
Summary: blockcopy to a gluster volume calls drive-mirror with wrong parameters
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.2
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Ján Tomko
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-03-27 02:56 UTC by Luyao Huang
Modified: 2015-11-19 06:25 UTC (History)
6 users (show)

Fixed In Version: libvirt-1.2.14-1.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-11-19 06:25:41 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:2202 0 normal SHIPPED_LIVE libvirt bug fix and enhancement update 2015-11-19 08:17:58 UTC

Description Luyao Huang 2015-03-27 02:56:53 UTC
description of problem:
libvirt send a wrong command to qemu when try to do blcok migrate to a gluster volume

Version-Release number of selected component (if applicable):
libvirt-1.2.13-1.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
 
1.prepare a transient vm
# virsh create test3.xml

2.prepare gluster volume xml:
# cat gluster.xml
    <disk type='network' device='disk'>
      <driver name='qemu' type='raw' cache='none'/>
      <source protocol='gluster' name='gluster-vol1/rh6.img.s2'>
        <host name='10.66.100.118'/>
      </source>
      <target dev='vdd' bus='virtio'/>
      <shareable/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
    </disk>


3. do blockcopy
# virsh blockcopy test3 hda --xml gluster.xml
error: internal error: unable to execute QEMU command 'drive-mirror': Could not create file: Permission denied

Actual results:
libvirt send a wrong command to qemu when try to do blcok migrate to a gluster volume

Expected results:
if support this do it success, if not report error more early

infomation:

2015-03-27 02:00:55.601+0000: 11778: debug : virStorageFileBackendGlusterInit:588 : initializing gluster storage file 0x7fdd58001300 (gluster://10.66.100.118:0/gluster-vol1/rh6.img.s2)[0:0]
2015-03-27 02:00:55.642+0000: 11778: debug : virStorageFileChown:2783 : chown of storage file 0x7fdd58001300 to 107:107
2015-03-27 02:00:55.644+0000: 11778: debug : virStorageFileBackendGlusterDeinit:559 : deinitializing gluster storage file 0x7fdd58001300 (gluster://10.66.100.118:0/gluster-vol1/rh6.img.s2)
2015-03-27 02:00:55.644+0000: 11778: info : virObjectUnref:259 : OBJECT_UNREF: obj=0x7fdd68186020
2015-03-27 02:00:55.644+0000: 11778: debug : qemuDomainObjEnterMonitorInternal:1548 : Entering monitor (mon=0x7fdd60000d00 vm=0x7fdd68248400 name=test3)
2015-03-27 02:00:55.644+0000: 11778: info : virObjectRef:296 : OBJECT_REF: obj=0x7fdd60000d00
2015-03-27 02:00:55.644+0000: 11778: debug : qemuMonitorDriveMirror:3430 : mon=0x7fdd60000d00, device=drive-ide0-0-0, file=/rh6.img.s2, format=raw, bandwidth=0, granularity=0, buf_size=0, flags=0
2015-03-27 02:00:55.644+0000: 11778: debug : virJSONValueToString:1665 : object=0x7fdd5829af70

2015-03-27 02:00:55.644+0000: 11778: debug : virJSONValueToString:1698 : result={"execute":"drive-mirror","arguments":{"device":"drive-ide0-0-0","target":"/rh6.img.s2","sync":"full","mode":"absolute-paths","format":"raw"},"id":"libvirt-10"}
2015-03-27 02:00:55.644+0000: 11778: debug : qemuMonitorJSONCommandWithFd:290 : Send command '{"execute":"drive-mirror","arguments":{"device":"drive-ide0-0-0","target":"/rh6.img.s2","sync":"full","mode":"absolute-paths","format":"raw"},"id":"libvirt-10"}' for write with FD -1
2015-03-27 02:00:55.644+0000: 11778: info : virEventPollUpdateHandle:152 : EVENT_POLL_UPDATE_HANDLE: watch=10 events=15
2015-03-27 02:00:55.644+0000: 11778: debug : virEventPollInterruptLocked:726 : Interrupting
2015-03-27 02:00:55.644+0000: 11778: info : qemuMonitorSend:972 : QEMU_MONITOR_SEND_MSG: mon=0x7fdd60000d00 msg={"execute":"drive-mirror","arguments":{"device":"drive-ide0-0-0","target":"/rh6.img.s2","sync":"full","mode":"absolute-paths","format":"raw"},"id":"libvirt-10"}
 fd=-1
...
2015-03-27 02:00:55.651+0000: 11774: info : qemuMonitorIOProcess:399 : QEMU_MONITOR_IO_PROCESS: mon=0x7fdd60000d00 buf={"id": "libvirt-10", "error": {"class": "GenericError", "desc": "Could not create file: Permission denied"}}
 len=110

Also i can find avc report that qemu try to create/read file in "/"

time->Fri Mar 27 09:58:07 2015
type=SYSCALL msg=audit(1427421487.828:135051): arch=c000003e syscall=4 success=yes exit=0 a0=7f070e71ce40 a1=7fff204b3370 a2=7fff204b3370 a3=7f0706262920 items=0 ppid=1 pid=10603 auid=4294967295 uid=107 gid=107 euid=107 suid=107 fsuid=107 egid=107 sgid=107 fsgid=107 tty=(none) ses=4294967295 comm="qemu-kvm" exe="/usr/libexec/qemu-kvm" subj=system_u:system_r:svirt_t:s0:c81,c359 key=(null)
type=AVC msg=audit(1427421487.828:135051): avc:  denied  { getattr } for  pid=10603 comm="qemu-kvm" path="/rh6.img.s2" dev="dm-0" ino=1055130 scontext=system_u:system_r:svirt_t:s0:c81,c359 tcontext=system_u:object_r:root_t:s0 tclass=file
----


Additional info:

From Shanzhi Yu:

The error show it is not supported to copy to no-file destination. 
What we need is a goto endjob when try to copy to a non-file destination

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index db4f0b4..f07e4fb 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -16642,6 +16642,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
     if (!virStorageSourceIsLocalStorage(mirror)) {
         virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
                        _("non-file destination not supported yet"));
+        goto endjob;
     }
     if (stat(mirror->path, &st) < 0) {
         if (errno != ENOENT) {

Comment 1 Ján Tomko 2015-03-27 09:33:15 UTC
Fixed upstream by:
commit c5fbad66234b1b1a9afc36ef2fe3a3d903886386
Author:     Shanzhi Yu <shyu>
CommitDate: 2015-03-27 10:30:50 +0100

    qemu: end the job when try to blockcopy to non-file destination
    
    Blockcopy to non-file destination is not supported according the code,
    but a 'goto endjob' is missed after checking the destination.
    
    This leads to calling drive-mirror with wrong parameters.
    
    Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1206406
    Signed-off-by: Shanzhi Yu <shyu>
    Signed-off-by: Ján Tomko <jtomko>

git describe: v1.2.14-rc1-2-gc5fbad6

Comment 3 Shanzhi Yu 2015-06-15 10:31:56 UTC
Verify this bug with libvirt-1.2.16-1.el7.x86_64 libvirt-1.2.16-1.el7.x86_64

1. Prepare transient guest 
# virsh list --transient
 Id    Name                           State
----------------------------------------------------
 4     vol-d                          running


2. Prepare destination file 
# cat gluster.xml 
    <disk type='network' device='disk'>
      <driver name='qemu' type='raw' cache='none'/>
      <source protocol='gluster' name='gluster-vol1/rh6.img.s2'>
        <host name='10.66.x.xxx'/>
      </source>
      <target dev='vdb' bus='virtio'/>
      <shareable/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
    </disk>
# cat rbd.xml 
    <disk type='network' device='disk'>
      <driver name='qemu' type='raw' cache='none'/>
      <source protocol='rbd' name='libvirt-pool/test.img'>
     <host name='10.66.x.xxx'/>
    <host name='10.66.x.xxx'/>
    <host name='10.66.x.xxx'/>
      </source>
      <target dev='vdb' bus='virtio'/>
      <shareable/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
    </disk>
# virsh blockcopy vol-d vdb --xml rbd.xml 
error: argument unsupported: non-file destination not supported yet

# virsh blockcopy vol-d vdb --xml gluster.xml 
error: argument unsupported: non-file destination not supported yet

I have a problem. when do block copy to a local file with absolute/relative path we don't need option "--dest", while if do block copy with "dest.xml", --xml is needed. 
otherwise it will treat dest.xml file as the real destination file. 

# virsh blockcopy r7 vdb 
error: need either --dest or --xml

# virsh blockcopy r7 vdb rbd.xml 
Block Copy started

Should libvirt can recognise it is a config file but not a destination file path when pass a xml file to it ?

Without this problem, this bug can be verified.

Comment 4 Ján Tomko 2015-06-15 12:14:12 UTC
virsh should not guess whether it's a config file based on the extension or its contents.

The third parameter is assumed to be the destination, I have sent a patch against the virsh manual to clarify that:
https://www.redhat.com/archives/libvir-list/2015-June/msg00629.html

Comment 5 Shanzhi Yu 2015-06-16 01:42:11 UTC
Thanks, verify this bug.

Comment 7 errata-xmlrpc 2015-11-19 06:25:41 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://rhn.redhat.com/errata/RHBA-2015-2202.html


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