Replace virDomainDiskByName by virDomainDiskByTarget in appropriate cases

In many cases we used virDomainDiskByName to solely look up disk by
target. We have a new helper now so we can replace it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
Peter Krempa 2019-10-14 17:24:20 +02:00
parent 7c21e38d38
commit 5bf573f62b
5 changed files with 8 additions and 9 deletions

View File

@ -4071,7 +4071,7 @@ libxlDomainUpdateDeviceConfig(virDomainDefPtr vmdef, virDomainDeviceDefPtr dev)
switch (dev->type) { switch (dev->type) {
case VIR_DOMAIN_DEVICE_DISK: case VIR_DOMAIN_DEVICE_DISK:
disk = dev->data.disk; disk = dev->data.disk;
if (!(orig = virDomainDiskByName(vmdef, disk->dst, false))) { if (!(orig = virDomainDiskByTarget(vmdef, disk->dst))) {
virReportError(VIR_ERR_INVALID_ARG, virReportError(VIR_ERR_INVALID_ARG,
_("target %s doesn't exist."), disk->dst); _("target %s doesn't exist."), disk->dst);
goto cleanup; goto cleanup;

View File

@ -599,7 +599,7 @@ qemuBlockJobRewriteConfigDiskSource(virDomainObjPtr vm,
if (!vm->newDef) if (!vm->newDef)
return; return;
if (!(persistDisk = virDomainDiskByName(vm->newDef, disk->dst, false))) if (!(persistDisk = virDomainDiskByTarget(vm->newDef, disk->dst)))
return; return;
if (!virStorageSourceIsSameLocation(disk->src, persistDisk->src)) if (!virStorageSourceIsSameLocation(disk->src, persistDisk->src))
@ -837,7 +837,7 @@ qemuBlockJobGetConfigDisk(virDomainObjPtr vm,
disksrc = disk->src; disksrc = disk->src;
if (!(ret = virDomainDiskByName(vm->newDef, disk->dst, false))) if (!(ret = virDomainDiskByTarget(vm->newDef, disk->dst)))
return NULL; return NULL;
cfgsrc = ret->src; cfgsrc = ret->src;
@ -882,7 +882,7 @@ qemuBlockJobClearConfigChain(virDomainObjPtr vm,
if (!vm->newDef || !disk) if (!vm->newDef || !disk)
return; return;
if (!(cfgdisk = virDomainDiskByName(vm->newDef, disk->dst, false))) if (!(cfgdisk = virDomainDiskByTarget(vm->newDef, disk->dst)))
return; return;
if (!virStorageSourceIsSameLocation(disk->src, cfgdisk->src)) if (!virStorageSourceIsSameLocation(disk->src, cfgdisk->src))

View File

@ -3198,7 +3198,7 @@ qemuDomainObjPrivateXMLParseBlockjobData(virDomainObjPtr vm,
invalidData = true; invalidData = true;
if ((diskdst = virXPathString("string(./disk/@dst)", ctxt)) && if ((diskdst = virXPathString("string(./disk/@dst)", ctxt)) &&
!(disk = virDomainDiskByName(vm->def, diskdst, false))) !(disk = virDomainDiskByTarget(vm->def, diskdst)))
invalidData = true; invalidData = true;
if ((mirror = virXPathString("string(./disk/@mirror)", ctxt)) && if ((mirror = virXPathString("string(./disk/@mirror)", ctxt)) &&
@ -3371,7 +3371,7 @@ qemuDomainObjPrivateXMLParseJobNBD(virDomainObjPtr vm,
virDomainDiskDefPtr disk; virDomainDiskDefPtr disk;
if ((dst = virXMLPropString(nodes[i], "dev")) && if ((dst = virXMLPropString(nodes[i], "dev")) &&
(disk = virDomainDiskByName(vm->def, dst, false))) { (disk = virDomainDiskByTarget(vm->def, dst))) {
QEMU_DOMAIN_DISK_PRIVATE(disk)->migrating = true; QEMU_DOMAIN_DISK_PRIVATE(disk)->migrating = true;
if (qemuDomainObjPrivateXMLParseJobNBDSource(nodes[i], ctxt, if (qemuDomainObjPrivateXMLParseJobNBDSource(nodes[i], ctxt,

View File

@ -15270,7 +15270,7 @@ qemuDomainSnapshotDiskPrepareOne(virQEMUDriverPtr driver,
/* modify disk in persistent definition only when the source is the same */ /* modify disk in persistent definition only when the source is the same */
if (vm->newDef && if (vm->newDef &&
(persistdisk = virDomainDiskByName(vm->newDef, dd->disk->dst, false)) && (persistdisk = virDomainDiskByTarget(vm->newDef, dd->disk->dst)) &&
virStorageSourceIsSameLocation(dd->disk->src, persistdisk->src)) { virStorageSourceIsSameLocation(dd->disk->src, persistdisk->src)) {
dd->persistdisk = persistdisk; dd->persistdisk = persistdisk;

View File

@ -318,8 +318,7 @@ qemuMigrationDstPrecreateStorage(virDomainObjPtr vm,
VIR_DEBUG("Looking up disk target '%s' (capacity=%llu)", VIR_DEBUG("Looking up disk target '%s' (capacity=%llu)",
nbd->disks[i].target, nbd->disks[i].capacity); nbd->disks[i].target, nbd->disks[i].capacity);
if (!(disk = virDomainDiskByName(vm->def, nbd->disks[i].target, if (!(disk = virDomainDiskByTarget(vm->def, nbd->disks[i].target))) {
false))) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("unable to find disk by target: %s"), _("unable to find disk by target: %s"),
nbd->disks[i].target); nbd->disks[i].target);