Bug 1155484

Summary: virDomainBlockCopy cannot get a right flag when use libvirt_virDomainBlockCopy
Product: Red Hat Enterprise Linux 7 Reporter: Luyao Huang <lhuang>
Component: libvirt-pythonAssignee: Pavel Hrdina <phrdina>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: high Docs Contact:
Priority: high    
Version: 7.1CC: dyuan, honzhang, jiahu, mzhan, phrdina
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-python-1.2.8-5.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1199682 (view as bug list) Environment:
Last Closed: 2015-03-05 07:57:18 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:
Bug Depends On:    
Bug Blocks: 1058757, 1199682, 1200718, 1209839    

Description Luyao Huang 2014-10-22 08:40:39 UTC
Description of problem:
virDomainBlockCopy cannot get a right flag when use libvirt_virDomainBlockCopy
(although cannot use virDomainBlockCopy in 1.2.8,but we can use upstream libvirt-1.2.9 to reproduce this issue or use gdb to reproduce this issue with libvirt-1.2.8-5.el7)

Version-Release number of selected component (if applicable):
libvirt-1.2.8-5.el7
libvirt-python-1.2.8-4.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1.# cat blockcopy.py 

import libvirt
import sys

con = libvirt.open()
domain = con.lookupByName(sys.argv[1])
print   domain.blockCopy("hda","<disk type='file' device='disk'><driver name='qemu' type='raw' cache='none'/><source file='/tmp/test3.img'/></disk>",flags=0)

2.# gdb python
(gdb) br virDomainBlockCopy
Function "virDomainBlockCopy" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y

Breakpoint 1 (virDomainBlockCopy) pending.
(gdb) r blockcopy.py test3

Breakpoint 1, virDomainBlockCopy (dom=dom@entry=0x7559b0, 
    disk=0x7ffff7eda2fc "hda", 
    destxml=0x7ffff7f8fb04 "<disk type='file' device='disk'><driver name='qemu' type='raw' cache='none'/><source file='/tmp/test3.img'/></disk>", params=0x0, 
    nparams=0, flags=32767) at libvirt.c:20069
(gdb) p flags
$1 = 32767

3.

Actual results:
Although we give flags=0
but flags always be 32767(or another value) this will make this function cannot work well with libvirt-1.2.9 and we will get error like:

unsupported flags (0x7f6c) in function qemuDomainBlockCopy

Expected results:
(gdb) p flags
$1 = 0

Additional info:


When use blockCopy, flags cannot get a right value, because
PyArg_ParseTuple want to get 6 parameters and blockCopy only
pass 5.So flags cannot get a right value:

in /usr/lib64/python2.7/site-packages/libvirt.py +637

 637     def blockCopy(self, disk, destxml, params=None, flags=0):
 638         """Copy the guest-visible contents of a disk image to a new file described by destxml """
 639         ret = libvirtmod.virDomainBlockCopy(self._o, disk, destxml, params, flags)
 640         if ret == -1: raise libvirtError ('virDomainBlockCopy() failed', dom=self)
 641         return ret
 642 


in /usr/src/debug/libvirt-python-1.2.8/libvirt-override.c +8111

8111     if (!PyArg_ParseTuple(args, (char *) "Ozz|Oi:virDomainBlockCopy",
8112                           &pyobj_dom, &disk, &destxml, &pyobj_dict, &params     ,
8113                           &flags))
8114         return VIR_PY_INT_FAIL;


Flags will get a unpredictable value, this will make
this function cannot be used.And error just like:

unsupported flags (0x7f6c) in function qemuDomainBlockCopy

I have send my patch to upstream:

https://www.redhat.com/archives/libvir-list/2014-October/msg00575.html

Comment 1 Pavel Hrdina 2014-10-22 09:41:44 UTC
Upstream commit:

commit a7303a56b5e55c29cb5336c84a89b8347a355770
Author: Pavel Hrdina <phrdina>
Date:   Wed Oct 22 11:10:54 2014 +0200

    flags cannot get right value for blockCopy function
    
    When use blockCopy, flags cannot get a right value, because
    PyArg_ParseTuple want to get 6 parameters and blockCopy only
    pass 5. Flags will get a unpredictable value, this will make
    the function fail with error:
    
    unsupported flags (0x7f6c) in function qemuDomainBlockCopy
    
    Signed-off-by: Luyao Huang <lhuang>

Comment 4 Hu Jianwei 2014-11-13 15:39:33 UTC
I can not reproduce it using below versions.

[root@ibm-x3850x5-06 ~]# rpm -q libvirt libvirt-python
libvirt-1.2.8-6.el7.x86_64
libvirt-python-1.2.8-5.el7.x86_64

[root@ibm-x3850x5-06 ~]# cat blockcopy.py 
import libvirt
import sys

con = libvirt.open()
domain = con.lookupByName(sys.argv[1])
print   domain.blockCopy("hda","<disk type='file' device='disk'><driver name='qemu' type='raw' cache='none'/><source file='/tmp/test3.img'/></disk>",flags=0)
[root@ibm-x3850x5-06 ~]# gdb python
...
Reading symbols from /usr/bin/python2.7...Reading symbols from /usr/lib/debug/usr/bin/python2.7.debug...done.
done.
(gdb) b virDomainBlockCopy
Function "virDomainBlockCopy" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (virDomainBlockCopy) pending.
(gdb) r blockcopy.py r7
...
Breakpoint 1, virDomainBlockCopy (dom=dom@entry=0x701a90, disk=0x7ffff7ee32fc "hda", 
    destxml=0x7ffff7f99b04 "<disk type='file' device='disk'><driver name='qemu' type='raw' cache='none'/><source file='/tmp/test3.img'/></disk>", params=0x0, nparams=0, flags=0) at libvirt.c:20069
(gdb) p flags
$1 = 0
(gdb) quit

So we can get expected results, change to Verified.

Comment 6 errata-xmlrpc 2015-03-05 07:57:18 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-0334.html