[libvirt PATCH 0/1] Do not add stub console to ch VMs

This patch resolves https://gitlab.com/libvirt/libvirt/-/issues/344 I tested various versions of cloud-hypervisor between v15 - v29. All of them fail to start a test VM without this patch. Praveen K Paladugu (1): ch: Do not add stub console to ch VMs src/ch/ch_domain.c | 1 + src/conf/domain_conf.c | 7 ++++--- src/conf/domain_conf.h | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) -- 2.34.1

virDomainDefAddConsoleCompat in post parsing step appends a stub console of type VIR_DOMAIN_CHR_TYPE_NULL to ch VMs' Domain XML. Cloud-hypervisor's deviceValidateCallback (chValidateDomainDeviceDef) checks that the type of stub console is not of type VIR_DOMAIN_CHR_TYPE_PTY and throws an error. This commit introduces NO_STUB_CONSOLE feature check to Domain features and uses it to skip adding stub console to ch VMs. Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com> --- src/ch/ch_domain.c | 1 + src/conf/domain_conf.c | 7 ++++--- src/conf/domain_conf.h | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/ch/ch_domain.c b/src/ch/ch_domain.c index 83defbb416..cf98654479 100644 --- a/src/ch/ch_domain.c +++ b/src/ch/ch_domain.c @@ -262,6 +262,7 @@ virDomainDefParserConfig virCHDriverDomainDefParserConfig = { .domainPostParseBasicCallback = virCHDomainDefPostParseBasic, .domainPostParseCallback = virCHDomainDefPostParse, .deviceValidateCallback = chValidateDomainDeviceDef, + .features = VIR_DOMAIN_DEF_FEATURE_NO_STUB_CONSOLE, }; virCHMonitor * diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ff1c78ecd1..a5578324b9 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -21751,9 +21751,10 @@ virDomainDefAddImplicitVideo(virDomainDef *def, virDomainXMLOption *xmlopt) int virDomainDefAddImplicitDevices(virDomainDef *def, virDomainXMLOption *xmlopt) { - if (virDomainDefAddConsoleCompat(def) < 0) - return -1; - + if ((xmlopt->config.features & VIR_DOMAIN_DEF_FEATURE_NO_STUB_CONSOLE) == 0) { + if (virDomainDefAddConsoleCompat(def) < 0) + return -1; + } if (virDomainDefAddImplicitControllers(def) < 0) return -1; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index e684edcf95..62f80d653d 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3231,6 +3231,7 @@ typedef enum { VIR_DOMAIN_DEF_FEATURE_FW_AUTOSELECT = (1 << 7), VIR_DOMAIN_DEF_FEATURE_NET_MODEL_STRING = (1 << 8), VIR_DOMAIN_DEF_FEATURE_DISK_FD = (1 << 9), + VIR_DOMAIN_DEF_FEATURE_NO_STUB_CONSOLE = (1 << 10), } virDomainDefFeatures; -- 2.34.1

On 2/9/23 23:09, Praveen K Paladugu wrote:
virDomainDefAddConsoleCompat in post parsing step appends a stub console of type VIR_DOMAIN_CHR_TYPE_NULL to ch VMs' Domain XML. Cloud-hypervisor's deviceValidateCallback (chValidateDomainDeviceDef) checks that the type of stub console is not of type VIR_DOMAIN_CHR_TYPE_PTY and throws an error.
This commit introduces NO_STUB_CONSOLE feature check to Domain features and uses it to skip adding stub console to ch VMs.
Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com> --- src/ch/ch_domain.c | 1 + src/conf/domain_conf.c | 7 ++++--- src/conf/domain_conf.h | 1 + 3 files changed, 6 insertions(+), 3 deletions(-)
Yes, I think we can finally break this backwards compatibility at least for this new driver. Reviewed-by: Michal Privoznik <mprivozn@redhat.com> and pushed. Michal

O Fri, Feb 10, 2023 at 03:24:02PM +0100, Michal Pr??vozn??k wrote:
On 2/9/23 23:09, Praveen K Paladugu wrote:
virDomainDefAddConsoleCompat in post parsing step appends a stub console of type VIR_DOMAIN_CHR_TYPE_NULL to ch VMs' Domain XML. Cloud-hypervisor's deviceValidateCallback (chValidateDomainDeviceDef) checks that the type of stub console is not of type VIR_DOMAIN_CHR_TYPE_PTY and throws an error.
This commit introduces NO_STUB_CONSOLE feature check to Domain features and uses it to skip adding stub console to ch VMs.
Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com> --- src/ch/ch_domain.c | 1 + src/conf/domain_conf.c | 7 ++++--- src/conf/domain_conf.h | 1 + 3 files changed, 6 insertions(+), 3 deletions(-)
Yes, I think we can finally break this backwards compatibility at least for this new driver.
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
and pushed.
Michal Thanks for promptly pushing this patch.
Praveen
participants (3)
-
Michal Prívozník
-
Praveen K Paladugu
-
Praveen Paladugu