qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Shahar Livne <shahar@codefidence.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] cut large snapshot startup time (Vista runs in 5 secs)
Date: Sun, 08 Jun 2008 11:10:08 +0300	[thread overview]
Message-ID: <484B93E0.5020801@codefidence.com> (raw)
In-Reply-To: <fb249edb0806011859s5e93ddeex9144cd2a267d1a@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1461 bytes --]

Andrzej - thank you for the remark.

version_id increase is indeed a good way to track the change in the 
format, and I will be happy to implement it if the maintainers find 
interest in this improvement. It can also join the next version_id 
change, which may come from other reasons.


For my purposes, I didn't have to work with the 2 formats in parallel, 
as I just ran one time conversion.

The conversion was done by firing a modified qemu that read the 
static_ram in the old format, and wrote the static_ram back in the new 
format (patch attached).

The converter was started with -S, so the VM never ran. When the monitor 
prompt appeared, I just asked for loadvm, delvm, savevm, quit, and the 
image was converted. A script did this job on the 500 old images which 
required conversion, and that was it.

Another small remark: If the old image was saved while -usb flag in the 
qemu was present, it must be present also during the conversion, or else 
the usb related state is not saved. RAM saving depends on the current 
hardware.

Shahar


andrzej zaborowski wrote:
> On 19/05/2008, Shahar Livne <shahar@codefidence.com> wrote:
>   
>>  It is important to mention that old snapshots must be converted once this
>> patch is applied.
>>     
>
> Great finding, but if the snapshot format changes, you need to at
> least attempt to detect old snapshots.  Qemu has an easy mechanism for
> this (note the version_id parameter, just increase it).
>   


[-- Attachment #2: qcow2-static-ram-format-converter.patch --]
[-- Type: text/x-patch, Size: 1670 bytes --]

Index: vl.c
===================================================================
--- vl.c	(revision 688)
+++ vl.c	(revision 689)
@@ -5788,6 +5788,10 @@
     return 0;
 }
 
+/* The PREV_BDRV_HASH_BLOCK_SIZE is used for converter */
+/* It can be set to the default of 1024, and then it */
+/* reads old format and writes new format */
+#define PREV_BDRV_HASH_BLOCK_SIZE 16384
 #define BDRV_HASH_BLOCK_SIZE 16384
 #define IOBUF_SIZE 4096
 #define RAM_CBLOCK_MAGIC 0xfabe
@@ -6013,7 +6017,7 @@
         return -EINVAL;
     if (ram_decompress_open(s, f) < 0)
         return -EINVAL;
-    for(i = 0; i < phys_ram_size; i+= BDRV_HASH_BLOCK_SIZE) {
+    for(i = 0; i < phys_ram_size; i+= PREV_BDRV_HASH_BLOCK_SIZE) {
 #ifdef USE_KVM
         if (kvm_allowed && (i>=0xa0000) && (i<0xc0000)) /* do not access video-addresses */
             continue;
@@ -6023,7 +6027,7 @@
             goto error;
         }
         if (buf[0] == 0) {
-            if (ram_decompress_buf(s, phys_ram_base + i, BDRV_HASH_BLOCK_SIZE) < 0) {
+            if (ram_decompress_buf(s, phys_ram_base + i, PREV_BDRV_HASH_BLOCK_SIZE) < 0) {
                 fprintf(stderr, "Error while reading ram block address=0x%08x", i);
                 goto error;
             }
@@ -6041,7 +6045,7 @@
                 goto error;
             }
             if (bdrv_read(bs_table[bs_index], sector_num, phys_ram_base + i, 
-                          BDRV_HASH_BLOCK_SIZE / 512) < 0) {
+                          PREV_BDRV_HASH_BLOCK_SIZE / 512) < 0) {
                 fprintf(stderr, "Error while reading sector %d:%" PRId64 "\n", 
                         bs_index, sector_num);
                 goto error;


      reply	other threads:[~2008-06-08  8:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-19 10:18 [Qemu-devel] [PATCH] cut large snapshot startup time (Vista runs in 5 secs) Shahar Livne
2008-06-02  1:59 ` andrzej zaborowski
2008-06-08  8:10   ` Shahar Livne [this message]

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=484B93E0.5020801@codefidence.com \
    --to=shahar@codefidence.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).