From nobody Fri May 17 11:28:43 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=1618587443; cv=none; d=zohomail.com; s=zohoarc; b=gM0ATwpcwbmfw4D2Yr+N6XfPfvOeDgM+jI6iuRL1yflnjOfRT6uS9PtYLWom0HYntE6zc3mnoc6rE1ajxQ33DagQiZrjx07ediaFisr5CvpKYlCGry9vyeBCXdNXVQDS3XBprQBoFcvnx53HE9bJA8h3B+7an1RDiX1VMINmO1A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618587443; 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=ZAgKqjDrtCZGgEMKwb0lL2ZdNcZVlq9usXJ3BhGyd6I=; b=n+3oZO0PTqO5+ZlxQoMNEsYi68POC9LyjwZphNuNGdDi5Z3fOOf+7hRLVcg4qjnvJRm5wB731RYHwv/fWsvTnlXasWzsydQUniEYQl5QZi4zj5pO4PEmUig8ZLvoH7qheuP87MDrg4W269amvuBzvsdoUufDUHUYVwh3eGytTMc= 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 1618587443928799.8753768928016; Fri, 16 Apr 2021 08:37:23 -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-349-B1auhCSZPAW0OtgIKEliFA-1; Fri, 16 Apr 2021 11:37:18 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8F812100A60D; Fri, 16 Apr 2021 15:37:07 +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 0412710023B5; Fri, 16 Apr 2021 15:37: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 92C851806D0F; Fri, 16 Apr 2021 15:37:03 +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 13GFYoh2009220 for ; Fri, 16 Apr 2021 11:34:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1951E1C4; Fri, 16 Apr 2021 15:34:50 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B0745C3DF for ; Fri, 16 Apr 2021 15:34:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618587442; 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=ZAgKqjDrtCZGgEMKwb0lL2ZdNcZVlq9usXJ3BhGyd6I=; b=SqgD1hHu2r2vOwqeoA9Lnc/qGU87hPhh67sqHCV9TbWk6Q6RBOtVliKlZ5FsX2fxyCv/bo 8cgNTpZRaI4xMRyQQyJa6HKurWJeiaukJvhERNl2AmLbZNvCQu0BH6wzL6Z1rimNfSw9G1 sMcjQMI7DtmGBE5w6kZ17XIkPufS4PU= X-MC-Unique: B1auhCSZPAW0OtgIKEliFA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 01/25] virXMLParseHelper: Add root XML node name validation capability Date: Fri, 16 Apr 2021 17:34:19 +0200 Message-Id: <88f9f97ca927340a1ed6baedfc63efdac9de7227.1618587222.git.pkrempa@redhat.com> 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.84 on 10.5.11.22 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" Some callers want to validate the root XML node name. Add the capability to the parser helper to prevent open-coding. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/util/virxml.c | 18 ++++++++++++++++-- src/util/virxml.h | 13 +++++++------ 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/util/virxml.c b/src/util/virxml.c index 83644af8ce..d0d9494009 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -1020,11 +1020,15 @@ catchXMLError(void *ctx, const char *msg G_GNUC_UNU= SED, ...) * @filename: file to be parsed or NULL if string parsing is requested * @xmlStr: XML string to be parsed in case filename is NULL * @url: URL of XML document for string parser + * @rootelement: Optional name of the expected root element * @ctxt: optional pointer to populate with new context pointer * * Parse XML document provided either as a file or a string. The function * guarantees that the XML document contains a root element. * + * If @rootelement is not NULL, the name of the root element of the parsed= XML + * is vaidated against + * * Returns parsed XML document. */ xmlDocPtr @@ -1032,11 +1036,13 @@ virXMLParseHelper(int domcode, const char *filename, const char *xmlStr, const char *url, + const char *rootelement, xmlXPathContextPtr *ctxt) { struct virParserData private; g_autoptr(xmlParserCtxt) pctxt =3D NULL; g_autoptr(xmlDoc) xml =3D NULL; + xmlNodePtr rootnode; const char *docname; if (filename) @@ -1075,18 +1081,26 @@ virXMLParseHelper(int domcode, return NULL; } - if (xmlDocGetRootElement(xml) =3D=3D NULL) { + if (!(rootnode =3D xmlDocGetRootElement(xml))) { virGenericReportError(domcode, VIR_ERR_INTERNAL_ERROR, "%s", _("missing root element")); return NULL; } + if (rootelement && + !virXMLNodeNameEqual(rootnode, rootelement)) { + virReportError(VIR_ERR_XML_ERROR, + _("expecting root element of '%s', not '%s'"), + rootelement, rootnode->name); + return NULL; + } + if (ctxt) { if (!(*ctxt =3D virXMLXPathContextNew(xml))) return NULL; - (*ctxt)->node =3D xmlDocGetRootElement(xml); + (*ctxt)->node =3D rootnode; } return g_steal_pointer(&xml); diff --git a/src/util/virxml.h b/src/util/virxml.h index 022ead58b5..38da2931a4 100644 --- a/src/util/virxml.h +++ b/src/util/virxml.h @@ -150,6 +150,7 @@ virXMLParseHelper(int domcode, const char *filename, const char *xmlStr, const char *url, + const char *rootelement, xmlXPathContextPtr *ctxt); const char * @@ -166,7 +167,7 @@ virXMLPickShellSafeComment(const char *str1, * Return the parsed document object, or NULL on failure. */ #define virXMLParse(filename, xmlStr, url) \ - virXMLParseHelper(VIR_FROM_THIS, filename, xmlStr, url, NULL) + virXMLParseHelper(VIR_FROM_THIS, filename, xmlStr, url, NULL, NULL) /** * virXMLParseString: @@ -178,7 +179,7 @@ virXMLPickShellSafeComment(const char *str1, * Return the parsed document object, or NULL on failure. */ #define virXMLParseString(xmlStr, url) \ - virXMLParseHelper(VIR_FROM_THIS, NULL, xmlStr, url, NULL) + virXMLParseHelper(VIR_FROM_THIS, NULL, xmlStr, url, NULL, NULL) /** * virXMLParseFile: @@ -189,7 +190,7 @@ virXMLPickShellSafeComment(const char *str1, * Return the parsed document object, or NULL on failure. */ #define virXMLParseFile(filename) \ - virXMLParseHelper(VIR_FROM_THIS, filename, NULL, NULL, NULL) + virXMLParseHelper(VIR_FROM_THIS, filename, NULL, NULL, NULL, NULL) /** * virXMLParseCtxt: @@ -204,7 +205,7 @@ virXMLPickShellSafeComment(const char *str1, * Return the parsed document object, or NULL on failure. */ #define virXMLParseCtxt(filename, xmlStr, url, pctxt) \ - virXMLParseHelper(VIR_FROM_THIS, filename, xmlStr, url, pctxt) + virXMLParseHelper(VIR_FROM_THIS, filename, xmlStr, url, NULL, pctxt) /** * virXMLParseStringCtxt: @@ -218,7 +219,7 @@ virXMLPickShellSafeComment(const char *str1, * Return the parsed document object, or NULL on failure. */ #define virXMLParseStringCtxt(xmlStr, url, pctxt) \ - virXMLParseHelper(VIR_FROM_THIS, NULL, xmlStr, url, pctxt) + virXMLParseHelper(VIR_FROM_THIS, NULL, xmlStr, url, NULL, pctxt) /** * virXMLParseFileCtxt: @@ -231,7 +232,7 @@ virXMLPickShellSafeComment(const char *str1, * Return the parsed document object, or NULL on failure. */ #define virXMLParseFileCtxt(filename, pctxt) \ - virXMLParseHelper(VIR_FROM_THIS, filename, NULL, NULL, pctxt) + virXMLParseHelper(VIR_FROM_THIS, filename, NULL, NULL, NULL, pctxt) int virXMLSaveFile(const char *path, --=20 2.30.2 From nobody Fri May 17 11:28:43 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=1618587566; cv=none; d=zohomail.com; s=zohoarc; b=L9cJ4rbL6wYCD94gxG09Y3ujW/03b8YGL/j3qGMDoQy1OYavJLoF9Pn6rJd5qCHzuVbKiZ5D3p3nWcmn8LvxGXPv2SRxj8MdfA0wrxP5lEA7wny4OBD870fFD6DXJO+pI4HrPWqSqNHiwN3TnP2YLgo1rKTgIKWcNjBl2udmPnE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618587566; 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=UkEUZjU5GafPbCFWR5eOL8WVyRSnmi8TDorc9HZBDds=; b=HA8zmG2RFI/FKPz+Ni1o9zsXkP0D47qqBj/1a/Go3DYYGCFgpHIJczA/Qi/y/4WCvj2D1nOQdcaMDEvHNl4PqoXMBnZMTYGFSeiMyb6Yq8Iiqhn+Ng1T5KQPHiXsUV5cFuKhyy8RCl4RpyuOXBlX07MIXBkoO9vyICAR/J9BKjg= 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 1618587566516121.30581196159869; Fri, 16 Apr 2021 08:39: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-278-d-dJi3LxMvqbE0Rt0AmXXA-1; Fri, 16 Apr 2021 11:39:22 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2003818BA286; Fri, 16 Apr 2021 15:39:18 +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 EDE5A5C260; Fri, 16 Apr 2021 15:39:17 +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 B992D1806D15; Fri, 16 Apr 2021 15:39:17 +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 13GFYpki009226 for ; Fri, 16 Apr 2021 11:34:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5579C1C4; Fri, 16 Apr 2021 15:34:51 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 84EC05C3DF for ; Fri, 16 Apr 2021 15:34:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618587565; 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=UkEUZjU5GafPbCFWR5eOL8WVyRSnmi8TDorc9HZBDds=; b=Wk/sAGTiANBcTJ2kXHUe7UvaoQPimYtyYXZHHePlyg2n0+yq2RWvzrXbhdAp4wDSoB3Qsq czr2FumlIMxAv3lSYAFPhepm3VTU2Rmokw7BiCS8GOn3dHc217TRmlOZV/GTQEpjVEekPr FR5/oqBUsxV465LcgWrMv6hO4SsfG0s= X-MC-Unique: d-dJi3LxMvqbE0Rt0AmXXA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 02/25] util: xml: Introduce virXMLParseStringCtxtRoot Date: Fri, 16 Apr 2021 17:34:20 +0200 Message-Id: <8d2913f634b7843898a84e12e1f4d3639f824dc1.1618587222.git.pkrempa@redhat.com> 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.16 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 new macro instead of virXMLParseStringCtxt in places where the root node is being validated. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 9 +-------- src/conf/storage_conf.c | 16 +++++----------- src/util/virxml.h | 4 ++++ 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 17bbeddec6..6795f0b3be 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -16438,16 +16438,9 @@ virDomainDiskDefParse(const char *xmlStr, g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; - if (!(xml =3D virXMLParseStringCtxt(xmlStr, _("(disk_definition)"), &c= txt))) + if (!(xml =3D virXMLParseStringCtxtRoot(xmlStr, _("(disk_definition)")= , "disk", &ctxt))) return NULL; - if (!virXMLNodeNameEqual(ctxt->node, "disk")) { - virReportError(VIR_ERR_XML_ERROR, - _("expecting root element of 'disk', not '%s'"), - ctxt->node->name); - return NULL; - } - return virDomainDiskDefParseXML(xmlopt, ctxt->node, ctxt, flags); } diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 66419616da..328650bd6a 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -691,25 +691,19 @@ virStoragePoolDefParseSourceString(const char *srcSpe= c, int pool_type) { g_autoptr(xmlDoc) doc =3D NULL; - xmlNodePtr node =3D NULL; g_autoptr(xmlXPathContext) xpath_ctxt =3D NULL; g_autoptr(virStoragePoolSource) def =3D NULL; - if (!(doc =3D virXMLParseStringCtxt(srcSpec, - _("(storage_source_specification)"), - &xpath_ctxt))) + if (!(doc =3D virXMLParseStringCtxtRoot(srcSpec, + _("(storage_source_specification= )"), + "source", + &xpath_ctxt))) return NULL; def =3D g_new0(virStoragePoolSource, 1); - if (!(node =3D virXPathNode("/source", xpath_ctxt))) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("root element was not source")); - return NULL; - } - if (virStoragePoolDefParseSource(xpath_ctxt, def, pool_type, - node) < 0) + xpath_ctxt->node) < 0) return NULL; return g_steal_pointer(&def); diff --git a/src/util/virxml.h b/src/util/virxml.h index 38da2931a4..2b40398eee 100644 --- a/src/util/virxml.h +++ b/src/util/virxml.h @@ -221,6 +221,10 @@ virXMLPickShellSafeComment(const char *str1, #define virXMLParseStringCtxt(xmlStr, url, pctxt) \ virXMLParseHelper(VIR_FROM_THIS, NULL, xmlStr, url, NULL, pctxt) +/* virXMLParseStringCtxtRoot is same as above, except it also validates ro= ot node name */ +#define virXMLParseStringCtxtRoot(xmlStr, url, rootnode, pctxt) \ + virXMLParseHelper(VIR_FROM_THIS, NULL, xmlStr, url, rootnode, pctxt) + /** * virXMLParseFileCtxt: * @filename: file to parse --=20 2.30.2 From nobody Fri May 17 11:28:43 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=1618587509; cv=none; d=zohomail.com; s=zohoarc; b=nxbWQa6IOysiWdI8+Up4i5LkyOqghBWRwIJa2D7EM0XiR00VgpTy/+IubLZ/E5Sp6uHKidS66dDXv9zt8qEx85suSUu4IcVkaFg6k1DUHFbwzqNsvLMEtk30n42jTvh24/Yi1K6e38a14lADFtf0hz92FCCsW6UQRTlnwxkrKSg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618587509; 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=HHklWnLeUeQ0hJpVdSbE/TzMCqXutZisOzSgDhw1OCI=; b=GKqAecGzal25S/X4P2qYHhm41qjmn5acbry2372KGhz0C/V9NpNlbaTWnCLdUh8Rowb2rjNzRGcCU60fqhKoRc2hZXDrLsSXtsyfByCIlpx6xdF5iizQuh+QvAo1zvaWzlk4ijPAnlWRk+1kkX9qk544TjujYoDMhnFukYXEoCg= 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 1618587509635348.9602921135429; Fri, 16 Apr 2021 08:38:29 -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-395-CP4gJmOUMaarOPUCHU1ynQ-1; Fri, 16 Apr 2021 11:38:26 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 573A0A6884; Fri, 16 Apr 2021 15:38:20 +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 2B71310023B5; Fri, 16 Apr 2021 15:38:20 +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 EA1351806D0F; Fri, 16 Apr 2021 15:38:19 +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 13GFYq6J009234 for ; Fri, 16 Apr 2021 11:34:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6957B5C3DF; Fri, 16 Apr 2021 15:34:52 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id B75395C6BD for ; Fri, 16 Apr 2021 15:34:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618587508; 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=HHklWnLeUeQ0hJpVdSbE/TzMCqXutZisOzSgDhw1OCI=; b=PhpT6wwP9LZeEEDHhokaRDd0nSySEkzfRbFYyeeZzEpM69GP7BDrVJfVylO0aCUhjMSQzD yTqK0NV6VvH00eqy+9qV6V5PbDJj2RzuiPZBTNHiqBFsXr3qzGc5iaLKuq4R8MU44SH3U4 I9IB4gmDAl2+SE/MsI2F8Lhf3TajOBA= X-MC-Unique: CP4gJmOUMaarOPUCHU1ynQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 03/25] conf: domain: Introduce virDomainDiskDefParseSource Date: Fri, 16 Apr 2021 17:34:21 +0200 Message-Id: <31b062efaddeb703e0b6736c8adb59584dcda8e6.1618587222.git.pkrempa@redhat.com> 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.84 on 10.5.11.22 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" Add a helper function which will parse the source portion of a . The idea is to replace *virDomainDiskDefParse with VIR_DOMAIN_DEF_PARSE_DISK_SOURCE with the new helper in the future. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 30 ++++++++++++++++++++++++++++++ src/conf/domain_conf.h | 3 +++ src/libvirt_private.syms | 1 + 3 files changed, 34 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6795f0b3be..57cad6ffde 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9704,6 +9704,21 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, } +static virStorageSource * +virDomainDiskDefParseSourceXML(virDomainXMLOption *xmlopt, + xmlNodePtr node, + xmlXPathContextPtr ctxt, + unsigned int flags) +{ + g_autoptr(virDomainDiskDef) diskdef =3D NULL; + + if (!(diskdef =3D virDomainDiskDefParseXML(xmlopt, node, ctxt, + flags | VIR_DOMAIN_DEF_PARSE_= DISK_SOURCE))) + return NULL; + + return g_steal_pointer(&diskdef->src); +} + /** * virDomainParseMemory: @@ -16445,6 +16460,21 @@ virDomainDiskDefParse(const char *xmlStr, } +virStorageSource * +virDomainDiskDefParseSource(const char *xmlStr, + virDomainXMLOption *xmlopt, + unsigned int flags) +{ + g_autoptr(xmlDoc) xml =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; + + if (!(xml =3D virXMLParseStringCtxtRoot(xmlStr, _("(disk_definition)")= , "disk", &ctxt))) + return NULL; + + return virDomainDiskDefParseSourceXML(xmlopt, ctxt->node, ctxt, flags); +} + + static const char * virDomainChrTargetTypeToString(int deviceType, int targetType) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 99ab2a96d9..83b9288941 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3406,6 +3406,9 @@ virDomainDeviceDef *virDomainDeviceDefParse(const cha= r *xmlStr, virDomainDiskDef *virDomainDiskDefParse(const char *xmlStr, virDomainXMLOption *xmlopt, unsigned int flags); +virStorageSource *virDomainDiskDefParseSource(const char *xmlStr, + virDomainXMLOption *xmlopt, + unsigned int flags); virDomainDef *virDomainDefParseString(const char *xmlStr, virDomainXMLOption *xmlopt, void *parseOpaque, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 0fcbf546a6..fe3b443171 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -371,6 +371,7 @@ virDomainDiskDefCheckDuplicateInfo; virDomainDiskDefFree; virDomainDiskDefNew; virDomainDiskDefParse; +virDomainDiskDefParseSource; virDomainDiskDetectZeroesTypeFromString; virDomainDiskDetectZeroesTypeToString; virDomainDiskDeviceTypeToString; --=20 2.30.2 From nobody Fri May 17 11:28:43 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=1618587451; cv=none; d=zohomail.com; s=zohoarc; b=CapvBZeQ4tIYFrBI3fKEU46NcylCUJkbgILDHWxQfhbGZXtEFuIQg37cxpGjUakz6rVMgK4orqUjISWQRCl1L4+1ljxIEeZwZeUMzd3RmbP3oAYFdI+UGUU433gDSD3NjO8zlOhuR5ehFZCHSiFyqMUay+VTOGIQU9uysmyLU8E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618587451; 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=brbEs3hTqLUUtNwudRBs1zxizhraxstWRsbUDicbTCk=; b=QYjQkNmb1HpzxYUmHperRGb3ixEVGUL0PZ6i+5zg4IQqsj37aaCOZv8R3ZytwemW4nzI3Hv74VXn0xtPtbPSX426DiKhgxFDzHXuxzZYYiRVIoFxWSUDWkB4vnojR0AWWhwIXDMGrceOdJ0giU1irF+Yf9Ie4yFOuspSmu8X3wo= 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 161858745104971.40445141556688; Fri, 16 Apr 2021 08:37:31 -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-19-ct1sO2IjNgu8tZfkilcB8Q-1; Fri, 16 Apr 2021 11:37:27 -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 9D6EA107ACE3; Fri, 16 Apr 2021 15:37:21 +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 7472D6A967; Fri, 16 Apr 2021 15:37:21 +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 E2F5D4ED7A; Fri, 16 Apr 2021 15:37:20 +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 13GFYruF009243 for ; Fri, 16 Apr 2021 11:34:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 798471C4; Fri, 16 Apr 2021 15:34:53 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id CBBAC5C3DF for ; Fri, 16 Apr 2021 15:34:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618587449; 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=brbEs3hTqLUUtNwudRBs1zxizhraxstWRsbUDicbTCk=; b=N1sJqQTUa62PLgLLAnB/2vV/jdf/3DBmFToFg1RNnr8+/iGMin+q685eYPpUl2X8wonmPm UOL3Es2Z6VTaQp9BXMQQpgZh4IhluKEXlQ0eLL+H5WBf/MFGZVvkpDd4ThWaMJYA9Du+H0 4mJV7bVShQBG9+OM2IDEMl3hHlUDGQ8= X-MC-Unique: ct1sO2IjNgu8tZfkilcB8Q-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 04/25] qemu: driver: Use virDomainDiskDefParseSource in qemuDomainBlockCopy Date: Fri, 16 Apr 2021 17:34:22 +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.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" qemuDomainBlockCopy needs just the source portion of the disk but uses the disk parser for it. Since we have a specific function now, refactor the code to avoid having to deal with the unused virDomainDiskDef. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_driver.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 88ee9e5d5e..d908e95ba7 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15273,7 +15273,6 @@ qemuDomainBlockCopy(virDomainPtr dom, const char *d= isk, const char *destxml, unsigned long long bandwidth =3D 0; unsigned int granularity =3D 0; unsigned long long buf_size =3D 0; - virDomainDiskDef *diskdef =3D NULL; virStorageSource *dest =3D NULL; size_t i; @@ -15326,18 +15325,14 @@ qemuDomainBlockCopy(virDomainPtr dom, const char = *disk, const char *destxml, } } - if (!(diskdef =3D virDomainDiskDefParse(destxml, driver->xmlopt, - VIR_DOMAIN_DEF_PARSE_INACTIVE | - VIR_DOMAIN_DEF_PARSE_DISK_SOURCE= ))) + if (!(dest =3D virDomainDiskDefParseSource(destxml, driver->xmlopt, + VIR_DOMAIN_DEF_PARSE_INACTIVE= ))) goto cleanup; - dest =3D g_steal_pointer(&diskdef->src); - ret =3D qemuDomainBlockCopyCommon(vm, dom->conn, disk, dest, bandwidth, granularity, buf_size, flags, false); cleanup: - virDomainDiskDefFree(diskdef); virDomainObjEndAPI(&vm); return ret; } --=20 2.30.2 From nobody Fri May 17 11:28:43 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=1618587512; cv=none; d=zohomail.com; s=zohoarc; b=BR44sW7P8Uj1Ra5rAV8hQGKExCVVuw3pRB+1s+NApWDo5BS8/xxFQAdHQBWUtktcptKgX+jDDyhYbgxrqA+2eWy+oDZlX5v5DOr0S2pjeNnMVfvFMt8zoCRzvmJ/aaOHxXOwj1+ULYETJm70JvwoiFNQKYhdtD2sq0kYf8ph4CQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618587512; 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=d3cYQ1hOdwb5myWV+uSgIDZOFYimW6fa1QoCfYtrSbY=; b=Tky6V7h7SKkXM4p8jNzJMTL8jQVnP1JCEEpmLiPqEJSyiQ7fGsXL1t95tdwuN9eBANsk+c76q7erJTe0/uztjjY7368oEjpAIL7nEEvmHaZFf1UwCtEvXhdUZ3sT3WQCX0oW7RSByHw9bB3RjZSSoGC1MB/ybHdRUwhvHhWyvh0= 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 161858751238429.11797560497064; Fri, 16 Apr 2021 08:38:32 -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-257-5iMlYoyXMi2RjbCYPmC2RA-1; Fri, 16 Apr 2021 11:38:28 -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 DE519108BD06; Fri, 16 Apr 2021 15:38:22 +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 C0EF213470; Fri, 16 Apr 2021 15:38:22 +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 886C01806D17; Fri, 16 Apr 2021 15:38:22 +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 13GFYsXV009256 for ; Fri, 16 Apr 2021 11:34:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 80EE91C4; Fri, 16 Apr 2021 15:34:54 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id E302D5C3DF for ; Fri, 16 Apr 2021 15:34:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618587511; 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=d3cYQ1hOdwb5myWV+uSgIDZOFYimW6fa1QoCfYtrSbY=; b=HxinWZ5pqFqvF59GThtCufBIPXI1F/1c5ehJNIZ4C5YIXD3NqV3LjTDRm9PUGjG1wdD0ob l8dsgewvt7tMnqR/t2EOkaV5lvCP9wVUi3jp7yT5WwB6pLaVeIQFIBhmJKuJPVQVZtrxW/ 8tRTzpdH92WHida5Vbx2CTW1RQn1IDA= X-MC-Unique: 5iMlYoyXMi2RjbCYPmC2RA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 05/25] conf: domain: Introduce an internal variant of virDomainDiskDefNew Date: Fri, 16 Apr 2021 17:34:23 +0200 Message-Id: <4edd7fbf396d6e4e10db557330b89dfcaef1e054.1618587222.git.pkrempa@redhat.com> 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" The XML element parser is going to be modified so that the virStorageSource bits are pre-parsed. Add virDomainDiskDefNewSource, which uses an existing 'src' pointer. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 57cad6ffde..f59d17930b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2230,25 +2230,32 @@ virDomainDefGetVcpusTopology(const virDomainDef *de= f, } -virDomainDiskDef * -virDomainDiskDefNew(virDomainXMLOption *xmlopt) +static virDomainDiskDef * +virDomainDiskDefNewSource(virDomainXMLOption *xmlopt, + virStorageSource **src) { + void *privateData =3D NULL; virDomainDiskDef *ret; - ret =3D g_new0(virDomainDiskDef, 1); - - ret->src =3D virStorageSourceNew(); - if (xmlopt && xmlopt->privateData.diskNew && - !(ret->privateData =3D xmlopt->privateData.diskNew())) - goto error; + !(privateData =3D xmlopt->privateData.diskNew())) + return NULL; + + ret =3D g_new0(virDomainDiskDef, 1); + ret->src =3D g_steal_pointer(src); + ret->privateData =3D privateData; return ret; +} - error: - virDomainDiskDefFree(ret); - return NULL; + +virDomainDiskDef * +virDomainDiskDefNew(virDomainXMLOption *xmlopt) +{ + g_autoptr(virStorageSource) src =3D virStorageSourceNew(); + + return virDomainDiskDefNewSource(xmlopt, &src); } --=20 2.30.2 From nobody Fri May 17 11:28:43 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=1618587570; cv=none; d=zohomail.com; s=zohoarc; b=myjlG2CdTV6o7t+GqXD8558H3+IvEpYgq17sicsMj2Dry+blK5eKWPSJrhSxDubMnRAQRDleNBT7DJ/QnnvAZEKU3c7gyNa5OOikSblkOlIihpeidpEP0x2lAVSqGSiu5azcZFTCznf3adxf8YGpWkGgddcjPitOl9PSM+9LAO4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618587570; 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=16Gm0ODHiAQ+IauuHm/ilbdVjxCBkAoyUnRmF3sj4wQ=; b=a0bHmXsiSk6AsT60s5tkBjmac2wuWZcTuniX5NPWYNokogno8Ge4pLCE83NW0TheO5ZZNP86V7mnf9uAyQReTcn9OpF4MjWlnWmb01PDWBldHW5EV9YOGYiK9KSm0cgvpYGjuc2UCbRSJiHcrohJowrYTP3jmCdJCuvFTvWnmfA= 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 1618587570012986.9509281575891; Fri, 16 Apr 2021 08:39:30 -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-228-ss69e6I4NmKe45LT-OtrXQ-1; Fri, 16 Apr 2021 11:39:26 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A979784BA43; Fri, 16 Apr 2021 15:39:21 +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 865C85D9C6; Fri, 16 Apr 2021 15:39:21 +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 4BD0E44A63; Fri, 16 Apr 2021 15:39:21 +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 13GFYttU009264 for ; Fri, 16 Apr 2021 11:34:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9474B5C3DF; Fri, 16 Apr 2021 15:34:55 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id E68BE5C6BD for ; Fri, 16 Apr 2021 15:34:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618587568; 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=16Gm0ODHiAQ+IauuHm/ilbdVjxCBkAoyUnRmF3sj4wQ=; b=dZ6KAAotb7xZ02frjw0DMQbi6Dr2r0m1LNBxd3Ynp5LHj0ynZNdUq5bfgQHTsGV675zOqn ERrKiFtX1SNAikYDMMzAqCRO26W/2tdpXA72OURZxPJHYCOSYLNBpiuwJaecFuiKP0RwKy j8DhbWoqFtFj8cYY8dv3nqAXlYcoQY8= X-MC-Unique: ss69e6I4NmKe45LT-OtrXQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 06/25] conf: domain: Split out source validation part from virDomainDiskDefParseValidate Date: Fri, 16 Apr 2021 17:34:24 +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.14 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" Separate the validation of the source so that it can be reused once we split up the XML parser too. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 82 +++++++++++++++++++++++------------------- 1 file changed, 46 insertions(+), 36 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f59d17930b..0eec4c9356 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9045,29 +9045,55 @@ virDomainDiskDefGeometryParse(virDomainDiskDef *def, static int -virDomainDiskSourceDefParseAuthValidate(const virStorageSource *src) +virDomainDiskDefParseValidateSourceChainOne(const virStorageSource *src) { - virStorageAuthDef *authdef =3D src->auth; - int actUsage; + if (src->type =3D=3D VIR_STORAGE_TYPE_NETWORK && src->auth) { + virStorageAuthDef *authdef =3D src->auth; + int actUsage; - if (src->type !=3D VIR_STORAGE_TYPE_NETWORK || !authdef) - return 0; + if ((actUsage =3D virSecretUsageTypeFromString(authdef->secrettype= )) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown secret type '%s'"), + NULLSTR(authdef->secrettype)); + return -1; + } - if ((actUsage =3D virSecretUsageTypeFromString(authdef->secrettype)) <= 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown secret type '%s'"), - NULLSTR(authdef->secrettype)); - return -1; + if ((src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_ISCSI && + actUsage !=3D VIR_SECRET_USAGE_TYPE_ISCSI) || + (src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_RBD && + actUsage !=3D VIR_SECRET_USAGE_TYPE_CEPH)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("invalid secret type '%s'"), + virSecretUsageTypeToString(actUsage)); + return -1; + } } - if ((src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_ISCSI && - actUsage !=3D VIR_SECRET_USAGE_TYPE_ISCSI) || - (src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_RBD && - actUsage !=3D VIR_SECRET_USAGE_TYPE_CEPH)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("invalid secret type '%s'"), - virSecretUsageTypeToString(actUsage)); - return -1; + if (src->encryption) { + virStorageEncryption *encryption =3D src->encryption; + + if (encryption->format =3D=3D VIR_STORAGE_ENCRYPTION_FORMAT_LUKS && + encryption->encinfo.cipher_name) { + + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("supplying for domain disk definitio= n " + "is unnecessary")); + return -1; + } + } + + return 0; +} + + +static int +virDomainDiskDefParseValidateSource(const virStorageSource *src) +{ + const virStorageSource *next; + + for (next =3D src; next; next =3D next->backingStore) { + if (virDomainDiskDefParseValidateSourceChainOne(next) < 0) + return -1; } return 0; @@ -9078,7 +9104,8 @@ static int virDomainDiskDefParseValidate(const virDomainDiskDef *def) { - virStorageSource *next; + if (virDomainDiskDefParseValidateSource(def->src) < 0) + return -1; if (def->bus !=3D VIR_DOMAIN_DISK_BUS_VIRTIO) { if (def->event_idx !=3D VIR_TRISTATE_SWITCH_ABSENT) { @@ -9150,23 +9177,6 @@ virDomainDiskDefParseValidate(const virDomainDiskDef= *def) } } - for (next =3D def->src; next; next =3D next->backingStore) { - if (virDomainDiskSourceDefParseAuthValidate(next) < 0) - return -1; - - if (next->encryption) { - virStorageEncryption *encryption =3D next->encryption; - - if (encryption->format =3D=3D VIR_STORAGE_ENCRYPTION_FORMAT_LU= KS && - encryption->encinfo.cipher_name) { - - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("supplying for domain disk defin= ition " - "is unnecessary")); - return -1; - } - } - } return 0; } --=20 2.30.2 From nobody Fri May 17 11:28:43 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=1618587515; cv=none; d=zohomail.com; s=zohoarc; b=PXTEkI4/7oDLhUtaMOSxOdhQdJiW8/g9LNWuTIe7fOop+WhQzoxy0uMw6S+UXJYQqksWiIpEUtJ2igXENmf2KmKuSZYjy0dny+oLgys6BPt/RPB/8C6PdUFVL9BLG44bnc1Y9V1rdWPgaBkpn2H3SahQT+Xz41dXjtGiRVbNjQ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618587515; 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=NwQ4Wl4w+ow5+yRhlidYt8dNhTp5Ht45q9fhb5F+Vs0=; b=nl9eWfQcsPSz45ea6JRJJEaDuu+4Lo72IS31k4ox4CocPkuyqdHVRVoZZ+AYF7hmsmvUEqGUR8E4+ui1N20VcBayYRDHh3J55IMh4lspV4gGHozI67CK2gOA06iS0Kt/om0PmeVxhrZlLYmaSoQqdb+I7gyqiEeYDs7QBBDm2NM= 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 1618587515141803.012101517119; Fri, 16 Apr 2021 08:38:35 -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-569-VAzJ7qgrOUqN9vKERqsQdw-1; Fri, 16 Apr 2021 11:38:31 -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 A9BEA1008065; Fri, 16 Apr 2021 15:38:25 +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 7F22319701; Fri, 16 Apr 2021 15:38:25 +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 4A4E2180B654; Fri, 16 Apr 2021 15:38:25 +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 13GFYuFt009270 for ; Fri, 16 Apr 2021 11:34:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9B9221C4; Fri, 16 Apr 2021 15:34:56 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0BF8A5C3DF for ; Fri, 16 Apr 2021 15:34:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618587514; 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=NwQ4Wl4w+ow5+yRhlidYt8dNhTp5Ht45q9fhb5F+Vs0=; b=EtCPumO5C2HvLktz8sjPauJ+2PNogQdI/cmVH+r1B+gi2mmTem0epIJSfhH+3ae1gYVlAQ nzT32zjcqZPtMnmAyyKG8sYgsAukZF+13W9h+noeLfOmtpO53ggEqx2zIqe3RIOHB3Az9D lQ2Oz5VeZkQA6JkWutJoJhn2NJJAXAA= X-MC-Unique: VAzJ7qgrOUqN9vKERqsQdw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 07/25] conf: domain: Split out parsing of source data from XML parser Date: Fri, 16 Apr 2021 17:34:25 +0200 Message-Id: <9f2d0a7917f9c00d79f790d284fdd5b359cdea3a.1618587222.git.pkrempa@redhat.com> 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.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" Extract all code related to parsing data which ends up in the 'src' member of a virDomainDiskDef. This allows to use the new function directly in virDomainDiskDefParseSource and removes the use of the VIR_DOMAIN_DEF_PARSE_DISK_SOURCE parser flag. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 185 ++++++++++++++++++++++------------------- 1 file changed, 100 insertions(+), 85 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 0eec4c9356..1793032301 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9341,6 +9341,86 @@ virDomainDiskDefParsePrivateData(xmlXPathContextPtr = ctxt, } +static virStorageSource * +virDomainDiskDefParseSourceXML(virDomainXMLOption *xmlopt, + xmlNodePtr node, + xmlXPathContextPtr ctxt, + unsigned int flags) +{ + g_autoptr(virStorageSource) src =3D virStorageSourceNew(); + VIR_XPATH_NODE_AUTORESTORE(ctxt) + g_autofree char *type =3D NULL; + xmlNodePtr tmp; + + ctxt->node =3D node; + + src->type =3D VIR_STORAGE_TYPE_FILE; + + if ((type =3D virXMLPropString(node, "type")) && + (src->type =3D virStorageTypeFromString(type)) <=3D 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown disk type '%s'"), type); + return NULL; + } + + if ((tmp =3D virXPathNode("./source[1]", ctxt))) { + if (virDomainStorageSourceParse(tmp, ctxt, src, flags, xmlopt) < 0) + return NULL; + + if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) { + g_autofree char *sourceindex =3D NULL; + + if ((sourceindex =3D virXMLPropString(tmp, "index")) && + virStrToLong_uip(sourceindex, NULL, 10, &src->id) < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("invalid disk index '%s'"), sourceindex); + return NULL; + } + } + } else { + /* Reset src->type in case when 'source' was not present */ + src->type =3D VIR_STORAGE_TYPE_FILE; + } + + if (virXPathNode("./readonly[1]", ctxt)) + src->readonly =3D true; + + if (virXPathNode("./shareable[1]", ctxt)) + src->shared =3D true; + + if ((tmp =3D virXPathNode("./auth", ctxt))) { + /* If we've already parsed and found an child, + * then generate an error to avoid ambiguity */ + if (src->auth) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("an definition already found for disk = source")); + return NULL; + } + + if (!(src->auth =3D virStorageAuthDefParse(tmp, ctxt))) + return NULL; + } + + if ((tmp =3D virXPathNode("./encryption", ctxt))) { + /* If we've already parsed and found an chil= d, + * then generate an error to avoid ambiguity */ + if (src->encryption) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("an definition already found for= disk source")); + return NULL; + } + + if (!(src->encryption =3D virStorageEncryptionParseNode(tmp, ctxt)= )) + return NULL; + } + + if (virDomainDiskBackingStoreParse(ctxt, src, flags, xmlopt) < 0) + return NULL; + + return g_steal_pointer(&src); +} + + static virDomainDiskDef * virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, xmlNodePtr node, @@ -9351,8 +9431,6 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, xmlNodePtr cur; VIR_XPATH_NODE_AUTORESTORE(ctxt) bool source =3D false; - g_autoptr(virStorageEncryption) encryption =3D NULL; - g_autoptr(virStorageAuthDef) authdef =3D NULL; g_autofree char *tmp =3D NULL; g_autofree char *snapshot =3D NULL; g_autofree char *rawio =3D NULL; @@ -9368,24 +9446,19 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, g_autofree char *product =3D NULL; g_autofree char *domain_name =3D NULL; g_autofree char *rotation_rate =3D NULL; + g_autoptr(virStorageSource) src =3D NULL; + + if (!(src =3D virDomainDiskDefParseSourceXML(xmlopt, node, ctxt, flags= ))) + return NULL; - if (!(def =3D virDomainDiskDefNew(xmlopt))) + if (!(def =3D virDomainDiskDefNewSource(xmlopt, &src))) return NULL; ctxt->node =3D node; /* defaults */ - def->src->type =3D VIR_STORAGE_TYPE_FILE; def->device =3D VIR_DOMAIN_DISK_DEVICE_DISK; - if ((tmp =3D virXMLPropString(node, "type")) && - (def->src->type =3D virStorageTypeFromString(tmp)) <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown disk type '%s'"), tmp); - return NULL; - } - VIR_FREE(tmp); - if ((tmp =3D virXMLPropString(node, "device")) && (def->device =3D virDomainDiskDeviceTypeFromString(tmp)) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -9412,9 +9485,6 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, continue; if (!source && virXMLNodeNameEqual(cur, "source")) { - if (virDomainStorageSourceParse(cur, ctxt, def->src, flags, xm= lopt) < 0) - return NULL; - source =3D true; if (virXMLPropEnum(cur, "startupPolicy", @@ -9423,13 +9493,6 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, &def->startupPolicy) < 0) return NULL; - if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) && - (tmp =3D virXMLPropString(cur, "index")) && - virStrToLong_uip(tmp, NULL, 10, &def->src->id) < 0) { - virReportError(VIR_ERR_XML_ERROR, _("invalid disk index '%= s'"), tmp); - return NULL; - } - VIR_FREE(tmp); } else if (!target && virXMLNodeNameEqual(cur, "target")) { target =3D virXMLPropString(cur, "dev"); @@ -9484,27 +9547,15 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, !(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) { if (virDomainDiskDefMirrorParse(def, cur, ctxt, flags, xmlopt)= < 0) return NULL; - } else if (!authdef && - virXMLNodeNameEqual(cur, "auth")) { - if (!(authdef =3D virStorageAuthDefParse(cur, ctxt))) - return NULL; + } else if (virXMLNodeNameEqual(cur, "auth")) { def->diskElementAuth =3D true; } else if (virXMLNodeNameEqual(cur, "iotune")) { if (virDomainDiskDefIotuneParse(def, ctxt) < 0) return NULL; - } else if (virXMLNodeNameEqual(cur, "readonly")) { - def->src->readonly =3D true; - } else if (virXMLNodeNameEqual(cur, "shareable")) { - def->src->shared =3D true; } else if (virXMLNodeNameEqual(cur, "transient")) { def->transient =3D true; - } else if (!encryption && - virXMLNodeNameEqual(cur, "encryption")) { - if (!(encryption =3D virStorageEncryptionParseNode(cur, ctxt))) - return NULL; - + } else if (virXMLNodeNameEqual(cur, "encryption")) { def->diskElementEnc =3D true; - } else if (!serial && virXMLNodeNameEqual(cur, "serial")) { if (!(serial =3D virXMLNodeContentString(cur))) @@ -9548,10 +9599,6 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, } } - /* Reset def->src->type in case when 'source' was not present */ - if (!source) - def->src->type =3D VIR_STORAGE_TYPE_FILE; - /* Only CDROM and Floppy devices are allowed missing source path * to indicate no media present. LUN is for raw access CD-ROMs * that are not attached to a physical device presently */ @@ -9676,40 +9723,12 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, } def->dst =3D g_steal_pointer(&target); - if (authdef) { - /* If we've already parsed and found an child, - * then generate an error to avoid ambiguity */ - if (def->src->auth) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("an definition already found for " - "disk source")); - return NULL; - } - - def->src->auth =3D g_steal_pointer(&authdef); - } - - if (encryption) { - /* If we've already parsed and found an = child, - * then generate an error to avoid ambiguity */ - if (def->src->encryption) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("an definition already found= for " - "disk source")); - return NULL; - } - - def->src->encryption =3D g_steal_pointer(&encryption); - } def->domain_name =3D g_steal_pointer(&domain_name); def->serial =3D g_steal_pointer(&serial); def->wwn =3D g_steal_pointer(&wwn); def->vendor =3D g_steal_pointer(&vendor); def->product =3D g_steal_pointer(&product); - if (virDomainDiskBackingStoreParse(ctxt, def->src, flags, xmlopt) < 0) - return NULL; - if (flags & VIR_DOMAIN_DEF_PARSE_STATUS && virDomainDiskDefParsePrivateData(ctxt, def, xmlopt) < 0) return NULL; @@ -9721,22 +9740,6 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, } -static virStorageSource * -virDomainDiskDefParseSourceXML(virDomainXMLOption *xmlopt, - xmlNodePtr node, - xmlXPathContextPtr ctxt, - unsigned int flags) -{ - g_autoptr(virDomainDiskDef) diskdef =3D NULL; - - if (!(diskdef =3D virDomainDiskDefParseXML(xmlopt, node, ctxt, - flags | VIR_DOMAIN_DEF_PARSE_= DISK_SOURCE))) - return NULL; - - return g_steal_pointer(&diskdef->src); -} - - /** * virDomainParseMemory: * @xpath: XPath to memory amount @@ -16484,11 +16487,23 @@ virDomainDiskDefParseSource(const char *xmlStr, { g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; + g_autoptr(virStorageSource) src =3D NULL; if (!(xml =3D virXMLParseStringCtxtRoot(xmlStr, _("(disk_definition)")= , "disk", &ctxt))) return NULL; - return virDomainDiskDefParseSourceXML(xmlopt, ctxt->node, ctxt, flags); + if (!(src =3D virDomainDiskDefParseSourceXML(xmlopt, ctxt->node, ctxt,= flags))) + return NULL; + + if (virStorageSourceIsEmpty(src)) { + virReportError(VIR_ERR_NO_SOURCE, NULL); + return NULL; + } + + if (virDomainDiskDefParseValidateSource(src) < 0) + return NULL; + + return g_steal_pointer(&src); } --=20 2.30.2 From nobody Fri May 17 11:28:43 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=1618587629; cv=none; d=zohomail.com; s=zohoarc; b=Im4rw65Nk+C7yAqvkwqwV0MbfW7wi8dHzDMLbbV5Pef38oraLS2zXD/G0+bquI1mfBQHuAO66QYtdQ2X9XZJbll8K63+IRm3Bduq0bQGw5dl+QsEy9jkRqC0M6kR6KsYhbPkZPkdIsVDPLc24wvfgO/jPedpEIfAAoZNiLmnkbs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618587629; 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=f9kuqdjQSoQi4toJ+w1V57l1Qw0APcapNRwV32EMtvs=; b=eqIpxSmuBadXrmBxm9/XLL24HVcdg3r2lRVcVlv6G6dJbg53tSFpeZQe6FQOkgjLSMiXPEIvxmdzjlIYc49SYcLykbu93yv//zwIMfDdDgkz35H4v/lhAChWLe/FOji0pazNu7UqyRihcNNRNvCwMN3uvMo8wpDKMxR/jp8imPc= 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 161858762932284.33262533771267; Fri, 16 Apr 2021 08:40:29 -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-44-08FbFdtoMNWIIpcrSHUWUQ-1; Fri, 16 Apr 2021 11:38:33 -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 8C3B5107ACF5; Fri, 16 Apr 2021 15:38:28 +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 6B5A96E6F9; Fri, 16 Apr 2021 15:38:28 +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 271EA44A5F; Fri, 16 Apr 2021 15:38:28 +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 13GFYvks009284 for ; Fri, 16 Apr 2021 11:34:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id A744B1C4; Fri, 16 Apr 2021 15:34:57 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 147A45C3DF for ; Fri, 16 Apr 2021 15:34:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618587627; 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=f9kuqdjQSoQi4toJ+w1V57l1Qw0APcapNRwV32EMtvs=; b=D/E2YhxWjW5s2MeVpEjvBM4EtIXo6D23xiHFOeDss8yYCcgA93rpxuABayJF1wpzwldZCK cy/wuuqYuFp/jfvGnDG5WZnlqVK9oTt3vdpUlJQR43ID3+12p//J0qiTKwfSfI3q+iKfNb iEXXP1xxuOvkqsnd9F28Jt8jTFop0W0= X-MC-Unique: 08FbFdtoMNWIIpcrSHUWUQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 08/25] conf: domain: Remove VIR_DOMAIN_DEF_PARSE_DISK_SOURCE parser flag Date: Fri, 16 Apr 2021 17:34:26 +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" There's no code which would assert it at this point. Remove the flag. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 47 ++++++++++++++++++++---------------------- src/conf/domain_conf.h | 14 ++++++------- 2 files changed, 28 insertions(+), 33 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 1793032301..3f32e046f3 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9603,14 +9603,13 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, * to indicate no media present. LUN is for raw access CD-ROMs * that are not attached to a physical device presently */ if (virStorageSourceIsEmpty(def->src) && - (def->device =3D=3D VIR_DOMAIN_DISK_DEVICE_DISK || - (flags & VIR_DOMAIN_DEF_PARSE_DISK_SOURCE))) { + def->device =3D=3D VIR_DOMAIN_DISK_DEVICE_DISK) { virReportError(VIR_ERR_NO_SOURCE, target ? "%s" : NULL, target); return NULL; } - if (!target && !(flags & VIR_DOMAIN_DEF_PARSE_DISK_SOURCE)) { + if (!target) { if (def->src->srcpool) { tmp =3D g_strdup_printf("pool =3D '%s', volume =3D '%s'", def->src->srcpool->pool, def->src->srcpo= ol->volume); @@ -9623,29 +9622,27 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, return NULL; } - if (!(flags & VIR_DOMAIN_DEF_PARSE_DISK_SOURCE)) { - if (def->device =3D=3D VIR_DOMAIN_DISK_DEVICE_FLOPPY && - !STRPREFIX(target, "fd")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid floppy device name: %s"), target); - return NULL; - } + if (def->device =3D=3D VIR_DOMAIN_DISK_DEVICE_FLOPPY && + !STRPREFIX(target, "fd")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid floppy device name: %s"), target); + return NULL; + } - /* Force CDROM to be listed as read only */ - if (def->device =3D=3D VIR_DOMAIN_DISK_DEVICE_CDROM) - def->src->readonly =3D true; + /* Force CDROM to be listed as read only */ + if (def->device =3D=3D VIR_DOMAIN_DISK_DEVICE_CDROM) + def->src->readonly =3D true; - if ((def->device =3D=3D VIR_DOMAIN_DISK_DEVICE_DISK || - def->device =3D=3D VIR_DOMAIN_DISK_DEVICE_LUN) && - !STRPREFIX((const char *)target, "hd") && - !STRPREFIX((const char *)target, "sd") && - !STRPREFIX((const char *)target, "vd") && - !STRPREFIX((const char *)target, "xvd") && - !STRPREFIX((const char *)target, "ubd")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid harddisk device name: %s"), target); - return NULL; - } + if ((def->device =3D=3D VIR_DOMAIN_DISK_DEVICE_DISK || + def->device =3D=3D VIR_DOMAIN_DISK_DEVICE_LUN) && + !STRPREFIX((const char *)target, "hd") && + !STRPREFIX((const char *)target, "sd") && + !STRPREFIX((const char *)target, "vd") && + !STRPREFIX((const char *)target, "xvd") && + !STRPREFIX((const char *)target, "ubd")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid harddisk device name: %s"), target); + return NULL; } if (snapshot) { @@ -9686,7 +9683,7 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, } else { if (def->device =3D=3D VIR_DOMAIN_DISK_DEVICE_FLOPPY) { def->bus =3D VIR_DOMAIN_DISK_BUS_FDC; - } else if (!(flags & VIR_DOMAIN_DEF_PARSE_DISK_SOURCE)) { + } else { if (STRPREFIX(target, "hd")) def->bus =3D VIR_DOMAIN_DISK_BUS_IDE; else if (STRPREFIX(target, "sd")) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 83b9288941..1a2e0fc872 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3353,25 +3353,23 @@ typedef enum { VIR_DOMAIN_DEF_PARSE_ALLOW_ROM =3D 1 << 4, /* internal flag passed to device info sub-parser to allow specifying = boot order */ VIR_DOMAIN_DEF_PARSE_ALLOW_BOOT =3D 1 << 5, - /* parse only source half of */ - VIR_DOMAIN_DEF_PARSE_DISK_SOURCE =3D 1 << 6, /* perform RNG schema validation on the passed XML document */ - VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA =3D 1 << 7, + VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA =3D 1 << 6, /* allow updates in post parse callback that would break ABI otherwise= */ - VIR_DOMAIN_DEF_PARSE_ABI_UPDATE =3D 1 << 8, + VIR_DOMAIN_DEF_PARSE_ABI_UPDATE =3D 1 << 7, /* skip definition validation checks meant to be executed on define ti= me only */ - VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE =3D 1 << 9, + VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE =3D 1 << 8, /* skip parsing of security labels */ - VIR_DOMAIN_DEF_PARSE_SKIP_SECLABEL =3D 1 << 10, + VIR_DOMAIN_DEF_PARSE_SKIP_SECLABEL =3D 1 << 9, /* Allows updates in post parse callback for incoming persistent migra= tion * that would break ABI otherwise. This should be used only if it's s= afe * to do such change. */ - VIR_DOMAIN_DEF_PARSE_ABI_UPDATE_MIGRATION =3D 1 << 11, + VIR_DOMAIN_DEF_PARSE_ABI_UPDATE_MIGRATION =3D 1 << 10, /* Allows to ignore certain failures in the post parse callbacks, which * may happen due to missing packages and can be fixed by re-running t= he * post parse callbacks before starting. Failure of the post parse cal= lback * is recorded as def->postParseFail */ - VIR_DOMAIN_DEF_PARSE_ALLOW_POST_PARSE_FAIL =3D 1 << 12, + VIR_DOMAIN_DEF_PARSE_ALLOW_POST_PARSE_FAIL =3D 1 << 11, } virDomainDefParseFlags; typedef enum { --=20 2.30.2 From nobody Fri May 17 11:28:43 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=1618587520; cv=none; d=zohomail.com; s=zohoarc; b=nQiyWRo3FgndKM/VlpA2y2Sp3gyEV/1rr4gq7ywMSUfsgPBQiOfIXoOJVTGhrGelLnOU2TwJy+ztBkl1yBwFCLcGVxYsJVYXu4NHEG7HAWy+xWDN80x7dOPbbExgp8uA5olhjcGQH3xVhSRTR+TVnBnAVVL4MUEP/1064evPpMA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618587520; 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=9FOTQ41AHC6ucdxxOcfIehy4XgXLGMyr3PrXnI3udh8=; b=lMPRNhHnMmfcrwXgblV4JjgYcahTykKtjbRlQC/vIubygWiHv4vyFegAj3+DLo+3mYVUB2xkRIN9ucirpoj1LNdXfc/eiRUcGa6kpzgclke88oQQ4w2IpYCihh+TqB00H2r4dba2Q6wXqZKgIu15TEPw7krVaR1wkzy9ViBng6s= 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 1618587520534260.608313529926; Fri, 16 Apr 2021 08:38:40 -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-40-xwkdU1dpNIq_gPnLoo2DMA-1; Fri, 16 Apr 2021 11:38:36 -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 7481D18B9FA9; Fri, 16 Apr 2021 15:38:31 +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 4DF976E703; Fri, 16 Apr 2021 15:38:31 +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 1220544A62; Fri, 16 Apr 2021 15:38:31 +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 13GFYwPO009297 for ; Fri, 16 Apr 2021 11:34:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id C20E31C4; Fri, 16 Apr 2021 15:34:58 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 19FD85C3DF for ; Fri, 16 Apr 2021 15:34:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618587519; 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=9FOTQ41AHC6ucdxxOcfIehy4XgXLGMyr3PrXnI3udh8=; b=WWAGbAwmVUjb7HB48fO3hENkstby+ytMIMzj08BPbkBuI0wpEHr/ay3aPgNgnZ577x6hF8 54NoHeZOnvat2JssHREFwdIwV2mlw3B6wOeuUuMrUSIgHkw3Z+73pBoeEPBWrkbmO+FIiF ZqwiBMwn5qHspC25+UJAy4lGiwcq4U0= X-MC-Unique: xwkdU1dpNIq_gPnLoo2DMA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 09/25] virDomainDiskDefValidate: Consolidate conditions Date: Fri, 16 Apr 2021 17:34:27 +0200 Message-Id: <1863e52e6fd6ea373462ff624573e51775d2280c.1618587222.git.pkrempa@redhat.com> 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" Consolidate the checks for '' and viritio queues under already existing blocks which have the same condition. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/conf/domain_validate.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 570279cd92..4d253599af 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -451,13 +451,12 @@ virDomainDiskDefValidate(const virDomainDef *def, "device=3D'lun'"), disk->dst); return -1; } - } - - if (disk->src->pr && - disk->device !=3D VIR_DOMAIN_DISK_DEVICE_LUN) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _(" allowed only for lun devices")); - return -1; + } else { + if (disk->src->pr) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _(" allowed only for lun devices= ")); + return -1; + } } /* Reject disks with a bus type that is not compatible with the @@ -474,13 +473,6 @@ virDomainDiskDefValidate(const virDomainDef *def, return -1; } - if (disk->queues && disk->bus !=3D VIR_DOMAIN_DISK_BUS_VIRTIO) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("queues attribute in disk driver element is only " - "supported by virtio-blk")); - return -1; - } - if (disk->bus !=3D VIR_DOMAIN_DISK_BUS_VIRTIO) { if (disk->model =3D=3D VIR_DOMAIN_DISK_MODEL_VIRTIO || disk->model =3D=3D VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL || @@ -492,6 +484,12 @@ virDomainDiskDefValidate(const virDomainDef *def, return -1; } + if (disk->queues) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("queues attribute in disk driver element is o= nly supported by virtio-blk")); + return -1; + } + if (virDomainCheckVirtioOptionsAreAbsent(disk->virtio) < 0) return -1; } --=20 2.30.2 From nobody Fri May 17 11:28:43 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=1618587575; cv=none; d=zohomail.com; s=zohoarc; b=cLxn2pUdeRDUguCZZGJUBQDE1zOAQTLK4mqQ4cVQYhA77FOgDABq+kAnOgC5R82lDxx4WcBBH87XbfefQswUlYnz8lkGrW/fbytbQQBwCNFS18JlXn5SHfZV58+5KOUSgkJfDVUGwnQtuMRaF+6UvcvahFY4XDw5Pb/a1KL6lMI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618587575; 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=ChKVSVfwBPl/AZec1sgGF4JuPx20pAqz0/FAip3H/2g=; b=cNn95hsR4/nIzssXQdQV63pNmp7PPVtk06SfCrl2EqzEVL/bc0Eed8P6YShwezocidGJxUneI0p+fJ9tpp+Gn3PpV429IHJ+VNBTDjrtFNoAho4z8GMSQ8rzA73yJEB963XdCLrjPP0DeankA+SOVANRidNAwGgxhrNbTU0mNls= 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 1618587575445950.8350989595733; Fri, 16 Apr 2021 08:39:35 -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-372-cppbq7YQO2ejpy_KwPLK_Q-1; Fri, 16 Apr 2021 11:39:29 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6936C1008065; Fri, 16 Apr 2021 15:39:24 +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 494975DAA5; Fri, 16 Apr 2021 15:39:24 +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 0FDDE44A66; Fri, 16 Apr 2021 15:39:24 +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 13GFYxvh009305 for ; Fri, 16 Apr 2021 11:34:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id ECF1B5C3DF; Fri, 16 Apr 2021 15:34:59 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 47C025C6BD for ; Fri, 16 Apr 2021 15:34:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618587574; 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=ChKVSVfwBPl/AZec1sgGF4JuPx20pAqz0/FAip3H/2g=; b=eHBsJuQKxVyt08a9njZt6033Axn6vxk0pVzzweZdnGgQaPYdSuW4jGqjLUfD9rwqrnEEKe WXuZuqVvTJ+ZG2D2EQCYz/M5pHiicNPIb5lZpzDXl2JDLP0CaI28/qpm8l32/7ijmDrmFk UYdherZIvUtb+1wvhwa9FpJ/fxK8zO0= X-MC-Unique: cppbq7YQO2ejpy_KwPLK_Q-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 10/25] conf: Move code from virDomainDiskDefParseValidate to virDomainDiskDefValidate Date: Fri, 16 Apr 2021 17:34:28 +0200 Message-Id: <57013829eb90e3ea50fbd8850d7e9f6f52774129.1618587222.git.pkrempa@redhat.com> 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.14 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" Unify the two distinct disk definition validators. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 143 +------------------------------------ src/conf/domain_validate.c | 125 ++++++++++++++++++++++++++++++++ src/conf/domain_validate.h | 2 + 3 files changed, 128 insertions(+), 142 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3f32e046f3..c8c0476a42 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9044,144 +9044,6 @@ virDomainDiskDefGeometryParse(virDomainDiskDef *def, } -static int -virDomainDiskDefParseValidateSourceChainOne(const virStorageSource *src) -{ - if (src->type =3D=3D VIR_STORAGE_TYPE_NETWORK && src->auth) { - virStorageAuthDef *authdef =3D src->auth; - int actUsage; - - if ((actUsage =3D virSecretUsageTypeFromString(authdef->secrettype= )) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown secret type '%s'"), - NULLSTR(authdef->secrettype)); - return -1; - } - - if ((src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_ISCSI && - actUsage !=3D VIR_SECRET_USAGE_TYPE_ISCSI) || - (src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_RBD && - actUsage !=3D VIR_SECRET_USAGE_TYPE_CEPH)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("invalid secret type '%s'"), - virSecretUsageTypeToString(actUsage)); - return -1; - } - } - - if (src->encryption) { - virStorageEncryption *encryption =3D src->encryption; - - if (encryption->format =3D=3D VIR_STORAGE_ENCRYPTION_FORMAT_LUKS && - encryption->encinfo.cipher_name) { - - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("supplying for domain disk definitio= n " - "is unnecessary")); - return -1; - } - } - - return 0; -} - - -static int -virDomainDiskDefParseValidateSource(const virStorageSource *src) -{ - const virStorageSource *next; - - for (next =3D src; next; next =3D next->backingStore) { - if (virDomainDiskDefParseValidateSourceChainOne(next) < 0) - return -1; - } - - return 0; -} - - -static int -virDomainDiskDefParseValidate(const virDomainDiskDef *def) - -{ - if (virDomainDiskDefParseValidateSource(def->src) < 0) - return -1; - - if (def->bus !=3D VIR_DOMAIN_DISK_BUS_VIRTIO) { - if (def->event_idx !=3D VIR_TRISTATE_SWITCH_ABSENT) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("disk event_idx mode supported only for virti= o bus")); - return -1; - } - - if (def->ioeventfd !=3D VIR_TRISTATE_SWITCH_ABSENT) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("disk ioeventfd mode supported only for virti= o bus")); - return -1; - } - } - - if (def->device !=3D VIR_DOMAIN_DISK_DEVICE_LUN) { - if (def->rawio !=3D VIR_TRISTATE_BOOL_ABSENT) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("rawio can be used only with device=3D'lun'")= ); - return -1; - } - - if (def->sgio !=3D VIR_DOMAIN_DEVICE_SGIO_DEFAULT) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("sgio can be used only with device=3D'lun'")); - return -1; - } - } - - if (def->device =3D=3D VIR_DOMAIN_DISK_DEVICE_FLOPPY && - def->bus !=3D VIR_DOMAIN_DISK_BUS_FDC) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid bus type '%s' for floppy disk"), - virDomainDiskBusTypeToString(def->bus)); - return -1; - } - - if (def->device !=3D VIR_DOMAIN_DISK_DEVICE_FLOPPY && - def->bus =3D=3D VIR_DOMAIN_DISK_BUS_FDC) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid bus type '%s' for disk"), - virDomainDiskBusTypeToString(def->bus)); - return -1; - } - - if (def->removable !=3D VIR_TRISTATE_SWITCH_ABSENT && - def->bus !=3D VIR_DOMAIN_DISK_BUS_USB) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("removable is only valid for usb disks")); - return -1; - } - - if (def->startupPolicy !=3D VIR_DOMAIN_STARTUP_POLICY_DEFAULT) { - if (def->src->type =3D=3D VIR_STORAGE_TYPE_NETWORK) { - virReportError(VIR_ERR_XML_ERROR, - _("Setting disk %s is not allowed for " - "disk of network type"), - virDomainStartupPolicyTypeToString(def->startup= Policy)); - return -1; - } - - if (def->device !=3D VIR_DOMAIN_DISK_DEVICE_CDROM && - def->device !=3D VIR_DOMAIN_DISK_DEVICE_FLOPPY && - def->startupPolicy =3D=3D VIR_DOMAIN_STARTUP_POLICY_REQUISITE)= { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Setting disk 'requisite' is allowed only for= " - "cdrom or floppy")); - return -1; - } - } - - - return 0; -} - - static int virDomainDiskDefDriverParseXML(virDomainDiskDef *def, xmlNodePtr cur, @@ -9730,9 +9592,6 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, virDomainDiskDefParsePrivateData(ctxt, def, xmlopt) < 0) return NULL; - if (virDomainDiskDefParseValidate(def) < 0) - return NULL; - return g_steal_pointer(&def); } @@ -16497,7 +16356,7 @@ virDomainDiskDefParseSource(const char *xmlStr, return NULL; } - if (virDomainDiskDefParseValidateSource(src) < 0) + if (virDomainDiskDefValidateSource(src) < 0) return NULL; return g_steal_pointer(&src); diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 4d253599af..97fa218252 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -430,6 +430,62 @@ virDomainDiskVhostUserValidate(const virDomainDiskDef = *disk) } +static int +virDomainDiskDefValidateSourceChainOne(const virStorageSource *src) +{ + if (src->type =3D=3D VIR_STORAGE_TYPE_NETWORK && src->auth) { + virStorageAuthDef *authdef =3D src->auth; + int actUsage; + + if ((actUsage =3D virSecretUsageTypeFromString(authdef->secrettype= )) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown secret type '%s'"), + NULLSTR(authdef->secrettype)); + return -1; + } + + if ((src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_ISCSI && + actUsage !=3D VIR_SECRET_USAGE_TYPE_ISCSI) || + (src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_RBD && + actUsage !=3D VIR_SECRET_USAGE_TYPE_CEPH)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("invalid secret type '%s'"), + virSecretUsageTypeToString(actUsage)); + return -1; + } + } + + if (src->encryption) { + virStorageEncryption *encryption =3D src->encryption; + + if (encryption->format =3D=3D VIR_STORAGE_ENCRYPTION_FORMAT_LUKS && + encryption->encinfo.cipher_name) { + + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("supplying for domain disk definitio= n " + "is unnecessary")); + return -1; + } + } + + return 0; +} + + +int +virDomainDiskDefValidateSource(const virStorageSource *src) +{ + const virStorageSource *next; + + for (next =3D src; next; next =3D next->backingStore) { + if (virDomainDiskDefValidateSourceChainOne(next) < 0) + return -1; + } + + return 0; +} + + #define VENDOR_LEN 8 #define PRODUCT_LEN 16 @@ -439,6 +495,9 @@ virDomainDiskDefValidate(const virDomainDef *def, { virStorageSource *next; + if (virDomainDiskDefValidateSource(disk->src) < 0) + return -1; + /* Validate LUN configuration */ if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_LUN) { /* volumes haven't been translated at this point, so accept them */ @@ -457,6 +516,18 @@ virDomainDiskDefValidate(const virDomainDef *def, _(" allowed only for lun devices= ")); return -1; } + + if (disk->rawio !=3D VIR_TRISTATE_BOOL_ABSENT) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("rawio can be used only with device=3D'lun'")= ); + return -1; + } + + if (disk->sgio !=3D VIR_DOMAIN_DEVICE_SGIO_DEFAULT) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("sgio can be used only with device=3D'lun'")); + return -1; + } } /* Reject disks with a bus type that is not compatible with the @@ -490,6 +561,18 @@ virDomainDiskDefValidate(const virDomainDef *def, return -1; } + if (disk->event_idx !=3D VIR_TRISTATE_SWITCH_ABSENT) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("disk event_idx mode supported only for virti= o bus")); + return -1; + } + + if (disk->ioeventfd !=3D VIR_TRISTATE_SWITCH_ABSENT) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("disk ioeventfd mode supported only for virti= o bus")); + return -1; + } + if (virDomainCheckVirtioOptionsAreAbsent(disk->virtio) < 0) return -1; } @@ -538,6 +621,48 @@ virDomainDiskDefValidate(const virDomainDef *def, return -1; } + if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_FLOPPY && + disk->bus !=3D VIR_DOMAIN_DISK_BUS_FDC) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid bus type '%s' for floppy disk"), + virDomainDiskBusTypeToString(disk->bus)); + return -1; + } + + if (disk->device !=3D VIR_DOMAIN_DISK_DEVICE_FLOPPY && + disk->bus =3D=3D VIR_DOMAIN_DISK_BUS_FDC) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid bus type '%s' for disk"), + virDomainDiskBusTypeToString(disk->bus)); + return -1; + } + + if (disk->removable !=3D VIR_TRISTATE_SWITCH_ABSENT && + disk->bus !=3D VIR_DOMAIN_DISK_BUS_USB) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("removable is only valid for usb disks")); + return -1; + } + + if (disk->startupPolicy !=3D VIR_DOMAIN_STARTUP_POLICY_DEFAULT) { + if (disk->src->type =3D=3D VIR_STORAGE_TYPE_NETWORK) { + virReportError(VIR_ERR_XML_ERROR, + _("Setting disk %s is not allowed for " + "disk of network type"), + virDomainStartupPolicyTypeToString(disk->startu= pPolicy)); + return -1; + } + + if (disk->device !=3D VIR_DOMAIN_DISK_DEVICE_CDROM && + disk->device !=3D VIR_DOMAIN_DISK_DEVICE_FLOPPY && + disk->startupPolicy =3D=3D VIR_DOMAIN_STARTUP_POLICY_REQUISITE= ) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Setting disk 'requisite' is allowed only for= " + "cdrom or floppy")); + return -1; + } + } + return 0; } diff --git a/src/conf/domain_validate.h b/src/conf/domain_validate.h index 5f31616c85..38a1abcc8f 100644 --- a/src/conf/domain_validate.h +++ b/src/conf/domain_validate.h @@ -38,3 +38,5 @@ int virDomainDeviceDefValidate(const virDomainDeviceDef *= dev, unsigned int parseFlags, virDomainXMLOption *xmlopt, void *parseOpaque); + +int virDomainDiskDefValidateSource(const virStorageSource *src); --=20 2.30.2 From nobody Fri May 17 11:28:43 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=1618587576; cv=none; d=zohomail.com; s=zohoarc; b=ODT8zi9rTCOeNzDIOCv88yEtzJv5ptA+2rvsNZxji4MO+6TwB0jZbffH+nFd7as+ECtcmzEZbqZuBpgkMeCzAoaWbYa0URgpPzz4NcOp2MYK4Hbd8e5BEdE6JGBN543HbA/5/JtdEgXAH0En4py5t90RYNSPcQKIa5O7Ak7If08= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618587576; 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=KE5Jk9w+iHVMwpUnLHQ+GxcgySWqpyycpr9y2NbXT6M=; b=i3gP05CzVlopyag2rVkNE77DnQ0gyaddWG1MjpOW1/4P9vj63MoecCzbbc1xSXLqRsO+G6lu5GIQwFXDgj7DeJobFnAfj2+Jo9YzFPT3NF50FDBGq2ghA3wsysrfuRviXNOIQ0GUyA+YDcdDVRNPhcrUxBYKOm6u1YOhVlgWDYo= 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 1618587576531937.4421429345947; Fri, 16 Apr 2021 08:39:36 -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-213-GA0aErGfOAOZ0jxMz5HKsg-1; Fri, 16 Apr 2021 11:39:33 -0400 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 4F295814256; Fri, 16 Apr 2021 15:39:27 +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 2C10D37DD; Fri, 16 Apr 2021 15:39:27 +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 E9FCD1806D18; Fri, 16 Apr 2021 15:39:26 +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 13GFZ1HY009327 for ; Fri, 16 Apr 2021 11:35:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 03D6C5C3DF; Fri, 16 Apr 2021 15:35:01 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B3125C257 for ; Fri, 16 Apr 2021 15:35:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618587575; 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=KE5Jk9w+iHVMwpUnLHQ+GxcgySWqpyycpr9y2NbXT6M=; b=SP9mdyQtrW7BxJBrWHImJ8q1K7SsM0/RgyZkvKAD9QD5kfh5kZraS+UGNfxbnmhTcX4fI0 CpdGgh9WgOIo6O28Q9EDW57IhJ9QeQ3A4ZtqlCslchuCyN4buA4HF9EjNgD55V0bDtkTPa bVDVuLeGdt0XBaXh2Eq7bi/wxODrFBw= X-MC-Unique: GA0aErGfOAOZ0jxMz5HKsg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 11/25] conf: Move disk vendor and product pritability check to domain_validate Date: Fri, 16 Apr 2021 17:34:29 +0200 Message-Id: <1eaf6a90d33e2d61b88ffaa5410d333f5394cc87.1618587222.git.pkrempa@redhat.com> 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.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" Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 12 ------------ src/conf/domain_validate.c | 37 +++++++++++++++++++++++++++---------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c8c0476a42..0738bf7f1f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9433,22 +9433,10 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, virXMLNodeNameEqual(cur, "vendor")) { if (!(vendor =3D virXMLNodeContentString(cur))) return NULL; - - if (!virStringIsPrintable(vendor)) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("disk vendor is not printable string")); - return NULL; - } } else if (!product && virXMLNodeNameEqual(cur, "product")) { if (!(product =3D virXMLNodeContentString(cur))) return NULL; - - if (!virStringIsPrintable(product)) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("disk product is not printable string")); - return NULL; - } } else if (virXMLNodeNameEqual(cur, "boot")) { /* boot is parsed as part of virDomainDeviceInfoParseXML */ } else if ((flags & VIR_DOMAIN_DEF_PARSE_STATUS) && diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 97fa218252..b2780b3562 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -27,6 +27,7 @@ #include "virconftypes.h" #include "virlog.h" #include "virutil.h" +#include "virstring.h" #define VIR_FROM_THIS VIR_FROM_DOMAIN @@ -607,18 +608,34 @@ virDomainDiskDefValidate(const virDomainDef *def, return -1; } - if (disk->vendor && strlen(disk->vendor) > VENDOR_LEN) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("disk vendor is more than %d characters"), - VENDOR_LEN); - return -1; + if (disk->vendor) { + if (!virStringIsPrintable(disk->vendor)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("disk vendor is not printable string")); + return -1; + } + + if (strlen(disk->vendor) > VENDOR_LEN) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("disk vendor is more than %d characters"), + VENDOR_LEN); + return -1; + } } - if (disk->product && strlen(disk->product) > PRODUCT_LEN) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("disk product is more than %d characters"), - PRODUCT_LEN); - return -1; + if (disk->product) { + if (!virStringIsPrintable(disk->product)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("disk product is not printable string")); + return -1; + } + + if (strlen(disk->product) > PRODUCT_LEN) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("disk product is more than %d characters"), + PRODUCT_LEN); + return -1; + } } if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_FLOPPY && --=20 2.30.2 From nobody Fri May 17 11:28:43 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=1618587457; cv=none; d=zohomail.com; s=zohoarc; b=bJIiSiclQAd+VIkYF1KOqa9h7699ij9M19zUceeQXUAZXmiMKaqyHqLu0w5AO8iPz2wHv7DNXOWSi3U/+7GTUb63g+32Qh0A2MN6dFd2rF1ahatZdEcfPdy3GOjeQmMm2VXTYHhJe53UcOu8bq7S+dhn5+1ZlFhjZ6iBCCtLR40= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618587457; 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=FESxON4LCVE9m9Q/HlERi87bzj0hixFkVXrgZVVDKZg=; b=SzmE4JwFqG9/+Sxp6CZxBkA+YzO/R7YNrW3pEII3/435ccfDt44D/r9wCkhpcmyXO9KSyreYItmfNuMuICFdSjObtnVglzOUMPOhMbL59EVxmE98EVdXjkUN+EGarnh4ExfEUsSR9ihlCuyyvqd/2cwjjoBgOo/hg38B0Sd83xo= 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 1618587457729980.3915805326225; Fri, 16 Apr 2021 08:37:37 -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-80-t6qP5urzM8Kq6BdsxXG-uA-1; Fri, 16 Apr 2021 11:37:33 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 094306D588; Fri, 16 Apr 2021 15:37:29 +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 DBDAC5D9C6; Fri, 16 Apr 2021 15:37:28 +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 9E24044A5F; Fri, 16 Apr 2021 15:37:28 +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 13GFZ2ru009340 for ; Fri, 16 Apr 2021 11:35:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id 15E645C6DE; Fri, 16 Apr 2021 15:35:02 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 71ACB5C3DF for ; Fri, 16 Apr 2021 15:35:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618587456; 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=FESxON4LCVE9m9Q/HlERi87bzj0hixFkVXrgZVVDKZg=; b=b9OdVL9nKgX3wQZVi4ey045Nifu07k/kExV5hKfMI8FfxgUFmv7lDKCTaW9cxRLJuOlszO 6d4O0esnOvYWDYE/wNhWuSGwVuOQr7wYMZuR2tzsalmYOU7KkKgb/aBKrdLLBbn4CTKagl 8JIEaGfnG2D3By9KL8Ca+ez6PeyIhqs= X-MC-Unique: t6qP5urzM8Kq6BdsxXG-uA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 12/25] conf: Move checks from virDomainDiskDefPostParse to virDomainDiskDefValidate Date: Fri, 16 Apr 2021 17:34:30 +0200 Message-Id: <8c794e00c3ddb7b2c7e09dd8155bbccf82c75914.1618587222.git.pkrempa@redhat.com> 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.14 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" The moved code contains only checks and does not modify the parsed document so it doesn't belong into the PostParse code. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 19 ------------------- src/conf/domain_validate.c | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 0738bf7f1f..ce0931c160 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5367,25 +5367,6 @@ virDomainDiskDefPostParse(virDomainDiskDef *disk, const virDomainDef *def, virDomainXMLOption *xmlopt) { - /* internal snapshots and config files are currently supported - * only with rbd: */ - if (virStorageSourceGetActualType(disk->src) !=3D VIR_STORAGE_TYPE_NET= WORK && - disk->src->protocol !=3D VIR_STORAGE_NET_PROTOCOL_RBD) { - if (disk->src->snapshot) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _(" element is currently supported " - "only with 'rbd' disks")); - return -1; - } - - if (disk->src->configFile) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _(" element is currently supported " - "only with 'rbd' disks")); - return -1; - } - } - if (disk->src->type =3D=3D VIR_STORAGE_TYPE_NETWORK && disk->src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_ISCSI) { virDomainPostParseCheckISCSIPath(&disk->src->path); diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index b2780b3562..5118d6a25e 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -469,6 +469,24 @@ virDomainDiskDefValidateSourceChainOne(const virStorag= eSource *src) } } + /* internal snapshots and config files are currently supported only wi= th rbd: */ + if (virStorageSourceGetActualType(src) !=3D VIR_STORAGE_TYPE_NETWORK && + src->protocol !=3D VIR_STORAGE_NET_PROTOCOL_RBD) { + if (src->snapshot) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _(" element is currently supported " + "only with 'rbd' disks")); + return -1; + } + + if (src->configFile) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _(" element is currently supported " + "only with 'rbd' disks")); + return -1; + } + } + return 0; } --=20 2.30.2 From nobody Fri May 17 11:28:43 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=1618587578; cv=none; d=zohomail.com; s=zohoarc; b=adIl7kxpBf3cHQYT0I7PenbQ2vUNL9Z+aLvL9IZH72GFdkew5VI/9yZog0DOJH/YO9hqOQCwt6NojcdW0b37xNAbHg4vq6L5rEcFCy4d63nj3u5eoIhp981HM+S7aXvglL7wAFFxZnWSRYyo0PudOqJ0THfgeZnfy0Rz4GGYtFE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618587578; 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=sOBEJ9may/yd/DDb2tnRBjrdU+U62aZP7Tuz+AVvX9E=; b=Dvq8aImN0GAzjm0+6trCLWPk4JKy5ymAHlpvsi4nPjimLyoIHIujXG7mnCRZutMrTMRWAZQXs4cGj6e4TFOch3A1vp6Faimx0qy/qNO0UaKq+rGZOgLbYyY2ZNocGExw8VjFxpW3xK1FEDAzD4wSXBKCwhrJ0TUPONaQGo1/fXE= 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 16185875788451017.549680673028; Fri, 16 Apr 2021 08:39:38 -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-504-DubizrGFNgSm59QUgNcjhw-1; Fri, 16 Apr 2021 11:39:34 -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 212008143F0; Fri, 16 Apr 2021 15:39: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 0117260D11; Fri, 16 Apr 2021 15:39: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 C2E591806D1A; Fri, 16 Apr 2021 15:39:29 +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 13GFZAX7009379 for ; Fri, 16 Apr 2021 11:35:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 822795C3DF; Fri, 16 Apr 2021 15:35:10 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id DBA8E5C260 for ; Fri, 16 Apr 2021 15:35:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618587577; 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=sOBEJ9may/yd/DDb2tnRBjrdU+U62aZP7Tuz+AVvX9E=; b=OFr/wjMYxz7JMz2lJNKMCf45P9MYNlXmplHWG0VD4518cEZn9RP81hXekxzDbCOxb614+9 Hur2/gLpPB9eX18LaOzmELAirE5ZDqjheuAjKlJQuh0Ymyv+WiZJnCvuzUZDaTsvbZW5bT dzo81YIRpQr5fEJrK5Xgbj+0GS6MiOk= X-MC-Unique: DubizrGFNgSm59QUgNcjhw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 13/25] conf: Move disk target 'ioemu:' stripping to virDomainDiskDefPostParse Date: Fri, 16 Apr 2021 17:34:31 +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.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" Modifications of the data such as this one don't belong into the parser. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ce0931c160..2803055204 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5367,6 +5367,16 @@ virDomainDiskDefPostParse(virDomainDiskDef *disk, const virDomainDef *def, virDomainXMLOption *xmlopt) { + if (disk->dst) { + char *newdst; + + /* Work around for compat with Xen driver in previous libvirt rele= ases */ + if ((newdst =3D g_strdup(STRSKIP(disk->dst, "ioemu:")))) { + g_free(disk->dst); + disk->dst =3D newdst; + } + } + if (disk->src->type =3D=3D VIR_STORAGE_TYPE_NETWORK && disk->src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_ISCSI) { virDomainPostParseCheckISCSIPath(&disk->src->path); @@ -9345,12 +9355,6 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, return NULL; removable =3D virXMLPropString(cur, "removable"); rotation_rate =3D virXMLPropString(cur, "rotation_rate"); - - /* HACK: Work around for compat with Xen - * driver in previous libvirt releases */ - if (target && - STRPREFIX(target, "ioemu:")) - memmove(target, target+6, strlen(target)-5); } else if (!domain_name && virXMLNodeNameEqual(cur, "backenddomain")) { domain_name =3D virXMLPropString(cur, "name"); --=20 2.30.2 From nobody Fri May 17 11:28:43 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=1618587464; cv=none; d=zohomail.com; s=zohoarc; b=j7gRp6ScRIddn3JKec9Qiwf/CmE21tDlM0wFPcX4NltZNe/2CxtgvEPy4NifP7oj7f8WjgD1DE/WO5uUgHdHFlNeD8m9BHrBgtCnGtZ5JeaDUog1mcq+Y0NqIJkJMKhH6o70HeGojpJPLuB2q6NwW6WXYNEWRzH3gyAo7Pa9JXk= 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=EDmjgsTSsLp78bHsfy2jNtlUjsljDzQRf2vh0qitseg=; b=QE1O8ooMAfVBTxb0s+bEokxzQYXCFU6nxhY37jjje5yqQdNXbgeTcPQCr2yQ9utLDbwid32Ii3FmYgS4vE5GnJlBsnpZowU7tHrhCB9eoQSQH2f+FxeFSCoKr/0bDPNS9+R3+eF4huDfElOcNsWkFHRc2NfP49afmJ+HCOKijis= 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 1618587464698716.4003630173435; 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-261-iCd5vF77NPa4FYlukMa-jg-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 C09C88030D5; Fri, 16 Apr 2021 15:37:32 +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 A55C259466; Fri, 16 Apr 2021 15:37:32 +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 71ED81806D17; Fri, 16 Apr 2021 15:37:32 +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 13GFZB7i009385 for ; Fri, 16 Apr 2021 11:35:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9C30C5C257; Fri, 16 Apr 2021 15:35:11 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id EBEF35C3DF for ; Fri, 16 Apr 2021 15:35:10 +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=EDmjgsTSsLp78bHsfy2jNtlUjsljDzQRf2vh0qitseg=; b=QZWvT8V+AIzcHI7RsukJY9VRaCJWfbT1iLtF5vX5+w0sEZlP4NDHztY5LG03No08JypjQl p6Nk0mWEuGyUy6PBrfPCPvGzbYun3exgwtixS/Wrjm5kXexcy5xMGYcdWIwpzzfItrW2RB eONrHI54DW/eWSTxhPxj5dLNwQ8wrlw= X-MC-Unique: iCd5vF77NPa4FYlukMa-jg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 14/25] conf: domain: Introduce VIR_DOMAIN_DISK_BUS_NONE Date: Fri, 16 Apr 2021 17:34:32 +0200 Message-Id: <9fb4e778bd6f694e6e7dc87c94bf8506b64688ce.1618587222.git.pkrempa@redhat.com> 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" Add a disk bus value represending no selected bus. This will help split up the XML parser. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 3 ++- src/conf/domain_conf.h | 1 + src/conf/domain_validate.c | 1 + src/qemu/qemu_alias.c | 1 + src/qemu/qemu_command.c | 2 ++ src/qemu/qemu_domain_address.c | 1 + src/qemu/qemu_hotplug.c | 2 ++ src/vbox/vbox_common.c | 1 + 8 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 2803055204..c600c1e6b1 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -340,6 +340,7 @@ VIR_ENUM_IMPL(virDomainDiskGeometryTrans, VIR_ENUM_IMPL(virDomainDiskBus, VIR_DOMAIN_DISK_BUS_LAST, + "none", "ide", "fdc", "scsi", @@ -9510,7 +9511,7 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, } if (bus) { - if ((def->bus =3D virDomainDiskBusTypeFromString(bus)) < 0) { + if ((def->bus =3D virDomainDiskBusTypeFromString(bus)) <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown disk bus type '%s'"), bus); return NULL; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 1a2e0fc872..cb5ce68fdb 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -371,6 +371,7 @@ typedef enum { } virDomainDiskDevice; typedef enum { + VIR_DOMAIN_DISK_BUS_NONE, VIR_DOMAIN_DISK_BUS_IDE, VIR_DOMAIN_DISK_BUS_FDC, VIR_DOMAIN_DISK_BUS_SCSI, diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 5118d6a25e..1073da3bfa 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -227,6 +227,7 @@ virDomainDiskAddressDiskBusCompatibility(virDomainDiskB= us bus, case VIR_DOMAIN_DISK_BUS_USB: case VIR_DOMAIN_DISK_BUS_UML: case VIR_DOMAIN_DISK_BUS_SD: + case VIR_DOMAIN_DISK_BUS_NONE: case VIR_DOMAIN_DISK_BUS_LAST: return true; } diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c index 7c86a6eeaa..63638b1402 100644 --- a/src/qemu/qemu_alias.c +++ b/src/qemu/qemu_alias.c @@ -255,6 +255,7 @@ qemuAssignDeviceDiskAlias(virDomainDef *def, case VIR_DOMAIN_DISK_BUS_XEN: case VIR_DOMAIN_DISK_BUS_UML: case VIR_DOMAIN_DISK_BUS_SD: + case VIR_DOMAIN_DISK_BUS_NONE: case VIR_DOMAIN_DISK_BUS_LAST: break; } diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 77d8e3f38c..6ac36da1bb 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1607,6 +1607,7 @@ qemuCheckIOThreads(const virDomainDef *def, case VIR_DOMAIN_DISK_BUS_UML: case VIR_DOMAIN_DISK_BUS_SATA: case VIR_DOMAIN_DISK_BUS_SD: + case VIR_DOMAIN_DISK_BUS_NONE: case VIR_DOMAIN_DISK_BUS_LAST: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("IOThreads not available for bus %s target %s"), @@ -1849,6 +1850,7 @@ qemuBuildDiskDeviceStr(const virDomainDef *def, case VIR_DOMAIN_DISK_BUS_XEN: case VIR_DOMAIN_DISK_BUS_UML: case VIR_DOMAIN_DISK_BUS_SD: + case VIR_DOMAIN_DISK_BUS_NONE: case VIR_DOMAIN_DISK_BUS_LAST: default: virReportError(VIR_ERR_INTERNAL_ERROR, diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 8adef60675..1ee75b8f2e 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -800,6 +800,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDevic= eDef *dev, case VIR_DOMAIN_DISK_BUS_UML: case VIR_DOMAIN_DISK_BUS_SATA: case VIR_DOMAIN_DISK_BUS_SD: + case VIR_DOMAIN_DISK_BUS_NONE: case VIR_DOMAIN_DISK_BUS_LAST: return 0; } diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 20c34ef104..4344edc75b 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1092,6 +1092,7 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver = *driver, /* Note that SD card hotplug support should be added only once * they support '-device' (don't require -drive only). * See also: qemuDiskBusIsSD */ + case VIR_DOMAIN_DISK_BUS_NONE: case VIR_DOMAIN_DISK_BUS_LAST: virReportError(VIR_ERR_OPERATION_UNSUPPORTED, _("disk bus '%s' cannot be hotplugged."), @@ -5315,6 +5316,7 @@ qemuDomainDetachPrepDisk(virDomainObj *vm, _("This type of disk cannot be hot unplugged")); return -1; + case VIR_DOMAIN_DISK_BUS_NONE: case VIR_DOMAIN_DISK_BUS_LAST: default: virReportEnumRangeError(virDomainDiskBus, disk->bus); diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 1ea1e4e537..1ca521321c 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -1154,6 +1154,7 @@ vboxAttachDrives(virDomainDef *def, struct _vboxDrive= r *data, IMachine *machine) case VIR_DOMAIN_DISK_BUS_USB: case VIR_DOMAIN_DISK_BUS_UML: case VIR_DOMAIN_DISK_BUS_SD: + case VIR_DOMAIN_DISK_BUS_NONE: case VIR_DOMAIN_DISK_BUS_LAST: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("The vbox driver does not support %s bus type= "), --=20 2.30.2 From nobody Fri May 17 11:28:43 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=1618587523; cv=none; d=zohomail.com; s=zohoarc; b=aU+rZSSIvPNIuoDEzJ0eiITqJdM+eTjyoIsrR+FgsoHsc/q3VKGhsrqbsj22u5tb//X6OPT8CZ8VW64so6HNWmwnsW2WhLuvrta2eiaOy4/UFk+2SF2jkzFoqJMXEjon6Haxb96JbgmBb6UWico9Qg+MxioLZSOu832eHU/1B2o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618587523; 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=npdOc9FzGMQXWtPL1x1Mu/zmnz30dfUqk24V+9i+Oeo=; b=OTGb2MbjWAYGSEr7fKC8045MDyxBdPuhC222J/o+ENI8KdJI9Z/dXdFroBEikAjfs+xpOXHJAxMZjCGj+RWa8nnxaD1TbJtoQhaDl2LB39uHgAS6s0Yufw75BCVHnb//r821C/MSue13dfZ2W8O/8dUOV2zwDucW6ivLtxpfCHE= 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 1618587523921207.92592134575943; Fri, 16 Apr 2021 08:38:43 -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-325-RmRvJihKOjerKELdJtViLA-1; Fri, 16 Apr 2021 11:38:40 -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 2ADEF84BA69; Fri, 16 Apr 2021 15:38:34 +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 0A75B60861; Fri, 16 Apr 2021 15:38:34 +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 C96191806D18; Fri, 16 Apr 2021 15:38:33 +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 13GFZC7r009395 for ; Fri, 16 Apr 2021 11:35:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id D3CC85C3DF; Fri, 16 Apr 2021 15:35:12 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 17D9D5C257 for ; Fri, 16 Apr 2021 15:35:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618587522; 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=npdOc9FzGMQXWtPL1x1Mu/zmnz30dfUqk24V+9i+Oeo=; b=flUcMWTijhIDfaz5NlPe+fxbkbTQgy5go9a/Mjv/Ta6H01wak3QGKyUFKWvwqJ7erI2Wpp JQ3+8S3ntvOJDhj6WGdkihWB/shYrQ3UVQEsm881Iab/zLognA4Z2ddyAyoRQ0x0xaLTKJ NqsrT5UDgok6JAtjlP+uRWrgd22N4PU= X-MC-Unique: RmRvJihKOjerKELdJtViLA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 15/25] vmx: Mark CDROM disk elements as read-only Date: Fri, 16 Apr 2021 17:34:33 +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.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" Mark it explicitly as read only in accordance with the comment outlining configuration. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/vmx/vmx.c | 3 +++ tests/vmx2xmldata/vmx2xml-cdrom-ide-device.xml | 1 + tests/vmx2xmldata/vmx2xml-cdrom-ide-empty-2.xml | 1 + tests/vmx2xmldata/vmx2xml-cdrom-ide-empty.xml | 1 + tests/vmx2xmldata/vmx2xml-cdrom-ide-file.xml | 1 + tests/vmx2xmldata/vmx2xml-cdrom-ide-raw-auto-detect.xml | 1 + tests/vmx2xmldata/vmx2xml-cdrom-ide-raw-device.xml | 1 + tests/vmx2xmldata/vmx2xml-cdrom-scsi-device.xml | 1 + tests/vmx2xmldata/vmx2xml-cdrom-scsi-empty.xml | 1 + tests/vmx2xmldata/vmx2xml-cdrom-scsi-file.xml | 1 + tests/vmx2xmldata/vmx2xml-cdrom-scsi-passthru.xml | 1 + tests/vmx2xmldata/vmx2xml-cdrom-scsi-raw-auto-detect.xml | 1 + tests/vmx2xmldata/vmx2xml-cdrom-scsi-raw-device.xml | 1 + tests/vmx2xmldata/vmx2xml-esx-in-the-wild-2.xml | 3 +++ tests/vmx2xmldata/vmx2xml-esx-in-the-wild-3.xml | 1 + tests/vmx2xmldata/vmx2xml-esx-in-the-wild-5.xml | 1 + tests/vmx2xmldata/vmx2xml-esx-in-the-wild-6.xml | 1 + tests/vmx2xmldata/vmx2xml-esx-in-the-wild-7.xml | 1 + tests/vmx2xmldata/vmx2xml-esx-in-the-wild-8.xml | 1 + tests/vmx2xmldata/vmx2xml-fusion-in-the-wild-1.xml | 1 + tests/vmx2xmldata/vmx2xml-ws-in-the-wild-1.xml | 1 + tests/vmx2xmldata/vmx2xml-ws-in-the-wild-2.xml | 1 + 22 files changed, 26 insertions(+) diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 7aa76c0055..65d2850f2c 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -2411,6 +2411,9 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptio= n *xmlopt, virConf *conf, goto cleanup; } } else if (device =3D=3D VIR_DOMAIN_DISK_DEVICE_CDROM) { + /* set cdrom to read-only */ + (*def)->src->readonly =3D true; + if (fileName && virStringHasCaseSuffix(fileName, ".vmdk")) { /* * This function was called in order to parse a CDROM device, = but diff --git a/tests/vmx2xmldata/vmx2xml-cdrom-ide-device.xml b/tests/vmx2xml= data/vmx2xml-cdrom-ide-device.xml index e5a242d1f4..8e67347e7d 100644 --- a/tests/vmx2xmldata/vmx2xml-cdrom-ide-device.xml +++ b/tests/vmx2xmldata/vmx2xml-cdrom-ide-device.xml @@ -15,6 +15,7 @@ +
diff --git a/tests/vmx2xmldata/vmx2xml-cdrom-ide-empty-2.xml b/tests/vmx2xm= ldata/vmx2xml-cdrom-ide-empty-2.xml index 6af0ee0704..406c3e9cc0 100644 --- a/tests/vmx2xmldata/vmx2xml-cdrom-ide-empty-2.xml +++ b/tests/vmx2xmldata/vmx2xml-cdrom-ide-empty-2.xml @@ -14,6 +14,7 @@ +
diff --git a/tests/vmx2xmldata/vmx2xml-cdrom-ide-empty.xml b/tests/vmx2xmld= ata/vmx2xml-cdrom-ide-empty.xml index 93670e7eb4..0c37b64dbb 100644 --- a/tests/vmx2xmldata/vmx2xml-cdrom-ide-empty.xml +++ b/tests/vmx2xmldata/vmx2xml-cdrom-ide-empty.xml @@ -14,6 +14,7 @@ +
diff --git a/tests/vmx2xmldata/vmx2xml-cdrom-ide-file.xml b/tests/vmx2xmlda= ta/vmx2xml-cdrom-ide-file.xml index 98548e9da8..03d8eaec8e 100644 --- a/tests/vmx2xmldata/vmx2xml-cdrom-ide-file.xml +++ b/tests/vmx2xmldata/vmx2xml-cdrom-ide-file.xml @@ -15,6 +15,7 @@ +
diff --git a/tests/vmx2xmldata/vmx2xml-cdrom-ide-raw-auto-detect.xml b/test= s/vmx2xmldata/vmx2xml-cdrom-ide-raw-auto-detect.xml index 392d580ffa..87bf2ee847 100644 --- a/tests/vmx2xmldata/vmx2xml-cdrom-ide-raw-auto-detect.xml +++ b/tests/vmx2xmldata/vmx2xml-cdrom-ide-raw-auto-detect.xml @@ -15,6 +15,7 @@ +
diff --git a/tests/vmx2xmldata/vmx2xml-cdrom-ide-raw-device.xml b/tests/vmx= 2xmldata/vmx2xml-cdrom-ide-raw-device.xml index c7cba73aa8..764443f4fe 100644 --- a/tests/vmx2xmldata/vmx2xml-cdrom-ide-raw-device.xml +++ b/tests/vmx2xmldata/vmx2xml-cdrom-ide-raw-device.xml @@ -15,6 +15,7 @@ +
diff --git a/tests/vmx2xmldata/vmx2xml-cdrom-scsi-device.xml b/tests/vmx2xm= ldata/vmx2xml-cdrom-scsi-device.xml index 9e5a985788..48453d4a3c 100644 --- a/tests/vmx2xmldata/vmx2xml-cdrom-scsi-device.xml +++ b/tests/vmx2xmldata/vmx2xml-cdrom-scsi-device.xml @@ -15,6 +15,7 @@ +
diff --git a/tests/vmx2xmldata/vmx2xml-cdrom-scsi-empty.xml b/tests/vmx2xml= data/vmx2xml-cdrom-scsi-empty.xml index 3678ef38b0..a972a4f538 100644 --- a/tests/vmx2xmldata/vmx2xml-cdrom-scsi-empty.xml +++ b/tests/vmx2xmldata/vmx2xml-cdrom-scsi-empty.xml @@ -14,6 +14,7 @@ +
diff --git a/tests/vmx2xmldata/vmx2xml-cdrom-scsi-file.xml b/tests/vmx2xmld= ata/vmx2xml-cdrom-scsi-file.xml index e79927ada8..977655cb53 100644 --- a/tests/vmx2xmldata/vmx2xml-cdrom-scsi-file.xml +++ b/tests/vmx2xmldata/vmx2xml-cdrom-scsi-file.xml @@ -15,6 +15,7 @@ +
diff --git a/tests/vmx2xmldata/vmx2xml-cdrom-scsi-passthru.xml b/tests/vmx2= xmldata/vmx2xml-cdrom-scsi-passthru.xml index b851e73b3b..c9445a1754 100644 --- a/tests/vmx2xmldata/vmx2xml-cdrom-scsi-passthru.xml +++ b/tests/vmx2xmldata/vmx2xml-cdrom-scsi-passthru.xml @@ -15,6 +15,7 @@ +
diff --git a/tests/vmx2xmldata/vmx2xml-cdrom-scsi-raw-auto-detect.xml b/tes= ts/vmx2xmldata/vmx2xml-cdrom-scsi-raw-auto-detect.xml index 497066972d..41f33885a6 100644 --- a/tests/vmx2xmldata/vmx2xml-cdrom-scsi-raw-auto-detect.xml +++ b/tests/vmx2xmldata/vmx2xml-cdrom-scsi-raw-auto-detect.xml @@ -15,6 +15,7 @@ +
diff --git a/tests/vmx2xmldata/vmx2xml-cdrom-scsi-raw-device.xml b/tests/vm= x2xmldata/vmx2xml-cdrom-scsi-raw-device.xml index d7d881e4a6..3d541cb14b 100644 --- a/tests/vmx2xmldata/vmx2xml-cdrom-scsi-raw-device.xml +++ b/tests/vmx2xmldata/vmx2xml-cdrom-scsi-raw-device.xml @@ -15,6 +15,7 @@ +
diff --git a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-2.xml b/tests/vmx2xm= ldata/vmx2xml-esx-in-the-wild-2.xml index b079808363..59071b5d3a 100644 --- a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-2.xml +++ b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-2.xml @@ -21,16 +21,19 @@ +
+
+
diff --git a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-3.xml b/tests/vmx2xm= ldata/vmx2xml-esx-in-the-wild-3.xml index d05318c7d8..cbe8eceb37 100644 --- a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-3.xml +++ b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-3.xml @@ -20,6 +20,7 @@ +
diff --git a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-5.xml b/tests/vmx2xm= ldata/vmx2xml-esx-in-the-wild-5.xml index 82643e9ffe..9eb975afe9 100644 --- a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-5.xml +++ b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-5.xml @@ -27,6 +27,7 @@ +
diff --git a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-6.xml b/tests/vmx2xm= ldata/vmx2xml-esx-in-the-wild-6.xml index 913bfedf30..51c74dd8a1 100644 --- a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-6.xml +++ b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-6.xml @@ -20,6 +20,7 @@ +
diff --git a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-7.xml b/tests/vmx2xm= ldata/vmx2xml-esx-in-the-wild-7.xml index 91913a2918..c117bd62e5 100644 --- a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-7.xml +++ b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-7.xml @@ -20,6 +20,7 @@ +
diff --git a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-8.xml b/tests/vmx2xm= ldata/vmx2xml-esx-in-the-wild-8.xml index 32affb5935..0eea610709 100644 --- a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-8.xml +++ b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-8.xml @@ -37,6 +37,7 @@ +
diff --git a/tests/vmx2xmldata/vmx2xml-fusion-in-the-wild-1.xml b/tests/vmx= 2xmldata/vmx2xml-fusion-in-the-wild-1.xml index f6e9f4acdf..a47fab5cd5 100644 --- a/tests/vmx2xmldata/vmx2xml-fusion-in-the-wild-1.xml +++ b/tests/vmx2xmldata/vmx2xml-fusion-in-the-wild-1.xml @@ -20,6 +20,7 @@ +
diff --git a/tests/vmx2xmldata/vmx2xml-ws-in-the-wild-1.xml b/tests/vmx2xml= data/vmx2xml-ws-in-the-wild-1.xml index 9901033bb9..5dcc6eb48e 100644 --- a/tests/vmx2xmldata/vmx2xml-ws-in-the-wild-1.xml +++ b/tests/vmx2xmldata/vmx2xml-ws-in-the-wild-1.xml @@ -20,6 +20,7 @@ +
diff --git a/tests/vmx2xmldata/vmx2xml-ws-in-the-wild-2.xml b/tests/vmx2xml= data/vmx2xml-ws-in-the-wild-2.xml index 6f8f30393c..dfabb16e58 100644 --- a/tests/vmx2xmldata/vmx2xml-ws-in-the-wild-2.xml +++ b/tests/vmx2xmldata/vmx2xml-ws-in-the-wild-2.xml @@ -20,6 +20,7 @@ +
--=20 2.30.2 From nobody Fri May 17 11:28:43 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=1618587525; cv=none; d=zohomail.com; s=zohoarc; b=nP/iVLhC7cqfrr3yEre8hhaul+vOw7ALfihBMtQ2xzx30SRvY/q8PiyrQVmg0jXjODa4tIVjV2XobUFdqxmh3J4pPYW120pTFBqT9AJIGSUlLve6oKguMAYpaVIhhOsqYSE0e3ePmm9fXuGr00MjkC7USUCgB7/JzrmXg/Hklic= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618587525; 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=W2qEwYvIH1U7piJkqhCoz/hIoCXkcoc5ub07uBgwU8w=; b=bUIq3t7MAk68E81/QVwpuNdW0fKosAFHbZwENrOcAyZfuMxWBazCsNX7JWKmuxHy8wWIf79eSok3e5jpVQKC9ZnngRknFbXni/m6SulF23pdsjLGZ5YBVQNRLCRZEBvsUzNyDco5XaxmfZw6bnS3E5KzYvP1rkJZNIh3aaAXiRs= 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 1618587525424684.540050011512; Fri, 16 Apr 2021 08:38:45 -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-102-Z5EjwZcQO62pg1PwsVynGQ-1; Fri, 16 Apr 2021 11:38:41 -0400 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 06A8F84BA55; Fri, 16 Apr 2021 15:38:37 +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 D568860BE5; Fri, 16 Apr 2021 15:38:36 +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 9C11C44A5E; Fri, 16 Apr 2021 15:38:36 +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 13GFZDiY009402 for ; Fri, 16 Apr 2021 11:35:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id DDDB25C260; Fri, 16 Apr 2021 15:35:13 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 40EE15C257 for ; Fri, 16 Apr 2021 15:35:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618587524; 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=W2qEwYvIH1U7piJkqhCoz/hIoCXkcoc5ub07uBgwU8w=; b=i6s8pb4jJBOUZys16+iWma3/F5Mz+iRMXb8+UKzxbiEb5KXoHCpHd6E+wxk3Y1c25o+cUY irs1Yg41Al5YxXP25vDkg5Jo3S9ABJ0L/GLrbq6l7arzw9unA/fscKYcxeTmQHc8ZuJ3wb fiiD5B7EUtrTx9Vm2PhGDPsxjYlXRBI= X-MC-Unique: Z5EjwZcQO62pg1PwsVynGQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 16/25] conf: domain: Move default setting from virDomainDiskDefParseXML to virDomainDiskDefPostParse Date: Fri, 16 Apr 2021 17:34:34 +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.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" Move the setting of read-only state, the default disk bus and setting of 'snapshot' state for read-only disks to the post parse callback to clean up the disk parser. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 50 +++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c600c1e6b1..867d74f31f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5378,6 +5378,33 @@ virDomainDiskDefPostParse(virDomainDiskDef *disk, } } + /* Force CDROM to be listed as read only */ + if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_CDROM) + disk->src->readonly =3D true; + + if (disk->bus =3D=3D VIR_DOMAIN_DISK_BUS_NONE) { + disk->bus =3D VIR_DOMAIN_DISK_BUS_IDE; + + if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_FLOPPY) { + disk->bus =3D VIR_DOMAIN_DISK_BUS_FDC; + } else if (disk->dst) { + if (STRPREFIX(disk->dst, "hd")) + disk->bus =3D VIR_DOMAIN_DISK_BUS_IDE; + else if (STRPREFIX(disk->dst, "sd")) + disk->bus =3D VIR_DOMAIN_DISK_BUS_SCSI; + else if (STRPREFIX(disk->dst, "vd")) + disk->bus =3D VIR_DOMAIN_DISK_BUS_VIRTIO; + else if (STRPREFIX(disk->dst, "xvd")) + disk->bus =3D VIR_DOMAIN_DISK_BUS_XEN; + else if (STRPREFIX(disk->dst, "ubd")) + disk->bus =3D VIR_DOMAIN_DISK_BUS_UML; + } + } + + if (disk->snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_DEFAULT && + disk->src->readonly) + disk->snapshot =3D VIR_DOMAIN_SNAPSHOT_LOCATION_NONE; + if (disk->src->type =3D=3D VIR_STORAGE_TYPE_NETWORK && disk->src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_ISCSI) { virDomainPostParseCheckISCSIPath(&disk->src->path); @@ -9465,10 +9492,6 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, return NULL; } - /* Force CDROM to be listed as read only */ - if (def->device =3D=3D VIR_DOMAIN_DISK_DEVICE_CDROM) - def->src->readonly =3D true; - if ((def->device =3D=3D VIR_DOMAIN_DISK_DEVICE_DISK || def->device =3D=3D VIR_DOMAIN_DISK_DEVICE_LUN) && !STRPREFIX((const char *)target, "hd") && @@ -9489,8 +9512,6 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, snapshot); return NULL; } - } else if (def->src->readonly) { - def->snapshot =3D VIR_DOMAIN_SNAPSHOT_LOCATION_NONE; } if (rawio) { @@ -9516,23 +9537,6 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, _("unknown disk bus type '%s'"), bus); return NULL; } - } else { - if (def->device =3D=3D VIR_DOMAIN_DISK_DEVICE_FLOPPY) { - def->bus =3D VIR_DOMAIN_DISK_BUS_FDC; - } else { - if (STRPREFIX(target, "hd")) - def->bus =3D VIR_DOMAIN_DISK_BUS_IDE; - else if (STRPREFIX(target, "sd")) - def->bus =3D VIR_DOMAIN_DISK_BUS_SCSI; - else if (STRPREFIX(target, "vd")) - def->bus =3D VIR_DOMAIN_DISK_BUS_VIRTIO; - else if (STRPREFIX(target, "xvd")) - def->bus =3D VIR_DOMAIN_DISK_BUS_XEN; - else if (STRPREFIX(target, "ubd")) - def->bus =3D VIR_DOMAIN_DISK_BUS_UML; - else - def->bus =3D VIR_DOMAIN_DISK_BUS_IDE; - } } if (removable) { --=20 2.30.2 From nobody Fri May 17 11:28:43 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=1618587580; cv=none; d=zohomail.com; s=zohoarc; b=IpF0STWAFI9ycbV9quskSEApRFzzEjvz3RvsDSrlVTmhwBJ0GZL8HagUST7kHBVeiLpcW3rMeltlIWu21G7orfcmnzzrRAqQfAKCMbyJW4xd1PB56Gs6xZBwmvvzZivBgTot5gJDPEEJqLKbEEBU9Pl5sCLHUG/cbM1t4evyOJI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618587580; 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=GKupx0d9PAQbxXsW1vIQFG5+lB26It9hWvG6qsAaIt8=; b=FwkHsOg8aFNF3JlLSipq+oEGJ3Km5jZUv90/L91LY55KI3kMZNgoTTgjGVIOEMUSKHTLKh7UGKqRkIP/4t4nry4oxzqMqCejMwUwFkKm/npIQ6qMmaW+DwGm3vxSfB504MTmb2mgqro92Yk6jIcUUIw7DNbbgL7NunZ56e/hqE4= 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 161858758086635.13587881250908; Fri, 16 Apr 2021 08:39:40 -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-378-uHDP5vuwPfu6si7XiBc7ew-1; Fri, 16 Apr 2021 11:39:37 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 073F0107ACF7; Fri, 16 Apr 2021 15:39:33 +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 DD1855BAFF; Fri, 16 Apr 2021 15:39:32 +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 A336444A67; Fri, 16 Apr 2021 15:39:32 +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 13GFZFgA009412 for ; Fri, 16 Apr 2021 11:35:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 06F735C260; Fri, 16 Apr 2021 15:35:15 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 527E75C257 for ; Fri, 16 Apr 2021 15:35:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618587579; 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=GKupx0d9PAQbxXsW1vIQFG5+lB26It9hWvG6qsAaIt8=; b=HaCFDJVWgxem2oy0AqxNOSi0ipWeQWhkGE7kSS9FIUcg5uogZjWz13vvYhmi5FARAyH7V3 WsUDDVrPxlxO6lkHHf6nZrB4pCoJ+D+BvqjloLxof9XNWBdAYzKJFjkqhvzN2C6rdZt24+ VY9OK0zFsx5Rff8JHZOSBx0te5LKByg= X-MC-Unique: uHDP5vuwPfu6si7XiBc7ew-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 17/25] conf: domain: Move checks from virDomainDiskDefParseXML to virDomainDiskDefValidate Date: Fri, 16 Apr 2021 17:34:35 +0200 Message-Id: <5de8a75909a12d649d3fa34663c15c2d35f89f68.1618587222.git.pkrempa@redhat.com> 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.15 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" Move the rest of the validations to the vaidation code. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 44 -------------------------------------- src/conf/domain_validate.c | 44 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 867d74f31f..ff408188d5 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9440,8 +9440,6 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, if (!(wwn =3D virXMLNodeContentString(cur))) return NULL; - if (!virValidateWWN(wwn)) - return NULL; } else if (!vendor && virXMLNodeNameEqual(cur, "vendor")) { if (!(vendor =3D virXMLNodeContentString(cur))) @@ -9462,48 +9460,6 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, } } - /* Only CDROM and Floppy devices are allowed missing source path - * to indicate no media present. LUN is for raw access CD-ROMs - * that are not attached to a physical device presently */ - if (virStorageSourceIsEmpty(def->src) && - def->device =3D=3D VIR_DOMAIN_DISK_DEVICE_DISK) { - virReportError(VIR_ERR_NO_SOURCE, - target ? "%s" : NULL, target); - return NULL; - } - - if (!target) { - if (def->src->srcpool) { - tmp =3D g_strdup_printf("pool =3D '%s', volume =3D '%s'", - def->src->srcpool->pool, def->src->srcpo= ol->volume); - - virReportError(VIR_ERR_NO_TARGET, "%s", tmp); - VIR_FREE(tmp); - } else { - virReportError(VIR_ERR_NO_TARGET, def->src->path ? "%s" : NULL= , def->src->path); - } - return NULL; - } - - if (def->device =3D=3D VIR_DOMAIN_DISK_DEVICE_FLOPPY && - !STRPREFIX(target, "fd")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid floppy device name: %s"), target); - return NULL; - } - - if ((def->device =3D=3D VIR_DOMAIN_DISK_DEVICE_DISK || - def->device =3D=3D VIR_DOMAIN_DISK_DEVICE_LUN) && - !STRPREFIX((const char *)target, "hd") && - !STRPREFIX((const char *)target, "sd") && - !STRPREFIX((const char *)target, "vd") && - !STRPREFIX((const char *)target, "xvd") && - !STRPREFIX((const char *)target, "ubd")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid harddisk device name: %s"), target); - return NULL; - } - if (snapshot) { def->snapshot =3D virDomainSnapshotLocationTypeFromString(snapshot= ); if (def->snapshot <=3D 0) { diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 1073da3bfa..686b9e8d16 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -699,6 +699,50 @@ virDomainDiskDefValidate(const virDomainDef *def, } } + if (disk->wwn && !virValidateWWN(disk->wwn)) + return -1; + + if (!disk->dst) { + if (disk->src->srcpool) { + virReportError(VIR_ERR_NO_TARGET, _("pool =3D '%s', volume =3D= '%s'"), + disk->src->srcpool->pool, + disk->src->srcpool->volume); + } else { + virReportError(VIR_ERR_NO_TARGET, + disk->src->path ? "%s" : NULL, disk->src->path); + } + + return -1; + } + + if ((disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_DISK || + disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_LUN) && + !STRPREFIX(disk->dst, "hd") && + !STRPREFIX(disk->dst, "sd") && + !STRPREFIX(disk->dst, "vd") && + !STRPREFIX(disk->dst, "xvd") && + !STRPREFIX(disk->dst, "ubd")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid harddisk device name: %s"), disk->dst); + return -1; + } + + if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_FLOPPY && + !STRPREFIX(disk->dst, "fd")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid floppy device name: %s"), disk->dst); + return -1; + } + + /* Only CDROM and Floppy devices are allowed missing source path to + * indicate no media present. LUN is for raw access CD-ROMs that are n= ot + * attached to a physical device presently */ + if (virStorageSourceIsEmpty(disk->src) && + disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_DISK) { + virReportError(VIR_ERR_NO_SOURCE, "%s", disk->dst); + return -1; + } + return 0; } --=20 2.30.2 From nobody Fri May 17 11:28:43 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=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 Reviewed-by: Michal Privoznik --- 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 From nobody Fri May 17 11:28:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1618587533; cv=none; d=zohomail.com; s=zohoarc; b=g/fzH1Ax5HLXczsO0CNS6aR38CX/Bbbgr54Yq2+z0BVUB2BtVFicjY8yYGc5J13uIwlW4YzK1ceGOFSahdy1B2FmlFZL9n/I7b/N8OXVge1avRmiADo65eFamp45bDeS5rl6yvIMci8KlaVVHcTY2duLXDpzWHNbiQrvs90Ay2Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618587533; 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=I6tm1IgHjnue+Hrco3UsIs/Qn3v2rrXaMFfKsrLFH+M=; b=BSxerbjopP0yYXoQpMHL49yQ60ujRWIif+EgBJSw6/9z/XaEfXvHc82JLkprBGtxFisLYF8ULRUB7Re/5X6WKEjfnyg+wtz3EXVs/xcJNf6dunvK1zTTCTW9ufO3jW1YUUnICtzd9ej0MM0f+nh1+rdkWjtEXpmGc3OPqcEh/fM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1618587533457718.5857706577186; Fri, 16 Apr 2021 08:38:53 -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-578-PVwASzXVN_e_d-RKfjSwVg-1; Fri, 16 Apr 2021 11:38:50 -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 7EAC3107ACF4; Fri, 16 Apr 2021 15:38:40 +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 6200D60861; Fri, 16 Apr 2021 15:38:40 +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 3270A1809C82; Fri, 16 Apr 2021 15:38:40 +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 13GFZHoR009428 for ; Fri, 16 Apr 2021 11:35:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1F7835C257; Fri, 16 Apr 2021 15:35:17 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6D6BC5C260 for ; Fri, 16 Apr 2021 15:35:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618587532; 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=I6tm1IgHjnue+Hrco3UsIs/Qn3v2rrXaMFfKsrLFH+M=; b=MBIbFFdpgIDurHqTNJ5SA2EP8S8JD7KtipfL8aQj/GkKihoBVXqc7In+3bsFf/quF0F3QD gDCftS9eq3se1ADFEtkftbA0+RS5YHLPeNBJZwfq34jmIPQA1MTCNLUUZbfeWQwF0wEwRy zS2E9WxeWAcDHGZMNVVJWamNfsMRYFI= X-MC-Unique: PVwASzXVN_e_d-RKfjSwVg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 19/25] conf: domain: Convert virDomainDiskDef's 'rawio' to virTristateBool Date: Fri, 16 Apr 2021 17:34:37 +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.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" Use the appropriate type for the variable and refactor the XML parser to parse it correctly using virXMLPropEnum. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 14 +++----------- src/conf/domain_conf.h | 2 +- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5e27ca6265..6641a7a78b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9314,7 +9314,6 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, bool source =3D false; g_autofree char *tmp =3D NULL; g_autofree char *snapshot =3D NULL; - g_autofree char *rawio =3D NULL; g_autofree char *sgio =3D NULL; g_autofree char *target =3D NULL; g_autofree char *bus =3D NULL; @@ -9357,7 +9356,9 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, snapshot =3D virXMLPropString(node, "snapshot"); - rawio =3D virXMLPropString(node, "rawio"); + if (virXMLPropTristateBool(node, "rawio", VIR_XML_PROP_OPTIONAL, &def-= >rawio) < 0) + return NULL; + sgio =3D virXMLPropString(node, "sgio"); for (cur =3D node->children; cur !=3D NULL; cur =3D cur->next) { @@ -9473,15 +9474,6 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, } } - if (rawio) { - if ((def->rawio =3D virTristateBoolTypeFromString(rawio)) <=3D 0) { - virReportError(VIR_ERR_XML_ERROR, - _("unknown disk rawio setting '%s'"), - rawio); - return NULL; - } - } - if (sgio) { if ((def->sgio =3D virDomainDeviceSGIOTypeFromString(sgio)) <=3D 0= ) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 878ba4c961..b3a91c0a4c 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -577,7 +577,7 @@ struct _virDomainDiskDef { virDomainStartupPolicy startupPolicy; bool transient; virDomainDeviceInfo info; - int rawio; /* enum virTristateBool */ + virTristateBool rawio; int sgio; /* enum virDomainDeviceSGIO */ int discard; /* enum virDomainDiskDiscard */ unsigned int iothread; /* unused =3D 0, > 0 specific thread # */ --=20 2.30.2 From nobody Fri May 17 11:28:43 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=1618587620; cv=none; d=zohomail.com; s=zohoarc; b=kU+tI2FbYiGzFFOKnuzo4ltGgUFrwQtOa47tQRhoP0bA0fjK9WTCdC0wd3aZglxof5ftJBLlgDyIKHShbh5woNme2q2Hfq4TQVCqMPXO0e8h5ERNLgkUbGxGtL1UzP3oVxBBKq4F22lyRQvpLuz2u3LdVYD7k4wyuagnuERUnQc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618587620; 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=G6hQqGRAsr6UNAVCaqrVJiN+sYbyW12S7xz2+bxrwoA=; b=l4uRsYwgFNWJK986m82uDAcrvPcKV6CeKpjJ+p5QKVkTvXi7NUQybWKqGy91euvocXj/VwjnL3IjvYspMNXPCCK8N0S/Rq36r6QBiQv5Neng7iKvUJIXtqyRjWTA43hm/ern5xtUnZR43o9DeJyeG7QDdvs/zvWYvHlawV1PmAE= 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 1618587620387151.5204301588425; Fri, 16 Apr 2021 08:40:20 -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-222-Vlj9FBxBNcqz4SPJIyXgcQ-1; Fri, 16 Apr 2021 11:38:51 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 41DAA10054F6; Fri, 16 Apr 2021 15:38:43 +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 11E34107D5C2; Fri, 16 Apr 2021 15:38:43 +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 CB10344A5F; Fri, 16 Apr 2021 15:38:42 +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 13GFZIDl009437 for ; Fri, 16 Apr 2021 11:35:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2A4215C260; Fri, 16 Apr 2021 15:35:18 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8B0605C257 for ; Fri, 16 Apr 2021 15:35:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618587619; 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=G6hQqGRAsr6UNAVCaqrVJiN+sYbyW12S7xz2+bxrwoA=; b=UvxfxvuLhFZoW5y7w5W++LnrJYzNMV58JWjQqiwV294fWIlh2PLwSSCulk+T5KHPi4WrzI zbSP6PqVUWx41Zpz1FgQkOO4g8y0SrpNOPZwf8WlGcJq5z4cImg5m0WpF3SPgbWNms+wJS yohNAMz/4TzOeGrz/bx4RBhyCYgT310= X-MC-Unique: Vlj9FBxBNcqz4SPJIyXgcQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 20/25] conf: domain: Convert virDomainDiskDef's 'sgio' to virDomainDeviceSGIO Date: Fri, 16 Apr 2021 17:34:38 +0200 Message-Id: <588ffe4f5b82c7822f944251a07f21fb0bc629c0.1618587222.git.pkrempa@redhat.com> 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.84 on 10.5.11.22 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 Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 13 +++---------- src/conf/domain_conf.h | 2 +- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6641a7a78b..fd933fefc8 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9314,7 +9314,6 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, bool source =3D false; g_autofree char *tmp =3D NULL; g_autofree char *snapshot =3D NULL; - g_autofree char *sgio =3D NULL; g_autofree char *target =3D NULL; g_autofree char *bus =3D NULL; g_autofree char *serial =3D NULL; @@ -9359,7 +9358,9 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, if (virXMLPropTristateBool(node, "rawio", VIR_XML_PROP_OPTIONAL, &def-= >rawio) < 0) return NULL; - sgio =3D virXMLPropString(node, "sgio"); + if (virXMLPropEnum(node, "sgio", virDomainDeviceSGIOTypeFromString, + VIR_XML_PROP_OPTIONAL | VIR_XML_PROP_NONZERO, &def-= >sgio) < 0) + return NULL; for (cur =3D node->children; cur !=3D NULL; cur =3D cur->next) { if (cur->type !=3D XML_ELEMENT_NODE) @@ -9474,14 +9475,6 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, } } - if (sgio) { - if ((def->sgio =3D virDomainDeviceSGIOTypeFromString(sgio)) <=3D 0= ) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown disk sgio mode '%s'"), sgio); - return NULL; - } - } - if (bus) { if ((def->bus =3D virDomainDiskBusTypeFromString(bus)) <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index b3a91c0a4c..1b62af6d63 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -578,7 +578,7 @@ struct _virDomainDiskDef { bool transient; virDomainDeviceInfo info; virTristateBool rawio; - int sgio; /* enum virDomainDeviceSGIO */ + virDomainDeviceSGIO sgio; int discard; /* enum virDomainDiskDiscard */ unsigned int iothread; /* unused =3D 0, > 0 specific thread # */ int detect_zeroes; /* enum virDomainDiskDetectZeroes */ --=20 2.30.2 From nobody Fri May 17 11:28:43 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=1618587539; cv=none; d=zohomail.com; s=zohoarc; b=lX5/4SeMVmPY/BDX/LnjsKiDSG+RrgJdAwEyk4DXLzH3Tqg76UZutDj81IQOgrkBgsG/pQCJqCtar7svszB3bepmqjk0P8VIwnvptRVZas08lACNlGIrfaYTiid2MFUWg9+AO/0K9YSJlpo0X8WjQlhaH5WWhMls7z+r1oXUohI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618587539; 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=VVy9Fn7iEfhv+zJIHAhHtym0KNBrRYX/BaLqbgb7Er4=; b=ZCYYB8jaDSb3Ed8bgafKzz1PAuUH2BxzKafUjm4YvDtCGaVTsJ1fEnOUTRBQb31eNrENoZL2JjzFXZy6VyXXK1RiH2Fk5oSV9KvAEtKx8xjUH++wsRIAQ83IQ+Dxir4AGTztMWfd2MOPr6tifSGUbMFen7pelkMAHHVjUzD2Cx8= 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 16185875390531020.8506202370072; Fri, 16 Apr 2021 08:38:59 -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-155-rYic26HAP4mOyrU3cGSHQg-1; Fri, 16 Apr 2021 11:38:55 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 425C1107ACF9; Fri, 16 Apr 2021 15:38:46 +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 E666D5C5AE; Fri, 16 Apr 2021 15:38:45 +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 ABF5344A62; Fri, 16 Apr 2021 15:38:45 +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 13GFZJZ8009454 for ; Fri, 16 Apr 2021 11:35:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 348BA5C260; Fri, 16 Apr 2021 15:35:19 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8C98F5C257 for ; Fri, 16 Apr 2021 15:35:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618587537; 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=VVy9Fn7iEfhv+zJIHAhHtym0KNBrRYX/BaLqbgb7Er4=; b=GcCcbwoNB2NcTSSbn00hyhajv2PyHD46xyMUGIczDE2ctY9kX20f/nvGSBwKtgCbKUkN4/ 7HkAh19+3WqO2QUM9Z5yWFpOhUE2ygx99X3UukGzNLZmsUFwcZNXIGREZH5Q7T570h9/Xy 3IxEBO1Epj5gSIqNdBWJp3aNPF5EmEE= X-MC-Unique: rYic26HAP4mOyrU3cGSHQg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 21/25] conf: domain: Convert virDomainDiskDef's 'model' to virDomainDiskModel Date: Fri, 16 Apr 2021 17:34:39 +0200 Message-Id: <6e8cf994303d234387bd9fb9820df7e7de522ae9.1618587222.git.pkrempa@redhat.com> 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.16 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 Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 8 ++------ src/conf/domain_conf.h | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index fd933fefc8..da0e7700ff 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9345,13 +9345,9 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, } VIR_FREE(tmp); - if ((tmp =3D virXMLPropString(node, "model")) && - (def->model =3D virDomainDiskModelTypeFromString(tmp)) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown disk model '%s'"), tmp); + if (virXMLPropEnum(node, "model", virDomainDiskModelTypeFromString, + VIR_XML_PROP_OPTIONAL, &def->model) < 0) return NULL; - } - VIR_FREE(tmp); snapshot =3D virXMLPropString(node, "snapshot"); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 1b62af6d63..a83d5b337f 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -584,7 +584,7 @@ struct _virDomainDiskDef { int detect_zeroes; /* enum virDomainDiskDetectZeroes */ char *domain_name; /* backend domain name */ unsigned int queues; - int model; /* enum virDomainDiskModel */ + virDomainDiskModel model; virDomainVirtioOptions *virtio; bool diskElementAuth; --=20 2.30.2 From nobody Fri May 17 11:28:43 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=1618587610; cv=none; d=zohomail.com; s=zohoarc; b=bemWTqnhNMLAvkI0GaUAMnEIe58Yf6cGgjkkRMvX2e3lfYeQ5Z5Tooj3SLOs9Ci3YtdaFLElFUITBg0XEIJcwi/naNpibaS2K9e7uGWPlBB2ltV8EEH4aXGf4cQmBlNkkbLewv1TjYgqgIV6piQVeL4ZvGk9YAaz4OYr5jc/lTU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618587610; 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=q7I8DT9o4s6nHb991i937iy1jJKO6TGuSrlQJyJzHdA=; b=Nsps56IDT82o8L5xs1AaYatXvcxowo2D3zuzz/BADaMcselJKHZi9vevh0uGsSmK3psKol8KYTTFySUTVUyhn4JX6HLh1GzZvk+JZyXmzGB1DIgt84K+GfGUd2RvZ3V9CJoYadUEG35TiHL5iKzF6wX5vlxr1R0QEFyVA56hwe4= 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 1618587610510916.6875498409906; Fri, 16 Apr 2021 08:40:10 -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-586-eTG5AQpRMXKnMKJbcu6pEA-1; Fri, 16 Apr 2021 11:39: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 A4CDA1008065; Fri, 16 Apr 2021 15:39: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 86DD86E6F5; Fri, 16 Apr 2021 15:39: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 4A41444A6B; Fri, 16 Apr 2021 15:39: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 13GFZK3U009461 for ; Fri, 16 Apr 2021 11:35:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 447C15C260; Fri, 16 Apr 2021 15:35:20 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id A54775C257 for ; Fri, 16 Apr 2021 15:35:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618587609; 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=q7I8DT9o4s6nHb991i937iy1jJKO6TGuSrlQJyJzHdA=; b=J9TRfvrfjIUX/ADAtab4mwayo4B2r9zNFhIT+LtYnRl6vTo5qvYClrILg+CE7eS8fbrziw eLExof9enpT89aJ+LaQkM4CdiiCNrqMLCeC6N7sFI+VH/bFifK06NIyIRyFjJKPTWoD/0Y bzdYDkyj6aJdj2cutN1o/adqu2wQUto= X-MC-Unique: eTG5AQpRMXKnMKJbcu6pEA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 22/25] conf: domain: Convert virDomainDiskDef's 'snapshot' to unsigned int Date: Fri, 16 Apr 2021 17:34:40 +0200 Message-Id: <4f1b31d92b0d01f9aa838353df13ef094a5b4f7b.1618587222.git.pkrempa@redhat.com> 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" Unfortunately virDomainSnapshotLocation is declared in snapshot_conf.h which includes domain_conf.h. To avoid a circular dependency use 'unsigned int' for now. Use XML parser can use virXMLPropEnum. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 15 +++------------ src/conf/domain_conf.h | 2 +- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index da0e7700ff..6f7948da0a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9313,7 +9313,6 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, VIR_XPATH_NODE_AUTORESTORE(ctxt) bool source =3D false; g_autofree char *tmp =3D NULL; - g_autofree char *snapshot =3D NULL; g_autofree char *target =3D NULL; g_autofree char *bus =3D NULL; g_autofree char *serial =3D NULL; @@ -9349,7 +9348,9 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, VIR_XML_PROP_OPTIONAL, &def->model) < 0) return NULL; - snapshot =3D virXMLPropString(node, "snapshot"); + if (virXMLPropEnum(node, "snapshot", virDomainSnapshotLocationTypeFrom= String, + VIR_XML_PROP_OPTIONAL | VIR_XML_PROP_NONZERO, &def-= >snapshot) < 0) + return NULL; if (virXMLPropTristateBool(node, "rawio", VIR_XML_PROP_OPTIONAL, &def-= >rawio) < 0) return NULL; @@ -9461,16 +9462,6 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, } } - if (snapshot) { - def->snapshot =3D virDomainSnapshotLocationTypeFromString(snapshot= ); - if (def->snapshot <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown disk snapshot setting '%s'"), - snapshot); - return NULL; - } - } - if (bus) { if ((def->bus =3D virDomainDiskBusTypeFromString(bus)) <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index a83d5b337f..17d830a822 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -573,7 +573,7 @@ struct _virDomainDiskDef { virTristateSwitch ioeventfd; virTristateSwitch event_idx; virTristateSwitch copy_on_read; - int snapshot; /* virDomainSnapshotLocation, snapshot_conf.h */ + unsigned int snapshot; /* virDomainSnapshotLocation, snapshot_conf.h */ virDomainStartupPolicy startupPolicy; bool transient; virDomainDeviceInfo info; --=20 2.30.2 From nobody Fri May 17 11:28:43 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=1618587538; cv=none; d=zohomail.com; s=zohoarc; b=J15H1e2frIYm/KohTplmR8p0YbRhaYnsJPwNtKMDZBeBGRh36NdXklHMASCrb4tIZbju0b0K+tDYJN1YNHyxDO6R6p9kUYTutPi2XRntsHhQ2pXqhgkETwkS+bm9VRHbnADFXUY2RkqFRGkzxNaN2wdP92ngQFMEHM405I7USrU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618587538; 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=8pL6hBzIMDXUI4fMP0aZv6QGzy7ToYOuYxVQarZdK7c=; b=gf/WBJcl+WYaRXxfXAlS3LldgJu6DCs8jZrtt4W3aucZUVcQygEEHD/I98Il0hxnoy0hQcERtpM3/RTxEthkBVNR2dC2uj8M5iK9xcBGyAjj4NIHopbmaGoi93IYtlrAJ0AOBxpDB38OgwP9V5FP65JaCnc2e+6MHAjSIZDQPNw= 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 161858753880693.72102800626942; Fri, 16 Apr 2021 08:38:58 -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-41-nJ6yvWcgNIGK5O7ZDwv8Wg-1; Fri, 16 Apr 2021 11:38:54 -0400 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 EF351BBF02; Fri, 16 Apr 2021 15:38:48 +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 C5F2B5FCAC; Fri, 16 Apr 2021 15:38:48 +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 8C9D5180B617; Fri, 16 Apr 2021 15:38:48 +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 13GFZLQY009467 for ; Fri, 16 Apr 2021 11:35:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 50D005C260; Fri, 16 Apr 2021 15:35:21 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id A2EFA5C257 for ; Fri, 16 Apr 2021 15:35:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618587537; 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=8pL6hBzIMDXUI4fMP0aZv6QGzy7ToYOuYxVQarZdK7c=; b=I4V1T9EKkrWc1ig1DHb0emPcXStVRxDm7tyymzKLjm5M++unGleZnTh6YRwvBZznySpXV6 xOiO3zmc7E/J7PGMfIauvD7+d+QrP84La4cnvrBk3ptBfgqaDrizG5zwr2tZroopOl5zGy 0uyBplq/g20Cw/atk222hNmic6/gMVs= X-MC-Unique: nJ6yvWcgNIGK5O7ZDwv8Wg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 23/25] conf: domain: Convert virDomainDiskDef's 'bus' to virDomainDiskBus Date: Fri, 16 Apr 2021 17:34:41 +0200 Message-Id: <7e6fdf7993787a0da7cffff69c106a6f24652ff4.1618587222.git.pkrempa@redhat.com> 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.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" Use the appropriate type for the variable and refactor the XML parser to parse it correctly using virXMLPropEnum. Changes to other places using switch statements were required. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/bhyve/bhyve_command.c | 9 +++++++++ src/bhyve/bhyve_domain.c | 12 ++++++++++++ src/conf/domain_conf.c | 26 ++++++++++++++++---------- src/conf/domain_conf.h | 2 +- src/hyperv/hyperv_driver.c | 16 ++++++++++++++++ src/qemu/qemu_validate.c | 3 +++ src/vz/vz_sdk.c | 22 +++++++++++++++++++--- src/vz/vz_utils.c | 8 ++++++++ 8 files changed, 84 insertions(+), 14 deletions(-) diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index b1558132e1..9731fee22f 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -309,6 +309,15 @@ bhyveBuildDiskArgStr(const virDomainDef *def, if (bhyveBuildVirtIODiskArgStr(def, disk, cmd) < 0) return -1; break; + case VIR_DOMAIN_DISK_BUS_SCSI: + case VIR_DOMAIN_DISK_BUS_IDE: + case VIR_DOMAIN_DISK_BUS_FDC: + case VIR_DOMAIN_DISK_BUS_NONE: + case VIR_DOMAIN_DISK_BUS_XEN: + case VIR_DOMAIN_DISK_BUS_USB: + case VIR_DOMAIN_DISK_BUS_UML: + case VIR_DOMAIN_DISK_BUS_SD: + case VIR_DOMAIN_DISK_BUS_LAST: default: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("unsupported disk device")); diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c index 0213878f26..33e74e2e25 100644 --- a/src/bhyve/bhyve_domain.c +++ b/src/bhyve/bhyve_domain.c @@ -133,6 +133,18 @@ bhyveDomainDiskDefAssignAddress(struct _bhyveConn *dri= ver, def->info.addr.drive.bus =3D 0; break; + case VIR_DOMAIN_DISK_BUS_SCSI: + case VIR_DOMAIN_DISK_BUS_IDE: + case VIR_DOMAIN_DISK_BUS_FDC: + case VIR_DOMAIN_DISK_BUS_NONE: + case VIR_DOMAIN_DISK_BUS_VIRTIO: + case VIR_DOMAIN_DISK_BUS_XEN: + case VIR_DOMAIN_DISK_BUS_USB: + case VIR_DOMAIN_DISK_BUS_UML: + case VIR_DOMAIN_DISK_BUS_SD: + case VIR_DOMAIN_DISK_BUS_LAST: + default: + break; } return 0; } diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6f7948da0a..9afb548ea7 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7874,6 +7874,13 @@ virDomainDiskDefAssignAddress(virDomainXMLOption *xm= lopt, def->info.addr.drive.unit =3D idx % 2; break; + case VIR_DOMAIN_DISK_BUS_NONE: + case VIR_DOMAIN_DISK_BUS_VIRTIO: + case VIR_DOMAIN_DISK_BUS_XEN: + case VIR_DOMAIN_DISK_BUS_USB: + case VIR_DOMAIN_DISK_BUS_UML: + case VIR_DOMAIN_DISK_BUS_SD: + case VIR_DOMAIN_DISK_BUS_LAST: default: /* Other disk bus's aren't controller based */ break; @@ -9314,7 +9321,6 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, bool source =3D false; g_autofree char *tmp =3D NULL; g_autofree char *target =3D NULL; - g_autofree char *bus =3D NULL; g_autofree char *serial =3D NULL; g_autofree char *logical_block_size =3D NULL; g_autofree char *physical_block_size =3D NULL; @@ -9375,7 +9381,11 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, } else if (!target && virXMLNodeNameEqual(cur, "target")) { target =3D virXMLPropString(cur, "dev"); - bus =3D virXMLPropString(cur, "bus"); + if (virXMLPropEnum(cur, "bus", + virDomainDiskBusTypeFromString, + VIR_XML_PROP_OPTIONAL | VIR_XML_PROP_NONZER= O, + &def->bus) < 0) + return NULL; if (virXMLPropEnum(cur, "tray", virDomainDiskTrayTypeFromStrin= g, VIR_XML_PROP_OPTIONAL, &def->tray_status) <= 0) return NULL; @@ -9462,14 +9472,6 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, } } - if (bus) { - if ((def->bus =3D virDomainDiskBusTypeFromString(bus)) <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown disk bus type '%s'"), bus); - return NULL; - } - } - if (rotation_rate && virStrToLong_ui(rotation_rate, NULL, 10, &def->rotation_rate) < 0)= { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -30042,6 +30044,10 @@ virDiskNameToBusDeviceIndex(virDomainDiskDef *disk, case VIR_DOMAIN_DISK_BUS_VIRTIO: case VIR_DOMAIN_DISK_BUS_XEN: case VIR_DOMAIN_DISK_BUS_SD: + case VIR_DOMAIN_DISK_BUS_NONE: + case VIR_DOMAIN_DISK_BUS_SATA: + case VIR_DOMAIN_DISK_BUS_UML: + case VIR_DOMAIN_DISK_BUS_LAST: default: *busIdx =3D 0; *devIdx =3D idx; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 17d830a822..29866927c7 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -536,7 +536,7 @@ struct _virDomainDiskDef { virObject *privateData; int device; /* enum virDomainDiskDevice */ - int bus; /* enum virDomainDiskBus */ + virDomainDiskBus bus; char *dst; virDomainDiskTray tray_status; virTristateSwitch removable; diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 0ac4f93d13..3a0eeb5178 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -961,6 +961,14 @@ hypervDomainAttachStorage(virDomainPtr domain, virDoma= inDef *def, const char *ho if (hypervDomainAttachFloppy(domain, def->disks[i], floppySett= ings, hostname) < 0) return -1; break; + case VIR_DOMAIN_DISK_BUS_NONE: + case VIR_DOMAIN_DISK_BUS_VIRTIO: + case VIR_DOMAIN_DISK_BUS_XEN: + case VIR_DOMAIN_DISK_BUS_USB: + case VIR_DOMAIN_DISK_BUS_UML: + case VIR_DOMAIN_DISK_BUS_SATA: + case VIR_DOMAIN_DISK_BUS_SD: + case VIR_DOMAIN_DISK_BUS_LAST: default: virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Unsupported co= ntroller type")); return -1; @@ -3108,6 +3116,14 @@ hypervDomainAttachDeviceFlags(virDomainPtr domain, c= onst char *xml, unsigned int if (!entry) return -1; break; + case VIR_DOMAIN_DISK_BUS_NONE: + case VIR_DOMAIN_DISK_BUS_VIRTIO: + case VIR_DOMAIN_DISK_BUS_XEN: + case VIR_DOMAIN_DISK_BUS_USB: + case VIR_DOMAIN_DISK_BUS_UML: + case VIR_DOMAIN_DISK_BUS_SATA: + case VIR_DOMAIN_DISK_BUS_SD: + case VIR_DOMAIN_DISK_BUS_LAST: default: virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid disk b= us in definition")); return -1; diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 18c851d693..44d20088bf 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -2755,6 +2755,9 @@ qemuValidateDomainDeviceDefDiskFrontend(const virDoma= inDiskDef *disk, case VIR_DOMAIN_DISK_BUS_XEN: case VIR_DOMAIN_DISK_BUS_SD: + case VIR_DOMAIN_DISK_BUS_NONE: + case VIR_DOMAIN_DISK_BUS_UML: + case VIR_DOMAIN_DISK_BUS_LAST: break; } diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index 048d4adacd..e09950812d 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -595,7 +595,7 @@ prlsdkAddDomainVideoInfoVm(PRL_HANDLE sdkdom, virDomain= Def *def) } static int -prlsdkGetDiskId(PRL_HANDLE disk, int *bus, char **dst) +prlsdkGetDiskId(PRL_HANDLE disk, virDomainDiskBus *bus, char **dst) { PRL_RESULT pret; PRL_UINT32 pos, ifType; @@ -1624,7 +1624,7 @@ prlsdkBootOrderCheck(PRL_HANDLE sdkdom, PRL_DEVICE_TY= PE sdkType, int sdkIndex, PRL_HANDLE dev =3D PRL_INVALID_HANDLE; virDomainDiskDef *disk; virDomainDiskDevice device; - int bus; + virDomainDiskBus bus; char *dst =3D NULL; int ret =3D -1; @@ -3462,6 +3462,14 @@ static int prlsdkConfigureDisk(struct _vzDriver *dri= ver, sdkbus =3D PMS_SATA_DEVICE; idx =3D drive->unit; break; + case VIR_DOMAIN_DISK_BUS_FDC: + case VIR_DOMAIN_DISK_BUS_NONE: + case VIR_DOMAIN_DISK_BUS_VIRTIO: + case VIR_DOMAIN_DISK_BUS_XEN: + case VIR_DOMAIN_DISK_BUS_USB: + case VIR_DOMAIN_DISK_BUS_UML: + case VIR_DOMAIN_DISK_BUS_SD: + case VIR_DOMAIN_DISK_BUS_LAST: default: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Specified disk bus is not " @@ -3500,7 +3508,7 @@ prlsdkGetDisk(PRL_HANDLE sdkdom, virDomainDiskDef *di= sk) PRL_UINT32 num; size_t i; PRL_HANDLE sdkdisk =3D PRL_INVALID_HANDLE; - int bus; + virDomainDiskBus bus; char *dst =3D NULL; PRL_DEVICE_TYPE devType; @@ -4339,6 +4347,14 @@ prlsdkGetBlockStats(PRL_HANDLE sdkstats, prefix =3D "scsi"; idx =3D address->unit; break; + case VIR_DOMAIN_DISK_BUS_FDC: + case VIR_DOMAIN_DISK_BUS_NONE: + case VIR_DOMAIN_DISK_BUS_VIRTIO: + case VIR_DOMAIN_DISK_BUS_XEN: + case VIR_DOMAIN_DISK_BUS_USB: + case VIR_DOMAIN_DISK_BUS_UML: + case VIR_DOMAIN_DISK_BUS_SD: + case VIR_DOMAIN_DISK_BUS_LAST: default: virReportError(VIR_ERR_INTERNAL_ERROR, _("Unknown disk bus: %X"), disk->bus); diff --git a/src/vz/vz_utils.c b/src/vz/vz_utils.c index a07754d5ec..8fed875281 100644 --- a/src/vz/vz_utils.c +++ b/src/vz/vz_utils.c @@ -237,6 +237,14 @@ vzCheckDiskAddressDriveUnsupportedParams(virDomainDisk= Def *disk) return -1; } break; + case VIR_DOMAIN_DISK_BUS_FDC: + case VIR_DOMAIN_DISK_BUS_NONE: + case VIR_DOMAIN_DISK_BUS_VIRTIO: + case VIR_DOMAIN_DISK_BUS_XEN: + case VIR_DOMAIN_DISK_BUS_USB: + case VIR_DOMAIN_DISK_BUS_UML: + case VIR_DOMAIN_DISK_BUS_SD: + case VIR_DOMAIN_DISK_BUS_LAST: default: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Specified disk bus is not supported by vz driver= .")); --=20 2.30.2 From nobody Fri May 17 11:28:43 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=1618587539; cv=none; d=zohomail.com; s=zohoarc; b=VQT0V6nN7K3+TQIZ73Q9QlHXvV4fESUm8HDjD9wZNzmLO+WUqAl56WETNtzMjpSAff2GXegVdIA/Gg0k6xB3oqfjRjBO7ranS/1mTvg2KWt55RVxVSNcHLoWp8UI1Sw75rSMUheObNM0R+3irsejU2i1aPC2m8NwdEfuwMp898s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618587539; 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=qAh3W6nLiJB6vatgcOY/fbxU73gy/V+gYmUlaPZKG60=; b=GcWbvNKjnOIB672ko5vsrs8kwv2nID7oxHJIDYCjod5BhPKIpafkBClOS0U8++WblSwJw40B+BRxdl9fTNFbU8GUv6VMCyV+fOJ9Sk6Ji8CZ8YfQPRlvuf5m1Euc0uVnoTOVjfSJxC2DeCBgfKRgdHvYJtKH+WojVbKOsjueneI= 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 1618587539734818.9783563566933; Fri, 16 Apr 2021 08:38:59 -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-342-DfT1W4RDN0mOW8V3pCeueA-1; Fri, 16 Apr 2021 11:38:56 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B98E084BA43; Fri, 16 Apr 2021 15:38:51 +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 9DE875D751; Fri, 16 Apr 2021 15:38:51 +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 68F561806D1B; Fri, 16 Apr 2021 15:38:51 +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 13GFZMeV009482 for ; Fri, 16 Apr 2021 11:35:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 70A6F5C260; Fri, 16 Apr 2021 15:35:22 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id BCF0B5C257 for ; Fri, 16 Apr 2021 15:35:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618587538; 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=qAh3W6nLiJB6vatgcOY/fbxU73gy/V+gYmUlaPZKG60=; b=BoyaVKTURWVlBCDChnbxIPHQPxLm25sUYkhDRERpTBGg2lTOF+7WCOmU807wyNKSSFCDbl fJ2KUGgCw3zr2oOx+Uwb8XT9koWPRTTo/KbUGc07CrCRvX7c2s+Y89szjCaxfsLpCEprwA PhvH8rzcdZ5zPefnqSX0Ng9njBaP+oc= X-MC-Unique: DfT1W4RDN0mOW8V3pCeueA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 24/25] conf: domain: Convert virDomainDiskDef's 'device' to virDomainDiskDevice Date: Fri, 16 Apr 2021 17:34:42 +0200 Message-Id: <0dcb2c7b984b393e893c74a91ada32d9d56586b9.1618587222.git.pkrempa@redhat.com> 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.15 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. Changes to other places using switch statements were required. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/bhyve/bhyve_command.c | 3 +++ src/conf/domain_conf.c | 9 ++------- src/conf/domain_conf.h | 2 +- src/hyperv/hyperv_driver.c | 2 ++ src/libxl/libxl_driver.c | 11 +++++++++++ src/qemu/qemu_command.c | 4 ++++ src/vmx/vmx.c | 1 + 7 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index 9731fee22f..f8e0ce5123 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -208,6 +208,9 @@ bhyveBuildAHCIControllerArgStr(const virDomainDef *def, else virBufferAsprintf(&device, "-cd,%s", disk_source); break; + case VIR_DOMAIN_DISK_DEVICE_FLOPPY: + case VIR_DOMAIN_DISK_DEVICE_LUN: + case VIR_DOMAIN_DISK_DEVICE_LAST: default: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("unsupported disk device")); diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 9afb548ea7..242839d60f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9319,7 +9319,6 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, xmlNodePtr cur; VIR_XPATH_NODE_AUTORESTORE(ctxt) bool source =3D false; - g_autofree char *tmp =3D NULL; g_autofree char *target =3D NULL; g_autofree char *serial =3D NULL; g_autofree char *logical_block_size =3D NULL; @@ -9342,13 +9341,9 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, /* defaults */ def->device =3D VIR_DOMAIN_DISK_DEVICE_DISK; - if ((tmp =3D virXMLPropString(node, "device")) && - (def->device =3D virDomainDiskDeviceTypeFromString(tmp)) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown disk device '%s'"), tmp); + if (virXMLPropEnum(node, "device", virDomainDiskDeviceTypeFromString, + VIR_XML_PROP_OPTIONAL, &def->device) < 0) return NULL; - } - VIR_FREE(tmp); if (virXMLPropEnum(node, "model", virDomainDiskModelTypeFromString, VIR_XML_PROP_OPTIONAL, &def->model) < 0) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 29866927c7..a17f241c53 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -535,7 +535,7 @@ struct _virDomainDiskDef { virObject *privateData; - int device; /* enum virDomainDiskDevice */ + virDomainDiskDevice device; virDomainDiskBus bus; char *dst; virDomainDiskTray tray_status; diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 3a0eeb5178..ff20d5548b 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -886,6 +886,8 @@ hypervDomainAttachStorageVolume(virDomainPtr domain, return hypervDomainAttachCDROM(domain, disk, controller, hostname); case VIR_DOMAIN_DISK_DEVICE_FLOPPY: return hypervDomainAttachFloppy(domain, disk, controller, hostname= ); + case VIR_DOMAIN_DISK_DEVICE_LUN: + case VIR_DOMAIN_DISK_DEVICE_LAST: default: virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Unsupported disk b= us")); break; diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index d924e033d9..cf3ee4db3d 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -3084,6 +3084,9 @@ libxlDomainAttachDeviceDiskLive(virDomainObj *vm, vir= DomainDeviceDef *dev) virDomainDiskBusTypeToString(l_disk->bus)); } break; + case VIR_DOMAIN_DISK_DEVICE_FLOPPY: + case VIR_DOMAIN_DISK_DEVICE_LUN: + case VIR_DOMAIN_DISK_DEVICE_LAST: default: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("disk device type '%s' cannot be hotplugged"), @@ -3369,6 +3372,10 @@ libxlDomainDetachDeviceDiskLive(virDomainObj *vm, vi= rDomainDeviceDef *dev) virDomainDiskBusTypeToString(dev->data.disk= ->bus)); } break; + case VIR_DOMAIN_DISK_DEVICE_CDROM: + case VIR_DOMAIN_DISK_DEVICE_FLOPPY: + case VIR_DOMAIN_DISK_DEVICE_LUN: + case VIR_DOMAIN_DISK_DEVICE_LAST: default: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("device type '%s' cannot hot unplugged"), @@ -4031,6 +4038,10 @@ libxlDomainUpdateDeviceLive(virDomainObj *vm, virDom= ainDeviceDef *dev) if (ret =3D=3D 0) dev->data.disk =3D NULL; break; + case VIR_DOMAIN_DISK_DEVICE_DISK: + case VIR_DOMAIN_DISK_DEVICE_FLOPPY: + case VIR_DOMAIN_DISK_DEVICE_LUN: + case VIR_DOMAIN_DISK_DEVICE_LAST: default: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("disk bus '%s' cannot be updated."), diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 6ac36da1bb..e55858bb79 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2252,6 +2252,10 @@ qemuBuildDisksCommandLine(virCommand *cmd, bootindex =3D bootDisk; bootDisk =3D 0; break; + case VIR_DOMAIN_DISK_DEVICE_FLOPPY: + case VIR_DOMAIN_DISK_DEVICE_LAST: + default: + break; } } diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 65d2850f2c..1cd5a82227 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -3474,6 +3474,7 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOp= tion *xmlopt, virDomainDef break; + case VIR_DOMAIN_DISK_DEVICE_LAST: default: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unsupported disk device type '%s'"), --=20 2.30.2 From nobody Fri May 17 11:28:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1618587543; cv=none; d=zohomail.com; s=zohoarc; b=nWksZqw0t/TGx4Xt6lzhp9Q+XbzZ6Ctu60Yq/qYn1vLbDGDPal7Ag7gvUaSV2ay57zya9UkCIqwYfj5xQAWFaC8ZPr0KJeQZYuKrKmZVyWBOvy6A4PvgYio7fzSZ3TQyP5a4MgE5AJAig+tKkePMUbK0VF6J+ytej5I28uqPMmw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618587543; 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=9dsqE68QqI6+hFP6002yMmH+5XTEMHsrwQULrrMLwEI=; b=i2Z8IqfhFGXibf2gtQqP9tiDIQXUHpgqS/QEeXOR5Lg4am1m0xaR25GUzBRrugo6eR2tYCeU37Zd7pCEM0PXpUVTXoqwc74z8bblhSfEVdxxD9RxV0jCwrNSRCresVAf2U/Cj34R7F7YIMoWd2APs1S4MoeccJ+AYt3zTmrIvEg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1618587543546834.5858289347264; Fri, 16 Apr 2021 08:39:03 -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-544-gRttLi2cOPygakfdNLpklQ-1; Fri, 16 Apr 2021 11:39:00 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 70890107ACC7; Fri, 16 Apr 2021 15:38:54 +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 4C6DE5C257; Fri, 16 Apr 2021 15:38:54 +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 0F2A344A60; Fri, 16 Apr 2021 15:38:54 +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 13GFZNMB009493 for ; Fri, 16 Apr 2021 11:35:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8E1EF5C260; Fri, 16 Apr 2021 15:35:23 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id D1DA95C257 for ; Fri, 16 Apr 2021 15:35:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618587542; 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=9dsqE68QqI6+hFP6002yMmH+5XTEMHsrwQULrrMLwEI=; b=LZWTfNtiH73BByJEpCnyYIWal61xQ7W7gDLG9G4TsM4HCeaxXQH/JBFpAPS9hzldhiZ86H UfSPj3wzN7fMuX/vnE7zlRLuOHH55yuWFBRSq3aX7ItzY/ZAh4kYU5AzJ1H5enfqwp+Nbz nCwS1V8ArbjR1ouda9y1f+U/3ju7e7E= X-MC-Unique: gRttLi2cOPygakfdNLpklQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 25/25] conf: domain: Refactor virDomainDiskDefParseXML Date: Fri, 16 Apr 2021 17:34:43 +0200 Message-Id: <7c6b57c6a2b512b382f64baf892c87a7577428eb.1618587222.git.pkrempa@redhat.com> 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.16 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 new virXMLProp helpers and XPath queries to get rid of the old style of iteration through element children. Note that in case of def->blockio.logical_block_size, def->blockio.physical_block_size and def->rotation_rate the wraparound behaviour of 'virStrToLong_ui' was _not_ forward ported to the new code as it makes no sense with the attributes. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 196 +++++++++++++++++------------------------ 1 file changed, 80 insertions(+), 116 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 242839d60f..a36d0a2713 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9316,18 +9316,13 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, unsigned int flags) { g_autoptr(virDomainDiskDef) def =3D NULL; - xmlNodePtr cur; VIR_XPATH_NODE_AUTORESTORE(ctxt) - bool source =3D false; - g_autofree char *target =3D NULL; - g_autofree char *serial =3D NULL; - g_autofree char *logical_block_size =3D NULL; - g_autofree char *physical_block_size =3D NULL; - g_autofree char *wwn =3D NULL; - g_autofree char *vendor =3D NULL; - g_autofree char *product =3D NULL; - g_autofree char *domain_name =3D NULL; - g_autofree char *rotation_rate =3D NULL; + xmlNodePtr sourceNode; + xmlNodePtr targetNode; + xmlNodePtr geometryNode; + xmlNodePtr blockioNode; + xmlNodePtr driverNode; + xmlNodePtr mirrorNode; g_autoptr(virStorageSource) src =3D NULL; if (!(src =3D virDomainDiskDefParseSourceXML(xmlopt, node, ctxt, flags= ))) @@ -9360,132 +9355,101 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlo= pt, VIR_XML_PROP_OPTIONAL | VIR_XML_PROP_NONZERO, &def-= >sgio) < 0) return NULL; - for (cur =3D node->children; cur !=3D NULL; cur =3D cur->next) { - if (cur->type !=3D XML_ELEMENT_NODE) - continue; + if ((sourceNode =3D virXPathNode("./source", ctxt))) { + if (virXMLPropEnum(sourceNode, "startupPolicy", + virDomainStartupPolicyTypeFromString, + VIR_XML_PROP_OPTIONAL | VIR_XML_PROP_NONZERO, + &def->startupPolicy) < 0) + return NULL; + } - if (!source && virXMLNodeNameEqual(cur, "source")) { - source =3D true; + if ((targetNode =3D virXPathNode("./target", ctxt))) { + def->dst =3D virXMLPropString(targetNode, "dev"); - if (virXMLPropEnum(cur, "startupPolicy", - virDomainStartupPolicyTypeFromString, - VIR_XML_PROP_OPTIONAL | VIR_XML_PROP_NONZER= O, - &def->startupPolicy) < 0) - return NULL; + if (virXMLPropEnum(targetNode, "bus", + virDomainDiskBusTypeFromString, + VIR_XML_PROP_OPTIONAL | VIR_XML_PROP_NONZERO, + &def->bus) < 0) + return NULL; - } else if (!target && - virXMLNodeNameEqual(cur, "target")) { - target =3D virXMLPropString(cur, "dev"); - if (virXMLPropEnum(cur, "bus", - virDomainDiskBusTypeFromString, - VIR_XML_PROP_OPTIONAL | VIR_XML_PROP_NONZER= O, - &def->bus) < 0) - return NULL; - if (virXMLPropEnum(cur, "tray", virDomainDiskTrayTypeFromStrin= g, - VIR_XML_PROP_OPTIONAL, &def->tray_status) <= 0) - return NULL; + if (virXMLPropEnum(targetNode, "tray", virDomainDiskTrayTypeFromSt= ring, + VIR_XML_PROP_OPTIONAL, &def->tray_status) < 0) + return NULL; - if (virXMLPropTristateSwitch(cur, "removable", VIR_XML_PROP_OP= TIONAL, - &def->removable) < 0) - return NULL; + if (virXMLPropTristateSwitch(targetNode, "removable", VIR_XML_PROP= _OPTIONAL, + &def->removable) < 0) + return NULL; - rotation_rate =3D virXMLPropString(cur, "rotation_rate"); - } else if (!domain_name && - virXMLNodeNameEqual(cur, "backenddomain")) { - domain_name =3D virXMLPropString(cur, "name"); - } else if (virXMLNodeNameEqual(cur, "geometry")) { - if (virDomainDiskDefGeometryParse(def, cur) < 0) - return NULL; - } else if (virXMLNodeNameEqual(cur, "blockio")) { - logical_block_size =3D - virXMLPropString(cur, "logical_block_size"); - if (logical_block_size && - virStrToLong_ui(logical_block_size, NULL, 0, - &def->blockio.logical_block_size) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("invalid logical block size '%s'"), - logical_block_size); - return NULL; - } - physical_block_size =3D - virXMLPropString(cur, "physical_block_size"); - if (physical_block_size && - virStrToLong_ui(physical_block_size, NULL, 0, - &def->blockio.physical_block_size) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("invalid physical block size '%s'"), - physical_block_size); - return NULL; - } - } else if (!virDomainDiskGetDriver(def) && - virXMLNodeNameEqual(cur, "driver")) { - if (virDomainVirtioOptionsParseXML(cur, &def->virtio) < 0) - return NULL; + if (virXMLPropUInt(targetNode, "rotation_rate", 10, VIR_XML_PROP_O= PTIONAL, + &def->rotation_rate) < 0) + return NULL; + } - if (virDomainDiskDefDriverParseXML(def, cur, ctxt) < 0) - return NULL; - } else if (!def->mirror && - virXMLNodeNameEqual(cur, "mirror") && - !(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) { - if (virDomainDiskDefMirrorParse(def, cur, ctxt, flags, xmlopt)= < 0) - return NULL; - } else if (virXMLNodeNameEqual(cur, "auth")) { - def->diskElementAuth =3D true; - } else if (virXMLNodeNameEqual(cur, "iotune")) { - if (virDomainDiskDefIotuneParse(def, ctxt) < 0) - return NULL; - } else if (virXMLNodeNameEqual(cur, "transient")) { - def->transient =3D true; - } else if (virXMLNodeNameEqual(cur, "encryption")) { - def->diskElementEnc =3D true; - } else if (!serial && - virXMLNodeNameEqual(cur, "serial")) { - if (!(serial =3D virXMLNodeContentString(cur))) - return NULL; - } else if (!wwn && - virXMLNodeNameEqual(cur, "wwn")) { - if (!(wwn =3D virXMLNodeContentString(cur))) - return NULL; + if ((geometryNode =3D virXPathNode("./geometry", ctxt))) { + if (virDomainDiskDefGeometryParse(def, geometryNode) < 0) + return NULL; + } - } else if (!vendor && - virXMLNodeNameEqual(cur, "vendor")) { - if (!(vendor =3D virXMLNodeContentString(cur))) - return NULL; - } else if (!product && - virXMLNodeNameEqual(cur, "product")) { - if (!(product =3D virXMLNodeContentString(cur))) + if ((blockioNode =3D virXPathNode("./blockio", ctxt))) { + if (virXMLPropUInt(blockioNode, "logical_block_size", 10, VIR_XML_= PROP_OPTIONAL, + &def->blockio.logical_block_size) < 0) + return NULL; + + if (virXMLPropUInt(blockioNode, "physical_block_size", 10, VIR_XML= _PROP_OPTIONAL, + &def->blockio.physical_block_size) < 0) + return NULL; + } + + if ((driverNode =3D virXPathNode("./driver", ctxt))) { + if (virDomainVirtioOptionsParseXML(driverNode, &def->virtio) < 0) + return NULL; + + if (virDomainDiskDefDriverParseXML(def, driverNode, ctxt) < 0) + return NULL; + } + + if ((mirrorNode =3D virXPathNode("./mirror", ctxt))) { + if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) { + if (virDomainDiskDefMirrorParse(def, mirrorNode, ctxt, flags, = xmlopt) < 0) return NULL; - } else if (virXMLNodeNameEqual(cur, "boot")) { - /* boot is parsed as part of virDomainDeviceInfoParseXML */ - } else if ((flags & VIR_DOMAIN_DEF_PARSE_STATUS) && - virXMLNodeNameEqual(cur, "diskSecretsPlacement")) { - g_autofree char *secretAuth =3D virXMLPropString(cur, "auth"); - g_autofree char *secretEnc =3D virXMLPropString(cur, "enc"); + } + } + + if (virXPathNode("./auth", ctxt)) + def->diskElementAuth =3D true; + + if (virXPathNode("./encryption", ctxt)) + def->diskElementEnc =3D true; + + if (flags & VIR_DOMAIN_DEF_PARSE_STATUS) { + xmlNodePtr diskSecretsPlacementNode; + + if ((diskSecretsPlacementNode =3D virXPathNode("./diskSecretsPlace= ment", ctxt))) { + g_autofree char *secretAuth =3D virXMLPropString(diskSecretsPl= acementNode, "auth"); + g_autofree char *secretEnc =3D virXMLPropString(diskSecretsPla= cementNode, "enc"); def->diskElementAuth =3D !!secretAuth; def->diskElementEnc =3D !!secretEnc; } } - if (rotation_rate && - virStrToLong_ui(rotation_rate, NULL, 10, &def->rotation_rate) < 0)= { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Cannot parse rotation rate '%s'"), rotation_rate= ); + if (virXPathNode("./transient", ctxt)) + def->transient =3D true; + + if (virDomainDiskDefIotuneParse(def, ctxt) < 0) return NULL; - } + + def->domain_name =3D virXPathString("string(./backenddomain/@name)", c= txt); + def->serial =3D virXPathString("string(./serial)", ctxt); + def->wwn =3D virXPathString("string(./wwn)", ctxt); + def->vendor =3D virXPathString("string(./vendor)", ctxt); + def->product =3D virXPathString("string(./product)", ctxt); if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info, flags | VIR_DOMAIN_DEF_PARSE_ALLOW_BOO= T) < 0) { return NULL; } - def->dst =3D g_steal_pointer(&target); - def->domain_name =3D g_steal_pointer(&domain_name); - def->serial =3D g_steal_pointer(&serial); - def->wwn =3D g_steal_pointer(&wwn); - def->vendor =3D g_steal_pointer(&vendor); - def->product =3D g_steal_pointer(&product); - if (flags & VIR_DOMAIN_DEF_PARSE_STATUS && virDomainDiskDefParsePrivateData(ctxt, def, xmlopt) < 0) return NULL; --=20 2.30.2