]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuhotplugtest: Verify domain XML on UPDATE
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 21 Apr 2023 07:56:20 +0000 (09:56 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 25 Apr 2023 06:46:27 +0000 (08:46 +0200)
Just like we check the resulting domain XML after ATTACH and
DETACH, we should do the same after UPDATE action. This is as
simple as calling testQemuHotplugCheckResult() and providing
missing XMLs. For those test cases where no change is done, we
can just make the expected XML a symlink to the input XML.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
tests/qemuhotplugtest.c
tests/qemuhotplugtestdomains/qemuhotplug-disk-cdrom+disk-cdrom-nochange.xml [new symlink]
tests/qemuhotplugtestdomains/qemuhotplug-disk-cdrom.xml
tests/qemuhotplugtestdomains/qemuhotplug-graphics-spice+graphics-spice-nochange.xml [new symlink]
tests/qemuhotplugtestdomains/qemuhotplug-graphics-spice-listen-network+graphics-spice-listen-network-password.xml [new file with mode: 0644]
tests/qemuhotplugtestdomains/qemuhotplug-graphics-spice-timeout+graphics-spice-timeout-nochange.xml [new symlink]
tests/qemuhotplugtestdomains/qemuhotplug-graphics-spice-timeout+graphics-spice-timeout-password.xml [new file with mode: 0644]
tests/qemuhotplugtestdomains/qemuhotplug-graphics-spice-timeout.xml
tests/qemuhotplugtestdomains/qemuhotplug-graphics-spice.xml

index d571cd38dcf063a6f7219e96b29df97fc8ab3433..5666e87f75b1e8dd47b301ab582f4f3b708ffab1 100644 (file)
@@ -123,7 +123,7 @@ testQemuHotplugCheckResult(virDomainObj *vm,
     if (!actual)
         return -1;
 
-    if (STREQ(expected, actual)) {
+    if (STREQ_NULLABLE(expected, actual)) {
         if (fail)
             VIR_TEST_VERBOSE("domain XML should not match the expected result");
         ret = 0;
@@ -170,7 +170,9 @@ testQemuHotplug(const void *data)
         virTestLoadFile(device_filename, &device_xml) < 0)
         goto cleanup;
 
-    if (test->action == ATTACH &&
+    if (!fail &&
+        (test->action == ATTACH ||
+         test->action == UPDATE) &&
         virTestLoadFile(result_filename, &result_xml) < 0)
         goto cleanup;
 
@@ -243,6 +245,9 @@ testQemuHotplug(const void *data)
 
     case UPDATE:
         ret = qemuDomainUpdateDeviceLive(vm, dev, &driver, false);
+        if (ret == 0 || fail)
+            ret = testQemuHotplugCheckResult(vm, result_xml,
+                                             result_filename, fail);
     }
 
     virObjectLock(priv->mon);
diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-disk-cdrom+disk-cdrom-nochange.xml b/tests/qemuhotplugtestdomains/qemuhotplug-disk-cdrom+disk-cdrom-nochange.xml
new file mode 120000 (symlink)
index 0000000..e07b01b
--- /dev/null
@@ -0,0 +1 @@
+qemuhotplug-disk-cdrom.xml
\ No newline at end of file
index 3acf55ab17ac99eaaf3e089073fc79f878c08a94..bcf4cf9bf80f963a80d0d87889e6d2db6386582c 100644 (file)
@@ -1,4 +1,4 @@
-<domain type='qemu'>
+<domain type='qemu' id='7'>
   <name>QEMUGuest1</name>
   <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
   <memory unit='KiB'>219100</memory>
@@ -8,6 +8,9 @@
     <type arch='x86_64' machine='pc'>hvm</type>
     <boot dev='hd'/>
   </os>
+  <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>
@@ -18,6 +21,7 @@
       <driver name='qemu' type='raw'/>
       <source dev='/dev/HostVG/QEMUGuest1'/>
       <target dev='hda' bus='ide'/>
+      <alias name='ide0-0-0'/>
       <address type='drive' controller='0' bus='0' target='0' unit='0'/>
     </disk>
     <disk type='file' device='cdrom'>
       <source file='/root/boot.iso'/>
       <target dev='hdc' bus='ide'/>
       <readonly/>
+      <alias name='ide0-1-0'/>
       <address type='drive' controller='0' bus='1' target='0' unit='0'/>
     </disk>
-    <controller type='usb' index='0'/>
-    <controller type='ide' index='0'/>
-    <controller type='pci' index='0' model='pci-root'/>
-    <input type='mouse' bus='ps2'/>
-    <input type='keyboard' bus='ps2'/>
+    <controller type='usb' index='0' model='piix3-uhci'>
+      <alias name='usb'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+    </controller>
+    <controller type='ide' index='0'>
+      <alias name='ide'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+    </controller>
+    <controller type='pci' index='0' model='pci-root'>
+      <alias name='pci.0'/>
+    </controller>
+    <input type='mouse' bus='ps2'>
+      <alias name='input0'/>
+    </input>
+    <input type='keyboard' bus='ps2'>
+      <alias name='input1'/>
+    </input>
+    <audio id='1' type='none'/>
     <memballoon model='none'/>
   </devices>
 </domain>
diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-graphics-spice+graphics-spice-nochange.xml b/tests/qemuhotplugtestdomains/qemuhotplug-graphics-spice+graphics-spice-nochange.xml
new file mode 120000 (symlink)
index 0000000..4f731cb
--- /dev/null
@@ -0,0 +1 @@
+qemuhotplug-graphics-spice.xml
\ No newline at end of file
diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-graphics-spice-listen-network+graphics-spice-listen-network-password.xml b/tests/qemuhotplugtestdomains/qemuhotplug-graphics-spice-listen-network+graphics-spice-listen-network-password.xml
new file mode 100644 (file)
index 0000000..9cc2734
--- /dev/null
@@ -0,0 +1,71 @@
+<domain type='qemu' id='7'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219136</memory>
+  <currentMemory unit='KiB'>219136</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='x86_64' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <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>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-x86_64</emulator>
+    <disk type='block' device='disk'>
+      <driver name='qemu' type='raw'/>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda' bus='ide'/>
+      <alias name='ide0-0-0'/>
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+    </disk>
+    <controller type='usb' index='0' model='piix3-uhci'>
+      <alias name='usb'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+    </controller>
+    <controller type='ide' index='0'>
+      <alias name='ide'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+    </controller>
+    <controller type='pci' index='0' model='pci-root'>
+      <alias name='pci.0'/>
+    </controller>
+    <input type='mouse' bus='ps2'>
+      <alias name='input0'/>
+    </input>
+    <input type='keyboard' bus='ps2'>
+      <alias name='input1'/>
+    </input>
+    <graphics type='spice' port='5900' tlsPort='5901' autoport='yes' listen='10.65.210.231' keymap='en-us' passwd='password2' passwdValidTo='2013-06-20T01:34:37' connected='disconnect'>
+      <listen type='network' address='10.65.210.231' network='vdsm-rhevm'/>
+      <channel name='main' mode='secure'/>
+      <channel name='display' mode='secure'/>
+      <channel name='inputs' mode='secure'/>
+      <channel name='cursor' mode='secure'/>
+      <channel name='playback' mode='secure'/>
+      <channel name='record' mode='secure'/>
+      <channel name='smartcard' mode='secure'/>
+      <channel name='usbredir' mode='secure'/>
+    </graphics>
+    <audio id='1' type='spice'/>
+    <video>
+      <model type='qxl' ram='65536' vram='32768' vgamem='16384' heads='1' primary='yes'/>
+      <alias name='video0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+    </video>
+    <video>
+      <model type='qxl' ram='65536' vram='32768' vgamem='16384' heads='1'/>
+      <alias name='video1'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+    </video>
+    <memballoon model='virtio'>
+      <alias name='balloon0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+    </memballoon>
+  </devices>
+</domain>
diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-graphics-spice-timeout+graphics-spice-timeout-nochange.xml b/tests/qemuhotplugtestdomains/qemuhotplug-graphics-spice-timeout+graphics-spice-timeout-nochange.xml
new file mode 120000 (symlink)
index 0000000..3a5bce5
--- /dev/null
@@ -0,0 +1 @@
+qemuhotplug-graphics-spice-timeout.xml
\ No newline at end of file
diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-graphics-spice-timeout+graphics-spice-timeout-password.xml b/tests/qemuhotplugtestdomains/qemuhotplug-graphics-spice-timeout+graphics-spice-timeout-password.xml
new file mode 100644 (file)
index 0000000..03964ad
--- /dev/null
@@ -0,0 +1,117 @@
+<domain type='kvm' id='7'>
+  <name>f14</name>
+  <uuid>553effab-b5e1-2d80-dfe3-da4344826c43</uuid>
+  <memory unit='KiB'>1048576</memory>
+  <currentMemory unit='KiB'>1048576</currentMemory>
+  <vcpu placement='static'>2</vcpu>
+  <os>
+    <type arch='x86_64' machine='pc'>hvm</type>
+    <boot dev='cdrom'/>
+    <boot dev='hd'/>
+    <bootmenu enable='yes'/>
+  </os>
+  <features>
+    <acpi/>
+    <apic/>
+    <pae/>
+  </features>
+  <cpu mode='custom' match='exact' check='partial'>
+    <model fallback='allow'>core2duo</model>
+    <vendor>Intel</vendor>
+    <topology sockets='1' dies='1' cores='2' threads='1'/>
+    <feature policy='require' name='lahf_lm'/>
+    <feature policy='require' name='xtpr'/>
+    <feature policy='require' name='cx16'/>
+    <feature policy='require' name='tm2'/>
+    <feature policy='require' name='est'/>
+    <feature policy='require' name='vmx'/>
+    <feature policy='require' name='ds_cpl'/>
+    <feature policy='require' name='pbe'/>
+    <feature policy='require' name='tm'/>
+    <feature policy='require' name='ht'/>
+    <feature policy='require' name='ss'/>
+    <feature policy='require' name='acpi'/>
+    <feature policy='require' name='ds'/>
+  </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='file' device='disk'>
+      <driver name='qemu' type='qcow2'/>
+      <source file='/var/lib/libvirt/images/f14.img'/>
+      <target dev='vda' bus='virtio'/>
+      <alias name='virtio-disk0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+    </disk>
+    <disk type='file' device='cdrom'>
+      <driver name='qemu' type='raw'/>
+      <source file='/var/lib/libvirt/Fedora-14-x86_64-Live-KDE.iso'/>
+      <target dev='hdc' bus='ide'/>
+      <readonly/>
+      <alias name='ide0-1-0'/>
+      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
+    </disk>
+    <controller type='ide' index='0'>
+      <alias name='ide'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+    </controller>
+    <controller type='virtio-serial' index='0'>
+      <alias name='virtio-serial0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
+    </controller>
+    <controller type='usb' index='0' model='piix3-uhci'>
+      <alias name='usb'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+    </controller>
+    <controller type='pci' index='0' model='pci-root'>
+      <alias name='pci.0'/>
+    </controller>
+    <interface type='ethernet'>
+      <mac address='52:54:00:71:70:89'/>
+      <script path='/etc/qemu-ifup'/>
+      <model type='rtl8139'/>
+      <alias name='net0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
+    </interface>
+    <serial type='pty'>
+      <target type='isa-serial' port='0'>
+        <model name='isa-serial'/>
+      </target>
+      <alias name='serial0'/>
+    </serial>
+    <console type='pty'>
+      <target type='serial' port='0'/>
+      <alias name='serial0'/>
+    </console>
+    <input type='tablet' bus='usb'>
+      <alias name='input0'/>
+      <address type='usb' bus='0' port='1'/>
+    </input>
+    <input type='mouse' bus='ps2'>
+      <alias name='input1'/>
+    </input>
+    <input type='keyboard' bus='ps2'>
+      <alias name='input2'/>
+    </input>
+    <graphics type='spice' port='5900' autoport='no' passwd='secret' passwdValidTo='2013-05-31T16:11:22' connected='disconnect'>
+      <listen type='address'/>
+    </graphics>
+    <sound model='ac97'>
+      <alias name='sound0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+    </sound>
+    <audio id='1' type='spice'/>
+    <video>
+      <model type='vga' vram='16384' heads='1' primary='yes'/>
+      <alias name='video0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+    </video>
+    <memballoon model='virtio'>
+      <alias name='balloon0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
+    </memballoon>
+  </devices>
+</domain>
index 0e96033fc8de0d58f0602e862d0620f363147ba0..e6b0cc833aabfffe9c7949e8e6f3a558ffb65062 100644 (file)
@@ -1,4 +1,4 @@
-<domain type='kvm'>
+<domain type='kvm' id='7'>
   <name>f14</name>
   <uuid>553effab-b5e1-2d80-dfe3-da4344826c43</uuid>
   <memory unit='KiB'>1048576</memory>
     <apic/>
     <pae/>
   </features>
-  <cpu match='exact'>
-    <model>core2duo</model>
+  <cpu mode='custom' match='exact' check='partial'>
+    <model fallback='allow'>core2duo</model>
     <vendor>Intel</vendor>
-    <topology sockets='1' cores='2' threads='1'/>
+    <topology sockets='1' dies='1' cores='2' threads='1'/>
     <feature policy='require' name='lahf_lm'/>
     <feature policy='require' name='xtpr'/>
     <feature policy='require' name='cx16'/>
@@ -43,6 +43,7 @@
       <driver name='qemu' type='qcow2'/>
       <source file='/var/lib/libvirt/images/f14.img'/>
       <target dev='vda' bus='virtio'/>
+      <alias name='virtio-disk0'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
     </disk>
     <disk type='file' device='cdrom'>
       <source file='/var/lib/libvirt/Fedora-14-x86_64-Live-KDE.iso'/>
       <target dev='hdc' bus='ide'/>
       <readonly/>
+      <alias name='ide0-1-0'/>
       <address type='drive' controller='0' bus='1' target='0' unit='0'/>
     </disk>
     <controller type='ide' index='0'>
+      <alias name='ide'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
     </controller>
     <controller type='virtio-serial' index='0'>
+      <alias name='virtio-serial0'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
     </controller>
+    <controller type='usb' index='0' model='piix3-uhci'>
+      <alias name='usb'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+    </controller>
+    <controller type='pci' index='0' model='pci-root'>
+      <alias name='pci.0'/>
+    </controller>
     <interface type='ethernet'>
       <mac address='52:54:00:71:70:89'/>
       <script path='/etc/qemu-ifup'/>
+      <model type='rtl8139'/>
+      <alias name='net0'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
     </interface>
     <serial type='pty'>
-      <target port='0'/>
+      <target type='isa-serial' port='0'>
+        <model name='isa-serial'/>
+      </target>
+      <alias name='serial0'/>
     </serial>
     <console type='pty'>
       <target type='serial' port='0'/>
+      <alias name='serial0'/>
     </console>
-    <input type='tablet' bus='usb'/>
-    <input type='mouse' bus='ps2'/>
-    <input type='keyboard' bus='ps2'/>
-    <graphics type='spice' port='5900' autoport='no' passwd='sercet' passwdValidTo='2011-05-31T16:11:22' connected='disconnect'/>
+    <input type='tablet' bus='usb'>
+      <alias name='input0'/>
+      <address type='usb' bus='0' port='1'/>
+    </input>
+    <input type='mouse' bus='ps2'>
+      <alias name='input1'/>
+    </input>
+    <input type='keyboard' bus='ps2'>
+      <alias name='input2'/>
+    </input>
+    <graphics type='spice' port='5900' autoport='no' passwd='sercet' passwdValidTo='2011-05-31T16:11:22' connected='disconnect'>
+      <listen type='address'/>
+    </graphics>
     <sound model='ac97'>
+      <alias name='sound0'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
     </sound>
+    <audio id='1' type='spice'/>
     <video>
-      <model type='vga' vram='16384' heads='1'/>
+      <model type='vga' vram='16384' heads='1' primary='yes'/>
+      <alias name='video0'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
     </video>
     <memballoon model='virtio'>
+      <alias name='balloon0'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
     </memballoon>
   </devices>
index ec761d661922a3b373f982a6a27092ff1c24d2fd..c4924eae090322b4d45f853ef33461a524b4bb49 100644 (file)
@@ -1,4 +1,4 @@
-<domain type='qemu'>
+<domain type='qemu' id='7'>
   <name>QEMUGuest1</name>
   <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
   <memory unit='KiB'>219136</memory>
@@ -8,6 +8,9 @@
     <type arch='x86_64' machine='pc'>hvm</type>
     <boot dev='hd'/>
   </os>
+  <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>
   <devices>
     <emulator>/usr/bin/qemu-system-x86_64</emulator>
     <disk type='block' device='disk'>
+      <driver name='qemu' type='raw'/>
       <source dev='/dev/HostVG/QEMUGuest1'/>
       <target dev='hda' bus='ide'/>
+      <alias name='ide0-0-0'/>
       <address type='drive' controller='0' bus='0' target='0' unit='0'/>
     </disk>
-    <controller type='usb' index='0'/>
-    <controller type='ide' index='0'/>
-    <controller type='pci' index='0' model='pci-root'/>
-    <input type='mouse' bus='ps2'/>
-    <input type='keyboard' bus='ps2'/>
+    <controller type='usb' index='0' model='piix3-uhci'>
+      <alias name='usb'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+    </controller>
+    <controller type='ide' index='0'>
+      <alias name='ide'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+    </controller>
+    <controller type='pci' index='0' model='pci-root'>
+      <alias name='pci.0'/>
+    </controller>
+    <input type='mouse' bus='ps2'>
+      <alias name='input0'/>
+    </input>
+    <input type='keyboard' bus='ps2'>
+      <alias name='input1'/>
+    </input>
     <graphics type='spice' port='5903' tlsPort='5904' autoport='no' listen='127.0.0.1' defaultMode='secure'>
       <listen type='address' address='127.0.0.1'/>
       <channel name='main' mode='secure'/>
       <clipboard copypaste='no'/>
       <filetransfer enable='no'/>
     </graphics>
+    <audio id='1' type='spice'/>
     <video>
-      <model type='qxl' ram='65536' vram='32768' vgamem='8192' heads='1'/>
+      <model type='qxl' ram='65536' vram='32768' vgamem='8192' heads='1' primary='yes'/>
+      <alias name='video0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
     </video>
     <video>
       <model type='qxl' ram='65536' vram='32768' vgamem='8192' heads='1'/>
+      <alias name='video1'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
     </video>
-    <memballoon model='virtio'/>
+    <memballoon model='virtio'>
+      <alias name='balloon0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+    </memballoon>
   </devices>
 </domain>