From nobody Tue May 7 23:11:19 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=1559132736; cv=none; d=zoho.com; s=zohoarc; b=NfiHRiP1HQNUqNGPqo+aMx8s1FNSModklMVkeueHlZLpTao6lWcDwJJ2/s4Et3R6ps4gZmoSnQsAQ6ZGj3omzLNT/M8/2DzewsRcJQoABtelbRd4xBL5/Lj6ugnIngoaENkMW9hXhlZhmWfALHLg9HhLTH3ZQj1DXGNToQCuAE0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559132736; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Lqd5Sqjd4N2hfFogRg203LF1K6bHLGkY/3JA8O9zPSo=; b=Xxyn2deWO4WNeZCuyT/2k+YuS0DQLbxy+Pfe82TUsbJgJjPwYisOqCcuV1SDbUM+sHcT35/NjYkO9QiG7xAT3hbZbTlolXAiJ7u7KChEHNMCE8tUz4B0HfezuffyiggEW9CdimQche2QWBcf43B4JZSd8SEa9c+tInfDa4falFk= 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 1559132736544195.23320133908896; Wed, 29 May 2019 05:25:36 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 5633E30C3192; Wed, 29 May 2019 12:25:16 +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 22D436B8C0; Wed, 29 May 2019 12:25: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 D56551806B19; Wed, 29 May 2019 12:25:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x4TCOIdp025693 for ; Wed, 29 May 2019 08:24:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id C9F376B8C4; Wed, 29 May 2019 12:24:18 +0000 (UTC) Received: from mx1.redhat.com (ext-mx16.extmail.prod.ext.phx2.redhat.com [10.5.110.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5DBBE60852; Wed, 29 May 2019 12:24:16 +0000 (UTC) Received: from mail-ed1-f68.google.com (mail-ed1-f68.google.com [209.85.208.68]) (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 87DDC30C1325; Wed, 29 May 2019 12:24:02 +0000 (UTC) Received: by mail-ed1-f68.google.com with SMTP id n17so3542526edb.0; Wed, 29 May 2019 05:24:02 -0700 (PDT) Received: from archpc.localdomain (x8d1ee222.agdsn.tu-dresden.de. [141.30.226.34]) by smtp.gmail.com with ESMTPSA id p37sm5214857edc.14.2019.05.29.05.23.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 May 2019 05:23:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=rrlp31/rseDh7nL5ed++wNX8uf14ffh8DDjN7ejo9LQ=; b=KZIHkloQB5phfIzEYiHXhema6tPrjoK96yKre1veKsBJoaU2v683twilsSICCpmLFQ 2gzCGs/QSoCjNOwRpePHaeO/2FmbDIicVT4UjcWsKSrhoCMhKg8ttblR+PS5pzc9/PfD Joq5WTAvfFdK980ZyT68dDf6r8hlzxxE73hpK3ELf1hXd7EVSSaWlwqWXMBE4547zX3T 1Usf6bOuAQ05mua0KuHPnJlCK4xC1ZdgI0h5JYlBK/IbLdf19FWAHF2fIgTiqQGnFKIB bhOI9ef7kQ/mR7d6ZV7grTfaNqwHvPV2EPFt+CZEcApfHRHsG8i+CkVtNaD2ZBh/94Hq Be8A== 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=rrlp31/rseDh7nL5ed++wNX8uf14ffh8DDjN7ejo9LQ=; b=i2N5rRuwqe+BVtBAwrX3OINj3e+OTUMW8CPN+Awvypah0+2yOPTPQE4wc/LdInG10p FXYyeUQyOhk6DJswC4nH02OWnW0LUI4NjsqNonTeM5FoQKjZm6IoCVOBmBBa8FtPsRsn QtUrQMt03Es1wOW8WscvOb5fxGdeE9vS9ccbhlSnSj1ldXlfjz4lH9OyACRx8ZFYko8u klYHacRe0Yf90sihcep/p4ihlfTdir4qUTZsEtRm2rQ9kZSeOn7tnNu8L3r/Lry/KQJi /HvmDrF3Hh+Q1lo6MWfU+nE+X7w431lTm8C6C7uuWkoTmdkqcHA7E+7ZDgXpcldZgX41 rKAQ== X-Gm-Message-State: APjAAAU1ekXUgVfus37123Zhm6R9xkaxlaNRBJUgRrxFpqCn4xGt793v qkutvJ5fh3AI3VnILWQnQM3xk53o X-Google-Smtp-Source: APXvYqwbqY5iBJRjZCUJb+vmqOZE/9BjIepLKfjtZuyOpAmrvvNkq9ySqmL0UHCrFKZzjC3tq/1Hog== X-Received: by 2002:a50:aed8:: with SMTP id f24mr134801610edd.214.1559132640765; Wed, 29 May 2019 05:24:00 -0700 (PDT) From: Ilias Stamatis To: libvir-list@redhat.com Date: Wed, 29 May 2019 14:22:56 +0200 Message-Id: <20190529122259.14979-2-stamatis.iliass@gmail.com> In-Reply-To: <20190529122259.14979-1-stamatis.iliass@gmail.com> References: <20190529122259.14979-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.45]); Wed, 29 May 2019 12:24:02 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Wed, 29 May 2019 12:24:02 +0000 (UTC) for IP:'209.85.208.68' DOMAIN:'mail-ed1-f68.google.com' HELO:'mail-ed1-f68.google.com' FROM:'stamatis.iliass@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.108 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE) 209.85.208.68 mail-ed1-f68.google.com 209.85.208.68 mail-ed1-f68.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.45 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/4] test_driver: extract image saving code into a separate function 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Wed, 29 May 2019 12:25:25 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Extracting the code logic for writing a test image to disk from testDomainSaveFlags into a separate function, allows us to reuse this code in other functions such as testDomainSaveImageDefineXML. Signed-off-by: Ilias Stamatis Reviewed-by: Erik Skultety --- src/test/test_driver.c | 114 +++++++++++++++++++++++++---------------- 1 file changed, 69 insertions(+), 45 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 2f58a1da95..e71b931790 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1974,75 +1974,106 @@ testDomainGetTime(virDomainPtr dom ATTRIBUTE_UNUSE= D, #define TEST_SAVE_MAGIC "TestGuestMagic" -static int -testDomainSaveFlags(virDomainPtr domain, const char *path, - const char *dxml, unsigned int flags) + +/** + * testDomainSaveImageWrite: + * @driver: test driver data + * @def: domain definition whose XML will be stored in the image + * @path: path of the save image + * + * Returns true on success, else false. + */ +static bool +testDomainSaveImageWrite(testDriverPtr driver, + virDomainDefPtr def, + const char *path) { - testDriverPtr privconn =3D domain->conn->privateData; - int fd =3D -1; int len; - virDomainObjPtr privdom; - virObjectEventPtr event =3D NULL; - int ret =3D -1; + int fd =3D -1; VIR_AUTOFREE(char *) xml =3D NULL; - virCheckFlags(0, -1); - if (dxml) { - virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", - _("xml modification unsupported")); - return -1; - } - - - if (!(privdom =3D testDomObjFromDomain(domain))) - goto cleanup; - - if (virDomainObjCheckActive(privdom) < 0) - goto cleanup; - - xml =3D virDomainDefFormat(privdom->def, privconn->caps, - VIR_DOMAIN_DEF_FORMAT_SECURE); + xml =3D virDomainDefFormat(def, driver->caps, VIR_DOMAIN_DEF_FORMAT_SE= CURE); if (xml =3D=3D NULL) { virReportSystemError(errno, _("saving domain '%s' failed to allocate spac= e for metadata"), - domain->name); - goto cleanup; + def->name); + goto error; } if ((fd =3D open(path, O_CREAT|O_TRUNC|O_WRONLY, S_IRUSR|S_IWUSR)) < 0= ) { virReportSystemError(errno, _("saving domain '%s' to '%s': open failed"), - domain->name, path); - goto cleanup; + def->name, path); + goto error; } - len =3D strlen(xml); + if (safewrite(fd, TEST_SAVE_MAGIC, sizeof(TEST_SAVE_MAGIC)) < 0) { virReportSystemError(errno, _("saving domain '%s' to '%s': write failed"), - domain->name, path); - goto cleanup; + def->name, path); + goto error; } + + len =3D strlen(xml); if (safewrite(fd, (char*)&len, sizeof(len)) < 0) { virReportSystemError(errno, _("saving domain '%s' to '%s': write failed"), - domain->name, path); - goto cleanup; + def->name, path); + goto error; } + if (safewrite(fd, xml, len) < 0) { virReportSystemError(errno, _("saving domain '%s' to '%s': write failed"), - domain->name, path); - goto cleanup; + def->name, path); + goto error; } if (VIR_CLOSE(fd) < 0) { virReportSystemError(errno, _("saving domain '%s' to '%s': write failed"), - domain->name, path); - goto cleanup; + def->name, path); + goto error; } - fd =3D -1; + + return true; + + error: + /* Don't report failure in close or unlink, because + * in either case we're already in a failure scenario + * and have reported an earlier error */ + VIR_FORCE_CLOSE(fd); + unlink(path); + + return false; +} + +static int +testDomainSaveFlags(virDomainPtr domain, const char *path, + const char *dxml, unsigned int flags) +{ + testDriverPtr privconn =3D domain->conn->privateData; + virDomainObjPtr privdom; + virObjectEventPtr event =3D NULL; + int ret =3D -1; + + virCheckFlags(0, -1); + + if (dxml) { + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("xml modification unsupported")); + return -1; + } + + if (!(privdom =3D testDomObjFromDomain(domain))) + goto cleanup; + + if (virDomainObjCheckActive(privdom) < 0) + goto cleanup; + + if (!testDomainSaveImageWrite(privconn, privdom->def, path)) + goto cleanup; testDomainShutdownState(domain, privdom, VIR_DOMAIN_SHUTOFF_SAVED); event =3D virDomainEventLifecycleNewFromObj(privdom, @@ -2054,13 +2085,6 @@ testDomainSaveFlags(virDomainPtr domain, const char = *path, ret =3D 0; cleanup: - /* Don't report failure in close or unlink, because - * in either case we're already in a failure scenario - * and have reported an earlier error */ - if (ret !=3D 0) { - VIR_FORCE_CLOSE(fd); - unlink(path); - } virDomainObjEndAPI(&privdom); virObjectEventStateQueue(privconn->eventState, event); return ret; -- 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 23:11:19 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=1559132690; cv=none; d=zoho.com; s=zohoarc; b=nGDxvJIL1j252T9Jqksxx8Xlxz6bMITfwM4rUUCU1M+ej0UoiMZc3Gc/BJgLppgnVbhu3r1G1S+8DCG2z5frCfzOcTaJgSQGytY1gGOLwyJRG17FONWueG1EhMRJ+TaJGTPOWSK6WqEX5wiAvMVZdzsBvs/ikZqYAWFeVLfHzjE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559132690; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=RSafVDcLoDMC/hzgFoAW6UPk+JHt8Wd3xe4uaxpVn00=; b=mLBoAnyPlZV+uMO7tUgA42XsmDcnOGXepi0cj3c7G+ftHJ/AOd1wb8E2rYRvixPdcDDmtueay77YdCi9LF/1yK+nilzCfQUo8RBwpItPcEkH36aUacsen5MJeqgcdUFJdkA0A9JcA3MeYKXvIHfC5GZzdmu21fnclOWOzI7Gp2Q= 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 15591326906501007.5697602741874; Wed, 29 May 2019 05:24:50 -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 F37C73087926; Wed, 29 May 2019 12:24:43 +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 821245B681; Wed, 29 May 2019 12:24:40 +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 D98C8C841; Wed, 29 May 2019 12:24:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x4TCOVV6025714 for ; Wed, 29 May 2019 08:24:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id 899AB5D9E2; Wed, 29 May 2019 12:24:31 +0000 (UTC) Received: from mx1.redhat.com (ext-mx16.extmail.prod.ext.phx2.redhat.com [10.5.110.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 707EE5D9E1; Wed, 29 May 2019 12:24:29 +0000 (UTC) Received: from mail-ed1-f66.google.com (mail-ed1-f66.google.com [209.85.208.66]) (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 9A26430C0DEA; Wed, 29 May 2019 12:24:15 +0000 (UTC) Received: by mail-ed1-f66.google.com with SMTP id f37so3433024edb.13; Wed, 29 May 2019 05:24:15 -0700 (PDT) Received: from archpc.localdomain (x8d1ee222.agdsn.tu-dresden.de. [141.30.226.34]) by smtp.gmail.com with ESMTPSA id p37sm5214857edc.14.2019.05.29.05.24.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 May 2019 05:24:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=SQkbWuShXyzEy1wXnLv5eN7YKuzQght45cOVxG2MELI=; b=H2PBrDbbl7MKsvFJFHHh2y/+tipNutxd9HAsu2FZBOJ+YroJdwYUuxmsIJkg4e3AE+ ArvhcUxwPYNpbwyZ+C5Z7KUB7yLxEom1OMhR3p+1c5kK20eXcmB/+GKliV8VEWHsrnhp OUiBnY6aM54iBpBF8YUBDkwoStmidBVJAsvnEuveFU18XqlAjrcpQR5ohU4lXWOPeD1m BoBmd9aKgAO2Bp3ngb65zEWyg7OU+jVbpGyV2HFk7m+2aw1z/Jx0IxGKniaMxfHh1T+u gTTOEwJNtW9nizIkp58xpfjplbk3leqtpHeZCLh71nQ/1CZq3iOO6Bck8bJpEuQBbe8Z aS7g== 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=SQkbWuShXyzEy1wXnLv5eN7YKuzQght45cOVxG2MELI=; b=hs472DZnzmHXUSc0DS9rsCiOQxBYatLUfr2tHUZbRMgyFDjj/uI8tmrqYIdRCTLzmT 5xm6cTW9SKjkB7mB0C5sWkxalXaJLWf3hkXjD1agG18PMEdc04pdIN/hHz76c6GSjB02 CEur8bxUQogz49lMQmFIbuVokmiOXTUAIn0tThuQPLcHjzaqzFOOrnwF3+umLpbZNjHD bp4C3c/PIrJy9u5lCi33LKRzAY8M7sqdzwq1voAajduALU5xmptVOksRVRcF1Y6qweex Syi70BzsSjFWgmQ1Mc9u1PaqBHXxIshHv7pY+C/uksNUJNFO5a2PYaUmrUau/FUv76sL Xzuw== X-Gm-Message-State: APjAAAU9ohcxfOiEU/2ubj3jwqA2ljBT6G/Vz5Z2N+MB5xyzWk6ebasL I9hWeihAMxW7doLw4ZiPjlWV3iNt X-Google-Smtp-Source: APXvYqzzTJezYIc6Sf9EgZUPyAQgfeQDNUji0AUQtj4lEvs1brrNQi25mkalVVDsqC6bDBX2wZQkMQ== X-Received: by 2002:a50:ee01:: with SMTP id g1mr134199621eds.263.1559132653790; Wed, 29 May 2019 05:24:13 -0700 (PDT) From: Ilias Stamatis To: libvir-list@redhat.com Date: Wed, 29 May 2019 14:22:57 +0200 Message-Id: <20190529122259.14979-3-stamatis.iliass@gmail.com> In-Reply-To: <20190529122259.14979-1-stamatis.iliass@gmail.com> References: <20190529122259.14979-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.45]); Wed, 29 May 2019 12:24:16 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Wed, 29 May 2019 12:24:16 +0000 (UTC) for IP:'209.85.208.66' DOMAIN:'mail-ed1-f66.google.com' HELO:'mail-ed1-f66.google.com' FROM:'stamatis.iliass@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.109 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS) 209.85.208.66 mail-ed1-f66.google.com 209.85.208.66 mail-ed1-f66.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.45 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/4] test_driver: extract image loading code into a separate function 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.45]); Wed, 29 May 2019 12:24:49 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Extracting the code logic for opening and parsing a test image from testDomainRestoreFlags into a separate function, allows us to reuse this code in other functions such as testDomainSaveImageGetXMLDesc. Signed-off-by: Ilias Stamatis Reviewed-by: Erik Skultety --- src/test/test_driver.c | 115 ++++++++++++++++++++++++++--------------- 1 file changed, 72 insertions(+), 43 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index e71b931790..ce32570b75 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -2049,6 +2049,77 @@ testDomainSaveImageWrite(testDriverPtr driver, return false; } +/** + * testDomainSaveImageOpen: + * @driver: test driver data + * @path: path of the save image + * @ret_def: returns domain definition created from the XML stored in the = image + * + * Returns the opened fd of the save image file and fills ret_def on succe= ss. + * Returns -1, on error. + */ +static int ATTRIBUTE_NONNULL(3) +testDomainSaveImageOpen(testDriverPtr driver, + const char *path, + virDomainDefPtr *ret_def) +{ + char magic[15]; + int fd =3D -1; + int len; + virDomainDefPtr def =3D NULL; + VIR_AUTOFREE(char *) xml =3D NULL; + + if ((fd =3D open(path, O_RDONLY)) < 0) { + virReportSystemError(errno, _("cannot read domain image '%s'"), pa= th); + goto error; + } + + if (saferead(fd, magic, sizeof(magic)) !=3D sizeof(magic)) { + virReportSystemError(errno, _("incomplete save header in '%s'"), p= ath); + goto error; + } + + if (memcmp(magic, TEST_SAVE_MAGIC, sizeof(magic))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("mismatched header = magic")); + goto error; + } + + if (saferead(fd, (char*)&len, sizeof(len)) !=3D sizeof(len)) { + virReportSystemError(errno, + _("failed to read metadata length in '%s'"), + path); + goto error; + } + + if (len < 1 || len > 8192) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("length of metadata out of range")); + goto error; + } + + if (VIR_ALLOC_N(xml, len+1) < 0) + goto error; + + if (saferead(fd, xml, len) !=3D len) { + virReportSystemError(errno, _("incomplete metadata in '%s'"), path= ); + goto error; + } + xml[len] =3D '\0'; + + if (!(def =3D virDomainDefParseString(xml, driver->caps, driver->xmlop= t, NULL, + VIR_DOMAIN_DEF_PARSE_INACTIVE | + VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE= ))) + goto error; + + VIR_STEAL_PTR(*ret_def, def); + return fd; + + error: + virDomainDefFree(def); + VIR_FORCE_CLOSE(fd); + return -1; +} + static int testDomainSaveFlags(virDomainPtr domain, const char *path, const char *dxml, unsigned int flags) @@ -2104,14 +2175,11 @@ testDomainRestoreFlags(virConnectPtr conn, unsigned int flags) { testDriverPtr privconn =3D conn->privateData; - char magic[15]; int fd =3D -1; - int len; virDomainDefPtr def =3D NULL; virDomainObjPtr dom =3D NULL; virObjectEventPtr event =3D NULL; int ret =3D -1; - VIR_AUTOFREE(char *) xml =3D NULL; virCheckFlags(0, -1); if (dxml) { @@ -2120,46 +2188,7 @@ testDomainRestoreFlags(virConnectPtr conn, return -1; } - if ((fd =3D open(path, O_RDONLY)) < 0) { - virReportSystemError(errno, - _("cannot read domain image '%s'"), - path); - goto cleanup; - } - if (saferead(fd, magic, sizeof(magic)) !=3D sizeof(magic)) { - virReportSystemError(errno, - _("incomplete save header in '%s'"), - path); - goto cleanup; - } - if (memcmp(magic, TEST_SAVE_MAGIC, sizeof(magic))) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("mismatched header magic")); - goto cleanup; - } - if (saferead(fd, (char*)&len, sizeof(len)) !=3D sizeof(len)) { - virReportSystemError(errno, - _("failed to read metadata length in '%s'"), - path); - goto cleanup; - } - if (len < 1 || len > 8192) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("length of metadata out of range")); - goto cleanup; - } - if (VIR_ALLOC_N(xml, len+1) < 0) - goto cleanup; - if (saferead(fd, xml, len) !=3D len) { - virReportSystemError(errno, - _("incomplete metadata in '%s'"), path); - goto cleanup; - } - xml[len] =3D '\0'; - - def =3D virDomainDefParseString(xml, privconn->caps, privconn->xmlopt, - NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE); - if (!def) + if ((fd =3D testDomainSaveImageOpen(privconn, path, &def)) < 0) goto cleanup; if (testDomainGenerateIfnames(def) < 0) -- 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 23:11:19 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=1559132807; cv=none; d=zoho.com; s=zohoarc; b=PISD/eNENtHtUZo84wQh7Waq+WMihEZT5i1034V1DtzPQdSsLx7lkDIOenUiEcWk0aaMG9Jzrwq3wsr9MmUsbcJ1anJ0DcD40ChEYAJQ/g5jz9/FNy0DtswOppUxXfP8uR8J3Ysjps++f9mIpP3kO7nr0In6plxKuhn+M24iNJc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559132807; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=BRSM3ZNI5fgerxyJZEb/PFQbS4MauSrO2eeUcJJ8hC4=; b=JQtFvSbbRRF5bvBCBkq/RvkDv7P2441glC/OxysqfxHWEhEGPWKUoEey5muLFu0tdWgzmLcOWET++F5YrhfixSj5CLi9CQKf9V2jqvbZ16UM6FTgT++2dMuWg91kcj2rrGuthfvDdqly35ww1oBb0DP3+NuVI0RJIjw0ePLUFPk= 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 1559132807779866.6466773054985; Wed, 29 May 2019 05:26:47 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 5E13A30253FE; Wed, 29 May 2019 12:26:45 +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 31A1C5D9D6; Wed, 29 May 2019 12:26:43 +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 DC5CC1806B14; Wed, 29 May 2019 12:26:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x4TCOjC8025731 for ; Wed, 29 May 2019 08:24:45 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8278F2B45E; Wed, 29 May 2019 12:24:45 +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 1AFB228991; Wed, 29 May 2019 12:24:43 +0000 (UTC) Received: from mail-ed1-f65.google.com (mail-ed1-f65.google.com [209.85.208.65]) (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 BC94EA3B5E; Wed, 29 May 2019 12:24:32 +0000 (UTC) Received: by mail-ed1-f65.google.com with SMTP id g13so3504511edu.5; Wed, 29 May 2019 05:24:32 -0700 (PDT) Received: from archpc.localdomain (x8d1ee222.agdsn.tu-dresden.de. [141.30.226.34]) by smtp.gmail.com with ESMTPSA id p37sm5214857edc.14.2019.05.29.05.24.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 May 2019 05:24:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=pfRLi8ac3smA6cg93yW+zIq36QaHYL5yYVz3R2KFZjU=; b=O+d2xOo4eI6GzvmzjkftPqxn4EJyE/rNo1/ZCweSOx5kBUxKPr/hz8UVWLiYNXQjC9 4ynlIn3OfZP4LyJR6k5ettBrkKmlqw/MeUq6XkOSjFfuPdBnInKKOMQZnWalY0bRVUbb 05VnZ2/xq4DKy9ycOGUAVpb/A3zEfKdFA5mtR2d92DzwJ2SrsITX6NgxrlQ/Ap51NEGN 47cRdvBtL0qPMnACuaO92tb+lHILqOb3xSmrhc9tDI/VfTDndep4+8eDnqeCP+hrN3qY Kq7YnSdvu0lCc3viHSPstDlvI5PDmZq/9dhF/++vp6s1yASiFR0nkbqiH1msDWTwarQD EHww== 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=pfRLi8ac3smA6cg93yW+zIq36QaHYL5yYVz3R2KFZjU=; b=o+KIHBKPXdAZjy+oXfr53fMaDRqLdY6ie5lOjOyMIOLSo812w4A6PQcd/Lf0FnZa/S nrweL+bHoRhOYHqnjAifabFHy3Bp3xlr0M9vW9SoH0QwxHRAX4VtrdaWwCFELtaUNYv7 sdHSgxKTDnI9SQYSlO29bEjrHXXkJ68G0Ek9ioBl5FsBBGBU0u19F+oWqeRy9AXlQcwy wW2tnG1zewCPwUu+7Gc3gvVj31nGSqg6mRImia7oavrtctcDeVJuBomMMtvQcKEAaTCE //kc839MceDhAT4VxFqHagy3oHvxLTWs/YHxJc9L55oMVgXKtk+o5LUSDVAUUk95orsw RfZA== X-Gm-Message-State: APjAAAVohRkIGj95jrMsrZPkxioHiRS4fZQbgR+WLyfXHHmHzJIgzF8U nZ1h6r2ob+quPz+Rqx7TlAMY/NUZ X-Google-Smtp-Source: APXvYqzWRF5s4BdvMBnqMGnDIR1Cl2VhgDFMt5vWWEE02NwdpJxZoil4fzLdwlLOAAzDzFSo5cnPLw== X-Received: by 2002:a50:fd15:: with SMTP id i21mr10360372eds.89.1559132667002; Wed, 29 May 2019 05:24:27 -0700 (PDT) From: Ilias Stamatis To: libvir-list@redhat.com Date: Wed, 29 May 2019 14:22:58 +0200 Message-Id: <20190529122259.14979-4-stamatis.iliass@gmail.com> In-Reply-To: <20190529122259.14979-1-stamatis.iliass@gmail.com> References: <20190529122259.14979-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]); Wed, 29 May 2019 12:24:33 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 29 May 2019 12:24:33 +0000 (UTC) for IP:'209.85.208.65' DOMAIN:'mail-ed1-f65.google.com' HELO:'mail-ed1-f65.google.com' FROM:'stamatis.iliass@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.109 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS) 209.85.208.65 mail-ed1-f65.google.com 209.85.208.65 mail-ed1-f65.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/4] test_driver: implement virDomainSaveImageDefineXML 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 29 May 2019 12:26:46 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Updates the existing image stored in @path, in case @dxml contains valid XML supported by the fake host. Signed-off-by: Ilias Stamatis Reviewed-by: Erik Skultety --- src/test/test_driver.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index ce32570b75..b0195ac63d 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -2228,6 +2228,33 @@ testDomainRestore(virConnectPtr conn, return testDomainRestoreFlags(conn, path, NULL, 0); } +static int +testDomainSaveImageDefineXML(virConnectPtr conn, + const char *path, + const char *dxml, + unsigned int flags) +{ + int ret =3D -1; + virDomainDefPtr def =3D NULL; + testDriverPtr privconn =3D conn->privateData; + + virCheckFlags(VIR_DOMAIN_SAVE_RUNNING | + VIR_DOMAIN_SAVE_PAUSED, -1); + + if ((def =3D virDomainDefParseString(dxml, privconn->caps, privconn->x= mlopt, NULL, + VIR_DOMAIN_DEF_PARSE_INACTIVE)) =3D= =3D NULL) + goto cleanup; + + if (!testDomainSaveImageWrite(privconn, def, path)) + goto cleanup; + + ret =3D 0; + + cleanup: + virDomainDefFree(def); + return ret; +} + static int testDomainCoreDumpWithFormat(virDomainPtr domain, const char *to, unsigned int dumpformat, @@ -7010,6 +7037,7 @@ static virHypervisorDriver testHypervisorDriver =3D { .domainSaveFlags =3D testDomainSaveFlags, /* 0.9.4 */ .domainRestore =3D testDomainRestore, /* 0.3.2 */ .domainRestoreFlags =3D testDomainRestoreFlags, /* 0.9.4 */ + .domainSaveImageDefineXML =3D testDomainSaveImageDefineXML, /* 5.4.0 */ .domainCoreDump =3D testDomainCoreDump, /* 0.3.2 */ .domainCoreDumpWithFormat =3D testDomainCoreDumpWithFormat, /* 1.2.3 */ .domainSetVcpus =3D testDomainSetVcpus, /* 0.1.4 */ -- 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 23:11:19 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=1559132716; cv=none; d=zoho.com; s=zohoarc; b=nfDb+AbtQMQhU7MyW+ho9Kfd2sDzrLnxy55ygz/nRiH4HMTbZrrod7LFLpcM/v4aYibOGZwDCuTvHs3INt5TMM8NmoNzv/VH3DRD5PPq/L4sY0udd5kWE6owXndBZa4OKhtAf9bmCTq60BZGaBRcMA6fHR8eKKPIYsIfMBPRxDA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559132716; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=qoqBknpGXNkF0GvfWs/S/CpzwPNJ8WLEiwJmAhItpO8=; b=dCmwp02psfvrs/fgGLM0c83YFgchfY9aEJSBqYks8mO4+Rdzyolp1aEtyTyLK7KNOXPGWYFo/WqauMX/O+gvAcp4jVp/5/8wzD8nMpV1r8dWR9fhh2YTX+7Y4ATU0t84ipAo3IoLzPq9Y8X4LXw6iZ+6sQsViNo7AXGZf/ugDAw= 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 15591327169328.375853892838904; Wed, 29 May 2019 05:25:16 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B4F262ED2C3; Wed, 29 May 2019 12:25:04 +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 2D62C1001E86; Wed, 29 May 2019 12:25:03 +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 CFA3E1806B16; Wed, 29 May 2019 12:25:00 +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 x4TCOxur025751 for ; Wed, 29 May 2019 08:24:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8A91C4DA; Wed, 29 May 2019 12:24:59 +0000 (UTC) Received: from mx1.redhat.com (ext-mx12.extmail.prod.ext.phx2.redhat.com [10.5.110.41]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4FA7D5C1B5; Wed, 29 May 2019 12:24:57 +0000 (UTC) Received: from mail-ed1-f66.google.com (mail-ed1-f66.google.com [209.85.208.66]) (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 DEEDB3179B46; Wed, 29 May 2019 12:24:45 +0000 (UTC) Received: by mail-ed1-f66.google.com with SMTP id f37so3435173edb.13; Wed, 29 May 2019 05:24:45 -0700 (PDT) Received: from archpc.localdomain (x8d1ee222.agdsn.tu-dresden.de. [141.30.226.34]) by smtp.gmail.com with ESMTPSA id p37sm5214857edc.14.2019.05.29.05.24.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 May 2019 05:24:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=lCgTiqKSpAnCns0INatTJVYSiu0l3SD+eleebXXCqTQ=; b=sDt8UuRY097XIeNP9/GiJqvTKxBHfGvlBDciFEMLYAlARecyBd4AqTXW3qJ9ZuMfio YOJnL0ZtRv4a7M2PpdCDTlnie8RNNG/lzx1gI0roPYoqsgyCDG3GSHa490+XulCmXiRv yo2rloOWyXRbrNUeh7uPkl5+maXxUzUT0rcydX/nfX73jKIQLUGNpWUI+TTnOvSserIU oD3Cm8VTQPgri9EefmBbngxJZpgVgIVlxy7CBBuwQRBsqdvLcnUxR4V/eCQZiqiAUjGp e4PpuIp/B69ZfKzIBT1Rrg9mJBAgAugwnwHAujH3x9it9e2LhJbNGaxV003TxcBlN5c7 tIiQ== 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=lCgTiqKSpAnCns0INatTJVYSiu0l3SD+eleebXXCqTQ=; b=c+7lN+dTQgVHXoRzvI05zbiaDzWaBB5k9xDLf32/PqkXsyz1O311HkGqxlvNcJ+XJN tvRujOuhyrwQbzIRjS+cewlUi/g+7xqaZAazwSGiuSOcAxe+EsBRqih5JCWKjwTj0BWo B34khLUp61HqPBA/u1bmOWiOW6EV6adwdI7h93XdiL8K7Zrdzbl7VgXXjOx/2NSj5FMi ZEociGZdgs2DpdT2XR4q6zsrtnjgHXsbf3arjuXSTbJI8vKmArYdNguZNVoXCCeoiInL Ku/l7I8kRv+CmamXW4Iy0FuTxgR9KwnT9NlQOsW1NnidvuILu2zITErLkWyipGsDGYR0 xrXg== X-Gm-Message-State: APjAAAUJn6kd8jPUvIjL/WIzQOrUgOjU0igRyO+uxlUP/ycxLC+lCzr1 LVx/IFGpymsGT2voPqN0fsSo5Rql X-Google-Smtp-Source: APXvYqxAVc8lurVZ1CuiNqT+61pGS45AAyHHvoa/R00JembsXinIC5rTNuediGl9uWSHwmWpChDKJQ== X-Received: by 2002:a05:6402:1610:: with SMTP id f16mr136323305edv.171.1559132679277; Wed, 29 May 2019 05:24:39 -0700 (PDT) From: Ilias Stamatis To: libvir-list@redhat.com Date: Wed, 29 May 2019 14:22:59 +0200 Message-Id: <20190529122259.14979-5-stamatis.iliass@gmail.com> In-Reply-To: <20190529122259.14979-1-stamatis.iliass@gmail.com> References: <20190529122259.14979-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.41]); Wed, 29 May 2019 12:24:46 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Wed, 29 May 2019 12:24:46 +0000 (UTC) for IP:'209.85.208.66' DOMAIN:'mail-ed1-f66.google.com' HELO:'mail-ed1-f66.google.com' FROM:'stamatis.iliass@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.109 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS) 209.85.208.66 mail-ed1-f66.google.com 209.85.208.66 mail-ed1-f66.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.41 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/4] test_driver: implement virDomainSaveImageGetXMLDesc 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.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 29 May 2019 12:25:10 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Ilias Stamatis Reviewed-by: Erik Skultety --- src/test/test_driver.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index b0195ac63d..719e956d99 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -2255,6 +2255,29 @@ testDomainSaveImageDefineXML(virConnectPtr conn, return ret; } +static char * +testDomainSaveImageGetXMLDesc(virConnectPtr conn, + const char *path, + unsigned int flags) +{ + int fd =3D -1; + char *ret =3D NULL; + virDomainDefPtr def =3D NULL; + testDriverPtr privconn =3D conn->privateData; + + virCheckFlags(VIR_DOMAIN_SAVE_IMAGE_XML_SECURE, NULL); + + if ((fd =3D testDomainSaveImageOpen(privconn, path, &def)) < 0) + goto cleanup; + + ret =3D virDomainDefFormat(def, privconn->caps, VIR_DOMAIN_DEF_FORMAT_= SECURE); + + cleanup: + virDomainDefFree(def); + VIR_FORCE_CLOSE(fd); + return ret; +} + static int testDomainCoreDumpWithFormat(virDomainPtr domain, const char *to, unsigned int dumpformat, @@ -7038,6 +7061,7 @@ static virHypervisorDriver testHypervisorDriver =3D { .domainRestore =3D testDomainRestore, /* 0.3.2 */ .domainRestoreFlags =3D testDomainRestoreFlags, /* 0.9.4 */ .domainSaveImageDefineXML =3D testDomainSaveImageDefineXML, /* 5.4.0 */ + .domainSaveImageGetXMLDesc =3D testDomainSaveImageGetXMLDesc, /* 5.4.0= */ .domainCoreDump =3D testDomainCoreDump, /* 0.3.2 */ .domainCoreDumpWithFormat =3D testDomainCoreDumpWithFormat, /* 1.2.3 */ .domainSetVcpus =3D testDomainSetVcpus, /* 0.1.4 */ -- 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list