On 01/23/2013 11:47 PM, Luiz Capitulino wrote:
On Wed, 23 Jan 2013 17:06:09 +0800
Lei Li <li...@linux.vnet.ibm.com> wrote:
Hi Anthony,
Resubmit this series with your comments squashed in and Luiz's new
comments fixed up. I will push console command part in another thread.
There are two bugs in this series. QEMU started with:
# qemu [...] -chardev memory,id=foo,maxcapacity=4
This explodes:
(qemu) memchar_read foo 10
I'd expect to read '3uiz' in the steps below:
(qemu) memchar_write foo luiz3
(qemu) memchar_read foo 10
uiz3,
(qemu)
Hi Luiz,
Thanks very much for your time to test this series!
I think the result shows how this algorithm works...
Initialize the buffer with maxcapacity 4,
CirMemCharDriver->size = 4;
This first time you write 5 bytes to the buffer, so
producer = 5;
consumer = 0; but (producer - consumer) > size:
-> consumer = (producer - size) = 1;
Then the read action, want to read 10 bytes, but the real
size would be adjusted to 4 since in qmp_memchar_read
will check if the size wanted to read is larger than the
current count in the buffer. (count = producer - consumer)
So the read would start at the second bytes in this buffer
for that the consumer's value is 1, which is 'u' as the oldest
data (Which is circular buffer does, always read (consumer) the
oldest data in the buffer). At last, read 4 bytes and return
'uiz3'.
-------------------------
| 3 | u | i | z |
-------------------------
^
|
prod
cons
I hope that I make it clear. :)
Also, please, wait for a discussion to settle before sending a new version,
otherwise we'll reach V50 and this won't be merged...
--
Lei