From nobody Wed May 14 17:26:53 2025 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1522324313052853.3574355123391; Thu, 29 Mar 2018 04:51:53 -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 774D3B179; Thu, 29 Mar 2018 11:51:51 +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 4050A5D730; Thu, 29 Mar 2018 11:51:51 +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 ED28B180BADB; Thu, 29 Mar 2018 11:51:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2TBpQEU016494 for ; Thu, 29 Mar 2018 07:51:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id E75F61102E2C; Thu, 29 Mar 2018 11:51:25 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 70D0A1102E2B; Thu, 29 Mar 2018 11:51:25 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 29 Mar 2018 13:51:10 +0200 Message-Id: <5c75377248e3b29b4710c6a36735251659e582db.1522323985.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 13/14] tests: qemuxml2argv: Allow testing of config processed at startup 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: , MIME-Version: 1.0 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.30]); Thu, 29 Mar 2018 11:51:52 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add a new kind of XML output test for the files in qemuxml2argvtest where we can validate setup and defaults applied when starting up the VM. This is achieved by formatting of the definition processed by the qemuxml2argvtest into a XML and it's compared against files in qemuxml2startupxmloutdata. This test is automatically executed if the output file is present and it's skipped otherwise. The first example test case is created from 'disk-drive-shared' test case. Signed-off-by: Peter Krempa --- tests/Makefile.am | 1 + tests/qemuxml2argvtest.c | 42 +++++++++++++++- .../disk-drive-shared.xml | 56 ++++++++++++++++++= ++++ 3 files changed, 97 insertions(+), 2 deletions(-) create mode 100644 tests/qemuxml2startupxmloutdata/disk-drive-shared.xml diff --git a/tests/Makefile.am b/tests/Makefile.am index 289ef35bdd..f2f5caed4f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -127,6 +127,7 @@ EXTRA_DIST =3D \ qemuhotplugtestdomains \ qemumonitorjsondata \ qemuxml2argvdata \ + qemuxml2startupxmloutdata \ qemuxml2xmloutdata \ qemustatusxml2xmldata \ qemuqapischema.json \ diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 896d104593..7e7a937c8d 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -277,6 +277,7 @@ struct testInfo { unsigned int flags; unsigned int parseFlags; bool skipLegacyCPUs; + virDomainObjPtr vm; }; @@ -402,9 +403,39 @@ testUpdateQEMUCaps(const struct testInfo *info, static int -testCompareXMLToArgv(const void *data) +testCompareXMLToStartupXML(const void *data) { const struct testInfo *info =3D data; + unsigned int format_flags =3D VIR_DOMAIN_DEF_FORMAT_SECURE; + char *xml =3D NULL; + char *actual =3D NULL; + int ret =3D -1; + + if (virAsprintf(&xml, "%s/qemuxml2startupxmloutdata/%s.xml", + abs_srcdir, info->name) < 0) + goto cleanup; + + if (!virFileExists(xml)) { + ret =3D EXIT_AM_SKIP; + goto cleanup; + } + + if (!(actual =3D virDomainDefFormat(info->vm->def, NULL, format_flags)= )) + goto cleanup; + + ret =3D virTestCompareToFile(actual, xml); + + cleanup: + VIR_FREE(xml); + VIR_FREE(actual); + return ret; +} + + +static int +testCompareXMLToArgv(const void *data) +{ + struct testInfo *info =3D (void *) data; char *xml =3D NULL; char *args =3D NULL; char *migrateURI =3D NULL; @@ -532,6 +563,9 @@ testCompareXMLToArgv(const void *data) ret =3D 0; } + if (!(flags & FLAG_EXPECT_FAILURE) && ret =3D=3D 0) + VIR_STEAL_PTR(info->vm, vm); + cleanup: VIR_FREE(log); VIR_FREE(actualargv); @@ -625,7 +659,7 @@ mymain(void) do { \ static struct testInfo info =3D { \ name, NULL, migrateFrom, migrateFd, (flags), parseFlags, \ - false \ + false, NULL \ }; \ info.skipLegacyCPUs =3D skipLegacyCPUs; \ if (testInitQEMUCaps(&info, gic) < 0) \ @@ -634,7 +668,11 @@ mymain(void) if (virTestRun("QEMU XML-2-ARGV " name, \ testCompareXMLToArgv, &info) < 0) \ ret =3D -1; \ + if (info.vm && virTestRun("QEMU XML-2-startup-XML " name, \ + testCompareXMLToStartupXML, &info) < 0) \ + ret =3D -1; \ virObjectUnref(info.qemuCaps); \ + virObjectUnref(info.vm); \ } while (0) # define DO_TEST(name, ...) \ diff --git a/tests/qemuxml2startupxmloutdata/disk-drive-shared.xml b/tests/= qemuxml2startupxmloutdata/disk-drive-shared.xml new file mode 100644 index 0000000000..f4d2871ae7 --- /dev/null +++ b/tests/qemuxml2startupxmloutdata/disk-drive-shared.xml @@ -0,0 +1,56 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + + + XYZXYZXYZYXXYZYZYXYZY + +
+ + + + + + + +
+ + + +
+ + + +
+ + + + + + + + + + + + +
+ + + --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list