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

Message ID ab3e90d1c8d5a8e526252bcaf4b51aa0dfcd0c7f.1575921490.git.crobinso@redhat.com
State Accepted
Commit 22e7997d0cb4dd52c023ea4a40873b8274281e25
Headers show
Series
  • [v2] lxc: Refresh capabilities if they have never been initalized
Related show

Commit Message

Cole Robinson Dec. 9, 2019, 7:58 p.m.
Adjust virLXCDriverGetCapabilities to fill in driver->caps if it is
empty, regardless of the passed 'refresh' value. This matches the
pattern used in virQEMUDriverGetCapabilities

This fixes LXC XML startup parsing for me

Signed-off-by: Cole Robinson <crobinso@redhat.com>

---
v2:
    Use the virQEMUDriverGetCapabilities like danpb suggested

 src/lxc/lxc_conf.c | 8 ++++++++
 1 file changed, 8 insertions(+)

-- 
2.23.0

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

Comments

Daniel P. Berrangé Dec. 10, 2019, 9:44 a.m. | #1
On Mon, Dec 09, 2019 at 02:58:51PM -0500, Cole Robinson wrote:
> Adjust virLXCDriverGetCapabilities to fill in driver->caps if it is
> empty, regardless of the passed 'refresh' value. This matches the
> pattern used in virQEMUDriverGetCapabilities
> 
> This fixes LXC XML startup parsing for me
> 
> Signed-off-by: Cole Robinson <crobinso@redhat.com>
> ---
> v2:
>     Use the virQEMUDriverGetCapabilities like danpb suggested
> 
>  src/lxc/lxc_conf.c | 8 ++++++++
>  1 file changed, 8 insertions(+)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>

> diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c
> index 2df1537b22..adf7a0b66c 100644
> --- a/src/lxc/lxc_conf.c
> +++ b/src/lxc/lxc_conf.c
> @@ -196,6 +196,14 @@ virCapsPtr virLXCDriverGetCapabilities(virLXCDriverPtr driver,
>          driver->caps = caps;
>      } else {
>          lxcDriverLock(driver);
> +
> +        if (driver->caps == NULL ||
> +            driver->caps->nguests == 0) {

nitpick:  nguests will never be zero in LXC since we hardcode the
set of guests, so you can drop that part of the condition when pushing.

> +            VIR_DEBUG("Capabilities didn't detect any guests. Forcing a "
> +                      "refresh.");
> +            lxcDriverUnlock(driver);
> +            return virLXCDriverGetCapabilities(driver, true);
> +        }
>      }
>  
>      ret = virObjectRef(driver->caps);

Regards,
Daniel

Patch

diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c
index 2df1537b22..adf7a0b66c 100644
--- a/src/lxc/lxc_conf.c
+++ b/src/lxc/lxc_conf.c
@@ -196,6 +196,14 @@  virCapsPtr virLXCDriverGetCapabilities(virLXCDriverPtr driver,
         driver->caps = caps;
     } else {
         lxcDriverLock(driver);
+
+        if (driver->caps == NULL ||
+            driver->caps->nguests == 0) {
+            VIR_DEBUG("Capabilities didn't detect any guests. Forcing a "
+                      "refresh.");
+            lxcDriverUnlock(driver);
+            return virLXCDriverGetCapabilities(driver, true);
+        }
     }
 
     ret = virObjectRef(driver->caps);