mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-07-31 14:07:16 +00:00
cgroup: Drop resource partition from virSystemdMakeScopeName
The scope name, even according to our docs is "machine-$DRIVER\x2d$VMNAME.scope" virSystemdMakeScopeName would use the resource partition name instead of "machine-" if it was specified thus creating invalid scope paths. This makes libvirt drop cgroups for a VM that uses custom resource partition upon reconnecting since the detected scope name would not match the expected name generated by virSystemdMakeScopeName. The error is exposed by the following log entry: debug : virCgroupValidateMachineGroup:302 : Name 'machine-qemu\x2dtestvm.scope' for controller 'cpu' does not match 'testvm', 'testvm.libvirt-qemu' or 'machine-test-qemu\x2dtestvm.scope' for a "/machine/test" resource and "testvm" vm. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1238570
This commit is contained in:
parent
6600f4f3d8
commit
88f6c007c3
@ -1319,9 +1319,6 @@ int virLXCProcessStart(virConnectPtr conn,
|
|||||||
* more reliable way to kill everything off if something
|
* more reliable way to kill everything off if something
|
||||||
* goes wrong from here onwards ... */
|
* goes wrong from here onwards ... */
|
||||||
if (virCgroupNewDetectMachine(vm->def->name, "lxc", vm->pid,
|
if (virCgroupNewDetectMachine(vm->def->name, "lxc", vm->pid,
|
||||||
vm->def->resource ?
|
|
||||||
vm->def->resource->partition :
|
|
||||||
NULL,
|
|
||||||
-1, &priv->cgroup) < 0)
|
-1, &priv->cgroup) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -1505,9 +1502,6 @@ virLXCProcessReconnectDomain(virDomainObjPtr vm,
|
|||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (virCgroupNewDetectMachine(vm->def->name, "lxc", vm->pid,
|
if (virCgroupNewDetectMachine(vm->def->name, "lxc", vm->pid,
|
||||||
vm->def->resource ?
|
|
||||||
vm->def->resource->partition :
|
|
||||||
NULL,
|
|
||||||
-1, &priv->cgroup) < 0)
|
-1, &priv->cgroup) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
@ -855,9 +855,6 @@ qemuConnectCgroup(virQEMUDriverPtr driver,
|
|||||||
if (virCgroupNewDetectMachine(vm->def->name,
|
if (virCgroupNewDetectMachine(vm->def->name,
|
||||||
"qemu",
|
"qemu",
|
||||||
vm->pid,
|
vm->pid,
|
||||||
vm->def->resource ?
|
|
||||||
vm->def->resource->partition :
|
|
||||||
NULL,
|
|
||||||
cfg->cgroupControllers,
|
cfg->cgroupControllers,
|
||||||
&priv->cgroup) < 0)
|
&priv->cgroup) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -243,7 +243,6 @@ static bool
|
|||||||
virCgroupValidateMachineGroup(virCgroupPtr group,
|
virCgroupValidateMachineGroup(virCgroupPtr group,
|
||||||
const char *name,
|
const char *name,
|
||||||
const char *drivername,
|
const char *drivername,
|
||||||
const char *partition,
|
|
||||||
bool stripEmulatorSuffix)
|
bool stripEmulatorSuffix)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
@ -258,10 +257,7 @@ virCgroupValidateMachineGroup(virCgroupPtr group,
|
|||||||
if (virCgroupPartitionEscape(&partname) < 0)
|
if (virCgroupPartitionEscape(&partname) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!partition)
|
if (!(scopename = virSystemdMakeScopeName(name, drivername)))
|
||||||
partition = "/machine";
|
|
||||||
|
|
||||||
if (!(scopename = virSystemdMakeScopeName(name, drivername, partition)))
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virCgroupPartitionEscape(&scopename) < 0)
|
if (virCgroupPartitionEscape(&scopename) < 0)
|
||||||
@ -1498,7 +1494,6 @@ int
|
|||||||
virCgroupNewDetectMachine(const char *name,
|
virCgroupNewDetectMachine(const char *name,
|
||||||
const char *drivername,
|
const char *drivername,
|
||||||
pid_t pid,
|
pid_t pid,
|
||||||
const char *partition,
|
|
||||||
int controllers,
|
int controllers,
|
||||||
virCgroupPtr *group)
|
virCgroupPtr *group)
|
||||||
{
|
{
|
||||||
@ -1508,8 +1503,7 @@ virCgroupNewDetectMachine(const char *name,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!virCgroupValidateMachineGroup(*group, name, drivername, partition,
|
if (!virCgroupValidateMachineGroup(*group, name, drivername, true)) {
|
||||||
true)) {
|
|
||||||
VIR_DEBUG("Failed to validate machine name for '%s' driver '%s'",
|
VIR_DEBUG("Failed to validate machine name for '%s' driver '%s'",
|
||||||
name, drivername);
|
name, drivername);
|
||||||
virCgroupFree(group);
|
virCgroupFree(group);
|
||||||
@ -4047,7 +4041,6 @@ int
|
|||||||
virCgroupNewDetectMachine(const char *name ATTRIBUTE_UNUSED,
|
virCgroupNewDetectMachine(const char *name ATTRIBUTE_UNUSED,
|
||||||
const char *drivername ATTRIBUTE_UNUSED,
|
const char *drivername ATTRIBUTE_UNUSED,
|
||||||
pid_t pid ATTRIBUTE_UNUSED,
|
pid_t pid ATTRIBUTE_UNUSED,
|
||||||
const char *partition ATTRIBUTE_UNUSED,
|
|
||||||
int controllers ATTRIBUTE_UNUSED,
|
int controllers ATTRIBUTE_UNUSED,
|
||||||
virCgroupPtr *group ATTRIBUTE_UNUSED)
|
virCgroupPtr *group ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
|
@ -92,7 +92,6 @@ int virCgroupNewDetect(pid_t pid,
|
|||||||
int virCgroupNewDetectMachine(const char *name,
|
int virCgroupNewDetectMachine(const char *name,
|
||||||
const char *drivername,
|
const char *drivername,
|
||||||
pid_t pid,
|
pid_t pid,
|
||||||
const char *partition,
|
|
||||||
int controllers,
|
int controllers,
|
||||||
virCgroupPtr *group);
|
virCgroupPtr *group);
|
||||||
|
|
||||||
|
@ -80,16 +80,11 @@ static void virSystemdEscapeName(virBufferPtr buf,
|
|||||||
|
|
||||||
|
|
||||||
char *virSystemdMakeScopeName(const char *name,
|
char *virSystemdMakeScopeName(const char *name,
|
||||||
const char *drivername,
|
const char *drivername)
|
||||||
const char *partition)
|
|
||||||
{
|
{
|
||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
||||||
|
|
||||||
if (*partition == '/')
|
virBufferAddLit(&buf, "machine-");
|
||||||
partition++;
|
|
||||||
|
|
||||||
virSystemdEscapeName(&buf, partition);
|
|
||||||
virBufferAddChar(&buf, '-');
|
|
||||||
virSystemdEscapeName(&buf, drivername);
|
virSystemdEscapeName(&buf, drivername);
|
||||||
virBufferAddLit(&buf, "\\x2d");
|
virBufferAddLit(&buf, "\\x2d");
|
||||||
virSystemdEscapeName(&buf, name);
|
virSystemdEscapeName(&buf, name);
|
||||||
|
@ -25,8 +25,7 @@
|
|||||||
# include "internal.h"
|
# include "internal.h"
|
||||||
|
|
||||||
char *virSystemdMakeScopeName(const char *name,
|
char *virSystemdMakeScopeName(const char *name,
|
||||||
const char *drivername,
|
const char *drivername);
|
||||||
const char *slicename);
|
|
||||||
char *virSystemdMakeSliceName(const char *partition);
|
char *virSystemdMakeSliceName(const char *partition);
|
||||||
|
|
||||||
char *virSystemdMakeMachineName(const char *name,
|
char *virSystemdMakeMachineName(const char *name,
|
||||||
|
@ -340,7 +340,6 @@ static int testCreateNetwork(const void *opaque ATTRIBUTE_UNUSED)
|
|||||||
|
|
||||||
struct testScopeData {
|
struct testScopeData {
|
||||||
const char *name;
|
const char *name;
|
||||||
const char *partition;
|
|
||||||
const char *expected;
|
const char *expected;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -351,9 +350,7 @@ testScopeName(const void *opaque)
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
char *actual = NULL;
|
char *actual = NULL;
|
||||||
|
|
||||||
if (!(actual = virSystemdMakeScopeName(data->name,
|
if (!(actual = virSystemdMakeScopeName(data->name, "lxc")))
|
||||||
"lxc",
|
|
||||||
data->partition)))
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (STRNEQ(actual, data->expected)) {
|
if (STRNEQ(actual, data->expected)) {
|
||||||
@ -472,22 +469,19 @@ mymain(void)
|
|||||||
if (virtTestRun("Test create with network ", testCreateNetwork, NULL) < 0)
|
if (virtTestRun("Test create with network ", testCreateNetwork, NULL) < 0)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
|
||||||
# define TEST_SCOPE(name, partition, unitname) \
|
# define TEST_SCOPE(name, unitname) \
|
||||||
do { \
|
do { \
|
||||||
struct testScopeData data = { \
|
struct testScopeData data = { \
|
||||||
name, partition, unitname \
|
name, unitname \
|
||||||
}; \
|
}; \
|
||||||
if (virtTestRun("Test scopename", testScopeName, &data) < 0) \
|
if (virtTestRun("Test scopename", testScopeName, &data) < 0) \
|
||||||
ret = -1; \
|
ret = -1; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
TEST_SCOPE("demo", "/machine", "machine-lxc\\x2ddemo.scope");
|
TEST_SCOPE("demo", "machine-lxc\\x2ddemo.scope");
|
||||||
TEST_SCOPE("demo-name", "/machine", "machine-lxc\\x2ddemo\\x2dname.scope");
|
TEST_SCOPE("demo-name", "machine-lxc\\x2ddemo\\x2dname.scope");
|
||||||
TEST_SCOPE("demo!name", "/machine", "machine-lxc\\x2ddemo\\x21name.scope");
|
TEST_SCOPE("demo!name", "machine-lxc\\x2ddemo\\x21name.scope");
|
||||||
TEST_SCOPE(".demo", "/machine", "machine-lxc\\x2d\\x2edemo.scope");
|
TEST_SCOPE(".demo", "machine-lxc\\x2d\\x2edemo.scope");
|
||||||
TEST_SCOPE("demo", "/machine/eng-dept", "machine-eng\\x2ddept-lxc\\x2ddemo.scope");
|
|
||||||
TEST_SCOPE("demo", "/machine/eng-dept/testing!stuff",
|
|
||||||
"machine-eng\\x2ddept-testing\\x21stuff-lxc\\x2ddemo.scope");
|
|
||||||
|
|
||||||
# define TESTS_PM_SUPPORT_HELPER(name, function) \
|
# define TESTS_PM_SUPPORT_HELPER(name, function) \
|
||||||
do { \
|
do { \
|
||||||
|
Loading…
Reference in New Issue
Block a user