mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 22:55:23 +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) {
|
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;
|
||||||
|
@ -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))
|
||||||
|
@ -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,
|
||||||
|
@ -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;
|
||||||
|
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user