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().