From nobody Mon Apr 29 02:12:32 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=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571819607; cv=none; d=zoho.com; s=zohoarc; b=H0RtT9/8umOHl/O/PMw0KwwjcNElVv6eELTYoquICb3Nr/VCfJQezRaIixTWABSQ9MOpN9fXcnm96AYUt4FpF5rEpKvTRMOY2rrdB74/bDtZC+Wn8zG20xtF/ceerVxm47RkZ/B3YVyytS3BoJ7it8SCb2UDSKP063ojThj1iMc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571819607; h=Content-Type: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=N1mXYBWjlIW+rCQl00usBp8V13DJOB43c4Zk4huMvtw=; b=UuRRY/GiDq60NHB2mhU+qmawoiiH2nJNfpX4AFB4U6/LB/PZr20KuSM4zb1hMVmmXkd/5uaBhSnDsjc11YYYvF+KNJIEehJlGrqR6pphe2dS0/PFyLvRuZqcK5TtmTiYDCgFQzvqTSMfVYzzh6eJFmAqSNQQi4O+kY2UtEPvzmQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571819607254854.2963639052412; Wed, 23 Oct 2019 01:33:27 -0700 (PDT) Received: from localhost ([::1]:57250 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNC4x-0004wp-NP for importer@patchew.org; Wed, 23 Oct 2019 04:33:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48284) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNBze-0002v9-90 for qemu-devel@nongnu.org; Wed, 23 Oct 2019 04:27:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNBzb-0005te-LG for qemu-devel@nongnu.org; Wed, 23 Oct 2019 04:27:46 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:37896 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iNBzS-0005mp-Ge for qemu-devel@nongnu.org; Wed, 23 Oct 2019 04:27:35 -0400 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-155-ofTJ5aN6Ormn2l3eygDQRw-1; Wed, 23 Oct 2019 04:27:30 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 922221800E01; Wed, 23 Oct 2019 08:27:29 +0000 (UTC) Received: from localhost (dhcp-192-217.str.redhat.com [10.33.192.217]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B9E2B60628; Wed, 23 Oct 2019 08:27:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571819253; 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=N1mXYBWjlIW+rCQl00usBp8V13DJOB43c4Zk4huMvtw=; b=QCVnNoUw6dzHUOPdtjk1i16wr6sYGmxH0YPogxLfxGBRNI/RSW1XfiKZLOKBFCC4qOzVVk 2t9AuRN6tLtPc9+rJ+AuS90gX6lrXpo0wRAJBIIok+i9EQGVPgnwgvc/ACqH4PxsvginS2 bDq/ep9ad+v8e5ibFpUg8D6NMhGh8VA= From: Jens Freimann To: qemu-devel@nongnu.org Subject: [PATCH v5 01/11] qdev/qbus: add hidden device support Date: Wed, 23 Oct 2019 10:27:01 +0200 Message-Id: <20191023082711.16694-2-jfreimann@redhat.com> In-Reply-To: <20191023082711.16694-1-jfreimann@redhat.com> References: <20191023082711.16694-1-jfreimann@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: ofTJ5aN6Ormn2l3eygDQRw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 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: pkrempa@redhat.com, berrange@redhat.com, ehabkost@redhat.com, mst@redhat.com, aadam@redhat.com, dgilbert@redhat.com, alex.williamson@redhat.com, laine@redhat.com, ailan@redhat.com, parav@mellanox.com 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 adds support for hiding a device to the qbus and qdev APIs. The first user of this will be the virtio-net failover feature but the API introduced with this patch could be used to implement other features as well, for example hiding pci devices when a pci bus is powered off. qdev_device_add() is modified to check for a net_failover_pair_id argument in the option string. A DeviceListener callback should_be_hidden() is added. It can be used by a standby device to inform qdev that this device should not be added now. The standby device handler can store the device options to plug the device in at a later point in time. One reason for hiding the device is that we don't want to expose both devices to the guest kernel until the respective virtio feature bit VIRTIO_NET_F_STANDBY was negotiated and we know that the devices will be handled correctly by the guest. More information on the kernel feature this is using: https://www.kernel.org/doc/html/latest/networking/net_failover.html An example where the primary device is a vfio-pci device and the standby device is a virtio-net device: A device is hidden when it has an "net_failover_pair_id" option, e.g. -device virtio-net-pci,...,failover=3Don,... -device vfio-pci,...,net_failover_pair_id=3Dnet1,... Signed-off-by: Jens Freimann Reviewed-by: Cornelia Huck --- hw/core/qdev.c | 23 +++++++++++++++++++++++ include/hw/qdev-core.h | 29 +++++++++++++++++++++++++++++ qdev-monitor.c | 41 +++++++++++++++++++++++++++++++++++++---- vl.c | 6 ++++-- 4 files changed, 93 insertions(+), 6 deletions(-) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index cbad6c1d55..f786650446 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -212,6 +212,29 @@ void device_listener_unregister(DeviceListener *listen= er) QTAILQ_REMOVE(&device_listeners, listener, link); } =20 +bool qdev_should_hide_device(QemuOpts *opts) +{ + int rc =3D -1; + DeviceListener *listener; + + QTAILQ_FOREACH(listener, &device_listeners, link) { + if (listener->should_be_hidden) { + /* should_be_hidden_will return + * 1 if device matches opts and it should be hidden + * 0 if device matches opts and should not be hidden + * -1 if device doesn't match opts + */ + rc =3D listener->should_be_hidden(listener, opts); + } + + if (rc > 0) { + break; + } + } + + return rc > 0; +} + void qdev_set_legacy_instance_id(DeviceState *dev, int alias_id, int required_for_version) { diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index aa123f88cb..710981af36 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -78,6 +78,19 @@ typedef void (*BusUnrealize)(BusState *bus, Error **errp= ); * respective parent types. * * + * + * # Hiding a device # + * To hide a device, a DeviceListener function should_be_hidden() needs to + * be registered. + * It can be used to defer adding a device and therefore hide it from the + * guest. The handler registering to this DeviceListener can save the QOpts + * passed to it for re-using it later and must return that it wants the de= vice + * to be/remain hidden or not. When the handler function decides the device + * shall not be hidden it will be added in qdev_device_add() and + * realized as any other device. Otherwise qdev_device_add() will return e= arly + * without adding the device. The guest will not see a "hidden" device + * until it was marked don't hide and qdev_device_add called again. + * */ typedef struct DeviceClass { /*< private >*/ @@ -154,6 +167,12 @@ struct DeviceState { struct DeviceListener { void (*realize)(DeviceListener *listener, DeviceState *dev); void (*unrealize)(DeviceListener *listener, DeviceState *dev); + /* + * This callback is called upon init of the DeviceState and allows to + * inform qdev that a device should be hidden, depending on the device + * opts, for example, to hide a standby device. + */ + int (*should_be_hidden)(DeviceListener *listener, QemuOpts *device_opt= s); QTAILQ_ENTRY(DeviceListener) link; }; =20 @@ -451,4 +470,14 @@ static inline bool qbus_is_hotpluggable(BusState *bus) void device_listener_register(DeviceListener *listener); void device_listener_unregister(DeviceListener *listener); =20 +/** + * @qdev_should_hide_device: + * @opts: QemuOpts as passed on cmdline. + * + * Check if a device should be added. + * When a device is added via qdev_device_add() this will be called, + * and return if the device should be added now or not. + */ +bool qdev_should_hide_device(QemuOpts *opts); + #endif diff --git a/qdev-monitor.c b/qdev-monitor.c index 148df9cacf..676a759fb4 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -32,9 +32,11 @@ #include "qemu/help_option.h" #include "qemu/option.h" #include "qemu/qemu-print.h" +#include "qemu/option_int.h" #include "sysemu/block-backend.h" #include "sysemu/sysemu.h" #include "migration/misc.h" +#include "migration/migration.h" =20 /* * Aliases were a bad idea from the start. Let's keep them @@ -562,13 +564,36 @@ void qdev_set_id(DeviceState *dev, const char *id) } } =20 +static int is_failover_device(void *opaque, const char *name, const char *= value, + Error **errp) +{ + if (strcmp(name, "net_failover_pair_id") =3D=3D 0) { + QemuOpts *opts =3D (QemuOpts *)opaque; + + if (qdev_should_hide_device(opts)) { + return 1; + } + } + + return 0; +} + +static bool should_hide_device(QemuOpts *opts) +{ + if (qemu_opt_foreach(opts, is_failover_device, opts, NULL) =3D=3D 0) { + return false; + } + return true; +} + DeviceState *qdev_device_add(QemuOpts *opts, Error **errp) { DeviceClass *dc; const char *driver, *path; - DeviceState *dev; + DeviceState *dev =3D NULL; BusState *bus =3D NULL; Error *err =3D NULL; + bool hide; =20 driver =3D qemu_opt_get(opts, "driver"); if (!driver) { @@ -602,11 +627,17 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **= errp) return NULL; } } - if (qdev_hotplug && bus && !qbus_is_hotpluggable(bus)) { + hide =3D should_hide_device(opts); + + if ((hide || qdev_hotplug) && bus && !qbus_is_hotpluggable(bus)) { error_setg(errp, QERR_BUS_NO_HOTPLUG, bus->name); return NULL; } =20 + if (hide) { + return NULL; + } + if (!migration_is_idle()) { error_setg(errp, "device_add not allowed while migrating"); return NULL; @@ -648,8 +679,10 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **e= rrp) =20 err_del_dev: error_propagate(errp, err); - object_unparent(OBJECT(dev)); - object_unref(OBJECT(dev)); + if (dev) { + object_unparent(OBJECT(dev)); + object_unref(OBJECT(dev)); + } return NULL; } =20 diff --git a/vl.c b/vl.c index 4489cfb2bb..62c388cb49 100644 --- a/vl.c +++ b/vl.c @@ -2204,10 +2204,12 @@ static int device_init_func(void *opaque, QemuOpts = *opts, Error **errp) DeviceState *dev; =20 dev =3D qdev_device_add(opts, errp); - if (!dev) { + if (!dev && *errp) { + error_report_err(*errp); return -1; + } else if (dev) { + object_unref(OBJECT(dev)); } - object_unref(OBJECT(dev)); return 0; } =20 --=20 2.21.0 From nobody Mon Apr 29 02:12:32 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=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571820025; cv=none; d=zoho.com; s=zohoarc; b=G16tDkXX4V1HViVbFhCkcvfmfXrc8dBedlGccT/5m0EFckTK7shv4TeATHMsa9jRyuWECRFY4MRRLMuYL63J4zkOwq2LAC+KmvJvyRQ96HhOj8NTnY1frtFrl+Y8yo7RyAcnm5H6zSut+RWdHERZdmS4vU621TvlrZqzgoII7z0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571820025; h=Content-Type: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=kprYC2KPvV+4Y2xOO3jQb8weHZrVvaPaWMGwzcgV3KU=; b=DgSNbI8bhsww5dyU3YV03q48YwbZwsplv1fbaYEL/QNVSxpEr9Z+DFMP5qsbmDLJRdyz93MCBkDmpn8OT9SWTZK1GiUiyd3AiUHd8aiG8jwldA3+3CYor4szkqLsfLBXHUfbPYyR7kwIILTBCgDsiv9um9TlBSmmF0EwtFXmIUo= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571820025669480.78139777928766; Wed, 23 Oct 2019 01:40:25 -0700 (PDT) Received: from localhost ([::1]:57334 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNCBq-0001DP-Hm for importer@patchew.org; Wed, 23 Oct 2019 04:40:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48288) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNBze-0002vF-DN for qemu-devel@nongnu.org; Wed, 23 Oct 2019 04:27:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNBzc-0005vZ-6j for qemu-devel@nongnu.org; Wed, 23 Oct 2019 04:27:46 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:60226 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iNBzc-0005sN-1p for qemu-devel@nongnu.org; Wed, 23 Oct 2019 04:27:44 -0400 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-307-W5o8t1UWMzueesezgljQrA-1; Wed, 23 Oct 2019 04:27:39 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3C7441005509; Wed, 23 Oct 2019 08:27:38 +0000 (UTC) Received: from localhost (dhcp-192-217.str.redhat.com [10.33.192.217]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 097205D6C8; Wed, 23 Oct 2019 08:27:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571819262; 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=kprYC2KPvV+4Y2xOO3jQb8weHZrVvaPaWMGwzcgV3KU=; b=fdDQCWAXbzKXU3sibKljPKgVpmx1lpIXC9+sEu3KuEHt+ASoz5iO2m3U0prBwqqljG7IeR R8a6ys77FTcjPcwnz+lozbJCb/5jTprU6Zo3Qim9W76yFtRlM7MLo/rmb3tDIOB/843zBu 9ihuNvigb1dBHhy3bRF8zLozQiyzVsk= From: Jens Freimann To: qemu-devel@nongnu.org Subject: [PATCH v5 02/11] pci: add option for net failover Date: Wed, 23 Oct 2019 10:27:02 +0200 Message-Id: <20191023082711.16694-3-jfreimann@redhat.com> In-Reply-To: <20191023082711.16694-1-jfreimann@redhat.com> References: <20191023082711.16694-1-jfreimann@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: W5o8t1UWMzueesezgljQrA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 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: pkrempa@redhat.com, berrange@redhat.com, ehabkost@redhat.com, mst@redhat.com, aadam@redhat.com, dgilbert@redhat.com, alex.williamson@redhat.com, laine@redhat.com, ailan@redhat.com, parav@mellanox.com 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 patch adds a net_failover_pair_id property to PCIDev which is used to link the primary device in a failover pair (the PCI dev) to a standby (a virtio-net-pci) device. It only supports ethernet devices. Also currently it only supports PCIe devices. QEMU will exit with an error message otherwise. Signed-off-by: Jens Freimann --- hw/pci/pci.c | 17 +++++++++++++++++ include/hw/pci/pci.h | 3 +++ 2 files changed, 20 insertions(+) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index aa05c2b9b2..fa9b5219f8 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -75,6 +75,8 @@ static Property pci_props[] =3D { QEMU_PCIE_LNKSTA_DLLLA_BITNR, true), DEFINE_PROP_BIT("x-pcie-extcap-init", PCIDevice, cap_present, QEMU_PCIE_EXTCAP_INIT_BITNR, true), + DEFINE_PROP_STRING("net_failover_pair_id", PCIDevice, + net_failover_pair_id), DEFINE_PROP_END_OF_LIST() }; =20 @@ -2077,6 +2079,7 @@ static void pci_qdev_realize(DeviceState *qdev, Error= **errp) ObjectClass *klass =3D OBJECT_CLASS(pc); Error *local_err =3D NULL; bool is_default_rom; + uint16_t class_id; =20 /* initialize cap_present for pci_is_express() and pci_config_size(), * Note that hybrid PCIs are not set automatically and need to manage @@ -2101,6 +2104,20 @@ static void pci_qdev_realize(DeviceState *qdev, Erro= r **errp) } } =20 + if (pci_dev->net_failover_pair_id) { + if (!pci_is_express(pci_dev)) { + error_setg(errp, "failover device is not a PCIExpress device"); + error_propagate(errp, local_err); + return; + } + class_id =3D pci_get_word(pci_dev->config + PCI_CLASS_DEVICE); + if (class_id !=3D PCI_CLASS_NETWORK_ETHERNET) { + error_setg(errp, "failover device is not an Ethernet device"); + error_propagate(errp, local_err); + return; + } + } + /* rom loading */ is_default_rom =3D false; if (pci_dev->romfile =3D=3D NULL && pc->romfile !=3D NULL) { diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index f3f0ffd5fb..def5435685 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -352,6 +352,9 @@ struct PCIDevice { MSIVectorUseNotifier msix_vector_use_notifier; MSIVectorReleaseNotifier msix_vector_release_notifier; MSIVectorPollNotifier msix_vector_poll_notifier; + + /* ID of standby device in net_failover pair */ + char *net_failover_pair_id; }; =20 void pci_register_bar(PCIDevice *pci_dev, int region_num, --=20 2.21.0 From nobody Mon Apr 29 02:12:32 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=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571819637; cv=none; d=zoho.com; s=zohoarc; b=ZCL5ZyjRQg9SvhxwJems39JlSJCHccxBym0IXb8k3BTjYgX65lxcBDAqpL3EwknF4ouQ/JghJKVf9Z6kXIgv1IGLcO9LDJTsGbXtdXA/BaTxUPF8nBg1N3JQGdNyG1qyOQAulak210OUtUaefoay8Er0od3m9KLUQLbenq04faE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571819637; h=Content-Type: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=XIilRMF3CC/CW5jbJi+pIxz32bjewuFi7+thsamBRu0=; b=Sfzb7ducyrFmmT0ypAwQ3xmktI7YErS+rb0vyi30KCXk530vrGTPchU07NK9mpH64yVis8iuXlOT49W6Bz9/+MUPmC/u+8IZwEh5DComc0a0qK8xy2XJcthOc0axneYSoQ+ZQ3HRR/GwndVBkA7TBnfGAi3X8sM/y1tOMepEl0w= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571819637548394.83984770560096; Wed, 23 Oct 2019 01:33:57 -0700 (PDT) Received: from localhost ([::1]:57254 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNC5c-0005TO-1Q for importer@patchew.org; Wed, 23 Oct 2019 04:33:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48450) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNBzo-00037b-Gf for qemu-devel@nongnu.org; Wed, 23 Oct 2019 04:27:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNBzn-00065v-EV for qemu-devel@nongnu.org; Wed, 23 Oct 2019 04:27:56 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:27185 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iNBzn-00065Y-Ak for qemu-devel@nongnu.org; Wed, 23 Oct 2019 04:27:55 -0400 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-125-HUfEIWybOM-7SSgJFhSAMQ-1; Wed, 23 Oct 2019 04:27:47 -0400 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 E84DA476; Wed, 23 Oct 2019 08:27:46 +0000 (UTC) Received: from localhost (dhcp-192-217.str.redhat.com [10.33.192.217]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AA5B95DD78; Wed, 23 Oct 2019 08:27:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571819274; 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=XIilRMF3CC/CW5jbJi+pIxz32bjewuFi7+thsamBRu0=; b=S8c1aB1gyEDUeC6vO4smK6ACGlQSVRd7uX2+Owrp7pVYvkMKmWuFUq5Mz8QK3rH1d6FxA/ I196jQiKNk2CIV1RSJ0p1U/eA9lq01GFJgzjAem3nv5TvnRe8s1FZ3gifejVGdsxNuWVqB s7h3veRnIDVxKVLOFWV9vV0nW/H/kcU= From: Jens Freimann To: qemu-devel@nongnu.org Subject: [PATCH v5 03/11] pci: mark devices partially unplugged Date: Wed, 23 Oct 2019 10:27:03 +0200 Message-Id: <20191023082711.16694-4-jfreimann@redhat.com> In-Reply-To: <20191023082711.16694-1-jfreimann@redhat.com> References: <20191023082711.16694-1-jfreimann@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: HUfEIWybOM-7SSgJFhSAMQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 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: pkrempa@redhat.com, berrange@redhat.com, ehabkost@redhat.com, mst@redhat.com, aadam@redhat.com, dgilbert@redhat.com, alex.williamson@redhat.com, laine@redhat.com, ailan@redhat.com, parav@mellanox.com 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" Only the guest unplug request was triggered. This is needed for the failover feature. In case of a failed migration we need to plug the device back to the guest. Signed-off-by: Jens Freimann --- hw/pci/pcie.c | 3 +++ include/hw/pci/pci.h | 1 + 2 files changed, 4 insertions(+) diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index a6beb567bd..19363ff8ce 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -456,6 +456,9 @@ static void pcie_unplug_device(PCIBus *bus, PCIDevice *= dev, void *opaque) { HotplugHandler *hotplug_ctrl =3D qdev_get_hotplug_handler(DEVICE(dev)); =20 + if (dev->partially_hotplugged) { + return; + } hotplug_handler_unplug(hotplug_ctrl, DEVICE(dev), &error_abort); object_unparent(OBJECT(dev)); } diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index def5435685..7b7eac845c 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -265,6 +265,7 @@ typedef struct PCIReqIDCache PCIReqIDCache; =20 struct PCIDevice { DeviceState qdev; + bool partially_hotplugged; =20 /* PCI config space */ uint8_t *config; --=20 2.21.0 From nobody Mon Apr 29 02:12:32 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=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571820022; cv=none; d=zoho.com; s=zohoarc; b=iKdb+RG0URc6RHMYUlLWUsBAx+zSoKccG4kGqFiGFpfbPXChTE5m3NOPNQE4grrnVfc48xMzf63aSMXD7r+02gAc6WajAVumV3m1W16rMAOFASLoLjjDb6rb0wXH7gCvxmVFqbqfG0iK/Z2a/e/qMQpvMN+18YLFKpgYf58gZQQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571820022; h=Content-Type: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=cWXf1NeLrJEnUZTvjnFVmdJJTcPrV818MVFofZ3mx0M=; b=VftY0Bw+n/HL9Q6cPxtVdTH7+pa620lixm5EiUfCjYGls5Iq9xkSNnJK0//T6d6GLKootgm8z449HPN5m1GT7r17wDFL6dQ9bvT8Wh+88oBRcwwSJVBJdm0Bb+Fk1HC+UFSb4nUJPmIbn6FXqaVvNWnb1qJCdMJUlSswXGCm/fQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571820022691816.02228082337; Wed, 23 Oct 2019 01:40:22 -0700 (PDT) Received: from localhost ([::1]:57322 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNCBo-0001BV-9b for importer@patchew.org; Wed, 23 Oct 2019 04:40:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48513) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNC07-0003Cc-9I for qemu-devel@nongnu.org; Wed, 23 Oct 2019 04:28:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNC04-0006Iu-U3 for qemu-devel@nongnu.org; Wed, 23 Oct 2019 04:28:14 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:45230 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iNC02-0006DZ-S3 for qemu-devel@nongnu.org; Wed, 23 Oct 2019 04:28:10 -0400 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-318-BxbsvTZTOvKYybL30USAew-1; Wed, 23 Oct 2019 04:28:00 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7E0BF1800E01; Wed, 23 Oct 2019 08:27:59 +0000 (UTC) Received: from localhost (dhcp-192-217.str.redhat.com [10.33.192.217]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 685B260161; Wed, 23 Oct 2019 08:27:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571819285; 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=cWXf1NeLrJEnUZTvjnFVmdJJTcPrV818MVFofZ3mx0M=; b=gJSOSPqYqwcb4PXsWsdyolLsNR0eWSdyMZEPjVpQ1vV9uocSvhOH2LuOYD6w/VwzKD122N ukxwP+m4JJeQFh/ofsnJa/KhwV8jljkOezN4WOzBKOCVMHaTMF3P24fLmBKWYGCFt+6slT m6RnbcRESlcLzx3nbKAzehuHrjeMSIA= From: Jens Freimann To: qemu-devel@nongnu.org Subject: [PATCH v5 04/11] pci: mark device having guest unplug request pending Date: Wed, 23 Oct 2019 10:27:04 +0200 Message-Id: <20191023082711.16694-5-jfreimann@redhat.com> In-Reply-To: <20191023082711.16694-1-jfreimann@redhat.com> References: <20191023082711.16694-1-jfreimann@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: BxbsvTZTOvKYybL30USAew-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 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: pkrempa@redhat.com, berrange@redhat.com, ehabkost@redhat.com, mst@redhat.com, aadam@redhat.com, dgilbert@redhat.com, alex.williamson@redhat.com, laine@redhat.com, ailan@redhat.com, parav@mellanox.com 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" Set pending_deleted_event in DeviceState for failover primary devices that were successfully unplugged by the Guest OS. Signed-off-by: Jens Freimann --- hw/pci/pcie.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index 19363ff8ce..08718188bb 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -457,6 +457,7 @@ static void pcie_unplug_device(PCIBus *bus, PCIDevice *= dev, void *opaque) HotplugHandler *hotplug_ctrl =3D qdev_get_hotplug_handler(DEVICE(dev)); =20 if (dev->partially_hotplugged) { + dev->qdev.pending_deleted_event =3D false; return; } hotplug_handler_unplug(hotplug_ctrl, DEVICE(dev), &error_abort); @@ -476,6 +477,8 @@ void pcie_cap_slot_unplug_request_cb(HotplugHandler *ho= tplug_dev, return; } =20 + dev->pending_deleted_event =3D true; + /* In case user cancel the operation of multi-function hot-add, * remove the function that is unexposed to guest individually, * without interaction with guest. --=20 2.21.0 From nobody Mon Apr 29 02:12:32 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=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571820296; cv=none; d=zoho.com; s=zohoarc; b=j/f9rajNKgQy6Hhe4DF/jNEqU1ymmCiP/KIduitFDho1vtU7uJFd0PR3tOw9dSFI+uHfI3wT765E2Q/XDhik11yRrO3hWqM3GIGAUNY82SImOH8NOnawlJssmGBgaYLIy9bUgxJzyaGcdiyagLSBFymcrOIoFWNMLfT5dbH9BsE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571820296; h=Content-Type: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=a0z18X9hX1k7WK6Ipini1RAn90sFvkNyQ0KnUbkp4vE=; b=k2/JQ5Nw00UinIwR1xbJ1Plno3npPX/B0ruuLbOz/896OMjUFTG0xM88Xcwde+kY+SRAaJYHLr51iC5kIwClExqJGFKT5F8WzfmUrzy+efpSWbDWhPtVCV2yMmXQawFJvCHH9Q9r67OlkKgh7+3kUTivyttSvuUs5TQv0G3PmHA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571820296058559.278284003725; Wed, 23 Oct 2019 01:44:56 -0700 (PDT) Received: from localhost ([::1]:57370 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNCGE-00044j-Eb for importer@patchew.org; Wed, 23 Oct 2019 04:44:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48532) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNC0C-0003Et-JO for qemu-devel@nongnu.org; Wed, 23 Oct 2019 04:28:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNC0A-0006Nd-Q6 for qemu-devel@nongnu.org; Wed, 23 Oct 2019 04:28:20 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:46158 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iNC07-0006If-1j for qemu-devel@nongnu.org; Wed, 23 Oct 2019 04:28:17 -0400 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-132-wz05NgOUOoeAc9xYQRuKOg-1; Wed, 23 Oct 2019 04:28:11 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2DD55107AD31; Wed, 23 Oct 2019 08:28:10 +0000 (UTC) Received: from localhost (dhcp-192-217.str.redhat.com [10.33.192.217]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F198319C78; Wed, 23 Oct 2019 08:28:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571819292; 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=a0z18X9hX1k7WK6Ipini1RAn90sFvkNyQ0KnUbkp4vE=; b=BnJfKHGV1MJBYr6/mXk+fEfDR391d//u4lGQ9KXZ+l8CC6mSUI8dClpe9uL0wUzeD1P+5k tZ1JtooO9Bm1iPtf6IqexA2mtOeL+890xeKeqjHBxAMLALfLJWvPR/1YwmXSJjGhu3vvt9 YmpBbmBUBTKQyVmZ11hwb7eHq7rxP88= From: Jens Freimann To: qemu-devel@nongnu.org Subject: [PATCH v5 05/11] qapi: add unplug primary event Date: Wed, 23 Oct 2019 10:27:05 +0200 Message-Id: <20191023082711.16694-6-jfreimann@redhat.com> In-Reply-To: <20191023082711.16694-1-jfreimann@redhat.com> References: <20191023082711.16694-1-jfreimann@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: wz05NgOUOoeAc9xYQRuKOg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 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: pkrempa@redhat.com, berrange@redhat.com, ehabkost@redhat.com, mst@redhat.com, aadam@redhat.com, dgilbert@redhat.com, alex.williamson@redhat.com, laine@redhat.com, ailan@redhat.com, parav@mellanox.com 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 event is emitted when we sent a request to unplug a failover primary device from the Guest OS and it includes the device id of the primary device. Signed-off-by: Jens Freimann --- qapi/migration.json | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/qapi/migration.json b/qapi/migration.json index 82feb5bd39..52e69e2868 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -1448,3 +1448,22 @@ # Since: 3.0 ## { 'command': 'migrate-pause', 'allow-oob': true } + +## +# @UNPLUG_PRIMARY: +# +# Emitted from source side of a migration when migration state is +# WAIT_UNPLUG. Device was unplugged by guest operating system. +# Device resources in QEMU are kept on standby to be able to re-plug it in= case +# of migration failure. +# +# @device_id: QEMU device id of the unplugged device +# +# Since: 4.2 +# +# Example: +# {"event": "UNPLUG_PRIMARY", "data": {"device_id": "hostdev0"} } +# +## +{ 'event': 'UNPLUG_PRIMARY', + 'data': { 'device_id': 'str' } } --=20 2.21.0 From nobody Mon Apr 29 02:12:32 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=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571820694; cv=none; d=zoho.com; s=zohoarc; b=kabt+hn6qa6VaB+dLMWzHvHsiHUwS7TMmA3mhN7awxonoqdNye1TN6+dtNQ1JR4qvYjtgSlBJJqzQcAEZrOPdqHn+AcS8d5JeQf5tCFW8vOTGSM1nPIwZrIJEJNoxOE9uo5DJrKv87iATvjb0mPuF8AJnyFHDvYZRbMARS9mQas= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571820694; h=Content-Type: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=RDg9Tl3+mjfssH5RsGrJw5+5sFGZgOaBVb+IEJM3M2A=; b=agaOhAGyTB9NMWTAXW8xk6Dzyk8tkBjHJsZx1XnyomzxgbuONSXo1BcQ1eJ0tUOCbXKRJoijb+mY4O57Ca9vsGgtGOSFeOPCa0bSttFJYTGyyF73e3yMnsWnrOIVBLstiyZRm+6e3pPea/izkbpr5niWRPWr5wSavRZRN965Ssc= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571820694587117.13219944386299; Wed, 23 Oct 2019 01:51:34 -0700 (PDT) Received: from localhost ([::1]:57486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNCMd-0008Iz-I6 for importer@patchew.org; Wed, 23 Oct 2019 04:51:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48548) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNC0I-0003Iv-1a for qemu-devel@nongnu.org; Wed, 23 Oct 2019 04:28:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNC0F-0006RM-Eg for qemu-devel@nongnu.org; Wed, 23 Oct 2019 04:28:25 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:39497 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iNC0F-0006Qq-91 for qemu-devel@nongnu.org; Wed, 23 Oct 2019 04:28:23 -0400 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-151-fSD6D3AXNN60JIhHXnwDyQ-1; Wed, 23 Oct 2019 04:28:19 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C05B11800D6B; Wed, 23 Oct 2019 08:28:18 +0000 (UTC) Received: from localhost (dhcp-192-217.str.redhat.com [10.33.192.217]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9FB72600CC; Wed, 23 Oct 2019 08:28:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571819302; 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=RDg9Tl3+mjfssH5RsGrJw5+5sFGZgOaBVb+IEJM3M2A=; b=H2wTZd2m94iPkHlwX0xAuZpttT4BggOofxeT6k1ioxn/dvnxpRlQn6e8TzRLXds8k3Ph8J Kd651VFVcSbu86moOzfrHPXE3Y+P+mxF+1xbNLCa7E7lA0TRpidvgQZS76TxHMNsl040F7 aeJOf+d+i6eMWRbiT+jTexJe3PPIZ3I= From: Jens Freimann To: qemu-devel@nongnu.org Subject: [PATCH v5 06/11] qapi: add failover negotiated event Date: Wed, 23 Oct 2019 10:27:06 +0200 Message-Id: <20191023082711.16694-7-jfreimann@redhat.com> In-Reply-To: <20191023082711.16694-1-jfreimann@redhat.com> References: <20191023082711.16694-1-jfreimann@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: fSD6D3AXNN60JIhHXnwDyQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 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: pkrempa@redhat.com, berrange@redhat.com, ehabkost@redhat.com, mst@redhat.com, aadam@redhat.com, dgilbert@redhat.com, alex.williamson@redhat.com, laine@redhat.com, ailan@redhat.com, parav@mellanox.com 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 event is sent to let libvirt know that VIRTIO_NET_F_STANDBY feature was not negotiated during virtio feature negotiation. If this event is received it means any primary devices hotplugged before this were were never really added to QEMU devices. Signed-off-by: Jens Freimann --- qapi/net.json | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/qapi/net.json b/qapi/net.json index 728990f4fb..8c5f3f1fb2 100644 --- a/qapi/net.json +++ b/qapi/net.json @@ -737,3 +737,19 @@ ## { 'command': 'announce-self', 'boxed': true, 'data' : 'AnnounceParameters'} + +## +# @FAILOVER_NEGOTIATED: +# +# Emitted when VIRTIO_NET_F_STANDBY was negotiated during feature negotiat= ion +# +# Since: 4.2 +# +# Example: +# +# <- { "event": "FAILOVER_NEGOTIATED", +# "data": {} } +# +## +{ 'event': 'FAILOVER_NEGOTIATED', + 'data': {} } --=20 2.21.0 From nobody Mon Apr 29 02:12:32 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=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571819816; cv=none; d=zoho.com; s=zohoarc; b=abgHZZwHr7/3vb4zj5RZb2mWZV9Q1e1KfiMbVZz6IUXOjRuLnc2gN3mxJTp640poKOZkAY5O5J2AN3I8c18IZm4YCNM1MV3NDveProQEKFZIrYtoR5FmmvIlno4AX9rBn6mm+8BH6IckLtPEjZ7/3IY8bGUDVx+85MHj89Y07eQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571819816; h=Content-Type: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=tsMGOxPnmVpYk8EllN+pMhqAga9WNaKjW/eMZMn6bvo=; b=km1EUIhEvXz4/7skHP0PpZWmgZDpFOsMaZPFS6z/XFnttQQXNXVO8YT/5w/kT+YodCT2Qc2MTM0+ykEp5IwOUZ8ObKXEYtw5lHXiGH7eJH+vwAVYt7WB+0nifwuN2K2UuxgwZThPFDaC7IdQazhk/cS/0SQzqQhkNWkDxX1WPIg= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 157181981641586.9540858844839; Wed, 23 Oct 2019 01:36:56 -0700 (PDT) Received: from localhost ([::1]:57290 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNC8U-0007iA-UL for importer@patchew.org; Wed, 23 Oct 2019 04:36:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48561) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNC0M-0003Jc-4o for qemu-devel@nongnu.org; Wed, 23 Oct 2019 04:28:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNC0K-0006Ul-33 for qemu-devel@nongnu.org; Wed, 23 Oct 2019 04:28:29 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:21580 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iNC0J-0006TE-Fp for qemu-devel@nongnu.org; Wed, 23 Oct 2019 04:28:28 -0400 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-374-CtChwgn_MNuBjaU6_0gQ7g-1; Wed, 23 Oct 2019 04:28:22 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D15AA107AD31; Wed, 23 Oct 2019 08:28:21 +0000 (UTC) Received: from localhost (dhcp-192-217.str.redhat.com [10.33.192.217]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 40489600CC; Wed, 23 Oct 2019 08:28:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571819306; 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=tsMGOxPnmVpYk8EllN+pMhqAga9WNaKjW/eMZMn6bvo=; b=XR5yCmQV6WEerV/ccbS79kSMlqBvJmkBEXbWpnRgsTcE9yj8xlFBo5+RQP+497xm74mq8R ffXH35GKCLOTmUbHx00HrUf1KnVL/Ht50MELQQMuHU9shxXUFR+m0qOUj9hPFFQMeJX84k kqfOo2jAKFgNLPxK6kyTg9+Nyr7l3XM= From: Jens Freimann To: qemu-devel@nongnu.org Subject: [PATCH v5 07/11] migration: allow unplug during migration for failover devices Date: Wed, 23 Oct 2019 10:27:07 +0200 Message-Id: <20191023082711.16694-8-jfreimann@redhat.com> In-Reply-To: <20191023082711.16694-1-jfreimann@redhat.com> References: <20191023082711.16694-1-jfreimann@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: CtChwgn_MNuBjaU6_0gQ7g-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 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: pkrempa@redhat.com, berrange@redhat.com, ehabkost@redhat.com, mst@redhat.com, aadam@redhat.com, dgilbert@redhat.com, alex.williamson@redhat.com, laine@redhat.com, ailan@redhat.com, parav@mellanox.com 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" In "b06424de62 migration: Disable hotplug/unplug during migration" we added a check to disable unplug for all devices until we have figured out what works. For failover primary devices qdev_unplug() is called from the migration handler, i.e. during migration. This patch adds a flag to DeviceState which is set to false for all devices and makes an exception for PCI devices that are also primary devices in a failover pair. Signed-off-by: Jens Freimann --- hw/core/qdev.c | 1 + hw/pci/pci.c | 1 + include/hw/qdev-core.h | 1 + qdev-monitor.c | 2 +- 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index f786650446..dc1289da86 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -995,6 +995,7 @@ static void device_initfn(Object *obj) =20 dev->instance_id_alias =3D -1; dev->realized =3D false; + dev->allow_unplug_during_migration =3D false; =20 object_property_add_bool(obj, "realized", device_get_realized, device_set_realized, NUL= L); diff --git a/hw/pci/pci.c b/hw/pci/pci.c index fa9b5219f8..8fbf32d68c 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -2116,6 +2116,7 @@ static void pci_qdev_realize(DeviceState *qdev, Error= **errp) error_propagate(errp, local_err); return; } + qdev->allow_unplug_during_migration =3D true; } =20 /* rom loading */ diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 710981af36..1518495b1e 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -156,6 +156,7 @@ struct DeviceState { bool pending_deleted_event; QemuOpts *opts; int hotplugged; + bool allow_unplug_during_migration; BusState *parent_bus; QLIST_HEAD(, NamedGPIOList) gpios; QLIST_HEAD(, BusState) child_bus; diff --git a/qdev-monitor.c b/qdev-monitor.c index 676a759fb4..bc6a41fa37 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -851,7 +851,7 @@ void qdev_unplug(DeviceState *dev, Error **errp) return; } =20 - if (!migration_is_idle()) { + if (!migration_is_idle() && !dev->allow_unplug_during_migration) { error_setg(errp, "device_del not allowed while migrating"); return; } --=20 2.21.0 From nobody Mon Apr 29 02:12:32 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=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571820940; cv=none; d=zoho.com; s=zohoarc; b=AvmGYZrgZ67VJplrgMWWRJjs/nkZuj9ts/Ojn5M7v7AiJxCtbgDN7Z/Vlv/7mFCrnhpT0nxQqPL/dCHqasdtDBbnIrWAzSmw8rW7lZNP2ceDrjisNXeIdsy96v68ucaHE9zoyMoHnclvovZbKYGlCRFtHaA9H697tdSUQXq5Fg8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571820940; h=Content-Type: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=l5RpSaMs8bMQN2SO4g/r35AIQAc1GgQ2h2NBpnRyB4k=; b=aC5FyBQUdEA10rVLGJ600hanrlxZrhhg6mS0pbvc2hNFXIwYs9svq92t13DX3KRalItfxALCoQ5ePLwZ1tNXh/Mxsr459UZNJEXo5A+IYC7AOv14Kb0Ib5IVY4s8iXQOrJYjfMK0mfhCiihMFq1CEK83BsVzR8V1nu/KMvPlhVg= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571820940460900.6484780281858; Wed, 23 Oct 2019 01:55:40 -0700 (PDT) Received: from localhost ([::1]:57546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNCQc-0002QS-B4 for importer@patchew.org; Wed, 23 Oct 2019 04:55:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48625) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNC0Y-0003M2-OR for qemu-devel@nongnu.org; Wed, 23 Oct 2019 04:28:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNC0V-0006eM-U4 for qemu-devel@nongnu.org; Wed, 23 Oct 2019 04:28:42 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:21680 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iNC0V-0006Zo-Pi for qemu-devel@nongnu.org; Wed, 23 Oct 2019 04:28:39 -0400 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-378-0x7QgRUBMR-E3a_pjlLgYg-1; Wed, 23 Oct 2019 04:28:32 -0400 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 13EAC107AD31; Wed, 23 Oct 2019 08:28:31 +0000 (UTC) Received: from localhost (dhcp-192-217.str.redhat.com [10.33.192.217]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 500D51F3; Wed, 23 Oct 2019 08:28:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571819313; 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=l5RpSaMs8bMQN2SO4g/r35AIQAc1GgQ2h2NBpnRyB4k=; b=VHm8ZuR9IRk0WVmBowap8OfXMUgmdlVg9pAXLRMF/4lAe0GR77qmoqvrX96bAHa1MSCOTh +mJXLqGu06LoMjCv9OtuXqfaBlZXuMD/Py9/rn2H7EU2GtXpVQAfT+Ts3TyhHwmVgX8KVZ 74eiAoP5DMpfcCIcX2VFX0i6I9XvX5M= From: Jens Freimann To: qemu-devel@nongnu.org Subject: [PATCH v5 08/11] migration: add new migration state wait-unplug Date: Wed, 23 Oct 2019 10:27:08 +0200 Message-Id: <20191023082711.16694-9-jfreimann@redhat.com> In-Reply-To: <20191023082711.16694-1-jfreimann@redhat.com> References: <20191023082711.16694-1-jfreimann@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: 0x7QgRUBMR-E3a_pjlLgYg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 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: pkrempa@redhat.com, berrange@redhat.com, ehabkost@redhat.com, mst@redhat.com, aadam@redhat.com, dgilbert@redhat.com, alex.williamson@redhat.com, laine@redhat.com, ailan@redhat.com, parav@mellanox.com 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 patch adds a new migration state called wait-unplug. It is entered after the SETUP state if failover devices are present. It will transition into ACTIVE once all devices were succesfully unplugged from the guest. So if a guest doesn't respond or takes long to honor the unplug request the user will see the migration state 'wait-unplug'. In the migration thread we query failover devices if they're are still pending the guest unplug. When all are unplugged the migration continues. If one device won't unplug migration will stay in wait_unplug state. Signed-off-by: Jens Freimann --- include/migration/vmstate.h | 2 ++ migration/migration.c | 21 +++++++++++++++++++++ migration/migration.h | 3 +++ migration/savevm.c | 36 ++++++++++++++++++++++++++++++++++++ migration/savevm.h | 2 ++ qapi/migration.json | 5 ++++- 6 files changed, 68 insertions(+), 1 deletion(-) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index b9ee563aa4..ac4f46a67d 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -186,6 +186,8 @@ struct VMStateDescription { int (*pre_save)(void *opaque); int (*post_save)(void *opaque); bool (*needed)(void *opaque); + bool (*dev_unplug_pending)(void *opaque); + const VMStateField *fields; const VMStateDescription **subsections; }; diff --git a/migration/migration.c b/migration/migration.c index 3febd0f8f3..51764f2565 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -52,6 +52,7 @@ #include "hw/qdev-properties.h" #include "monitor/monitor.h" #include "net/announce.h" +#include "qemu/queue.h" =20 #define MAX_THROTTLE (32 << 20) /* Migration transfer speed throttli= ng */ =20 @@ -819,6 +820,7 @@ bool migration_is_setup_or_active(int state) case MIGRATION_STATUS_SETUP: case MIGRATION_STATUS_PRE_SWITCHOVER: case MIGRATION_STATUS_DEVICE: + case MIGRATION_STATUS_WAIT_UNPLUG: return true; =20 default: @@ -954,6 +956,9 @@ static void fill_source_migration_info(MigrationInfo *i= nfo) case MIGRATION_STATUS_CANCELLED: info->has_status =3D true; break; + case MIGRATION_STATUS_WAIT_UNPLUG: + info->has_status =3D true; + break; } info->status =3D s->state; } @@ -1694,6 +1699,7 @@ bool migration_is_idle(void) case MIGRATION_STATUS_COLO: case MIGRATION_STATUS_PRE_SWITCHOVER: case MIGRATION_STATUS_DEVICE: + case MIGRATION_STATUS_WAIT_UNPLUG: return false; case MIGRATION_STATUS__MAX: g_assert_not_reached(); @@ -3264,6 +3270,19 @@ static void *migration_thread(void *opaque) =20 qemu_savevm_state_setup(s->to_dst_file); =20 + if (qemu_savevm_nr_failover_devices()) { + migrate_set_state(&s->state, MIGRATION_STATUS_SETUP, + MIGRATION_STATUS_WAIT_UNPLUG); + + while (s->state =3D=3D MIGRATION_STATUS_WAIT_UNPLUG && + !qemu_savevm_state_guest_unplug_pending()) { + qemu_sem_timedwait(&s->wait_unplug_sem, 250); + } + + migrate_set_state(&s->state, MIGRATION_STATUS_WAIT_UNPLUG, + MIGRATION_STATUS_ACTIVE); + } + s->setup_time =3D qemu_clock_get_ms(QEMU_CLOCK_HOST) - setup_start; migrate_set_state(&s->state, MIGRATION_STATUS_SETUP, MIGRATION_STATUS_ACTIVE); @@ -3511,6 +3530,7 @@ static void migration_instance_finalize(Object *obj) qemu_mutex_destroy(&ms->qemu_file_lock); g_free(params->tls_hostname); g_free(params->tls_creds); + qemu_sem_destroy(&ms->wait_unplug_sem); qemu_sem_destroy(&ms->rate_limit_sem); qemu_sem_destroy(&ms->pause_sem); qemu_sem_destroy(&ms->postcopy_pause_sem); @@ -3556,6 +3576,7 @@ static void migration_instance_init(Object *obj) qemu_sem_init(&ms->postcopy_pause_rp_sem, 0); qemu_sem_init(&ms->rp_state.rp_sem, 0); qemu_sem_init(&ms->rate_limit_sem, 0); + qemu_sem_init(&ms->wait_unplug_sem, 0); qemu_mutex_init(&ms->qemu_file_lock); } =20 diff --git a/migration/migration.h b/migration/migration.h index 4f2fe193dc..79b3dda146 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -206,6 +206,9 @@ struct MigrationState /* Flag set once the migration thread called bdrv_inactivate_all */ bool block_inactive; =20 + /* Migration is waiting for guest to unplug device */ + QemuSemaphore wait_unplug_sem; + /* Migration is paused due to pause-before-switchover */ QemuSemaphore pause_sem; =20 diff --git a/migration/savevm.c b/migration/savevm.c index 8d95e261f6..0f18dea49e 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1113,6 +1113,42 @@ void qemu_savevm_state_header(QEMUFile *f) } } =20 +int qemu_savevm_nr_failover_devices(void) +{ + SaveStateEntry *se; + int n =3D 0; + + QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { + if (se->vmsd && se->vmsd->dev_unplug_pending) { + n++; + } + } + + return n; +} + +bool qemu_savevm_state_guest_unplug_pending(void) +{ + int nr_failover_devs; + SaveStateEntry *se; + bool ret =3D false; + int n =3D 0; + + nr_failover_devs =3D qemu_savevm_nr_failover_devices(); + + QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { + if (!se->vmsd || !se->vmsd->dev_unplug_pending) { + continue; + } + ret =3D se->vmsd->dev_unplug_pending(se->opaque); + if (!ret) { + n++; + } + } + + return n =3D=3D nr_failover_devs; +} + void qemu_savevm_state_setup(QEMUFile *f) { SaveStateEntry *se; diff --git a/migration/savevm.h b/migration/savevm.h index 51a4b9caa8..c42b9c80ee 100644 --- a/migration/savevm.h +++ b/migration/savevm.h @@ -31,6 +31,8 @@ =20 bool qemu_savevm_state_blocked(Error **errp); void qemu_savevm_state_setup(QEMUFile *f); +int qemu_savevm_nr_failover_devices(void); +bool qemu_savevm_state_guest_unplug_pending(void); int qemu_savevm_state_resume_prepare(MigrationState *s); void qemu_savevm_state_header(QEMUFile *f); int qemu_savevm_state_iterate(QEMUFile *f, bool postcopy); diff --git a/qapi/migration.json b/qapi/migration.json index 52e69e2868..5a06cd489f 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -133,6 +133,9 @@ # @device: During device serialisation when pause-before-switchover is ena= bled # (since 2.11) # +# @wait-unplug: wait for device unplug request by guest OS to be completed. +# (since 4.2) +# # Since: 2.3 # ## @@ -140,7 +143,7 @@ 'data': [ 'none', 'setup', 'cancelling', 'cancelled', 'active', 'postcopy-active', 'postcopy-paused', 'postcopy-recover', 'completed', 'failed', 'colo', - 'pre-switchover', 'device' ] } + 'pre-switchover', 'device', 'wait-unplug' ] } =20 ## # @MigrationInfo: --=20 2.21.0 From nobody Mon Apr 29 02:12:32 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=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571820335; cv=none; d=zoho.com; s=zohoarc; b=k53x2qSucszU1qOZOoJBwUUW5Z1y5xNMxx/HkdkfCU3K/c3/cbKddODwriLPvwRDVmkkdbTxStcbpqO8l5g/cM7TV2z3EVINPxoWCAHXx40hoyBg9J1hljH1ulxIw67dvGyqhfjZXKV1KJlUcZspywA54SsAtTqO4HvcvwKTAUk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571820335; h=Content-Type: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=RYq1a2cQnwSoFC7ZG9jOkK0ifFOYr2LBMa3wLluDZwY=; b=JWDaaOsdm4FKxOhRmxjLkPe1lR39tP/I1lXSa0/zpHh6Fr8Tz9kWI5WzKAt5ASecf0KCQym9v/05+6cX6yFyLKjvlscACJt9JYxZhx+1QmnzvM+iZZWtGB8dIwTGDubiXFZTD+xQkhttZRNoSNF8fYD1q6nhU1/SH7GQi8xxktU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571820335668948.5711512379197; Wed, 23 Oct 2019 01:45:35 -0700 (PDT) Received: from localhost ([::1]:57386 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNCGr-0004F1-QR for importer@patchew.org; Wed, 23 Oct 2019 04:45:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48777) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNC0g-0003VA-Aw for qemu-devel@nongnu.org; Wed, 23 Oct 2019 04:28:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNC0f-0006pz-8t for qemu-devel@nongnu.org; Wed, 23 Oct 2019 04:28:50 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:53276 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iNC0f-0006pd-4r for qemu-devel@nongnu.org; Wed, 23 Oct 2019 04:28:49 -0400 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-134-PoitEdo6N0ywMGGDRQBNsg-1; Wed, 23 Oct 2019 04:28:43 -0400 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 A988D1800D6B; Wed, 23 Oct 2019 08:28:42 +0000 (UTC) Received: from localhost (dhcp-192-217.str.redhat.com [10.33.192.217]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 834BB5C72D; Wed, 23 Oct 2019 08:28:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571819328; 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=RYq1a2cQnwSoFC7ZG9jOkK0ifFOYr2LBMa3wLluDZwY=; b=bLVA35PNIrc6jy6NfgJktB9nHiRvA2iUIyRsMArVV9Z2zQEQ3CaaE1Wn3jVu2LUqgT+ePL cbm90JMoJoDqGDMviv0PJ+AGBvff1U5AAd5+wIFmiiCelR6pmisdVXdfDRg402TfqSUBhh DK3gP7suIgShrFGQ6kO4X0TquiDHUGM= From: Jens Freimann To: qemu-devel@nongnu.org Subject: [PATCH v5 09/11] libqos: tolerate wait-unplug migration state Date: Wed, 23 Oct 2019 10:27:09 +0200 Message-Id: <20191023082711.16694-10-jfreimann@redhat.com> In-Reply-To: <20191023082711.16694-1-jfreimann@redhat.com> References: <20191023082711.16694-1-jfreimann@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: PoitEdo6N0ywMGGDRQBNsg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 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: pkrempa@redhat.com, berrange@redhat.com, ehabkost@redhat.com, mst@redhat.com, aadam@redhat.com, dgilbert@redhat.com, alex.williamson@redhat.com, laine@redhat.com, ailan@redhat.com, parav@mellanox.com 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" Signed-off-by: Jens Freimann --- tests/libqos/libqos.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/libqos/libqos.c b/tests/libqos/libqos.c index d71557c5cb..f229eb2cb8 100644 --- a/tests/libqos/libqos.c +++ b/tests/libqos/libqos.c @@ -125,7 +125,8 @@ void migrate(QOSState *from, QOSState *to, const char *= uri) break; } =20 - if ((strcmp(st, "setup") =3D=3D 0) || (strcmp(st, "active") =3D=3D= 0)) { + if ((strcmp(st, "setup") =3D=3D 0) || (strcmp(st, "active") =3D=3D= 0) + || (strcmp(st, "wait-unplug") =3D=3D 0)) { qobject_unref(rsp); g_usleep(5000); continue; --=20 2.21.0 From nobody Mon Apr 29 02:12:32 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=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571820758; cv=none; d=zoho.com; s=zohoarc; b=hn4y88NipuzFxF9Hdigms++OnAZX5UiLsRpkJTFGdHsxZxol5Di2BRoyj6KsoArpaAIN6zfptfb+Y8rO9NaqaENxNHiyx7EtCs25VZeD4Q0pNTFPSsvwy0/nWmpNmxBN9wUtHqInOMYHDkq4ZbteerFlUvtndnkAqTjSb9rcL04= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571820758; h=Content-Type: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=UsKKx048Mm8iT+6HGuXTCVbp9cbMwhDB3tKh4z/w+RQ=; b=bw/0AchUEIgxZ6zmhz3CR9eBW+vgx3EL23r8tx5AsESQdSLzJHYG/GQDlC72F+97hBfl5chVYTBilyOr6MwlWiVrLuXnh/8hQRIiBxADYhZbFR1LzUUjIIZqz9jj6HLV+uRD23JG59D1JHOq/7+mwk7K1V/dnjwDve6saEZH/QE= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571820758429350.7029755825175; Wed, 23 Oct 2019 01:52:38 -0700 (PDT) Received: from localhost ([::1]:57490 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNCNf-0000Np-8D for importer@patchew.org; Wed, 23 Oct 2019 04:52:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48883) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNC0t-0003cM-Rk for qemu-devel@nongnu.org; Wed, 23 Oct 2019 04:29:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNC0r-00073L-EZ for qemu-devel@nongnu.org; Wed, 23 Oct 2019 04:29:03 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:44679 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iNC0p-00070e-Ak for qemu-devel@nongnu.org; Wed, 23 Oct 2019 04:28:59 -0400 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-229-juPC8h5rNNKT6pbnI_T-mA-1; Wed, 23 Oct 2019 04:28:52 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 185C1800D49; Wed, 23 Oct 2019 08:28:52 +0000 (UTC) Received: from localhost (dhcp-192-217.str.redhat.com [10.33.192.217]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 26DBE6CE5F; Wed, 23 Oct 2019 08:28:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571819337; 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=UsKKx048Mm8iT+6HGuXTCVbp9cbMwhDB3tKh4z/w+RQ=; b=bfDAtoS5enLLOkbewOsnTsEwmi0Efqy6kF5vMyMoTXvKbL7nCGevpoHn/0PDfy0pmPNtNN WSpsXXvuVxHgTVucxOPd2Fa/mRNO53IF109RRsDnB2WEsZU/DX8SQtncLrWvb80Y5BfC8y NwgdZiAdx6DyPhTYa1/DuBxmDCdG7Sg= From: Jens Freimann To: qemu-devel@nongnu.org Subject: [PATCH v5 10/11] net/virtio: add failover support Date: Wed, 23 Oct 2019 10:27:10 +0200 Message-Id: <20191023082711.16694-11-jfreimann@redhat.com> In-Reply-To: <20191023082711.16694-1-jfreimann@redhat.com> References: <20191023082711.16694-1-jfreimann@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: juPC8h5rNNKT6pbnI_T-mA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 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: pkrempa@redhat.com, berrange@redhat.com, ehabkost@redhat.com, mst@redhat.com, aadam@redhat.com, dgilbert@redhat.com, alex.williamson@redhat.com, laine@redhat.com, ailan@redhat.com, parav@mellanox.com 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 patch adds support to handle failover device pairs of a virtio-net device and a vfio-pci device, where the virtio-net acts as the standby device and the vfio-pci device as the primary. The general idea is that we have a pair of devices, a vfio-pci and a emulated (virtio-net) device. Before migration the vfio device is unplugged and data flows to the emulated device, on the target side another vfio-pci device is plugged in to take over the data-path. In the guest the net_failover module will pair net devices with the same MAC address. To achieve this we need: 1. Provide a callback function for the should_be_hidden DeviceListener. It is called when the primary device is plugged in. Evaluate the QOpt passed in to check if it is the matching primary device. It returns two values: - one to signal if the device to be added is the matching primary device - another one to signal to qdev if it should actually continue with adding the device or skip it. In the latter case it stores the device options in the VirtioNet struct and the device is added once the VIRTIO_NET_F_STANDBY feature is negotiated during virtio feature negotiation. If the virtio-net devices are not realized at the time the vfio-pci devices are realized, we need to connect the devices later. This way we make sure primary and standby devices can be specified in any order. 2. Register a callback for migration status notifier. When called it will unplug its primary device before the migration happens. 3. Register a callback for the migration code that checks if a device needs to be unplugged from the guest. Signed-off-by: Jens Freimann --- hw/net/virtio-net.c | 302 +++++++++++++++++++++++++++++++++ include/hw/virtio/virtio-net.h | 12 ++ include/hw/virtio/virtio.h | 1 + 3 files changed, 315 insertions(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 9f11422337..cccaf77bde 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -12,6 +12,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/atomic.h" #include "qemu/iov.h" #include "qemu/main-loop.h" #include "qemu/module.h" @@ -21,6 +22,10 @@ #include "net/tap.h" #include "qemu/error-report.h" #include "qemu/timer.h" +#include "qemu/option.h" +#include "qemu/option_int.h" +#include "qemu/config-file.h" +#include "qapi/qmp/qdict.h" #include "hw/virtio/virtio-net.h" #include "net/vhost_net.h" #include "net/announce.h" @@ -28,11 +33,15 @@ #include "qapi/error.h" #include "qapi/qapi-events-net.h" #include "hw/qdev-properties.h" +#include "qapi/qapi-types-migration.h" +#include "qapi/qapi-events-migration.h" #include "hw/virtio/virtio-access.h" #include "migration/misc.h" #include "standard-headers/linux/ethtool.h" #include "sysemu/sysemu.h" #include "trace.h" +#include "monitor/qdev.h" +#include "hw/pci/pci.h" =20 #define VIRTIO_NET_VM_VERSION 11 =20 @@ -746,9 +755,99 @@ static inline uint64_t virtio_net_supported_guest_offl= oads(VirtIONet *n) return virtio_net_guest_offloads_by_features(vdev->guest_features); } =20 +static void failover_add_primary(VirtIONet *n, Error **errp) +{ + Error *err =3D NULL; + + n->primary_device_opts =3D qemu_opts_find(qemu_find_opts("device"), + n->primary_device_id); + if (n->primary_device_opts) { + n->primary_dev =3D qdev_device_add(n->primary_device_opts, &err); + if (err) { + qemu_opts_del(n->primary_device_opts); + } + if (n->primary_dev) { + n->primary_bus =3D n->primary_dev->parent_bus; + if (err) { + qdev_unplug(n->primary_dev, &err); + qdev_set_id(n->primary_dev, ""); + + } + } + } else { + error_setg(errp, "Primary device not found"); + error_append_hint(errp, "Virtio-net failover will not work. Make " + "sure primary device has parameter" + " net_failover_pair_id=3D\n"); +} + if (err) { + error_propagate(errp, err); + } +} + +static int is_my_primary(void *opaque, QemuOpts *opts, Error **errp) +{ + VirtIONet *n =3D opaque; + int ret =3D 0; + + const char *standby_id =3D qemu_opt_get(opts, "net_failover_pair_id"); + + if (standby_id !=3D NULL && (g_strcmp0(standby_id, n->netclient_name) = =3D=3D 0)) { + n->primary_device_id =3D g_strdup(opts->id); + ret =3D 1; + } + + return ret; +} + +static DeviceState *virtio_net_find_primary(VirtIONet *n, Error **errp) +{ + DeviceState *dev =3D NULL; + Error *err =3D NULL; + + if (qemu_opts_foreach(qemu_find_opts("device"), + is_my_primary, n, &err)) { + if (err) { + error_propagate(errp, err); + return NULL; + } + if (n->primary_device_id) { + dev =3D qdev_find_recursive(sysbus_get_default(), + n->primary_device_id); + } else { + error_setg(errp, "Primary device id not found"); + return NULL; + } + } + return dev; +} + + + +static DeviceState *virtio_connect_failover_devices(VirtIONet *n, + DeviceState *dev, + Error **errp) +{ + DeviceState *prim_dev =3D NULL; + Error *err =3D NULL; + + prim_dev =3D virtio_net_find_primary(n, &err); + if (prim_dev) { + n->primary_device_id =3D g_strdup(prim_dev->id); + n->primary_device_opts =3D prim_dev->opts; + } else { + if (err) { + error_propagate(errp, err); + } + } + + return prim_dev; +} + static void virtio_net_set_features(VirtIODevice *vdev, uint64_t features) { VirtIONet *n =3D VIRTIO_NET(vdev); + Error *err =3D NULL; int i; =20 if (n->mtu_bypass_backend && @@ -790,6 +889,27 @@ static void virtio_net_set_features(VirtIODevice *vdev= , uint64_t features) } else { memset(n->vlans, 0xff, MAX_VLAN >> 3); } + + if (virtio_has_feature(features, VIRTIO_NET_F_STANDBY)) { + atomic_set(&n->primary_should_be_hidden, false); + failover_add_primary(n, &err); + if (err) { + n->primary_dev =3D virtio_connect_failover_devices(n, n->qdev,= &err); + if (err) { + goto out_err; + } + failover_add_primary(n, &err); + if (err) { + goto out_err; + } + } + } + return; + +out_err: + if (err) { + warn_report_err(err); + } } =20 static int virtio_net_handle_rx_mode(VirtIONet *n, uint8_t cmd, @@ -2630,6 +2750,151 @@ void virtio_net_set_netclient_name(VirtIONet *n, co= nst char *name, n->netclient_type =3D g_strdup(type); } =20 +static bool failover_unplug_primary(VirtIONet *n) +{ + HotplugHandler *hotplug_ctrl; + PCIDevice *pci_dev; + Error *err =3D NULL; + + hotplug_ctrl =3D qdev_get_hotplug_handler(n->primary_dev); + if (hotplug_ctrl) { + pci_dev =3D PCI_DEVICE(n->primary_dev); + pci_dev->partially_hotplugged =3D true; + hotplug_handler_unplug_request(hotplug_ctrl, n->primary_dev, &err); + if (err) { + error_report_err(err); + return false; + } + } else { + return false; + } + return true; +} + +static bool failover_replug_primary(VirtIONet *n, Error **errp) +{ + HotplugHandler *hotplug_ctrl; + PCIDevice *pdev =3D PCI_DEVICE(n->primary_dev); + + if (!pdev->partially_hotplugged) { + return true; + } + if (!n->primary_device_opts) { + n->primary_device_opts =3D qemu_opts_from_qdict( + qemu_find_opts("device"), + n->primary_device_dict, errp); + } + if (n->primary_device_opts) { + if (n->primary_dev) { + n->primary_bus =3D n->primary_dev->parent_bus; + } + qdev_set_parent_bus(n->primary_dev, n->primary_bus); + n->primary_should_be_hidden =3D false; + qemu_opt_set_bool(n->primary_device_opts, + "partially_hotplugged", true, errp); + hotplug_ctrl =3D qdev_get_hotplug_handler(n->primary_dev); + if (hotplug_ctrl) { + hotplug_handler_pre_plug(hotplug_ctrl, n->primary_dev, errp); + hotplug_handler_plug(hotplug_ctrl, n->primary_dev, errp); + } + if (!n->primary_dev) { + error_setg(errp, "virtio_net: couldn't find primary device"); + } + } + return *errp !=3D NULL; +} + +static void virtio_net_handle_migration_primary(VirtIONet *n, + MigrationState *s) +{ + bool should_be_hidden; + Error *err =3D NULL; + + should_be_hidden =3D atomic_read(&n->primary_should_be_hidden); + + if (!n->primary_dev) { + n->primary_dev =3D virtio_connect_failover_devices(n, n->qdev, &er= r); + if (!n->primary_dev) { + return; + } + } + + if (migration_in_setup(s) && !should_be_hidden && + n->primary_dev) { + if (failover_unplug_primary(n)) { + vmstate_unregister(n->primary_dev, qdev_get_vmsd(n->primary_de= v), + n->primary_dev); + qapi_event_send_unplug_primary(n->primary_device_id); + atomic_set(&n->primary_should_be_hidden, true); + } else { + warn_report("couldn't unplug primary device"); + } + } else if (migration_has_failed(s)) { + /* We already unplugged the device let's plugged it back */ + if (!failover_replug_primary(n, &err)) { + if (err) { + error_report_err(err); + } + } + } +} + +static void virtio_net_migration_state_notifier(Notifier *notifier, void *= data) +{ + MigrationState *s =3D data; + VirtIONet *n =3D container_of(notifier, VirtIONet, migration_state); + virtio_net_handle_migration_primary(n, s); +} + +static int virtio_net_primary_should_be_hidden(DeviceListener *listener, + QemuOpts *device_opts) +{ + VirtIONet *n =3D container_of(listener, VirtIONet, primary_listener); + bool match_found; + bool hide; + + n->primary_device_dict =3D qemu_opts_to_qdict(device_opts, + n->primary_device_dict); + if (n->primary_device_dict) { + g_free(n->standby_id); + n->standby_id =3D g_strdup(qdict_get_try_str(n->primary_device_dic= t, + "net_failover_pair_id")); + } + if (device_opts && g_strcmp0(n->standby_id, n->netclient_name) =3D=3D = 0) { + match_found =3D true; + } else { + match_found =3D false; + hide =3D false; + g_free(n->standby_id); + n->primary_device_dict =3D NULL; + warn_report("primary_device_id not found in device options"); + goto out; + } + + n->primary_device_opts =3D device_opts; + + /* primary_should_be_hidden is set during feature negotiation */ + hide =3D atomic_read(&n->primary_should_be_hidden); + + if (n->primary_device_dict) { + g_free(n->primary_device_id); + n->primary_device_id =3D g_strdup(qdict_get_try_str( + n->primary_device_dict, "id")); + if (!n->primary_device_id) { + warn_report("primary_device_id not set"); + } + } + +out: + if (match_found && hide) { + return 1; + } else if (match_found && !hide) { + return 0; + } else { + return -1; + } +} + static void virtio_net_device_realize(DeviceState *dev, Error **errp) { VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); @@ -2660,6 +2925,16 @@ static void virtio_net_device_realize(DeviceState *d= ev, Error **errp) n->host_features |=3D (1ULL << VIRTIO_NET_F_SPEED_DUPLEX); } =20 + if (n->failover) { + n->primary_listener.should_be_hidden =3D + virtio_net_primary_should_be_hidden; + atomic_set(&n->primary_should_be_hidden, true); + device_listener_register(&n->primary_listener); + n->migration_state.notify =3D virtio_net_migration_state_notifier; + add_migration_state_change_notifier(&n->migration_state); + n->host_features |=3D (1ULL << VIRTIO_NET_F_STANDBY); + } + virtio_net_set_config_size(n, n->host_features); virtio_init(vdev, "virtio-net", VIRTIO_ID_NET, n->config_size); =20 @@ -2782,6 +3057,13 @@ static void virtio_net_device_unrealize(DeviceState = *dev, Error **errp) g_free(n->mac_table.macs); g_free(n->vlans); =20 + if (n->failover) { + g_free(n->primary_device_id); + g_free(n->standby_id); + qobject_unref(n->primary_device_dict); + n->primary_device_dict =3D NULL; + } + max_queues =3D n->multiqueue ? n->max_queues : 1; for (i =3D 0; i < max_queues; i++) { virtio_net_del_queue(n, i); @@ -2819,6 +3101,23 @@ static int virtio_net_pre_save(void *opaque) return 0; } =20 +static bool primary_unplug_pending(void *opaque) +{ + DeviceState *dev =3D opaque; + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VirtIONet *n =3D VIRTIO_NET(vdev); + + return n->primary_dev ? n->primary_dev->pending_deleted_event : false; +} + +static bool dev_unplug_pending(void *opaque) +{ + DeviceState *dev =3D opaque; + VirtioDeviceClass *vdc =3D VIRTIO_DEVICE_GET_CLASS(dev); + + return vdc->primary_unplug_pending(dev); +} + static const VMStateDescription vmstate_virtio_net =3D { .name =3D "virtio-net", .minimum_version_id =3D VIRTIO_NET_VM_VERSION, @@ -2828,6 +3127,7 @@ static const VMStateDescription vmstate_virtio_net = =3D { VMSTATE_END_OF_LIST() }, .pre_save =3D virtio_net_pre_save, + .dev_unplug_pending =3D dev_unplug_pending, }; =20 static Property virtio_net_properties[] =3D { @@ -2889,6 +3189,7 @@ static Property virtio_net_properties[] =3D { true), DEFINE_PROP_INT32("speed", VirtIONet, net_conf.speed, SPEED_UNKNOWN), DEFINE_PROP_STRING("duplex", VirtIONet, net_conf.duplex_str), + DEFINE_PROP_BOOL("failover", VirtIONet, failover, false), DEFINE_PROP_END_OF_LIST(), }; =20 @@ -2913,6 +3214,7 @@ static void virtio_net_class_init(ObjectClass *klass,= void *data) vdc->guest_notifier_pending =3D virtio_net_guest_notifier_pending; vdc->legacy_features |=3D (0x1 << VIRTIO_NET_F_GSO); vdc->vmsd =3D &vmstate_virtio_net_device; + vdc->primary_unplug_pending =3D primary_unplug_pending; } =20 static const TypeInfo virtio_net_info =3D { diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index b96f0c643f..3da4ca382a 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -18,6 +18,7 @@ #include "standard-headers/linux/virtio_net.h" #include "hw/virtio/virtio.h" #include "net/announce.h" +#include "qemu/option_int.h" =20 #define TYPE_VIRTIO_NET "virtio-net-device" #define VIRTIO_NET(obj) \ @@ -43,6 +44,7 @@ typedef struct virtio_net_conf int32_t speed; char *duplex_str; uint8_t duplex; + char *primary_id_str; } virtio_net_conf; =20 /* Coalesced packets type & status */ @@ -185,6 +187,16 @@ struct VirtIONet { AnnounceTimer announce_timer; bool needs_vnet_hdr_swap; bool mtu_bypass_backend; + QemuOpts *primary_device_opts; + QDict *primary_device_dict; + DeviceState *primary_dev; + BusState *primary_bus; + char *primary_device_id; + char *standby_id; + bool primary_should_be_hidden; + bool failover; + DeviceListener primary_listener; + Notifier migration_state; }; =20 void virtio_net_set_netclient_name(VirtIONet *n, const char *name, diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 48e8d04ff6..0c857ecf1a 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -159,6 +159,7 @@ typedef struct VirtioDeviceClass { void (*save)(VirtIODevice *vdev, QEMUFile *f); int (*load)(VirtIODevice *vdev, QEMUFile *f, int version_id); const VMStateDescription *vmsd; + bool (*primary_unplug_pending)(void *opaque); } VirtioDeviceClass; =20 void virtio_instance_init_common(Object *proxy_obj, void *data, --=20 2.21.0 From nobody Mon Apr 29 02:12:32 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=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571821151; cv=none; d=zoho.com; s=zohoarc; b=S3av4KtBC3HIOAQmLEcEeFfPy8185hpMBM6vaWORr13k2P6lFv6GMVfu/mxmajD2YR8HhIXwWnNG4BAN0bViQCW0OF0QwlW8aSsRtF8kyLifpmFr18ND/T9yEVdC9x+CMfiNF8ieLup0r/ICTy66IEOX5RnsNoKmdDVDfIP3Rrk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571821151; h=Content-Type: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=QZS+Bpg3A6NPh7e22P/XIvlyKZUB0+Jeal7rH5qYaGI=; b=jn9yvm4XaFSpXWkXJcvRzzbKmlwggXz7+plGnq+/1hZ4kRSHVgsQPrhDSYvl+843Rj8uBiBOpkbg0BPDgzzFHNs1NksCTA3psrtYplgE3guV2sBIcxwz9A6jKbZjIHBE43IGEnX1guJ82IXIpPLQNS2yPvLW4z0dP0Gqttto8SE= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571821151693820.4589529974735; Wed, 23 Oct 2019 01:59:11 -0700 (PDT) Received: from localhost ([::1]:57592 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNCU1-00051R-Ej for importer@patchew.org; Wed, 23 Oct 2019 04:59:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48904) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNC0z-0003eC-Li for qemu-devel@nongnu.org; Wed, 23 Oct 2019 04:29:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNC0x-00077X-LO for qemu-devel@nongnu.org; Wed, 23 Oct 2019 04:29:09 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:26579 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iNC0v-00075c-QH for qemu-devel@nongnu.org; Wed, 23 Oct 2019 04:29:06 -0400 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-86-KYC4yDNGM-OqmCJhnCHPTA-1; Wed, 23 Oct 2019 04:29:01 -0400 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 9C912476; Wed, 23 Oct 2019 08:29:00 +0000 (UTC) Received: from localhost (dhcp-192-217.str.redhat.com [10.33.192.217]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8ADF55C1D4; Wed, 23 Oct 2019 08:28:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571819344; 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=QZS+Bpg3A6NPh7e22P/XIvlyKZUB0+Jeal7rH5qYaGI=; b=QL8yn2OyRmsJ2KrCyb6HyIz2jHjCCLZQ78eShe91BGDzF67qaxHB0FIjRIiZoqMfkqZy6b MyYxgyLvk+x56TGRaHj/c4NtMJtznOOBTjwAHMToqwE+zS+l23E1n1m1AgTBsN6h6gvZ32 ZHBFFK9Vydct7q/LqKdoB2jQBR3GL4s= From: Jens Freimann To: qemu-devel@nongnu.org Subject: [PATCH v5 11/11] vfio: unplug failover primary device before migration Date: Wed, 23 Oct 2019 10:27:11 +0200 Message-Id: <20191023082711.16694-12-jfreimann@redhat.com> In-Reply-To: <20191023082711.16694-1-jfreimann@redhat.com> References: <20191023082711.16694-1-jfreimann@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: KYC4yDNGM-OqmCJhnCHPTA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 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: pkrempa@redhat.com, berrange@redhat.com, ehabkost@redhat.com, mst@redhat.com, aadam@redhat.com, dgilbert@redhat.com, alex.williamson@redhat.com, laine@redhat.com, ailan@redhat.com, parav@mellanox.com 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" As usual block all vfio-pci devices from being migrated, but make an exception for failover primary devices. This is achieved by setting unmigratable to 0 but also add a migration blocker for all vfio-pci devices except failover primary devices. These will be unplugged before migration happens by the migration handler of the corresponding virtio-net standby device. Signed-off-by: Jens Freimann Acked-by: Alex Williamson --- hw/vfio/pci.c | 26 ++++++++++++++++++++------ hw/vfio/pci.h | 1 + 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 12fac39804..5dadfec6e8 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -40,6 +40,7 @@ #include "pci.h" #include "trace.h" #include "qapi/error.h" +#include "migration/blocker.h" =20 #define TYPE_VFIO_PCI "vfio-pci" #define PCI_VFIO(obj) OBJECT_CHECK(VFIOPCIDevice, obj, TYPE_VFIO_PCI) @@ -2732,6 +2733,17 @@ static void vfio_realize(PCIDevice *pdev, Error **er= rp) return; } =20 + if (!pdev->net_failover_pair_id) { + error_setg(&vdev->migration_blocker, + "VFIO device doesn't support migration"); + ret =3D migrate_add_blocker(vdev->migration_blocker, &err); + if (err) { + error_propagate(errp, err); + error_free(vdev->migration_blocker); + return; + } + } + vdev->vbasedev.name =3D g_path_get_basename(vdev->vbasedev.sysfsdev); vdev->vbasedev.ops =3D &vfio_pci_ops; vdev->vbasedev.type =3D VFIO_DEVICE_TYPE_PCI; @@ -3008,6 +3020,10 @@ out_teardown: vfio_bars_exit(vdev); error: error_prepend(errp, VFIO_MSG_PREFIX, vdev->vbasedev.name); + if (vdev->migration_blocker) { + migrate_del_blocker(vdev->migration_blocker); + error_free(vdev->migration_blocker); + } } =20 static void vfio_instance_finalize(Object *obj) @@ -3019,6 +3035,10 @@ static void vfio_instance_finalize(Object *obj) vfio_bars_finalize(vdev); g_free(vdev->emulated_config_bits); g_free(vdev->rom); + if (vdev->migration_blocker) { + migrate_del_blocker(vdev->migration_blocker); + error_free(vdev->migration_blocker); + } /* * XXX Leaking igd_opregion is not an oversight, we can't remove the * fw_cfg entry therefore leaking this allocation seems like the safest @@ -3151,11 +3171,6 @@ static Property vfio_pci_dev_properties[] =3D { DEFINE_PROP_END_OF_LIST(), }; =20 -static const VMStateDescription vfio_pci_vmstate =3D { - .name =3D "vfio-pci", - .unmigratable =3D 1, -}; - static void vfio_pci_dev_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); @@ -3163,7 +3178,6 @@ static void vfio_pci_dev_class_init(ObjectClass *klas= s, void *data) =20 dc->reset =3D vfio_pci_reset; dc->props =3D vfio_pci_dev_properties; - dc->vmsd =3D &vfio_pci_vmstate; dc->desc =3D "VFIO-based PCI device assignment"; set_bit(DEVICE_CATEGORY_MISC, dc->categories); pdc->realize =3D vfio_realize; diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h index 834a90d646..b329d50338 100644 --- a/hw/vfio/pci.h +++ b/hw/vfio/pci.h @@ -168,6 +168,7 @@ typedef struct VFIOPCIDevice { bool no_vfio_ioeventfd; bool enable_ramfb; VFIODisplay *dpy; + Error *migration_blocker; } VFIOPCIDevice; =20 uint32_t vfio_pci_read_config(PCIDevice *pdev, uint32_t addr, int len); --=20 2.21.0