On 2/9/21 11:01 AM, Daniel P. Berrangé wrote:
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
src/conf/domain_conf.c | 17 ++++++++++++
src/conf/domain_conf.h | 1 +
src/libvirt_private.syms | 2 ++
src/qemu/qemu_domain.h | 3 +++
src/qemu/qemu_driver.c | 58 ++++++++++++++++++++++++++++++++++++++++
5 files changed, 81 insertions(+)
[...]
+static int
+qemuDomainGetMessages(virDomainPtr dom,
+ char ***msgs,
+ unsigned int flags)
+{
+ virDomainObjPtr vm = NULL;
+ int rv = -1;
+ size_t i, n;
+ int nmsgs;
+
+ virCheckFlags(VIR_DOMAIN_MESSAGE_DEPRECATION |
+ VIR_DOMAIN_MESSAGE_TAINTING, -1);
+
+ if (!(vm = qemuDomainObjFromDomain(dom)))
+ return -1;
+
+ if (virDomainGetMessagesEnsureACL(dom->conn, vm->def) < 0)
+ goto cleanup;
+
+ *msgs = NULL;
+ nmsgs = 0;
+ n = 0;
+
+ if (!flags || (flags & VIR_DOMAIN_MESSAGE_TAINTING)) {
+ nmsgs += __builtin_popcount(vm->taint);
+ *msgs = g_renew(char *, *msgs, nmsgs+1);
+
+ for (i = 0; i < VIR_DOMAIN_TAINT_LAST; i++) {
+ if (vm->taint & (1 << i)) {
+ (*msgs)[n++] = g_strdup_printf(
+ _("tainted: %s"),
+ _(virDomainTaintMessageTypeToString(i)));
+ }
+ }
+ }
+
+ if (!flags || (flags & VIR_DOMAIN_MESSAGE_DEPRECATION)) {
+ nmsgs += vm->ndeprecations;
+ *msgs = g_renew(char *, *msgs, nmsgs+1);
+
+ for (i = 0; i < vm->ndeprecations; i++) {
+ (*msgs)[n++] = g_strdup_printf(
+ _("deprecated configuration: %s"),
+ vm->deprecations[i]);
+ }
+ }
+
+ (*msgs)[nmsgs] = NULL;
FYI: Coverity got grumpy right here as it believes *msgs could be NULL
because of the !flags || condition and not realizing that flags could
only be one of the two or 0.
Wasn't sure whether being safe and adding a if (*msgs) is desired, but
figured I'd at least note it.
John
+
+ rv = nmsgs;
+
+ cleanup:
+ virDomainObjEndAPI(&vm);
+ return rv;
+}
+
[...]