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
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.
*** Bug 1595931 has been marked as a duplicate of this bug. ***
After evaluating this issue, there are no plans to address it further or fix it in an upcoming release. Therefore, it is being closed. If plans change such that this issue will be fixed in an upcoming release, then the bug can be reopened.
Support for setting rotation rate is proposed here https://listman.redhat.com/archives/libvir-list/2021-March/msg01438.html
This is now merged upstream commit 8dac0ca1b259c53d09983fe09f935baa18eb416c Author: Daniel P. Berrangé <berrange> Date: Wed Mar 31 10:17:07 2021 +0100 qemu: implement setting of rotation rate for SCSI/IDE disks This is available in QEMU with "ide-hd" and "scsi-hd" device types. It was originally mistakenly added to the "scsi-block" device type too, but later removed. This doesn't affect libvirt since we restrict usage to device=disk. When this property is not set then QEMU's default behaviour is to not report any rotation rate information, which causes most guest OS to assume rotational storage. https://bugzilla.redhat.com/show_bug.cgi?id=1498955 Reviewed-by: Ján Tomko <jtomko> Signed-off-by: Daniel P. Berrangé <berrange> commit feac14fa2e7cc737a0f5920fab531602703d2a13 Author: Daniel P. Berrangé <berrange> Date: Wed Mar 31 10:14:12 2021 +0100 conf: add support for disk "rotation_rate" property This lets the app expose the virtual SCSI or IDE disks as solid state devices by setting a rate of '1', or rotational media by setting a rate between 1025 and 65534. https://bugzilla.redhat.com/show_bug.cgi?id=1498955 Reviewed-by: Ján Tomko <jtomko> Signed-off-by: Daniel P. Berrangé <berrange> This will become part of a future 7.3.0 libvirt release, so will get it automatically upon a rebase.
Tested https://listman.redhat.com/archives/libvir-list/2021-April/msg00000.html
Test on libvirt-7.3.0-1.module+el8.5.0+11004+f4810536.x86_64 qemu-kvm-6.0.0-16.module+el8.5.0+10848+2dccc46d.x86_64 Steps 1. Start VM with ide/sata disk and set the rotation_rate <disk type='file' device='disk'> <driver name='qemu' type='raw'/> <source file='/var/lib/libvirt/images/hda' index='2'/> <backingStore/> <target dev='hda' bus='ide' rotation_rate='5400'/> <alias name='ide0-0-0'/> <address type='drive' controller='0' bus='0' target='0' unit='0'/> </disk> <disk type='file' device='disk'> <driver name='qemu' type='raw'/> <source file='/var/lib/libvirt/images/sdb' index='1'/> <backingStore/> <target dev='sdb' bus='sata' rotation_rate='5500'/> <alias name='sata0-0-1'/> <address type='drive' controller='0' bus='0' target='0' unit='1'/> </disk> 2. Hot-plug scsi disk with rotation_rate 3. Check the rotation_rate inside the VM by `smartctl -i /dev/sdX` All pass
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 (virt:av bug fix and enhancement update), 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/RHBA-2021:4684