提交 891c6fd7 编写于 作者: O Osier Yang

storage: Ensure the device path exists before refreshing disk pool

Doing libvirt_parthelper on an not existed device path will get
an unfriendly error message. This patch is to prohibit it.
上级 232392b1
...@@ -262,7 +262,6 @@ static int ...@@ -262,7 +262,6 @@ static int
virStorageBackendDiskReadPartitions(virStoragePoolObjPtr pool, virStorageBackendDiskReadPartitions(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol) virStorageVolDefPtr vol)
{ {
/* /*
* # libvirt_parthelper DEVICE * # libvirt_parthelper DEVICE
* /dev/sda1 normal data 32256 106928128 106896384 * /dev/sda1 normal data 32256 106928128 106896384
...@@ -320,6 +319,13 @@ virStorageBackendDiskRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED, ...@@ -320,6 +319,13 @@ virStorageBackendDiskRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
virFileWaitForDevices(); virFileWaitForDevices();
if (!virFileExists(pool->def->source.devices[0].path)) {
virStorageReportError(VIR_ERR_INVALID_ARG,
_("device path '%s' doesn't exist"),
pool->def->source.devices[0].path);
return -1;
}
if (virStorageBackendDiskReadGeometry(pool) != 0) { if (virStorageBackendDiskReadGeometry(pool) != 0) {
return -1; return -1;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册