[libvirt] [PATCH] lxc: Refresh capabilities if they have never been initalized

Cole Robinson posted 1 patch 4 years, 4 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/ae302da2285cebe3d5d5d1ae0d8a37fea687c045.1575915302.git.crobinso@redhat.com
There is a newer version of this series
src/lxc/lxc_conf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[libvirt] [PATCH] lxc: Refresh capabilities if they have never been initalized
Posted by Cole Robinson 4 years, 4 months ago
Adjust virLXCDriverGetCapabilities to fill in driver->caps if it has
never been set, regardless of the passed 'refresh' boolean.

This fixes LXC XML startup parsing for me

Signed-off-by: Cole Robinson <crobinso@redhat.com>
---
 src/lxc/lxc_conf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c
index 2df1537b22..803176f52b 100644
--- a/src/lxc/lxc_conf.c
+++ b/src/lxc/lxc_conf.c
@@ -186,7 +186,7 @@ virCapsPtr virLXCDriverGetCapabilities(virLXCDriverPtr driver,
                                        bool refresh)
 {
     virCapsPtr ret;
-    if (refresh) {
+    if (refresh || !driver->caps) {
         virCapsPtr caps = NULL;
         if ((caps = virLXCDriverCapsInit(driver)) == NULL)
             return NULL;
-- 
2.23.0

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

Re: [libvirt] [PATCH] lxc: Refresh capabilities if they have never been initalized
Posted by Cole Robinson 4 years, 4 months ago
On 12/9/19 1:15 PM, Cole Robinson wrote:
> Adjust virLXCDriverGetCapabilities to fill in driver->caps if it has
> never been set, regardless of the passed 'refresh' boolean.
> 
> This fixes LXC XML startup parsing for me
> 
> Signed-off-by: Cole Robinson <crobinso@redhat.com>
> ---
>  src/lxc/lxc_conf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 

I meant to add: not sure if it's safe to access driver->caps like this
without holding the driver lock ...

- Cole

> diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c
> index 2df1537b22..803176f52b 100644
> --- a/src/lxc/lxc_conf.c
> +++ b/src/lxc/lxc_conf.c
> @@ -186,7 +186,7 @@ virCapsPtr virLXCDriverGetCapabilities(virLXCDriverPtr driver,
>                                         bool refresh)
>  {
>      virCapsPtr ret;
> -    if (refresh) {
> +    if (refresh || !driver->caps) {
>          virCapsPtr caps = NULL;
>          if ((caps = virLXCDriverCapsInit(driver)) == NULL)
>              return NULL;
>

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

Re: [libvirt] [PATCH] lxc: Refresh capabilities if they have never been initalized
Posted by Daniel P. Berrangé 4 years, 4 months ago
On Mon, Dec 09, 2019 at 01:16:42PM -0500, Cole Robinson wrote:
> On 12/9/19 1:15 PM, Cole Robinson wrote:
> > Adjust virLXCDriverGetCapabilities to fill in driver->caps if it has
> > never been set, regardless of the passed 'refresh' boolean.
> > 
> > This fixes LXC XML startup parsing for me
> > 
> > Signed-off-by: Cole Robinson <crobinso@redhat.com>
> > ---
> >  src/lxc/lxc_conf.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> 
> I meant to add: not sure if it's safe to access driver->caps like this
> without holding the driver lock ...

No, you'll have to hold the lock - take a look at
virQEMUDriverGetCapabilities for the pattern we can
copy.

> 
> - Cole
> 
> > diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c
> > index 2df1537b22..803176f52b 100644
> > --- a/src/lxc/lxc_conf.c
> > +++ b/src/lxc/lxc_conf.c
> > @@ -186,7 +186,7 @@ virCapsPtr virLXCDriverGetCapabilities(virLXCDriverPtr driver,
> >                                         bool refresh)
> >  {
> >      virCapsPtr ret;
> > -    if (refresh) {
> > +    if (refresh || !driver->caps) {
> >          virCapsPtr caps = NULL;
> >          if ((caps = virLXCDriverCapsInit(driver)) == NULL)
> >              return NULL;
> >
> 
> --
> libvir-list mailing list
> libvir-list@redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

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