From: Olaf Hering <olaf@aepfle.de>
To: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: xen-devel@lists.xenproject.org, Olaf Hering <ohering@suse.de>
Subject: [PATCH qemu-xen-traditional 1/2] xen_platform: unplug also SCSI disks
Date: Thu, 24 Nov 2016 20:11:29 +0000 [thread overview]
Message-ID: <20161124201130.16558-2-olaf@aepfle.de> (raw)
In-Reply-To: <20161124201130.16558-1-olaf@aepfle.de>
From: Olaf Hering <ohering@suse.de>
Using 'vdev=sd[a-o]' will create an emulated LSI controller, which can
be used by the emulated BIOS to boot from disk. If the HVM domU has also
PV driver the disk may appear twice in the guest. To avoid this an
unplug of the emulated hardware is needed, similar to what is done for
IDE and NIC drivers already.
Since the SCSI controller provides only disks the entire controller can
be unplugged at once.
Impact of the change for classic and pvops based guest kernels:
vdev=sda:disk0
before: pvops: disk0=pv xvda + emulated sda
classic: disk0=pv sda + emulated sdq
after: pvops: disk0=pv xvda
classic: disk0=pv sda
vdev=hda:disk0, vdev=sda:disk1
before: pvops: disk0=pv xvda
disk1=emulated sda
classic: disk0=pv hda
disk1=pv sda + emulated sdq
after: pvops: disk0=pv xvda
disk1=not accessible by blkfront, index hda==index sda
classic: disk0=pv hda
disk1=pv sda
vdev=hda:disk0, vdev=sda:disk1, vdev=sdb:disk2
before: pvops: disk0=pv xvda
disk1=emulated sda
disk2=pv xvdb + emulated sdb
classic: disk0=pv hda
disk1=pv sda + emulated sdq
disk2=pv sdb + emulated sdr
after: pvops: disk0=pv xvda
disk1=not accessible by blkfront, index hda==index sda
disk2=pv xvdb
classic: disk0=pv hda
disk1=pv sda
disk2=pv sda
Upstream commit 78f66897ddf58d1ffe5e0b95f7c1a1dad103a8da
Signed-off-by: Olaf Hering <ohering@suse.de>
---
hw/pci.c | 41 +++++++++++++++++++++++++++++++++++++++++
hw/xen_platform.c | 4 +++-
qemu-xen.h | 1 +
3 files changed, 45 insertions(+), 1 deletion(-)
diff --git a/hw/pci.c b/hw/pci.c
index c423285..7d8e3b6 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -871,6 +871,47 @@ void pci_unplug_netifs(void)
}
}
+void pci_unplug_scsi(void)
+{
+ PCIBus *bus;
+ PCIDevice *dev;
+ PCIIORegion *region;
+ int x;
+ int i;
+
+ /* We only support one PCI bus */
+ for (bus = first_bus; bus; bus = NULL) {
+ for (x = 0; x < 256; x++) {
+ dev = bus->devices[x];
+ if (dev &&
+ dev->config[0xa] == 0 &&
+ dev->config[0xb] == 1
+#ifdef CONFIG_PASSTHROUGH
+ && test_pci_devfn(x) != 1
+#endif
+ ) {
+ /* Found a scsi disk. Remove it from the bus. Note that
+ we don't free it here, since there could still be
+ references to it floating around. There are only
+ ever one or two structures leaked, and it's not
+ worth finding them all. */
+ bus->devices[x] = NULL;
+ for (i = 0; i < PCI_NUM_REGIONS; i++) {
+ region = &dev->io_regions[i];
+ if (region->addr == (uint32_t)-1 ||
+ region->size == 0)
+ continue;
+ if (region->type == PCI_ADDRESS_SPACE_IO) {
+ isa_unassign_ioport(region->addr, region->size);
+ } else if (region->type == PCI_ADDRESS_SPACE_MEM) {
+ unregister_iomem(region->addr);
+ }
+ }
+ }
+ }
+ }
+}
+
typedef struct {
PCIDevice dev;
PCIBus *bus;
diff --git a/hw/xen_platform.c b/hw/xen_platform.c
index d282f8e..0a94e0d 100644
--- a/hw/xen_platform.c
+++ b/hw/xen_platform.c
@@ -154,8 +154,10 @@ static void platform_fixed_ioport_write2(void *opaque, uint32_t addr, uint32_t v
/* Unplug devices. Value is a bitmask of which devices to
unplug, with bit 0 the IDE devices, bit 1 the network
devices, and bit 2 the non-primary-master IDE devices. */
- if (val & UNPLUG_ALL_IDE_DISKS)
+ if (val & UNPLUG_ALL_IDE_DISKS) {
ide_unplug_harddisks();
+ pci_unplug_scsi();
+ }
if (val & UNPLUG_ALL_NICS) {
pci_unplug_netifs();
net_tap_shutdown_all();
diff --git a/qemu-xen.h b/qemu-xen.h
index 0598668..d315623 100644
--- a/qemu-xen.h
+++ b/qemu-xen.h
@@ -47,6 +47,7 @@ void unset_vram_mapping(void *opaque);
#endif
void pci_unplug_netifs(void);
+void pci_unplug_scsi(void);
void destroy_hvm_domain(void);
void unregister_iomem(target_phys_addr_t start);
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-11-24 20:11 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-24 20:11 [PATCH qemu-xen-traditional 0/2] Xen HVM unplug changes Olaf Hering
2016-11-24 20:11 ` Olaf Hering [this message]
2017-01-09 14:34 ` [PATCH qemu-xen-traditional 1/2] xen_platform: unplug also SCSI disks [and 1 more messages] Ian Jackson
2017-01-09 16:39 ` Olaf Hering
2017-01-10 10:34 ` George Dunlap
2017-01-31 17:14 ` Olaf Hering
2017-01-31 17:32 ` Ian Jackson
2017-01-31 17:44 ` Olaf Hering
2016-11-24 20:11 ` [PATCH qemu-xen-traditional 2/2] xen_platform: SUSE xenlinux unplug for emulated PCI Olaf Hering
2017-01-09 11:23 ` [PATCH qemu-xen-traditional 0/2] Xen HVM unplug changes Olaf Hering
2017-01-09 14:26 ` Ian Jackson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161124201130.16558-2-olaf@aepfle.de \
--to=olaf@aepfle.de \
--cc=ian.jackson@eu.citrix.com \
--cc=ohering@suse.de \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.