From nobody Thu May 2 23:29:10 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1622577935; cv=none; d=zohomail.com; s=zohoarc; b=F6IrDZYa+Fm/jjs9SbGBdsJOsS5bUm4yZXErtXHfDCBVlCcqCR20EgD5HSFj98/6d02+hH9Es/LbOneYad+LjEgIi7UIGxl8JvK0FumI2Ifu0jYWdAKBxXdIodiu7rhC8ujrWWX2kcr7qQmeYy7wbKs8+GfGC/5Vn/hhV0helnk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622577935; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=OhxZvgPrm7ef3poM6zsNJTUnNBRvQVJmMr/OyqsDOyY=; b=hp53ckrIB4El6Wj/ewufXiTTujnNRo2DcAXclmaSVISiwC8QHWY0pgLlvUoIdIvgOjysSaJMb0RBbHlgrCqsSwPF5K2gCxDnAjBoOK8XoNpLtItpUAVhy4/EugUJRwT4diw2OJvaszfhuALArtB+efQNveLDDmEjM1PpO2/mRok= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622577935553752.1689092186314; Tue, 1 Jun 2021 13:05:35 -0700 (PDT) Received: from localhost ([::1]:54286 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1loAdq-0004NP-AW for importer2@patchew.org; Tue, 01 Jun 2021 16:05:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38496) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loAbZ-0002JX-TL for qemu-devel@nongnu.org; Tue, 01 Jun 2021 16:03:13 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]:37417) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1loAbW-0002sM-Lv for qemu-devel@nongnu.org; Tue, 01 Jun 2021 16:03:13 -0400 Received: by mail-pl1-x631.google.com with SMTP id u7so7478790plq.4 for ; Tue, 01 Jun 2021 13:03:10 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id 23sm15486229pgv.90.2021.06.01.13.03.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Jun 2021 13:03:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OhxZvgPrm7ef3poM6zsNJTUnNBRvQVJmMr/OyqsDOyY=; b=qlU9LWAW9U6tbuZG75446844jllPghM95m1Uxu8VrA1PrqnxbAl3YxcR7VMCPJYB1l URCFdAAbAxl1+HhyRc9H4pMsngTVlceQNot7+MHJv/5qX0WZNPWzd4M/xResJIOGmI4P xBY0asWKqbQ65G6vHZ27gpJAGoqa64vpQ5JpRP10P/RW+SaRkPYGl4bdBUJNpEUNx51U dUVFTCJpDCpSFTmrj/sHf/SiohhJGxGK3hd388ZJRFJiV2poENhHEmWMEr1Hl6cBZ+h3 bQup97mw8h0o9fOKs7Zu179rANH0WNdzZBdsu0XtV914ShdFWTAmRsZWJCVlBuSQkCgI 191g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OhxZvgPrm7ef3poM6zsNJTUnNBRvQVJmMr/OyqsDOyY=; b=jwr2cRp14pG7O/qMvqClrSKwWnD//SQfdA1Th1nhqR4jHMT5PaThHlLyvsc/eXooB0 T/5b2b3ryOk97bF4rkjheuEacaALtU7X7PBfjjF3xMcjP27htsfUbH8vN/kkJaf772oK a4FrX0bnKfL34bKQLBVyRYxlsttiVPqrMNcEh8WsQqBnPVDI9lczteVCPUuTi78X30wf bgj7dlVplZ5NnBHOTFZoImjUvRjXLDPrFBq/gJOeNh1TAxyLgx/tEF/X5mwCMVAOkkkp 0LR0iq8p3GyXOm89pH9GgArHEtFAKKfcQPBOJRQD8CHKDZNY+pO4U0pAG6HjaUCQjBEG xv4A== X-Gm-Message-State: AOAM530CfZ1uZX13ZKLYiWT84frKurXJ5lcFji3GOPYdVXOT/AbEDJec 4rNEHVBCDDMdm7a4n8T7AN/Grg== X-Google-Smtp-Source: ABdhPJzs8d8Lx6mk8h+liJSW3Xy18YDp4QtopbTE/tEQdwZSRWQsS4HejtLT+QmaMQIjbkxuUIakjQ== X-Received: by 2002:a17:902:aa02:b029:f0:cc19:faae with SMTP id be2-20020a170902aa02b02900f0cc19faaemr27132055plb.57.1622577789115; Tue, 01 Jun 2021 13:03:09 -0700 (PDT) From: Mathieu Poirier To: mst@redhat.com Subject: [PATCH 1/5] vhost-user-rng: Add vhost-user-rng implementation Date: Tue, 1 Jun 2021 14:03:01 -0600 Message-Id: <20210601200305.1772391-2-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210601200305.1772391-1-mathieu.poirier@linaro.org> References: <20210601200305.1772391-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=mathieu.poirier@linaro.org; helo=mail-pl1-x631.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: viresh.kumar@linaro.org, alex.bennee@linaro.org, qemu-devel@nongnu.org, stratos-dev@op-lists.linaro.org Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Following in the footsteps of what whas done for vhost-user-i2c and virtiofsd, introduce a random number generator (RNG) backend that communicates with a vhost-user server to retrieve entropy. That way another VMM could be using the same vhost-user daemon and avoid having to write yet another RNG driver. Signed-off-by: Mathieu Poirier --- hw/virtio/Kconfig | 5 + hw/virtio/meson.build | 1 + hw/virtio/vhost-user-rng.c | 294 +++++++++++++++++++++++++++++ include/hw/virtio/vhost-user-rng.h | 33 ++++ 4 files changed, 333 insertions(+) create mode 100644 hw/virtio/vhost-user-rng.c create mode 100644 include/hw/virtio/vhost-user-rng.h diff --git a/hw/virtio/Kconfig b/hw/virtio/Kconfig index 0eda25c4e1bf..69066ab14e6d 100644 --- a/hw/virtio/Kconfig +++ b/hw/virtio/Kconfig @@ -58,3 +58,8 @@ config VIRTIO_MEM depends on LINUX depends on VIRTIO_MEM_SUPPORTED select MEM_DEVICE + +config VHOST_USER_RNG + bool + default y + depends on VIRTIO && VHOST_USER diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index fbff9bc9d4de..e386791f2a05 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -25,6 +25,7 @@ virtio_ss.add(when: 'CONFIG_VHOST_USER_VSOCK', if_true: f= iles('vhost-user-vsock. virtio_ss.add(when: 'CONFIG_VIRTIO_RNG', if_true: files('virtio-rng.c')) virtio_ss.add(when: 'CONFIG_VIRTIO_IOMMU', if_true: files('virtio-iommu.c'= )) virtio_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-mem.c')) +virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user-rn= g.c')) =20 virtio_pci_ss =3D ss.source_set() virtio_pci_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock-= pci.c')) diff --git a/hw/virtio/vhost-user-rng.c b/hw/virtio/vhost-user-rng.c new file mode 100644 index 000000000000..78447e8d3791 --- /dev/null +++ b/hw/virtio/vhost-user-rng.c @@ -0,0 +1,294 @@ +/* + * Vhost-user RNG virtio device + * + * Copyright (c) 2021 Mathieu Poirier + * + * Implementation seriously tailored on vhost-user-i2c.c + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/qdev-properties.h" +#include "hw/virtio/virtio-bus.h" +#include "hw/virtio/vhost-user-rng.h" +#include "qemu/error-report.h" +#include "standard-headers/linux/virtio_ids.h" + +static void vu_rng_start(VirtIODevice *vdev) +{ + VHostUserRNG *rng =3D VHOST_USER_RNG(vdev); + BusState *qbus =3D BUS(qdev_get_parent_bus(DEVICE(vdev))); + VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(qbus); + int ret; + int i; + + if (!k->set_guest_notifiers) { + error_report("binding does not support guest notifiers"); + return; + } + + ret =3D vhost_dev_enable_notifiers(&rng->vhost_dev, vdev); + if (ret < 0) { + error_report("Error enabling host notifiers: %d", -ret); + return; + } + + ret =3D k->set_guest_notifiers(qbus->parent, rng->vhost_dev.nvqs, true= ); + if (ret < 0) { + error_report("Error binding guest notifier: %d", -ret); + goto err_host_notifiers; + } + + rng->vhost_dev.acked_features =3D vdev->guest_features; + ret =3D vhost_dev_start(&rng->vhost_dev, vdev); + if (ret < 0) { + error_report("Error starting vhost-user-rng: %d", -ret); + goto err_guest_notifiers; + } + + /* + * guest_notifier_mask/pending not used yet, so just unmask + * everything here. virtio-pci will do the right thing by + * enabling/disabling irqfd. + */ + for (i =3D 0; i < rng->vhost_dev.nvqs; i++) { + vhost_virtqueue_mask(&rng->vhost_dev, vdev, i, false); + } + + return; + +err_guest_notifiers: + k->set_guest_notifiers(qbus->parent, rng->vhost_dev.nvqs, false); +err_host_notifiers: + vhost_dev_disable_notifiers(&rng->vhost_dev, vdev); +} + +static void vu_rng_stop(VirtIODevice *vdev) +{ + VHostUserRNG *rng =3D VHOST_USER_RNG(vdev); + BusState *qbus =3D BUS(qdev_get_parent_bus(DEVICE(vdev))); + VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(qbus); + int ret; + + if (!k->set_guest_notifiers) { + return; + } + + vhost_dev_stop(&rng->vhost_dev, vdev); + + ret =3D k->set_guest_notifiers(qbus->parent, rng->vhost_dev.nvqs, fals= e); + if (ret < 0) { + error_report("vhost guest notifier cleanup failed: %d", ret); + return; + } + + vhost_dev_disable_notifiers(&rng->vhost_dev, vdev); +} + +static void vu_rng_set_status(VirtIODevice *vdev, uint8_t status) +{ + VHostUserRNG *rng =3D VHOST_USER_RNG(vdev); + bool should_start =3D status & VIRTIO_CONFIG_S_DRIVER_OK; + + if (!vdev->vm_running) { + should_start =3D false; + } + + if (rng->vhost_dev.started =3D=3D should_start) { + return; + } + + if (should_start) { + vu_rng_start(vdev); + } else { + vu_rng_stop(vdev); + } +} + +static uint64_t vu_rng_get_features(VirtIODevice *vdev, + uint64_t requested_features, Error **e= rrp) +{ + /* No feature bits used yet */ + return requested_features; +} + +static void vu_rng_handle_output(VirtIODevice *vdev, VirtQueue *vq) +{ + /* + * Not normally called; it's the daemon that handles the queue; + * however virtio's cleanup path can call this. + */ +} + +static void vu_rng_guest_notifier_mask(VirtIODevice *vdev, int idx, bool m= ask) +{ + VHostUserRNG *rng =3D VHOST_USER_RNG(vdev); + + vhost_virtqueue_mask(&rng->vhost_dev, vdev, idx, mask); +} + +static bool vu_rng_guest_notifier_pending(VirtIODevice *vdev, int idx) +{ + VHostUserRNG *rng =3D VHOST_USER_RNG(vdev); + + return vhost_virtqueue_pending(&rng->vhost_dev, idx); +} + +static void vu_rng_connect(DeviceState *dev) +{ + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostUserRNG *rng =3D VHOST_USER_RNG(vdev); + + if (rng->connected) { + return; + } + + rng->connected =3D true; + + /* restore vhost state */ + if (virtio_device_started(vdev, vdev->status)) { + vu_rng_start(vdev); + } +} + +static void vu_rng_disconnect(DeviceState *dev) +{ + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostUserRNG *rng =3D VHOST_USER_RNG(vdev); + + if (!rng->connected) { + return; + } + + rng->connected =3D false; + + if (rng->vhost_dev.started) { + vu_rng_stop(vdev); + } +} + +static void vu_rng_event(void *opaque, QEMUChrEvent event) +{ + DeviceState *dev =3D opaque; + + switch (event) { + case CHR_EVENT_OPENED: + vu_rng_connect(dev); + break; + case CHR_EVENT_CLOSED: + vu_rng_disconnect(dev); + break; + case CHR_EVENT_BREAK: + case CHR_EVENT_MUX_IN: + case CHR_EVENT_MUX_OUT: + /* Ignore */ + break; + } +} + +static void vu_rng_device_realize(DeviceState *dev, Error **errp) +{ + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostUserRNG *rng =3D VHOST_USER_RNG(dev); + int ret; + + if (!rng->chardev.chr) { + error_setg(errp, "missing chardev"); + return; + } + + if (!vhost_user_init(&rng->vhost_user, &rng->chardev, errp)) { + return; + } + + virtio_init(vdev, "vhost-user-rng", VIRTIO_ID_RNG, 0); + + rng->req_vq =3D virtio_add_queue(vdev, 4, vu_rng_handle_output); + if (!rng->req_vq) { + error_setg_errno(errp, -1, "virtio_add_queue() failed"); + goto virtio_add_queue_failed; + } + + rng->vhost_dev.nvqs =3D 1; + rng->vhost_dev.vqs =3D g_new0(struct vhost_virtqueue, rng->vhost_dev.n= vqs); + if (!rng->vhost_dev.vqs) { + error_setg_errno(errp, -1, "memory allocation failed"); + goto vhost_dev_init_failed; + } + + ret =3D vhost_dev_init(&rng->vhost_dev, &rng->vhost_user, + VHOST_BACKEND_TYPE_USER, 0); + if (ret < 0) { + error_setg_errno(errp, -ret, "vhost_dev_init() failed"); + goto vhost_dev_init_failed; + } + + qemu_chr_fe_set_handlers(&rng->chardev, NULL, NULL, vu_rng_event, NULL, + dev, NULL, true); + + return; + +vhost_dev_init_failed: + virtio_delete_queue(rng->req_vq); +virtio_add_queue_failed: + virtio_cleanup(vdev); + vhost_user_cleanup(&rng->vhost_user); +} + +static void vu_rng_device_unrealize(DeviceState *dev) +{ + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostUserRNG *rng =3D VHOST_USER_RNG(dev); + + vu_rng_set_status(vdev, 0); + + vhost_dev_cleanup(&rng->vhost_dev); + g_free(rng->vhost_dev.vqs); + rng->vhost_dev.vqs =3D NULL; + virtio_delete_queue(rng->req_vq); + virtio_cleanup(vdev); + vhost_user_cleanup(&rng->vhost_user); +} + +static const VMStateDescription vu_rng_vmstate =3D { + .name =3D "vhost-user-rng", + .unmigratable =3D 1, +}; + +static Property vu_rng_properties[] =3D { + DEFINE_PROP_CHR("chardev", VHostUserRNG, chardev), + DEFINE_PROP_END_OF_LIST(), +}; + +static void vu_rng_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + VirtioDeviceClass *vdc =3D VIRTIO_DEVICE_CLASS(klass); + + device_class_set_props(dc, vu_rng_properties); + dc->vmsd =3D &vu_rng_vmstate; + set_bit(DEVICE_CATEGORY_INPUT, dc->categories); + + vdc->realize =3D vu_rng_device_realize; + vdc->unrealize =3D vu_rng_device_unrealize; + vdc->get_features =3D vu_rng_get_features; + vdc->set_status =3D vu_rng_set_status; + vdc->guest_notifier_mask =3D vu_rng_guest_notifier_mask; + vdc->guest_notifier_pending =3D vu_rng_guest_notifier_pending; +} + +static const TypeInfo vu_rng_info =3D { + .name =3D TYPE_VHOST_USER_RNG, + .parent =3D TYPE_VIRTIO_DEVICE, + .instance_size =3D sizeof(VHostUserRNG), + .class_init =3D vu_rng_class_init, +}; + +static void vu_rng_register_types(void) +{ + type_register_static(&vu_rng_info); +} + +type_init(vu_rng_register_types) diff --git a/include/hw/virtio/vhost-user-rng.h b/include/hw/virtio/vhost-u= ser-rng.h new file mode 100644 index 000000000000..071539996d1d --- /dev/null +++ b/include/hw/virtio/vhost-user-rng.h @@ -0,0 +1,33 @@ +/* + * Vhost-user RNG virtio device + * + * Copyright (c) 2021 Mathieu Poirier + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef _QEMU_VHOST_USER_RNG_H +#define _QEMU_VHOST_USER_RNG_H + +#include "hw/virtio/virtio.h" +#include "hw/virtio/vhost.h" +#include "hw/virtio/vhost-user.h" +#include "chardev/char-fe.h" + +#define TYPE_VHOST_USER_RNG "vhost-user-rng" +OBJECT_DECLARE_SIMPLE_TYPE(VHostUserRNG, VHOST_USER_RNG) + +struct VHostUserRNG { + /*< private >*/ + VirtIODevice parent; + CharBackend chardev; + struct vhost_virtqueue *vhost_vq; + struct vhost_dev vhost_dev; + VhostUserState vhost_user; + VirtQueue *req_vq; + bool connected; + + /*< public >*/ +}; + +#endif /* _QEMU_VHOST_USER_RNG_H */ --=20 2.25.1 From nobody Thu May 2 23:29:10 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1622577936; cv=none; d=zohomail.com; s=zohoarc; b=jvnUXu2hqSdirEyQRC4WapDYWesWXKNT9R1Pq59EqHQ4YMjpq0CL0IdjUU7xMK6fltB34BKQeWv/VBNUeOhJJJ0jTngTd/PV96xQlX865T+dDlMK+ItAX6HPR+qPMju7K1bqohnFBBi+OlM7zPcRqSgvM8pW0+s0o+qULyKI2Gk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622577936; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=S/O1M1xy8qnEH5DkM7qojc/M8Nl3BQRdLguDgKBWfTs=; b=aGLIr2C/lnMDxcxGVSFd1wLEIQGvkmwqrTGQeL+5/L+CE23Taus3YiIuWokz1qKxikyDdrQsg2V21+kfMucOHRG1DiiKNwij2m0v4YBGcyKqOiyHytgxhJgLhg3WAM66lRnNE8Dm+ufz4cBn4jjVLJwVRJIvhOrY3t5ZXXdZRn0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622577936187372.25774079375867; Tue, 1 Jun 2021 13:05:36 -0700 (PDT) Received: from localhost ([::1]:54390 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1loAdr-0004S4-5Z for importer2@patchew.org; Tue, 01 Jun 2021 16:05:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38520) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loAbb-0002LN-M8 for qemu-devel@nongnu.org; Tue, 01 Jun 2021 16:03:15 -0400 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]:37382) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1loAbZ-0002tP-Jp for qemu-devel@nongnu.org; Tue, 01 Jun 2021 16:03:15 -0400 Received: by mail-pj1-x1030.google.com with SMTP id 22-20020a17090a0c16b0290164a5354ad0so2097508pjs.2 for ; Tue, 01 Jun 2021 13:03:12 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id 23sm15486229pgv.90.2021.06.01.13.03.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Jun 2021 13:03:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=S/O1M1xy8qnEH5DkM7qojc/M8Nl3BQRdLguDgKBWfTs=; b=YoGcrAavacaYvrhB0kKTS/cEqqtP+LX30mTCG3MGptOqIK5hgqzkIakNFm+tvE0RJC rY2oSzhIQ+FSDksGfIkqgxxSNy5Frzwf0tnla3iLt54wIPBA/lljEPdyHrX9zRcDeGs3 TxAjLR1mnfTvHJyhDBING8EFRj3FOU1Lk1GktTQBcb4r7JvIUJoaoxKg5e7Kx4FXyq80 81rJHsM8OPwsom73iIkvck8MQDwkFOR+8zlaBF5snM53bdEbpOJ5kAwgvzw8dfg5zaX+ rhTrryciVF+wBDAwVKSQfVStUzwWLnpDvzi2tnfZBo3vY2k7hN82O6jfEFfanSgxvubd gY8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=S/O1M1xy8qnEH5DkM7qojc/M8Nl3BQRdLguDgKBWfTs=; b=rk4WbhdwjmEGvNoidXntsY5tHJdzVqQ8XLGuxCTaN9iZEGDtn9I4JOYrn/HYttUOpm b+DRIbUd9BW3eOIL8Ij8PnQrwgvOGKlZTIPQRfm8NAWZ8aAWRbakYhSzU7Ig10ZYGJvj //fhhn54kMn2oZP6tACsJ/b3f+UHzpvJGBf+fbfVDBzoQvHcRrpYfGwrWe691z4C/rtw 3DB/45bosOuz2Havxi2PTvDb0QkfBHdMnPlLq0OS/6EUQ7bcvtAYf0H6NzFi3pmCoxHw DuoVwrx40IxTUyWf3agHZ4iU/vNGzRXjf6MeYz5HkQzIf9VY5wQFvEMUTvpYS2VyHxgH dTLw== X-Gm-Message-State: AOAM530tfIBZgOQLg6OxpWosg9qrQfmMjjs7JApJMRk1/cyo3hC0yElM M2gR5IPIXv/nh6SBdiGiFMpWMA== X-Google-Smtp-Source: ABdhPJyj9TJm8j0fOHrFzYvtuFdqxlGvbQ+xbm256BZCFYirXFq5GJzqGNedWX9+PXuI8HuCQwn2XQ== X-Received: by 2002:a17:90a:8581:: with SMTP id m1mr26781567pjn.47.1622577791191; Tue, 01 Jun 2021 13:03:11 -0700 (PDT) From: Mathieu Poirier To: mst@redhat.com Subject: [PATCH 2/5] vhost-user-rng-pci: Add vhost-user-rng-pci implementation Date: Tue, 1 Jun 2021 14:03:02 -0600 Message-Id: <20210601200305.1772391-3-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210601200305.1772391-1-mathieu.poirier@linaro.org> References: <20210601200305.1772391-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1030; envelope-from=mathieu.poirier@linaro.org; helo=mail-pj1-x1030.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: viresh.kumar@linaro.org, alex.bennee@linaro.org, qemu-devel@nongnu.org, stratos-dev@op-lists.linaro.org Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This patch provides a PCI bus interface to the vhost-user-rng backed. The implentation is similar to what was done for vhost-user-i2c-pci and vhost-user-fs-pci. Signed-off-by: Mathieu Poirier --- hw/virtio/meson.build | 1 + hw/virtio/vhost-user-rng-pci.c | 79 ++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 hw/virtio/vhost-user-rng-pci.c diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index e386791f2a05..1430b370e64d 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -26,6 +26,7 @@ virtio_ss.add(when: 'CONFIG_VIRTIO_RNG', if_true: files('= virtio-rng.c')) virtio_ss.add(when: 'CONFIG_VIRTIO_IOMMU', if_true: files('virtio-iommu.c'= )) virtio_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-mem.c')) virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user-rn= g.c')) +virtio_ss.add(when: ['CONFIG_VHOST_USER_RNG', 'CONFIG_VIRTIO_PCI'], if_tru= e: files('vhost-user-rng-pci.c')) =20 virtio_pci_ss =3D ss.source_set() virtio_pci_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock-= pci.c')) diff --git a/hw/virtio/vhost-user-rng-pci.c b/hw/virtio/vhost-user-rng-pci.c new file mode 100644 index 000000000000..ffff2de39fd4 --- /dev/null +++ b/hw/virtio/vhost-user-rng-pci.c @@ -0,0 +1,79 @@ +/* + * Vhost-user RNG virtio device PCI glue + * + * Copyright (c) 2021 Mathieu Poirier + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "hw/qdev-properties.h" +#include "hw/virtio/vhost-user-rng.h" +#include "virtio-pci.h" + +struct VHostUserRNGPCI { + VirtIOPCIProxy parent_obj; + VHostUserRNG vdev; +}; + +typedef struct VHostUserRNGPCI VHostUserRNGPCI; + +#define TYPE_VHOST_USER_RNG_PCI "vhost-user-rng-pci-base" + +DECLARE_INSTANCE_CHECKER(VHostUserRNGPCI, VHOST_USER_RNG_PCI, + TYPE_VHOST_USER_RNG_PCI) + +static Property vhost_user_rng_pci_properties[] =3D { + DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, + DEV_NVECTORS_UNSPECIFIED), + DEFINE_PROP_END_OF_LIST(), +}; + +static void vhost_user_rng_pci_realize(VirtIOPCIProxy *vpci_dev, Error **e= rrp) +{ + VHostUserRNGPCI *dev =3D VHOST_USER_RNG_PCI(vpci_dev); + DeviceState *vdev =3D DEVICE(&dev->vdev); + + if (vpci_dev->nvectors =3D=3D DEV_NVECTORS_UNSPECIFIED) { + vpci_dev->nvectors =3D 1; + } + + qdev_realize(vdev, BUS(&vpci_dev->bus), errp); +} + +static void vhost_user_rng_pci_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + VirtioPCIClass *k =3D VIRTIO_PCI_CLASS(klass); + PCIDeviceClass *pcidev_k =3D PCI_DEVICE_CLASS(klass); + k->realize =3D vhost_user_rng_pci_realize; + set_bit(DEVICE_CATEGORY_INPUT, dc->categories); + device_class_set_props(dc, vhost_user_rng_pci_properties); + pcidev_k->vendor_id =3D PCI_VENDOR_ID_REDHAT_QUMRANET; + pcidev_k->device_id =3D 0; /* Set by virtio-pci based on virtio id */ + pcidev_k->revision =3D 0x00; + pcidev_k->class_id =3D PCI_CLASS_COMMUNICATION_OTHER; +} + +static void vhost_user_rng_pci_instance_init(Object *obj) +{ + VHostUserRNGPCI *dev =3D VHOST_USER_RNG_PCI(obj); + + virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), + TYPE_VHOST_USER_RNG); +} + +static const VirtioPCIDeviceTypeInfo vhost_user_rng_pci_info =3D { + .base_name =3D TYPE_VHOST_USER_RNG_PCI, + .non_transitional_name =3D "vhost-user-rng-pci", + .instance_size =3D sizeof(VHostUserRNGPCI), + .instance_init =3D vhost_user_rng_pci_instance_init, + .class_init =3D vhost_user_rng_pci_class_init, +}; + +static void vhost_user_rng_pci_register(void) +{ + virtio_pci_types_register(&vhost_user_rng_pci_info); +} + +type_init(vhost_user_rng_pci_register); --=20 2.25.1 From nobody Thu May 2 23:29:10 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1622578210; cv=none; d=zohomail.com; s=zohoarc; b=XO4lHI+RHAVHmeSbAE6Acte6dxzPOcyCx6nNdZjBy6oR3cm86Rn1fw6vBugzrHwWAjt77MJulhgtt7XaLOW+xt12eO/fGwCZt9XdX9MxqNuvOdm2+EV6YZg9M28gBk9N0JFQtEIEeZvj9v0zHOEQWwHLJAjuxu1mM86e5DirXfk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622578210; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=W8R0Atg7saQ4X6SR6zrNuGrXq38wBBSyfe438VmYV3M=; b=lxSmUWrc1W6J/K3Q14FWyU49ETZBIWfeDFH9uoI2UxWp1I/H9Nt+KRX5pU5s5VnF4XCcS1Ce8LTZrt2YCpXzNb7S/I5nrTDXM8cHvLaVCntxrrpaHkfUCFOAWRw6nLLMVPf6m7WxqTWsOE3Cf1RVb/iyu/VjyNnDtok4R83tSfI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622578210341438.838919860694; Tue, 1 Jun 2021 13:10:10 -0700 (PDT) Received: from localhost ([::1]:37470 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1loAiH-0003fg-5r for importer2@patchew.org; Tue, 01 Jun 2021 16:10:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38604) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loAbm-0002bY-L0 for qemu-devel@nongnu.org; Tue, 01 Jun 2021 16:03:26 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]:45846) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1loAbb-0002um-6E for qemu-devel@nongnu.org; Tue, 01 Jun 2021 16:03:26 -0400 Received: by mail-pf1-x42c.google.com with SMTP id d16so332238pfn.12 for ; Tue, 01 Jun 2021 13:03:14 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id 23sm15486229pgv.90.2021.06.01.13.03.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Jun 2021 13:03:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=W8R0Atg7saQ4X6SR6zrNuGrXq38wBBSyfe438VmYV3M=; b=bX5OMOKEzR9p/hbp6imDHjjQpmwQsffUO73nB98auPvjFJODrVyYJLMt8y5p5E//C2 9B4cfgkyknHWjWCildXUsXQaUv14of6kgUVdfgC1E38GBuiOG/cJsYMm+5tKLMVsEx4y 9bY0iGpSB2EOq+ZWR7g1GOGBixmx8JA7Pq+sKwQcTfeG3TZR4kUjf6dnmTXYFaQ2vaU1 his2EDiEqooefGsaisSlqoud6TWHyq+Z4gZWQPpfCuglpmMxrzIopVJgdRvpkHA/ova9 Ntzov2GgBfxvurWrv/WQiy0pdMsulC7oSyVePDqgs79W/sZSo7EDwyqyAztsEYx01vBB EgFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=W8R0Atg7saQ4X6SR6zrNuGrXq38wBBSyfe438VmYV3M=; b=QbByFgBv8yAT5qOEqt/2QiQ73g4r6XA42AHiQJos9P9bzZXb4Oe1WvXK5hCL6spYKW tj431OMfDSp6xjNSRtMnF+eDKnQ9j+6UTBL5GPc+xArMrkT/tesVX5bpgS73GHIhNS8p 4gCHzlTK+hBEPb7H+qKb2RthjrFrgE6jsdByKXi2QERgp0YYPahZGjVzO9EM6M88/qkM sYw+Foh4FpZfQZg/FzZcULASJkb6H/xSt39T8N5y4s2WEPAt7MzcdVhlZpHOjqcQcC39 8m5D8x9x27RNCrTZOlpVRVHsEa6NyQOS0TlrctN/k9Yu+W/pPoAGxXYgcdZBPox5z28A r4ZA== X-Gm-Message-State: AOAM533+LVlv+3dakR4JTRQm7Fy+xniasMirtJTNCaEeINAFOa7pBdoS LXpM2KfFJcvgyUOOivztKSeQYw== X-Google-Smtp-Source: ABdhPJxcxnp3S9EJl3BpTW+Xvn8Ls90KZWsk3XaXtmfsnKY2PQpwzn7lgB2u0sIdDrPoEtXSUc80+A== X-Received: by 2002:a65:52c8:: with SMTP id z8mr29974848pgp.50.1622577793416; Tue, 01 Jun 2021 13:03:13 -0700 (PDT) From: Mathieu Poirier To: mst@redhat.com Subject: [PATCH 3/5] vhost-user-rng: backend: Add RNG vhost-user daemon implementation Date: Tue, 1 Jun 2021 14:03:03 -0600 Message-Id: <20210601200305.1772391-4-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210601200305.1772391-1-mathieu.poirier@linaro.org> References: <20210601200305.1772391-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=mathieu.poirier@linaro.org; helo=mail-pf1-x42c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: viresh.kumar@linaro.org, alex.bennee@linaro.org, qemu-devel@nongnu.org, stratos-dev@op-lists.linaro.org Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This patch provides the vhost-user backend implementation to work in tandem with the vhost-user-rng implementation of the QEMU VMM. It uses the vhost-user API so that other VMM can re-use the interface without having to write the driver again. Signed-off-by: Mathieu Poirier --- tools/meson.build | 8 + tools/vhost-user-rng/50-qemu-rng.json.in | 5 + tools/vhost-user-rng/main.c | 403 +++++++++++++++++++++++ tools/vhost-user-rng/meson.build | 10 + 4 files changed, 426 insertions(+) create mode 100644 tools/vhost-user-rng/50-qemu-rng.json.in create mode 100644 tools/vhost-user-rng/main.c create mode 100644 tools/vhost-user-rng/meson.build diff --git a/tools/meson.build b/tools/meson.build index 3e5a0abfa29f..66b0a11fbb45 100644 --- a/tools/meson.build +++ b/tools/meson.build @@ -24,3 +24,11 @@ endif if have_virtiofsd subdir('virtiofsd') endif + +have_virtiorng =3D (have_system and + have_tools and + 'CONFIG_LINUX' in config_host) + +if have_virtiorng + subdir('vhost-user-rng') +endif diff --git a/tools/vhost-user-rng/50-qemu-rng.json.in b/tools/vhost-user-rn= g/50-qemu-rng.json.in new file mode 100644 index 000000000000..9186c3c6fe1d --- /dev/null +++ b/tools/vhost-user-rng/50-qemu-rng.json.in @@ -0,0 +1,5 @@ +{ + "description": "QEMU vhost-user-rng", + "type": "bridge", + "binary": "@libexecdir@/vhost-user-rng" +} diff --git a/tools/vhost-user-rng/main.c b/tools/vhost-user-rng/main.c new file mode 100644 index 000000000000..ba7380b12659 --- /dev/null +++ b/tools/vhost-user-rng/main.c @@ -0,0 +1,403 @@ +/* + * VIRTIO RNG Emulation via vhost-user + * + * Copyright (c) 2021 Mathieu Poirier + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#define G_LOG_DOMAIN "vhost-user-rng" +#define G_LOG_USE_STRUCTURED 1 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "qemu/cutils.h" +#include "subprojects/libvhost-user/libvhost-user-glib.h" +#include "subprojects/libvhost-user/libvhost-user.h" + +#ifndef container_of +#define container_of(ptr, type, member) ({ \ + const typeof(((type *) 0)->member) * __mptr =3D (ptr); \ + (type *) ((char *) __mptr - offsetof(type, member)); }) +#endif + +typedef struct { + VugDev dev; + struct itimerspec ts; + timer_t rate_limit_timer; + pthread_mutex_t rng_mutex; + pthread_cond_t rng_cond; + int64_t quota_remaining; + bool activate_timer; + GMainLoop *loop; +} VuRNG; + +static gboolean print_cap, verbose; +static gchar *source_path, *socket_path; +static gint source_fd, socket_fd =3D -1; + +/* Defaults tailored on virtio-rng.c */ +static uint32_t period_ms =3D 1 << 16; +static uint64_t max_bytes =3D INT64_MAX; + +static void check_rate_limit(union sigval sv) +{ + VuRNG *rng =3D sv.sival_ptr; + bool wakeup =3D false; + + pthread_mutex_lock(&rng->rng_mutex); + /* + * The timer has expired and the guest has used all available + * antropy, which means function vu_rng_handle_request() is waiting + * on us. As such wake it up once we're done here. + */ + if (rng->quota_remaining =3D=3D 0) { + wakeup =3D true; + } + + /* + * Reset the antropy available to the guest and tell function + * vu_rng_handle_requests() to start the timer before using it. + */ + rng->quota_remaining =3D max_bytes; + rng->activate_timer =3D true; + pthread_mutex_unlock(&rng->rng_mutex); + + if (wakeup) { + pthread_cond_signal(&rng->rng_cond); + } +} + +static void setup_timer(VuRNG *rng) +{ + struct sigevent sev; + int ret; + + memset(&rng->ts, 0, sizeof(struct itimerspec)); + rng->ts.it_value.tv_sec =3D period_ms / 1000; + rng->ts.it_value.tv_nsec =3D (period_ms % 1000) * 1000000; + + /* + * Call function check_rate_limit() as if it was the start of + * a new thread when the timer expires. + */ + sev.sigev_notify =3D SIGEV_THREAD; + sev.sigev_notify_function =3D check_rate_limit; + sev.sigev_value.sival_ptr =3D rng; + /* Needs to be NULL if defaults attributes are to be used. */ + sev.sigev_notify_attributes =3D NULL; + ret =3D timer_create(CLOCK_MONOTONIC, &sev, &rng->rate_limit_timer); + if (ret < 0) { + fprintf(stderr, "timer_create() failed\n"); + } + +} + + +/* Virtio helpers */ +static uint64_t rng_get_features(VuDev *dev) +{ + if (verbose) { + g_info("%s: replying", __func__); + } + return 0; +} + +static void rng_set_features(VuDev *dev, uint64_t features) +{ + if (verbose && features) { + g_autoptr(GString) s =3D g_string_new("Requested un-handled featur= e"); + g_string_append_printf(s, " 0x%" PRIx64 "", features); + g_info("%s: %s", __func__, s->str); + } +} + +static void vu_rng_handle_requests(VuDev *dev, int qidx) +{ + VuRNG *rng =3D container_of(dev, VuRNG, dev.parent); + VuVirtq *vq =3D vu_get_queue(dev, qidx); + VuVirtqElement *elem; + size_t to_read; + int len, ret; + + for (;;) { + /* Get element in the vhost virtqueue */ + elem =3D vu_queue_pop(dev, vq, sizeof(VuVirtqElement)); + if (!elem) { + break; + } + + /* Get the amount of antropy to read from the vhost server */ + to_read =3D elem->in_sg[0].iov_len; + + pthread_mutex_lock(&rng->rng_mutex); + + /* + * We have consumed all entropy available for this time slice. + * Wait for the timer (check_rate_limit()) to tell us about the + * start of a new time slice. + */ + if (rng->quota_remaining =3D=3D 0) { + pthread_cond_wait(&rng->rng_cond, &rng->rng_mutex); + } + + /* Start the timer if the last time slice has expired */ + if (rng->activate_timer =3D=3D true) { + rng->activate_timer =3D false; + ret =3D timer_settime(rng->rate_limit_timer, 0, &rng->ts, NULL= ); + if (ret < 0) { + fprintf(stderr, "timer_settime() failed\n"); + } + } + + /* Make sure we don't read more than it's available */ + if (rng->quota_remaining < to_read) { + to_read =3D rng->quota_remaining; + } + + len =3D read(source_fd, elem->in_sg[0].iov_base, to_read); + + /* Simply return 0 if an error occurs */ + if (len < 0) { + len =3D 0; + } + + rng->quota_remaining -=3D len; + + pthread_mutex_unlock(&rng->rng_mutex); + + vu_queue_push(dev, vq, elem, len); + free(elem); + } + + vu_queue_notify(dev, vq); +} + +static void +vu_rng_queue_set_started(VuDev *dev, int qidx, bool started) +{ + VuVirtq *vq =3D vu_get_queue(dev, qidx); + + g_debug("queue started %d:%d\n", qidx, started); + + if (!qidx) { + vu_set_queue_handler(dev, vq, started ? vu_rng_handle_requests : N= ULL); + } +} + +/* + * Any messages not handled here are processed by the libvhost library + * itself. + */ +static int rng_process_msg(VuDev *dev, VhostUserMsg *msg, int *do_reply) +{ + VuRNG *rng =3D container_of(dev, VuRNG, dev.parent); + + if (msg->request =3D=3D VHOST_USER_NONE) { + g_main_loop_quit(rng->loop); + return 1; + } + + return 0; +} + +static const VuDevIface vuiface =3D { + .set_features =3D rng_set_features, + .get_features =3D rng_get_features, + .queue_set_started =3D vu_rng_queue_set_started, + .process_msg =3D rng_process_msg, +}; + +static gboolean hangup(gpointer user_data) +{ + GMainLoop *loop =3D (GMainLoop *) user_data; + + g_printerr("%s: caught hangup/quit signal, quitting", __func__); + g_main_loop_quit(loop); + return true; +} + +static void panic(VuDev *dev, const char *msg) +{ + g_critical("%s\n", msg); + exit(EXIT_FAILURE); +} + +/* Print vhost-user.json backend program capabilities */ +static void print_capabilities(void) +{ + printf("{\n"); + printf(" \"type\": \"RNG\"\n"); + printf(" \"filename\": [ RNG source ]\n"); + printf("}\n"); +} + +static GOptionEntry options[] =3D { + { "socket-path", 's', 0, G_OPTION_ARG_FILENAME, &socket_path, + "Location of vhost-user Unix domain socket, incompatible with --fd", + "PATH" }, + { "fd", 'f', 0, G_OPTION_ARG_INT, &socket_fd, + "Specify the backend file-descriptor, incompatible with --socket-pat= h", + "FD" }, + { "period", 'p', 0, G_OPTION_ARG_INT, &period_ms, + "Time needed (in ms) to transfer a maximum amount of byte", NULL }, + { "max-bytes", 'm', 0, G_OPTION_ARG_INT64, &max_bytes, + "Maximum amount of byte that can be transferred in a period", NULL }, + { "filename", 'n', 0, G_OPTION_ARG_FILENAME, &source_path, + "RNG source, defaults to /dev/urandom", "PATH" }, + { "print-capabilities", 'c', 0, G_OPTION_ARG_NONE, &print_cap, + "Output to stdout the backend capabilities in JSON format and exit", + NULL}, + { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, + "Be more verbose in output", NULL}, + { NULL } +}; + +int main(int argc, char *argv[]) +{ + GError *error =3D NULL; + GOptionContext *context; + g_autoptr(GSocket) socket =3D NULL; + char default_source[] =3D "/dev/urandom"; + char *source =3D default_source; + VuRNG rng; + + context =3D g_option_context_new("vhost-user emulation of RNG device"); + g_option_context_add_main_entries(context, options, "vhost-user-rng"); + if (!g_option_context_parse(context, &argc, &argv, &error)) { + g_printerr("option parsing failed: %s\n", error->message); + exit(1); + } + + if (print_cap) { + print_capabilities(); + exit(0); + } + + if (!socket_path && socket_fd < 0) { + g_printerr("Please specify either --fd or --socket-path\n"); + exit(EXIT_FAILURE); + } + + if (socket_path && socket_fd > 0) { + g_printerr("Either --fd or --socket-path, not both\n"); + exit(EXIT_FAILURE); + } + + if (max_bytes > INT64_MAX) { + g_printerr("'max-bytes' parameter must be non-negative, " + "and less than 2^63\n"); + exit(EXIT_FAILURE); + } + + if (period_ms <=3D 0) { + g_printerr("'period' parameter expects a positive integer\n"); + exit(EXIT_FAILURE); + } + + /* + * Now create a vhost-user socket that we will receive messages + * on. Once we have our handler set up we can enter the glib main + * loop. + */ + if (socket_path) { + g_autoptr(GSocketAddress) addr =3D g_unix_socket_address_new(socke= t_path); + g_autoptr(GSocket) bind_socket =3D g_socket_new(G_SOCKET_FAMILY_UN= IX, + G_SOCKET_TYPE_STREAM, + G_SOCKET_PROTOCOL_DE= FAULT, + &error); + + if (!g_socket_bind(bind_socket, addr, false, &error)) { + g_printerr("Failed to bind to socket at %s (%s).\n", + socket_path, error->message); + exit(EXIT_FAILURE); + } + if (!g_socket_listen(bind_socket, &error)) { + g_printerr("Failed to listen on socket %s (%s).\n", + socket_path, error->message); + } + g_message("awaiting connection to %s", socket_path); + socket =3D g_socket_accept(bind_socket, NULL, &error); + if (!socket) { + g_printerr("Failed to accept on socket %s (%s).\n", + socket_path, error->message); + } + } else { + socket =3D g_socket_new_from_fd(socket_fd, &error); + if (!socket) { + g_printerr("Failed to connect to FD %d (%s).\n", + socket_fd, error->message); + exit(EXIT_FAILURE); + } + } + + /* Overwrite default RNG source with what user provided, if any */ + if (source_path) { + source =3D source_path; + } + + source_fd =3D open(source, O_RDWR); + if (source_fd < 0) { + g_printerr("Failed to open RNG source %s\n", source); + g_socket_close(socket, &error); + unlink(socket_path); + exit(EXIT_FAILURE); + } + + /* catch exit signals */ + g_unix_signal_add(SIGHUP, hangup, rng.loop); + g_unix_signal_add(SIGINT, hangup, rng.loop); + + /* + * Create the main loop first so all the various sources can be + * added. As well as catching signals we need to ensure vug_init + * can add it's GSource watches. + */ + rng.loop =3D g_main_loop_new(NULL, FALSE); + + if (!vug_init(&rng.dev, 1, g_socket_get_fd(socket), + panic, &vuiface)) { + g_printerr("Failed to initialize libvhost-user-glib.\n"); + exit(EXIT_FAILURE); + } + + rng.quota_remaining =3D max_bytes; + rng.activate_timer =3D true; + pthread_mutex_init(&rng.rng_mutex, NULL); + pthread_cond_init(&rng.rng_cond, NULL); + setup_timer(&rng); + + if (verbose) { + g_info("period_ms: %d tv_sec: %ld tv_nsec: %lu\n", + period_ms, rng.ts.it_value.tv_sec, rng.ts.it_value.tv_nsec); + } + + g_message("entering main loop, awaiting messages"); + g_main_loop_run(rng.loop); + g_message("finished main loop, cleaning up"); + + g_main_loop_unref(rng.loop); + vug_deinit(&rng.dev); + timer_delete(rng.rate_limit_timer); + close(source_fd); + unlink(socket_path); +} diff --git a/tools/vhost-user-rng/meson.build b/tools/vhost-user-rng/meson.= build new file mode 100644 index 000000000000..4dc386daf335 --- /dev/null +++ b/tools/vhost-user-rng/meson.build @@ -0,0 +1,10 @@ +executable('vhost-user-rng', files( + 'main.c'), + dependencies: [qemuutil, glib, gio, rt], + install: true, + install_dir: get_option('libexecdir')) + +configure_file(input: '50-qemu-rng.json.in', + output: '50-qemu-rng.json', + configuration: config_host, + install_dir: qemu_datadir / 'vhost-user') --=20 2.25.1 From nobody Thu May 2 23:29:10 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1622578127; cv=none; d=zohomail.com; s=zohoarc; b=YwGhBysJlCxN8ov7GXXBhbsT5r1GhR4VbUuGVqVYvWWCcdD3kWer8xqRfdeScDZeOwCluBjp1CKwMNSxbN5enAw6+F8q+qYDl3qVLP9cHrW/r8Woy54fdgEunEmQwn7kJIaWRbnEZiKCIOcTcw6uMDAMcHSFzzF1y4fiMoNuEDE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622578127; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bw6uvOLKEisckETLGn7QqEllExX+W/+p46wjCLwcazI=; b=FoiwzM+xW+ADGLzSfUWbqpn5MiDBjxPy6RrbJuFwYqsufBuaCueyvj/ewHIVYNRcEkWe83cHrlxeip4JI5zbchejbOzit02jOIrYXCL40TGODD+pGtwQfU5B4kh0YX/luosP1oAUDzHC3zZmyOSpdd+zH6/OrQlr/rNHwFge5x0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622578127135141.50675121989389; Tue, 1 Jun 2021 13:08:47 -0700 (PDT) Received: from localhost ([::1]:60516 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1loAgw-0000B2-4B for importer2@patchew.org; Tue, 01 Jun 2021 16:08:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38572) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loAbg-0002Re-Ti for qemu-devel@nongnu.org; Tue, 01 Jun 2021 16:03:20 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]:39760) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1loAbc-0002x5-TS for qemu-devel@nongnu.org; Tue, 01 Jun 2021 16:03:20 -0400 Received: by mail-pf1-x42e.google.com with SMTP id k15so360335pfp.6 for ; Tue, 01 Jun 2021 13:03:16 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id 23sm15486229pgv.90.2021.06.01.13.03.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Jun 2021 13:03:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bw6uvOLKEisckETLGn7QqEllExX+W/+p46wjCLwcazI=; b=Zn4t39gQjDWPIh9hs4r3J4Igjv/8VduTKdW0SvyAD31aQjYr9nNhOdx7WdLup8ObT8 cOAvzax7p3PaTVTiGoj+RzgPmBK3tdgKwL+HnDkyuFENcY48adRnE7jGwWSYJ3ufTqRD GH4dgE6JdOSSuDiF/ykNqTuiMOctw7NnzIj7MWPBPpdUwqVVFslkZpbuNHPUsOQFhOak Aullbw6hDLfz/ens9AWZAxOjfLRPYzCP43L9ZSD3lvX7C7HzFkfuYZPuQktvWWmcg316 pqARbDEEK6pXzj9SkNTcof2gw3zfgzyAyvwzHsJyfqusyuwmWqfn5y2KdGUIGWCmyfJS eAxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bw6uvOLKEisckETLGn7QqEllExX+W/+p46wjCLwcazI=; b=pB4PhsoUQftHr3Sf0GKaivjjhP9aGI0xiFLXvKsokyHy8qDcVVtroTr7dHhy2li7v7 wZaEos9+hW/CjEGmbBLa/kb3VJlQS3RLKrqtotXmVfGtMf/uBquPvltUvXcRxaf0sH0W VRe8QNTSOL6ljzVw0NPdlj8uTxdm9MrnJWzjHYWXIOSRMePfycexJvo4/StyfP0efgZm eNlyIKHITUHMUm1YDf4BhIKwwXfr/8jHQvGp9DhRkrgyuBpxRPzt+zc8eyqvU3cdvj1B 5whZu2rRaCQQc95QngZfjuxXSFaaN6icq081qZU2B4fOmMBCpjc1giDj8WoHkQ+kA/e2 3WJA== X-Gm-Message-State: AOAM530+/1/+5GeW6aBSTSiMBTljioehJiCy53iYOboL1mry6hVw3EuI eQj9r44wlO9kbNCz0cMixTG8gw== X-Google-Smtp-Source: ABdhPJxmHWEHDPOVaZ/BiGHUlG65MvDjMANP/XwmRwLFdFULf1pbcr3vIQryNdAQTGg2UvR1PyNx4A== X-Received: by 2002:a63:1613:: with SMTP id w19mr29419436pgl.379.1622577795398; Tue, 01 Jun 2021 13:03:15 -0700 (PDT) From: Mathieu Poirier To: mst@redhat.com Subject: [PATCH 4/5] docs: Add documentation for vhost based RNG implementation Date: Tue, 1 Jun 2021 14:03:04 -0600 Message-Id: <20210601200305.1772391-5-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210601200305.1772391-1-mathieu.poirier@linaro.org> References: <20210601200305.1772391-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42e; envelope-from=mathieu.poirier@linaro.org; helo=mail-pf1-x42e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: viresh.kumar@linaro.org, alex.bennee@linaro.org, qemu-devel@nongnu.org, stratos-dev@op-lists.linaro.org Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Add description and example for the vhost-user based RNG implementation. Tailored on Viresh Kumar's vhost-user-i2c documentation. Signed-off-by: Mathieu Poirier --- docs/tools/vhost-user-rng.rst | 74 +++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 docs/tools/vhost-user-rng.rst diff --git a/docs/tools/vhost-user-rng.rst b/docs/tools/vhost-user-rng.rst new file mode 100644 index 000000000000..7f69d7bb3c58 --- /dev/null +++ b/docs/tools/vhost-user-rng.rst @@ -0,0 +1,74 @@ +QEMU vhost-user-rng - RNG emulation backend +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Synopsis +-------- + +**vhost-user-rng** [*OPTIONS*] + +Description +----------- + +This program is a vhost-user backend that emulates a VirtIO random number +generator (RNG). It uses the host's random number generator pool, +/dev/urandom by default but configurable at will, to satisfy requests from +guests. + +This program is designed to work with QEMU's ``-device +vhost-user-rng-pci`` but should work with any virtual machine monitor +(VMM) that supports vhost-user. See the Examples section below. + +Options +------- + +.. program:: vhost-user-rng + +.. option:: -h, --help + + Print help. + +.. option:: -v, --verbose + + Increase verbosity of output + +.. option:: -s, --socket-path=3DPATH + + Listen on vhost-user UNIX domain socket at PATH. Incompatible with --fd. + +.. option:: -f, --fd=3DFDNUM + + Accept connections from vhost-user UNIX domain socket file descriptor FD= NUM. + The file descriptor must already be listening for connections. + Incompatible with --socket-path. + +.. option:: -p, --period + + Rate, in milliseconds, at which the RNG hardware can generate random dat= a. + Used in conjunction with the --max-bytes option. + +.. option:: -m, --max-bytes + + In conjuction with the --period parameter, provides the maximum number o= f byte + per milliseconds a RNG device can generate. + +Examples +-------- + +The daemon should be started first: + +:: + + host# vhost-user-rng --socket-path=3Drng.sock --period=3D1000 --max-byte= s=3D4096 + +The QEMU invocation needs to create a chardev socket the device can +use to communicate as well as share the guests memory over a memfd. + +:: + + host# qemu-system \ + -chardev socket,path=3D$(PATH)/rng.sock,id=3Drng0 \ + -device vhost-user-rng-pci,chardev=3Drng0 \ + -m 4096 \ + -object memory-backend-file,id=3Dmem,size=3D4G,mem-path=3D/dev/shm,s= hare=3Don \ + -numa node,memdev=3Dmem \ + ... --=20 2.25.1 From nobody Thu May 2 23:29:10 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1622578123; cv=none; d=zohomail.com; s=zohoarc; b=IQXbA3WdnVauHsV58v/U3GSc3xVv86shv1K1mprIdaL3pmlFvHv2MKUFVb60a4dWPFIHRBBE0+JJW7NVXrj4majbsySlWwe0F1ggHnpcrWx+hf9oy5bYriizUfX1u4JzLRm9AFq7iManbqb7kox+SdfHp2kDjc0YO9gyc5r2iPw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622578123; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hWMEMeWS1rJpbPU/bwAynu8rJ3Hz8BETIjICwx5CVa8=; b=Y/bwPbgzonh16n3zsub6eX2/owFGIqBRx4cRz6fsFa4fRDnG/l+SMLV2xfxdxNDpFVQIDXaYHWIpAksLvR2j0IlkDNNVqLLYHcHqy095TmvTos4jMOiInoDCmUfk2olmvJRbfZJ9a9SPc+7Usu8mdF0yezBW5yB4bC29WG6Gfn0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622578123829577.4847861346606; Tue, 1 Jun 2021 13:08:43 -0700 (PDT) Received: from localhost ([::1]:60164 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1loAgs-0008Nk-Mh for importer2@patchew.org; Tue, 01 Jun 2021 16:08:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38600) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loAbl-0002Xp-Bs for qemu-devel@nongnu.org; Tue, 01 Jun 2021 16:03:25 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]:39780) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1loAbe-0002y2-Ss for qemu-devel@nongnu.org; Tue, 01 Jun 2021 16:03:25 -0400 Received: by mail-pl1-x636.google.com with SMTP id q16so7488828pls.6 for ; Tue, 01 Jun 2021 13:03:17 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id 23sm15486229pgv.90.2021.06.01.13.03.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Jun 2021 13:03:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hWMEMeWS1rJpbPU/bwAynu8rJ3Hz8BETIjICwx5CVa8=; b=dSV2fgLieD94DqXaTh1FwvRU6L/ewQP4qVQyGRUzKcCwIXE771UcSzvQDCX5RLwUHk xrgVigpojLzmzijtFQl3QsHcIR7C7bs7//ajKYwhmyZHUuZEx/ciwdEYR6W1luZplKVW v7DxYkxTdzBPlmHzzafWFp4GubAbihox9b8wi1WaYSkFsurSuLSlofd8qq3aVQSTpfXc JPOvJ+ZOVxanxHRE9IOcYCuLYftwCH4qEAZHBSYM6HpdilApWAyu3NFzc+DjlJHG1d2B rId6Hte1ImLrA6tZG679skcy60TpIdnRETKXJtJkMQQGyk6bOFqkazepVz48jNld6W4p cj+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hWMEMeWS1rJpbPU/bwAynu8rJ3Hz8BETIjICwx5CVa8=; b=p9kbExF4bJC3PcysNjcy/P/BJlV8nm6obvawIQLUpC+Xl9gtT6r6Bj3bxjV1WOEmYi w6hWsU0EwRNRD98XFTfyHKXUuzf2/TPdQlytPBQtDHB7qIP137n7Ef8xyEleYYY8Q/oa Tcn6x8JfDgr+jzO6IGqLxcs4QL9Ky2lqleaVyJMMbKz0tH1HWCFK2kmDaopA7vwXSiTJ Ih7VZgEYYJ2cEg9RNQEza44rEJcKG1PRZjGa3HaFXEpxgor2AVZQhIxX7NFnhQEu2Ckh KdW6HsiC2ZBi8nGhY+gvPczHvVJsJC9ATeOJNeEe4yR5nIsKGH7IOAZIQmiKYBYf3eg6 eqmg== X-Gm-Message-State: AOAM530aJgxeWDvB3YeDcQ6f7Ch1G4waYLKXz/ACBexHf7iemYoRvJOs Cr6ZtLe4y6SyFpLwYiTsf9L/Ww== X-Google-Smtp-Source: ABdhPJxwIc0XwMcy0j+A2glFHFWKYBRYo2sGc2pqaGdgM45s3Ml+rQJmIOgP69FNDFNt9Y1T1SSsxw== X-Received: by 2002:a17:90a:3f8a:: with SMTP id m10mr1534326pjc.77.1622577796943; Tue, 01 Jun 2021 13:03:16 -0700 (PDT) From: Mathieu Poirier To: mst@redhat.com Subject: [PATCH 5/5] MAINTAINERS: Add maintainer for vhost-user RNG implementation Date: Tue, 1 Jun 2021 14:03:05 -0600 Message-Id: <20210601200305.1772391-6-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210601200305.1772391-1-mathieu.poirier@linaro.org> References: <20210601200305.1772391-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=mathieu.poirier@linaro.org; helo=mail-pl1-x636.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: viresh.kumar@linaro.org, alex.bennee@linaro.org, qemu-devel@nongnu.org, stratos-dev@op-lists.linaro.org Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This patch adds entry for the vhost-user-rng related files. Signed-off-by: Mathieu Poirier --- MAINTAINERS | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 5f55404f2fae..6a0d61443571 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1937,6 +1937,15 @@ F: include/sysemu/rng*.h F: backends/rng*.c F: tests/qtest/virtio-rng-test.c =20 +vhost-user-rng +M: Mathieu Poirier +S: Supported +F: docs/tools/vhost-user-rng.rst +F: hw/virtio/vhost-user-rng.c +F: hw/virtio/vhost-user-rng-pci.c +F: include/hw/virtio/vhost-user-rng.h +F: tools/vhost-user-rng/* + virtio-crypto M: Gonglei S: Supported --=20 2.25.1