d76c62
From 6e2efb5b67a6d1a65c4e4facb7013f5e24622591 Mon Sep 17 00:00:00 2001
d76c62
Message-Id: <6e2efb5b67a6d1a65c4e4facb7013f5e24622591@dist-git>
d76c62
From: Peter Krempa <pkrempa@redhat.com>
d76c62
Date: Wed, 19 Feb 2020 15:10:25 +0100
d76c62
Subject: [PATCH] tests: qemu: Add test data for the new <slice> element
d76c62
MIME-Version: 1.0
d76c62
Content-Type: text/plain; charset=UTF-8
d76c62
Content-Transfer-Encoding: 8bit
d76c62
d76c62
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
d76c62
Reviewed-by: Ján Tomko <jtomko@redhat.com>
d76c62
(cherry picked from commit 293e7750c9c26ac19ed4fafa9c9f1fe3e90d5078)
d76c62
d76c62
 Changes:
d76c62
  tests/qemuxml2argvdata/disk-slices.x86_64-latest.args
d76c62
  tests/qemuxml2xmloutdata/disk-slices.x86_64-latest.xml
d76c62
d76c62
 Due to missing backport of changes related to CPU detection there is
d76c62
 difference in the XML files in unrelated parts.
d76c62
d76c62
https://bugzilla.redhat.com/show_bug.cgi?id=1791788
d76c62
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
d76c62
Message-Id: <21b28fdf8e4fc8aaf9a68b8c32be5d5a1fdedacc.1582120424.git.pkrempa@redhat.com>
d76c62
Reviewed-by: Ján Tomko <jtomko@redhat.com>
d76c62
---
d76c62
 .../disk-slices.x86_64-latest.args            | 52 ++++++++++++++++++
d76c62
 tests/qemuxml2argvdata/disk-slices.xml        | 45 ++++++++++++++++
d76c62
 tests/qemuxml2argvtest.c                      |  2 +
d76c62
 .../disk-slices.x86_64-latest.xml             | 53 +++++++++++++++++++
d76c62
 tests/qemuxml2xmltest.c                       |  2 +
d76c62
 5 files changed, 154 insertions(+)
d76c62
 create mode 100644 tests/qemuxml2argvdata/disk-slices.x86_64-latest.args
d76c62
 create mode 100644 tests/qemuxml2argvdata/disk-slices.xml
d76c62
 create mode 100644 tests/qemuxml2xmloutdata/disk-slices.x86_64-latest.xml
d76c62
d76c62
diff --git a/tests/qemuxml2argvdata/disk-slices.x86_64-latest.args b/tests/qemuxml2argvdata/disk-slices.x86_64-latest.args
d76c62
new file mode 100644
d76c62
index 0000000000..661b3f7ea1
d76c62
--- /dev/null
d76c62
+++ b/tests/qemuxml2argvdata/disk-slices.x86_64-latest.args
d76c62
@@ -0,0 +1,52 @@
d76c62
+LC_ALL=C \
d76c62
+PATH=/bin \
d76c62
+HOME=/tmp/lib/domain--1-QEMUGuest1 \
d76c62
+USER=test \
d76c62
+LOGNAME=test \
d76c62
+XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \
d76c62
+XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \
d76c62
+XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
d76c62
+QEMU_AUDIO_DRV=none \
d76c62
+/usr/bin/qemu-system-i386 \
d76c62
+-name guest=QEMUGuest1,debug-threads=on \
d76c62
+-S \
d76c62
+-object secret,id=masterKey0,format=raw,\
d76c62
+file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
d76c62
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
d76c62
+-m 214 \
d76c62
+-overcommit mem-lock=off \
d76c62
+-smp 1,sockets=1,cores=1,threads=1 \
d76c62
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
d76c62
+-display none \
d76c62
+-no-user-config \
d76c62
+-nodefaults \
d76c62
+-chardev socket,id=charmonitor,fd=1729,server,nowait \
d76c62
+-mon chardev=charmonitor,id=monitor,mode=control \
d76c62
+-rtc base=utc \
d76c62
+-no-shutdown \
d76c62
+-no-acpi \
d76c62
+-boot strict=on \
d76c62
+-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
d76c62
+-blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/raw.img",\
d76c62
+"node-name":"libvirt-3-storage","auto-read-only":true,"discard":"unmap"}' \
d76c62
+-blockdev '{"node-name":"libvirt-3-format","read-only":false,"driver":"raw",\
d76c62
+"offset":1234,"size":321,"file":"libvirt-3-storage"}' \
d76c62
+-device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x2,drive=libvirt-3-format,\
d76c62
+id=virtio-disk0,bootindex=1 \
d76c62
+-blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/raw.img",\
d76c62
+"node-name":"libvirt-2-storage","auto-read-only":true,"discard":"unmap"}' \
d76c62
+-blockdev '{"driver":"raw","node-name":"libvirt-2-slice-sto","offset":9876,\
d76c62
+"size":123456789,"file":"libvirt-2-storage","auto-read-only":true,\
d76c62
+"discard":"unmap"}' \
d76c62
+-blockdev '{"node-name":"libvirt-2-format","read-only":true,"driver":"qcow2",\
d76c62
+"file":"libvirt-2-slice-sto","backing":null}' \
d76c62
+-blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/overlay.qcow2",\
d76c62
+"node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \
d76c62
+-blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"qcow2",\
d76c62
+"file":"libvirt-1-storage","backing":"libvirt-2-format"}' \
d76c62
+-device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x3,drive=libvirt-1-format,\
d76c62
+id=virtio-disk1 \
d76c62
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 \
d76c62
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
d76c62
+resourcecontrol=deny \
d76c62
+-msg timestamp=on
d76c62
diff --git a/tests/qemuxml2argvdata/disk-slices.xml b/tests/qemuxml2argvdata/disk-slices.xml
d76c62
new file mode 100644
d76c62
index 0000000000..cff7cc7ee4
d76c62
--- /dev/null
d76c62
+++ b/tests/qemuxml2argvdata/disk-slices.xml
d76c62
@@ -0,0 +1,45 @@
d76c62
+<domain type='qemu'>
d76c62
+  <name>QEMUGuest1</name>
d76c62
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
d76c62
+  <memory unit='KiB'>219136</memory>
d76c62
+  <currentMemory unit='KiB'>219136</currentMemory>
d76c62
+  <vcpu placement='static'>1</vcpu>
d76c62
+  <os>
d76c62
+    <type arch='i686' machine='pc'>hvm</type>
d76c62
+    <boot dev='hd'/>
d76c62
+  </os>
d76c62
+  <clock offset='utc'/>
d76c62
+  <on_poweroff>destroy</on_poweroff>
d76c62
+  <on_reboot>restart</on_reboot>
d76c62
+  <on_crash>destroy</on_crash>
d76c62
+  <devices>
d76c62
+    <emulator>/usr/bin/qemu-system-i386</emulator>
d76c62
+    <disk type='file' device='disk'>
d76c62
+      <driver name='qemu' type='raw'/>
d76c62
+      <source file='/var/lib/libvirt/images/raw.img'>
d76c62
+        <slices>
d76c62
+          <slice type='storage' offset='1234' size='321'/>
d76c62
+        </slices>
d76c62
+      </source>
d76c62
+      <backingStore/>
d76c62
+      <target dev='vda' bus='virtio'/>
d76c62
+    </disk>
d76c62
+    <disk type='file' device='disk'>
d76c62
+      <driver name='qemu' type='qcow2'/>
d76c62
+      <source file='/var/lib/libvirt/images/overlay.qcow2'/>
d76c62
+      <backingStore type='file'>
d76c62
+        <format type='qcow2'/>
d76c62
+        <source file='/var/lib/libvirt/images/raw.img'>
d76c62
+          <slices>
d76c62
+            <slice type='storage' offset='9876' size='123456789'/>
d76c62
+          </slices>
d76c62
+        </source>
d76c62
+        <backingStore/>
d76c62
+      </backingStore>
d76c62
+      <target dev='vdb' bus='virtio'/>
d76c62
+    </disk>
d76c62
+    <controller type='usb'/>
d76c62
+    <controller type='pci' model='pci-root'/>
d76c62
+    <memballoon model='virtio'/>
d76c62
+  </devices>
d76c62
+</domain>
d76c62
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
d76c62
index 508dfee3fb..8215935bab 100644
d76c62
--- a/tests/qemuxml2argvtest.c
d76c62
+++ b/tests/qemuxml2argvtest.c
d76c62
@@ -1162,6 +1162,8 @@ mymain(void)
d76c62
     DO_TEST_CAPS_VER("disk-backing-chains-noindex", "2.12.0");
d76c62
     DO_TEST_CAPS_LATEST("disk-backing-chains-noindex");
d76c62
 
d76c62
+    DO_TEST_CAPS_LATEST("disk-slices");
d76c62
+
d76c62
     DO_TEST("graphics-egl-headless",
d76c62
             QEMU_CAPS_EGL_HEADLESS,
d76c62
             QEMU_CAPS_DEVICE_CIRRUS_VGA);
d76c62
diff --git a/tests/qemuxml2xmloutdata/disk-slices.x86_64-latest.xml b/tests/qemuxml2xmloutdata/disk-slices.x86_64-latest.xml
d76c62
new file mode 100644
d76c62
index 0000000000..8a56936910
d76c62
--- /dev/null
d76c62
+++ b/tests/qemuxml2xmloutdata/disk-slices.x86_64-latest.xml
d76c62
@@ -0,0 +1,53 @@
d76c62
+<domain type='qemu'>
d76c62
+  <name>QEMUGuest1</name>
d76c62
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
d76c62
+  <memory unit='KiB'>219136</memory>
d76c62
+  <currentMemory unit='KiB'>219136</currentMemory>
d76c62
+  <vcpu placement='static'>1</vcpu>
d76c62
+  <os>
d76c62
+    <type arch='i686' machine='pc'>hvm</type>
d76c62
+    <boot dev='hd'/>
d76c62
+  </os>
d76c62
+  <clock offset='utc'/>
d76c62
+  <on_poweroff>destroy</on_poweroff>
d76c62
+  <on_reboot>restart</on_reboot>
d76c62
+  <on_crash>destroy</on_crash>
d76c62
+  <devices>
d76c62
+    <emulator>/usr/bin/qemu-system-i386</emulator>
d76c62
+    <disk type='file' device='disk'>
d76c62
+      <driver name='qemu' type='raw'/>
d76c62
+      <source file='/var/lib/libvirt/images/raw.img'>
d76c62
+        <slices>
d76c62
+          <slice type='storage' offset='1234' size='321'/>
d76c62
+        </slices>
d76c62
+      </source>
d76c62
+      <backingStore/>
d76c62
+      <target dev='vda' bus='virtio'/>
d76c62
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
d76c62
+    </disk>
d76c62
+    <disk type='file' device='disk'>
d76c62
+      <driver name='qemu' type='qcow2'/>
d76c62
+      <source file='/var/lib/libvirt/images/overlay.qcow2'/>
d76c62
+      <backingStore type='file'>
d76c62
+        <format type='qcow2'/>
d76c62
+        <source file='/var/lib/libvirt/images/raw.img'>
d76c62
+          <slices>
d76c62
+            <slice type='storage' offset='9876' size='123456789'/>
d76c62
+          </slices>
d76c62
+        </source>
d76c62
+        <backingStore/>
d76c62
+      </backingStore>
d76c62
+      <target dev='vdb' bus='virtio'/>
d76c62
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
d76c62
+    </disk>
d76c62
+    <controller type='usb' index='0' model='piix3-uhci'>
d76c62
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
d76c62
+    </controller>
d76c62
+    <controller type='pci' index='0' model='pci-root'/>
d76c62
+    <input type='mouse' bus='ps2'/>
d76c62
+    <input type='keyboard' bus='ps2'/>
d76c62
+    <memballoon model='virtio'>
d76c62
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
d76c62
+    </memballoon>
d76c62
+  </devices>
d76c62
+</domain>
d76c62
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
d76c62
index 6a8ae9f7eb..a3c7f8fd47 100644
d76c62
--- a/tests/qemuxml2xmltest.c
d76c62
+++ b/tests/qemuxml2xmltest.c
d76c62
@@ -527,6 +527,8 @@ mymain(void)
d76c62
     DO_TEST("pci-rom-disabled-invalid", NONE);
d76c62
     DO_TEST("pci-serial-dev-chardev", NONE);
d76c62
 
d76c62
+    DO_TEST_CAPS_LATEST("disk-slices");
d76c62
+
d76c62
     DO_TEST("encrypted-disk", QEMU_CAPS_QCOW2_LUKS);
d76c62
     DO_TEST("encrypted-disk-usage", QEMU_CAPS_QCOW2_LUKS);
d76c62
     DO_TEST("luks-disks", NONE);
d76c62
-- 
d76c62
2.25.0
d76c62