]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: Add test cases for previous commit
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 3 Sep 2014 17:06:55 +0000 (19:06 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 5 Sep 2014 06:35:34 +0000 (08:35 +0200)
This commit is rather big. Firstly, the in memory config
representation is adjusted like if security_driver was set to "none".
The rest is then just adaptation to the new code that will generate
different seclabels.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
tests/qemuhotplugtestdata/qemuhotplug-hotplug-base+disk-scsi.xml
tests/qemuhotplugtestdata/qemuhotplug-hotplug-base+disk-usb.xml
tests/qemuhotplugtestdata/qemuhotplug-hotplug-base+disk-virtio.xml
tests/qemuxml2argvdata/qemuxml2argv-hotplug-base.xml
tests/qemuxml2argvdata/qemuxml2argv-seclabel-dynamic-none-relabel.xml [new file with mode: 0644]
tests/qemuxml2xmloutdata/qemuxml2xmlout-seclabel-dynamic-none-relabel.xml [new file with mode: 0644]
tests/qemuxml2xmloutdata/qemuxml2xmlout-seclabel-dynamic-relabel.xml [new file with mode: 0644]
tests/qemuxml2xmloutdata/qemuxml2xmlout-seclabel-none.xml [new file with mode: 0644]
tests/qemuxml2xmltest.c
tests/testutilsqemu.c

index a06158b8ff9f16c27e9c3a6b4ad1c4ca17e11981..ca46e5a8ea901bc05e5ad07c20b43a109f53c18d 100644 (file)
@@ -42,5 +42,5 @@
     </controller>
     <memballoon model='none'/>
   </devices>
-  <seclabel type='none'/>
+  <seclabel type='none' model='none'/>
 </domain>
index 1ea0f88313a9e71e8a23cf6f5d52a5a535bb7bd1..7904c4fc6580f8237020cee042ea369e1aadb386 100644 (file)
@@ -41,5 +41,5 @@
     </controller>
     <memballoon model='none'/>
   </devices>
-  <seclabel type='none'/>
+  <seclabel type='none' model='none'/>
 </domain>
index e96055c3552efd3f669b076e4a2621bf8f9b394c..f3d0351f2993907fef1dda4c7ea10fc09fed295f 100644 (file)
@@ -42,5 +42,5 @@
     </controller>
     <memballoon model='none'/>
   </devices>
-  <seclabel type='none'/>
+  <seclabel type='none' model='none'/>
 </domain>
index bfb0167f39e27de81b90473cae01e9ca8ff05040..f1a55009e77d6f4f0ad3ad67988788abc9f0d269 100644 (file)
@@ -34,5 +34,5 @@
     </controller>
     <memballoon model='none'/>
   </devices>
-  <seclabel type='none'/>
+  <seclabel type='none' model='none'/>
 </domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-seclabel-dynamic-none-relabel.xml b/tests/qemuxml2argvdata/qemuxml2argv-seclabel-dynamic-none-relabel.xml
new file mode 100644 (file)
index 0000000..47f253b
--- /dev/null
@@ -0,0 +1,53 @@
+<domain type='kvm'>
+  <name>migt10</name>
+  <uuid>0d73c5c3-43d0-f75b-31de-6aa919b0176b</uuid>
+  <memory unit='KiB'>262144</memory>
+  <currentMemory unit='KiB'>262144</currentMemory>
+  <memoryBacking>
+    <hugepages>
+      <page size='2048' unit='KiB' nodeset='0'/>
+    </hugepages>
+  </memoryBacking>
+  <vcpu placement='static'>4</vcpu>
+  <os>
+    <type arch='x86_64' machine='pc-i440fx-2.1'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <features>
+    <acpi/>
+  </features>
+  <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>
+    <controller type='usb' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+    </controller>
+    <controller type='virtio-serial' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+    </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>
+    <channel type='spicevmc'>
+      <target type='virtio' name='com.redhat.spice.0'/>
+      <address type='virtio-serial' controller='0' bus='0' port='1'/>
+    </channel>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <graphics type='spice' autoport='yes' listen='0.0.0.0'>
+      <listen type='address' address='0.0.0.0'/>
+    </graphics>
+    <video>
+      <model type='cirrus' vram='8192' heads='1'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+    </video>
+    <memballoon model='virtio'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
+    </memballoon>
+  </devices>
+  <seclabel type='dynamic' relabel='yes'/>
+</domain>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-seclabel-dynamic-none-relabel.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-seclabel-dynamic-none-relabel.xml
new file mode 100644 (file)
index 0000000..1b36533
--- /dev/null
@@ -0,0 +1,53 @@
+<domain type='kvm'>
+  <name>migt10</name>
+  <uuid>0d73c5c3-43d0-f75b-31de-6aa919b0176b</uuid>
+  <memory unit='KiB'>262144</memory>
+  <currentMemory unit='KiB'>262144</currentMemory>
+  <memoryBacking>
+    <hugepages>
+      <page size='2048' unit='KiB' nodeset='0'/>
+    </hugepages>
+  </memoryBacking>
+  <vcpu placement='static'>4</vcpu>
+  <os>
+    <type arch='x86_64' machine='pc-i440fx-2.1'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <features>
+    <acpi/>
+  </features>
+  <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>
+    <controller type='usb' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+    </controller>
+    <controller type='virtio-serial' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+    </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>
+    <channel type='spicevmc'>
+      <target type='virtio' name='com.redhat.spice.0'/>
+      <address type='virtio-serial' controller='0' bus='0' port='1'/>
+    </channel>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <graphics type='spice' autoport='yes' listen='0.0.0.0'>
+      <listen type='address' address='0.0.0.0'/>
+    </graphics>
+    <video>
+      <model type='cirrus' vram='8192' heads='1'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+    </video>
+    <memballoon model='virtio'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
+    </memballoon>
+  </devices>
+  <seclabel type='none' model='none'/>
+</domain>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-seclabel-dynamic-relabel.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-seclabel-dynamic-relabel.xml
new file mode 100644 (file)
index 0000000..cec59f8
--- /dev/null
@@ -0,0 +1,28 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static' cpuset='1-4,8-20,525'>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu</emulator>
+    <disk type='block' device='disk'>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda' bus='ide'/>
+      <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'/>
+    <memballoon model='virtio'/>
+  </devices>
+  <seclabel type='none' model='none'/>
+</domain>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-seclabel-none.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-seclabel-none.xml
new file mode 100644 (file)
index 0000000..cec59f8
--- /dev/null
@@ -0,0 +1,28 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static' cpuset='1-4,8-20,525'>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu</emulator>
+    <disk type='block' device='disk'>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda' bus='ide'/>
+      <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'/>
+    <memballoon model='virtio'/>
+  </devices>
+  <seclabel type='none' model='none'/>
+</domain>
index b4ab67149b92e0979848ff00cdc9a5724e1c1fbb..03c05daf747efec83b42be42262014237ce04401 100644 (file)
@@ -315,12 +315,13 @@ mymain(void)
     DO_TEST_FULL("seclabel-dynamic-baselabel", false, WHEN_INACTIVE);
     DO_TEST_FULL("seclabel-dynamic-override", false, WHEN_INACTIVE);
     DO_TEST_FULL("seclabel-dynamic-labelskip", true, WHEN_INACTIVE);
-    DO_TEST_FULL("seclabel-dynamic-relabel", false, WHEN_INACTIVE);
+    DO_TEST_FULL("seclabel-dynamic-relabel", true, WHEN_INACTIVE);
     DO_TEST("seclabel-static");
     DO_TEST_FULL("seclabel-static-labelskip", false, WHEN_ACTIVE);
-    DO_TEST("seclabel-none");
+    DO_TEST_DIFFERENT("seclabel-none");
     DO_TEST("seclabel-dac-none");
     DO_TEST("seclabel-dynamic-none");
+    DO_TEST_FULL("seclabel-dynamic-none-relabel", true, WHEN_INACTIVE);
     DO_TEST("numad-static-vcpu-no-numatune");
     DO_TEST("disk-scsi-lun-passthrough-sgio");
 
index 52abb8c47a49f65f9bcbb8d1a67ae52ad1d41c5d..7b26e50bde6241509b68961db7832daa17c0a0a1 100644 (file)
@@ -252,6 +252,16 @@ virCapsPtr testQemuCapsInit(void)
                                    false, false)) == NULL)
         return NULL;
 
+    /* Add dummy 'none' security_driver. This is equal to setting
+     * security_driver = "none" in qemu.conf. */
+    if (VIR_ALLOC_N(caps->host.secModels, 1) < 0)
+        goto cleanup;
+    caps->host.nsecModels = 1;
+
+    if (VIR_STRDUP(caps->host.secModels[0].model, "none") < 0 ||
+        VIR_STRDUP(caps->host.secModels[0].doi, "0") < 0)
+        goto cleanup;
+
     if ((caps->host.cpu = virCPUDefCopy(&host_cpu)) == NULL ||
         (machines = testQemuAllocMachines(&nmachines)) == NULL)
         goto cleanup;