[libvirt] [PATCH v2] virsh: fixed domdisplay command

The 'domdisplay' command didn't properly evaluate '--include-password' option. --- v2: - switched to using 'flags' - kept the second condition in place - fixed indentation after virAsprintf tools/virsh.c | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/virsh.c b/tools/virsh.c index 5888d6c..5f96445 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -13870,6 +13870,7 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd) const char *scheme[] = { "vnc", "spice", "rdp", NULL }; int iter = 0; int tmp; + int flags = 0; if (!vshConnectionUsability(ctl, ctl->conn)) return false; @@ -13882,7 +13883,11 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd) goto cleanup; } - doc = virDomainGetXMLDesc(dom, 0); + if (vshCommandOptBool(cmd, "include-password")) + flags |= VIR_DOMAIN_XML_SECURE; + + doc = virDomainGetXMLDesc(dom, flags); + if (!doc) goto cleanup; @@ -13944,10 +13949,10 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd) if (tmp) tls_port = 0; - if (vshCommandOptBool(cmd, "daemon")) { + if (vshCommandOptBool(cmd, "include-password")) { /* Create our XPATH lookup for the SPICE password */ virAsprintf(&xpath, "string(/domain/devices/graphics" - "[@type='%s']/@passwd)", scheme[iter]); + "[@type='%s']/@passwd)", scheme[iter]); if (!xpath) { virReportOOMError(); goto cleanup; -- 1.7.8.6

On 07/24/12 16:06, Martin Kletzander wrote:
The 'domdisplay' command didn't properly evaluate '--include-password' option. --- v2: - switched to using 'flags' - kept the second condition in place - fixed indentation after virAsprintf
tools/virsh.c | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c index 5888d6c..5f96445 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -13870,6 +13870,7 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd) const char *scheme[] = { "vnc", "spice", "rdp", NULL }; int iter = 0; int tmp; + int flags = 0;
if (!vshConnectionUsability(ctl, ctl->conn)) return false; @@ -13882,7 +13883,11 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd) goto cleanup; }
- doc = virDomainGetXMLDesc(dom, 0); + if (vshCommandOptBool(cmd, "include-password")) + flags |= VIR_DOMAIN_XML_SECURE; + + doc = virDomainGetXMLDesc(dom, flags); + if (!doc) goto cleanup;
@@ -13944,10 +13949,10 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd) if (tmp) tls_port = 0;
- if (vshCommandOptBool(cmd, "daemon")) { + if (vshCommandOptBool(cmd, "include-password")) { /* Create our XPATH lookup for the SPICE password */ virAsprintf(&xpath, "string(/domain/devices/graphics" - "[@type='%s']/@passwd)", scheme[iter]); + "[@type='%s']/@passwd)", scheme[iter]);
The indentation is still bad here.
if (!xpath) { virReportOOMError(); goto cleanup; -- 1.7.8.6
ACK with indentation where you touched code fixed. It's still a mess in other parts of the function. Peter

On 07/24/2012 04:49 PM, Peter Krempa wrote:
On 07/24/12 16:06, Martin Kletzander wrote:
The 'domdisplay' command didn't properly evaluate '--include-password' option. --- v2: - switched to using 'flags' - kept the second condition in place - fixed indentation after virAsprintf
tools/virsh.c | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c index 5888d6c..5f96445 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -13870,6 +13870,7 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd) const char *scheme[] = { "vnc", "spice", "rdp", NULL }; int iter = 0; int tmp; + int flags = 0;
if (!vshConnectionUsability(ctl, ctl->conn)) return false; @@ -13882,7 +13883,11 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd) goto cleanup; }
- doc = virDomainGetXMLDesc(dom, 0); + if (vshCommandOptBool(cmd, "include-password")) + flags |= VIR_DOMAIN_XML_SECURE; + + doc = virDomainGetXMLDesc(dom, flags); + if (!doc) goto cleanup;
@@ -13944,10 +13949,10 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd) if (tmp) tls_port = 0;
- if (vshCommandOptBool(cmd, "daemon")) { + if (vshCommandOptBool(cmd, "include-password")) { /* Create our XPATH lookup for the SPICE password */ virAsprintf(&xpath, "string(/domain/devices/graphics" - "[@type='%s']/@passwd)", scheme[iter]); + "[@type='%s']/@passwd)", scheme[iter]);
The indentation is still bad here.
if (!xpath) { virReportOOMError(); goto cleanup; -- 1.7.8.6
ACK with indentation where you touched code fixed. It's still a mess in other parts of the function.
Thanks, pushed and the line is back as nothing happened there. Martin

On Tue, Jul 24, 2012 at 9:06 AM, Martin Kletzander <mkletzan@redhat.com> wrote:
The 'domdisplay' command didn't properly evaluate '--include-password' option. --- v2: - switched to using 'flags' - kept the second condition in place - fixed indentation after virAsprintf
tools/virsh.c | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c index 5888d6c..5f96445 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -13870,6 +13870,7 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd) const char *scheme[] = { "vnc", "spice", "rdp", NULL }; int iter = 0; int tmp; + int flags = 0;
nit pick but virDomainGetXMLDesc() takes an unsigned int and not an int.
if (!vshConnectionUsability(ctl, ctl->conn)) return false; @@ -13882,7 +13883,11 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd) goto cleanup; }
- doc = virDomainGetXMLDesc(dom, 0); + if (vshCommandOptBool(cmd, "include-password")) + flags |= VIR_DOMAIN_XML_SECURE; + + doc = virDomainGetXMLDesc(dom, flags); + if (!doc) goto cleanup;
@@ -13944,10 +13949,10 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd) if (tmp) tls_port = 0;
- if (vshCommandOptBool(cmd, "daemon")) { + if (vshCommandOptBool(cmd, "include-password")) { /* Create our XPATH lookup for the SPICE password */ virAsprintf(&xpath, "string(/domain/devices/graphics" - "[@type='%s']/@passwd)", scheme[iter]); + "[@type='%s']/@passwd)", scheme[iter]); if (!xpath) { virReportOOMError(); goto cleanup; -- 1.7.8.6
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
-- Doug Goldstein

On 07/24/2012 06:09 PM, Doug Goldstein wrote:
On Tue, Jul 24, 2012 at 9:06 AM, Martin Kletzander <mkletzan@redhat.com> wrote:
The 'domdisplay' command didn't properly evaluate '--include-password' option. --- v2: - switched to using 'flags' - kept the second condition in place - fixed indentation after virAsprintf
tools/virsh.c | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c index 5888d6c..5f96445 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -13870,6 +13870,7 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd) const char *scheme[] = { "vnc", "spice", "rdp", NULL }; int iter = 0; int tmp; + int flags = 0;
nit pick but virDomainGetXMLDesc() takes an unsigned int and not an int.
You're absolutely right, thanks for noticing. I see it's not the only function in there, so I'll go through that and fix it everywhere. But most probably I'll wait for Osier's patches to be in, first. Martin
participants (3)
-
Doug Goldstein
-
Martin Kletzander
-
Peter Krempa