RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 607598 - Incorrect & misleading error reporting when failing to open a drive due to block driver whitelist denial
Summary: Incorrect & misleading error reporting when failing to open a drive due to bl...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: qemu-kvm
Version: 6.0
Hardware: All
OS: Linux
low
medium
Target Milestone: rc
: 6.1
Assignee: Markus Armbruster
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks: 580953
TreeView+ depends on / blocked
 
Reported: 2010-06-24 13:08 UTC by Daniel Berrangé
Modified: 2013-01-09 22:47 UTC (History)
6 users (show)

Fixed In Version: qemu-kvm-0.12.1.2-2.149.el6
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-05-19 11:31:51 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2011:0534 0 normal SHIPPED_LIVE Important: qemu-kvm security, bug fix, and enhancement update 2011-05-19 11:20:36 UTC

Description Daniel Berrangé 2010-06-24 13:08:07 UTC
Description of problem:
When attempting to launch a KVM instance with a disk using the vvfat protocol, QEMU exits with apparently random error messages reported back

So far I've seen 

qemu: could not open disk image fat:floppy:/home/berrange/src/virt/libvirt-tck/fat: Inappropriate ioctl for device

qemu: could not open disk image fat:floppy:/tmp: No such file or directory

qemu: could not open disk image fat:floppy:/tmp: Invalid argument

This appears to be a flaw in vl.c handling of bdrv_open() return codes. It currently does


         fprintf(stderr, "qemu: could not open disk image %s: %s\n",
                         file, strerror(errno));

However, the bdrv_open() API contract does *not* actually set errno, so this is just reporting the last errno that happened to be set by some other random piece of QEMU code. The actual error is in the bdrv_open() return value.

Something like this appears to be neccessary:

diff --git a/vl.c b/vl.c
index 6d08ec8..4a4c818 100644
--- a/vl.c
+++ b/vl.c
@@ -792,6 +792,7 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque,
     const char *devaddr;
     DriveInfo *dinfo;
     int snapshot = 0;
+    int err;
 
     *fatal_error = 1;
 
@@ -1122,9 +1123,9 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque,
 
     bdrv_flags |= ro ? 0 : BDRV_O_RDWR;
 
-    if (bdrv_open(dinfo->bdrv, file, bdrv_flags, drv) < 0) {
+    if ((err = bdrv_open(dinfo->bdrv, file, bdrv_flags, drv)) < 0) {
         fprintf(stderr, "qemu: could not open disk image %s: %s\n",
-                        file, strerror(errno));
+                        file, strerror(-err));
         return NULL;
     }
 

There is still a problem with this though. When bdrv_open() fails to open a disk due to its protocol/format not being in the whitelist, it set  ret=-ENOENT.

The ENOENT error code is a very commonly seen error in user configuration errors due to typos in disk paths. Thus it is rather mis-leading as a way of reporting a block driver is not allowed by the whitelist.

Ideally this will all use qerror() eventually, but in the meantime, it would be more helpful to use a different errno for this case


diff --git a/block.c b/block.c
index 39724c1..36b7e3f 100644
--- a/block.c
+++ b/block.c
@@ -565,7 +565,7 @@ int bdrv_open(BlockDriverState *bs, const char *filename, int flags,
     }
 
     if (!drv) {
-        ret = -ENOENT;
+        ret = -ENOSYS;
         goto unlink_and_fail;
     }
 


This makes it report:

qemu: could not open disk image fat:floppy:/tmp: Function not implemented


which gives a better indication that the fat capability has been disabled by the whitelist.

Version-Release number of selected component (if applicable):
qemu-kvm-0.12.1.2-2.78.el6.x86_64

How reproducible:
Sometimes, occassionally the previously set errno matches the currently ENOENT, but often it doesn't.  Regardless ENOENT is a very misleading code.

Steps to Reproduce:
1. qemu -drive file=fat:floppy:/tmp
2.
3.
  
Actual results:
qemu: could not open disk image fat:floppy:/tmp: No such file or directory


Expected results:
qemu: could not open disk image fat:floppy:/tmp: Function not implemented


Additional info:

Comment 2 RHEL Program Management 2010-06-24 13:32:53 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
inclusion.

Comment 5 Markus Armbruster 2011-02-16 18:05:19 UTC
Need to backport two upstream patches:
236f1f6 Fix error message in drive_init
c98ac35 block: Use error codes from lower levels for error message

Comment 10 Shaolong Hu 2011-03-18 14:45:29 UTC
Reproduced on qemu-kvm-0.12.1.2-2.147.el6 as following steps.

Reproduce Procedure:
---------------------
1. boot a guest with: -drive file=fat:floppy:/tmp

Actual results:
----------------
qemu: could not open disk image fat:floppy:/tmp: No such file or directory



Verify this bug on qemu-img-0.12.1.2-2.150.el6 as same steps above.

Actual results:
----------------
qemu: could not open disk image fat:floppy:/tmp: Operation not supported.



Conclusion:
-------------
According to results above, this bug has been resolved.

Comment 11 errata-xmlrpc 2011-05-19 11:31:51 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHSA-2011-0534.html

Comment 12 errata-xmlrpc 2011-05-19 12:46:03 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHSA-2011-0534.html


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