From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49905) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a6bfX-0008Vh-Me for qemu-devel@nongnu.org; Wed, 09 Dec 2015 05:08:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a6bfS-0006cR-JC for qemu-devel@nongnu.org; Wed, 09 Dec 2015 05:08:19 -0500 Received: from mail-ig0-x22e.google.com ([2607:f8b0:4001:c05::22e]:37198) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a6bfS-0006cN-Ep for qemu-devel@nongnu.org; Wed, 09 Dec 2015 05:08:14 -0500 Received: by igcto18 with SMTP id to18so36674252igc.0 for ; Wed, 09 Dec 2015 02:08:14 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 9.1 \(3096.5\)) From: Huaicheng Li In-Reply-To: <20151209092008.GB2712@work-vm> Date: Wed, 9 Dec 2015 04:08:12 -0600 Content-Transfer-Encoding: quoted-printable Message-Id: <844F969F-F793-4190-93A6-3C20491D8439@gmail.com> References: <20151209092008.GB2712@work-vm> Subject: Re: [Qemu-devel] Save IDEState data to files when VM shutdown List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Dr. David Alan Gilbert" Cc: qemu-devel@nongnu.org > 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=E2=80=99s a safe way to do this during shutdown. When the = VM is started again, it can continue from the status saved during last = shutdown.=20 Thanks for your help. I will look into the code first. > On Dec 9, 2015, at 3:20 AM, Dr. David Alan Gilbert = wrote: >=20 > * Huaicheng Li (lhcwhu@gmail.com) wrote: >> Hi all, >>=20 >> Please correct me if I=E2=80=99m wrong. >>=20 >> I made some changes to IDE emulation (add some extra structures to = =E2=80=9Cstruct 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=E2=80=99t find where exactly this function starts execution or being = called. My questions are:=20 >=20 > Version 0.11 is *ancient* - please start with something newer; = pci_ide_save was removed 6 years ago. >=20 >> (1). Does QEMUFile structure represent a running VM instance, through = which I can access the IDE drive (struct IDEState) pointers ? >>=20 >> (2). When does qemu execute pci_ide_save()?=20 >=20 > 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. >=20 >> (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.=20 >=20 > I don't know the detail of that; I suggest following > the code from qemu_system_powerdown. >=20 > Why are you trying to save the state during shutdown? >=20 > Dave >=20 >>=20 >> Any hints, suggestions would be appreciated. Thanks. >>=20 >> Huaicheng Li > -- > Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK