qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Save IDEState data to files when VM shutdown
@ 2015-12-09  6:24 Huaicheng Li
  2015-12-09  9:20 ` Dr. David Alan Gilbert
  0 siblings, 1 reply; 3+ messages in thread
From: Huaicheng Li @ 2015-12-09  6:24 UTC (permalink / raw)
  To: qemu-devel

Hi all,

Please correct me if I’m wrong.

I made some changes to IDE emulation (add some extra structures to “struct IDEState") and want to save these info to files when VM shutdowns. So I can reload these info from files next time when VM starts.  According to my understanding, one IDEState structure is corresponding to one disk for VM and all available drives are probed/initialised by ide_init2() in hw/ide.c (I used qemu v0.11) during VM startup. It seemed that IDEState structure are saved to QEMUFile structure via pci_ide_save(), but I can only trace up to register_savevm(), where pci_ide_save() is registered as a callback. I can’t find where exactly this function starts execution or being called.  My questions are: 

(1). Does QEMUFile structure represent a running VM instance, through which I can access the IDE drive (struct IDEState) pointers ?

(2). When does qemu execute pci_ide_save()? 

(3). How does qemu handle VM shutdown? It seems ACPI event is sent to VM so guest OS will shutdown in the way like real OS running on real hardware. But how and where does qemu exactly handle this? I think I need to add my codes here. 

Any hints, suggestions would be appreciated. Thanks.

Huaicheng Li

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] Save IDEState data to files when VM shutdown
  2015-12-09  6:24 [Qemu-devel] Save IDEState data to files when VM shutdown Huaicheng Li
@ 2015-12-09  9:20 ` Dr. David Alan Gilbert
  2015-12-09 10:08   ` Huaicheng Li
  0 siblings, 1 reply; 3+ messages in thread
From: Dr. David Alan Gilbert @ 2015-12-09  9:20 UTC (permalink / raw)
  To: Huaicheng Li; +Cc: jsnow, qemu-devel

* Huaicheng Li (lhcwhu@gmail.com) wrote:
> Hi all,
> 
> Please correct me if I’m wrong.
> 
> I made some changes to IDE emulation (add some extra structures to “struct IDEState") and want to save these info to files when VM shutdowns. So I can reload these info from files next time when VM starts.  According to my understanding, one IDEState structure is corresponding to one disk for VM and all available drives are probed/initialised by ide_init2() in hw/ide.c (I used qemu v0.11) during VM startup. It seemed that IDEState structure are saved to QEMUFile structure via pci_ide_save(), but I can only trace up to register_savevm(), where pci_ide_save() is registered as a callback. I can’t find where exactly this function starts execution or being called.  My questions are: 

Version 0.11 is *ancient* - please start with something newer; pci_ide_save was removed 6 years ago.

> (1). Does QEMUFile structure represent a running VM instance, through which I can access the IDE drive (struct IDEState) pointers ?
> 
> (2). When does qemu execute pci_ide_save()? 

QEMUFile is part of the migration code; it forms a stream of data containing
all of the device and RAM State during migration.  See savevm.c for what drives
this (in migration/savevm.c in modern qemu).
Extracting the state of one device from the stream isn't that easy.

> (3). How does qemu handle VM shutdown? It seems ACPI event is sent to VM so guest OS will shutdown in the way like real OS running on real hardware. But how and where does qemu exactly handle this? I think I need to add my codes here. 

I don't know the detail of that; I suggest following
the code from qemu_system_powerdown.

Why are you trying to save the state during shutdown?

Dave

> 
> Any hints, suggestions would be appreciated. Thanks.
> 
> Huaicheng Li
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] Save IDEState data to files when VM shutdown
  2015-12-09  9:20 ` Dr. David Alan Gilbert
@ 2015-12-09 10:08   ` Huaicheng Li
  0 siblings, 0 replies; 3+ messages in thread
From: Huaicheng Li @ 2015-12-09 10:08 UTC (permalink / raw)
  To: Dr. David Alan Gilbert; +Cc: qemu-devel

> Why are you trying to save the state during shutdown?


The structure I added into IDEState keeps being updated when VM is up. So I think it’s a safe way to do this during shutdown. When the VM is started again, it can continue from the status saved during last shutdown. 

Thanks for your help. I will look into the code first.


> On Dec 9, 2015, at 3:20 AM, Dr. David Alan Gilbert <dgilbert@redhat.com> wrote:
> 
> * Huaicheng Li (lhcwhu@gmail.com) wrote:
>> Hi all,
>> 
>> Please correct me if I’m wrong.
>> 
>> I made some changes to IDE emulation (add some extra structures to “struct IDEState") and want to save these info to files when VM shutdowns. So I can reload these info from files next time when VM starts.  According to my understanding, one IDEState structure is corresponding to one disk for VM and all available drives are probed/initialised by ide_init2() in hw/ide.c (I used qemu v0.11) during VM startup. It seemed that IDEState structure are saved to QEMUFile structure via pci_ide_save(), but I can only trace up to register_savevm(), where pci_ide_save() is registered as a callback. I can’t find where exactly this function starts execution or being called.  My questions are: 
> 
> Version 0.11 is *ancient* - please start with something newer; pci_ide_save was removed 6 years ago.
> 
>> (1). Does QEMUFile structure represent a running VM instance, through which I can access the IDE drive (struct IDEState) pointers ?
>> 
>> (2). When does qemu execute pci_ide_save()? 
> 
> QEMUFile is part of the migration code; it forms a stream of data containing
> all of the device and RAM State during migration.  See savevm.c for what drives
> this (in migration/savevm.c in modern qemu).
> Extracting the state of one device from the stream isn't that easy.
> 
>> (3). How does qemu handle VM shutdown? It seems ACPI event is sent to VM so guest OS will shutdown in the way like real OS running on real hardware. But how and where does qemu exactly handle this? I think I need to add my codes here. 
> 
> I don't know the detail of that; I suggest following
> the code from qemu_system_powerdown.
> 
> Why are you trying to save the state during shutdown?
> 
> Dave
> 
>> 
>> Any hints, suggestions would be appreciated. Thanks.
>> 
>> Huaicheng Li
> --
> Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-12-09 10:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-09  6:24 [Qemu-devel] Save IDEState data to files when VM shutdown Huaicheng Li
2015-12-09  9:20 ` Dr. David Alan Gilbert
2015-12-09 10:08   ` Huaicheng Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).