On 10/18/19 1:10 PM, Peter Krempa wrote:
Introduce a simpler replacement for virDomainDiskByName when looking up by disk target. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> ---
Reviewed-by: Daniel Henrique Barboza <danielhb413@xxxxxxxxx>
src/conf/domain_conf.c | 16 ++++++++++++++++ src/conf/domain_conf.h | 4 ++++ src/libvirt_private.syms | 1 + 3 files changed, 21 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 8b4e80fa8d..1fffd56a22 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -16931,6 +16931,22 @@ virDomainDiskByName(virDomainDefPtr def, return idx < 0 ? NULL : def->disks[idx]; } + +virDomainDiskDefPtr +virDomainDiskByTarget(virDomainDefPtr def, + const char *dst) +{ + size_t i; + + for (i = 0; i < def->ndisks; i++) { + if (STREQ(def->disks[i]->dst, dst)) + return def->disks[i]; + } + + return NULL; +} + + int virDomainDiskInsert(virDomainDefPtr def, virDomainDiskDefPtr disk) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index ad8e88c2ee..690aa3c84b 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3162,6 +3162,10 @@ int virDomainDiskIndexByName(virDomainDefPtr def, const char *name, virDomainDiskDefPtr virDomainDiskByName(virDomainDefPtr def, const char *name, bool allow_ambiguous); +virDomainDiskDefPtr +virDomainDiskByTarget(virDomainDefPtr def, + const char *dst); + int virDomainDiskInsert(virDomainDefPtr def, virDomainDiskDefPtr disk) G_GNUC_WARN_UNUSED_RESULT; diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index e6d40d1cbe..2379c1ed8b 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -330,6 +330,7 @@ virDomainDiskBackingStoreParse; virDomainDiskBusTypeToString; virDomainDiskByAddress; virDomainDiskByName; +virDomainDiskByTarget; virDomainDiskCacheTypeFromString; virDomainDiskCacheTypeToString; virDomainDiskDefAssignAddress;
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list