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);
}
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;
if (!virBitmapIsBitSet(driver->chCaps, CH_SERIAL_CONSOLE_IN_PARALLEL)) {
if ((def->nconsoles &&
- def->consoles[0]->source->type == VIR_DOMAIN_CHR_TYPE_PTY)
- && (def->nserials &&
- def->serials[0]->source->type == VIR_DOMAIN_CHR_TYPE_PTY)) {
+ def->consoles[0]->source->type == VIR_DOMAIN_CHR_TYPE_PTY) &&
+ (def->nserials &&
+ def->serials[0]->source->type == VIR_DOMAIN_CHR_TYPE_PTY)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Only a single console or serial can be configured for this domain"));
+ _("Only a single console or serial can be configured for this domain"));
return -1;
}
}
-
if (def->nconsoles > 1) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Only a single console can be configured for this domain"));
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;
}