qemu-io: add option to enable tracing
It can be useful to enable QEMU tracing when trying out block layer interfaces via qemu-io. Tracing can be enabled using the new -T FILE option where the given file contains a list of trace events to enable (just like the qemu --trace events=FILE option). $ echo qemu_vfree >my-events $ ./qemu-io -T my-events ... Remember to use ./configure --enable-trace-backend=BACKEND when building qemu-io. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
		
							parent
							
								
									3948d1d487
								
							
						
					
					
						commit
						d7bb72c83c
					
				
							
								
								
									
										10
									
								
								qemu-io.c
								
								
								
								
							
							
						
						
									
										10
									
								
								qemu-io.c
								
								
								
								
							| 
						 | 
					@ -17,6 +17,7 @@
 | 
				
			||||||
#include "qemu-common.h"
 | 
					#include "qemu-common.h"
 | 
				
			||||||
#include "block_int.h"
 | 
					#include "block_int.h"
 | 
				
			||||||
#include "cmd.h"
 | 
					#include "cmd.h"
 | 
				
			||||||
 | 
					#include "trace/control.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define VERSION	"0.0.1"
 | 
					#define VERSION	"0.0.1"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1783,6 +1784,7 @@ static void usage(const char *name)
 | 
				
			||||||
"  -g, --growable       allow file to grow (only applies to protocols)\n"
 | 
					"  -g, --growable       allow file to grow (only applies to protocols)\n"
 | 
				
			||||||
"  -m, --misalign       misalign allocations for O_DIRECT\n"
 | 
					"  -m, --misalign       misalign allocations for O_DIRECT\n"
 | 
				
			||||||
"  -k, --native-aio     use kernel AIO implementation (on Linux only)\n"
 | 
					"  -k, --native-aio     use kernel AIO implementation (on Linux only)\n"
 | 
				
			||||||
 | 
					"  -T, --trace FILE     enable trace events listed in the given file\n"
 | 
				
			||||||
"  -h, --help           display this help and exit\n"
 | 
					"  -h, --help           display this help and exit\n"
 | 
				
			||||||
"  -V, --version        output version information and exit\n"
 | 
					"  -V, --version        output version information and exit\n"
 | 
				
			||||||
"\n",
 | 
					"\n",
 | 
				
			||||||
| 
						 | 
					@ -1794,7 +1796,7 @@ int main(int argc, char **argv)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int readonly = 0;
 | 
					    int readonly = 0;
 | 
				
			||||||
    int growable = 0;
 | 
					    int growable = 0;
 | 
				
			||||||
    const char *sopt = "hVc:rsnmgk";
 | 
					    const char *sopt = "hVc:rsnmgkT:";
 | 
				
			||||||
    const struct option lopt[] = {
 | 
					    const struct option lopt[] = {
 | 
				
			||||||
        { "help", 0, NULL, 'h' },
 | 
					        { "help", 0, NULL, 'h' },
 | 
				
			||||||
        { "version", 0, NULL, 'V' },
 | 
					        { "version", 0, NULL, 'V' },
 | 
				
			||||||
| 
						 | 
					@ -1806,6 +1808,7 @@ int main(int argc, char **argv)
 | 
				
			||||||
        { "misalign", 0, NULL, 'm' },
 | 
					        { "misalign", 0, NULL, 'm' },
 | 
				
			||||||
        { "growable", 0, NULL, 'g' },
 | 
					        { "growable", 0, NULL, 'g' },
 | 
				
			||||||
        { "native-aio", 0, NULL, 'k' },
 | 
					        { "native-aio", 0, NULL, 'k' },
 | 
				
			||||||
 | 
					        { "trace", 1, NULL, 'T' },
 | 
				
			||||||
        { NULL, 0, NULL, 0 }
 | 
					        { NULL, 0, NULL, 0 }
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
    int c;
 | 
					    int c;
 | 
				
			||||||
| 
						 | 
					@ -1837,6 +1840,11 @@ int main(int argc, char **argv)
 | 
				
			||||||
        case 'k':
 | 
					        case 'k':
 | 
				
			||||||
            flags |= BDRV_O_NATIVE_AIO;
 | 
					            flags |= BDRV_O_NATIVE_AIO;
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
 | 
					        case 'T':
 | 
				
			||||||
 | 
					            if (!trace_backend_init(optarg, NULL)) {
 | 
				
			||||||
 | 
					                exit(1); /* error message will have been printed */
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
        case 'V':
 | 
					        case 'V':
 | 
				
			||||||
            printf("%s version %s\n", progname, VERSION);
 | 
					            printf("%s version %s\n", progname, VERSION);
 | 
				
			||||||
            exit(0);
 | 
					            exit(0);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue