Skip to contentSkip to conversation

s390x: one bugfix

GIT PULL Applied Cornelia Huck 2 participants 3 messages Mar 20, 2017

lore
Share & tools
lore
#0 lore raw

The following changes since commit ebedf0f9cd46b617df331eecc857c379d574ac62:

nios2: iic: Convert CPU prop to qom link (2017-03-18 18:22:54 +0000)

are available in the git repository at:

git://github.com/cohuck/qemu tags/s390x-20170320

for you to fetch changes up to 3c788ebc6f6eef5ac6e9cb4a28c578abcf08247d:

s390x/css: reassign subchannel if schid is changed after migration (2017-03-20 09:22:57 +0100)

----------------------------------------------------------------
One bugfix for device plug/unplug and migration in the channel subsystem code.

----------------------------------------------------------------

Dong Jia Shi (1):
s390x/css: reassign subchannel if schid is changed after migration

 hw/s390x/css.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
Signature · 1 line
2.11.0
#1 lore raw

[Qemu-devel] [PULL for-2.9 1/1] s390x/css: reassign subchannel if schid is changed after migration

From: Dong Jia Shi <[email protected]>

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.

---
 hw/s390x/css.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
hw/s390x/css.c +15 -0
index e32b2a4d42..37caa98195 100644
@@ -1675,12 +1675,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 */
Signature · 1 line
2.11.0
#2 lore raw
In reply to Cornelia Huck
Quoted 16 lines · Cornelia Huck

The following changes since commit ebedf0f9cd46b617df331eecc857c379d574ac62:

nios2: iic: Convert CPU prop to qom link (2017-03-18 18:22:54 +0000)

are available in the git repository at:

git://github.com/cohuck/qemu tags/s390x-20170320

for you to fetch changes up to 3c788ebc6f6eef5ac6e9cb4a28c578abcf08247d:

s390x/css: reassign subchannel if schid is changed after migration (2017-03-20 09:22:57 +0100)

----------------------------------------------------------------
One bugfix for device plug/unplug and migration in the channel subsystem code.

Quoted 7 lines

----------------------------------------------------------------

Dong Jia Shi (1):
s390x/css: reassign subchannel if schid is changed after migration

 hw/s390x/css.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Applied, thanks.

-- PMM