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 1154918 - 2 small issue in libvirt_virDomainGetTime and libvirt_virDomainSetTime
Summary: 2 small issue in libvirt_virDomainGetTime and libvirt_virDomainSetTime
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt-python
Version: 7.1
Hardware: x86_64
OS: Linux
low
low
Target Milestone: rc
: ---
Assignee: Michal Privoznik
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-10-21 03:53 UTC by Luyao Huang
Modified: 2015-11-19 05:33 UTC (History)
3 users (show)

Fixed In Version: libvirt-python-1.2.13-1.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-11-19 05:33:12 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


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

Description Luyao Huang 2014-10-21 03:53:31 UTC
Description of problem:
2 small issue found in  libvirt_virDomainGetTime  and libvirt_virDomainSetTime.
In libvirt_virDomainGetTime ,libvirt return NULL without set exception.
In libvirt_virDomainSetTime , should add a type check for time.

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


How reproducible:
100%

Steps to Reproduce:
1.For libvirt_virDomainGetTime
# ipython
In [1]: import libvirt
In [2]: con = libvirt.open()
In [3]: domain = con.lookupByName('test3')
In [4]: domain.getTime()
libvirt: QEMU Driver error : Requested operation is not valid: domain is not running
---------------------------------------------------------------------------
SystemError                               Traceback (most recent call last)
<ipython-input-4-8783bc50ec3c> in <module>()
----> 1 domain.getTime()

/usr/lib64/python2.7/site-packages/libvirt.pyc in getTime(self, flags)
   2695     def getTime(self, flags=0):
   2696         """Extract information about guest time """
-> 2697         ret = libvirtmod.virDomainGetTime(self._o, flags)
   2698         if ret == -1: raise libvirtError ('virDomainGetTime() failed', dom=self)
   2699         return ret

SystemError: error return without exception set

2.For libvirt_virDomainSetTime

3.# ipython
In [1]: import libvirt
In [2]: con = libvirt.open()
In [3]: domain = con.lookupByName('test3')
In [4]: domain.setTime(12345)
Out[4]: 0

In [5]: domain.getTime()
Out[5]: {'nseconds': 591617000, 'seconds': 11L}

Actual results:
In libvirt_virDomainGetTime ,libvirt return NULL without set exception.
In libvirt_virDomainSetTime , should add a type check for time.

Expected results:
In [19]: domain.getTime(1)
libvirt: QEMU Driver error : unsupported flags (0x1) in function qemuDomainGetTime


TypeError: time must be dict

Additional info:


I write two patch for the issue and send to upstream:

For libvirt_virDomainGetTime:
https://www.redhat.com/archives/libvir-list/2014-October/msg00538.html

For libvirt_virDomainSetTime:
https://www.redhat.com/archives/libvir-list/2014-October/msg00528.html

Comment 1 Michal Privoznik 2014-12-05 07:46:52 UTC
Moving to POST:

commit d8b7aa4b1839237e384e6547eb56f889046793ed
Author:     Luyao Huang <lhuang>
AuthorDate: Mon Oct 20 15:55:00 2014 +0200
Commit:     Pavel Hrdina <phrdina>
CommitDate: Mon Oct 20 17:06:12 2014 +0200

    Improve error output when use getTime with a nonzero flags.
    
    When give a nonzero flags to getTime, c_retval will get -1 and goto
    cleanup. But py_retval still is NULL, so set py_retval =  VIR_PY_NONE.
    This will make the output message more correct.
    
    Signed-off-by: Luyao Huang <lhuang>


commit 3d1d3fd52a60d9ab4159e4f9f8680b92dd7a9866
Author:     Luyao Huang <lhuang>
AuthorDate: Fri Oct 31 10:02:16 2014 +0800
Commit:     Michal Privoznik <mprivozn>
CommitDate: Tue Nov 11 15:58:12 2014 +0100

    Add dict check for setTime and allow pass 'seconds' parameter
    
    When pass None or a empty dictionary to time, it will report
    error. This commit allows a one-element dictionary which contains
    just 'seconds' field, which results in the same as passing 0 for
    'nseconds' field. Moreover, dict is checked for unknown fields.
    
    Signed-off-by: Luyao Huang <lhuang>
    Signed-off-by: Michal Privoznik <mprivozn>

v1.2.10-3-g3d1d3fd

Comment 3 hongming 2015-05-12 08:30:57 UTC
Verify it as follows. The result is expected.Move its status to VERIFIED.


# rpm -q libvirt libvirt-python
libvirt-1.2.15-2.el7.x86_64
libvirt-python-1.2.13-1.el7.x86_64

# python
Python 2.7.5 (default, Feb 11 2014, 07:46:25) 
[GCC 4.8.2 20140120 (Red Hat 4.8.2-13)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import libvirt
>>> con = libvirt.open('')
>>> dom = con.lookupByName('r7a')
>>> dom.getTime()
{'seconds': 1431418041L, 'nseconds': 384722000}
>>> dom.setTime(12345)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.7/site-packages/libvirt.py", line 2769, in setTime
    ret = libvirtmod.virDomainSetTime(self._o, time, flags)
TypeError: time must be a dictionary or None with flags set

>>> dom.setTime(1431418041,384722000)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.7/site-packages/libvirt.py", line 2769, in setTime
    ret = libvirtmod.virDomainSetTime(self._o, time, flags)
TypeError: time must be a dictionary or None with flags set

>>> dom.setTime({'seconds': 384722000, 'nseconds': 0}, 1)
0

>>> dom.getTime(0)
{'seconds': 1431419304L, 'nseconds': 771291000}

>>> dom.getTime()
{'seconds': 1431419308L, 'nseconds': 115300000}

>>> dom.getTime(1)
libvirt: QEMU Driver error : unsupported flags (0x1) in function qemuDomainGetTime

>>> dom.getTime(-1)
libvirt: QEMU Driver error : unsupported flags (0xffffffff) in function qemuDomainGetTime

Comment 4 hongming 2015-05-12 09:24:32 UTC
The result is also passed in libvirt-python-1.2.15-1.el7.x86_64

Comment 6 errata-xmlrpc 2015-11-19 05:33: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://rhn.redhat.com/errata/RHBA-2015-2203.html


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