From patchwork Mon Aug 9 17:13:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1515162 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=cEysDShS; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Gk2mG0JH5z9sXN for ; Tue, 10 Aug 2021 03:15:56 +1000 (AEST) Received: from localhost ([::1]:58496 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mD8sT-0006y9-EP for incoming@patchwork.ozlabs.org; Mon, 09 Aug 2021 13:15:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34206) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mD8qi-00057E-Qh for qemu-devel@nongnu.org; Mon, 09 Aug 2021 13:14:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:59368) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mD8qh-0004mH-1z for qemu-devel@nongnu.org; Mon, 09 Aug 2021 13:14:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628529242; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=dAJEUbtuOE6/UYLgmsCKE90Cal3QyPf5B4d47mc3cWE=; b=cEysDShSSYkx1JUSsgBNX7MAsBIWXfOYINQKeb+CMf0Z6sMF/mbuLjDXf4R26lAyYZMt29 mjQ0Uqy5vW/3bZe3HAww0BTcy7y77B3iwZU9cY5t+S6YqHU8niINA2kXeFHr74jx+6QoOt JPMCit2PySlFx9xmP9fo7gJt2zlRD1s= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-515-uxu5PixuNOWGou1Voa3weQ-1; Mon, 09 Aug 2021 13:13:54 -0400 X-MC-Unique: uxu5PixuNOWGou1Voa3weQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4E78D8799E0 for ; Mon, 9 Aug 2021 17:13:53 +0000 (UTC) Received: from thinkpad.redhat.com (unknown [10.39.194.218]) by smtp.corp.redhat.com (Postfix) with ESMTP id 76FA117C0B; Mon, 9 Aug 2021 17:13:43 +0000 (UTC) From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PATCH v2 0/1] virtio: failover: allow to keep the VFIO device rather than the virtio-net one Date: Mon, 9 Aug 2021 19:13:41 +0200 Message-Id: <20210809171342.18146-1-lvivier@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lvivier@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=lvivier@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.702, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Juan Quintela , Jason Wang , Jens Freimann , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" v2: use validate_features() to disable the guest driver rather than setting vring.num to 0. With failover, when the guest virtio-net driver doesn't support the STANDBY feature, the primary device is not plugged and only the virtio-net device is kept. Doing like that we can migrate the machine and keep the network connection. But in some cases, when performance is more important than availability we would prefer to keep the VFIO device rather than the virtio-net one, even if it means to lose the network connection during the migration of the machine. To do that we can't simply unplug the virtio-net device and plug the VFIO one because for the migration the initial state must be kept (virtio-net plugged, VFIO unplugged) but we can try to disable the virtio-net driver and plug the VFIO card, so the initial state is correct (the virtio-net card is plugged, but disabled in guest, and the VFIO card is unplugged before migration). This change doesn't impact the case when guest and host support the STANDBY feature. I've introduced the "failover-default" property to virtio-net device to set which device to keep (failover-default=true keeps the virtio-net device, =off the other one). For example, with a guest driver that doesn't support STANDBY: ... -device virtio-net-pci,id=virtio0,failover=on,failover-default=on \ -device vfio-pci,host=$PCI,id=hostdev0,failover_pair_id=virtio0 \ ... [root@localhost ~]# ip a 1: lo: mtu 65536 qdisc noqueue state UNKNOWN qlen 1 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: mtu 1500 qdisc pfifo_fast state UP q0 link/ether 26:28:c5:7f:14:24 brd ff:ff:ff:ff:ff:ff inet 192.168.20.2/24 brd 192.168.20.255 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::2428:c5ff:fe7f:1424/64 scope link valid_lft forever preferred_lft forever # ethtool -i eth0 driver: virtio_net version: 1.0.0 firmware-version: expansion-rom-version: bus-info: 0000:04:00.0 supports-statistics: no supports-test: no supports-eeprom-access: no supports-register-dump: no supports-priv-flags: no ... -device virtio-net-pci,id=virtio0,failover=on,failover-default=off \ -device vfio-pci,host=$PCI,id=hostdev0,failover_pair_id=virtio0 \ ... [root@localhost ~]# ip a 1: lo: mtu 65536 qdisc noqueue state UNKNOWN qlen 1 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: enp2s0: mtu 1500 qdisc mq state UP qlen 100 link/ether 26:28:c5:7f:14:24 brd ff:ff:ff:ff:ff:ff inet 192.168.20.2/24 brd 192.168.20.255 scope global enp2s0 valid_lft forever preferred_lft forever inet6 fe80::2428:c5ff:fe7f:1424/64 scope link valid_lft forever preferred_lft forever [root@localhost ~]# ethtool -i enp2s0 driver: i40evf version: 1.6.27-k firmware-version: N/A expansion-rom-version: bus-info: 0000:02:00.0 supports-statistics: yes supports-test: no supports-eeprom-access: no supports-register-dump: no supports-priv-flags: no With guest driver that supports STANDBY, we would always have: [root@localhost ~]# ip a 1: lo: mtu 65536 qdisc noqueue state UNKNOWN group defau0 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: enp4s0: mtu 1500 qdisc noqueue state UP gr0 link/ether 26:28:c5:7f:14:24 brd ff:ff:ff:ff:ff:ff inet 192.168.20.2/24 brd 192.168.20.255 scope global noprefixroute enp4s0 valid_lft forever preferred_lft forever inet6 fe80::2428:c5ff:fe7f:1424/64 scope link valid_lft forever preferred_lft forever 3: enp4s0nsby: mtu 1500 qdisc fq_codel master0 link/ether 26:28:c5:7f:14:24 brd ff:ff:ff:ff:ff:ff 4: enp2s0: mtu 1500 qdisc mq master enp4s0 st0 link/ether 26:28:c5:7f:14:24 brd ff:ff:ff:ff:ff:ff [root@localhost ~]# ethtool -i enp4s0 driver: net_failover version: 0.1 firmware-version: expansion-rom-version: bus-info: supports-statistics: no supports-test: no supports-eeprom-access: no supports-register-dump: no supports-priv-flags: no [root@localhost ~]# ethtool -i enp4s0nsby driver: virtio_net version: 1.0.0 firmware-version: expansion-rom-version: bus-info: 0000:04:00.0 supports-statistics: yes supports-test: no supports-eeprom-access: no supports-register-dump: no supports-priv-flags: no [root@localhost ~]# ethtool -i enp2s0 driver: iavf version: 4.18.0-310.el8.x86_64 firmware-version: N/A expansion-rom-version: bus-info: 0000:02:00.0 supports-statistics: yes supports-test: no supports-eeprom-access: no supports-register-dump: no supports-priv-flags: yes Laurent Vivier (1): virtio: failover: define the default device to use in case of error include/hw/virtio/virtio-net.h | 1 + hw/net/virtio-net.c | 49 +++++++++++++++++++++++++++++----- 2 files changed, 44 insertions(+), 6 deletions(-)