summaryrefslogtreecommitdiffstats
path: root/src/guestfs.c
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2010-05-08 09:28:19 +0100
committerRichard Jones <rjones@redhat.com>2010-05-08 09:28:19 +0100
commit55e9707f8591488542da48fc89738234b4d85016 (patch)
treec6ab7fa1e9bb57cdc61064152b5c0e2b86ece9a4 /src/guestfs.c
parent301abf33c6985b61604dfae5db75cf767aa5e651 (diff)
downloadlibguestfs-55e9707f8591488542da48fc89738234b4d85016.tar.gz
libguestfs-55e9707f8591488542da48fc89738234b4d85016.tar.xz
libguestfs-55e9707f8591488542da48fc89738234b4d85016.zip
launch: Rearrange the code so config check is first.
Move the config state check first in the guestfs_launch function, so that we don't reset g->launch_t or calculate the temporary directory in the case where the launch function will immediately return with an error.
Diffstat (limited to 'src/guestfs.c')
-rw-r--r--src/guestfs.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/guestfs.c b/src/guestfs.c
index 2fc73efe..027e08c9 100644
--- a/src/guestfs.c
+++ b/src/guestfs.c
@@ -948,9 +948,21 @@ guestfs__launch (guestfs_h *g)
char unixsock[256];
struct sockaddr_un addr;
+ /* Configured? */
+ if (!g->cmdline) {
+ error (g, _("you must call guestfs_add_drive before guestfs_launch"));
+ return -1;
+ }
+
+ if (g->state != CONFIG) {
+ error (g, _("the libguestfs handle has already been launched"));
+ return -1;
+ }
+
/* Start the clock ... */
gettimeofday (&g->launch_t, NULL);
+ /* Make the temporary directory. */
#ifdef P_tmpdir
tmpdir = P_tmpdir;
#else
@@ -960,18 +972,6 @@ guestfs__launch (guestfs_h *g)
tmpdir = getenv ("TMPDIR") ? : tmpdir;
snprintf (dir_template, sizeof dir_template, "%s/libguestfsXXXXXX", tmpdir);
- /* Configured? */
- if (!g->cmdline) {
- error (g, _("you must call guestfs_add_drive before guestfs_launch"));
- return -1;
- }
-
- if (g->state != CONFIG) {
- error (g, _("qemu has already been launched"));
- return -1;
- }
-
- /* Make the temporary directory. */
if (!g->tmpdir) {
g->tmpdir = safe_strdup (g, dir_template);
if (mkdtemp (g->tmpdir) == NULL) {