virDomainRNGEquals is a func which check if two rng device are the same. And export virDomainRNGEquals.
Signed-off-by: Luyao Huang <lhu...@redhat.com> --- src/conf/domain_conf.c | 34 ++++++++++++++++++++++++++++++++++ src/conf/domain_conf.h | 3 +++ src/libvirt_private.syms | 1 + 3 files changed, 38 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d1a483a..9afef72 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -12136,6 +12136,40 @@ virDomainChrRemove(virDomainDefPtr vmdef, return ret; } +bool +virDomainRNGEquals(virDomainRNGDefPtr src, + virDomainRNGDefPtr tgt) +{ + if (!src || !tgt) + return src == tgt; + + if (src->model != tgt->model) + return false; + + if (src->rate != tgt->rate || src->period != tgt->period) + return false; + + switch ((virDomainRNGModel) src->model) { + case VIR_DOMAIN_RNG_MODEL_VIRTIO: + switch ((virDomainRNGBackend) src->backend) { + case VIR_DOMAIN_RNG_BACKEND_RANDOM: + return STREQ_NULLABLE(src->source.file, tgt->source.file); + break; + case VIR_DOMAIN_RNG_BACKEND_EGD: + return virDomainChrSourceDefIsEqual(src->source.chardev, + tgt->source.chardev); + break; + case VIR_DOMAIN_RNG_BACKEND_LAST: + break; + } + break; + + case VIR_DOMAIN_RNG_MODEL_LAST: + break; + } + return false; +} + char * virDomainDefGetDefaultEmulator(virDomainDefPtr def, virCapsPtr caps) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index ac1f4f8..e4a8b29 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2623,6 +2623,9 @@ virDomainChrDefPtr virDomainChrRemove(virDomainDefPtr vmdef, virDomainChrDefPtr chr); +bool virDomainRNGEquals(virDomainRNGDefPtr src, + virDomainRNGDefPtr tgt); + int virDomainSaveXML(const char *configDir, virDomainDefPtr def, const char *xml); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index fb5d003..6390566 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -376,6 +376,7 @@ virDomainPMSuspendedReasonTypeToString; virDomainRedirdevBusTypeFromString; virDomainRedirdevBusTypeToString; virDomainRNGBackendTypeToString; +virDomainRNGEquals; virDomainRNGModelTypeToString; virDomainRunningReasonTypeFromString; virDomainRunningReasonTypeToString; -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list