From: Kamala Narasimhan Date: Tue, 17 Nov 2009 14:50:06 +0000 (-0500) Subject: Send xenstore notification while entering different Sx states. X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=af5c8fa96a55d015c54b7a98a33f2686e2fe050e;p=xenclient%2Fioemu-pq.git Send xenstore notification while entering different Sx states. --- diff --git a/master/series b/master/series index 9d28e48..7a680ea 100644 --- a/master/series +++ b/master/series @@ -17,7 +17,7 @@ suspend-by-signal battery-management oem-features thermal-management - +xenstore-notify-pm-events vga-passthrough switcher diff --git a/master/xenstore-notify-pm-events b/master/xenstore-notify-pm-events new file mode 100644 index 0000000..1001533 --- /dev/null +++ b/master/xenstore-notify-pm-events @@ -0,0 +1,66 @@ +diff --git a/hw/piix4acpi.c b/hw/piix4acpi.c +index 4e0410b..06b0bfa 100644 +--- a/hw/piix4acpi.c ++++ b/hw/piix4acpi.c +@@ -35,6 +35,10 @@ + #include + #include + ++#define GUEST_STATE_SLEEP 3 ++#define GUEST_STATE_HIBERNATE 4 ++#define GUEST_STATE_SHUTDOWN 5 ++ + /* PM1a_CNT bits, as defined in the ACPI specification. */ + #define SCI_EN (1 << 0) + #define GBL_RLS (1 << 2) +@@ -139,10 +143,15 @@ static void acpi_shutdown(uint32_t val) + s3_shutdown_flag = 0; + cmos_set_s3_resume(); + xc_set_hvm_param(xc_handle, domid, HVM_PARAM_ACPI_S_STATE, 3); ++ xenstore_guest_pm_notification(GUEST_STATE_SLEEP); + break; + case SLP_TYP_S4: ++ qemu_system_shutdown_request(); ++ xenstore_guest_pm_notification(GUEST_STATE_HIBERNATE); ++ break; + case SLP_TYP_S5: + qemu_system_shutdown_request(); ++ xenstore_guest_pm_notification(GUEST_STATE_SHUTDOWN); + break; + default: + break; +diff --git a/qemu-xen.h b/qemu-xen.h +index 0b6214c..5ad40a8 100644 +--- a/qemu-xen.h ++++ b/qemu-xen.h +@@ -124,6 +124,7 @@ void xenstore_dm_finished_startup(void); + int xenstore_vm_write(int domid, const char *key, const char *val); + char *xenstore_vm_read(int domid, const char *key, unsigned int *len); + char *xenstore_device_model_read(int domid, const char *key, unsigned int *len); ++int xenstore_guest_pm_notification(int state); + int xenstore_extended_power_mgmt_read_int(const char *key, int default_value); + char *xenstore_read_battery_data(int battery_status); + int xenstore_refresh_battery_status(void); +diff --git a/xenstore.c b/xenstore.c +index 3cd2ba6..a298f40 100644 +--- a/xenstore.c ++++ b/xenstore.c +@@ -1718,6 +1718,18 @@ int xenstore_write(const char *path, const char *val) + return xs_write(xsh, XBT_NULL, path, val, strlen(val)); + } + ++int xenstore_guest_pm_notification(int state) ++{ ++ int ret; ++ char *value = NULL; ++ ++ if (pasprintf(&value, "%d", state) == -1) ++ return -1; ++ ++ ret = xenstore_dom_write(domid, "power-state", value); ++ free(value); ++ return ret; ++} + + /* Advertise through xenstore that the device model is up and the + domain can be started. */