qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Haoqian He <haoqian.he@smartx.com>
To: "Marc-André Lureau" <marcandre.lureau@gmail.com>, qemu-devel@nongnu.org
Subject: Re: [PATCH] chardev: use remoteAddr if the chardev is client
Date: Wed, 26 Feb 2025 12:56:55 +0800	[thread overview]
Message-ID: <EBF8821F-91BA-4EB4-AAD0-E4D00696941B@smartx.com> (raw)
In-Reply-To: <CAJ+F1C+hoQAUfvn6FN=TJ74vWaSfqa-rxa3HCOPe7gBDz3P=tA@mail.gmail.com>


> 2025年2月25日 21:29,Marc-André Lureau <marcandre.lureau@gmail.com> 写道:
> 
> Hi Haoqian
> 
> On Tue, Feb 25, 2025 at 5:19 PM Haoqian He <haoqian.he@smartx.com> wrote:
>> 
>> I use chardev to connect with a vhost-user target, the chardev backend type is
>> socket, part of QEMU boot parameter:
>>  -device vhost-user-blk-pci,chardev=my-vhost-blk-0,id=my-vhost-blk-0,\
>>  bus=pci.1,addr=0x1,bootindex=1,num-queues=4 \
>>  -chardev socket,id=my-vhost-blk-0,path=/tmp/vhost-blk.1
>> 
>> I want to log the chardev’s socket path when socket successfully connected
>> in tcp_chr_connect (chr->filename), but i got "unix:" instead of the expected
>> "unix:/tmp/vhost-blk.1".
>> 
>> The chr->filename was computed from the function qemu_chr_compute_filename,
>> which always return the unix path store by local QIOChannelSocket localAddr.
>> 
>> Unfortunately, the localAddr is obtained via getsockname (see the function
>> qio_channel_socket_set_fd), and according to the man page:
>> "getsockname() returns the current address bound by the socket sockfd".
>> 
>> In this scenario, the socket client's sockfd is unbonded, so the socket
>> filename in localAddr(ss) is NULL.
>> As a solution, we can use remoteAddr(ps) obtained by getpeername (see the
>> function qio_channel_socket_set_fd).
>> 
> 
> thanks a lot, I didn't notice ps != ss in the patch. That makes sense.
> 
> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> 
> 
> 
> -- 
> Marc-André Lureau

Thanks, Lureau.

--
Haoqian

      parent reply	other threads:[~2025-02-26  4:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-25 10:45 [PATCH] chardev: use remoteAddr if the chardev is client Haoqian He
2025-02-25 11:49 ` Marc-André Lureau
     [not found]   ` <C7E4AAD7-657F-4109-9627-49EB9F4CD7DA@smartx.com>
     [not found]     ` <CAJ+F1C+hoQAUfvn6FN=TJ74vWaSfqa-rxa3HCOPe7gBDz3P=tA@mail.gmail.com>
2025-02-26  4:56       ` Haoqian He [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=EBF8821F-91BA-4EB4-AAD0-E4D00696941B@smartx.com \
    --to=haoqian.he@smartx.com \
    --cc=marcandre.lureau@gmail.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).