Re: [libvirt PATCH 6/6] tools: report messages for 'dominfo' command

2021-02-05 Thread Pino Toscano
On Friday, 5 February 2021 15:18:31 CET Daniel P. Berrangé wrote:
> diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
> index 02ff1fbd62..df24543ef8 100644
> --- a/tools/virsh-domain-monitor.c
> +++ b/tools/virsh-domain-monitor.c
> @@ -1291,6 +1291,7 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
>  char *str, uuid[VIR_UUID_STRING_BUFLEN];
>  int has_managed_save = 0;
>  virshControlPtr priv = ctl->privData;
> +char **messages = NULL;
>  
>  if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
>  return false;
> @@ -1391,6 +1392,18 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
>  VIR_FREE(seclabel);
>  }
>  }
> +
> +if (virDomainGetMessages(dom, &messages, 0) > 0) {
> +size_t i;
> +for (i = 0; messages[i] != NULL; i++) {
> +if (i == 0) {
> +vshPrint(ctl, "%-15s %s\n", _("Messages:"), messages[i]);
> +} else {
> +vshPrint(ctl, "%-15s %s\n", "", messages[i]);
> +}
> +}
> +}

'messages' is leaked here.

-- 
Pino Toscano

signature.asc
Description: This is a digitally signed message part.


[libvirt PATCH 6/6] tools: report messages for 'dominfo' command

2021-02-05 Thread Daniel P . Berrangé
$ virsh dominfo demo
Id: 2
Name:   demo
UUID:   eadf8ef0-bf14-4c5f-9708-4a19bacf9e81
OS Type:hvm
State:  running
CPU(s): 2
CPU time:   15.8s
Max memory: 1536000 KiB
Used memory:1536000 KiB
Persistent: yes
Autostart:  disable
Managed save:   no
Security model: selinux
Security DOI:   0
Security label: unconfined_u:unconfined_r:svirt_t:s0:c443,c956 (permissive)
Messages:   tainted: custom monitor control commands issued
tainted: use of deprecated configuration settings
deprecated configuration: machine type 'pc-1.2'

Signed-off-by: Daniel P. Berrangé 
---
 tools/virsh-domain-monitor.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index 02ff1fbd62..df24543ef8 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -1291,6 +1291,7 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
 char *str, uuid[VIR_UUID_STRING_BUFLEN];
 int has_managed_save = 0;
 virshControlPtr priv = ctl->privData;
+char **messages = NULL;
 
 if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
 return false;
@@ -1391,6 +1392,18 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
 VIR_FREE(seclabel);
 }
 }
+
+if (virDomainGetMessages(dom, &messages, 0) > 0) {
+size_t i;
+for (i = 0; messages[i] != NULL; i++) {
+if (i == 0) {
+vshPrint(ctl, "%-15s %s\n", _("Messages:"), messages[i]);
+} else {
+vshPrint(ctl, "%-15s %s\n", "", messages[i]);
+}
+}
+}
+
 virshDomainFree(dom);
 return ret;
 }
-- 
2.29.2