From nobody Wed May 15 19:38:25 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; 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=1622125467; cv=none; d=zohomail.com; s=zohoarc; b=ahEzLEKvZwf33Iz0HD2Y8kx1BCwrAOMhc8nZ9T50dSFvmaxaV+jipht0vGeQW0B9xAd4xsAy1yvPVlRuhl/3LVAmAOfMAIcFRLcTdrQPuSregREk1rNZtJSqzRqIxsHyO+OG5eVCh+hQz4PteUSUcTRQkCSwL06prfp6TSFXN00= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622125467; 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=AYEAzAXEXBkYoZNUVKTiR226SJ1YNs6Tvpkc3jDSd5w=; b=ZJnyGR5DpHZG4TlDBLtx6lszGu0EjGf7ZVg1jsnU4yu0af0sr3vO0wtXS2Ucc305TuhaWHU7fHrUkqfynGBJLIcNgeslSdju4TqOlWOCvXPitChP2faDlN2u2cX3QFQypxDAKHyguMpC9CeV7q0lgr/AKmH7s9ikPNwqu+bbSLI= 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 1622125466776126.07261554218269; Thu, 27 May 2021 07:24:26 -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-376-ffjEVndIN_StbjED1mh1RQ-1; Thu, 27 May 2021 10:24:21 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 598231009461; Thu, 27 May 2021 14:24:15 +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 2EB0419C66; Thu, 27 May 2021 14:24:15 +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 E7278180B463; Thu, 27 May 2021 14:24:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14RENVYu028348 for ; Thu, 27 May 2021 10:23:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id EDFC910023AF; Thu, 27 May 2021 14:23:31 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.193.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6DB8E100EBB0 for ; Thu, 27 May 2021 14:23:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622125463; 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=AYEAzAXEXBkYoZNUVKTiR226SJ1YNs6Tvpkc3jDSd5w=; b=hAiBMUB5vBM0LF0adD8N5n5AKmMB39SSU/bRr8Ai/J9+JGgj+r2NvlU0WOzCLe5PSe962g V8gYTQn+A31rVefNcqiN4bs8ECeMzJuCvft6bOY/ROT6raFJaaXAWiecn2k5iAB9WppIaZ NOexiZ5qQSRZn3ljgCuS/oOF9AoGjM4= X-MC-Unique: ffjEVndIN_StbjED1mh1RQ-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 1/2] domain_conf: extract disk driver source bits to its own function Date: Thu, 27 May 2021 16:23:25 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.84 on 10.5.11.23 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" Attribute `type` and sub-element `metadata_cache` are internally stored in the `virStorageSource` structure. Sometimes we only care about the disk source bits so we need a dedicated helper for that. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/conf/domain_conf.c | 46 ++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6d90041bf8..f7920bce2c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8849,7 +8849,6 @@ virDomainDiskDefDriverParseXML(virDomainDiskDef *def, xmlNodePtr cur, xmlXPathContextPtr ctxt) { - g_autofree char *tmp =3D NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt) =20 ctxt->node =3D cur; @@ -8900,19 +8899,6 @@ virDomainDiskDefDriverParseXML(virDomainDiskDef *def, if (virXMLPropUInt(cur, "iothread", 10, VIR_XML_PROP_NONZERO, &def->io= thread) < 0) return -1; =20 - if ((tmp =3D virXMLPropString(cur, "type"))) { - if (STREQ(tmp, "aio")) { - /* Xen back-compat */ - def->src->format =3D VIR_STORAGE_FILE_RAW; - } else { - if ((def->src->format =3D virStorageFileFormatTypeFromString(t= mp)) <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown driver format value '%s'"), tmp); - return -1; - } - } - } - if (virXMLPropEnum(cur, "detect_zeroes", virDomainDiskDetectZeroesTypeFromString, VIR_XML_PROP_NONZERO, &def->detect_zeroes) < 0) @@ -8921,9 +8907,36 @@ virDomainDiskDefDriverParseXML(virDomainDiskDef *def, if (virXMLPropUInt(cur, "queues", 10, VIR_XML_PROP_NONE, &def->queues)= < 0) return -1; =20 + return 0; +} + + +static int +virDomainDiskDefDriverSourceParseXML(virStorageSource *src, + xmlNodePtr cur, + xmlXPathContextPtr ctxt) +{ + g_autofree char *tmp =3D NULL; + VIR_XPATH_NODE_AUTORESTORE(ctxt) + + ctxt->node =3D cur; + + if ((tmp =3D virXMLPropString(cur, "type"))) { + if (STREQ(tmp, "aio")) { + /* Xen back-compat */ + src->format =3D VIR_STORAGE_FILE_RAW; + } else { + if ((src->format =3D virStorageFileFormatTypeFromString(tmp)) = <=3D 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown driver format value '%s'"), tmp); + return -1; + } + } + } + if (virParseScaledValue("./metadata_cache/max_size", NULL, ctxt, - &def->src->metadataCacheMaxSize, + &src->metadataCacheMaxSize, 1, ULLONG_MAX, false) < 0) return -1; =20 @@ -9129,6 +9142,9 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, =20 if (virDomainDiskDefDriverParseXML(def, driverNode, ctxt) < 0) return NULL; + + if (virDomainDiskDefDriverSourceParseXML(def->src, driverNode, ctx= t) < 0) + return NULL; } =20 if ((mirrorNode =3D virXPathNode("./mirror", ctxt))) { --=20 2.31.1 From nobody Wed May 15 19:38:25 2024 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=1622125456; cv=none; d=zohomail.com; s=zohoarc; b=SYoiXtJNU1jb1tk0J3aLu2ygcPVu2/evBKriQ7/BxuEb5OntFVGNGsS4AJ+sSM4TXPWG5GG+zNggzKbA2iCAKV4htLwxek6eCHWu8nLqcvF04cbIfGucdWA7PBGeYDHWDs4r/SH9Hff0PYndUbdHQ7FC3qnOqlagcxQf9A3WZuA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622125456; 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=4BXVp0a3qKvv12SkFDBTLNEAm64D8oevv2h4f3tUHOY=; b=CNO6PaS+LQmakawRN3/1oKcjsNC4+lq1SEgL9PLnYeRphKaIO9dmY05VU/cqptpeRWzpF+UWINx/tyCe6v3Uq4pYBYlevAXXevGuZnHulnVSlDQhKPBwidRA1jKjg4Eb86xGIc4HqM1++EL2+HT7yUT0c8D3rru1Mtq11jbUMZ4= 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 1622125456596383.61053643850425; Thu, 27 May 2021 07:24:16 -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-187-EKAamifYO668zxsttjOIVw-1; Thu, 27 May 2021 10:24:13 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8558F107ACF5; Thu, 27 May 2021 14:24:06 +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 0D8AF50D15; Thu, 27 May 2021 14:24:06 +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 4690955358; Thu, 27 May 2021 14:24:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14RENWwg028359 for ; Thu, 27 May 2021 10:23:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id CF2AF10023AF; Thu, 27 May 2021 14:23:32 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.193.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4F8EE100763C for ; Thu, 27 May 2021 14:23:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622125455; 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=4BXVp0a3qKvv12SkFDBTLNEAm64D8oevv2h4f3tUHOY=; b=Q3eHc1MjKM8RcBP01Lsk+Ky/Lr0KheS/W9ZcJUD+LVtWy9OHRjjaRDjs/KFXp5d+fKktgN aAY4252jMnfCBksto6SDzg/Co8D5sfBK4bi9Zf02F9xnAaU86UG1EmRE5FOhUgfHj2D2E8 gDcfWgJ0gRyscGSKzsHMt0pkgFIYcjA= X-MC-Unique: EKAamifYO668zxsttjOIVw-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 2/2] virDomainDiskDefParseSource: parse source bits from driver element Date: Thu, 27 May 2021 16:23:26 +0200 Message-Id: <3bd034c4e829a0336ce64baf451c89654572c5bc.1622125214.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.13 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" Before the mentioned commit we always parsed the whole disk definition for qemuDomainBlockCopy API but we only used the @src part. Based on that assumption the code was changed to parse only the disk element. Unfortunately that is not correct as we need to parse some parts of element as well. Fixes: 0202467c4ba8663db2304b140af609f93a9b3091 Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/conf/domain_conf.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f7920bce2c..f424ed731f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -15141,6 +15141,7 @@ virDomainDiskDefParseSource(const char *xmlStr, g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; g_autoptr(virStorageSource) src =3D NULL; + xmlNodePtr driverNode; =20 if (!(xml =3D virXMLParseStringCtxtRoot(xmlStr, _("(disk_definition)")= , "disk", &ctxt))) return NULL; @@ -15148,6 +15149,11 @@ virDomainDiskDefParseSource(const char *xmlStr, if (!(src =3D virDomainDiskDefParseSourceXML(xmlopt, ctxt->node, ctxt,= flags))) return NULL; =20 + if ((driverNode =3D virXPathNode("./driver", ctxt))) { + if (virDomainDiskDefDriverSourceParseXML(src, driverNode, ctxt) < = 0) + return NULL; + } + if (virStorageSourceIsEmpty(src)) { virReportError(VIR_ERR_NO_SOURCE, NULL); return NULL; --=20 2.31.1