mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
virDomainRNGDef: Convert 'backend' field to proper enum type
Convert the field and adjust the XML parser to use virXMLPropEnum(). Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
53edfa23f1
commit
b691d249d1
@ -215,7 +215,7 @@ virDomainAuditRNG(virDomainObj *vm,
|
||||
const char *oldsrcpath = NULL;
|
||||
|
||||
if (newDef) {
|
||||
switch ((virDomainRNGBackend) newDef->backend) {
|
||||
switch (newDef->backend) {
|
||||
case VIR_DOMAIN_RNG_BACKEND_RANDOM:
|
||||
newsrcpath = newDef->source.file;
|
||||
break;
|
||||
@ -231,7 +231,7 @@ virDomainAuditRNG(virDomainObj *vm,
|
||||
}
|
||||
|
||||
if (oldDef) {
|
||||
switch ((virDomainRNGBackend) oldDef->backend) {
|
||||
switch (oldDef->backend) {
|
||||
case VIR_DOMAIN_RNG_BACKEND_RANDOM:
|
||||
oldsrcpath = oldDef->source.file;
|
||||
break;
|
||||
|
@ -12116,7 +12116,6 @@ virDomainRNGDefParseXML(virDomainXMLOption *xmlopt,
|
||||
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
||||
int nbackends;
|
||||
g_autofree xmlNodePtr *backends = NULL;
|
||||
g_autofree char *backend = NULL;
|
||||
g_autofree char *type = NULL;
|
||||
|
||||
def = g_new0(virDomainRNGDef, 1);
|
||||
@ -12151,19 +12150,14 @@ virDomainRNGDefParseXML(virDomainXMLOption *xmlopt,
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!(backend = virXMLPropString(backends[0], "model"))) {
|
||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||
_("missing RNG device backend model"));
|
||||
if (virXMLPropEnum(backends[0], "model",
|
||||
virDomainRNGBackendTypeFromString,
|
||||
VIR_XML_PROP_REQUIRED,
|
||||
&def->backend) < 0) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
if ((def->backend = virDomainRNGBackendTypeFromString(backend)) < 0) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("unknown RNG backend model '%1$s'"), backend);
|
||||
goto error;
|
||||
}
|
||||
|
||||
switch ((virDomainRNGBackend) def->backend) {
|
||||
switch (def->backend) {
|
||||
case VIR_DOMAIN_RNG_BACKEND_RANDOM:
|
||||
def->source.file = virXPathString("string(./backend)", ctxt);
|
||||
break;
|
||||
@ -15197,7 +15191,7 @@ virDomainRNGFind(virDomainDef *def,
|
||||
if (rng->rate != tmp->rate || rng->period != tmp->period)
|
||||
continue;
|
||||
|
||||
switch ((virDomainRNGBackend) rng->backend) {
|
||||
switch (rng->backend) {
|
||||
case VIR_DOMAIN_RNG_BACKEND_RANDOM:
|
||||
if (STRNEQ_NULLABLE(rng->source.file, tmp->source.file))
|
||||
continue;
|
||||
@ -25076,7 +25070,7 @@ virDomainRNGDefFormat(virBuffer *buf,
|
||||
}
|
||||
virBufferAsprintf(buf, "<backend model='%s'", backend);
|
||||
|
||||
switch ((virDomainRNGBackend) def->backend) {
|
||||
switch (def->backend) {
|
||||
case VIR_DOMAIN_RNG_BACKEND_RANDOM:
|
||||
virBufferEscapeString(buf, ">%s</backend>\n", def->source.file);
|
||||
break;
|
||||
@ -25117,7 +25111,7 @@ virDomainRNGDefFree(virDomainRNGDef *def)
|
||||
if (!def)
|
||||
return;
|
||||
|
||||
switch ((virDomainRNGBackend) def->backend) {
|
||||
switch (def->backend) {
|
||||
case VIR_DOMAIN_RNG_BACKEND_RANDOM:
|
||||
g_free(def->source.file);
|
||||
break;
|
||||
|
@ -2610,7 +2610,7 @@ typedef enum {
|
||||
|
||||
struct _virDomainRNGDef {
|
||||
virDomainRNGModel model;
|
||||
int backend;
|
||||
virDomainRNGBackend backend;
|
||||
unsigned int rate; /* bytes per period */
|
||||
unsigned int period; /* milliseconds */
|
||||
|
||||
|
@ -5361,7 +5361,7 @@ qemuBuildRNGBackendChrdev(virCommand *cmd,
|
||||
{
|
||||
g_autofree char *charAlias = qemuAliasChardevFromDevAlias(rng->info.alias);
|
||||
|
||||
switch ((virDomainRNGBackend) rng->backend) {
|
||||
switch (rng->backend) {
|
||||
case VIR_DOMAIN_RNG_BACKEND_RANDOM:
|
||||
case VIR_DOMAIN_RNG_BACKEND_BUILTIN:
|
||||
case VIR_DOMAIN_RNG_BACKEND_LAST:
|
||||
@ -5390,7 +5390,7 @@ qemuBuildRNGBackendProps(virDomainRNGDef *rng,
|
||||
|
||||
objAlias = g_strdup_printf("obj%s", rng->info.alias);
|
||||
|
||||
switch ((virDomainRNGBackend) rng->backend) {
|
||||
switch (rng->backend) {
|
||||
case VIR_DOMAIN_RNG_BACKEND_RANDOM:
|
||||
if (qemuMonitorCreateObjectProps(props, "rng-random", objAlias,
|
||||
"s:filename", rng->source.file,
|
||||
|
@ -574,7 +574,7 @@ static int
|
||||
qemuDomainSetupRNG(virDomainRNGDef *rng,
|
||||
GSList **paths)
|
||||
{
|
||||
switch ((virDomainRNGBackend) rng->backend) {
|
||||
switch (rng->backend) {
|
||||
case VIR_DOMAIN_RNG_BACKEND_RANDOM:
|
||||
*paths = g_slist_prepend(*paths, g_strdup(rng->source.file));
|
||||
break;
|
||||
|
@ -2154,7 +2154,7 @@ qemuValidateDomainRNGDef(const virDomainRNGDef *def,
|
||||
{
|
||||
virDomainCapsDeviceRNG rngCaps = { 0 };
|
||||
|
||||
switch ((virDomainRNGBackend) def->backend) {
|
||||
switch (def->backend) {
|
||||
case VIR_DOMAIN_RNG_BACKEND_RANDOM:
|
||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_RNG_RANDOM)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
|
Loading…
Reference in New Issue
Block a user