The name 'virDomainDiskSnapshot' didn't fit in with our normal
conventions of using a prefix hinting that it is related to a
virDomainSnapshotPtr. Also, a future patch will reuse the
enum for declaring where the VM memory is stored.
* src/conf/snapshot_conf.h (virDomainDiskSnapshot): Rename...
(virDomainSnapshotLocation): ...to this.
(_virDomainSnapshotDiskDef): Update clients.
* src/conf/domain_conf.h (_virDomainDiskDef): Likewise.
* src/libvirt_private.syms (domain_conf.h): Likewise.
* src/conf/domain_conf.c (virDomainDiskDefParseXML)
(virDomainDiskDefFormat): Likewise.
* src/conf/snapshot_conf.c: (virDomainSnapshotDiskDefParseXML)
(virDomainSnapshotAlignDisks, virDomainSnapshotDefFormat):
Likewise.
* src/qemu/qemu_driver.c (qemuDomainSnapshotDiskPrepare)
(qemuDomainSnapshotCreateSingleDiskActive)
(qemuDomainSnapshotCreateDiskActive, qemuDomainSnapshotCreateXML):
Likewise.
---
src/conf/domain_conf.c | 8 ++++----
src/conf/domain_conf.h | 2 +-
src/conf/snapshot_conf.c | 16 +++++++++-------
src/conf/snapshot_conf.h | 16 ++++++++--------
src/libvirt_private.syms | 4 ++--
src/qemu/qemu_driver.c | 19 ++++++++++---------
6 files changed, 34 insertions(+), 31 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e2700fa..e5069dc 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -3594,7 +3594,7 @@ virDomainDiskDefParseXML(virCapsPtr caps,
}
if (snapshot) {
- def->snapshot = virDomainDiskSnapshotTypeFromString(snapshot);
+ def->snapshot = virDomainSnapshotLocationTypeFromString(snapshot);
if (def->snapshot <= 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unknown disk snapshot setting '%s'"),
@@ -3602,7 +3602,7 @@ virDomainDiskDefParseXML(virCapsPtr caps,
goto error;
}
} else if (def->readonly) {
- def->snapshot = VIR_DOMAIN_DISK_SNAPSHOT_NO;
+ def->snapshot = VIR_DOMAIN_SNAPSHOT_LOCATION_NONE;
}
if (rawio) {
@@ -11045,9 +11045,9 @@ virDomainDiskDefFormat(virBufferPtr buf,
}
}
if (def->snapshot &&
- !(def->snapshot == VIR_DOMAIN_DISK_SNAPSHOT_NO && def->readonly))
+ !(def->snapshot == VIR_DOMAIN_SNAPSHOT_LOCATION_NONE &&
def->readonly))
virBufferAsprintf(buf, " snapshot='%s'",
- virDomainDiskSnapshotTypeToString(def->snapshot));
+ virDomainSnapshotLocationTypeToString(def->snapshot));
virBufferAddLit(buf, ">\n");
if (def->driverName || def->driverType || def->cachemode ||
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 4b4719e..d7a55b9 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -562,7 +562,7 @@ struct _virDomainDiskDef {
int ioeventfd;
int event_idx;
int copy_on_read;
- int snapshot; /* enum virDomainDiskSnapshot, snapshot_conf.h */
+ int snapshot; /* enum virDomainSnapshotLocation, snapshot_conf.h */
int startupPolicy; /* enum virDomainStartupPolicy */
unsigned int readonly : 1;
unsigned int shared : 1;
diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index 894a74c..b9eb74c 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -51,7 +51,7 @@
#define VIR_FROM_THIS VIR_FROM_DOMAIN_SNAPSHOT
-VIR_ENUM_IMPL(virDomainDiskSnapshot, VIR_DOMAIN_DISK_SNAPSHOT_LAST,
+VIR_ENUM_IMPL(virDomainSnapshotLocation, VIR_DOMAIN_SNAPSHOT_LOCATION_LAST,
"default",
"no",
"internal",
@@ -120,7 +120,7 @@ virDomainSnapshotDiskDefParseXML(xmlNodePtr node,
snapshot = virXMLPropString(node, "snapshot");
if (snapshot) {
- def->snapshot = virDomainDiskSnapshotTypeFromString(snapshot);
+ def->snapshot = virDomainSnapshotLocationTypeFromString(snapshot);
if (def->snapshot <= 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unknown disk snapshot setting '%s'"),
@@ -144,7 +144,7 @@ virDomainSnapshotDiskDefParseXML(xmlNodePtr node,
}
if (!def->snapshot && (def->file || def->driverType))
- def->snapshot = VIR_DOMAIN_DISK_SNAPSHOT_EXTERNAL;
+ def->snapshot = VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL;
ret = 0;
cleanup:
@@ -390,14 +390,16 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def,
disk->snapshot = disk_snapshot;
} else if (disk_snapshot && require_match &&
disk->snapshot != disk_snapshot) {
- const char *tmp = virDomainDiskSnapshotTypeToString(disk_snapshot);
+ const char *tmp;
+
+ tmp = virDomainSnapshotLocationTypeToString(disk_snapshot);
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("disk '%s' must use snapshot mode
'%s'"),
disk->name, tmp);
goto cleanup;
}
if (disk->file &&
- disk->snapshot != VIR_DOMAIN_DISK_SNAPSHOT_EXTERNAL) {
+ disk->snapshot != VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("file '%s' for disk '%s' requires
"
"use of external snapshot mode"),
@@ -445,7 +447,7 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def,
for (i = 0; i < def->ndisks; i++) {
virDomainSnapshotDiskDefPtr disk = &def->disks[i];
- if (disk->snapshot == VIR_DOMAIN_DISK_SNAPSHOT_EXTERNAL &&
+ if (disk->snapshot == VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL &&
!disk->file) {
const char *original = def->dom->disks[i]->src;
const char *tmp;
@@ -534,7 +536,7 @@ char *virDomainSnapshotDefFormat(const char *domain_uuid,
virBufferEscapeString(&buf, " <disk name='%s'",
disk->name);
if (disk->snapshot)
virBufferAsprintf(&buf, " snapshot='%s'",
- virDomainDiskSnapshotTypeToString(disk->snapshot));
+
virDomainSnapshotLocationTypeToString(disk->snapshot));
if (disk->file || disk->driverType) {
virBufferAddLit(&buf, ">\n");
if (disk->driverType)
diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h
index 314c4d1..7d46a82 100644
--- a/src/conf/snapshot_conf.h
+++ b/src/conf/snapshot_conf.h
@@ -29,13 +29,13 @@
/* Items related to snapshot state */
-enum virDomainDiskSnapshot {
- VIR_DOMAIN_DISK_SNAPSHOT_DEFAULT = 0,
- VIR_DOMAIN_DISK_SNAPSHOT_NO,
- VIR_DOMAIN_DISK_SNAPSHOT_INTERNAL,
- VIR_DOMAIN_DISK_SNAPSHOT_EXTERNAL,
+enum virDomainSnapshotLocation {
+ VIR_DOMAIN_SNAPSHOT_LOCATION_DEFAULT = 0,
+ VIR_DOMAIN_SNAPSHOT_LOCATION_NONE,
+ VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL,
+ VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL,
- VIR_DOMAIN_DISK_SNAPSHOT_LAST
+ VIR_DOMAIN_SNAPSHOT_LOCATION_LAST
};
enum virDomainSnapshotState {
@@ -50,7 +50,7 @@ typedef virDomainSnapshotDiskDef *virDomainSnapshotDiskDefPtr;
struct _virDomainSnapshotDiskDef {
char *name; /* name matching the <target dev='...' of the domain */
int index; /* index within snapshot->dom->disks that matches name */
- int snapshot; /* enum virDomainDiskSnapshot */
+ int snapshot; /* enum virDomainSnapshotLocation */
char *file; /* new source file when snapshot is external */
char *driverType; /* file format type of new file */
};
@@ -151,7 +151,7 @@ int virDomainListSnapshots(virDomainSnapshotObjListPtr snapshots,
virDomainSnapshotPtr **snaps,
unsigned int flags);
-VIR_ENUM_DECL(virDomainDiskSnapshot)
+VIR_ENUM_DECL(virDomainSnapshotLocation)
VIR_ENUM_DECL(virDomainSnapshotState)
#endif /* __SNAPSHOT_CONF_H */
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index bf37cb3..1aefb74 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -331,8 +331,6 @@ virDomainDiskIoTypeToString;
virDomainDiskPathByName;
virDomainDiskRemove;
virDomainDiskRemoveByName;
-virDomainDiskSnapshotTypeFromString;
-virDomainDiskSnapshotTypeToString;
virDomainDiskTypeFromString;
virDomainDiskTypeToString;
virDomainFSDefFree;
@@ -473,6 +471,8 @@ virDomainSnapshotFindByName;
virDomainSnapshotForEach;
virDomainSnapshotForEachChild;
virDomainSnapshotForEachDescendant;
+virDomainSnapshotLocationTypeFromString;
+virDomainSnapshotLocationTypeToString;
virDomainSnapshotObjListGetNames;
virDomainSnapshotObjListNum;
virDomainSnapshotObjListRemove;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 11e043f..8264bf2 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -10039,7 +10039,7 @@ qemuDomainSnapshotDiskPrepare(virDomainObjPtr vm,
virDomainSnapshotDefPtr def,
virDomainSnapshotDiskDefPtr disk = &def->disks[i];
switch (disk->snapshot) {
- case VIR_DOMAIN_DISK_SNAPSHOT_INTERNAL:
+ case VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL:
if (active) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("active qemu domains require external disk "
@@ -10059,7 +10059,7 @@ qemuDomainSnapshotDiskPrepare(virDomainObjPtr vm,
virDomainSnapshotDefPtr def,
found = true;
break;
- case VIR_DOMAIN_DISK_SNAPSHOT_EXTERNAL:
+ case VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL:
if (!disk->driverType) {
if (!(disk->driverType = strdup("qcow2"))) {
virReportOOMError();
@@ -10091,10 +10091,10 @@ qemuDomainSnapshotDiskPrepare(virDomainObjPtr vm,
virDomainSnapshotDefPtr def,
external++;
break;
- case VIR_DOMAIN_DISK_SNAPSHOT_NO:
+ case VIR_DOMAIN_SNAPSHOT_LOCATION_NONE:
break;
- case VIR_DOMAIN_DISK_SNAPSHOT_DEFAULT:
+ case VIR_DOMAIN_SNAPSHOT_LOCATION_DEFAULT:
default:
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("unexpected code path"));
@@ -10149,7 +10149,7 @@ qemuDomainSnapshotCreateSingleDiskActive(struct qemud_driver
*driver,
char *origdriver = NULL;
bool need_unlink = false;
- if (snap->snapshot != VIR_DOMAIN_DISK_SNAPSHOT_EXTERNAL) {
+ if (snap->snapshot != VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("unexpected code path"));
return -1;
@@ -10400,7 +10400,7 @@ qemuDomainSnapshotCreateDiskActive(virConnectPtr conn,
for (i = 0; i < snap->def->ndisks; i++) {
virDomainDiskDefPtr persistDisk = NULL;
- if (snap->def->disks[i].snapshot == VIR_DOMAIN_DISK_SNAPSHOT_NO)
+ if (snap->def->disks[i].snapshot == VIR_DOMAIN_SNAPSHOT_LOCATION_NONE)
continue;
if (vm->newDef) {
int indx = virDomainDiskIndexByName(vm->newDef,
@@ -10430,7 +10430,8 @@ qemuDomainSnapshotCreateDiskActive(virConnectPtr conn,
while (--i >= 0) {
virDomainDiskDefPtr persistDisk = NULL;
- if (snap->def->disks[i].snapshot == VIR_DOMAIN_DISK_SNAPSHOT_NO)
+ if (snap->def->disks[i].snapshot ==
+ VIR_DOMAIN_SNAPSHOT_LOCATION_NONE)
continue;
if (vm->newDef) {
int indx = virDomainDiskIndexByName(vm->newDef,
@@ -10659,7 +10660,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
}
if (def->state == VIR_DOMAIN_DISK_SNAPSHOT && def->dom) {
if (virDomainSnapshotAlignDisks(def,
- VIR_DOMAIN_DISK_SNAPSHOT_EXTERNAL,
+ VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL,
false) < 0)
goto cleanup;
}
@@ -10680,7 +10681,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
goto cleanup;
}
if (virDomainSnapshotAlignDisks(def,
- VIR_DOMAIN_DISK_SNAPSHOT_EXTERNAL,
+ VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL,
false) < 0)
goto cleanup;
if (qemuDomainSnapshotDiskPrepare(vm, def, &flags) < 0)
--
1.7.11.2