Similarly to how we store gluster names, split the name into a pool and
image portions when paring the XML and store them separately.
---
src/conf/domain_conf.c | 13 +++++++------
src/libxl/libxl_conf.c | 2 +-
src/qemu/qemu_command.c | 2 +-
src/util/virstoragefile.c | 22 +++++++++++-----------
src/xenconfig/xen_xl.c | 2 +-
tests/domainsnapshotxml2xmlin/disk_snapshot.xml | 2 +-
tests/domainsnapshotxml2xmlout/disk_snapshot.xml | 2 +-
7 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 01cd3811c..a7fe1ac85 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -8383,16 +8383,17 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node,
src->tlsFromConfig = !!tlsCfgVal;
}
- /* for historical reasons the volume name for gluster volume is stored
- * as a part of the path. This is hard to work with when dealing with
- * relative names. Split out the volume into a separate variable */
- if (src->path && src->protocol == VIR_STORAGE_NET_PROTOCOL_GLUSTER) {
+ /* for historical reasons we store the volume and image name in one XML
+ * element although it complicates thing when attempting to access them. */
+ if (src->path &&
+ (src->protocol == VIR_STORAGE_NET_PROTOCOL_GLUSTER ||
+ src->protocol == VIR_STORAGE_NET_PROTOCOL_RBD)) {
char *tmp;
if (!(tmp = strchr(src->path, '/')) ||
tmp == src->path) {
virReportError(VIR_ERR_XML_ERROR,
- _("missing volume name or file name in "
- "gluster source path '%s'"),
src->path);
+ _("can't split path '%s' into pool name and
image "
+ "name"), src->path);
goto cleanup;
}
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index ecbabfc79..63397e94c 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -657,7 +657,7 @@ libxlMakeNetworkDiskSrcStr(virStorageSourcePtr src,
goto cleanup;
}
- virBufferStrcat(&buf, "rbd:", src->path, NULL);
+ virBufferStrcat(&buf, "rbd:", src->volume, "/",
src->path, NULL);
if (username) {
virBufferEscape(&buf, '\\', ":", ":id=%s",
username);
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 25d5fdf18..0dcdc8976 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -951,7 +951,7 @@ qemuBuildNetworkDriveStr(virStorageSourcePtr src,
goto cleanup;
}
- virBufferStrcat(&buf, "rbd:", src->path, NULL);
+ virBufferStrcat(&buf, "rbd:", src->volume, "/",
src->path, NULL);
if (src->snapshot)
virBufferEscape(&buf, '\\', ":", "@%s",
src->snapshot);
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index d48358abb..9cee64312 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -2545,6 +2545,14 @@ virStorageSourceParseRBDColonString(const char *rbdstr,
*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 */
if (!options)
return 0; /* all done */
@@ -3178,7 +3186,6 @@ virStorageSourceParseBackingJSONRBD(virStorageSourcePtr src,
const char *conf = virJSONValueObjectGetString(json, "conf");
const char *snapshot = virJSONValueObjectGetString(json, "snapshot");
virJSONValuePtr servers = virJSONValueObjectGetArray(json, "server");
- char *fullname = NULL;
size_t nservers;
size_t i;
int ret = -1;
@@ -3197,17 +3204,12 @@ virStorageSourceParseBackingJSONRBD(virStorageSourcePtr src,
return -1;
}
- /* currently we need to store the pool name and image name together, since
- * the rest of the code is not prepared for it */
- if (virAsprintf(&fullname, "%s/%s", pool, image) < 0)
- return -1;
-
- if (VIR_STRDUP(src->snapshot, snapshot) < 0 ||
+ if (VIR_STRDUP(src->volume, pool) < 0 ||
+ VIR_STRDUP(src->path, image) < 0 ||
+ VIR_STRDUP(src->snapshot, snapshot) < 0 ||
VIR_STRDUP(src->configFile, conf) < 0)
goto cleanup;
- VIR_STEAL_PTR(src->path, fullname);
-
if (servers) {
nservers = virJSONValueArraySize(servers);
@@ -3225,8 +3227,6 @@ virStorageSourceParseBackingJSONRBD(virStorageSourcePtr src,
ret = 0;
cleanup:
- VIR_FREE(fullname);
-
return ret;
}
diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c
index 8acbfe3f6..a61f1d7d5 100644
--- a/src/xenconfig/xen_xl.c
+++ b/src/xenconfig/xen_xl.c
@@ -1040,7 +1040,7 @@ xenFormatXLDiskSrcNet(virStorageSourcePtr src)
goto cleanup;
}
- virBufferStrcat(&buf, "rbd:", src->path, NULL);
+ virBufferStrcat(&buf, "rbd:", src->volume, "/",
src->path, NULL);
virBufferAddLit(&buf, ":auth_supported=none");
diff --git a/tests/domainsnapshotxml2xmlin/disk_snapshot.xml
b/tests/domainsnapshotxml2xmlin/disk_snapshot.xml
index aa1522a45..cf5ea0814 100644
--- a/tests/domainsnapshotxml2xmlin/disk_snapshot.xml
+++ b/tests/domainsnapshotxml2xmlin/disk_snapshot.xml
@@ -24,7 +24,7 @@
</source>
</disk>
<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='host2' port='1234' transport='rdma'/>
<host name='host3' port='1234'/>
diff --git a/tests/domainsnapshotxml2xmlout/disk_snapshot.xml
b/tests/domainsnapshotxml2xmlout/disk_snapshot.xml
index c2e77d7ac..0e81f35c6 100644
--- a/tests/domainsnapshotxml2xmlout/disk_snapshot.xml
+++ b/tests/domainsnapshotxml2xmlout/disk_snapshot.xml
@@ -23,7 +23,7 @@
</source>
</disk>
<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='host2' port='1234' transport='rdma'/>
<host name='host3' port='1234'/>
--
2.14.3