migration: Make analyze-migration script target-page-size aware
PATCH 1/1 migration: Make analyze-migration script target-page-size aware
The configuration section has a new subsection to transmit the target page size along with the migration stream. The analyze migration script needs to learn about that to read configuration streams that were triggering this subsection to get transmitted.
With this patch applied, I can successfully analyze migration streams on AArch64 again.
--- scripts/analyze-migration.py | 13 +++++++++++++ 1 file changed, 13 insertions(+)
scripts/analyze-migration.py +13 -0
@@ -254,12 +254,25 @@ class HTABSection(object): class ConfigurationSection(object): + QEMU_VM_SUBSECTION = 0x05 + def __init__(self, file): self.file = file def read(self): name_len = self.file.read32() name = self.file.readstr(len = name_len) + oldpos = self.file.tell() + if self.file.read8() == self.QEMU_VM_SUBSECTION: + name = self.file.readstr() + version_id = self.file.read32() + if name == "configuration/target-page-bits": + target_page_size = self.file.read32() + else: + raise Exception("Unknown config subsection: %s" % name) + else: + # No subsection following, forget that we ever read anything + self.file.seek(oldpos) class VMSDFieldGeneric(object): def __init__(self, desc, file):
Signature · 1 line
1.8.5.6
scripts/analyze-migration.py class HTABSection(object):
Quoted 18 lines · * Alexander Graf ([email protected]) wrote:
The configuration section has a new subsection to transmit the target page size along with the migration stream. The analyze migration script needs to learn about that to read configuration streams that were triggering this subsection to get transmitted.
With this patch applied, I can successfully analyze migration streams on AArch64 again.
Signed-off-by Alexander Graf <[email protected]>--- scripts/analyze-migration.py | 13 +++++++++++++ 1 file changed, 13 insertions(+)scripts/analyze-migration.py +0
-0@@ -254,12 +254,25 @@ class HTABSection(object):
(Note I'm not a particularly python person, so take lightly)
scripts/analyze-migration.py class HTABSection(object): · line 258
Quoted 3 lines
scripts/analyze-migration.py +2
-0class ConfigurationSection(object): + QEMU_VM_SUBSECTION = 0x05 +
It's odd, you already have this constant defined twice in this script.
scripts/analyze-migration.py class HTABSection(object): · line 270
Quoted 12 lines
scripts/analyze-migration.py +6
-0def __init__(self, file): self.file = file def read(self): name_len = self.file.read32() name = self.file.readstr(len = name_len) + oldpos = self.file.tell() + if self.file.read8() == self.QEMU_VM_SUBSECTION: + name = self.file.readstr() + version_id = self.file.read32() + if name == "configuration/target-page-bits": + target_page_size = self.file.read32()
All of your other references to target_page_size in the script are self.TARGET_PAGE_SIZE.
You might want to make the conditional subsection check into a function somewhere, but that's OK for now.
Dave
Quoted 11 lines
scripts/analyze-migration.py +5
-0+ else: + raise Exception("Unknown config subsection: %s" % name) + else: + # No subsection following, forget that we ever read anything + self.file.seek(oldpos) class VMSDFieldGeneric(object): def __init__(self, desc, file):Signature · 1 line
1.8.5.6
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Quoted 22 lines · Dr. David Alan Gilbert
scripts/analyze-migration.py class HTABSection(object):
Quoted 18 lines · * Alexander Graf ([email protected]) wrote:
The configuration section has a new subsection to transmit the target page size along with the migration stream. The analyze migration script needs to learn about that to read configuration streams that were triggering this subsection to get transmitted.
With this patch applied, I can successfully analyze migration streams on AArch64 again.
Signed-off-by Alexander Graf <[email protected]>--- scripts/analyze-migration.py | 13 +++++++++++++ 1 file changed, 13 insertions(+)scripts/analyze-migration.py +0
-0@@ -254,12 +254,25 @@ class HTABSection(object):(Note I'm not a particularly python person, so take lightly)
Quoted 5 lines
scripts/analyze-migration.py class HTABSection(object): · line 258
Quoted 3 lines
scripts/analyze-migration.py +2
-0class ConfigurationSection(object): + QEMU_VM_SUBSECTION = 0x05 +It's odd, you already have this constant defined twice in this script.
Yes, it lives once per class. I am not sure how to easily make it a global.
Quoted 14 lines
scripts/analyze-migration.py class HTABSection(object): · line 270
Quoted 13 lines
scripts/analyze-migration.py +6
-0def __init__(self, file): self.file = file def read(self): name_len = self.file.read32() name = self.file.readstr(len = name_len) + oldpos = self.file.tell() + if self.file.read8() == self.QEMU_VM_SUBSECTION: + name = self.file.readstr() + version_id = self.file.read32() + if name == "configuration/target-page-bits": + target_page_size = self.file.read32()
Quoted 2 lines
All of your other references to
target_page_sizein the script are self.TARGET_PAGE_SIZE.
Well, all other ones are actual page sizes :). This variable is never used anywhere - we just want to stash it somewhere.
Quoted 2 lines
You might want to make the conditional subsection check into a function somewhere, but that's OK for now.
I really hope we don't need it again. All subsections should be described via the in-stream json description. We just missed out the configuration one because it's not part of the object model.
Alex
Quoted 46 lines · * Alexander Graf ([email protected]) wrote:
Quoted 22 lines · Dr. David Alan Gilbert
scripts/analyze-migration.py class HTABSection(object):
Quoted 18 lines · * Alexander Graf ([email protected]) wrote:
The configuration section has a new subsection to transmit the target page size along with the migration stream. The analyze migration script needs to learn about that to read configuration streams that were triggering this subsection to get transmitted.
With this patch applied, I can successfully analyze migration streams on AArch64 again.
Signed-off-by Alexander Graf <[email protected]>--- scripts/analyze-migration.py | 13 +++++++++++++ 1 file changed, 13 insertions(+)scripts/analyze-migration.py +0
-0@@ -254,12 +254,25 @@ class HTABSection(object):(Note I'm not a particularly python person, so take lightly)
Quoted 5 lines
scripts/analyze-migration.py class HTABSection(object): · line 258
Quoted 3 lines
scripts/analyze-migration.py +2
-0class ConfigurationSection(object): + QEMU_VM_SUBSECTION = 0x05 +It's odd, you already have this constant defined twice in this script.
Yes, it lives once per class. I am not sure how to easily make it a global.
Quoted 13 lines
Quoted 12 lines
scripts/analyze-migration.py +6
-0def __init__(self, file): self.file = file def read(self): name_len = self.file.read32() name = self.file.readstr(len = name_len) + oldpos = self.file.tell() + if self.file.read8() == self.QEMU_VM_SUBSECTION: + name = self.file.readstr() + version_id = self.file.read32() + if name == "configuration/target-page-bits": + target_page_size = self.file.read32()
Quoted 5 lines
Quoted 2 lines
All of your other references to
target_page_sizein the script are self.TARGET_PAGE_SIZE.Well, all other ones are actual page sizes :). This variable is never used anywhere - we just want to stash it somewhere.
oh, so you're not actually using the value read here to influence the parsing later?
Quoted 6 lines
Quoted 2 lines
You might want to make the conditional subsection check into a function somewhere, but that's OK for now.
I really hope we don't need it again. All subsections should be described via the in-stream json description. We just missed out the configuration one because it's not part of the object model.
OK.
Dave
Quoted 3 lines
Alex
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Quoted 47 lines · Dr. David Alan Gilbert
Quoted 46 lines · * Alexander Graf ([email protected]) wrote:
Quoted 22 lines · Dr. David Alan Gilbert
scripts/analyze-migration.py class HTABSection(object):
Quoted 18 lines · * Alexander Graf ([email protected]) wrote:
The configuration section has a new subsection to transmit the target page size along with the migration stream. The analyze migration script needs to learn about that to read configuration streams that were triggering this subsection to get transmitted.
With this patch applied, I can successfully analyze migration streams on AArch64 again.
Signed-off-by Alexander Graf <[email protected]>--- scripts/analyze-migration.py | 13 +++++++++++++ 1 file changed, 13 insertions(+)scripts/analyze-migration.py +0
-0@@ -254,12 +254,25 @@ class HTABSection(object):(Note I'm not a particularly python person, so take lightly)
Quoted 5 lines
scripts/analyze-migration.py class HTABSection(object): · line 258
Quoted 3 lines
scripts/analyze-migration.py +2
-0class ConfigurationSection(object): + QEMU_VM_SUBSECTION = 0x05 +It's odd, you already have this constant defined twice in this script.
Yes, it lives once per class. I am not sure how to easily make it a global.
Quoted 13 lines
Quoted 12 lines
scripts/analyze-migration.py +6
-0def __init__(self, file): self.file = file def read(self): name_len = self.file.read32() name = self.file.readstr(len = name_len) + oldpos = self.file.tell() + if self.file.read8() == self.QEMU_VM_SUBSECTION: + name = self.file.readstr() + version_id = self.file.read32() + if name == "configuration/target-page-bits": + target_page_size = self.file.read32()
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
All of your other references to
target_page_sizein the script are self.TARGET_PAGE_SIZE.Well, all other ones are actual page sizes :). This variable is never used anywhere - we just want to stash it somewhere.
oh, so you're not actually using the value read here to influence the parsing later?
Exactly. As far as I can tell it doesn't have any impact on the migration format, so there's no need to use it.
Alex
Quoted 46 lines · * Alexander Graf ([email protected]) wrote:
Quoted 22 lines · Dr. David Alan Gilbert
scripts/analyze-migration.py class HTABSection(object):
Quoted 18 lines · * Alexander Graf ([email protected]) wrote:
The configuration section has a new subsection to transmit the target page size along with the migration stream. The analyze migration script needs to learn about that to read configuration streams that were triggering this subsection to get transmitted.
With this patch applied, I can successfully analyze migration streams on AArch64 again.
Signed-off-by Alexander Graf <[email protected]>--- scripts/analyze-migration.py | 13 +++++++++++++ 1 file changed, 13 insertions(+)scripts/analyze-migration.py +0
-0@@ -254,12 +254,25 @@ class HTABSection(object):(Note I'm not a particularly python person, so take lightly)
Quoted 5 lines
scripts/analyze-migration.py class HTABSection(object): · line 258
Quoted 3 lines
scripts/analyze-migration.py +2
-0class ConfigurationSection(object): + QEMU_VM_SUBSECTION = 0x05 +It's odd, you already have this constant defined twice in this script.
Yes, it lives once per class. I am not sure how to easily make it a global.
Quoted 13 lines
Quoted 12 lines
scripts/analyze-migration.py +6
-0def __init__(self, file): self.file = file def read(self): name_len = self.file.read32() name = self.file.readstr(len = name_len) + oldpos = self.file.tell() + if self.file.read8() == self.QEMU_VM_SUBSECTION: + name = self.file.readstr() + version_id = self.file.read32() + if name == "configuration/target-page-bits": + target_page_size = self.file.read32()
Quoted 5 lines
Quoted 2 lines
All of your other references to
target_page_sizein the script are self.TARGET_PAGE_SIZE.Well, all other ones are actual page sizes :). This variable is never used anywhere - we just want to stash it somewhere.
Well you do read self.TARGET_PAGE_SIZE elsewhere - it determines the amount of data to read from each RAM header in RamSections::read
Also note that the value being read in the config header is target_page_bits - i.e. ln2(target_page_size).
Quoted 6 lines
Quoted 2 lines
You might want to make the conditional subsection check into a function somewhere, but that's OK for now.
I really hope we don't need it again. All subsections should be described via the in-stream json description. We just missed out the configuration one because it's not part of the object model.
Dave
Quoted 2 lines
Alex
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Quoted 21 lines · Alexander Graf
The configuration section has a new subsection to transmit the target page size along with the migration stream. The analyze migration script needs to learn about that to read configuration streams that were triggering this subsection to get transmitted.
With this patch applied, I can successfully analyze migration streams on AArch64 again.
Signed-off-by Alexander Graf <[email protected]>--- scripts/analyze-migration.py | 13 +++++++++++++ 1 file changed, 13 insertions(+)scripts/analyze-migration.py +0
-0@@ -254,12 +254,25 @@ class HTABSection(object): class ConfigurationSection(object):
scripts/analyze-migration.py class HTABSection(object): · line 266
Quoted 10 lines
scripts/analyze-migration.py +4
-0+ QEMU_VM_SUBSECTION = 0x05 + def __init__(self, file): self.file = file def read(self): name_len = self.file.read32() name = self.file.readstr(len = name_len) + oldpos = self.file.tell() + if self.file.read8() == self.QEMU_VM_SUBSECTION:
Here name_len missing?
name_len = self.file.read8()
(though all of them are going to be threw away...)
scripts/analyze-migration.py class HTABSection(object): · line 275
Quoted 9 lines
scripts/analyze-migration.py +9
-0+ name = self.file.readstr() + version_id = self.file.read32() + if name == "configuration/target-page-bits": + target_page_size = self.file.read32() + else: + raise Exception("Unknown config subsection: %s" % name) + else: + # No subsection following, forget that we ever read anything + self.file.seek(oldpos)
I guess we need self.file.file.seek(oldpos) here? Since otherwise on x86 we'll get:
Traceback (most recent call last):
File "./analyze-migration.py", line 615, in <module>
dump.read(dump_memory = args.memory)
File "./analyze-migration.py", line 542, in read
section.read()
File "./analyze-migration.py", line 275, in read
self.file.seek(oldpos)
AttributeError: 'MigrationFile' object has no attribute 'seek'
Thanks,
Signature · 1 line
Peter Xu