From nobody Mon Feb 9 14:02:47 2026 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1669990688; cv=none; d=zohomail.com; s=zohoarc; b=X7Ctc1jTCJSmQhdSyLkETL4OUYD+zZk2BtSxWTnWm/V9W/t0cMK0fXQo7MIfnQp9hnsCmXTD1p7GLAEIMBO1W/AZ/qFc5hHhIAz2ZUIPKYV9dlPXVNfWq56Id4imKfXuh7BLtgZX22KvbZOhIaoAns5YTo0nvMQs2BVGnFWokwE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669990688; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vUOns0kOYd4WamHZ9XPxAaTg3dvrrkAFuKHl7Z3xKbo=; b=B5bgrcqAP26hE1uUWGZbE/DfUPR10xFL+p3fSk6s4EMAYymaQqbEZZ9CM8vRGfemJZXTESDxS9tr8riynuOKvh6wgRp1rAsUKJCIn+UMB4awDCwPCgOPlC8mmYyZMo0ttXfZP0CfCB1K7zkQXjb1XwhcDj1Jqrw+OvHpAlzdg0Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) 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 1669990688271721.8001270510675; Fri, 2 Dec 2022 06:18:08 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-630-GUll2wIQPiuMzu_eX5nUhg-1; Fri, 02 Dec 2022 09:17:24 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4A68E894E82; Fri, 2 Dec 2022 14:17:21 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 35EA320290A6; Fri, 2 Dec 2022 14:17:21 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1BA091946A63; Fri, 2 Dec 2022 14:17:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 553E01946A43 for ; Fri, 2 Dec 2022 14:17:19 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 362B640E9787; Fri, 2 Dec 2022 14:17:19 +0000 (UTC) Received: from speedmetal.redhat.com (ovpn-208-20.brq.redhat.com [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 951E740E9785 for ; Fri, 2 Dec 2022 14:17:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669990686; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=vUOns0kOYd4WamHZ9XPxAaTg3dvrrkAFuKHl7Z3xKbo=; b=IIX4Kl+NP+I7oxK+tFyfXscOQx6eJTTWw7mlPwj1QnJNHQDtLsDE7Fa0wMXgPjRIE8viHJ ByauWzrkRhZijVDTZzjDZLnyoEP6uJDuTneCXAyXZSHrDR+IJddt492foribxIFNM47M58 5k4I7XOqtmlnpQ7rf7MLLsZRVuOPHTM= X-MC-Unique: GUll2wIQPiuMzu_eX5nUhg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 11/13] virshFindDisk: Sanitize removable media check Date: Fri, 2 Dec 2022 15:16:55 +0100 Message-Id: <1b379033d33d5cf33812bbe74763c6b3b9655de6.1669990545.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1669990688822100001 Content-Type: text/plain; charset="utf-8" The XPath lookup guarantees that the top level element is always 'disk' so there's no need to check that it actually is. We can also remove the two unnecessary temporary variables. Signed-off-by: Peter Krempa --- tools/virsh-domain.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 1beaacd5e9..8bd058a33a 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -12658,22 +12658,13 @@ virshFindDisk(const char *doc, /* search disk using @path */ for (i =3D 0; i < nnodes; i++) { - bool is_supported =3D true; - if (type =3D=3D VIRSH_FIND_DISK_CHANGEABLE) { - xmlNodePtr n =3D nodes[i]; - is_supported =3D false; + g_autofree char *device =3D virXMLPropString(nodes[i], "device= "); /* Check if the disk is CDROM or floppy disk */ - if (virXMLNodeNameEqual(n, "disk")) { - g_autofree char *device_value =3D virXMLPropString(n, "dev= ice"); - - if (STREQ(device_value, "cdrom") || - STREQ(device_value, "floppy")) - is_supported =3D true; - } - - if (!is_supported) + if (device && + STRNEQ(device, "cdrom") && + STRNEQ(device, "floppy")) continue; } --=20 2.38.1