From nobody Sat Feb 7 15:15:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=linux.ibm.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1531306240328898.8362052600446; Wed, 11 Jul 2018 03:50:40 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 90B4630820CB; Wed, 11 Jul 2018 10:50:38 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 48B94308BDAC; Wed, 11 Jul 2018 10:50:38 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id D5EBA264FC; Wed, 11 Jul 2018 10:50:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6BAoZ4U017899 for ; Wed, 11 Jul 2018 06:50:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6232910694D2; Wed, 11 Jul 2018 10:50:35 +0000 (UTC) Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 55A4910694E8 for ; Wed, 11 Jul 2018 10:50:19 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8C21281DF4 for ; Wed, 11 Jul 2018 10:50:18 +0000 (UTC) Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w6BAoDYZ001332 for ; Wed, 11 Jul 2018 06:50:18 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2k5db9fvta-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 11 Jul 2018 06:50:17 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 11 Jul 2018 11:49:43 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 11 Jul 2018 11:49:42 +0100 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w6BAnfhM42139660 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 11 Jul 2018 10:49:41 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F03F911C04C; Wed, 11 Jul 2018 13:50:02 +0100 (BST) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CFD0E11C050; Wed, 11 Jul 2018 13:50:02 +0100 (BST) Received: from s38lp19.boeblingen.de.ibm.com (unknown [9.152.161.19]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 11 Jul 2018 13:50:02 +0100 (BST) From: Bjoern Walk To: libvir-list@redhat.com Date: Wed, 11 Jul 2018 12:49:20 +0200 In-Reply-To: <20180711104922.26783-1-bwalk@linux.ibm.com> References: <20180711104922.26783-1-bwalk@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18071110-0028-0000-0000-000002DA6E8B X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18071110-0029-0000-0000-000023921474 Message-Id: <20180711104922.26783-8-bwalk@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-07-11_02:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807110116 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 11 Jul 2018 10:50:18 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 11 Jul 2018 10:50:18 +0000 (UTC) for IP:'148.163.156.1' DOMAIN:'mx0a-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'bwalk@linux.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.701 (RCVD_IN_DNSWL_LOW, SPF_PASS) 148.163.156.1 mx0a-001b2d01.pphosted.com 148.163.156.1 mx0a-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.83 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Bjoern Walk Subject: [libvirt] [PATCH 7/9] virsh: domstate: report detailed state if available X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Wed, 11 Jul 2018 10:50:39 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add a new parameter to virsh domstate, --info, to additionally report additional information for the domain state: virsh # domstate --info guest-1 crashed (panicked: disabled-wait core=3D'1' psw-mask=3D'0x000000000010f= 146' \ psw-addr=3D'0x0002000180000000') When the new API virDomainGetStateParams is not available for the server or not supported by the hypervisor driver, fall back to the old API using virDomainGetState function. The --info parameter implies the --reason parameter and if additional information is not available, the output is the same. Reviewed-by: Boris Fiuczynski Reviewed-by: Stefan Zimmermann Signed-off-by: Bjoern Walk --- tools/virsh-domain-monitor.c | 31 ++++++++++++++++++++++++++----- tools/virsh.pod | 5 +++-- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 87660ee6..ed732126 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -1372,6 +1372,10 @@ static const vshCmdOptDef opts_domstate[] =3D { .type =3D VSH_OT_BOOL, .help =3D N_("also print reason for the state") }, + {.name =3D "info", + .type =3D VSH_OT_BOOL, + .help =3D N_("also print reason and information for the state") + }, {.name =3D NULL} }; =20 @@ -1381,26 +1385,43 @@ cmdDomstate(vshControl *ctl, const vshCmd *cmd) virDomainPtr dom; bool ret =3D true; bool showReason =3D vshCommandOptBool(cmd, "reason"); + bool showInfo =3D vshCommandOptBool(cmd, "info"); + virTypedParameterPtr params =3D NULL; + int nparams =3D 0; int state, reason; + const char *info =3D NULL; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 - if ((state =3D virshDomainState(ctl, dom, &reason)) < 0) { - ret =3D false; - goto cleanup; + if (virDomainGetStateParams(dom, ¶ms, &nparams, 0) < 0 || + virTypedParamsGetInt(params, nparams, VIR_DOMAIN_STATE_PARAMS_STAT= E, + &state) < 0 || + virTypedParamsGetInt(params, nparams, VIR_DOMAIN_STATE_PARAMS_REAS= ON, + &reason) < 0 || + virTypedParamsGetString(params, nparams, VIR_DOMAIN_STATE_PARAMS_I= NFO, + &info) < 0) { + if ((state =3D virshDomainState(ctl, dom, &reason)) < 0) { + ret =3D false; + goto cleanup; + } } =20 - if (showReason) { - vshPrint(ctl, "%s (%s)\n", + if (showInfo || showReason) { + vshPrint(ctl, "%s (%s", virshDomainStateToString(state), virshDomainStateReasonToString(state, reason)); + if (showInfo && info && strlen(info) > 0) + vshPrint(ctl, ": %s)\n", info); + else + vshPrint(ctl, ")\n"); } else { vshPrint(ctl, "%s\n", virshDomainStateToString(state)); } =20 cleanup: + virTypedParamsFree(params, nparams); virshDomainFree(dom); return ret; } diff --git a/tools/virsh.pod b/tools/virsh.pod index 4c6e21fc..b30b0b79 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -1519,10 +1519,11 @@ specified in the second argument. =20 B: Domain must be inactive and without snapshots. =20 -=3Ditem B I [I<--reason>] +=3Ditem B I [I<--reason>] [I<--info>] =20 Returns state about a domain. I<--reason> tells virsh to also print -reason for the state. +reason for the state. I<--info> prints additional state information if +available, I<--info> implies I<--reason>. =20 =3Ditem B I =20 --=20 2.17.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list