2014-05-19 12:47:31 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2014, diateam (www.diateam.net)
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2019-06-18 16:13:09 +00:00
|
|
|
#pragma once
|
2014-05-19 12:47:31 +00:00
|
|
|
|
2019-06-18 16:13:09 +00:00
|
|
|
#include "internal.h"
|
2014-05-19 12:47:31 +00:00
|
|
|
|
2019-06-18 16:13:09 +00:00
|
|
|
#define VBOX_UUID_REGEX "([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})"
|
2014-05-19 12:47:31 +00:00
|
|
|
|
|
|
|
/*Stores VirtualBox xml hard disk information
|
|
|
|
A hard disk can have a parent and children*/
|
|
|
|
typedef struct _virVBoxSnapshotConfHardDisk virVBoxSnapshotConfHardDisk;
|
|
|
|
struct _virVBoxSnapshotConfHardDisk {
|
2021-03-11 07:16:13 +00:00
|
|
|
virVBoxSnapshotConfHardDisk *parent;
|
2014-05-19 12:47:31 +00:00
|
|
|
char *uuid;
|
|
|
|
char *location;
|
|
|
|
char *format;
|
|
|
|
char *type;
|
|
|
|
size_t nchildren;
|
2021-03-11 07:16:13 +00:00
|
|
|
virVBoxSnapshotConfHardDisk **children;
|
2014-05-19 12:47:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*Stores Virtualbox xml media registry information
|
|
|
|
We separate disks from other media to manipulate them*/
|
|
|
|
typedef struct _virVBoxSnapshotConfMediaRegistry virVBoxSnapshotConfMediaRegistry;
|
|
|
|
struct _virVBoxSnapshotConfMediaRegistry {
|
|
|
|
size_t ndisks;
|
2021-03-11 07:16:13 +00:00
|
|
|
virVBoxSnapshotConfHardDisk **disks;
|
2014-05-19 12:47:31 +00:00
|
|
|
size_t notherMedia;
|
|
|
|
char **otherMedia;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*Stores VirtualBox xml snapshot information
|
|
|
|
A snapshot can have a parent and children*/
|
|
|
|
typedef struct _virVBoxSnapshotConfSnapshot virVBoxSnapshotConfSnapshot;
|
|
|
|
struct _virVBoxSnapshotConfSnapshot {
|
2021-03-11 07:16:13 +00:00
|
|
|
virVBoxSnapshotConfSnapshot *parent;
|
2014-05-19 12:47:31 +00:00
|
|
|
char *uuid;
|
|
|
|
char *name;
|
|
|
|
char *timeStamp;
|
|
|
|
char *description;
|
|
|
|
char *hardware;
|
|
|
|
char *storageController;
|
|
|
|
size_t nchildren;
|
2021-03-11 07:16:13 +00:00
|
|
|
virVBoxSnapshotConfSnapshot **children;
|
2014-05-19 12:47:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*Stores VirtualBox xml Machine information*/
|
|
|
|
typedef struct _virVBoxSnapshotConfMachine virVBoxSnapshotConfMachine;
|
|
|
|
struct _virVBoxSnapshotConfMachine {
|
|
|
|
char *uuid;
|
|
|
|
char *name;
|
|
|
|
char *currentSnapshot;
|
|
|
|
char *snapshotFolder;
|
|
|
|
int currentStateModified;
|
|
|
|
char *lastStateChange;
|
2021-03-11 07:16:13 +00:00
|
|
|
virVBoxSnapshotConfMediaRegistry *mediaRegistry;
|
2014-05-19 12:47:31 +00:00
|
|
|
char *hardware;
|
|
|
|
char *extraData;
|
2021-03-11 07:16:13 +00:00
|
|
|
virVBoxSnapshotConfSnapshot *snapshot;
|
2014-05-19 12:47:31 +00:00
|
|
|
char *storageController;
|
|
|
|
};
|
|
|
|
|
|
|
|
void
|
2021-03-11 07:16:13 +00:00
|
|
|
virVboxSnapshotConfHardDiskFree(virVBoxSnapshotConfHardDisk *disk);
|
2014-05-19 12:47:31 +00:00
|
|
|
void
|
2021-03-11 07:16:13 +00:00
|
|
|
virVBoxSnapshotConfMediaRegistryFree(virVBoxSnapshotConfMediaRegistry *mediaRegistry);
|
2014-05-19 12:47:31 +00:00
|
|
|
void
|
2021-03-11 07:16:13 +00:00
|
|
|
virVBoxSnapshotConfSnapshotFree(virVBoxSnapshotConfSnapshot *snapshot);
|
2014-05-19 12:47:31 +00:00
|
|
|
void
|
2021-03-11 07:16:13 +00:00
|
|
|
virVBoxSnapshotConfMachineFree(virVBoxSnapshotConfMachine *machine);
|
2014-05-19 12:47:31 +00:00
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virVBoxSnapshotConfMachine *
|
2014-05-19 12:47:31 +00:00
|
|
|
virVBoxSnapshotConfLoadVboxFile(const char *filePath,
|
|
|
|
const char *machineLocation);
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virVBoxSnapshotConfAddSnapshotToXmlMachine(virVBoxSnapshotConfSnapshot *snapshot,
|
|
|
|
virVBoxSnapshotConfMachine *machine,
|
2014-05-19 12:47:31 +00:00
|
|
|
const char *snapshotParentName);
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virVBoxSnapshotConfAddHardDiskToMediaRegistry(virVBoxSnapshotConfHardDisk *hardDisk,
|
|
|
|
virVBoxSnapshotConfMediaRegistry *mediaRegistry,
|
2014-05-19 12:47:31 +00:00
|
|
|
const char *parentHardDiskId);
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virVBoxSnapshotConfRemoveSnapshot(virVBoxSnapshotConfMachine *machine,
|
2014-05-19 12:47:31 +00:00
|
|
|
const char *snapshotName);
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virVBoxSnapshotConfRemoveHardDisk(virVBoxSnapshotConfMediaRegistry *mediaRegistry,
|
2014-05-19 12:47:31 +00:00
|
|
|
const char *uuid);
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virVBoxSnapshotConfSaveVboxFile(virVBoxSnapshotConfMachine *machine,
|
2014-05-19 12:47:31 +00:00
|
|
|
const char *filePath);
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virVBoxSnapshotConfIsCurrentSnapshot(virVBoxSnapshotConfMachine *machine,
|
2014-05-19 12:47:31 +00:00
|
|
|
const char *snapshotName);
|
|
|
|
int
|
|
|
|
virVBoxSnapshotConfGetRWDisksPathsFromLibvirtXML(const char *filePath,
|
|
|
|
char ***realReadWriteDisksPath);
|
|
|
|
int
|
|
|
|
virVBoxSnapshotConfGetRODisksPathsFromLibvirtXML(const char *filePath,
|
|
|
|
char ***realReadOnlyDisksPath);
|
|
|
|
const char *
|
2021-03-11 07:16:13 +00:00
|
|
|
virVBoxSnapshotConfHardDiskUuidByLocation(virVBoxSnapshotConfMachine *machine,
|
2014-05-19 12:47:31 +00:00
|
|
|
const char *location);
|
|
|
|
size_t
|
2021-03-11 07:16:13 +00:00
|
|
|
virVBoxSnapshotConfDiskListToOpen(virVBoxSnapshotConfMachine *machine,
|
|
|
|
virVBoxSnapshotConfHardDisk ***hardDiskToOpen,
|
2014-05-19 12:47:31 +00:00
|
|
|
const char *location);
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virVBoxSnapshotConfRemoveFakeDisks(virVBoxSnapshotConfMachine *machine);
|
2014-05-19 12:47:31 +00:00
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virVBoxSnapshotConfDiskIsInMediaRegistry(virVBoxSnapshotConfMachine *machine,
|
2014-05-19 12:47:31 +00:00
|
|
|
const char *location);
|
2021-03-11 07:16:13 +00:00
|
|
|
virVBoxSnapshotConfHardDisk *
|
|
|
|
virVBoxSnapshotConfHardDiskPtrByLocation(virVBoxSnapshotConfMachine *machine,
|
2014-05-19 12:47:31 +00:00
|
|
|
const char *location);
|
2021-03-11 07:16:13 +00:00
|
|
|
virVBoxSnapshotConfSnapshot *
|
|
|
|
virVBoxSnapshotConfSnapshotByName(virVBoxSnapshotConfSnapshot *snapshot,
|
2014-05-19 12:47:31 +00:00
|
|
|
const char *snapshotName);
|