Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 877240 - QMP: improve error message for blockdev-snapshot-sync failure
QMP: improve error message for blockdev-snapshot-sync failure
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: qemu-kvm (Show other bugs)
6.4
Unspecified Unspecified
medium Severity medium
: rc
: ---
Assigned To: Laszlo Ersek
Virtualization Bugs
:
: 876024 (view as bug list)
Depends On: 952873
Blocks:
  Show dependency treegraph
 
Reported: 2012-11-15 21:23 EST by Sibiao Luo
Modified: 2013-11-21 19:38 EST (History)
15 users (show)

See Also:
Fixed In Version: qemu-kvm-0.12.1.2-2.367.el6
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-11-21 19:38:16 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2013:1754 normal SHIPPED_LIVE Important: qemu-kvm-rhev, qemu-kvm-rhev-tools, qemu-img-rhev security and bug fix update 2013-11-21 05:48:24 EST

  None (edit)
Description Sibiao Luo 2012-11-15 21:23:26 EST
Description of problem:
Boot a guest and create a snapshot, then try to create the image with the same filename as the backing file, it will prompts 'Error: Trying to create an image with the same filename as the backing file', but QMP did not give a correctly errno information to OpenFileFailed error.

Version-Release number of selected component (if applicable):
host info:
# uname -r && rpm -q qemu-kvm-rhev
2.6.32-340.el6.x86_64
qemu-kvm-rhev-0.12.1.2-2.334.el6.x86_64
guest info:
# uname -r
2.6.32-340.el6.x86_64

How reproducible:
100%

Steps to Reproduce:
1.boot a guest with the sluo-base as a data disk.
eg:...-drive file=/dev/vg_sluo_live_snapshot/sluo-base,if=none,id=data-scsi-disk,format=qcow2,cache=none,werror=stop,rerror=stop -device virtio-scsi-pci,id=scsi1,addr=0x7 -device scsi-hd,scsi-id=0,lun=0,bus=scsi1.0,drive=data-scsi-disk,id=data-disk
2.create live snapshot to a filename.
{ "execute": "blockdev-snapshot-sync", "arguments": { "device": "data-scsi-disk", "snapshot-file": "/dev/vg_sluo_live_snapshot/sluo-snap1", "format": "qcow2" } }
{"return": {}}
3.create another snapshot with the same filename as the backing file.
- QMP monitor:
{ "execute": "blockdev-snapshot-sync", "arguments": { "device": "data-scsi-disk", "snapshot-file": "/dev/vg_sluo_live_snapshot/sluo-snap1", "format": "qcow2" } }
- HMP monitor:
(qemu) snapshot_blkdev data-scsi-disk /dev/vg_sluo_live_snapshot/sluo-snap1 qcow2

Actual results:
after the step 3,
- QMP monitor:
{ "execute": "blockdev-snapshot-sync", "arguments": { "device": "data-scsi-disk", "snapshot-file": "/dev/vg_sluo_live_snapshot/sluo-snap1", "format": "qcow2" } }
{"error": {"class": "OpenFileFailed", "desc": "Could not open '/dev/vg_sluo_live_snapshot/sluo-snap1': Invalid argument", "data": {"filename": "/dev/vg_sluo_live_snapshot/sluo-snap1", "__com.redhat_error_message": "Invalid argument"}}}
- HMP monitor:
(qemu) snapshot_blkdev data-scsi-disk /dev/vg_sluo_live_snapshot/sluo-snap1 qcow2
Error: Trying to create an image with the same filename as the backing file
Could not open '/dev/vg_sluo_live_snapshot/sluo-snap1': Invalid argument

Expected results:
the errno value to OPenFileFailed's error message should some thing like:
Permission denied.
eg:
{"error": {"class": "OpenFileFailed", "desc": "Could not open '/dev/vg_sluo_live_snapshot/sluo-snap1': Permission denied", "data": {"filename": "/dev/vg_sluo_live_snapshot/sluo-snap1", "__com.redhat_error_message": "Permission denied"}}}

Error: Trying to create an image with the same filename as the backing file
Could not open '/dev/vg_sluo_live_snapshot/sluo-snap1': Permission denied

Additional info:
Comment 2 Sibiao Luo 2012-11-15 21:34:35 EST
(In reply to comment #0)
> Description of problem:
> Boot a guest and create a snapshot, then try to create the image with the
> same filename as the backing file, it will prompts 'Error: Trying to create
> an image with the same filename as the backing file', but QMP did not give a
> correctly errno information to OpenFileFailed error.
> 
> Expected results:
> the errno value to OPenFileFailed's error message should some thing like:
> Permission denied.
> eg:
> {"error": {"class": "OpenFileFailed", "desc": "Could not open
> '/dev/vg_sluo_live_snapshot/sluo-snap1': Permission denied", "data":
> {"filename": "/dev/vg_sluo_live_snapshot/sluo-snap1",
> "__com.redhat_error_message": "Permission denied"}}}
> 
> Error: Trying to create an image with the same filename as the backing file
> Could not open '/dev/vg_sluo_live_snapshot/sluo-snap1': Permission denied
> 
The most important thing to check is the more complete 'desc' key. It's very important that add the errno string (as returned by strerror()) and the errno value to OPenFileFailed's error message. please correct me if any error & thx.

Best Regards.
sluo
Comment 3 Luiz Capitulino 2012-11-20 14:39:35 EST
The problem here is that bdrv_img_create() returns -EINVAL to callers, and qmp_transaction() uses that to build the error message. It prints the correct message on HMP because bdrv_img_create() also calls error_report(), which doesn't work on QMP.

I have a series pending upstream that does the Right Thing to fix this issue, which is to propagate the Error object from bdrv_img_create():

  https://lists.gnu.org/archive/html/qemu-devel/2012-10/msg03509.html

I don't think it's feasible to backport this to 6.4, though.

Jeff, feel free to reassign the bug to me if this works better for you.
Comment 5 Jeff Cody 2012-11-20 14:48:49 EST
(In reply to comment #3)
> Jeff, feel free to reassign the bug to me if this works better for you.

Luiz, since you are already addressing this upstream, I will go ahead and do that.  Thanks.
Comment 6 Luiz Capitulino 2012-11-20 14:54:01 EST
Updated summary and proposing this bz to 6.5, as I don't think we'll have time to fix this for 6.4.
Comment 7 Jeff Cody 2012-11-27 11:13:02 EST
*** Bug 876024 has been marked as a duplicate of this bug. ***
Comment 9 Laszlo Ersek 2013-04-17 12:00:24 EDT
List of patches (top to bottom):

71c7981 block: bdrv_img_create(): add Error ** argument
9b37525 qemu-img: img_create(): pass Error object to bdrv_img_create()
a930091 qemu-img: img_create(): drop unneeded goto and ret variable
43e1704 qmp: qmp_transaction(): pass Error object to bdrv_img_create()
cf8f242 qmp: qmp_drive_mirror(): pass Error object to bdrv_img_create()
d92ada2 block: bdrv_img_create(): drop unused error handling code
Comment 10 Laszlo Ersek 2013-04-18 10:33:04 EDT
These patches depend on error_setg() and error_setg_errno(). I reimplement them for RHEL-6 in the series for bug 952873; setting BZ dependency.
Comment 11 Laszlo Ersek 2013-04-18 14:47:44 EDT
I tested the backport as follows:
(1) edited the spec file to enable RHEV features for the RHEL build too:

diff --git a/redhat/qemu-kvm.spec.template b/redhat/qemu-kvm.spec.template
index b45381d..7b66383 100644
--- a/redhat/qemu-kvm.spec.template
+++ b/redhat/qemu-kvm.spec.template
@@ -414,7 +414,8 @@ cd qemu-kvm-x86_64-build
             --disable-smartcard-nss \
             --enable-usb-redir \
             %{fake_machine_arg} \
-            %{disable_rhev_features_arg}
+            %{disable_rhev_features_arg} \
+            --enable-rhev-features

 echo "config-host.mak contents:"
 echo "==="

(2) After adding another virtio disk to the guest and starting the guest,
executed the following qmp commands over libvirtd:

  virsh qemu-monitor-command --domain fw-seabios63.g-rhel63.e-rhel63 \
      --cmd '{ "execute": "blockdev-snapshot-sync", "arguments": { "device":
             "drive-virtio-disk1", "snapshot-file": "/tmp/sn1.img", "format":
             "qcow2" } }'

  {"return":{},"id":"libvirt-10"}

This created the new image file in /tmp/sn1.img.

  ls -l /tmp/sn1.img

  -rw-r--r--. 1 qemu qemu 262144 Apr 18 20:38 /tmp/sn1.img

Then I repeated the previous QMP monitor command, the response was this
time:

  {
    "id":"libvirt-11",
    "error":{
      "class":"GenericError",
      "desc":"Error: Trying to create an image with the same filename as the backing file",
      "data":{
        "message":"Error: Trying to create an image with the same filename as the backing file"
      }
    }
  }

Finally I tried to create an image in a directory (/var/lib/libvirt/images/)
where qemu-kvm has no write permission:

  virsh qemu-monitor-command --domain fw-seabios63.g-rhel63.e-rhel63 \
      --cmd '{ "execute": "blockdev-snapshot-sync", "arguments": { "device":
             "drive-virtio-disk1", "snapshot-file":
             "/var/lib/libvirt/images/sn1.img", "format": "qcow2" } }'

  {
    "id":"libvirt-12",
    "error":{
      "class":"GenericError",
      "desc":"/var/lib/libvirt/images/sn1.img: error while creating qcow2: Permission denied",
      "data":{
        "message":"/var/lib/libvirt/images/sn1.img: error while creating qcow2: Permission denied"
      }
    }
  }
Comment 18 langfang 2013-06-24 23:08:13 EDT
Reproduce this bug as follow version:
Host :
# uname -r
2.6.32-389.el6.x86_64
# rpm -q qemu-kvm-rhev
qemu-kvm-rhev-0.12.1.2-2.355.el6.x86_64

Guest:
# uname -r
2.6.32-358.el6.x86_64

Steps
1.Boot guest 
/usr/libexec/qemu-kvm -m 2G -smp 2 -cpu Penryn -usbdevice tablet -drive file=/home/RHEL-Server-6.4-64-virtio.qcow2,format=qcow2,if=none,id=drive-virtio-disk0,werror=stop,rerror=stop,cache=none -device virtio-blk-pci,drive=drive-virtio-disk0,id=ide0-0-0 -netdev tap,id=hostnet0,script=/etc/qemu-ifup -device virtio-net-pci,netdev=hostnet0,mac=05:10:20:2f:37:26,bus=pci.0,addr=0x4,id=net0 -boot order=cn,menu=on -uuid `uuidgen` -rtc base=utc,clock=host,driftfix=slew -no-kvm-pit-reinjection -monitor stdio -name rhel6.4 -spice port=5830,disable-ticketing -vga qxl  -qmp tcp:0:5555,server,nowait

2.[root@localhost ~]# telnet 10.66.5.160 5555
Trying 10.66.5.160...
Connected to 10.66.5.160.
Escape character is '^]'.
{"QMP": {"version": {"qemu": {"micro": 1, "minor": 12, "major": 0}, "package": "(qemu-kvm-0.12.1.2)"}, "capabilities": []}}
{"execute":"qmp_capabilities"}
{"return": {}}
{ "execute": "blockdev-snapshot-sync", "arguments": { "device": "drive-virtio-disk0", "snapshot-file": "/home/sn1", "format": "qcow2" } }
{"return": {}}
{ "execute": "blockdev-snapshot-sync", "arguments": { "device": "drive-virtio-disk0", "snapshot-file": "/home/sn1", "format": "qcow2" } }
{"error": {"class": "OpenFileFailed", "desc": "Could not open '/home/sn1': Invalid argument", "data": {"filename": "/home/sn1", "__com.redhat_error_message": "Invalid argument"}}}

Results:
HMP:
(qemu) blockdev-snapshot-sync drive-virtio-disk0 /home/sn1
Error: Trying to create an image with the same filename as the backing file
Could not open '/home/sn1': Invalid argument

QMP:
{ "execute": "blockdev-snapshot-sync", "arguments": { "device": "drive-virtio-disk0", "snapshot-file": "/home/sn1", "format": "qcow2" } }
{"error": {"class": "OpenFileFailed", "desc": "Could not open '/home/sn1': Invalid argument", "data": {"filename": "/home/sn1", "__com.redhat_error_message": "Invalid argument"}}}

QMP not give the detail error info.

Verify this bug as follow version:
Host:
# uname -r 
2.6.32-389.el6.x86_64
# rpm -q qemu-kvm-rhev
qemu-kvm-rhev-0.12.1.2-2.376.el6.x86_64

Guest:
2.6.32-358.el6.x86_64

Steps as same as reproduce

Resutls:

HMP:
(qemu) blockdev-snapshot-sync drive-virtio-disk0 /home/sn1
Error: Trying to create an image with the same filename as the backing file

QMP:
{ "execute": "blockdev-snapshot-sync", "arguments": { "device": "drive-virtio-disk0", "snapshot-file": "/home/sn1", "format": "qcow2" } }
{"error": {"class": "GenericError", "desc": "Error: Trying to create an image with the same filename as the backing file", "data": {"message": "Error: Trying to create an image with the same filename as the backing file"}}}

Addtional info :
1)Also test the senario of the duplicate bug876024
QMP:
{ "execute": "blockdev-snapshot-sync", "arguments": { "device": "drive-virtio-disk0", "snapshot-file": "/lls/ll", "format": "qcow2" } }
{"error": {"class": "GenericError", "desc": "/lls/ll: error while creating qcow2: No such file or directory", "data": {"message": "/lls/ll: error while creating qcow2: No such file or directory"}}}
HMP:
(qemu) blockdev-snapshot-sync drive-virtio-disk0 /tt/ll
Formatting '/tt/ll', fmt=qcow2 size=21474836480 backing_file='/home/sn1' backing_fmt='qcow2' encryption=off cluster_size=65536 
/tt/ll: error while creating qcow2: No such file or directory


According to above test ,this bug fixed.
Comment 24 errata-xmlrpc 2013-11-21 19:38:16 EST
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHSA-2013-1754.html

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