From nobody Mon May 20 23:42:26 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=1697124621; cv=none; d=zohomail.com; s=zohoarc; b=g7wI3C9yC20dZwSHyYZcE0Nfuvl5cXWWDXqbmnfh7HFgzWDH64Mr8MQPAW5v/OSptAi9mpBzqCLUdVWIHeK/EfnKh8FvWj3MdFz8+Xn0xgluRRmSjdCYxRz6KMz3UdSizp+iQvgufm3bOr1DnEDUl35ZTLxAoBJTcYfR8PLZH3w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697124621; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=mLyevtQTCd93+9nV8uXmMpDXjZq8z4HiVh+xvGvbIPo=; b=Iwe1YVFFkF+cS1BzbDmYvpqoY2MrtgnhrBX5GgS4i/q2UswyPXbZUVlBvGyvwgfO0xTSvqnLxJUIALT8RIKHGCQf6ruw2S6GifIga7/9ycnKnawHH0ixln8cv7t1tCziMaCosh54CGBB3UrlQleHFpmKSi0GXa3tSwhpt9a39uw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1697124621600152.18018565297177; Thu, 12 Oct 2023 08:30:21 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-434-SarVqQC2PyG3NT-Hl061gg-1; Thu, 12 Oct 2023 11:30:17 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F412980B915; Thu, 12 Oct 2023 15:30:14 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 790E92157F5A; Thu, 12 Oct 2023 15:30:14 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 583801946588; Thu, 12 Oct 2023 15:30:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9EEF41946586 for ; Thu, 12 Oct 2023 14:47:33 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 8E83AC1598A; Thu, 12 Oct 2023 14:47:33 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1AA2AC15BBC for ; Thu, 12 Oct 2023 14:47:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697124620; 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=mLyevtQTCd93+9nV8uXmMpDXjZq8z4HiVh+xvGvbIPo=; b=JiCmknrGEgGQy24bG84KxZlTZwpWmrrYjrLaGgpiuZoxl/hjZCA/N6CtwIyZ/mYELRjEIP DWsySJNa5DXPxGIRTamjsYqWtthyKsfwi6qFb9TXHb4IwTG2mnPSMBVUvyShO1apSg3ElU 4OBy2rcVl1psG1WGmO/5y6eMsiuP4+Y= X-MC-Unique: SarVqQC2PyG3NT-Hl061gg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/7] virStorageSourcePoolDef: Turn 'mode' member into proper enum type Date: Thu, 12 Oct 2023 16:47:25 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1697124623661100001 Content-Type: text/plain; charset="utf-8" Use proper enum type and refactor the formatter accordingly. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 12 ++++-------- src/conf/storage_source_conf.h | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 4435ee2ad4..d7f167a469 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7011,7 +7011,6 @@ virDomainDiskSourcePoolDefParse(xmlNodePtr node, { virStorageSourcePoolDef *source; int ret =3D -1; - g_autofree char *mode =3D NULL; *srcpool =3D NULL; @@ -7019,7 +7018,6 @@ virDomainDiskSourcePoolDefParse(xmlNodePtr node, source->pool =3D virXMLPropString(node, "pool"); source->volume =3D virXMLPropString(node, "volume"); - mode =3D virXMLPropString(node, "mode"); /* CD-ROM and Floppy allows no source */ if (!source->pool && !source->volume) { @@ -7033,13 +7031,11 @@ virDomainDiskSourcePoolDefParse(xmlNodePtr node, goto cleanup; } - if (mode && - (source->mode =3D virStorageSourcePoolModeTypeFromString(mode)) <= =3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown source mode '%1$s' for volume type disk"= ), - mode); + if (virXMLPropEnum(node, "mode", + virStorageSourcePoolModeTypeFromString, + VIR_XML_PROP_NONZERO, + &source->mode) < 0) goto cleanup; - } *srcpool =3D g_steal_pointer(&source); ret =3D 0; diff --git a/src/conf/storage_source_conf.h b/src/conf/storage_source_conf.h index fc6c67f426..bfa8d625e5 100644 --- a/src/conf/storage_source_conf.h +++ b/src/conf/storage_source_conf.h @@ -201,7 +201,7 @@ struct _virStorageSourcePoolDef { int voltype; /* virStorageVolType, internal only */ int pooltype; /* virStoragePoolType from storage_conf.h, internal only= */ virStorageType actualtype; /* internal only */ - int mode; /* virStorageSourcePoolMode, currently makes sense only for = iscsi pool */ + virStorageSourcePoolMode mode; /* currently makes sense only for iscsi= pool */ }; --=20 2.41.0 From nobody Mon May 20 23:42:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1697123884; cv=none; d=zohomail.com; s=zohoarc; b=M43TWPb4eKceynCWszIdXKYN+AAVbE2EKPOBKNKqIRolCAnWuDlHtsATRhLa8TGAiJY3ftBW+pNyKTCGkzOl/3ogYSVu5X/nINC391ZXxrB5aIF8ODgQQ1NY5WB2j3LyVXnPaPQjknsw/lV+3N94YsCOO2oMnR84y3W3+CGVnsE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697123884; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=+0qJCtkfRVI000CNXdR7X0N9OcYXMTHNvXP/K3TX4YI=; b=P4CRprb3mia60xOtXwAlspaAAQOt8GoHZPG0i0yyC8lgmHZh/g6/CZt7MNtKiTM7qR+40UZLBdERusGdBXocMmXG3a8uNDy9mGC+OHHyg31IoRy3uaXFRQi5VtaO3em0jV3e4L52b7G0ywEJtHT7wzYBWwXc5e7P6U7fpwe7ark= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1697123884988810.3217627146357; Thu, 12 Oct 2023 08:18:04 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-341-P6WU4LvDOFaWeL8EcGtmlQ-1; Thu, 12 Oct 2023 11:18:00 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2ED433C1F14F; Thu, 12 Oct 2023 15:17:55 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 29670400F5B; Thu, 12 Oct 2023 15:17:54 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D5C4E1946588; Thu, 12 Oct 2023 15:17:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7FAE41946586 for ; Thu, 12 Oct 2023 14:47:34 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 619E1C1598A; Thu, 12 Oct 2023 14:47:34 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id DB806C15BBC for ; Thu, 12 Oct 2023 14:47:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697123883; 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=+0qJCtkfRVI000CNXdR7X0N9OcYXMTHNvXP/K3TX4YI=; b=V+2pCU8uHre0sjs9R7W2Sqx0THmN/m4lSMZVrVpMT8E7byOcIJft1SUp0eY7XvclHDJuDj ihF8NhrahLht0UH8xEnyI6YjyE+ElBMS65OCA6mpxUAQVMMB/q6Do6TuASSpCLeocQ9tuY XP6Ao0BbMEx+PwIswIYc/ZKPlpKH7Bs= X-MC-Unique: P6WU4LvDOFaWeL8EcGtmlQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/7] virDomainDiskSourcePoolDefParse: Refactor cleanup Date: Thu, 12 Oct 2023 16:47:26 +0200 Message-ID: <1ab637d9eda732bab57e36d973938c0da9ca4e72.1697121886.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1697123886087100001 Content-Type: text/plain; charset="utf-8" Register autoptr cleanup function for virStorageSourcePoolDef and refactor the parser to simplify the logic. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 35 +++++++++++----------------------- src/conf/storage_source_conf.h | 1 + 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d7f167a469..3e0989e2e8 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7005,44 +7005,31 @@ virDomainLeaseDefParseXML(xmlNodePtr node, return NULL; } -static int -virDomainDiskSourcePoolDefParse(xmlNodePtr node, - virStorageSourcePoolDef **srcpool) +static virStorageSourcePoolDef * +virDomainDiskSourcePoolDefParse(xmlNodePtr node) { - virStorageSourcePoolDef *source; - int ret =3D -1; - - *srcpool =3D NULL; - - source =3D g_new0(virStorageSourcePoolDef, 1); + g_autoptr(virStorageSourcePoolDef) source =3D g_new0(virStorageSourceP= oolDef, 1); source->pool =3D virXMLPropString(node, "pool"); source->volume =3D virXMLPropString(node, "volume"); - /* CD-ROM and Floppy allows no source */ - if (!source->pool && !source->volume) { - ret =3D 0; - goto cleanup; - } + /* CD-ROM and Floppy allows no source -> empty pool */ + if (!source->pool && !source->volume) + return g_steal_pointer(&source); if (!source->pool || !source->volume) { virReportError(VIR_ERR_XML_ERROR, "%s", _("'pool' and 'volume' must be specified together f= or 'pool' type source")); - goto cleanup; + return NULL; } if (virXMLPropEnum(node, "mode", virStorageSourcePoolModeTypeFromString, VIR_XML_PROP_NONZERO, &source->mode) < 0) - goto cleanup; - - *srcpool =3D g_steal_pointer(&source); - ret =3D 0; + return NULL; - cleanup: - virStorageSourcePoolDefFree(source); - return ret; + return g_steal_pointer(&source); } @@ -7482,7 +7469,7 @@ virDomainStorageSourceParse(xmlNodePtr node, return -1; break; case VIR_STORAGE_TYPE_VOLUME: - if (virDomainDiskSourcePoolDefParse(node, &src->srcpool) < 0) + if (!(src->srcpool =3D virDomainDiskSourcePoolDefParse(node))) return -1; break; case VIR_STORAGE_TYPE_NVME: @@ -8660,7 +8647,7 @@ virDomainFSDefParseXML(virDomainXMLOption *xmlopt, units =3D virXMLPropString(source_node, "units"); } else if (def->type =3D=3D VIR_DOMAIN_FS_TYPE_VOLUME) { def->src->type =3D VIR_STORAGE_TYPE_VOLUME; - if (virDomainDiskSourcePoolDefParse(source_node, &def->src->sr= cpool) < 0) + if (!(def->src->srcpool =3D virDomainDiskSourcePoolDefParse(so= urce_node))) goto error; } } diff --git a/src/conf/storage_source_conf.h b/src/conf/storage_source_conf.h index bfa8d625e5..0cd5cd0192 100644 --- a/src/conf/storage_source_conf.h +++ b/src/conf/storage_source_conf.h @@ -498,6 +498,7 @@ virStorageSourceInitChainElement(virStorageSource *newe= lem, void virStorageSourcePoolDefFree(virStorageSourcePoolDef *def); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virStorageSourcePoolDef, virStorageSourcePoo= lDefFree); void virStorageSourceClear(virStorageSource *def); --=20 2.41.0 From nobody Mon May 20 23:42:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1697122391; cv=none; d=zohomail.com; s=zohoarc; b=jeJvIVSehsHNzfzM2spp6Fg6jCljWrgYue5fca4vRRYzyiDSBhcSOrJbADZXlvnhI+9HAFsZCD8eh38KmzVWxBpPb3DklqNyL7hmheuh/RIkxNF54vGN6HolUa6m1BU8dapchwnlO7q/0vX8O5aOdlZ9AJTadhLQQlizhCoUG2Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697122391; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=d1Skv3PjIuLi7JB1P+xDZtGiq4ZePI0kAw66tmQ+Qqg=; b=Wu9fUevmXnimW9JZw5r0b2bHdolhCzf0oQ8/Vlvf7TGzZ1mClCIm+8ilnY7gu4EKmldMaqWbkAf/ttb/BR008M+TQr6DAoNGB7YX3QhT1LaRkMQ81XY2StgVcTySdcXMYqZqH7oi74452MoAoUwiez1qUxPznqbwMpyI1/Y8lVA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1697122391808561.2866036279643; Thu, 12 Oct 2023 07:53:11 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-517-c_p0nXNjPaKRRw8ttrWlfQ-1; Thu, 12 Oct 2023 10:53:06 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 93DAC3C0C890; Thu, 12 Oct 2023 14:53:03 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 803C71C060DF; Thu, 12 Oct 2023 14:53:03 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 219341946588; Thu, 12 Oct 2023 14:53:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 472221946586 for ; Thu, 12 Oct 2023 14:47:35 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3CB27C15BBC; Thu, 12 Oct 2023 14:47:35 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id B1D8AC1598B for ; Thu, 12 Oct 2023 14:47:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697122390; 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=d1Skv3PjIuLi7JB1P+xDZtGiq4ZePI0kAw66tmQ+Qqg=; b=aVh6Fq6DnCZsd6u0dksKVDR2d6acPxSSLj7+laN7x3iwMBIqNPa5k48OBbbvBEr6HOJjlg dVs67UCAmgHNcEVfWpuHd/15Q6xAYyHseoAs3Y3GIUiSHkvlMKaco2QP7e987LOIg3vK/2 EFxo+4B/KCg1mYMk0GXKHVNDqE0fvx8= X-MC-Unique: c_p0nXNjPaKRRw8ttrWlfQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 3/7] virDomainDiskTranslateSourcePool: Don't re-translate already translated defs Date: Thu, 12 Oct 2023 16:47:27 +0200 Message-ID: <0e7b24b0b9bb6c16b7af6c69ca921e1037808071.1697121886.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1697122392756100001 Content-Type: text/plain; charset="utf-8" If a disk definition was already translated re-doing it makes no sense. Skip the translation if the 'actualtype' is already populated. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3e0989e2e8..e128457b00 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -30529,7 +30529,7 @@ virDomainDiskTranslateSourcePool(virDomainDiskDef *= def) virStorageSource *n; for (n =3D def->src; virStorageSourceIsBacking(n); n =3D n->backingSto= re) { - if (n->type !=3D VIR_STORAGE_TYPE_VOLUME || !n->srcpool) + if (n->type !=3D VIR_STORAGE_TYPE_VOLUME || !n->srcpool || n->srcp= ool->actualtype !=3D VIR_STORAGE_TYPE_NONE) continue; if (!conn) { --=20 2.41.0 From nobody Mon May 20 23:42:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1697122578; cv=none; d=zohomail.com; s=zohoarc; b=Lwbg9LT8EXCgj+sSdRgALEq444BqQObOsfgJIzPVSGAkJM4i1FxHJ9sMneirlSfKDiqkXQ3Fmaikr8QFEcpVAyHYDylacK4j9z4qh7LYO7X9khpaX2hk3gBTseiwA4kYuvhQRd1LrAWJ8DCbTv4xnJ0XPYSXkI6x67EarnG9eI4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697122578; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=pYVpRWuKaFQv9R31OLmAYdnQLdYCVCP86tE1Tc7lLz0=; b=FOIkylc2GaZl5dwa5rx7W7qRgv63iWHJ/HRlNlnTZxv2uqn18Ulv+NdV2OW5YKJgrSV0eIzhk1Cydk2/V8uZuI61O7cvFtYSMEDxEnkYtq9PH2Ryv+ySi1d2EU2X1L9jWWdmCEN30TKECu48MRwm9vvB2h/UdCev8SlxRw5PReg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1697122578031656.9365802679246; Thu, 12 Oct 2023 07:56:18 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-479-q3EkVJGyPQyyGvFeZbvXPA-1; Thu, 12 Oct 2023 10:56:14 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 274541029F55; Thu, 12 Oct 2023 14:56:10 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 13FFF2017EA6; Thu, 12 Oct 2023 14:56:10 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5228C19465BB; Thu, 12 Oct 2023 14:56:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3456B1946586 for ; Thu, 12 Oct 2023 14:47:36 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 24A35C1598A; Thu, 12 Oct 2023 14:47:36 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9463CC15BBC for ; Thu, 12 Oct 2023 14:47:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697122577; 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=pYVpRWuKaFQv9R31OLmAYdnQLdYCVCP86tE1Tc7lLz0=; b=OPZdiRMNAo7m7BNsxJyLrVDJxE9gRXJVllEQwCV/q3GpEhyh1mhUx6DjR5SIFzpvPEUacM YXdyaeHDb/74gY6DOcYPV40BXrUI6HitnL5lVkr0ZcgONrEjqJY+XQT7GqOgyLUfK1krIC SpMdSbqsISYDB3XSZp15F6R9YptD2kc= X-MC-Unique: q3EkVJGyPQyyGvFeZbvXPA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 4/7] qemu: domain: Allow preserving translated disk type='volume' data into XML if needed Date: Thu, 12 Oct 2023 16:47:28 +0200 Message-ID: <046218dfb6a68015a3cac4d0694c8a9b88ed7db2.1697121886.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1697122579469100001 Content-Type: text/plain; charset="utf-8" Re-translating a disk type=3D'volume' definition from a storage pool is not a good idea in cases when the volume might have changed or we might not have access to the storage driver. Specific cases are if a storage pool is not activated on daemon restart, then re-connecting to a VM fails, or if the virt-aa-helper program tries to setup labelling for apparmor. Add a new flag which will preserve the translated data in the definition. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 69 ++++++++++++++++++++++++++++++------------ src/conf/domain_conf.h | 4 +++ 2 files changed, 53 insertions(+), 20 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e128457b00..9b636215e9 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7006,7 +7006,8 @@ virDomainLeaseDefParseXML(xmlNodePtr node, } static virStorageSourcePoolDef * -virDomainDiskSourcePoolDefParse(xmlNodePtr node) +virDomainDiskSourcePoolDefParse(xmlNodePtr node, + virDomainDefParseFlags flags) { g_autoptr(virStorageSourcePoolDef) source =3D g_new0(virStorageSourceP= oolDef, 1); @@ -7029,6 +7030,14 @@ virDomainDiskSourcePoolDefParse(xmlNodePtr node) &source->mode) < 0) return NULL; + if (flags & VIR_DOMAIN_DEF_PARSE_VOLUME_TRANSLATED) { + if (virXMLPropEnum(node, "actualType", + virStorageTypeFromString, + VIR_XML_PROP_NONZERO, + &source->actualtype) < 0) + return NULL; + } + return g_steal_pointer(&source); } @@ -7448,12 +7457,22 @@ virDomainStorageSourceParse(xmlNodePtr node, unsigned int flags, virDomainXMLOption *xmlopt) { + virStorageType actualType =3D src->type; VIR_XPATH_NODE_AUTORESTORE(ctxt) xmlNodePtr tmp; ctxt->node =3D node; - switch (src->type) { + if (src->type =3D=3D VIR_STORAGE_TYPE_VOLUME) { + if (!(src->srcpool =3D virDomainDiskSourcePoolDefParse(node, flags= ))) + return -1; + + /* If requested we need to also parse the translated volume runtim= e data */ + if (flags & VIR_DOMAIN_DEF_PARSE_VOLUME_TRANSLATED) + actualType =3D virStorageSourceGetActualType(src); + } + + switch (actualType) { case VIR_STORAGE_TYPE_FILE: src->path =3D virXMLPropString(node, "file"); src->fdgroup =3D virXMLPropString(node, "fdgroup"); @@ -7469,8 +7488,7 @@ virDomainStorageSourceParse(xmlNodePtr node, return -1; break; case VIR_STORAGE_TYPE_VOLUME: - if (!(src->srcpool =3D virDomainDiskSourcePoolDefParse(node))) - return -1; + /* parsed above */ break; case VIR_STORAGE_TYPE_NVME: if (virDomainDiskSourceNVMeParse(node, ctxt, src) < 0) @@ -7488,7 +7506,7 @@ virDomainStorageSourceParse(xmlNodePtr node, case VIR_STORAGE_TYPE_LAST: virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected disk type %1$s"), - virStorageTypeToString(src->type)); + virStorageTypeToString(actualType)); return -1; } @@ -8647,7 +8665,7 @@ virDomainFSDefParseXML(virDomainXMLOption *xmlopt, units =3D virXMLPropString(source_node, "units"); } else if (def->type =3D=3D VIR_DOMAIN_FS_TYPE_VOLUME) { def->src->type =3D VIR_STORAGE_TYPE_VOLUME; - if (!(def->src->srcpool =3D virDomainDiskSourcePoolDefParse(so= urce_node))) + if (!(def->src->srcpool =3D virDomainDiskSourcePoolDefParse(so= urce_node, flags))) goto error; } } @@ -22335,10 +22353,28 @@ virDomainDiskSourceFormat(virBuffer *buf, bool skipEnc, virDomainXMLOption *xmlopt) { + virStorageType actualType =3D src->type; g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; g_auto(virBuffer) childBuf =3D VIR_BUFFER_INIT_CHILD(buf); - switch (src->type) { + if (src->type =3D=3D VIR_STORAGE_TYPE_VOLUME) { + if (src->srcpool) { + virBufferEscapeString(&attrBuf, " pool=3D'%s'", src->srcpool->= pool); + virBufferEscapeString(&attrBuf, " volume=3D'%s'", src->srcpool= ->volume); + if (src->srcpool->mode) + virBufferAsprintf(&attrBuf, " mode=3D'%s'", + virStorageSourcePoolModeTypeToString(src= ->srcpool->mode)); + } + + if (flags & VIR_DOMAIN_DEF_FORMAT_VOLUME_TRANSLATED && + src->srcpool->actualtype !=3D VIR_STORAGE_TYPE_NONE) { + virBufferAsprintf(&attrBuf, " actualType=3D'%s'", + virStorageTypeToString(src->srcpool->actualt= ype)); + actualType =3D virStorageSourceGetActualType(src); + } + } + + switch (actualType) { case VIR_STORAGE_TYPE_FILE: virBufferEscapeString(&attrBuf, " file=3D'%s'", src->path); virBufferEscapeString(&attrBuf, " fdgroup=3D'%s'", src->fdgroup); @@ -22357,15 +22393,7 @@ virDomainDiskSourceFormat(virBuffer *buf, break; case VIR_STORAGE_TYPE_VOLUME: - if (src->srcpool) { - virBufferEscapeString(&attrBuf, " pool=3D'%s'", src->srcpool->= pool); - virBufferEscapeString(&attrBuf, " volume=3D'%s'", - src->srcpool->volume); - if (src->srcpool->mode) - virBufferAsprintf(&attrBuf, " mode=3D'%s'", - virStorageSourcePoolModeTypeToString(src= ->srcpool->mode)); - } - + /* formatted above */ break; case VIR_STORAGE_TYPE_NVME: @@ -22383,13 +22411,13 @@ virDomainDiskSourceFormat(virBuffer *buf, case VIR_STORAGE_TYPE_NONE: case VIR_STORAGE_TYPE_LAST: virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected disk type %1$d"), src->type); + _("unexpected disk type %1$d"), actualType); return -1; } virDomainDiskSourceFormatSlices(&childBuf, src); - if (src->type !=3D VIR_STORAGE_TYPE_NETWORK) + if (actualType !=3D VIR_STORAGE_TYPE_NETWORK) virDomainSourceDefFormatSeclabel(&childBuf, src->nseclabels, src->seclabels, flags); @@ -22408,7 +22436,7 @@ virDomainDiskSourceFormat(virBuffer *buf, if (src->pr) virStoragePRDefFormat(&childBuf, src->pr, flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE); - if (policy && src->type !=3D VIR_STORAGE_TYPE_NETWORK) + if (policy && actualType !=3D VIR_STORAGE_TYPE_NETWORK) virBufferEscapeString(&attrBuf, " startupPolicy=3D'%s'", virDomainStartupPolicyTypeToString(policy)); @@ -27512,7 +27540,8 @@ virDomainDefFormatInternalSetRootName(virDomainDef = *def, VIR_DOMAIN_DEF_FORMAT_STATUS | VIR_DOMAIN_DEF_FORMAT_ACTUAL_NET | VIR_DOMAIN_DEF_FORMAT_PCI_ORIG_STATES | - VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST, + VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST | + VIR_DOMAIN_DEF_FORMAT_VOLUME_TRANSLATED, -1); if (!(type =3D virDomainVirtTypeToString(def->virtType))) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 16289789c2..9e6dd930fa 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3734,6 +3734,8 @@ typedef enum { * 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 << 11, + /* Parse the translated disk type=3D'volume' data if present */ + VIR_DOMAIN_DEF_PARSE_VOLUME_TRANSLATED =3D 1 << 12, } virDomainDefParseFlags; typedef enum { @@ -3749,6 +3751,8 @@ typedef enum { VIR_DOMAIN_DEF_FORMAT_ALLOW_ROM =3D 1 << 6, VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT =3D 1 << 7, VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST =3D 1 << 8, + /* format disk type=3D'volume' translated data if present */ + VIR_DOMAIN_DEF_FORMAT_VOLUME_TRANSLATED =3D 1 << 9, } virDomainDefFormatFlags; /* Use these flags to skip specific domain ABI consistency checks done --=20 2.41.0 From nobody Mon May 20 23:42:26 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=1697124263; cv=none; d=zohomail.com; s=zohoarc; b=kd0CF7FK/fsl1EENL2qfqFq8QJDe9V/R53wL7dseEeEFqBJXLEwqWd4vpdXWDJzMRASXBqGwrebcIAx5Quyz56PxjYgjPXD8bDwOec6tZu7K2R2+0444KCWPObyb++2UsmtC6mO3U4zmyDFJAbGXogsGbkMATGbXK0wMoacTPwE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697124263; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=AXZ9h/Vvzy1aSsSqb2znzgGEMaZH9uLe1yg8OrWLK6s=; b=gPZXeh9EJvu4WAHdfQcenOVZgJdfIAgY+EKSGYR9XPxxd94AuXgsiHtHny8TvIGphiDVNK//JltK6/ERs3kFxVa5YBQ+TQcPKus4/4FNR1QLFO5T8f3Z6svNx3kKIJxJBfDVGmicpRQsVw/c+iQ/ZLVZoAoGFcRJFWrzDTM8MnI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1697124263498848.8921375968191; Thu, 12 Oct 2023 08:24:23 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-62-8kUNIArcPLaTXItn0RnnbA-1; Thu, 12 Oct 2023 11:24:10 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BAFD33822564; Thu, 12 Oct 2023 15:23:48 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2CA6A903; Thu, 12 Oct 2023 15:23:48 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 91B5019465A4; Thu, 12 Oct 2023 15:23:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0A4051946586 for ; Thu, 12 Oct 2023 14:47:37 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E230BC1598A; Thu, 12 Oct 2023 14:47:36 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E897C15BBC for ; Thu, 12 Oct 2023 14:47:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697124262; 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=AXZ9h/Vvzy1aSsSqb2znzgGEMaZH9uLe1yg8OrWLK6s=; b=bOxss0TbwR7aoaBrfrsFdtt+lEvLvdfC+KI9jSDqWib73DceRh7XCcralu3uQmfHBJe/a9 7kIe0AXXvvhsBPtlpjHK1k1GxNizBupSM1c/Or+hOk10CBz2Gfl3ZYbrEbAkUVADo4G2Kr v74IXNZWxKSLWDOfz5RtXqcH603ozA4= X-MC-Unique: 8kUNIArcPLaTXItn0RnnbA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 5/7] qemustatusxml2xmltest: Demonstrate use of VIR_DOMAIN_DEF_(PARSE|FORMAT)_VOLUME_TRANSLATED Date: Thu, 12 Oct 2023 16:47:29 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1697124264185100001 Content-Type: text/plain; charset="utf-8" Enable the flags in the status xml2xmtest and add an exaple to the test data. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/qemustatusxml2xmldata/modern-in.xml | 4 ++-- tests/qemustatusxml2xmltest.c | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/qemustatusxml2xmldata/modern-in.xml b/tests/qemustatusxm= l2xmldata/modern-in.xml index e139c8d38c..67e0aa4952 100644 --- a/tests/qemustatusxml2xmldata/modern-in.xml +++ b/tests/qemustatusxml2xmldata/modern-in.xml @@ -378,9 +378,9 @@
- + - + diff --git a/tests/qemustatusxml2xmltest.c b/tests/qemustatusxml2xmltest.c index 418a724b94..f1589345c3 100644 --- a/tests/qemustatusxml2xmltest.c +++ b/tests/qemustatusxml2xmltest.c @@ -30,7 +30,8 @@ testCompareStatusXMLToXMLFiles(const void *opaque) VIR_DOMAIN_DEF_PARSE_ACTUAL_NET | VIR_DOMAIN_DEF_PARSE_PCI_ORIG_STATES= | VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE | - VIR_DOMAIN_DEF_PARSE_ALLOW_POST_PARS= E_FAIL))) { + VIR_DOMAIN_DEF_PARSE_ALLOW_POST_PARS= E_FAIL | + VIR_DOMAIN_DEF_PARSE_VOLUME_TRANSLAT= ED))) { VIR_TEST_DEBUG("\nfailed to parse '%s'", data->infile); goto cleanup; } @@ -40,7 +41,8 @@ testCompareStatusXMLToXMLFiles(const void *opaque) VIR_DOMAIN_DEF_FORMAT_STATUS | VIR_DOMAIN_DEF_FORMAT_ACTUAL_NET | VIR_DOMAIN_DEF_FORMAT_PCI_ORIG_STATE= S | - VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST))= ) { + VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST | + VIR_DOMAIN_DEF_FORMAT_VOLUME_TRANSLA= TED))) { VIR_TEST_DEBUG("\nfailed to format back '%s'", data->infile); goto cleanup; } --=20 2.41.0 From nobody Mon May 20 23:42:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1697124854; cv=none; d=zohomail.com; s=zohoarc; b=iFPWMTMKtbCRMntBGbEg+UW9j6Vaf+ITUiPfJ//gggrD8LKaav5HG/zZX+/lVYFdnXlevcb1WuybzmL5yf5PBU2Wk3Z1JKECXUt2lsfr5LByAGwUnXgA3f5elhUVfkiVfSw/Y4a3P7UQJVjWV1rgkHMr8Fh6J0jwG0NJJByL5cU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697124854; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=Lhi8i+n8ULwWNsMfEc1nP1eZYZGYxHtYGkzwMkoS1fk=; b=cGhtMzS0670Q8c6KaAd9im6PWwT8RWPZ2yjP4YUsC9nxpXuKGV+2oOLsHnJQvEn38MB9Qx/vhVra1h5CK8zkmjE+eJW0LdU1Ptn/dwMu00cnjOzRXZiVMDjKCKkjoIIF9L9R0UHglOQ/F6BBj8uEscuWkDjgQkW5g2MMXOZ+OBs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 169712485441013.476283526679708; Thu, 12 Oct 2023 08:34:14 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-665-CyBgiWVOPK60rAhsNrKMnQ-1; Thu, 12 Oct 2023 11:34:05 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 33FA9185A7BC; Thu, 12 Oct 2023 15:34:03 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1EA10202701E; Thu, 12 Oct 2023 15:34:03 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CE7691946588; Thu, 12 Oct 2023 15:34:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CA8FB1946586 for ; Thu, 12 Oct 2023 14:47:37 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id AD196C1598B; Thu, 12 Oct 2023 14:47:37 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3894BC15BBC for ; Thu, 12 Oct 2023 14:47:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697124853; 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=Lhi8i+n8ULwWNsMfEc1nP1eZYZGYxHtYGkzwMkoS1fk=; b=WYN/LZP+x4usp2axLNmpNS+oKYHBYu7OQAtAtxe1nRn/SNWqhi3chvUOFLzWKjprOBI3Yx qcL3IttlFffmSCqaibuDlOl2r84V1CF7WEfGxef8wqKamB2lapaqHZ6C6hTHClvJJQlBmL xK4xrNRJsj0nk2dOghWD3YKOkkizFF0= X-MC-Unique: CyBgiWVOPK60rAhsNrKMnQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 6/7] conf: Save translated disk definition for disk type='volume' to status XML Date: Thu, 12 Oct 2023 16:47:30 +0200 Message-ID: <0754c7adb2421a7defa334fc501cb8bbe87bd18e.1697121886.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1697124855993100001 Content-Type: text/plain; charset="utf-8" Re-translating the disk source pools when reconnecting to a VM makes no sense as the volume might have changed or pool became inactive. The VM still uses the original volume though. Failing to re-translate the pool also causes the VM to be killed. Fix this by storing the original translation in the status XML. Resolves: https://issues.redhat.com/browse/RHEL-7345 Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 3 ++- src/conf/virdomainobjlist.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 9b636215e9..80f467ae7a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -28247,7 +28247,8 @@ virDomainObjSave(virDomainObj *obj, VIR_DOMAIN_DEF_FORMAT_STATUS | VIR_DOMAIN_DEF_FORMAT_ACTUAL_NET | VIR_DOMAIN_DEF_FORMAT_PCI_ORIG_STATES | - VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST); + VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST | + VIR_DOMAIN_DEF_FORMAT_VOLUME_TRANSLATED); g_autofree char *xml =3D NULL; diff --git a/src/conf/virdomainobjlist.c b/src/conf/virdomainobjlist.c index 6be5de5e2b..0bd833257d 100644 --- a/src/conf/virdomainobjlist.c +++ b/src/conf/virdomainobjlist.c @@ -532,7 +532,8 @@ virDomainObjListLoadStatus(virDomainObjList *doms, VIR_DOMAIN_DEF_PARSE_ACTUAL_NET | VIR_DOMAIN_DEF_PARSE_PCI_ORIG_STATES= | VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE | - VIR_DOMAIN_DEF_PARSE_ALLOW_POST_PARS= E_FAIL))) + VIR_DOMAIN_DEF_PARSE_ALLOW_POST_PARS= E_FAIL | + VIR_DOMAIN_DEF_PARSE_VOLUME_TRANSLAT= ED))) goto error; virUUIDFormat(obj->def->uuid, uuidstr); --=20 2.41.0 From nobody Mon May 20 23:42:26 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=1697122114; cv=none; d=zohomail.com; s=zohoarc; b=DlodZuYLwLLJdJ52isF3xAiJYR7F5bU+5RCYyAWbiPO408yYXIGkMnseEcimzoI97YI2bYbC+jQfzAxPPOzZC96dJzWYIRAqJA5FT4HpD0KaVxBfofsOeBdkmIZRiG7220PJtSqkQkBLBiPsMj0VZjsS6DtSLU1Y8jUascucXGU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697122114; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=lZHW/to8ilQqQXF+tpciVrSpuJqNQl+IGP6bjR41e9w=; b=OZI4YmcrxVweWjVr8uKq63K0WYpL+otbWqjF85AvdEUpTTuRZDlUqwz/T+DKvNZM1f39YvYPEGO95iYKFjWgMYNQabPwCO7+xmdZSVGzKmlvYLXo7Q2zvqAR+E44sAw9h3YMHi3eAKjs9zhoI0xxUH+V/GxLOafBSsie0BmbN1M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1697122114444173.0045135648886; Thu, 12 Oct 2023 07:48:34 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-288-RPb4kE4dNdidKvPMEwV0Sw-1; Thu, 12 Oct 2023 10:48:30 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 12E671871DB4; Thu, 12 Oct 2023 14:48:27 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 977BD2157F5B; Thu, 12 Oct 2023 14:48:25 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1A95C1946588; Thu, 12 Oct 2023 14:48:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 93B861946586 for ; Thu, 12 Oct 2023 14:47:38 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 7807CC15BBC; Thu, 12 Oct 2023 14:47:38 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 05BFCC1598A for ; Thu, 12 Oct 2023 14:47:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697122113; 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=lZHW/to8ilQqQXF+tpciVrSpuJqNQl+IGP6bjR41e9w=; b=QNvRrOjsmKoyBCEIdoIGUUwsljJe91NLdesen9WNjG2Zo5iqWiBPG5qBnRh4/siGD2/AJe I/cdeingO1EjZ4y2x38FZSrUx9S+0+PKe1SnwcTp9t+MPFinHkmG8Hp4/gxfV6/JOVPqQ+ O4gbY3V6f53GIzR9W4g8p2cUvw5CbNY= X-MC-Unique: RPb4kE4dNdidKvPMEwV0Sw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 7/7] security: apparmor: Use translated disk definitions for disk type=volume Date: Thu, 12 Oct 2023 16:47:31 +0200 Message-ID: <3cf2bf1ef3ca32dc4cafd8e6c5bbe0c41dc0a0e9.1697121886.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1697122115647100001 Content-Type: text/plain; charset="utf-8" The 'virt-aa-helper' process gets a XML of the VM it needs to create a profile for. For a disk type=3D'volume' this XML contained only the pool and volume name. The 'virt-aa-helper' needs a local path though for anything it needs to label. This means that we'd either need to invoke connection to the storage driver and re-resolve the volume. Alternative which makes more sense is to pass the proper data in the XML already passed to it via the new XML formatter and parser flags. This was indirectly reported upstream in https://gitlab.com/libvirt/libvirt/-/issues/546 The configuration in the issue above was created by Cockpit on Debian. Since Cockpit is getting more popular it's more likely that users will be impacted by this problem. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/security/security_apparmor.c | 8 ++++++-- src/security/virt-aa-helper.c | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/security/security_apparmor.c b/src/security/security_appar= mor.c index bce797de7c..6fd0aedacf 100644 --- a/src/security/security_apparmor.c +++ b/src/security/security_apparmor.c @@ -159,13 +159,17 @@ load_profile(virSecurityManager *mgr G_GNUC_UNUSED, bool append) { bool create =3D true; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; g_autofree char *xml =3D NULL; g_autoptr(virCommand) cmd =3D NULL; - xml =3D virDomainDefFormat(def, NULL, VIR_DOMAIN_DEF_FORMAT_SECURE); - if (!xml) + if (virDomainDefFormatInternal(def, NULL, &buf, + VIR_DOMAIN_DEF_FORMAT_SECURE | + VIR_DOMAIN_DEF_FORMAT_VOLUME_TRANSLATED= ) < 0) return -1; + xml =3D virBufferContentAndReset(&buf); + if (profile_status_file(profile) >=3D 0) create =3D false; diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 0855eb68ca..be13979cef 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -654,7 +654,8 @@ get_definition(vahControl * ctl, const char *xmlStr) ctl->def =3D virDomainDefParseString(xmlStr, ctl->xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_SKIP_SECLABEL | - VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE); + VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE | + VIR_DOMAIN_DEF_PARSE_VOLUME_TRANSLA= TED); if (ctl->def =3D=3D NULL) { vah_error(ctl, 0, _("could not parse XML")); --=20 2.41.0