From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE7F5C2D0E4 for ; Fri, 20 Nov 2020 18:57:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5CFF620760 for ; Fri, 20 Nov 2020 18:57:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="iHL5Nl0i" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730091AbgKTS5s (ORCPT ); Fri, 20 Nov 2020 13:57:48 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:46012 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730060AbgKTS5r (ORCPT ); Fri, 20 Nov 2020 13:57:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605898666; 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: in-reply-to:in-reply-to:references:references; bh=O+qiriFl30O5ZK13M3dH3aBYCSEg2kw5TfbYjHT/iYc=; b=iHL5Nl0iest7VSS05rFaJu8IoKGhwhaLrccFmkCio4hcqgs6nBAJhCqfeJR1i+hu1XNE2X CLxvi7hN+aM10S/eCC1VeROcXEVsoEipAHEma8nwYzatB7em00PRJTNiYB4Atti/4LvCDK 96wrwNKkpa4WOkmUgyF4ljGeqNGD1lU= 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-320--iW6dT1CPiib-6aLo2w7YA-1; Fri, 20 Nov 2020 13:57:42 -0500 X-MC-Unique: -iW6dT1CPiib-6aLo2w7YA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DA5C21084422; Fri, 20 Nov 2020 18:57:38 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-88.ams2.redhat.com [10.36.112.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id CDD7B5C1D5; Fri, 20 Nov 2020 18:57:23 +0000 (UTC) From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Lars Ganrot , virtualization@lists.linux-foundation.org, Salil Mehta , "Michael S. Tsirkin" , Liran Alon , Rob Miller , Max Gurtovoy , Alex Barba , Stefan Hajnoczi , Jim Harford , Jason Wang , Harpreet Singh Anand , Christophe Fontaine , vm , Daniel Daly , Michael Lilja , Stefano Garzarella , Nitin Shrivastav , Lee Ballard , Dmytro Kazantsev , Juan Quintela , kvm@vger.kernel.org, Howard Cai , Xiao W Wang , Sean Mooney , Parav Pandit , Eli Cohen , Siwei Liu , Stephen Finucane Subject: [RFC PATCH 26/27] vhost: Add vhost_hdev_can_sw_lm Date: Fri, 20 Nov 2020 19:51:04 +0100 Message-Id: <20201120185105.279030-27-eperezma@redhat.com> In-Reply-To: <20201120185105.279030-1-eperezma@redhat.com> References: <20201120185105.279030-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This allows a device to migrate if it meet a few requirements. Signed-off-by: Eugenio PĂ©rez --- hw/virtio/vhost.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index cf000b979f..44a51ccf5e 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1529,6 +1529,37 @@ static void vhost_virtqueue_cleanup(struct vhost_virtqueue *vq) event_notifier_cleanup(&vq->masked_notifier); } +static bool vhost_hdev_can_sw_lm(struct vhost_dev *hdev) +{ + const char *cause = NULL; + + if (hdev->features & (VIRTIO_F_IOMMU_PLATFORM)) { + cause = "have iommu"; + } else if (hdev->features & VIRTIO_F_RING_PACKED) { + cause = "is packed"; + } else if (hdev->features & VIRTIO_RING_F_EVENT_IDX) { + cause = "Have event idx"; + } else if (hdev->features & VIRTIO_RING_F_INDIRECT_DESC) { + cause = "Supports indirect descriptors"; + } else if (hdev->nvqs != 2) { + cause = "!= 2 #vq supported"; + } else if (!hdev->vhost_ops->vhost_net_set_backend) { + cause = "cannot pause device"; + } + + if (cause) { + if (!hdev->migration_blocker) { + error_setg(&hdev->migration_blocker, + "Migration disabled: vhost lacks VHOST_F_LOG_ALL feature and %s.", + cause); + } + + return false; + } + + return true; +} + int vhost_dev_init(struct vhost_dev *hdev, void *opaque, VhostBackendType backend_type, uint32_t busyloop_timeout) { @@ -1604,7 +1635,8 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque, }; if (hdev->migration_blocker == NULL) { - if (!vhost_dev_can_log(hdev)) { + if (!vhost_dev_can_log(hdev) && !vhost_hdev_can_sw_lm(hdev) + && hdev->migration_blocker == NULL) { error_setg(&hdev->migration_blocker, "Migration disabled: vhost lacks VHOST_F_LOG_ALL feature."); } else if (vhost_dev_log_is_shared(hdev) && !qemu_memfd_alloc_check()) { -- 2.18.4