From: Stefan Hajnoczi <stefanha@gmail.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org, famz@redhat.com, qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [Qemu-block] [PATCH 08/10] scsi: build qemu-pr-helper
Date: Wed, 30 Aug 2017 16:44:16 +0100 [thread overview]
Message-ID: <20170830154416.GV24565@stefanha-x1.localdomain> (raw)
In-Reply-To: <20170822131832.20191-9-pbonzini@redhat.com>
On Tue, Aug 22, 2017 at 03:18:30PM +0200, Paolo Bonzini wrote:
> diff --git a/docs/interop/pr-helper.rst b/docs/interop/pr-helper.rst
> new file mode 100644
> index 0000000000..765174c31f
> --- /dev/null
> +++ b/docs/interop/pr-helper.rst
> @@ -0,0 +1,78 @@
> +..
> +
> +======================================
> +Persistent reservation helper protocol
> +======================================
> +
> +QEMU's SCSI passthrough devices, ``scsi-block`` and ``scsi-generic``,
> +can delegate implementation of persistent reservations to an external
> +(and typically privilege) program. Persistent Reservations allow
privileged
> diff --git a/scsi/pr-helper.h b/scsi/pr-helper.h
> new file mode 100644
> index 0000000000..2c7ccc9928
> --- /dev/null
> +++ b/scsi/pr-helper.h
> @@ -0,0 +1,13 @@
Do you want to license this file under the BSD license just in case
someone wants to copy it into an external helper implementation? The
file is trivial but still.
> +#ifndef QEMU_PR_HELPER_H
> +#define QEMU_PR_HELPER_H 1
> +
Missing #include <stdint.h> for in32_t and uint8_t.
> +#include "qemu/osdep.h"
> +#include <getopt.h>
> +#include "qapi/error.h"
> +#include "qemu-common.h"
> +#include "qemu/cutils.h"
> +#include "qemu/main-loop.h"
> +#include "qemu/error-report.h"
> +#include "qemu/config-file.h"
> +#include "qemu/bswap.h"
> +#include "qemu/log.h"
> +#include "qemu/systemd.h"
> +#include "qapi/util.h"
> +#include "qapi/qmp/qstring.h"
> +#include "io/channel-socket.h"
> +#include "trace/control.h"
> +#include "qemu-version.h"
> +
> +#include "block/aio.h"
> +#include "block/thread-pool.h"
> +
> +#include "scsi/constants.h"
> +#include "scsi/utils.h"
> +#include "pr-helper.h"
> +#include <sys/ioctl.h>
> +#include <linux/dm-ioctl.h>
> +#include <scsi/sg.h>
> +
> +#ifdef CONFIG_LIBCAP
> +#include <cap-ng.h>
> +#endif
> +#include <pwd.h>
> +#include <grp.h>
#include ordering
> +static int prh_read(PRHelperClient *client, void *buf, int sz, Error **errp)
> +{
> + while (sz > 0) {
> + int *fds = NULL;
> + size_t nfds = 0;
> + int i;
> + struct iovec iov;
> + ssize_t n_read;
> +
> + iov.iov_base = buf;
> + iov.iov_len = sz;
> + n_read = qio_channel_readv_full(QIO_CHANNEL(client->ioc), &iov, 1,
> + &fds, &nfds, errp);
> +
> + if (n_read == QIO_CHANNEL_ERR_BLOCK) {
> + qio_channel_yield(QIO_CHANNEL(client->ioc), G_IO_IN);
> + continue;
> + }
> + if (n_read <= 0) {
> + return n_read ? n_read : -1;
This assumes that client->fd == -1. It's probably true on Linux but I'm
not sure. What happens if the client sends an fd with a write that is
smaller than sz, and then follows up by closing the socket? In the
worst case this would leak client->fd (the caller assumes it's -1 on
failure).
> + }
> +
> + /* Stash one file descriptor per request. */
> + if (nfds) {
> + for (i = 0; i < nfds; i++) {
> + if (client->fd == -1) {
> + client->fd = fds[i++];
i++ looks like a bug. The loop is already iterating fds[i] so we don't
need to increment it. This would leak the following file descriptor.
> +static void prh_co_entry(void *opaque)
coroutine_fn
next prev parent reply other threads:[~2017-08-30 15:44 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-22 13:18 [Qemu-devel] [RFC PATCH 00/10] scsi, block: introduce persistent reservation managers Paolo Bonzini
2017-08-22 13:18 ` [Qemu-devel] [PATCH 01/10] scsi: rename scsi_convert_sense Paolo Bonzini
2017-08-22 13:38 ` Philippe Mathieu-Daudé
2017-08-22 13:18 ` [Qemu-devel] [PATCH 02/10] scsi: move non-emulation specific code to scsi/ Paolo Bonzini
2017-08-22 13:34 ` Philippe Mathieu-Daudé
2017-08-22 13:18 ` [Qemu-devel] [PATCH 03/10] scsi: introduce scsi_build_sense Paolo Bonzini
2017-08-22 13:35 ` Philippe Mathieu-Daudé
2017-08-30 13:39 ` Stefan Hajnoczi
2017-08-22 13:18 ` [Qemu-devel] [PATCH 04/10] scsi: introduce sg_io_sense_from_errno Paolo Bonzini
2017-08-22 13:45 ` Philippe Mathieu-Daudé
2017-08-22 13:53 ` Paolo Bonzini
2017-08-30 13:41 ` Stefan Hajnoczi
2017-08-22 13:18 ` [Qemu-devel] [PATCH 05/10] scsi: move block/scsi.h to include/scsi/constants.h Paolo Bonzini
2017-08-22 13:37 ` Philippe Mathieu-Daudé
2017-08-30 13:41 ` Stefan Hajnoczi
2017-08-22 13:18 ` [Qemu-devel] [PATCH 06/10] scsi, file-posix: add support for persistent reservation management Paolo Bonzini
2017-08-23 4:13 ` Fam Zheng
2017-08-23 6:56 ` Paolo Bonzini
2017-08-24 15:37 ` Eric Blake
2017-08-24 15:47 ` Paolo Bonzini
2017-08-30 12:59 ` Daniel P. Berrange
2017-08-30 14:26 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2017-08-22 13:18 ` [Qemu-devel] [PATCH 07/10] io: add qio_channel_read/write_all Paolo Bonzini
2017-08-23 5:08 ` Fam Zheng
2017-08-23 6:54 ` Paolo Bonzini
2017-08-30 12:52 ` Daniel P. Berrange
2017-08-30 14:33 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2017-08-22 13:18 ` [Qemu-devel] [PATCH 08/10] scsi: build qemu-pr-helper Paolo Bonzini
2017-08-22 14:34 ` Marc-André Lureau
2017-08-22 16:04 ` Paolo Bonzini
2017-08-24 15:45 ` Eric Blake
2017-08-30 15:44 ` Stefan Hajnoczi [this message]
2017-08-30 16:06 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2017-08-22 13:18 ` [Qemu-devel] [PATCH 09/10] scsi: add multipath support to qemu-pr-helper Paolo Bonzini
2017-08-23 5:01 ` Fam Zheng
2017-08-23 6:50 ` Paolo Bonzini
2017-08-30 16:06 ` Stefan Hajnoczi
2017-08-30 16:37 ` Stefan Hajnoczi
2017-09-11 9:14 ` [Qemu-devel] [Qemu-block] " Paolo Bonzini
2017-08-22 13:18 ` [Qemu-devel] [PATCH 10/10] scsi: add persistent reservation manager using qemu-pr-helper Paolo Bonzini
2017-08-23 4:49 ` Fam Zheng
2017-08-23 6:55 ` Paolo Bonzini
2017-08-23 7:48 ` Paolo Bonzini
2017-08-30 16:58 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2017-08-22 13:48 ` [Qemu-devel] [RFC PATCH 00/10] scsi, block: introduce persistent reservation managers no-reply
2017-08-22 13:50 ` no-reply
2017-08-22 13:50 ` no-reply
2017-08-22 13:51 ` no-reply
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=20170830154416.GV24565@stefanha-x1.localdomain \
--to=stefanha@gmail.com \
--cc=famz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--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).