From nobody Thu May 2 21:27:45 2024 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; 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=none dis=none) header.from=nutanix.com 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 1640241722812429.75290955815797; Wed, 22 Dec 2021 22:42:02 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-639-MDhJRxM3OOunHIJO_lttNA-1; Thu, 23 Dec 2021 01:41:15 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 414891006AA0; Thu, 23 Dec 2021 06:41:10 +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 371276060F; Thu, 23 Dec 2021 06:41:09 +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 EEE444BB7C; Thu, 23 Dec 2021 06:41:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1BN6e2BV028429 for ; Thu, 23 Dec 2021 01:40:03 -0500 Received: by smtp.corp.redhat.com (Postfix) id D9B96403579B; Thu, 23 Dec 2021 06:40:02 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D46804035788 for ; Thu, 23 Dec 2021 06:40:02 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (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 B6780101A52D for ; Thu, 23 Dec 2021 06:40:02 +0000 (UTC) Received: from mx0b-002c1b01.pphosted.com (mx0b-002c1b01.pphosted.com [148.163.155.12]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-596-zzZJa02FPHOFiqIyURilQQ-1; Thu, 23 Dec 2021 01:40:00 -0500 Received: from pps.filterd (m0127841.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1BN0ih5J025158 for ; Wed, 22 Dec 2021 22:40:00 -0800 Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2044.outbound.protection.outlook.com [104.47.66.44]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 3d3mksbaqg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 22 Dec 2021 22:40:00 -0800 Received: from SJ0PR02MB8564.namprd02.prod.outlook.com (2603:10b6:a03:3f6::16) by BYAPR02MB4759.namprd02.prod.outlook.com (2603:10b6:a03:42::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.18; Thu, 23 Dec 2021 06:39:58 +0000 Received: from SJ0PR02MB8564.namprd02.prod.outlook.com ([fe80::5916:1188:53ed:2065]) by SJ0PR02MB8564.namprd02.prod.outlook.com ([fe80::5916:1188:53ed:2065%2]) with mapi id 15.20.4823.019; Thu, 23 Dec 2021 06:39:58 +0000 X-MC-Unique: MDhJRxM3OOunHIJO_lttNA-1 X-MC-Unique: zzZJa02FPHOFiqIyURilQQ-1 From: Rohit Kumar To: libvir-list@redhat.com Subject: [PATCH v2] Add VM info to improve error log message for qemu monitor Date: Wed, 22 Dec 2021 22:39:21 -0800 Message-Id: <20211223063921.550303-1-rohit.kumar3@nutanix.com> X-ClientProxiedBy: SJ0PR05CA0045.namprd05.prod.outlook.com (2603:10b6:a03:33f::20) To SJ0PR02MB8564.namprd02.prod.outlook.com (2603:10b6:a03:3f6::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 213652e6-3ab4-4846-90f1-08d9c5df0989 X-MS-TrafficTypeDiagnostic: BYAPR02MB4759:EE_ X-Microsoft-Antispam-PRVS: x-proofpoint-crosstenant: true X-MS-Oob-TLC-OOBClassifiers: OLM:901 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: 6ZtOa/IrWoZX2S2w48ECJDGf4U1w62snqOSSStf9GS4jY42uJBiZLA5pftfp9DhwDv+yM8pQKps2o2uCvAJOhAK9+qOtrG7zUz0YhTR5HzLN4WRw2K3uc+5AjyVCPx0a9OwpngrAisp6ofoa4SSaX8sfB9262zPUbwVMPvdXquHP/HYTLQOe/omhjttqrhSd7rrO5NqVAhr529Oa7IluhtwlsEUdW0vAeFsWsQBSWd2Yq/WFDC9kmcdua8b3n6vuC6mLCjsRxsBgnuJfuTs+LcRHvALjf4osuSG0P9IqqskoLajHF20MEEs4hmKTmpOry1Z9VflhjhfCD0X3uaZNbhK+oU5HtKXew1UGKw+6NNu4kPxzKIKR8Ltgvyg/VWIl7dvIu/jFbxNi3oW9C6c+IL3F8VPyBtf/Arj6R++KfdVB9Vx4T9emEnJrD7sh7QdqXWmc/xdAbucUmVb9uNngTqP/xo+/H2IKnJuLYl7pGWlKpP3sy0LDulVuP91+7cY0DovrqOS9T5x9TfRkIrBC+ccEMJxZC3E0cPfbKI9CCktn6Ts+Z5c5o43q+z8oZ9w3PHf9LZ4lPVxj0hyNyuVwjlCxj5Q+7t+/A2kAFN8bgcwjrwIai31/G1jKSVsJAnnGGDVWMVfxXNQE92PYaoh9gY/DRWqSReaH5gTMn3EfFgmLa6nsW667dWSQ9j2mECp8YFO+rcHgdEl0uGvMFVfBq2WRYX0fvLB2GclsUpkn+yqpgS3wzsvn+34ZTOcEsvzOmM19oCVsRNDwlffP1DaO0BhN0pd0VdCJVVq0Xnvv6Gw= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR02MB8564.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(38100700002)(15650500001)(38350700002)(316002)(4326008)(107886003)(6506007)(86362001)(966005)(8936002)(2906002)(508600001)(36756003)(5660300002)(83380400001)(6512007)(186003)(8676002)(1076003)(26005)(66946007)(6916009)(52116002)(66476007)(6486002)(2616005)(6666004)(66556008); DIR:OUT; SFP:1102 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?ZWgNmr3Pn597MG9ybkU/7ZqG9A5OhIv5Kd0FOxCJo63m6Qq1W6PYWvwi/Sur?= =?us-ascii?Q?FNIm48uTG3cRQ9Nrv7oiSOHObTRyKyllM8uPq/x4rg5RfA7ZttPLhYg600Kk?= =?us-ascii?Q?pxSZSs0BcRHC06NSeOX/iwhIqlbus8R54nfhZbv2tPwwecyamU64wk248KAX?= =?us-ascii?Q?+4m2F5bQzlAjijNZGHMyzl1tiGI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ascii?Q?o6k53G8iz22abvnXwuYpG+m8UVdJinffxTrgPd2GeLvMlWwo7qHSBbQ43Mor?= =?us-ascii?Q?R/gfMTv8wYvR5/++GoLigf8oV2MTRKmnT0CDHqdjn2ZXa9qvHFQiMYbcKWZT?= =?us-ascii?Q?sEYASqsV6X7W9HsMgBqlf+daYhvkDf8xG8t83TcsXhfd+43sQLDpa8UOZizy?= =?us-ascii?Q?KJebWWyx2YZVSe/7zbLmfnBn5hdAr5/XpFYLDz0ycSVY1MSceBj/v5ihX9/Q?= =?us-ascii?Q?0R0N4lKUfjVtylglu0GTNhHjzrp5tlgwtMv+h/7jhuhgDQlhi7JYq8f0B+QE?= =?us-ascii?Q?dEXnV9SIEv9ySfwUxzQds5UwlSVtIhLeW4T1OAFFNE8+7x22fG/tR7QPvFXJ?= =?us-ascii?Q?S5PakI7KOtF858gUBof0tjKmhV6h6DQgVZ1XJ51scOfU8FERomX4epRh78Uo?= =?us-ascii?Q?n6nN2E4MtZonZg61UpVHgaIXlyt95iYFUrnofxY6klpllmNUBnEyUJedEvwo?= =?us-ascii?Q?1HJOMOqaZkopDsb4S/wZwW5X/js3aBMoFSNKs0zz3wSVJsS63mLBe/75fbqD?= =?us-ascii?Q?HNGluzWUa/lL9/rFIPoxKyplPah0OjZCu9eQ5YMKi2Swsro4xyjGY/AgG7AW?= =?us-ascii?Q?5ARfSO1sJqzH46ik3bGJESiqi1Y=3D?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 213652e6-3ab4-4846-90f1-08d9c5df0989 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR02MB8564.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Dec 2021 06:39:57.9275 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: p+SjnLGVNH4l9xr7Nd2bt+IUUGAIHDRVvHoKUmUeChezGXm1vDEbZGuFIk+pJP3Y/zqbf14imRi9hnLSpPOR9gCP7lNAfqRMTrkqAIbe30o= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR02MB4759 X-Proofpoint-GUID: 19DTaEHpfcueVKbQzBt6BBuk9rS9mtVn X-Proofpoint-ORIG-GUID: 19DTaEHpfcueVKbQzBt6BBuk9rS9mtVn X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205, Aquarius:18.0.790, Hydra:6.0.425, FMLib:17.11.62.513 definitions=2021-12-23_01,2021-12-22_01,2021-12-02_01 X-Proofpoint-Spam-Reason: safe 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 2.84 on 10.11.54.2 X-loop: libvir-list@redhat.com Cc: prachatos.mitra@nutanix.com, Rohit Kumar , prerna.saxena@nutanix.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1640241723964100001 Content-Type: text/plain; charset="utf-8" This patch is to determine the VM which had IO or socket hangup error. Accessing directly vm->def->name inside qemuMonitorIO() or qemuMonitorSend() might leads to illegal access as we are out of 'vm' context and vm->def mig= ht not exist. Adding a field "domainName" inside mon object to access vm name and initialising it when creating mon object. Signed-off-by: Rohit Kumar --- diff to v1: - Adding a field domainName inside _qemuMonitor struct for accessing vm n= ame instead of directly accessing mon->vm->def->name. - Link to v1: https://listman.redhat.com/archives/libvir-list/2021-Decemb= er/msg00217.html - Talked with peter on RFC and he suggested me to add a field inside=20 monitor struct to get VM name. =20 src/qemu/qemu_monitor.c | 47 +++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index dda6ae9796..c3a0227795 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -80,6 +80,7 @@ struct _qemuMonitor { GSource *watch; =20 virDomainObj *vm; + char *domainName; =20 qemuMonitorCallbacks *cb; void *callbackOpaque; @@ -243,6 +244,7 @@ qemuMonitorDispose(void *obj) virCondDestroy(&mon->notify); g_free(mon->buffer); g_free(mon->balloonpath); + g_free(mon->domainName); } =20 =20 @@ -530,13 +532,18 @@ qemuMonitorIO(GSocket *socket G_GNUC_UNUSED, qemuMonitor *mon =3D opaque; bool error =3D false; bool hangup =3D false; + virDomainObj *vm =3D NULL; + char *vmName =3D NULL; =20 virObjectRef(mon); =20 + vm =3D mon->vm; + vmName =3D mon->domainName; + /* lock access to the monitor and protect fd */ virObjectLock(mon); #if DEBUG_IO - VIR_DEBUG("Monitor %p I/O on socket %p cond %d", mon, socket, cond); + VIR_DEBUG("Monitor %p I/O on socket %p cond %d vm=3D%p name=3D%s", mon= , socket, cond, vm, NULLSTR(vmName)); #endif if (mon->fd =3D=3D -1 || !mon->watch) { virObjectUnlock(mon); @@ -583,8 +590,8 @@ qemuMonitorIO(GSocket *socket G_GNUC_UNUSED, =20 if (!error && !mon->goteof && cond & G_IO_ERR) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Invalid file descriptor while waiting for mo= nitor")); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("%s: Invalid file descriptor while waiting fo= r monitor"), NULLSTR(vmName)); mon->goteof =3D true; } } @@ -609,13 +616,14 @@ qemuMonitorIO(GSocket *socket G_GNUC_UNUSED, virResetLastError(); } else { if (virGetLastErrorCode() =3D=3D VIR_ERR_OK && !mon->goteof) - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Error while processing monitor IO")); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("%s: Error while processing monitor IO"),= NULLSTR(vmName)); virCopyLastError(&mon->lastError); virResetLastError(); } =20 - VIR_DEBUG("Error on monitor %s", NULLSTR(mon->lastError.message)); + VIR_DEBUG("Error on monitor %s mon=3D%p vm=3D%p name=3D%s", + NULLSTR(mon->lastError.message), mon, vm, NULLSTR(vmName= )); /* If IO process resulted in an error & we have a message, * then wakeup that waiter */ if (mon->msg && !mon->msg->finished) { @@ -631,22 +639,22 @@ qemuMonitorIO(GSocket *socket G_GNUC_UNUSED, * will try to acquire the virDomainObj *mutex next */ if (mon->goteof) { qemuMonitorEofNotifyCallback eofNotify =3D mon->cb->eofNotify; - virDomainObj *vm =3D mon->vm; =20 /* Make sure anyone waiting wakes up now */ virCondSignal(&mon->notify); virObjectUnlock(mon); - VIR_DEBUG("Triggering EOF callback"); + VIR_DEBUG("Triggering EOF callback mon=3D%p vm=3D%p name=3D%s", + mon, vm, NULLSTR(vmName)); (eofNotify)(mon, vm, mon->callbackOpaque); virObjectUnref(mon); } else if (error) { qemuMonitorErrorNotifyCallback errorNotify =3D mon->cb->errorNotif= y; - virDomainObj *vm =3D mon->vm; =20 /* Make sure anyone waiting wakes up now */ virCondSignal(&mon->notify); virObjectUnlock(mon); - VIR_DEBUG("Triggering error callback"); + VIR_DEBUG("Triggering error callback mon=3D%p vm=3D%p name=3D%s", + mon, vm, NULLSTR(vmName)); (errorNotify)(mon, vm, mon->callbackOpaque); virObjectUnref(mon); } else { @@ -694,6 +702,7 @@ qemuMonitorOpenInternal(virDomainObj *vm, mon->fd =3D fd; mon->context =3D g_main_context_ref(context); mon->vm =3D virObjectRef(vm); + mon->domainName =3D g_strdup(vm->def->name); mon->waitGreeting =3D true; mon->cb =3D cb; mon->callbackOpaque =3D opaque; @@ -932,17 +941,19 @@ qemuMonitorSend(qemuMonitor *mon, qemuMonitorMessage *msg) { int ret =3D -1; + virDomainObj *vm =3D mon->vm; + char *vmName =3D mon->domainName; =20 /* Check whether qemu quit unexpectedly */ if (mon->lastError.code !=3D VIR_ERR_OK) { - VIR_DEBUG("Attempt to send command while error is set %s", - NULLSTR(mon->lastError.message)); + VIR_DEBUG("Attempt to send command while error is set %s mon=3D%p = vm=3D%p name=3D%s", + NULLSTR(mon->lastError.message), mon, vm, NULLSTR(vmName= )); virSetError(&mon->lastError); return -1; } if (mon->goteof) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("End of file from qemu monitor")); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("%s: End of file from qemu monitor"), NULLSTR(vmN= ame)); return -1; } =20 @@ -955,15 +966,15 @@ qemuMonitorSend(qemuMonitor *mon, =20 while (!mon->msg->finished) { if (virCondWait(&mon->notify, &mon->parent.lock) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to wait on monitor condition")); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("%s: Unable to wait on monitor condition"), N= ULLSTR(vmName)); goto cleanup; } } =20 if (mon->lastError.code !=3D VIR_ERR_OK) { - VIR_DEBUG("Send command resulted in error %s", - NULLSTR(mon->lastError.message)); + VIR_DEBUG("Send command resulted in error %s mon=3D%p vm=3D%p name= =3D%s", + NULLSTR(mon->lastError.message), mon, vm, NULLSTR(vmName= )); virSetError(&mon->lastError); goto cleanup; } --=20 2.25.1