From nobody Thu Apr 18 10:01:31 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.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=1570711416; cv=none; d=zoho.com; s=zohoarc; b=TO7rBhBUxhlqQrpgJGce06j9zfSGEyCTYhrBUy70POcrKKwrCMNQ0buuEdZ1k7s1hCila9JjoyoFgkrSKiOmm6/pTfC3uPu1VMSZ9ZkccOqd8I/NBSFhn0FTmnMY4SrmN1efjyk463rmArWZF0hXexPkT1H0b0RhzF8cKMmBiY4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570711416; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=O05afTw00yJcZG1EFAC8CfJufdnfwcI7yyhOpKWurQA=; b=ICIaLjG5EVD4zoyMnrOiJglx96LEJbxlHJ7xoF26k17aYj60Jf/R7mqQi87ZPJhFRu/WZJNdkIl7zso11L/T3PxFk5JmddIDXKxhiucIebHqwWt4+/0djuTLSStVTqaSo+vco3SCzPQ5TquVX27Bg3NYf0MKKwqJQLqRJyfSK+Q= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.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 1570711416444100.08183728930373; Thu, 10 Oct 2019 05:43:36 -0700 (PDT) Received: from localhost ([::1]:37512 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iIXn4-0002OI-SZ for importer@patchew.org; Thu, 10 Oct 2019 08:43:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55388) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iIXIg-0005gU-UB for qemu-devel@nongnu.org; Thu, 10 Oct 2019 08:12:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iIXIf-00024D-LF for qemu-devel@nongnu.org; Thu, 10 Oct 2019 08:12:10 -0400 Received: from mail-ed1-x544.google.com ([2a00:1450:4864:20::544]:37745) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iIXIf-00023j-6o for qemu-devel@nongnu.org; Thu, 10 Oct 2019 08:12:09 -0400 Received: by mail-ed1-x544.google.com with SMTP id r4so5246975edy.4 for ; Thu, 10 Oct 2019 05:12:08 -0700 (PDT) Received: from msennikovskii2.pb.local ([2001:1438:4010:2558:31c1:ae55:82cf:3681]) by smtp.googlemail.com with ESMTPSA id c22sm949157edc.9.2019.10.10.05.12.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 10 Oct 2019 05:12:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=O05afTw00yJcZG1EFAC8CfJufdnfwcI7yyhOpKWurQA=; b=f2Y3EBWtW39HjwSfQ/iRVm976oQ6/A+jwY6KSpbBmLkStIy6559VgbSvd+ZxtCIC+e kYcpSJ5zQU6PhDCDOHOSain23mqP3zw70LYZ5fmYIM59R0gAFkQspUQDQmG+wvSXQ5Lp /+KD0TO6j6dSRHSxTe9uCGXc06fHFfHoklHGKZWAldHIgVl8jI8nvzrM5Sxelcw84gri ePID/2Hl/0AxIkNilJyH8RTi9NX9Tzrw7hpLNvdp/gs3fqRMsZVVufe9hm6wePN7+JRJ wE4ET34pdwPnNfX8B6qlALn9taxr5U1QOyMomd6wo6NFedZufQ4M2CvJA31ZdlSFS206 6RsQ== 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; bh=O05afTw00yJcZG1EFAC8CfJufdnfwcI7yyhOpKWurQA=; b=D4Z/+9QnvfHaXMOVLM5EKaIT5qu38mD5K23VNcQpmrE1Y301NPsmG4nLgOBAp2w239 YV/au9uHUz98FNf/7pp1GK8Z/0JJdiVVrUiOJy41p4Da0rwr+WjdlebJfq4goYojFwmc z7+b7ibMb7vcPVJZLhTfp0MOEyQntCQCG/bGcXXJaRNM7976aa8MpF8hsCVwb6tUls9D RCPAA3a7Am/0sf1gkp0NvPZpwElI/NdK/TEikr/VkVm1OFyjGQpcgBZhKxwvKhYZzso6 i/ZCKLpuqB0Ij2fybMN/Vquh1rIq9vk6BG93h1jFSpCU67n/xg7mEJiPbdZZv0C523B4 3JKg== X-Gm-Message-State: APjAAAUUsbZiXkHt3wl3JeusJH1gqLr3V6/Stdkgv4djyQHDx+s5r8nb 8+FMNQHhBU8EE+BlTmmDm9VHPBL/nE4= X-Google-Smtp-Source: APXvYqwQa6RxW1XPv+X3yDdM8QYFtxTI9MY7LgAje4I6iuThRWfn4ULgs6cwWUz/5RGzRvUmZq5yIQ== X-Received: by 2002:a50:afa1:: with SMTP id h30mr7733758edd.126.1570709527019; Thu, 10 Oct 2019 05:12:07 -0700 (PDT) From: Mikhail Sennikovsky To: qemu-devel@nongnu.org, jasowang@redhat.com, stefanha@redhat.com, mst@redhat.com, "Dr. David Alan Gilbert" Subject: [PATCH v3] virtio-net: prevent offloads reset on migration Date: Thu, 10 Oct 2019 14:11:15 +0200 Message-Id: <1570709475-32073-2-git-send-email-mikhail.sennikovskii@cloud.ionos.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1570709475-32073-1-git-send-email-mikhail.sennikovskii@cloud.ionos.com> References: <1570709475-32073-1-git-send-email-mikhail.sennikovskii@cloud.ionos.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::544 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: Mikhail Sennikovsky Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @cloud.ionos.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Currently offloads disabled by guest via the VIRTIO_NET_CTRL_GUEST_OFFLOADS= _SET command are not preserved on VM migration. Instead all offloads reported by guest features (via VIRTIO_PCI_GUEST_FEATU= RES) get enabled. What happens is: first the VirtIONet::curr_guest_offloads gets restored and offloads are getting set correctly: #0 qemu_set_offload (nc=3D0x555556a11400, csum=3D1, tso4=3D0, tso6=3D0, e= cn=3D0, ufo=3D0) at net/net.c:474 #1 virtio_net_apply_guest_offloads (n=3D0x555557701ca0) at hw/net/virtio-= net.c:720 #2 virtio_net_post_load_device (opaque=3D0x555557701ca0, version_id=3D11)= at hw/net/virtio-net.c:2334 #3 vmstate_load_state (f=3D0x5555569dc010, vmsd=3D0x555556577c80 , opaque=3D0x555557701ca0, version_id=3D11) at migration/vmstate.c:168 #4 virtio_load (vdev=3D0x555557701ca0, f=3D0x5555569dc010, version_id=3D1= 1) at hw/virtio/virtio.c:2197 #5 virtio_device_get (f=3D0x5555569dc010, opaque=3D0x555557701ca0, size= =3D0, field=3D0x55555668cd00 <__compound_literal.5>) at hw/virtio/virtio.c:= 2036 #6 vmstate_load_state (f=3D0x5555569dc010, vmsd=3D0x555556577ce0 , opaque=3D0x555557701ca0, version_id=3D11) at migration/vmstat= e.c:143 #7 vmstate_load (f=3D0x5555569dc010, se=3D0x5555578189e0) at migration/sa= vevm.c:829 #8 qemu_loadvm_section_start_full (f=3D0x5555569dc010, mis=3D0x5555569eee= 20) at migration/savevm.c:2211 #9 qemu_loadvm_state_main (f=3D0x5555569dc010, mis=3D0x5555569eee20) at m= igration/savevm.c:2395 #10 qemu_loadvm_state (f=3D0x5555569dc010) at migration/savevm.c:2467 #11 process_incoming_migration_co (opaque=3D0x0) at migration/migration.c:= 449 However later on the features are getting restored, and offloads get reset = to everything supported by features: #0 qemu_set_offload (nc=3D0x555556a11400, csum=3D1, tso4=3D1, tso6=3D1, e= cn=3D0, ufo=3D0) at net/net.c:474 #1 virtio_net_apply_guest_offloads (n=3D0x555557701ca0) at hw/net/virtio-= net.c:720 #2 virtio_net_set_features (vdev=3D0x555557701ca0, features=3D5104441767)= at hw/net/virtio-net.c:773 #3 virtio_set_features_nocheck (vdev=3D0x555557701ca0, val=3D5104441767) = at hw/virtio/virtio.c:2052 #4 virtio_load (vdev=3D0x555557701ca0, f=3D0x5555569dc010, version_id=3D1= 1) at hw/virtio/virtio.c:2220 #5 virtio_device_get (f=3D0x5555569dc010, opaque=3D0x555557701ca0, size= =3D0, field=3D0x55555668cd00 <__compound_literal.5>) at hw/virtio/virtio.c:= 2036 #6 vmstate_load_state (f=3D0x5555569dc010, vmsd=3D0x555556577ce0 , opaque=3D0x555557701ca0, version_id=3D11) at migration/vmstat= e.c:143 #7 vmstate_load (f=3D0x5555569dc010, se=3D0x5555578189e0) at migration/sa= vevm.c:829 #8 qemu_loadvm_section_start_full (f=3D0x5555569dc010, mis=3D0x5555569eee= 20) at migration/savevm.c:2211 #9 qemu_loadvm_state_main (f=3D0x5555569dc010, mis=3D0x5555569eee20) at m= igration/savevm.c:2395 #10 qemu_loadvm_state (f=3D0x5555569dc010) at migration/savevm.c:2467 #11 process_incoming_migration_co (opaque=3D0x0) at migration/migration.c:= 449 Fix this by making the virtio_net_set_features not reset the curr_guest_offloads in case the VM runstate is RUN_STATE_INMIGRATE Signed-off-by: Mikhail Sennikovsky --- hw/net/virtio-net.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index b9e1cd7..49be172 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -767,7 +767,14 @@ static void virtio_net_set_features(VirtIODevice *vdev= , uint64_t features) n->rsc6_enabled =3D virtio_has_feature(features, VIRTIO_NET_F_RSC_EXT)= && virtio_has_feature(features, VIRTIO_NET_F_GUEST_TSO6); =20 - if (n->has_vnet_hdr) { + /* + * In case of RUN_STATE_INMIGRATE the virtio_net_set_features + * is called as part of VM state restore process. + * At this stage we do not want the curr_guest_offloads to be reset, + * i.e. want to preserve them in the same state as was set + * by the guest on the source machine. + */ + if (n->has_vnet_hdr && !runstate_check(RUN_STATE_INMIGRATE)) { n->curr_guest_offloads =3D virtio_net_guest_offloads_by_features(features); virtio_net_apply_guest_offloads(n); --=20 2.7.4