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 1598119 - "share-rw=on" does not work for luks format image
Summary: "share-rw=on" does not work for luks format image
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: qemu-kvm-rhev
Version: 7.6
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: Hanna Czenczek
QA Contact: Xueqiang Wei
URL:
Whiteboard:
Depends On:
Blocks: 1629701 1649160 1651787
TreeView+ depends on / blocked
 
Reported: 2018-07-04 12:06 UTC by Xueqiang Wei
Modified: 2019-08-22 09:19 UTC (History)
9 users (show)

Fixed In Version: qemu-kvm-rhev-2.12.0-22.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1629701 (view as bug list)
Environment:
Last Closed: 2019-08-22 09:18:46 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2019:2553 0 None None None 2019-08-22 09:19:41 UTC

Description Xueqiang Wei 2018-07-04 12:06:51 UTC
Description of problem:

2 VMs can not boot at the same time with 'share-rw=on' for the same luks format image.



Version-Release number of selected component (if applicable):
Host:
kernel-3.10.0-915.el7.x86_64
qemu-kvm-rhev-2.12.0-6.el7
Guest:
kernel-3.10.0-862.el7.x86_64


How reproducible:
100%


Steps to Reproduce:
1. create luks format disk and install guest
# qemu-img create -f luks --object secret,id=sec0,data=`printf %s "redhat" |base64`,format=base64 -o key-secret=sec0 system.luks 20G
2. boot guest with share-rw=on
/usr/libexec/qemu-kvm \
-cpu host \
-rtc base=localtime,clock=host,driftfix=slew \
-M  pc-i440fx-rhel7.5.0 \
-enable-kvm \
-name rhel7.5 \
-smp 4,cores=2,threads=1,sockets=2 \
-m 4G \
-uuid c944829b-9aa0-46a2-b3d0-493c135da24d \
-boot menu=on \
-object iothread,id=iothread0 \
-object secret,id=sec0,data=`printf %s "redhat" |base64`,format=base64 \
-device virtio-scsi-pci,id=scsi0,addr=0x3,iothread=iothread0 \
-drive format=luks,key-secret=sec0,file=/home/system.luks,id=drive_sysdisk,if=none,werror=stop,rerror=stop \
-device scsi-hd,drive=drive_sysdisk,bootindex=0,share-rw=on \
-device virtio-net-pci,mac=fa:f7:f8:5f:fa:5b,id=idn0VnaA,vectors=4,netdev=id8xJhp7,bus=pci.0,addr=06 \
-netdev tap,id=id8xJhp7,vhost=on \
-monitor stdio \
-usb \
-vnc :0 \

3. boot the guest with share-rw=on again.


Actual results:
after step 2, guest boot up normally.
after step 3, guest can not boot up.
qemu-kvm: -drive format=luks,key-secret=sec0,file=/home/system.luks,id=drive_sysdisk,if=none,werror=stop,rerror=stop: Failed to get "write" lock
Is another process using the image?


Expected results:
two guest can boot up at the same time.


Additional info:

Tested with luks format on RHEL7.5 also hit this issue.
Host:
kernel-3.10.0-862.el7.x86_64
qemu-kvm-rhev-2.10.0-21.el7_5.4
Guest:
kernel-3.10.0-862.el7.x86_64


Tested with raw format, works well.

Comment 2 Fam Zheng 2018-07-10 06:04:41 UTC
luks is a format driver in QEMU. So it has the same restrictions as any other format like qcow2: share-rw DOES NOT allow two VMs to share it.

Comment 3 Daniel Berrangé 2018-07-10 08:53:23 UTC
Re-opening, as there is no reason why sharing could not be made to work. LUKS is a format driver, but all the metadata in the LUKS header region is readonly, at least by default. So it is reasonable to expect to be able to have multiple writers, provided the driver beneath lucks supports it.

In the future, we will allow some live changes to the header regions, such as adding/removing key slots. In such a cases, we would need to require exclusive access during those operations, but that shouldn't block sharing during normal use.

Comment 4 Fam Zheng 2018-07-16 06:29:08 UTC
Dan, does that mean if I use "locking=off" on the "driver beneath luks", it is guaranteed safe to write to the image from two VMs, and no corruption can happen with today's QEMU luks driver? Or is there additional work needed on the driver to handle concurrent writes?

Comment 5 Daniel Berrangé 2018-07-16 09:24:45 UTC
Yes, /at this point in time/ it should be safe to use locking=off on the driver beneath luks.

This will change when we later provide the ability to update keyslots on the fly, but we can worry about that when we get there.

Comment 6 Fam Zheng 2018-08-14 07:41:57 UTC
Upstream work:

https://lists.gnu.org/archive/html/qemu-devel/2018-08/msg02344.html

Comment 7 Fam Zheng 2018-09-17 08:39:48 UTC
Addressed by below commit from QEMU 3.1:

commit 497da8236ab2663a8108858ba7ea59aac21c5fe6
Author: Fam Zheng <famz>
Date:   Tue Aug 14 15:25:51 2018 +0800

    luks: Allow share-rw=on

    Format drivers such as qcow2 don't allow sharing the same image between
    two QEMU instances in order to prevent image corruptions, because of
    metadata cache. LUKS driver don't modify metadata except for when
    creating image, so it is safe to relax the permission. This makes
    share-rw=on property work on virtual devices.

    Suggested-by: Daniel P. Berrangé <berrange>
    Signed-off-by: Fam Zheng <famz>
    Reviewed-by: Daniel P. Berrangé <berrange>
    Signed-off-by: Kevin Wolf <kwolf>

Comment 10 Ademar Reis 2018-12-04 21:40:08 UTC
(In reply to Fam Zheng from comment #7)
> Addressed by below commit from QEMU 3.1:
> 
> commit 497da8236ab2663a8108858ba7ea59aac21c5fe6
> Author: Fam Zheng <famz>
> Date:   Tue Aug 14 15:25:51 2018 +0800
> 
>     luks: Allow share-rw=on
> 
>     Format drivers such as qcow2 don't allow sharing the same image between
>     two QEMU instances in order to prevent image corruptions, because of
>     metadata cache. LUKS driver don't modify metadata except for when
>     creating image, so it is safe to relax the permission. This makes
>     share-rw=on property work on virtual devices.
> 
>     Suggested-by: Daniel P. Berrangé <berrange>
>     Signed-off-by: Fam Zheng <famz>
>     Reviewed-by: Daniel P. Berrangé <berrange>
>     Signed-off-by: Kevin Wolf <kwolf>

Pending backport.

Comment 12 Miroslav Rezanina 2019-02-05 17:08:15 UTC
Fix included in qemu-kvm-rhev-2.12.0-22.el7

Comment 13 Xueqiang Wei 2019-02-12 06:25:23 UTC
According to steps mentioned in Description, tested on qemu-kvm-rhev-2.12.0-22.el7, not hit this issue. So set status to VERIFIED.


Versions:

kernel-3.10.0-991.el7.x86_64
qemu-kvm-rhev-2.12.0-22.el7

Comment 15 errata-xmlrpc 2019-08-22 09:18:46 UTC
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.

https://access.redhat.com/errata/RHSA-2019:2553


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