It would be nice if we expose the capability of choosing the UEFI
and NVRAM store file format among with all the possibilities.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
docs/formatdomaincaps.html.in | 26 ++++++++++++++++++++++
docs/schemas/domaincaps.rng | 13 +++++++++++
src/conf/domain_capabilities.c | 18 +++++++++++++++
src/conf/domain_capabilities.h | 2 ++
src/qemu/qemu_capabilities.c | 10 +++++++--
tests/domaincapsschemadata/domaincaps-full.xml | 10 +++++++++
.../domaincaps-qemu_1.6.50-1.xml | 10 +++++++++
tests/domaincapstest.c | 2 ++
8 files changed, 89 insertions(+), 2 deletions(-)
diff --git a/docs/formatdomaincaps.html.in b/docs/formatdomaincaps.html.in
index 850109f..10e382f 100644
--- a/docs/formatdomaincaps.html.in
+++ b/docs/formatdomaincaps.html.in
@@ -117,7 +117,17 @@
<value>yes</value>
<value>no</value>
</enum>
+ <enum name='format'>
+ <value>raw</value>
+ <value>qcow2</value>
+ </enum>
</loader>
+ <nvram supported='yes'>
+ <enum name='format'>
+ <value>raw</value>
+ <value>qcow2</value>
+ </enum>
+ </nvram>
</os>
...
<domainCapabilities>
@@ -140,6 +150,22 @@
<dt>readonly</dt>
<dd>Options for the <code>readonly</code> attribute of the
<loader/> element.</dd>
+
+ <dt>format</dt>
+ <dd>What formats of UEFI file are supported. The default is
+ <code>raw</code>, but depending on hypervisor's capabilities,
+ <code>qcow2</code> may be supported as well. This refers to
+ <code>format</code> attribute of the <loader/>
element.</dd>
+ </dl>
+
+ <p>For the <code>nvram</code> element, the following can be
listed:</p>
+
+ <dl>
+ <dt>format</dt>
+ <dd>What formats of NVRAM store file are supported. The default is
+ <code>raw</code>, but depending on hypervisor's capabilities,
+ <code>qcow2</code> may be supported as well. This refers to
+ <code>format</code> attribute of the <nvram/>
element.</dd>
</dl>
<h3><a name="elementsDevices">Devices</a></h3>
diff --git a/docs/schemas/domaincaps.rng b/docs/schemas/domaincaps.rng
index 35d3745..e8a1e59 100644
--- a/docs/schemas/domaincaps.rng
+++ b/docs/schemas/domaincaps.rng
@@ -54,6 +54,16 @@
</element>
</define>
+ <define name='nvram'>
+ <element name='nvram'>
+ <ref name='supported'/>
+ <optional>
+ <ref name='value'/>
+ </optional>
+ <ref name='enum'/>
+ </element>
+ </define>
+
<define name='os'>
<element name='os'>
<interleave>
@@ -61,6 +71,9 @@
<optional>
<ref name='loader'/>
</optional>
+ <optional>
+ <ref name='nvram'/>
+ </optional>
</interleave>
</element>
</define>
diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c
index 7c59912..9393d06 100644
--- a/src/conf/domain_capabilities.c
+++ b/src/conf/domain_capabilities.c
@@ -216,11 +216,28 @@ virDomainCapsLoaderFormat(virBufferPtr buf,
virDomainCapsStringValuesFormat(buf, &loader->values);
ENUM_PROCESS(loader, type, virDomainLoaderTypeToString);
ENUM_PROCESS(loader, readonly, virTristateBoolTypeToString);
+ ENUM_PROCESS(loader, format, virDomainLoaderFormatTypeToString);
FORMAT_EPILOGUE(loader);
}
static void
+virDomainCapsNVRAMFormat(virBufferPtr buf,
+ virDomainCapsLoaderPtr nvram)
+{
+ /* Even though the type of @nvram would suggest naming it
+ * differently than 'nvram' ('loader' for instance), keep in
+ * mind that the FORMAT_PROLOGUE macro emits the variable
+ * name into the XML where we want to see 'nvram'. Really. */
+ FORMAT_PROLOGUE(nvram);
+
+ virDomainCapsEnumFormat(buf, &nvram->nvramFormat, "format",
+ virDomainLoaderFormatTypeToString);
+
+ FORMAT_EPILOGUE(nvram);
+}
+
+static void
virDomainCapsOSFormat(virBufferPtr buf,
virDomainCapsOSPtr os)
{
@@ -229,6 +246,7 @@ virDomainCapsOSFormat(virBufferPtr buf,
FORMAT_PROLOGUE(os);
virDomainCapsLoaderFormat(buf, loader);
+ virDomainCapsNVRAMFormat(buf, loader);
FORMAT_EPILOGUE(os);
}
diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h
index 597ac75..d59b126 100644
--- a/src/conf/domain_capabilities.h
+++ b/src/conf/domain_capabilities.h
@@ -57,6 +57,8 @@ struct _virDomainCapsLoader {
virDomainCapsStringValues values; /* Info about values for the element */
virDomainCapsEnum type; /* Info about virDomainLoader */
virDomainCapsEnum readonly; /* Info about readonly:virTristateBool */
+ virDomainCapsEnum format; /* Info about virDomainLoaderFormat */
+ virDomainCapsEnum nvramFormat; /* Info about virDomainLoaderFormat */
};
typedef struct _virDomainCapsOS virDomainCapsOS;
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 13f3cd3..addd9d3 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -3706,10 +3706,16 @@ virQEMUCapsFillDomainLoaderCaps(virQEMUCapsPtr qemuCaps,
VIR_DOMAIN_LOADER_TYPE_ROM);
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE) &&
- virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_FORMAT))
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_FORMAT)) {
VIR_DOMAIN_CAPS_ENUM_SET(capsLoader->type,
VIR_DOMAIN_LOADER_TYPE_PFLASH);
-
+ VIR_DOMAIN_CAPS_ENUM_SET(capsLoader->format,
+ VIR_DOMAIN_LOADER_FORMAT_RAW,
+ VIR_DOMAIN_LOADER_FORMAT_QCOW2);
+ VIR_DOMAIN_CAPS_ENUM_SET(capsLoader->nvramFormat,
+ VIR_DOMAIN_LOADER_FORMAT_RAW,
+ VIR_DOMAIN_LOADER_FORMAT_QCOW2);
+ }
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_READONLY))
VIR_DOMAIN_CAPS_ENUM_SET(capsLoader->readonly,
diff --git a/tests/domaincapsschemadata/domaincaps-full.xml
b/tests/domaincapsschemadata/domaincaps-full.xml
index 96202bc..c2b501c 100644
--- a/tests/domaincapsschemadata/domaincaps-full.xml
+++ b/tests/domaincapsschemadata/domaincaps-full.xml
@@ -17,7 +17,17 @@
<value>yes</value>
<value>no</value>
</enum>
+ <enum name='format'>
+ <value>raw</value>
+ <value>qcow2</value>
+ </enum>
</loader>
+ <nvram supported='yes'>
+ <enum name='format'>
+ <value>raw</value>
+ <value>qcow2</value>
+ </enum>
+ </nvram>
</os>
<devices>
<disk supported='yes'>
diff --git a/tests/domaincapsschemadata/domaincaps-qemu_1.6.50-1.xml
b/tests/domaincapsschemadata/domaincaps-qemu_1.6.50-1.xml
index 346ef65..d45d6b5 100644
--- a/tests/domaincapsschemadata/domaincaps-qemu_1.6.50-1.xml
+++ b/tests/domaincapsschemadata/domaincaps-qemu_1.6.50-1.xml
@@ -14,7 +14,17 @@
<value>yes</value>
<value>no</value>
</enum>
+ <enum name='format'>
+ <value>raw</value>
+ <value>qcow2</value>
+ </enum>
</loader>
+ <nvram supported='yes'>
+ <enum name='format'>
+ <value>raw</value>
+ <value>qcow2</value>
+ </enum>
+ </nvram>
</os>
<devices>
<disk supported='yes'>
diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c
index 70d2ef3..b483de1 100644
--- a/tests/domaincapstest.c
+++ b/tests/domaincapstest.c
@@ -70,6 +70,8 @@ fillAll(virDomainCapsPtr domCaps,
loader->device.supported = true;
SET_ALL_BITS(loader->type);
SET_ALL_BITS(loader->readonly);
+ SET_ALL_BITS(loader->format);
+ SET_ALL_BITS(loader->nvramFormat);
if (fillStringValues(&loader->values,
"/foo/bar",
"/tmp/my_path",
--
2.0.5