[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 80/81] s390x/css: reassign subchannel if schid is ch
From: |
Michael Roth |
Subject: |
[Qemu-devel] [PATCH 80/81] s390x/css: reassign subchannel if schid is changed after migration |
Date: |
Mon, 20 Mar 2017 18:08:44 -0500 |
From: Dong Jia Shi <address@hidden>
The subchannel is a means to access a device. While the device number is
assigned by the administrator, the subchannel number is assigned by
the channel subsystem in an ascending order on cold and hot plug.
When doing unplug and replug operations, the same device may end up on
a different subchannel; for example
- We start with a device fe.1.2222, which ends up at subchannel
fe.1.0000.
- Now we detach the device, attach a device fe.1.3333 (which would get
the now-free subchannel fe.1.0000), re-attach fe.1.2222 (which ends
up at subchannel fe.1.0001) and detach fe.1.3333.
- We now have the same device (fe.1.2222) available to the guest; it
just shows up on a different subchannel.
In such a case, the subchannel numbers are different from what a
QEMU would create during cold plug when parsing the command line.
As this would cause a guest visible change on migration, we do restore
the source system's value of the subchannel number on load.
So we are now fine from the guest perspective. From the host
perspective this will cause an inconsistent state in our internal data
structures, though.
For example, the subchannel 0 might not be at array position 0. This will
lead to problems when we continue doing hot (un/re) plug operations.
Let's fix this by cleaning up our internal data structures.
Reported-by: Cornelia Huck <address@hidden>
Signed-off-by: Dong Jia Shi <address@hidden>
Cc: address@hidden
Signed-off-by: Cornelia Huck <address@hidden>
(cherry picked from commit 3c788ebc6f6eef5ac6e9cb4a28c578abcf08247d)
Signed-off-by: Michael Roth <address@hidden>
---
hw/s390x/css.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/hw/s390x/css.c b/hw/s390x/css.c
index 0f2580d..91a9fa4 100644
--- a/hw/s390x/css.c
+++ b/hw/s390x/css.c
@@ -1672,12 +1672,27 @@ void subch_device_save(SubchDev *s, QEMUFile *f)
int subch_device_load(SubchDev *s, QEMUFile *f)
{
+ SubchDev *old_s;
+ uint16_t old_schid = s->schid;
int i;
s->cssid = qemu_get_byte(f);
s->ssid = qemu_get_byte(f);
s->schid = qemu_get_be16(f);
s->devno = qemu_get_be16(f);
+ /* Re-assign subch. */
+ if (old_schid != s->schid) {
+ old_s = channel_subsys.css[s->cssid]->sch_set[s->ssid]->sch[old_schid];
+ /*
+ * (old_s != s) means that some other device has its correct
+ * subchannel already assigned (in load).
+ */
+ if (old_s == s) {
+ css_subch_assign(s->cssid, s->ssid, old_schid, s->devno, NULL);
+ }
+ /* It's OK to re-assign without a prior de-assign. */
+ css_subch_assign(s->cssid, s->ssid, s->schid, s->devno, s);
+ }
s->thinint_active = qemu_get_byte(f);
/* SCHIB */
/* PMCW */
--
2.7.4
- [Qemu-devel] [PATCH 64/81] vnc: do not disconnect on EAGAIN, (continued)
- [Qemu-devel] [PATCH 64/81] vnc: do not disconnect on EAGAIN, Michael Roth, 2017/03/20
- [Qemu-devel] [PATCH 63/81] sd: sdhci: check data length during dma_memory_read, Michael Roth, 2017/03/20
- [Qemu-devel] [PATCH 76/81] NetRxPkt: Account buffer with ETH header in IOV length, Michael Roth, 2017/03/20
- [Qemu-devel] [PATCH 66/81] block/vmdk: Fix the endian problem of buf_len and lba, Michael Roth, 2017/03/20
- [Qemu-devel] [PATCH 73/81] eth: Extend vlan stripping functions, Michael Roth, 2017/03/20
- [Qemu-devel] [PATCH 77/81] e1000e: correctly tear down MSI-X memory regions, Michael Roth, 2017/03/20
- [Qemu-devel] [PATCH 78/81] scsi: mptsas: fix the wrong reading size in fetch request, Michael Roth, 2017/03/20
- [Qemu-devel] [PATCH 81/81] thread-pool: add missing qemu_bh_cancel in completion function, Michael Roth, 2017/03/20
- [Qemu-devel] [PATCH 71/81] hmp: fix block_set_io_throttle, Michael Roth, 2017/03/20
- [Qemu-devel] [PATCH 72/81] cirrus: add blit_is_unsafe call to cirrus_bitblt_cputovideo (CVE-2017-2620), Michael Roth, 2017/03/20
- [Qemu-devel] [PATCH 80/81] s390x/css: reassign subchannel if schid is changed after migration,
Michael Roth <=
- [Qemu-devel] [PATCH 79/81] virtio-pci: reset modern vq meta data, Michael Roth, 2017/03/20
- [Qemu-devel] [PATCH 07/81] 9pfs: local: lgetxattr: don't follow symlinks, Michael Roth, 2017/03/20
- Re: [Qemu-devel] [PATCH 00/81] Patch Round-up for stable 2.8.1, freeze on 2017-03-27, Eric Blake, 2017/03/20
- Re: [Qemu-devel] [PATCH 00/81] Patch Round-up for stable 2.8.1, freeze on 2017-03-27, Richard Henderson, 2017/03/20
- Re: [Qemu-devel] [Qemu-stable] [PATCH 00/81] Patch Round-up for stable 2.8.1, freeze on 2017-03-27, Greg Kurz, 2017/03/21
- [Qemu-devel] [PATCH 55/81] s390x/kvm: fix cmma reset for KVM, Michael Roth, 2017/03/21
- Re: [Qemu-devel] [PATCH 00/81] Patch Round-up for stable 2.8.1, freeze on 2017-03-27, Christian Borntraeger, 2017/03/22