virDomainRNGEquals is a func which check if two rng device
are the same.
Signed-off-by: Luyao Huang <lhuang(a)redhat.com>
---
src/conf/domain_conf.c | 34 ++++++++++++++++++++++++++++++++++
src/conf/domain_conf.h | 3 +++
2 files changed, 37 insertions(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index aafc05e..91c114e 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -11922,6 +11922,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((virDomainChrSourceDef *)
src->source.chardev,
+ (virDomainChrSourceDef *)
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 57297cd..c197095 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2597,6 +2597,9 @@ virDomainChrInsert(virDomainDefPtr vmdef,
virDomainChrDefPtr
virDomainChrRemove(virDomainDefPtr vmdef,
virDomainChrDefPtr chr);
+bool
+virDomainRNGEquals(virDomainRNGDefPtr src,
+ virDomainRNGDefPtr tgt);
int virDomainSaveXML(const char *configDir,
virDomainDefPtr def,
--
1.8.3.1