[libvirt] [PATCH v7 0/4] Handling of undefine and re define snapshots with VirtualBox 4.2 or higher
by Yohan BELLEGUIC
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
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 | 1383 +++++++++++++++++++++++++
src/vbox/vbox_snapshot_conf.h | 100 ++
src/vbox/vbox_tmpl.c | 2225 +++++++++++++++++++++++++++++++++++++----
5 files changed, 3538 insertions(+), 172 deletions(-)
create mode 100644 src/vbox/vbox_snapshot_conf.c
create mode 100644 src/vbox/vbox_snapshot_conf.h
--
1.7.10.4
10 years, 7 months
[libvirt] [PATCH] conf: handle 'vda[-1]' uniformly
by Eric Blake
Commit f22b7899 stumbled across a difference between 32-bit and
64-bit platforms; on 64-bit, parsing "-1" as a long produces
0xffffffffffffffff, which does not fit in unsigned int; but on
32-bit, it parses as 0xffffffff, which DOES fit. Another patch
will tweak virStrToLong_ui to behave the same across platforms,
but regardless of which of the two choices it makes, the chain
lookup code wants to reject negative numbers rather than treating
it as large integers.
* src/util/virstoragefile.c (virStorageFileParseChainIndex):
Reject negative sign.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Therefore, although this qualifies as a build-breaker fix on
32-bit, I haven't pushed it yet: I'm still working on my patch
to virstring.c for uniform behavior; and that turned up the
fact that virstringtest.c doesn't have coverage of integer
parsing, so of course, I have to expand that test too...
src/util/virstoragefile.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index dcce1ef..5d933a4 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -1525,7 +1525,9 @@ virStorageFileParseChainIndex(const char *diskTarget,
if (virStringListLength(strings) != 2)
goto cleanup;
- if (virStrToLong_ui(strings[1], &suffix, 10, &idx) < 0 ||
+ /* Rule out spaces or negative sign */
+ if (!c_isdigit(*strings[1]) ||
+ virStrToLong_ui(strings[1], &suffix, 10, &idx) < 0 ||
STRNEQ(suffix, "]"))
goto cleanup;
--
1.9.0
10 years, 7 months