snapshot.c revision 18aa217bb187b551206fe66075229ba382a1dbe4
/* liblxcapi
*
* Copyright © 2013 Serge Hallyn <serge.hallyn@ubuntu.com>.
* Copyright © 2013 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 <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define MYNAME "snapxxx1"
#define MYNAME2 "snapxxx3"
#define RESTNAME "snapxxx2"
static void try_to_remove(void)
{
struct lxc_container *c;
if (c) {
c->snapshot_destroy_all(c);
if (c->is_defined(c))
c->destroy(c);
}
if (c) {
c->destroy_with_snapshots(c);
}
if (c) {
c->snapshot_destroy_all(c);
if (c->is_defined(c))
c->destroy(c);
}
}
{
char *template = "busybox";
if (argc > 1)
if (!c) {
exit(1);
}
if (c->is_defined(c)) {
(void) c->destroy_with_snapshots(c);
}
goto err;
}
c->save_config(c, NULL);
goto err;
}
c->load_config(c, NULL);
goto err;
}
int ret;
char path[1024];
snprintf(path, 1024, "%s/%s/snaps/snap0/rootfs", lxc_get_global_config_item("lxc.lxcpath"), MYNAME);
if (ret != 0) {
goto err;
}
struct lxc_snapshot *s;
int i, n;
n = c->snapshot_list(c, &s);
if (n < 1) {
goto err;
}
goto err;
}
for (i=0; i<n; i++) {
s[i].free(&s[i]);
}
free(s);
goto err;
}
if (!c->snapshot_destroy(c, "snap0")) {
goto err;
}
if (!c2) {
goto good;
}
goto err;
}
if (n < 1) {
goto err;
}
goto err;
}
for (i=0; i<n; i++) {
s[i].free(&s[i]);
}
free(s);
goto err;
}
goto err;
}
good:
printf("All tests passed\n");
exit(0);
err:
exit(1);
}