From nobody Mon Feb 9 19:26:15 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1695917648; cv=none; d=zohomail.com; s=zohoarc; b=VSAgjS5ccLwVf3zfvaW8LEzNbPlLgG0Y7DDmeDzQbA6ImT61YtKECIMcXME6gCd1ksv4vDtV0JL+/LNgDwNxeDVP/vVpiTML17HXU+RZhUv7wAUXmXeV0DSy/GG1e2rXlfqynAh0TkKMLWukNiPD6pSjUWuWGRFjkDSVLQb1hEI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695917648; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nr4faqBu7BYXdMJ1RAquN0GKNZXNsBeIAmN9AgBSTCk=; b=ky4H7KARj2XtO/eFjdXHjea6/jvXTbJJw9eVgVQt7f9bpdl3I0dKynOtGx1Ruq2sitrD+2gWueJwunc9V5KUijGOOE9JzKnzhl98t4sbeF0xL+B0AvjTlwmRo+tON4rbG+ZW2CA+Sar7pO9SDiKOYnNQ2pb73KrR+67QZsS2xJk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=reject dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1695917648554767.8073446048385; Thu, 28 Sep 2023 09:14:08 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-204--3dzTob9MByr_ajUeMVMBA-1; Thu, 28 Sep 2023 12:14:03 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DCCB2101A550; Thu, 28 Sep 2023 16:14:00 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3BEE740C2009; Thu, 28 Sep 2023 16:14:00 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id DFC361946589; Thu, 28 Sep 2023 16:13:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CC0C51946587 for ; Thu, 28 Sep 2023 15:37:40 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A98C0176E4; Thu, 28 Sep 2023 15:37:35 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A124D28FE for ; Thu, 28 Sep 2023 15:37:35 +0000 (UTC) Received: from us-smtp-inbound-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 825571875052 for ; Thu, 28 Sep 2023 15:37:35 +0000 (UTC) Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-348-vUqbvtJ3M3qgSD2nYyNpOg-1; Thu, 28 Sep 2023 11:37:33 -0400 Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38SFIvtV008306; Thu, 28 Sep 2023 15:37:32 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3tdbk29c81-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Sep 2023 15:37:32 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 38SDt2l9010995; Thu, 28 Sep 2023 15:37:31 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3tabukwaue-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Sep 2023 15:37:31 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 38SFbTdf21758628 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Sep 2023 15:37:29 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A779D20040; Thu, 28 Sep 2023 15:37:29 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4910220043; Thu, 28 Sep 2023 15:37:29 +0000 (GMT) Received: from li-1de7cd4c-3205-11b2-a85c-d27f97db1fe1.ibm.com.com (unknown [9.171.83.163]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 28 Sep 2023 15:37:29 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695917647; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=nr4faqBu7BYXdMJ1RAquN0GKNZXNsBeIAmN9AgBSTCk=; b=hj5m75vKGicWmH7jx+N3LxIRbifumDlR1kv1CXPQOULmoUuvKtSzAsStHOncnCy9ur5LoO EAliLZJDIIMWjKFqOebIRW8gDzT8R/xolGYpH8SREuWFx+VLVoKSzkQKQzv5Tvpaboanbh bB3qDFABXrPz1Fq1g898aFxNAksmmys= X-MC-Unique: -3dzTob9MByr_ajUeMVMBA-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: vUqbvtJ3M3qgSD2nYyNpOg-1 From: Marc Hartmayer To: Subject: [PATCH libvirt v1 3/3] Improve `virsh create --console` behavior Date: Thu, 28 Sep 2023 17:37:10 +0200 Message-ID: <20230928153710.14340-4-mhartmay@linux.ibm.com> In-Reply-To: <20230928153710.14340-1-mhartmay@linux.ibm.com> References: <20230928153710.14340-1-mhartmay@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: x7JQS5iiMvuEOGLXeImjLz2nCMELp5tU X-Proofpoint-ORIG-GUID: x7JQS5iiMvuEOGLXeImjLz2nCMELp5tU X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-09-28_14,2023-09-28_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 priorityscore=1501 lowpriorityscore=0 malwarescore=0 phishscore=0 clxscore=1015 mlxscore=0 spamscore=0 bulkscore=0 mlxlogscore=603 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2309280130 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , Boris Fiuczynski Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: linux.ibm.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695917649907100001 Content-Type: text/plain; charset="utf-8"; x-default="true" When starting a guest via libvirt (`virsh create --console`), early console output was missed because the guest was started first and then the console was attached. This patch changes this to the following sequence: 1. create a paused transient guest 2. attach the console 3. resume the guest Reviewed-by: Boris Fiuczynski Signed-off-by: Marc Hartmayer Reviewed-by: Thomas Huth --- tools/virsh-domain.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 36670039444c..2f055df0d97d 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -8212,6 +8212,13 @@ static const vshCmdOptDef opts_create[] =3D { {.name =3D NULL} }; =20 + +static virshDomain *virDomainCreateXMLHelper(virConnectPtr conn, const cha= r *xmlDesc, unsigned int nfds, int *fds, unsigned int flags) { + if (nfds) + return virDomainCreateXMLWithFiles(conn, xmlDesc, nfds, fds, flags); + return virDomainCreateXML(conn, xmlDesc, flags); +} + static bool cmdCreate(vshControl *ctl, const vshCmd *cmd) { @@ -8220,6 +8227,7 @@ cmdCreate(vshControl *ctl, const vshCmd *cmd) g_autofree char *buffer =3D NULL; #ifndef WIN32 bool console =3D vshCommandOptBool(cmd, "console"); + bool resume_domain =3D false; #endif unsigned int flags =3D 0; size_t nfds =3D 0; @@ -8235,8 +8243,14 @@ cmdCreate(vshControl *ctl, const vshCmd *cmd) if (virshFetchPassFdsList(ctl, cmd, &nfds, &fds) < 0) return false; =20 - if (vshCommandOptBool(cmd, "paused")) + if (vshCommandOptBool(cmd, "paused")) { flags |=3D VIR_DOMAIN_START_PAUSED; +#ifndef WIN32 + } else if (console) { + flags |=3D VIR_DOMAIN_START_PAUSED; + resume_domain =3D true; +#endif + } if (vshCommandOptBool(cmd, "autodestroy")) flags |=3D VIR_DOMAIN_START_AUTODESTROY; if (vshCommandOptBool(cmd, "validate")) @@ -8244,10 +8258,18 @@ cmdCreate(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "reset-nvram")) flags |=3D VIR_DOMAIN_START_RESET_NVRAM; =20 - if (nfds) - dom =3D virDomainCreateXMLWithFiles(priv->conn, buffer, nfds, fds,= flags); - else - dom =3D virDomainCreateXML(priv->conn, buffer, flags); + dom =3D virDomainCreateXMLHelper(priv->conn, buffer, nfds, fds, flags); +#ifndef WIN32 + /* If the driver does not support the paused flag, let's fallback to t= he old + * behavior without the flag. */ + if (!dom && resume_domain && last_error && last_error->code =3D=3D VIR= _ERR_INVALID_ARG) { + vshResetLibvirtError(); + + flags &=3D ~VIR_DOMAIN_START_PAUSED; + resume_domain =3D false; + dom =3D virDomainCreateXMLHelper(priv->conn, buffer, nfds, fds, flag= s); + } +#endif =20 if (!dom) { vshError(ctl, _("Failed to create domain from %1$s"), from); @@ -8258,7 +8280,7 @@ cmdCreate(vshControl *ctl, const vshCmd *cmd) virDomainGetName(dom), from); #ifndef WIN32 if (console) - cmdRunConsole(ctl, dom, NULL, false, 0); + cmdRunConsole(ctl, dom, NULL, resume_domain, 0); #endif return true; } --=20 2.34.1