On 2/21/19 4:42 PM, Ján Tomko wrote:
Add a function that will convert the "name" attributes from the passed
nodes to QEMU capabilities.
Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx>
---
src/qemu/qemu_capabilities.c | 51 +++++++++++++++++++++++++-----------
1 file changed, 35 insertions(+), 16 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 7160860ab4..a355ee2e37 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -3442,6 +3442,38 @@ virQEMUCapsParseSEVInfo(virQEMUCapsPtr qemuCaps, xmlXPathContextPtr ctxt)
}
+static int
+virQEMUCapsSetFromNodes(virQEMUCapsPtr qemuCaps,
+ xmlNodePtr *nodes,
+ size_t n)
+{
+ size_t i;
+ char *str = NULL;
VIR_AUTOFREE()
And if you declare the variable only in the loop body then ..
+ int ret = -1;
+
+ for (i = 0; i < n; i++) {
+ int flag;
+ if (!(str = virXMLPropString(nodes[i], "name"))) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("missing flag name in QEMU capabilities cache"));
+ goto cleanup;
+ }
+ flag = virQEMUCapsTypeFromString(str);
+ if (flag < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unknown qemu capabilities flag %s"), str);
+ goto cleanup;
+ }
+ VIR_FREE(str);
.. this can be dropped too.
+ virQEMUCapsSet(qemuCaps, flag);
+ }
+ ret = 0;
+ cleanup:
+ VIR_FREE(str);
+ return ret;
+}
+
Michal
--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list