From nobody Mon Feb 9 01:21:02 2026 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 --- 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