From nobody Tue May 14 05:05:49 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1709672349664402.08661937249894; Tue, 5 Mar 2024 12:59:09 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 5D3B11C9F; Tue, 5 Mar 2024 15:59:08 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 5B66F1A45; Tue, 5 Mar 2024 15:57:17 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 71C711A4C; Tue, 5 Mar 2024 15:57:11 -0500 (EST) Received: from mail-oo1-f41.google.com (mail-oo1-f41.google.com [209.85.161.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 305E31A30 for ; Tue, 5 Mar 2024 15:57:10 -0500 (EST) Received: by mail-oo1-f41.google.com with SMTP id 006d021491bc7-595aa5b1fe0so723540eaf.2 for ; Tue, 05 Mar 2024 12:57:10 -0800 (PST) Received: from home.. (2603-8081-c640-0001-0000-0000-0000-1006.res6.spectrum.com. [2603:8081:c640:1::1006]) by smtp.gmail.com with ESMTPSA id uk14-20020a0568714e8e00b0022100a80b01sm1298004oab.39.2024.03.05.12.57.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 12:57:08 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709672229; x=1710277029; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TOahg8n0vsHhQbc3U3Bgg7waKXGz39ySCq6rCR3PtXc=; b=O5AquzBiuBfxtts2M6ekUURTgXS7ZJ+GEPZHDc4jRoBzalIp5hDSM41ifLgkpFoFf7 wMTobAmnMG2d9c85VqvlcHDRXOahKiyhNq+oio2WoiUcKioSHeJ5P0wlaQZRTwWcHu+n vFruifNixfH2SFdztCVJi5elQdCNm6rt76A1D/ufENU8uurB8Z+jRD+tzU+BFIWbUlmW 45kYEnn8seVMXNTpr8JkEzu48pP5HsxwXAk1VmFlTRIBkJ+yJ3GmTmfhMSVFHH3mX3c/ Eg/SCOX5rbGo6F58oPmsW8j3ubl5SBL/7/wRxYBFT3oJmXxy4i2ZdkjrG5rKb3ZF+ssv 5JFA== X-Gm-Message-State: AOJu0YwNxNRYxd5Ym6z8nrfpQAeF6yUDCnrqFzdwoWhQKIRfdDwaGg9l Gt9BtlumV6sfEG4Rz7MEUILVQeF/sA8dHHDyVP3JZZ96PTK+YbzSusZbXtrH X-Google-Smtp-Source: AGHT+IG63VaIjrxWagjSLvKwhhePYDvRDjD4URpKMR09z0lzOF4YYRmkzlqxJhm+WTVcpzw4x+kYlw== X-Received: by 2002:a05:6871:3424:b0:221:3a2c:69bc with SMTP id nh36-20020a056871342400b002213a2c69bcmr3000562oac.6.1709672229039; Tue, 05 Mar 2024 12:57:09 -0800 (PST) From: Praveen K Paladugu X-Google-Original-From: Praveen K Paladugu To: devel@lists.libvirt.org Subject: [PATCH 1/2] ch: Add Cap checks for unix backend of serial port Date: Tue, 5 Mar 2024 14:57:03 -0600 Message-ID: <20240305205704.34991-2-prapal@linux.microsoft.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240305205704.34991-1-prapal@linux.microsoft.com> References: <20240305205704.34991-1-prapal@linux.microsoft.com> MIME-Version: 1.0 Message-ID-Hash: RVVQ3EXVYMEDM5Q5DNE6WY37I3HLMI6Y X-Message-ID-Hash: RVVQ3EXVYMEDM5Q5DNE6WY37I3HLMI6Y X-MailFrom: praveenkpaladugu@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: liuwe@microsoft.com X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1709672351097100001 From: Praveen K Paladugu Unix Socket backend is only supported for serial port in cloud-hypervisor. Add relevant checks in chValidateDomainDeviceDef. Signed-off-by: Praveen K Paladugu Reviewed-by: Michal Privoznik --- 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 >=3D 22000000) virCHCapsSet(chCaps, CH_MULTIFD_IN_ADDNET); =20 + /* Starting v36, Cloud-Hypervisor accepts Unix Socket as a backend for + * guest's serial port. + * https://github.com/cloud-hypervisor/cloud-hypervisor/releases/tag/v= 36.0 */ + if (version >=3D 36000000) + virCHCapsSet(chCaps, CH_SOCKET_BACKEND_SERIAL_PORT); + return g_steal_pointer(&chCaps); =20 } 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 a= dd-net api */ + CH_SOCKET_BACKEND_SERIAL_PORT, /* Support Unix socket as a backend for= a serial port */ =20 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 *d= ev, =20 if (def->nconsoles && def->consoles[0]->source->type !=3D VIR_DOMAIN_C= HR_TYPE_PTY) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Console can only be enabled for a PTY")); + _("Console only works in PTY mode")); return -1; } =20 - if (def->nserials && def->serials[0]->source->type !=3D 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 !=3D VIR_DOMAIN_CHR_TYPE_PTY && + def->serials[0]->source->type !=3D 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_PO= RT) && + def->serials[0]->source->type =3D=3D 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; } =20 --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Tue May 14 05:05:49 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1709672549672665.0283785482247; Tue, 5 Mar 2024 13:02:29 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 920691C65; Tue, 5 Mar 2024 16:02:28 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 51B421B38; Tue, 5 Mar 2024 15:57:32 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 4C55C1996; Tue, 5 Mar 2024 15:57:12 -0500 (EST) Received: from mail-ot1-f53.google.com (mail-ot1-f53.google.com [209.85.210.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id D6F2A1A3F for ; Tue, 5 Mar 2024 15:57:10 -0500 (EST) Received: by mail-ot1-f53.google.com with SMTP id 46e09a7af769-6e4e8be9c85so941517a34.3 for ; Tue, 05 Mar 2024 12:57:10 -0800 (PST) Received: from home.. (2603-8081-c640-0001-0000-0000-0000-1006.res6.spectrum.com. [2603:8081:c640:1::1006]) by smtp.gmail.com with ESMTPSA id uk14-20020a0568714e8e00b0022100a80b01sm1298004oab.39.2024.03.05.12.57.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 12:57:09 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709672230; x=1710277030; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dCbmdQtdrZq+N8E4aCtDeCmNl2kgHJ2KfcZrYN32ie8=; b=cFzzpgBy0dQLDCIAESg8+vuMKhtrHf8QMW7+HpZUzhOctYf9Z+yGM0CFMauAvWJ7jH gt3ubFGaBS2VtyiYtQmUHMyKQCkwoo73FN1v6COt8UagGrj3WIlTtSrbnoVn/mUt27cr E3E2aXwmJsCH0GHRkM/vnglHl6vpe9TAVXiWPACB0snXKoQFebgRIE0E92UqIZU/FGM9 K4S8TMmRR9rsM0/+kzdmDD20O214xn1uf6sPffHhQWfeICEUSVqhGFzC2d//PdZVmQA1 d0jaDa1wVcW6guHBXpkYzb8eVIZ1lhTNJc5KNNSWVNSaAQ3D/HbDfIObmkPArOPVX54F GCFw== X-Gm-Message-State: AOJu0YzW/TEWEQZgB8NRYPo8WKTgULs6GRDV8xPtbTFQqodTNT29s9vV 1Q1bwpyvOLfVgc/CQ3AGsLl/ilJkLuQQbOU0/ND2P4K1xc9conhQoBN/WtzJ X-Google-Smtp-Source: AGHT+IEasa8XN1dXHQKmdwLUSQh01tMpJhtBf5SgR3Xcs8R7KGpj11fa22xAA7tuHbr6jnjqKU6Ogg== X-Received: by 2002:a05:6870:9d06:b0:221:2259:c042 with SMTP id pp6-20020a0568709d0600b002212259c042mr3421662oab.18.1709672229808; Tue, 05 Mar 2024 12:57:09 -0800 (PST) From: Praveen K Paladugu X-Google-Original-From: Praveen K Paladugu To: devel@lists.libvirt.org Subject: [PATCH 2/2] ch: Add support for `Unix` mode to serial port dev Date: Tue, 5 Mar 2024 14:57:04 -0600 Message-ID: <20240305205704.34991-3-prapal@linux.microsoft.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240305205704.34991-1-prapal@linux.microsoft.com> References: <20240305205704.34991-1-prapal@linux.microsoft.com> MIME-Version: 1.0 Message-ID-Hash: EEPBGOCTBWJPL6BVARNLSCCUO6HSDO4Z X-Message-ID-Hash: EEPBGOCTBWJPL6BVARNLSCCUO6HSDO4Z X-MailFrom: praveenkpaladugu@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: liuwe@microsoft.com X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1709672550202100001 With Unix mode, pass a socket path to cloud-hypervisor. Cloud-Hypervisor will attach guest's serial port to this socket path. Users can connect to the serial port using one of the following commands: `socat -,crnl UNIX-CONNECT:` OR `minicom --device unix#` Signed-off-by: Praveen K Paladugu Reviewed-by: Michal Privoznik --- src/ch/ch_domain.c | 1 - src/ch/ch_monitor.c | 35 ++++++++++++++++++++++++----------- src/ch/ch_process.c | 7 +++++++ 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/src/ch/ch_domain.c b/src/ch/ch_domain.c index 214574cf00..5b2ab6dd99 100644 --- a/src/ch/ch_domain.c +++ b/src/ch/ch_domain.c @@ -204,7 +204,6 @@ chValidateDomainDeviceDef(const virDomainDeviceDef *dev, } } =20 - if (def->nconsoles > 1) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Only a single console can be configured for this= domain")); diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c index 62ba72bb82..3536d3d63e 100644 --- a/src/ch/ch_monitor.c +++ b/src/ch/ch_monitor.c @@ -89,22 +89,35 @@ virCHMonitorBuildCPUJson(virJSONValue *content, virDoma= inDef *vmdef) } =20 static int -virCHMonitorBuildPTYJson(virJSONValue *content, virDomainDef *vmdef) +virCHMonitorBuildConsoleJson(virJSONValue *content, virDomainDef *vmdef) { - if (vmdef->nconsoles) { - g_autoptr(virJSONValue) pty =3D virJSONValueNewObject(); - if (virJSONValueObjectAppendString(pty, "mode", "Pty") < 0) + g_autoptr(virJSONValue) console =3D virJSONValueNewObject(); + g_autoptr(virJSONValue) serial =3D virJSONValueNewObject(); + + if (vmdef->nconsoles && + vmdef->consoles[0]->source->type =3D=3D VIR_DOMAIN_CHR_TYPE_PTY) { + if (virJSONValueObjectAppendString(console, "mode", "Pty") < 0) return -1; - if (virJSONValueObjectAppend(content, "console", &pty) < 0) + if (virJSONValueObjectAppend(content, "console", &console) < 0) return -1; } =20 if (vmdef->nserials) { - g_autoptr(virJSONValue) pty =3D virJSONValueNewObject(); - if (virJSONValueObjectAppendString(pty, "mode", "Pty") < 0) - return -1; - if (virJSONValueObjectAppend(content, "serial", &pty) < 0) - return -1; + if (vmdef->serials[0]->source->type =3D=3D VIR_DOMAIN_CHR_TYPE_PTY= ) { + if (virJSONValueObjectAppendString(serial, "mode", "Pty") < 0) + return -1; + } + else if (vmdef->serials[0]->source->type =3D=3D VIR_DOMAIN_CHR_TYP= E_UNIX) { + if (virJSONValueObjectAppendString(serial, "mode", "Socket") <= 0) + return -1; + if (virJSONValueObjectAppendString(serial, + "socket", + vmdef->serials[0]->source->= data.file.path) < 0) + return -1; + } + + if (virJSONValueObjectAppend(content, "serial", &serial) < 0) + return -1; } =20 return 0; @@ -415,7 +428,7 @@ virCHMonitorBuildVMJson(virCHDriver *driver, virDomainD= ef *vmdef, return -1; } =20 - if (virCHMonitorBuildPTYJson(content, vmdef) < 0) + if (virCHMonitorBuildConsoleJson(content, vmdef) < 0) return -1; =20 if (virCHMonitorBuildCPUJson(content, vmdef) < 0) diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c index 3bde9d9dcf..b371181fb2 100644 --- a/src/ch/ch_process.c +++ b/src/ch/ch_process.c @@ -69,6 +69,13 @@ virCHProcessUpdateConsoleDevice(virDomainObj *vm, if (!config) return; =20 + /* This method is used to extract pty info from cloud-hypervisor and c= apture + * it in domain configuration. This step can be skipped for serial dev= ices + * with unix backend.*/ + if (STREQ(device, "serial") && + vm->def->serials[0]->source->type =3D=3D VIR_DOMAIN_CHR_TYPE_UNIX) + return; + dev =3D virJSONValueObjectGet(config, device); if (!dev) { virReportError(VIR_ERR_INTERNAL_ERROR, --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org