]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Properly handle setting of <iotune> for empty cdrom
authorPeter Krempa <pkrempa@redhat.com>
Tue, 5 Jan 2021 11:06:32 +0000 (12:06 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 6 Jan 2021 08:24:48 +0000 (09:24 +0100)
When starting a VM with an empty cdrom which has <iotune> configured the
startup fails as qemu is not happy about setting tuning for an empty
drive:

 error: internal error: unable to execute 'block_set_io_throttle', unexpected error: 'Device has no medium'

Resolve this by skipping the setting of throttling for empty drives and
updating the throttling when new medium is inserted into the drive.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/111
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
src/qemu/qemu_hotplug.c
src/qemu/qemu_process.c

index 9b93f256e8a7e6e51a3508231489703ed1e0930c..57635cd419ab3a5ea35fe9da2f04fe5a6f737095 100644 (file)
@@ -558,6 +558,16 @@ qemuDomainChangeMediaBlockdev(virQEMUDriverPtr driver,
                                                  nodename);
     }
 
+    /* set throttling for the new image */
+    if (rc == 0 &&
+        !virStorageSourceIsEmpty(newsrc) &&
+        qemuDiskConfigBlkdeviotuneEnabled(disk)) {
+        rc = qemuMonitorSetBlockIoThrottle(priv->mon, NULL,
+                                           diskPriv->qomName,
+                                           &disk->blkdeviotune,
+                                           true, true, true);
+    }
+
     if (rc == 0)
         rc = qemuMonitorBlockdevTrayClose(priv->mon, diskPriv->qomName);
 
index e7421b415f688b896ca7c288c2ed8e8e42e38710..414e9327d21e396c99747de5472b7b6bc03c1a41 100644 (file)
@@ -6838,6 +6838,10 @@ qemuProcessSetupDiskThrottlingBlockdev(virQEMUDriverPtr driver,
         if (qemuDiskBusIsSD(disk->bus))
             continue;
 
+        /* Setting throttling for empty drives fails */
+        if (virStorageSourceIsEmpty(disk->src))
+            continue;
+
         if (!qemuDiskConfigBlkdeviotuneEnabled(disk))
             continue;