qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Dietrich Lauter <dd_l@inbox.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] Bug report: Windows and serial port lager than COM9
Date: Mon, 30 Mar 2009 01:23:58 -0800	[thread overview]
Message-ID: <EED55D3A2EE.000000A2dd_l@inbox.com> (raw)

Hi,

I run into a smaller bug using QEMU (0.10.1) on Windows. I was able to track down the issue and also found a solution. I want to share with you this fix. I hope I did it in the proper way, so you might integrate it.



Solution:

I made a change in the function "win_chr_init(...)" of the source file "qemu-char.c" . I took parts from the function "win_chr_pipe_init(...)" to implement the fix, as a pipe needs to be open using a similar name format than for serial ports larger than COM9.

The output of the a diff looks like the following:
$ diff qemu-char.c.ORG qemu-char.c    
1389a1390
>     char openname[256];
1402c1403,1404
<     s->hcom = CreateFile(filename, GENERIC_READ|GENERIC_WRITE, 0, NULL,
---
>     snprintf(openname, sizeof(openname), "\\\\.\\%s", filename);
>     s->hcom = CreateFile(openname, GENERIC_READ|GENERIC_WRITE, 0, NULL,



Background:

I had tested the ARM-Emulator from QEMU using the parameter "-serial" to connect to one of my virutal serial ports (com0com). The port, I wanted to use, has the name "COM50:". When I started the emulator using command "qemu-system-arm ... -serial COM50" I got the following error message:
  Failed CreateFile (2)
  qemu: could not open serial device 'COM50'

Reading the definition for the CreateFile function, I saw that for serial ports lager than COM9 the format of FileName should be in a specific format e.g. "\\.\COM10". This specific handling is also described in the following article:
HOWTO: Specify Serial Ports Larger than COM9 (http://support.microsoft.com/kb/115831)


Kind regards,

Dietrich

PS: That's my first posting ... so please let me known if I was doing something wrong.



=== (new) qemu-char.c ===
...
static int win_chr_init(CharDriverState *chr, const char *filename)
{
    WinCharState *s = chr->opaque;
    COMMCONFIG comcfg;
    COMMTIMEOUTS cto = { 0, 0, 0, 0, 0};
    COMSTAT comstat;
    DWORD size;
    DWORD err;
    char openname[256];

    s->hsend = CreateEvent(NULL, TRUE, FALSE, NULL);
    if (!s->hsend) {
        fprintf(stderr, "Failed CreateEvent\n");
        goto fail;
    }
    s->hrecv = CreateEvent(NULL, TRUE, FALSE, NULL);
    if (!s->hrecv) {
        fprintf(stderr, "Failed CreateEvent\n");
        goto fail;
    }

    snprintf(openname, sizeof(openname), "\\\\.\\%s", filename);
    s->hcom = CreateFile(openname, GENERIC_READ|GENERIC_WRITE, 0, NULL,
                      OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0);
...

                 reply	other threads:[~2009-03-30 10:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=EED55D3A2EE.000000A2dd_l@inbox.com \
    --to=dd_l@inbox.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).