From nobody Fri May 3 19:07:47 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 1629733284536534.3368621222584; Mon, 23 Aug 2021 08:41:24 -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-328-ZUp-5FEzOcGswmVwp6XUDg-1; Mon, 23 Aug 2021 11:41:21 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B631F804169; Mon, 23 Aug 2021 15:41:14 +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 6C05D1017CE7; Mon, 23 Aug 2021 15:41:14 +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 80F884BB7B; Mon, 23 Aug 2021 15:41:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17NFfBVH025717 for ; Mon, 23 Aug 2021 11:41:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7AE48215673B; Mon, 23 Aug 2021 15:41:11 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6F6EE200AD03 for ; Mon, 23 Aug 2021 15:41:04 +0000 (UTC) Received: from us-smtp-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 13419800159 for ; Mon, 23 Aug 2021 15:41:04 +0000 (UTC) Received: from mx0b-002c1b01.pphosted.com (mx0b-002c1b01.pphosted.com [148.163.155.12]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-552-qX_HNJdtNi2kT9tMxO5mpA-1; Mon, 23 Aug 2021 11:41:02 -0400 Received: from pps.filterd (m0127844.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.16.1.2/8.16.0.43) with SMTP id 17NEgRGY000717 for ; Mon, 23 Aug 2021 08:41:01 -0700 Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam08lp2173.outbound.protection.outlook.com [104.47.73.173]) by mx0b-002c1b01.pphosted.com with ESMTP id 3ambwg917s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 23 Aug 2021 08:41:01 -0700 Received: from BN8PR02MB6433.namprd02.prod.outlook.com (2603:10b6:408:ad::10) by BN8PR02MB5892.namprd02.prod.outlook.com (2603:10b6:408:ba::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.22; Mon, 23 Aug 2021 15:40:59 +0000 Received: from BN8PR02MB6433.namprd02.prod.outlook.com ([fe80::bdb2:16e:e432:a7b0]) by BN8PR02MB6433.namprd02.prod.outlook.com ([fe80::bdb2:16e:e432:a7b0%5]) with mapi id 15.20.4436.024; Mon, 23 Aug 2021 15:40:59 +0000 Received: from simon-rowe.ubvm.nutanix.com (192.146.154.247) by BY5PR16CA0018.namprd16.prod.outlook.com (2603:10b6:a03:1a0::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Mon, 23 Aug 2021 15:40:58 +0000 X-MC-Unique: ZUp-5FEzOcGswmVwp6XUDg-1 X-MC-Unique: qX_HNJdtNi2kT9tMxO5mpA-1 From: Simon Rowe To: libvir-list@redhat.com Subject: [PATCHv2 1/2] iohelper: skip lseek() and ftruncate() on block devices Date: Mon, 23 Aug 2021 15:40:47 +0000 Message-Id: <20210823154048.94655-2-simon.rowe@nutanix.com> In-Reply-To: <20210823154048.94655-1-simon.rowe@nutanix.com> References: <20210823154048.94655-1-simon.rowe@nutanix.com> X-ClientProxiedBy: BY5PR16CA0018.namprd16.prod.outlook.com (2603:10b6:a03:1a0::31) To BN8PR02MB6433.namprd02.prod.outlook.com (2603:10b6:408:ad::10) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 35b3dd49-e698-4ac8-6853-08d9664c6793 X-MS-TrafficTypeDiagnostic: BN8PR02MB5892: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: x-proofpoint-crosstenant: true X-MS-Oob-TLC-OOBClassifiers: OLM:655 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: bkiRYk6CKtReuTk8wvbwtnGeCeRzQr0WZmfugoNrYoYz6JiL4qGNocoqCJFSAPgJ/pruZC/NNIGUkj9goTkjIIx3KXH3sKMTR0iqLkzeVes2RljK7OHfRF16fvv8dNNjbC1ez41N4R3GNBAcbB5RLLLQUI3MBgFh9rFIz2hdi3fUY56u5ubdi9Gz9CsimkVvbLsc2iblA1cAUSUDQnGCa4/92Vgi5v1OR71y/Dnlhck/Ao//AqJh8LvnLvEokvadIVkW3PrWt/tW49fVgGaAXiZVp5/uXRoR0ylaKQPS/sfaB2/Cf1g8yI210kWTTYlxCPbICllFFLCNAHDpgqzNYkxphQq+x035itiYmSRBKCBdbB6sOB0tnanM5BjMUAykdOAok4diVUkY6XfDFiVEmpWsTHut0Swc2cPsssgqhgf7lB8ZMFQpx4AqcnikNS5k/ASTjSbGoy28DkVeTv2Dtt707fAeDJqsK/pnwUZlHG93uJKi7+cvK2VKNVaCcIIGDQQM24IK/ExRTrWeu1lBGcHRlYX2AGGl0X7N30AWQ3awFV3yhOjax98N4yUX9KGtx1Wocsq979ih2jQWvFIFMH4Qh5plig1whQIaF+VgX15oud2f31BXNAGJx5UrGK/KfKyq6YKEmO/QiyHIboBkhXkceZILJIMwvYmqDAqeUioTYwRrW5W+cga4YSLiPvX2B5H1St0P80UWDqMpKKigPg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN8PR02MB6433.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(396003)(136003)(366004)(39860400002)(346002)(376002)(6486002)(38350700002)(478600001)(6666004)(2906002)(83380400001)(26005)(38100700002)(186003)(36756003)(6916009)(4326008)(1076003)(316002)(86362001)(66476007)(66556008)(66946007)(7696005)(2616005)(107886003)(44832011)(8936002)(8676002)(5660300002)(956004)(52116002); DIR:OUT; SFP:1102 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?D4XcKI75D8kM7BazAHg/BlEIQPg0vEoKefOaVLmLoAx6ENowvwG4LH8q2h0o?= =?us-ascii?Q?u30kU7nuTLG8//8UjxZopcLysqXd+gnveKRenpxwGxGAb2V9ZgDGkhwDJdnX?= =?us-ascii?Q?StKtS7aCWv+zIycp4PhIOw+YbsHgVDU8LmfSQYjKRjJy+9OGudV2npi4uXSO?= =?us-ascii?Q?bIx0bMR4ASStVVMX+N2jTJppOdITa/qKY00OUhiQRjiZl0nEOU6IDoGk2Uix?= =?us-ascii?Q?yELN38yUt0tQyJXqfFfbVols2t62iUt2lXNG39GHt9E1Y2kHBSrie265W5gI?= =?us-ascii?Q?CmCpPyPim0uK1owBsiSbzZAg76Nlxqr5gx/cgYW+/3VlYtbSXeZ92DZbBx9z?= =?us-ascii?Q?Auq+oBZan7H9lGN2IlxGqB3GGWK842SBUzWlxPFkp75TGeePUf6pTO0JSZy1?= =?us-ascii?Q?RgEFuOiKfymf3xQRd5du18MuYKSKcwb7wgssJnem1Ffd7gdOFRtaMSyJ3zSi?= =?us-ascii?Q?MvFYK2ZErCGReMbOJbhgc37lAJnh+/dOIbPPsgnILA9fq8hycnvgKLNNRifE?= =?us-ascii?Q?mzYSOYQOuRQdfdT4+7HHfsjMj26dv9gi4wQ3JJVuaPM5I1gB+sVOmhVgumxr?= =?us-ascii?Q?jzzLdb4ZJ36bljcSXV6xjdUuSfJJxafQjc+36008haacsWykiio60lldY1D0?= =?us-ascii?Q?eGAk5T2sdqjKzRHCfEuQW0S+t63Wz2XUzBlnCIRmVJIxt4HgE2SyrLhc2RVd?= =?us-ascii?Q?c2O86D/BxNdzjiGv5Kk+3hDf3PE0TDUlojgx2NkH25ed8DdmpE6NgA0hiXU3?= =?us-ascii?Q?cJUABaWciUqiuwDctmKoXnTgJBZ9G1arA8fnOsUbRFnVMvQvYH27Pnvv7Hhh?= =?us-ascii?Q?tOZINIZL+zzhKCpwdub9c5gpkoSMo/6SriuVWRPys5Z/b3UNRNYB+w+mx0eM?= =?us-ascii?Q?D8RyFUqDNTmiUd3+7s85ekjo/lbyjl1J5pmPlD+YhReTLgId/rKN6xOg95N0?= =?us-ascii?Q?QEb4vhd3wImZHkkfPQGjXzEHPixtQzNN4C2b5pXR0iYgcX92chZKrkVyAdP6?= =?us-ascii?Q?nmOY0rZS7ciBDnMM4JOsPoD9aKfezS+cKKY7ijLtYKCJVhhKS6joabeC9wIW?= =?us-ascii?Q?io9qxffucVXgeNIOqNzzwEkTuGZAnG7gxQ9xi7f/VltNh8pfqMD2199BM+KQ?= =?us-ascii?Q?+fgYixYkpBdE7xe6Ipz1EZSeCK1xeuV/arRPdqbLL7rvRaBSYJXhuHLja8P8?= =?us-ascii?Q?f/vP1SWtAQrk7QBW42op9AB4kHiG7I483xKumPq/Xs9JtSOxwmIYzx92ZbdA?= =?us-ascii?Q?KvX5cht0y5WYuoT9lA9QLfAQX5EtZ8NK9SSJxx8jSVCzgPmJiK+g9uhwfZ6a?= =?us-ascii?Q?JYxoaljpAk/aP8lIEA9oVEh2?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 35b3dd49-e698-4ac8-6853-08d9664c6793 X-MS-Exchange-CrossTenant-AuthSource: BN8PR02MB6433.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2021 15:40:59.2406 (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: M0DpJqn2XpNI4bXC8F/hYVbWYYLKHw1ojR65eOGK+LL+S1tQQvPxIvQGl2T4Zy/JcRNU6VLID6WmHxEWJBjGRA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR02MB5892 X-Proofpoint-ORIG-GUID: S9fodZGaToSlh0bLaAfH6DCsPqmjDz2m X-Proofpoint-GUID: S9fodZGaToSlh0bLaAfH6DCsPqmjDz2m X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1, Aquarius:18.0.790, Hydra:6.0.391, FMLib:17.0.607.475 definitions=2021-08-23_03,2021-08-23_01,2020-04-07_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.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Cc: Simon Rowe 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.22 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: 1629733286263100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Simon Rowe Reviewed-by: Michal Privoznik --- src/util/iohelper.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/util/iohelper.c b/src/util/iohelper.c index b8810d16d3..e6eb178fde 100644 --- a/src/util/iohelper.c +++ b/src/util/iohelper.c @@ -28,6 +28,8 @@ #include #include #include +#include +#include =20 #include "virthread.h" #include "virfile.h" @@ -56,6 +58,8 @@ runIO(const char *path, int fd, int oflags) unsigned long long total =3D 0; bool direct =3D O_DIRECT && ((oflags & O_DIRECT) !=3D 0); off_t end =3D 0; + struct stat sb; + bool isBlockDev =3D false; =20 #if WITH_POSIX_MEMALIGN if (posix_memalign(&base, alignMask + 1, buflen)) @@ -86,9 +90,11 @@ runIO(const char *path, int fd, int oflags) fdinname =3D "stdin"; fdout =3D fd; fdoutname =3D path; + if (fstat(fd, &sb) =3D=3D 0) + isBlockDev =3D S_ISBLK(sb.st_mode); /* To make the implementation simpler, we give up on any * attempt to use O_DIRECT in a non-trivial manner. */ - if (direct && (end =3D lseek(fd, 0, SEEK_END)) !=3D 0) { + if (!isBlockDev && direct && (end =3D lseek(fd, 0, SEEK_END)) !=3D= 0) { virReportSystemError(end < 0 ? errno : EINVAL, "%s", _("O_DIRECT write needs empty seekable fi= le")); goto cleanup; @@ -140,7 +146,7 @@ runIO(const char *path, int fd, int oflags) goto cleanup; } =20 - if (ftruncate(fd, total) < 0) { + if (!isBlockDev && ftruncate(fd, total) < 0) { virReportSystemError(errno, _("Unable to truncate %s"), fd= outname); goto cleanup; } --=20 2.22.3 From nobody Fri May 3 19:07:47 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 16297332851061002.8657361094538; Mon, 23 Aug 2021 08:41:25 -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-338-uQZLu1K0ObGObQJSuniMuA-1; Mon, 23 Aug 2021 11:41:21 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0E8EF107ACF5; Mon, 23 Aug 2021 15:41:15 +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 734F96C8F7; Mon, 23 Aug 2021 15:41:14 +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 42A164BB7C; Mon, 23 Aug 2021 15:41:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17NFf9EM025707 for ; Mon, 23 Aug 2021 11:41:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8999A202F303; Mon, 23 Aug 2021 15:41:09 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 806DB202F306 for ; Mon, 23 Aug 2021 15:41:06 +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 BB82E8011AF for ; Mon, 23 Aug 2021 15:41:06 +0000 (UTC) Received: from mx0b-002c1b01.pphosted.com (mx0b-002c1b01.pphosted.com [148.163.155.12]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-325-FYDfgPrKO--lDMeUXYPI1g-1; Mon, 23 Aug 2021 11:41:04 -0400 Received: from pps.filterd (m0127844.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.16.1.2/8.16.0.43) with SMTP id 17NFAOJO000731 for ; Mon, 23 Aug 2021 08:41:04 -0700 Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam08lp2171.outbound.protection.outlook.com [104.47.73.171]) by mx0b-002c1b01.pphosted.com with ESMTP id 3ambwg9189-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 23 Aug 2021 08:41:03 -0700 Received: from BN8PR02MB6433.namprd02.prod.outlook.com (2603:10b6:408:ad::10) by BN8PR02MB5892.namprd02.prod.outlook.com (2603:10b6:408:ba::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.22; Mon, 23 Aug 2021 15:41:02 +0000 Received: from BN8PR02MB6433.namprd02.prod.outlook.com ([fe80::bdb2:16e:e432:a7b0]) by BN8PR02MB6433.namprd02.prod.outlook.com ([fe80::bdb2:16e:e432:a7b0%5]) with mapi id 15.20.4436.024; Mon, 23 Aug 2021 15:41:02 +0000 Received: from simon-rowe.ubvm.nutanix.com (192.146.154.247) by BY5PR16CA0018.namprd16.prod.outlook.com (2603:10b6:a03:1a0::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Mon, 23 Aug 2021 15:41:01 +0000 X-MC-Unique: uQZLu1K0ObGObQJSuniMuA-1 X-MC-Unique: FYDfgPrKO--lDMeUXYPI1g-1 From: Simon Rowe To: libvir-list@redhat.com Subject: [PATCHv2 2/2] qemu: check unlink hint from virQEMUFileOpenAs() Date: Mon, 23 Aug 2021 15:40:48 +0000 Message-Id: <20210823154048.94655-3-simon.rowe@nutanix.com> In-Reply-To: <20210823154048.94655-1-simon.rowe@nutanix.com> References: <20210823154048.94655-1-simon.rowe@nutanix.com> X-ClientProxiedBy: BY5PR16CA0018.namprd16.prod.outlook.com (2603:10b6:a03:1a0::31) To BN8PR02MB6433.namprd02.prod.outlook.com (2603:10b6:408:ad::10) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 77cb6e9c-64dd-4e4d-ba74-08d9664c694e X-MS-TrafficTypeDiagnostic: BN8PR02MB5892: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: x-proofpoint-crosstenant: true X-MS-Oob-TLC-OOBClassifiers: OLM:983 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: qMIgG+Ck7WhHivHgR736bmua5l95PZzqQpdccZZoRIWxg7Ap4lpxCmXETPSAN6TAcxtPjox81VqV6vE8zQFJIaDA9jMfxn2TPrWbfLOAa0TTIT40gp9Vl6cnDVMNuGsXMxRZIq6viP/CA6s3o1duR8vfMUMK13GClOA/UWRfIZ1CFaW8FqCib2tjVwN7FAVzdjnSZCM7E/u45kKWLahFITqz3BrMrn0k74ZM9b7Iz7OcvuCJditIWQDNACSeo5p83EA0ogbH5RXpJEmx3Ud3h7H/4Ka7e3SD+a3aRJzRe+Zb+QD8GVMM5KdQ50QzCuKVCYg81Y/wjSi6U81spGLVhcRmD6pPANq4n1Za3OnhPBEczMgLMngMvgpTrH8PRvBNtuovA2WNWcIfbUW80EKorLWRVL8llzmi1kMcybbAK739clWNGMlwmIuvYNC28gdijaDDVREY7m/yPj8cwo6e5cIVv/Cpj7k0Z1KwRTaryq1h5c9dQrJFYjjohP7MA8r0wEc+4fXI00SykCdftRkmo+kzNsn65Y5bzjdYtRK2wUpgwFIxFR3yvllrJWz2Lz48/WmWAPAMv6SK6gt+tywOUIp7tvVXWulUBwLoXZE4qFDyhi6dWPI26hXAXuV5NakumE3zpXiZq71kQrVj+GQTBw9+oYKeVQmzTBDNE0lJ+ERr13PUf4SBAWd0vKiZugnZXleAZWnkWOs9pnzOMd7Ejg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN8PR02MB6433.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(396003)(136003)(366004)(39860400002)(346002)(376002)(6486002)(38350700002)(478600001)(6666004)(2906002)(83380400001)(26005)(38100700002)(186003)(36756003)(6916009)(4326008)(1076003)(316002)(86362001)(66476007)(66556008)(66946007)(7696005)(2616005)(107886003)(44832011)(8936002)(8676002)(5660300002)(956004)(52116002); DIR:OUT; SFP:1102 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?t04U6BlWxIvbB0NVqM/cjqqhqvj3lIxcofw9NhRdvbB2dwNTxmVrO2u81h0/?= =?us-ascii?Q?p6y8NXatOrLnDiJSbSIqTXvPzEG/SeBWrgWlw9NZu59pZjf0y2/QJWI7z2Px?= =?us-ascii?Q?EX73cPeZ33FLquQl4WfHSe45T3XU/B1gIH6Iq4bxUafnDwv3Qj3hGHeRHwGa?= =?us-ascii?Q?ooxNRCFog06krsTWBKFZmYVCpRp8Zjk+7wkT4KgwNj4djRRecGJegd5HD+X2?= =?us-ascii?Q?e8JZSlOjmbzwH1UYcfCDolNODJRyK59E5ifHf49d5wLjzb6y6+8h0E/edDGD?= =?us-ascii?Q?j+E2Os0YL8JuhD1LBL4VaH/0Z4t+Zo+KrU3qSFSib2N8xVe11joPq3jXqFDr?= =?us-ascii?Q?KVXPlEgB8AY4HEzvVYz0XTxf1HXVjX1sGqzD4nTxLaomwp3NfNsglS5SzRyb?= =?us-ascii?Q?FcWl1VO0QLkkKmAs0xUUVTrxnFp0MookLVgFX4SNVB4mjDgZ3RnZ2FPhY3f0?= =?us-ascii?Q?aVWOcASmuuqYcuAlnPiCrjlQnB1g7k0zKdDlGf/u8pOZXX1Btn3sPzHb53Wl?= =?us-ascii?Q?5OsnUZtZSojRNdndtsHATRRqq/ooT6zDL6X+yJ0OWkZ5uXNmab4Mf+ikEFpx?= =?us-ascii?Q?JPreCNFlmRW2omydhFCdpR/Rj5C2wOEsUhbkHVwwGvpAcUG4fyQq3ajwWRCF?= =?us-ascii?Q?G0edRJgLFwynSnoXgWSHeF6HU6ND4vO1FnLOg5WDzHbnCxWPuQN4VqmlHGEn?= =?us-ascii?Q?wCA2Yi8CPnzKZrDZWwDhN4syoaiZiAjI+7aJgsLCp0OlKfaHxa41m9QBMciN?= =?us-ascii?Q?/HDIb8Fig072g0ct3ogc6esTsh8RSaOoQQQgn/2gVDoTRR9j5yzIuleKQBsh?= =?us-ascii?Q?9Firsl9I6ESCQHp6o4lWRwP/8Y72/ZrC1e0PFE6dQdEdeReSYgGFDg8dtWWO?= =?us-ascii?Q?sJMDGMGJGuXeE8+qsHTaNTzRDjYPWg7YjSnU+uKAzn/xldCGY57ygbhZ+2QI?= =?us-ascii?Q?qGP27WkNq3l+bWrd/eoAr4syQ8hc4XftnxCnr69a/fHbYKWTHaSNAF0HW43F?= =?us-ascii?Q?dDs6lYwzvkYX+OrYEV9mE/0zOOzQEo+xM26X0QJqBZCcjakjGen2fUeI52CG?= =?us-ascii?Q?VAxVDeWXQX4BHFIRdl1iXeaAXV5ybD/aN8rB6P/ipyLvlikesbsDwRoc9AC+?= =?us-ascii?Q?K6QrnsyBrrWMJMokwhVTL3HA1sO2XboyuTuTgVE6M4LgsvEQZ7uTQCfr6tIh?= =?us-ascii?Q?/jQHsx4vOaB9oGGHcftvmkHi+dE427JZmNM4wqJDlnzLU3fEPKKcM+G2pw/A?= =?us-ascii?Q?9kDksYLpU0eSH+S7h9UQthOI3pIjH+uZ9Q3MSmbFKU2/UARkpj3ues0jTTUi?= =?us-ascii?Q?C8U2Yzif7acUksBG0rx9WtL0?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 77cb6e9c-64dd-4e4d-ba74-08d9664c694e X-MS-Exchange-CrossTenant-AuthSource: BN8PR02MB6433.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2021 15:41:02.1509 (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: LlngjFyDVmhGAwqdyHpLAvQ7S3kN6LFAj04UY5BrCOx084s9fug4o/RoSyD4/EcE3VibG580txdf0rVHXr6EFQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR02MB5892 X-Proofpoint-ORIG-GUID: IObAuJ1MWHHYehPYEEhmjWQCzC3891Uz X-Proofpoint-GUID: IObAuJ1MWHHYehPYEEhmjWQCzC3891Uz X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1, Aquarius:18.0.790, Hydra:6.0.391, FMLib:17.0.607.475 definitions=2021-08-23_03,2021-08-23_01,2020-04-07_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.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: Simon Rowe 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.15 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: 1629733286270100002 Content-Type: text/plain; charset="utf-8" Signed-off-by: Simon Rowe Reviewed-by: Michal Privoznik --- src/qemu/qemu_driver.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) Changes from v1: * only unlink if virQEMUFileOpenAs() created the file diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 444e9e5cbc..6e83d7e068 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -3201,6 +3201,7 @@ doCoreDump(virQEMUDriver *driver, int rc =3D -1; virFileWrapperFd *wrapperFd =3D NULL; int directFlag =3D 0; + bool needUnlink =3D false; unsigned int flags =3D VIR_FILE_WRAPPER_NON_BLOCKING; const char *memory_dump_format =3D NULL; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); @@ -3224,12 +3225,9 @@ doCoreDump(virQEMUDriver *driver, goto cleanup; } } - /* Core dumps usually imply last-ditch analysis efforts are - * desired, so we intentionally do not unlink even if a file was - * created. */ if ((fd =3D virQEMUFileOpenAs(cfg->user, cfg->group, false, path, O_CREAT | O_TRUNC | O_WRONLY | directFlag, - NULL)) < 0) + &needUnlink)) < 0) goto cleanup; =20 if (!(wrapperFd =3D virFileWrapperFdNew(&fd, path, flags))) @@ -3282,7 +3280,7 @@ doCoreDump(virQEMUDriver *driver, if (qemuDomainFileWrapperFDClose(vm, wrapperFd) < 0) ret =3D -1; virFileWrapperFdFree(wrapperFd); - if (ret !=3D 0) + if (ret !=3D 0 && needUnlink) unlink(path); return ret; } --=20 2.22.3