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 +++
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 8792f5e..81e4030 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -12061,6 +12061,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 09ab194..b3843e8 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2653,6 +2653,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 a2eec83..653655f 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -377,6 +377,7 @@ virDomainPMSuspendedReasonTypeToString;
virDomainRedirdevBusTypeFromString;
virDomainRedirdevBusTypeToString;
virDomainRNGBackendTypeToString;
+virDomainRNGEquals;
virDomainRNGModelTypeToString;
virDomainRunningReasonTypeFromString;
virDomainRunningReasonTypeToString;
--
1.8.3.1