Bug 731133

Summary: Non-existant path to serial console file causes libvirtd to crash
Product: Red Hat Enterprise Linux 6 Reporter: Gurhan Ozen <gozen>
Component: libvirtAssignee: Eric Blake <eblake>
Status: CLOSED CURRENTRELEASE QA Contact: Virtualization Bugs <virt-bugs>
Severity: high Docs Contact:
Priority: high    
Version: 6.0CC: dallan, dyuan, jburke, mzhan, rwu, vbian, ydu
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-09-21 19:51:04 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Gurhan Ozen 2011-08-16 19:00:10 UTC
Description of problem:
When a file redirection to serial console is required with --serial file,path=/file/to/nonexistant/path , libvirtd process crashes. Below are the last lines of log in the libvirtd log file in debug level:

13:00:21.933: debug : qemudStartVMDaemon:3868 : Beginning VM startup process
13:00:21.933: debug : qemudStartVMDaemon:3877 : Preparing host devices
13:00:21.933: debug : qemudStartVMDaemon:3881 : Preparing chr devices
13:00:21.933: error : qemuPrepareChardevDevice:3437 : Unable to pre-create chardev file '/mnt/tests/distribution/virt/install/rh6_x86_64_hvm_guest/logs/console.log': No such file or directory
13:00:21.933: debug : qemuSecurityDACRestoreSecurityAllLabel:426 : Restoring security label on RH6_x86_64_hvm_guest migrated=0
13:00:21.933: info : qemuSecurityDACRestoreSecurityFileLabel:80 : Restoring DAC user and group on '/var/lib/libvirt/images/RH6_x86_64_hvm_guest_aaaa.img'
13:00:21.933: info : qemuSecurityDACSetOwnership:40 : Setting DAC user and group on '/var/lib/libvirt/images/RH6_x86_64_hvm_guest_aaaa.img' to '0:0'
13:00:21.933: info : qemuSecurityDACRestoreSecurityFileLabel:80 : Restoring DAC user and group on '/mnt/tests/distribution/virt/install/rh6_x86_64_hvm_guest/logs/console.log'
13:00:21.933: error : qemuSecurityDACRestoreSecurityFileLabel:84 : cannot resolve symlink /mnt/tests/distribution/virt/install/rh6_x86_64_hvm_guest/logs/console.log: No such file or directory
13:00:21.933: info : qemuSecurityDACRestoreSecurityFileLabel:80 : Restoring DAC user and group on '/var/lib/libvirt/boot/virtinst-vmlinuz.CCG4j9'
13:00:21.934: info : qemuSecurityDACSetOwnership:40 : Setting DAC user and group on '/var/lib/libvirt/boot/virtinst-vmlinuz.CCG4j9' to '0:0'
13:00:21.934: info : qemuSecurityDACRestoreSecurityFileLabel:80 : Restoring DAC user and group on '/var/lib/libvirt/boot/virtinst-initrd.img.orZywG'
13:00:21.934: info : qemuSecurityDACSetOwnership:40 : Setting DAC user and group on '/var/lib/libvirt/boot/virtinst-initrd.img.orZywG' to '0:0'



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

How reproducible:
every time. 

Steps to Reproduce:
1. Try to install a guest with --serial file,path=/non/existing/path.log args.
2.
3.
  
Actual results:


Expected results:


Additional info:

Comment 1 Dave Allan 2011-08-16 19:08:06 UTC
Gurhan, can you attach the guest XML?  Thanks, Dave

Comment 3 Gurhan Ozen 2011-08-16 19:23:48 UTC
Dave, here is the xml:

debug : virDomainCreateXML:1937 : conn=0x7fa4e8000a20, xmlDesc=<domain type='kvm'>
  <name>RH6_x86_64_hvm_guest</name>
  <currentMemory>1048576</currentMemory>
  <memory>1048576</memory>
  <uuid>0cdd3673-8ebb-b653-95ec-64b26439210e</uuid>
  <os>
    <type arch='x86_64'>hvm</type>
    <kernel>/var/lib/libvirt/boot/virtinst-vmlinuz.CCG4j9</kernel>
    <initrd>/var/lib/libvirt/boot/virtinst-initrd.img.orZywG</initrd>
    <cmdline>method=nfs:bigpapi.bos.redhat.com:/vol/engarchive2/redhat/released/RHEL-6/6.0/Client/x86_64/os ks=http://lab2.rhts.eng.bos.redhat.com/cblr/svc/op/ks/system/guest-80-99.rhts.eng.bos.redhat.com</cmdline>
  </os>
  <features>
    <acpi/><apic/><pae/>
  </features>
  <clock offset="utc"/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>destroy</on_reboot>
  <on_crash>destroy</on_crash>
  <vcpu>1</vcpu>
  <devices>
    <emulator>/usr/libexec/qemu-kvm</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='none'/>
      <source file='/var/lib/libvirt/images/RH6_x86_64_hvm_guest_aaaa.img'/>
      <target dev='vda' bus='virtio'/>
    </disk>
    <interface type='bridge'>
      <source bridge='br0'/>
      <mac address='52:54:00:35:cf:ea'/>
      <model type='virtio'/>
    </interface>
    <input type='mouse' bus='ps2'/>
    <graphics type='vnc' port='-1' keymap='en-us'/>
    <serial type='file'>
      <source path='/mnt/tests/distribution/virt/install/rh6_x86_64_hvm_guest/logs/console.log'/>
    </serial>
    <video>
      <model type='cirrus'/>
    </video>
  </devices>
</domain>

And i will try to reproduce this on 6.2 as well.

Comment 4 Gurhan Ozen 2011-08-17 05:27:10 UTC
This works fine with 6.2 (RHEL6.2-20110816.n.1 tree)

Wed, 17 Aug 2011 01:25:27 ERROR    Unable to pre-create chardev file '/mnt/tests/distribution/virt/install/NOPATH/no.log': No such file or directory
Wed, 17 Aug 2011 01:25:27 DEBUG    Traceback (most recent call last):
  File "/usr/sbin/virt-install", line 620, in start_install
    noboot=options.noreboot)
  File "/usr/lib/python2.6/site-packages/virtinst/Guest.py", line 1223, in start_install
    noboot)
  File "/usr/lib/python2.6/site-packages/virtinst/Guest.py", line 1291, in _create_guest
    dom = self.conn.createLinux(start_xml or final_xml, 0)
  File "/usr/lib64/python2.6/site-packages/libvirt.py", line 1966, in createLinux
    if ret is None:raise libvirtError('virDomainCreateLinux() failed', conn=self)
libvirtError: Unable to pre-create chardev file '/mnt/tests/distribution/virt/install/NOPATH/no.log': No such file or directory
Wed, 17 Aug 2011 01:25:27 DEBUG    Domain installation does not appear to have been successful.
If it was, you can restart your domain by running:
  virsh --connect qemu:///system start GuestTwo_ser
otherwise, please restart your installation.
Domain installation does not appear to have been successful.
If it was, you can restart your domain by running:
  virsh --connect qemu:///system start GuestTwo_ser
otherwise, please restart your installation.

# service libvirtd status
libvirtd (pid  3930) is running...

Comment 6 yanbing du 2011-08-18 05:37:29 UTC
I test this bug on rhel6.1 with libvirt-0.8.7-18.el6_1.1.x86_64, and can't reproduce this bug.
Steps:
1. Add console=ttyS0,115200 to guest kernel line.

2. Add the following XML to a domain.
<serial type='file'>
   <source path='/tmp/solog/vm-serial.log'/>
   <target port='1'/>
</serial>

3. Start the domain.
# virsh start demo
error: Failed to start domain demo
error: Unable to pre-create chardev file '/tmp/solog/vm-serial.log': No such file or directory

if directory "/tmp/solog/" exist, and vm-serial.log will be created automatically.

Comment 7 Dave Allan 2011-09-21 19:51:04 UTC
Closing per comment 6