Add the virDomainRNGDefForeach and +virDomainRedirdevDefForeach iterators to traverse all the RNG and Redirdevs just like the Smartcard's and Chr's Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx> --- src/conf/domain_conf.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ src/conf/domain_conf.h | 18 ++++++++++++++++++ src/libvirt_private.syms | 2 ++ 3 files changed, 68 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index de7df5c..30f2d6d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -24559,6 +24559,54 @@ virDomainSmartcardDefForeach(virDomainDefPtr def, int +virDomainRNGDefForeach(virDomainDefPtr def, + bool abortOnError, + virDomainRNGDefIterator iter, + void *opaque) +{ + size_t i; + int rc = 0; + + for (i = 0; i < def->nrngs; i++) { + if ((iter)(def, + def->rngs[i], + opaque) < 0) + rc = -1; + + if (abortOnError && rc != 0) + goto done; + } + + done: + return rc; +} + + +int +virDomainRedirdevDefForeach(virDomainDefPtr def, + bool abortOnError, + virDomainRedirdevDefIterator iter, + void *opaque) +{ + size_t i; + int rc = 0; + + for (i = 0; i < def->nredirdevs; i++) { + if ((iter)(def, + def->redirdevs[i], + opaque) < 0) + rc = -1; + + if (abortOnError && rc != 0) + goto done; + } + + done: + return rc; +} + + +int virDomainUSBDeviceDefForeach(virDomainDefPtr def, virDomainUSBDeviceDefIterator iter, void *opaque, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index df216e8..df962d7 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2948,6 +2948,24 @@ int virDomainChrDefForeach(virDomainDefPtr def, virDomainChrDefIterator iter, void *opaque); +typedef int (*virDomainRNGDefIterator)(virDomainDefPtr def, + virDomainRNGDefPtr dev, + void *opaque); + +int virDomainRNGDefForeach(virDomainDefPtr def, + bool abortOnError, + virDomainRNGDefIterator iter, + void *opaque); + +typedef int (*virDomainRedirdevDefIterator)(virDomainDefPtr def, + virDomainRedirdevDefPtr dev, + void *opaque); + +int virDomainRedirdevDefForeach(virDomainDefPtr def, + bool abortOnError, + virDomainRedirdevDefIterator iter, + void *opaque); + typedef int (*virDomainDiskDefPathIterator)(virDomainDiskDefPtr disk, const char *path, size_t depth, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index bf503a5..c777738 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -453,9 +453,11 @@ virDomainPMSuspendedReasonTypeToString; virDomainRedirdevBusTypeFromString; virDomainRedirdevBusTypeToString; virDomainRedirdevDefFind; +virDomainRedirdevDefForeach; virDomainRedirdevDefFree; virDomainRedirdevDefRemove; virDomainRNGBackendTypeToString; +virDomainRNGDefForeach; virDomainRNGDefFree; virDomainRNGFind; virDomainRNGModelTypeToString; -- 2.7.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list