Index: xen/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c =================================================================== --- xen.orig/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c +++ xen/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c @@ -257,6 +257,8 @@ static void frontend_changed(struct xenb switch (frontend_state) { case XenbusStateInitialising: case XenbusStateConnected: + case XenbusStateSuspend: + case XenbusStateResume: break; case XenbusStateInitialised: Index: xen/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c =================================================================== --- xen.orig/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c +++ xen/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c @@ -273,6 +273,8 @@ static void backend_changed(struct xenbu case XenbusStateInitWait: case XenbusStateInitialised: case XenbusStateClosed: + case XenbusStateSuspend: + case XenbusStateResume: break; case XenbusStateConnected: Index: xen/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c =================================================================== --- xen.orig/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c +++ xen/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c @@ -205,6 +205,8 @@ static void frontend_changed(struct xenb switch (frontend_state) { case XenbusStateInitialising: case XenbusStateInitialised: + case XenbusStateSuspend: + case XenbusStateResume: break; case XenbusStateConnected: Index: xen/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c =================================================================== --- xen.orig/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c +++ xen/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c @@ -402,6 +402,8 @@ static void backend_changed(struct xenbu case XenbusStateConnected: case XenbusStateUnknown: case XenbusStateClosed: + case XenbusStateSuspend: + case XenbusStateResume: break; case XenbusStateClosing: Index: xen/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c =================================================================== --- xen.orig/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c +++ xen/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c @@ -31,6 +31,7 @@ struct backend_info long int frontend_id; long int instance; // instance of TPM u8 is_instance_set;// whether instance number has been set + u8 is_suspending; /* watch front end for changes */ struct xenbus_watch backend_watch; @@ -99,6 +100,30 @@ fail: return err; } +static int tpmback_hotplug(struct xenbus_device *xdev, char **envp, + int num_envp, char *buffer, int buffer_size) +{ + struct backend_info *be = xdev->data; + int i = 0; + int length = 0; + int idx = 0; + static const char *reason[2] = + {"REASON=hibernate", + "REASON=create"}; + + if (be->frontend_state != XenbusStateSuspend && + be->frontend_state != XenbusStateResume) { + idx = 1; + } + + add_hotplug_env_var(envp, num_envp, &i, + buffer, buffer_size, &length, + reason[idx]); + + envp[i] = NULL; + return 0; +} + static void backend_changed(struct xenbus_watch *watch, const char **vec, unsigned int len) @@ -173,6 +204,8 @@ static void frontend_changed(struct xenb if (err) { return; } + if (be->is_suspending == 0) + kobject_hotplug(&dev->dev.kobj, KOBJ_ONLINE); maybe_connect(be); break; @@ -180,6 +213,16 @@ static void frontend_changed(struct xenb xenbus_switch_state(dev, NULL, XenbusStateClosing); break; + case XenbusStateSuspend: + be->is_suspending = 1; + kobject_hotplug(&dev->dev.kobj, KOBJ_OFFLINE); + break; + + case XenbusStateResume: + be->is_suspending = 1; + kobject_hotplug(&dev->dev.kobj, KOBJ_ONLINE); + break; + case XenbusStateClosed: /* * Notify the vTPM manager about the front-end @@ -309,6 +352,7 @@ static struct xenbus_driver tpmback = { .ids = tpmback_ids, .probe = tpmback_probe, .remove = tpmback_remove, + .hotplug = tpmback_hotplug, .otherend_changed = frontend_changed, }; Index: xen/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c =================================================================== --- xen.orig/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c +++ xen/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c @@ -802,6 +802,7 @@ static int suspend_dev(struct device *de if (err) printk(KERN_WARNING "xenbus: suspend %s failed: %i\n", dev->bus_id, err); + xenbus_switch_state(xdev, NULL, XenbusStateSuspend); return 0; } @@ -826,6 +827,8 @@ static int resume_dev(struct device *dev return err; } + xenbus_switch_state(xdev, NULL, XenbusStateResume); + if (drv->resume) err = drv->resume(xdev); if (err) Index: xen/xen-unstable.hg/xen/include/public/io/xenbus.h =================================================================== --- xen.orig/xen-unstable.hg/xen/include/public/io/xenbus.h +++ xen/xen-unstable.hg/xen/include/public/io/xenbus.h @@ -26,7 +26,9 @@ typedef enum XenbusStateConnected = 4, XenbusStateClosing = 5, /* The device is being closed due to an error or an unplug event. */ - XenbusStateClosed = 6 + XenbusStateClosed = 6, + XenbusStateSuspend = 7, + XenbusStateResume = 8 } XenbusState; Index: xen/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c =================================================================== --- xen.orig/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c +++ xen/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c @@ -338,6 +338,8 @@ static void backend_changed(struct xenbu case XenbusStateInitWait: case XenbusStateInitialised: case XenbusStateUnknown: + case XenbusStateSuspend: + case XenbusStateResume: break; case XenbusStateConnected: Index: xen/xen-unstable.hg/tools/examples/vtpm =================================================================== --- xen.orig/xen-unstable.hg/tools/examples/vtpm +++ xen/xen-unstable.hg/tools/examples/vtpm @@ -5,18 +5,18 @@ dir=$(dirname "$0") case "$command" in - online | offline) - exit 0 - ;; -esac - -case "$command" in add) vtpm_create_instance ;; + online) + vtpm_create_instance + ;; remove) vtpm_remove_instance ;; + offline) + vtpm_remove_instance + ;; esac log debug "Successful vTPM operation '$command'." Index: xen/xen-unstable.hg/tools/examples/vtpm-common.sh =================================================================== --- xen.orig/xen-unstable.hg/tools/examples/vtpm-common.sh +++ xen/xen-unstable.hg/tools/examples/vtpm-common.sh @@ -256,7 +256,8 @@ function vtpm_create_instance () { vtpm_setup $instance else #default case for 'now' - vtpm_reset $instance + #vtpm_reset $instance + true fi xenstore_write $XENBUS_PATH/instance $instance set -e