Bug 1498955 - RFE: option to mark virtual block device as rotational/non-rotational
Summary: RFE: option to mark virtual block device as rotational/non-rotational
Keywords:
Status: NEW
Alias: None
Product: Red Hat Enterprise Linux Advanced Virtualization
Classification: Red Hat
Component: libvirt
Version: 8.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: 8.0
Assignee: Pavel Mores
QA Contact: Han Han
URL:
Whiteboard:
Depends On: 1664302 1498042
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-10-05 15:47 UTC by Daniel Berrangé
Modified: 2019-09-05 14:52 UTC (History)
11 users (show)

Fixed In Version:
Doc Type: Enhancement
Doc Text:
Clone Of: 1498042
Environment:
Last Closed:
Type: Feature Request
Target Upstream Version:


Attachments (Terms of Use)

Description Daniel Berrangé 2017-10-05 15:47:01 UTC
Cloning QEMU bug to libvirt to track exposing this in <disk> XML.

+++ This bug was initially created as a clone of Bug #1498042 +++

Description of problem:
In absence of information to the contrary, Linux guests assume that all block devices are backed by rotational storage. The guest OS admin can override this by setting the 'rotational' flag in sysfs.

It would be desirable to be able to inform the guest OS the correct rotational/non-rotational setting based on what is used as the backing for the virtual block device.

In Linux, if a disk is marked non-rotational disk, it is also removed as a source of random entropy, so if a virtual disk is backed by SSD it is desirable that the guest know this so that it doesn't consider it an entropy source.

Both ATA and SCSI protocols have a way to report this feature.

For SCSI the Block Device Characteristics VPD, page 0xb1 provides a flag that Linux checks:

        if (!buffer ||
            /* Block Device Characteristics VPD */
            scsi_get_vpd_page(sdkp->device, 0xb1, buffer, vpd_len))
                goto out;

        rot = get_unaligned_be16(&buffer[4]);

        if (rot == 1) {
                queue_flag_set_unlocked(QUEUE_FLAG_NONROT, q);
                queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, q);
        }


For ATA there is an ID flag with the info that Linux checks

        ATA_ID_ROT_SPEED        = 217,

static inline bool ata_id_is_ssd(const u16 *id)
{
        return id[ATA_ID_ROT_SPEED] == 0x01;
}



virtio-blk has no mechanism for this. One could be added, or just rely on a recommendation use of virtio-scsi instead.

So QEMU would need to have a 'rotational' boolean flag added for its SCSI & ATA disk device backends. Libvirt would in turn expose this setting to mgmt apps, which would set it based on their knowledge of the storage in use.

--- Additional comment from Eric Blake on 2017-10-03 13:02:37 BST ---

NBD also supports the advertisement of rotational or not

--- Additional comment from Daniel Berrange on 2017-10-03 13:05:49 BST ---

(In reply to Eric Blake from comment #3)
> NBD also supports the advertisement of rotational or not

Interestingly/strangely the Linux NBD kernel client ignores this feature, and unconditionally sets the block dev as non-rotational.

--- Additional comment from Daniel Berrange on 2017-10-04 12:52:54 BST ---

Posted some possible patches for IDE/SCSI https://lists.gnu.org/archive/html/qemu-devel/2017-10/msg00698.html

Comment 3 Erik Skultety 2019-01-07 12:49:12 UTC
In order to implement this properly, libvirt needs to be able to QAPI introspect device options. Once we can query for the rotation_rate property, it's fairly simple to expose it as an attribute within the XML.


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