]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Refuse setting <iotune> for 'SD' disks
authorPeter Krempa <pkrempa@redhat.com>
Thu, 25 May 2023 14:48:24 +0000 (16:48 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 5 Jun 2023 11:20:13 +0000 (13:20 +0200)
Historically this didn't work with any supported qemu version as we
don't set the alias of the device, and thus qemu uses a different alias
resulting in a failure to startup the VM:

  internal error: unable to execute QEMU command 'block_set_io_throttle': Device 'drive-sd-disk0' not found

Refuse setting throttling as this is unlikely to be needed and proper
fix requires using -device instead of -drive if=sd.

Note that this was broken when I moved the setup of throttling as a
command at startup for blockdev integration quite a while ago. Until
then throttling was passed as arguments for -drive.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_driver.c
src/qemu/qemu_validate.c

index 00b58e042424347ded92a8fe496e078a8bcb0910..d3b37486c32d708a6e0e8efb3b1656b3a0869c03 100644 (file)
@@ -14764,11 +14764,12 @@ typedef enum {
 
 
 static bool
-qemuDomainDiskBlockIoTuneIsSupported(virStorageSource *src)
+qemuDomainDiskBlockIoTuneIsSupported(virDomainDiskDef *disk)
 {
-    if (virStorageSourceGetActualType(src) == VIR_STORAGE_TYPE_VHOST_USER) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("a block I/O throttling is not supported for vhostuser disk"));
+    if (virStorageSourceGetActualType(disk->src) == VIR_STORAGE_TYPE_VHOST_USER ||
+        disk->bus == VIR_DOMAIN_DISK_BUS_SD) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       _("block I/O throttling is not supported for disk '%1$s'"), disk->dst);
         return false;
     }
 
@@ -15107,7 +15108,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
         if (!(disk = qemuDomainDiskByName(def, path)))
             goto endjob;
 
-        if (!qemuDomainDiskBlockIoTuneIsSupported(disk->src))
+        if (!qemuDomainDiskBlockIoTuneIsSupported(disk))
             goto endjob;
 
         if (QEMU_DOMAIN_DISK_PRIVATE(disk)->qomName) {
@@ -15193,7 +15194,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
             goto endjob;
         }
 
-        if (!qemuDomainDiskBlockIoTuneIsSupported(conf_disk->src))
+        if (!qemuDomainDiskBlockIoTuneIsSupported(conf_disk))
             goto endjob;
 
         conf_cur_info = qemuDomainFindGroupBlockIoTune(persistentDef, conf_disk, &info);
@@ -15284,7 +15285,7 @@ qemuDomainGetBlockIoTune(virDomainPtr dom,
         if (!(disk = qemuDomainDiskByName(def, path)))
             goto endjob;
 
-        if (!qemuDomainDiskBlockIoTuneIsSupported(disk->src))
+        if (!qemuDomainDiskBlockIoTuneIsSupported(disk))
             goto endjob;
 
         if (QEMU_DOMAIN_DISK_PRIVATE(disk)->qomName) {
@@ -15309,7 +15310,7 @@ qemuDomainGetBlockIoTune(virDomainPtr dom,
             goto endjob;
         }
 
-        if (!qemuDomainDiskBlockIoTuneIsSupported(disk->src))
+        if (!qemuDomainDiskBlockIoTuneIsSupported(disk))
             goto endjob;
 
         reply = disk->blkdeviotune;
index da4b9a3b359e85055a2a7142d8a544491a761136..04d0c9df73de71c5b501bcbf008d5e6cdf470996 100644 (file)
@@ -3094,6 +3094,14 @@ qemuValidateDomainDeviceDefDiskBlkdeviotune(const virDomainDiskDef *disk,
         return -1;
     }
 
+    /* setting throttling for the SD card didn't work, refuse it explicitly */
+    if (disk->bus == VIR_DOMAIN_DISK_BUS_SD &&
+        qemuDiskConfigBlkdeviotuneEnabled(disk)) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("<iotune> is not supported with bus='sd'"));
+        return -1;
+    }
+
     /* checking def here is only for calling from tests */
     if (disk->blkdeviotune.group_name) {
         size_t i;