From patchwork Tue May 24 15:40:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 575739 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:c603:0:0:0:0 with SMTP id jv3csp2417384mab; Tue, 24 May 2022 08:52:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycDI0A4imfXg19pp8r+8uk8qZ6jS5/22LBsZPyArsqfbWHBVm5uRhqil4sQUfs3uYRUvzp X-Received: by 2002:a0c:e7c7:0:b0:461:e559:18d0 with SMTP id c7-20020a0ce7c7000000b00461e55918d0mr22029960qvo.2.1653407564082; Tue, 24 May 2022 08:52:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653407564; cv=none; d=google.com; s=arc-20160816; b=mcANVbKBXYr7+YFzhYfPJzL2A3XGD33BM38+EuTvw1kTYBBeYaw8k8orB/Q5g8MxNd ZvIH2Jjpy8y3p6jzVohNHt5GO9S4daDgMCRXAGLemVIs3Bwax5veoUKYWnuT5CUYk123 igoX52v5BWDXBex5zJiiDfw4hDgSc4SAzWkMOwI5cP9ZGhHi0HtItVTBA4b42akKSGxi aRwvZNofStEQvVKYMLXdqMB5otJIO/lxmarjPw0vMnTbqN5Fv5Pvu/hpp5N9EzIkj+Oi pr8XRtW13FrTf7xAFYKPgZqmDNj33NrKuP2sz5fxO1QwXRwinX6EkKiW+ucch80wwKcz mylQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vBtL52cUVXRCn2Iw8uz2+J2VOEbS3hV9Ib2rQvMqV9g=; b=Uec+BBxPKayJhSeyPv8gXYqGwimW/CarQVoYAK3IPGAXzp6bIM5HKuVEDXFJHP5Xm+ fTLgs2Ar7MoCSBMEvz8bildoW/1aOotMOTMJ3fQYHWj72wNzYWcCGyteRUdKGH8Z2+Z9 tl07QKHM2pE3wzrZwjZh5SXE6t9r6W3JFsGMlhY3iYrFQyXMiJWAwie2Vg4LF09Sl3lz Ig/oYhqcAjDBUasx79UPy1zEygiLkXMV1DP7wLT8Lrv12jCyB8xgvJUKanl8wrUIi9QM gt8OQogYz1ff8z5/ykSZN704wnjeKvI6AFpelDbQ7fAqwa7ecj3vRmEjFOZLGJtJ2M1A MvYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FB+WsbPW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d14-20020ac85d8e000000b002ebd7a977dbsi4681836qtx.310.2022.05.24.08.52.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 May 2022 08:52:44 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FB+WsbPW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59888 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntWpu-0000Ju-Lg for patch@linaro.org; Tue, 24 May 2022 11:52:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42940) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntWej-00042Z-QC for qemu-devel@nongnu.org; Tue, 24 May 2022 11:41:09 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:37841) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ntWec-0005Lz-LR for qemu-devel@nongnu.org; Tue, 24 May 2022 11:41:09 -0400 Received: by mail-wr1-x436.google.com with SMTP id t6so26286248wra.4 for ; Tue, 24 May 2022 08:41:02 -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=vBtL52cUVXRCn2Iw8uz2+J2VOEbS3hV9Ib2rQvMqV9g=; b=FB+WsbPWMMXudRzX/nrHkt/8nRUQMXPRKwDKsm7ykE8csKKpJ/kuARHxSrgXx08dz5 RWNXbVpeVgNVivIVfWCV20b/ioGObn+PpBuY7UJWIANpX0Qe2tPAQlaZ9p6usidh3OhC pHbcUYy7/G9UY6FhD2L+mOZV5gcXjbZSd88S3p2vACVayEP1m+zypJjdlJtIlAs5dd8R 18z+Ot/es6sS8pyT6YS6ZkDoV2hmZtQxt2GcEpRfmj2vdrw8MlFa1uyhPsmPsHTBXuRf qAY+eFT5TQCyXKX2m7V9vLE+2yL4WOPKgRi6QNWcirJ2oayg/P0iEGEal3aEv0EKcno8 0Clg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vBtL52cUVXRCn2Iw8uz2+J2VOEbS3hV9Ib2rQvMqV9g=; b=uhapn9sEDSjVdKxSVb8Jy4cEnJG5ha8LOnNGkAckc6OWG2IAl0pKaAc/pm/Le9Muhu /BjANOHCxByaXh99yB/RRYl40qFAV9UX6WhoaSpvV7Gc+2oLq9vPF4Eern3eupkKzPCJ SMq+lbxiQk8aVnf4kubvMMAiwYzQ8H1Bpw8eIknrO8MyjIPTQt1LGV1krhTJJicbM2/G 9OFPZTqkrPm2bdKKZD0kGZVdRpPgnc5uI3WCylKZHeiJQV71WiHFcwD8XW4Hd/kwcUEk 8PtPGkw63a1RfCKBQl8cGYfCGjoiQXeuAjJXNtjWoDVcsWH2vKf+s2E89Po/l6CAJnKL pJGg== X-Gm-Message-State: AOAM532wgON9nCNadGDjkTgsIo7PBAhcm4ePkFdT9dAivEeN9duy7KO6 PE/F1RwMjraFpmLsEp4UQeaqdA== X-Received: by 2002:a5d:648e:0:b0:20f:d9b6:a35f with SMTP id o14-20020a5d648e000000b0020fd9b6a35fmr9739650wri.333.1653406861281; Tue, 24 May 2022 08:41:01 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id z16-20020adfbbd0000000b0020cfed0bb7fsm13081406wrg.53.2022.05.24.08.40.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 May 2022 08:40:57 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 7EB501FFB8; Tue, 24 May 2022 16:40:56 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Raphael Norwitz Subject: [PATCH v2 01/15] contrib/vhost-user-blk: fix 32 bit build and enable Date: Tue, 24 May 2022 16:40:42 +0100 Message-Id: <20220524154056.2896913-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220524154056.2896913-1-alex.bennee@linaro.org> References: <20220524154056.2896913-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x436.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We were not building the vhost-user-blk server due to 32 bit compilation problems. The problem was due to format string types so fix that and then enable the build. Tweak the rule to follow the same rules as other vhost-user daemons. Signed-off-by: Alex Bennée Message-Id: <20220321153037.3622127-12-alex.bennee@linaro.org> Reviewed-by: Stefan Hajnoczi Reviewed-by: Raphael Norwitz --- meson.build | 2 +- contrib/vhost-user-blk/vhost-user-blk.c | 6 +++--- contrib/vhost-user-blk/meson.build | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/meson.build b/meson.build index 9ebc00f032..a33ed52b7a 100644 --- a/meson.build +++ b/meson.build @@ -1489,7 +1489,7 @@ have_vhost_user_blk_server = get_option('vhost_user_blk_server') \ error_message: 'vhost_user_blk_server requires linux') \ .require(have_vhost_user, error_message: 'vhost_user_blk_server requires vhost-user support') \ - .disable_auto_if(not have_system) \ + .disable_auto_if(not have_tools and not have_system) \ .allowed() if get_option('fuse').disabled() and get_option('fuse_lseek').enabled() diff --git a/contrib/vhost-user-blk/vhost-user-blk.c b/contrib/vhost-user-blk/vhost-user-blk.c index cd4a5d7335..9cb78ca1d0 100644 --- a/contrib/vhost-user-blk/vhost-user-blk.c +++ b/contrib/vhost-user-blk/vhost-user-blk.c @@ -146,7 +146,7 @@ vub_readv(VubReq *req, struct iovec *iov, uint32_t iovcnt) req->size = vub_iov_size(iov, iovcnt); rc = preadv(vdev_blk->blk_fd, iov, iovcnt, req->sector_num * 512); if (rc < 0) { - fprintf(stderr, "%s, Sector %"PRIu64", Size %lu failed with %s\n", + fprintf(stderr, "%s, Sector %"PRIu64", Size %zu failed with %s\n", vdev_blk->blk_name, req->sector_num, req->size, strerror(errno)); return -1; @@ -169,7 +169,7 @@ vub_writev(VubReq *req, struct iovec *iov, uint32_t iovcnt) req->size = vub_iov_size(iov, iovcnt); rc = pwritev(vdev_blk->blk_fd, iov, iovcnt, req->sector_num * 512); if (rc < 0) { - fprintf(stderr, "%s, Sector %"PRIu64", Size %lu failed with %s\n", + fprintf(stderr, "%s, Sector %"PRIu64", Size %zu failed with %s\n", vdev_blk->blk_name, req->sector_num, req->size, strerror(errno)); return -1; @@ -188,7 +188,7 @@ vub_discard_write_zeroes(VubReq *req, struct iovec *iov, uint32_t iovcnt, size = vub_iov_size(iov, iovcnt); if (size != sizeof(*desc)) { - fprintf(stderr, "Invalid size %ld, expect %ld\n", size, sizeof(*desc)); + fprintf(stderr, "Invalid size %zd, expect %zd\n", size, sizeof(*desc)); return -1; } buf = g_new0(char, size); diff --git a/contrib/vhost-user-blk/meson.build b/contrib/vhost-user-blk/meson.build index 601ea15ef5..dcb9e2ffcd 100644 --- a/contrib/vhost-user-blk/meson.build +++ b/contrib/vhost-user-blk/meson.build @@ -1,5 +1,4 @@ -# FIXME: broken on 32-bit architectures executable('vhost-user-blk', files('vhost-user-blk.c'), dependencies: [qemuutil, vhost_user], - build_by_default: false, + build_by_default: targetos == 'linux', install: false) From patchwork Tue May 24 15:40:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 575735 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:c603:0:0:0:0 with SMTP id jv3csp2410133mab; Tue, 24 May 2022 08:42:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxi9MdzkPhii+ctg+nzYqOS71Pr6ovEUrWWir3n8cnMNoQmhnERuRd7fNFUi7w52csGgAhu X-Received: by 2002:ac8:5c54:0:b0:2f9:2304:6504 with SMTP id j20-20020ac85c54000000b002f923046504mr14009991qtj.246.1653406968351; Tue, 24 May 2022 08:42:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653406968; cv=none; d=google.com; s=arc-20160816; b=sK0TeYdLsoKuvyCez7l3Vp2zwZNMHDliOoUprAkEB1sZhnBkgBF9AM2CtTwEzXMev0 IeQRv7jH8ENlFhhdGMGAZn+9J0HY/muQCSASD0gQAEIzsqjPpGw9aycuw8sgcp582K2e JGy+jkHIpXNVNPBzgNEI22EmIi8VED/C+83FMbzHwO5hJ7CjVPJMUDvtKJbGjxaVlVnv z2Lex6f+6ReBfZJkgFbT+pMl/xET/tKFvlXn3HKtfOzDSdSN2IhzgpipIMl//5IcbjFq LVC7CcnG618nOhr0NFIK4sqZeYwIYq4ikGmgsOifxTKMxA4EiCWVVcpvHrhSCRqIRE6v vgsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wuv0XY2H3KqTbh7O/QyKEXQHF+ELTPI/LNmsm5wiDv4=; b=w5iN/FaV1aDBsKmZLGtuppArtgRNYlxytsIoJXtaHDEF78OJ6jNLa4YoclkyEJuANE v/fmR3RDDmLBWt/bMU2nzNXzBYkOkTPd83vrP1GweEM5xVxEFM6Y/zHPi1vLtIJJoe+s bMHB5MBgksmv7IrYgqvi5z92Wq3D+vE7nr6Ef/mhrUinPAP7/jq6WZe2OtbIjDdnFYXI hnkiwtv67TkfYtoo4isxCW9d7fHyPMyw8sP6npLQGlMipVWDVQOkV6XnZqu830LwnkBq txhvEYIvJS8lGJutksrIshOABwBB+9Ti1eNnDnDaTtdSyF1656SBU9p3o392Yy/iIr8P gHVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lgIihCWi; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6-20020a056214202600b004410d5193e1si5005174qvf.131.2022.05.24.08.42.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 May 2022 08:42:48 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lgIihCWi; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:41784 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntWgJ-000467-TT for patch@linaro.org; Tue, 24 May 2022 11:42:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42934) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntWej-00042U-OL for qemu-devel@nongnu.org; Tue, 24 May 2022 11:41:09 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]:51866) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ntWea-0005Lp-KS for qemu-devel@nongnu.org; Tue, 24 May 2022 11:41:09 -0400 Received: by mail-wm1-x32d.google.com with SMTP id z17so3978513wmf.1 for ; Tue, 24 May 2022 08:41:00 -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=wuv0XY2H3KqTbh7O/QyKEXQHF+ELTPI/LNmsm5wiDv4=; b=lgIihCWikM2XdSIQsw1gRlsHXfdcEyoU6a2au0m2lylQxjv4oRorj1/qser3tYMsRq uhj9bcgHsl6G/aCxkzaeriMiFDGZ06r9kCL9k6R4M3TmnO+XJSe1sk4uBnXBpCwjpfgv LATH7qQ69E27UUdeO2+7ojltDfWhd1GRS/sIf7G3YsDjlgG/+Zz9WMumBRpg7MUKyTIe s+qRRgi99So67IkY621FrOpPtjg0tMYtTF4ZGlbvhxpwie7wTFHR1WX/If2YCEqHNUBh 6/vWweNEFXXs4CQGZxgeTyG78jvLDiTJW5weTAWgE1gs82SyJT59Sciopjeu3+ndJcIe NcdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wuv0XY2H3KqTbh7O/QyKEXQHF+ELTPI/LNmsm5wiDv4=; b=4vn/pJfxKw9a1LVxmXHKCgdO0rzVkoxygo6zbLtKFOAcooATtm5mNfjy3RsM0O5l9Y qDr4eU+32MNIGVitgktLL+YjMY3tSl7M5vZIT4kNiSkSvlZ9xmLDa1HeabFjmx7cawSo KO1CWwXsevui4fdag7Y1kTiI5/tCDp9Z+S9As2LqyZ5I0gPu/2dvb8oSV4iaq6qH/7mT KGYsvMil9wQoT4HJ0IF1zjYmdlgBnee3cJQZHyB0InwSJ8rJ/ecf5QlIO/3UHQp+iYnz aAyrIguqb/b7KscMhJRYBdLxdSnJ95fWit68slOihrZziK0pk2ZHRIaXQZk0evKbnFjk /1KQ== X-Gm-Message-State: AOAM532nu2UgPzfpw6G9Ywe3MVOK7A/UV0LsNudoi4u2xS7TgkRZbrAo GGcfag96/8UUKsSdmzjkpKIL+Q== X-Received: by 2002:a7b:c841:0:b0:394:890e:9195 with SMTP id c1-20020a7bc841000000b00394890e9195mr4368259wml.59.1653406859054; Tue, 24 May 2022 08:40:59 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id q2-20020adfb182000000b0020c5253d8d0sm13055061wra.28.2022.05.24.08.40.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 May 2022 08:40:57 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 8C3051FFBA; Tue, 24 May 2022 16:40:56 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH v2 02/15] include/hw/virtio: more comment for VIRTIO_F_BAD_FEATURE Date: Tue, 24 May 2022 16:40:43 +0100 Message-Id: <20220524154056.2896913-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220524154056.2896913-1-alex.bennee@linaro.org> References: <20220524154056.2896913-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32d.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" When debugging a new vhost user you may be surprised to see VHOST_USER_F_PROTOCOL getting squashed in the maze of backend_features, acked_features and guest_features. Expand the description here to help the next poor soul trying to work through this. Signed-off-by: Alex Bennée --- include/hw/virtio/virtio.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index db1c0ddf6b..2b2587d324 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -24,7 +24,12 @@ #include "qom/object.h" #include "hw/virtio/vhost.h" -/* A guest should never accept this. It implies negotiation is broken. */ +/* + * A guest should never accept this. It implies negotiation is + * broken between the driver frontend and the device. This bit is + * re-used for vhost to advertise VHOST_USER_F_PROTOCOL_FEATURES + * between QEMU and a vhost backend. + */ #define VIRTIO_F_BAD_FEATURE 30 #define VIRTIO_LEGACY_FEATURES ((0x1ULL << VIRTIO_F_BAD_FEATURE) | \ From patchwork Tue May 24 15:40:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 575736 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:c603:0:0:0:0 with SMTP id jv3csp2413431mab; Tue, 24 May 2022 08:47:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJD68Mn/+oUakjR+Zlw54wOFNFekZz0rB4cC8DT7SuJ11qWeGFV6+nJvTKbkDP+qRyNbb/ X-Received: by 2002:a05:6214:2aaf:b0:45b:9f:8752 with SMTP id js15-20020a0562142aaf00b0045b009f8752mr21895482qvb.9.1653407227226; Tue, 24 May 2022 08:47:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653407227; cv=none; d=google.com; s=arc-20160816; b=kGykIG3V9BhGRIkLpy7TS3cwQYPwxS7AXmKf5o85v0JMUXIZyzux7vXh9/pxZSBpJ0 Ed6s34o2X7INucQlpGizjH1itVXjluLWt4Z3M1EzmXEL9fGHmfgb6o1jb+/dE5gxESJh pmmIgGC/QOzEsPLxI+JQQgC/L/hCA7xG9/oVMg/F7abFMZYonYscpaoPG+Fg1wxwAKes VsBY/CSnlb0dYTvISgZ0syiSSbu0Yfb+WdRDH4RhCsP09rRQND8yDuXham1PcorSBds2 GCs0cy3WhPBblHz7BlVbQl6VbwAsaj0GRVWOMv/PjDdTPiUFWQ4zbXJm9dRby5tci0hq c9Nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=FgzK20NI+E0P86TSvhLUf2mlqYDXY7EcnmvPOs0iPUg=; b=ADFoz+Wbf5B3/Vbe7jDUR0+gXTTPoXCSzPByY+Va5UaJJqcw4FNaGPrqUJk/EZSbzY GmSTfo8mRxKLf4l6JpqN76U/P+00OzUvTBmOudFqIQ1HvS8W+eQTrhDGgzqWK2zWnstJ T95E18QLOVZ456+FzOjltAgs1wtRcvxY6R5BF216DmhmpdZ3s/TnlYc06Ddml5PHP859 jQOD7vXRHviSq6ksChfDI8/2k4LD3j1dhq5rrXNyY8DoVuqhDeh7cb7bCRH5wXILqKQD /vV7KDIU0zl/BOk1BtZf8W1Wh39JPn1sYTYUrxXf3819UXtBxp3u0YI8y/+AzFVHNtva 6nAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=em1GXJ6f; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id jn4-20020ad45de4000000b004625dbfa797si619963qvb.165.2022.05.24.08.47.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 May 2022 08:47:07 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=em1GXJ6f; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:49918 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntWkU-0001OE-Qh for patch@linaro.org; Tue, 24 May 2022 11:47:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42960) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntWek-00043s-OZ for qemu-devel@nongnu.org; Tue, 24 May 2022 11:41:10 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:56300) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ntWed-0005M5-LB for qemu-devel@nongnu.org; Tue, 24 May 2022 11:41:10 -0400 Received: by mail-wm1-x329.google.com with SMTP id y24so3091467wmq.5 for ; Tue, 24 May 2022 08:41:03 -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=FgzK20NI+E0P86TSvhLUf2mlqYDXY7EcnmvPOs0iPUg=; b=em1GXJ6ftMhEHLwhpn8kbH22HgOaqz4WxzXaq2dmxd+QYbkkAlL9KGx3JekCiN0O4n pBst2/i5nDilULaxPtrA2LhUTg1ZSWHQL43WHZEE6URO0xtXGLWX8g3/Ii/zDSFimfXj mNtXlGUGqoc2a6woXUO2LAcO1/lPLwVr8uzeQ1WWbwbY1djJaYit1yZ6/HB94HAZ7u+J Ch16Qe8UtLOshHIo/WrKnUGZsrYqhmGWOOysZmsgQ01I6RK0JtS5xzVlpPt5hI9eeE7I X/+SIB0N8e0ahca+P+i2z656zZjlHrFul/ocPXR/wlg8KHGs2NCfEkN7FXTfvamI0CEy qhYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FgzK20NI+E0P86TSvhLUf2mlqYDXY7EcnmvPOs0iPUg=; b=pr+BsvnPq0U/CKZXAiY9zgFU8uj8s3mJ4oq3g4etozV3kgUE+apFCnVvHOcHtOVYt5 39N+xjYygHCbQMrR6Z+lZMFDddh3D/ZL/BpK5waSZT8zmL2ZxKDf1yzTUvn781XLJT7I PIicKnJ+eZFJLp1OhCTfdQpc4zlslxBvpkTXoCUvmsC8cfafcx+In/S1YMQuXfqTjftk BdcH8UBTzXrP1+evR7y7/d2NKgBXx2l2Wl3b+GckfFXZPHy5GsGLHI10E+yiGDspzspb BdKEvyna47FOLeAGp3u7fUKjiamuCN4uo0PTKEpWsRgK7yIBOtgedjkTwu9b/bju2R8Z y9VQ== X-Gm-Message-State: AOAM5332xroz9tv5EYFN4aCaopU6dz9f1oTsWKn+auhqxknMaUZ4gu+7 JfXLaiQS3mSWsRQq0+SvFDWiag== X-Received: by 2002:a05:600c:1504:b0:397:4d98:8b85 with SMTP id b4-20020a05600c150400b003974d988b85mr4375845wmg.39.1653406862290; Tue, 24 May 2022 08:41:02 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id n32-20020a05600c3ba000b003942a244ecbsm2678034wms.16.2022.05.24.08.40.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 May 2022 08:41:00 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id A3B811FFBB; Tue, 24 May 2022 16:40:56 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH v2 03/15] include/hw/virtio: document vhost_get_features Date: Tue, 24 May 2022 16:40:44 +0100 Message-Id: <20220524154056.2896913-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220524154056.2896913-1-alex.bennee@linaro.org> References: <20220524154056.2896913-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x329.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alex Bennée Reviewed-by: Stefan Hajnoczi --- include/hw/virtio/vhost.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index b291fe4e24..9f9f57c46e 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -246,6 +246,17 @@ bool vhost_virtqueue_pending(struct vhost_dev *hdev, int n); */ void vhost_virtqueue_mask(struct vhost_dev *hdev, VirtIODevice *vdev, int n, bool mask); + +/** + * vhost_get_features() - return a sanitised set of feature bits + * @hdev: common vhost_dev structure + * @feature_bits: pointer to terminated table of feature bits + * @features: original feature set + * + * This returns a set of features bits that is an intersection of what + * is supported by the vhost backend (hdev->features), the supported + * feature_bits and the requested feature set. + */ uint64_t vhost_get_features(struct vhost_dev *hdev, const int *feature_bits, uint64_t features); void vhost_ack_features(struct vhost_dev *hdev, const int *feature_bits, From patchwork Tue May 24 15:40:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 575749 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:c603:0:0:0:0 with SMTP id jv3csp2452354mab; Tue, 24 May 2022 09:33:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx6/iSXI1Ee7PuL7QvVKlZL9jubgHj27MNFV6c4RWw2EQyp6EkFCEry9/QwyHGyJctPg6pg X-Received: by 2002:a05:622a:d3:b0:2f9:1b8e:19e1 with SMTP id p19-20020a05622a00d300b002f91b8e19e1mr16970584qtw.666.1653410024932; Tue, 24 May 2022 09:33:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653410024; cv=none; d=google.com; s=arc-20160816; b=sAB2S2ncxrrDum8o2VfU2yJZlj7HcH425Xp6wpF7tCARyMmyuInKBcOJFobnWR3jJ3 bw4Cer6KGcrhcMmip8cWKHiv4OZ2LWAQRAOdHyaK993PkRosJEiKkjDk9QV6IqgZJAuF F7cBXydKxcO0TJhKIcoiL/9FZDb7+H1w6q5DGrO+MWc3NqRocOnABsytafD+lFrosTk+ fU0gIAnmKUeF1OLB2H7bilwh/qioPJ8StBNUUjxSirNcVlINd59d89hISUQ2A3Pfv9Xt +6Sv+91LVv9C43fQaKMMVxV0Wz7vpV/xJPQedAxCAKiRmI7XM0daNLDzFWF1rj75STRj FRHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=HF3oxtJzbPygKRRjZfwIDjRnPR4HjsUqS/dYhqTV/10=; b=YyLI16ivq2YXJqmjZ4ae9V1PVNWnMx3MfoWvKJV4cjokEM0mISVc+Nu16svhmsx3Qi xYbpkPPpq40Dj9PXVSP6X84oOTZDnr1X77HRtqvfSBIgXgMawAWHYNe6pLsKGWegjM4J +89W9TDNDkXx+CQ/5wMESkmXfPkXvHbxgBkL6mGdSL09QDbg/X4/Kitbpw9WWzAQ3mPq f/HBsLh3bdlN1dC9vHalq2zl4EjASDnaZQ2ZetIsGpdFHDjQV6ZwaJ7qg6nOqFud7jBg wIK6SEWQO6C9s2ReGxHInBcnjUAqF206iN0bSE1wmbMzzlr+PVxig5LHYSIMpvydLES7 tAUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hD48p295; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f5-20020ac859c5000000b002f3be513fb7si246994qtf.299.2022.05.24.09.33.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 May 2022 09:33:44 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hD48p295; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47636 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntXTc-0001Yl-F8 for patch@linaro.org; Tue, 24 May 2022 12:33:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43128) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntWex-0004No-Uy for qemu-devel@nongnu.org; Tue, 24 May 2022 11:41:26 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:47084) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ntWef-0005MF-Ch for qemu-devel@nongnu.org; Tue, 24 May 2022 11:41:23 -0400 Received: by mail-wr1-x434.google.com with SMTP id m20so15150194wrb.13 for ; Tue, 24 May 2022 08:41:04 -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=HF3oxtJzbPygKRRjZfwIDjRnPR4HjsUqS/dYhqTV/10=; b=hD48p295CVWJRIAJyIIPjaTKTd3fFYgBcO3F7H6LjSkboZRHGU5DIzcziCgCDSRmVf CnC+wvc3rU+2rtN5OwfVuA3Av35lGsGqc8QpUeYhn7ixF1ZA34qX1hvS4dt9os5++eGM LwgMYp68V6JNBRdZPT4vzw8RvdIdHOUl3FaRJaXJId9jxnU5UI2QN8w3ArZACMT62YWn Nkdn+UcNafSzJLH2J93oZI47A0knOLX3zSZZSBO3NrVy5hTgG9PaQ+grEjQxrK0o62PW cwfUE4+Io3pe9ojRNKdsQKLFDxyoVDpAQcBwdGB8Q8LOF8xMrpUXvEqYGe+N0VQsL9kD xslQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HF3oxtJzbPygKRRjZfwIDjRnPR4HjsUqS/dYhqTV/10=; b=PFS2cHb31bB6jtjKJ7/anE7WTDi0IXODs0knFLtPyrR6wgQSHz6cYFgZ6/OWpoXW9e syTa6uU4yUSXadOIm7asXndy+axKKJSzaJd5HhfA5/3U33WHZWtKmlouAtHWXRhx0MRj OJfA/ls12yomN9lKzbt/BvaRkqWVBp5iVZUomMzipE6q2YfAOByqXQLeKma2FH6zBP5/ KIfXClZ4CioA2zN4fWJtdCW4vmHRmZF+D6IPEHoGZGzGn4GzEd6Duh/KmRrZ+Sl8b95C GFSr5KTQv58L308lRJ5Zji3LljA8TFRYhj1X2uHXncuw8i/HkNC1Z/x7kVCKOVIpYvEi +Ofw== X-Gm-Message-State: AOAM530pvJVK6NO9RRzEs4Xaw/pFUfK9/NyF5C4pB3wulXcbP8MAaQhz URRBFN1WmwF2SmVeY7spghJVhw== X-Received: by 2002:a05:6000:1843:b0:20e:6a9c:afa1 with SMTP id c3-20020a056000184300b0020e6a9cafa1mr22275662wri.218.1653406864088; Tue, 24 May 2022 08:41:04 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id i1-20020adfaac1000000b0020c5253d8dasm13459631wrc.38.2022.05.24.08.40.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 May 2022 08:41:01 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id B0B861FFBC; Tue, 24 May 2022 16:40:56 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH v2 04/15] include/hw/virtio: document vhost_ack_features Date: Tue, 24 May 2022 16:40:45 +0100 Message-Id: <20220524154056.2896913-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220524154056.2896913-1-alex.bennee@linaro.org> References: <20220524154056.2896913-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x434.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alex Bennée Reviewed-by: Stefan Hajnoczi --- include/hw/virtio/vhost.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 9f9f57c46e..bfe868e341 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -259,6 +259,16 @@ void vhost_virtqueue_mask(struct vhost_dev *hdev, VirtIODevice *vdev, int n, */ uint64_t vhost_get_features(struct vhost_dev *hdev, const int *feature_bits, uint64_t features); + +/** + * vhost_ack_features() - set vhost acked_features + * @hdev: common vhost_dev structure + * @feature_bits: pointer to terminated table of feature bits + * @features: requested feature set + * + * This sets the internal hdev->acked_features to the intersection of + * the backends advertised features and the supported feature_bits. + */ void vhost_ack_features(struct vhost_dev *hdev, const int *feature_bits, uint64_t features); bool vhost_has_free_slot(void); From patchwork Tue May 24 15:40:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 575746 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:c603:0:0:0:0 with SMTP id jv3csp2445960mab; Tue, 24 May 2022 09:25:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPlMaQpxcvps7RWCwcY2grJiRspL2bdodU9unr3wYGu9EnMwv+3mlK4JdMFnkL2p1BNDQ+ X-Received: by 2002:a05:622a:54a:b0:2f3:dd33:7e3 with SMTP id m10-20020a05622a054a00b002f3dd3307e3mr21122832qtx.138.1653409545723; Tue, 24 May 2022 09:25:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653409545; cv=none; d=google.com; s=arc-20160816; b=qn1GaguAJVocGCUXTZzp/YnkMvpkPih1joe5+hk2xqCjkY3/QrzqjQOnG3TzaE4yA5 RpOBbbIwSPWeTDHfutG4eDfY3gw+eeQrWgoS0IfzqvvGJ0bd/zzOA0ToPgwAmphB6OnV ovM5uP4IUulB1Mo+13T3QkEChWUX3sYi+7oKOP6pdReJof9sS1kdxbGNwekT3o/hlMd5 zZiICObIEnRxYxpuiVl7ZldYfEB6M6LjaI+9NrGDlHk93XOOGa/qEcb5zAI+n6ICywnK rpb2KHUm8K6a9sMTHSBTU7k5nmmD0NEUopkRrXzK4CX6zh9xsDHSOoyZcWLrBwE9LBoa Vewg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0eZjoHrxexxNL+fKaMsZMS+KyvjWLWtAv8XDuWHLS4w=; b=pyHDT1MEH8IM7IlOzmhe+eHxQwo9VrNgxjHiFZSs+psh0GiQ17a1gV58PVe0rCWCT5 pNx/CH/irVm9PugWi8csrKEmes1Re5Ujwb0zIrLMl+YaWlmuCn3he4Dw09OQ3ne3DQd4 k2e34pQcEFq6lJmaS1px3IoII48w4nZ3D2XLtD6lqeT7cmbSij7ThqLCqvHWha47gBBM Mm7scOLPlwtXE6nsV2Q+qlJ1YptX+Kcv+zNG1Bqjgz2HFv2SxM0wepp16mEBNtEnqHC6 fUbguwsnWwHWsK1icQ4xNWDjrzjSsARZ/qvIWGb3cf9CeUywGr5h23xAqmycvIrS5sKy U/OQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Wx00BlMx; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 12-20020a05621420ec00b004622a29565esi4206806qvk.26.2022.05.24.09.25.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 May 2022 09:25:45 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Wx00BlMx; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:60338 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntXLt-0007NE-AG for patch@linaro.org; Tue, 24 May 2022 12:25:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43050) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntWeo-0004Ds-2o for qemu-devel@nongnu.org; Tue, 24 May 2022 11:41:14 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:37832) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ntWek-0005My-8l for qemu-devel@nongnu.org; Tue, 24 May 2022 11:41:13 -0400 Received: by mail-wr1-x42b.google.com with SMTP id t6so26286691wra.4 for ; Tue, 24 May 2022 08:41: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=0eZjoHrxexxNL+fKaMsZMS+KyvjWLWtAv8XDuWHLS4w=; b=Wx00BlMxgOAU6pvzZmY8zh/cFzwftNqeM+HANCvKRhHBqB92dBrn0a6ejeqQeIWkAo VLYlI/GGa8u9tx011Hym+mWgWtiW5rg/+8Bqkn/5m85U1qWLc7yu5ZuIB6Z/nXIeifae 7olGSc/QiBEpTPjMgx16cdYP7uY43lMbM+eKYRyCvk6txigwZqJMMycNOq0EnIyzAM40 pkx7uTt3TrUx8UXmES2eCB4iChRXLBOUbMHOvilav9x9BJjwokJWhj9xcM7PmKN5OwH/ NIkOC0TZSAdxR1DdNzB6jr3pmnKJu55AHQjLXSMXxTsgDliMxgoy39EH4vNQCcaWpobE vqJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0eZjoHrxexxNL+fKaMsZMS+KyvjWLWtAv8XDuWHLS4w=; b=1WhdDZ0VeR58CA/oYyVkkDxUz41ezySBKUaV5aPCzkFpBcLNmwC6Eg92HOZ5GZnGfv +kWxofEQJs8pD69AM5AUxq5obeXUvqlQ26DAZfDJ5RbZ4KYX7qhXyGih7y90z9esRddx SAee4hKq7FrgN5jOTnara5pJPqZsRnnJEbRvR/hV7+QM7xiDgZvCCT752Fg0IA8Q+4qt MoyfywURHr+wo3WetxAr1trcOzFsWNIfhIhoJwLonT26q67AwpXkaH+lODSGp8ztTz7N 3qmqzPbQyT561QQHZSo3oyypEIgCHbNpUGOjmLZHJEcfDCQiV3t9Zw4dC/jDCf8uQB0y jegw== X-Gm-Message-State: AOAM530rw6xSJFiFU7Mo9M0eYN3OMeiE9iip24kK8tNIrXMpX/oh8sDz ddh4a+WywqnxeOnJL/W7xy/XJg== X-Received: by 2002:a05:6000:34b:b0:20f:fb31:872d with SMTP id e11-20020a056000034b00b0020ffb31872dmr691660wre.449.1653406867791; Tue, 24 May 2022 08:41:07 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id k21-20020a7bc315000000b003942a244edfsm2655202wmj.36.2022.05.24.08.40.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 May 2022 08:41:01 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id D32E41FFBD; Tue, 24 May 2022 16:40:56 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH v2 05/15] hw/virtio: add boilerplate for vhost-user-gpio device Date: Tue, 24 May 2022 16:40:46 +0100 Message-Id: <20220524154056.2896913-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220524154056.2896913-1-alex.bennee@linaro.org> References: <20220524154056.2896913-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42b.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Viresh Kumar This creates the QEMU side of the vhost-user-gpio device which connects to the remote daemon. It is based of vhost-user-i2c code. Signed-off-by: Viresh Kumar Reviewed-by: Alex Bennée Message-Id: <5390324a748194a21bc99b1538e19761a8c64092.1641987128.git.viresh.kumar@linaro.org> [AJB: fixes for qtest] Signed-off-by: Alex Bennée --- v2 - set VIRTIO_F_VERSION_1 - set VHOST_USER_F_PROTOCOL_FEATURES - terminate feature_bits with VHOST_INVALID_FEATURE_BIT - ensure vdev->backend_features set - ensure vhost_dev.acked_features set --- include/hw/virtio/vhost-user-gpio.h | 35 +++ hw/virtio/vhost-user-gpio.c | 357 ++++++++++++++++++++++++++++ hw/virtio/Kconfig | 5 + hw/virtio/meson.build | 1 + 4 files changed, 398 insertions(+) create mode 100644 include/hw/virtio/vhost-user-gpio.h create mode 100644 hw/virtio/vhost-user-gpio.c diff --git a/include/hw/virtio/vhost-user-gpio.h b/include/hw/virtio/vhost-user-gpio.h new file mode 100644 index 0000000000..afeb56f53e --- /dev/null +++ b/include/hw/virtio/vhost-user-gpio.h @@ -0,0 +1,35 @@ +/* + * Vhost-user GPIO virtio device + * + * Copyright (c) 2021 Viresh Kumar + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef _QEMU_VHOST_USER_GPIO_H +#define _QEMU_VHOST_USER_GPIO_H + +#include "hw/virtio/virtio.h" +#include "hw/virtio/vhost.h" +#include "hw/virtio/vhost-user.h" +#include "standard-headers/linux/virtio_gpio.h" +#include "chardev/char-fe.h" + +#define TYPE_VHOST_USER_GPIO "vhost-user-gpio-device" +OBJECT_DECLARE_SIMPLE_TYPE(VHostUserGPIO, VHOST_USER_GPIO); + +struct VHostUserGPIO { + /*< private >*/ + VirtIODevice parent; + CharBackend chardev; + struct virtio_gpio_config config; + struct vhost_virtqueue *vhost_vq; + struct vhost_dev vhost_dev; + VhostUserState vhost_user; + VirtQueue *command_vq; + VirtQueue *interrupt_vq; + bool connected; + /*< public >*/ +}; + +#endif /* _QEMU_VHOST_USER_GPIO_H */ diff --git a/hw/virtio/vhost-user-gpio.c b/hw/virtio/vhost-user-gpio.c new file mode 100644 index 0000000000..87e3976880 --- /dev/null +++ b/hw/virtio/vhost-user-gpio.c @@ -0,0 +1,357 @@ +/* + * Vhost-user GPIO virtio device + * + * Copyright (c) 2022 Viresh Kumar + * + * 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-gpio.h" +#include "qemu/error-report.h" +#include "standard-headers/linux/virtio_ids.h" + +/* do no other vhost-user daemons need this? */ +#define VHOST_USER_F_PROTOCOL_FEATURES 30 + +static const int feature_bits[] = { + VIRTIO_F_VERSION_1, + VIRTIO_GPIO_F_IRQ, + VHOST_USER_F_PROTOCOL_FEATURES, + VHOST_INVALID_FEATURE_BIT +}; + +static void vu_gpio_get_config(VirtIODevice *vdev, uint8_t *config) +{ + VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); + + memcpy(config, &gpio->config, sizeof(gpio->config)); +} + +static int vu_gpio_config_notifier(struct vhost_dev *dev) +{ + VHostUserGPIO *gpio = VHOST_USER_GPIO(dev->vdev); + + memcpy(dev->vdev->config, &gpio->config, sizeof(gpio->config)); + virtio_notify_config(dev->vdev); + + return 0; +} + +const VhostDevConfigOps gpio_ops = { + .vhost_dev_config_notifier = vu_gpio_config_notifier, +}; + +static int vu_gpio_start(VirtIODevice *vdev) +{ + BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); + VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); + VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); + int ret, i; + + if (!k->set_guest_notifiers) { + error_report("binding does not support guest notifiers"); + return -ENOSYS; + } + + ret = vhost_dev_enable_notifiers(&gpio->vhost_dev, vdev); + if (ret < 0) { + error_report("Error enabling host notifiers: %d", ret); + return ret; + } + + ret = k->set_guest_notifiers(qbus->parent, gpio->vhost_dev.nvqs, true); + if (ret < 0) { + error_report("Error binding guest notifier: %d", ret); + goto err_host_notifiers; + } + + /* + * Before we start up we need to ensure we have the final feature + * set needed for the vhost configuration. + */ + vhost_ack_features(&gpio->vhost_dev, feature_bits, vdev->backend_features); + + ret = vhost_dev_start(&gpio->vhost_dev, vdev); + if (ret < 0) { + error_report("Error starting vhost-user-gpio: %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 = 0; i < gpio->vhost_dev.nvqs; i++) { + vhost_virtqueue_mask(&gpio->vhost_dev, vdev, i, false); + } + + return 0; + +err_guest_notifiers: + k->set_guest_notifiers(qbus->parent, gpio->vhost_dev.nvqs, false); +err_host_notifiers: + vhost_dev_disable_notifiers(&gpio->vhost_dev, vdev); + + return ret; +} + +static void vu_gpio_stop(VirtIODevice *vdev) +{ + VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); + BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); + VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); + int ret; + + if (!k->set_guest_notifiers) { + return; + } + + vhost_dev_stop(&gpio->vhost_dev, vdev); + + ret = k->set_guest_notifiers(qbus->parent, gpio->vhost_dev.nvqs, false); + if (ret < 0) { + error_report("vhost guest notifier cleanup failed: %d", ret); + return; + } + + vhost_dev_disable_notifiers(&gpio->vhost_dev, vdev); +} + +static void vu_gpio_set_status(VirtIODevice *vdev, uint8_t status) +{ + VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); + bool should_start = status & VIRTIO_CONFIG_S_DRIVER_OK; + + if (!vdev->vm_running) { + should_start = false; + } + + if (!gpio->connected) { + return; + } + + if (gpio->vhost_dev.started == should_start) { + return; + } + + if (should_start) { + if (vu_gpio_start(vdev)) { + qemu_chr_fe_disconnect(&gpio->chardev); + } + } else { + vu_gpio_stop(vdev); + } +} + +static uint64_t vu_gpio_get_features(VirtIODevice *vdev, uint64_t features, + Error **errp) +{ + VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); + + virtio_add_feature(&features, VIRTIO_GPIO_F_IRQ); + virtio_add_feature(&features, VIRTIO_F_VERSION_1); + + vdev->backend_features = vhost_get_features(&gpio->vhost_dev, feature_bits, + features); + return vdev->backend_features; +} + +static void vu_gpio_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_gpio_guest_notifier_mask(VirtIODevice *vdev, int idx, bool mask) +{ + VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); + + vhost_virtqueue_mask(&gpio->vhost_dev, vdev, idx, mask); +} + +static void do_vhost_user_cleanup(VirtIODevice *vdev, VHostUserGPIO *gpio) +{ + virtio_delete_queue(gpio->command_vq); + virtio_delete_queue(gpio->interrupt_vq); + g_free(gpio->vhost_dev.vqs); + gpio->vhost_dev.vqs = NULL; + virtio_cleanup(vdev); + vhost_user_cleanup(&gpio->vhost_user); +} + +static int vu_gpio_connect(DeviceState *dev) +{ + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); + Error *local_err = NULL; + int ret; + + if (gpio->connected) { + return 0; + } + gpio->connected = true; + + vhost_dev_set_config_notifier(&gpio->vhost_dev, &gpio_ops); + + ret = vhost_dev_init(&gpio->vhost_dev, &gpio->vhost_user, + VHOST_BACKEND_TYPE_USER, 0, &local_err); + if (ret < 0) { + error_report("vhost-user-gpio: vhost initialization failed: %s", + strerror(-ret)); + return ret; + } + + /* restore vhost state */ + if (virtio_device_started(vdev, vdev->status)) { + vu_gpio_start(vdev); + } + + return 0; +} + +static void vu_gpio_disconnect(DeviceState *dev) +{ + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); + + if (!gpio->connected) { + return; + } + gpio->connected = false; + + vu_gpio_stop(vdev); + vhost_dev_cleanup(&gpio->vhost_dev); +} + +static void vu_gpio_event(void *opaque, QEMUChrEvent event) +{ + DeviceState *dev = opaque; + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); + + switch (event) { + case CHR_EVENT_OPENED: + if (vu_gpio_connect(dev) < 0) { + qemu_chr_fe_disconnect(&gpio->chardev); + return; + } + break; + case CHR_EVENT_CLOSED: + vu_gpio_disconnect(dev); + break; + case CHR_EVENT_BREAK: + case CHR_EVENT_MUX_IN: + case CHR_EVENT_MUX_OUT: + /* Ignore */ + break; + } +} + +static void vu_gpio_device_realize(DeviceState *dev, Error **errp) +{ + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserGPIO *gpio = VHOST_USER_GPIO(dev); + Error *err = NULL; + int ret; + + if (!gpio->chardev.chr) { + error_setg(errp, "vhost-user-gpio: chardev is mandatory"); + return; + } + + if (!vhost_user_init(&gpio->vhost_user, &gpio->chardev, errp)) { + return; + } + + virtio_init(vdev, VIRTIO_ID_GPIO, sizeof(gpio->config)); + + gpio->vhost_dev.nvqs = 2; + gpio->command_vq = virtio_add_queue(vdev, 256, vu_gpio_handle_output); + gpio->interrupt_vq = virtio_add_queue(vdev, 256, vu_gpio_handle_output); + gpio->vhost_dev.vqs = g_new0(struct vhost_virtqueue, gpio->vhost_dev.nvqs); + + gpio->connected = false; + + qemu_chr_fe_set_handlers(&gpio->chardev, NULL, NULL, vu_gpio_event, NULL, + dev, NULL, true); + +reconnect: + if (qemu_chr_fe_wait_connected(&gpio->chardev, &err) < 0) { + error_report_err(err); + do_vhost_user_cleanup(vdev, gpio); + return; + } + + /* check whether vhost_user_gpio_connect() failed or not */ + if (!gpio->connected) { + goto reconnect; + } + + ret = vhost_dev_get_config(&gpio->vhost_dev, (uint8_t *)&gpio->config, + sizeof(gpio->config), errp); + if (ret < 0) { + error_report("vhost-user-gpio: get config failed"); + goto reconnect; + } + + return; +} + +static void vu_gpio_device_unrealize(DeviceState *dev) +{ + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserGPIO *gpio = VHOST_USER_GPIO(dev); + + vu_gpio_set_status(vdev, 0); + qemu_chr_fe_set_handlers(&gpio->chardev, NULL, NULL, NULL, NULL, NULL, NULL, + false); + vhost_dev_cleanup(&gpio->vhost_dev); + do_vhost_user_cleanup(vdev, gpio); +} + +static const VMStateDescription vu_gpio_vmstate = { + .name = "vhost-user-gpio", + .unmigratable = 1, +}; + +static Property vu_gpio_properties[] = { + DEFINE_PROP_CHR("chardev", VHostUserGPIO, chardev), + DEFINE_PROP_END_OF_LIST(), +}; + +static void vu_gpio_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass); + + device_class_set_props(dc, vu_gpio_properties); + dc->vmsd = &vu_gpio_vmstate; + set_bit(DEVICE_CATEGORY_INPUT, dc->categories); + vdc->realize = vu_gpio_device_realize; + vdc->unrealize = vu_gpio_device_unrealize; + vdc->get_features = vu_gpio_get_features; + vdc->get_config = vu_gpio_get_config; + vdc->set_status = vu_gpio_set_status; + vdc->guest_notifier_mask = vu_gpio_guest_notifier_mask; +} + +static const TypeInfo vu_gpio_info = { + .name = TYPE_VHOST_USER_GPIO, + .parent = TYPE_VIRTIO_DEVICE, + .instance_size = sizeof(VHostUserGPIO), + .class_init = vu_gpio_class_init, +}; + +static void vu_gpio_register_types(void) +{ + type_register_static(&vu_gpio_info); +} + +type_init(vu_gpio_register_types) diff --git a/hw/virtio/Kconfig b/hw/virtio/Kconfig index e9ecae1f50..cbfd8c7173 100644 --- a/hw/virtio/Kconfig +++ b/hw/virtio/Kconfig @@ -80,3 +80,8 @@ config VHOST_USER_FS bool default y depends on VIRTIO && VHOST_USER + +config VHOST_USER_GPIO + bool + default y + depends on VIRTIO && VHOST_USER diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index 7e8877fd64..33c8e71fab 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -29,6 +29,7 @@ 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_I2C', if_true: files('vhost-user-i2c.c')) virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user-rng.c')) +virtio_ss.add(when: 'CONFIG_VHOST_USER_GPIO', if_true: files('vhost-user-gpio.c')) virtio_pci_ss = ss.source_set() virtio_pci_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock-pci.c')) From patchwork Tue May 24 15:40:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 575738 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:c603:0:0:0:0 with SMTP id jv3csp2416669mab; Tue, 24 May 2022 08:51:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxg8yy1xfQzm6SggE0PWpss17tVt0KkHuGJqXN5NWFbwkfKE/egZEaFGAqpGMbP6f3fx8x9 X-Received: by 2002:a05:622a:1cc:b0:2f3:e619:8088 with SMTP id t12-20020a05622a01cc00b002f3e6198088mr20973130qtw.261.1653407506081; Tue, 24 May 2022 08:51:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653407506; cv=none; d=google.com; s=arc-20160816; b=XxMvJzkdrpc1WLDd3OFGGooVdyLdjVbkg3GivJNSbiaDNqeJ3IcK9SK1g179E9OGeB XszhXCFhPUmx/p8Djgb/ZpCLA7arBk2byE5GVLpHmzluLthgmefkNY5QryNqwFZuqc/e MIHnRYHSx4BIhwa7jUsu01k/Kx9N+yg+tcrAKgH5fOXoejaJ+wJXWGJJQvYxD39ZCeoi 4t8VZfaZ72muGSfZytKal6L8Bq/7HcIdrAXMWqHGE4OPEyyUKMv1Uqn3RTwc6zr6lRwD HvMYip362JItXCjxjRJfFLmeFZ5ju1miv1mh7fD2JeNx3XjokuGAQSEjnyR+1hj7zVr4 6zmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=TJYGQIz+rWx7e0twPEDMb7ZMcWZRr8Vc82PxTGHPmrg=; b=bNicIU5KMREdjxEM2p/mol4Uy8hDmBboXM7naiUEPNEMb2sGwg/prBp28DwHJn8qjU /a6inAHRGrUPWHC7MOj+RU7Ef/Hw9+P46Q6jAAuO/yrf2ZydDbUppKvYROHs/8sSBqaN sXzHwPp8TmlICZZHq/aXHVLwCE4ifSuHy11d2F1pA4HJfiQwuIJebsvhEhFZsLdnU3Iu 2BfgPnvByfwhwS08crc/lWDErch2fjpKG27foy6gpFkNl6owdobehH5oZHsK9dfOR9Pu ssecH/gi8LQIMDDuRdTkZGq1JLQjoK+1BD+MtrDyh85cCsK4XawEioRZEl9u1WB40XBZ agDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mKkwyDWI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 15-20020ad45baf000000b004440a0bf8e5si4430879qvq.86.2022.05.24.08.51.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 May 2022 08:51:46 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mKkwyDWI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:58338 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntWoz-0007fR-LC for patch@linaro.org; Tue, 24 May 2022 11:51:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43002) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntWem-00049H-Lo for qemu-devel@nongnu.org; Tue, 24 May 2022 11:41:12 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:45601) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ntWei-0005MW-7B for qemu-devel@nongnu.org; Tue, 24 May 2022 11:41:12 -0400 Received: by mail-wr1-x434.google.com with SMTP id p10so7649706wrg.12 for ; Tue, 24 May 2022 08:41:07 -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=TJYGQIz+rWx7e0twPEDMb7ZMcWZRr8Vc82PxTGHPmrg=; b=mKkwyDWINbHLLi93Re+r4vIPV20FFv+yvrrkwiezPir1JKQbFssYW/9VOKfbxRyZcx OrDJc/tPYSbApKTJF5/Zjg9alBOzibWhGSpsiuB3pghtiDigVQrf4//Y3dTrn7wVvAyM dQe7fQ8m2v3tR72rsXM3e79YHiVUhoWG2YAgOlYVIDPrkuWNNOpVjHVKIo4W/1J2a/HJ zqihnYQT1xXGMCi7/fCYoBUVMlMbTXudXS3NCa9Jm3oz84UZwMQ0RX9DpHYB13avTDHQ jdM+ARwcrGFWjdvMe2lvi/D3SLzGgx2jUPIvup7LBg8BUndbIqvoQTSnMf592i6cjW3Y rG3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TJYGQIz+rWx7e0twPEDMb7ZMcWZRr8Vc82PxTGHPmrg=; b=cJjWbc42PEvIj76t4rNC9DJHbRe/kZ2+CrRIIq7e7yvB40PVjAAkJpQ5qvtWhLQCHE 4g3nk9tUYgVa9JWDHxfJEZUWJM/I7yz3dU6tf56CeKMVsLR+L35t7HXn3JYBWlnv7Y5L NravLdcL+b51z2xn7H9f05EoB0ib9oRBer3esf0nU8ksqDc/zPutc2bFkYoRQl4BF03d k4EkR1M5P7jDTzVbdpvDreKYr36GPridsddeZiF1yLomQLrJR7oONH6YspSDHr2M9riR kEIHeo14yPUExQauv+efXq54CADNSUxK4NNs+ZiSbhi7RRsq7FkKSCgzNSl60gxGVnvu gkeQ== X-Gm-Message-State: AOAM530KBxAKDWjF+dOP323lVcaqBRamFQE4Vd3cLAU0OoAnSE0qDfiE bMCE08GBhQPJR85JWyXwiKK5MHFl5P4c7Q== X-Received: by 2002:adf:d08d:0:b0:20f:fb5a:6b43 with SMTP id y13-20020adfd08d000000b0020ffb5a6b43mr365028wrh.637.1653406866850; Tue, 24 May 2022 08:41:06 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id o9-20020adfba09000000b0020d07d90b71sm13472736wrg.66.2022.05.24.08.40.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 May 2022 08:41:01 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E65F91FFBE; Tue, 24 May 2022 16:40:56 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH v2 06/15] hw/virtio: add vhost-user-gpio-pci boilerplate Date: Tue, 24 May 2022 16:40:47 +0100 Message-Id: <20220524154056.2896913-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220524154056.2896913-1-alex.bennee@linaro.org> References: <20220524154056.2896913-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x434.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Viresh Kumar This allows is to instantiate a vhost-user-gpio device as part of a PCI bus. It is mostly boilerplate which looks pretty similar to the vhost-user-fs-pci device. Signed-off-by: Viresh Kumar Reviewed-by: Alex Bennée Message-Id: <5f560cab92d0d789b1c94295ec74b9952907d69d.1641987128.git.viresh.kumar@linaro.org> Signed-off-by: Alex Bennée --- hw/virtio/vhost-user-gpio-pci.c | 69 +++++++++++++++++++++++++++++++++ hw/virtio/meson.build | 1 + 2 files changed, 70 insertions(+) create mode 100644 hw/virtio/vhost-user-gpio-pci.c diff --git a/hw/virtio/vhost-user-gpio-pci.c b/hw/virtio/vhost-user-gpio-pci.c new file mode 100644 index 0000000000..b3028a24a1 --- /dev/null +++ b/hw/virtio/vhost-user-gpio-pci.c @@ -0,0 +1,69 @@ +/* + * Vhost-user gpio virtio device PCI glue + * + * Copyright (c) 2022 Viresh Kumar + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "hw/qdev-properties.h" +#include "hw/virtio/vhost-user-gpio.h" +#include "hw/virtio/virtio-pci.h" + +struct VHostUserGPIOPCI { + VirtIOPCIProxy parent_obj; + VHostUserGPIO vdev; +}; + +typedef struct VHostUserGPIOPCI VHostUserGPIOPCI; + +#define TYPE_VHOST_USER_GPIO_PCI "vhost-user-gpio-pci-base" + +DECLARE_INSTANCE_CHECKER(VHostUserGPIOPCI, VHOST_USER_GPIO_PCI, + TYPE_VHOST_USER_GPIO_PCI) + +static void vhost_user_gpio_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp) +{ + VHostUserGPIOPCI *dev = VHOST_USER_GPIO_PCI(vpci_dev); + DeviceState *vdev = DEVICE(&dev->vdev); + + vpci_dev->nvectors = 1; + qdev_realize(vdev, BUS(&vpci_dev->bus), errp); +} + +static void vhost_user_gpio_pci_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + VirtioPCIClass *k = VIRTIO_PCI_CLASS(klass); + PCIDeviceClass *pcidev_k = PCI_DEVICE_CLASS(klass); + k->realize = vhost_user_gpio_pci_realize; + set_bit(DEVICE_CATEGORY_INPUT, dc->categories); + pcidev_k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET; + pcidev_k->device_id = 0; /* Set by virtio-pci based on virtio id */ + pcidev_k->revision = 0x00; + pcidev_k->class_id = PCI_CLASS_COMMUNICATION_OTHER; +} + +static void vhost_user_gpio_pci_instance_init(Object *obj) +{ + VHostUserGPIOPCI *dev = VHOST_USER_GPIO_PCI(obj); + + virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), + TYPE_VHOST_USER_GPIO); +} + +static const VirtioPCIDeviceTypeInfo vhost_user_gpio_pci_info = { + .base_name = TYPE_VHOST_USER_GPIO_PCI, + .non_transitional_name = "vhost-user-gpio-pci", + .instance_size = sizeof(VHostUserGPIOPCI), + .instance_init = vhost_user_gpio_pci_instance_init, + .class_init = vhost_user_gpio_pci_class_init, +}; + +static void vhost_user_gpio_pci_register(void) +{ + virtio_pci_types_register(&vhost_user_gpio_pci_info); +} + +type_init(vhost_user_gpio_pci_register); diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index 33c8e71fab..c14e3db10a 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -30,6 +30,7 @@ virtio_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-mem.c')) virtio_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-user-i2c.c')) virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user-rng.c')) virtio_ss.add(when: 'CONFIG_VHOST_USER_GPIO', if_true: files('vhost-user-gpio.c')) +virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_GPIO'], if_true: files('vhost-user-gpio-pci.c')) virtio_pci_ss = ss.source_set() virtio_pci_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock-pci.c')) From patchwork Tue May 24 15:40:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 575741 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:c603:0:0:0:0 with SMTP id jv3csp2421480mab; Tue, 24 May 2022 08:58:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLk1EX1/FZf82iZSBHGcoyOpKAPwnGpy36HMwtT4wpvYBvtwnteDjVDI8L/yniMWTBNWH3 X-Received: by 2002:a05:622a:15d6:b0:2fa:1132:b9 with SMTP id d22-20020a05622a15d600b002fa113200b9mr522782qty.335.1653407914428; Tue, 24 May 2022 08:58:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653407914; cv=none; d=google.com; s=arc-20160816; b=JEXpP+U0MKV/z5jV12dpzsLmn1HCwfo28ivbB8icIoySpBNLvtICcMU7xdhOL3u4Uo +3/wCXFjLUpEUUNhZNchqAzelsMK0UC7bIJzPCP3hucyERYnxNXPjrsV6T982su4zMAJ OJ/c6IRzfzO6b18ySi22UZ6OH5ECoqA4y+H2m78SgO7Jsq+F2OhBwuTeDG9diqM2eTxx 2WhFwvbpdJsQxICCpPrfhZTFQfcINfzdIYQXhKmg4yxGpXjd7La9FlNqrNPamXiLQtY2 xl3FKeJB62evNGDXWmAJWTWe0qqk+0yZfJAYOiRN/DbqcHPzaLFZjUji76rEOnfygZFJ cr7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=73P2SMfBOog2gRv6U2nGWjPCxj4E1QB8i6yDPAw1Qyw=; b=fGD8rzbGCNh38Cbj92gMD4BFdQMytyLsKmqJJamSpL7VSdO2ONKD6Ep4T4351J39hD 5OKx85CN6Mbubl89CFyB3TGFKewsYoBzcj8zyq2+C+E99orv4gAw6boTVD/fxxiW9b/C 8zMt0XBgrhQ1NBtmcv32kE1kSgILH0eEj4IGfDQ3U9dDqXMl3p8ebvHZd+4AcGfhPG1d DjmAe2xUvqeyK7Zy70kNQoiPJQ/OL1LjMoub5U1daeE7yy1wKny8B2Uaysc8iaH83uIa WVPtFHnZSm7SbKRT0bulAQuMD2freMx180Cyf6VaEQ8UnJOEpT/eNq1R+Ks54SUMiOcq TRjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MFaISvz2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id z26-20020a05620a261a00b006a394cd0d13si2827628qko.612.2022.05.24.08.58.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 May 2022 08:58:34 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MFaISvz2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39908 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntWvY-0006JY-Vx for patch@linaro.org; Tue, 24 May 2022 11:58:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43038) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntWen-0004DH-Ul for qemu-devel@nongnu.org; Tue, 24 May 2022 11:41:13 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:39685) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ntWek-0005NG-T4 for qemu-devel@nongnu.org; Tue, 24 May 2022 11:41:13 -0400 Received: by mail-wr1-x434.google.com with SMTP id j25so1852119wrb.6 for ; Tue, 24 May 2022 08:41:10 -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=73P2SMfBOog2gRv6U2nGWjPCxj4E1QB8i6yDPAw1Qyw=; b=MFaISvz2azzTtPrFFX4NyGWm4lxgOJI8TFsP2QrvLGim43R53CY5nEq2VdUCImsnK+ N8C3lXlF3i4Jc/l6OUmKOjvsP/Mw8HZKk3/+YE0q/Chv+5+LdipxRjwIJ07pK5FvDkvP YT6PriNhmBkAOrmksjZGQXMlBbxTIFQON+2iHVoGyymIit4jPXZ7AvjHWJ0gex+5E/t8 j//0JGKiaxv2kd7bJ200gqMG7i/KXDxiakFILYbzpGv3X2NQdWD8BCixaQ/iUWmIgrWI xyAPryr+wEfUo/cly5iwpmyfIlmkgeSC4BaZsB1gpB4b6EhfEWXWcHSVHJ3aUjpV5koh I26g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=73P2SMfBOog2gRv6U2nGWjPCxj4E1QB8i6yDPAw1Qyw=; b=MWPwf5Gw4N1iha5hcMUzDgAd3yvWO3g4SfnBdq7JdrRMF3Th5q+Cle1LvVT9UCI2fI FNoBPgkR1X/6q/DgWzY22kstD/IdsJ1M676z3LYqAL9jr6weNLA6PfEwImhTYRbi1tzl zrn6hVgpUVJe3WY1vt9Gsc+VIi+W8F8nHtCQdEPPCtqY4FZGFilff7V1zFAdwGvGrprb b71rySnd8FSaG4ogeDcUVqnwxjW/8JEUREyx55cPghtJfOt0zbmFZlGG6V4ef5Sfy5cs 2w6FreC8sHLbD5pi9IVdgAelKyc2PYZwKPVkug03E4rsOfDG+kHAzL8e2EVEhm9/MQLu x0Cg== X-Gm-Message-State: AOAM532xmwmALpyjjyGOYhFOhmv22KhXHsjLiMMOnqbXlTAr1Y51hD3T wtRSYh7RWhQyaU6bqWCrFvDy7g== X-Received: by 2002:adf:e791:0:b0:20e:677a:c449 with SMTP id n17-20020adfe791000000b0020e677ac449mr23630183wrm.610.1653406869512; Tue, 24 May 2022 08:41:09 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id l24-20020adfa398000000b0020fcaba73bcsm10312496wrb.104.2022.05.24.08.40.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 May 2022 08:41:01 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 09B7A1FFBF; Tue, 24 May 2022 16:40:57 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v2 07/15] tests/qtest: pass stdout/stderr down to subtests Date: Tue, 24 May 2022 16:40:48 +0100 Message-Id: <20220524154056.2896913-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220524154056.2896913-1-alex.bennee@linaro.org> References: <20220524154056.2896913-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x434.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" When trying to work out what the virtio-net-tests where doing it was hard because the g_test_trap_subprocess redirects all output to /dev/null. Lift this restriction by using the appropriate flags so you can see something similar to what the vhost-user-blk tests show when running. Signed-off-by: Alex Bennée Message-Id: <20220407150042.2338562-1-alex.bennee@linaro.org> --- v2 - keep dumping of CLI behind the g_test_verbose flag --- tests/qtest/qos-test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/qtest/qos-test.c b/tests/qtest/qos-test.c index f97d0a08fd..7e1c8fc579 100644 --- a/tests/qtest/qos-test.c +++ b/tests/qtest/qos-test.c @@ -185,7 +185,8 @@ static void run_one_test(const void *arg) static void subprocess_run_one_test(const void *arg) { const gchar *path = arg; - g_test_trap_subprocess(path, 0, 0); + g_test_trap_subprocess(path, 0, + G_TEST_SUBPROCESS_INHERIT_STDOUT | G_TEST_SUBPROCESS_INHERIT_STDERR); g_test_trap_assert_passed(); } From patchwork Tue May 24 15:40:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 575745 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:c603:0:0:0:0 with SMTP id jv3csp2443200mab; Tue, 24 May 2022 09:22:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxx3jISZjIAaxs7BahxvoNagxXkLGgtrmA0+S9IQbhm4rGaKm7g2oepw4gk3nXNh23y1RSJ X-Received: by 2002:a05:620a:b4a:b0:69f:66fc:a3db with SMTP id x10-20020a05620a0b4a00b0069f66fca3dbmr17431889qkg.679.1653409342392; Tue, 24 May 2022 09:22:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653409342; cv=none; d=google.com; s=arc-20160816; b=n9cGwI9ujwHWaN/GGR3i3Spw8mVYV2jA66fvdcAAt2NuT9SkLipxlIADSwBmxA4UQ6 xLVba1AnmbDbW/t0q37ushVf6nB438uogUVyl9oXQzo1IYj0HTbU5T3jn6yLyiXnndiR LMhn18edZrKRzEP6GzGiRKLA8Q4vUzEBRsAp3ooGQ7fL3gaKx7bXKclULDN35rFQPhym dPmf588LlIKiH+9UotHtdjGpbzp6csr22YU1aB3DOlOG9d9h72Giz2KiCC9oXW1MTwrH 2KGFNiZjEDPkHHy2YB7Z7yDGKuKMPQCkhq5gTplwQHqT0DDMcehE7ilbO4M6edmc+wAh yDWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Hk1aHrQ9TVl6KrEJ1C7v3kI0UJPqRUC122r5YQRX1T0=; b=MZfRZVbLXdShpqGJVWe1MR5zSyyLdqhSXMDckzNw47q2TjTCk1GlheSFi71ZH6yM/b osY4DyUALJ4MUgLYhoP+gbZij1FHZLs8IVRwZVJsCFxvJZx2+efPuGWsy7dk2+GKvp2V thQYZwX2KoQhIj14j13c+/wbrpG/Esn3+EPv58FNWzjvjjnFrJgveVvBbd7pk3xjucm4 uDsUy+xMDv2afGMlDmcz7+OT3PcFJTYMOB0DR1ZHT0TPZuVa8ZMkYyCpKvoUQ+4JCKt6 NXFMnFx+VmiQWps7WWcfFiC3uVqI4bQjk1MPCyVnzd3pMrgEMxcsRWwOY+t7gVRNnCei 785Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EN+VhVPr; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y8-20020ac85f48000000b002f3cf1f3b02si4219893qta.640.2022.05.24.09.22.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 May 2022 09:22:22 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EN+VhVPr; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:53786 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntXIb-0002kn-W2 for patch@linaro.org; Tue, 24 May 2022 12:22:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42974) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntWel-00044w-4f for qemu-devel@nongnu.org; Tue, 24 May 2022 11:41:11 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:41869) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ntWeg-0005MN-Ku for qemu-devel@nongnu.org; Tue, 24 May 2022 11:41:10 -0400 Received: by mail-wr1-x42c.google.com with SMTP id u27so25452414wru.8 for ; Tue, 24 May 2022 08:41:06 -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=Hk1aHrQ9TVl6KrEJ1C7v3kI0UJPqRUC122r5YQRX1T0=; b=EN+VhVPrP0M8IVs4+YqePHOeZevPT9qaCGj+B4BvNgSlJhupwjZanpmunUUVUeBatm +Q1hVCAWlABbE1CAwnAaA4su1BWSNP1d1TVUHn6X1hGDKeNTlpBE4znAALo1l3Ttnxug i+U4EWRzIpVK/UVPjfqw49uUji7mZjBhm0M7lQX8lIamIWJDwSfGQe3JosZlJm6k+DnQ Jeg1+kJ0mQ4ouzcbbVf8Wsr4Xj2f8hnZRNaH8onqVkBLzNMZzNPA34Q/XGVmeHVx3wMe zUH5bYUlgnThB6KFIRjxWfBnOX6A/SXnWg5IpX7a3IyXQT/CSDyjL0nioQU0UXNOpuk/ I9PQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Hk1aHrQ9TVl6KrEJ1C7v3kI0UJPqRUC122r5YQRX1T0=; b=KTOMCekQI8GlxEIwejLfnN3+66zEcB9suqKNJQ3ZQzyGFdAh2oshpbwYMIrfmP0C+G fdhgK05gDN/R6GcroHVSztnX5ZZYmAWR8Q22SU9AafEls3HisrrHIO63eXa8BPhiWzEC f7PmCYyG5R0xKJ7J227N4DJUjNGUUQKegl/70Bx0OQaOwEUGqpE1Ws6+LzFSobqRdIgK S4HZ6S497olQgauGrHli958wZU6lXolHX7Seq2Fl53JTLAPdH7ZwllBJfXUqWR5ElN97 0N9Yy0OTs5x5xNShzzfDM/p3Is5UjP0y2N5ASkVf3eNlwJ5qr8mY6cEcv5FP6CKiicLG h0Ag== X-Gm-Message-State: AOAM532owOyask8LhyozsNJSSbkXBmjvH5g8KcCHik1u12ho0KYl9uWL iJoDKl4gvCzU5D8HkSjv9jTG0O5fsvcxsg== X-Received: by 2002:a5d:58f3:0:b0:20d:d14:4801 with SMTP id f19-20020a5d58f3000000b0020d0d144801mr23269955wrd.168.1653406865102; Tue, 24 May 2022 08:41:05 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id l4-20020adfbd84000000b0020e5d2a9d0bsm15698734wrh.54.2022.05.24.08.40.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 May 2022 08:41:01 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 223591FFC0; Tue, 24 May 2022 16:40:57 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v2 08/15] tests/qtest: add a timeout for subprocess_run_one_test Date: Tue, 24 May 2022 16:40:49 +0100 Message-Id: <20220524154056.2896913-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220524154056.2896913-1-alex.bennee@linaro.org> References: <20220524154056.2896913-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Hangs have been observed in the tests and currently we don't timeout if a subprocess hangs. Rectify that. Signed-off-by: Alex Bennée --- tests/qtest/qos-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/qtest/qos-test.c b/tests/qtest/qos-test.c index 7e1c8fc579..46623da731 100644 --- a/tests/qtest/qos-test.c +++ b/tests/qtest/qos-test.c @@ -185,7 +185,7 @@ static void run_one_test(const void *arg) static void subprocess_run_one_test(const void *arg) { const gchar *path = arg; - g_test_trap_subprocess(path, 0, + g_test_trap_subprocess(path, 60 * G_USEC_PER_SEC, G_TEST_SUBPROCESS_INHERIT_STDOUT | G_TEST_SUBPROCESS_INHERIT_STDERR); g_test_trap_assert_passed(); } From patchwork Tue May 24 15:40:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 575748 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:c603:0:0:0:0 with SMTP id jv3csp2449038mab; Tue, 24 May 2022 09:30:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6V1qIO3nt8luvmxncm/uW+Yj9HOZLXopk8AXM56WXG7WmrGjJD+5Y+0mZVa+itVv9Hz6H X-Received: by 2002:a05:620a:2848:b0:67d:35de:bb5b with SMTP id h8-20020a05620a284800b0067d35debb5bmr17584393qkp.499.1653409800383; Tue, 24 May 2022 09:30:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653409800; cv=none; d=google.com; s=arc-20160816; b=oBGzg//e/rWQgVIqllteELbXtMIL3KA53UbQTyyKcRK5KXC+j1MxHCYvJqD1AyIRPq dHsixJu7CY79+MACQVZal/Zaj2zWNeJuBzOiEC5N+9rXDyl5E0YXmP8sDlrE5AWbr0xa NSgTdFrrv0vF+1y2gPvsfYP35jZW+XH1jgAGtF3aniXXr32v0uAA822UNVkwtA8nzhD0 0jtHRbSVuxADZWN34cU3zGzJ+Gk4aWSsu2+SlHjLLatg4HKRA08UzIqukfcEqMUeBp2U JQa4it7gmiMbkKYW9t7XEWrAfRjvsqN59AYxxYu65RRXnf+XmKggzLIbbduXToZQ7wEp dUaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Y8ciTvhxSJt5x501FNvMsdfAL7fFfmd90rVjD5hpgVI=; b=ONW0VzJHSsVyQLSjGKAoqVDMe185mubYRSQU8oB8SgS2Xtk7YDqKxeMU5SIUCZrBfb Xeg/QEKNcpVk5QIQPAcq84t/xKolE2Nr902ytqcanm20N5/WDfjeL117KsD1bIfAXpU6 6ESgU+ynMeMVDCQ9klJDqA0F+nABYjlfjGKHTB26VWB/SgCJyuioPEgdWwQ1l5Os2xVr DeNs76q8qq2d8ZCOeQ35sXHhFo3+7DG68QCXOTCFgPZF4LfGEStq5mQOJ+Clks/FEqXY AemmrhqLVZ0Ho7LePlqUqypLVJ4BWsTYtaLRrFn1dQaYIx64vEcSau+VbOugefHtJXrb xqwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pnh4bnwM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c207-20020ae9edd8000000b006a0929ab679si4157445qkg.268.2022.05.24.09.30.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 May 2022 09:30:00 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pnh4bnwM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:43170 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntXPz-0006fM-V7 for patch@linaro.org; Tue, 24 May 2022 12:29:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43126) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntWeu-0004N0-1X for qemu-devel@nongnu.org; Tue, 24 May 2022 11:41:21 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]:38403) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ntWes-0005Sd-E0 for qemu-devel@nongnu.org; Tue, 24 May 2022 11:41:19 -0400 Received: by mail-wm1-x32a.google.com with SMTP id h205-20020a1c21d6000000b003972dda143eso1646825wmh.3 for ; Tue, 24 May 2022 08:41:17 -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=Y8ciTvhxSJt5x501FNvMsdfAL7fFfmd90rVjD5hpgVI=; b=pnh4bnwMq3JDzoRqE2IJXmUT/7GtBFMyslEiI8F7GdDjCx6WYAux77fAzvyrlHMkdQ ob8M5hFG51GattIqu80KX3muPBzArMp+O7sWBkChC6VBFBTne+H6ZZ2u1vyiK+YIIcLh zuPw5YnCrBYpphxiCy9Yo9zTJpk/rfrwU6EmzckYQFU1JR/4dTegm7qJ9+FWYK8CRHjL ODid1SvoSc6ioeNhSn0ZZNbKvTNUVUOsRw1tOTAnC+Vk/oDTeOX47YGFq5xSf/jqxG6Q BGmRKQoToYxqMhpZSDF39en6S9uYHX9WDXDu34jcf90a5qj8ju0h9aZYNVKAeNH/4FF5 2PuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Y8ciTvhxSJt5x501FNvMsdfAL7fFfmd90rVjD5hpgVI=; b=COFCF7TOizFIvK/MoWekTx/i+o21FdtzfitjeH+Yoy/02mG9jDM4wR60glp9QmPSX+ iS1pDsr5xAS9PytYzQSgJlkoKjXOsgk0BuVzRI9gmSLUq5Dm/ierOlaajWySLBYiWxAV 3szxZUfHmiIXTcbjnCd2dPvcUjjXW2sKy+eae83WTffS5sPDGn3H5Hd2Dwk2Ye3UCOW5 6YAAdpes/4Q6kVchLjoBR1C3CcINb9QRt9yOG+Kmed3fATJUAh4iL/AOaxf++3bWeVTx 3Myb/wAtuZrGJS3oVTOFHvxxunbXO0i8nJC6C/aofAUsdHmfQxRtY3nutO9Ftom9mT1S oyZg== X-Gm-Message-State: AOAM530AGYNi5RdhROHmwfU5SihLb2O0QzwIxDG05sYWEdqU1pZ3z56G wjbhDZya+fXREKj9gtFfNTh4EA== X-Received: by 2002:a05:600c:384c:b0:397:404a:3ccd with SMTP id s12-20020a05600c384c00b00397404a3ccdmr4347076wmr.114.1653406877086; Tue, 24 May 2022 08:41:17 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id h25-20020adfaa99000000b0020fe61acd09sm4890040wrc.12.2022.05.24.08.41.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 May 2022 08:41:09 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 3145F1FFC1; Tue, 24 May 2022 16:40:57 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v2 09/15] tests/qtest: use qos_printf instead of g_test_message Date: Tue, 24 May 2022 16:40:50 +0100 Message-Id: <20220524154056.2896913-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220524154056.2896913-1-alex.bennee@linaro.org> References: <20220524154056.2896913-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32a.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The vhost-user tests respawn qos-test as a standalone process. As a result the gtester framework squashes all messages coming out of it which make it hard to debug. As the test does not care about asserting certain messages just convert the tests to use the direct qos_printf. Signed-off-by: Alex Bennée --- tests/qtest/qos-test.c | 5 +++++ tests/qtest/vhost-user-test.c | 13 +++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/qtest/qos-test.c b/tests/qtest/qos-test.c index 46623da731..fef2471f8f 100644 --- a/tests/qtest/qos-test.c +++ b/tests/qtest/qos-test.c @@ -320,6 +320,11 @@ static void walk_path(QOSGraphNode *orig_path, int len) int main(int argc, char **argv, char** envp) { g_test_init(&argc, &argv, NULL); + + if (g_test_subprocess()) { + qos_printf("qos_test running single test in subprocess\n"); + } + if (g_test_verbose()) { qos_printf("ENVIRONMENT VARIABLES: {\n"); for (char **env = envp; *env != 0; env++) { diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c index a2cec87684..90749c147e 100644 --- a/tests/qtest/vhost-user-test.c +++ b/tests/qtest/vhost-user-test.c @@ -26,6 +26,7 @@ #include "libqos/virtio-pci.h" #include "libqos/malloc-pc.h" +#include "libqos/qgraph_internal.h" #include "hw/virtio/virtio-net.h" #include "standard-headers/linux/vhost_types.h" @@ -316,7 +317,7 @@ static void chr_read(void *opaque, const uint8_t *buf, int size) } if (size != VHOST_USER_HDR_SIZE) { - g_test_message("Wrong message size received %d", size); + qos_printf("%s: Wrong message size received %d\n", __func__, size); return; } @@ -327,8 +328,8 @@ static void chr_read(void *opaque, const uint8_t *buf, int size) p += VHOST_USER_HDR_SIZE; size = qemu_chr_fe_read_all(chr, p, msg.size); if (size != msg.size) { - g_test_message("Wrong message size received %d != %d", - size, msg.size); + qos_printf("%s: Wrong message size received %d != %d\n", + __func__, size, msg.size); return; } } @@ -450,7 +451,7 @@ static const char *init_hugepagefs(void) } if (access(path, R_OK | W_OK | X_OK)) { - g_test_message("access on path (%s): %s", path, strerror(errno)); + qos_printf("access on path (%s): %s", path, strerror(errno)); g_test_fail(); return NULL; } @@ -460,13 +461,13 @@ static const char *init_hugepagefs(void) } while (ret != 0 && errno == EINTR); if (ret != 0) { - g_test_message("statfs on path (%s): %s", path, strerror(errno)); + qos_printf("statfs on path (%s): %s", path, strerror(errno)); g_test_fail(); return NULL; } if (fs.f_type != HUGETLBFS_MAGIC) { - g_test_message("Warning: path not on HugeTLBFS: %s", path); + qos_printf("Warning: path not on HugeTLBFS: %s", path); g_test_fail(); return NULL; } From patchwork Tue May 24 15:40:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 575740 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:c603:0:0:0:0 with SMTP id jv3csp2419748mab; Tue, 24 May 2022 08:56:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9j3UD/rmdrHzF4AQnyYX9qI+RejfDipNoYbtnYkI6+NaQwsmryelEFoon+3NbqQlqIlPT X-Received: by 2002:ac8:7e8d:0:b0:2f3:b3c3:edfb with SMTP id w13-20020ac87e8d000000b002f3b3c3edfbmr20838092qtj.680.1653407764300; Tue, 24 May 2022 08:56:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653407764; cv=none; d=google.com; s=arc-20160816; b=F+GlbNsSMxPBZ6wAiJBgm3qckd1g8uhyq/oqTFsuJUTEy6h0bgvyz2Q+5SWUvsbQZR gh+9VPd4piWIkKdo4tOTztSB5xRjtDQiomhzDKd0uaVSdVSoBgBLp/r/6mW33FYB4Hvd RdNCBbcsdQDfPNEHqY1cbX6f1kpqCFqpykha2rDAIOUnOdBr/15TLR/mj0+fK01LqIg8 dEEkIQmlFAKyaaunLNreTlPhwKQW8LYxnmyTFH5BoosO8MZwZ7/shROEFinrjJu9EFom MSFarcR78ynmmig94VBgL6JfzchYidFgLctehmjPSYkJ12nVLq9lVNF8/Z8DYGprYp6V 8XHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0BYVTVZiKjXfpCfzCQnV5P+1PaZA5TNtHfPlJaQOz5w=; b=I4PECn1w7xWOr/CLAAs5OHYSWhr3/o0cDXgReizK29lUNSIIOGT+DTXnAdppcRW7fa OyOG/d+VDPdBxMppheHzCyJE9/TEqGFOetVtfzGI+TLntA9l4UmxvBYVV7BBpgyePMQg bet4ST6rlAdsHk17Wh0ZXySZnx8fr+UlV4D5uMIrqSbgJakJ1r5zLB8+XGTgteDjV1OS 8Czt1H5pixicWIMOVvvZjVLCpt8TGnYAy+ZnE9LwqdeGok9tfbtVXpdTMHqgD9YXFFJS wO1k3lZ0xv1zGzjdHYz1v8vLfQh/yYpsA73Tukcrg3UNJxAphtrdtLjnFkSBGPK4P2Rg +Wpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xnOug7Af; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ib13-20020a0562141c8d00b00458c912b5dbsi4333243qvb.478.2022.05.24.08.56.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 May 2022 08:56:04 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xnOug7Af; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38442 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntWt9-0005HU-RD for patch@linaro.org; Tue, 24 May 2022 11:56:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43072) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntWep-0004II-Iu for qemu-devel@nongnu.org; Tue, 24 May 2022 11:41:15 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]:43802) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ntWen-0005PR-RN for qemu-devel@nongnu.org; Tue, 24 May 2022 11:41:15 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 67-20020a1c1946000000b00397382b44f4so1643509wmz.2 for ; Tue, 24 May 2022 08:41: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=0BYVTVZiKjXfpCfzCQnV5P+1PaZA5TNtHfPlJaQOz5w=; b=xnOug7AfIomU33Kc7qg3cEIpkRU7kqx0I97Ls3urj6QlKRPizGmVCaQMaMNgdxQNQL 4uTtHGCgE1RnB5t8XvDhlfPPVFnjfHz2lJ0i1Vi8oqTn/lOz45EQoLxWURMk7h9UD2Sr K3gVbM/XJtniBLib60gukwbV7MUEWdNojT9QIp5y0LeN6PaDdAKow6RLTNCOEuzBtdfP C0fxqnB+kjfVm+kFx/8ZVk1HAlJ6N1gqOBdNX+u+lZwA4lLGTfqliVlEiOWp0gVGCMPn Otib3d0ZSKpSjK/+UG75BmLVR8e7a3LTIGK1FydK/q40OwZh7oDDBaI3fOXVRf0iGsgT CNfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0BYVTVZiKjXfpCfzCQnV5P+1PaZA5TNtHfPlJaQOz5w=; b=FBSp9mwM+48KSmkY5qPh5ODYzNLY0FX9hO177pvUpDPOaUdRJUBmG0DLp+CZXhvGtH Po3PzGTARoCTmgqBXbJk0Rxca4m6jT/bhLKZlbKzKKpaEFQ5xIoG24hmP5OAqVziaUvm NnO/9N+jjTy2xvS+vBE8WKhBJBpav+Rihxl/7XUZpVEY/vPAPKiNOHi7KZThU3anWMtI Kkg3KlRD8pvffysqQcWgAHoNzAhVgpTpWjLCCV5e/qrHgC4E3jVBbvr7Z1QfGNZNZVm/ Y03MzQQeFPxbZT5zRL0YNx31wdNGWiEJEBrBbZ/7IPElpwaT/cJaO/tIby9/Pck7bTq0 OJew== X-Gm-Message-State: AOAM531N1c63K70uj+Q0u8gu0deSCyMBTpeOnGPMoBK/lpd3160qGEzb sh8H/KCzKfgYVPdfOmelvaTCcQ== X-Received: by 2002:a7b:c5cd:0:b0:38c:8b1b:d220 with SMTP id n13-20020a7bc5cd000000b0038c8b1bd220mr4308413wmk.118.1653406872538; Tue, 24 May 2022 08:41:12 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id u22-20020adfa196000000b0020c5253d8dcsm13477778wru.40.2022.05.24.08.41.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 May 2022 08:41:09 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 50D3D1FFC2; Tue, 24 May 2022 16:40:57 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v2 10/15] tests/qtest: catch unhandled vhost-user messages Date: Tue, 24 May 2022 16:40:51 +0100 Message-Id: <20220524154056.2896913-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220524154056.2896913-1-alex.bennee@linaro.org> References: <20220524154056.2896913-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32c.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We don't need to action every message but lets document the ones we are expecting to consume so future tests don't get confused about unhandled bits. Signed-off-by: Alex Bennée --- v1 - drop g_test_fail() when we get unexpected result, that just hangs --- tests/qtest/vhost-user-test.c | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c index 90749c147e..11da6ff07a 100644 --- a/tests/qtest/vhost-user-test.c +++ b/tests/qtest/vhost-user-test.c @@ -358,12 +358,41 @@ static void chr_read(void *opaque, const uint8_t *buf, int size) } break; + case VHOST_USER_SET_OWNER: + /* + * We don't need to do anything here, the remote is just + * letting us know it is in charge. Just log it. + */ + qos_printf("set_owner: start of session\n"); + break; + case VHOST_USER_GET_PROTOCOL_FEATURES: if (s->vu_ops->get_protocol_features) { s->vu_ops->get_protocol_features(s, chr, &msg); } break; + case VHOST_USER_SET_PROTOCOL_FEATURES: + /* + * We did set VHOST_USER_F_PROTOCOL_FEATURES so its valid for + * the remote end to send this. There is no handshake reply so + * just log the details for debugging. + */ + qos_printf("set_protocol_features: 0x%"PRIx64 "\n", msg.payload.u64); + break; + + /* + * A real vhost-user backend would actually set the size and + * address of the vrings but we can simply report them. + */ + case VHOST_USER_SET_VRING_NUM: + qos_printf("set_vring_num: %d/%d\n", + msg.payload.state.index, msg.payload.state.num); + break; + case VHOST_USER_SET_VRING_ADDR: + qos_printf("set_vring_addr:\n"); + break; + case VHOST_USER_GET_VRING_BASE: /* send back vring base to qemu */ msg.flags |= VHOST_USER_REPLY_MASK; @@ -428,7 +457,18 @@ static void chr_read(void *opaque, const uint8_t *buf, int size) qemu_chr_fe_write_all(chr, p, VHOST_USER_HDR_SIZE + msg.size); break; + case VHOST_USER_SET_VRING_ENABLE: + /* + * Another case we ignore as we don't need to respond. With a + * fully functioning vhost-user we would enable/disable the + * vring monitoring. + */ + qos_printf("set_vring(%d)=%s\n", msg.payload.state.index, + msg.payload.state.num ? "enabled" : "disabled"); + break; + default: + qos_printf("vhost-user: un-handled message: %d\n", msg.request); break; } From patchwork Tue May 24 15:40:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 575747 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:c603:0:0:0:0 with SMTP id jv3csp2447858mab; Tue, 24 May 2022 09:28:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCtVTmEV6q3k2Da74OenhurKRB57rp64Ye9TtRay1LajldtqgHCYc6EXi8e9FHOSPXx8RS X-Received: by 2002:a05:6214:508c:b0:461:eb00:a171 with SMTP id kk12-20020a056214508c00b00461eb00a171mr22716383qvb.51.1653409710672; Tue, 24 May 2022 09:28:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653409710; cv=none; d=google.com; s=arc-20160816; b=gmRfB288PPXzeZMNgyBG1AU1Lh7I8GLQiwk845GpK/E7EeMaBEXPA0P+AOME+lhEbB By6UZ/mAjrQJrecRsxrAkM2cCCK2Npa4aID3GBUfqHUvtGp+VAdlD7G12AVoF8k6GuQr 37E4g0AKtg53a3jH7xr+8yiFPX0Lc77sI0BloP8Vui7cSAzf/0uPvsPtgVz6V/2h89TQ 3VyHI1L2wPx622LW65lodFYsAEKDWrngXacdL8PguCy7xtlPwvgQpUVCofAvpKyKyMln lfnQuE8EI0jdYwn2ntCTr1I/FVFkPb0UZTyoGj7RlYrWxoycFEbcp2UGtf4RjdMXV/58 iu5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lIw/XzESBQ2ZIkAn8maFDXE0YZAEzzp1ypsC723X+go=; b=fPOnLGdEA+ii6rhzYsIKoLLmo4qxrXUzpgXqj31+82ZLV1H7oKLQZ3LDSVTbfPLfF3 YZryMBmB2L6Up1gbSTH9QKtArgRfwKrLCf+fRZS/tWshcyqKwm/sC0olzGpIIFN6UQ2E iYVUiftZcAf19rjlgCelDTQH2wp41BTSxvebddvneTZ1J8W2dfQc0ENrcL4lQF82aDRT wFUfOkRE1FdLjygxbdU63F3RiUMVY1AUKzR7w8rNC9Nf7H/uebPRTUmY7V84BU3HNDu5 L5xubN9yiPy7R5VoyhuLpA/LWUia2ugFMWXP998BFaq25C6y9OQUGILovaQhwjn6xaZz GNzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gdpZI4BU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id e20-20020a05622a111400b002f3abdf6661si3579910qty.444.2022.05.24.09.28.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 May 2022 09:28:30 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gdpZI4BU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38600 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntXOY-0003Wj-7c for patch@linaro.org; Tue, 24 May 2022 12:28:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43064) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntWeo-0004G0-O9 for qemu-devel@nongnu.org; Tue, 24 May 2022 11:41:14 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:42743) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ntWem-0005OV-VH for qemu-devel@nongnu.org; Tue, 24 May 2022 11:41:14 -0400 Received: by mail-wr1-x435.google.com with SMTP id t13so7097652wrg.9 for ; Tue, 24 May 2022 08:41: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=lIw/XzESBQ2ZIkAn8maFDXE0YZAEzzp1ypsC723X+go=; b=gdpZI4BUKvCAhqLp2M0ofCADf0PazqBD6SQ7MfY0plJUJZ3cbvVyI3htPrrM2RFjTS Sb3H9xEzsISa+OsSwzqYAkEMd+Ok/hfNYqCEaMB41FEWZwAzqk3HlZAVpDmMzManaRQy j6FAuFj86gP3NhlvR+kZENLLEUnodkpRS6H5Em/uVbmWgQBTd87H549gVtRcXTDOtX6B TLKJWBRVJ7US4cZ9yxrkiH00XurZXoS7Qa5KVDP8PoCxNuvCfWgPZhrRWFHokGjigOcm 22ITGYqTdi03hl0PlADAPf8KReIoPXBjNZXv59KLHWu60zouqzB4Aaohm12yXEV1uWNV Xq+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lIw/XzESBQ2ZIkAn8maFDXE0YZAEzzp1ypsC723X+go=; b=wjxV7SU4Ym6tA7iingfiFkXKSgbUX1fjrngf50CIZJD/lviULtTFXVyGbA9zmv42iH 85/Cgtzb9PSEyGoem10DVLU5qgsp/2BsArwxcBK/BNIlMIXboN8WoyiiOqN/88wxVDx2 kzGdfj5DJbhYMZotjFW/hf+vWFOUi/3HBHiMy6LEV6W/gtD+1949zKDKCuCPXYekICoK hau2Ii6QP3OH3KEhbG4FxNOHML53M241bRo1njBLkdW2L0rJvqKpds1uU3VK6hugCiH6 tkddQ7RlN0QgRd9iiAK2rTB31AqDGkQL+BFJ3DR7s4ggW8cFFns0jmPQ+XnLxB+FcE8N rCvw== X-Gm-Message-State: AOAM532Lf7pjGZsM+IAEXKgCzzYJwUqrjcSByOkd1IcQlLYuu85gfkOg D6gCl2+KKV9lTr1IijD9RpGbZA== X-Received: by 2002:a05:6000:186c:b0:20f:e176:df0b with SMTP id d12-20020a056000186c00b0020fe176df0bmr8004355wri.608.1653406871606; Tue, 24 May 2022 08:41:11 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id u25-20020adfae59000000b0020d106c0386sm13283414wrd.89.2022.05.24.08.41.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 May 2022 08:41:09 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 5DAA41FFC3; Tue, 24 May 2022 16:40:57 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v2 11/15] tests/qtest: use g_autofree for test_server_create_chr Date: Tue, 24 May 2022 16:40:52 +0100 Message-Id: <20220524154056.2896913-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220524154056.2896913-1-alex.bennee@linaro.org> References: <20220524154056.2896913-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x435.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alex Bennée --- tests/qtest/vhost-user-test.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c index 11da6ff07a..d0fa034601 100644 --- a/tests/qtest/vhost-user-test.c +++ b/tests/qtest/vhost-user-test.c @@ -565,14 +565,13 @@ static void chr_event(void *opaque, QEMUChrEvent event) static void test_server_create_chr(TestServer *server, const gchar *opt) { - gchar *chr_path; + g_autofree gchar *chr_path = g_strdup_printf("unix:%s%s", + server->socket_path, opt); Chardev *chr; - chr_path = g_strdup_printf("unix:%s%s", server->socket_path, opt); chr = qemu_chr_new(server->chr_name, chr_path, server->context); - g_free(chr_path); + g_assert(chr); - g_assert_nonnull(chr); qemu_chr_fe_init(&server->chr, chr, &error_abort); qemu_chr_fe_set_handlers(&server->chr, chr_can_read, chr_read, chr_event, NULL, server, server->context, true); From patchwork Tue May 24 15:40:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 575743 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:c603:0:0:0:0 with SMTP id jv3csp2429366mab; Tue, 24 May 2022 09:06:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnhsWNUOOU30+yb/5IiCY9UrG1+Er+zh3Wm+EOJEfo37owWcpgpemQcKhtFaW+J/qC/e2t X-Received: by 2002:a05:622a:100a:b0:2f3:c5db:70ef with SMTP id d10-20020a05622a100a00b002f3c5db70efmr21327266qte.334.1653408401682; Tue, 24 May 2022 09:06:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653408401; cv=none; d=google.com; s=arc-20160816; b=bsLFF/gvOf/2sFjBoVVQQbQQmATqksTKMXZBdW8AHWTOnarumbi/qvFPqk5if/3SFY 7J/K6a0h99LDgdE9aTfzfnY3hM+FV4on+Lg8+/yQSJ1tejZK/O2J6SRzH8DArde3l5iN oVbacqB+3T6rHGmO22ttP7QpbiFb+XWqds4O5LHWEVmgR1UElymPNS2vnI9LAUZkDRZ1 x7uOQT2sedqUjHMGSJXhtfKvrBTSs5NfkqPNO/YcZ6+/PPw1HmXNHq/LbvJzwpyGF8bS 37SHpK1NyJ8DcRtJuB2v9bCN9d+jf9VF/9P695B7KsfIm/vZPm79uR5/QLhTs35ru0Wv lZ7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=M3AwLOO4tJSX2vgFnHe89rY8t5sl7yh4FwF2sza60a4=; b=Utg0UgUvIKalrn54Oc5FDdtnj1Mru5eWiSCrSndIowGuciWXg1n3zcB4DzD+6SDByz qmGvqtPyEFJzeLgSv/4uRC4q3E8H8yxkvYgC7ubOUuDihHkrvQDI8nDoJonSGFZVHayR JLWOa3gPeDi2J1tnf9I3b1stsZHf+z1sL51X9xFBOSilTwAULWK65VVMcv4eT/WMZ4gg EZ0Fl4eKmaKo5nc5XYh6asTiCcpmyOqOx4HemtPFKb1rPf1tGKfv5ou25qe0jkRQGg1P FMp7E0Y+iwCzstgGd8GFYRLDc2H/bWyHeRLKU9nBUsXE1L1/mOGfzf+ACRwr9mWzOXm3 3LrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=im3x5G7w; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q5-20020a37a705000000b0069f6dfefd01si4012737qke.532.2022.05.24.09.06.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 May 2022 09:06:41 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=im3x5G7w; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:55216 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntX3R-0000wN-24 for patch@linaro.org; Tue, 24 May 2022 12:06:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43116) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntWes-0004M5-OG for qemu-devel@nongnu.org; Tue, 24 May 2022 11:41:18 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:39685) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ntWer-0005NG-3u for qemu-devel@nongnu.org; Tue, 24 May 2022 11:41:18 -0400 Received: by mail-wr1-x434.google.com with SMTP id j25so1852119wrb.6 for ; Tue, 24 May 2022 08:41: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=M3AwLOO4tJSX2vgFnHe89rY8t5sl7yh4FwF2sza60a4=; b=im3x5G7w4bnJoBUOvFnpZURKf6o+gjxK1ObwTA8fOKl4hI1s05cgQ35jQGBdTtQeHF s4Zj+u8tXyCwOP0GI66tFBD0/UWvsOfX0iLxWHSD24zj6jKLtjb0LwhePcoL+owWg2qx s3Gi4g1HyXkgwe8HidDEVq9pDtaAGFNjzpki2mQ4F1MLei0GtBWiYqs2ykFvq2C/pHFm 37tBpSu57P6tmx+vMKz5/xaRn29fVCPs+5Ax//cJNMNS/O3dE7IQEOq2N538lNtjoMsQ C2qXh26Xg/57epFIiQeMBMZR+7tvwY713no05Uamks7pP0UNaHMr+O7p+FakOU7sXev6 JNYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=M3AwLOO4tJSX2vgFnHe89rY8t5sl7yh4FwF2sza60a4=; b=7ocoZSKPME2yA+Pk1R46er54g459qMjY1txXGuJJcbo9CCqH935iZ03AiGBiYB1id6 pWVmEnuoiBN6gsVChzyV+fKtibRkUkYJu/unl783j/UvbYtO2fJTF3tqFHFG+5G6dY0t b4agyUgA0IXkd11pc+V6Nl0Pxsq/6GdxNkJT/p2kCvPYrATOgYoTnrpx8617QkDF+da1 Cq4vM72GucDNW7r4/QBa8M92fX9AkWvVIuwq4TE09sVg7kC9bMUfSQ7k1Y/SN4Jw2Cjj XMeYhU5C+5UYumZf+kagweB6FU5ylTFv7PFawUnXu+lhIqcZzFAavl7+lAezmXHQjDBv 3PDQ== X-Gm-Message-State: AOAM533F3roZtWXvsQlQJWvvlnD48GH437/5ObN0uZuFev0kkdZ3YjPz uu+ZkJjsfMmvwL7JqQkQYadXNA== X-Received: by 2002:a05:6000:2a8:b0:20f:c56e:3f5e with SMTP id l8-20020a05600002a800b0020fc56e3f5emr14531517wry.22.1653406876331; Tue, 24 May 2022 08:41:16 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id p42-20020a05600c1daa00b003942a244f40sm2661488wms.25.2022.05.24.08.41.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 May 2022 08:41:09 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 751451FFC4; Tue, 24 May 2022 16:40:57 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v2 12/15] tests/qtest: plain g_assert for VHOST_USER_F_PROTOCOL_FEATURES Date: Tue, 24 May 2022 16:40:53 +0100 Message-Id: <20220524154056.2896913-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220524154056.2896913-1-alex.bennee@linaro.org> References: <20220524154056.2896913-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x434.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" checkpatch.pl warns that non-plain asserts should be avoided so convert the check to a plain g_assert. Signed-off-by: Alex Bennée --- tests/qtest/vhost-user-test.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c index d0fa034601..db18e0b664 100644 --- a/tests/qtest/vhost-user-test.c +++ b/tests/qtest/vhost-user-test.c @@ -980,8 +980,7 @@ static void test_multiqueue(void *obj, void *arg, QGuestAllocator *alloc) static void vu_net_set_features(TestServer *s, CharBackend *chr, VhostUserMsg *msg) { - g_assert_cmpint(msg->payload.u64 & - (0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES), !=, 0ULL); + g_assert(msg->payload.u64 & (0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES)); if (s->test_flags == TEST_FLAGS_DISCONNECT) { qemu_chr_fe_disconnect(chr); s->test_flags = TEST_FLAGS_BAD; From patchwork Tue May 24 15:40:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 575742 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:c603:0:0:0:0 with SMTP id jv3csp2425878mab; Tue, 24 May 2022 09:03:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqe6IaWAnHUBr6sdQEkGRbmb/QPrEu3606VxeSizVjJ7jUNhLLylL0Uz+KNH1XePBxd2xz X-Received: by 2002:ac8:5988:0:b0:2f3:decb:6b6b with SMTP id e8-20020ac85988000000b002f3decb6b6bmr20513902qte.289.1653408197532; Tue, 24 May 2022 09:03:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653408197; cv=none; d=google.com; s=arc-20160816; b=EZ8BYQcBdtDUJu/ymhSGq0ywXaZrQfg1Wnd1wAYcXtO/Dc/nOlT2q2utMFwPNKk4rV s6MapfPpi2WhYPlWaD3N7/IWMwcPM5YwmRdvwje0/b5qnyk6887Ja1ANEQkFaMG/7WNY UBTVf7wbZo3OXM4HkIwiUH0+gm7SfBizrmsj2CzKMHzFOJiFVqrprp40VGqvq+d+Mdem XYs52Z+RKD8YBxiLEjLTg2epaEccyhFrAaE4xiq0fdKzMinFBkMNo5rp/G5XmZQ8I4fk 4BOoXbo9qbVmKZ0BOBC6/excKlPa8R6p5av24L52uLxnv8LBfANPd5DhNNs0HqND5WdC xcSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hfKNVlrrL3u0vef+FWTAR3LbzLx2Gk+OTMM5YcoQN7Q=; b=HYv4NWQ7JpkYAeMQbRJMqoKviZ3pAhwiqHsHemSMeYjzqzXYmVBbCxTLQzXUGW3PTY TMeH5rbACm87WO3qcHfAI6ZJM5fl2ddN14rWLsodCctM/odLwKbcdzvnPEXBkokWMTpa AuGR8YjzIJrOo1d9H+GjZCNYQJ49YDEffrsqq3bxm29hxAxOkOJlO8ZxJ5+4gkhnvb1v +2fpAg2XuWoOJW3uFMDGw+nT3Vo3EnFxPdi2UQ0JyuOH8mYzKHIRI8SXkVJR8/CBcPPG TpHRvCt2QSkXwW8SYA4cEduLXeJKl1FCH+8jquZTN5HkSrPCexOnj0kFxAFrh37lfPDN gp1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="owQHW/kR"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p21-20020a05620a113500b006a38b115213si2707992qkk.632.2022.05.24.09.03.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 May 2022 09:03:17 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="owQHW/kR"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:46866 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntX09-00037n-46 for patch@linaro.org; Tue, 24 May 2022 12:03:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43102) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntWer-0004LA-In for qemu-devel@nongnu.org; Tue, 24 May 2022 11:41:18 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:35775) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ntWep-0005QW-QQ for qemu-devel@nongnu.org; Tue, 24 May 2022 11:41:17 -0400 Received: by mail-wr1-x434.google.com with SMTP id x12so2027892wrg.2 for ; Tue, 24 May 2022 08:41:15 -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=hfKNVlrrL3u0vef+FWTAR3LbzLx2Gk+OTMM5YcoQN7Q=; b=owQHW/kRAB58wTje3tlWm07SzXA21elY3U42uFBe60oQRlewztfkpjz7YmVg6PB6zA /bauRLTd1k2Q3s81zHWbo2J79jhBIEHELgr97AYV+upEdGcqqOo6zuSI869Zr0hwTptX 3wEI/aillpylk1ulvGCFYkyKpT5kpAOBf0zdDTs8YZ0bYjvWMjjT9YZKr/Hk3G4PgP1h xnV3hI82zbmyXPZ7eeowiriOZBuPsz3GXzkoyfo0xectFFk5UG41kyX7Zql8QB0QA3Ng /mMTFEnIxbwlPgECPCwtSrgSlo1GqpST+/mA8LVWTecI07AH3i3Xwqwy4ALgsndaswjs VYwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hfKNVlrrL3u0vef+FWTAR3LbzLx2Gk+OTMM5YcoQN7Q=; b=zDr13bIXccctEz+kEG4COZLnyRilWcbNMbwHHSlIPj6iOtlX2YvzTmPhIlDCPbiCsD E+reaATfitx1pY7ptQc8o3vwh3iqY7ZFkd+UdxhwUdd4RrdzGLEJ7ZSJDnfgJJpqoahJ 0MTzZZMBOYN61fx6n1jDl5v02B2Y4o0/NTVRChnI/t2ru4N+2WPOiYH8QFqErmrA58Ap clVR98F1CQRDllkMHualB9SdwlqlAYTUBirNynGWrMqdNB7bc73Cu6xLnyETrOVnI127 4wiOyluZcLLlMQVIGedB4lfBomtowGYUQvzm9pRv6MZENi3oNG9PgrixZ/kuyLhZbDa/ nxCg== X-Gm-Message-State: AOAM530cptbqyTzzFK45E4HlG4wgUtRlKob3XhdnojNDMWM4DLg9AEiw QLqh7ta5ga4FhSMkvXO/ifI7ywRFwVX8eg== X-Received: by 2002:a5d:4e05:0:b0:20d:1f0:1f31 with SMTP id p5-20020a5d4e05000000b0020d01f01f31mr24130748wrt.492.1653406874518; Tue, 24 May 2022 08:41:14 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id q22-20020a1cf316000000b00394708a3d7dsm2355759wmq.15.2022.05.24.08.41.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 May 2022 08:41:09 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 820E91FFC5; Tue, 24 May 2022 16:40:57 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v2 13/15] tests/qtest: implement stub for VHOST_USER_GET_CONFIG Date: Tue, 24 May 2022 16:40:54 +0100 Message-Id: <20220524154056.2896913-14-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220524154056.2896913-1-alex.bennee@linaro.org> References: <20220524154056.2896913-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x434.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We don't implement the full solution because frankly none of the tests need to at the moment. We may end up re-implementing libvhostuser in the end. Signed-off-by: Alex Bennée --- tests/qtest/vhost-user-test.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c index db18e0b664..d546721f5d 100644 --- a/tests/qtest/vhost-user-test.c +++ b/tests/qtest/vhost-user-test.c @@ -79,6 +79,8 @@ typedef enum VhostUserRequest { VHOST_USER_SET_PROTOCOL_FEATURES = 16, VHOST_USER_GET_QUEUE_NUM = 17, VHOST_USER_SET_VRING_ENABLE = 18, + VHOST_USER_GET_CONFIG = 24, + VHOST_USER_SET_CONFIG = 25, VHOST_USER_MAX } VhostUserRequest; @@ -372,6 +374,17 @@ static void chr_read(void *opaque, const uint8_t *buf, int size) } break; + case VHOST_USER_GET_CONFIG: + /* + * Treat GET_CONFIG as a NOP and just reply and let the guest + * consider we have updated its memory. Tests currently don't + * require working configs. + */ + msg.flags |= VHOST_USER_REPLY_MASK; + p = (uint8_t *) &msg; + qemu_chr_fe_write_all(chr, p, VHOST_USER_HDR_SIZE + msg.size); + break; + case VHOST_USER_SET_PROTOCOL_FEATURES: /* * We did set VHOST_USER_F_PROTOCOL_FEATURES so its valid for From patchwork Tue May 24 15:40:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 575750 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:c603:0:0:0:0 with SMTP id jv3csp2456401mab; Tue, 24 May 2022 09:38:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzyBAGGGKmft9oW/T2/fcj6WSFsQuRmaOtmNuH+tR1rqYm1i90a2QaWQtZXZ7n6/PMvazdU X-Received: by 2002:a05:622a:8f:b0:2f9:3b95:431e with SMTP id o15-20020a05622a008f00b002f93b95431emr6138553qtw.129.1653410322849; Tue, 24 May 2022 09:38:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653410322; cv=none; d=google.com; s=arc-20160816; b=IkAqSugRAHJkZxAORDAyyd/dTKkMfphsO8zyc1ZussLbH7Dd2Z5QXW5JMIOsjyszzl /4EJa0hbN7ACSVBMb1RPwlr2rma7aAxC2vYs12ArfTorfkB3Oe4WZ+MBZZUErLQD+q5q 1qLw6BlOvxKWSpxjpA7Ck0zDYQZL4j9qUrGzN91NIohoy9FS3TavN9rZSWDMa4FiOMGs ldBArfQ0DBZzioY5FuKutqZl2ojFqmXy8XpkGP/fgJ8JnPz5UzTCO0zaQcB3Oi3jhahI MyJVLWWBXSbWn2tu/st5DELjSzVSMnbfjwv/l0YhQ7VJs3Ne8RRenmd8JihuBF/K8fM6 bJHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5yuBY8XhniW5U3BckTrWu3/MUge9sIzVNIAB45zhSUM=; b=pPDr0LrOXXG4XXoCo6gNQoUs+GjqfI6sIsinWjUREQu4UHSt0eidB8+CfYUfRPpSTF mqEbj9fz76A4lhCMFwUe7a484QzoWbJML9XiHgIZ7NdvfxKuDQcmkisIwmgCHmyY+iPX 5+MXzj666GVu75EZitEJpWhkzFydNYM+bHxdSx0bvbro8OqEiGXLshH2RNPheX3RcJXT GUsp2Ji/qo8p+Vk+P+HTb2cgIs/Y9qSgHx92X7dJ/jwX7fZGvzi6IE7mL0DPMhZstgdD oOg0v94F1oqu72mGngeXq4kCmEwu78lTqpo5YxvV0IjKas5QpIYrAUrvLU47eXIEmhih jTBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Y6HqfDQH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u18-20020a05622a199200b002f935c976cbsi3218403qtc.719.2022.05.24.09.38.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 May 2022 09:38:42 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Y6HqfDQH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:58712 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntXYQ-0000ea-ET for patch@linaro.org; Tue, 24 May 2022 12:38:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45348) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntWn2-00086o-Lz for qemu-devel@nongnu.org; Tue, 24 May 2022 11:49:45 -0400 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]:47039) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ntWn1-0006bw-14 for qemu-devel@nongnu.org; Tue, 24 May 2022 11:49:44 -0400 Received: by mail-ej1-x62d.google.com with SMTP id rs12so24471380ejb.13 for ; Tue, 24 May 2022 08:49:42 -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=5yuBY8XhniW5U3BckTrWu3/MUge9sIzVNIAB45zhSUM=; b=Y6HqfDQHFttIjqC81mmE82QINLR8upwEZNbs5ioxVJBvMlel5J73AR8dM+FfN4cPqm /xiU0W+60mFkLU26ADGqp4fq4y/uY6fJK82+ATViGmwrCkmC07QzubmJ2I7+5e9z/tN6 ++2c9/VmPb7olA6TGkpfTIncAC2l1RQnrSP28HVtgzOZb1DpaB2KdhJe7sNIX7+wJSG9 5FRT7VNcrAfF9NqvDmgxsGrokpwcwBeD7DOn4ZStgVuav+PJmtqO0h3TWckPq05Aupud vfSKnsuCGH9nJGcZQIkYiDyFfie6jIAbHQfDpWF4o8AGYyfGa4FBcrqGruVzGig4IabN dzcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5yuBY8XhniW5U3BckTrWu3/MUge9sIzVNIAB45zhSUM=; b=B1a6POS90F4PPAXUUhZITaMr3wUmSMc8WLWACWGRF0/yiYPGNryHSWFKIm0rZKgaMa R48+EKiCjatdQwCosPab7c7hJshv03Vi43fQenr3dVHMapACxsvL3LJp9LZwPMgA907X GnEO04q4rXhsFZxo+ow+jbr07wde+1sM6TIuHYQHlAfd+Ot3O86WI+eehrfaHnDCC8c9 7aTUByi8YXqGt4OGNf8DMHP+FVfRTU5wU30iANKin5MoVZ7Y/DCWpnAPA335jdwKFl11 hQZ8UIsiN4TzNnGXTBSbaiigpQelXu2DjHurytwcKrzQyKRcpzoO2nLMToeuGTAxeaB/ EEfg== X-Gm-Message-State: AOAM532+0WVt8xYbfxO/eArYbs2tyKKwDhW9NLYdeoMUnklOKqD+jzpt T5Gf5EaAN0C5CheajjAvMYowjQ== X-Received: by 2002:a17:907:6093:b0:6fe:a585:143c with SMTP id ht19-20020a170907609300b006fea585143cmr19705845ejc.236.1653407381562; Tue, 24 May 2022 08:49:41 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id z9-20020a1709063ac900b006fedcb78854sm2525982ejd.164.2022.05.24.08.49.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 May 2022 08:49:40 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 99E3A1FFC6; Tue, 24 May 2022 16:40:57 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v2 14/15] tests/qtest: add a get_features op to vhost-user-test Date: Tue, 24 May 2022 16:40:55 +0100 Message-Id: <20220524154056.2896913-15-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220524154056.2896913-1-alex.bennee@linaro.org> References: <20220524154056.2896913-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62d; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x62d.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" As we expand this test for more virtio devices we will need to support different feature sets. Add a mandatory op field to fetch the list of features needed for the test itself. Signed-off-by: Alex Bennée --- tests/qtest/vhost-user-test.c | 37 +++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c index d546721f5d..28b4cf28ec 100644 --- a/tests/qtest/vhost-user-test.c +++ b/tests/qtest/vhost-user-test.c @@ -171,10 +171,11 @@ struct vhost_user_ops { const char *chr_opts); /* VHOST-USER commands. */ + uint64_t (*get_features)(TestServer *s); void (*set_features)(TestServer *s, CharBackend *chr, - VhostUserMsg *msg); + VhostUserMsg *msg); void (*get_protocol_features)(TestServer *s, - CharBackend *chr, VhostUserMsg *msg); + CharBackend *chr, VhostUserMsg *msg); }; static const char *init_hugepagefs(void); @@ -338,20 +339,22 @@ static void chr_read(void *opaque, const uint8_t *buf, int size) switch (msg.request) { case VHOST_USER_GET_FEATURES: + /* Mandatory for tests to define get_features */ + g_assert(s->vu_ops->get_features); + /* send back features to qemu */ msg.flags |= VHOST_USER_REPLY_MASK; msg.size = sizeof(m.payload.u64); - msg.payload.u64 = 0x1ULL << VHOST_F_LOG_ALL | - 0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES; - if (s->queues > 1) { - msg.payload.u64 |= 0x1ULL << VIRTIO_NET_F_MQ; - } + if (s->test_flags >= TEST_FLAGS_BAD) { msg.payload.u64 = 0; s->test_flags = TEST_FLAGS_END; + } else { + msg.payload.u64 = s->vu_ops->get_features(s); } - p = (uint8_t *) &msg; - qemu_chr_fe_write_all(chr, p, VHOST_USER_HDR_SIZE + msg.size); + + qemu_chr_fe_write_all(chr, (uint8_t *) &msg, + VHOST_USER_HDR_SIZE + msg.size); break; case VHOST_USER_SET_FEATURES: @@ -990,8 +993,21 @@ static void test_multiqueue(void *obj, void *arg, QGuestAllocator *alloc) wait_for_rings_started(s, s->queues * 2); } + +static uint64_t vu_net_get_features(TestServer *s) +{ + uint64_t features = 0x1ULL << VHOST_F_LOG_ALL | + 0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES; + + if (s->queues > 1) { + features |= 0x1ULL << VIRTIO_NET_F_MQ; + } + + return features; +} + static void vu_net_set_features(TestServer *s, CharBackend *chr, - VhostUserMsg *msg) + VhostUserMsg *msg) { g_assert(msg->payload.u64 & (0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES)); if (s->test_flags == TEST_FLAGS_DISCONNECT) { @@ -1020,6 +1036,7 @@ static struct vhost_user_ops g_vu_net_ops = { .append_opts = append_vhost_net_opts, + .get_features = vu_net_get_features, .set_features = vu_net_set_features, .get_protocol_features = vu_net_get_protocol_features, }; From patchwork Tue May 24 15:40:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 575744 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:c603:0:0:0:0 with SMTP id jv3csp2440721mab; Tue, 24 May 2022 09:19:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykjOO9MZWDRnb/0PfmQ3BGDYX35sAnpzd570JXtuKWxc0XMtQKbFgU9+GC2GH8IGyHXggf X-Received: by 2002:a05:620a:3704:b0:6a3:83fa:4c91 with SMTP id de4-20020a05620a370400b006a383fa4c91mr7285996qkb.720.1653409157223; Tue, 24 May 2022 09:19:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653409157; cv=none; d=google.com; s=arc-20160816; b=VYFixI5Wmw2K6SRXjTlhMgFGwlOD8aUHhn4s5KcbO0CyNe6RuDusbAIjufy7h/vxbO 8nAmqQ3zbA24YhOb/GUJPNsFpvZpQBoEa06rFvM2H6g0B2lgzOYn7XkmHqNrl8hIl+FC 1dwKsqgPnHvXAJ52DO8zP9n8YBl4EQ+qb6b/pvG4BI9lgxiZIiBbt3sPuWZViM8GzrIl ZY1elWogKA7x397vgrkV8dgO0tC6+rVhiaLyP8USgUpcRAFGiVa6ZvVWtvJOVs728Mg2 by9upJleckjqK/FemYhUCDcrsljh4N8jr7Ead8WEG9mhmVFpu7jlTXhbaTGXXL/oj/wN Om+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lCTpKnmtO5WxNA6xgenekcxC5CTR5A2/QeDUhDt/YRE=; b=o4g9MdjShxHkYbb9cnwFxnfCiqeN22CeD36Mjsam3JP7Uxl3ZiI45+7vJfUjsHZ+QG OErbGSUSQcNLqBD20zNW/mNqdZN/Zujyj0fNPL+r+nGERzsEvtvLHApEthQqmRNGHchp MI4SunmNfxqlCRbQuE/vs1ydGqeA7GVAW6/re8HRiqLOIuYP3qWl5o45p+BJl+KseK8D 4dIPd4fJZGu2iCmvb0QsiXItL/LIc9bR0jQcCkRdWDfNohbBSz/dlewqSvPJZJpwSPSV ddc7Fi9nTLH/9M+MRxqgmpW8RqqKMuHG5q5dAnzl7Z6oueHFFK93H4PRdPBxLcGWhHJl 1nZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="n4RGXj/1"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id kj23-20020a056214529700b0046217920b31si3911123qvb.241.2022.05.24.09.19.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 May 2022 09:19:17 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="n4RGXj/1"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:49522 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntXFc-0008Ez-Pr for patch@linaro.org; Tue, 24 May 2022 12:19:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45358) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntWn4-000883-3k for qemu-devel@nongnu.org; Tue, 24 May 2022 11:49:46 -0400 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]:41552) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ntWn1-0006cF-Up for qemu-devel@nongnu.org; Tue, 24 May 2022 11:49:45 -0400 Received: by mail-ed1-x52d.google.com with SMTP id h11so22459406eda.8 for ; Tue, 24 May 2022 08:49:43 -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=lCTpKnmtO5WxNA6xgenekcxC5CTR5A2/QeDUhDt/YRE=; b=n4RGXj/1g8KP4E31aLIBhQ30OWlzBVm2QMNLmdaFCPS5nMlL6ew3xyOk62i1zetS06 rLCYb4CzfpraXDwHbd61nTBcRj6zJG8+iAGjZFtH4zwm+6iQcqj5LSn3DZt0ieTfkLJt Fy808hYu9G5LwsbhPg5JvUYxhhFSY9pZntgMa+vGfjRU2qwg64jiUYqwmDwytU9eajTH 8/wL2Do8UlmBhVA+drR6DkpbrmJGbaCjZGaiTtnhQaACOXRUQLyv7UN5jRw+BvBCrVSb Kjz6uvOaCE9X7nvr0akqTxw/L4twKY78YrPJGvM7XOAyXna2vxLOT68Qs6x25sMssESG 5jwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lCTpKnmtO5WxNA6xgenekcxC5CTR5A2/QeDUhDt/YRE=; b=jKUbZ2A5vLVTeGilMP2MOgjrhnphAQ5Zss13JmAjFcyDbLOkb5xn2mh61AdtUe2bnB 9W6LkGC5QdWsuHdEiWyfeksco8FsDKka8R9XcWERfjUERJlNrJtHl6veXt5wRMAKGclH TchRtlW4DbjUcZBbZYxwORKUP6xGvJBKEIAP1KDpxGMXnh71r48q57zlSF/FdysgsrqM DGijxLsUVtNKCWuNH9EMdmwC9oeCNXnLni0Ub+P+2jz4MNHdBjL/46wVB2Wb4889XXmW uOFj1vgAs4K+DJ6j29InGqY2IkmvfrWoZ+fwlMnnPRlQlMLdGY/XNZfgzPXCl0PhF5h2 RRjQ== X-Gm-Message-State: AOAM533qh4HNNqgKVvpAh5rmWlNJMYLMIJo+1e5LeTI/XS/xq2YYxAWJ fsb3bNikHrPMDjBKEvqty/H71g== X-Received: by 2002:aa7:c3d2:0:b0:42a:b39d:b30c with SMTP id l18-20020aa7c3d2000000b0042ab39db30cmr30172269edr.368.1653407382447; Tue, 24 May 2022 08:49:42 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id h24-20020a1709070b1800b006f3ef214e5csm5403135ejl.194.2022.05.24.08.49.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 May 2022 08:49:40 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id B48CA1FFC7; Tue, 24 May 2022 16:40:57 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Paolo Bonzini , Eric Auger , Thomas Huth , Laurent Vivier Subject: [PATCH v2 15/15] tests/qtest: enable tests for virtio-gpio Date: Tue, 24 May 2022 16:40:56 +0100 Message-Id: <20220524154056.2896913-16-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220524154056.2896913-1-alex.bennee@linaro.org> References: <20220524154056.2896913-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52d; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x52d.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We don't have a virtio-gpio implementation in QEMU and only support a vhost-user backend. The QEMU side of the code is minimal so it should be enough to instantiate the device and pass some vhost-user messages over the control socket. To do this we hook into the existing vhost-user-test code and just add the bits required for gpio. Signed-off-by: Alex Bennée Cc: Viresh Kumar Cc: Paolo Bonzini Cc: Eric Auger Message-Id: <20220408155704.2777166-1-alex.bennee@linaro.org> --- v2 - add more of the missing boilerplate - don't request LOG_SHMD - use get_features op - report VIRTIO_F_VERSION_1 - more comments --- tests/qtest/libqos/virtio-gpio.h | 35 +++++++ tests/qtest/libqos/virtio-gpio.c | 171 +++++++++++++++++++++++++++++++ tests/qtest/libqos/virtio.c | 2 +- tests/qtest/vhost-user-test.c | 66 ++++++++++++ tests/qtest/libqos/meson.build | 1 + 5 files changed, 274 insertions(+), 1 deletion(-) create mode 100644 tests/qtest/libqos/virtio-gpio.h create mode 100644 tests/qtest/libqos/virtio-gpio.c diff --git a/tests/qtest/libqos/virtio-gpio.h b/tests/qtest/libqos/virtio-gpio.h new file mode 100644 index 0000000000..f11d41bd19 --- /dev/null +++ b/tests/qtest/libqos/virtio-gpio.h @@ -0,0 +1,35 @@ +/* + * virtio-gpio structures + * + * Copyright (c) 2022 Linaro Ltd + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef TESTS_LIBQOS_VIRTIO_GPIO_H +#define TESTS_LIBQOS_VIRTIO_GPIO_H + +#include "qgraph.h" +#include "virtio.h" +#include "virtio-pci.h" + +typedef struct QVhostUserGPIO QVhostUserGPIO; +typedef struct QVhostUserGPIOPCI QVhostUserGPIOPCI; +typedef struct QVhostUserGPIODevice QVhostUserGPIODevice; + +struct QVhostUserGPIO { + QVirtioDevice *vdev; + QVirtQueue **queues; +}; + +struct QVhostUserGPIOPCI { + QVirtioPCIDevice pci_vdev; + QVhostUserGPIO gpio; +}; + +struct QVhostUserGPIODevice { + QOSGraphObject obj; + QVhostUserGPIO gpio; +}; + +#endif diff --git a/tests/qtest/libqos/virtio-gpio.c b/tests/qtest/libqos/virtio-gpio.c new file mode 100644 index 0000000000..762aa6695b --- /dev/null +++ b/tests/qtest/libqos/virtio-gpio.c @@ -0,0 +1,171 @@ +/* + * virtio-gpio nodes for testing + * + * Copyright (c) 2022 Linaro Ltd + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "standard-headers/linux/virtio_config.h" +#include "../libqtest.h" +#include "qemu/module.h" +#include "qgraph.h" +#include "virtio-gpio.h" + +static QGuestAllocator *alloc; + +static void virtio_gpio_cleanup(QVhostUserGPIO *gpio) +{ + QVirtioDevice *vdev = gpio->vdev; + int i; + + for (i = 0; i < 2; i++) { + qvirtqueue_cleanup(vdev->bus, gpio->queues[i], alloc); + } + g_free(gpio->queues); +} + +/* + * This handles the VirtIO setup from the point of view of the driver + * frontend and therefor doesn't present any vhost specific features + * and in fact masks of the re-used bit. + */ +static void virtio_gpio_setup(QVhostUserGPIO *gpio) +{ + QVirtioDevice *vdev = gpio->vdev; + uint64_t features; + int i; + + features = qvirtio_get_features(vdev); + features &= ~QVIRTIO_F_BAD_FEATURE; + qvirtio_set_features(vdev, features); + + gpio->queues = g_new(QVirtQueue *, 2); + for (i = 0; i < 2; i++) { + gpio->queues[i] = qvirtqueue_setup(vdev, alloc, i); + } + qvirtio_set_driver_ok(vdev); +} + +static void *qvirtio_gpio_get_driver(QVhostUserGPIO *v_gpio, + const char *interface) +{ + if (!g_strcmp0(interface, "vhost-user-gpio")) { + return v_gpio; + } + if (!g_strcmp0(interface, "virtio")) { + return v_gpio->vdev; + } + + g_assert_not_reached(); +} + +static void *qvirtio_gpio_device_get_driver(void *object, + const char *interface) +{ + QVhostUserGPIODevice *v_gpio = object; + return qvirtio_gpio_get_driver(&v_gpio->gpio, interface); +} + +/* virtio-gpio (mmio) */ +static void qvirtio_gpio_device_destructor(QOSGraphObject *obj) +{ + QVhostUserGPIODevice *gpio_dev = (QVhostUserGPIODevice *) obj; + virtio_gpio_cleanup(&gpio_dev->gpio); +} + +static void qvirtio_gpio_device_start_hw(QOSGraphObject *obj) +{ + QVhostUserGPIODevice *gpio_dev = (QVhostUserGPIODevice *) obj; + virtio_gpio_setup(&gpio_dev->gpio); +} + +static void *virtio_gpio_device_create(void *virtio_dev, + QGuestAllocator *t_alloc, + void *addr) +{ + QVhostUserGPIODevice *virtio_device = g_new0(QVhostUserGPIODevice, 1); + QVhostUserGPIO *interface = &virtio_device->gpio; + + interface->vdev = virtio_dev; + alloc = t_alloc; + + virtio_device->obj.get_driver = qvirtio_gpio_device_get_driver; + virtio_device->obj.start_hw = qvirtio_gpio_device_start_hw; + virtio_device->obj.destructor = qvirtio_gpio_device_destructor; + + return &virtio_device->obj; +} + +/* virtio-gpio-pci */ +static void qvirtio_gpio_pci_destructor(QOSGraphObject *obj) +{ + QVhostUserGPIOPCI *gpio_pci = (QVhostUserGPIOPCI *) obj; + QOSGraphObject *pci_vobj = &gpio_pci->pci_vdev.obj; + + virtio_gpio_cleanup(&gpio_pci->gpio); + qvirtio_pci_destructor(pci_vobj); +} + +static void qvirtio_gpio_pci_start_hw(QOSGraphObject *obj) +{ + QVhostUserGPIOPCI *gpio_pci = (QVhostUserGPIOPCI *) obj; + QOSGraphObject *pci_vobj = &gpio_pci->pci_vdev.obj; + + qvirtio_pci_start_hw(pci_vobj); + virtio_gpio_setup(&gpio_pci->gpio); +} + +static void *qvirtio_gpio_pci_get_driver(void *object, const char *interface) +{ + QVhostUserGPIOPCI *v_gpio = object; + + if (!g_strcmp0(interface, "pci-device")) { + return v_gpio->pci_vdev.pdev; + } + return qvirtio_gpio_get_driver(&v_gpio->gpio, interface); +} + +static void *virtio_gpio_pci_create(void *pci_bus, QGuestAllocator *t_alloc, + void *addr) +{ + QVhostUserGPIOPCI *virtio_spci = g_new0(QVhostUserGPIOPCI, 1); + QVhostUserGPIO *interface = &virtio_spci->gpio; + QOSGraphObject *obj = &virtio_spci->pci_vdev.obj; + + virtio_pci_init(&virtio_spci->pci_vdev, pci_bus, addr); + interface->vdev = &virtio_spci->pci_vdev.vdev; + alloc = t_alloc; + + obj->get_driver = qvirtio_gpio_pci_get_driver; + obj->start_hw = qvirtio_gpio_pci_start_hw; + obj->destructor = qvirtio_gpio_pci_destructor; + + return obj; +} + +static void virtio_gpio_register_nodes(void) +{ + QPCIAddress addr = { + .devfn = QPCI_DEVFN(4, 0), + }; + + QOSGraphEdgeOptions edge_opts = { }; + + /* vhost-user-gpio-device */ + edge_opts.extra_device_opts = "id=gpio0,chardev=chr-vhost-user-test"; + qos_node_create_driver("vhost-user-gpio-device", + virtio_gpio_device_create); + qos_node_consumes("vhost-user-gpio-device", "virtio-bus", &edge_opts); + qos_node_produces("vhost-user-gpio-device", "vhost-user-gpio"); + + /* virtio-gpio-pci */ + edge_opts.extra_device_opts = "id=gpio0,addr=04.0,chardev=chr-vhost-user-test"; + add_qpci_address(&edge_opts, &addr); + qos_node_create_driver("vhost-user-gpio-pci", virtio_gpio_pci_create); + qos_node_consumes("vhost-user-gpio-pci", "pci-bus", &edge_opts); + qos_node_produces("vhost-user-gpio-pci", "vhost-user-gpio"); +} + +libqos_init(virtio_gpio_register_nodes); diff --git a/tests/qtest/libqos/virtio.c b/tests/qtest/libqos/virtio.c index 09ec09b655..d6fc4f5a29 100644 --- a/tests/qtest/libqos/virtio.c +++ b/tests/qtest/libqos/virtio.c @@ -108,7 +108,7 @@ void qvirtio_set_features(QVirtioDevice *d, uint64_t features) * This could be a separate function for drivers that want to access * configuration space before setting FEATURES_OK, but no existing users * need that and it's less code for callers if this is done implicitly. - */ + */ if (features & (1ull << VIRTIO_F_VERSION_1)) { uint8_t status = d->bus->get_status(d) | VIRTIO_CONFIG_S_FEATURES_OK; diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c index 28b4cf28ec..04950e8458 100644 --- a/tests/qtest/vhost-user-test.c +++ b/tests/qtest/vhost-user-test.c @@ -32,6 +32,7 @@ #include "standard-headers/linux/vhost_types.h" #include "standard-headers/linux/virtio_ids.h" #include "standard-headers/linux/virtio_net.h" +#include "standard-headers/linux/virtio_gpio.h" #ifdef CONFIG_LINUX #include @@ -53,9 +54,12 @@ #define VHOST_MAX_VIRTQUEUES 0x100 #define VHOST_USER_F_PROTOCOL_FEATURES 30 +#define VIRTIO_F_VERSION_1 32 + #define VHOST_USER_PROTOCOL_F_MQ 0 #define VHOST_USER_PROTOCOL_F_LOG_SHMFD 1 #define VHOST_USER_PROTOCOL_F_CROSS_ENDIAN 6 +#define VHOST_USER_PROTOCOL_F_CONFIG 9 #define VHOST_LOG_PAGE 0x1000 @@ -140,6 +144,7 @@ enum { enum { VHOST_USER_NET, + VHOST_USER_GPIO, }; typedef struct TestServer { @@ -198,6 +203,19 @@ static void append_vhost_net_opts(TestServer *s, GString *cmd_line, chr_opts, s->chr_name); } +/* + * For GPIO there are no other magic devices we need to add (like + * block or netdev) so all we need to worry about is the vhost-user + * chardev socket. + */ +static void append_vhost_gpio_opts(TestServer *s, GString *cmd_line, + const char *chr_opts) +{ + g_string_append_printf(cmd_line, QEMU_CMD_CHR, + s->chr_name, s->socket_path, + chr_opts); +} + static void append_mem_opts(TestServer *server, GString *cmd_line, int size, enum test_memfd memfd) { @@ -1085,3 +1103,51 @@ static void register_vhost_user_test(void) test_multiqueue, &opts); } libqos_init(register_vhost_user_test); + +static uint64_t vu_gpio_get_features(TestServer *s) +{ + return 0x1ULL << VIRTIO_F_VERSION_1 | + 0x1ULL << VIRTIO_GPIO_F_IRQ | + 0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES; +} + +/* + * This stub can't handle all the message types but we should reply + * that we support VHOST_USER_PROTOCOL_F_CONFIG as gpio would use it + * talking to a read vhost-user daemon. + */ +static void vu_gpio_get_protocol_features(TestServer *s, CharBackend *chr, + VhostUserMsg *msg) +{ + /* send back features to qemu */ + msg->flags |= VHOST_USER_REPLY_MASK; + msg->size = sizeof(m.payload.u64); + msg->payload.u64 = 1ULL << VHOST_USER_PROTOCOL_F_CONFIG; + + qemu_chr_fe_write_all(chr, (uint8_t *)msg, VHOST_USER_HDR_SIZE + msg->size); +} + +static struct vhost_user_ops g_vu_gpio_ops = { + .type = VHOST_USER_GPIO, + + .append_opts = append_vhost_gpio_opts, + + .get_features = vu_gpio_get_features, + .set_features = vu_net_set_features, + .get_protocol_features = vu_gpio_get_protocol_features, +}; + +static void register_vhost_gpio_test(void) +{ + QOSGraphTestOptions opts = { + .before = vhost_user_test_setup, + .subprocess = true, + .arg = &g_vu_gpio_ops, + }; + + qemu_add_opts(&qemu_chardev_opts); + + qos_add_test("read-guest-mem/memfile", + "vhost-user-gpio", test_read_guest_mem, &opts); +} +libqos_init(register_vhost_gpio_test); diff --git a/tests/qtest/libqos/meson.build b/tests/qtest/libqos/meson.build index fd5d6e5ae1..9dc815ddd4 100644 --- a/tests/qtest/libqos/meson.build +++ b/tests/qtest/libqos/meson.build @@ -45,6 +45,7 @@ libqos_srcs = files( 'virtio-scsi.c', 'virtio-serial.c', 'virtio-iommu.c', + 'virtio-gpio.c', 'generic-pcihost.c', # qgraph machines: