From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39345) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a6av3-0007n2-UX for qemu-devel@nongnu.org; Wed, 09 Dec 2015 04:20:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a6auz-0003Lc-UZ for qemu-devel@nongnu.org; Wed, 09 Dec 2015 04:20:17 -0500 Received: from mx1.redhat.com ([209.132.183.28]:32973) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a6auz-0003LY-Oq for qemu-devel@nongnu.org; Wed, 09 Dec 2015 04:20:13 -0500 Date: Wed, 9 Dec 2015 09:20:09 +0000 From: "Dr. David Alan Gilbert" Message-ID: <20151209092008.GB2712@work-vm> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable 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: Huaicheng Li Cc: jsnow@redhat.com, qemu-devel@nongnu.org * 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 shutdow= ns. So I can reload these info from files next time when VM starts. Acco= rding 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 IDES= tate structure are saved to QEMUFile structure via pci_ide_save(), but I = can only trace up to register_savevm(), where pci_ide_save() is registere= d as a callback. I can=E2=80=99t find where exactly this function starts = execution or being called. My questions are:=20 Version 0.11 is *ancient* - please start with something newer; pci_ide_sa= ve was removed 6 years ago. > (1). Does QEMUFile structure represent a running VM instance, through w= hich I can access the IDE drive (struct IDEState) pointers ? >=20 > (2). When does qemu execute pci_ide_save()?=20 QEMUFile is part of the migration code; it forms a stream of data contain= ing 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 V= M so guest OS will shutdown in the way like real OS running on real hardw= are. But how and where does qemu exactly handle this? I think I need to a= dd my codes here.=20 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 >=20 > Any hints, suggestions would be appreciated. Thanks. >=20 > Huaicheng Li -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK