All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Sementsov-Ogievskiy <v.sementsov-og@mail.ru>
To: Nikita Lapshin <nikita.lapshin@openvz.org>, qemu-devel@nongnu.org
Cc: den@openvz.org, Nikita Lapshin <nikita.lapshin@virtuozzo.com>
Subject: Re: [PATCH v1 7/8] migration: analyze-migration script changed
Date: Wed, 23 Mar 2022 16:57:40 +0300	[thread overview]
Message-ID: <48f06c75-de34-ade1-afa4-bcac105e4520@mail.ru> (raw)
In-Reply-To: <20220323105400.17649-8-nikita.lapshin@openvz.org>

23.03.2022 13:53, Nikita Lapshin wrote:
> From: Nikita Lapshin <nikita.lapshin@virtuozzo.com>
> 
> 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@openvz.org>
> ---
>   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)

could this ram_only instead be stored into object, so that we do

dump = MigrationDump(args.file, ram_only=args.ram_only)

and don't update each read call?

>   
> -    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)
>       print(jsonenc.encode(dump.vmsd_desc))
>   else:
>       raise Exception("Please specify either -x, -d state or -d desc")


-- 
Best regards,
Vladimir


  parent reply	other threads:[~2022-03-23 14:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20220323105400.17649-1-nikita.lapshin@openvz.org>
     [not found] ` <20220323105400.17649-2-nikita.lapshin@openvz.org>
2022-03-23 12:28   ` [PATCH v1 1/8] migration: Implemented new parameter stream_content Vladimir Sementsov-Ogievskiy
     [not found] ` <20220323105400.17649-3-nikita.lapshin@openvz.org>
2022-03-23 12:34   ` [PATCH v1 2/8] migration: should_skip() implemented Vladimir Sementsov-Ogievskiy
     [not found] ` <20220323105400.17649-4-nikita.lapshin@openvz.org>
2022-03-23 12:40   ` [PATCH v1 3/8] migration: Add vmstate part of migration stream Vladimir Sementsov-Ogievskiy
2022-03-23 12:49     ` Vladimir Sementsov-Ogievskiy
     [not found]       ` <f03bf2db-a424-17e2-38f1-1608c004c0e4@openvz.org>
2022-03-23 14:07         ` Vladimir Sementsov-Ogievskiy
     [not found] ` <20220323105400.17649-5-nikita.lapshin@openvz.org>
2022-03-23 12:49   ` [PATCH v1 4/8] migration: Add dirty-bitmaps " Vladimir Sementsov-Ogievskiy
     [not found] ` <20220323105400.17649-6-nikita.lapshin@openvz.org>
2022-03-23 12:50   ` [PATCH v1 5/8] migration: Add block " Vladimir Sementsov-Ogievskiy
     [not found] ` <20220323105400.17649-7-nikita.lapshin@openvz.org>
2022-03-23 13:52   ` [PATCH v1 6/8] migration: Add RAM " Vladimir Sementsov-Ogievskiy
     [not found] ` <20220323105400.17649-8-nikita.lapshin@openvz.org>
2022-03-23 13:57   ` Vladimir Sementsov-Ogievskiy [this message]
2022-03-23 14:38     ` [PATCH v1 7/8] migration: analyze-migration script changed Nikita Lapshin
     [not found] ` <20220323105400.17649-9-nikita.lapshin@openvz.org>
2022-03-23 14:05   ` [PATCH v1 8/8] migration: Test for RAM and vmstate parts Vladimir Sementsov-Ogievskiy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48f06c75-de34-ade1-afa4-bcac105e4520@mail.ru \
    --to=v.sementsov-og@mail.ru \
    --cc=den@openvz.org \
    --cc=nikita.lapshin@openvz.org \
    --cc=nikita.lapshin@virtuozzo.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.