Bug 591363 - Unclear prompt is seen when specify a non-existent image file in domain config file
Summary: Unclear prompt is seen when specify a non-existent image file in domain confi...
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt
Version: 6.0
Hardware: All
OS: Linux
Target Milestone: rc
: ---
Assignee: Eric Blake
QA Contact: Virtualization Bugs
Depends On:
TreeView+ depends on / blocked
Reported: 2010-05-12 02:41 UTC by Johnny Liu
Modified: 2010-09-07 06:06 UTC (History)
7 users (show)

Fixed In Version: libvirt-0.8.1-5.el6
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2010-07-02 19:33:28 UTC
Target Upstream Version:

Attachments (Terms of Use)
upstream patch (4.50 KB, patch)
2010-05-17 22:40 UTC, Eric Blake
no flags Details | Diff

Description Johnny Liu 2010-05-12 02:41:33 UTC
Description of problem:
When specify a non-existent image file in domain config file, try to start the domain, the following message is seen:

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

How reproducible:

Steps to Reproduce:
1. Specify a non-existent image file in domain config file
   <disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/demo1.img'/>
      <target dev='hda' bus='ide'/>
      <address type='drive' controller='0' bus='0' unit='0'/>
The image file - '/var/lib/libvirt/images/demo1.img' is not existent in host.
2. Try to start domain
# virsh start demo
Actual results:
# virsh start demo
error: Failed to start domain demo
error: cannot stat (null): Bad address

Expected results:
The prompt should be more clear. It should prompt that it can not find the specified image file.

Additional info:

Comment 2 RHEL Program Management 2010-05-12 03:39:33 UTC
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux major release.  Product Management has requested further
review of this request by Red Hat Engineering, for potential inclusion in a Red
Hat Enterprise Linux Major release.  This request is not yet committed for

Comment 3 Hugh Brock 2010-05-13 19:10:40 UTC
Eric, you're already looking at the error message stuff, so this seems like a good one for you.

Comment 4 Eric Blake 2010-05-13 23:10:40 UTC
In trying to reproduce this, I get slightly different behavior on Fedora 13:
# virsh start demo
error: Failed to start domain demo
error: cannot open file '/var/lib/libvirt/images/demo.img': No such file or directory
# virsh --version

So I need to repeat this on RHEL6 with virsh 0.8.1, but this does look like a regression.  The fact that we complain about stat(NULL) failing points is a good clue what might have happened - the earlier ENOENT error detected by 0.7.7 is now being replaced by an EFAULT on an error path that should have been skipped.

Comment 5 Daniel Berrangé 2010-05-14 09:30:37 UTC
I think this is a bug in virFileResolveLink(const char *linkpath) returning 'errno' instead of '-errno', causing the callers of this function which check < 0 for failure to think it succeeded.

Comment 6 Eric Blake 2010-05-14 20:44:22 UTC
Indeed, that's the problem.  SELinuxRestoreSecurityFileLabel is the only place that prints "cannot stat %s", and newpath is indeed NULL due to the virFileResolveLink return value being confused.  I'm working on a patch now, and auditing all other callers of virFileResolveLink in the process.

Comment 7 Eric Blake 2010-05-14 21:09:54 UTC
Proposed upstream patch:

Comment 8 Eric Blake 2010-05-17 22:40:33 UTC
Created attachment 414678 [details]
upstream patch

Backport of upstream patch; upstream ACK at https://www.redhat.com/archives/libvir-list/2010-May/msg00525.html

Comment 9 Dave Allan 2010-05-19 03:45:29 UTC
libvirt-0.8.1-5.el6 has been built in RHEL-6-candidate with the fix


Comment 11 Johnny Liu 2010-05-24 02:03:11 UTC
Verified this bug with libvirt-0.8.1-6.el6 and PASSED.

# virsh start demo
error: Failed to start domain demo
error: cannot resolve symlink /var/lib/libvirt/images/demo1.img: No such file or directory

Comment 13 releng-rhel@redhat.com 2010-07-02 19:33:28 UTC
Red Hat Enterprise Linux Beta 2 is now available and should resolve
the problem described in this bug report. This report is therefore being closed
with a resolution of CURRENTRELEASE. You may reopen this bug report if the
solution does not work for you.

Comment 14 xhu 2010-09-07 06:06:50 UTC
Verified this bug with RHEL6 RC build and it passed:

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