Replace virDomainDiskInsertPreAlloced by virDomainDiskInsert

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 <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Peter Krempa 2021-05-18 16:00:48 +02:00
parent 3df66f27a6
commit 7c67afce65
3 changed files with 3 additions and 10 deletions

View File

@ -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,

View File

@ -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;

View File

@ -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: