public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Ross Boylan <ross@biostat.ucsf.edu>
Cc: kvm@vger.kernel.org
Subject: Re: Best choice for copy/clone/snapshot
Date: Wed, 13 May 2009 10:07:44 +0300	[thread overview]
Message-ID: <4A0A71C0.1060109@redhat.com> (raw)
In-Reply-To: <1242176905.15140.38.camel@iron.psg.net>

Ross Boylan wrote:
> First, I have a feeling this might be a question I could ask on a qemu
> list.  

It is.

> Is there a way for me to tell which questions should go where?
>   

If the question is equally valid for qemu and qemu-kvm, then qemu-devel 
is the correct forum.

> Is it OK to ask here?
>   

Sure, we aren't sticklers for this sort of thing.

> As I install software onto a system I want to preserve its state--just
> the disk state---at various points so I can go back.  What is the best
> way to do this?
>   

LVM snapshots.  Read up on the 'lvcreate -s' command and option.

> First, I think I could just make a copy of the virtual disk, although I
> haven't seen this suggested anywhere.  I assume this will work if the VM
> is off; 

Yes.

> are there other circumstances in which it is safe?  

You could suspend the guest, either by having it sleep, or externally 
using ctrl-Z.

> Since my
> original virtual disk file isn't really occupying its nominal space, I
> assume this will be true of the copy too.
>
> Second, kvm-img could create a copy on write image.  There are several
> things I don't understand about this.  Suppose I go
> kvm-img -b A.img  B.img
>
> If I then go on and use A.img as I did before, changing what is on disk,
> have I screwed up B.img?
>   

Yes.  If you use an image as a backing store, you promise not to change 
it.  Use B.img instead.

> Do A.img or B.img have to be qcow2 format?  I created a raw image for
> portability.
>   

Only B.img, though it works better if both are qcow2s.

> Suppose I work for awhile installing new stuff on B.img, and then want
> to preserve the state.  Is
> kvm-img -b B.img C.img
> sensible, or is this kind of recursive operation (B.img is already the
> copy on write version of A.img) not OK?
>   

Should work.

> Does ‘commit [-f fmt] filename’, documented as
>         Commit the changes recorded in filename in its base image.
> mean commit the recorded changes TO its base image?
>   

Yes.  It was broken until recently, so use with caution.

> Here are some other things I think I don't want to do.  Please let me
> know if I'm mistaken.
>
> -snapshot on the kvm command line: nothing persistent comes of this
> (maybe if you commit you update the original image, but you don't get
> 2).
>   

Right.

> snapshot in the monitor: this snapshots the non-disk state of the VM;
> further, that state is not guaranteed to work if you later change what
> is on the disk.  I think kvm-img snapshot also accesses these
> facilities.
>   

It snapshots both the disk and non-disk state.  You have to use qcow2 
for this.


-- 
Do not meddle in the internals of kernels, for they are subtle and quick to panic.


  reply	other threads:[~2009-05-13  7:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-13  1:08 Best choice for copy/clone/snapshot Ross Boylan
2009-05-13  7:07 ` Avi Kivity [this message]
2009-05-13 15:49   ` Ross Boylan
2009-05-13 17:19     ` Charles Duffy
2009-05-14  9:16     ` Avi Kivity

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=4A0A71C0.1060109@redhat.com \
    --to=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=ross@biostat.ucsf.edu \
    /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