On 10/18/19 1:10 PM, Peter Krempa wrote:
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(a)redhat.com>
---
Reviewed-by: Daniel Henrique Barboza <danielhb413(a)gmail.com>
src/libxl/libxl_driver.c | 2 +-
src/qemu/qemu_blockjob.c | 6 +++---
src/qemu/qemu_domain.c | 4 ++--
src/qemu/qemu_driver.c | 2 +-
src/qemu/qemu_migration.c | 3 +--
5 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 64b21f2073..a08bafe5ce 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -4072,7 +4072,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;
diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
index 3506fa165b..f9b3bdaff4 100644
--- a/src/qemu/qemu_blockjob.c
+++ b/src/qemu/qemu_blockjob.c
@@ -601,7 +601,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))
@@ -839,7 +839,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;
@@ -884,7 +884,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))
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 3deb69cb63..e330d2390c 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -3201,7 +3201,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)) &&
@@ -3374,7 +3374,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,
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index ac5f108537..e50f2277d2 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -15276,7 +15276,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;
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index c65491f9d6..40aa598832 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -319,8 +319,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);