qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Jay Zhou <jianjay.zhou@huawei.com>
Cc: qemu-devel@nongnu.org, pbonzini@redhat.com,
	weidong.huang@huawei.com, stefanha@redhat.com,
	pasic@linux.vnet.ibm.com, longpeng2@huawei.com,
	xin.zeng@intel.com, roy.fan.zhang@intel.com,
	arei.gonglei@huawei.com, wangxinxin.wang@huawei.com
Subject: Re: [Qemu-devel] [PATCH v6 1/4] cryptodev: add vhost-user as a new cryptodev backend
Date: Tue, 13 Feb 2018 18:46:21 +0200	[thread overview]
Message-ID: <20180213183154-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <f50145f0696050167fbfde1656a687d42954f258.1516538887.git.arei.gonglei@huawei.com>

On Sun, Jan 21, 2018 at 08:54:47PM +0800, Jay Zhou wrote:
> diff --git a/backends/cryptodev-vhost-user.c b/backends/cryptodev-vhost-user.c
> new file mode 100644
> index 0000000..4e63ece
> --- /dev/null
> +++ b/backends/cryptodev-vhost-user.c
> @@ -0,0 +1,333 @@
> +/*
> + * QEMU Cryptodev backend for QEMU cipher APIs
> + *
> + * Copyright (c) 2016 HUAWEI TECHNOLOGIES CO., LTD.
> + *
> + * Authors:
> + *    Gonglei <arei.gonglei@huawei.com>
> + *
> + * This library is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2 of the License, or (at your option) any later version.
> + *
> + * This library is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this library; if not, see <http://www.gnu.org/licenses/>.
> + *
> + */
> +
> +#include "qemu/osdep.h"
> +#include "hw/boards.h"
> +#include "qapi/error.h"
> +#include "qapi/qmp/qerror.h"
> +#include "qemu/error-report.h"
> +#include "standard-headers/linux/virtio_crypto.h"
> +#include "sysemu/cryptodev-vhost.h"
> +#include "chardev/char-fe.h"
> +
> +
> +/**
> + * @TYPE_CRYPTODEV_BACKEND_VHOST_USER:
> + * name of backend that uses vhost user server
> + */
> +#define TYPE_CRYPTODEV_BACKEND_VHOST_USER "cryptodev-vhost-user"
> +
> +#define CRYPTODEV_BACKEND_VHOST_USER(obj) \
> +    OBJECT_CHECK(CryptoDevBackendVhostUser, \
> +                 (obj), TYPE_CRYPTODEV_BACKEND_VHOST_USER)
> +
> +
> +typedef struct CryptoDevBackendVhostUser {
> +    CryptoDevBackend parent_obj;
> +
> +    CharBackend chr;
> +    char *chr_name;
> +    bool opened;
> +    CryptoDevBackendVhost *vhost_crypto[MAX_CRYPTO_QUEUE_NUM];
> +} CryptoDevBackendVhostUser;
> +
> +static int
> +cryptodev_vhost_user_running(
> +             CryptoDevBackendVhost *crypto)
> +{
> +    return crypto ? 1 : 0;
> +}
> +
> +static void cryptodev_vhost_user_stop(int queues,
> +                          CryptoDevBackendVhostUser *s)
> +{
> +    size_t i;
> +
> +    for (i = 0; i < queues; i++) {
> +        if (!cryptodev_vhost_user_running(s->vhost_crypto[i])) {
> +            continue;
> +        }
> +
> +        if (s->vhost_crypto) {
> +            cryptodev_vhost_cleanup(s->vhost_crypto[i]);
> +            s->vhost_crypto[i] = NULL;
> +        }
> +    }
> +}

This test is problematic: clang build triggers an error:
> /home/petmay01/linaro/qemu-for-merges/backends/cryptodev-vhost-user.c:86:16:
> error: address of array 's->vhost_crypto' will always evaluate to
> 'true' [-Werror,-Wpointer-bool-conversion]
>         if (s->vhost_crypto) {
>         ~~  ~~~^~~~~~~~~~~~

I really don't see how this could do the right thing, which
makes me suspect that either you did not test stop, or
you always have all queues enabled.

Pls test a config with some queues disabled.

In particular this machinery needs some unit tests
to catch errors like this.


-- 
MST

  reply	other threads:[~2018-02-13 16:46 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-21 12:54 [Qemu-devel] [PATCH v6 0/4] cryptodev: add vhost support Jay Zhou
2018-01-21 12:54 ` [Qemu-devel] [PATCH v6 1/4] cryptodev: add vhost-user as a new cryptodev backend Jay Zhou
2018-02-13 16:46   ` Michael S. Tsirkin [this message]
2018-02-14  2:30     ` Zhoujian (jay)
2018-01-21 12:54 ` [Qemu-devel] [PATCH v6 2/4] cryptodev: add vhost support Jay Zhou
2018-02-13 16:44   ` Michael S. Tsirkin
2018-02-14  2:54     ` Zhoujian (jay)
2018-01-21 12:54 ` [Qemu-devel] [PATCH v6 3/4] cryptodev-vhost-user: add crypto session handler Jay Zhou
2018-01-21 12:54 ` [Qemu-devel] [PATCH v6 4/4] cryptodev-vhost-user: set the key length Jay Zhou
2018-02-01 11:29 ` [Qemu-devel] [PATCH v6 0/4] cryptodev: add vhost support Zhoujian (jay)
2018-02-01 17:06   ` Michael S. Tsirkin
2018-02-02  1:06     ` Jay Zhou
2018-02-13 16:47 ` Michael S. Tsirkin
2018-02-14  2:35   ` Zhoujian (jay)

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=20180213183154-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=arei.gonglei@huawei.com \
    --cc=jianjay.zhou@huawei.com \
    --cc=longpeng2@huawei.com \
    --cc=pasic@linux.vnet.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=roy.fan.zhang@intel.com \
    --cc=stefanha@redhat.com \
    --cc=wangxinxin.wang@huawei.com \
    --cc=weidong.huang@huawei.com \
    --cc=xin.zeng@intel.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).