Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lxc/lxc_process.c
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,7 @@ virLXCProcessBuildControllerCmd(virLXCDriver *driver,
virCommandAddArgPair(cmd, "--security",
virSecurityManagerGetModel(driver->securityManager));

virCommandAddArg(cmd, "--handshake");
virCommandAddArg(cmd, "--handshakefd");
virCommandAddArgFormat(cmd, "%d", handshakefd);

for (i = 0; veths && veths[i]; i++)
Expand Down
29 changes: 25 additions & 4 deletions src/util/vircgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -1477,6 +1477,24 @@ virCgroupHasController(virCgroup *cgroup, int controller)
}


static int
virCgroupGetAnyController(virCgroup *cgroup)
{
size_t i;

for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
if (!cgroup->backends[i])
continue;

return cgroup->backends[i]->getAnyController(cgroup);
}

virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to get any controller"));
return -1;
}


int
virCgroupPathOfController(virCgroup *group,
unsigned int controller,
Expand Down Expand Up @@ -2715,18 +2733,21 @@ int
virCgroupKillRecursiveInternal(virCgroup *group,
int signum,
GHashTable *pids,
int controller,
const char *taskFile,
bool dormdir)
{
int rc;
int controller;
bool killedAny = false;
g_autofree char *keypath = NULL;
g_autoptr(DIR) dp = NULL;
struct dirent *ent;
int direrr;
VIR_DEBUG("group=%p signum=%d pids=%p",
group, signum, pids);
VIR_DEBUG("group=%p signum=%d pids=%p taskFile=%s dormdir=%d",
group, signum, pids, taskFile, dormdir);

if ((controller = virCgroupGetAnyController(group)) < 0)
return -1;

if (virCgroupPathOfController(group, controller, "", &keypath) < 0)
return -1;
Expand Down Expand Up @@ -2760,7 +2781,7 @@ virCgroupKillRecursiveInternal(virCgroup *group,
return -1;

if ((rc = virCgroupKillRecursiveInternal(subgroup, signum, pids,
controller, taskFile, true)) < 0)
taskFile, true)) < 0)
return -1;
if (rc == 1)
killedAny = true;
Expand Down
1 change: 0 additions & 1 deletion src/util/vircgroupbackend.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

#define VIR_FROM_THIS VIR_FROM_CGROUP

VIR_ENUM_DECL(virCgroupBackend);
VIR_ENUM_IMPL(virCgroupBackend,
VIR_CGROUP_BACKEND_TYPE_LAST,
"cgroup V2",
Expand Down
8 changes: 6 additions & 2 deletions src/util/vircgroupbackend.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ typedef enum {
VIR_CGROUP_BACKEND_TYPE_LAST,
} virCgroupBackendType;

VIR_ENUM_DECL(virCgroupBackend);

typedef bool
(*virCgroupAvailableCB)(void);

Expand Down Expand Up @@ -464,12 +466,14 @@ virCgroupBackendForController(virCgroup *group,
virCgroupBackend *backend = virCgroupBackendForController(group, controller); \
if (!backend) { \
virReportError(VIR_ERR_INTERNAL_ERROR, \
_("failed to get cgroup backend for '%s'"), #func); \
_("failed to get cgroup backend for '%s' controller '%u'"), \
#func, controller); \
return ret; \
} \
if (!backend->func) { \
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, \
_("operation '%s' not supported"), #func); \
_("operation '%s' not supported for backend '%s'"), \
#func, virCgroupBackendTypeToString(backend->type)); \
return ret; \
} \
return backend->func(group, ##__VA_ARGS__); \
Expand Down
1 change: 0 additions & 1 deletion src/util/vircgrouppriv.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,5 @@ int virCgroupRemoveRecursively(char *grppath);
int virCgroupKillRecursiveInternal(virCgroup *group,
int signum,
GHashTable *pids,
int controller,
const char *taskFile,
bool dormdir);
7 changes: 1 addition & 6 deletions src/util/vircgroupv1.c
Original file line number Diff line number Diff line change
Expand Up @@ -812,12 +812,7 @@ virCgroupV1KillRecursive(virCgroup *group,
int signum,
GHashTable *pids)
{
int controller = virCgroupV1GetAnyController(group);

if (controller < 0)
return -1;

return virCgroupKillRecursiveInternal(group, signum, pids, controller,
return virCgroupKillRecursiveInternal(group, signum, pids,
"tasks", false);
}

Expand Down
7 changes: 1 addition & 6 deletions src/util/vircgroupv2.c
Original file line number Diff line number Diff line change
Expand Up @@ -577,12 +577,7 @@ virCgroupV2KillRecursive(virCgroup *group,
int signum,
GHashTable *pids)
{
int controller = virCgroupV2GetAnyController(group);

if (controller < 0)
return -1;

return virCgroupKillRecursiveInternal(group, signum, pids, controller,
return virCgroupKillRecursiveInternal(group, signum, pids,
"cgroup.threads", false);
}

Expand Down
10 changes: 5 additions & 5 deletions tools/virsh-domain-monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -1220,7 +1220,7 @@ cmdDomBlkError(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
virDomainDiskErrorPtr disks = NULL;
unsigned int ndisks;
unsigned int ndisks = 0;
size_t i;
int count;
bool ret = false;
Expand All @@ -1230,10 +1230,10 @@ cmdDomBlkError(vshControl *ctl, const vshCmd *cmd)

if ((count = virDomainGetDiskErrors(dom, NULL, 0, 0)) < 0)
goto cleanup;
ndisks = count;

if (ndisks) {
disks = g_new0(virDomainDiskError, ndisks);
if (count > 0) {
disks = g_new0(virDomainDiskError, count);
ndisks = count;

if ((count = virDomainGetDiskErrors(dom, disks, ndisks, 0)) == -1)
goto cleanup;
Expand All @@ -1252,7 +1252,7 @@ cmdDomBlkError(vshControl *ctl, const vshCmd *cmd)
ret = true;

cleanup:
for (i = 0; i < count; i++)
for (i = 0; i < ndisks; i++)
VIR_FREE(disks[i].disk);
VIR_FREE(disks);
virshDomainFree(dom);
Expand Down