All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] no-fork option for tapdisk2 debugging
@ 2011-06-21 13:29 Philipp Hahn
  2011-06-21 14:29 ` Ian Jackson
  0 siblings, 1 reply; 6+ messages in thread
From: Philipp Hahn @ 2011-06-21 13:29 UTC (permalink / raw)
  To: Xen-devel


[-- Attachment #1.1.1: Type: text/plain, Size: 661 bytes --]

Hello,

For debugging tapdisk2 it would be nice if forking into the background could 
be disabled by passing some command line argument. The attached patch adds 
such an option (-n).
The second patch re-indents four un-changed lines.
It would be nice if this could be included into the source core repository.

Sincerely
Philipp Hahn
-- 
Philipp Hahn           Open Source Software Engineer      hahn@univention.de
Univention GmbH        Linux for Your Business        fon: +49 421 22 232- 0
Mary-Somerville-Str.1  D-28359 Bremen                 fax: +49 421 22 232-99
                                                   http://www.univention.de/

[-- Attachment #1.1.2: tapdisk2.diff --]
[-- Type: text/x-diff, Size: 1521 bytes --]

Add option to disable forking

To simplify running tapdisk2 from a debugger, add an opttion "-n" to disable foring into the background.

Signed-off-by: Philipp Hahn <hahn@univention.de>
--- xen-4.0.1.orig/tools/blktap2/drivers/tapdisk2.c	2010-08-25 12:22:07.000000000 +0200
+++ xen-4.0.1/tools/blktap2/drivers/tapdisk2.c	2011-06-17 17:37:35.000000000 +0200
@@ -402,7 +402,7 @@ tapdisk2_wait_for_device(void)
 static void
 usage(const char *app, int err)
 {
-	fprintf(stderr, "usage: %s <-n file>\n", app);
+	fprintf(stderr, "usage: %s [-f] -n driver:file\n", app);
 	exit(err);
 }
 
@@ -411,10 +411,11 @@ main(int argc, char *argv[])
 {
 	int c;
 	char *params;
+	int do_fork = 1;
 
 	params = NULL;
 
-	while ((c = getopt(argc, argv, "n:s:h")) != -1) {
+	while ((c = getopt(argc, argv, "n:s:fh")) != -1) {
 		switch (c) {
 		case 'n':
 			params = optarg;
@@ -430,6 +431,9 @@ main(int argc, char *argv[])
 			exit(EXIT_FAILURE);
 #endif
 			break;
+		case 'f':
+			do_fork = 0;
+			break;
 		default:
 			usage(argv[0], EINVAL);
 		}
@@ -438,12 +442,17 @@ main(int argc, char *argv[])
 	if (!params || optind != argc)
 		usage(argv[0], EINVAL);
 
+	if (do_fork) {
 	if (pipe(channel) == -1) {
 		printf("pipe failed: %d\n", errno);
 		return errno;
 	}
+	} else {
+		channel[0] = dup(STDIN_FILENO);
+		channel[1] = dup(STDERR_FILENO);
+	}
 
-	switch (fork()) {
+	switch (do_fork ? fork() : 0) {
 	case -1:
 		printf("fork failed: %d\n", errno);
 		return errno;

[-- Attachment #1.1.3: tapdisk2_indent.diff --]
[-- Type: text/x-diff, Size: 682 bytes --]

Re-indent lines.

Re-indent lines after applying patch to add no-fork option.

Signed-off-by: Philipp Hahn <hahn@univention.de>
--- xen-4.0.1.orig/tools/blktap2/drivers/tapdisk2.c	2010-08-25 12:22:07.000000000 +0200
+++ xen-4.0.1/tools/blktap2/drivers/tapdisk2.c	2011-06-17 17:37:35.000000000 +0200
@@ -443,10 +443,10 @@ main(int argc, char *argv[])
 		usage(argv[0], EINVAL);
 
 	if (do_fork) {
-	if (pipe(channel) == -1) {
-		printf("pipe failed: %d\n", errno);
-		return errno;
-	}
+		if (pipe(channel) == -1) {
+			printf("pipe failed: %d\n", errno);
+			return errno;
+		}
 	} else {
 		channel[0] = dup(STDIN_FILENO);
 		channel[1] = dup(STDERR_FILENO);

[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

[-- Attachment #2: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] no-fork option for tapdisk2 debugging
  2011-06-21 13:29 [PATCH] no-fork option for tapdisk2 debugging Philipp Hahn
@ 2011-06-21 14:29 ` Ian Jackson
  2011-06-21 15:12   ` [PATCH v2] " Philipp Hahn
  0 siblings, 1 reply; 6+ messages in thread
From: Ian Jackson @ 2011-06-21 14:29 UTC (permalink / raw)
  To: Philipp Hahn; +Cc: Xen-devel

Philipp Hahn writes ("[Xen-devel] [PATCH] no-fork option for tapdisk2 debugging"):
> For debugging tapdisk2 it would be nice if forking into the background could 
> be disabled by passing some command line argument. The attached patch adds 
> such an option (-n).

This seems reasonable.

> The second patch re-indents four un-changed lines.

That should be folded into the first patch, which otherwise leaves the
indentation wrong.

> It would be nice if this could be included into the source core repository.

Also, you to add a Signed-off-by line to your patch to signify its
copyright status (see below).

Thanks,
Ian.

>From Documentation/SubmittingPatches in the Linux kernel tree:
 
        Developer's Certificate of Origin 1.1
 
        By making a contribution to this project, I certify that:
 
        (a) The contribution was created in whole or in part by me and I
            have the right to submit it under the open source license
            indicated in the file; or
 
        (b) The contribution is based upon previous work that, to the best
            of my knowledge, is covered under an appropriate open source
            license and I have the right under that license to submit that
            work with modifications, whether created in whole or in part
            by me, under the same open source license (unless I am
            permitted to submit under a different license), as indicated
            in the file; or
 
        (c) The contribution was provided directly to me by some other
            person who certified (a), (b) or (c) and I have not modified
            it.
 
        (d) I understand and agree that this project and the contribution
            are public and that a record of the contribution (including all
            personal information I submit with it, including my sign-off) is
            maintained indefinitely and may be redistributed consistent with
            this project or the open source license(s) involved.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] no-fork option for tapdisk2 debugging
  2011-06-21 14:29 ` Ian Jackson
@ 2011-06-21 15:12   ` Philipp Hahn
  2011-06-21 15:14     ` Ian Jackson
  0 siblings, 1 reply; 6+ messages in thread
From: Philipp Hahn @ 2011-06-21 15:12 UTC (permalink / raw)
  To: Ian Jackson; +Cc: Xen-devel


[-- Attachment #1.1.1: Type: text/plain, Size: 886 bytes --]

Hello Ian,

Am Dienstag 21 Juni 2011 16:29:20 schrieb Ian Jackson:
> That should be folded into the first patch, which otherwise leaves the
> indentation wrong.

Done. I submitted it as an extra patch only for simplifying review of the 
additional implementation.

> Also, you to add a Signed-off-by line to your patch to signify its
> copyright status (see below).

The original patch already contained the Signed-off-line, since I knew you (or 
somebody else) would be asking for it ;-) If more is needed, please ask 
again.

Sincerely
Philipp Hahn
-- 
Philipp Hahn           Open Source Software Engineer      hahn@univention.de
Univention GmbH        Linux for Your Business        fon: +49 421 22 232- 0
Mary-Somerville-Str.1  D-28359 Bremen                 fax: +49 421 22 232-99
                                                   http://www.univention.de/

[-- Attachment #1.1.2: tapdisk2.diff --]
[-- Type: text/x-diff, Size: 1676 bytes --]

no-fork option for tapdisk2 debugging.

To simplify running tapdisk2 from a debugger, add an opttion "-n" to disable foring into the background.

Signed-off-by: Philipp Hahn <hahn@univention.de>
--
[v2] fold extra indention patch into patch.
--- xen-4.0.1.orig/tools/blktap2/drivers/tapdisk2.c	2010-08-25 12:22:07.000000000 +0200
+++ xen-4.0.1/tools/blktap2/drivers/tapdisk2.c	2011-06-17 17:37:35.000000000 +0200
@@ -402,7 +402,7 @@ tapdisk2_wait_for_device(void)
 static void
 usage(const char *app, int err)
 {
-	fprintf(stderr, "usage: %s <-n file>\n", app);
+	fprintf(stderr, "usage: %s [-f] -n driver:file\n", app);
 	exit(err);
 }
 
@@ -411,10 +411,11 @@ main(int argc, char *argv[])
 {
 	int c;
 	char *params;
+	int do_fork = 1;
 
 	params = NULL;
 
-	while ((c = getopt(argc, argv, "n:s:h")) != -1) {
+	while ((c = getopt(argc, argv, "n:s:fh")) != -1) {
 		switch (c) {
 		case 'n':
 			params = optarg;
@@ -430,6 +431,9 @@ main(int argc, char *argv[])
 			exit(EXIT_FAILURE);
 #endif
 			break;
+		case 'f':
+			do_fork = 0;
+			break;
 		default:
 			usage(argv[0], EINVAL);
 		}
@@ -438,12 +442,17 @@ main(int argc, char *argv[])
 	if (!params || optind != argc)
 		usage(argv[0], EINVAL);
 
-	if (pipe(channel) == -1) {
-		printf("pipe failed: %d\n", errno);
-		return errno;
-	}
+	if (do_fork) {
+		if (pipe(channel) == -1) {
+			printf("pipe failed: %d\n", errno);
+			return errno;
+		}
+	} else {
+		channel[0] = dup(STDIN_FILENO);
+		channel[1] = dup(STDERR_FILENO);
+	}
 
-	switch (fork()) {
+	switch (do_fork ? fork() : 0) {
 	case -1:
 		printf("fork failed: %d\n", errno);
 		return errno;

[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

[-- Attachment #2: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] no-fork option for tapdisk2 debugging
  2011-06-21 15:12   ` [PATCH v2] " Philipp Hahn
@ 2011-06-21 15:14     ` Ian Jackson
  2011-06-21 15:40       ` Philipp Hahn
  0 siblings, 1 reply; 6+ messages in thread
From: Ian Jackson @ 2011-06-21 15:14 UTC (permalink / raw)
  To: Philipp Hahn; +Cc: Xen-devel

Philipp Hahn writes ("Re: [Xen-devel] [PATCH v2] no-fork option for tapdisk2 debugging"):
> Am Dienstag 21 Juni 2011 16:29:20 schrieb Ian Jackson:
> > That should be folded into the first patch, which otherwise leaves the
> > indentation wrong.
> 
> Done. I submitted it as an extra patch only for simplifying review of the 
> additional implementation.

Thanks, but we have tools which can suppress whitespace changes when
showing us diffs :-).

> > Also, you to add a Signed-off-by line to your patch to signify its
> > copyright status (see below).
> 
> The original patch already contained the Signed-off-line, since I
> knew you (or somebody else) would be asking for it ;-) If more is
> needed, please ask again.

Sorry, I must have missed that.

But I'm afraid your patch doesn't apply cleanly to xen-unstable tip:

patching file tools/blktap2/drivers/tapdisk2.c
Hunk #1 FAILED at 402.
Hunk #2 FAILED at 411.
Hunk #3 succeeded at 72 (offset -359 lines).
Hunk #4 FAILED at 83.
3 out of 4 hunks FAILED -- saving rejects to file tools/blktap2/drivers/tapdisk2.c.rej

Ian.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] no-fork option for tapdisk2 debugging
  2011-06-21 15:14     ` Ian Jackson
@ 2011-06-21 15:40       ` Philipp Hahn
  2011-06-21 15:53         ` Ian Jackson
  0 siblings, 1 reply; 6+ messages in thread
From: Philipp Hahn @ 2011-06-21 15:40 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson


[-- Attachment #1.1.1: Type: text/plain, Size: 650 bytes --]

Hello Ian,

On Tuesday 21 June 2011 17:14:28 Ian Jackson wrote:
> But I'm afraid your patch doesn't apply cleanly to xen-unstable tip:

Seems like someone other also missed that option and added it already. So me 
patch is mostly obsolete, but perhaps a little bit of documentation would be 
okay.

Sincerely
Philipp Hahn
-- 
Philipp Hahn           Open Source Software Engineer      hahn@univention.de
Univention GmbH        Linux for Your Business        fon: +49 421 22 232- 0
Mary-Somerville-Str.1  D-28359 Bremen                 fax: +49 421 22 232-99
                                                   http://www.univention.de/

[-- Attachment #1.1.2: Add documentation to no-daemon-option.diff --]
[-- Type: text/plain, Size: 868 bytes --]

Document -D option for no-daemonize.                                                                                                                                                
                                                                                                                                                                                    
Signed-off-by: Philipp Hahn <hahn@univention.de>
diff -r eca057e4475c tools/blktap2/drivers/tapdisk2.c
--- a/tools/blktap2/drivers/tapdisk2.c  Fri Jun 17 08:08:13 2011 +0100
+++ b/tools/blktap2/drivers/tapdisk2.c  Tue Jun 21 17:35:58 2011 +0200
@@ -42,7 +42,7 @@
 static void
 usage(const char *app, int err)
 {
-       fprintf(stderr, "usage: %s <-u uuid> <-c control socket>\n", app);
+       fprintf(stderr, "usage: %s [-D] <-u uuid> <-c control socket>\n", app);
        exit(err);
 }
 

[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

[-- Attachment #2: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] no-fork option for tapdisk2 debugging
  2011-06-21 15:40       ` Philipp Hahn
@ 2011-06-21 15:53         ` Ian Jackson
  0 siblings, 0 replies; 6+ messages in thread
From: Ian Jackson @ 2011-06-21 15:53 UTC (permalink / raw)
  To: Philipp Hahn; +Cc: xen-devel, Ian Jackson

Philipp Hahn writes ("Re: [Xen-devel] [PATCH v2] no-fork option for tapdisk2 debugging"):
> On Tuesday 21 June 2011 17:14:28 Ian Jackson wrote:
> > But I'm afraid your patch doesn't apply cleanly to xen-unstable tip:
> 
> Seems like someone other also missed that option and added it already. So me 
> patch is mostly obsolete, but perhaps a little bit of documentation would be 
> okay.

Right, thanks, I have applied your patch.  (I had to do this by hand
because something in the Citrix email system mangled your tabs.  Not
your fault.)

Ian.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-06-21 15:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-21 13:29 [PATCH] no-fork option for tapdisk2 debugging Philipp Hahn
2011-06-21 14:29 ` Ian Jackson
2011-06-21 15:12   ` [PATCH v2] " Philipp Hahn
2011-06-21 15:14     ` Ian Jackson
2011-06-21 15:40       ` Philipp Hahn
2011-06-21 15:53         ` Ian Jackson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.