[libvirt] [PATCH] 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. --- src/storage/storage_backend_disk.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c index 80f9dd1..82d6e8a 100644 --- a/src/storage/storage_backend_disk.c +++ b/src/storage/storage_backend_disk.c @@ -262,7 +262,6 @@ static int virStorageBackendDiskReadPartitions(virStoragePoolObjPtr pool, virStorageVolDefPtr vol) { - /* * # libvirt_parthelper DEVICE * /dev/sda1 normal data 32256 106928128 106896384 @@ -320,6 +319,13 @@ virStorageBackendDiskRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED, 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) { return -1; } -- 1.7.6

On 09/19/2011 08:28 AM, Osier Yang wrote:
Doing libvirt_parthelper on an not existed device path will get an unfriendly error message. This patch is to prohibit it. --- src/storage/storage_backend_disk.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c index 80f9dd1..82d6e8a 100644 --- a/src/storage/storage_backend_disk.c +++ b/src/storage/storage_backend_disk.c @@ -262,7 +262,6 @@ static int virStorageBackendDiskReadPartitions(virStoragePoolObjPtr pool, virStorageVolDefPtr vol) { - /* * # libvirt_parthelper DEVICE * /dev/sda1 normal data 32256 106928128 106896384 @@ -320,6 +319,13 @@ virStorageBackendDiskRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
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; + }
ACK. Worth including in 0.9.5. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

于 2011年09月20日 08:17, Eric Blake 写道:
On 09/19/2011 08:28 AM, Osier Yang wrote:
Doing libvirt_parthelper on an not existed device path will get an unfriendly error message. This patch is to prohibit it. --- src/storage/storage_backend_disk.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c index 80f9dd1..82d6e8a 100644 --- a/src/storage/storage_backend_disk.c +++ b/src/storage/storage_backend_disk.c @@ -262,7 +262,6 @@ static int virStorageBackendDiskReadPartitions(virStoragePoolObjPtr pool, virStorageVolDefPtr vol) { - /* * # libvirt_parthelper DEVICE * /dev/sda1 normal data 32256 106928128 106896384 @@ -320,6 +319,13 @@ virStorageBackendDiskRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
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; + }
ACK. Worth including in 0.9.5.
Pushed, Thanks Osier
participants (2)
-
Eric Blake
-
Osier Yang