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   
URL:
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-09-17 14:59:43 UTC Type: ---
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: 498968    
Attachments:
Description Flags
VM_connection_failure traceback
none
VM_cannot_start traceback
none
gdb libvirtd
none
(gdb) backtrace of libvirtd none

Description Martin Banas 2009-09-17 11:33:23 UTC
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):
libvirt-0.7.1-1.fc12.x86_64
virt-viewer-0.2.0-1.fc12.x86_64
virt-manager-0.8.0-3.fc12.noarch

How reproducible:
always

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' />
</interface>
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 11:34:35 UTC
Created attachment 361484 [details]
VM_cannot_start traceback

Comment 2 Martin Banas 2009-09-17 11:35:23 UTC
Kernel version: 2.6.31-14.fc12.x86_64

Comment 3 Mark McLoughlin 2009-09-17 11:56:57 UTC
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 12:27:16 UTC
Created attachment 361487 [details]
gdb libvirtd

Comment 5 Daniel Berrangé 2009-09-17 12:30:58 UTC
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 12:35:54 UTC
Created attachment 361491 [details]
(gdb) backtrace of libvirtd

Comment 7 Mark McLoughlin 2009-09-17 13:12:12 UTC
Looks like it's this:

  http://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=2d6adabd53

+    } 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 14:59:43 UTC
Fixes are building in rawhide now:

* Thu Sep 17 2009 Mark McLoughlin <markmc> - 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!