From nobody Sun Apr 28 02:13:06 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; 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 1501593991640440.64010271440964; Tue, 1 Aug 2017 06:26:31 -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 24D2CAB0AC; Tue, 1 Aug 2017 13:26:28 +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 E623D6D2A4; Tue, 1 Aug 2017 13:26:27 +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 2C49B1800C83; Tue, 1 Aug 2017 13:26:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v71DP8H5016353 for ; Tue, 1 Aug 2017 09:25:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 18BCA7B59F; Tue, 1 Aug 2017 13:25:08 +0000 (UTC) Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 089A47B594 for ; Tue, 1 Aug 2017 13:25:04 +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 0D80DD5F23 for ; Tue, 1 Aug 2017 13:24:56 +0000 (UTC) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 048A720872; Tue, 1 Aug 2017 09:17:56 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute7.internal (MEProxy); Tue, 01 Aug 2017 09:17:56 -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 E0D7F7E6C1; Tue, 1 Aug 2017 09:17:54 -0400 (EDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 24D2CAB0AC Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=invisiblethingslab.com Authentication-Results: ext-mx10.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 24D2CAB0AC Authentication-Results: mx1.redhat.com; dkim=fail reason="signature verification failed" (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="CHf3kqtN" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0D80DD5F23 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=invisiblethingslab.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=none smtp.mailfrom=marmarek@invisiblethingslab.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 0D80DD5F23 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=fm1; bh=+O/DkFimW4tWk/aXdK Jd0YAZXgLPQOvJhEO26Os4Wec=; b=CHf3kqtNB9PdHDVZYIgbOrpQfJVbdkXa9X 83X1jOH+GRvIbgzjHZGbJLNXbVNaKuwFbOBAMP2kqnbNRFP5xm8MEGst+aFBT4O0 AJ7aU9OvunSV8k49Tlc5NiXoc8R7OJ9odfDpC8evWdzwrQAe2hJnK4VrjiBSOc1c 9q319+rH1l9RU18/L3U4ACzZILlKMzC8L1layx2nYwBxme+RbWQk7lnkEmJf/cQW 75CJmWqAxEl77NuWAndhye1myJySLpebVOSxtbWsm8qAWLFhOhq4lF2P3iNMeXaD bhhAJOLRIR5GdZ9diS/NAa7l0mGQb7iZ7EibpKrIuz9qDZC9lyfQ== X-ME-Sender: X-Sasl-enc: hdXeadSE7nOgFrs3sS+KzdNDYul8Djr+cyEhUZxBz9hY 1501593475 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= To: libvir-list@redhat.com Date: Tue, 1 Aug 2017 15:17:51 +0200 Message-Id: <5c67e36f0886f1d21f67b132b9332c3d63231e17.1501593378.git-series.marmarek@invisiblethingslab.com> MIME-Version: 1.0 X-Greylist: Delayed for 00:06:59 by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 01 Aug 2017 13:24:57 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 01 Aug 2017 13:24:57 +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: -1.52 (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.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3] 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 01 Aug 2017 13:26:29 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 From: Jim Fehlig 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, use /bin/true emulator] Signed-off-by: Marek Marczykowski-G=C3=B3recki Reviewed-by: Joao Martins --- 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 3e3d580..49b9d40 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 -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..6fa41f3 --- /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": "/bin/true", + "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..d8cd2a2 --- /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 + + + + + + + + + /bin/true + + + + + + + + +