From nobody Thu Apr 25 05:19:55 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=1560158034; cv=none; d=zoho.com; s=zohoarc; b=d8Vo4pjTu9zf4+Vs+iS1NhGAkmkL/4iR89faH+THbqnTumWfxel/uxSqTSDWrzrfDBYA9zKInMMIlBM15lLT6gsuOy1bBAr3hmLowLD3pBGc4IzGmXlFkX4UvQN2TDuMWzue8ZwlRCHzJAouO1jNvWZNfBIAMFzerrULTkePdpY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560158034; 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=eR8rOWN2oTe0Qgh2D4TFqdMZnorRTiNtl2f0NXs5DLA=; b=avCr+2EkTIBSVcOp6BO05orDQqoJ04tk9ZNd6vx8HfWxK5jKUaPK1MGgrFtCFxkmLed7WVEh5xCww04OTNxcONU+rhr2jg2sOARiZMgt16i67y6PZY/bRzEGMt4IkIvrBkibWsJzg+QcDfNyZyDo4b+/JGSuoZqVhKVR3swCxwE= 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 156015803410015.784077758454487; Mon, 10 Jun 2019 02:13:54 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 6619887633; Mon, 10 Jun 2019 09:13:47 +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 325C66064B; Mon, 10 Jun 2019 09:13:47 +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 CE3631806B18; Mon, 10 Jun 2019 09:13:46 +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 x5A96Ox9003314 for ; Mon, 10 Jun 2019 05:06:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id A62A8611D5; Mon, 10 Jun 2019 09:06:24 +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 9CC02611D0 for ; Mon, 10 Jun 2019 09:06:17 +0000 (UTC) Received: from mail-ed1-f67.google.com (mail-ed1-f67.google.com [209.85.208.67]) (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 DF7EC44BCD for ; Mon, 10 Jun 2019 09:05:57 +0000 (UTC) Received: by mail-ed1-f67.google.com with SMTP id c26so13499174edt.1 for ; Mon, 10 Jun 2019 02:05:57 -0700 (PDT) Received: from archpc.localdomain (x8d1ee222.agdsn.tu-dresden.de. [141.30.226.34]) by smtp.gmail.com with ESMTPSA id b10sm1724334eje.29.2019.06.10.02.05.47 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 10 Jun 2019 02:05:47 -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=okdFHbgv/iaSPpvcgi/GSoSCQ3NHvXZsy8F++mDjdck=; b=p+FlW42x8zyFJr17ScjPi8cnt5yw26Z/4O60x+U0TgE2PonQSTEd851Z0GqVET1JHz a40YCztqUwhqqhtUmyoRYEM6gFZYMW3fAWry8K2B9UgIT8JarzDHDmw//Fg1gx3HYNDu /QUsRHAPV4HGDTwIARMEO+0PD6qCuhy+2EoBr6GK9rt1FQ0rnDrCJ/+83rasu3F3rd1x RBThJ1aUO5Wu7/LsddIrDYYv766u904UZRHxyc/QIUlvAcrehicQJXxc6bYlhw2yCbY+ WoyiAfim389kk0sElkWjW5otZ+BVViqCujKVPYih6ipeRzYDuHal8bb3Okk+TGbN/FoZ KQZw== 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=okdFHbgv/iaSPpvcgi/GSoSCQ3NHvXZsy8F++mDjdck=; b=nwnTnemKBNvmFk3OAr1gcI/BeIEEG9AckPlBhDcT1irrGz0SNpRTunKQI3g2Zo8hwL Ik1x2i/zazfHwjpJU/HfSBSgdd/psexBWD1u/yvWOXbvLvgvhJO3XeXbbN1nSypNY2eS 4wADBANFslaUGwgJTdUBENO7AFZ0kDw1oI/twzX2JyB5h3NHjuTsLAoDbK8OW22B8New 7nD9Q1HSlNhP71nyvLhoKoTXk8D3vj1B6PY/qPV8A3v3tuvqq41px6NOHZqB1Oz70ddE L0YtLpUOC7XWO2lkVYcaOx80iLOaKOOmeglqUBwGrG14YVGtzgTcBTKl/94GK+O5eQz2 mHCg== X-Gm-Message-State: APjAAAUg74nuFo0ZgXu+M6NbkY6r3sH7kooQS2EwLIt8CdqM+TVOigkU A3zgfFGs75mvIWRLEwph9ezFvOnQ X-Google-Smtp-Source: APXvYqz4QDCJiENSv7RwrUYf58v6hEz5Q764xmziNh3nI4UGSzTz3qztUa+bkyjaJOLxj0ojKSHLmA== X-Received: by 2002:a50:86dc:: with SMTP id 28mr44775935edu.132.1560157548158; Mon, 10 Jun 2019 02:05:48 -0700 (PDT) From: Ilias Stamatis To: libvir-list@redhat.com Date: Mon, 10 Jun 2019 11:04:58 +0200 Message-Id: <20190610090501.2274-2-stamatis.iliass@gmail.com> In-Reply-To: <20190610090501.2274-1-stamatis.iliass@gmail.com> References: <20190610090501.2274-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]); Mon, 10 Jun 2019 09:05:58 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 10 Jun 2019 09:05:58 +0000 (UTC) for IP:'209.85.208.67' DOMAIN:'mail-ed1-f67.google.com' HELO:'mail-ed1-f67.google.com' FROM:'stamatis.iliass@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.11 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS) 209.85.208.67 mail-ed1-f67.google.com 209.85.208.67 mail-ed1-f67.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 10 Jun 2019 09:13:53 +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 | 115 +++++++++++++++++++++++++---------------- 1 file changed, 70 insertions(+), 45 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 1aa79ce898..3331ed5495 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1999,75 +1999,107 @@ 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 to the saved image + * + * Returns true on success, else false. + */ +static bool +testDomainSaveImageWrite(testDriverPtr driver, + const char *path, + virDomainDefPtr def) { - 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; + } + + 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; } - fd =3D -1; + + if (!(privdom =3D testDomObjFromDomain(domain))) + goto cleanup; + + if (virDomainObjCheckActive(privdom) < 0) + goto cleanup; + + if (!testDomainSaveImageWrite(privconn, path, privdom->def)) + goto cleanup; testDomainShutdownState(domain, privdom, VIR_DOMAIN_SHUTOFF_SAVED); event =3D virDomainEventLifecycleNewFromObj(privdom, @@ -2079,13 +2111,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 Thu Apr 25 05:19:55 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=1560157978; cv=none; d=zoho.com; s=zohoarc; b=hLjIgxZDdT0Nrh1DURN+FYLsZag1CRUHnWbdJLrjDBJ3d+V9JtGmlrkHlEoU0oDBkvdhxnnkpJ0pBzwNGZISk0tFCZMWpQETK3bLWtZVAUT6oKorTfms30nV3dWHJH9ROlZ2+PHAJ6mZAYs6YqRXVMr9Ys7L3zrhFMC149L0l8g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560157978; 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=nYdLr8+seyjfmc3QvYnjqelAkeqjosMin5elWg131XQ=; b=aCMNzaL4UgNftA9sh/vs4TKGRWG5gqaDdioUR87DrLZUUVGahFBR/7tTj5wL0lTAoP4sLbj0qBgdaJi9GuKYM56I9vlBBoArKrEyJ8bJUHjvRipMFgOY3p3OwwAcn52rULfZXYs9BuaWTu33xAx049z8wmwAZlWGfmiLBLXIQcY= 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 1560157978889156.44816345896947; Mon, 10 Jun 2019 02:12:58 -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 887A331628EF; Mon, 10 Jun 2019 09:12:49 +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 5668F6062D; Mon, 10 Jun 2019 09:12:47 +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 0A1F224F19; Mon, 10 Jun 2019 09:12:46 +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 x5A96BI0003298 for ; Mon, 10 Jun 2019 05:06:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5C5E012C85; Mon, 10 Jun 2019 09:06:11 +0000 (UTC) Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 55C115DDA3 for ; Mon, 10 Jun 2019 09:06:08 +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 041CCC1EB214 for ; Mon, 10 Jun 2019 09:06:03 +0000 (UTC) Received: by mail-ed1-f66.google.com with SMTP id g13so13484327edu.5 for ; Mon, 10 Jun 2019 02:06:02 -0700 (PDT) Received: from archpc.localdomain (x8d1ee222.agdsn.tu-dresden.de. [141.30.226.34]) by smtp.gmail.com with ESMTPSA id b10sm1724334eje.29.2019.06.10.02.06.00 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 10 Jun 2019 02:06:00 -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=PXW6o3XjaembSWblwvEmyu4XkzXF6qKgpOKWXhKv5Lo=; b=iJFsb6lHgA2kIY1K8PfdN5DKbZHN3c3CQN7AOLq4OW73DvUDUFjMfK3FmfbNDmnEl1 9Js7LVkOVs8ztBXT06KGPs9+7ffmOUkxuOaR8kXWsioex77I5hj3Q23RhAlS5oNvvOJd Cae8AEtdwJV7NH8UFVnssJy2A2OKH1PzErp8/LAWhKC09Eyl98zE+QxRaZyFiT66lEub fCpNZcoZz1/wNb4bqDT7gdrIGHSlOvexfYi/it0YoSBH2RlF0BRZWCVYFeztIT5Da4pC E15jqu77EMNh+IOx236Pv4Ee7hxAkub1FuIb4ew1LJCIq00Fq282G+mEXxSv2ctsFsp5 615Q== 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=PXW6o3XjaembSWblwvEmyu4XkzXF6qKgpOKWXhKv5Lo=; b=MMHnD3LoUntX8by1Mdppd1neZu4Mml0dJ620F3gDmRUjjdXtBVn+IxRC6uP3itNEkU KCShxgkanH9g4vhXVKZFaSmcIdlPG9uQ+xisqY/9d0YKXiO8aI8z7zz1XyYVjq+QtIRP zs8u9tMb4KcUHwY91POrJ6M2aEXJ5ZikUwbMspN8eZLiCsuGCTcLBOzTlarPZy3A7R5T eWKkiCQ2jFbx2gppIkCbMeulHLKRYbjACoXVhFZWtYhOL8c1LT+10LZeXPj66qEsxmR+ brycCDhEIvY71m7FEhOmFaZ6i7FV9OzciZ98t/vDxrSHvxaNnQHfmSQ8dtedBK6sy+sg +/3w== X-Gm-Message-State: APjAAAXTJUkAG9671VpL9BJMx3HxftMKsXJ9KTUY0BJkR0Mqv8nvAdw2 J9ZWrtuR9rbbBWwJyZ2jY5Hh0+0N X-Google-Smtp-Source: APXvYqyBkRxRLxqmySzllnnKiy1nZsfTCbI42u2wyFKQIlWPDF/SaFvaLZkwrDBeaMvP23JlEC3WEA== X-Received: by 2002:a50:be03:: with SMTP id a3mr72019774edi.5.1560157561322; Mon, 10 Jun 2019 02:06:01 -0700 (PDT) From: Ilias Stamatis To: libvir-list@redhat.com Date: Mon, 10 Jun 2019 11:04:59 +0200 Message-Id: <20190610090501.2274-3-stamatis.iliass@gmail.com> In-Reply-To: <20190610090501.2274-1-stamatis.iliass@gmail.com> References: <20190610090501.2274-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.32]); Mon, 10 Jun 2019 09:06:03 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 10 Jun 2019 09:06:03 +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.78 on 10.5.110.32 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Mon, 10 Jun 2019 09:12:57 +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 | 116 ++++++++++++++++++++++++++--------------- 1 file changed, 73 insertions(+), 43 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 3331ed5495..1b92cb43dd 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -2075,6 +2075,78 @@ testDomainSaveImageWrite(testDriverPtr driver, } +/** + * testDomainSaveImageOpen: + * @driver: test driver data + * @path: path of the saved 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) @@ -2130,14 +2202,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) { @@ -2146,46 +2215,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 Thu Apr 25 05:19:55 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=1560157908; cv=none; d=zoho.com; s=zohoarc; b=WhQMP2poW8zDuQTZj9hgg1nzVknqid0xj+OTf8hyrL6FhOA5/r+/6btwzZyUR8kjDo3lNpIL6i1z9smx7aBSF48tzFxzS5Hr7lmZ4Wuoi7R5hBwmk5ek7wKsMVpF9xjCB5QKTAA7LaWzLAIlmUOmI2hG/2jwC7bOD6clUKbMqqc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560157908; 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=2r/PLJh0rKrFkpR1kO4PBOUOvgRopmN5s6NqYDdBCq4=; b=Mk/BffspzCeQWG0H16C1iJ0VS+7lj4KCC3MNTEwOb6OiHA0qKfa5MiRGY0MmQ3HqwK6EpNV8+dUjBeRj08ZuOxcWMh4V+o17HATzOq8asVYb0oJhnlUPKMR1pjicyhr7XyjYOPXPOeWYtTWDS/x1lxy6ApYi3CiEjn5zO6d0bwA= 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 1560157908011394.4199322916128; Mon, 10 Jun 2019 02:11:48 -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 6552187622; Mon, 10 Jun 2019 09:11:19 +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 82F2F5D705; Mon, 10 Jun 2019 09:11:07 +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 13FB81806B12; Mon, 10 Jun 2019 09:10:50 +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 x5A96WS5003329 for ; Mon, 10 Jun 2019 05:06:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6B06D611BF; Mon, 10 Jun 2019 09:06:32 +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 64D0F60856 for ; Mon, 10 Jun 2019 09:06:28 +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 5CA283058838 for ; Mon, 10 Jun 2019 09:06:17 +0000 (UTC) Received: by mail-ed1-f65.google.com with SMTP id h10so13427590edi.13 for ; Mon, 10 Jun 2019 02:06:17 -0700 (PDT) Received: from archpc.localdomain (x8d1ee222.agdsn.tu-dresden.de. [141.30.226.34]) by smtp.gmail.com with ESMTPSA id b10sm1724334eje.29.2019.06.10.02.06.14 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 10 Jun 2019 02:06:15 -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=eFBNISUslQJbQvdh9bOkpuXU0D78PZCBmXB4cxfLGKs=; b=cB+u0xXtm+RDVUWO2qCAFLPALBKnG49+GFhvKQuhrRyTa4bcyBudtkDVdEBZWKW38Z OrTYgj7ljveuYRAg4M0aptzB6dT3+nRPH2nA6UKyJ7uWRwLhFOqxwzLTyvBBpwXnd2ZI paJ/uwTReM6J2LyW2eqjGfxt9g7Hg9g0e1p74tJ89H7DNCELvpjmFhEnwVedlOjpFFY+ 0egoeEF99VputFU7xLYvOmXk7oDLX9Zyj+jaI9feOo67PXijgEZiwGTGzvTD4OP5tuB8 H883PP43m3m2H9NUlPeL5t5laGY2HDWbROP0+FQCVO+tuTzfBEmF3a9sHJdtkayj5H3A aOJA== 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=eFBNISUslQJbQvdh9bOkpuXU0D78PZCBmXB4cxfLGKs=; b=X5NHYBEj12MI9wPbs/Sgu6xnfMS/Bqt7qIXH95VfXiSgFD9ruMMB605EaCV+TVyafq DwuV9S3GDGJPMIEaGS2aPSDi1Rtx03Ns8Mwm1OXm+nRYthfy0UBDn9OHHJE8PpH7bsNn zyxyWvKDJYdXMHpVegD6QMI4owf+ai+n/2/mkssBflM3LHzx+rK30iZcZJpJJHiMMftH zil+gksjKxjUEBjUBPiewpuZ/lToeRHxbhanq68C+UOYZcNvb7E5m9NAM8hW1OsRzvdw roGkWb9Rd6AfN4xZIEIdmBJg4KGgaP6eNAhbhfJNfC1isM9m6+WRt9GLEfwSuH2w4OvI Jd3w== X-Gm-Message-State: APjAAAWyrJTowX1A6IiKxgP14RQhHXfyvH7fccChitlUO5lv4otVFIvU BrABEVYiL9S2u4QS7sJUxZH8Rfch X-Google-Smtp-Source: APXvYqxt1ixVQ7/td+CKYoyR5OEQacZcwUJt7J2akXpfy4QHhS93PgTqXd/sgW9Uc/CXD5izJYXpqQ== X-Received: by 2002:a50:ad7d:: with SMTP id z58mr49967754edc.277.1560157575730; Mon, 10 Jun 2019 02:06:15 -0700 (PDT) From: Ilias Stamatis To: libvir-list@redhat.com Date: Mon, 10 Jun 2019 11:05:00 +0200 Message-Id: <20190610090501.2274-4-stamatis.iliass@gmail.com> In-Reply-To: <20190610090501.2274-1-stamatis.iliass@gmail.com> References: <20190610090501.2274-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]); Mon, 10 Jun 2019 09:06:17 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Mon, 10 Jun 2019 09:06:17 +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.84 on 10.5.110.41 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 10 Jun 2019 09:11:34 +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 | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 1b92cb43dd..906c9d5365 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -2255,6 +2255,42 @@ 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; + int fd =3D -1; + virDomainDefPtr def =3D NULL; + virDomainDefPtr newdef =3D NULL; + testDriverPtr privconn =3D conn->privateData; + + virCheckFlags(VIR_DOMAIN_SAVE_RUNNING | + VIR_DOMAIN_SAVE_PAUSED, -1); + + if ((fd =3D testDomainSaveImageOpen(privconn, path, &def)) < 0) + goto cleanup; + + if ((newdef =3D virDomainDefParseString(dxml, privconn->caps, privconn= ->xmlopt, NULL, + VIR_DOMAIN_DEF_PARSE_INACTIVE)) = =3D=3D NULL) + goto cleanup; + + if (!testDomainSaveImageWrite(privconn, path, newdef)) + goto cleanup; + + ret =3D 0; + + cleanup: + VIR_FORCE_CLOSE(fd); + virDomainDefFree(def); + virDomainDefFree(newdef); + return ret; +} + + static int testDomainCoreDumpWithFormat(virDomainPtr domain, const char *to, unsigned int dumpformat, @@ -7077,6 +7113,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.5.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 Thu Apr 25 05:19:55 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=1560157974; cv=none; d=zoho.com; s=zohoarc; b=Sg2xLguwNYZ0PhAIIQHJ4QVqxushShpnT2CHS47gOn7vyHfje4UkseuGCH/s1rzmq+299fsp2R1ShgwY4/T9qdEOiCbUDCyJAqONk+AwZ1MElnC9BDbHGPiV4pl4Ggv5xFrCN6h/rZ543xJekLORfiEQp2r67xQaXiQHHYYkh8g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560157974; 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=tqTdkGSEgBc8PSCXGoFq9Fl9Bf0QHTkHGujnpQWo31s=; b=gpVbBPFkqf1eYI1w9Dymw8WVNFQMXFnMgeWZ2Brz+bfRNnG+Mk80znXudts4DWydDy8VMi/aj3ZGTDOKd3lj0pWGxCxGvnzYh0lhWWi3iiosWBC/kIIDYLN36d3e5oaHFc4Q9NigVZgqTYHwOHRXX9COYdWyka6vqnI2m9dv4W4= 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 1560157974359842.0020969187382; Mon, 10 Jun 2019 02:12:54 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 967AFA3B60; Mon, 10 Jun 2019 09:12:46 +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 5DB0460C4E; Mon, 10 Jun 2019 09:12:46 +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 0D3431806B1D; Mon, 10 Jun 2019 09:12:46 +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 x5A978kv003963 for ; Mon, 10 Jun 2019 05:07:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id E5E181969F; Mon, 10 Jun 2019 09:07:08 +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 B44F619698 for ; Mon, 10 Jun 2019 09:07:08 +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 24090317916B for ; Mon, 10 Jun 2019 09:06:57 +0000 (UTC) Received: by mail-ed1-f66.google.com with SMTP id p15so13472786eds.8 for ; Mon, 10 Jun 2019 02:06:57 -0700 (PDT) Received: from archpc.localdomain (x8d1ee222.agdsn.tu-dresden.de. [141.30.226.34]) by smtp.gmail.com with ESMTPSA id b10sm1724334eje.29.2019.06.10.02.06.38 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 10 Jun 2019 02:06: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=27nE8/WZCzYzY36qXPFSKD2zP5qFsEpkOmBjQXYt5TE=; b=CdTnkg44aW3cIDbMsWHXw0nTB+bIX/hKF7aZFZH+KFP3O4abO9od1p7NKLqKIrnDMe EvXFkMWYDUc8J0wwZjmHsN8vYr8ZwgQQVaUTj2bDXWEXddKj0J9B+V6WOCjIoARbZ+cQ fqQtLJfGlS7sLbbOgKjceY9Ng//Od1h9ObEZZ1eaYgaKMjNlMW+JgheJgFH+Lr0BHALn gYkrNS/8m1MnlF/611nvArTvs1GyBHboQd/W8Ia/UHxAEizUs6xkYw6rw+2ujE60cYkF Xj3a7jjhIvo3/H2VU4q/h4h6xM7hP8yMI183CtCrFE8gOM83crUEpiNnkKcE7JZDpQb0 d8aw== 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=27nE8/WZCzYzY36qXPFSKD2zP5qFsEpkOmBjQXYt5TE=; b=oTChK7RaRm9YzCTrJw4LUs1Tz7F3wqMJsCYkUlpyrBuKn3eU9nmoKDbnEi+tvOWFm8 qTfhZzsg+j620n+2kIHJR2KVxQmekzEmOeroks0KzMsaou5CVCnnCVzptFTpmOFvb9XK o0y1zFtfbv0hfkzCpNQ74YE5RcMn1tqtSIFp+tTxGH6lgmTOqBk9gKi10He+Qw62wqSM 7IlacYaWFFqbshSLFSFbInNPyRg767Co5IOxCCxgSEyh6kkJhYtHC8N4FpMg33B+qKsX f6QcOjTTrEwSom4e/fgbvXS9QytMU3kCXRpCrp+Vst10Ry414IsyS60JSm6Xob1bG0Q8 sQmg== X-Gm-Message-State: APjAAAXod+FDC/0d4UWnmmjSl/jaO8tCSg5RirhORfz6+ELTCfSRgGed sdvbo86X/liytZ+7+C95py3ukBGX X-Google-Smtp-Source: APXvYqwhZeFfscgIrdf8/lGO6j3sCRsdN8L7D8QO412Q+l5Nlibg8tn94JsayeXdkJ5sUzb6oMkEEQ== X-Received: by 2002:a17:906:9410:: with SMTP id q16mr23193414ejx.90.1560157599379; Mon, 10 Jun 2019 02:06:39 -0700 (PDT) From: Ilias Stamatis To: libvir-list@redhat.com Date: Mon, 10 Jun 2019 11:05:01 +0200 Message-Id: <20190610090501.2274-5-stamatis.iliass@gmail.com> In-Reply-To: <20190610090501.2274-1-stamatis.iliass@gmail.com> References: <20190610090501.2274-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]); Mon, 10 Jun 2019 09:06:57 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Mon, 10 Jun 2019 09:06:57 +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.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 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.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 10 Jun 2019 09:12:52 +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 | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 906c9d5365..ebf6f84b58 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -2291,6 +2291,30 @@ testDomainSaveImageDefineXML(virConnectPtr conn, } +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, @@ -7114,6 +7138,7 @@ static virHypervisorDriver testHypervisorDriver =3D { .domainRestore =3D testDomainRestore, /* 0.3.2 */ .domainRestoreFlags =3D testDomainRestoreFlags, /* 0.9.4 */ .domainSaveImageDefineXML =3D testDomainSaveImageDefineXML, /* 5.5.0 */ + .domainSaveImageGetXMLDesc =3D testDomainSaveImageGetXMLDesc, /* 5.5.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