[PATCH] virsh: Fix ambiguous output in metadata-change event

Han Han posted 1 patch 2 years, 5 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20211027085233.193677-1-hhan@redhat.com
tools/virsh-domain.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] virsh: Fix ambiguous output in metadata-change event
Posted by Han Han 2 years, 5 months ago
When you set metadata with type element like the following:
dom.setMetadata(libvirt.VIR_DOMAIN_METADATA_ELEMENT, "<test/>", 'abc', "HAHAH", 0)

Then for `virsh event --all`, then it will output this message:
event 'metadata-change' for domain 'rhel9': element HAHAH

The message is ambiguous since it looks like the params for
metadata-change event is the element HAHAH. Actually that means the type is
element while the url is HAHAH. Let's make it more clear.

Signed-off-by: Han Han <hhan@redhat.com>
---
 tools/virsh-domain.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 7f3356a536..d454075dfc 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -13317,7 +13317,7 @@ virshEventMetadataChangePrint(virConnectPtr conn G_GNUC_UNUSED,
 {
     g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 
-    virBufferAsprintf(&buf, _("event 'metadata-change' for domain '%s': %s %s\n"),
+    virBufferAsprintf(&buf, _("event 'metadata-change' for domain '%s': type %s, uri %s\n"),
                       virDomainGetName(dom),
                       UNKNOWNSTR(virshEventMetadataChangeTypeTypeToString(type)),
                       NULLSTR(nsuri));
-- 
2.33.1

Re: [PATCH] virsh: Fix ambiguous output in metadata-change event
Posted by Michal Prívozník 2 years, 5 months ago
On 10/27/21 10:52 AM, Han Han wrote:
> When you set metadata with type element like the following:
> dom.setMetadata(libvirt.VIR_DOMAIN_METADATA_ELEMENT, "<test/>", 'abc', "HAHAH", 0)
> 
> Then for `virsh event --all`, then it will output this message:
> event 'metadata-change' for domain 'rhel9': element HAHAH
> 
> The message is ambiguous since it looks like the params for
> metadata-change event is the element HAHAH. Actually that means the type is
> element while the url is HAHAH. Let's make it more clear.
> 
> Signed-off-by: Han Han <hhan@redhat.com>
> ---
>  tools/virsh-domain.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>

Michal