qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 2/4] scsi: build qemu-pr-helper
Date: Tue, 19 Sep 2017 14:33:51 +0100	[thread overview]
Message-ID: <20170919133351.GO9536@redhat.com> (raw)
In-Reply-To: <20170919102434.21147-3-pbonzini@redhat.com>

On Tue, Sep 19, 2017 at 12:24:32PM +0200, Paolo Bonzini wrote:
> Introduce a privileged helper to run persistent reservation commands.
> This lets virtual machines send persistent reservations without using
> CAP_SYS_RAWIO or out-of-tree patches.  The helper uses Unix permissions
> and SCM_RIGHTS to restrict access to processes that can access its socket
> and prove that they have an open file descriptor for a raw SCSI device.
> 
> The next patch will also correct the usage of persistent reservations
> with multipath devices.
> 
> It would also be possible to support for Linux's IOC_PR_* ioctls in
> the future, to support NVMe devices.  For now, however, only SCSI is
> supported.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---


> +
> +#define PR_HELPER_CDB_SIZE     16
> +#define PR_HELPER_SENSE_SIZE   96
> +#define PR_HELPER_DATA_SIZE    8192
> +
> +typedef struct PRHelperResponse {
> +    int32_t result;
> +    int32_t sz;
> +    uint8_t sense[PR_HELPER_SENSE_SIZE];
> +} PRHelperResponse;

Should we annotate this with 'packed' to ensure its immune to compiler
padding ?


> +typedef struct PRHelperRequest {
> +    int fd;
> +    size_t sz;
> +    uint8_t cdb[PR_HELPER_CDB_SIZE];
> +} PRHelperRequest;

Same q here ?


> +static int coroutine_fn prh_write_response(PRHelperClient *client,
> +                                           PRHelperRequest *req,
> +                                           PRHelperResponse *resp, Error **errp)
> +{
> +    ssize_t r;

Can just be int

> +    size_t sz;
> +
> +    if (req->cdb[0] == PERSISTENT_RESERVE_IN && resp->result == GOOD) {
> +        assert(resp->sz <= req->sz && resp->sz <= sizeof(client->data));
> +    } else {
> +        assert(resp->sz == 0);
> +    }
> +
> +    sz = resp->sz;
> +
> +    resp->result = cpu_to_be32(resp->result);
> +    resp->sz = cpu_to_be32(resp->sz);
> +    r = qio_channel_write_all(QIO_CHANNEL(client->ioc),
> +                              (char *) resp, sizeof(*resp), errp);
> +    if (r < 0) {
> +        return r;
> +    }
> +
> +    r = qio_channel_write_all(QIO_CHANNEL(client->ioc),
> +                              (char *) client->data,
> +                              sz, errp);
> +    return r < 0 ? r : 0;

Just return 'r' directly, its only ever -1 or 0



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 :|

  reply	other threads:[~2017-09-19 13:34 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-19 10:24 [Qemu-devel] [PATCH v2 0/4] scsi, block: introduce persistent reservation managers Paolo Bonzini
2017-09-19 10:24 ` [Qemu-devel] [PATCH 1/4] scsi, file-posix: add support for persistent reservation management Paolo Bonzini
2017-09-19 10:24 ` [Qemu-devel] [PATCH 2/4] scsi: build qemu-pr-helper Paolo Bonzini
2017-09-19 13:33   ` Daniel P. Berrange [this message]
2017-09-19 14:25     ` Paolo Bonzini
2017-09-19 10:24 ` [Qemu-devel] [PATCH 3/4] scsi: add multipath support to qemu-pr-helper Paolo Bonzini
2017-09-19 10:24 ` [Qemu-devel] [PATCH 4/4] scsi: add persistent reservation manager using qemu-pr-helper Paolo Bonzini
2017-09-19 12:50   ` Daniel P. Berrange
2017-09-19 12:53   ` Daniel P. Berrange
2017-09-19 12:57     ` Paolo Bonzini
2017-09-19 13:12       ` Daniel P. Berrange
2017-09-19 13:23         ` Paolo Bonzini
2017-09-19 13:26           ` Daniel P. Berrange
2017-09-19 14:32             ` Paolo Bonzini
2017-09-21 16:20           ` [Qemu-devel] [Qemu-block] " Paolo Bonzini
2017-09-21 16:07 ` [Qemu-devel] [Qemu-block] [PATCH v2 0/4] scsi, block: introduce persistent reservation managers Stefan Hajnoczi
2017-09-21 16:22 ` [Qemu-devel] " no-reply
2017-09-21 16:24 ` no-reply
2017-09-21 16:29   ` Paolo Bonzini

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=20170919133351.GO9536@redhat.com \
    --to=berrange@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).