From nobody Sat Feb 7 07:25:38 2026 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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=1607358881; cv=none; d=zohomail.com; s=zohoarc; b=Ge6ieoPVM2IWrG73BkrFRG2+v+4Rl5/oqSySem5hKrDFkncs1CYJCFVyQE6W2LipGgJ0ogBxqK0hxvb+y+zNMUhyy9EESoK8ywVZmgXHfvT44wkiGb61GlSgeDlZXRlV8YN9/x0a0wfzO5QEyeLgze6Uf0vwhBnE073E6zdf88g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607358881; 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=dLhJgDHpEIJlALO9C0m9uYDgjjpCppuln5fNtrguiws=; b=Oq6d0MIlwD9ksxvIbgSv+Rh4ScgT6sgJaaljNto3FgPO+han9k3sPkUU0Y1ORD1t3Yfwwhqgd87j4KXXFH2biJQ5E90xphZjbvWaDJZkcRJOJhXS/Z2+dIqZYYDGVc71oqGt8zInsqnjddTpnnvd0iH2vOU2FkcKjHbr+ABFtLw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1607358881562249.02024354377568; Mon, 7 Dec 2020 08:34:41 -0800 (PST) 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-491-AcAT9lJLNz2k0z-Eb79QYg-1; Mon, 07 Dec 2020 11:34:36 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 728DB107ACE3; Mon, 7 Dec 2020 16:34:30 +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 51EA060BE2; Mon, 7 Dec 2020 16:34:30 +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 A39271809C9F; Mon, 7 Dec 2020 16:34:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0B7GYSjE029128 for ; Mon, 7 Dec 2020 11:34:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id 18A3B5D6AD; Mon, 7 Dec 2020 16:34:28 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6826B5D6AB for ; Mon, 7 Dec 2020 16:34:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607358880; 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=dLhJgDHpEIJlALO9C0m9uYDgjjpCppuln5fNtrguiws=; b=TN/+xSGgGHr5K4WiUh6QqasIDbrlGM2hZcKVZzXL9+O+p8cXNyY51ACAknwTwXg3uLGmqS og/w9P5IPa9j66vTeQ/cmifzui9nKIh+BP0ZR+6vRbm5mvycjch7Knj3eBAYv+OHd7M0GY E9XbvCIPgrZOQo8FPGYCaX7T6yCMSXg= X-MC-Unique: AcAT9lJLNz2k0z-Eb79QYg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 5/8] virDomainBackupDiskDefParseXML: Use virDomainStorageSourceParseBase Date: Mon, 7 Dec 2020 17:34:14 +0100 Message-Id: <7d4d64f5633c470e6a8ed0f6cc0fde5b7b5cebb9.1607358804.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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.12 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" Don't duplicate code to parse the virStorageSource basics. Signed-off-by: Peter Krempa --- src/conf/backup_conf.c | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/src/conf/backup_conf.c b/src/conf/backup_conf.c index 47e3bc1d60..11d419ce2b 100644 --- a/src/conf/backup_conf.c +++ b/src/conf/backup_conf.c @@ -104,7 +104,7 @@ virDomainBackupDiskDefParseXML(xmlNodePtr node, { VIR_XPATH_NODE_AUTORESTORE(ctxt) g_autofree char *type =3D NULL; - g_autofree char *driver =3D NULL; + g_autofree char *format =3D NULL; g_autofree char *backup =3D NULL; g_autofree char *state =3D NULL; g_autofree char *backupmode =3D NULL; @@ -169,23 +169,17 @@ virDomainBackupDiskDefParseXML(xmlNodePtr node, def->state =3D tmp; } - def->store =3D virStorageSourceNew(); + type =3D virXMLPropString(node, "type"); + format =3D virXPathString("string(./driver/@type)", ctxt); - if ((type =3D virXMLPropString(node, "type"))) { - if ((def->store->type =3D virStorageTypeFromString(type)) <=3D 0) { - virReportError(VIR_ERR_XML_ERROR, - _("unknown disk backup type '%s'"), type); - return -1; - } + if (!(def->store =3D virDomainStorageSourceParseBase(type, format, NUL= L))) + return -1; - if (def->store->type !=3D VIR_STORAGE_TYPE_FILE && - def->store->type !=3D VIR_STORAGE_TYPE_BLOCK) { - virReportError(VIR_ERR_XML_ERROR, - _("unsupported disk backup type '%s'"), type); - return -1; - } - } else { - def->store->type =3D VIR_STORAGE_TYPE_FILE; + if (def->store->type !=3D VIR_STORAGE_TYPE_FILE && + def->store->type !=3D VIR_STORAGE_TYPE_BLOCK) { + virReportError(VIR_ERR_XML_ERROR, + _("unsupported disk backup type '%s'"), type); + return -1; } if (push) @@ -198,15 +192,6 @@ virDomainBackupDiskDefParseXML(xmlNodePtr node, storageSourceParseFlags, xmlopt) < 0) return -1; - if ((driver =3D virXPathString("string(./driver/@type)", ctxt))) { - def->store->format =3D virStorageFileFormatTypeFromString(driver); - if (def->store->format <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown disk backup driver '%s'"), driver); - return -1; - } - } - return 0; } --=20 2.28.0