mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 19:41:16 +00:00
conf: Add helpers to insert/remove/find RNG devices in domain def
The helpers will be useful when implementing hotplug and coldplug of random number generator devices. Signed-off-by: Luyao Huang <lhuang@redhat.com> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
ad3e99e21b
commit
37b620059b
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -380,7 +380,10 @@ virDomainPMSuspendedReasonTypeToString;
|
||||
virDomainRedirdevBusTypeFromString;
|
||||
virDomainRedirdevBusTypeToString;
|
||||
virDomainRNGBackendTypeToString;
|
||||
virDomainRNGFind;
|
||||
virDomainRNGInsert;
|
||||
virDomainRNGModelTypeToString;
|
||||
virDomainRNGRemove;
|
||||
virDomainRunningReasonTypeFromString;
|
||||
virDomainRunningReasonTypeToString;
|
||||
virDomainSaveConfig;
|
||||
|
Loading…
Reference in New Issue
Block a user