Re: [PATCH 10/47] vircgroup: extract virCgroupV1GetPlacement

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Sep 18, 2018 at 05:45:31PM +0200, Pavel Hrdina wrote:
Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
src/util/vircgroup.c        |  3 +--
src/util/vircgroupbackend.h |  4 ++++
src/util/vircgroupv1.c      | 12 ++++++++++++
3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 864dd876b0..ff102e2cb0 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -1317,8 +1317,7 @@ virCgroupNewMachineSystemd(const char *name,
                           &init) < 0)
        return -1;

-    path = init->controllers[VIR_CGROUP_CONTROLLER_SYSTEMD].placement;
-    init->controllers[VIR_CGROUP_CONTROLLER_SYSTEMD].placement = NULL;
+    path = init->backend->getPlacement(init);
    virCgroupFree(&init);

    if (!path || STREQ(path, "/") || path[0] != '/') {
diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h
index 086cfb8090..1856164c6b 100644
--- a/src/util/vircgroupbackend.h
+++ b/src/util/vircgroupbackend.h
@@ -66,6 +66,9 @@ typedef int
(*virCgroupValidatePlacementCB)(virCgroupPtr group,
                                pid_t pid);

+typedef char *
+(*virCgroupGetPlacementCB)(virCgroupPtr group);
+
struct _virCgroupBackend {
    virCgroupBackendType type;

@@ -77,6 +80,7 @@ struct _virCgroupBackend {
    virCgroupDetectMountsCB detectMounts;
    virCgroupDetectPlacementCB detectPlacement;
    virCgroupValidatePlacementCB validatePlacement;
+    virCgroupGetPlacementCB getPlacement;
};
typedef struct _virCgroupBackend virCgroupBackend;
typedef virCgroupBackend *virCgroupBackendPtr;
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
index 68df323d72..ab8988cd59 100644
--- a/src/util/vircgroupv1.c
+++ b/src/util/vircgroupv1.c
@@ -402,6 +402,17 @@ virCgroupV1ValidatePlacement(virCgroupPtr group,
}


+static char *
+virCgroupV1GetPlacement(virCgroupPtr group)
+{
+    char *ret = NULL;
+
+    ignore_value(VIR_STRDUP(ret, group->controllers[VIR_CGROUP_CONTROLLER_SYSTEMD].placement));

This ignores a potential OOM error which could not have happened before.

I'd suggest calling this virCgroupV1StealPlacement and using
VIR_STEAL_PTR here.

Alternatively, propagate the return value of VIR_STRDUP.

Reviewed-by: Ján Tomko <jtomko@xxxxxxxxxx>

Jano

Attachment: signature.asc
Description: Digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux