]> git.ipfire.org Git - thirdparty/qemu.git/commit
hw/xen: Avoid crash when backend watch fires too early
authorPaul Durrant <pdurrant@amazon.com>
Mon, 30 Jan 2023 14:35:28 +0000 (14:35 +0000)
committerDavid Woodhouse <dwmw@amazon.co.uk>
Tue, 7 Mar 2023 17:04:30 +0000 (17:04 +0000)
commit240cc11369fc692c037a6ec46b358e75a55df894
treef29f246e90aca1ae098cb227907637f7071ab32b
parent4ca8cf092dabf934a32968c917f0d0682053cd4e
hw/xen: Avoid crash when backend watch fires too early

The xen-block code ends up calling aio_poll() through blkconf_geometry(),
which means we see watch events during the indirect call to
xendev_class->realize() in xen_device_realize(). Unfortunately this call
is made before populating the initial frontend and backend device nodes
in xenstore and hence xen_block_frontend_changed() (which is called from
a watch event) fails to read the frontend's 'state' node, and hence
believes the device is being torn down. This in-turn sets the backend
state to XenbusStateClosed and causes the device to be deleted before it
is fully set up, leading to the crash.
By simply moving the call to xendev_class->realize() after the initial
xenstore nodes are populated, this sorry state of affairs is avoided.

Reported-by: David Woodhouse <dwmw@amazon.co.uk>
Signed-off-by: Paul Durrant <pdurrant@amazon.com>
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>
hw/xen/xen-bus.c