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 912170 - memoryStats fail did not raise libvirtError
Summary: memoryStats fail did not raise libvirtError
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt
Version: 6.4
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Gunannan Ren
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks: 912172 950419 999077 999454 1045196
TreeView+ depends on / blocked
 
Reported: 2013-02-18 02:30 UTC by Wayne Sun
Modified: 2013-12-20 16:18 UTC (History)
11 users (show)

Fixed In Version: libvirt-0.10.2-23.el6
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 912172 (view as bug list)
Environment:
Last Closed: 2013-11-21 08:45:45 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2013:1581 0 normal SHIPPED_LIVE libvirt bug fix and enhancement update 2013-11-21 01:11:35 UTC

Description Wayne Sun 2013-02-18 02:30:36 UTC
Description of problem:
memoryStats fail did not raise libvirtError 

# python
Python 2.7.3 (default, Aug 10 2012, 02:54:27)
[GCC 4.7.1 20120720 (Red Hat 4.7.1-5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import libvirt
>>> con = libvirt.open(None)
>>> dom = con.lookupByName('test')
>>> dom.memoryStats()
libvir: QEMU Driver error : Requested operation is not valid: domain is not running

user will fail to catch exception. 

Version-Release number of selected component (if applicable):
libvirt-0.10.2-18.el6.x86_64 

How reproducible:
always

Steps to Reproduce:
1. as description 
2.
3.
  
Actual results:
memoryStats fail did not raise libvirtError 

Expected results:
memoryStats fail raise libvirtError

>>> dom.memoryStats()
libvir: QEMU Driver error : Requested operation is not valid: domain is not running
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.7/site-packages/libvirt.py", line 1981, in memoryStats
    if ret is None: raise libvirtError ('virDomainMemoryStats() failed', dom=self)
libvirt.libvirtError: Requested operation is not valid: domain is not running

Additional info:

Comment 2 Gunannan Ren 2013-04-18 12:29:14 UTC
commit 4b143ab23173000d1afa258726be0ff38cf2b386
Author: Guannan Ren <gren>
Date:   Thu Mar 21 11:24:49 2013 +0800

    python: fix bindings that don't raise an exception
    
    For example:
     >>> dom.memoryStats()
     libvir: QEMU Driver error : Requested operation is not valid:\
             domain is not running
    
    There are six such python API functions like so.
    The root reason is that generator.py script checks the type of return
    value of a python stub function defined in libvirt-api.xml or
    libvirt-override-api.xml to see whether to add the raise clause or not
    in python wrapper code in libvirt.py.
    
    The type of return value is supposed to be C types.
    For those stub functions which return python non-integer data type like
    string, list, tuple, dictionary, the existing type in functions varies
    from each other which leads problem like this.
    
    Currently, in generator.py, it maintains a buggy whitelist for stub functions
    returning a list type. I think it is easy to forget adding new function name
    in the whitelist.
    
    This patch makes the value of type consistent with C type "char *"
    in libvirt-override-api.xml. For python, any of types could be printed
    as string, so I choose "char *" in this case. And the comment in xml
    could explain it when adding new function definition.
    
          <function name='virNodeGetCPUStats' file='python'>
            ...
     -      <return type='virNodeCPUStats' info='...'/>
     +      <return type='char *' info='...'/>
            ...
          </function>

Comment 8 Gunannan Ren 2013-08-21 08:09:17 UTC
Backport patch
http://post-office.corp.redhat.com/archives/rhvirt-patches/2013-August/msg01196.html

Wayne, please test this backport patch. Don't make any regression is the point.
Thanks.

Comment 9 Wayne Sun 2013-08-21 11:27:08 UTC
(In reply to Gunannan Ren from comment #8)
> Backport patch
> http://post-office.corp.redhat.com/archives/rhvirt-patches/2013-August/
> msg01196.html
> 
> Wayne, please test this backport patch. Don't make any regression is the
> point.
> Thanks.

With test build of those patches:
libvirt-python-0.10.2-22.el6_update.x86_64

steps:
# virsh list --all
 Id    Name                           State
----------------------------------------------------
 5     kvm-rhel6.3-x86_64-qcow2-ide   running
 -     kvm-rhel6.4-x86_64-qcow2-ide   shut off


# python
Python 2.6.6 (r266:84292, May 27 2013, 05:35:12) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import libvirt
>>> con = libvirt.open(None)
>>> dom = con.lookupByName('kvm-rhel6.3-x86_64-qcow2-ide')
>>> dom1 = con.lookupByName('kvm-rhel6.4-x86_64-qcow2-ide')
>>> con.listDomainsID()
[5]
>>> con.listDefinedDomains()
['kvm-rhel6.4-x86_64-qcow2-ide', 'kvm-rhel6.4-x86_64-qcow2-virtio']
>>> con.listAllNetworks(0)
[<libvirt.virNetwork instance at 0x7fa7ec8a3b00>]
>>> dom.info()
[1, 1048576L, 1048576L, 1, 57500000000L]
>>> dom1.info()
[5, 1048576L, 1048576L, 1, 0L]
>>> dom.state(0)
[1, 1]
>>> dom1.state(0)
[5, 2]
>>> dom.controlInfo(0)
[0, 0, 0L]
>>> dom1.controlInfo(0)
libvir: QEMU Driver error : Requested operation is not valid: domain is not running
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.6/site-packages/libvirt.py", line 1850, in controlInfo
    if ret is None: raise libvirtError ('virDomainGetControlInfo() failed', dom=self)
libvirt.libvirtError: Requested operation is not valid: domain is not running
>>> dom.blockInfo('hda', 0)
[6442450944L, 10891264L, 10891264L]
>>> dom1.blockInfo('hda', 0)
[8589934592L, 21835776L, 21835776L]
>>> dom.jobInfo()
[0, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L]
>>> dom1.jobInfo()
libvir: QEMU Driver error : Requested operation is not valid: domain is not running
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.6/site-packages/libvirt.py", line 1892, in jobInfo
    if ret is None: raise libvirtError ('virDomainGetJobInfo() failed', dom=self)
libvirt.libvirtError: Requested operation is not valid: domain is not running
>>> con.getInfo()
['x86_64', 129005, 64, 2593, 1, 1, 64, 1]
>>> con.getCPUStats(0, 0)
{'kernel': 363760000000L, 'idle': 626675970000000L, 'user': 296640000000L, 'iowait': 10330000000L}
>>> con.getMemoryStats(0, 0)
{'total': 16742060L, 'free': 15402520L}
>>> dom.blockStats('hda')
(42717L, 89180672L, 523L, 5452800L, -1L)
>>> dom1.blockStats('hda')
libvir: QEMU Driver error : Requested operation is not valid: domain is not running
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.6/site-packages/libvirt.py", line 1838, in blockStats
    if ret is None: raise libvirtError ('virDomainBlockStats() failed', dom=self)
libvirt.libvirtError: Requested operation is not valid: domain is not running
>>> dom.blockStatsFlags('hda', 0)
{'wr_total_times': 2832686901L, 'rd_operations': 42717L, 'flush_total_times': 196750944L, 'rd_total_times': 34928412833L, 'rd_bytes': 89180672L, 'flush_operations': 40L, 'wr_operations': 528L, 'wr_bytes': 5473280L}
>>> dom1.blockStatsFlags('hda', 0)
libvir: QEMU Driver error : Requested operation is not valid: domain is not running
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.6/site-packages/libvirt.py", line 1844, in blockStatsFlags
    if ret is None: raise libvirtError ('virDomainBlockStatsFlags() failed', dom=self)
libvirt.libvirtError: Requested operation is not valid: domain is not running
>>> dom.getCPUStats(2, 0)
[{'cpu_time': 63318613072L, 'system_time': 24060000000L, 'user_time': 4730000000L}]
>>> dom1.getCPUStats(2, 0)
libvir: QEMU Driver error : Requested operation is not valid: domain is not running
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.6/site-packages/libvirt.py", line 1868, in getCPUStats
    if ret is None: raise libvirtError ('virDomainGetCPUStats() failed', dom=self)
libvirt.libvirtError: Requested operation is not valid: domain is not running
>>> dom.interfaceStats('vnet0')
(20664L, 366L, 0L, 0L, 4957L, 28L, 0L, 0L)
>>> dom1.interfaceStats('vnet0')
libvir: QEMU Driver error : Requested operation is not valid: domain is not running
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.6/site-packages/libvirt.py", line 1886, in interfaceStats
    if ret is None: raise libvirtError ('virDomainInterfaceStats() failed', dom=self)
libvirt.libvirtError: Requested operation is not valid: domain is not running
>>> dom.memoryStats()
{'actual': 1048576L, 'rss': 339080L}
>>> dom1.memoryStats()
libvir: QEMU Driver error : Requested operation is not valid: domain is not running
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.6/site-packages/libvirt.py", line 1910, in memoryStats
    if ret is None: raise libvirtError ('virDomainMemoryStats() failed', dom=self)
libvirt.libvirtError: Requested operation is not valid: domain is not running
>>> con.getCellsFreeMemory(0, 3)
[15772016640L, 16604061696L, 16311586816L]
>>> dom.schedulerParameters()
{'vcpu_quota': -1L, 'vcpu_period': 100000L, 'emulator_period': 100000L, 'emulator_quota': -1L, 'cpu_shares': 1024L}
>>> dom1.schedulerParameters()
{'vcpu_quota': 0L, 'vcpu_period': 0L, 'emulator_period': 0L, 'emulator_quota': 0L, 'cpu_shares': 0L}
>>> dom.schedulerParametersFlags(0)
{'vcpu_quota': -1L, 'vcpu_period': 100000L, 'emulator_period': 100000L, 'emulator_quota': -1L, 'cpu_shares': 1024L}
>>> dom1.schedulerParametersFlags(0)
{'vcpu_quota': 0L, 'vcpu_period': 0L, 'emulator_period': 0L, 'emulator_quota': 0L, 'cpu_shares': 0L}
>>> dom.vcpuPinInfo(0)
[(True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True)]
>>> dom1.vcpuPinInfo(0)
[(True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True)]
>>> dom.blkioParameters(0)
{'device_weight': '', 'weight': 500}
>>> dom1.blkioParameters(0)
{'device_weight': '', 'weight': 0}
>>> dom.memoryParameters(0)
{'swap_hard_limit': 9007199254740991L, 'hard_limit': 1824256L, 'soft_limit': 9007199254740991L}
>>> dom1.memoryParameters(0)
{'swap_hard_limit': 0L, 'hard_limit': 0L, 'soft_limit': 0L}
>>> dom.numaParameters(0)
{'numa_nodeset': '0-7', 'numa_mode': 0}
>>> dom1.numaParameters(0)
{'numa_nodeset': '', 'numa_mode': 0}
>>> dom.interfaceParameters('vnet0', 0)
{'outbound.peak': 0, 'inbound.peak': 0, 'inbound.burst': 0, 'inbound.average': 0, 'outbound.average': 0, 'outbound.burst': 0}
>>> dom1.interfaceParameters('vnet0', 0)
libvir: QEMU Driver error : invalid argument: Can't find device vnet0
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.6/site-packages/libvirt.py", line 1880, in interfaceParameters
    if ret is None: raise libvirtError ('virDomainGetInterfaceParameters() failed', dom=self)
libvirt.libvirtError: invalid argument: Can't find device vnet0
>>> con.listStoragePools()
['default']
>>> con.listDefinedStoragePools()
[]
>>> con.listAllStoragePools(0)
[<libvirt.virStoragePool instance at 0x7f04398437a0>]
>>> poolobj = con.listAllStoragePools(0)[0]
>>> poolobj.listVolumes()
['kvm-rhel5.9-x86_64-qcow2.img', 'kvm-rhel5.9-x86_64-qcow2-ide.xml', 'kvm-rhel6.4-x86_64-qcow2.img', 'kvm-rhel6.3-x86_64-qcow2-ide.xml', 'kvm-rhel6.4-x86_64-qcow2-virtio.xml', 'kvm-rhel6.3-x86_64-qcow2.img', 'kvm-rhel6.4-x86_64-qcow2-ide.xml']
>>> poolobj.info()
[2, 52844687360L, 3851284480L, 48993402880L]
>>> con.numOfDevices(None, 0)
114
>>> con.listAllDevices(0)
[<libvirt.virNodeDevice instance at 0x7f0439843bd8>, ...]
>>> con.listAllDevices(0)[1].listCaps()
['pci']
>>> con.listSecrets()
[]
>>> con.listAllSecrets(0)
[]
>>> con.listNWFilters()
['qemu-announce-self', 'no-ip-spoofing', 'allow-incoming-ipv4', 'allow-dhcp-server', 'no-arp-ip-spoofing', 'no-other-l2-traffic', 'allow-dhcp', 'allow-arp', 'allow-ipv4', 'no-mac-broadcast', 'qemu-announce-self-rarp', 'no-ip-multicast', 'clean-traffic', 'no-arp-mac-spoofing', 'no-other-rarp-traffic', 'no-arp-spoofing', 'no-mac-spoofing']
>>> con.listAllNWFilters(0)
[<libvirt.virNWFilter instance at 0x7f0439843bd8>, <libvirt.virNWFilter instance at 0x7f0439851cf8>, <libvirt.virNWFilter instance at 0x7f043985f290>, <libvirt.virNWFilter instance at 0x7f043985f440>, <libvirt.virNWFilter instance at 0x7f04398623b0>, <libvirt.virNWFilter instance at 0x7f04398622d8>, <libvirt.virNWFilter instance at 0x7f0439862290>, <libvirt.virNWFilter instance at 0x7f0439862cb0>, <libvirt.virNWFilter instance at 0x7f0439862f38>, <libvirt.virNWFilter instance at 0x7f0439862f80>, <libvirt.virNWFilter instance at 0x7f043986b128>, <libvirt.virNWFilter instance at 0x7f043986b170>, <libvirt.virNWFilter instance at 0x7f043986b1b8>, <libvirt.virNWFilter instance at 0x7f043986b200>, <libvirt.virNWFilter instance at 0x7f043986b248>, <libvirt.virNWFilter instance at 0x7f043986b290>, <libvirt.virNWFilter instance at 0x258c830>]
>>> con.listInterfaces()
['eth0', 'eth1', 'eth2', 'eth3', 'eth4', 'eth5', 'lo']
>>> con.listDefinedInterfaces()
[]
>>> dom.listAllSnapshots(0)
[<libvirt.virDomainSnapshot instance at 0x7f043985f290>]
>>> snap = dom.listAllSnapshots(0)[0]
>>> snap.listChildrenNames(0)
[]
>>> dom.snapshotListNames(0)
['1377054946']
>>> snap.listAllChildren(0)
[]
>>> dom.blockIoTune('hda', 0)
libvir: QEMU Driver error : Operation not supported: block_io_throttle field 'total_bytes_sec' missing in qemu's output
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.6/site-packages/libvirt.py", line 1820, in blockIoTune
    if ret is None: raise libvirtError ('virDomainGetBlockIoTune() failed', dom=self)
libvirt.libvirtError: Operation not supported: block_io_throttle field 'total_bytes_sec' missing in qemu's output
>>> dom1.blockIoTune('hda', 0)
{'write_bytes_sec': 0L, 'total_iops_sec': 0L, 'read_iops_sec': 0L, 'read_bytes_sec': 0L, 'write_iops_sec': 0L, 'total_bytes_sec': 0L}
>>> dom1.diskErrors()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: diskErrors() takes exactly 2 arguments (1 given)
>>> dom1.diskErrors(0)
libvir: QEMU Driver error : Requested operation is not valid: domain is not running
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.6/site-packages/libvirt.py", line 1856, in diskErrors
    if ret is None: raise libvirtError ('virDomainGetDiskErrors() failed', dom=self)
libvirt.libvirtError: Requested operation is not valid: domain is not running
>>> dom.diskErrors(0)
{}
>>> con.getMemoryParameters(0)
{'shm_pages_shared': 0L, 'shm_full_scans': 0L, 'shm_pages_to_scan': 100, 'shm_pages_unshared': 0L, 'shm_sleep_millisecs': 20, 'shm_pages_sharing': 0L, 'shm_pages_volatile': 0L}
>>> dom.blockJobInfo('hda', 0)
{}
>>> dom1.blockJobInfo('hda', 0)
libvir: QEMU Driver error : Requested operation is not valid: domain is not running
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.6/site-packages/libvirt.py", line 1826, in blockJobInfo
    if ret is None: raise libvirtError ('virDomainGetBlockJobInfo() failed', dom=self)
libvirt.libvirtError: Requested operation is not valid: domain is not running

As far all affected API works fine.

Comment 11 Jincheng Miao 2013-08-22 12:36:49 UTC
I used qemu-kvm-rhev which support IO throttling. The verification steps like:

# rpm -q libvirt qemu-kvm-rhev
libvirt-0.10.2-23.el6.x86_64
qemu-kvm-rhev-0.12.1.2-2.398.el6.x86_64

# virsh list --all
 Id    Name                           State
----------------------------------------------------
 4     kvm-rhel6.3-x86_64-qcow2-ide   running
 -     kvm-rhel6.4-x86_64-qcow2-ide   shut off

# python
Python 2.6.6 (r266:84292, May 27 2013, 05:35:12) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import libvirt
>>> con = libvirt.open(None)
>>> dom = con.lookupByName('kvm-rhel6.3-x86_64-qcow2-ide')
>>> dom1 = con.lookupByName('kvm-rhel6.4-x86_64-qcow2-ide')
>>> con.listDomainsID()
[4]
>>> con.listDefinedDomains()
['kvm-rhel6.4-x86_64-qcow2-ide']
>>> con.listAllNetworks(0)
[<libvirt.virNetwork instance at 0x7fef4c178878>]
>>> dom.info()
[1, 1048576L, 1048576L, 1, 53150000000L]
>>> dom1.info()
[5, 1048576L, 1048576L, 1, 0L]
>>> dom.state(0)
[1, 1]
>>> dom1.state(0)
[5, 2]
>>> dom.controlInfo(0)
[0, 0, 0L]
>>> dom1.controlInfo(0)
libvir: QEMU Driver error : Requested operation is not valid: domain is not running
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "libvirt.py", line 1849, in controlInfo
    if ret is None: raise libvirtError ('virDomainGetControlInfo() failed', dom=self)
libvirt.libvirtError: Requested operation is not valid: domain is not running
>>> dom.blockInfo('hda', 0)
[6442450944L, 349720576L, 349720576L]
>>> dom1.blockInfo('hda', 0)
[8589934592L, 57548800L, 57548800L]
>>> dom.jobInfo()
[0, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L]
>>> dom1.jobInfo()
libvir: QEMU Driver error : Requested operation is not valid: domain is not running
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "libvirt.py", line 1890, in jobInfo
    if ret is None: raise libvirtError ('virDomainGetJobInfo() failed', dom=self)
libvirt.libvirtError: Requested operation is not valid: domain is not running
>>> con.getInfo()
['x86_64', 129005, 64, 2593, 1, 1, 64, 1]
>>> con.getCPUStats(0, 0)
{'kernel': 9920000000L, 'idle': 24330110000000L, 'user': 13060000000L, 'iowait': 9330000000L}
>>> con.getMemoryStats(0, 0)
{'total': 16742060L, 'free': 16025372L}
>>> dom.blockStats('hda')
(43089L, 125233664L, 366L, 4412416L, -1L)
>>> dom1.blockStats('hda')
libvir: QEMU Driver error : Requested operation is not valid: domain is not running
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "libvirt.py", line 1837, in blockStats
    if ret is None: raise libvirtError ('virDomainBlockStats() failed', dom=self)
libvirt.libvirtError: Requested operation is not valid: domain is not running
>>> dom.blockStatsFlags('hda', 0)
{'wr_total_times': 1803472399L, 'rd_operations': 43089L, 'flush_total_times': 16999759L, 'rd_total_times': 56164008228L, 'rd_bytes': 125233664L, 'flush_operations': 16L, 'wr_operations': 377L, 'wr_bytes': 4535296L}
>>> dom1.blockStatsFlags('hda', 0)
libvir: QEMU Driver error : Requested operation is not valid: domain is not running
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "libvirt.py", line 1843, in blockStatsFlags
    if ret is None: raise libvirtError ('virDomainBlockStatsFlags() failed', dom=self)
libvirt.libvirtError: Requested operation is not valid: domain is not running
>>> dom.getCPUStats(2, 0)
[{'cpu_time': 77006099445L, 'system_time': 30330000000L, 'user_time': 4600000000L}]
>>> dom1.getCPUStats(2, 0)
libvir: QEMU Driver error : Requested operation is not valid: domain is not running
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "libvirt.py", line 1866, in getCPUStats
    if ret is None: raise libvirtError ('virDomainGetCPUStats() failed', dom=self)
libvirt.libvirtError: Requested operation is not valid: domain is not running
>>> dom.interfaceStats('vnet0')
(5804L, 84L, 0L, 0L, 4957L, 28L, 0L, 0L)
>>> dom1.interfaceStats('vnet0')
libvir: QEMU Driver error : Requested operation is not valid: domain is not running
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "libvirt.py", line 1884, in interfaceStats
    if ret is None: raise libvirtError ('virDomainInterfaceStats() failed', dom=self)
libvirt.libvirtError: Requested operation is not valid: domain is not running
>>> dom.memoryStats()
{'actual': 1048576L, 'rss': 386004L}
>>> dom1.memoryStats()
libvir: QEMU Driver error : Requested operation is not valid: domain is not running
>>> con.getCellsFreeMemory(0, 3)
[16410423296L, 16350552064L, 16424255488L]
>>> dom.schedulerParameters()
{'vcpu_quota': -1L, 'vcpu_period': 100000L, 'emulator_period': 100000L, 'emulator_quota': -1L, 'cpu_shares': 1024L}
>>> dom1.schedulerParameters()
{'vcpu_quota': 0L, 'vcpu_period': 0L, 'emulator_period': 0L, 'emulator_quota': 0L, 'cpu_shares': 0L}
>>> dom.schedulerParametersFlags(0)
{'vcpu_quota': -1L, 'vcpu_period': 100000L, 'emulator_period': 100000L, 'emulator_quota': -1L, 'cpu_shares': 1024L}
>>> dom1.schedulerParametersFlags(0)
{'vcpu_quota': 0L, 'vcpu_period': 0L, 'emulator_period': 0L, 'emulator_quota': 0L, 'cpu_shares': 0L}
>>> dom.vcpuPinInfo(0)
[(True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True)]
>>> dom1.vcpuPinInfo(0)
[(True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True)]
>>> dom.blkioParameters(0)
{'device_weight': '', 'weight': 500}
>>> dom1.blkioParameters(0)
{'device_weight': '', 'weight': 0}
>>> dom.memoryParameters(0)
{'swap_hard_limit': 9007199254740991L, 'hard_limit': 1824256L, 'soft_limit': 9007199254740991L}
>>> dom1.memoryParameters(0)
{'swap_hard_limit': 0L, 'hard_limit': 0L, 'soft_limit': 0L}
>>> dom.numaParameters(0)
{'numa_nodeset': '0-7', 'numa_mode': 0}
>>> dom1.numaParameters(0)
{'numa_nodeset': '', 'numa_mode': 0}
>>> dom.interfaceParameters('vnet0', 0)
{'outbound.peak': 0, 'inbound.peak': 0, 'inbound.burst': 0, 'inbound.average': 0, 'outbound.average': 0, 'outbound.burst': 0}
>>> dom1.interfaceParameters('vnet0', 0)
libvir: QEMU Driver error : invalid argument: Can't find device vnet0
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "libvirt.py", line 1878, in interfaceParameters
    if ret is None: raise libvirtError ('virDomainGetInterfaceParameters() failed', dom=self)
libvirt.libvirtError: invalid argument: Can't find device vnet0
>>> con.listStoragePools()
['default']
>>> con.listDefinedStoragePools()
[]
>>> con.listAllStoragePools(0)
[<libvirt.virStoragePool instance at 0x7fef4c178b00>]
>>> poolobj = con.listAllStoragePools(0)[0]
>>> poolobj.listVolumes()
['kvm-rhel7.0-x86_64-qcow2.img', 'kvm-rhel5.9-x86_64-qcow2.img', 'kvm-rhel5.9-x86_64-qcow2-ide.xml', 'kvm-rhel6.4-x86_64-qcow2.img', 'kvm-rhel7.0-x86_64-qcow2-virtio.xml', 'kvm-rhel6.3-x86_64-qcow2-ide.xml', 'kvm-rhel6.4-x86_64-qcow2-virtio.xml', 'kvm-rhel6.3-x86_64-qcow2.img', 'kvm-rhel6.4-x86_64-qcow2-ide.xml']
>>> poolobj.info()
[2, 52844687360L, 4354818048L, 48489869312L]
>>> con.numOfDevices(None, 0)
114
>>> con.listAllDevices(0)
[<libvirt.virNodeDevice instance at 0x7fef4c178c68>, ...]
>>> con.listAllDevices(0)[1].listCaps()
['pci']
>>> con.listSecrets()
[]
>>> con.listAllSecrets(0)
[]
>>> con.listNWFilters()
['qemu-announce-self', 'no-ip-spoofing', 'allow-incoming-ipv4', 'allow-dhcp-server', 'no-arp-ip-spoofing', 'no-other-l2-traffic', 'allow-dhcp', 'allow-arp', 'allow-ipv4', 'no-mac-broadcast', 'qemu-announce-self-rarp', 'no-ip-multicast', 'clean-traffic', 'no-arp-mac-spoofing', 'no-other-rarp-traffic', 'no-arp-spoofing', 'no-mac-spoofing']
>>> con.listAllNWFilters(0)
[<libvirt.virNWFilter instance at 0x7fef4c178cf8>, <libvirt.virNWFilter instance at 0x7fef4c178d40>, <libvirt.virNWFilter instance at 0x7fef4c178d88>, <libvirt.virNWFilter instance at 0x7fef4c178dd0>, <libvirt.virNWFilter instance at 0x7fef4c178b00>, <libvirt.virNWFilter instance at 0x7fef4c178e18>, <libvirt.virNWFilter instance at 0x7fef4c178e60>, <libvirt.virNWFilter instance at 0x7fef4c178ea8>, <libvirt.virNWFilter instance at 0x7fef4c178ef0>, <libvirt.virNWFilter instance at 0x7fef4c178f38>, <libvirt.virNWFilter instance at 0x7fef4c178f80>, <libvirt.virNWFilter instance at 0x7fef4c178fc8>, <libvirt.virNWFilter instance at 0x7fef4c186cf8>, <libvirt.virNWFilter instance at 0x7fef4c186050>, <libvirt.virNWFilter instance at 0x7fef4c186098>, <libvirt.virNWFilter instance at 0x7fef4c1860e0>, <libvirt.virNWFilter instance at 0x7fef4c186128>]
>>> con.listInterfaces()
['eth0', 'eth1', 'eth2', 'eth3', 'eth4', 'eth5', 'lo']
>>> con.listDefinedInterfaces()
[]
>>> dom.listAllSnapshots(0)
[<libvirt.virDomainSnapshot instance at 0x7fef4c178d40>]
>>> snap = dom.listAllSnapshots(0)[0]
>>> snap.listChildrenNames(0)
[]
>>> dom.snapshotListNames(0)
['1377054946']
>>> snap.listAllChildren(0)
[]
>>> dom.blockIoTune('hda', 0)
{'write_bytes_sec': 0L, 'total_iops_sec': 0L, 'read_iops_sec': 0L, 'read_bytes_sec': 0L, 'write_iops_sec': 0L, 'total_bytes_sec': 0L}
>>> dom1.blockIoTune('hda', 0)
{'write_bytes_sec': 0L, 'total_iops_sec': 0L, 'read_iops_sec': 0L, 'read_bytes_sec': 0L, 'write_iops_sec': 0L, 'total_bytes_sec': 0L}
>>> dom1.diskErrors()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: diskErrors() takes exactly 2 arguments (1 given)
>>> dom1.diskErrors(0)
libvir: QEMU Driver error : Requested operation is not valid: domain is not running
>>> dom.diskErrors(0)
{}
>>> con.getMemoryParameters(0)
{'shm_pages_shared': 0L, 'shm_full_scans': 0L, 'shm_merge_across_nodes': 1, 'shm_pages_to_scan': 100, 'shm_pages_unshared': 0L, 'shm_sleep_millisecs': 20, 'shm_pages_sharing': 0L, 'shm_pages_volatile': 0L}
>>> dom.blockJobInfo('hda', 0)
>>> dom1.blockJobInfo('hda', 0)
libvir: QEMU Driver error : Requested operation is not valid: domain is not running

It seems work well, so I change the status to VIRIFIED.

Comment 12 Jincheng Miao 2013-08-22 14:43:28 UTC
Sorry, I miss the part:
>>> dom1.memoryStats()
libvir: QEMU Driver error : Requested operation is not valid: domain is not running

It still do not raise an exception.

Comment 13 Jincheng Miao 2013-08-23 04:28:16 UTC
Sorry for my careless, the problem I met is because I import the original libvirt.py which is backed up in local directory. 

Thanks for Wayne and Guannan Ren's help.

The following is verification steps:

# python
Python 2.6.6 (r266:84292, May 27 2013, 05:35:12) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import libvirt
>>> con = libvirt.open(None)
>>> dom = con.lookupByName('kvm-rhel6.3-x86_64-qcow2-ide')
>>> dom1 = con.lookupByName('kvm-rhel6.4-x86_64-qcow2-ide')
>>> con.listDomainsID()
[4]
>>> con.listDefinedDomains()
['kvm-rhel6.4-x86_64-qcow2-ide']
>>> dom.controlInfo(0)
[0, 0, 0L]
>>> dom1.controlInfo(0)
libvir: QEMU Driver error : Requested operation is not valid: domain is not running
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.6/site-packages/libvirt.py", line 1850, in controlInfo
    if ret is None: raise libvirtError ('virDomainGetControlInfo() failed', dom=self)
libvirt.libvirtError: Requested operation is not valid: domain is not running
>>> dom.blockInfo('hda', 0)
[6442450944L, 353783808L, 353783808L]
>>> dom1.blockInfo('hda', 0)
[8589934592L, 57548800L, 57548800L]
>>> dom.jobInfo()
[0, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L]
>>> dom1.jobInfo()
libvir: QEMU Driver error : Requested operation is not valid: domain is not running
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.6/site-packages/libvirt.py", line 1892, in jobInfo
    if ret is None: raise libvirtError ('virDomainGetJobInfo() failed', dom=self)
libvirt.libvirtError: Requested operation is not valid: domain is not running
>>> dom.blockStats('hda')
(43361L, 130492928L, 7441L, 47993856L, -1L)
>>> dom1.blockStats('hda')
libvir: QEMU Driver error : Requested operation is not valid: domain is not running
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.6/site-packages/libvirt.py", line 1838, in blockStats
    if ret is None: raise libvirtError ('virDomainBlockStats() failed', dom=self)
libvirt.libvirtError: Requested operation is not valid: domain is not running
>>> dom.blockStatsFlags('hda', 0)
{'wr_total_times': 6884353152L, 'rd_operations': 43361L, 'flush_total_times': 888655951L, 'rd_total_times': 59911423137L, 'rd_bytes': 130492928L, 'flush_operations': 3080L, 'wr_operations': 7441L, 'wr_bytes': 47993856L}
>>> dom1.blockStatsFlags('hda', 0)
libvir: QEMU Driver error : Requested operation is not valid: domain is not running
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.6/site-packages/libvirt.py", line 1844, in blockStatsFlags
    if ret is None: raise libvirtError ('virDomainBlockStatsFlags() failed', dom=self)
libvirt.libvirtError: Requested operation is not valid: domain is not running
>>> dom.getCPUStats(2, 0)
[{'cpu_time': 866177677834L, 'system_time': 408890000000L, 'user_time': 236890000000L}]
>>> dom1.getCPUStats(2, 0)
libvir: QEMU Driver error : Requested operation is not valid: domain is not running
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.6/site-packages/libvirt.py", line 1868, in getCPUStats
    if ret is None: raise libvirtError ('virDomainGetCPUStats() failed', dom=self)
libvirt.libvirtError: Requested operation is not valid: domain is not running
>>> dom.memoryStats()
{'actual': 1048576L, 'rss': 390820L}
>>> dom1.memoryStats()
libvir: QEMU Driver error : Requested operation is not valid: domain is not running
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.6/site-packages/libvirt.py", line 1910, in memoryStats
    if ret is None: raise libvirtError ('virDomainMemoryStats() failed', dom=self)
libvirt.libvirtError: Requested operation is not valid: domain is not running
>>> dom.blockIoTune('hda', 0)
{'write_bytes_sec': 0L, 'total_iops_sec': 0L, 'read_iops_sec': 0L, 'read_bytes_sec': 0L, 'write_iops_sec': 0L, 'total_bytes_sec': 0L}
>>> dom1.blockIoTune('hda', 0)
{'write_bytes_sec': 0L, 'total_iops_sec': 0L, 'read_iops_sec': 0L, 'read_bytes_sec': 0L, 'write_iops_sec': 0L, 'total_bytes_sec': 0L}
>>> dom.diskErrors(0)
{}
>>> dom1.diskErrors(0)
libvir: QEMU Driver error : Requested operation is not valid: domain is not running
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.6/site-packages/libvirt.py", line 1856, in diskErrors
    if ret is None: raise libvirtError ('virDomainGetDiskErrors() failed', dom=self)
libvirt.libvirtError: Requested operation is not valid: domain is not running
>>> dom.blockJobInfo('hda', 0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.6/site-packages/libvirt.py", line 1826, in blockJobInfo
    if ret is None: raise libvirtError ('virDomainGetBlockJobInfo() failed', dom=self)
libvirt.libvirtError: virDomainGetBlockJobInfo() failed
>>> dom1.blockJobInfo('hda', 0)
libvir: QEMU Driver error : Requested operation is not valid: domain is not running
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.6/site-packages/libvirt.py", line 1826, in blockJobInfo
    if ret is None: raise libvirtError ('virDomainGetBlockJobInfo() failed', dom=self)
libvirt.libvirtError: Requested operation is not valid: domain is not running

As we seen, for the shutoff domain, each libvirt python API will raise an exception. So I change the status to VERIFIED

Comment 15 errata-xmlrpc 2013-11-21 08:45:45 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.

http://rhn.redhat.com/errata/RHBA-2013-1581.html


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