case VIR_STORAGE_TYPE_VOLUME:
case VIR_STORAGE_TYPE_NVME:
case VIR_STORAGE_TYPE_VHOST_USER:
+ case VIR_STORAGE_TYPE_LAST:
default:
virReportEnumRangeError(virStorageType, diskdef->src->type);
return -1;
src = virStorageSourceNew();
src->type = VIR_STORAGE_TYPE_FILE;
- if (type &&
- (src->type = virStorageTypeFromString(type)) <= 0) {
- virReportError(VIR_ERR_XML_ERROR,
- _("unknown storage source type '%s'"), type);
- return NULL;
+ if (type) {
+ int tmp;
+ if ((tmp = virStorageTypeFromString(type)) <= 0) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("unknown storage source type '%s'"), type);
+ return NULL;
+ }
+
+ src->type = tmp;
}
if (format &&
{
g_autoptr(virStorageSource) src = virStorageSourceNew();
VIR_XPATH_NODE_AUTORESTORE(ctxt)
- g_autofree char *type = NULL;
xmlNodePtr tmp;
ctxt->node = node;
- src->type = VIR_STORAGE_TYPE_FILE;
-
- if ((type = virXMLPropString(node, "type")) &&
- (src->type = virStorageTypeFromString(type)) <= 0) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("unknown disk type '%s'"), type);
+ if (virXMLPropEnumDefault(node, "type",
+ virStorageTypeFromString,
+ VIR_XML_PROP_NONZERO,
+ &src->type,
+ VIR_STORAGE_TYPE_FILE) < 0)
return NULL;
- }
if ((tmp = virXPathNode("./source[1]", ctxt))) {
if (virDomainStorageSourceParse(tmp, ctxt, src, flags, xmlopt) < 0)
virDomainXMLOption *xmlopt)
{
g_autofree char *snapshot = NULL;
- g_autofree char *type = NULL;
g_autofree char *driver = NULL;
g_autofree char *name = NULL;
g_autoptr(virStorageSource) src = virStorageSourceNew();
}
}
- if ((type = virXMLPropString(node, "type"))) {
- if ((src->type = virStorageTypeFromString(type)) <= 0 ||
- src->type == VIR_STORAGE_TYPE_VOLUME ||
- src->type == VIR_STORAGE_TYPE_DIR) {
- virReportError(VIR_ERR_XML_ERROR,
- _("unknown disk snapshot type '%s'"), type);
- return -1;
- }
- } else {
- src->type = VIR_STORAGE_TYPE_FILE;
+ if (virXMLPropEnumDefault(node, "type",
+ virStorageTypeFromString,
+ VIR_XML_PROP_NONZERO,
+ &src->type,
+ VIR_STORAGE_TYPE_FILE) < 0)
+ return -1;
+
+ if (src->type == VIR_STORAGE_TYPE_VOLUME ||
+ src->type == VIR_STORAGE_TYPE_DIR) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("unsupported disk snapshot type '%s'"),
+ virStorageTypeToString(src->type));
+ return -1;
}
if ((cur = virXPathNode("./source", ctxt)) &&
virObject parent;
unsigned int id; /* backing chain identifier, 0 is unset */
- int type; /* virStorageType */
+ virStorageType type;
char *path;
int protocol; /* virStorageNetProtocol */
char *volume; /* volume name for remote storage */