From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46665) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYVRE-0006mq-75 for qemu-devel@nongnu.org; Sun, 06 Sep 2015 04:36:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYVRB-0001ed-1P for qemu-devel@nongnu.org; Sun, 06 Sep 2015 04:36:36 -0400 Received: from mx2.suse.de ([195.135.220.15]:42132) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYVRA-0001eQ-RG for qemu-devel@nongnu.org; Sun, 06 Sep 2015 04:36:32 -0400 References: <1441482708-31848-1-git-send-email-mark.cave-ayland@ilande.co.uk> <1441482708-31848-2-git-send-email-mark.cave-ayland@ilande.co.uk> From: Alexander Graf Message-ID: <55EBFB0E.7080502@suse.de> Date: Sun, 6 Sep 2015 10:36:30 +0200 MIME-Version: 1.0 In-Reply-To: <1441482708-31848-2-git-send-email-mark.cave-ayland@ilande.co.uk> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] migration: fix analyze-migration.py script List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Mark Cave-Ayland Cc: qemu-devel@nongnu.org, dgilbert@redhat.com, quintela@redhat.com On 05.09.15 21:51, Mark Cave-Ayland wrote: > Commit 61964 "Add configuration section" broke the analyze-migration.py= script > which terminates due to the unrecognised section. Fix the script by par= sing > the contents of the configuration section directly into a new > ConfigurationSection object (although nothing is done with it yet). >=20 > Signed-off-by: Mark Cave-Ayland > --- > scripts/analyze-migration.py | 13 +++++++++++++ > 1 file changed, 13 insertions(+) >=20 > diff --git a/scripts/analyze-migration.py b/scripts/analyze-migration.p= y > index f6894be..1455387 100755 > --- a/scripts/analyze-migration.py > +++ b/scripts/analyze-migration.py > @@ -252,6 +252,15 @@ class HTABSection(object): > def getDict(self): > return "" > =20 > + > +class ConfigurationSection(object): > + def __init__(self, file): > + self.file =3D file > + > + def read(self): > + name_len =3D self.file.read32() > + name =3D self.file.readstr(len =3D name_len) > + > class VMSDFieldGeneric(object): > def __init__(self, desc, file): > self.file =3D file > @@ -474,6 +483,7 @@ class MigrationDump(object): > QEMU_VM_SECTION_FULL =3D 0x04 > QEMU_VM_SUBSECTION =3D 0x05 > QEMU_VM_VMDESCRIPTION =3D 0x06 > + QEMU_VM_CONFIGURATION =3D 0x07 > QEMU_VM_SECTION_FOOTER=3D 0x7e > =20 > def __init__(self, filename): > @@ -514,6 +524,9 @@ class MigrationDump(object): > section_type =3D file.read8() > if section_type =3D=3D self.QEMU_VM_EOF: > break > + elif section_type =3D=3D self.QEMU_VM_CONFIGURATION: > + section =3D ConfigurationSection(file) > + section.read() So since we don't have a normal section header, there is no version field either. That in turn means that the format is determined by the machine version only - bleks. So if there ever has to be more in the configuration section than the machine name, please move to a more detectable scheme. Ideally something that contains * version * length of dynamically sized fields * lenght of full blob would be ideal, so that we have a chance to at least put code into the analyze script to examine it. For now, I think the hard coded solution in the analyze script is reasonable. However, I think we should print out the name if we find it. It should be as simple as adding a special case for the configuration section in MigrationDump.getDict(). Thanks a lot for the patch :), Alex > elif section_type =3D=3D self.QEMU_VM_SECTION_START or sec= tion_type =3D=3D self.QEMU_VM_SECTION_FULL: > section_id =3D file.read32() > name =3D file.readstr() >=20