qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 5/6] migration: analyze-migration script changed


From: Vladimir Sementsov-Ogievskiy
Subject: Re: [PATCH 5/6] migration: analyze-migration script changed
Date: Tue, 28 Dec 2021 16:27:53 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0

24.12.2021 14:11, Nikita Lapshin wrote:
This script is used for RAM capabilities test. But it cannot work
in case of no vm description in migration stream.
So new flag is added to allow work this script with ram-only
migration stream.

Signed-off-by: Nikita Lapshin <nikita.lapshin@virtuozzo.com>
---
  scripts/analyze-migration.py | 19 ++++++++++++-------
  1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/scripts/analyze-migration.py b/scripts/analyze-migration.py
index b82a1b0c58..80077a09bc 100755
--- a/scripts/analyze-migration.py
+++ b/scripts/analyze-migration.py
@@ -495,7 +495,7 @@ def __init__(self, filename):
          self.filename = filename
          self.vmsd_desc = None
- def read(self, desc_only = False, dump_memory = False, write_memory = False):
+    def read(self, ram_only, desc_only = False, dump_memory = False, 
write_memory = False):
          # Read in the whole file
          file = MigrationFile(self.filename)
@@ -509,7 +509,8 @@ def read(self, desc_only = False, dump_memory = False, write_memory = False):
          if data != self.QEMU_VM_FILE_VERSION:
              raise Exception("Invalid version number %d" % data)
- self.load_vmsd_json(file)
+        if not ram_only:
+            self.load_vmsd_json(file)
# Read sections
          self.sections = collections.OrderedDict()
@@ -518,7 +519,10 @@ def read(self, desc_only = False, dump_memory = False, 
write_memory = False):
              return
ramargs = {}
-        ramargs['page_size'] = self.vmsd_desc['page_size']
+        if ram_only:
+            ramargs['page_size'] = 4096
+        else:
+            ramargs['page_size'] = self.vmsd_desc['page_size']
          ramargs['dump_memory'] = dump_memory
          ramargs['write_memory'] = write_memory
          self.section_classes[('ram',0)][1] = ramargs
@@ -579,6 +583,7 @@ def default(self, o):
  parser.add_argument("-m", "--memory", help='dump RAM contents as well', 
action='store_true')
  parser.add_argument("-d", "--dump", help='what to dump ("state" or "desc")', 
default='state')
  parser.add_argument("-x", "--extract", help='extract contents into individual 
files', action='store_true')
+parser.add_argument("--ram-only", help='parse migration dump containing only 
RAM', action='store_true')
  args = parser.parse_args()
jsonenc = JSONEncoder(indent=4, separators=(',', ': '))
@@ -586,14 +591,14 @@ def default(self, o):
  if args.extract:
      dump = MigrationDump(args.file)
- dump.read(desc_only = True)
+    dump.read(desc_only = True, ram_only = args.ram_only)
      print("desc.json")
      f = open("desc.json", "w")
      f.truncate()
      f.write(jsonenc.encode(dump.vmsd_desc))
      f.close()
- dump.read(write_memory = True)
+    dump.read(write_memory = True, ram_only = args.ram_only)
      dict = dump.getDict()
      print("state.json")
      f = open("state.json", "w")
@@ -602,12 +607,12 @@ def default(self, o):
      f.close()
  elif args.dump == "state":
      dump = MigrationDump(args.file)
-    dump.read(dump_memory = args.memory)
+    dump.read(dump_memory = args.memory, ram_only = args.ram_only)
      dict = dump.getDict()
      print(jsonenc.encode(dict))
  elif args.dump == "desc":
      dump = MigrationDump(args.file)
-    dump.read(desc_only = True)
+    dump.read(desc_only = True, ram_only = args.ram_only)

I think, ram_only can't be supperted when we want to dump description ?

Otherwise looks good to me.

      print(jsonenc.encode(dump.vmsd_desc))
  else:
      raise Exception("Please specify either -x, -d state or -d desc")



--
Best regards,
Vladimir



reply via email to

[Prev in Thread] Current Thread [Next in Thread]