xl: check for restore file open failure in create_domain
authorMatthew Daley <mattjd@gmail.com>
Wed, 30 Oct 2013 07:51:56 +0000 (20:51 +1300)
committerIan Campbell <ian.campbell@citrix.com>
Thu, 31 Oct 2013 21:55:52 +0000 (21:55 +0000)
...otherwise you get a less helpful error message.

Coverity-ID: 1055569
Signed-off-by: Matthew Daley <mattjd@gmail.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
tools/libxl/xl_cmdimpl.c

index 43d15190e20bab7888c3b85654ac36e7fb46dd42..a935a18cb47106e44c730264ff6f36f7c6ccb726 100644 (file)
@@ -1919,6 +1919,10 @@ static uint32_t create_domain(struct domain_create *dom_info)
         } else {
             restore_source = restore_file;
             restore_fd = open(restore_file, O_RDONLY);
+            if (restore_fd == -1) {
+                fprintf(stderr, "Can't open restore file: %s\n", strerror(errno));
+                return ERROR_INVAL;
+            }
             rc = libxl_fd_set_cloexec(ctx, restore_fd, 1);
             if (rc) return rc;
         }