1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

Add virtio-related options to rng devices

https://bugzilla.redhat.com/show_bug.cgi?id=1283251

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Ján Tomko 2016-06-06 17:01:56 +02:00
parent b10c22d9fa
commit f65db1be12
5 changed files with 37 additions and 0 deletions

@ -7064,6 +7064,17 @@ qemu-kvm -net nic,model=? /dev/null
</dd> </dd>
</dl> </dl>
</dd> </dd>
<dt><code>driver</code></dt>
<dd>
The subelement <code>driver</code> can be used to tune the device:
<dl>
<dt>virtio options</dt>
<dd>
<a href="#elementsVirtio">Virtio-specific options</a> can also be
set. (<span class="since">Since 3.5.0</span>)
</dd>
</dl>
</dd>
</dl> </dl>

@ -4965,6 +4965,11 @@
</attribute> </attribute>
<interleave> <interleave>
<ref name="rng-backend"/> <ref name="rng-backend"/>
<optional>
<element name="driver">
<ref name="virtioOptions"/>
</element>
</optional>
<optional> <optional>
<ref name="rng-rate"/> <ref name="rng-rate"/>
</optional> </optional>

@ -12949,6 +12949,9 @@ virDomainRNGDefParseXML(virDomainXMLOptionPtr xmlopt,
if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0) if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0)
goto error; goto error;
if (virDomainVirtioOptionsParseXML(ctxt, &def->virtio) < 0)
goto error;
cleanup: cleanup:
VIR_FREE(model); VIR_FREE(model);
VIR_FREE(backend); VIR_FREE(backend);
@ -19663,6 +19666,10 @@ virDomainRNGDefCheckABIStability(virDomainRNGDefPtr src,
return false; return false;
} }
if (src->virtio && dst->virtio &&
!virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio))
return false;
if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info)) if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info))
return false; return false;
@ -23176,6 +23183,7 @@ virDomainRNGDefFormat(virBufferPtr buf,
{ {
const char *model = virDomainRNGModelTypeToString(def->model); const char *model = virDomainRNGModelTypeToString(def->model);
const char *backend = virDomainRNGBackendTypeToString(def->backend); const char *backend = virDomainRNGBackendTypeToString(def->backend);
virBuffer driverBuf = VIR_BUFFER_INITIALIZER;
virBufferAsprintf(buf, "<rng model='%s'>\n", model); virBufferAsprintf(buf, "<rng model='%s'>\n", model);
virBufferAdjustIndent(buf, 2); virBufferAdjustIndent(buf, 2);
@ -23204,6 +23212,16 @@ virDomainRNGDefFormat(virBufferPtr buf,
break; break;
} }
virDomainVirtioOptionsFormat(&driverBuf, def->virtio);
if (virBufferCheckError(&driverBuf) < 0)
return -1;
if (virBufferUse(&driverBuf)) {
virBufferAddLit(buf, "<driver");
virBufferAddBuffer(buf, &driverBuf);
virBufferAddLit(buf, "/>\n");
}
if (virDomainDeviceInfoNeedsFormat(&def->info, flags)) { if (virDomainDeviceInfoNeedsFormat(&def->info, flags)) {
if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
return -1; return -1;
@ -23232,6 +23250,7 @@ virDomainRNGDefFree(virDomainRNGDefPtr def)
} }
virDomainDeviceInfoClear(&def->info); virDomainDeviceInfoClear(&def->info);
VIR_FREE(def->virtio);
VIR_FREE(def); VIR_FREE(def);
} }

@ -2020,6 +2020,7 @@ struct _virDomainRNGDef {
} source; } source;
virDomainDeviceInfo info; virDomainDeviceInfo info;
virDomainVirtioOptionsPtr virtio;
}; };
typedef enum { typedef enum {

@ -80,6 +80,7 @@
</memballoon> </memballoon>
<rng model='virtio'> <rng model='virtio'>
<backend model='random'>/dev/random</backend> <backend model='random'>/dev/random</backend>
<driver iommu='on' ats='on'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x0d' function='0x0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x0d' function='0x0'/>
</rng> </rng>
</devices> </devices>