How to get the Snapshot Description

This is for discussing general topics about how to use VirtualBox.
Post Reply
samyantoun
Posts: 5
Joined: 9. Jul 2008, 23:20

How to get the Snapshot Description

Post 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
TerryE
Volunteer
Posts: 3572
Joined: 28. May 2008, 08:40
Primary OS: Ubuntu other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Ubuntu 10.04 & 11.10, both Svr&Wstn, Debian, CentOS
Contact:

Post 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.
Read the Forum Posting Guide
Google your Q site:VirtualBox.org or search for the answer before posting.
samyantoun
Posts: 5
Joined: 9. Jul 2008, 23:20

Post 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.
TerryE
Volunteer
Posts: 3572
Joined: 28. May 2008, 08:40
Primary OS: Ubuntu other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Ubuntu 10.04 & 11.10, both Svr&Wstn, Debian, CentOS
Contact:

Post 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
Read the Forum Posting Guide
Google your Q site:VirtualBox.org or search for the answer before posting.
harmscon
Posts: 8
Joined: 30. Apr 2009, 03:02
Primary OS: Debian Lenny
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Debian

Re: How to get the Snapshot Description

Post 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.
TerryE
Volunteer
Posts: 3572
Joined: 28. May 2008, 08:40
Primary OS: Ubuntu other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Ubuntu 10.04 & 11.10, both Svr&Wstn, Debian, CentOS
Contact:

Re: How to get the Snapshot Description

Post 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:
Read the Forum Posting Guide
Google your Q site:VirtualBox.org or search for the answer before posting.
Post Reply