From nobody Tue May 21 05:14:26 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=oracle.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1546900344288926.7001088307106; Mon, 7 Jan 2019 14:32:24 -0800 (PST) Received: from localhost ([127.0.0.1]:50980 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggdRU-0006C2-SO for importer@patchew.org; Mon, 07 Jan 2019 17:32:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39210) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggdPK-0004jB-6H for qemu-devel@nongnu.org; Mon, 07 Jan 2019 17:30:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ggdPJ-00044I-Fj for qemu-devel@nongnu.org; Mon, 07 Jan 2019 17:30:06 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:43666) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ggdPJ-00043i-8S for qemu-devel@nongnu.org; Mon, 07 Jan 2019 17:30:05 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x07MJJpj113531; Mon, 7 Jan 2019 22:30:02 GMT Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2ptm0u0exg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 07 Jan 2019 22:30:02 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x07MU0Ek015019 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 7 Jan 2019 22:30:01 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x07MU0mW018553; Mon, 7 Jan 2019 22:30:00 GMT Received: from ban25x6uut28.us.oracle.com (/10.153.73.28) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 07 Jan 2019 14:30:00 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=9yNkGO3ScnTJ9C7Z3b4BimoHgvKXa+MGstp/F/AQpvM=; b=WKSSOqF8kb0aHDt6rE5gaEGHeWgb+Ur7nIDevMS6nIR76i+tfPeGTD5eR/VCYY7fJxoH pSmmuWHK/lwpgiGfbttyAfz0gjqW8g+6/iwh3797ohUK8XiuZ7H+gSssoGwfyIlmkZVo 237ruR/wj1wo8XvZ9TYHHyVX75woJhZyArdf9Za88/hNGKIuwYYhQDXswgMmRH8NAYOc B/atVSQv3/9kBTo+tNBgSqBm2Sipo61eWpksHM27e+qNvkiSVZtyXTA1lbN7O/p9yGEa h3BmUM7YYCHg7jfV3GP1KffVMvSewzH9J6rohfBh+ggtWSS5ilPHrUEPzeZsY0oCoZHM +g== From: Venu Busireddy To: venu.busireddy@oracle.com, "Michael S. Tsirkin" , Marcel Apfelbaum Date: Mon, 7 Jan 2019 17:29:40 -0500 Message-Id: <1546900184-27403-2-git-send-email-venu.busireddy@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1546900184-27403-1-git-send-email-venu.busireddy@oracle.com> References: <1546900184-27403-1-git-send-email-venu.busireddy@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9129 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901070183 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [PATCH v3 1/5] virtio_net: Add VIRTIO_NET_F_STANDBY feature bit. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sridhar Samudrala , qemu-devel@nongnu.org, virtio-dev@lists.oasis-open.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Sridhar Samudrala This feature bit can be used by a hypervisor to indicate to the virtio_net device that it can act as a standby for another device with the same MAC address. Signed-off-by: Sridhar Samudrala Signed-off-by: Venu Busireddy --- hw/net/virtio-net.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 385b1a0..411f8fb 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -2198,6 +2198,8 @@ 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_BIT64("standby", VirtIONet, host_features, VIRTIO_NET_F_ST= ANDBY, + false), DEFINE_PROP_END_OF_LIST(), }; =20 From nobody Tue May 21 05:14:26 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=oracle.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1546900390339878.6155738268651; Mon, 7 Jan 2019 14:33:10 -0800 (PST) Received: from localhost ([127.0.0.1]:51157 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggdSG-0006tS-M2 for importer@patchew.org; Mon, 07 Jan 2019 17:33:08 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39498) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggdPq-0005L3-3r for qemu-devel@nongnu.org; Mon, 07 Jan 2019 17:30:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ggdPl-00050d-Fc for qemu-devel@nongnu.org; Mon, 07 Jan 2019 17:30:38 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:43824) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ggdPl-0004Ds-3S for qemu-devel@nongnu.org; Mon, 07 Jan 2019 17:30:33 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x07MIflB113285; Mon, 7 Jan 2019 22:30:12 GMT Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2ptm0u0eyn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 07 Jan 2019 22:30:12 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x07MU5nX015989 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 7 Jan 2019 22:30:06 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x07MU52o018618; Mon, 7 Jan 2019 22:30:05 GMT Received: from ban25x6uut28.us.oracle.com (/10.153.73.28) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 07 Jan 2019 14:30:05 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=LKkRDXabacVMKHOdqfYZYSIzQWrGPVXtqIBuchM7XyY=; b=NMiBEKyNPIyzPXUoaKteQKnNwv6DbZbIDF3gxXTROzzP4dnls6TcX3ZwND70CCIbsWSr 9i4kQHqZ66fmhNc29NxHT30PAOQJ50fmfbmZJBoP/weXoczlq+AE2ZOo/FCnK9XW6Tmv 2UbT2TDTsRdsvGeUKe23nEvVkVbCcemTDV2AYWQf19zFYDe0wuEm1STzKBTHJnF9XBdN 6wNVdeV6TM5bIBu26zpoU6oPdGKJnOGUKTYv2H69DMxjtEyl47knNbSN1YIouQs7zmKH QLKeOQ7QtvLAgCt7F1wMiNbQ1uxEjK45O7q2fPSts4U4d25b13Y/UBpwWXgFInd9U0a5 Ug== From: Venu Busireddy To: venu.busireddy@oracle.com, "Michael S. Tsirkin" , Marcel Apfelbaum Date: Mon, 7 Jan 2019 17:29:41 -0500 Message-Id: <1546900184-27403-3-git-send-email-venu.busireddy@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1546900184-27403-1-git-send-email-venu.busireddy@oracle.com> References: <1546900184-27403-1-git-send-email-venu.busireddy@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9129 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901070183 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [PATCH v3 2/5] virtio_net: Add support for "Data Path Switching" during Live Migration. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: virtio-dev@lists.oasis-open.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Added a new event, FAILOVER_STANDBY_CHANGED, which is emitted whenever the status of the virtio_net driver in the guest changes (either the guest successfully loads the driver after the F_STANDBY feature bit is negotiated, or the guest unloads the driver or reboots). Management stack can use this event to determine when to plug/unplug the VF device to/from the guest. Also, the Virtual Functions will be automatically removed from the guest if the guest is rebooted. To properly identify the VFIO devices that must be removed, a new property named "failover-primary" is added to the vfio-pci devices. Only the vfio-pci devices that have this property enabled are removed from the guest upon reboot. Signed-off-by: Venu Busireddy --- hw/acpi/pcihp.c | 27 +++++++++++++++++++++++++++ hw/net/virtio-net.c | 24 ++++++++++++++++++++++++ hw/vfio/pci.c | 3 +++ hw/vfio/pci.h | 1 + include/hw/pci/pci.h | 1 + qapi/net.json | 28 ++++++++++++++++++++++++++++ 6 files changed, 84 insertions(+) diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c index 80d42e1..2a3ffd3 100644 --- a/hw/acpi/pcihp.c +++ b/hw/acpi/pcihp.c @@ -176,6 +176,25 @@ static void acpi_pcihp_eject_slot(AcpiPciHpState *s, u= nsigned bsel, unsigned slo } } =20 +static void acpi_pcihp_cleanup_failover_primary(AcpiPciHpState *s, int bse= l) +{ + BusChild *kid, *next; + PCIBus *bus =3D acpi_pcihp_find_hotplug_bus(s, bsel); + + if (!bus) { + return; + } + QTAILQ_FOREACH_SAFE(kid, &bus->qbus.children, sibling, next) { + DeviceState *qdev =3D kid->child; + PCIDevice *pdev =3D PCI_DEVICE(qdev); + int slot =3D PCI_SLOT(pdev->devfn); + + if (pdev->failover_primary) { + s->acpi_pcihp_pci_status[bsel].down |=3D (1U << slot); + } + } +} + static void acpi_pcihp_update_hotplug_bus(AcpiPciHpState *s, int bsel) { BusChild *kid, *next; @@ -207,6 +226,14 @@ static void acpi_pcihp_update(AcpiPciHpState *s) int i; =20 for (i =3D 0; i < ACPI_PCIHP_MAX_HOTPLUG_BUS; ++i) { + /* + * Set the acpi_pcihp_pci_status[].down bits of all the + * failover_primary devices so that the devices are ejected + * from the guest. We can't use the qdev_unplug() as well as the + * hotplug_handler to unplug the devices, because the guest may + * not be in a state to cooperate. + */ + acpi_pcihp_cleanup_failover_primary(s, i); acpi_pcihp_update_hotplug_bus(s, i); } } diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 411f8fb..7b1bcde 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -248,6 +248,29 @@ static void virtio_net_drop_tx_queue_data(VirtIODevice= *vdev, VirtQueue *vq) } } =20 +static void virtio_net_failover_notify_event(VirtIONet *n, uint8_t status) +{ + VirtIODevice *vdev =3D VIRTIO_DEVICE(n); + + if (virtio_has_feature(vdev->guest_features, VIRTIO_NET_F_STANDBY)) { + const char *ncn =3D n->netclient_name; + gchar *path =3D object_get_canonical_path(OBJECT(n->qdev)); + /* + * Emit FAILOVER_STANDBY_CHANGED event with enabled=3Dtrue + * when the status transitions from 0 to VIRTIO_CONFIG_S_DRIVER_= OK + * Emit FAILOVER_STANDBY_CHANGED event with enabled=3Dfalse + * when the status transitions from VIRTIO_CONFIG_S_DRIVER_OK to= 0 + */ + if ((status & VIRTIO_CONFIG_S_DRIVER_OK) && + (!(vdev->status & VIRTIO_CONFIG_S_DRIVER_OK))) { + qapi_event_send_failover_standby_changed(!!ncn, ncn, path, tru= e); + } else if ((!(status & VIRTIO_CONFIG_S_DRIVER_OK)) && + (vdev->status & VIRTIO_CONFIG_S_DRIVER_OK)) { + qapi_event_send_failover_standby_changed(!!ncn, ncn, path, fal= se); + } + } +} + static void virtio_net_set_status(struct VirtIODevice *vdev, uint8_t statu= s) { VirtIONet *n =3D VIRTIO_NET(vdev); @@ -256,6 +279,7 @@ static void virtio_net_set_status(struct VirtIODevice *= vdev, uint8_t status) uint8_t queue_status; =20 virtio_net_vnet_endian_status(n, status); + virtio_net_failover_notify_event(n, status); virtio_net_vhost_status(n, status); =20 for (i =3D 0; i < n->max_queues; i++) { diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 5c7bd96..bd83b58 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -3077,6 +3077,7 @@ static void vfio_realize(PCIDevice *pdev, Error **err= p) vfio_register_err_notifier(vdev); vfio_register_req_notifier(vdev); vfio_setup_resetfn_quirk(vdev); + pdev->failover_primary =3D vdev->failover_primary; =20 return; =20 @@ -3219,6 +3220,8 @@ static Property vfio_pci_dev_properties[] =3D { qdev_prop_nv_gpudirect_clique, uint8_t), DEFINE_PROP_OFF_AUTO_PCIBAR("x-msix-relocation", VFIOPCIDevice, msix_r= elo, OFF_AUTOPCIBAR_OFF), + DEFINE_PROP_BOOL("failover-primary", VFIOPCIDevice, failover_primary, + false), /* * TODO - support passed fds... is this necessary? * DEFINE_PROP_STRING("vfiofd", VFIOPCIDevice, vfiofd_name), diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h index b1ae4c0..06ca661 100644 --- a/hw/vfio/pci.h +++ b/hw/vfio/pci.h @@ -167,6 +167,7 @@ typedef struct VFIOPCIDevice { bool no_vfio_ioeventfd; bool enable_ramfb; VFIODisplay *dpy; + bool failover_primary; } VFIOPCIDevice; =20 uint32_t vfio_pci_read_config(PCIDevice *pdev, uint32_t addr, int len); diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index e6514bb..b0111d1 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -351,6 +351,7 @@ struct PCIDevice { MSIVectorUseNotifier msix_vector_use_notifier; MSIVectorReleaseNotifier msix_vector_release_notifier; MSIVectorPollNotifier msix_vector_poll_notifier; + bool failover_primary; }; =20 void pci_register_bar(PCIDevice *pci_dev, int region_num, diff --git a/qapi/net.json b/qapi/net.json index 8f99fd9..6a6d6fe 100644 --- a/qapi/net.json +++ b/qapi/net.json @@ -683,3 +683,31 @@ ## { 'event': 'NIC_RX_FILTER_CHANGED', 'data': { '*name': 'str', 'path': 'str' } } + +## +# @FAILOVER_STANDBY_CHANGED: +# +# Emitted whenever the virtio_net driver status changes (either the guest +# successfully loads the driver after the F_STANDBY feature bit is negotia= ted, +# or the guest unloads the driver or reboots). +# +# @device: Indicates the virtio_net device. +# +# @path: Indicates the device path. +# +# @enabled: true if the virtio_net driver is loaded. +# false if the virtio_net driver is unloaded or the guest reboot= s. +# +# Since: 4.0 +# +# Example: +# +# <- { "event": "FAILOVER_STANDBY_CHANGED", +# "data": { "device": "net0", +# "path": "/machine/peripheral/net0/virtio-backend", +# "enabled": "true" }, +# "timestamp": { "seconds": 1432121972, "microseconds": 744001 } }, +# +## +{ 'event': 'FAILOVER_STANDBY_CHANGED', + 'data': {'*device': 'str', 'path': 'str', 'enabled': 'bool'} } From nobody Tue May 21 05:14:26 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=oracle.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1546900724573737.9301432998279; Mon, 7 Jan 2019 14:38:44 -0800 (PST) Received: from localhost ([127.0.0.1]:52313 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggdXa-00036q-Ve for importer@patchew.org; Mon, 07 Jan 2019 17:38:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39388) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggdPm-0005IH-Qi for qemu-devel@nongnu.org; Mon, 07 Jan 2019 17:30:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ggdPl-0004z0-7A for qemu-devel@nongnu.org; Mon, 07 Jan 2019 17:30:34 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:36520) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ggdPg-0004Ng-OQ for qemu-devel@nongnu.org; Mon, 07 Jan 2019 17:30:31 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x07MIjA6070732; Mon, 7 Jan 2019 22:30:17 GMT Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2ptn7qr9d2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 07 Jan 2019 22:30:17 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x07MUBhO016386 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 7 Jan 2019 22:30:11 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x07MUAMQ004905; Mon, 7 Jan 2019 22:30:11 GMT Received: from ban25x6uut28.us.oracle.com (/10.153.73.28) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 07 Jan 2019 14:30:10 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=U5N2p965rTu4s6uMd8/7gDpKrNQrFbJ+f8IIj/8KhAg=; b=uWxuVOWkS4l1WZ3lFls1aXx7WuCidjpFy0JLtxWTJyd8RzUbOq4Svhx7QD2U1LCSgF7a daNyL4GjWgUJ27zEJJ8sjjPfA9SCX9aZmjRvr4CbODprM/izEbzqLvgJRB7rFqZzxwg6 whDynS94wMgEq5t1Xt9aTJazbKvJyvQcABpP6az/k+ytq5iD599J8yoFCNw0X/HPBVoj EwUgM83g6TQ0ZHNpwPPt+86K8iwDIFcBqZ6N1lun6QaEM/eJTIW0pEMltpaaAOiKVOgs TRiZU7afdqNDCeYqB2pUmuOTd5cbNwDGK+IeH/aWP/go2zO/phgpsYDGm2X82NzvuOyT wA== From: Venu Busireddy To: venu.busireddy@oracle.com, "Michael S. Tsirkin" , Marcel Apfelbaum Date: Mon, 7 Jan 2019 17:29:42 -0500 Message-Id: <1546900184-27403-4-git-send-email-venu.busireddy@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1546900184-27403-1-git-send-email-venu.busireddy@oracle.com> References: <1546900184-27403-1-git-send-email-venu.busireddy@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9129 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901070183 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [PATCH v3 3/5] virtio_net: Add a query command for FAILOVER_STANDBY_CHANGED event. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: virtio-dev@lists.oasis-open.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add a query command to check the status of the FAILOVER_STANDBY_CHANGED state of the virtio_net devices. Signed-off-by: Venu Busireddy --- hw/net/virtio-net.c | 16 +++++++++++ include/hw/virtio/virtio-net.h | 1 + include/net/net.h | 2 ++ net/net.c | 61 ++++++++++++++++++++++++++++++++++++++= ++++ qapi/net.json | 46 +++++++++++++++++++++++++++++++ 5 files changed, 126 insertions(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 7b1bcde..a4e07ac 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -263,9 +263,11 @@ static void virtio_net_failover_notify_event(VirtIONet= *n, uint8_t status) */ if ((status & VIRTIO_CONFIG_S_DRIVER_OK) && (!(vdev->status & VIRTIO_CONFIG_S_DRIVER_OK))) { + n->standby_enabled =3D true; qapi_event_send_failover_standby_changed(!!ncn, ncn, path, tru= e); } else if ((!(status & VIRTIO_CONFIG_S_DRIVER_OK)) && (vdev->status & VIRTIO_CONFIG_S_DRIVER_OK)) { + n->standby_enabled =3D false; qapi_event_send_failover_standby_changed(!!ncn, ncn, path, fal= se); } } @@ -448,6 +450,19 @@ static RxFilterInfo *virtio_net_query_rxfilter(NetClie= ntState *nc) return info; } =20 +static StandbyStatusInfo *virtio_net_query_standby_status(NetClientState *= nc) +{ + StandbyStatusInfo *info; + VirtIONet *n =3D qemu_get_nic_opaque(nc); + + info =3D g_malloc0(sizeof(*info)); + info->device =3D g_strdup(n->netclient_name); + info->path =3D g_strdup(object_get_canonical_path(OBJECT(n->qdev))); + info->enabled =3D n->standby_enabled; + + return info; +} + static void virtio_net_reset(VirtIODevice *vdev) { VirtIONet *n =3D VIRTIO_NET(vdev); @@ -1923,6 +1938,7 @@ static NetClientInfo net_virtio_info =3D { .receive =3D virtio_net_receive, .link_status_changed =3D virtio_net_set_link_status, .query_rx_filter =3D virtio_net_query_rxfilter, + .query_standby_status =3D virtio_net_query_standby_status, }; =20 static bool virtio_net_guest_notifier_pending(VirtIODevice *vdev, int idx) diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index 4d7f3c8..9071e96 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -103,6 +103,7 @@ typedef struct VirtIONet { int announce_counter; bool needs_vnet_hdr_swap; bool mtu_bypass_backend; + bool standby_enabled; } VirtIONet; =20 void virtio_net_set_netclient_name(VirtIONet *n, const char *name, diff --git a/include/net/net.h b/include/net/net.h index ec13702..61e8513 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -50,6 +50,7 @@ typedef void (NetCleanup) (NetClientState *); typedef void (LinkStatusChanged)(NetClientState *); typedef void (NetClientDestructor)(NetClientState *); typedef RxFilterInfo *(QueryRxFilter)(NetClientState *); +typedef StandbyStatusInfo *(QueryStandbyStatus)(NetClientState *); typedef bool (HasUfo)(NetClientState *); typedef bool (HasVnetHdr)(NetClientState *); typedef bool (HasVnetHdrLen)(NetClientState *, int); @@ -71,6 +72,7 @@ typedef struct NetClientInfo { NetCleanup *cleanup; LinkStatusChanged *link_status_changed; QueryRxFilter *query_rx_filter; + QueryStandbyStatus *query_standby_status; NetPoll *poll; HasUfo *has_ufo; HasVnetHdr *has_vnet_hdr; diff --git a/net/net.c b/net/net.c index 1f7d626..fbf288e 100644 --- a/net/net.c +++ b/net/net.c @@ -1320,6 +1320,67 @@ RxFilterInfoList *qmp_query_rx_filter(bool has_name,= const char *name, return filter_list; } =20 +StandbyStatusInfoList *qmp_query_standby_status(bool has_device, + const char *device, + Error **errp) +{ + NetClientState *nc; + StandbyStatusInfoList *status_list =3D NULL, *last_entry =3D NULL; + + QTAILQ_FOREACH(nc, &net_clients, next) { + StandbyStatusInfoList *entry; + StandbyStatusInfo *info; + + if (has_device && strcmp(nc->name, device) !=3D 0) { + continue; + } + + /* only query standby status information of NIC */ + if (nc->info->type !=3D NET_CLIENT_DRIVER_NIC) { + if (has_device) { + error_setg(errp, "net client(%s) isn't a NIC", device); + return NULL; + } + continue; + } + + /* + * only query information on queue 0 since the info is per nic, + * not per queue. + */ + if (nc->queue_index !=3D 0) { + continue; + } + + if (nc->info->query_standby_status) { + info =3D nc->info->query_standby_status(nc); + entry =3D g_malloc0(sizeof(*entry)); + entry->value =3D info; + + if (!status_list) { + status_list =3D entry; + } else { + last_entry->next =3D entry; + } + last_entry =3D entry; + } else if (has_device) { + error_setg(errp, "net client(%s) doesn't support" + " standby status querying", device); + return NULL; + } + + if (has_device) { + break; + } + } + + if (status_list =3D=3D NULL && has_device) { + error_setg(errp, "invalid net client name: %s", device); + } + + return status_list; +} + void hmp_info_network(Monitor *mon, const QDict *qdict) { NetClientState *nc, *peer; diff --git a/qapi/net.json b/qapi/net.json index 6a6d6fe..633ac87 100644 --- a/qapi/net.json +++ b/qapi/net.json @@ -711,3 +711,49 @@ ## { 'event': 'FAILOVER_STANDBY_CHANGED', 'data': {'*device': 'str', 'path': 'str', 'enabled': 'bool'} } + +## +# @StandbyStatusInfo: +# +# Standby status information for a virtio_net device. +# +# @device: Indicates the virtio_net device. +# +# @path: Indicates the device path. +# +# @enabled: true if the virtio_net driver is loaded. +# false if the virtio_net driver is unloaded or the guest reboot= ed. +# +# Since: 4.0 +## +{ 'struct': 'StandbyStatusInfo', + 'data': {'device': 'str', 'path': 'str', 'enabled': 'bool'} } + +## +# @query-standby-status: +# +# Return Standby status information for all virtio_net devices, +# or for the given virtio_net device. +# +# @device: Name of the virtio_net device. +# +# Returns: List of @StandbyStatusInfo for all virtio_net devices, +# or for the given virtio_net device. +# Returns an error if the given @device doesn't exist. +# +# Since: 4.0 +# +# Example: +# +# -> { "execute": "query-standby-status", "arguments": { "device": "net0" = } } +# <- { "return": [ +# { 'device': 'net0', +# 'path': '/machine/peripheral/net0/virtio-backend', +# 'enabled': 'true' +# } +# ] +# } +# +## +{ 'command': 'query-standby-status', 'data': { '*device': 'str' }, + 'returns': ['StandbyStatusInfo'] } From nobody Tue May 21 05:14:26 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=oracle.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1546900445323957.844178058271; Mon, 7 Jan 2019 14:34:05 -0800 (PST) Received: from localhost ([127.0.0.1]:51320 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggdT9-0007Te-O8 for importer@patchew.org; Mon, 07 Jan 2019 17:34:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39467) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggdPo-0005Jl-Qy for qemu-devel@nongnu.org; Mon, 07 Jan 2019 17:30:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ggdPl-00050p-HC for qemu-devel@nongnu.org; Mon, 07 Jan 2019 17:30:36 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:54880) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ggdPl-0004OV-7F for qemu-devel@nongnu.org; Mon, 07 Jan 2019 17:30:33 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x07MJ7gc065781; Mon, 7 Jan 2019 22:30:18 GMT Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2130.oracle.com with ESMTP id 2ptj3drmq3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 07 Jan 2019 22:30:18 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x07MUHBH016803 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 7 Jan 2019 22:30:17 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x07MUGYc004925; Mon, 7 Jan 2019 22:30:17 GMT Received: from ban25x6uut28.us.oracle.com (/10.153.73.28) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 07 Jan 2019 14:30:16 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=GYSSbM2dP/ffT9saV7ZsC9XarM+4zqBgClXC9DaD8YE=; b=ZOWgpyTLfvwFA/jgPqdg2IhG+9VUWxfTJgxdse1M8myQB/jhzp4dPVPAJB9i5WQCaBNr sWULaDhTPz4c5C/KuhegUTAf7Q5xkmdTUxjXf68rHJlITa3/t5SYgj8aWoutdRNWMKhx 3MA/cTFHO9k6jJZyXdkKUj8ABQXEA6gs0PEbXwyQ8mNE3CvwzsGMdb//U3b7JEhNrnhP g1w5ZKTBpWNX9oEEVu5wmTKGlDcTMrdBcVjbIvLy28g2d9Op88ZbpVK4G8Db714d0slE qf192TEGzreWltPrdUp11EP1Mx09NttPJT5Xzbp+rTA/TRtyW0MMkzEnPlP+GVmOoP3f Pw== From: Venu Busireddy To: venu.busireddy@oracle.com, "Michael S. Tsirkin" , Marcel Apfelbaum Date: Mon, 7 Jan 2019 17:29:43 -0500 Message-Id: <1546900184-27403-5-git-send-email-venu.busireddy@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1546900184-27403-1-git-send-email-venu.busireddy@oracle.com> References: <1546900184-27403-1-git-send-email-venu.busireddy@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9129 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901070183 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.79 Subject: [Qemu-devel] [PATCH v3 4/5] vfio-pci: Add FAILOVER_PRIMARY_CHANGED event to shorten downtime during failover X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Si-Wei Liu , virtio-dev@lists.oasis-open.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Si-Wei Liu When a VF is hotplugged into the guest, datapath switching will be performed immediately, which is sub-optimal in terms of timing, and could end up with substantial network downtime. One of ways to shorten this downtime is to switch the datapath only after the VF is seen to get enabled by guest, indicated by the bus master bit in VF's PCI config space getting enabled. The FAILOVER_PRIMARY_CHANGED event is emitted at that time to indicate this condition. Then management stack can kick off datapath switching upon receiving the event. Signed-off-by: Si-Wei Liu Signed-off-by: Venu Busireddy --- hw/vfio/pci.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++= ++ qapi/net.json | 26 ++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index bd83b58..adcc95a 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -34,6 +34,7 @@ #include "pci.h" #include "trace.h" #include "qapi/error.h" +#include "qapi/qapi-events-net.h" =20 #define MSIX_CAP_LENGTH 12 =20 @@ -42,6 +43,7 @@ =20 static void vfio_disable_interrupts(VFIOPCIDevice *vdev); static void vfio_mmap_set_enabled(VFIOPCIDevice *vdev, bool enabled); +static void vfio_failover_notify(VFIOPCIDevice *vdev, bool status); =20 /* * Disabling BAR mmaping can be slow, but toggling it around INTx can @@ -1170,6 +1172,8 @@ void vfio_pci_write_config(PCIDevice *pdev, { VFIOPCIDevice *vdev =3D PCI_VFIO(pdev); uint32_t val_le =3D cpu_to_le32(val); + bool may_notify =3D false; + bool master_was =3D false; =20 trace_vfio_pci_write_config(vdev->vbasedev.name, addr, val, len); =20 @@ -1180,6 +1184,14 @@ void vfio_pci_write_config(PCIDevice *pdev, __func__, vdev->vbasedev.name, addr, val, len); } =20 + /* Bus Master Enabling/Disabling */ + if (pdev->failover_primary && current_cpu && + range_covers_byte(addr, len, PCI_COMMAND)) { + master_was =3D !!(pci_get_word(pdev->config + PCI_COMMAND) & + PCI_COMMAND_MASTER); + may_notify =3D true; + } + /* MSI/MSI-X Enabling/Disabling */ if (pdev->cap_present & QEMU_PCI_CAP_MSI && ranges_overlap(addr, len, pdev->msi_cap, vdev->msi_cap_size)) { @@ -1235,6 +1247,14 @@ void vfio_pci_write_config(PCIDevice *pdev, /* Write everything to QEMU to keep emulated bits correct */ pci_default_write_config(pdev, addr, val, len); } + + if (may_notify) { + bool master_now =3D !!(pci_get_word(pdev->config + PCI_COMMAND) & + PCI_COMMAND_MASTER); + if (master_was !=3D master_now) { + vfio_failover_notify(vdev, master_now); + } + } } =20 /* @@ -2801,6 +2821,17 @@ static void vfio_unregister_req_notifier(VFIOPCIDevi= ce *vdev) vdev->req_enabled =3D false; } =20 +static void vfio_failover_notify(VFIOPCIDevice *vdev, bool status) +{ + PCIDevice *pdev =3D &vdev->pdev; + const char *n; + gchar *path; + + n =3D pdev->qdev.id ? pdev->qdev.id : vdev->vbasedev.name; + path =3D object_get_canonical_path(OBJECT(vdev)); + qapi_event_send_failover_primary_changed(!!n, n, path, status); +} + static void vfio_realize(PCIDevice *pdev, Error **errp) { VFIOPCIDevice *vdev =3D PCI_VFIO(pdev); @@ -3109,10 +3140,36 @@ static void vfio_instance_finalize(Object *obj) vfio_put_group(group); } =20 +static void vfio_exit_failover_notify(VFIOPCIDevice *vdev) +{ + PCIDevice *pdev =3D &vdev->pdev; + + /* + * Guest driver may not get the chance to disable bus mastering + * before the device object gets to be unrealized. In that event, + * send out a "disabled" notification on behalf of guest driver. + */ + if (pdev->failover_primary && + pdev->bus_master_enable_region.enabled) { + vfio_failover_notify(vdev, false); + } +} + static void vfio_exitfn(PCIDevice *pdev) { VFIOPCIDevice *vdev =3D PCI_VFIO(pdev); =20 + /* + * During the guest reboot sequence, it is sometimes possible that + * the guest may not get sufficient time to complete the entire driver + * removal sequence, near the end of which a PCI config space write to + * disable bus mastering can be intercepted by device. In such cases, + * the FAILOVER_PRIMARY_CHANGED "disable" event will not be emitted. It + * is imperative to generate the event on the guest's behalf if the + * guest fails to make it. + */ + vfio_exit_failover_notify(vdev); + vfio_unregister_req_notifier(vdev); vfio_unregister_err_notifier(vdev); pci_device_set_intx_routing_notifier(&vdev->pdev, NULL); diff --git a/qapi/net.json b/qapi/net.json index 633ac87..a5b8d70 100644 --- a/qapi/net.json +++ b/qapi/net.json @@ -757,3 +757,29 @@ ## { 'command': 'query-standby-status', 'data': { '*device': 'str' }, 'returns': ['StandbyStatusInfo'] } + +## +# @FAILOVER_PRIMARY_CHANGED: +# +# Emitted whenever the driver of failover primary is loaded or unloaded +# by the guest. +# +# @device: device name +# +# @path: device path +# +# @enabled: true if driver is loaded thus device is enabled in guest +# +# Since: 3.0 +# +# Example: +# +# <- { "event": "FAILOVER_PRIMARY_CHANGED", +# "data": { "device": "vfio-0", +# "path": "/machine/peripheral/vfio-0" }, +# "enabled": "true" }, +# "timestamp": { "seconds": 1539935213, "microseconds": 753529 } } +# +## +{ 'event': 'FAILOVER_PRIMARY_CHANGED', + 'data': { '*device': 'str', 'path': 'str', 'enabled': 'bool' } } From nobody Tue May 21 05:14:26 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=oracle.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1546900553866801.9011929461807; Mon, 7 Jan 2019 14:35:53 -0800 (PST) Received: from localhost ([127.0.0.1]:51731 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggdUu-0000j3-6L for importer@patchew.org; Mon, 07 Jan 2019 17:35:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39386) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggdPm-0005IG-Q7 for qemu-devel@nongnu.org; Mon, 07 Jan 2019 17:30:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ggdPl-00050C-DW for qemu-devel@nongnu.org; Mon, 07 Jan 2019 17:30:34 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:36644) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ggdPl-0004YH-1R for qemu-devel@nongnu.org; Mon, 07 Jan 2019 17:30:33 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x07MIhxn070722; Mon, 7 Jan 2019 22:30:23 GMT Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2120.oracle.com with ESMTP id 2ptn7qr9dh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 07 Jan 2019 22:30:23 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x07MUMNB001816 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 7 Jan 2019 22:30:22 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x07MUM27010535; Mon, 7 Jan 2019 22:30:22 GMT Received: from ban25x6uut28.us.oracle.com (/10.153.73.28) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 07 Jan 2019 14:30:22 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=7aTwapqUJp8TAE107BG7YNxfp8aFak6XrepdzSJl7hQ=; b=aS7ccKV0g7R1woUPEYPMLqtFkC9XXOCRcFoF5eFYEu37MnEaS64nsWAeDCMoqSGsJtgW /5F2Ya4C2M+Zc0u8/4S0RBFWUu0+9jf2zkoZCVBB1Adn3ZG/mzqUvkP0tbA+CxFMD1BY S4E3GSOTMXOAPZzplgHeTYjw1B6ZkN7WfphVz7LQ8DrRRzOpsSj2zsx01AEJlTmAUZCm XjZ30C4Ov+mQtHYU6CueOQI6gqjYioUntmvh3Ehk6qMSW0wIk05N+tQnHQg+dPZhIG+5 poS3z7lCP/85DUBSfZHMWBFPCHHL9ySgJXMDEBvG5hlkX/ET5gRIMBzxt75r4YdLZ8Ba uw== From: Venu Busireddy To: venu.busireddy@oracle.com, "Michael S. Tsirkin" , Marcel Apfelbaum Date: Mon, 7 Jan 2019 17:29:44 -0500 Message-Id: <1546900184-27403-6-git-send-email-venu.busireddy@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1546900184-27403-1-git-send-email-venu.busireddy@oracle.com> References: <1546900184-27403-1-git-send-email-venu.busireddy@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9129 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901070183 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [PATCH v3 5/5] pci: query command extension to check the bus master enabling status of the failover-primary device X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Si-Wei Liu , virtio-dev@lists.oasis-open.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Si-Wei Liu Signed-off-by: Si-Wei Liu Signed-off-by: Venu Busireddy --- hmp.c | 5 +++++ hw/pci/pci.c | 5 +++++ qapi/misc.json | 5 ++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/hmp.c b/hmp.c index 7828f93..7a75c93 100644 --- a/hmp.c +++ b/hmp.c @@ -890,6 +890,11 @@ static void hmp_info_pci_device(Monitor *mon, const Pc= iDeviceInfo *dev) } } =20 + if (dev->has_failover_status) { + monitor_printf(mon, " Failover primary, bus master %s.\n", + dev->failover_status ? "enabled" : "disabled"); + } + monitor_printf(mon, " id \"%s\"\n", dev->qdev_id); =20 if (dev->has_pci_bridge) { diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 56b13b3..9da49fd 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1761,6 +1761,11 @@ static PciDeviceInfo *qmp_query_pci_device(PCIDevice= *dev, PCIBus *bus, pci_get_word(dev->config + PCI_CB_SUBSYSTEM_VENDOR_ID); } =20 + if (dev->failover_primary) { + info->has_failover_status =3D true; + info->failover_status =3D dev->bus_master_enable_region.enabled; + } + return info; } =20 diff --git a/qapi/misc.json b/qapi/misc.json index 6c1c5c0..05f003e 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -865,6 +865,9 @@ # # @regions: a list of the PCI I/O regions associated with the device # +# @failover_status: if 'failover-primary' property is 'true', true if PCI +# bus master bit on the device is enabled +# # Notes: the contents of @class_info.desc are not stable and should only be # treated as informational. # @@ -874,7 +877,7 @@ 'data': {'bus': 'int', 'slot': 'int', 'function': 'int', 'class_info': 'PciDeviceClass', 'id': 'PciDeviceId', '*irq': 'int', 'qdev_id': 'str', '*pci_bridge': 'PciBridgeInfo', - 'regions': ['PciMemoryRegion']} } + 'regions': ['PciMemoryRegion'], '*failover_status': 'bool'} } =20 ## # @PciInfo: