]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Setup disk throttling for SD cards via monitor
authorPeter Krempa <pkrempa@redhat.com>
Fri, 22 Jul 2022 09:29:54 +0000 (11:29 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 11 Aug 2022 13:25:51 +0000 (15:25 +0200)
Set it same way we set throttling for other disks in
qemuProcessSetupDiskThrottling.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_command.c
src/qemu/qemu_process.c

index fbcd5421e6978833cbf556204a5d95abbffe1b67..c5e41ac61931a24e0e12f2679e63ea243da8b676 100644 (file)
@@ -1676,46 +1676,6 @@ qemuBuildDriveSourceStr(virDomainDiskDef *disk,
 }
 
 
-static void
-qemuBuildDiskThrottling(virDomainDiskDef *disk,
-                        virBuffer *buf)
-{
-#define IOTUNE_ADD(_field, _label) \
-    if (disk->blkdeviotune._field) { \
-        virBufferAsprintf(buf, ",throttling." _label "=%llu", \
-                          disk->blkdeviotune._field); \
-    }
-
-    IOTUNE_ADD(total_bytes_sec, "bps-total");
-    IOTUNE_ADD(read_bytes_sec, "bps-read");
-    IOTUNE_ADD(write_bytes_sec, "bps-write");
-    IOTUNE_ADD(total_iops_sec, "iops-total");
-    IOTUNE_ADD(read_iops_sec, "iops-read");
-    IOTUNE_ADD(write_iops_sec, "iops-write");
-
-    IOTUNE_ADD(total_bytes_sec_max, "bps-total-max");
-    IOTUNE_ADD(read_bytes_sec_max, "bps-read-max");
-    IOTUNE_ADD(write_bytes_sec_max, "bps-write-max");
-    IOTUNE_ADD(total_iops_sec_max, "iops-total-max");
-    IOTUNE_ADD(read_iops_sec_max, "iops-read-max");
-    IOTUNE_ADD(write_iops_sec_max, "iops-write-max");
-
-    IOTUNE_ADD(size_iops_sec, "iops-size");
-    if (disk->blkdeviotune.group_name) {
-        virBufferAddLit(buf, ",throttling.group=");
-        virQEMUBuildBufferEscapeComma(buf, disk->blkdeviotune.group_name);
-    }
-
-    IOTUNE_ADD(total_bytes_sec_max_length, "bps-total-max-length");
-    IOTUNE_ADD(read_bytes_sec_max_length, "bps-read-max-length");
-    IOTUNE_ADD(write_bytes_sec_max_length, "bps-write-max-length");
-    IOTUNE_ADD(total_iops_sec_max_length, "iops-total-max-length");
-    IOTUNE_ADD(read_iops_sec_max_length, "iops-read-max-length");
-    IOTUNE_ADD(write_iops_sec_max_length, "iops-write-max-length");
-#undef IOTUNE_ADD
-}
-
-
 static void
 qemuBuildDiskGetErrorPolicy(virDomainDiskDef *disk,
                             const char **wpolicy,
@@ -1790,8 +1750,6 @@ qemuBuildDriveStr(virDomainDiskDef *disk)
         }
     }
 
-    qemuBuildDiskThrottling(disk, &opt);
-
     return virBufferContentAndReset(&opt);
 }
 
index efd87069579c0b3ea9f9b29fb7a8d7ef183a478f..ce4257d671d59744bc4f775e30ce118fecab2c4b 100644 (file)
@@ -7198,7 +7198,7 @@ qemuProcessGenID(virDomainObj *vm,
 
 
 /**
- * qemuProcessSetupDiskThrottlingBlockdev:
+ * qemuProcessSetupDiskThrottling:
  *
  * Sets up disk trottling for -blockdev via block_set_io_throttle monitor
  * command. This hack should be replaced by proper use of the 'throttle'
@@ -7206,8 +7206,8 @@ qemuProcessGenID(virDomainObj *vm,
  * Same hack is done in qemuDomainAttachDiskGeneric.
  */
 static int
-qemuProcessSetupDiskThrottlingBlockdev(virDomainObj *vm,
-                                       virDomainAsyncJob asyncJob)
+qemuProcessSetupDiskThrottling(virDomainObj *vm,
+                               virDomainAsyncJob asyncJob)
 {
     size_t i;
     int ret = -1;
@@ -7220,10 +7220,12 @@ qemuProcessSetupDiskThrottlingBlockdev(virDomainObj *vm,
     for (i = 0; i < vm->def->ndisks; i++) {
         virDomainDiskDef *disk = vm->def->disks[i];
         qemuDomainDiskPrivate *diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
+        g_autofree char *drivealias = NULL;
 
-        /* sd-cards are instantiated via -drive */
-        if (qemuDiskBusIsSD(disk->bus))
-            continue;
+        if (!QEMU_DOMAIN_DISK_PRIVATE(disk)->qomName) {
+            if (!(drivealias = qemuAliasDiskDriveFromDisk(disk)))
+                goto cleanup;
+        }
 
         /* Setting throttling for empty drives fails */
         if (virStorageSourceIsEmpty(disk->src))
@@ -7232,7 +7234,7 @@ qemuProcessSetupDiskThrottlingBlockdev(virDomainObj *vm,
         if (!qemuDiskConfigBlkdeviotuneEnabled(disk))
             continue;
 
-        if (qemuMonitorSetBlockIoThrottle(qemuDomainGetMonitor(vm), NULL,
+        if (qemuMonitorSetBlockIoThrottle(qemuDomainGetMonitor(vm), drivealias,
                                           diskPriv->qomName, &disk->blkdeviotune) < 0)
             goto cleanup;
     }
@@ -7745,7 +7747,7 @@ qemuProcessLaunch(virConnectPtr conn,
     if (qemuProcessSetupBalloon(vm, asyncJob) < 0)
         goto cleanup;
 
-    if (qemuProcessSetupDiskThrottlingBlockdev(vm, asyncJob) < 0)
+    if (qemuProcessSetupDiskThrottling(vm, asyncJob) < 0)
         goto cleanup;
 
     /* Since CPUs were not started yet, the balloon could not return the memory