From nobody Mon May 13 15:48:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1695649196; cv=none; d=zohomail.com; s=zohoarc; b=AVKOMIwh5/lVn+0Z3bEBEPFCWbarvI51VfBO0Le2e1Q68yeqyObRcB3/f1DZnrWPr3xICYYV23eoSd9pqCycyePb6OF4bGrLfUfou+PA/6knklCRZ6LBWHRjrQM/9jmo3gfqfdHyQUvjmjwvW6dvkDqI2T1WHiNm9ItYsqWa5Aw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695649196; 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=Aun/URs/nh7pSCUseegZjHv99ty+tFGSah7SqofMqFY=; b=dL7Omppc5SqUqseM7xpbF5WstH1rkCazRuBFaf5yiW5MB61p90hpmQ3jJNLXTY9auNtdy/JeD7Az2yd/U/BVrCcSnZ5sslowm0Htu69fFUnuIeqACXG4zHei4g40Fz2i9Z4rur+SOaxftXbT2aLPAYrU1KnyjNwR03Q9fmV8X/A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 169564919613780.92517553472942; Mon, 25 Sep 2023 06:39:56 -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-575-T3fv66qWNZaPgw3W5rgB-Q-1; Mon, 25 Sep 2023 09:39:52 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (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 9EA37803470; Mon, 25 Sep 2023 13:39:46 +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 844F2C154CD; Mon, 25 Sep 2023 13:39:46 +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 33870194658F; Mon, 25 Sep 2023 13:39:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 85059194658C for ; Mon, 25 Sep 2023 13:39:44 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 765962026D2C; Mon, 25 Sep 2023 13:39:44 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast08.extmail.prod.ext.rdu2.redhat.com [10.11.55.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6DD572026D68 for ; Mon, 25 Sep 2023 13:39:44 +0000 (UTC) Received: from us-smtp-inbound-delivery-1.mimecast.com (us-smtp-inbound-delivery-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 B3A5B3822EB4 for ; Mon, 25 Sep 2023 13:39:36 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-112-XPoPq2NkMmedlJbcKcW1nQ-1; Mon, 25 Sep 2023 09:39:32 -0400 Received: from pps.filterd (m0353727.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38PC8jqR005796; Mon, 25 Sep 2023 13:39:24 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3ta5rdde88-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 Sep 2023 13:39:24 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 38PDWnDZ008122; Mon, 25 Sep 2023 13:39:22 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3taaqy2p85-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 Sep 2023 13:39:22 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 38PDdJop28508762 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 25 Sep 2023 13:39:19 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F06142005A; Mon, 25 Sep 2023 13:39:18 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A6A5420040; Mon, 25 Sep 2023 13:39:18 +0000 (GMT) Received: from li-1de7cd4c-3205-11b2-a85c-d27f97db1fe1.ibm.com.com (unknown [9.171.42.216]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 25 Sep 2023 13:39:18 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695649195; 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=Aun/URs/nh7pSCUseegZjHv99ty+tFGSah7SqofMqFY=; b=bUYoG7z2ofZ/xf/hFkJ65fi5Oki8m/5kSQkHzswOGmaqordu1YT7sNqP7gQvQptXQnws1r TBhDmo7xvLHRE5X+x4yJ36jUFDt7L8Mh9in0KnToUVRpoJICUYmPMuPQXkTA2RTDjHuE3w qWe64m/JXIR+3hR0s70sERfX6HFVpzc= X-MC-Unique: T3fv66qWNZaPgw3W5rgB-Q-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: XPoPq2NkMmedlJbcKcW1nQ-1 From: Marc Hartmayer To: Subject: [RFC PATCH libvirt v1 1/3] virsh: add `console --resume` support Date: Mon, 25 Sep 2023 15:39:08 +0200 Message-ID: <20230925133910.77945-2-mhartmay@linux.ibm.com> In-Reply-To: <20230925133910.77945-1-mhartmay@linux.ibm.com> References: <20230925133910.77945-1-mhartmay@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: wiGOT1HLLPMMDq__CjEaZOD5UH0B7gpD X-Proofpoint-GUID: wiGOT1HLLPMMDq__CjEaZOD5UH0B7gpD 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-25_11,2023-09-25_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 mlxlogscore=655 phishscore=0 adultscore=0 clxscore=1011 impostorscore=0 malwarescore=0 priorityscore=1501 mlxscore=0 spamscore=0 suspectscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2309250102 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.4 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.8 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: 1695649197531100001 Content-Type: text/plain; charset="utf-8"; x-default="true" This patch adds the command line flag `--resume` to the `virsh console` command. This resumes a paused guest after connecting to the console. This might be handy since it's a "common" pattern to start a guest paused, connect to the console, and then resume it so as not to miss any console messages. Reviewed-by: Boris Fiuczynski Signed-off-by: Marc Hartmayer --- tools/virsh-console.c | 8 ++++++++ tools/virsh-console.h | 1 + tools/virsh-domain.c | 14 ++++++++++---- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/tools/virsh-console.c b/tools/virsh-console.c index 6bfb44a190ec..e44a070e7045 100644 --- a/tools/virsh-console.c +++ b/tools/virsh-console.c @@ -401,6 +401,7 @@ int virshRunConsole(vshControl *ctl, virDomainPtr dom, const char *dev_name, + const bool resume_domain, unsigned int flags) { virConsole *con =3D NULL; @@ -476,6 +477,13 @@ virshRunConsole(vshControl *ctl, goto cleanup; } =20 + if (resume_domain) { + if (virDomainResume(dom) !=3D 0) { + vshError(ctl, _("Failed to resume domain '%1$s'"), virDomainGe= tName(dom)); + goto cleanup; + } + } + while (!con->quit) { if (virCondWait(&con->cond, &con->parent.lock) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", diff --git a/tools/virsh-console.h b/tools/virsh-console.h index e89484d24bf4..2d00ed90cf4a 100644 --- a/tools/virsh-console.h +++ b/tools/virsh-console.h @@ -27,6 +27,7 @@ int virshRunConsole(vshControl *ctl, virDomainPtr dom, const char *dev_name, + const bool resume_domain, unsigned int flags); =20 #endif /* !WIN32 */ diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 7abafe2ba30c..5c3c6d18aebf 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -3012,6 +3012,10 @@ static const vshCmdOptDef opts_console[] =3D { .type =3D VSH_OT_BOOL, .help =3D N_("force console connection (disconnect already connected= sessions)") }, + {.name =3D "resume", + .type =3D VSH_OT_BOOL, + .help =3D N_("resume a paused guest after connecting to console") + }, {.name =3D "safe", .type =3D VSH_OT_BOOL, .help =3D N_("only connect if safe console handling is supported") @@ -3022,6 +3026,7 @@ static const vshCmdOptDef opts_console[] =3D { static bool cmdRunConsole(vshControl *ctl, virDomainPtr dom, const char *name, + const bool resume_domain, unsigned int flags) { int state; @@ -3048,7 +3053,7 @@ cmdRunConsole(vshControl *ctl, virDomainPtr dom, vshPrintExtra(ctl, " (Ctrl + %c)", priv->escapeChar[1]); vshPrintExtra(ctl, "\n"); fflush(stdout); - if (virshRunConsole(ctl, dom, name, flags) =3D=3D 0) + if (virshRunConsole(ctl, dom, name, resume_domain, flags) =3D=3D 0) return true; =20 return false; @@ -3059,6 +3064,7 @@ cmdConsole(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; bool force =3D vshCommandOptBool(cmd, "force"); + bool resume =3D vshCommandOptBool(cmd, "resume"); bool safe =3D vshCommandOptBool(cmd, "safe"); unsigned int flags =3D 0; const char *name =3D NULL; @@ -3074,7 +3080,7 @@ cmdConsole(vshControl *ctl, const vshCmd *cmd) if (safe) flags |=3D VIR_DOMAIN_CONSOLE_SAFE; =20 - return cmdRunConsole(ctl, dom, name, flags); + return cmdRunConsole(ctl, dom, name, resume, flags); } #endif /* WIN32 */ =20 @@ -4136,7 +4142,7 @@ cmdStart(vshControl *ctl, const vshCmd *cmd) vshPrintExtra(ctl, _("Domain '%1$s' started\n"), virDomainGetName(dom)); #ifndef WIN32 - if (console && !cmdRunConsole(ctl, dom, NULL, 0)) + if (console && !cmdRunConsole(ctl, dom, NULL, false, 0)) return false; #endif =20 @@ -8232,7 +8238,7 @@ cmdCreate(vshControl *ctl, const vshCmd *cmd) virDomainGetName(dom), from); #ifndef WIN32 if (console) - cmdRunConsole(ctl, dom, NULL, 0); + cmdRunConsole(ctl, dom, NULL, false, 0); #endif return true; } --=20 2.34.1 From nobody Mon May 13 15:48:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1695649236; cv=none; d=zohomail.com; s=zohoarc; b=eSpylBqQ/dYr0aPpi/Xxs6RiobWTsqSy1gI95vacR9dixrkedjx0STYa0kihUQvKvmqtAyV4cwOQAdY4aZxbsWmXhMNdeujrQ9QjMJd1fygUHQ3lXHhGHuZsTabjCwSQLWqj0uaDUlMXJq12m5wRGT2npsRbGZPSihSIEji33Dg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695649236; 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=A60CIVy2zs4lPBLol6PFzoN3+MIlxHObEq7I2rHgiRg=; b=LEIoBwwWzX6JMOseci2kxtLal0tjFJcpAG2r9i8kSYzqKRTHohJs0SbbRx19KMW8S3/b45cnrXeSjTbOf0/9mIka0X8f6Ulw6nN4PYo/qYGIYUUTfdymMXAuRzMlJgC5/GZ6RyNoshcLrcTXDHVvpyNtUeAKScPyxmJ+DsKyiI0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1695649236696608.3670723003552; Mon, 25 Sep 2023 06:40:36 -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-591-aYClOGQKMJu-16bsODYMow-1; Mon, 25 Sep 2023 09:40:32 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (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 55A4E811E8D; Mon, 25 Sep 2023 13:40:28 +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 3ED2551E3; Mon, 25 Sep 2023 13:40:28 +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 D47C3194658F; Mon, 25 Sep 2023 13:40:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 03902194658C for ; Mon, 25 Sep 2023 13:40:27 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D6D36711294; Mon, 25 Sep 2023 13:40:26 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CF3D0711291 for ; Mon, 25 Sep 2023 13:40:26 +0000 (UTC) Received: from us-smtp-inbound-delivery-1.mimecast.com (us-smtp-2.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 B2A5385A5BF for ; Mon, 25 Sep 2023 13:40:26 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-456-fGq8hNzuPUmh2RN200vsow-1; Mon, 25 Sep 2023 09:40:22 -0400 Received: from pps.filterd (m0353728.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38PDdsBB011386; Mon, 25 Sep 2023 13:40:21 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 3tb9a8upvd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 Sep 2023 13:40:20 +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 38PBjxDR010996; Mon, 25 Sep 2023 13:39:22 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3tabuk29cp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 Sep 2023 13:39:22 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 38PDdJvG21889694 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 25 Sep 2023 13:39:19 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5EA2B2004B; Mon, 25 Sep 2023 13:39:19 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 15CC120040; Mon, 25 Sep 2023 13:39:19 +0000 (GMT) Received: from li-1de7cd4c-3205-11b2-a85c-d27f97db1fe1.ibm.com.com (unknown [9.171.42.216]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 25 Sep 2023 13:39:18 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695649235; 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=A60CIVy2zs4lPBLol6PFzoN3+MIlxHObEq7I2rHgiRg=; b=HgCq8P4vAwOoAAiMWvnlBrnU+DolnjpJB5YB2CFg5hqq6qyplu1hO10y0Ydz0bKjbuKpfZ uWrLozXVpxMLfsKwQbZxwt9pIRHlPIq1B3Wt3xDPZkloQqvZJGTybmQP44fmIld017j0Lq yX1LpuDxDMhVUN2tzl93rFEVAwjedk4= X-MC-Unique: aYClOGQKMJu-16bsODYMow-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: fGq8hNzuPUmh2RN200vsow-1 From: Marc Hartmayer To: Subject: [RFC PATCH libvirt v1 2/3] Improve `virsh start --console` behavior Date: Mon, 25 Sep 2023 15:39:09 +0200 Message-ID: <20230925133910.77945-3-mhartmay@linux.ibm.com> In-Reply-To: <20230925133910.77945-1-mhartmay@linux.ibm.com> References: <20230925133910.77945-1-mhartmay@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: dkYgJ1LWWjuQKDO06pRFmg54lRttOxOm X-Proofpoint-GUID: dkYgJ1LWWjuQKDO06pRFmg54lRttOxOm 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-25_11,2023-09-25_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 suspectscore=0 mlxlogscore=376 clxscore=1015 priorityscore=1501 impostorscore=0 spamscore=0 adultscore=0 phishscore=0 malwarescore=0 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2309250102 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.9 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.5 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: 1695649237698100001 Content-Type: text/plain; charset="utf-8"; x-default="true" When starting a guest via libvirt (`virsh start --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 guest 2. attach the console 3. resume the guest Reviewed-by: Boris Fiuczynski Signed-off-by: Marc Hartmayer --- tools/virsh-domain.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 5c3c6d18aebf..3581161c6f53 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -4065,6 +4065,7 @@ cmdStart(vshControl *ctl, const vshCmd *cmd) g_autoptr(virshDomain) dom =3D NULL; #ifndef WIN32 bool console =3D vshCommandOptBool(cmd, "console"); + bool resume_domain =3D false; #endif unsigned int flags =3D VIR_DOMAIN_NONE; int rc; @@ -4083,8 +4084,14 @@ cmdStart(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, "bypass-cache")) @@ -4142,7 +4149,7 @@ cmdStart(vshControl *ctl, const vshCmd *cmd) vshPrintExtra(ctl, _("Domain '%1$s' started\n"), virDomainGetName(dom)); #ifndef WIN32 - if (console && !cmdRunConsole(ctl, dom, NULL, false, 0)) + if (console && !cmdRunConsole(ctl, dom, NULL, resume_domain, 0)) return false; #endif =20 --=20 2.34.1 From nobody Mon May 13 15:48:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1695649198; cv=none; d=zohomail.com; s=zohoarc; b=HAx9Toq2BFatzxgYuE1vN1/kwzSiYHkef1e16eyn6B8bymUb3/JNI0MoiaFvJfFSlQuPFA1giYEUZRskfUENPcD1lY3Jud8YVHGJaKH9pDpp4XNl85wEYYnF0x/3dcdE0JR20bCaEPU1cXMd6twJn38WqjkIW+QZPvjrRBrHdAo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695649198; 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=qiBpkneqi2ZlatrlGknO2r2sFlYAklS58eNT6qPhkZc=; b=Wk7q3O0sf5HsIDYq1e5MzUpTc3z32UH4aeG4u7VDkD5tU0a9SNefTRs1j0x0LqoOpq/L2jE/d2FmtsEExK22oqGeHKpt3KUiWsRk4xVg2R59cUeVY1FTcb1qaTMfrYdR5svgHABR27bTZayz5qqV8dYYs5AULmme62lw7Dzjd7Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 169564919869816.232404350834372; Mon, 25 Sep 2023 06:39:58 -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-607-cwCnyjPoNuaO0fTG80T_bA-1; Mon, 25 Sep 2023 09:39:52 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (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 9D2BA804BA4; Mon, 25 Sep 2023 13:39:40 +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 7C1C040C6E77; Mon, 25 Sep 2023 13:39:38 +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 EC7C3194658F; Mon, 25 Sep 2023 13:39:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BA380194658C for ; Mon, 25 Sep 2023 13:39:37 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 6E80640C6E77; Mon, 25 Sep 2023 13:39:37 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6710440C6EA8 for ; Mon, 25 Sep 2023 13:39:37 +0000 (UTC) Received: from us-smtp-inbound-delivery-1.mimecast.com (us-smtp-inbound-delivery-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 C2AB385C1A7 for ; Mon, 25 Sep 2023 13:39:33 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-292-6rFQMmRKP9Otknj_VdC0bQ-1; Mon, 25 Sep 2023 09:39:31 -0400 Received: from pps.filterd (m0353727.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38PDEWBG022006; Mon, 25 Sep 2023 13:39:27 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 3ta5rddea5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 Sep 2023 13:39:26 +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 38PC6gOc011032; Mon, 25 Sep 2023 13:39:25 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3tabuk29dy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 Sep 2023 13:39:25 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 38PDdJKE21889698 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 25 Sep 2023 13:39:19 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C106E2004B; Mon, 25 Sep 2023 13:39:19 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 77A7520040; Mon, 25 Sep 2023 13:39:19 +0000 (GMT) Received: from li-1de7cd4c-3205-11b2-a85c-d27f97db1fe1.ibm.com.com (unknown [9.171.42.216]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 25 Sep 2023 13:39:19 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695649197; 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=qiBpkneqi2ZlatrlGknO2r2sFlYAklS58eNT6qPhkZc=; b=I9R05OWv6y7x5+qxUMuMdTM1FWCfrtRwsSwaXH5Lb0/moPlaeci9JtCD6x/5HgB9HWLJYp 0IeZrqLbX9gaHdKO/+GXyBrGkbYMD5Ya1fPO+gyggsjZVimegmTqkkTA/kbvONSTQIW6f4 xPXAeQbF1ueFGEEzKbaHkzdxRL1S9+4= X-MC-Unique: cwCnyjPoNuaO0fTG80T_bA-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: 6rFQMmRKP9Otknj_VdC0bQ-1 From: Marc Hartmayer To: Subject: [RFC PATCH libvirt v1 3/3] Improve `virsh create --console` behavior Date: Mon, 25 Sep 2023 15:39:10 +0200 Message-ID: <20230925133910.77945-4-mhartmay@linux.ibm.com> In-Reply-To: <20230925133910.77945-1-mhartmay@linux.ibm.com> References: <20230925133910.77945-1-mhartmay@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: Cruw2LjMFc6k6hmB-p6LQAoqoMS3qNRq X-Proofpoint-GUID: Cruw2LjMFc6k6hmB-p6LQAoqoMS3qNRq 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-25_11,2023-09-25_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 mlxlogscore=429 phishscore=0 adultscore=0 clxscore=1015 impostorscore=0 malwarescore=0 priorityscore=1501 mlxscore=0 spamscore=0 suspectscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2309250102 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.2 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.2 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: 1695649200886100001 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 --- tools/virsh-domain.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 3581161c6f53..5a97d44190c4 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -8207,6 +8207,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; @@ -8222,8 +8223,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")) @@ -8245,7 +8252,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