提交 1385c9cd 编写于 作者: E Eric Blake

snapshot: rename an enum

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.
上级 6478ec16
...@@ -3768,7 +3768,7 @@ virDomainDiskDefParseXML(virCapsPtr caps, ...@@ -3768,7 +3768,7 @@ virDomainDiskDefParseXML(virCapsPtr caps,
} }
if (snapshot) { if (snapshot) {
def->snapshot = virDomainDiskSnapshotTypeFromString(snapshot); def->snapshot = virDomainSnapshotLocationTypeFromString(snapshot);
if (def->snapshot <= 0) { if (def->snapshot <= 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("unknown disk snapshot setting '%s'"), _("unknown disk snapshot setting '%s'"),
...@@ -3776,7 +3776,7 @@ virDomainDiskDefParseXML(virCapsPtr caps, ...@@ -3776,7 +3776,7 @@ virDomainDiskDefParseXML(virCapsPtr caps,
goto error; goto error;
} }
} else if (def->readonly) { } else if (def->readonly) {
def->snapshot = VIR_DOMAIN_DISK_SNAPSHOT_NO; def->snapshot = VIR_DOMAIN_SNAPSHOT_LOCATION_NONE;
} }
if (rawio) { if (rawio) {
...@@ -11369,9 +11369,9 @@ virDomainDiskDefFormat(virBufferPtr buf, ...@@ -11369,9 +11369,9 @@ virDomainDiskDefFormat(virBufferPtr buf,
} }
} }
if (def->snapshot && 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'", virBufferAsprintf(buf, " snapshot='%s'",
virDomainDiskSnapshotTypeToString(def->snapshot)); virDomainSnapshotLocationTypeToString(def->snapshot));
virBufferAddLit(buf, ">\n"); virBufferAddLit(buf, ">\n");
if (def->driverName || def->driverType || def->cachemode || if (def->driverName || def->driverType || def->cachemode ||
......
...@@ -578,7 +578,7 @@ struct _virDomainDiskDef { ...@@ -578,7 +578,7 @@ struct _virDomainDiskDef {
int ioeventfd; int ioeventfd;
int event_idx; int event_idx;
int copy_on_read; int copy_on_read;
int snapshot; /* enum virDomainDiskSnapshot, snapshot_conf.h */ int snapshot; /* enum virDomainSnapshotLocation, snapshot_conf.h */
int startupPolicy; /* enum virDomainStartupPolicy */ int startupPolicy; /* enum virDomainStartupPolicy */
unsigned int readonly : 1; unsigned int readonly : 1;
unsigned int shared : 1; unsigned int shared : 1;
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
#define VIR_FROM_THIS VIR_FROM_DOMAIN_SNAPSHOT #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", "default",
"no", "no",
"internal", "internal",
...@@ -119,7 +119,7 @@ virDomainSnapshotDiskDefParseXML(xmlNodePtr node, ...@@ -119,7 +119,7 @@ virDomainSnapshotDiskDefParseXML(xmlNodePtr node,
snapshot = virXMLPropString(node, "snapshot"); snapshot = virXMLPropString(node, "snapshot");
if (snapshot) { if (snapshot) {
def->snapshot = virDomainDiskSnapshotTypeFromString(snapshot); def->snapshot = virDomainSnapshotLocationTypeFromString(snapshot);
if (def->snapshot <= 0) { if (def->snapshot <= 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("unknown disk snapshot setting '%s'"), _("unknown disk snapshot setting '%s'"),
...@@ -143,7 +143,7 @@ virDomainSnapshotDiskDefParseXML(xmlNodePtr node, ...@@ -143,7 +143,7 @@ virDomainSnapshotDiskDefParseXML(xmlNodePtr node,
} }
if (!def->snapshot && (def->file || def->driverType)) if (!def->snapshot && (def->file || def->driverType))
def->snapshot = VIR_DOMAIN_DISK_SNAPSHOT_EXTERNAL; def->snapshot = VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL;
ret = 0; ret = 0;
cleanup: cleanup:
...@@ -389,14 +389,16 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def, ...@@ -389,14 +389,16 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def,
disk->snapshot = disk_snapshot; disk->snapshot = disk_snapshot;
} else if (disk_snapshot && require_match && } else if (disk_snapshot && require_match &&
disk->snapshot != disk_snapshot) { disk->snapshot != disk_snapshot) {
const char *tmp = virDomainDiskSnapshotTypeToString(disk_snapshot); const char *tmp;
tmp = virDomainSnapshotLocationTypeToString(disk_snapshot);
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("disk '%s' must use snapshot mode '%s'"), _("disk '%s' must use snapshot mode '%s'"),
disk->name, tmp); disk->name, tmp);
goto cleanup; goto cleanup;
} }
if (disk->file && if (disk->file &&
disk->snapshot != VIR_DOMAIN_DISK_SNAPSHOT_EXTERNAL) { disk->snapshot != VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("file '%s' for disk '%s' requires " _("file '%s' for disk '%s' requires "
"use of external snapshot mode"), "use of external snapshot mode"),
...@@ -444,7 +446,7 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def, ...@@ -444,7 +446,7 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def,
for (i = 0; i < def->ndisks; i++) { for (i = 0; i < def->ndisks; i++) {
virDomainSnapshotDiskDefPtr disk = &def->disks[i]; virDomainSnapshotDiskDefPtr disk = &def->disks[i];
if (disk->snapshot == VIR_DOMAIN_DISK_SNAPSHOT_EXTERNAL && if (disk->snapshot == VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL &&
!disk->file) { !disk->file) {
const char *original = def->dom->disks[i]->src; const char *original = def->dom->disks[i]->src;
const char *tmp; const char *tmp;
...@@ -533,7 +535,7 @@ char *virDomainSnapshotDefFormat(const char *domain_uuid, ...@@ -533,7 +535,7 @@ char *virDomainSnapshotDefFormat(const char *domain_uuid,
virBufferEscapeString(&buf, " <disk name='%s'", disk->name); virBufferEscapeString(&buf, " <disk name='%s'", disk->name);
if (disk->snapshot) if (disk->snapshot)
virBufferAsprintf(&buf, " snapshot='%s'", virBufferAsprintf(&buf, " snapshot='%s'",
virDomainDiskSnapshotTypeToString(disk->snapshot)); virDomainSnapshotLocationTypeToString(disk->snapshot));
if (disk->file || disk->driverType) { if (disk->file || disk->driverType) {
virBufferAddLit(&buf, ">\n"); virBufferAddLit(&buf, ">\n");
if (disk->driverType) if (disk->driverType)
......
...@@ -29,13 +29,13 @@ ...@@ -29,13 +29,13 @@
/* Items related to snapshot state */ /* Items related to snapshot state */
enum virDomainDiskSnapshot { enum virDomainSnapshotLocation {
VIR_DOMAIN_DISK_SNAPSHOT_DEFAULT = 0, VIR_DOMAIN_SNAPSHOT_LOCATION_DEFAULT = 0,
VIR_DOMAIN_DISK_SNAPSHOT_NO, VIR_DOMAIN_SNAPSHOT_LOCATION_NONE,
VIR_DOMAIN_DISK_SNAPSHOT_INTERNAL, VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL,
VIR_DOMAIN_DISK_SNAPSHOT_EXTERNAL, VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL,
VIR_DOMAIN_DISK_SNAPSHOT_LAST VIR_DOMAIN_SNAPSHOT_LOCATION_LAST
}; };
enum virDomainSnapshotState { enum virDomainSnapshotState {
...@@ -50,7 +50,7 @@ typedef virDomainSnapshotDiskDef *virDomainSnapshotDiskDefPtr; ...@@ -50,7 +50,7 @@ typedef virDomainSnapshotDiskDef *virDomainSnapshotDiskDefPtr;
struct _virDomainSnapshotDiskDef { struct _virDomainSnapshotDiskDef {
char *name; /* name matching the <target dev='...' of the domain */ char *name; /* name matching the <target dev='...' of the domain */
int index; /* index within snapshot->dom->disks that matches name */ 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 *file; /* new source file when snapshot is external */
char *driverType; /* file format type of new file */ char *driverType; /* file format type of new file */
}; };
...@@ -151,7 +151,7 @@ int virDomainListSnapshots(virDomainSnapshotObjListPtr snapshots, ...@@ -151,7 +151,7 @@ int virDomainListSnapshots(virDomainSnapshotObjListPtr snapshots,
virDomainSnapshotPtr **snaps, virDomainSnapshotPtr **snaps,
unsigned int flags); unsigned int flags);
VIR_ENUM_DECL(virDomainDiskSnapshot) VIR_ENUM_DECL(virDomainSnapshotLocation)
VIR_ENUM_DECL(virDomainSnapshotState) VIR_ENUM_DECL(virDomainSnapshotState)
#endif /* __SNAPSHOT_CONF_H */ #endif /* __SNAPSHOT_CONF_H */
...@@ -341,8 +341,6 @@ virDomainDiskIoTypeToString; ...@@ -341,8 +341,6 @@ virDomainDiskIoTypeToString;
virDomainDiskPathByName; virDomainDiskPathByName;
virDomainDiskRemove; virDomainDiskRemove;
virDomainDiskRemoveByName; virDomainDiskRemoveByName;
virDomainDiskSnapshotTypeFromString;
virDomainDiskSnapshotTypeToString;
virDomainDiskTypeFromString; virDomainDiskTypeFromString;
virDomainDiskTypeToString; virDomainDiskTypeToString;
virDomainEmulatorPinAdd; virDomainEmulatorPinAdd;
...@@ -485,6 +483,8 @@ virDomainSnapshotFindByName; ...@@ -485,6 +483,8 @@ virDomainSnapshotFindByName;
virDomainSnapshotForEach; virDomainSnapshotForEach;
virDomainSnapshotForEachChild; virDomainSnapshotForEachChild;
virDomainSnapshotForEachDescendant; virDomainSnapshotForEachDescendant;
virDomainSnapshotLocationTypeFromString;
virDomainSnapshotLocationTypeToString;
virDomainSnapshotObjListGetNames; virDomainSnapshotObjListGetNames;
virDomainSnapshotObjListNum; virDomainSnapshotObjListNum;
virDomainSnapshotObjListRemove; virDomainSnapshotObjListRemove;
......
...@@ -10558,7 +10558,7 @@ qemuDomainSnapshotDiskPrepare(virDomainObjPtr vm, virDomainSnapshotDefPtr def, ...@@ -10558,7 +10558,7 @@ qemuDomainSnapshotDiskPrepare(virDomainObjPtr vm, virDomainSnapshotDefPtr def,
virDomainSnapshotDiskDefPtr disk = &def->disks[i]; virDomainSnapshotDiskDefPtr disk = &def->disks[i];
switch (disk->snapshot) { switch (disk->snapshot) {
case VIR_DOMAIN_DISK_SNAPSHOT_INTERNAL: case VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL:
if (active) { if (active) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("active qemu domains require external disk " _("active qemu domains require external disk "
...@@ -10578,7 +10578,7 @@ qemuDomainSnapshotDiskPrepare(virDomainObjPtr vm, virDomainSnapshotDefPtr def, ...@@ -10578,7 +10578,7 @@ qemuDomainSnapshotDiskPrepare(virDomainObjPtr vm, virDomainSnapshotDefPtr def,
found = true; found = true;
break; break;
case VIR_DOMAIN_DISK_SNAPSHOT_EXTERNAL: case VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL:
if (!disk->driverType) { if (!disk->driverType) {
if (!(disk->driverType = strdup("qcow2"))) { if (!(disk->driverType = strdup("qcow2"))) {
virReportOOMError(); virReportOOMError();
...@@ -10610,10 +10610,10 @@ qemuDomainSnapshotDiskPrepare(virDomainObjPtr vm, virDomainSnapshotDefPtr def, ...@@ -10610,10 +10610,10 @@ qemuDomainSnapshotDiskPrepare(virDomainObjPtr vm, virDomainSnapshotDefPtr def,
external++; external++;
break; break;
case VIR_DOMAIN_DISK_SNAPSHOT_NO: case VIR_DOMAIN_SNAPSHOT_LOCATION_NONE:
break; break;
case VIR_DOMAIN_DISK_SNAPSHOT_DEFAULT: case VIR_DOMAIN_SNAPSHOT_LOCATION_DEFAULT:
default: default:
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("unexpected code path")); _("unexpected code path"));
...@@ -10668,7 +10668,7 @@ qemuDomainSnapshotCreateSingleDiskActive(struct qemud_driver *driver, ...@@ -10668,7 +10668,7 @@ qemuDomainSnapshotCreateSingleDiskActive(struct qemud_driver *driver,
char *origdriver = NULL; char *origdriver = NULL;
bool need_unlink = false; 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", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("unexpected code path")); _("unexpected code path"));
return -1; return -1;
...@@ -10919,7 +10919,7 @@ qemuDomainSnapshotCreateDiskActive(virConnectPtr conn, ...@@ -10919,7 +10919,7 @@ qemuDomainSnapshotCreateDiskActive(virConnectPtr conn,
for (i = 0; i < snap->def->ndisks; i++) { for (i = 0; i < snap->def->ndisks; i++) {
virDomainDiskDefPtr persistDisk = NULL; 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; continue;
if (vm->newDef) { if (vm->newDef) {
int indx = virDomainDiskIndexByName(vm->newDef, int indx = virDomainDiskIndexByName(vm->newDef,
...@@ -10949,7 +10949,8 @@ qemuDomainSnapshotCreateDiskActive(virConnectPtr conn, ...@@ -10949,7 +10949,8 @@ qemuDomainSnapshotCreateDiskActive(virConnectPtr conn,
while (--i >= 0) { while (--i >= 0) {
virDomainDiskDefPtr persistDisk = NULL; 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; continue;
if (vm->newDef) { if (vm->newDef) {
int indx = virDomainDiskIndexByName(vm->newDef, int indx = virDomainDiskIndexByName(vm->newDef,
...@@ -11178,7 +11179,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain, ...@@ -11178,7 +11179,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
} }
if (def->state == VIR_DOMAIN_DISK_SNAPSHOT && def->dom) { if (def->state == VIR_DOMAIN_DISK_SNAPSHOT && def->dom) {
if (virDomainSnapshotAlignDisks(def, if (virDomainSnapshotAlignDisks(def,
VIR_DOMAIN_DISK_SNAPSHOT_EXTERNAL, VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL,
false) < 0) false) < 0)
goto cleanup; goto cleanup;
} }
...@@ -11199,7 +11200,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain, ...@@ -11199,7 +11200,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
goto cleanup; goto cleanup;
} }
if (virDomainSnapshotAlignDisks(def, if (virDomainSnapshotAlignDisks(def,
VIR_DOMAIN_DISK_SNAPSHOT_EXTERNAL, VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL,
false) < 0) false) < 0)
goto cleanup; goto cleanup;
if (qemuDomainSnapshotDiskPrepare(vm, def, &flags) < 0) if (qemuDomainSnapshotDiskPrepare(vm, def, &flags) < 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册