QemuImgInfo: encrypted has inconsistent value according to format

Bug #1942682 reported by Takashi Kajinami
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oslo.utils
Fix Released
Medium
Takashi Kajinami

Bug Description

When format='human' is used, the ecnrypted attribute can be 'yes' or None. This is because the `qemu-img info` command shows "encrypted: yes" for encrypted images while no line with the encrypted key for non-encrypted images.

``
image: /dev/disk/by-id/scsi-3600140564d2875a88d3462f89d7123d3
file format: luks
virtual size: 0.998 GiB (1071644672 bytes)
disk size: 0 B
encrypted: yes <====(*)
Format specific information:
    ivgen alg: plain64
    hash alg: sha256
    cipher alg: aes-128
    uuid: 001bdcd8-ec3c-4c83-9702-1d3d0267cd71
    cipher mode: xts
    slots:
        [0]:
            ...
    payload offset: 2097152
    master key iters: 113188
```

However when json format is used, the encrypted field of "qemu-img info" shows true or false.

```
{
    "virtual-size": 1071644672,
    "filename": "/dev/disk/by-id/scsi-36001405ed1da8b633ed4b238518a1dfb",
    "format": "luks",
    "actual-size": 0,
    "format-specific": {
        "type": "luks",
        "data": {
            "ivgen-alg": "plain64",
            "hash-alg": "sha256",
            "cipher-alg": "aes-128",
            "uuid": "ab4c427c-b0d7-4ef6-afaf-c9a55a8c079d",
            "cipher-mode": "xts",
            "slots": [
                {
                    ...
                }
    },
    "encrypted": true, <===(*)
    "dirty-flag": false
}
```

Because of this now encrypted attribute can be different ('yes'/None vs true/false) according to the output format used.

description: updated
Changed in oslo.utils:
assignee: nobody → Takashi Kajinami (kajinamit)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to oslo.utils (master)

Fix proposed to branch: master
Review: https://review.opendev.org/c/openstack/oslo.utils/+/807456

Changed in oslo.utils:
status: New → In Progress
description: updated
description: updated
Revision history for this message
Takashi Kajinami (kajinamit) wrote :

This results in a problem in cinder, which asserts the exact value to determine whether the image is encrypted or not.
  https://github.com/openstack/cinder/blob/fff0ee68a8b1b5210038a272e9751405250b6b01/cinder/volume/flows/manager/create_volume.py#L562

Honestly speaking the current format(true/false) looks more proper and we should fix how cinder handles the attribute but changing the value format would not be ideal.

description: updated
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to oslo.utils (master)

Reviewed: https://review.opendev.org/c/openstack/oslo.utils/+/807456
Committed: https://opendev.org/openstack/oslo.utils/commit/2922a3491a5987aa80f0612df44bd60ed22a0225
Submitter: "Zuul (22348)"
Branch: master

commit 2922a3491a5987aa80f0612df44bd60ed22a0225
Author: Takashi Kajinami <email address hidden>
Date: Sat Sep 4 23:03:17 2021 +0900

    QemuImgInfo: Fix inconsistent value format of encrypted

    The qemu-img info command shows the encrpyed field in different formats
    according to the output format. When the default human format is used
    the field can be 'yes' or None while when json format is used the same
    field can be True or False.
    This change ensures the corresponding attribute has the consistent
    format regardless of the output format used.

    Closes-Bug: #1942682
    Change-Id: I949f07582a708114fdfba76f1a05aa3a3e5c4f40

Changed in oslo.utils:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to oslo.utils (stable/xena)

Fix proposed to branch: stable/xena
Review: https://review.opendev.org/c/openstack/oslo.utils/+/814264

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/oslo.utils 4.11.0

This issue was fixed in the openstack/oslo.utils 4.11.0 release.

Changed in oslo.utils:
importance: Undecided → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to oslo.utils (stable/xena)

Reviewed: https://review.opendev.org/c/openstack/oslo.utils/+/814264
Committed: https://opendev.org/openstack/oslo.utils/commit/3e81ba70a617c450b4d7d71a95d323c7af035405
Submitter: "Zuul (22348)"
Branch: stable/xena

commit 3e81ba70a617c450b4d7d71a95d323c7af035405
Author: Takashi Kajinami <email address hidden>
Date: Sat Sep 4 23:03:17 2021 +0900

    QemuImgInfo: Fix inconsistent value format of encrypted

    The qemu-img info command shows the encrpyed field in different formats
    according to the output format. When the default human format is used
    the field can be 'yes' or None while when json format is used the same
    field can be True or False.
    This change ensures the corresponding attribute has the consistent
    format regardless of the output format used.

    Closes-Bug: #1942682
    Change-Id: I949f07582a708114fdfba76f1a05aa3a3e5c4f40
    (cherry picked from commit 2922a3491a5987aa80f0612df44bd60ed22a0225)

tags: added: in-stable-xena
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/oslo.utils 4.10.1

This issue was fixed in the openstack/oslo.utils 4.10.1 release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.