From nobody Mon May 6 00:28:37 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; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com 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 1626089579002122.96092074268847; Mon, 12 Jul 2021 04:32: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-162-6gwf-Vi4NY6wT8bLzC9Bhg-1; Mon, 12 Jul 2021 07:32:56 -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 8AA84804141; Mon, 12 Jul 2021 11:32:51 +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 68F005C225; Mon, 12 Jul 2021 11:32: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 353294EA3A; Mon, 12 Jul 2021 11:32:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 16CBWWj1020850 for ; Mon, 12 Jul 2021 07:32:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id A8ABD21686A8; Mon, 12 Jul 2021 11:32:32 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A3F5521686A5 for ; Mon, 12 Jul 2021 11:32:29 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (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 7675E108C0E1 for ; Mon, 12 Jul 2021 11:32:29 +0000 (UTC) Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-263-Wzim78D0Pr28XNLbjLOzRg-1; Mon, 12 Jul 2021 07:32:27 -0400 Received: by mail-pg1-f175.google.com with SMTP id y4so15405801pgl.10 for ; Mon, 12 Jul 2021 04:32:27 -0700 (PDT) Received: from localhost ([103.142.141.217]) by smtp.gmail.com with ESMTPSA id p24sm17137192pgl.68.2021.07.12.04.32.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jul 2021 04:32:25 -0700 (PDT) X-MC-Unique: 6gwf-Vi4NY6wT8bLzC9Bhg-1 X-MC-Unique: Wzim78D0Pr28XNLbjLOzRg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Z3A9vI2FOlHFb9QPrMuoAM5DoyT7yvGSBFi1XN2TDjU=; b=YhgP2wveknvVuAWuu1lKV+C45aTMb8imkCMu3EoAfEp5j9h/qPxuVpN3XXWSbUkjzd zzNhBtDELodHXMNOCQ3kvXWLi53i0HSZbgwasWkuv9nhjiBqzLJDH1yl9f2NraF9uYlz bW4qRcqaVijQvZbqbBis/oDS7VLOI9aSx+hA5cYyC/1vjUlMbZJyhAdxzPgEINlJ4Irm G/K3MESSiMFmqBeru6gU/Y/nkcGl199Pxm0J3CBr4cOGVcQGq6t7KbF92cXLG2D2poP/ ViMLWumKpKENNYsiPTYhO6tjkSsIpDfnRS8Hnax/UKvWv8dlS8iNmD2PkZBR62+egM88 5X0A== X-Gm-Message-State: AOAM532zhIDi93VoYJMTtxPmFDni6IYG77D8nbbg6DPYMVBrxoCghGb4 quFxGBHHFBdF9NIhTD7koVZe+7wEC/Dveuu0TLk= X-Google-Smtp-Source: ABdhPJwUj4E707cyKyRCYe8nK4OkMyVMhdLziOQAvsejtHFxJsQso0iNJwpSkvpj+msO+PsaMc5uTA== X-Received: by 2002:a65:63c3:: with SMTP id n3mr3829072pgv.369.1626089546115; Mon, 12 Jul 2021 04:32:26 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v4 1/4] conf: domain: Introduce and use virDomainObjGetMessages() Date: Mon, 12 Jul 2021 19:32:14 +0800 Message-Id: <20210712113217.60492-2-lukedyue@gmail.com> In-Reply-To: <20210712113217.60492-1-lukedyue@gmail.com> References: <20210712113217.60492-1-lukedyue@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 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-ZM-MESSAGEID: 1626089581066100001 Content-Type: text/plain; charset="utf-8" The test driver and qemu driver could share the same code in virDomainGetMessages(), so extract it to a function. Signed-off-by: Luke Yue Reviewed-by: Martin Kletzander --- src/conf/domain_conf.c | 53 ++++++++++++++++++++++++++++++++++++++++ src/conf/domain_conf.h | 5 ++++ src/libvirt_private.syms | 1 + src/qemu/qemu_driver.c | 34 +------------------------- 4 files changed, 60 insertions(+), 33 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 2d8ae7e860..09aa81f476 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -31134,3 +31134,56 @@ virHostdevIsVFIODevice(const virDomainHostdevDef *= hostdev) hostdev->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_= PCI && hostdev->source.subsys.u.pci.backend =3D=3D VIR_DOMAIN_HOSTDEV_PCI= _BACKEND_VFIO; } + + +/** + * virDomainObjGetMessages: + * @vm: domain object + * @msgs: pointer to a variable to store messages + * @flags: zero or more virDomainMessageType flags + * + * Returns number of messages stored in @msgs, -1 otherwise. + */ +int +virDomainObjGetMessages(virDomainObj *vm, + char ***msgs, + unsigned int flags) +{ + size_t i, n; + int nmsgs; + int rv =3D -1; + + *msgs =3D NULL; + nmsgs =3D 0; + n =3D 0; + + if (!flags || (flags & VIR_DOMAIN_MESSAGE_TAINTING)) { + nmsgs +=3D __builtin_popcount(vm->taint); + *msgs =3D g_renew(char *, *msgs, nmsgs+1); + + for (i =3D 0; i < VIR_DOMAIN_TAINT_LAST; i++) { + if (vm->taint & (1 << i)) { + (*msgs)[n++] =3D g_strdup_printf( + _("tainted: %s"), + _(virDomainTaintMessageTypeToString(i))); + } + } + } + + if (!flags || (flags & VIR_DOMAIN_MESSAGE_DEPRECATION)) { + nmsgs +=3D vm->ndeprecations; + *msgs =3D g_renew(char *, *msgs, nmsgs+1); + + for (i =3D 0; i < vm->ndeprecations; i++) { + (*msgs)[n++] =3D g_strdup_printf( + _("deprecated configuration: %s"), + vm->deprecations[i]); + } + } + + (*msgs)[nmsgs] =3D NULL; + + rv =3D nmsgs; + + return rv; +} diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index c31531c93b..35cdfa3a9f 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -4142,3 +4142,8 @@ virHostdevIsMdevDevice(const virDomainHostdevDef *hos= tdev) bool virHostdevIsVFIODevice(const virDomainHostdevDef *hostdev) ATTRIBUTE_NONNULL(1); + +int +virDomainObjGetMessages(virDomainObj *vm, + char ***msgs, + unsigned int flags); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index cc7533a707..b20bcb2c65 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -564,6 +564,7 @@ virDomainObjDeprecation; virDomainObjEndAPI; virDomainObjFormat; virDomainObjGetDefs; +virDomainObjGetMessages; virDomainObjGetMetadata; virDomainObjGetOneDef; virDomainObjGetOneDefState; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 235f575901..592e1236e7 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -20319,8 +20319,6 @@ qemuDomainGetMessages(virDomainPtr dom, { virDomainObj *vm =3D NULL; int rv =3D -1; - size_t i, n; - int nmsgs; =20 virCheckFlags(VIR_DOMAIN_MESSAGE_DEPRECATION | VIR_DOMAIN_MESSAGE_TAINTING, -1); @@ -20331,37 +20329,7 @@ qemuDomainGetMessages(virDomainPtr dom, if (virDomainGetMessagesEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - *msgs =3D NULL; - nmsgs =3D 0; - n =3D 0; - - if (!flags || (flags & VIR_DOMAIN_MESSAGE_TAINTING)) { - nmsgs +=3D __builtin_popcount(vm->taint); - *msgs =3D g_renew(char *, *msgs, nmsgs+1); - - for (i =3D 0; i < VIR_DOMAIN_TAINT_LAST; i++) { - if (vm->taint & (1 << i)) { - (*msgs)[n++] =3D g_strdup_printf( - _("tainted: %s"), - _(virDomainTaintMessageTypeToString(i))); - } - } - } - - if (!flags || (flags & VIR_DOMAIN_MESSAGE_DEPRECATION)) { - nmsgs +=3D vm->ndeprecations; - *msgs =3D g_renew(char *, *msgs, nmsgs+1); - - for (i =3D 0; i < vm->ndeprecations; i++) { - (*msgs)[n++] =3D g_strdup_printf( - _("deprecated configuration: %s"), - vm->deprecations[i]); - } - } - - (*msgs)[nmsgs] =3D NULL; - - rv =3D nmsgs; + rv =3D virDomainObjGetMessages(vm, msgs, flags); =20 cleanup: virDomainObjEndAPI(&vm); --=20 2.32.0 From nobody Mon May 6 00:28:37 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; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com 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 16260895668331008.1131434162495; Mon, 12 Jul 2021 04:32:46 -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-322-K0Tmand5POKMofwqnzM5HA-1; Mon, 12 Jul 2021 07:32:44 -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 13521100C611; Mon, 12 Jul 2021 11:32:39 +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 E344560871; Mon, 12 Jul 2021 11:32:38 +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 1E0264EA29; Mon, 12 Jul 2021 11:32:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 16CBWZ0G020869 for ; Mon, 12 Jul 2021 07:32:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id B23B46B5B8; Mon, 12 Jul 2021 11:32:35 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ACF806B5BF for ; Mon, 12 Jul 2021 11:32:32 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (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 E1E9780D2B6 for ; Mon, 12 Jul 2021 11:32:31 +0000 (UTC) Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-581-F48y7Nz6OhKDaHGNv27vlg-1; Mon, 12 Jul 2021 07:32:29 -0400 Received: by mail-pf1-f177.google.com with SMTP id 17so16128929pfz.4 for ; Mon, 12 Jul 2021 04:32:29 -0700 (PDT) Received: from localhost ([103.142.141.217]) by smtp.gmail.com with ESMTPSA id o34sm17766315pgm.6.2021.07.12.04.32.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jul 2021 04:32:28 -0700 (PDT) X-MC-Unique: K0Tmand5POKMofwqnzM5HA-1 X-MC-Unique: F48y7Nz6OhKDaHGNv27vlg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KRG9C1HKMwPjnk2BruBSB8UsaZ//UvzSq8dkJiIrSqU=; b=MSaJWXS7c+h7o6/3otsKku5IwXwILHZt25PuM5ylLrNBFkYnvtCZdA6QFga8vTztXB FRxzD1XbpHXIZS1772LaLtMWzIElud2EnA4uZocfbn//ptZ2AURmz9MGya8RAlU58+VN EqRNOY6KmTF3ZA5/Wkmw1/hiLzAn1XVCU6/Pn63fQlhTWlvr6nTSacfjQKphnp3KjiP0 qH7E73fKSdeRc/VO5UdzhCu15GrfEZ7EfY4gGbOHvT44QYibCAVGPyTfSjqp4615tTk/ U2khhqnMNAlQSP+59/2pQPkHAUL+IaLYai6zDizG8U6pSYuymfbBe2uRloXpKUYMZltJ E67A== X-Gm-Message-State: AOAM532lA/FPDyxDS+ysUpobyfpQR7n1U6gdD5wTlRH2jTaqPyidIN4A a0QJyBQiel9NJvYxa36t4oFPYAohsZk3ebNdMIU= X-Google-Smtp-Source: ABdhPJys1E37de8hq9Lh0ckjrhtIGZugnDFAIWzmGDxtEVMI0YnnUJylPOwY29RCFbeBzJu8sPmuWA== X-Received: by 2002:a62:ed06:0:b029:32c:a800:ba47 with SMTP id u6-20020a62ed060000b029032ca800ba47mr2403918pfh.56.1626089548719; Mon, 12 Jul 2021 04:32:28 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v4 2/4] test_driver: Implement virDomainGetMessages Date: Mon, 12 Jul 2021 19:32:15 +0800 Message-Id: <20210712113217.60492-3-lukedyue@gmail.com> In-Reply-To: <20210712113217.60492-1-lukedyue@gmail.com> References: <20210712113217.60492-1-lukedyue@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 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-ZM-MESSAGEID: 1626089567879100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Luke Yue Reviewed-by: Martin Kletzander --- src/test/test_driver.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 65710b78ef..ef406a3d99 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -9331,6 +9331,26 @@ testDomainCheckpointDelete(virDomainCheckpointPtr ch= eckpoint, return ret; } =20 +static int +testDomainGetMessages(virDomainPtr dom, + char ***msgs, + unsigned int flags) +{ + virDomainObj *vm =3D NULL; + int rv =3D -1; + + virCheckFlags(VIR_DOMAIN_MESSAGE_DEPRECATION | + VIR_DOMAIN_MESSAGE_TAINTING, -1); + + if (!(vm =3D testDomObjFromDomain(dom))) + return -1; + + rv =3D virDomainObjGetMessages(vm, msgs, flags); + + virDomainObjEndAPI(&vm); + return rv; +} + /* * Test driver */ @@ -9489,6 +9509,7 @@ static virHypervisorDriver testHypervisorDriver =3D { .domainCheckpointLookupByName =3D testDomainCheckpointLookupByName, /*= 5.6.0 */ .domainCheckpointGetParent =3D testDomainCheckpointGetParent, /* 5.6.0= */ .domainCheckpointDelete =3D testDomainCheckpointDelete, /* 5.6.0 */ + .domainGetMessages =3D testDomainGetMessages, /* 7.6.0 */ }; =20 static virNetworkDriver testNetworkDriver =3D { --=20 2.32.0 From nobody Mon May 6 00:28:37 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; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com 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 1626089583574112.51594230876276; Mon, 12 Jul 2021 04:33: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-448-9XCvhZUaMHyUuTUlejhWYA-1; Mon, 12 Jul 2021 07:33:00 -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 A35D1100C61B; Mon, 12 Jul 2021 11:32:55 +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 814EB60871; Mon, 12 Jul 2021 11:32:55 +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 46FB11809CAC; Mon, 12 Jul 2021 11:32:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 16CBWYia020863 for ; Mon, 12 Jul 2021 07:32:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id BA4BA21686A8; Mon, 12 Jul 2021 11:32:34 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B646821686A5 for ; Mon, 12 Jul 2021 11:32:34 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (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 99B57800FFB for ; Mon, 12 Jul 2021 11:32:34 +0000 (UTC) Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-98-oEr5_XYBMASXAuHC2H-ulQ-1; Mon, 12 Jul 2021 07:32:32 -0400 Received: by mail-pl1-f182.google.com with SMTP id j3so7077491plx.7 for ; Mon, 12 Jul 2021 04:32:32 -0700 (PDT) Received: from localhost ([103.142.141.217]) by smtp.gmail.com with ESMTPSA id y1sm15794882pfe.72.2021.07.12.04.32.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jul 2021 04:32:31 -0700 (PDT) X-MC-Unique: 9XCvhZUaMHyUuTUlejhWYA-1 X-MC-Unique: oEr5_XYBMASXAuHC2H-ulQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iry8xoCGZht9s+C59m3QY4iQmEfoVDQmwBSXCYcC7xc=; b=MfhJddF/FcSOvYT2ze3eAyxqCEw0ruX1xpD5kkPQvzIMVOoEry5Rtb5y2cusCOaTYg Tjs5uuwW5asHm97L6u4IwGZf2Tx70Ipf7enqHJ06ErCMsrlFzOXAbdcaYQuxvCBma9wE Z3c7pHb/8zgXRgQrueV5cZFdpX5JY9mIKHDQxOZkx6k7R7dtYbQIT9gOHfIBjoYC5yEg Kb/UOpteQqxS8S1tlj/LFpmSpl1ldTxxZb3ZOOc6XS6GTHuLUVAFbZf2aGyPXnWwI11k Oq8e8GwyA73HIv2k8oUfkESYdw5xc+9ZNgmfZWqBb4asG5vLOw45Y4oe1+gWX9TGOKGI BRIg== X-Gm-Message-State: AOAM5332GK7koguxHuxLsQh+ZWqcFo/UkAMGcp6bLDVtifhWFZ6cGRRC QS/x2+4+MxD+vJed+y+h9yYSQRlfV54QNjSgbl8= X-Google-Smtp-Source: ABdhPJw/BFG+nZGy9qF2+9NnCeZLnRNNcRjhQwAx1cHi11Y6+CbI/RIBaWH/skLRtOYJFPkXWzqviA== X-Received: by 2002:a17:902:7488:b029:129:c9cd:67ec with SMTP id h8-20020a1709027488b0290129c9cd67ecmr23254337pll.58.1626089551231; Mon, 12 Jul 2021 04:32:31 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v4 3/4] test_driver: Introduce testDomainObjCheckTaint Date: Mon, 12 Jul 2021 19:32:16 +0800 Message-Id: <20210712113217.60492-4-lukedyue@gmail.com> In-Reply-To: <20210712113217.60492-1-lukedyue@gmail.com> References: <20210712113217.60492-1-lukedyue@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 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-ZM-MESSAGEID: 1626089585815100001 Content-Type: text/plain; charset="utf-8" In order to test the virDomainGetMessages for test driver, we need to check some taints or deprecations, so introduce testDomainObjCheckTaint for checking taints. As we introduced testDomainObjCheckTaint for test driver, the `dominfo` command in virshtest will now print tainting messages, so add them for test. Signed-off-by: Luke Yue Reviewed-by: Martin Kletzander --- src/test/test_driver.c | 77 ++++++++++++++++++++++++++++++++++++++++++ tests/virshtest.c | 2 ++ 2 files changed, 79 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index ef406a3d99..ca9c2fa2fb 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -747,6 +747,81 @@ static char *testBuildFilename(const char *relativeTo, return g_strdup_printf("%s/%s", basename, filename); } =20 +static void +testDomainObjCheckCPUTaint(virDomainObj *obj) +{ + switch (obj->def->cpu->mode) { + case VIR_CPU_MODE_CUSTOM: + if (obj->def->cpu->model) + if (STREQ(obj->def->cpu->model, "Deprecated-Test")) { + virDomainObjTaint(obj, VIR_DOMAIN_TAINT_DEPRECATED_CONFIG); + virDomainObjDeprecation(obj, "CPU model Deprecated-Test"); + } + + break; + default: + break; + } +} + +static void +testDomainObjCheckDiskTaint(virDomainObj *obj, + virDomainDiskDef *disk) +{ + if (disk->rawio =3D=3D VIR_TRISTATE_BOOL_YES) + virDomainObjTaint(obj, VIR_DOMAIN_TAINT_HIGH_PRIVILEGES); + + if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_CDROM && + virStorageSourceGetActualType(disk->src) =3D=3D VIR_STORAGE_TYPE_B= LOCK && + disk->src->path) + virDomainObjTaint(obj, VIR_DOMAIN_TAINT_CDROM_PASSTHROUGH); +} + +static void +testDomainObjCheckHostdevTaint(virDomainObj *obj, + virDomainHostdevDef *hostdev) +{ + if (!virHostdevIsSCSIDevice(hostdev)) + return; + + if (hostdev->source.subsys.u.scsi.rawio =3D=3D VIR_TRISTATE_BOOL_YES) + virDomainObjTaint(obj, VIR_DOMAIN_TAINT_HIGH_PRIVILEGES); +} + +static void +testDomainObjCheckNetTaint(virDomainObj *obj, + virDomainNetDef *net) +{ + /* script is only useful for NET_TYPE_ETHERNET (qemu) and + * NET_TYPE_BRIDGE (xen), but could be (incorrectly) specified for + * any interface type. In any case, it's adding user sauce into + * the soup, so it should taint the domain. + */ + if (net->script !=3D NULL) + virDomainObjTaint(obj, VIR_DOMAIN_TAINT_SHELL_SCRIPTS); +} + +static void +testDomainObjCheckTaint(virDomainObj *obj) +{ + size_t i; + + for (i =3D 0; i < obj->def->ndisks; i++) + testDomainObjCheckDiskTaint(obj, obj->def->disks[i]); + + for (i =3D 0; i < obj->def->nhostdevs; i++) + testDomainObjCheckHostdevTaint(obj, obj->def->hostdevs[i]); + + for (i =3D 0; i < obj->def->nnets; i++) + testDomainObjCheckNetTaint(obj, obj->def->nets[i]); + + if (obj->def->cpu) + testDomainObjCheckCPUTaint(obj); + + if (obj->def->os.dtb) + virDomainObjTaint(obj, VIR_DOMAIN_TAINT_CUSTOM_DTB); +} + static xmlNodePtr testParseXMLDocFromFile(xmlNodePtr node, const char *file, const char *typ= e) { @@ -969,6 +1044,8 @@ testParseDomains(testDriver *privconn, } virDomainObjSetState(obj, nsdata->runstate, 0); =20 + testDomainObjCheckTaint(obj); + virDomainObjEndAPI(&obj); } =20 diff --git a/tests/virshtest.c b/tests/virshtest.c index c1974c46cb..937448cefc 100644 --- a/tests/virshtest.c +++ b/tests/virshtest.c @@ -22,6 +22,7 @@ main(void) =20 # define DOM_UUID "ef861801-45b9-11cb-88e3-afbfe5370493" # define SECURITY_LABEL "libvirt-test (enforcing)" +# define MESSAGES "tainted: network configuration using opaque shell scrip= ts" =20 static const char *dominfo_fc4 =3D "\ Id: 2\n\ @@ -38,6 +39,7 @@ Managed save: no\n\ Security model: testSecurity\n\ Security DOI: \n\ Security label: " SECURITY_LABEL "\n\ +Messages: " MESSAGES "\n\ \n"; static const char *domuuid_fc4 =3D DOM_UUID "\n\n"; static const char *domid_fc4 =3D "2\n\n"; --=20 2.32.0 From nobody Mon May 6 00:28:37 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; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com 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 1626089585498259.6009887304036; Mon, 12 Jul 2021 04:33:05 -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-334-23XCYnOUOSaIoKEh1qVY8w-1; Mon, 12 Jul 2021 07:33:02 -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 03B7C100CA89; Mon, 12 Jul 2021 11:32:52 +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 D63481383B; Mon, 12 Jul 2021 11:32: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 9EA3A1809C99; Mon, 12 Jul 2021 11:32:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 16CBWbcx020882 for ; Mon, 12 Jul 2021 07:32:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6A15763536; Mon, 12 Jul 2021 11:32:37 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 658EF64695 for ; Mon, 12 Jul 2021 11:32:37 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (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 4990C800B36 for ; Mon, 12 Jul 2021 11:32:37 +0000 (UTC) Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-295-kVV1rE4UN-OtiJKlUUplWQ-1; Mon, 12 Jul 2021 07:32:35 -0400 Received: by mail-pg1-f172.google.com with SMTP id h4so17895965pgp.5 for ; Mon, 12 Jul 2021 04:32:34 -0700 (PDT) Received: from localhost ([103.142.141.217]) by smtp.gmail.com with ESMTPSA id h20sm16207618pfn.173.2021.07.12.04.32.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jul 2021 04:32:33 -0700 (PDT) X-MC-Unique: 23XCYnOUOSaIoKEh1qVY8w-1 X-MC-Unique: kVV1rE4UN-OtiJKlUUplWQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MUPHO/JKFN2IAOVCiBIpUQ4wM7O86FYS/qQfFG566Eo=; b=Jt/mUARjwCI6RaG8zM/mAihOY/jFWoaJwuPDOgQUK7MScXcHXhLZy0YbxZ0cTEfS6H s4xYR+fWRfZABq0vK7qryvgAGa7eoPG5AhQ6rzQ3/h5OkiDjZYXlfvo7SGk3LZgA7Dsy ZQap2eSoAbdnu68d+fhVJWq82tYfefjzhUSmoYiPCVEd3JIgZcgD2t+3FB4z8BDejkur P6Lid7B3ocPRTsldArxNm0tmfISeh5QuYAFD+OwGx6HqBQ8vek/Y7L7RiltkItMh28mo OwScOwGHpK+qMWPPlByA7cFxFRhU6LsCnaeVae+Y3apQprjQD8CGWM+FP6n3E6nymfy/ FYSQ== X-Gm-Message-State: AOAM533YnBe2bwzMIbl6lJtqWNNdV3Ue7C60/xXxDXFX/dooqih0ipFk ylDBCGTDQ0mecDqjoqylF10ZygyqVZkFhAuo7p0= X-Google-Smtp-Source: ABdhPJzu79y58kQF2rut5EHBw7lrNIDBu3ot/z5TXLlCW8vTBxnAF4ZDLUw+fcCG7sfh1txx/pEuyQ== X-Received: by 2002:a63:d211:: with SMTP id a17mr52916038pgg.265.1626089553763; Mon, 12 Jul 2021 04:32:33 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v4 4/4] examples: test: Add a new test xml with more tainted configs for testing Date: Mon, 12 Jul 2021 19:32:17 +0800 Message-Id: <20210712113217.60492-5-lukedyue@gmail.com> In-Reply-To: <20210712113217.60492-1-lukedyue@gmail.com> References: <20210712113217.60492-1-lukedyue@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 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-ZM-MESSAGEID: 1626089587669100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Luke Yue Reviewed-by: Martin Kletzander --- examples/xml/test/testdomfc5.xml | 51 ++++++++++++++++++++++++++ examples/xml/test/testnode.xml | 1 + examples/xml/test/testnodeinline.xml | 51 ++++++++++++++++++++++++++ tests/virshtest.c | 54 +++++++++++++++++++++++----- 4 files changed, 148 insertions(+), 9 deletions(-) create mode 100644 examples/xml/test/testdomfc5.xml diff --git a/examples/xml/test/testdomfc5.xml b/examples/xml/test/testdomfc= 5.xml new file mode 100644 index 0000000000..a8afc211f6 --- /dev/null +++ b/examples/xml/test/testdomfc5.xml @@ -0,0 +1,51 @@ + + fc5 + 08721f993d1d4aec96eb97803297bb36 + + Deprecated-Test + Libvirt + + + + hvm + /usr/lib/xen/boot/hvmloader + /root/ppc.dtb + + + 2097152 + 4 + destroy + restart + restart + + + + + + + /usr/lib/xen/bin/qemu-dm + + + +