[libvirt] [PATCH v8 0/4] Handling of undefine and re define snapshots with VirtualBox 4.2 or higher

Yohan BELLEGUIC yohan.belleguic at diateam.net
Mon May 19 12:47:29 UTC 2014


Hello,

This is a new series of patches in order to support undefining and redefining 
snapshots with VirtualBox 4.2 or higher.
These patches are based on Manuel Vives' patches, taking into account Daniel 
P. Berrange's remarks.

The VirtualBox API provides only high level operations to manipulate snapshots,
so it not possible to support flags like VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE and
VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY with only API calls.
Following an IRC talk with Eric Blake, the decision was made to emulate these
behaviours by manipulating directly the .vbox XML files.

The first patch adds extra details in the snapshot XML returned by libvirt. We 
will need those details in order to redefine the snapshots.

The second patch adds a new API to manipulate the VirtualBox XML file. It 
provides several structs describing the VirtualBox XML file nodes and 
functions which can manipulate these structs.

The third patch adds support of the VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE 
and VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT flags in virDomainSnapshotCreateXML.
The idea is to unregister the machine, add the snapshot in the Virtualbox XML 
file and re-register the machine.
However, VirtualBox forbids a machine to have snapshots but no current 
snapshot. So, if the real current snapshot has not been redefined yet, we 
create fake disks, allowing us to have an intermediate state in order to not 
corrupt the snapshot's read-write disks. These fake disks will be deleted during the 
next redefine.

The fourth and last patch adds support of the 
VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY flag in virDomainSnapshotDelete.
As in the third patch, we also create fake disks to not corrupt the snapshot's read-write disks.

The patches were only tested with VirtualBox 4.3.10 and VirtualBox 4.2.24.

Regards
Yohan BELLEGUIC

v8:
* Fix patches according to Daniel P. Berrange review (May 01, 2014)
* Rename all the methods in vbox_snapshot.{c,h} 
* Add a test case for serialize and deserialize a virVBoxSnapshotConfMachine
* Fix memory leaks

v7:
* Add vbox_snapshot_conf.{h,c} files to (de)serialize VirtualBox XML files
* Update the code to use the API exposed by vbox_snapshot_conf.h
* Handle the fact that VirtualBox forbids a machine to have snapshots but no
    current snapshot

v6:
* Rebased because of a massive change in vbox_tmpl.c due to changes in
  the handling of different versions of VirtualBox

v5:
* The patches are modified according to a first review by Laine Stump:
    * renamed virSearchUuid to virSearchRegex and moved it from
      viruuid.{c,h} to virstring.{c,h}.
    * Various fixes.

v4:
* The code is compliant with Virtualbox 4.3 API
* Some minor modifications in order to satisfy "make syntax-check"

v3:
* Use of STREQ_NULLABLE instead of STREQ in one case
* Fix the method for finding uuids according to Ján Tomko review

v2:
* Fix a licence problem with the method for string replacement

Manuel VIVES (1):
  vbox_tmpl.c: Better XML description for snapshots

Yohan BELLEGUIC (3):
  Add vbox_snapshot_conf struct
  vbox_tmpl.c: Patch for redefining snapshots
  vbox_tmpl.c: Add function for undefining snapshot

 po/POTFILES.in                                     |    1 +
 src/Makefile.am                                    |    1 +
 src/vbox/vbox_snapshot_conf.c                      | 1490 +++++++++++++++
 src/vbox/vbox_snapshot_conf.h                      |  105 ++
 src/vbox/vbox_tmpl.c                               | 1982 +++++++++++++++++++-
 tests/Makefile.am                                  |   15 +
 tests/vboxsnapshotxmldata/2disks-1snap.vbox        |  322 ++++
 tests/vboxsnapshotxmldata/2disks-2snap.vbox        |  478 +++++
 .../vboxsnapshotxmldata/2disks-3snap-brother.vbox  |  786 ++++++++
 tests/vboxsnapshotxmldata/2disks-3snap.vbox        |  636 +++++++
 tests/vboxsnapshotxmldata/2disks-nosnap.vbox       |  168 ++
 tests/vboxsnapshotxmltest.c                        |  161 ++
 12 files changed, 6100 insertions(+), 45 deletions(-)
 create mode 100644 src/vbox/vbox_snapshot_conf.c
 create mode 100644 src/vbox/vbox_snapshot_conf.h
 create mode 100644 tests/vboxsnapshotxmldata/2disks-1snap.vbox
 create mode 100644 tests/vboxsnapshotxmldata/2disks-2snap.vbox
 create mode 100644 tests/vboxsnapshotxmldata/2disks-3snap-brother.vbox
 create mode 100644 tests/vboxsnapshotxmldata/2disks-3snap.vbox
 create mode 100644 tests/vboxsnapshotxmldata/2disks-nosnap.vbox
 create mode 100644 tests/vboxsnapshotxmltest.c

-- 
1.7.10.4




More information about the libvir-list mailing list