From 9d6867198dd7fbc2979638ba7796e1e1439fbeed Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Tue, 23 May 2023 15:32:49 +0200 Subject: [PATCH] qemuMonitorSetBlockIoThrottle: Drop 'diskalias' argument MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Every caller will pass 'qdevid' as it's populated in the data mandatorily with qemu-4.2 and onwards due to mandatory -blockdev use. Thus we can drop compatibility with the old way of matching the disk via alias. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/qemu/qemu_driver.c | 13 +++---------- src/qemu/qemu_hotplug.c | 4 ++-- src/qemu/qemu_monitor.c | 6 ++---- src/qemu/qemu_monitor.h | 1 - src/qemu/qemu_monitor_json.c | 4 +--- src/qemu/qemu_monitor_json.h | 1 - src/qemu/qemu_process.c | 12 +++--------- tests/qemumonitorjsontest.c | 2 +- 8 files changed, 12 insertions(+), 31 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 430b75880b..56f4cd6197 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -14914,8 +14914,6 @@ qemuDomainSetBlockIoTune(virDomainPtr dom, virDomainDef *persistentDef = NULL; virDomainBlockIoTuneInfo info; virDomainBlockIoTuneInfo conf_info; - g_autofree char *drivealias = NULL; - const char *qdevid = NULL; int ret = -1; size_t i; virDomainDiskDef *conf_disk = NULL; @@ -15111,13 +15109,6 @@ qemuDomainSetBlockIoTune(virDomainPtr dom, if (!qemuDomainDiskBlockIoTuneIsSupported(disk)) goto endjob; - if (QEMU_DOMAIN_DISK_PRIVATE(disk)->qomName) { - qdevid = QEMU_DOMAIN_DISK_PRIVATE(disk)->qomName; - } else { - if (!(drivealias = qemuAliasDiskDriveFromDisk(disk))) - goto endjob; - } - cur_info = qemuDomainFindGroupBlockIoTune(def, disk, &info); if (qemuDomainSetBlockIoTuneDefaults(&info, cur_info, @@ -15167,7 +15158,9 @@ qemuDomainSetBlockIoTune(virDomainPtr dom, int rc = 0; qemuDomainObjEnterMonitor(vm); - rc = qemuMonitorSetBlockIoThrottle(priv->mon, drivealias, qdevid, &info); + rc = qemuMonitorSetBlockIoThrottle(priv->mon, + QEMU_DOMAIN_DISK_PRIVATE(disk)->qomName, + &info); qemuDomainObjExitMonitor(vm); if (rc < 0) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 972df572a7..806aecb29d 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -517,7 +517,7 @@ qemuDomainChangeMediaBlockdev(virDomainObj *vm, if (rc == 0 && !virStorageSourceIsEmpty(newsrc) && qemuDiskConfigBlkdeviotuneEnabled(disk)) { - rc = qemuMonitorSetBlockIoThrottle(priv->mon, NULL, + rc = qemuMonitorSetBlockIoThrottle(priv->mon, diskPriv->qomName, &disk->blkdeviotune); } @@ -734,7 +734,7 @@ qemuDomainAttachDiskGeneric(virDomainObj *vm, g_autoptr(GHashTable) blockinfo = NULL; if (qemuDiskConfigBlkdeviotuneEnabled(disk)) { - if (qemuMonitorSetBlockIoThrottle(priv->mon, NULL, diskPriv->qomName, + if (qemuMonitorSetBlockIoThrottle(priv->mon, diskPriv->qomName, &disk->blkdeviotune) < 0) VIR_WARN("failed to set blkdeviotune for '%s' of '%s'", disk->dst, vm->def->name); } diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 5faf64a4ec..73a019e732 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -2973,16 +2973,14 @@ qemuMonitorJobComplete(qemuMonitor *mon, int qemuMonitorSetBlockIoThrottle(qemuMonitor *mon, - const char *drivealias, const char *qomid, virDomainBlockIoTuneInfo *info) { - VIR_DEBUG("drivealias=%s, qomid=%s, info=%p", - NULLSTR(drivealias), NULLSTR(qomid), info); + VIR_DEBUG("qomid=%s, info=%p", NULLSTR(qomid), info); QEMU_CHECK_MONITOR(mon); - return qemuMonitorJSONSetBlockIoThrottle(mon, drivealias, qomid, info); + return qemuMonitorJSONSetBlockIoThrottle(mon, qomid, info); } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 6006a451a3..8f1bfc702a 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1052,7 +1052,6 @@ int qemuMonitorOpenGraphics(qemuMonitor *mon, bool skipauth); int qemuMonitorSetBlockIoThrottle(qemuMonitor *mon, - const char *drivealias, const char *qomid, virDomainBlockIoTuneInfo *info); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 900cb43e74..2ece33a651 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4596,7 +4596,6 @@ qemuMonitorJSONBlockIoThrottleInfo(virJSONValue *io_throttle, #undef GET_THROTTLE_STATS_OPTIONAL int qemuMonitorJSONSetBlockIoThrottle(qemuMonitor *mon, - const char *drivealias, const char *qomid, virDomainBlockIoTuneInfo *info) { @@ -4604,8 +4603,7 @@ int qemuMonitorJSONSetBlockIoThrottle(qemuMonitor *mon, g_autoptr(virJSONValue) result = NULL; if (!(cmd = qemuMonitorJSONMakeCommand("block_set_io_throttle", - "S:device", drivealias, - "S:id", qomid, + "s:id", qomid, "U:bps", info->total_bytes_sec, "U:bps_rd", info->read_bytes_sec, "U:bps_wr", info->write_bytes_sec, diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 3f77ab0ab3..802f6e7b44 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -401,7 +401,6 @@ qemuMonitorJSONOpenGraphics(qemuMonitor *mon, int qemuMonitorJSONSetBlockIoThrottle(qemuMonitor *mon, - const char *drivealias, const char *qomid, virDomainBlockIoTuneInfo *info); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index de18fd7a3d..a4a4a17a9b 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -7307,13 +7307,6 @@ qemuProcessSetupDiskThrottling(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; - - if (!QEMU_DOMAIN_DISK_PRIVATE(disk)->qomName) { - if (!(drivealias = qemuAliasDiskDriveFromDisk(disk))) - goto cleanup; - } /* Setting throttling for empty drives fails */ if (virStorageSourceIsEmpty(disk->src)) @@ -7322,8 +7315,9 @@ qemuProcessSetupDiskThrottling(virDomainObj *vm, if (!qemuDiskConfigBlkdeviotuneEnabled(disk)) continue; - if (qemuMonitorSetBlockIoThrottle(qemuDomainGetMonitor(vm), drivealias, - diskPriv->qomName, &disk->blkdeviotune) < 0) + if (qemuMonitorSetBlockIoThrottle(qemuDomainGetMonitor(vm), + QEMU_DOMAIN_DISK_PRIVATE(disk)->qomName, + &disk->blkdeviotune) < 0) goto cleanup; } diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index ba12aae5b7..7e79b2e757 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -1904,7 +1904,7 @@ testQemuMonitorJSONqemuMonitorJSONSetBlockIoThrottle(const void *opaque) goto cleanup; if (qemuMonitorJSONSetBlockIoThrottle(qemuMonitorTestGetMonitor(test), - NULL, "drive-virtio-disk1", &info) < 0) + "drive-virtio-disk1", &info) < 0) goto cleanup; ret = 0;