From nobody Fri May 16 08:53:39 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 1501283312578650.58403059956; Fri, 28 Jul 2017 16:08:32 -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 B22AF734D8; Fri, 28 Jul 2017 23:08:30 +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 7FF0960F8A; Fri, 28 Jul 2017 23:08:30 +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 10A1A4BB79; Fri, 28 Jul 2017 23:08:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v6SN8CGt007079 for ; Fri, 28 Jul 2017 19:08:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id ED99018B54; Fri, 28 Jul 2017 23:08:12 +0000 (UTC) Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E805760317 for ; Fri, 28 Jul 2017 23:08:11 +0000 (UTC) Received: from smtp2.provo.novell.com (smtp2.provo.novell.com [137.65.250.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4920233887A for ; Fri, 28 Jul 2017 23:08:03 +0000 (UTC) Received: from linux-tbji.Home (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by smtp2.provo.novell.com with ESMTP (NOT encrypted); Fri, 28 Jul 2017 17:07:58 -0600 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B22AF734D8 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B22AF734D8 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4920233887A Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jfehlig@suse.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4920233887A From: Jim Fehlig To: libvir-list@redhat.com Date: Fri, 28 Jul 2017 17:07:34 -0600 Message-Id: <20170728230734.11001-3-jfehlig@suse.com> In-Reply-To: <20170728230734.11001-1-jfehlig@suse.com> References: <20170728230734.11001-1-jfehlig@suse.com> X-Greylist: Delayed for 25:43:21 by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 28 Jul 2017 23:08:04 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 28 Jul 2017 23:08:04 +0000 (UTC) for IP:'137.65.250.81' DOMAIN:'smtp2.provo.novell.com' HELO:'smtp2.provo.novell.com' FROM:'jfehlig@suse.com' RCPT:'' X-RedHat-Spam-Score: -2.301 (RCVD_IN_DNSWL_MED, SPF_PASS) 137.65.250.81 smtp2.provo.novell.com 137.65.250.81 smtp2.provo.novell.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: joao.m.martins@oracle.com Subject: [libvirt] [PATCH V2 2/2] libxl: Add a test suite for libxl_domain_config generator 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 28 Jul 2017 23:08:31 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The libxl library allows a libxl_domain_config object to be serialized from/to a JSON string. Use this to allow testing of the XML to libxl_domain_config conversion process. Test XML is converted to libxl_domain_config, which is then serialized to json. A json template corresponding to the test XML is converted to a libxl_domain_config object using libxl_domain_config_from_json(), and then serialized back to json using libxl_domain_config_to_json(). The two json docs are then compared. Using libxl to convert the json template to a libxl_domain_config object and then back to json provides a simple way to account for any changes or additions to the json representation across Xen releases. Signed-off-by: Jim Fehlig --- m4/virt-driver-libxl.m4 | 4 + tests/Makefile.am | 18 ++- tests/libxlxml2domconfigdata/basic-hvm.json | 89 +++++++++++ tests/libxlxml2domconfigdata/basic-hvm.xml | 36 +++++ tests/libxlxml2domconfigdata/basic-pv.json | 65 ++++++++ tests/libxlxml2domconfigdata/basic-pv.xml | 28 ++++ tests/libxlxml2domconfigdata/moredevs-hvm.json | 111 +++++++++++++ tests/libxlxml2domconfigdata/moredevs-hvm.xml | 63 ++++++++ tests/libxlxml2domconfigtest.c | 209 +++++++++++++++++++++= ++++ tests/virmocklibxl.c | 106 +++++++++++++ 10 files changed, 727 insertions(+), 2 deletions(-) diff --git a/m4/virt-driver-libxl.m4 b/m4/virt-driver-libxl.m4 index 96a9d4736..e6dbfef68 100644 --- a/m4/virt-driver-libxl.m4 +++ b/m4/virt-driver-libxl.m4 @@ -80,6 +80,10 @@ AC_DEFUN([LIBVIRT_DRIVER_CHECK_LIBXL], [ LIBXL_LIBS=3D"$LIBXL_LIBS -lxenctrl" ]) =20 + dnl Check if libxl_domain_config_from_json is available for domXML to + dnl libxl_domain_config tests + LIBS=3D"$LIBS -lxenlight -lxenctrl" + AC_CHECK_FUNCS([libxl_domain_config_from_json]) CFLAGS=3D"$old_CFLAGS" LIBS=3D"$old_LIBS" fi diff --git a/tests/Makefile.am b/tests/Makefile.am index 3e3d58071..1f8c4cd42 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -99,6 +99,7 @@ EXTRA_DIST =3D \ genericxml2xmlindata \ genericxml2xmloutdata \ interfaceschemadata \ + libxlxml2domconfigdata \ lxcconf2xmldata \ lxcxml2xmldata \ lxcxml2xmloutdata \ @@ -271,7 +272,8 @@ test_programs +=3D xml2sexprtest sexpr2xmltest \ endif WITH_XEN =20 if WITH_LIBXL -test_programs +=3D xlconfigtest +test_programs +=3D xlconfigtest libxlxml2domconfigtest +test_libraries +=3D virmocklibxl.la endif WITH_LIBXL =20 if WITH_QEMU @@ -528,8 +530,20 @@ xlconfigtest_SOURCES =3D \ xlconfigtest.c testutilsxen.c testutilsxen.h \ testutils.c testutils.h xlconfigtest_LDADD =3D$(libxl_LDADDS) + +libxlxml2domconfigtest_SOURCES =3D \ + libxlxml2domconfigtest.c testutilsxen.c testutilsxen.h \ + testutils.c testutils.h +libxlxml2domconfigtest_LDADD =3D $(libxl_LDADDS) $(LIBXML_LIBS) + +virmocklibxl_la_SOURCES =3D \ + virmocklibxl.c +virmocklibxl_la_CFLAGS =3D $(AM_CFLAGS) +virmocklibxl_la_LDFLAGS =3D $(MOCKLIBS_LDFLAGS) +virmocklibxl_la_LIBADD =3D $(MOCKLIBS_LIBS) + else ! WITH_LIBXL -EXTRA_DIST +=3D xlconfigtest.c +EXTRA_DIST +=3D xlconfigtest.c libxlxml2domconfigtest.c endif ! WITH_LIBXL =20 QEMUMONITORTESTUTILS_SOURCES =3D \ diff --git a/tests/libxlxml2domconfigdata/basic-hvm.json b/tests/libxlxml2d= omconfigdata/basic-hvm.json new file mode 100644 index 000000000..e4771920e --- /dev/null +++ b/tests/libxlxml2domconfigdata/basic-hvm.json @@ -0,0 +1,89 @@ +{ + "c_info": { + "type": "hvm", + "name": "test-hvm", + "uuid": "2147d599-9cc6-c0dc-92ab-4064b5446e9b" + }, + "b_info": { + "max_vcpus": 4, + "avail_vcpus": [ + 0, + 1, + 2, + 3 + ], + "max_memkb": 1048576, + "target_memkb": 1048576, + "video_memkb": 8192, + "shadow_memkb": 12288, + "device_model_version": "qemu_xen", + "device_model": "/usr/lib/xen/bin/qemu-system-i386", + "sched_params": { + "weight": 1000 + }, + "type.hvm": { + "pae": "True", + "apic": "True", + "acpi": "True", + "vga": { + "kind": "cirrus" + }, + "vnc": { + "enable": "True", + "listen": "0.0.0.0", + "findunused": "False" + }, + "sdl": { + "enable": "False" + }, + "spice": { + + }, + "boot": "c", + "rdm": { + + } + }, + "arch_arm": { + + } + }, + "disks": [ + { + "pdev_path": "/var/lib/xen/images/test-hvm.img", + "vdev": "hda", + "backend": "qdisk", + "format": "raw", + "removable": 1, + "readwrite": 1 + } + ], + "nics": [ + { + "devid": 0, + "mac": "00:16:3e:66:12:b4", + "bridge": "br0", + "script": "/etc/xen/scripts/vif-bridge", + "nictype": "vif_ioemu" + } + ], + "vfbs": [ + { + "devid": -1, + "vnc": { + "enable": "True", + "listen": "0.0.0.0", + "findunused": "False" + }, + "sdl": { + "enable": "False" + } + } + ], + "vkbs": [ + { + "devid": -1 + } + ], + "on_reboot": "restart" +} diff --git a/tests/libxlxml2domconfigdata/basic-hvm.xml b/tests/libxlxml2do= mconfigdata/basic-hvm.xml new file mode 100644 index 000000000..9dedf1729 --- /dev/null +++ b/tests/libxlxml2domconfigdata/basic-hvm.xml @@ -0,0 +1,36 @@ + + test-hvm + None + 2147d599-9cc6-c0dc-92ab-4064b5446e9b + 1048576 + 1048576 + 4 + destroy + restart + destroy + + + hvm + /usr/lib/xen/boot/hvmloader + + + + + + + + + /usr/lib/xen/bin/qemu-system-i386 + + + + + + + + +