Page 1 of 1

How to get the Snapshot Description

Posted: 22. Jul 2008, 11:14
by samyantoun
Hi,
Does anyone know a VBoxManage command (or any other command) to get (display, print, echo) the snapshot description?

I know there is a command to set a new description

Code: Select all

VBoxManage snapshot "VM Name" edit "Snapshot Name" -newdesc "New Description"
I also know that the description is saved in the machine’s xml file, but I would prefer not to use an xml parser

Code: Select all

<Snapshots>
...
<Description>This is the Snapshot Description</Description>
</Snapshot>
Thanks in advance

Posted: 22. Jul 2008, 14:51
by TerryE
Yup any dump utility will do. It's in the first 512byte header block at bytes 0x0054 to 0x0153. See my VDI Tutorial for more details. You could write a 5 line Perl script to do the same thing.

Posted: 22. Jul 2008, 16:42
by samyantoun
Terry,

Thank you, I think we are talking about 2 different things.
As I mentioned in my post I'm talking about the Snapshot description that can be set using

Code: Select all

VBoxManage snapshot "VM Name" edit "Snapshot Name" -newdesc "New Description"
After I read your post I did an interesting experiment, I changed the description using the above mentioned command. The new description is 300 characters long. The description has been populated in the xml file but the snapshot vdi file timestamp didn't change !!!.

I even tried to read the first 512 bytes from the vdi file, but the description was not there

Code: Select all

dd if="vdifile.vdi" bs=1 count=512
I think this means that the Snapshot description is NOT written in the vdi file.

Please advise.

Posted: 22. Jul 2008, 18:25
by TerryE
Sorry yes, you are correct. The only place that the snapshot exists as a coherent entity is in the XML file. I can parse vboxmanage showvminfo <vm> -machinereadable to get the snapshot name but the description has to come from the XML. However, you don't need to use a full parser, you could just use Perl or AWK:

Code: Select all

perl -ne "print $1 if $nxt && !<description>(.*?)</description>!i; $nxt = m!uuid=..$UUID!i;"  $XMLfile

Re: How to get the Snapshot Description

Posted: 17. Mar 2011, 07:10
by harmscon
Hi Terry, I get what your perl script is trying to do but I can't get it to run. I'm only a bash masher and didn't have any success:

Code: Select all

~/.VirtualBox/Machines/Ubuntu 9.10 Desktop$ perl -ne "print $1 if $nxt && !<description>(.*?)</description>!i; $nxt = m!uuid=..$UUID!i;"  "Ubuntu 9.10 Desktop.xml"
bash: !: event not found

~/.VirtualBox/Machines/Ubuntu 9.10 Desktop$ perl -ne 'print $1 if $nxt && !<description>(.*?)</description>!i; $nxt = m!uuid=..$UUID!i;'  "Ubuntu 9.10 Desktop.xml"
syntax error at -e line 1, near "<description>("
Search pattern not terminated at -e line 1.
Can you help please?

This to me is an obvious lack of functionality- the value of setting a description from VBoxManage is lessened by not being able to retrieve it without a GUI or custom code. After looking through the VBoxManage help, I think the snapshot descriptions should be enumerated by "VBoxManage showvminfo VMNAME --details" and especially by "VBoxManage snapshot vmname showvminfo snapshotname".
Does anyone have any thoughts about this suggestion? I'll add it to the suggestions forum in a couple of days.

Re: How to get the Snapshot Description

Posted: 17. Mar 2011, 18:23
by TerryE
Sorry, I got the one liner work but obviously didn't check it as a script. This worked for me:

Code: Select all

perl -ne 'BEGIN{$UUID=shift;} print "$1\n" if $nxt && m!<description>(.*?)</description>!i; $nxt = m!uuid=..$UUID!i;' \
56693fe0-0cec-4ff4-9a6a-9f1bd37586be ~/work/Machines/blog/blog.xml
:oops: