Bug 523953

Summary: Detaching device through virsh detach-device command fails - libvirtd segfault
Product: [Fedora] Fedora Reporter: Martin Banas <mbanas>
Component: libvirtAssignee: Mark McLoughlin <markmc>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: high    
Version: rawhideCC: berrange, clalance, crobinso, itamar, markmc, mbanas, veillard, virt-maint
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-09-17 10:59:43 EDT Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Bug Depends On:    
Bug Blocks: 498968    
Description Flags
VM_connection_failure traceback
VM_cannot_start traceback
gdb libvirtd
(gdb) backtrace of libvirtd none

Description Martin Banas 2009-09-17 07:33:23 EDT
Created attachment 361483 [details]
VM_connection_failure traceback

Description of problem:
Detaching device through virsh detach-device command fails
error: Failed to detach device from XML-file
error: server closed connection

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. install Fedora 12 by any means
2. install group Virtualization
3. run virt-manager and create new virtual machine
4. install F11-Gold into the virtual machine
5. reboot to the installed system and then shut down.

6. execute virsh edit <your_guest_name> , remove every <interface> blocks in the file, save the file
7. create new xml file:
<interface type='network'>
  <mac address='52:54:00:ab:cd:ef' />
  <source network='default' />
  <model type='virtio' />
8. run the virtual machine through virt-manager. Open the window with your guest.

9. make sure that there is no interface in ifconfig than lo.
10. attach new interface by executing in console:
virsh attach-device <your_guest_name> <name_of_xml_file>
11. detach the interface by running:
virsh detach-device <your_guest_name> <name_of_xml_file>

Actual results:
in console:
error: Failed to detach device from XML-file
error: server closed connection

the viewer of the guest has closed, window "Virtual Machine Manager" is not responding.

running virt-manager again shows message:
see 'VM_connection_failure.png'

[root@hp-xw9400-01 ~]# /etc/init.d/libvirtd status
libvirtd dead but pid file exists

restarting libvirtd service and running virt-manager, virt-manager shows the guest is running. Stopping the guest and then running again shows error message: see 'VM_cannot_start.png'

Expected results:
No errors, root can detach device.

Additional info:
after rebooting the machine user is again able to start the virtual guest
Comment 1 Martin Banas 2009-09-17 07:34:35 EDT
Created attachment 361484 [details]
VM_cannot_start traceback
Comment 2 Martin Banas 2009-09-17 07:35:23 EDT
Kernel version: 2.6.31-14.fc12.x86_64
Comment 3 Mark McLoughlin 2009-09-17 07:56:57 EDT
Does /var/log/messages show that libvirtd segfaulted ?

if so, try this:

  $> service libvirtd stop
  $> yum install -y libvirt-debuginfo
  $> gdb libvirtd
  (gdb) run

and then repeat the procedure and capture a stack trace
Comment 4 Martin Banas 2009-09-17 08:27:16 EDT
Created attachment 361487 [details]
gdb libvirtd
Comment 5 Daniel Berrange 2009-09-17 08:30:58 EDT
You need to type 'backtrace' in the (gdb) prompt when it crashes to get a proper trace. The one you attached is just glibc output which isn't as detailed as what gdb will give us.
Comment 6 Martin Banas 2009-09-17 08:35:54 EDT
Created attachment 361491 [details]
(gdb) backtrace of libvirtd
Comment 7 Mark McLoughlin 2009-09-17 09:12:12 EDT
Looks like it's this:


+    } else {
+        VIR_FREE(vm->def->nets[0]);
+        vm->def->nnets = 0;
+    virDomainNetDefFree(detach);

That should be:

+        VIR_FREE(vm->def->nets);

Fix coming soon
Comment 8 Mark McLoughlin 2009-09-17 10:59:43 EDT
Fixes are building in rawhide now:

* Thu Sep 17 2009 Mark McLoughlin <markmc@redhat.com> - 0.7.1-4
- A couple of hot-unplug memory handling fixes (#523953)

I'll push them upstream too once they're reviewed

Thanks Marthin!