{
VIR_FREE(disk->name);
VIR_FREE(disk->file);
- VIR_FREE(disk->driverType);
}
void virDomainSnapshotDefFree(virDomainSnapshotDefPtr def)
if (!def->file &&
xmlStrEqual(cur->name, BAD_CAST "source")) {
def->file = virXMLPropString(cur, "file");
- } else if (!def->driverType &&
+ } else if (!def->format &&
xmlStrEqual(cur->name, BAD_CAST "driver")) {
- def->driverType = virXMLPropString(cur, "type");
+ char *driver = virXMLPropString(cur, "type");
+ def->format = virStorageFileFormatTypeFromString(driver);
+ if (def->format <= 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("unknown disk snapshot driver '%s'"),
+ driver);
+ VIR_FREE(driver);
+ goto cleanup;
+ }
+ VIR_FREE(driver);
}
}
cur = cur->next;
}
- if (!def->snapshot && (def->file || def->driverType))
+ if (!def->snapshot && (def->file || def->format))
def->snapshot = VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL;
ret = 0;
if (disk->snapshot)
virBufferAsprintf(&buf, " snapshot='%s'",
virDomainSnapshotLocationTypeToString(disk->snapshot));
- if (disk->file || disk->driverType) {
+ if (disk->file || disk->format > 0) {
virBufferAddLit(&buf, ">\n");
- if (disk->driverType)
+ if (disk->format > 0)
virBufferEscapeString(&buf, " <driver type='%s'/>\n",
- disk->driverType);
+ virStorageFileFormatTypeToString(
+ disk->format));
if (disk->file)
virBufferEscapeString(&buf, " <source file='%s'/>\n",
disk->file);
break;
case VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL:
- if (!disk->driverType) {
- if (!(disk->driverType = strdup("qcow2"))) {
- virReportOOMError();
- goto cleanup;
- }
- } else if (STRNEQ(disk->driverType, "qcow2") &&
- STRNEQ(disk->driverType, "qed")) {
+ if (!disk->format) {
+ disk->format = VIR_STORAGE_FILE_QCOW2;
+ } else if (disk->format != VIR_STORAGE_FILE_QCOW2 &&
+ disk->format != VIR_STORAGE_FILE_QED) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("external snapshot format for disk %s "
"is unsupported: %s"),
- disk->name, disk->driverType);
+ disk->name,
+ virStorageFileFormatTypeToString(disk->format));
goto cleanup;
}
if (stat(disk->file, &st) < 0) {
qemuDomainObjPrivatePtr priv = vm->privateData;
char *device = NULL;
char *source = NULL;
- int format = VIR_STORAGE_FILE_NONE;
+ int format = snap->format;
+ const char *formatStr = NULL;
char *persistSource = NULL;
int ret = -1;
int fd = -1;
return -1;
}
- if (snap->driverType) {
- format = virStorageFileFormatTypeFromString(snap->driverType);
- if (format <= 0) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("unknown driver type %s"), snap->driverType);
- goto cleanup;
- }
- }
-
if (virAsprintf(&device, "drive-%s", disk->info.alias) < 0 ||
!(source = strdup(snap->file)) ||
(persistDisk &&
disk->format = origdriver;
/* create the actual snapshot */
+ if (snap->format)
+ formatStr = virStorageFileFormatTypeToString(snap->format);
ret = qemuMonitorDiskSnapshot(priv->mon, actions, device, source,
- snap->driverType, reuse);
+ formatStr, reuse);
virDomainAuditDisk(vm, disk->src, source, "snapshot", ret >= 0);
if (ret < 0)
goto cleanup;