[PATCH 1/9] ch_domain: Add virChrdevs for console support

William Douglas posted 9 patches 4 years, 5 months ago
[PATCH 1/9] ch_domain: Add virChrdevs for console support
Posted by William Douglas 4 years, 5 months ago
Add and initialize a virChrdevs to the _virCHDomainObjPrivate
structure in order to eventually track the consoles in use by a domain.

Signed-off-by: William Douglas <william.douglas@intel.com>
---
 src/ch/ch_domain.c | 7 +++++++
 src/ch/ch_domain.h | 3 +++
 2 files changed, 10 insertions(+)

diff --git a/src/ch/ch_domain.c b/src/ch/ch_domain.c
index 780a46ba00..a6b87e28e5 100644
--- a/src/ch/ch_domain.c
+++ b/src/ch/ch_domain.c
@@ -22,6 +22,7 @@
 
 #include "ch_domain.h"
 #include "viralloc.h"
+#include "virchrdev.h"
 #include "virlog.h"
 #include "virtime.h"
 
@@ -146,6 +147,11 @@ virCHDomainObjPrivateAlloc(void *opaque G_GNUC_UNUSED)
         return NULL;
     }
 
+    if (!(priv->chrdevs = virChrdevAlloc())) {
+        g_free(priv);
+        return NULL;
+    }
+
     return priv;
 }
 
@@ -154,6 +160,7 @@ virCHDomainObjPrivateFree(void *data)
 {
     virCHDomainObjPrivate *priv = data;
 
+    virChrdevFree(priv->chrdevs);
     virCHDomainObjFreeJob(priv);
     g_free(priv);
 }
diff --git a/src/ch/ch_domain.h b/src/ch/ch_domain.h
index b4e0d4c212..61b34b0467 100644
--- a/src/ch/ch_domain.h
+++ b/src/ch/ch_domain.h
@@ -22,6 +22,7 @@
 
 #include "ch_conf.h"
 #include "ch_monitor.h"
+#include "virchrdev.h"
 
 /* Give up waiting for mutex after 30 seconds */
 #define CH_JOB_WAIT_TIME (1000ull * 30)
@@ -52,6 +53,8 @@ struct _virCHDomainObjPrivate {
     struct virCHDomainJobObj job;
 
     virCHMonitor *monitor;
+
+     virChrdevs *chrdevs;
 };
 
 extern virDomainXMLPrivateDataCallbacks virCHDriverPrivateDataCallbacks;
-- 
2.31.1

Re: [PATCH 1/9] ch_domain: Add virChrdevs for console support
Posted by Daniel P. Berrangé 4 years, 5 months ago
On Wed, Sep 08, 2021 at 11:01:15AM -0700, William Douglas wrote:
> Add and initialize a virChrdevs to the _virCHDomainObjPrivate
> structure in order to eventually track the consoles in use by a domain.
> 
> Signed-off-by: William Douglas <william.douglas@intel.com>
> ---
>  src/ch/ch_domain.c | 7 +++++++
>  src/ch/ch_domain.h | 3 +++
>  2 files changed, 10 insertions(+)
> 
> diff --git a/src/ch/ch_domain.c b/src/ch/ch_domain.c
> index 780a46ba00..a6b87e28e5 100644
> --- a/src/ch/ch_domain.c
> +++ b/src/ch/ch_domain.c
> @@ -22,6 +22,7 @@
>  
>  #include "ch_domain.h"
>  #include "viralloc.h"
> +#include "virchrdev.h"
>  #include "virlog.h"
>  #include "virtime.h"
>  
> @@ -146,6 +147,11 @@ virCHDomainObjPrivateAlloc(void *opaque G_GNUC_UNUSED)
>          return NULL;
>      }
>  
> +    if (!(priv->chrdevs = virChrdevAlloc())) {

Needs

  virCHDomainObjFreeJob(priv);

> +        g_free(priv);
> +        return NULL;
> +    }
> +
>      return priv;
>  }

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 :|