From nobody Sat Apr 27 19:13:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=quarantine dis=quarantine) header.from=suse.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1634255617239704.5313358175438; Thu, 14 Oct 2021 16:53:37 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-311-xkMqoM-sO1i86DO0tNm36A-1; Thu, 14 Oct 2021 19:53:33 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 59F31104ECE6; Thu, 14 Oct 2021 23:53:28 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DB13D19724; Thu, 14 Oct 2021 23:53:25 +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 334F71800FDD; Thu, 14 Oct 2021 23:53:21 +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 19ENrJd5013256 for ; Thu, 14 Oct 2021 19:53:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5ABE0404727A; Thu, 14 Oct 2021 23:53:19 +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 55CE24047272 for ; Thu, 14 Oct 2021 23:53:19 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.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 38EEF1066680 for ; Thu, 14 Oct 2021 23:53:19 +0000 (UTC) Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [194.104.111.102]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-481-KDjZPeRcOoWvDmqH6MKILg-1; Thu, 14 Oct 2021 19:53:16 -0400 Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01lp2058.outbound.protection.outlook.com [104.47.1.58]) (Using TLS) by relay.mimecast.com with ESMTP id de-mta-2-_RVcrpo5MGmh5jxOXB6hmw-1; Fri, 15 Oct 2021 01:53:14 +0200 Received: from AM8PR04MB7970.eurprd04.prod.outlook.com (2603:10a6:20b:24f::9) by AM0PR04MB5956.eurprd04.prod.outlook.com (2603:10a6:208:114::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.18; Thu, 14 Oct 2021 23:53:12 +0000 Received: from AM8PR04MB7970.eurprd04.prod.outlook.com ([fe80::2ce6:80e:c776:afbf]) by AM8PR04MB7970.eurprd04.prod.outlook.com ([fe80::2ce6:80e:c776:afbf%7]) with mapi id 15.20.4608.016; Thu, 14 Oct 2021 23:53:12 +0000 Received: from localhost (75.169.9.141) by FR0P281CA0009.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:15::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.9 via Frontend Transport; Thu, 14 Oct 2021 23:53:11 +0000 X-MC-Unique: xkMqoM-sO1i86DO0tNm36A-1 X-MC-Unique: KDjZPeRcOoWvDmqH6MKILg-1 X-MC-Unique: _RVcrpo5MGmh5jxOXB6hmw-1 From: Jim Fehlig To: libvir-list@redhat.com Subject: [PATCH] qemu: Do not report eof when processing monitor IO Date: Thu, 14 Oct 2021 17:53:08 -0600 Message-ID: <20211014235308.8661-1-jfehlig@suse.com> X-ClientProxiedBy: FR0P281CA0009.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:15::14) To AM8PR04MB7970.eurprd04.prod.outlook.com (2603:10a6:20b:24f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bb3b0055-4483-4ae5-bf44-08d98f6dc832 X-MS-TrafficTypeDiagnostic: AM0PR04MB5956: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4502 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: w9J8mt5/heZl2W7nD/LKaAY3o1EVjSkpxU0fzYkGr1YF8oC623iIqTmQKo9kdweFKlzE7Bacczpw2Wq7ez1mMgYNLT2buT2J27VJq38Zh4laeFTDN/AJv8ekp4akfzHaDerHLjo9iofW1CoJ/pzq4QiNk/4Vh3g+/PFcK1LvqINYjFmbPdjMc3qoV1Doe+wzqy3tXgm1k6vJE5xtDKNFV1iGkdrqg3w0rLZmbFC+/TIxo5/4Vgv+dvP5nzD/WXhD/jHIplxSmRAhagLCNru6sTFz956r7f8vQpxQKmUUsXe+qGVZ2hFJKsVk+O8LXjOKXDLLhnazZcb8UcyEz8Ej4ertis7xKrQKXccWlIwHySj0lV7YR8BHIvOUlaOdZA8JiLXXnEGlMlYN2E58MDYA1Jh4P4zk8UkiM2eTF3jDHOwophL+NOVyFBweWoaQSG5WCki3aqhO2yKnAcXwwgOH4Ea61b6DJVCbgW8YrBu+BaF0eDac61UAoKZ1/vSeVlIiVTkIgd7/Xz6Cy308s5gyxCNX5SOH2wMG8q1+JJQabrYR4x8msnJPFe8TUGv6TwxGtbYWTai23cMMG6RtaziXU21lI0v/ALNKr6gNCBBdXVNYoFCpcjXO0DTaGOiTNLrgU5sGGIWOpF86QaTKevsb1iKnN8T7kYgQ1wikZlRB+PW2RmYnOzWkiMGo8PS7S4LcfSEFUQUKkgNFoIubvlY6+bYwCP2v6JHaiCAAvyHj+8tekR4FsV/szLjE1tD0wmaLKiejBVBqeafmfUjD+i4AEA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM8PR04MB7970.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(5660300002)(8676002)(83380400001)(8936002)(38100700002)(186003)(66946007)(26005)(66476007)(6496006)(6486002)(2616005)(956004)(6666004)(1076003)(36756003)(2906002)(966005)(316002)(86362001)(6916009)(66556008)(508600001); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Cn98lr66TOrbEWn0gK2izLJkRJv9LrvDBmfpFF1eLmIEqabiJOktGk5B1Fnp?= =?us-ascii?Q?LusHZWdP+Pnj6fgz/nqEEcgWr7bpKwixbWThPj/By3KVqN9ZQCZ+cC+uBzan?= =?us-ascii?Q?eQDNdxupr09mTQ69yBWRryWWZTNDSxnzM1RZcYZHjFrdLV7CFG4wGG54KOCY?= =?us-ascii?Q?kcouKUXaWNfLrc3G8yf+Y4j1YtR63fDoKG2IJZwxzmVtpf6swDQe7NxCqQEd?= =?us-ascii?Q?IPQw2Fo3fal0EACBRFyFliZQ23q1+8csW0UTCD8g97ms4yRMWE/FtEG6Gy5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DcDCeOfnKr8CUjXH6e9X6oj2zlSdSz1qTEKR?= =?us-ascii?Q?YaWlhy3PJEdlLJR2arrxtw8unmwLam/JHwhQygfMOLtliUlxxN/saIk1936C?= =?us-ascii?Q?k6rs2yo0NQDxo+J0p1MvYDFvfjVlYijmD61NhOe9kYsBbQFNT1qWw36h4tnw?= =?us-ascii?Q?VrNT384JRpk30X063eqPOGEc?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: bb3b0055-4483-4ae5-bf44-08d98f6dc832 X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7970.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2021 23:53:12.5320 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: nRH42HyW0A9niPbMFfl+eh748UKrj61sbVnpxMxEaAkeJIoF0QQikMLsz440aiIgOK7U/sGDfHfnFCSC2UeOhg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5956 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-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 19ENrJd5013256 X-loop: libvir-list@redhat.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.84 on 10.5.11.23 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: 1634255619519100001 Content-Type: text/plain; charset="utf-8" There have been countless reports from users concerned about the following error reported by libvirtd when qemu domains are shutdown internal error: End of file from qemu monitor While the error is harmless, users often mistaken it for real problem with their deployments. EOF from the monitor can't be entirely ignored since other threads may be using the monitor and must be able to detect the EOF condition. One potential fix is to delay reporting EOF until the monitor is used after EOF is detected. This patch adds a 'goteof' member to the qemuMonitor structure, which is set when EOF is detected on the monitor socket. If another thread later tries to send data on the monitor, the EOF error is reported. Signed-off-by: Jim Fehlig Reviewed-by: Michal Privoznik --- First non-RFC version of the patch. RFC version can be found here https://listman.redhat.com/archives/libvir-list/2021-October/msg00484.html Tests mentioned in the below post are running on this version of the patch and have completed 12 iterations thus far https://listman.redhat.com/archives/libvir-list/2021-October/msg00351.html src/qemu/qemu_monitor.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 7ff6a1161f..434cc26c10 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -113,6 +113,7 @@ struct _qemuMonitor { =20 /* true if qemu no longer wants 'props' sub-object of object-add */ bool objectAddNoWrap; + bool goteof; }; =20 /** @@ -526,7 +527,6 @@ qemuMonitorIO(GSocket *socket G_GNUC_UNUSED, { qemuMonitor *mon =3D opaque; bool error =3D false; - bool eof =3D false; bool hangup =3D false; =20 virObjectRef(mon); @@ -544,7 +544,7 @@ qemuMonitorIO(GSocket *socket G_GNUC_UNUSED, =20 if (mon->lastError.code !=3D VIR_ERR_OK) { if (cond & (G_IO_HUP | G_IO_ERR)) - eof =3D true; + mon->goteof =3D true; error =3D true; } else { if (cond & G_IO_OUT) { @@ -562,7 +562,7 @@ qemuMonitorIO(GSocket *socket G_GNUC_UNUSED, if (errno =3D=3D ECONNRESET) hangup =3D true; } else if (got =3D=3D 0) { - eof =3D true; + mon->goteof =3D true; } else { /* Ignore hangup/error cond if we read some data, to * give time for that data to be consumed */ @@ -575,22 +575,19 @@ qemuMonitorIO(GSocket *socket G_GNUC_UNUSED, =20 if (cond & G_IO_HUP) { hangup =3D true; - if (!error) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("End of file from qemu monitor")); - eof =3D true; - } + if (!error) + mon->goteof =3D true; } =20 - if (!error && !eof && + if (!error && !mon->goteof && cond & G_IO_ERR) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid file descriptor while waiting for mo= nitor")); - eof =3D true; + mon->goteof =3D true; } } =20 - if (error || eof) { + if (error || mon->goteof) { if (hangup && mon->logFunc !=3D NULL) { /* Check if an error message from qemu is available and if so,= use * it to overwrite the actual message. It's done only in early @@ -609,7 +606,7 @@ qemuMonitorIO(GSocket *socket G_GNUC_UNUSED, /* Already have an error, so clear any new error */ virResetLastError(); } else { - if (virGetLastErrorCode() =3D=3D VIR_ERR_OK) + if (virGetLastErrorCode() =3D=3D VIR_ERR_OK && !mon->goteof) virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Error while processing monitor IO")); virCopyLastError(&mon->lastError); @@ -630,7 +627,7 @@ qemuMonitorIO(GSocket *socket G_GNUC_UNUSED, /* We have to unlock to avoid deadlock against command thread, * but is this safe ? I think it is, because the callback * will try to acquire the virDomainObj *mutex next */ - if (eof) { + if (mon->goteof) { qemuMonitorEofNotifyCallback eofNotify =3D mon->cb->eofNotify; virDomainObj *vm =3D mon->vm; =20 @@ -949,6 +946,11 @@ qemuMonitorSend(qemuMonitor *mon, virSetError(&mon->lastError); return -1; } + if (mon->goteof) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("End of file from qemu monitor")); + return -1; + } =20 mon->msg =3D msg; qemuMonitorUpdateWatch(mon); --=20 2.33.0