From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: thuth@redhat.com, quintela@redhat.com, qemu-devel@nongnu.org,
armbru@redhat.com
Subject: Re: [PATCH 0/2] monitor openfd commands
Date: Thu, 11 Jun 2020 17:45:50 +0100 [thread overview]
Message-ID: <20200611164550.GG2968@work-vm> (raw)
In-Reply-To: <cec98884-f2cd-02f3-1806-a6579ce68961@redhat.com>
* Eric Blake (eblake@redhat.com) wrote:
> On 6/11/20 6:17 AM, Dr. David Alan Gilbert (git) wrote:
> > From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> >
> > The monitors currently have a 'getfd' command that lets you pass an fd
> > via the monitor socket. 'openfd' is a new command that opens a file
> > and puts the fd in the same fd pool. The file is opened RW and created
> > if it doesn't exist.
> > It makes it easy to test migration to and from a file.
>
> We have two fd-passing mechanisms: getfd and add-fd. add-fd is newer, and
> allows things like /dev/fdset/NNN to work anywhere a filename works.
Ewww I do dislike fake paths, they tend to be the source of great
security bugs.
> I'm
> guessing that the issue here is that migration hasn't been tweaked to work
> nicely with the newer add-fd, but instead insists on the older getfd
> interface (where you have to use getfd to associate an fd with a name, then
> tell migration to use that special name, but the special name is via a
> different parameter than the normal filename parameter). At which point
> openfd looks like it is just sugar to make getfd easier to use.
Yep, openfd is just intended to be sugar; it's a pain to use getfd at
runtime because you have to play all the passing fd's over socket magic.
My main reason here is because I wanted an easy way to migrate to
/dev/null for performance testing, but it would make life easier when
migrating to/from a file.
> Would it instead be worth modifying migration to work with add-fd?
Probably. At the moment what we have is an 'fd:string' syntax for both
inbound and outbound migration.
The outbound migration looks up the string in the getfd index and uses
it. (via monitor_get_fd)
The inbound migration checks if the string starts with a number, if it
is then it uses it raw as the unix fd; else it passes it to getfd index.
(via monitor_fd_param).
(getfd disallows names that are numeric)
I can see a few solutions here:
a) Teach qemu a new fdset:number syntax - it's a bit of a pain
but is discoverable.
b) Modify the getfd string lookup to parse /dev/fdset and go use
the fdset
The problem with (b) is that the getfd mechanism doesn't have a
concept of open mode, and only has a single fd bound to a name,
so none of the existing parsing code would know which entry to use in an
fdset. (I'm assuming here no one created a getfd entry named
/dev/fdset/0 - although it seems legal).
The problem with (a) is that adding a new syntax is a bit more code;
but I guess it's probably more discoverable.
ANy preferences?
> add-fd need the same sort of sugar?
Yep, I'd like to have a way to open a file other than via scmrights.
I'd also need to add an HMP equivalent.
Dave
>
> >
> > Dr. David Alan Gilbert (2):
> > qmp: Add 'openfd' command
> > hmp: Add 'openfd' command
> >
> > hmp-commands.hx | 16 +++++++++++++-
> > include/monitor/hmp.h | 1 +
> > monitor/hmp-cmds.c | 10 +++++++++
> > monitor/misc.c | 48 +++++++++++++++++++++++++++++++++---------
> > qapi/misc.json | 23 +++++++++++++++++++-
> > tests/qtest/test-hmp.c | 2 ++
> > 6 files changed, 88 insertions(+), 12 deletions(-)
> >
>
> --
> Eric Blake, Principal Software Engineer
> Red Hat, Inc. +1-919-301-3226
> Virtualization: qemu.org | libvirt.org
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
prev parent reply other threads:[~2020-06-11 16:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-11 11:17 [PATCH 0/2] monitor openfd commands Dr. David Alan Gilbert (git)
2020-06-11 11:17 ` [PATCH 1/2] qmp: Add 'openfd' command Dr. David Alan Gilbert (git)
2020-06-11 14:34 ` Eric Blake
2020-06-11 11:17 ` [PATCH 2/2] hmp: " Dr. David Alan Gilbert (git)
2020-06-11 14:31 ` [PATCH 0/2] monitor openfd commands Eric Blake
2020-06-11 16:45 ` Dr. David Alan Gilbert [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=20200611164550.GG2968@work-vm \
--to=dgilbert@redhat.com \
--cc=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=thuth@redhat.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).