From nobody Sun Oct 5 00:06:50 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1757491536; cv=none; d=zohomail.com; s=zohoarc; b=HI90yASdDSbhv3HTdNihojgqm9D4JWw2bYMPm3UKKhEDz3zoaDaFKkbhrNxBPvAp2V2+zVpxJ5jsP8ZxjwryRxkxqcpFo2g1XWKmNfGJpZmjLh1b9uVWATyM+121gEeE8eV5mBramYZIUJa3qtazJJZODwy1EMqg9Kxu2C5ejCQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757491536; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=6lAEOUZqipenL61ZQ14UB0OtODqyXGq23GEj08oZiyU=; b=eQYbICQzkJqgskm/Q6c36pUunqxKuqWKwtF8N7S6nPbtTgekbHFBrIiSzA1yKV8RkhBPR1/Y5b5Kam42vsBgsWkm+qBWtA869i7iLSv44MpxRVktyp/wce/OlWSjCZWsLPIOTCPiviXWeBc1r9ZZgWJA/QGWYLXsd+Sx9cVA7ts= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1757491536028346.00718741419905; Wed, 10 Sep 2025 01:05:36 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 4B1BD41A9A; Wed, 10 Sep 2025 04:05:35 -0400 (EDT) Received: from [172.19.199.3] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 3962843DB0; Wed, 10 Sep 2025 04:04:16 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 986A0419D9; Wed, 10 Sep 2025 04:03:50 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id DB1F841B00 for ; Wed, 10 Sep 2025 04:03:49 -0400 (EDT) Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-42-_CVo-K8IOoWvnLTYUF_FuA-1; Wed, 10 Sep 2025 04:03:48 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8A2B71800577 for ; Wed, 10 Sep 2025 08:03:47 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.3.236]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DB51019560B8 for ; Wed, 10 Sep 2025 08:03:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1757491429; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6lAEOUZqipenL61ZQ14UB0OtODqyXGq23GEj08oZiyU=; b=AMy+uYTCfNpob6mqLCj+pM/K7RX2ClZgGD51AUKoUKpigF4cZQqzZg+OFYzleEjk6GD7qi IvF5w+EwY78jp70315H8E7lo74k6uledIVMzyy2NcCbJ0na9aTug4NAw7JlzBoavNSC/4n Gm0JemP88pJZ3awrA3wQ0xGcCr3BmWQ= X-MC-Unique: _CVo-K8IOoWvnLTYUF_FuA-1 X-Mimecast-MFC-AGG-ID: _CVo-K8IOoWvnLTYUF_FuA_1757491427 To: devel@lists.libvirt.org Subject: [PATCH 1/4] ch: Actually remove device in chDomainDetachDeviceLive() Date: Wed, 10 Sep 2025 10:03:38 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 1zRmYzfZzCBAd4AbkaPecpLYiseOsLTBFn0A9pfOG8k_1757491427 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: I2VGRMMWTEG3LI76ZJPB7M4OGKGRPF37 X-Message-ID-Hash: I2VGRMMWTEG3LI76ZJPB7M4OGKGRPF37 X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Michal Privoznik via Devel Reply-To: Michal Privoznik X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1757491540265154100 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik Inside of chDomainDetachDeviceLive() there are two variables that are important in this case: 'match' and 'detach'. The first one contains device definition as parsed from user provided XML, the other contains pointer to the device definition inside virDomainDef (as returned by chDomainFindDisk()). Now, when chDomainRemoveDevice() is called, it looks up the device inside virDomainDef and removes it (using pointer comparison). Well, that means 'detach' must be passed as an argument instead of 'match'. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/ch/ch_hotplug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ch/ch_hotplug.c b/src/ch/ch_hotplug.c index 058954035d..b06fdbe5a8 100644 --- a/src/ch/ch_hotplug.c +++ b/src/ch/ch_hotplug.c @@ -336,7 +336,7 @@ chDomainDetachDeviceLive(virDomainObj *vm, return -1; } =20 - if (chDomainRemoveDevice(vm, match) < 0) + if (chDomainRemoveDevice(vm, &detach) < 0) return -1; =20 if (match->type =3D=3D VIR_DOMAIN_DEVICE_DISK) { --=20 2.49.1 From nobody Sun Oct 5 00:06:50 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1757491591; cv=none; d=zohomail.com; s=zohoarc; b=AdgLAQRcSrQnxMRUwHVbfeqSL9bojF24ckhYwaPA9JMZEWZJTDm7LHg+EOI9BRL7usjuZek+l9pNaM2kXlCC+OwQvqjJSIsv6gWHBP/vQ+KmggPaaIvCa/u34RA+ahj+fCHD0ZoKTEQEP+1tDtFpzOR97myH9Q+fvTEIsbM+u6c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757491591; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=+I2FDI7dpnaquEFQ4//koFPiucRikzGqeRWLlMDlP/k=; b=W6zk32f/xT7vVPHv/sj5mWlEdeiJDWzT+i0upbtomx9fhloayr+kbK7uSopf/NtLTUh+5NQjP46JnJCVDAhmz08srn/u2YOrZHPra8U5rD862prMyYfjSmeUWQM5PQuKDKM0zbJKaX7bCQyReOwlNeT4vNXopOfxz1uEmtT4sOA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1757491591421829.7038395472096; Wed, 10 Sep 2025 01:06:31 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id C9E6841B6D; Wed, 10 Sep 2025 04:06:30 -0400 (EDT) Received: from [172.19.199.3] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 301CC43E07; Wed, 10 Sep 2025 04:04:28 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id D663941AFC; Wed, 10 Sep 2025 04:03:51 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 0C29841A9A for ; Wed, 10 Sep 2025 04:03:51 -0400 (EDT) Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-137-ZZSi0SAOPPKyREjuDiDKcA-1; Wed, 10 Sep 2025 04:03:49 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8CD6D1800378 for ; Wed, 10 Sep 2025 08:03:48 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.3.236]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E7D6219560AB for ; Wed, 10 Sep 2025 08:03:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1757491430; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+I2FDI7dpnaquEFQ4//koFPiucRikzGqeRWLlMDlP/k=; b=hN8IzsOu2xQjJ3pwiH4cmwlsBjsoa9J31bx4kukGlrAbEa1fUTfLiHeXgws4PvcloPMNSx MuYRiJEnUp00SxCDoLHbUb/qJ7OElG3+OmT9/l9a4lzP8GL8ceCMeXwH7CJOETYaj4XGIa F8CDmLcIos9Pmqnht/UBjql7xVhs3CE= X-MC-Unique: ZZSi0SAOPPKyREjuDiDKcA-1 X-Mimecast-MFC-AGG-ID: ZZSi0SAOPPKyREjuDiDKcA_1757491428 To: devel@lists.libvirt.org Subject: [PATCH 2/4] ch: Drop deadcode from chDomainDetachDeviceLive() Date: Wed, 10 Sep 2025 10:03:39 +0200 Message-ID: <54009d67d2ca8fd53c166d497ffc4b7db6ea7e41.1757491293.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: OWwsw5BD0aL0c-qPE4qCSd6XuKks_eJwi9GG7Uyc0BU_1757491428 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 3ZU4DHLMELOBYLB64F4QS3PVMGPIBVIR X-Message-ID-Hash: 3ZU4DHLMELOBYLB64F4QS3PVMGPIBVIR X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Michal Privoznik via Devel Reply-To: Michal Privoznik X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1757491593726154100 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik At the end of chDomainDetachDeviceLive() there's a code that tries to remove the disk that's being detached from the domain definition. Well, it's a leftover from the original patch which I forgot to remove when rewriting it to use chDomainRemoveDevice(). The disk is removed there so this code has no chance in removing it again. Drop the code. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/ch/ch_hotplug.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/ch/ch_hotplug.c b/src/ch/ch_hotplug.c index b06fdbe5a8..aa723dd123 100644 --- a/src/ch/ch_hotplug.c +++ b/src/ch/ch_hotplug.c @@ -263,7 +263,6 @@ chDomainDetachDeviceLive(virDomainObj *vm, virDomainDeviceDef detach =3D { .type =3D match->type }; virDomainDeviceInfo *info =3D NULL; virCHDomainObjPrivate *priv =3D vm->privateData; - int idx =3D 0; =20 switch (match->type) { case VIR_DOMAIN_DEVICE_DISK: @@ -339,13 +338,6 @@ chDomainDetachDeviceLive(virDomainObj *vm, if (chDomainRemoveDevice(vm, &detach) < 0) return -1; =20 - if (match->type =3D=3D VIR_DOMAIN_DEVICE_DISK) { - idx =3D chFindDiskId(vm->def, match->data.disk->dst); - if (idx >=3D 0) { - virDomainDiskRemove(vm->def, idx); - } - } - return 0; } =20 --=20 2.49.1 From nobody Sun Oct 5 00:06:50 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1757491626; cv=none; d=zohomail.com; s=zohoarc; b=cBJ+A5IqkM6TMoRZfIHEb1HEGaItJz/Xw2BJqP2mRgoIMxhfUhDPyRP0t5QDnY7M8+Yos/zVPMh1P6dOhGY/cqeZMf+Bf/20ve0H0q4ziHq8ryJbaJHh7dI86UP7pXcGvuhBRm78sdlTMeSOY8SNWi3pDit1HL5Vc1sdUsSrPws= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757491626; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=qzFLM4Lx+6KndgUEkuhue3s1RX1hfkom63PcBcTcO0M=; b=AbmrR7X8VTa0YnrXX0Ap6eJrZqOK6jb6/uQaJ1tytWd76OT7FYGgMPWfTZ8ccRlaIXi2Ffrjcu6CQ8vv7WRFaoGLX4JVvfNTguFCS8qSroViWB2b2Jfxj7LeVHwe/11NCoTzGYOosW2xS6ivRdPgZpwOz0br17SaA5jxTP1KdjQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1757491626877163.48510877775163; Wed, 10 Sep 2025 01:07:06 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 631E841B76; Wed, 10 Sep 2025 04:07:06 -0400 (EDT) Received: from [172.19.199.3] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id B46F543DDE; Wed, 10 Sep 2025 04:04:56 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 0218641A9E; Wed, 10 Sep 2025 04:03:52 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 026AB41A9A for ; Wed, 10 Sep 2025 04:03:51 -0400 (EDT) Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-33-cH35xf3uNn6w1zobmdw_4A-1; Wed, 10 Sep 2025 04:03:50 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9FC6D195608B for ; Wed, 10 Sep 2025 08:03:49 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.3.236]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id F1EAE19560AB for ; Wed, 10 Sep 2025 08:03:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1757491431; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qzFLM4Lx+6KndgUEkuhue3s1RX1hfkom63PcBcTcO0M=; b=G8eQW2XCGNJug15Oj3NfjPfS84/4ez/XmXaGeWqKn3C92pyOEAVSSzEiiavFKksGfndDxA SooQPiOhCZXg5+ZKoh8MiPT6ll1nQyIrw/SejwCSi1ChAYs1ueVb8Z+qee6D+MPE33c7oO DHscXgUfmEIJndB5WKGmURsRW4buX8w= X-MC-Unique: cH35xf3uNn6w1zobmdw_4A-1 X-Mimecast-MFC-AGG-ID: cH35xf3uNn6w1zobmdw_4A_1757491429 To: devel@lists.libvirt.org Subject: [PATCH 3/4] ch: Drop useless variable in chDomainFindDisk() Date: Wed, 10 Sep 2025 10:03:40 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: HdQZDXWyOIavcZxVy54ga7wihOafRK9Zc0eQHUjLQvo_1757491429 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: JCJMU2KLIFNCY3J4XEFSGM2W2WPDXU5A X-Message-ID-Hash: JCJMU2KLIFNCY3J4XEFSGM2W2WPDXU5A X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Michal Privoznik via Devel Reply-To: Michal Privoznik X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1757491636121154100 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik The 'disk' variable inside of chDomainFindDisk() is not used really. Drop it. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/ch/ch_hotplug.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ch/ch_hotplug.c b/src/ch/ch_hotplug.c index aa723dd123..cfa11cc5e5 100644 --- a/src/ch/ch_hotplug.c +++ b/src/ch/ch_hotplug.c @@ -185,7 +185,6 @@ chDomainFindDisk(virDomainObj *vm, virDomainDiskDef *match, virDomainDiskDef **detach) { - virDomainDiskDef *disk; int idx; =20 if ((idx =3D chFindDiskId(vm->def, match->dst)) < 0) { @@ -193,7 +192,7 @@ chDomainFindDisk(virDomainObj *vm, _("disk %1$s not found"), match->dst); return -1; } - *detach =3D disk =3D vm->def->disks[idx]; + *detach =3D vm->def->disks[idx]; =20 return 0; } --=20 2.49.1 From nobody Sun Oct 5 00:06:50 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1757491681; cv=none; d=zohomail.com; s=zohoarc; b=Pibc3X5ECBKgxmOXH9IbYRn76HYErM2wtpaMeFd+ocgtbOAQuE/jQBGEazCPrDiNiDv5wJ6O+z/txVE7iR6eLy1OPvHEw629FF7YPyrAHHnvhDZd9BKnfl1Dk1mReES8PNre6viWT9/u3eZnl80ou4/emV6GJIQVHvEhpbNv45c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757491681; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=lJ23vWp3eSF5IOEXAuIF0H+vtdcr3V8HjvHx94b1Ew8=; b=ScZbZutY/t1hUJklNcLCrPDkmFHmPrRtWKfPLeGIA61aC5CLkJ9yrHv8XwpGqMg0uIaHuxeUUVjwj+ZjqGbMIgpC8OGmk9dhSuCSPAKeoa4DXqbQ3ZPWYrrI3xRUouDRW6iMg1NYTdQSiQZ9HV6imHCCYDHm0yj+JaRE4SwRNAk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1757491681419340.9226636274318; Wed, 10 Sep 2025 01:08:01 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id CF45341B73; Wed, 10 Sep 2025 04:07:53 -0400 (EDT) Received: from [172.19.199.3] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 056D643DF4; Wed, 10 Sep 2025 04:05:19 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 06CCF41A9A; Wed, 10 Sep 2025 04:03:53 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id F37C541AFC for ; Wed, 10 Sep 2025 04:03:52 -0400 (EDT) Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-328-JLAO3E-YP9m2bIK-yrJf9g-1; Wed, 10 Sep 2025 04:03:51 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A405C1800562 for ; Wed, 10 Sep 2025 08:03:50 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.3.236]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0A50D19560AB for ; Wed, 10 Sep 2025 08:03:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1757491432; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lJ23vWp3eSF5IOEXAuIF0H+vtdcr3V8HjvHx94b1Ew8=; b=ifr6BQ7MZbCAxiwCogP69BC4PtFLy6J5AGYaXg5CEhS/MAYswdkIeaywfGuD7FFNiUR8XH /lpmjU+4DebZ/AXMoZjTUJQ8fGBTevSpq2MYWHW8gwm3Y+tc6Rd7cSQ9hWNzNoqveksf5I weevcsSPlQCf5aJJe6Q5TXF847Zkrmk= X-MC-Unique: JLAO3E-YP9m2bIK-yrJf9g-1 X-Mimecast-MFC-AGG-ID: JLAO3E-YP9m2bIK-yrJf9g_1757491430 To: devel@lists.libvirt.org Subject: [PATCH 4/4] ch: Avoid memleak on disk detach in chDomainRemoveDevice() Date: Wed, 10 Sep 2025 10:03:41 +0200 Message-ID: <51bc73f7d4bf7c028033fb21035e85c5278a0204.1757491293.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: GACcbMb3ep-m3GHyiZ6_fpXiMoo4h5WRA-lvPg4lcg8_1757491430 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: SABW6Z3BDB4TTMZACKPLBKNOASLQJM3B X-Message-ID-Hash: SABW6Z3BDB4TTMZACKPLBKNOASLQJM3B X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Michal Privoznik via Devel Reply-To: Michal Privoznik X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1757491684746154100 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik The aim of chDomainRemoveDevice() is to remove device from virDomainDef. Well, in case of disks this is done by calling virDomainDiskRemove() which merely just removes it from the array of virDomainDiskDef-s but leaves it up to the caller to actually free the disk def. 1,286 (560 direct, 726 indirect) bytes in 1 blocks are definitely lost in l= oss record 2,005 of 2,041 at 0x4919EF3: calloc (vg_replace_malloc.c:1675) by 0x4FEB249: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.8400.3) by 0x4AFD9A4: virDomainDiskDefNewSource (domain_conf.c:2409) by 0x4B10ACA: virDomainDiskDefParseXML (domain_conf.c:8509) by 0x4B24F07: virDomainDeviceDefParse (domain_conf.c:14631) by 0xB8D8881: chDomainAttachDeviceLiveAndUpdateConfig (ch_hotplug.c:135) by 0xB8CCFE0: chDomainAttachDeviceFlags (ch_driver.c:2376) by 0xB8CD057: chDomainAttachDevice (ch_driver.c:2394) by 0x4DC1C7D: virDomainAttachDevice (libvirt-domain.c:8951) by 0x405E545: remoteDispatchDomainAttachDevice (remote_daemon_dispatch_s= tubs.h:3763) by 0x405E495: remoteDispatchDomainAttachDeviceHelper (remote_daemon_disp= atch_stubs.h:3742) by 0x4BF3164: virNetServerProgramDispatchCall (virnetserverprogram.c:423) Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/ch/ch_hotplug.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ch/ch_hotplug.c b/src/ch/ch_hotplug.c index cfa11cc5e5..0a55a57069 100644 --- a/src/ch/ch_hotplug.c +++ b/src/ch/ch_hotplug.c @@ -212,6 +212,7 @@ chDomainRemoveDevice(virDomainObj *vm, for (i =3D 0; i < vm->def->ndisks; i++) { if (vm->def->disks[i] =3D=3D device->data.disk) { virDomainDiskRemove(vm->def, i); + g_clear_pointer(&device->data.disk, virDomainDiskDefFree); break; } } --=20 2.49.1