qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: <ning.bo9@zte.com.cn>
To: <stefanha@gmail.com>
Cc: mst@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com
Subject: Re:[Qemu-devel] [PATCH v2] vhost-vsock: report QMP eventwhensetrunning
Date: Fri, 20 Dec 2019 10:38:12 +0800 (CST)	[thread overview]
Message-ID: <201912201038127222527@zte.com.cn> (raw)
In-Reply-To: <20191219113503.GC1624084@stefanha-x1.localdomain>


[-- Attachment #1.1: Type: text/plain, Size: 1312 bytes --]

> > There will be an additional problem if do this:
> > Who decides which port the `runtime` should listen?
> 
> Let the host kernel automatically assign a port using VMADDR_PORT_ANY.
> It works like this:
> 
>   struct sockaddr_vm svm = {
>       .svm_family = AF_VSOCK,
>       .svm_port = VMADDR_PORT_ANY,
>       .svm_cid = VMADDR_CID_ANY,
>   };
> 
>   int fd = socket(AF_VSOCK, SOCK_STREAM, 0);
>   ...
>   if (bind(fd, (const struct sockaddr  )&svm, sizeof(svm)) < 0) {
>       ...
>   }
> 
>   socklen_t socklen = sizeof(svm);
>   if (getsockname(fd, (struct sockaddr *)&svm, &socklen) < 0) {
>       ...
>   }
> 
>   printf("cid %u port %u\n", svm.svm_cid, svm.svm_port);
> 
> > Consider the worst case: 
> > The ports selected by two `runtime` running in parallel always conflict, 
> > and this case is unavoidable, even if we can reduce the possibility of 
> > conflicts through algorithms.
> > Because we don't have a daemon that can allocate unique port to `runtime`.
> 
> The kernel assigns unique ports and only fails if the entire port
> namespace is exhausted.  The port namespace is 32-bits so this is not a
> real-world concern.
> 
> Does this information clarify how the runtime can connect to the guest
> agent without loops or delays?

Thank you very much. I will do as you instructed above

      reply	other threads:[~2019-12-20  2:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-05  3:32 [Qemu-devel] [PATCH v2] vhost-vsock: report QMP event when set running Ning Bo
2019-08-09 13:41 ` Stefan Hajnoczi
2019-11-28 11:26   ` Re:[Qemu-devel] [PATCH v2] vhost-vsock: report QMP event when setrunning ning.bo9
2019-12-12 11:05     ` [Qemu-devel] " Stefan Hajnoczi
2019-12-12 11:24       ` Michael S. Tsirkin
2019-12-19 11:18         ` Stefan Hajnoczi
2019-12-13  7:11       ` Re:[Qemu-devel] [PATCH v2] vhost-vsock: report QMP event whensetrunning ning.bo9
2019-12-19 11:35         ` [Qemu-devel] " Stefan Hajnoczi
2019-12-20  2:38           ` ning.bo9 [this message]

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=201912201038127222527@zte.com.cn \
    --to=ning.bo9@zte.com.cn \
    --cc=armbru@redhat.com \
    --cc=mst@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 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).