[PATCH 7/7] qemu: process: Wire up ACPI OST events to notify users of failed memory unplug

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Since qemu is now able to notify us that the guest rejected the memory
unplug operation we can relay this to the user and make the API fail
right away.

Additionally document the possible values from the ACPI docs for future
reference.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1320447
---
 src/qemu/qemu_process.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 69 insertions(+)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index bbde32c..effc9b1 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -1388,6 +1388,74 @@ qemuProcessHandleDeviceDeleted(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
 }


+/**
+ *
+ * Meaning of fields reported by the event according to the ACPI standard:
+ * @source:
+ *  0x00 - 0xff: Notification values, as passed at the request time
+ *  0x100: Operating System Shutdown Processing
+ *  0x103: Ejection processing
+ *  0x200: Insertion processing
+ *  other values are reserved
+ *
+ * @status:
+ *   general values
+ *     0x00: success
+ *     0x01: non-specific failure
+ *     0x02: unrecognized notify code
+ *     0x03 - 0x7f: reserved
+ *     other values are specific to the notification type
+ *
+ *   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 fields and semantics are specific to the qemu handling of the event.
+ *  - @alias may be NULL for successful unplug operations
+ *  - @slotType describes the device type a bit more closely, currently the
+ *    only known value is 'DIMM'
+ *  - @slot describes the specific device
+ *
+ *  Note that qemu does not emit the event for all the documented sources or
+ *  devices.
+ */
+static int
+qemuProcessHandleAcpiOstInfo(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
+                             virDomainObjPtr vm,
+                             const char *alias,
+                             const char *slotType,
+                             const char *slot,
+                             unsigned int source,
+                             unsigned int status,
+                             void *opaque)
+{
+    virQEMUDriverPtr driver = opaque;
+    virObjectEventPtr event = NULL;
+
+    virObjectLock(vm);
+
+    VIR_DEBUG("ACPI OST info for device %s domain %p %s. "
+              "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_UNPLUG_DEVICE_STATUS_GUEST_REJECTED);
+
+        event = virDomainEventDeviceRemovalFailedNewFromObj(vm, alias);
+    }
+
+    virObjectUnlock(vm);
+    qemuDomainEventQueue(driver, event);
+
+    return 0;
+}
+
+
 static int
 qemuProcessHandleNicRxFilterChanged(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
                                     virDomainObjPtr vm,
@@ -1583,6 +1651,7 @@ static qemuMonitorCallbacks monitorCallbacks = {
     .domainSpiceMigrated = qemuProcessHandleSpiceMigrated,
     .domainMigrationStatus = qemuProcessHandleMigrationStatus,
     .domainMigrationPass = qemuProcessHandleMigrationPass,
+    .domainAcpiOstInfo = qemuProcessHandleAcpiOstInfo,
 };

 static void
-- 
2.8.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]