From patchwork Thu Oct 25 14:06:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sameeh Jubran X-Patchwork-Id: 10655877 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D385713B5 for ; Thu, 25 Oct 2018 14:11:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C127E2BBFB for ; Thu, 25 Oct 2018 14:11:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B5A472BBFF; Thu, 25 Oct 2018 14:11:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 541052BBFB for ; Thu, 25 Oct 2018 14:11:08 +0000 (UTC) Received: from localhost ([::1]:54757 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gFgLr-0004B3-EQ for patchwork-qemu-devel@patchwork.kernel.org; Thu, 25 Oct 2018 10:11:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43609) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gFgHe-0007q7-0n for qemu-devel@nongnu.org; Thu, 25 Oct 2018 10:06:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gFgHZ-0007cf-8s for qemu-devel@nongnu.org; Thu, 25 Oct 2018 10:06:45 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:42618) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gFgHZ-0007bz-0G for qemu-devel@nongnu.org; Thu, 25 Oct 2018 10:06:41 -0400 Received: by mail-wr1-x434.google.com with SMTP id y15-v6so5091729wru.9 for ; Thu, 25 Oct 2018 07:06:40 -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; bh=9Jls4lYoNoVmuAv2XzxWT17TvYykZ7SEcF/L9ZJ35a8=; b=1S+0kOAzpq/kFvgSD7h9LBBw/dTrMqRHGr3thgTp+WMxdr1Fe/JzIQNcTCxAtUlU0z arR03qsPI7IcemKnJJK/g6MPPVGpHOPmb+P1INTpk2qRm+JdIUR6n+aG5VmtrCnTwPg6 GkuBTuxxM8QCJ/7AYq0CEqB/iR7M5qzcV6ku9CuojMdW+yMrF3XbmuyQldAIEMlNsOzZ gbTaCp2W3DZSpEYXK+4xRMrtkPY4MbvkiLo1gIkItumA45CJdOoze6kJHYyWs5qraILD jeNn0126oKi9qVkWjoekB65foFM3Cb7X0zP9CjPosex7FR1FSQqSCSk4cB30hqrA7IZ3 SpbQ== 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; bh=9Jls4lYoNoVmuAv2XzxWT17TvYykZ7SEcF/L9ZJ35a8=; b=ZWjaUZtCLJh2sPkfPGS88wl6RWBbW/1B+AlJzELMKjr8jpd07SOiJRRappzwoHfRl7 DJ/zk8NeJRzR+OHUYfSsK/dhGerKL9yu2q4aR7dnqGg3voVXK10U+HKA0Zq2hTEf5nsL 2Rurw8q4pzRnpaB6Fj5HN8O2EK7uWvE1sh7syOsChDDDdgb9dX32SN2u/4tHqmQu9Zuv aVCZqeQ7glOh3H8LnI39FTOw1ovB0Xv7joRhfv/AthuaWmbYw2NEyP191mjzEB4ZIpIL 3FtK26aopkzG5m0vkPcRbHkuElPfk1OGoURgXl5X1070ev18SBER+lb4Ip+h61si3R7L b5zA== X-Gm-Message-State: AGRZ1gL09nqeW844yBPxJJ+Rt4EDgbv7/oGUIgJ5JPRx9HU69Ddjl3fB 2m2HWUBOctIEy1E+AAU4nmA5bF65pxDnnQ== X-Google-Smtp-Source: AJdET5e8l4MRmmDH4PSzbKQ6J3fAo23ghUGpCGX6Rbl5U+Ix5nL6aUPDwyjhLPSqimJ8rjsQEun7QQ== X-Received: by 2002:a5d:6707:: with SMTP id o7-v6mr2134793wru.326.1540476399346; Thu, 25 Oct 2018 07:06:39 -0700 (PDT) Received: from bark.daynix ([141.226.163.173]) by smtp.gmail.com with ESMTPSA id t194-v6sm2061842wmd.48.2018.10.25.07.06.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 Oct 2018 07:06:38 -0700 (PDT) From: Sameeh Jubran To: qemu-devel@nongnu.org, Jason Wang Date: Thu, 25 Oct 2018 17:06:29 +0300 Message-Id: <20181025140631.634922-1-sameeh@daynix.com> X-Mailer: git-send-email 2.17.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::434 Subject: [Qemu-devel] [RFC 0/2] Attempt to implement the standby feature for assigned network devices X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yan Vugenfirer , Eduardo Habkost , "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Sameeh Jubran Hi all, Background: There has been a few attempts to implement the standby feature for vfio assigned devices which aims to enable the migration of such devices. This is another attempt. The series implements an infrastructure for hiding devices from the bus upon boot. What it does is the following: * In the first patch the infrastructure for hiding the device is added for the qbus and qdev APIs. A "hidden" boolean is added to the device state and it is set based on a callback to the standby device which registers itself for handling the assessment: "should the primary device be hidden?" by cross validating the ids of the devices. * In the second patch the virtio-net uses the API to hide the vfio device and unhides it when the feature is acked. Disclaimers: * I have only scratch tested this and from qemu side, it seems to be working. * This is an RFC so it lacks some proper error handling in few cases and proper resource freeing. I wanted to get some feedback first before it is finalized. Command line example: /home/sameeh/Builds/failover/qemu/x86_64-softmmu/qemu-system-x86_64 \ -netdev tap,id=hostnet0,script=world_bridge_standalone.sh,downscript=no,ifname=cc1_71 \ -netdev tap,vhost=on,id=hostnet1,script=world_bridge_standalone.sh,downscript=no,ifname=cc1_72,queues=4 \ -device virtio-net,host_mtu=1500,netdev=hostnet1,id=cc1_72,vectors=10,mq=on,primary=cc1_71 \ -device e1000,netdev=hostnet0,id=cc1_71,standby=cc1_72 \ Migration support: Pre migration or during setup phase of the migration we should send an unplug request to the guest to unplug the primary device. I haven't had the chance to implement that part yet but should do soon. Do you know what's the best approach to do so? I wanted to have a callback to the virtio-net device which tries to send an unplug request to the guest and if succeeds then the migration continues. It needs to handle the case where the migration fails and then it has to replug the primary device back. The following terms are used as interchangeable: standby - virtio-net primary - vfio-device - physical device - assigned device Please share your thoughts and suggestions, Thanks! Sameeh Jubran (2): qdev/qbus: Add hidden device support virtio-net: Implement VIRTIO_NET_F_STANDBY feature hw/core/qdev.c | 48 +++++++++++++++++++++++++--- hw/net/virtio-net.c | 25 +++++++++++++++ hw/pci/pci.c | 1 + include/hw/pci/pci.h | 2 ++ include/hw/qdev-core.h | 11 ++++++- include/hw/virtio/virtio-net.h | 5 +++ qdev-monitor.c | 58 ++++++++++++++++++++++++++++++++-- 7 files changed, 142 insertions(+), 8 deletions(-)