From: Eric Blake <eblake@redhat.com>
To: Corey Bryant <coreyb@linux.vnet.ibm.com>
Cc: kwolf@redhat.com, libvir-list@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v4 4/4] qemu-config: Add new -add-fd command line option
Date: Thu, 18 Oct 2012 16:09:55 -0600 [thread overview]
Message-ID: <50807E33.3080905@redhat.com> (raw)
In-Reply-To: <1350587974-6378-5-git-send-email-coreyb@linux.vnet.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 1352 bytes --]
On 10/18/2012 01:19 PM, Corey Bryant wrote:
> This option can be used for passing file descriptors on the
> command line. It mirrors the existing add-fd QMP command which
> allows an fd to be passed to QEMU via SCM_RIGHTS and added to an
> fd set.
>
> +
> +static int cleanup_add_fd(QemuOpts *opts, void *opaque)
> +{
> + int fd;
> +
> + fd = qemu_opt_get_number(opts, "fd", -1);
> + close(fd);
One other subtle point: Given 'qemu-kvm -add-fd fd=3,set=1 -add-fd
fd=3,set=2', this code will call close(3) twice. In a single-threaded
scenario, we happen to be safe (because we merely ignore that the second
one fails with EBADF), but in a multi-threaded scenario, it is a recipe
for disaster with a chance for closing an fd opened by another thread.
> @@ -3320,6 +3390,14 @@ int main(int argc, char **argv, char **envp)
> exit(1);
> }
>
> + if (qemu_opts_foreach(qemu_find_opts("add-fd"), parse_add_fd, NULL, 1)) {
> + exit(1);
> + }
> +
> + if (qemu_opts_foreach(qemu_find_opts("add-fd"), cleanup_add_fd, NULL, 1)) {
> + exit(1);
> + }
Thankfully, we only ever call that code in main(), prior to spawning
threads. So my positive review still stands.
--
Eric Blake eblake@redhat.com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 617 bytes --]
next prev parent reply other threads:[~2012-10-18 22:11 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-18 19:19 [Qemu-devel] [PATCH v4 0/4] command line fd passing using fd sets Corey Bryant
2012-10-18 19:19 ` [Qemu-devel] [PATCH v4 1/4] monitor: Allow add-fd to any specified fd set Corey Bryant
2012-10-18 19:19 ` [Qemu-devel] [PATCH v4 2/4] monitor: Enable adding an inherited fd to an " Corey Bryant
2012-10-18 19:19 ` [Qemu-devel] [PATCH v4 3/4] monitor: Prevent removing fd from set during init Corey Bryant
2012-10-18 19:19 ` [Qemu-devel] [PATCH v4 4/4] qemu-config: Add new -add-fd command line option Corey Bryant
2012-10-18 20:43 ` Eric Blake
2012-10-18 21:37 ` Corey Bryant
2012-10-19 11:05 ` Kevin Wolf
2012-10-19 13:12 ` Corey Bryant
2012-10-18 22:09 ` Eric Blake [this message]
2012-10-22 14:36 ` [Qemu-devel] [PATCH v5] " Kevin Wolf
2012-10-22 15:06 ` Corey Bryant
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=50807E33.3080905@redhat.com \
--to=eblake@redhat.com \
--cc=coreyb@linux.vnet.ibm.com \
--cc=kwolf@redhat.com \
--cc=libvir-list@redhat.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).