correspond to the files that can be found when mounting the
gluster volume. The <code>name</code> is the path relative to
the effective mount specified for the pool; and
- the <code>key</code> is a path including the gluster volume
- name and any subdirectory specified by the pool.</p>
+ the <code>key</code> is a string that identifies a single volume
+ uniquely. Currently the <code>key</code> attribute consists of the
+ URI of the volume but it may be changed to a UUID of the volume
+ in the future.</p>
<pre>
<volume>
<name>myfile</name>
- <key>volname/myfile</key>
+ <key>gluster://localhost/volname/myfile</key>
<source>
</source>
<capacity unit='bytes'>53687091200</capacity>
const char *name)
{
int ret = -1;
+ char *path = NULL;
char *tmp;
VIR_FREE(vol->key);
goto cleanup;
}
- if (virAsprintf(&vol->key, "%s%s%s", state->volname, state->dir,
+ if (virAsprintf(&path, "%s%s%s", state->volname, state->dir,
vol->name) < 0)
goto cleanup;
tmp = state->uri->path;
- if (virAsprintf(&state->uri->path, "/%s", vol->key) < 0) {
+ if (virAsprintf(&state->uri->path, "/%s", path) < 0) {
state->uri->path = tmp;
goto cleanup;
}
VIR_FREE(state->uri->path);
state->uri->path = tmp;
+ /* the path is unique enough to serve as a volume key */
+ if (VIR_STRDUP(vol->key, vol->target.path) < 0)
+ goto cleanup;
+
ret = 0;
cleanup:
+ VIR_FREE(path);
return ret;
}