[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v1 20/23] xen platform: unplug ahci object
From: |
Joel Upham |
Subject: |
[PATCH v1 20/23] xen platform: unplug ahci object |
Date: |
Tue, 20 Jun 2023 13:24:54 -0400 |
This will unplug the ahci device when the Xen driver calls for an unplug.
This has been tested to work in linux and Windows guests.
When q35 is detected, we will remove the ahci controller
with the hard disks. In the libxl config, cdrom devices
are put on a seperate ahci controller. This allows for 6 cdrom
devices to be added, and 6 qemu hard disks.
Signed-off-by: Joel Upham <jupham125@gmail.com>
---
hw/i386/xen/xen_platform.c | 19 ++++++++++++++++++-
hw/pci/pci.c | 17 +++++++++++++++++
include/hw/pci/pci.h | 3 +++
3 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/hw/i386/xen/xen_platform.c b/hw/i386/xen/xen_platform.c
index 57f1d742c1..0375337222 100644
--- a/hw/i386/xen/xen_platform.c
+++ b/hw/i386/xen/xen_platform.c
@@ -34,6 +34,7 @@
#include "sysemu/block-backend.h"
#include "qemu/error-report.h"
#include "qemu/module.h"
+#include "include/hw/i386/pc.h"
#include "qom/object.h"
#ifdef CONFIG_XEN
@@ -223,6 +224,12 @@ static void unplug_disks(PCIBus *b, PCIDevice *d, void
*opaque)
if (flags & UNPLUG_NVME_DISKS) {
object_unparent(OBJECT(d));
}
+ break;
+
+ case PCI_CLASS_STORAGE_SATA:
+ if (!aux) {
+ object_unparent(OBJECT(d));
+ }
default:
break;
@@ -231,7 +238,17 @@ static void unplug_disks(PCIBus *b, PCIDevice *d, void
*opaque)
static void pci_unplug_disks(PCIBus *bus, uint32_t flags)
{
- pci_for_each_device(bus, 0, unplug_disks, &flags);
+ PCIBus *q35 = find_q35();
+ if (q35) {
+ /* When q35 is detected, we will remove the ahci controller
+ * with the hard disks. In the libxl config, cdrom devices
+ * are put on a seperate ahci controller. This allows for 6 cdrom
+ * devices to be added, and 6 qemu hard disks.
+ */
+ pci_function_for_one_bus(bus, unplug_disks, &flags);
+ } else {
+ pci_for_each_device(bus, 0, unplug_disks, &flags);
+ }
}
static void platform_fixed_ioport_writew(void *opaque, uint32_t addr, uint32_t
val)
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 1cc7c89036..8eac3d751a 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -1815,6 +1815,23 @@ void pci_for_each_device_reverse(PCIBus *bus, int
bus_num,
}
}
+void pci_function_for_one_bus(PCIBus *bus,
+ void (*fn)(PCIBus *b, PCIDevice *d, void *opaque),
+ void *opaque)
+{
+ bus = pci_find_bus_nr(bus, 0);
+
+ if (bus) {
+ PCIDevice *d;
+
+ d = bus->devices[PCI_DEVFN(4,0)];
+ if (d) {
+ fn(bus, d, opaque);
+ return;
+ }
+ }
+}
+
void pci_for_each_device_under_bus(PCIBus *bus,
pci_bus_dev_fn fn, void *opaque)
{
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index e6d0574a29..c53e21082a 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -343,6 +343,9 @@ void pci_for_each_device_under_bus(PCIBus *bus,
void pci_for_each_device_under_bus_reverse(PCIBus *bus,
pci_bus_dev_fn fn,
void *opaque);
+void pci_function_for_one_bus(PCIBus *bus,
+ void (*fn)(PCIBus *bus, PCIDevice *d, void *opaque),
+ void *opaque);
void pci_for_each_bus_depth_first(PCIBus *bus, pci_bus_ret_fn begin,
pci_bus_fn end, void *parent_state);
PCIDevice *pci_get_function_0(PCIDevice *pci_dev);
--
2.34.1
- [PATCH v1 00/23] Q35 support for Xen, Joel Upham, 2023/06/20
- [PATCH v1 01/23] pc/xen: Xen Q35 support: provide IRQ handling for PCI devices, Joel Upham, 2023/06/20
- [PATCH v1 07/23] xen/pt: avoid reading PCIe device type and cap version multiple times, Joel Upham, 2023/06/20
- [PATCH v1 10/23] xen/pt: add support for PCIe Extended Capabilities and larger config space, Joel Upham, 2023/06/20
- [PATCH v1 17/23] xen/pt: add Resizable BAR PCIe Extended Capability descriptor and sizing, Joel Upham, 2023/06/20
- [PATCH v1 12/23] xen/pt: allow to hide PCIe Extended Capabilities, Joel Upham, 2023/06/20
- [PATCH v1 15/23] xen/pt: add AER PCIe Extended Capability descriptor and sizing, Joel Upham, 2023/06/20
- [PATCH v1 18/23] xen/pt: add VC/VC9/MFVC PCIe Extended Capabilities descriptors and sizing, Joel Upham, 2023/06/20
- [PATCH v1 20/23] xen platform: unplug ahci object,
Joel Upham <=
- [PATCH v1 02/23] pc/q35: Apply PCI bus BSEL property for Xen PCI device hotplug, Joel Upham, 2023/06/20
- [PATCH v1 03/23] q35/acpi/xen: Provide ACPI PCI hotplug interface for Xen on Q35, Joel Upham, 2023/06/20
- [PATCH v1 04/23] q35/xen: Add Xen platform device support for Q35, Joel Upham, 2023/06/20