From nobody Fri May 3 17:01:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1623676402626732.9322864924345; Mon, 14 Jun 2021 06:13:22 -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-195-_2Pzp88jPgKbuvmLkQiBew-1; Mon, 14 Jun 2021 09:13:20 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E46DA80ED8E; Mon, 14 Jun 2021 13:13:14 +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 03B4718AD4; Mon, 14 Jun 2021 13:13:14 +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 706AC4EA6C; Mon, 14 Jun 2021 13:13:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15EDDAZI030083 for ; Mon, 14 Jun 2021 09:13:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0DAB8111CB9E; Mon, 14 Jun 2021 13:13:10 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 09127111CB9C for ; Mon, 14 Jun 2021 13:13:06 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (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 BC9AD82A6C6 for ; Mon, 14 Jun 2021 13:13:06 +0000 (UTC) Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.182]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-427-YbHLSamQNNiVTyQkkQazxA-1; Mon, 14 Jun 2021 09:13:04 -0400 Received: by mail-pg1-f182.google.com with SMTP id n12so8570830pgs.13 for ; Mon, 14 Jun 2021 06:13:04 -0700 (PDT) Received: from localhost ([103.142.141.217]) by smtp.gmail.com with ESMTPSA id u20sm12524941pfn.192.2021.06.14.06.13.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 06:13:02 -0700 (PDT) X-MC-Unique: _2Pzp88jPgKbuvmLkQiBew-1 X-MC-Unique: YbHLSamQNNiVTyQkkQazxA-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:mime-version :content-transfer-encoding; bh=f1SOPaARnKuRU/lUQJGLQsIlGbEKCE8CzeyZtrEUsuw=; b=lcjahTsCmXBcJ5HZJG5a4OLo1kEW/wMMH5XgfEVn+rpza5qBPSp6ly1JfZX8uyL0g2 BtR2ITN57vjA+COeR/zSCeJbhaJGGHVEvsJjHU70SH0qbpbCPMbU4JEaZDeO2f4I93NA vjT/SsVB5PDXcp0AlidLx6FIO1x/lnJGTqbpsNE6SlquIPqVhd/Voieo7ooqyh+/BQAP bAcGmKgCm3cEP0yvguEahKpUfEAsuDMSeW9bzliOELzDwAH7W2YXZJGHImEHphg+ssy/ Y38pHh2zJJ8FeSyM42K6Oj4ODJRLVyGaF1r6JGZpcrNMglbxQMpyl0VTvSOO/8Ku8IlA hcNg== X-Gm-Message-State: AOAM530Om8KLsHno5Hr7WLxCJ1LnsBHoDzyuYWZ5Ig80J7LcM+Psp1hU kixKQMy906+mafEfhPXdnsn4trJu1N2Iz6F7C0E= X-Google-Smtp-Source: ABdhPJxPfIjCdgv2avKqjaITYtBNWnQx5gmQ2x4BV6o21nCLryttS+6tFpmytJ6prg3ZEB8wO/3A3Q== X-Received: by 2002:a63:3246:: with SMTP id y67mr13947344pgy.244.1623676382906; Mon, 14 Jun 2021 06:13:02 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH] test_driver: Implement virDomainGetSecurityLabelList Date: Mon, 14 Jun 2021 21:12:57 +0800 Message-Id: <20210614131257.28841-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.3 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Signed-off-by: Luke Yue --- src/test/test_driver.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 611ec6d7ec..ae1b8ebc23 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -136,6 +136,7 @@ VIR_ONCE_GLOBAL_INIT(testDriver); =20 #define TEST_MODEL "i686" #define TEST_EMULATOR "/usr/bin/test-hv" +#define TEST_SECURITY_LABEL_LIST_LENGTH 2 =20 static const virNodeInfo defaultNodeInfo =3D { TEST_MODEL, @@ -5037,6 +5038,45 @@ testDomainGetSecurityLabel(virDomainPtr dom, return ret; } =20 +static int +testDomainGetSecurityLabelList(virDomainPtr dom, + virSecurityLabelPtr* seclabels) +{ + virDomainObj *vm; + size_t i; + int ret =3D -1; + + if (!(vm =3D testDomObjFromDomain(dom))) + return -1; + + if (!virDomainObjIsActive(vm)) { + /* No seclabels */ + *seclabels =3D NULL; + ret =3D 0; + } else { + int len =3D TEST_SECURITY_LABEL_LIST_LENGTH; + + (*seclabels) =3D g_new0(virSecurityLabel, len); + memset(*seclabels, 0, sizeof(**seclabels) * len); + + /* Fill the array */ + for (i =3D 0; i < len; i++) { + if (virStrcpyStatic(seclabels[i]->label, "libvirt-test") < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("security label exceeds maximum: %zu"), + sizeof(seclabels[i]->label) - 1); + VIR_FREE(*seclabels); + goto cleanup; + } + } + ret =3D len; + } + + cleanup: + virDomainObjEndAPI(&vm); + return ret; +} + static int testNodeGetSecurityModel(virConnectPtr conn, virSecurityModelPtr secmodel) @@ -9357,6 +9397,7 @@ static virHypervisorDriver testHypervisorDriver =3D { .domainGetVcpuPinInfo =3D testDomainGetVcpuPinInfo, /* 1.2.18 */ .domainGetMaxVcpus =3D testDomainGetMaxVcpus, /* 0.7.3 */ .domainGetSecurityLabel =3D testDomainGetSecurityLabel, /* 7.5.0 */ + .domainGetSecurityLabelList =3D testDomainGetSecurityLabelList, /* 7.5= .0 */ .nodeGetSecurityModel =3D testNodeGetSecurityModel, /* 7.5.0 */ .domainGetXMLDesc =3D testDomainGetXMLDesc, /* 0.1.4 */ .domainSetMemoryParameters =3D testDomainSetMemoryParameters, /* 5.6.0= */ --=20 2.32.0