]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: add support for disk "rotation_rate" property
authorDaniel P. Berrangé <berrange@redhat.com>
Wed, 31 Mar 2021 09:14:12 +0000 (10:14 +0100)
committerDaniel P. Berrangé <berrange@redhat.com>
Thu, 1 Apr 2021 14:11:38 +0000 (15:11 +0100)
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@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
docs/formatdomain.rst
docs/schemas/domaincommon.rng
src/conf/domain_conf.c
src/conf/domain_conf.h

index 741130bf21c9617f917e49cac6974ba2b3138737..7ba32ea9c1d0eb4dae03a648f7ad126416594d87 100644 (file)
@@ -2372,7 +2372,7 @@ paravirtualized driver is specified via the ``disk`` element.
        <source protocol="tftp" name="url_path">
          <host name="hostname" port="69"/>
        </source>
-       <target dev='hdi' bus='ide' tray='open'/>
+       <target dev='hdi' bus='ide' tray='open' rotation_rate='7200'/>
        <readonly/>
      </disk>
      <disk type='block' device='lun'>
@@ -2385,7 +2385,7 @@ paravirtualized driver is specified via the ``disk`` element.
            <source type='unix' path='/path/to/qemu-pr-helper' mode='client'/>
          </reservations>
        </source>
-       <target dev='sda' bus='scsi'/>
+       <target dev='sda' bus='scsi' rotation_rate='1'/>
        <address type='drive' controller='0' bus='0' target='3' unit='0'/>
      </disk>
      <disk type='block' device='disk'>
@@ -2885,10 +2885,17 @@ paravirtualized driver is specified via the ``disk`` element.
    to "closed". NB, the value of ``tray`` could be updated while the domain is
    running. The optional attribute ``removable`` sets the removable flag for USB
    disks, and its value can be either "on" or "off", defaulting to "off".
+   The optional attribute ``rotation_rate`` sets the rotation rate of the
+   storage for disks on a SCSI, IDE, or SATA bus. Values in the range 1025 to
+   65534 are used to indicate rotational media speed in revolutions per minute.
+   A value of one is used to indicate solid state, or otherwise non-rotational,
+   storage. These values are not required to match the values of the underlying
+   host storage.
    :since:`Since 0.0.3`; ``bus`` attribute :since:`since 0.4.3`; ``tray``
    attribute :since:`since 0.9.11`; "usb" attribute value
    :since:`since after 0.4.4`; "sata" attribute value :since:`since 0.9.7`;
-   "removable" attribute value :since:`since 1.1.3`
+   "removable" attribute value :since:`since 1.1.3`;
+   "rotation_rate" attribute value :since:`since 7.3.0`
 ``iotune``
    The optional ``iotune`` element provides the ability to provide additional
    per-device I/O tuning, with values that can vary for each device (contrast
index f5ced5b7a2f661929e3034a0412b5f05a25e246b..2ff786253956c70084ecbefc92c67e35e0865eb8 100644 (file)
           <ref name="virOnOff"/>
         </attribute>
       </optional>
+      <optional>
+        <attribute name="rotation_rate">
+          <ref name="positiveInteger"/>
+        </attribute>
+      </optional>
     </element>
   </define>
   <define name="geometry">
index d050a519c690edc85c0bbda962a6e8661ef10761..1e72171586ce0371ed545d7a0be199fdae4808f6 100644 (file)
@@ -9319,6 +9319,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
     g_autofree char *vendor = NULL;
     g_autofree char *product = NULL;
     g_autofree char *domain_name = NULL;
+    g_autofree char *rotation_rate = NULL;
 
     if (!(def = virDomainDiskDefNew(xmlopt)))
         return NULL;
@@ -9383,6 +9384,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
             bus = virXMLPropString(cur, "bus");
             tray = virXMLPropString(cur, "tray");
             removable = virXMLPropString(cur, "removable");
+            rotation_rate = virXMLPropString(cur, "rotation_rate");
 
             /* HACK: Work around for compat with Xen
              * driver in previous libvirt releases */
@@ -9615,6 +9617,13 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
         }
     }
 
+    if (rotation_rate &&
+        virStrToLong_ui(rotation_rate, NULL, 10, &def->rotation_rate) < 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("Cannot parse rotation rate '%s'"), rotation_rate);
+        return NULL;
+    }
+
     if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info,
                                     flags | VIR_DOMAIN_DEF_PARSE_ALLOW_BOOT) < 0) {
         return NULL;
@@ -25141,6 +25150,8 @@ virDomainDiskDefFormat(virBufferPtr buf,
         virBufferAsprintf(buf, " removable='%s'",
                           virTristateSwitchTypeToString(def->removable));
     }
+    if (def->rotation_rate)
+        virBufferAsprintf(buf, " rotation_rate='%u'", def->rotation_rate);
     virBufferAddLit(buf, "/>\n");
 
     virDomainDiskDefFormatIotune(buf, def);
index 0b8895bbdf1427ddcf84cbdd04dac74537a87fe4..3da9ba01bf25de2dcd4b506405080342aef575b7 100644 (file)
@@ -539,6 +539,7 @@ struct _virDomainDiskDef {
     char *dst;
     int tray_status; /* enum virDomainDiskTray */
     int removable; /* enum virTristateSwitch */
+    unsigned int rotation_rate;
 
     virStorageSourcePtr mirror;
     int mirrorState; /* enum virDomainDiskMirrorState */