>
I 'm trying to copy hiberfile onto my own storage device (which is
not
the boot device). I’m planning to hook my driver hiber_MyDriver in the
hiber stack but there are few questions I need answers for:
Q1. is it safe to assume that all the runtime drivers including my own
run
time driver for all the storage devices are still alive during
hibernation? If I makes call to these driver’s functions from my
hiber_MyDriver - is it OK?
In order for my Xen block device drivers to work, they must:
. make a call back to the bus driver to notify Xen/Dom0 that a disk
request has been put on the ring
. receive an interrupt via the bus driver logic (actually I have a
sneaking suspicion that this is incorrect - it appears that the ISR is
called not as a result of receiving a hardware interrupt but just at
regular intervals on a timer).
It works for me anyway, so the code I call is still loaded in memory at
the same place. See below though.
I save my state (or pointers to it) in my resource memory area in the
real device, and the dump_ and hiber_ devices are handed the same
physical resources (blindly I assume), so I can get at the bus call
table and the ring state from there.
The only routine in my call table that is called in dump mode is very
very simple (almost purely a hypercall).
Q2. I also do something during hibernation time with the device
objects
created during normal runtime by some driver in the storage stack -
are
these device objects still valid?
Probably not, although if they are in memory and you have saved a
pointer to them in a way that is accessible to the hibernation driver
then it may ‘work’ (for certain values of the work ‘work’). Don’t expect
any of the IRP handling code to work.
I’m writing from experience with making my xen driver work in ‘dump’
mode though, and dump mode is a little different as you can make very
little assumption about the state of the system (eg for all I know it
was my xen bus driver that caused the crash in the first place, so
involving it is probably a bad idea). In hibernation mode you can
probably be a little more certain about the state of the system,
although the idea is that everything else is frozen in a state that is
ready to be dumped to disk, so it’s probably a good idea not to tinker
with it too much. Your driver in hibernation/dump mode is kind of
operating ‘outside’ the system, which is why it is so constrained in
what it is allowed to do.
Q3. When does hiber_* drivers gets loaded in the system? Is it when
the
user clicks on “Hibernate” or is it immediately after boot time?
For the dump driver, it is definitely only loaded at crash time, so I
assume the same would apply to the hibernation driver.
You could verify this easily enough using the debugger - put a print
statement in your driver entry that fires when you detect you are being
invoked as a hibernation driver (how to detect this is well documented).
James