diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e9766e7b382ff222263b0e588ae39be9f771a8a3..6a57d80b61334bbbf40d85fc8cf000692581fa92 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -12177,6 +12177,76 @@ virDomainChrRemove(virDomainDefPtr vmdef, return ret; } + +int +virDomainRNGInsert(virDomainDefPtr def, + virDomainRNGDefPtr rng, + bool inplace) +{ + if (inplace) + return VIR_APPEND_ELEMENT_INPLACE(def->rngs, def->nrngs, rng); + else + return VIR_APPEND_ELEMENT(def->rngs, def->nrngs, rng); +} + + +ssize_t +virDomainRNGFind(virDomainDefPtr def, + virDomainRNGDefPtr rng) +{ + size_t i; + + for (i = 0; i < def->nrngs; i++) { + virDomainRNGDefPtr tmp = def->rngs[i]; + + if (rng->model != tmp->model || rng->backend != tmp->backend) + continue; + + if (rng->rate != tmp->rate || rng->period != tmp->period) + continue; + + switch ((virDomainRNGBackend) rng->backend) { + case VIR_DOMAIN_RNG_BACKEND_RANDOM: + if (STRNEQ_NULLABLE(rng->source.file, tmp->source.file)) + continue; + break; + + case VIR_DOMAIN_RNG_BACKEND_EGD: + if (!virDomainChrSourceDefIsEqual(rng->source.chardev, + tmp->source.chardev)) + continue; + break; + + case VIR_DOMAIN_RNG_BACKEND_LAST: + break; + } + + if (rng->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && + !virDomainDeviceInfoAddressIsEqual(&rng->info, &tmp->info)) + continue; + + break; + } + + if (i < def->nrngs) + return i; + + return -1; +} + + +virDomainRNGDefPtr +virDomainRNGRemove(virDomainDefPtr def, + size_t idx) +{ + virDomainRNGDefPtr ret = def->rngs[idx]; + + VIR_DELETE_ELEMENT(def->rngs, idx, def->nrngs); + + return ret; +} + + char * virDomainDefGetDefaultEmulator(virDomainDefPtr def, virCapsPtr caps) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index f0177c34dcaa5786a52274ae0b4d40ce90476a0c..e96d2e311d267ffaef759d3e41a762a5b5c22939 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2665,6 +2665,12 @@ virDomainChrDefPtr virDomainChrRemove(virDomainDefPtr vmdef, virDomainChrDefPtr chr); +int virDomainRNGInsert(virDomainDefPtr def, + virDomainRNGDefPtr rng, + bool inplace); +ssize_t virDomainRNGFind(virDomainDefPtr def, virDomainRNGDefPtr rng); +virDomainRNGDefPtr virDomainRNGRemove(virDomainDefPtr def, size_t idx); + int virDomainSaveXML(const char *configDir, virDomainDefPtr def, const char *xml); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 85d6d05208b63a4523c1f879aec5492823367c41..7d82809ca2d9ddd9e84bc2cf79807010dffdfc75 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -380,7 +380,10 @@ virDomainPMSuspendedReasonTypeToString; virDomainRedirdevBusTypeFromString; virDomainRedirdevBusTypeToString; virDomainRNGBackendTypeToString; +virDomainRNGFind; +virDomainRNGInsert; virDomainRNGModelTypeToString; +virDomainRNGRemove; virDomainRunningReasonTypeFromString; virDomainRunningReasonTypeToString; virDomainSaveConfig;