Re: [Qemu-devel] About the trace framework

2017-07-26 Thread Wang Dong



On 07/14/2017 09:25 PM, Stefan Hajnoczi wrote:

On Thu, Jul 13, 2017 at 04:01:09PM +0800, Wang Dong wrote:

On 07/10/2017 08:40 PM, Stefan Hajnoczi wrote:

On Mon, Jul 10, 2017 at 01:24:23PM +0800, Xie Changlong wrote:

在 7/9/2017 5:57 PM, Wang Dong 写道:

Hi,

I am new to QEMU. But I got some problem so that  I want to figure it out.

So I try to debug qemu to see what happened.

And I found trace framework. I think this will help me understand the
point.

So I compiled qemu with option:

## *--enable-trace-backends=simple*

And did as the docs/tracing.txt tell. But when I execute the example
command in it, nothing just happens.

*./scripts/simpletrace.py trace-events-all trace-xx(my trace file
produced by qemu)
I am not sure what happened. Just ask this.
Any clue will be appreciated. Thanks in advance.
*


Did you set *trace-event*? I've encountered this issue in the past :)
(qemu) help trace-event
trace-event name on|off -- changes status of a specific trace event
(qemu) info trace-events

Yes, you need to enable specific trace events that you are interested
in.  'trace-event' does that from the QEMU monitor at runtime.  If you'd
rather keep a file with a list of events to enable:

$ echo bdrv_aio_readv   > /tmp/events
$ echo bdrv_aio_writev >> /tmp/events
$ qemu -trace events=/tmp/events ... # your normal QEMU invocation

It's hard to know what is missing without seeing your QEMU command-line
and monitor commands you used.

Stefan

I thought the example in doc was enabled by default.

Thanks for your reply. Below is my command:
When to compile:

./configure --enable-debug --enable-trace-backends=simple

$ echo bdrv_aio_readv   > /tmp/events
$ echo bdrv_aio_writev >> /tmp/events


qemu [...]

-chardev socket,id=mon1,host=localhost,port=,server,nowait \
-mon chardev=mon1,mode=control,pretty=on \
-trace events=/tmp/events


Did I miss something?

Recent QEMU versions do not have bdrv_aio_readv/bdrv_aio_writev trace
events, so you may not get any output.

Which events do you actually want to trace?

I will update the example in docs/devel/tracing.txt with trace events
that are more likely to be triggered.

Stefan

Hi Stefan,
Thanks for the reply and your patch.
I just want to learn qemu with debugging.
I think it will be easier for me to learn the detail with this 
trace framework.


So I just tried it. I will try it again with your updated.


--
Best regards. Wang Dong




Re: [Qemu-devel] About the trace framework

2017-07-13 Thread Wang Dong



On 07/11/2017 05:39 PM, Xie Changlong wrote:

在 7/11/2017 9:33 AM, Wang Dong 写道:



On 07/10/2017 01:24 PM, Xie Changlong wrote:

在 7/9/2017 5:57 PM, Wang Dong 写道:

Hi,

I am new to QEMU. But I got some problem so that  I want to figure 
it out.


So I try to debug qemu to see what happened.

And I found trace framework. I think this will help me understand 
the point.


So I compiled qemu with option:

## *--enable-trace-backends=simple*

And did as the docs/tracing.txt tell. But when I execute the 
example command in it, nothing just happens.


*./scripts/simpletrace.py trace-events-all trace-xx(my trace 
file produced by qemu)

I am not sure what happened. Just ask this.
Any clue will be appreciated. Thanks in advance.
*



Did you set *trace-event*? I've encountered this issue in the past :)
(qemu) help trace-event
trace-event name on|off -- changes status of a specific trace event
(qemu) info trace-events
yes, I set it. I just did as the docs told. If this does not work or 
misses something, it should be corrected I think.


Have you also tried out the examples in docs? how did you do that? I 


Yes, just follow the docs. No something special.


think I misses some. Could you tell more about
it? Thanks.


You should confirm the *trace-event*s you set are really triggered by 
qemu. Use gdb breakpoint to verify it is a good choice.





OK, I will try that. Thanks for your advice.

--
Best regards. Wang Dong




Re: [Qemu-devel] About the trace framework

2017-07-13 Thread Wang Dong



On 07/10/2017 08:40 PM, Stefan Hajnoczi wrote:

On Mon, Jul 10, 2017 at 01:24:23PM +0800, Xie Changlong wrote:

在 7/9/2017 5:57 PM, Wang Dong 写道:

Hi,

I am new to QEMU. But I got some problem so that  I want to figure it out.

So I try to debug qemu to see what happened.

And I found trace framework. I think this will help me understand the
point.

So I compiled qemu with option:

## *--enable-trace-backends=simple*

And did as the docs/tracing.txt tell. But when I execute the example
command in it, nothing just happens.

*./scripts/simpletrace.py trace-events-all trace-xx(my trace file
produced by qemu)
I am not sure what happened. Just ask this.
Any clue will be appreciated. Thanks in advance.
*


Did you set *trace-event*? I've encountered this issue in the past :)
(qemu) help trace-event
trace-event name on|off -- changes status of a specific trace event
(qemu) info trace-events

Yes, you need to enable specific trace events that you are interested
in.  'trace-event' does that from the QEMU monitor at runtime.  If you'd
rather keep a file with a list of events to enable:

   $ echo bdrv_aio_readv   > /tmp/events
   $ echo bdrv_aio_writev >> /tmp/events
   $ qemu -trace events=/tmp/events ... # your normal QEMU invocation

It's hard to know what is missing without seeing your QEMU command-line
and monitor commands you used.

Stefan


I thought the example in doc was enabled by default.

Thanks for your reply. Below is my command:
When to compile:

./configure --enable-debug --enable-trace-backends=simple

$ echo bdrv_aio_readv   > /tmp/events
$ echo bdrv_aio_writev >> /tmp/events


qemu [...]

-chardev socket,id=mon1,host=localhost,port=,server,nowait \
-mon chardev=mon1,mode=control,pretty=on \
-trace events=/tmp/events


Did I miss something?

--
Best regards. Wang Dong




Re: [Qemu-devel] About the trace framework

2017-07-10 Thread Wang Dong



On 07/10/2017 01:24 PM, Xie Changlong wrote:

在 7/9/2017 5:57 PM, Wang Dong 写道:

Hi,

I am new to QEMU. But I got some problem so that  I want to figure it 
out.


So I try to debug qemu to see what happened.

And I found trace framework. I think this will help me understand the 
point.


So I compiled qemu with option:

## *--enable-trace-backends=simple*

And did as the docs/tracing.txt tell. But when I execute the example 
command in it, nothing just happens.


*./scripts/simpletrace.py trace-events-all trace-xx(my trace file 
produced by qemu)

I am not sure what happened. Just ask this.
Any clue will be appreciated. Thanks in advance.
*



Did you set *trace-event*? I've encountered this issue in the past :)
(qemu) help trace-event
trace-event name on|off -- changes status of a specific trace event
(qemu) info trace-events
yes, I set it. I just did as the docs told. If this does not work or 
misses something, it should be corrected I think.


Have you also tried out the examples in docs? how did you do that? I 
think I misses some. Could you tell more about

it? Thanks.

--
Best regards. Wang Dong




[Qemu-devel] About the trace framework

2017-07-09 Thread Wang Dong

Hi,

I am new to QEMU. But I got some problem so that  I want to figure it out.

So I try to debug qemu to see what happened.

And I found trace framework. I think this will help me understand the point.

So I compiled qemu with option:

## *--enable-trace-backends=simple*

And did as the docs/tracing.txt tell. But when I execute the example 
command in it, nothing just happens.


*./scripts/simpletrace.py trace-events-all trace-xx(my trace file 
produced by qemu)

I am not sure what happened. Just ask this.
Any clue will be appreciated. Thanks in advance.
*

--
Best regards.

Wang Dong



[Qemu-devel] when the device property is called?

2017-06-12 Thread Wang Dong

Hi,

I am newbie to qemu. Recently, I am reading the code and found one question.

I can see some property function is added to the object. But I wonder 
when these


property functions are called or triggered. When I try to trace them, 
only the initialization


is found. I found some unclear lines in the doc, I can not figure out 
the details.


*"Device properties in QOM are bound to devices and are implemented by 
closures provided by the device.

***

*A Visitor is passed to the closure which effectively allows properties 
to be set/get through native C types.***


*Mapping to any other type of representation (string or otherwise) is 
done by a Visitor with no knowledge of the device or property.***


 "

I also found this property function has something to do with the 
*Visitor*, and I trace the function *x86_cpu_get_crash_info_qom* along with


Visitor. And I found that these crash information is finally read out to 
log file along with this visitor. *But **still I have no idea when this **

**x86_cpu_get_crash_info_qom is triggered.
*

But as I found that the cpu class is initialized with an another 
function *cc->get_crash_info = x86_cpu_get_crash_info*


And with this function, the crash information will also be put out to 
log file. And this function will return a crash information struct to 
*qemu_system_**guest**_panicked*, which will then print the crash info 
to log file too.


*I wonder what is the difference between them? And when the property 
function is called?

*

*
*

*Any clue will be very appreciated. Thanks in advance.
*

Thanks in advance.



--
Best regards.

Wang Dong



Re: [Qemu-devel] new to qemu with a simple question

2017-05-25 Thread Wang Dong



On 05/24/2017 09:30 PM, Eric Blake wrote:

On 05/23/2017 09:56 PM, Wang Dong wrote:

Hi guys,

I am new to qemu. But I need do some job in it right now.

When I try read qmp code. I found a interesting part against it.

Some C source code is generate from json file.

I wonder why this? What is the benefits of this?

Boring and repetitive code that is easy to typo is best written by
computer, which excels at boring and repetitive tasks.  Writing our
description in a more concise higher language and generating C code from
that lets us focus on the actual design, rather than the mundane
correctness of the code implementing the design.

It's the same reason that people use bison/yacc rather than hand-written
parsers for complex grammars - you isolate the correctness of the code
to the correctness of the generator, and free yourself to now only have
to worry about the bigger picture of the input you feed to the
generator.  And on another level, it's why we write programs in C
instead of assembly.  Abstraction is good.


Thanks for your reply. I really appreciate it.

--
Best regards. Wang Dong




Re: [Qemu-devel] new to qemu with a simple question

2017-05-24 Thread Wang Dong

Thank you, Fam.


On 05/24/2017 11:11 AM, Fam Zheng wrote:

On Wed, 05/24 10:56, Wang Dong wrote:

Some C source code is generate from json file.

I wonder why this? What is the benefits of this?

This allows you to concentrate on the high level semantics of the QMP API,
without worrying about C syntax and structural code here and there. In one
word, more conciseness and little code duplication.

If done in C, it would be much more lines of code and hardly readable.

Fam



--
Best regards. Wang Dong




[Qemu-devel] new to qemu with a simple question

2017-05-23 Thread Wang Dong


Hi guys,

I am new to qemu. But I need do some job in it right now.

When I try read qmp code. I found a interesting part against it.

Some C source code is generate from json file.

I wonder why this? What is the benefits of this?

Thanks in advance.


--
Best regards. Wang Dong