From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GuZ1D-0006e6-F3 for qemu-devel@nongnu.org; Wed, 13 Dec 2006 13:39:51 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GuZ1A-0006bo-Q6 for qemu-devel@nongnu.org; Wed, 13 Dec 2006 13:39:50 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GuZ1A-0006bd-Db for qemu-devel@nongnu.org; Wed, 13 Dec 2006 13:39:48 -0500 Received: from [209.85.132.244] (helo=an-out-0708.google.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GuZ1A-0003ej-8d for qemu-devel@nongnu.org; Wed, 13 Dec 2006 13:39:48 -0500 Received: by an-out-0708.google.com with SMTP id d40so84043and for ; Wed, 13 Dec 2006 10:39:47 -0800 (PST) Message-ID: Date: Wed, 13 Dec 2006 10:39:45 -0800 From: "Ed Swierk" Sender: eswierk@gmail.com MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_174889_7168605.1166035185642" Subject: [Qemu-devel] Unidirectional pipe support Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org ------=_Part_174889_7168605.1166035185642 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline qemu allows redirecting the monitor to a named pipe (fifo): if you specify "-monitor pipe:/my/fifo", it opens "/my/fifo" and uses it for communication in both directions. Unfortunately pipes are unidirectional on Linux. The pipe(7) man page says: "Portability notes: On some systems (but not Linux), pipes are bidirectional: data can be transmitted in both directions between the pipe ends. According to POSIX.1-2001, pipes only need to be unidirectional. Portable applications should avoid reliance on bidirectional pipe semantics." When qemu writes into the pipe, it immediately reads back what it just wrote and treats it as a monitor command, endlessly breathing its own exhaust. The attached patch changes qemu to first try opening a pair of pipes, "/my/fifo.in" and "/my/fifo.out", and uses each to communicate in a single direction. If either file cannot be opened, it reverts to the current behavior, using "/my/fifo" bidirectionally. --Ed ------=_Part_174889_7168605.1166035185642 Content-Type: text/x-patch; name=qemu-pipe-pair.patch; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: base64 X-Attachment-Id: f_evo362h6 Content-Disposition: attachment; filename="qemu-pipe-pair.patch" SW5kZXg6IHFlbXUtMC44LjIvdmwuYwo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBxZW11LTAuOC4yLm9yaWcvdmwu YworKysgcWVtdS0wLjguMi92bC5jCkBAIC0xMjg1LDEyICsxMjg1LDE5IEBAIENoYXJEcml2ZXJT dGF0ZSAqcWVtdV9jaHJfb3Blbl9maWxlX291dCgKIAogQ2hhckRyaXZlclN0YXRlICpxZW11X2No cl9vcGVuX3BpcGUoY29uc3QgY2hhciAqZmlsZW5hbWUpCiB7Ci0gICAgaW50IGZkOworICAgIGlu dCBmZF9pbiwgZmRfb3V0OworICAgIGNoYXIgZmlsZW5hbWVfaW5bMjU2XSwgZmlsZW5hbWVfb3V0 WzI1Nl07CiAKLSAgICBmZCA9IG9wZW4oZmlsZW5hbWUsIE9fUkRXUiB8IE9fQklOQVJZKTsKLSAg ICBpZiAoZmQgPCAwKQotICAgICAgICByZXR1cm4gTlVMTDsKLSAgICByZXR1cm4gcWVtdV9jaHJf b3Blbl9mZChmZCwgZmQpOworICAgIHNucHJpbnRmKGZpbGVuYW1lX2luLCAyNTYsICIlcy5pbiIs IGZpbGVuYW1lKTsKKyAgICBzbnByaW50ZihmaWxlbmFtZV9vdXQsIDI1NiwgIiVzLm91dCIsIGZp bGVuYW1lKTsKKyAgICBmZF9pbiA9IG9wZW4oZmlsZW5hbWVfaW4sIE9fUkRXUiB8IE9fQklOQVJZ KTsKKyAgICBmZF9vdXQgPSBvcGVuKGZpbGVuYW1lX291dCwgT19SRFdSIHwgT19CSU5BUlkpOwor ICAgIGlmIChmZF9pbiA8IDAgfHwgZmRfb3V0IDwgMCkgeworICAgICAgICBmZF9pbiA9IGZkX291 dCA9IG9wZW4oZmlsZW5hbWUsIE9fUkRXUiB8IE9fQklOQVJZKTsKKyAgICAgICAgaWYgKGZkX2lu IDwgMCkKKyAgICAgICAgICAgIHJldHVybiBOVUxMOworICAgIH0KKyAgICByZXR1cm4gcWVtdV9j aHJfb3Blbl9mZChmZF9pbiwgZmRfb3V0KTsKIH0KIAogCg== ------=_Part_174889_7168605.1166035185642--