From patchwork Thu Apr 25 12:57:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 162852 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp1900777jan; Thu, 25 Apr 2019 05:57:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqyhnL2r6T8kjqdAu9UXkmDrxfSg6OGjwswMdKzrawZn+uRS9fxVzOilaDmgMK5n35rE2ci/ X-Received: by 2002:a37:7fc7:: with SMTP id a190mr29501087qkd.358.1556197047977; Thu, 25 Apr 2019 05:57:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556197047; cv=none; d=google.com; s=arc-20160816; b=jbumLX50qrbX/gMwoBmDGC191X1acjP3cJjJnzplcodYNjz4qlsh2Nst3Xi9SJ5uN6 EX43kCZImV45u0/EccBxD3qsFiB+UurguEIhXtx20M/mBDR6lpF84HUEpAp31KZ8y7gn 2bWGDjTCB7OM0RP4BcX+SehZfDxCw/AyFdZADTVl7I+sr71F/rXDJcN2vqDlmH+cjZkt WGtFViZLFAtWd2GRYF9wbkzTuAbJ/Y6f8ofSADpWYDUEhhakDkK124YfHpkI/JUJXjrt epsS9rKoI8CCPAJ/mh0+eEb+XWkOt8R1jzDjNl9QIoDcz2L5SYaiO86c3VVGwQbOyjVH VCSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :cc:mime-version:message-id:date:to:from:delivered-to; bh=WMJe8Lten28yqendo8jb+rF0Ay6qMnJ+wf7ydUNR/xw=; b=BrTsdpjCY0vcCMwVblgzPRa+PZidJINvYApoxG5W81kA85E4WZJfaecGC5ICBQQfxk FIeWAtGoYneEJ+3S8ltFZ0z51TSNT5baesfV9YegRbZnbEWfptyfXO3quoK0sXUiZTVW D39p49zhm2pK9UmWDq0CoyzJFpumzPy58+hm69Flz7JZhRVKcUrme7sl3GxOtdeBmpz9 XHxYMPV1Wdid7uZSPAX1n0wjUgfxLqJeU6ardRoQWPhpOQ/wndB2N2pCd2JH4ASW+hQC HnkdDK9eQjRWNNcLaHCA6wj7MVo60E4raDJ42A1MChppCTYNs/K1AlcSQJ/EJxEa3HX0 G6pA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id i95si8226932qtb.11.2019.04.25.05.57.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Apr 2019 05:57:27 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 mx1.redhat.com (Postfix) with ESMTPS id 32E53A146A; Thu, 25 Apr 2019 12:57:26 +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 8AA356683B; Thu, 25 Apr 2019 12:57:24 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 8DC96181AC90; Thu, 25 Apr 2019 12:57:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x3PCvMnQ005064 for ; Thu, 25 Apr 2019 08:57:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id DCA8966D2D; Thu, 25 Apr 2019 12:57:21 +0000 (UTC) Delivered-To: libvirt-list@redhat.com Received: from worklaptop.redhat.com (ovpn-122-101.rdu2.redhat.com [10.10.122.101]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2B40566841; Thu, 25 Apr 2019 12:57:21 +0000 (UTC) From: Cole Robinson To: libvirt-list@redhat.com Date: Thu, 25 Apr 2019 08:57:11 -0400 Message-Id: <407cb2b56fea2a9621e5dbabe38fdb45764eb691.1556196423.git.crobinso@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: John.Allen@amd.com Subject: [libvirt] [PATCH] test: Use nodeInfo content for virNodeGetCPUMap 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 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 25 Apr 2019 12:57:27 +0000 (UTC) Right now the test driver implementation of virNodeGetCPUMap uses hardcoded data. Instead use cpu data from our nodeInfo, which can be overridden with input test XML. This helps to emulate some virsh commands (vcpupin, hostcpumap) with a large number of host cpus. [1] The content reported for test:///default is now slightly different: previously it would report 8 total cpus with 0,2,4 online. Now it reports 16 cpus with all online, which is the pre-existing nodeInfo default. [1] https://www.redhat.com/archives/libvir-list/2019-March/msg02042.html Signed-off-by: Cole Robinson --- John, in trying to understand and test your bitmap patch, I added this to the test driver. I think there's a bigger issue at play but I'm still trying to work it out, I'll send a follow up email when I've collected my thoughts src/test/test_driver.c | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) -- 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list diff --git a/src/test/test_driver.c b/src/test/test_driver.c index d5eecf4b7f..f00b6eb1c8 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -5811,23 +5811,46 @@ static int testConnectListAllDomains(virConnectPtr conn, } static int -testNodeGetCPUMap(virConnectPtr conn ATTRIBUTE_UNUSED, +testNodeGetCPUMap(virConnectPtr conn, unsigned char **cpumap, unsigned int *online, unsigned int flags) { + testDriverPtr privconn = conn->privateData; + int maxcpus = VIR_NODEINFO_MAXCPUS(privconn->nodeInfo); + virBitmapPtr cpus = NULL; + int ret = -1; + int dummy; + size_t i; + virCheckFlags(0, -1); + if (!cpumap && !online) + return maxcpus; + + if (!(cpus = virBitmapNew(maxcpus))) + goto cleanup; + if (cpumap) { - if (VIR_ALLOC_N(*cpumap, 1) < 0) - return -1; - *cpumap[0] = 0x15; + for (i = 0; i < privconn->nodeInfo.cpus; i++) { + if (virBitmapSetBit(cpus, i) < 0) + goto cleanup; + } + + if (virBitmapToData(cpus, cpumap, &dummy) < 0) + goto cleanup; } if (online) - *online = 3; + *online = privconn->nodeInfo.cpus; - return 8; + ret = maxcpus; + + cleanup: + if (ret < 0 && cpumap) + VIR_FREE(*cpumap); + VIR_FREE(cpus); + return ret; } static char *