mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 22:25:25 +00:00
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:
parent
7c21e38d38
commit
5bf573f62b
@ -4071,7 +4071,7 @@ libxlDomainUpdateDeviceConfig(virDomainDefPtr vmdef, virDomainDeviceDefPtr dev)
|
||||
switch (dev->type) {
|
||||
case VIR_DOMAIN_DEVICE_DISK:
|
||||
disk = dev->data.disk;
|
||||
if (!(orig = virDomainDiskByName(vmdef, disk->dst, false))) {
|
||||
if (!(orig = virDomainDiskByTarget(vmdef, disk->dst))) {
|
||||
virReportError(VIR_ERR_INVALID_ARG,
|
||||
_("target %s doesn't exist."), disk->dst);
|
||||
goto cleanup;
|
||||
|
@ -599,7 +599,7 @@ qemuBlockJobRewriteConfigDiskSource(virDomainObjPtr vm,
|
||||
if (!vm->newDef)
|
||||
return;
|
||||
|
||||
if (!(persistDisk = virDomainDiskByName(vm->newDef, disk->dst, false)))
|
||||
if (!(persistDisk = virDomainDiskByTarget(vm->newDef, disk->dst)))
|
||||
return;
|
||||
|
||||
if (!virStorageSourceIsSameLocation(disk->src, persistDisk->src))
|
||||
@ -837,7 +837,7 @@ qemuBlockJobGetConfigDisk(virDomainObjPtr vm,
|
||||
|
||||
disksrc = disk->src;
|
||||
|
||||
if (!(ret = virDomainDiskByName(vm->newDef, disk->dst, false)))
|
||||
if (!(ret = virDomainDiskByTarget(vm->newDef, disk->dst)))
|
||||
return NULL;
|
||||
|
||||
cfgsrc = ret->src;
|
||||
@ -882,7 +882,7 @@ qemuBlockJobClearConfigChain(virDomainObjPtr vm,
|
||||
if (!vm->newDef || !disk)
|
||||
return;
|
||||
|
||||
if (!(cfgdisk = virDomainDiskByName(vm->newDef, disk->dst, false)))
|
||||
if (!(cfgdisk = virDomainDiskByTarget(vm->newDef, disk->dst)))
|
||||
return;
|
||||
|
||||
if (!virStorageSourceIsSameLocation(disk->src, cfgdisk->src))
|
||||
|
@ -3198,7 +3198,7 @@ qemuDomainObjPrivateXMLParseBlockjobData(virDomainObjPtr vm,
|
||||
invalidData = true;
|
||||
|
||||
if ((diskdst = virXPathString("string(./disk/@dst)", ctxt)) &&
|
||||
!(disk = virDomainDiskByName(vm->def, diskdst, false)))
|
||||
!(disk = virDomainDiskByTarget(vm->def, diskdst)))
|
||||
invalidData = true;
|
||||
|
||||
if ((mirror = virXPathString("string(./disk/@mirror)", ctxt)) &&
|
||||
@ -3371,7 +3371,7 @@ qemuDomainObjPrivateXMLParseJobNBD(virDomainObjPtr vm,
|
||||
virDomainDiskDefPtr disk;
|
||||
|
||||
if ((dst = virXMLPropString(nodes[i], "dev")) &&
|
||||
(disk = virDomainDiskByName(vm->def, dst, false))) {
|
||||
(disk = virDomainDiskByTarget(vm->def, dst))) {
|
||||
QEMU_DOMAIN_DISK_PRIVATE(disk)->migrating = true;
|
||||
|
||||
if (qemuDomainObjPrivateXMLParseJobNBDSource(nodes[i], ctxt,
|
||||
|
@ -15270,7 +15270,7 @@ qemuDomainSnapshotDiskPrepareOne(virQEMUDriverPtr driver,
|
||||
|
||||
/* modify disk in persistent definition only when the source is the same */
|
||||
if (vm->newDef &&
|
||||
(persistdisk = virDomainDiskByName(vm->newDef, dd->disk->dst, false)) &&
|
||||
(persistdisk = virDomainDiskByTarget(vm->newDef, dd->disk->dst)) &&
|
||||
virStorageSourceIsSameLocation(dd->disk->src, persistdisk->src)) {
|
||||
|
||||
dd->persistdisk = persistdisk;
|
||||
|
@ -318,8 +318,7 @@ qemuMigrationDstPrecreateStorage(virDomainObjPtr vm,
|
||||
VIR_DEBUG("Looking up disk target '%s' (capacity=%llu)",
|
||||
nbd->disks[i].target, nbd->disks[i].capacity);
|
||||
|
||||
if (!(disk = virDomainDiskByName(vm->def, nbd->disks[i].target,
|
||||
false))) {
|
||||
if (!(disk = virDomainDiskByTarget(vm->def, nbd->disks[i].target))) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("unable to find disk by target: %s"),
|
||||
nbd->disks[i].target);
|
||||
|
Loading…
Reference in New Issue
Block a user