Description of problem:
When I send data from WinXP guest to Fedora 17 host the order of the messages is not kept. Also some messages are sent multiple times.
Version-Release number of selected component (if applicable):
Guest:
Windows XP SP3
virtio-win-0.1-30
Host:
Fedora 17,
kernel 3.5.3-1.fc17.x86_64
qemu-kvm-1.0.1-1.fc17.x86_64
How reproducible:
lots of changed messages and 0.01-0.1% of messages is sent multiple times.
Steps to Reproduce:
1. Boot guest with virtio_serialport
2. Start sending 2 messages ('a', 'b') in a loop
3. Receive the data and watch the differences
Actual results:
The message order is not kept. (aaabbababbababbbab)
the number of received 'a' or 'b' is sometimes higher than number of sent 'a' and 'b'.
Expected results:
Receive what I sent in the right order. (abababababababab)

Keep in mind that some of the data are corrupted - see bug: https://bugzilla.redhat.com/show_bug.cgi?id=858674 for details.
This issue is replicable using smp=1 and smp=2 (using smp=2 leads to more frequent corruptions).
I reproduced this using host chardev unix socket (path=/tmp/port0) and posix (host=0.0.0.0).
time.sleep() > 0.001 between WriteFile solves this issue. When I use time.sleep() < 0.001 (included 0 sleep) doesn't help.
for _ in range(512):
WriteFile(port, 'a')
time.sleep(sleep_time)
WriteFile(port, 'b')
time.sleep(sleep_time)
I checked the outputs and non of the WriteFile failed.

About the multiple messages, the script above (for _ in range(512)) should produce 512*'a' and 512*'b'. It results usually around 485-535*'a' and 485-535*'b' with total length over 1024 (1030-1050).
S ome of those characers are corrupted so the total number of received items might be significatnly over the number of the sent characters.

Hi Vadim,
very nice. I tried "ab"*4096 without any corruptions and mis-queued characters. Also with this patch I don't have problems with missing ports anymore.
I tried more tests and the queue seems fine, although some characters are corrupted (bz 858674) - https://bugzilla.redhat.com/show_bug.cgi?id=858674

1) host-> guest - no errors observed
on host:
I created a file using 'ab'*10240 (so basically lots of 'ababababab') and executed this command:
while :; do cat /tmp/huge-ab-file | sudo socat /tmp/virtio_port-vs1-20120924-093501-0yc6VTGu - ; done
on guest:
I executed python and run a loop which received 2 characters and verified, whether it's 'ab':
from ctypes import *
from win32file import *
import time
port = CreateFile("\\\\.\\com.redhat.spice.0", GENERIC_WRITE | GENERIC_READ, 0, None, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, None)
i = 0
while True:
if not i % 1024:
print i
try:
if ReadFile(port, 2)[1] != "ab":
print "ERROR: %s" % time.time()
except error:
continue
i += 1
(first I tried it without 'i' to maximize the stress, then I added it to verify I'm not only getting receive errors. The try-catch is necessarily because when there are no data I get an read error...)
Anyway this worked brilliantly, so the host->guest part works fine.

This message is a reminder that Fedora 17 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 17. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as WONTFIX if it remains open with a Fedora
'version' of '17'.
Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version prior to Fedora 17's end of life.
Bug Reporter: Thank you for reporting this issue and we are sorry that
we may not be able to fix it before Fedora 17 is end of life. If you
would still like to see this bug fixed and are able to reproduce it
against a later version of Fedora, you are encouraged change the
'version' to a later Fedora version prior to Fedora 17's end of life.
Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.

Fedora 17 changed to end-of-life (EOL) status on 2013-07-30. Fedora 17 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.
If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version.
Thank you for reporting this bug and we are sorry it could not be fixed.

Yes, the situation in virtio-win-prewehql-67 improved a lot. I haven't encounter data corruption while running the test for 1 our. So I think this bug status should be NEXTRELEASE. (please correct me if I'm wrong)