From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: "Kevin Wolf" <kwolf@redhat.com>,
"xiaoqiang zhao" <zxq_yx_007@163.com>,
qemu-devel@nongnu.org, "Markus Armbruster" <armbru@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>
Subject: Re: Our abstract UNIX domain socket support is a mess
Date: Fri, 30 Oct 2020 09:16:18 +0000 [thread overview]
Message-ID: <20201030091618.GB99222@redhat.com> (raw)
In-Reply-To: <c52b8cd0-feea-a7ca-fe95-47112a4c36b1@redhat.com>
On Thu, Oct 29, 2020 at 01:47:02PM -0500, Eric Blake wrote:
> On 10/29/20 11:07 AM, Kevin Wolf wrote:
>
> >>>
> >>> QEMU's interface is differently messy.
> >>>
> >>> Our equivalent to struct sockaddr_un is QAPI type UnixSocketAddress:
> >>>
> >>> { 'struct': 'UnixSocketAddress',
> >>> 'data': {
> >>> 'path': 'str' }
> >>>
> >>> @path corresponds to sockaddr_un member sun_path. sun_family = AF_UNIX
> >>> and socklen_t sizeof(sockaddr_un) are implied.
> >>>
> >>> We didn't repurpose @path for abstract sockets like the Linux kernel did
> >>> with sun_path. Instead, we added a flag @abstract (default false).
> >>> When it's on, we make a binary blob by prefixing @path with a 0 byte,
> >>> and pad it with more 0 bytes.
> >>>
> >>> We added a second flag @tight (default true) to optionally cut the
> >>> socklen_t to the end of the string (the terminating 0 byte is not
> >>> included).
> >>>
>
> > Using magic characters in strings to distinguish different types of
> > objects is always wrong in QAPI. If we interpreted leading '@' this way,
> > you wouldn't be able to specify a relative filename starting with '@'
> > any more.
> >
> >> Or, just or by having explicit flags "abstract" and "tight" to
> >> control the behaviour. The latter is what 'socat' does to allow
> >> use of abstract sockets.
> >>
> >> For QEMU the former approach gives broad interoperabiltiy with
> >> userspace applications, so made more sense than using magic "@".
> >
> > Boolean flags to distinguish different types are better than parsing
> > strings, but still not optimal. Documentation like "only matters for
> > abstract sockets" is another hint that we're treating things the same
> > that aren't the same.
>
> But why two boolean flags for three sensible states (where it is unclear
> if the fourth combination that makes no sense is silently accepted or
> loudly rejected), instead of a single tri-state-valued enum?
This is simply mirroring what "socat" supports as configuration.
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
next prev parent reply other threads:[~2020-10-30 9:17 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-28 12:41 Our abstract UNIX domain socket support is a mess Markus Armbruster
2020-10-29 14:02 ` Daniel P. Berrangé
2020-10-29 16:07 ` Kevin Wolf
2020-10-29 18:47 ` Eric Blake
2020-10-30 9:16 ` Daniel P. Berrangé [this message]
2020-10-30 10:30 ` Markus Armbruster
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=20201030091618.GB99222@redhat.com \
--to=berrange@redhat.com \
--cc=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=zxq_yx_007@163.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).