From 7c67afce652f90a8d29166419b07a6dee6bfccfc Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Tue, 18 May 2021 16:00:48 +0200 Subject: [PATCH] Replace virDomainDiskInsertPreAlloced by virDomainDiskInsert MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Pre-extending the disk array size is pointless nowadays since we've switched to memory APIs which don't return failure. Switch all uses of reallocation of the array followed by 'virDomainDiskInsertPreAlloced' with direct virDomainDiskInsert. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko Reviewed-by: Pavel Hrdina --- src/libxl/libxl_driver.c | 4 +--- src/lxc/lxc_driver.c | 6 +----- src/qemu/qemu_hotplug.c | 3 +-- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 75da7d7ff2..6a4378b2f2 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -3042,8 +3042,6 @@ libxlDomainAttachDeviceDiskLive(virDomainObj *vm, virDomainDeviceDef *dev) goto cleanup; } - VIR_REALLOC_N(vm->def->disks, vm->def->ndisks+1); - if (libxlMakeDisk(l_disk, &x_disk) < 0) goto cleanup; @@ -3066,7 +3064,7 @@ libxlDomainAttachDeviceDiskLive(virDomainObj *vm, virDomainDeviceDef *dev) } libxlUpdateDiskDef(l_disk, &x_disk); - virDomainDiskInsertPreAlloced(vm->def, l_disk); + virDomainDiskInsert(vm->def, l_disk); } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 07aeb56b0c..8f2ca19f44 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -3401,10 +3401,6 @@ lxcDomainAttachDeviceDiskLive(virLXCDriver *driver, perms) < 0) goto cleanup; - vm->def->disks = g_renew(virDomainDiskDef *, - vm->def->disks, - vm->def->ndisks + 1); - file = g_strdup_printf("/dev/%s", def->dst); if (lxcDomainAttachDeviceMknod(driver, @@ -3423,7 +3419,7 @@ lxcDomainAttachDeviceDiskLive(virLXCDriver *driver, goto cleanup; } - virDomainDiskInsertPreAlloced(vm->def, def); + virDomainDiskInsert(vm->def, def); ret = 0; diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index a37f3dcc68..d954ddac1f 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -737,7 +737,6 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, if (!(devstr = qemuBuildDiskDeviceStr(vm->def, disk, priv->qemuCaps))) goto cleanup; - VIR_REALLOC_N(vm->def->disks, vm->def->ndisks + 1); if (qemuHotplugAttachManagedPR(driver, vm, disk->src, QEMU_ASYNC_JOB_NONE) < 0) goto cleanup; @@ -784,7 +783,7 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, virDomainAuditDisk(vm, NULL, disk->src, "attach", true); - virDomainDiskInsertPreAlloced(vm->def, disk); + virDomainDiskInsert(vm->def, disk); ret = 0; cleanup: -- 2.47.2