[PATCH 11/11] tests: qemuxml2*: Add testing of authenticated http/ftp disks

Peter Krempa pkrempa at redhat.com
Fri Apr 22 15:31:55 UTC 2022


Extend the 'disk-cdrom-network' to cover this instance. This also
validates that the parameters of -blockdev conform to the QAPI schema.

Also add the xml2xml variant of this test case.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 .../disk-cdrom-network.x86_64-4.1.0.args      |  6 +-
 .../disk-cdrom-network.x86_64-latest.args     |  6 +-
 tests/qemuxml2argvdata/disk-cdrom-network.xml |  6 ++
 .../disk-cdrom-network.x86_64-latest.xml      | 72 +++++++++++++++++++
 tests/qemuxml2xmltest.c                       |  1 +
 5 files changed, 87 insertions(+), 4 deletions(-)
 create mode 100644 tests/qemuxml2xmloutdata/disk-cdrom-network.x86_64-latest.xml

diff --git a/tests/qemuxml2argvdata/disk-cdrom-network.x86_64-4.1.0.args b/tests/qemuxml2argvdata/disk-cdrom-network.x86_64-4.1.0.args
index 00030f208d..34bd38622a 100644
--- a/tests/qemuxml2argvdata/disk-cdrom-network.x86_64-4.1.0.args
+++ b/tests/qemuxml2argvdata/disk-cdrom-network.x86_64-4.1.0.args
@@ -28,9 +28,11 @@ QEMU_AUDIO_DRV=none \
 -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
 -drive file=ftp://host.name:21/url/path/file.iso,format=raw,if=none,id=drive-ide0-0-0,readonly=on \
 -device ide-cd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
--drive file=ftps://host.name:990/url/path/file.iso,format=raw,if=none,id=drive-ide0-0-1,readonly=on \
+-object secret,id=ide0-0-1-auth-secret0,data=9eao5F8qtkGt+seB1HYivWIxbtwUu6MQtg1zpj/oDtUsPr1q8wBYM91uEHCn6j/1,keyid=masterKey0,iv=AAECAwQFBgcICQoLDA0ODw==,format=base64 \
+-drive file=ftps://host.name:990/url/path/file.iso,file.password-secret=ide0-0-1-auth-secret0,format=raw,if=none,id=drive-ide0-0-1,readonly=on \
 -device ide-cd,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1 \
--drive 'file=https://host.name:443/url/path/file.iso?test=val,format=raw,if=none,id=drive-ide0-1-0,readonly=on' \
+-object secret,id=ide0-1-0-auth-secret0,data=9eao5F8qtkGt+seB1HYivWIxbtwUu6MQtg1zpj/oDtUsPr1q8wBYM91uEHCn6j/1,keyid=masterKey0,iv=AAECAwQFBgcICQoLDA0ODw==,format=base64 \
+-drive 'file=https://host.name:443/url/path/file.iso?test=val,file.password-secret=ide0-1-0-auth-secret0,format=raw,if=none,id=drive-ide0-1-0,readonly=on' \
 -device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \
 -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
diff --git a/tests/qemuxml2argvdata/disk-cdrom-network.x86_64-latest.args b/tests/qemuxml2argvdata/disk-cdrom-network.x86_64-latest.args
index 6bc09072eb..267e4cb47b 100644
--- a/tests/qemuxml2argvdata/disk-cdrom-network.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/disk-cdrom-network.x86_64-latest.args
@@ -30,10 +30,12 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
 -blockdev '{"driver":"ftp","url":"ftp://host.name:21/url/path/file.iso","node-name":"libvirt-3-storage","auto-read-only":true,"discard":"unmap"}' \
 -blockdev '{"node-name":"libvirt-3-format","read-only":true,"driver":"raw","file":"libvirt-3-storage"}' \
 -device '{"driver":"ide-cd","bus":"ide.0","unit":0,"drive":"libvirt-3-format","id":"ide0-0-0","bootindex":1}' \
--blockdev '{"driver":"ftps","url":"ftps://host.name:990/url/path/file.iso","node-name":"libvirt-2-storage","auto-read-only":true,"discard":"unmap"}' \
+-object '{"qom-type":"secret","id":"libvirt-2-storage-auth-secret0","data":"9eao5F8qtkGt+seB1HYivWIxbtwUu6MQtg1zpj/oDtUsPr1q8wBYM91uEHCn6j/1","keyid":"masterKey0","iv":"AAECAwQFBgcICQoLDA0ODw==","format":"base64"}' \
+-blockdev '{"driver":"ftps","url":"ftps://host.name:990/url/path/file.iso","username":"testuser","password-secret":"libvirt-2-storage-auth-secret0","node-name":"libvirt-2-storage","auto-read-only":true,"discard":"unmap"}' \
 -blockdev '{"node-name":"libvirt-2-format","read-only":true,"driver":"raw","file":"libvirt-2-storage"}' \
 -device '{"driver":"ide-cd","bus":"ide.0","unit":1,"drive":"libvirt-2-format","id":"ide0-0-1"}' \
--blockdev '{"driver":"https","url":"https://host.name:443/url/path/file.iso?test=val","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \
+-object '{"qom-type":"secret","id":"libvirt-1-storage-auth-secret0","data":"9eao5F8qtkGt+seB1HYivWIxbtwUu6MQtg1zpj/oDtUsPr1q8wBYM91uEHCn6j/1","keyid":"masterKey0","iv":"AAECAwQFBgcICQoLDA0ODw==","format":"base64"}' \
+-blockdev '{"driver":"https","url":"https://host.name:443/url/path/file.iso?test=val","username":"testuser","password-secret":"libvirt-1-storage-auth-secret0","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \
 -blockdev '{"node-name":"libvirt-1-format","read-only":true,"driver":"raw","file":"libvirt-1-storage"}' \
 -device '{"driver":"ide-cd","bus":"ide.1","unit":0,"drive":"libvirt-1-format","id":"ide0-1-0"}' \
 -audiodev '{"id":"audio1","driver":"none"}' \
diff --git a/tests/qemuxml2argvdata/disk-cdrom-network.xml b/tests/qemuxml2argvdata/disk-cdrom-network.xml
index 14872d8889..40c53dd8fc 100644
--- a/tests/qemuxml2argvdata/disk-cdrom-network.xml
+++ b/tests/qemuxml2argvdata/disk-cdrom-network.xml
@@ -32,6 +32,9 @@
       <driver name='qemu' type='raw'/>
       <source protocol='ftps' name='/url/path/file.iso'>
         <host name='host.name' port='990'/>
+        <auth username='testuser'>
+          <secret type='iscsi' usage='mycluster_myname'/>
+        </auth>
       </source>
       <target dev='hdb' bus='ide'/>
       <readonly/>
@@ -41,6 +44,9 @@
       <driver name='qemu' type='raw'/>
       <source protocol='https' name='/url/path/file.iso' query='test=val'>
         <host name='host.name' port='443'/>
+        <auth username='testuser'>
+          <secret type='iscsi' usage='mycluster_myname'/>
+        </auth>
       </source>
       <target dev='hdc' bus='ide'/>
       <readonly/>
diff --git a/tests/qemuxml2xmloutdata/disk-cdrom-network.x86_64-latest.xml b/tests/qemuxml2xmloutdata/disk-cdrom-network.x86_64-latest.xml
new file mode 100644
index 0000000000..86f8ccf921
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/disk-cdrom-network.x86_64-latest.xml
@@ -0,0 +1,72 @@
+<domain type='kvm'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>1048576</memory>
+  <currentMemory unit='KiB'>1048576</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='x86_64' machine='pc'>hvm</type>
+    <boot dev='cdrom'/>
+  </os>
+  <features>
+    <acpi/>
+    <apic/>
+    <pae/>
+  </features>
+  <cpu mode='custom' match='exact' check='none'>
+    <model fallback='forbid'>qemu64</model>
+  </cpu>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>restart</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-x86_64</emulator>
+    <disk type='network' device='cdrom'>
+      <driver name='qemu' type='raw'/>
+      <source protocol='ftp' name='/url/path/file.iso'>
+        <host name='host.name' port='21'/>
+      </source>
+      <target dev='hda' bus='ide'/>
+      <readonly/>
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+    </disk>
+    <disk type='network' device='cdrom'>
+      <driver name='qemu' type='raw'/>
+      <source protocol='ftps' name='/url/path/file.iso'>
+        <host name='host.name' port='990'/>
+        <auth username='testuser'>
+          <secret type='iscsi' usage='mycluster_myname'/>
+        </auth>
+      </source>
+      <target dev='hdb' bus='ide'/>
+      <readonly/>
+      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
+    </disk>
+    <disk type='network' device='cdrom'>
+      <driver name='qemu' type='raw'/>
+      <source protocol='https' name='/url/path/file.iso' query='test=val'>
+        <host name='host.name' port='443'/>
+        <auth username='testuser'>
+          <secret type='iscsi' usage='mycluster_myname'/>
+        </auth>
+      </source>
+      <target dev='hdc' bus='ide'/>
+      <readonly/>
+      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
+    </disk>
+    <controller type='usb' index='0' model='piix3-uhci'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+    </controller>
+    <controller type='pci' index='0' model='pci-root'/>
+    <controller type='ide' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+    </controller>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <audio id='1' type='none'/>
+    <memballoon model='virtio'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+    </memballoon>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 16d2269423..58ee29cd33 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -322,6 +322,7 @@ mymain(void)
     DO_TEST_CAPS_LATEST("disk-aio-io_uring");
     DO_TEST_NOCAPS("disk-cdrom");
     DO_TEST_CAPS_LATEST("disk-cdrom-empty-network-invalid");
+    DO_TEST_CAPS_LATEST("disk-cdrom-network");
     DO_TEST("disk-cdrom-bus-other", QEMU_CAPS_DEVICE_USB_STORAGE);
     DO_TEST_NOCAPS("disk-floppy");
     DO_TEST("disk-usb-device", QEMU_CAPS_DEVICE_USB_STORAGE);
-- 
2.35.1



More information about the libvir-list mailing list