conf: Add rng backend model builtin

The 'builtin' rng backend model can be used as following:
  <rng model='virtio'>
    <backend model='builtin'/>
  </rng>

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Han Han 2020-01-09 16:00:07 +08:00 committed by Michal Privoznik
parent 1bd17918b6
commit 6a6d00e168
8 changed files with 43 additions and 0 deletions

View File

@ -8259,6 +8259,8 @@ qemu-kvm -net nic,model=? /dev/null
&lt;source mode='bind' service='1234'/&gt;
&lt;source mode='connect' host='1.2.3.4' service='1234'/&gt;
&lt;/backend&gt;
&lt;!-- OR --&gt;
&lt;backend model='builtin'/&gt;
&lt;/rng&gt;
&lt;/devices&gt;
...
@ -8323,6 +8325,14 @@ qemu-kvm -net nic,model=? /dev/null
for more information.
</p>
</dd>
<dt><code>builtin</code></dt>
<dd>
<p>
This backend uses qemu builtin random generator, which uses
<code>getrandom()</code> syscall as the source of entropy.
(<span class="since">Since 6.1.0 and QEMU 4.2</span>)
</p>
</dd>
</dl>
</dd>
<dt><code>driver</code></dt>

View File

@ -481,6 +481,7 @@
&lt;enum name='backendModel'&gt;
&lt;value&gt;random&lt;/value&gt;
&lt;value&gt;egd&lt;/value&gt;
&lt;value&gt;builtin&lt;/value&gt;
&lt;/enum&gt;
&lt;/rng&gt;
...

View File

@ -5683,6 +5683,12 @@
<ref name="qemucdevSrcType"/>
<ref name="qemucdevSrcDef"/>
</group>
<group>
<attribute name="model">
<value>builtin</value>
</attribute>
<empty/>
</group>
</choice>
</element>
</define>

View File

@ -227,6 +227,7 @@ virDomainAuditRNG(virDomainObjPtr vm,
newsrcpath = virDomainChrSourceDefGetPath(newDef->source.chardev);
break;
case VIR_DOMAIN_RNG_BACKEND_BUILTIN:
case VIR_DOMAIN_RNG_BACKEND_LAST:
break;
}
@ -242,6 +243,7 @@ virDomainAuditRNG(virDomainObjPtr vm,
oldsrcpath = virDomainChrSourceDefGetPath(oldDef->source.chardev);
break;
case VIR_DOMAIN_RNG_BACKEND_BUILTIN:
case VIR_DOMAIN_RNG_BACKEND_LAST:
break;
}

View File

@ -1113,6 +1113,7 @@ VIR_ENUM_IMPL(virDomainRNGBackend,
VIR_DOMAIN_RNG_BACKEND_LAST,
"random",
"egd",
"builtin",
);
VIR_ENUM_IMPL(virDomainTPMModel,
@ -14792,6 +14793,7 @@ virDomainRNGDefParseXML(virDomainXMLOptionPtr xmlopt,
goto error;
break;
case VIR_DOMAIN_RNG_BACKEND_BUILTIN:
case VIR_DOMAIN_RNG_BACKEND_LAST:
break;
}
@ -17851,6 +17853,7 @@ virDomainRNGFind(virDomainDefPtr def,
continue;
break;
case VIR_DOMAIN_RNG_BACKEND_BUILTIN:
case VIR_DOMAIN_RNG_BACKEND_LAST:
break;
}
@ -26531,6 +26534,11 @@ virDomainRNGDefFormat(virBufferPtr buf,
return -1;
virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</backend>\n");
break;
case VIR_DOMAIN_RNG_BACKEND_BUILTIN:
virBufferAddLit(buf, "/>\n");
break;
case VIR_DOMAIN_RNG_BACKEND_LAST:
break;
@ -26562,6 +26570,7 @@ virDomainRNGDefFree(virDomainRNGDefPtr def)
case VIR_DOMAIN_RNG_BACKEND_EGD:
virObjectUnref(def->source.chardev);
break;
case VIR_DOMAIN_RNG_BACKEND_BUILTIN:
case VIR_DOMAIN_RNG_BACKEND_LAST:
break;
}

View File

@ -2106,6 +2106,7 @@ typedef enum {
typedef enum {
VIR_DOMAIN_RNG_BACKEND_RANDOM,
VIR_DOMAIN_RNG_BACKEND_EGD,
VIR_DOMAIN_RNG_BACKEND_BUILTIN,
VIR_DOMAIN_RNG_BACKEND_LAST
} virDomainRNGBackend;

View File

@ -5594,6 +5594,12 @@ qemuBuildRNGBackendChrdevStr(virLogManagerPtr logManager,
rng->info.alias, qemuCaps,
cdevflags)))
return -1;
break;
case VIR_DOMAIN_RNG_BACKEND_BUILTIN:
virReportUnsupportedError();
return -1;
break;
}
return 0;
@ -5644,6 +5650,10 @@ qemuBuildRNGBackendProps(virDomainRNGDefPtr rng,
break;
case VIR_DOMAIN_RNG_BACKEND_BUILTIN:
virReportUnsupportedError();
return -1;
case VIR_DOMAIN_RNG_BACKEND_LAST:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("unknown rng-random backend"));

View File

@ -14807,8 +14807,10 @@ qemuDomainSetupRNG(virQEMUDriverConfigPtr cfg G_GNUC_UNUSED,
case VIR_DOMAIN_RNG_BACKEND_RANDOM:
if (qemuDomainCreateDevice(rng->source.file, data, false) < 0)
return -1;
break;
case VIR_DOMAIN_RNG_BACKEND_EGD:
case VIR_DOMAIN_RNG_BACKEND_BUILTIN:
case VIR_DOMAIN_RNG_BACKEND_LAST:
/* nada */
break;
@ -15788,6 +15790,7 @@ qemuDomainNamespaceSetupRNG(virDomainObjPtr vm,
break;
case VIR_DOMAIN_RNG_BACKEND_EGD:
case VIR_DOMAIN_RNG_BACKEND_BUILTIN:
case VIR_DOMAIN_RNG_BACKEND_LAST:
break;
}
@ -15811,6 +15814,7 @@ qemuDomainNamespaceTeardownRNG(virDomainObjPtr vm,
break;
case VIR_DOMAIN_RNG_BACKEND_EGD:
case VIR_DOMAIN_RNG_BACKEND_BUILTIN:
case VIR_DOMAIN_RNG_BACKEND_LAST:
break;
}