mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
ch: Add Cap checks for unix backend of serial port
Unix Socket backend is only supported for serial port in cloud-hypervisor. Add relevant checks in chValidateDomainDeviceDef. Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
75ace65104
commit
b2e43609fd
@ -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);
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -195,16 +195,15 @@ chValidateDomainDeviceDef(const virDomainDeviceDef *dev,
|
||||
|
||||
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"));
|
||||
@ -219,15 +218,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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user