All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Marchand <david.marchand@6wind.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: "qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>,
	Olivier Matz <olivier.matz@6wind.com>, kvm <kvm@vger.kernel.org>,
	Stefan Hajnoczi <stefanha@gmail.com>,
	Claudio Fontana <claudio.fontana@huawei.com>,
	Markus Armbruster <armbru@redhat.com>,
	"Gonglei (Arei)" <arei.gonglei@huawei.com>,
	Martin Kletzander <mkletzan@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Jani Kokkonen <jani.kokkonen@huawei.com>,
	Cam Macdonell <cam@cs.ualberta.ca>
Subject: Re: [PATCH v5 1/3] contrib: add ivshmem client and server
Date: Fri, 05 Sep 2014 14:07:54 +0200	[thread overview]
Message-ID: <5409A79A.8050302@6wind.com> (raw)
In-Reply-To: <20140904155657.GD21203@redhat.com>

Hello Michael,

On 09/04/2014 05:56 PM, Michael S. Tsirkin wrote:
>> +    /* create the unix listening socket */
>> +    sock_fd = socket(AF_UNIX, SOCK_STREAM, 0);
>> +    if (sock_fd < 0) {
>> +        debug_log(server, "cannot create socket: %s\n", strerror(errno));
>> +        goto err_close_shm;
>> +    }
>> +
>> +    sun.sun_family = AF_UNIX;
>> +    snprintf(sun.sun_path, sizeof(sun.sun_path), "%s", server->unix_sock_path);
>> +    unlink(sun.sun_path);
>
> why unlink it?

Yes, this is wrong, because this means that when starting multiple
servers on the same socket, the last server is the one who wins ...
while I think it should be the opposite (first server wins, as it may
have some connected clients).

I have been scratching my head about this: when should I unlink ?

My current fix unlinks from ivshmem_server_close() (which should be the
right place).
I need to call this when exiting, but I can only do this when the server
exits gracefully (when an error occurs on the server socket or when 
receiving a SIGTERM).

If something unexpected happens (like a bug/crash or a SIGKILL), the
socket won't be unlinked and the next server process will refuse to start.
Is this something acceptable ?

Do you have a better idea ?


Thanks.

-- 
David Marchand

WARNING: multiple messages have this Message-ID (diff)
From: David Marchand <david.marchand@6wind.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Olivier Matz <olivier.matz@6wind.com>, kvm <kvm@vger.kernel.org>,
	Stefan Hajnoczi <stefanha@gmail.com>,
	Claudio Fontana <claudio.fontana@huawei.com>,
	Markus Armbruster <armbru@redhat.com>,
	"qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>,
	"Gonglei (Arei)" <arei.gonglei@huawei.com>,
	Martin Kletzander <mkletzan@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Jani Kokkonen <jani.kokkonen@huawei.com>,
	Cam Macdonell <cam@cs.ualberta.ca>
Subject: Re: [Qemu-devel] [PATCH v5 1/3] contrib: add ivshmem client and server
Date: Fri, 05 Sep 2014 14:07:54 +0200	[thread overview]
Message-ID: <5409A79A.8050302@6wind.com> (raw)
In-Reply-To: <20140904155657.GD21203@redhat.com>

Hello Michael,

On 09/04/2014 05:56 PM, Michael S. Tsirkin wrote:
>> +    /* create the unix listening socket */
>> +    sock_fd = socket(AF_UNIX, SOCK_STREAM, 0);
>> +    if (sock_fd < 0) {
>> +        debug_log(server, "cannot create socket: %s\n", strerror(errno));
>> +        goto err_close_shm;
>> +    }
>> +
>> +    sun.sun_family = AF_UNIX;
>> +    snprintf(sun.sun_path, sizeof(sun.sun_path), "%s", server->unix_sock_path);
>> +    unlink(sun.sun_path);
>
> why unlink it?

Yes, this is wrong, because this means that when starting multiple
servers on the same socket, the last server is the one who wins ...
while I think it should be the opposite (first server wins, as it may
have some connected clients).

I have been scratching my head about this: when should I unlink ?

My current fix unlinks from ivshmem_server_close() (which should be the
right place).
I need to call this when exiting, but I can only do this when the server
exits gracefully (when an error occurs on the server socket or when 
receiving a SIGTERM).

If something unexpected happens (like a bug/crash or a SIGKILL), the
socket won't be unlinked and the next server process will refuse to start.
Is this something acceptable ?

Do you have a better idea ?


Thanks.

-- 
David Marchand

  parent reply	other threads:[~2014-09-05 12:08 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-04 12:50 [PATCH v5 0/3] ivshmem: update documentation, add client/server tools David Marchand
2014-09-04 12:50 ` [Qemu-devel] " David Marchand
2014-09-04 12:50 ` [PATCH v5 1/3] contrib: add ivshmem client and server David Marchand
2014-09-04 12:50   ` [Qemu-devel] " David Marchand
2014-09-04 15:56   ` Michael S. Tsirkin
2014-09-04 15:56     ` [Qemu-devel] " Michael S. Tsirkin
2014-09-05  8:52     ` Claudio Fontana
2014-09-05  8:52       ` [Qemu-devel] " Claudio Fontana
2014-09-05 12:07     ` David Marchand [this message]
2014-09-05 12:07       ` David Marchand
2014-09-07  5:58       ` Michael S. Tsirkin
2014-09-07  5:58         ` [Qemu-devel] " Michael S. Tsirkin
2014-09-04 15:58   ` Michael S. Tsirkin
2014-09-04 15:58     ` [Qemu-devel] " Michael S. Tsirkin
2014-09-05 10:40   ` Stefan Hajnoczi
2014-09-05 10:40     ` [Qemu-devel] " Stefan Hajnoczi
2014-09-04 12:51 ` [PATCH v5 2/3] docs: update ivshmem device spec David Marchand
2014-09-04 12:51   ` [Qemu-devel] " David Marchand
2014-09-05 10:30   ` Stefan Hajnoczi
2014-09-05 10:30     ` [Qemu-devel] " Stefan Hajnoczi
2014-09-04 12:51 ` [PATCH v5 3/3] ivshmem: add check on protocol version in QEMU David Marchand
2014-09-04 12:51   ` [Qemu-devel] " David Marchand
2014-09-05 10:29   ` Stefan Hajnoczi
2014-09-05 10:29     ` [Qemu-devel] " Stefan Hajnoczi
2014-09-05 12:25     ` David Marchand
2014-09-05 12:25       ` [Qemu-devel] " David Marchand
2014-09-08  8:30       ` Stefan Hajnoczi
2014-09-08  8:30         ` [Qemu-devel] " Stefan Hajnoczi
2014-09-04 15:40 ` [PATCH v5 0/3] ivshmem: update documentation, add client/server tools Michael S. Tsirkin
2014-09-04 15:40   ` [Qemu-devel] " Michael S. Tsirkin

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=5409A79A.8050302@6wind.com \
    --to=david.marchand@6wind.com \
    --cc=arei.gonglei@huawei.com \
    --cc=armbru@redhat.com \
    --cc=cam@cs.ualberta.ca \
    --cc=claudio.fontana@huawei.com \
    --cc=jani.kokkonen@huawei.com \
    --cc=kvm@vger.kernel.org \
    --cc=mkletzan@redhat.com \
    --cc=mst@redhat.com \
    --cc=olivier.matz@6wind.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.