提交 12b8290f 编写于 作者: N Nehal J Wani 提交者: Daniel P. Berrange

Use virFileFindResource to locate parthelper for storage backend

Instead of hardcoding LIBEXECDIR as the location of the libvirt_parthelper
binary, use virFileFindResource to optionally find it in the current
build directory.
Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
上级 89de838f
......@@ -40,8 +40,6 @@
VIR_LOG_INIT("storage.storage_backend_disk");
#define PARTHELPER LIBEXECDIR "/libvirt_parthelper"
#define SECTOR_SIZE 512
static int
......@@ -262,15 +260,24 @@ virStorageBackendDiskReadPartitions(virStoragePoolObjPtr pool,
* - normal metadata 100027630080 100030242304 2612736
*
*/
virCommandPtr cmd = virCommandNewArgList(PARTHELPER,
pool->def->source.devices[0].path,
NULL);
char *parthelper_path;
virCommandPtr cmd;
struct virStorageBackendDiskPoolVolData cbdata = {
.pool = pool,
.vol = vol,
};
int ret;
if (!(parthelper_path = virFileFindResource("libvirt_parthelper",
"src",
LIBEXECDIR)))
return -1;
cmd = virCommandNewArgList(parthelper_path,
pool->def->source.devices[0].path,
NULL);
pool->def->allocation = pool->def->capacity = pool->def->available = 0;
ret = virCommandRunNul(cmd,
......@@ -278,6 +285,7 @@ virStorageBackendDiskReadPartitions(virStoragePoolObjPtr pool,
virStorageBackendDiskMakeVol,
&cbdata);
virCommandFree(cmd);
VIR_FREE(parthelper_path);
return ret;
}
......@@ -302,17 +310,26 @@ virStorageBackendDiskMakePoolGeometry(size_t ntok ATTRIBUTE_UNUSED,
static int
virStorageBackendDiskReadGeometry(virStoragePoolObjPtr pool)
{
virCommandPtr cmd = virCommandNewArgList(PARTHELPER,
char *parthelper_path;
virCommandPtr cmd;
int ret;
if (!(parthelper_path = virFileFindResource("libvirt_parthelper",
"src",
LIBEXECDIR)))
return -1;
cmd = virCommandNewArgList(parthelper_path,
pool->def->source.devices[0].path,
"-g",
NULL);
int ret;
ret = virCommandRunNul(cmd,
3,
virStorageBackendDiskMakePoolGeometry,
pool);
virCommandFree(cmd);
VIR_FREE(parthelper_path);
return ret;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册