From nobody Sun Apr 28 21:24:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1565109453; cv=none; d=zoho.com; s=zohoarc; b=cF2JX+r9vQq1NatBIW4ScybFPJr5SdlFbjHolVef+8Iau2Q2rLqpvvGSEh8vyLHDTeoM40BacTysXAZPXR3LsshxRVsk35HdVbDo4OpMOuN7dqOGxqEU+Kiyf9es3/ZJCogmk+QgcFePCpzn9rKCuUPw/FGUTL0e0NQJbv2veSY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565109453; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=NH1MPcUOZbyXEbcbGZyraTtF0o2zycyHgjEWX2tV1yM=; b=iKJF030j3Uy2e5zOwSjEOZaO/Yf9GD6lgtEGoiCtdNqeVfDELV2yteHLxohgkouzJd47xJEul4zHR34cP0jQn4SLjFk11jv6Ydv7PuwwBAlSQhJCC+80Ih7J0hBcwjfQyqo1gUhBW/VRPy/v5bxKvrrcbGf2g6aQ09+8bVRuwxw= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 156510945335171.37651572795164; Tue, 6 Aug 2019 09:37:33 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DBF5D316D797; Tue, 6 Aug 2019 16:37:31 +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 B75A95D717; Tue, 6 Aug 2019 16:37:31 +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 544EA24F31; Tue, 6 Aug 2019 16:37:31 +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 x76GKJ9W026235 for ; Tue, 6 Aug 2019 12:20:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3B2D05C3F8; Tue, 6 Aug 2019 16:20:19 +0000 (UTC) Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 34F385C1B5 for ; Tue, 6 Aug 2019 16:20:17 +0000 (UTC) Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B8BF53B551 for ; Tue, 6 Aug 2019 16:20:15 +0000 (UTC) Received: by mail-wm1-f52.google.com with SMTP id p74so78781015wme.4 for ; Tue, 06 Aug 2019 09:20:15 -0700 (PDT) Received: from archpc.localdomain (x8d1ee222.agdsn.tu-dresden.de. [141.30.226.34]) by smtp.gmail.com with ESMTPSA id 32sm81540046wrh.76.2019.08.06.09.20.12 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 06 Aug 2019 09:20:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=27ftZRP2h8PEHYM//LRgrWjAffwF7b+VVeMLI5zCx1E=; b=Yfkn6loyfvrYfG76rAEZiFaPeLq9QNMYoi3IGM+PnCSIXo9eBJxNTNgpeZjsNzGp3C zC1NukXzkpeWuEPfrfaJVrtsXDgHrXNgE74CAlTj6z7yxME7TZgd0mEjcq+stUSCd0TE SuPGXghM7LSnOVzd9cMCOULyH8DsKT+u2b/n15AbIrCNbF9Hn/qQRFyEEIrjQEhwuw9h t4prDCJ3sn3/irfzrzl/CIOWw5Jy4bcpYS2yaFJiiIIomyGe0VIE+G+t3nwP3QzybjZr zDkjzZgn+PoH7JfYTY+xy1nHfZN1+aFR3biXVPEI5Gxx4C3N9chilnMQgWCInNpfx/P1 LSWA== 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=27ftZRP2h8PEHYM//LRgrWjAffwF7b+VVeMLI5zCx1E=; b=DOhR/JGrihAzM7sjtPBTIQTPAK0ZRG7Rk3qhhTLHPfC07DSmPqJONCiI9NvQIxfMuE oUgBoQCsj3pVOhrUJdVoTs2UTuEZ+4gbwXtWeCvKvK3kW2Nel/X15psf36oEQeS8hYH3 leLfsV1/MVY9poxjS63fi/hsJB4v1Qktbw2+w/GLY433ZnWFlLYbZZAN9HYAUxRFLS8H MPRtG+5TTVEqFRzVj90YWZFJVrQwGLB7EHtqGdnCcWC+hVusBU46Ei45E+gkF4HU2XMB L89fzBOyM5TLWJ7PAnAP3eelyDEzGgDNN2ixJTSww09hWnrPKAMT2kkp0WKMvCjS91jp bXAg== X-Gm-Message-State: APjAAAVh4mnyewxRwKAiIx802Mubl1+cfJnIJTqIl130W80oIg8T6rUK JIupdoWNXR8q90taXuSfZU2PliOsKFFBsQ== X-Google-Smtp-Source: APXvYqxYldixg5teOW2CRDseLazeqlzNDEJLxAExtkm4khlNzMyK51SqW//8IcFKRHY4jZ9oUXMa7Q== X-Received: by 2002:a7b:cf32:: with SMTP id m18mr5625357wmg.27.1565108414057; Tue, 06 Aug 2019 09:20:14 -0700 (PDT) From: Ilias Stamatis To: libvir-list@redhat.com Date: Tue, 6 Aug 2019 18:20:07 +0200 Message-Id: <20190806162007.6415-1-stamatis.iliass@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 06 Aug 2019 16:20:16 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 06 Aug 2019 16:20:16 +0000 (UTC) for IP:'209.85.128.52' DOMAIN:'mail-wm1-f52.google.com' HELO:'mail-wm1-f52.google.com' FROM:'stamatis.iliass@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.1 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS) 209.85.128.52 mail-wm1-f52.google.com 209.85.128.52 mail-wm1-f52.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] test_driver: implement virDomainSetTime and update virDomainGetTime 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Tue, 06 Aug 2019 16:37:32 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Until now, testDomainGetTime would always return the same fixed value everytime it was called. By using domain-private data we can make this API return the values previously set with testDomainSetTime, or use the same old fixed value in case testDomainSetTime hasn't been called at all. --- src/test/test_driver.c | 45 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index d9a7f815d5..6a75e63429 100755 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -392,6 +392,11 @@ struct _testDomainObjPrivate { testDriverPtr driver; bool frozen[2]; /* used by file system related calls */ + + + /* used by get/set time APIs */ + long long seconds; + unsigned int nseconds; }; @@ -406,6 +411,9 @@ testDomainObjPrivateAlloc(void *opaque) priv->driver =3D opaque; priv->frozen[0] =3D priv->frozen[1] =3D false; + priv->seconds =3D 627319920; + priv->nseconds =3D 0; + return priv; } @@ -2082,6 +2090,7 @@ testDomainGetTime(virDomainPtr dom, unsigned int flags) { virDomainObjPtr vm =3D NULL; + testDomainObjPrivatePtr priv; int ret =3D -1; virCheckFlags(0, -1); @@ -2095,8 +2104,39 @@ testDomainGetTime(virDomainPtr dom, goto cleanup; } - *seconds =3D 627319920; - *nseconds =3D 0; + priv =3D vm->privateData; + + *seconds =3D priv->seconds; + *nseconds =3D priv->nseconds; + + ret =3D 0; + cleanup: + virDomainObjEndAPI(&vm); + return ret; +} + + +static int +testDomainSetTime(virDomainPtr dom, + long long seconds, + unsigned int nseconds, + unsigned int flags) +{ + virDomainObjPtr vm =3D NULL; + testDomainObjPrivatePtr priv; + int ret =3D -1; + + virCheckFlags(VIR_DOMAIN_TIME_SYNC, ret); + + if (!(vm =3D testDomObjFromDomain(dom))) + return -1; + + if (virDomainObjCheckActive(vm) < 0) + goto cleanup; + + priv =3D vm->privateData; + priv->seconds =3D seconds; + priv->nseconds =3D nseconds; ret =3D 0; cleanup: @@ -8891,6 +8931,7 @@ static virHypervisorDriver testHypervisorDriver =3D { .domainGetInfo =3D testDomainGetInfo, /* 0.1.1 */ .domainGetState =3D testDomainGetState, /* 0.9.2 */ .domainGetTime =3D testDomainGetTime, /* 5.4.0 */ + .domainSetTime =3D testDomainSetTime, /* 5.7.0 */ .domainSave =3D testDomainSave, /* 0.3.2 */ .domainSaveFlags =3D testDomainSaveFlags, /* 0.9.4 */ .domainRestore =3D testDomainRestore, /* 0.3.2 */ -- 2.22.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list