LXC: workaround machined uncleaned data with containers running systemd.

The problem is described by [0] but its effect on libvirt is that
starting a container with a full distro running systemd after having
stopped it simply fails.

The container cleanup now calls the machined Terminate function to make
sure that everything is in order for the next run.

 [0]: https://bugs.freedesktop.org/show_bug.cgi?id=68370
This commit is contained in:
Cédric Bosdonnat
2013-09-30 16:46:29 +02:00
committed by Daniel P. Berrange
parent edc61bf63e
commit bd773e74f0
5 changed files with 115 additions and 11 deletions

View File

@@ -54,6 +54,18 @@ static int testCreateContainer(const void *opaque ATTRIBUTE_UNUSED)
return 0;
}
static int testTerminateContainer(const void *opaque ATTRIBUTE_UNUSED)
{
if (virSystemdTerminateMachine("demo",
"lxc",
true) < 0) {
fprintf(stderr, "%s", "Failed to terminate LXC machine\n");
return -1;
}
return 0;
}
static int testCreateMachine(const void *opaque ATTRIBUTE_UNUSED)
{
unsigned char uuid[VIR_UUID_BUFLEN] = {
@@ -77,6 +89,18 @@ static int testCreateMachine(const void *opaque ATTRIBUTE_UNUSED)
return 0;
}
static int testTerminateMachine(const void *opaque ATTRIBUTE_UNUSED)
{
if (virSystemdTerminateMachine("demo",
"qemu",
false) < 0) {
fprintf(stderr, "%s", "Failed to terminate KVM machine\n");
return -1;
}
return 0;
}
static int testCreateNoSystemd(const void *opaque ATTRIBUTE_UNUSED)
{
unsigned char uuid[VIR_UUID_BUFLEN] = {
@@ -184,8 +208,12 @@ mymain(void)
if (virtTestRun("Test create container ", 1, testCreateContainer, NULL) < 0)
ret = -1;
if (virtTestRun("Test terminate container ", 1, testTerminateContainer, NULL) < 0)
ret = -1;
if (virtTestRun("Test create machine ", 1, testCreateMachine, NULL) < 0)
ret = -1;
if (virtTestRun("Test terminate machine ", 1, testTerminateMachine, NULL) < 0)
ret = -1;
if (virtTestRun("Test create no systemd ", 1, testCreateNoSystemd, NULL) < 0)
ret = -1;
if (virtTestRun("Test create bad systemd ", 1, testCreateBadSystemd, NULL) < 0)