summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
fe3836a)
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.
(cherry picked from commit
55e9707f8591488542da48fc89738234b4d85016)
char unixsock[256];
struct sockaddr_un addr;
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);
/* Start the clock ... */
gettimeofday (&g->launch_t, NULL);
+ /* Make the temporary directory. */
#ifdef P_tmpdir
tmpdir = P_tmpdir;
#else
#ifdef P_tmpdir
tmpdir = P_tmpdir;
#else
tmpdir = getenv ("TMPDIR") ? : tmpdir;
snprintf (dir_template, sizeof dir_template, "%s/libguestfsXXXXXX", tmpdir);
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) {
if (!g->tmpdir) {
g->tmpdir = safe_strdup (g, dir_template);
if (mkdtemp (g->tmpdir) == NULL) {