mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 20:45:18 +00:00
conf: track when storage type is still undetermined
Right now, virStorageFileMetadata tracks bool backingStoreIsFile for whether the backing string specified in metadata can be resolved as a file (covering both block and regular file resources) or is treated as a network protocol. But when merging this struct with virStorageSource, it will be easier to just actually track which type of resource it is, as well as have a reserved value for the case where the resource type is unknown (or had an error during probing). * src/util/virstoragefile.h (virStorageType): Add a placeholder value, swap order to match similar public enum. * src/util/virstoragefile.c (virStorage): Update string mapping. * src/conf/domain_conf.c (virDomainDiskSourceParse) (virDomainDiskDefParseXML, virDomainDiskDefFormat) (virDomainDiskSourceFormat): Adjust clients. * src/conf/snapshot_conf.c (virDomainSnapshotDiskDefParseXML): Likewise. * src/qemu/qemu_driver.c (qemuDomainSnapshotPrepareDiskExternalBackingInactive) (qemuDomainSnapshotPrepareDiskExternalOverlayActive) (qemuDomainSnapshotPrepareDiskExternalOverlayInactive) (qemuDomainSnapshotPrepareDiskInternal) (qemuDomainSnapshotCreateSingleDiskActive): Likewise. * src/qemu/qemu_command.c (qemuGetDriveSourceString): Likewise. Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
d1a1d841db
commit
9673418ce5
@ -4965,7 +4965,7 @@ virDomainDiskSourceParse(xmlNodePtr node,
|
|||||||
|
|
||||||
memset(&host, 0, sizeof(host));
|
memset(&host, 0, sizeof(host));
|
||||||
|
|
||||||
switch (src->type) {
|
switch ((enum virStorageType)src->type) {
|
||||||
case VIR_STORAGE_TYPE_FILE:
|
case VIR_STORAGE_TYPE_FILE:
|
||||||
src->path = virXMLPropString(node, "file");
|
src->path = virXMLPropString(node, "file");
|
||||||
break;
|
break;
|
||||||
@ -5053,7 +5053,8 @@ virDomainDiskSourceParse(xmlNodePtr node,
|
|||||||
if (virDomainDiskSourcePoolDefParse(node, &src->srcpool) < 0)
|
if (virDomainDiskSourcePoolDefParse(node, &src->srcpool) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
break;
|
break;
|
||||||
default:
|
case VIR_STORAGE_TYPE_NONE:
|
||||||
|
case VIR_STORAGE_TYPE_LAST:
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("unexpected disk type %s"),
|
_("unexpected disk type %s"),
|
||||||
virStorageTypeToString(src->type));
|
virStorageTypeToString(src->type));
|
||||||
@ -5150,7 +5151,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
|
|||||||
|
|
||||||
type = virXMLPropString(node, "type");
|
type = virXMLPropString(node, "type");
|
||||||
if (type) {
|
if (type) {
|
||||||
if ((def->src.type = virStorageTypeFromString(type)) < 0) {
|
if ((def->src.type = virStorageTypeFromString(type)) <= 0) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("unknown disk type '%s'"), type);
|
_("unknown disk type '%s'"), type);
|
||||||
goto error;
|
goto error;
|
||||||
@ -14836,6 +14837,7 @@ virDomainDiskSourceFormat(virBufferPtr buf,
|
|||||||
src->seclabels, flags);
|
src->seclabels, flags);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case VIR_STORAGE_TYPE_NONE:
|
||||||
case VIR_STORAGE_TYPE_LAST:
|
case VIR_STORAGE_TYPE_LAST:
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("unexpected disk type %d"), src->type);
|
_("unexpected disk type %d"), src->type);
|
||||||
@ -14867,7 +14869,7 @@ virDomainDiskDefFormat(virBufferPtr buf,
|
|||||||
|
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
|
|
||||||
if (!type) {
|
if (!type || !def->src.type) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("unexpected disk type %d"), def->src.type);
|
_("unexpected disk type %d"), def->src.type);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -132,7 +132,7 @@ virDomainSnapshotDiskDefParseXML(xmlNodePtr node,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((type = virXMLPropString(node, "type"))) {
|
if ((type = virXMLPropString(node, "type"))) {
|
||||||
if ((def->src.type = virStorageTypeFromString(type)) < 0 ||
|
if ((def->src.type = virStorageTypeFromString(type)) <= 0 ||
|
||||||
def->src.type == VIR_STORAGE_TYPE_VOLUME ||
|
def->src.type == VIR_STORAGE_TYPE_VOLUME ||
|
||||||
def->src.type == VIR_STORAGE_TYPE_DIR) {
|
def->src.type == VIR_STORAGE_TYPE_DIR) {
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
virReportError(VIR_ERR_XML_ERROR,
|
||||||
|
@ -3856,6 +3856,7 @@ qemuGetDriveSourceString(int type,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_STORAGE_TYPE_VOLUME:
|
case VIR_STORAGE_TYPE_VOLUME:
|
||||||
|
case VIR_STORAGE_TYPE_NONE:
|
||||||
case VIR_STORAGE_TYPE_LAST:
|
case VIR_STORAGE_TYPE_LAST:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -12356,6 +12356,7 @@ qemuDomainSnapshotPrepareDiskExternalBackingInactive(virDomainDiskDefPtr disk)
|
|||||||
|
|
||||||
case VIR_STORAGE_TYPE_DIR:
|
case VIR_STORAGE_TYPE_DIR:
|
||||||
case VIR_STORAGE_TYPE_VOLUME:
|
case VIR_STORAGE_TYPE_VOLUME:
|
||||||
|
case VIR_STORAGE_TYPE_NONE:
|
||||||
case VIR_STORAGE_TYPE_LAST:
|
case VIR_STORAGE_TYPE_LAST:
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("external inactive snapshots are not supported on "
|
_("external inactive snapshots are not supported on "
|
||||||
@ -12420,6 +12421,7 @@ qemuDomainSnapshotPrepareDiskExternalOverlayActive(virDomainSnapshotDiskDefPtr d
|
|||||||
|
|
||||||
case VIR_STORAGE_TYPE_DIR:
|
case VIR_STORAGE_TYPE_DIR:
|
||||||
case VIR_STORAGE_TYPE_VOLUME:
|
case VIR_STORAGE_TYPE_VOLUME:
|
||||||
|
case VIR_STORAGE_TYPE_NONE:
|
||||||
case VIR_STORAGE_TYPE_LAST:
|
case VIR_STORAGE_TYPE_LAST:
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("external active snapshots are not supported on "
|
_("external active snapshots are not supported on "
|
||||||
@ -12444,6 +12446,7 @@ qemuDomainSnapshotPrepareDiskExternalOverlayInactive(virDomainSnapshotDiskDefPtr
|
|||||||
case VIR_STORAGE_TYPE_NETWORK:
|
case VIR_STORAGE_TYPE_NETWORK:
|
||||||
case VIR_STORAGE_TYPE_DIR:
|
case VIR_STORAGE_TYPE_DIR:
|
||||||
case VIR_STORAGE_TYPE_VOLUME:
|
case VIR_STORAGE_TYPE_VOLUME:
|
||||||
|
case VIR_STORAGE_TYPE_NONE:
|
||||||
case VIR_STORAGE_TYPE_LAST:
|
case VIR_STORAGE_TYPE_LAST:
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("external inactive snapshots are not supported on "
|
_("external inactive snapshots are not supported on "
|
||||||
@ -12561,6 +12564,7 @@ qemuDomainSnapshotPrepareDiskInternal(virConnectPtr conn,
|
|||||||
|
|
||||||
case VIR_STORAGE_TYPE_DIR:
|
case VIR_STORAGE_TYPE_DIR:
|
||||||
case VIR_STORAGE_TYPE_VOLUME:
|
case VIR_STORAGE_TYPE_VOLUME:
|
||||||
|
case VIR_STORAGE_TYPE_NONE:
|
||||||
case VIR_STORAGE_TYPE_LAST:
|
case VIR_STORAGE_TYPE_LAST:
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("internal inactive snapshots are not supported on "
|
_("internal inactive snapshots are not supported on "
|
||||||
@ -12766,7 +12770,7 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver,
|
|||||||
VIR_STRDUP(persistSource, snap->src.path) < 0)
|
VIR_STRDUP(persistSource, snap->src.path) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
switch (snap->src.type) {
|
switch ((enum virStorageType)snap->src.type) {
|
||||||
case VIR_STORAGE_TYPE_BLOCK:
|
case VIR_STORAGE_TYPE_BLOCK:
|
||||||
reuse = true;
|
reuse = true;
|
||||||
/* fallthrough */
|
/* fallthrough */
|
||||||
@ -12813,7 +12817,10 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
case VIR_STORAGE_TYPE_DIR:
|
||||||
|
case VIR_STORAGE_TYPE_VOLUME:
|
||||||
|
case VIR_STORAGE_TYPE_NONE:
|
||||||
|
case VIR_STORAGE_TYPE_LAST:
|
||||||
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
|
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
|
||||||
_("snapshots are not supported on '%s' volumes"),
|
_("snapshots are not supported on '%s' volumes"),
|
||||||
virStorageTypeToString(snap->src.type));
|
virStorageTypeToString(snap->src.type));
|
||||||
|
@ -48,8 +48,9 @@
|
|||||||
VIR_LOG_INIT("util.storagefile");
|
VIR_LOG_INIT("util.storagefile");
|
||||||
|
|
||||||
VIR_ENUM_IMPL(virStorage, VIR_STORAGE_TYPE_LAST,
|
VIR_ENUM_IMPL(virStorage, VIR_STORAGE_TYPE_LAST,
|
||||||
"block",
|
"none",
|
||||||
"file",
|
"file",
|
||||||
|
"block",
|
||||||
"dir",
|
"dir",
|
||||||
"network",
|
"network",
|
||||||
"volume")
|
"volume")
|
||||||
|
@ -38,10 +38,14 @@
|
|||||||
# define VIR_STORAGE_MAX_HEADER 0x8200
|
# define VIR_STORAGE_MAX_HEADER 0x8200
|
||||||
|
|
||||||
|
|
||||||
/* Types of disk backends (host resource) */
|
/* Types of disk backends (host resource). Comparable to the public
|
||||||
|
* virStorageVolType, except we have an undetermined state, don't have
|
||||||
|
* a netdir type, and add a volume type for reference through a
|
||||||
|
* storage pool. */
|
||||||
enum virStorageType {
|
enum virStorageType {
|
||||||
VIR_STORAGE_TYPE_BLOCK,
|
VIR_STORAGE_TYPE_NONE,
|
||||||
VIR_STORAGE_TYPE_FILE,
|
VIR_STORAGE_TYPE_FILE,
|
||||||
|
VIR_STORAGE_TYPE_BLOCK,
|
||||||
VIR_STORAGE_TYPE_DIR,
|
VIR_STORAGE_TYPE_DIR,
|
||||||
VIR_STORAGE_TYPE_NETWORK,
|
VIR_STORAGE_TYPE_NETWORK,
|
||||||
VIR_STORAGE_TYPE_VOLUME,
|
VIR_STORAGE_TYPE_VOLUME,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user