From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49339) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brMIl-0004Q3-5A for qemu-devel@nongnu.org; Tue, 04 Oct 2016 05:46:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1brMIh-0004nK-8M for qemu-devel@nongnu.org; Tue, 04 Oct 2016 05:46:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55712) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brMIh-0004mw-1P for qemu-devel@nongnu.org; Tue, 04 Oct 2016 05:46:15 -0400 Date: Tue, 4 Oct 2016 10:46:10 +0100 From: Stefan Hajnoczi Message-ID: <20161004094610.GF4587@stefanha-x1.localdomain> References: <1475051152-400276-1-git-send-email-arei.gonglei@huawei.com> <1475051152-400276-8-git-send-email-arei.gonglei@huawei.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="f61P+fpdnY2FZS1u" Content-Disposition: inline In-Reply-To: <1475051152-400276-8-git-send-email-arei.gonglei@huawei.com> Subject: Re: [Qemu-devel] [PATCH v4 07/13] virtio-crypto: set capacity of algorithms supported List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gonglei Cc: qemu-devel@nongnu.org, virtio-dev@lists.oasis-open.org, luonengjun@huawei.com, mst@redhat.com, pbonzini@redhat.com, berrange@redhat.com, weidong.huang@huawei.com, wu.wubin@huawei.com, mike.caraman@nxp.com, agraf@suse.de, xin.zeng@intel.com, claudio.fontana@huawei.com, nmorey@kalray.eu, vincent.jardin@6wind.com, jianjay.zhou@huawei.com, hanweidong@huawei.com, peter.huangpeng@huawei.com --f61P+fpdnY2FZS1u Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Sep 28, 2016 at 04:25:46PM +0800, Gonglei wrote: > static void virtio_crypto_get_config(VirtIODevice *vdev, uint8_t *config) > { > - > + VirtIOCrypto *c = VIRTIO_CRYPTO(vdev); > + struct virtio_crypto_config crypto_cfg; > + > + crypto_cfg.status = c->status; > + crypto_cfg.max_dataqueues = c->max_queues; > + crypto_cfg.crypto_services = c->conf.crypto_services; > + crypto_cfg.cipher_algo_l = c->conf.cipher_algo_l; > + crypto_cfg.cipher_algo_h = c->conf.cipher_algo_h; > + crypto_cfg.hash_algo = c->conf.hash_algo; > + crypto_cfg.mac_algo_l = c->conf.mac_algo_l; > + crypto_cfg.mac_algo_h = c->conf.mac_algo_h; > + crypto_cfg.aead_algo = c->conf.aead_algo; > + > + memcpy(config, &crypto_cfg, c->config_size); > } What about endianness? For example, if the host is big-endian then this VIRTIO 1.0 device needs to byteswap multi-byte fields. There is a family of functions to help with this: virtio_stl_p(). --f61P+fpdnY2FZS1u Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJX83piAAoJEJykq7OBq3PIc+sIAIMrhdNVN3cNtWrKzp8QyGAn ByBFmQcK25727/NpFOG/5wfBcXexe3bwzvf71Q6rh5pVjnwlPpd9iTAnXdumA2VB PDLqxxwVtf4wXYi2CeyvKkXZop8vNt6pS0C13PIOBjB4TfpcpyTb8qMxLX1bVR1u 4l8x2EgH2nyBg+7KCtX3D9FXjdkjx5yW1U0nyo/UBjNV/jzypEpVfsxMArWjzt6P A4N4CasbaOIamNX9WKjQ++heIykQKD+fkidzuliLxOty/efMWCFLFZG4HruMFNEp vPZ+2wrrwc8ng78akPojfmPvcBUFOsyDBbLgtun8bj5TW4d0NoHuBiZAlaN/d0A= =Kzpg -----END PGP SIGNATURE----- --f61P+fpdnY2FZS1u--