[libvirt] [PATCH RFC] lxc: Include support to lxc version 3.0 and higher.

Julio Faracco posted 1 patch 5 years, 5 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20181001021858.4650-1-jcfaracco@gmail.com
src/lxc/lxc_native.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
[libvirt] [PATCH RFC] lxc: Include support to lxc version 3.0 and higher.
Posted by Julio Faracco 5 years, 5 months ago
This patch introduce the new settings for LXC 3.0 and higher. The older
versions keep the compatibility to deprecated settings for LXC, but
after release 3.0, the compatibility was removed. This commit adds the
support to the refactored settings.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
---
 src/lxc/lxc_native.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c
index cbdec723dd..c0f70ebb7d 100644
--- a/src/lxc/lxc_native.c
+++ b/src/lxc/lxc_native.c
@@ -200,7 +200,9 @@ lxcSetRootfs(virDomainDefPtr def,
     int type = VIR_DOMAIN_FS_TYPE_MOUNT;
     VIR_AUTOFREE(char *) value = NULL;
 
-    if (virConfGetValueString(properties, "lxc.rootfs", &value) <= 0)
+    if (virConfGetValueString(properties, "lxc.rootfs", &value) <= 0 &&
+        /* Legacy config keys were removed after release 3.0. */
+        virConfGetValueString(properties, "lxc.rootfs.path", &value) <= 0)
         return -1;
 
     if (STRPREFIX(value, "/dev/"))
@@ -1041,7 +1043,9 @@ lxcParseConfigString(const char *config,
     if (VIR_STRDUP(vmdef->os.init, "/sbin/init") < 0)
         goto error;
 
-    if (virConfGetValueString(properties, "lxc.utsname", &value) <= 0 ||
+    if ((virConfGetValueString(properties, "lxc.utsname", &value) <= 0 &&
+         /* Legacy config keys were removed after release 3.0. */
+         virConfGetValueString(properties, "lxc.uts.name", &value) <= 0) ||
         VIR_STRDUP(vmdef->name, value) < 0)
         goto error;
     if (!vmdef->name && (VIR_STRDUP(vmdef->name, "unnamed") < 0))
@@ -1051,7 +1055,9 @@ lxcParseConfigString(const char *config,
         goto error;
 
     /* Look for fstab: we shouldn't have it */
-    if (virConfGetValue(properties, "lxc.mount")) {
+    if (virConfGetValue(properties, "lxc.mount") ||
+         /* Legacy config keys were removed after release 3.0. */
+        virConfGetValue(properties, "lxc.mount.fstab")) {
         virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
                        _("lxc.mount found, use lxc.mount.entry lines instead"));
         goto error;
-- 
2.17.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH RFC] lxc: Include support to lxc version 3.0 and higher.
Posted by Julio Faracco 5 years, 5 months ago
Hi guys,

I put the RFC mark because I don't know if this is the best way to
enhance the support for LXC 3.0. Considering this patch, I can use
both o version without any issue, but I would like to see other points
of view. I'm not completely right about this approach.

--
Julio Cesar Faracco

Em dom, 30 de set de 2018 às 23:19, Julio Faracco
<jcfaracco@gmail.com> escreveu:
>
> This patch introduce the new settings for LXC 3.0 and higher. The older
> versions keep the compatibility to deprecated settings for LXC, but
> after release 3.0, the compatibility was removed. This commit adds the
> support to the refactored settings.
>
> Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
> ---
>  src/lxc/lxc_native.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c
> index cbdec723dd..c0f70ebb7d 100644
> --- a/src/lxc/lxc_native.c
> +++ b/src/lxc/lxc_native.c
> @@ -200,7 +200,9 @@ lxcSetRootfs(virDomainDefPtr def,
>      int type = VIR_DOMAIN_FS_TYPE_MOUNT;
>      VIR_AUTOFREE(char *) value = NULL;
>
> -    if (virConfGetValueString(properties, "lxc.rootfs", &value) <= 0)
> +    if (virConfGetValueString(properties, "lxc.rootfs", &value) <= 0 &&
> +        /* Legacy config keys were removed after release 3.0. */
> +        virConfGetValueString(properties, "lxc.rootfs.path", &value) <= 0)
>          return -1;
>
>      if (STRPREFIX(value, "/dev/"))
> @@ -1041,7 +1043,9 @@ lxcParseConfigString(const char *config,
>      if (VIR_STRDUP(vmdef->os.init, "/sbin/init") < 0)
>          goto error;
>
> -    if (virConfGetValueString(properties, "lxc.utsname", &value) <= 0 ||
> +    if ((virConfGetValueString(properties, "lxc.utsname", &value) <= 0 &&
> +         /* Legacy config keys were removed after release 3.0. */
> +         virConfGetValueString(properties, "lxc.uts.name", &value) <= 0) ||
>          VIR_STRDUP(vmdef->name, value) < 0)
>          goto error;
>      if (!vmdef->name && (VIR_STRDUP(vmdef->name, "unnamed") < 0))
> @@ -1051,7 +1055,9 @@ lxcParseConfigString(const char *config,
>          goto error;
>
>      /* Look for fstab: we shouldn't have it */
> -    if (virConfGetValue(properties, "lxc.mount")) {
> +    if (virConfGetValue(properties, "lxc.mount") ||
> +         /* Legacy config keys were removed after release 3.0. */
> +        virConfGetValue(properties, "lxc.mount.fstab")) {
>          virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
>                         _("lxc.mount found, use lxc.mount.entry lines instead"));
>          goto error;
> --
> 2.17.1
>

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH RFC] lxc: Include support to lxc version 3.0 and higher.
Posted by Julio Faracco 5 years, 5 months ago
For further reference:
https://lists.linuxcontainers.org/pipermail/lxc-devel/2018-April/017663.html

Em dom, 30 de set de 2018 às 23:24, Julio Faracco
<jcfaracco@gmail.com> escreveu:
>
> Hi guys,
>
> I put the RFC mark because I don't know if this is the best way to
> enhance the support for LXC 3.0. Considering this patch, I can use
> both o version without any issue, but I would like to see other points
> of view. I'm not completely right about this approach.
>
> --
> Julio Cesar Faracco
>
> Em dom, 30 de set de 2018 às 23:19, Julio Faracco
> <jcfaracco@gmail.com> escreveu:
> >
> > This patch introduce the new settings for LXC 3.0 and higher. The older
> > versions keep the compatibility to deprecated settings for LXC, but
> > after release 3.0, the compatibility was removed. This commit adds the
> > support to the refactored settings.
> >
> > Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
> > ---
> >  src/lxc/lxc_native.c | 12 +++++++++---
> >  1 file changed, 9 insertions(+), 3 deletions(-)
> >
> > diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c
> > index cbdec723dd..c0f70ebb7d 100644
> > --- a/src/lxc/lxc_native.c
> > +++ b/src/lxc/lxc_native.c
> > @@ -200,7 +200,9 @@ lxcSetRootfs(virDomainDefPtr def,
> >      int type = VIR_DOMAIN_FS_TYPE_MOUNT;
> >      VIR_AUTOFREE(char *) value = NULL;
> >
> > -    if (virConfGetValueString(properties, "lxc.rootfs", &value) <= 0)
> > +    if (virConfGetValueString(properties, "lxc.rootfs", &value) <= 0 &&
> > +        /* Legacy config keys were removed after release 3.0. */
> > +        virConfGetValueString(properties, "lxc.rootfs.path", &value) <= 0)
> >          return -1;
> >
> >      if (STRPREFIX(value, "/dev/"))
> > @@ -1041,7 +1043,9 @@ lxcParseConfigString(const char *config,
> >      if (VIR_STRDUP(vmdef->os.init, "/sbin/init") < 0)
> >          goto error;
> >
> > -    if (virConfGetValueString(properties, "lxc.utsname", &value) <= 0 ||
> > +    if ((virConfGetValueString(properties, "lxc.utsname", &value) <= 0 &&
> > +         /* Legacy config keys were removed after release 3.0. */
> > +         virConfGetValueString(properties, "lxc.uts.name", &value) <= 0) ||
> >          VIR_STRDUP(vmdef->name, value) < 0)
> >          goto error;
> >      if (!vmdef->name && (VIR_STRDUP(vmdef->name, "unnamed") < 0))
> > @@ -1051,7 +1055,9 @@ lxcParseConfigString(const char *config,
> >          goto error;
> >
> >      /* Look for fstab: we shouldn't have it */
> > -    if (virConfGetValue(properties, "lxc.mount")) {
> > +    if (virConfGetValue(properties, "lxc.mount") ||
> > +         /* Legacy config keys were removed after release 3.0. */
> > +        virConfGetValue(properties, "lxc.mount.fstab")) {
> >          virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
> >                         _("lxc.mount found, use lxc.mount.entry lines instead"));
> >          goto error;
> > --
> > 2.17.1
> >

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH RFC] lxc: Include support to lxc version 3.0 and higher.
Posted by Michal Privoznik 5 years, 5 months ago
On 10/01/2018 04:18 AM, Julio Faracco wrote:
> This patch introduce the new settings for LXC 3.0 and higher. The older
> versions keep the compatibility to deprecated settings for LXC, but
> after release 3.0, the compatibility was removed. This commit adds the
> support to the refactored settings.
> 
> Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
> ---
>  src/lxc/lxc_native.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c
> index cbdec723dd..c0f70ebb7d 100644
> --- a/src/lxc/lxc_native.c
> +++ b/src/lxc/lxc_native.c
> @@ -200,7 +200,9 @@ lxcSetRootfs(virDomainDefPtr def,
>      int type = VIR_DOMAIN_FS_TYPE_MOUNT;
>      VIR_AUTOFREE(char *) value = NULL;
>  
> -    if (virConfGetValueString(properties, "lxc.rootfs", &value) <= 0)
> +    if (virConfGetValueString(properties, "lxc.rootfs", &value) <= 0 &&
> +        /* Legacy config keys were removed after release 3.0. */
> +        virConfGetValueString(properties, "lxc.rootfs.path", &value) <= 0)

The intention looks good to me, but the formatting doesn't. Either:

/* comment */
if (func() <= 0 &&
    func() <= 0)
    return -1;

or:

if (func() <= 0) {
  /* comment */
  if (func() <= 0)
     return -1;
}

Michal

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