[libvirt] [PATCH 0/2] qemu: Improve and document states handled in qemuProcessHandleAcpiOstInfo

We did not handle all the possible error states of memory unplug. Add more ACPI table documentation and fix the code to conform to it. Peter Krempa (2): qemu: process: Improve documentation of values handled by qemuProcessHandleAcpiOstInfo qemu: process: Handle all failure values for dimms in qemuProcessHandleAcpiOstInfo src/qemu/qemu_process.c | 44 +++++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 8 deletions(-) -- 2.20.1

We forgot to document the specific fields for the 0x103 and 0x200 sources which are tied to device removal and device hotplug respectively. The value description is based on the ACPI 6.2A standard Table 6-207 and Table 6-208. At the time of writing of this patch the standard can be accessed e.g. at: https://www.uefi.org/sites/default/files/resources/ACPI%206_2_A_Sept29.pdf Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_process.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 855bd9cb14..6533106cdd 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -1344,14 +1344,36 @@ qemuProcessHandleDeviceDeleted(qemuMonitorPtr mon ATTRIBUTE_UNUSED, * 0x01: non-specific failure * 0x02: unrecognized notify code * 0x03 - 0x7f: reserved - * other values are specific to the notification type + * other values are specific to the notification type (see below) * - * for the 0x100 source the following additional codes are standardized + * for the 0x100 source the following additional codes are standardized: * 0x80: OS Shutdown request denied * 0x81: OS Shutdown in progress * 0x82: OS Shutdown completed * 0x83: OS Graceful shutdown not supported - * other values are reserved + * other higher values are reserved + * + * for the 0x003 (Ejection request) and 0x103 (Ejection processing) source + * the following additional codes are standardized: + * 0x80: Device ejection not supported by OSPM + * 0x81: Device in use by application + * 0x82: Device Busy + * 0x83: Ejection dependency is busy or not supported for ejection by OSPM + * 0x84: Ejection is in progress (pending) + * other higher values are reserved + * + * for the 0x200 source the following additional codes are standardized: + * 0x80: Device insertion in progress (pending) + * 0x81: Device driver load failure + * 0x82: Device insertion not supported by OSPM + * 0x83-0x8F: Reserved + * 0x90-0x9F: Insertion failure - Resources Unavailable as described by the + * following bit encodings: + * Bit [3]: Bus or Segment Numbers + * Bit [2]: Interrupts + * Bit [1]: I/O + * Bit [0]: Memory + * other higher values are reserved * * Other fields and semantics are specific to the qemu handling of the event. * - @alias may be NULL for successful unplug operations -- 2.20.1

Hanlde all the possible failure codes as per ACPI standard documented in the function header. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1660410 Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_process.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 6533106cdd..993f0e7bd2 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -1403,14 +1403,20 @@ qemuProcessHandleAcpiOstInfo(qemuMonitorPtr mon ATTRIBUTE_UNUSED, "slotType='%s' slot='%s' source=%u status=%u", NULLSTR(alias), vm, vm->def->name, slotType, slot, source, status); - /* handle memory unplug failure */ - if (STREQ(slotType, "DIMM") && alias && status == 1) { - qemuDomainSignalDeviceRemoval(vm, alias, - QEMU_DOMAIN_UNPLUGGING_DEVICE_STATUS_GUEST_REJECTED); + if (!alias) + goto cleanup; + + if (STREQ(slotType, "DIMM")) { + if ((source == 0x003 || source == 0x103) && + (status == 0x01 || (status >= 0x80 && status <= 0x83))) { + qemuDomainSignalDeviceRemoval(vm, alias, + QEMU_DOMAIN_UNPLUGGING_DEVICE_STATUS_GUEST_REJECTED); - event = virDomainEventDeviceRemovalFailedNewFromObj(vm, alias); + event = virDomainEventDeviceRemovalFailedNewFromObj(vm, alias); + } } + cleanup: virObjectUnlock(vm); virObjectEventStateQueue(driver->domainEventState, event); -- 2.20.1

On Tuesday, 22 January 2019 12:25:58 CET Peter Krempa wrote:
Hanlde all the possible failure codes as per ACPI standard documented in the function header.
typo, "Handle" -- Pino Toscano

On Tue, Jan 22, 2019 at 12:25:56PM +0100, Peter Krempa wrote:
We did not handle all the possible error states of memory unplug. Add more ACPI table documentation and fix the code to conform to it.
Peter Krempa (2): qemu: process: Improve documentation of values handled by qemuProcessHandleAcpiOstInfo qemu: process: Handle all failure values for dimms in qemuProcessHandleAcpiOstInfo
src/qemu/qemu_process.c | 44 +++++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 8 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano
participants (3)
-
Ján Tomko
-
Peter Krempa
-
Pino Toscano