From nobody Mon Feb 9 04:45:11 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=1618587464; cv=none; d=zohomail.com; s=zohoarc; b=kVUztdDywsWnk+xAeV8yzLMm8E6mO7bo3A9WHRdmI201TIxeuK3SoGUIYyMjLvouorfXxqXBEMEC57td+MBw3qrTmilsZDGkpFr9WcWZZDak56+Tm45sznUhW8KfeWcaQLOZFbisj73H9yaxfTijweq3ARoEbObXJn6x5owbn70= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618587464; 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=ejy9nCaprVmpIlYg9FT1OOb6RacDqaca5OzInayTu2c=; b=H1ZvT+r3nZEe8/Pn2sFZQnQrXhLkdLLLLqOubpq55jcdrvz9XS16KXZFdVpgYJgjwF3mXZwcJolEcIf1AqcJZWmDvjqJeI2heGqZ29maBQwQuPY0tWrOQZM7CowctIzO/DxU7TncodGZ6Dy9NWcyQta5YhZpDXuRSxmop1nNyhE= 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) header.from= 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 1618587464123843.7009030093881; Fri, 16 Apr 2021 08:37:44 -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-506-2saAHOrDOJG05rP2HLEB-Q-1; Fri, 16 Apr 2021 11:37:40 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6B78E881D6C; Fri, 16 Apr 2021 15:37:35 +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 4E50E18F0A; Fri, 16 Apr 2021 15:37:35 +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 0E60C44A62; Fri, 16 Apr 2021 15:37:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13GFZG7v009423 for ; Fri, 16 Apr 2021 11:35:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0F52B5C257; Fri, 16 Apr 2021 15:35:16 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 704595C260 for ; Fri, 16 Apr 2021 15:35:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618587463; 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=ejy9nCaprVmpIlYg9FT1OOb6RacDqaca5OzInayTu2c=; b=S2VewjP0FY+gV1JfIhemzW4hnlv0HThYtdNkh4Pfeqw1q3uo5X5HsH2bvE1BSZKbp3J1JO BAJ1US9vrMdauPUiPlkqyK3p2lXAm0jYG1S+bN32XWDH2MRtBgPKLoV06YVXIgQQiLj7P3 cd99TOv925YQMd6GsHdqbY5WGH1se1s= X-MC-Unique: 2saAHOrDOJG05rP2HLEB-Q-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 18/25] conf: domain: Convert virDomainDiskDef's 'removable' to virTristateSwitch Date: Fri, 16 Apr 2021 17:34:36 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.79 on 10.5.11.11 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-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Use the appropriate type for the variable and refactor the XML parser to parse it correctly using virXMLPropEnum. Signed-off-by: Peter Krempa --- src/conf/domain_conf.c | 15 +++++---------- src/conf/domain_conf.h | 2 +- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ff408188d5..5e27ca6265 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9319,7 +9319,6 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, g_autofree char *target =3D NULL; g_autofree char *bus =3D NULL; g_autofree char *serial =3D NULL; - g_autofree char *removable =3D NULL; g_autofree char *logical_block_size =3D NULL; g_autofree char *physical_block_size =3D NULL; g_autofree char *wwn =3D NULL; @@ -9381,7 +9380,11 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, if (virXMLPropEnum(cur, "tray", virDomainDiskTrayTypeFromStrin= g, VIR_XML_PROP_OPTIONAL, &def->tray_status) <= 0) return NULL; - removable =3D virXMLPropString(cur, "removable"); + + if (virXMLPropTristateSwitch(cur, "removable", VIR_XML_PROP_OP= TIONAL, + &def->removable) < 0) + return NULL; + rotation_rate =3D virXMLPropString(cur, "rotation_rate"); } else if (!domain_name && virXMLNodeNameEqual(cur, "backenddomain")) { @@ -9495,14 +9498,6 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, } } - if (removable) { - if ((def->removable =3D virTristateSwitchTypeFromString(removable)= ) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown disk removable status '%s'"), remova= ble); - return NULL; - } - } - if (rotation_rate && virStrToLong_ui(rotation_rate, NULL, 10, &def->rotation_rate) < 0)= { virReportError(VIR_ERR_INTERNAL_ERROR, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index cb5ce68fdb..878ba4c961 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -539,7 +539,7 @@ struct _virDomainDiskDef { int bus; /* enum virDomainDiskBus */ char *dst; virDomainDiskTray tray_status; - int removable; /* enum virTristateSwitch */ + virTristateSwitch removable; unsigned int rotation_rate; virStorageSource *mirror; --=20 2.30.2