Skip to contentSkip to conversation

xl: print message to stdout when (!debug && dryrun)

PATCH Superseded Wei Liu 3 participants 6 messages Dec 13, 2014 – Dec 15, 2014

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Wei Liu

author
#0 lore raw

PATCH 1/1 xl: print message to stdout when (!debug && dryrun)

In commit d36a3734a ("xl: fix migration failure with xl migrate --debug"), message is printed to stderr for both debug mode and dryrun mode. That caused rdname() in xendomains fails to parse domain name since it's expecting input from xl's stdout.

So this patch separates those two cases. If xl is running in debug mode, then message is printed to stderr; if xl is running in dryrun mode and debug is not enabled, message is printed to stdout. This will fix xendomains and other scripts that use "xl create --dryrun", as well as not re-introducing the old bug fixed in d36a3734a.

Cc M A Young <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Konrad Wilk <[email protected]>

---
This is a regression, and this bug is so subtle that's a bit hard to debug from user's point of view. So I think this should go into 4.5.

Mark posted a workaround in <104017455.78913.1418434454763.JavaMail.yahoo@jws10624.mail.bf1.yahoo.com> but to be honest I don't think it's nice to have everyone patch their scripts in order to work around this.

---
 tools/libxl/xl_cmdimpl.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/libxl/xl_cmdimpl.c +3 -1
index 3737c7e..0a5f7c8 100644
@@ -2472,8 +2472,10 @@ static uint32_t create_domain(struct domain_create *dom_info)
         }
     }
 
-    if (debug || dom_info->dryrun)
+    if (debug)
         printf_info(default_output_format, -1, &d_config, stderr);
+    if (!debug && dom_info->dryrun)
+        printf_info(default_output_format, -1, &d_config, stdout);
 
     ret = 0;
     if (dom_info->dryrun)
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 33 lines · Wei Liu

In commit d36a3734a ("xl: fix migration failure with xl migrate --debug"), message is printed to stderr for both debug mode and dryrun mode. That caused rdname() in xendomains fails to parse domain name since it's expecting input from xl's stdout.

So this patch separates those two cases. If xl is running in debug mode, then message is printed to stderr; if xl is running in dryrun mode and debug is not enabled, message is printed to stdout. This will fix xendomains and other scripts that use "xl create --dryrun", as well as not re-introducing the old bug fixed in d36a3734a.

Cc M A Young <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Konrad Wilk <[email protected]>

---
This is a regression, and this bug is so subtle that's a bit hard to debug from user's point of view. So I think this should go into 4.5.

Mark posted a workaround in <104017455.78913.1418434454763.JavaMail.yahoo@jws10624.mail.bf1.yahoo.com> but to be honest I don't think it's nice to have everyone patch their scripts in order to work around this.

---
 tools/libxl/xl_cmdimpl.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/libxl/xl_cmdimpl.c +0 -0
index 3737c7e..0a5f7c8 100644

tools/libxl/xl_cmdimpl.c static uint32_t create_domain(struct domain_create *dom_info) · line 2477

Quoted 7 lines
tools/libxl/xl_cmdimpl.c +2 -1
@@ -2472,8 +2472,10 @@ static uint32_t create_domain(struct domain_create *dom_info)
         }
     }
 
-    if (debug || dom_info->dryrun)
+    if (debug)
         printf_info(default_output_format, -1, &d_config, stderr);
+    if (!debug && dom_info->dryrun)

Could this 'else if (dom_info->dry_run)' ?

I know that semantically it is exactly the same as the 'if (!debug ..)' but it just "feels" more proper? Thought since you are the maintainer in that area - your opinion on how you want to do that is of course authoritive.

Regardless,

Quoted 7 lines
tools/libxl/xl_cmdimpl.c +1 -0
+        printf_info(default_output_format, -1, &d_config, stdout);
 
     ret = 0;
     if (dom_info->dryrun)
Signature · 1 line
1.7.10.4
author
#2 lore raw
Quoted 44 lines · Konrad Rzeszutek Wilk
Quoted 33 lines · Wei Liu

In commit d36a3734a ("xl: fix migration failure with xl migrate --debug"), message is printed to stderr for both debug mode and dryrun mode. That caused rdname() in xendomains fails to parse domain name since it's expecting input from xl's stdout.

So this patch separates those two cases. If xl is running in debug mode, then message is printed to stderr; if xl is running in dryrun mode and debug is not enabled, message is printed to stdout. This will fix xendomains and other scripts that use "xl create --dryrun", as well as not re-introducing the old bug fixed in d36a3734a.

Cc M A Young <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Konrad Wilk <[email protected]>

---
This is a regression, and this bug is so subtle that's a bit hard to debug from user's point of view. So I think this should go into 4.5.

Mark posted a workaround in <104017455.78913.1418434454763.JavaMail.yahoo@jws10624.mail.bf1.yahoo.com> but to be honest I don't think it's nice to have everyone patch their scripts in order to work around this.

---
 tools/libxl/xl_cmdimpl.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/libxl/xl_cmdimpl.c +0 -0
index 3737c7e..0a5f7c8 100644

tools/libxl/xl_cmdimpl.c static uint32_t create_domain(struct domain_create *dom_info) · line 2477

Quoted 7 lines
tools/libxl/xl_cmdimpl.c +2 -1
@@ -2472,8 +2472,10 @@ static uint32_t create_domain(struct domain_create *dom_info)
         }
     }
 
-    if (debug || dom_info->dryrun)
+    if (debug)
         printf_info(default_output_format, -1, &d_config, stderr);
+    if (!debug && dom_info->dryrun)

Could this 'else if (dom_info->dry_run)' ?

Quoted 4 lines

I know that semantically it is exactly the same as the 'if (!debug ..)' but it just "feels" more proper? Thought since you are the maintainer in that area - your opinion on how you want to do that is of course authoritive.

I don't have strong preference on this. I just happened to type in whatever style that flowed though my mind at that particular point. If Ian and you both feel strongly about this I can certainly resend. :-)

Wei.

Quoted 10 lines

Regardless,

Quoted 7 lines
tools/libxl/xl_cmdimpl.c +1 -0
+        printf_info(default_output_format, -1, &d_config, stdout);
 
     ret = 0;
     if (dom_info->dryrun)
Signature · 1 line
1.7.10.4
#3 lore raw
Quoted 45 lines · Wei Liu
Quoted 44 lines · Konrad Rzeszutek Wilk
Quoted 33 lines · Wei Liu

In commit d36a3734a ("xl: fix migration failure with xl migrate --debug"), message is printed to stderr for both debug mode and dryrun mode. That caused rdname() in xendomains fails to parse domain name since it's expecting input from xl's stdout.

So this patch separates those two cases. If xl is running in debug mode, then message is printed to stderr; if xl is running in dryrun mode and debug is not enabled, message is printed to stdout. This will fix xendomains and other scripts that use "xl create --dryrun", as well as not re-introducing the old bug fixed in d36a3734a.

Cc M A Young <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Konrad Wilk <[email protected]>

---
This is a regression, and this bug is so subtle that's a bit hard to debug from user's point of view. So I think this should go into 4.5.

Mark posted a workaround in <104017455.78913.1418434454763.JavaMail.yahoo@jws10624.mail.bf1.yahoo.com> but to be honest I don't think it's nice to have everyone patch their scripts in order to work around this.

---
 tools/libxl/xl_cmdimpl.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/libxl/xl_cmdimpl.c +0 -0
index 3737c7e..0a5f7c8 100644

tools/libxl/xl_cmdimpl.c static uint32_t create_domain(struct domain_create *dom_info) · line 2477

Quoted 7 lines
tools/libxl/xl_cmdimpl.c +2 -1
@@ -2472,8 +2472,10 @@ static uint32_t create_domain(struct domain_create *dom_info)
         }
     }
 
-    if (debug || dom_info->dryrun)
+    if (debug)
         printf_info(default_output_format, -1, &d_config, stderr);
+    if (!debug && dom_info->dryrun)

Could this 'else if (dom_info->dry_run)' ?

Quoted 8 lines
Quoted 4 lines

I know that semantically it is exactly the same as the 'if (!debug ..)' but it just "feels" more proper? Thought since you are the maintainer in that area - your opinion on how you want to do that is of course authoritive.

I don't have strong preference on this. I just happened to type in whatever style that flowed though my mind at that particular point. If Ian and you both feel strongly about this I can certainly resend. :-)

Lets wait to see what Ian says (or what he ends up checking in).

Quoted 13 lines

Wei.

Quoted 10 lines

Regardless,

Quoted 7 lines
tools/libxl/xl_cmdimpl.c +1 -0
+        printf_info(default_output_format, -1, &d_config, stdout);
 
     ret = 0;
     if (dom_info->dryrun)
Signature · 1 line
1.7.10.4
#5 lore raw
In reply to Wei Liu
Quoted 11 lines · Wei Liu

In commit d36a3734a ("xl: fix migration failure with xl migrate --debug"), message is printed to stderr for both debug mode and dryrun mode. That caused rdname() in xendomains fails to parse domain name since it's expecting input from xl's stdout.

So this patch separates those two cases. If xl is running in debug mode, then message is printed to stderr; if xl is running in dryrun mode and debug is not enabled, message is printed to stdout. This will fix xendomains and other scripts that use "xl create --dryrun", as well as not re-introducing the old bug fixed in d36a3734a.

Quoted 8 lines
Cc M A Young <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Konrad Wilk <[email protected]>

---
This is a regression, and this bug is so subtle that's a bit hard to debug from user's point of view. So I think this should go into 4.5.

Agreed.

Quoted 4 lines

Mark posted a workaround in <104017455.78913.1418434454763.JavaMail.yahoo@jws10624.mail.bf1.yahoo.com> but to be honest I don't think it's nice to have everyone patch their scripts in order to work around this.

Right.

Quoted 9 lines
---
 tools/libxl/xl_cmdimpl.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/libxl/xl_cmdimpl.c +0 -0
index 3737c7e..0a5f7c8 100644

tools/libxl/xl_cmdimpl.c static uint32_t create_domain(struct domain_create *dom_info) · line 2477

Quoted 7 lines
tools/libxl/xl_cmdimpl.c +2 -1
@@ -2472,8 +2472,10 @@ static uint32_t create_domain(struct domain_create *dom_info)
         }
     }
 
-    if (debug || dom_info->dryrun)
+    if (debug)
         printf_info(default_output_format, -1, &d_config, stderr);
+    if (!debug && dom_info->dryrun)
       else if ( dom_info->dry-run )

is the same (right?) and less thinking for the reader.

Or the whole thing could be just:

    if (debug || dom_info->dryrun)
          printf_info(default_output_format, -1, &d_config, debug ? stderr : stdout);

Less repetitive.

Ian.

#4 lore raw
In reply to Konrad Rzeszutek Wilk
Quoted 51 lines · Konrad Rzeszutek Wilk
Quoted 50 lines · Wei Liu
Quoted 48 lines · Konrad Rzeszutek Wilk
Quoted 33 lines · Wei Liu

In commit d36a3734a ("xl: fix migration failure with xl migrate --debug"), message is printed to stderr for both debug mode and dryrun mode. That caused rdname() in xendomains fails to parse domain name since it's expecting input from xl's stdout.

So this patch separates those two cases. If xl is running in debug mode, then message is printed to stderr; if xl is running in dryrun mode and debug is not enabled, message is printed to stdout. This will fix xendomains and other scripts that use "xl create --dryrun", as well as not re-introducing the old bug fixed in d36a3734a.

Cc M A Young <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Konrad Wilk <[email protected]>

---
This is a regression, and this bug is so subtle that's a bit hard to debug from user's point of view. So I think this should go into 4.5.

Mark posted a workaround in <104017455.78913.1418434454763.JavaMail.yahoo@jws10624.mail.bf1.yahoo.com> but to be honest I don't think it's nice to have everyone patch their scripts in order to work around this.

---
 tools/libxl/xl_cmdimpl.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/libxl/xl_cmdimpl.c +0 -0
index 3737c7e..0a5f7c8 100644

tools/libxl/xl_cmdimpl.c static uint32_t create_domain(struct domain_create *dom_info) · line 2477

Quoted 7 lines
tools/libxl/xl_cmdimpl.c +2 -1
@@ -2472,8 +2472,10 @@ static uint32_t create_domain(struct domain_create *dom_info)
         }
     }
 
-    if (debug || dom_info->dryrun)
+    if (debug)
         printf_info(default_output_format, -1, &d_config, stderr);
+    if (!debug && dom_info->dryrun)

Could this 'else if (dom_info->dry_run)' ?

I know that semantically it is exactly the same as the 'if (!debug ..)' but it just "feels" more proper? Thought since you are the maintainer in that area - your opinion on how you want to do that is of course authoritive.

Quoted 5 lines
Quoted 3 lines

I don't have strong preference on this. I just happened to type in whatever style that flowed though my mind at that particular point. If Ian and you both feel strongly about this I can certainly resend. :-)

Lets wait to see what Ian says (or what he ends up checking in).

I really ought to read the thread before replying. I do prefer the else if style, or the ternary operator one I also proposed.