提交 90521d07 编写于 作者: P Peter Krempa

storage: Store RBD image name as pool and image name

Similarly to how we store gluster names, split the name into a pool and
image portions when paring the XML and store them separately.
上级 bb14d989
...@@ -8388,16 +8388,17 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node, ...@@ -8388,16 +8388,17 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node,
src->tlsFromConfig = !!tlsCfgVal; src->tlsFromConfig = !!tlsCfgVal;
} }
/* for historical reasons the volume name for gluster volume is stored /* for historical reasons we store the volume and image name in one XML
* as a part of the path. This is hard to work with when dealing with * element although it complicates thing when attempting to access them. */
* relative names. Split out the volume into a separate variable */ if (src->path &&
if (src->path && src->protocol == VIR_STORAGE_NET_PROTOCOL_GLUSTER) { (src->protocol == VIR_STORAGE_NET_PROTOCOL_GLUSTER ||
src->protocol == VIR_STORAGE_NET_PROTOCOL_RBD)) {
char *tmp; char *tmp;
if (!(tmp = strchr(src->path, '/')) || if (!(tmp = strchr(src->path, '/')) ||
tmp == src->path) { tmp == src->path) {
virReportError(VIR_ERR_XML_ERROR, virReportError(VIR_ERR_XML_ERROR,
_("missing volume name or file name in " _("can't split path '%s' into pool name and image "
"gluster source path '%s'"), src->path); "name"), src->path);
goto cleanup; goto cleanup;
} }
......
...@@ -657,7 +657,7 @@ libxlMakeNetworkDiskSrcStr(virStorageSourcePtr src, ...@@ -657,7 +657,7 @@ libxlMakeNetworkDiskSrcStr(virStorageSourcePtr src,
goto cleanup; goto cleanup;
} }
virBufferStrcat(&buf, "rbd:", src->path, NULL); virBufferStrcat(&buf, "rbd:", src->volume, "/", src->path, NULL);
if (username) { if (username) {
virBufferEscape(&buf, '\\', ":", ":id=%s", username); virBufferEscape(&buf, '\\', ":", ":id=%s", username);
......
...@@ -951,7 +951,7 @@ qemuBuildNetworkDriveStr(virStorageSourcePtr src, ...@@ -951,7 +951,7 @@ qemuBuildNetworkDriveStr(virStorageSourcePtr src,
goto cleanup; goto cleanup;
} }
virBufferStrcat(&buf, "rbd:", src->path, NULL); virBufferStrcat(&buf, "rbd:", src->volume, "/", src->path, NULL);
if (src->snapshot) if (src->snapshot)
virBufferEscape(&buf, '\\', ":", "@%s", src->snapshot); virBufferEscape(&buf, '\\', ":", "@%s", src->snapshot);
......
...@@ -2545,6 +2545,14 @@ virStorageSourceParseRBDColonString(const char *rbdstr, ...@@ -2545,6 +2545,14 @@ virStorageSourceParseRBDColonString(const char *rbdstr,
*p = '\0'; *p = '\0';
} }
/* pool vs. image name */
if ((p = strchr(src->path, '/'))) {
VIR_STEAL_PTR(src->volume, src->path);
if (VIR_STRDUP(src->path, p + 1) < 0)
goto error;
*p = '\0';
}
/* options */ /* options */
if (!options) if (!options)
return 0; /* all done */ return 0; /* all done */
...@@ -3178,7 +3186,6 @@ virStorageSourceParseBackingJSONRBD(virStorageSourcePtr src, ...@@ -3178,7 +3186,6 @@ virStorageSourceParseBackingJSONRBD(virStorageSourcePtr src,
const char *conf = virJSONValueObjectGetString(json, "conf"); const char *conf = virJSONValueObjectGetString(json, "conf");
const char *snapshot = virJSONValueObjectGetString(json, "snapshot"); const char *snapshot = virJSONValueObjectGetString(json, "snapshot");
virJSONValuePtr servers = virJSONValueObjectGetArray(json, "server"); virJSONValuePtr servers = virJSONValueObjectGetArray(json, "server");
char *fullname = NULL;
size_t nservers; size_t nservers;
size_t i; size_t i;
int ret = -1; int ret = -1;
...@@ -3197,17 +3204,12 @@ virStorageSourceParseBackingJSONRBD(virStorageSourcePtr src, ...@@ -3197,17 +3204,12 @@ virStorageSourceParseBackingJSONRBD(virStorageSourcePtr src,
return -1; return -1;
} }
/* currently we need to store the pool name and image name together, since if (VIR_STRDUP(src->volume, pool) < 0 ||
* the rest of the code is not prepared for it */ VIR_STRDUP(src->path, image) < 0 ||
if (virAsprintf(&fullname, "%s/%s", pool, image) < 0) VIR_STRDUP(src->snapshot, snapshot) < 0 ||
return -1;
if (VIR_STRDUP(src->snapshot, snapshot) < 0 ||
VIR_STRDUP(src->configFile, conf) < 0) VIR_STRDUP(src->configFile, conf) < 0)
goto cleanup; goto cleanup;
VIR_STEAL_PTR(src->path, fullname);
if (servers) { if (servers) {
nservers = virJSONValueArraySize(servers); nservers = virJSONValueArraySize(servers);
...@@ -3225,8 +3227,6 @@ virStorageSourceParseBackingJSONRBD(virStorageSourcePtr src, ...@@ -3225,8 +3227,6 @@ virStorageSourceParseBackingJSONRBD(virStorageSourcePtr src,
ret = 0; ret = 0;
cleanup: cleanup:
VIR_FREE(fullname);
return ret; return ret;
} }
......
...@@ -1040,7 +1040,7 @@ xenFormatXLDiskSrcNet(virStorageSourcePtr src) ...@@ -1040,7 +1040,7 @@ xenFormatXLDiskSrcNet(virStorageSourcePtr src)
goto cleanup; goto cleanup;
} }
virBufferStrcat(&buf, "rbd:", src->path, NULL); virBufferStrcat(&buf, "rbd:", src->volume, "/", src->path, NULL);
virBufferAddLit(&buf, ":auth_supported=none"); virBufferAddLit(&buf, ":auth_supported=none");
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
</source> </source>
</disk> </disk>
<disk name='hdh' snapshot='external' type='network'> <disk name='hdh' snapshot='external' type='network'>
<source protocol='rbd' name='name'> <source protocol='rbd' name='vol/name'>
<host name='host' port='1234'/> <host name='host' port='1234'/>
<host name='host2' port='1234' transport='rdma'/> <host name='host2' port='1234' transport='rdma'/>
<host name='host3' port='1234'/> <host name='host3' port='1234'/>
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
</source> </source>
</disk> </disk>
<disk name='hdh' snapshot='external' type='network'> <disk name='hdh' snapshot='external' type='network'>
<source protocol='rbd' name='name'> <source protocol='rbd' name='vol/name'>
<host name='host' port='1234'/> <host name='host' port='1234'/>
<host name='host2' port='1234' transport='rdma'/> <host name='host2' port='1234' transport='rdma'/>
<host name='host3' port='1234'/> <host name='host3' port='1234'/>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册