[PATCH 1/2] ch: Add Cap checks for unix backend of serial port

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

 



From: Praveen K Paladugu <praveenkpaladugu@xxxxxxxxx>

Unix Socket backend is only supported for serial port in
cloud-hypervisor. Add relevant checks in chValidateDomainDeviceDef.

Signed-off-by: Praveen K Paladugu <prapal@xxxxxxxxxxxxxxxxxxx>
---
 src/ch/ch_capabilities.c |  6 ++++++
 src/ch/ch_capabilities.h |  1 +
 src/ch/ch_domain.c       | 20 +++++++++++++++-----
 3 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/src/ch/ch_capabilities.c b/src/ch/ch_capabilities.c
index b9e62d2d5b..5941851500 100644
--- a/src/ch/ch_capabilities.c
+++ b/src/ch/ch_capabilities.c
@@ -59,6 +59,12 @@ virCHCapsInitCHVersionCaps(int version)
     if (version >= 22000000)
         virCHCapsSet(chCaps, CH_MULTIFD_IN_ADDNET);
 
+    /* Starting v36, Cloud-Hypervisor accepts Unix Socket as a backend for
+     * guest's serial port.
+     * https://github.com/cloud-hypervisor/cloud-hypervisor/releases/tag/v36.0 */
+    if (version >= 36000000)
+        virCHCapsSet(chCaps, CH_SOCKET_BACKEND_SERIAL_PORT);
+
     return g_steal_pointer(&chCaps);
 
 }
diff --git a/src/ch/ch_capabilities.h b/src/ch/ch_capabilities.h
index ffb8881a11..03932511f6 100644
--- a/src/ch/ch_capabilities.h
+++ b/src/ch/ch_capabilities.h
@@ -27,6 +27,7 @@ typedef enum {
     CH_KERNEL_API_DEPRCATED, /* Use `payload` in place of `kernel` api */
     CH_SERIAL_CONSOLE_IN_PARALLEL, /* Serial and Console ports can work in parallel */
     CH_MULTIFD_IN_ADDNET, /* Cloud-hypervisor can accept multiple FDs in add-net api */
+    CH_SOCKET_BACKEND_SERIAL_PORT, /* Support Unix socket as a backend for a serial port */
 
     CH_CAPS_LAST /* this must always be the last item */
 } virCHCapsFlags;
diff --git a/src/ch/ch_domain.c b/src/ch/ch_domain.c
index a6bf749d89..214574cf00 100644
--- a/src/ch/ch_domain.c
+++ b/src/ch/ch_domain.c
@@ -219,15 +219,25 @@ chValidateDomainDeviceDef(const virDomainDeviceDef *dev,
 
     if (def->nconsoles && def->consoles[0]->source->type != VIR_DOMAIN_CHR_TYPE_PTY) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("Console can only be enabled for a PTY"));
+                       _("Console only works in PTY mode"));
         return -1;
     }
 
-    if (def->nserials && def->serials[0]->source->type != VIR_DOMAIN_CHR_TYPE_PTY) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("Serial can only be enabled for a PTY"));
-        return -1;
+    if (def->nserials) {
+        if (def->serials[0]->source->type != VIR_DOMAIN_CHR_TYPE_PTY &&
+            def->serials[0]->source->type != VIR_DOMAIN_CHR_TYPE_UNIX) {
+                virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                               _("Serial only works in UNIX/PTY modes"));
+                return -1;
+            }
+        if (!virBitmapIsBitSet(driver->chCaps, CH_SOCKET_BACKEND_SERIAL_PORT) &&
+            def->serials[0]->source->type == VIR_DOMAIN_CHR_TYPE_UNIX) {
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                           _("Unix Socket backend is not supported by this version of ch."));
+            return -1;
+        }
     }
+
     return 0;
 }
 
-- 
2.43.0
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[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