destroytest.c revision 72d0e1cb2facaa4b8ba2f15e311d6bb9491badb7
/* liblxcapi
*
* Copyright © 2012 Serge Hallyn <serge.hallyn@ubuntu.com>.
* Copyright © 2012 Canonical Ltd.
*
* it under the terms of the GNU General Public License version 2, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "../lxc/lxccontainer.h"
#include <unistd.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#define MYNAME "lxctest1"
static int create_ubuntu(void)
{
if (pid < 0) {
perror("fork");
return -1;
}
if (pid == 0) {
ret = execlp("lxc-create", "lxc-create", "-t", "ubuntu", "-f", "/etc/lxc/lxc.conf", "-n", MYNAME, NULL);
// Should not return
perror("execl");
exit(1);
}
if (ret == -1) {
goto again;
perror("waitpid");
return -1;
}
goto again;
return -1;
}
return WEXITSTATUS(status);
}
{
struct lxc_container *c;
int ret = 1;
ret = 1;
goto out;
}
if (c->is_defined(c)) {
goto out;
}
if (create_ubuntu()) {
goto out;
}
if (!c->is_defined(c)) {
goto out;
}
if (!c->destroy(c)) {
goto out;
}
if (c->is_defined(c)) {
goto out;
}
ret = 0;
out:
}