From nobody Mon Apr 29 05:15:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1616416171; cv=none; d=zohomail.com; s=zohoarc; b=Ek4SNzRabFmVqurm9RiaGGG4IRXzxGsRzD8a1PH+Ppe7o0C02fyVLuWedPRVYbDCNgT0AYdV480imI9hRQtYd2Q1ylPddF4cZ+sD1bXYteWPqDjhlP6tUPduJfTGdJccPDhCN9VLWAS4/NBWKAs8hSb91V0oR0Mfx8I9pFCbhWc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616416171; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=OJriT6OHsNVPmr/xBcOCwHqhfooctMGjJPAgbRBfHXA=; b=G/GheZ+U9smwslvOyW+M6oaQtlkkilBXLtMpCwDNgh6CqZpR/EqNbqYaIsl07mzgUF2ueIkzvpAc4BY+hZCAH5kOtiPI9n+qh4N1XBkr/mc88CJewCGybOG0Pq+Zp9JkYeO8T+RtvW72vtrJozPBMrwX45eelQJ9Ju+7diCwkcw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616416171884631.7026951798028; Mon, 22 Mar 2021 05:29:31 -0700 (PDT) Received: from localhost ([::1]:43434 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOJgY-00032n-Or for importer@patchew.org; Mon, 22 Mar 2021 08:29:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36902) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOJcF-00085J-OW for qemu-devel@nongnu.org; Mon, 22 Mar 2021 08:25:03 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]:42811) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lOJcE-0005Zb-0Y for qemu-devel@nongnu.org; Mon, 22 Mar 2021 08:25:03 -0400 Received: by mail-wm1-x32b.google.com with SMTP id b2-20020a7bc2420000b029010be1081172so9152430wmj.1 for ; Mon, 22 Mar 2021 05:25:01 -0700 (PDT) Received: from f1.Home (bzq-79-176-30-57.red.bezeqint.net. [79.176.30.57]) by smtp.gmail.com with ESMTPSA id w132sm16785325wmg.39.2021.03.22.05.24.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Mar 2021 05:25:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OJriT6OHsNVPmr/xBcOCwHqhfooctMGjJPAgbRBfHXA=; b=RNNjWRRUobdCzFz5mNVkBfFGHPvgoGIomO/DGYGu4WCRJv1cgTz4v0b2R4gfvPMLIA B6qAGIrZub3+r8cWtcCI/uDr+ckcgOYSOMRVPwP/my2ooiGKKtVNK/bPX+TyljEz262M tJJRZOG3KBjjlckSM0cJLe/w8vwa2Ft/sHxVmF7LRpZ0ehE4GowOCPEV0c2KkfblC4J2 IeROpKuRofAoKoXhPhuWRAS2W9I2laByr6+5Yy6opMlU4yKpkETKutSoV2K23szHx4+Q O4QbNBeRm/DFBDtjnepYZyIakFi260EIKY95nTxKEeKpQz3nKukdmoCCD3zOnLpS0P1W w8Xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OJriT6OHsNVPmr/xBcOCwHqhfooctMGjJPAgbRBfHXA=; b=YIl/BAGypo6lJAQ+PbdtOeHdLZNRozguqBXAY/Zv7atXlVZvlIH2kt8fMTy2YGKsIS fJCMcDE5TpDwpKYLN1z2XGE1dQlqyrKkk+zGbC+Xn7N5GPlQOQJ+cO9qel5t0K/BLnKD 4qbi5C95YPXPhH3UWW3RPhXS4OFG/LZHjbkyHV313YX97FFpoCW6YBUmEnA7P3ts/ydc WOlNjaowXIYzumyAVNFGeEpNc4KJIBYX6+76gPwWRpHJS56FrHfMfPlbrAriteW9armj L4fpWHwPpCnfZd9yLp+AK+Te54oYkOsPvLBWQcYQmudKjzGm77HyLBhCoYKV4OIR+Xpn R9LQ== X-Gm-Message-State: AOAM530nBc9QTEb+V8s5ZMV2p79Ifd5INWoWOuROgDKyd35Cl37cyPNP 3Bt9tECr+SCXa+K7CqhE1PYUHA== X-Google-Smtp-Source: ABdhPJw5PqLan5VyjNVJb1e2H9/NU+NsinTsZq1dqwko7dAEDA+39A0v7QLPoS5uulPRHgprcVjyag== X-Received: by 2002:a1c:5f54:: with SMTP id t81mr15779689wmb.84.1616415900611; Mon, 22 Mar 2021 05:25:00 -0700 (PDT) From: Yuri Benditovich To: mst@redhat.com, jasowang@redhat.com, berrange@redhat.com Subject: [RFC PATCH v2 1/3] net: add ability to hide (disable) vhost_net Date: Mon, 22 Mar 2021 14:24:50 +0200 Message-Id: <20210322122452.369750-2-yuri.benditovich@daynix.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210322122452.369750-1-yuri.benditovich@daynix.com> References: <20210322122452.369750-1-yuri.benditovich@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2a00:1450:4864:20::32b; envelope-from=yuri.benditovich@daynix.com; helo=mail-wm1-x32b.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yan@daynix.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" If 'vhost_net_disabled' in the NetClientState of the net device, get_vhost_net for TAP returns NULL. Network adapters can use this ability to hide the vhost_net temporary between resets in case some active features contradict with vhost. Signed-off-by: Yuri Benditovich --- hw/net/vhost_net.c | 4 +++- include/net/net.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 24d555e764..6660efd9ea 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -436,7 +436,9 @@ VHostNetState *get_vhost_net(NetClientState *nc) =20 switch (nc->info->type) { case NET_CLIENT_DRIVER_TAP: - vhost_net =3D tap_get_vhost_net(nc); + if (!nc->vhost_net_disabled) { + vhost_net =3D tap_get_vhost_net(nc); + } break; #ifdef CONFIG_VHOST_NET_USER case NET_CLIENT_DRIVER_VHOST_USER: diff --git a/include/net/net.h b/include/net/net.h index a02949f6db..a938211524 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -103,6 +103,7 @@ struct NetClientState { int vring_enable; int vnet_hdr_len; bool is_netdev; + bool vhost_net_disabled; QTAILQ_HEAD(, NetFilterState) filters; }; =20 --=20 2.26.2 From nobody Mon Apr 29 05:15:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1616416348; cv=none; d=zohomail.com; s=zohoarc; b=HEnBPtqeTN3SW+rpVeGebiJtggnBbrcXoGcRkVy8x+S7nggpTZu6UwN9psf70aBWgXnClbnT1wfZOaRafPXaEXs73+/yuWLDTS6IJCSKFijdSvdRFUwdU0HEBJMh1beRCcDP8+wQEtYVvOSzZ92EZ0J6eo3PyQLwpFUCRyOx7/E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616416348; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hxON1Qr7rb7hFg/JIyQs/CCbfbSPzw+UVS/lLPV7U0w=; b=hCxHFmJ+MXLtReKpjlxmrazoAO3MXNa7ewlhwZuAb99xFaZ0iiZk1i5gGZC4GIHo/Ihr7PC5eQDQ8H4MXSw1c8gI8a6B5SCB79tteeeCGVIMpN4p+E0jP+xQT4sG/+o/mHU+aRuVOZSh8VqXuaMFqrOeGYKsnNSGk9nCdec9OsQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 161641634847711.057281641357463; Mon, 22 Mar 2021 05:32:28 -0700 (PDT) Received: from localhost ([::1]:49294 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOJjO-0005b6-GM for importer@patchew.org; Mon, 22 Mar 2021 08:32:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36938) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOJcL-00088I-MB for qemu-devel@nongnu.org; Mon, 22 Mar 2021 08:25:10 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:38787) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lOJcF-0005aZ-Jy for qemu-devel@nongnu.org; Mon, 22 Mar 2021 08:25:09 -0400 Received: by mail-wr1-x42c.google.com with SMTP id z2so16487253wrl.5 for ; Mon, 22 Mar 2021 05:25:02 -0700 (PDT) Received: from f1.Home (bzq-79-176-30-57.red.bezeqint.net. [79.176.30.57]) by smtp.gmail.com with ESMTPSA id w132sm16785325wmg.39.2021.03.22.05.25.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Mar 2021 05:25:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hxON1Qr7rb7hFg/JIyQs/CCbfbSPzw+UVS/lLPV7U0w=; b=Dl0NOOKcxsXkZFrdBmrwToBObb3519KfbJFPuF6eqWNqTjFdpKv/XuVFXNtMwtjHkj lHTlWHcZ6YCnlsXhaktnAKHK+/l6LuOcBT5EmRrHvmBs/8EKvL6tqP4Cv4BUjtO/ZBoL uL17NWFifydFezExsDi2a7+ad9zkWurdIgB1GdOQA/EPXxyvz2P9UM950hgcfNIgZo/6 rtRHin/cerlX/VMF7eqc+qSoo4NKOe4cCyQj/kpn59ZFM26Q43B0oosGGWOClGij25Iu yB4n3zvRUZ75+Y3xX33X59BWr/RwOE5ZvdVXkXQ2VherCgvLLCnilXp5eu4ZEFIpMgK7 5Huw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hxON1Qr7rb7hFg/JIyQs/CCbfbSPzw+UVS/lLPV7U0w=; b=IMTu2OJ6xi82h7qRhKdFT5nYuVZpE6Z4QrkUrEpWgsPKyzBhgufl9KpiFxj1Op86sC Ql0CDTlwsHVIzMBxFyVnGgrEZQgSAixFIF3NcListYawpHT4QGf3UsV9EEe7JvAVm72U sLKpoA5jDNT+8IUGuQRx9KFev4RGYYBq3gV6ksn1FrrO2ljCtnOe85hlBnHOl04PYqRE RN9Zfem9N0IWPJXp3ratkHhurTRvu+6yqj2YZrQgWyW82YR8Yrm/YPVbHKl4bxLxMzX4 8fZBiseFHY9yVatAvQLtZhu1/n2OyRPfNVai14+7EXIag38tBi1KtG84wV2GwptiRawl +z5w== X-Gm-Message-State: AOAM530qzZRYfCtP+5a2Ke4OJwFSzlIPnIJu/36S1s3rRL+x5jq5A/wZ AovYMFAVHWibd8S2O/uzkT/hcA== X-Google-Smtp-Source: ABdhPJzHkvV3pfdCx8gtsbuBQ6+MXzbUiuthrdFQ/55YqBqjc+luZwvDkJVL/FMVkmzxPzRtdEeWIw== X-Received: by 2002:adf:c70b:: with SMTP id k11mr18261180wrg.165.1616415902037; Mon, 22 Mar 2021 05:25:02 -0700 (PDT) From: Yuri Benditovich To: mst@redhat.com, jasowang@redhat.com, berrange@redhat.com Subject: [RFC PATCH v2 2/3] virtio: introduce 'missing_features_migrated' device callback Date: Mon, 22 Mar 2021 14:24:51 +0200 Message-Id: <20210322122452.369750-3-yuri.benditovich@daynix.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210322122452.369750-1-yuri.benditovich@daynix.com> References: <20210322122452.369750-1-yuri.benditovich@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2a00:1450:4864:20::42c; envelope-from=yuri.benditovich@daynix.com; helo=mail-wr1-x42c.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yan@daynix.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This optional callback addresses migration problem in case some of negotiated features not present on the destination system. The device has a chance to avoid migration failure. Signed-off-by: Yuri Benditovich --- hw/virtio/virtio.c | 8 ++++++++ include/hw/virtio/virtio.h | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 07f4e60b30..36dcac75e5 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3107,6 +3107,14 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f, int= version_id) vdev->device_endian =3D virtio_default_endian(); } =20 + if (vdc->missing_features_migrated) { + uint64_t missing =3D (vdev->guest_features & ~(vdev->host_features= )); + if (missing && vdc->missing_features_migrated(vdev, missing)) { + vdev->host_features =3D + vdc->get_features(vdev, vdev->host_features, NULL); + } + } + if (virtio_64bit_features_needed(vdev)) { /* * Subsection load filled vdev->guest_features. Run them diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index b7ece7a6a8..fbfbec6ef2 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -158,6 +158,14 @@ struct VirtioDeviceClass { * processed, e.g. for bounds checking. */ int (*post_load)(VirtIODevice *vdev); + /* In case when some of negotiated features are missing on the destina= tion + system, the migration is expected to fail. To avoid such failure, t= he + device may implement this callback and apply graceful configuration + change to extend host features (for example, disable vhost). + If the device returns true the virtio reinitializes the host featur= es + and further set_features call may succeed. + */ + bool (*missing_features_migrated)(VirtIODevice *vdev, uint64_t val); const VMStateDescription *vmsd; bool (*primary_unplug_pending)(void *opaque); }; --=20 2.26.2 From nobody Mon Apr 29 05:15:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1616416443; cv=none; d=zohomail.com; s=zohoarc; b=J3obnhWgKU58+/GAbjHLOOKJrna7e6drxQ6yJ2z0nensKOCrKIxcaxIqB+4cPBy9Qv2TU32XBTw7y1VgGuY9xDTzdjLXpCKtjtlnRc5VU3IY5e9PMIRHUBOlJJJQMuFpiYd6qjTxsIm4jcqluwgbovfiMVevVb+n9VU/Hw2GKr8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616416443; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fLcpOzPll1cJxC9iX7UzZaPl9AO2DsZ8ElInXHDxMfQ=; b=CvQgKJtR/mBrmIdWWP8VI1Dg2ij8cbBWku5ng1ntuyWn0WbrMZycQw1JpuQZbR05UP2ExI9890g3WNCBtEJ6w1Kbafb1RrLrgRZpVmAsIihTvKZ1+sRurgZywrK9UKTX/YckefvCNtnYNLtXyN2qKT36UHZEAV10UPLkDc1SvfU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616416443843560.9086436417018; Mon, 22 Mar 2021 05:34:03 -0700 (PDT) Received: from localhost ([::1]:52954 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOJkw-000749-Op for importer@patchew.org; Mon, 22 Mar 2021 08:34:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36960) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOJcN-00088n-Q1 for qemu-devel@nongnu.org; Mon, 22 Mar 2021 08:25:16 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]:39508) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lOJcH-0005bY-AB for qemu-devel@nongnu.org; Mon, 22 Mar 2021 08:25:11 -0400 Received: by mail-wm1-x335.google.com with SMTP id d8-20020a1c1d080000b029010f15546281so8980877wmd.4 for ; Mon, 22 Mar 2021 05:25:04 -0700 (PDT) Received: from f1.Home (bzq-79-176-30-57.red.bezeqint.net. [79.176.30.57]) by smtp.gmail.com with ESMTPSA id w132sm16785325wmg.39.2021.03.22.05.25.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Mar 2021 05:25:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fLcpOzPll1cJxC9iX7UzZaPl9AO2DsZ8ElInXHDxMfQ=; b=H7GT01aT++UN079YkvDUL6zrzORUuJ/doxaaQTSG3gXGO2aGrEnejp7wm8/q+Qm8OT 7R+uzhEPByLzg1W/b/UnvOYq22N2sVQODLd/RPxTr7QNce89xX8AHRhKyRwCobWquolK 5/ACP+ZuYR7iZJ88IkmzqKx7VGeZwCE5nwFLWVzFLuxCOQgKYWbflgxnMckKb+4F0P3O AlzUgtubeV9Z9ZITHOsrNEONqiBKmlghryLgAegLa75HxJaGhlCfYXqWnnhKTyKdwumq ItumckKubKzKcM1GJsnuJnGHUh/UWpb7tCJRbsNP8Ica2SkcwnCpu2BJhJFKHBiUC2Tb /qbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fLcpOzPll1cJxC9iX7UzZaPl9AO2DsZ8ElInXHDxMfQ=; b=UtsWqplPyJjMZMWBqHrTRkm+J9vK5iaUfUrYJyfDaQ6qak/oj0gfOoF7JBvoETywDz UciZDliC5+egWqIxIkcb1GqTjqTlZodpvrlF+ztkHqdI7KZVH2qHHurS9gKNM44hjkhw Bo0Unr/tK9uOYXXKBARdWgWf9WeOF9lmwa98MPr2NDS3XH5YQ7HS3Qk4rxMMtG1VNBdy uqij8QxKCRoQ3ZaryRxrYINGdi+J5MtAlS8JGyB+arqTvdmaweDP1eHPM7pSKzIQYpdN 7DXvc/pdkC6XzZTuQcE7+76nQj2vT6h6yJtaxk8gPbLRZx2t+8UsvorjCpeK6EgV49Sb 6Qhw== X-Gm-Message-State: AOAM530JoSTduDOYP5WQfYN0sYIRmQP2x96dhpaCAkqobD8fGg+ipuLw 3cpM0q7Xy/1mg2NjHlwx08H+uz7rf+QRtw== X-Google-Smtp-Source: ABdhPJxkdgglDKmf9rJLHgDXR+A5ndGrUeHqmVuTyR6SPGzXwH/Bfbpp0EWtIb0xZz6CINqxFnjnJg== X-Received: by 2002:a1c:e388:: with SMTP id a130mr16166166wmh.187.1616415903558; Mon, 22 Mar 2021 05:25:03 -0700 (PDT) From: Yuri Benditovich To: mst@redhat.com, jasowang@redhat.com, berrange@redhat.com Subject: [RFC PATCH v2 3/3] virtio-net: implement missing_features_migrated callback Date: Mon, 22 Mar 2021 14:24:52 +0200 Message-Id: <20210322122452.369750-4-yuri.benditovich@daynix.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210322122452.369750-1-yuri.benditovich@daynix.com> References: <20210322122452.369750-1-yuri.benditovich@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2a00:1450:4864:20::335; envelope-from=yuri.benditovich@daynix.com; helo=mail-wm1-x335.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yan@daynix.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Graceful drop to userspace virtio in case selected features are missing on the destination system. Currently used for 3 features that might be supported by the vhost kernel on the source machine and not supported on the destination machine: rss, hash reporting, packed ring. Signed-off-by: Yuri Benditovich --- hw/net/virtio-net.c | 51 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 96a3cc8357..97afca34e7 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -527,6 +527,15 @@ static RxFilterInfo *virtio_net_query_rxfilter(NetClie= ntState *nc) return info; } =20 +static void virtio_net_allow_vhost(VirtIONet *n, bool allow) +{ + int i; + for (i =3D 0; i < n->max_queues; i++) { + NetClientState *nc =3D qemu_get_subqueue(n->nic, i)->peer; + nc->vhost_net_disabled =3D !allow; + } +} + static void virtio_net_reset(VirtIODevice *vdev) { VirtIONet *n =3D VIRTIO_NET(vdev); @@ -564,6 +573,7 @@ static void virtio_net_reset(VirtIODevice *vdev) assert(!virtio_net_get_subqueue(nc)->async_tx.elem); } } + virtio_net_allow_vhost(n, true); } =20 static void peer_test_vnet_hdr(VirtIONet *n) @@ -701,6 +711,27 @@ static void virtio_net_set_queues(VirtIONet *n) } } =20 +static bool can_disable_vhost(VirtIONet *n) +{ + NetClientState *peer =3D qemu_get_queue(n->nic)->peer; + NetdevInfo *ndi; + if (!get_vhost_net(peer)) { + return false; + } + if (!peer) { + return true; + } + if (peer->info->type !=3D NET_CLIENT_DRIVER_TAP) { + return false; + } + ndi =3D peer->stored_config; + if (ndi && ndi->u.tap.has_vhostforce && ndi->u.tap.vhostforce) { + printf("vhost forced, can't drop it\n"); + return false; + } + return true; +} + static void virtio_net_set_multiqueue(VirtIONet *n, int multiqueue); =20 static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t featu= res, @@ -3433,6 +3464,25 @@ static bool dev_unplug_pending(void *opaque) return vdc->primary_unplug_pending(dev); } =20 +static bool virtio_net_missing_features_migrated(VirtIODevice *vdev, + uint64_t missing) +{ + VirtIONet *n =3D VIRTIO_NET(vdev); + bool disable_vhost =3D false; + if (virtio_has_feature(missing, VIRTIO_NET_F_HASH_REPORT) || + virtio_has_feature(missing, VIRTIO_NET_F_RSS) || + virtio_has_feature(missing, VIRTIO_F_RING_PACKED)) { + disable_vhost =3D true; + } + disable_vhost =3D disable_vhost && can_disable_vhost(n); + if (disable_vhost) { + warn_report("falling back to userspace virtio due to missing" + " features %lx", missing); + virtio_net_allow_vhost(n, false); + } + return disable_vhost; +} + static const VMStateDescription vmstate_virtio_net =3D { .name =3D "virtio-net", .minimum_version_id =3D VIRTIO_NET_VM_VERSION, @@ -3527,6 +3577,7 @@ static void virtio_net_class_init(ObjectClass *klass,= void *data) vdc->get_features =3D virtio_net_get_features; vdc->set_features =3D virtio_net_set_features; vdc->bad_features =3D virtio_net_bad_features; + vdc->missing_features_migrated =3D virtio_net_missing_features_migrate= d; vdc->reset =3D virtio_net_reset; vdc->set_status =3D virtio_net_set_status; vdc->guest_notifier_mask =3D virtio_net_guest_notifier_mask; --=20 2.26.2