Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 1029308

Summary: misleading error message inside the guest when trying to format a read-only disk
Product: Red Hat Enterprise Linux 7 Reporter: Sibiao Luo <sluo>
Component: qemu-kvmAssignee: Fam Zheng <famz>
Status: CLOSED NOTABUG QA Contact: Virtualization Bugs <virt-bugs>
Severity: low Docs Contact:
Priority: low    
Version: 7.0CC: acathrow, chayang, famz, hhuang, juzhang, michen, pbonzini, qzhang, sluo, virt-bugs, virt-maint, xfu
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: 2013-12-23 08:06:22 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Sibiao Luo 2013-11-12 06:39:13 UTC
Description of problem:
Boot guest with a VMDK format disk which specified read-only, and then format it in guest with a wrong authority permitted message.
BTW, if use rhel6.5 guest in rhel7.0 host to test which did not meet such issue.

Version-Release number of selected component (if applicable):
host info:
3.10.0-48.el7.x86_64
qemu-kvm-1.5.3-19.el7.x86_64
guest info:
3.10.0-48.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1.boot guest with a VMDK format disk which specified read-only.
e.g:...-drive file=/home/RHEL-7.0-20131030.1-Server-x86_64.vmdk,if=none,id=drive-data-disk,format=vmdk,cache=none,werror=stop,rerror=stop,readonly=on -device virtio-blk-pci,bus=pci.0,addr=0x7,drive=drive-data-disk,id=data-disk
2.format it in guest.
# mkfs.ext4 /dev/vda

Actual results:
after step 2, the VMDK disk(/dev/vda) has a wrong authority permitted message.
# mkfs.ext4 /dev/vda
mke2fs 1.42.8 (20-Jun-2013)
/dev/vda is apparently in use by the system; will not make a filesystem here!

Expected results:
It should prompt a warning message(Operation not permitted), like:
# mkfs.ext4 /dev/vda
/dev/vda: Operation not permitted while setting up superblock

Additional info:

Comment 1 Sibiao Luo 2013-11-12 06:52:34 UTC
My RHEL-7.0-20131030.1-Server-x86_64.vmdk was installed by VMware-Workstation-9.0.0-812388.x86_64.

# qemu-img info /home/RHEL-7.0-20131030.1-Server-x86_64.vmdk
image: /home/RHEL-7.0-20131030.1-Server-x86_64.vmdk
file format: vmdk
virtual size: 10G (10737418240 bytes)
disk size: 932M
Format specific information:
    cid: 1535971103
    parent cid: 4294967295
    create type: monolithicSparse
    extents:
        [0]:
            virtual size: 10737418240
            filename: /home/RHEL-7.0-20131030.1-Server-x86_64.vmdk
            cluster size: 65536
            format: 

Best Regards,
sluo

Comment 2 Ademar Reis 2013-12-18 10:41:19 UTC
The error message should be the same no matter which image format you use. Can you try formating a qcow2 image attached as read-only as well?

Comment 3 Paolo Bonzini 2013-12-18 12:10:14 UTC
> # mkfs.ext4 /dev/vda
> mke2fs 1.42.8 (20-Jun-2013)
> /dev/vda is apparently in use by the system; will not make a filesystem here!

This typically means that the device is partitioned (so you wanted /dev/vda1) or mounted already somewhere.

Try booting into a new VM where the disk is writable, "dd if=/dev/zero of=/dev/vda bs=10M count=1", then retry this testcase.

Comment 5 Sibiao Luo 2013-12-23 07:07:13 UTC
(In reply to Paolo Bonzini from comment #3)
> > # mkfs.ext4 /dev/vda
> > mke2fs 1.42.8 (20-Jun-2013)
> > /dev/vda is apparently in use by the system; will not make a filesystem here!
> 
> This typically means that the device is partitioned (so you wanted
> /dev/vda1) or mounted already somewhere.
Yes, I also agree with you, as my RHEL-7.0-20131030.1-Server-x86_64.vmdk has file system which install rhel7.0 guest in it.
> Try booting into a new VM where the disk is writable, "dd if=/dev/zero
> of=/dev/vda bs=10M count=1", then retry this testcase.
this have no such issue that prompt operation not permitted. Even there is no need to dd, just create a new qcow2/raw image with the same testing which has not meet such issue.
e.g:...-drive file=/home/my-data-disk.qcow2,if=none,id=drive-data-disk,format=qcow2,cache=none,werror=stop,rerror=stop,readonly=on -device virtio-blk-pci,bus=pci.0,addr=0x7,drive=drive-data-disk,id=data-disk
guest]# mkfs.ext4 /dev/vda
mke2fs 1.42.8 (20-Jun-2013)
/dev/vda: Operation not permitted while setting up superblock

Best Regards,
sluo