[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[QEMU][PATCHv2 1/8] xen: when unplugging emulated devices skip virtio devices


  • To: <qemu-devel@xxxxxxxxxx>
  • From: Vikram Garhwal <vikram.garhwal@xxxxxxx>
  • Date: Wed, 25 Oct 2023 14:24:14 -0700
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nongnu.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=j8RBc3mGaBZEzIDWAq6TaBKCLaPuj7qNGyoRNGoAD/4=; b=nENxdoUCU65ttVFbtpQEwGemXjlD7lMx6m6DISKmvScNTvHKeoa2fRjBu8hkuH1yGBpl9q1s3wxoE6Ehq/iBlZSU2rwo5u5LH00h5KCCV3I01QUsb2V5q0xZV/CiUeVQ7aF3qQ3lMM99ChJDhIDJgcqEAaeInV7hOYYJATYa7u+5OcWhfsxHbN6/lOv1tE9L91naGCC8UVeJEiY58Pgc9rVd9vUPbDBge4su5tCmvRzYkLLOsm4AP+k0mPph1w4tnoCodRwqf7yDOPWNeALNpbvpW82fEj9DfMoIl724T4eaNmDFrKh/Q/H0FUrtn4B8boqSOF/gVhWPaZJl+xJ0XQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LR6H8GH8Qh4HsvZO9PMqZvjcnbNnevZK8FgMsbNcnOSpkKpkSyd5IfUVacDVJmvYp8XjXV1eB53woxQP+k1kiSRmecOe5a24k7GlhkFjodLgS0sPaQRAe+OHgtEKYFugHdzk19c1zEG71MewGukfEsmAUc8uRHtPIAyQQrJgDwqdRB65NwdUG4/1A20x1w/agDjbZPa0p+ojA+LuPxQjl/EnMrs6J6nrGtXuBvx16/dhl34VzuqKYEmJJazMWpIBbiw9dve3kBScXfWUP6SGSD3x82h+kctprTYZ4F8ZxuhWiB3pEjVB+ZxDfbB9EedxtZSavxctnKgei8Gs7OnhwA==
  • Cc: <sstabellini@xxxxxxxxxx>, <vikram.garhwal@xxxxxxx>, <jgross@xxxxxxxx>, Anthony Perard <anthony.perard@xxxxxxxxxx>, Paul Durrant <paul@xxxxxxx>, Paolo Bonzini <pbonzini@xxxxxxxxxx>, Richard Henderson <richard.henderson@xxxxxxxxxx>, Eduardo Habkost <eduardo@xxxxxxxxxxx>, "Michael S. Tsirkin" <mst@xxxxxxxxxx>, Marcel Apfelbaum <marcel.apfelbaum@xxxxxxxxx>, "open list:X86 Xen CPUs" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Wed, 25 Oct 2023 21:24:52 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

From: Juergen Gross <jgross@xxxxxxxx>

Virtio devices should never be unplugged at boot time, as they are
similar to pci passthrough devices.

Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
Signed-off-by: Vikram Garhwal <vikram.garhwal@xxxxxxx>
---
 docs/system/i386/xen.rst   |  3 ---
 hw/i386/xen/xen_platform.c | 10 ++++++++--
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/docs/system/i386/xen.rst b/docs/system/i386/xen.rst
index f06765e88c..b86d57af6e 100644
--- a/docs/system/i386/xen.rst
+++ b/docs/system/i386/xen.rst
@@ -52,9 +52,6 @@ It is necessary to use the pc machine type, as the q35 
machine uses AHCI instead
 of legacy IDE, and AHCI disks are not unplugged through the Xen PV unplug
 mechanism.
 
-VirtIO devices can also be used; Linux guests may need to be dissuaded from
-umplugging them by adding 'xen_emul_unplug=never' on their command line.
-
 Properties
 ----------
 
diff --git a/hw/i386/xen/xen_platform.c b/hw/i386/xen/xen_platform.c
index 17457ff3de..0187b73eeb 100644
--- a/hw/i386/xen/xen_platform.c
+++ b/hw/i386/xen/xen_platform.c
@@ -28,6 +28,7 @@
 #include "hw/ide/pci.h"
 #include "hw/pci/pci.h"
 #include "migration/vmstate.h"
+#include "hw/virtio/virtio-bus.h"
 #include "net/net.h"
 #include "trace.h"
 #include "sysemu/xen.h"
@@ -129,10 +130,11 @@ static bool pci_device_is_passthrough(PCIDevice *d)
 
 static void unplug_nic(PCIBus *b, PCIDevice *d, void *o)
 {
-    /* We have to ignore passthrough devices */
+    /* We have to ignore passthrough devices  and virtio devices. */
     if (pci_get_word(d->config + PCI_CLASS_DEVICE) ==
             PCI_CLASS_NETWORK_ETHERNET
-            && !pci_device_is_passthrough(d)) {
+            && !pci_device_is_passthrough(d)
+            && !qdev_get_child_bus(&d->qdev, TYPE_VIRTIO_BUS)) {
         object_unparent(OBJECT(d));
     }
 }
@@ -208,6 +210,10 @@ static void unplug_disks(PCIBus *b, PCIDevice *d, void 
*opaque)
     /* We have to ignore passthrough devices */
     if (pci_device_is_passthrough(d))
         return;
+    /* Ignore virtio devices */
+    if (qdev_get_child_bus(&d->qdev, TYPE_VIRTIO_BUS)) {
+        return;
+    }
 
     switch (pci_get_word(d->config + PCI_CLASS_DEVICE)) {
     case PCI_CLASS_STORAGE_IDE:
-- 
2.17.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.