Bug 489646 - Segfault in libvirt
Segfault in libvirt
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: libvirt (Show other bugs)
10
All Linux
low Severity high
: ---
: ---
Assigned To: Daniel Veillard
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2009-03-11 01:25 EDT by Evan Klitzke
Modified: 2009-03-11 07:36 EDT (History)
6 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-03-11 07:36:31 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Evan Klitzke 2009-03-11 01:25:11 EDT
I get a segfault when trying to lookupByName for a domain that doesn't exist. This is possibly more appropriate for upstream, but my understanding is that Red Hat is pretty involved in the development of libvirt, so I'm hoping an RH engineer who is involved with that project can take a look:

[evan@gemini ~]$ cat seg.py
import libvirt
c = libvirt.virConnect('system:///qemu')
c.lookupByName('fjdsl')

[evan@gemini ~]$ sudo gdb python
GNU gdb Fedora (6.8-29.fc10)
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu"...
(no debugging symbols found)
Missing separate debuginfos, use: debuginfo-install python-2.5.2-1.fc10.x86_64
(gdb) run seg.py
Starting program: /usr/bin/python seg.py
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[Thread debugging using libthread_db enabled]
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[New Thread 0x7ffff7fdf6f0 (LWP 7925)]
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)

Program received signal SIGSEGV, Segmentation fault.
0x0000003c9dc23d7e in virDomainLookupByName () from /usr/lib64/libvirt.so.0
(gdb) bt
#0  0x0000003c9dc23d7e in virDomainLookupByName () from /usr/lib64/libvirt.so.0
#1  0x0000000000d882e3 in libvirt_virDomainLookupByName () from /usr/lib64/python2.5/site-packages/libvirtmod.so
#2  0x0000003be22bed1c in PyEval_EvalFrameEx () from /usr/lib64/libpython2.5.so.1.0
#3  0x0000003be22bfe6d in PyEval_EvalFrameEx () from /usr/lib64/libpython2.5.so.1.0
#4  0x0000003be22c0865 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.5.so.1.0
#5  0x0000003be22c0aa2 in PyEval_EvalCode () from /usr/lib64/libpython2.5.so.1.0
#6  0x0000003be22dc931 in ?? () from /usr/lib64/libpython2.5.so.1.0
#7  0x0000003be22dca06 in PyRun_FileExFlags () from /usr/lib64/libpython2.5.so.1.0
#8  0x0000003be22ddfed in PyRun_SimpleFileExFlags () from /usr/lib64/libpython2.5.so.1.0
#9  0x0000003be22e7ef1 in Py_Main () from /usr/lib64/libpython2.5.so.1.0
#10 0x000000347901e576 in __libc_start_main () from /lib64/libc.so.6
#11 0x0000000000400649 in _start ()


I'm running the latest libvirt and libvirt-python in FC10:
[evan@gemini ~]$ yum info libvirt libvirt-python
Loaded plugins: changelog, fastestmirror, refresh-packagekit
Installed Packages
Name       : libvirt
Arch       : x86_64
Version    : 0.5.1
Release    : 2.fc10
Size       : 6.1 M
Repo       : installed
Summary    : Library providing a simple API virtualization
URL        : http://libvirt.org/
License    : LGPLv2+
Description: Libvirt is a C toolkit to interact with the virtualization
           : capabilities of recent versions of Linux (and other OSes).

Name       : libvirt-python
Arch       : x86_64
Version    : 0.5.1
Release    : 2.fc10
Size       : 319 k
Repo       : installed
Summary    : Python bindings for the libvirt library
URL        : http://libvirt.org/
License    : LGPLv2+
Description: The libvirt-python package contains a module that permits
           : applications written in the Python programming language to use the
           : interface supplied by the libvirt library to use the virtualization
           : capabilities of recent versions of Linux (and other OSes).
Comment 1 Daniel Berrange 2009-03-11 07:36:31 EDT
There are two problems here:

 - You use the wrong URI when connecting  'system:///qemu' is wrong. It should be 'qemu:///system'. 
 - You use the wrong method to open the connection.  libvirt.virConnect() is an internal lowlevel method. You should in fact be using libvirt.open("qemu:///system")

So your example should be

  import libvirt
  c = libvirt.open('qemu:///system')
  c.lookupByName('fjdsl')


Which gives exception for the missing domain as expected

# python /home/berrange/seg.py
libvir: QEMU error : Domain not found
Traceback (most recent call last):
  File "/home/berrange/seg.py", line 3, in <module>
    c.lookupByName('fjdsl')
  File "/usr/lib/python2.5/site-packages/libvirt.py", line 1090, in lookupByName
    if ret is None:raise libvirtError('virDomainLookupByName() failed', conn=self)
libvirt.libvirtError: Domain not found

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