From nobody Fri Apr 19 20:04:28 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.zoho.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 1498962245720213.4345065085239; Sat, 1 Jul 2017 19:24:05 -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 90FE385543; Sun, 2 Jul 2017 02:24:03 +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 C715D61F31; Sun, 2 Jul 2017 02:24:02 +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 2E71F4A492; Sun, 2 Jul 2017 02:24:01 +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 v622Nxt4021489 for ; Sat, 1 Jul 2017 22:23:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4E48060318; Sun, 2 Jul 2017 02:23:59 +0000 (UTC) Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.phx2.redhat.com [10.5.110.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 47943600CD for ; Sun, 2 Jul 2017 02:23:57 +0000 (UTC) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 51DC76AAE7 for ; Sun, 2 Jul 2017 02:23:50 +0000 (UTC) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id CD36B20AB8; Sat, 1 Jul 2017 22:23:49 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute7.internal (MEProxy); Sat, 01 Jul 2017 22:23:49 -0400 Received: from devel-3rdparty.localdomain (89-70-103-23.dynamic.chello.pl [89.70.103.23]) by mail.messagingengine.com (Postfix) with ESMTPA id CB6E97E766; Sat, 1 Jul 2017 22:23:48 -0400 (EDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 90FE385543 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=invisiblethingslab.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 90FE385543 Authentication-Results: mx1.redhat.com; dkim=fail reason="signature verification failed" (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="Rohyu65M" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 51DC76AAE7 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=invisiblethingslab.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=none smtp.mailfrom=marmarek@invisiblethingslab.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 51DC76AAE7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= fm1; bh=sP0P7ZbsRCud2SC+FNfFR/Dw51Lpo7q8wkBO40Dd93E=; b=Rohyu65M 5RBTJBnLpyRDsnkgbAHCmRALmqcFwMr33q4KYt7ySbxfaS+W5e2FFK/dfcd3FUWJ 5ZqtbYPcJiB/qy2CjOOuIFJlpUN1gbbuJPW8PcWZ59lRSMvbZoqUWcwH6C2KzeY8 8uV/iMc8cFjI1yZiVygBwjbgAy5FSvAudROBYFWFhJ+A8bb9w7G6WDdHp2OoKJIi uVq0b4QDn4BGeQ/dQ2U0JtIx0Q7VEI4UJTvLs9hrmytHZhs1mlfz6UtAMFIEt+uN 8AM4GSRM4jtDfTlg2Zcv/kapJczgXLTUuE9UsTH8wvCA2BovE8ZGjMkV5PoiQYUI hdyOPcNEr0gHKg== X-ME-Sender: X-Sasl-enc: iU0k9Zpj6BXBuTtvOmQWFzfFtl8C0tSUNnQoeaVWgKIL 1498962229 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= To: libvir-list@redhat.com Date: Sun, 2 Jul 2017 04:22:51 +0200 Message-Id: <1498962171-2129-1-git-send-email-marmarek@invisiblethingslab.com> In-Reply-To: <20170227020227.15438-4-jfehlig@suse.com> References: <20170227020227.15438-4-jfehlig@suse.com> MIME-Version: 1.0 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 203 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Sun, 02 Jul 2017 02:23:50 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Sun, 02 Jul 2017 02:23:50 +0000 (UTC) for IP:'66.111.4.25' DOMAIN:'out1-smtp.messagingengine.com' HELO:'out1-smtp.messagingengine.com' FROM:'marmarek@invisiblethingslab.com' RCPT:'' X-RedHat-Spam-Score: -0.32 (BAYES_50, DCC_REPUT_00_12, DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL) 66.111.4.25 out1-smtp.messagingengine.com 66.111.4.25 out1-smtp.messagingengine.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.26 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2] 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: , Content-Type: text/plain; charset="utf-8" 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.28]); Sun, 02 Jul 2017 02:24:04 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 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 [update to v3.5.0-rc1, improve error reporting] Signed-off-by: Marek Marczykowski-G=C3=B3recki --- m4/virt-driver-libxl.m4 | 6 +- 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 | 205 +++++++++++++++++++++= ++++ tests/virmocklibxl.c | 87 +++++++++++ 10 files changed, 705 insertions(+), 3 deletions(-) create mode 100644 tests/libxlxml2domconfigdata/basic-hvm.json create mode 100644 tests/libxlxml2domconfigdata/basic-hvm.xml create mode 100644 tests/libxlxml2domconfigdata/basic-pv.json create mode 100644 tests/libxlxml2domconfigdata/basic-pv.xml create mode 100644 tests/libxlxml2domconfigdata/moredevs-hvm.json create mode 100644 tests/libxlxml2domconfigdata/moredevs-hvm.xml create mode 100644 tests/libxlxml2domconfigtest.c create mode 100644 tests/virmocklibxl.c diff --git a/m4/virt-driver-libxl.m4 b/m4/virt-driver-libxl.m4 index 96a9d47..3d635f0 100644 --- a/m4/virt-driver-libxl.m4 +++ b/m4/virt-driver-libxl.m4 @@ -35,7 +35,7 @@ AC_DEFUN([LIBVIRT_DRIVER_CHECK_LIBXL], [ if test "x$with_libxl" =3D "xyes" ; then LIBXL_FIRMWARE_DIR=3D$($PKG_CONFIG --variable xenfirmwaredir xenlight) LIBXL_EXECBIN_DIR=3D$($PKG_CONFIG --variable libexec_bin xenlight) - fi + fi =20 dnl pkgconfig file not found, fallback to lib probe if test "x$with_libxl" =3D "xno" ; then @@ -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 19986dc..6e4419f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -102,6 +102,7 @@ EXTRA_DIST =3D \ genericxml2xmlindata \ genericxml2xmloutdata \ interfaceschemadata \ + libxlxml2domconfigdata \ lxcconf2xmldata \ lxcxml2xmldata \ lxcxml2xmloutdata \ @@ -274,7 +275,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 @@ -529,8 +531,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 -module -avoid-version \ + -rpath /evil/libtool/hack/to/force/shared/lib/creation + 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 0000000..e477192 --- /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 0000000..9dedf17 --- /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 + + + + + + + + +