some stability improvements

This commit is contained in:
Martin Willi
2008-07-04 06:58:04 +00:00
parent 60721cee73
commit 4302d4f012
4 changed files with 21 additions and 15 deletions
+3 -1
View File
@@ -858,13 +858,15 @@ cowfs_t *cowfs_create(char *master, char *host, char *mount)
{ {
DBG1("failed to open master filesystem '%s'", master); DBG1("failed to open master filesystem '%s'", master);
free(this); free(this);
return NULL;
} }
this->host_fd = open(host, O_RDONLY | O_DIRECTORY); this->host_fd = open(host, O_RDONLY | O_DIRECTORY);
if (this->master_fd < 0) if (this->host_fd < 0)
{ {
DBG1("failed to open host filesystem '%s'", host); DBG1("failed to open host filesystem '%s'", host);
close(this->master_fd); close(this->master_fd);
free(this); free(this);
return NULL;
} }
this->over_fd = -1; this->over_fd = -1;
+1
View File
@@ -424,6 +424,7 @@ static void destroy(private_guest_t *this)
{ {
close(this->dir); close(this->dir);
} }
this->ifaces->destroy(this->ifaces);
free(this->dirname); free(this->dirname);
free(this->name); free(this->name);
free(this); free(this);
+4 -4
View File
@@ -205,10 +205,6 @@ iface_t *iface_create(char *guest, char *guestif, mconsole_t *mconsole)
free(this); free(this);
return NULL; return NULL;
} }
if (!iface_control(this->hostif, TRUE))
{
DBG1("bringing iface '%s' up failed: %m", this->hostif);
}
if (!this->mconsole->add_iface(this->mconsole, this->guestif, this->hostif)) if (!this->mconsole->add_iface(this->mconsole, this->guestif, this->hostif))
{ {
DBG1("creating interface '%s' in guest failed", this->guestif); DBG1("creating interface '%s' in guest failed", this->guestif);
@@ -218,6 +214,10 @@ iface_t *iface_create(char *guest, char *guestif, mconsole_t *mconsole)
free(this); free(this);
return NULL; return NULL;
} }
if (!iface_control(this->hostif, TRUE))
{
DBG1("bringing iface '%s' up failed: %m", this->hostif);
}
return &this->public; return &this->public;
} }
+13 -10
View File
@@ -156,21 +156,25 @@ static int request(private_mconsole_t *this, char *command,
*/ */
static bool add_iface(private_mconsole_t *this, char *guest, char *host) static bool add_iface(private_mconsole_t *this, char *guest, char *host)
{ {
char buf[128]; char in[128], out[128];
int len; int len, tries = 0;
len = snprintf(buf, sizeof(buf), "config %s=tuntap,%s", guest, host); len = snprintf(in, sizeof(in), "config %s=tuntap,%s", guest, host);
if (len < 0 || len >= sizeof(buf)) if (len < 0 || len >= sizeof(in))
{ {
return FALSE; return FALSE;
} }
len = sizeof(buf); while (tries++ < 10)
if (request(this, buf, buf, &len) != 0)
{ {
DBG1("adding interface failed: %.*s", len, buf); len = sizeof(in);
return FALSE; if (request(this, in, out, &len) == 0)
{
return TRUE;
}
usleep(10000 * tries);
} }
return TRUE; DBG1("adding interface failed: %.*s", len, out);
return FALSE;
} }
/** /**
@@ -188,7 +192,6 @@ static bool del_iface(private_mconsole_t *this, char *guest)
} }
if (request(this, buf, buf, &len) != 0) if (request(this, buf, buf, &len) != 0)
{ {
DBG1("removing interface failed: %.*s", len, buf);
return FALSE; return FALSE;
} }
return TRUE; return TRUE;