Skip to content

Commit 6322021

Browse files
committed
ch: Check if disk path exists
We currently test if the path is set but we could also provide a useful error here early on if the path doesn't exist as well.
1 parent e896db9 commit 6322021

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/ch/ch_monitor.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,11 @@ virCHMonitorBuildDiskJson(virJSONValuePtr disks, virDomainDiskDefPtr diskdef)
254254

255255
if (diskdef->src != NULL && diskdef->src->path != NULL) {
256256
disk = virJSONValueNewObject();
257+
if (!virFileExists(diskdef->src->path)) {
258+
virReportError(VIR_ERR_INVALID_ARG,
259+
_("failed to find disk '%s'"), diskdef->src->path);
260+
goto cleanup;
261+
}
257262
if (virJSONValueObjectAppendString(disk, "path", diskdef->src->path) < 0)
258263
goto cleanup;
259264
if (diskdef->src->readonly) {

0 commit comments

Comments
 (0)