1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-22 17:34:18 +03:00

examples: test: Add a new test xml with more tainted configs for testing

Signed-off-by: Luke Yue <lukedyue@gmail.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
Luke Yue 2021-07-12 19:32:17 +08:00 committed by Martin Kletzander
parent 7c399a9b0e
commit 8d90bf34f5
4 changed files with 148 additions and 9 deletions

View File

@ -0,0 +1,51 @@
<domain type='test'>
<name>fc5</name>
<uuid>08721f993d1d4aec96eb97803297bb36</uuid>
<cpu mode='custom'>
<model>Deprecated-Test</model>
<vendor>Libvirt</vendor>
<topology sockets='1' dies='1' cores='4' threads='1'/>
</cpu>
<os>
<type>hvm</type>
<loader>/usr/lib/xen/boot/hvmloader</loader>
<dtb>/root/ppc.dtb</dtb>
<boot dev='hd'/>
</os>
<memory>2097152</memory>
<vcpu>4</vcpu>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<features>
<pae/>
<acpi/>
<apic/>
</features>
<devices>
<emulator>/usr/lib/xen/bin/qemu-dm</emulator>
<interface type='bridge'>
<source bridge='xenbr0'/>
<mac address='00:16:3e:5d:c7:26'/>
<script path='vif-bridge'/>
</interface>
<disk type='file'>
<source file='/root/fv0'/>
<target dev='hda'/>
</disk>
<disk type='block' device='cdrom'>
<source dev='/dev/sr0'/>
<target dev='hdb' bus='ide'/>
<readonly/>
</disk>
<disk type='file' device='floppy'>
<source file='/root/fd.img'/>
<target dev='fda'/>
</disk>
<disk type='block' device='lun' rawio='yes'>
<source dev='/dev/disk/by-path/ip-127.0.0.1:3260-iscsi-test.target-lun-0'/>
<target dev='sda' bus='scsi'/>
</disk>
<graphics type='vnc' port='5904'/>
</devices>
</domain>

View File

@ -9,6 +9,7 @@
-->
<domain file="testdomfv0.xml"/>
<domain file="testdomfc4.xml"/>
<domain file="testdomfc5.xml"/>
<network file="testnetpriv.xml"/>
<network file="testnetdef.xml"/>
<pool file="testpool.xml">

View File

@ -75,6 +75,57 @@
<console tty="/dev/pts/5"/>
</devices>
</domain>
<domain type='test'>
<name>fc5</name>
<uuid>08721f993d1d4aec96eb97803297bb36</uuid>
<cpu mode='custom'>
<model>Deprecated-Test</model>
<vendor>Libvirt</vendor>
<topology sockets='1' dies='1' cores='4' threads='1'/>
</cpu>
<os>
<type>hvm</type>
<loader>/usr/lib/xen/boot/hvmloader</loader>
<dtb>/root/ppc.dtb</dtb>
<boot dev='hd'/>
</os>
<memory>2097152</memory>
<vcpu>4</vcpu>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<features>
<pae/>
<acpi/>
<apic/>
</features>
<devices>
<emulator>/usr/lib/xen/bin/qemu-dm</emulator>
<interface type='bridge'>
<source bridge='xenbr0'/>
<mac address='00:16:3e:5d:c7:26'/>
<script path='vif-bridge'/>
</interface>
<disk type='file'>
<source file='/root/fv0'/>
<target dev='hda'/>
</disk>
<disk type='block' device='cdrom'>
<source dev='/dev/sr0'/>
<target dev='hdb' bus='ide'/>
<readonly/>
</disk>
<disk type='file' device='floppy'>
<source file='/root/fd.img'/>
<target dev='fda'/>
</disk>
<disk type='block' device='lun' rawio='yes'>
<source dev='/dev/disk/by-path/ip-127.0.0.1:3260-iscsi-test.target-lun-0'/>
<target dev='sda' bus='scsi'/>
</disk>
<graphics type='vnc' port='5904'/>
</devices>
</domain>
<network>
<name>private</name>
<uuid>004b22212d78c30f5aa5f03c87d21e69</uuid>

View File

@ -20,14 +20,21 @@ main(void)
#else
# define DOM_UUID "ef861801-45b9-11cb-88e3-afbfe5370493"
# define DOM_FC4_UUID "ef861801-45b9-11cb-88e3-afbfe5370493"
# define DOM_FC5_UUID "08721f99-3d1d-4aec-96eb-97803297bb36"
# define SECURITY_LABEL "libvirt-test (enforcing)"
# define MESSAGES "tainted: network configuration using opaque shell scripts"
# define FC4_MESSAGES "tainted: network configuration using opaque shell scripts"
# define FC5_MESSAGES "tainted: running with undesirable elevated privileges\n\
tainted: network configuration using opaque shell scripts\n\
tainted: use of host cdrom passthrough\n\
tainted: custom device tree blob used\n\
tainted: use of deprecated configuration settings\n\
deprecated configuration: CPU model Deprecated-Test"
static const char *dominfo_fc4 = "\
Id: 2\n\
Name: fc4\n\
UUID: " DOM_UUID "\n\
UUID: " DOM_FC4_UUID "\n\
OS Type: linux\n\
State: running\n\
CPU(s): 1\n\
@ -39,12 +46,29 @@ Managed save: no\n\
Security model: testSecurity\n\
Security DOI: \n\
Security label: " SECURITY_LABEL "\n\
Messages: " MESSAGES "\n\
Messages: " FC4_MESSAGES "\n\
\n";
static const char *domuuid_fc4 = DOM_UUID "\n\n";
static const char *domuuid_fc4 = DOM_FC4_UUID "\n\n";
static const char *domid_fc4 = "2\n\n";
static const char *domname_fc4 = "fc4\n\n";
static const char *domstate_fc4 = "running\n\n";
static const char *dominfo_fc5 = "\
Id: 3\n\
Name: fc5\n\
UUID: " DOM_FC5_UUID "\n\
OS Type: linux\n\
State: running\n\
CPU(s): 4\n\
Max memory: 2097152 KiB\n\
Used memory: 2097152 KiB\n\
Persistent: yes\n\
Autostart: disable\n\
Managed save: no\n\
Security model: testSecurity\n\
Security DOI: \n\
Security label: " SECURITY_LABEL "\n\
Messages: " FC5_MESSAGES "\n\
\n";
static int testFilterLine(char *buffer,
const char *toRemove)
@ -128,6 +152,7 @@ static int testCompareListCustom(const void *data G_GNUC_UNUSED)
----------------------\n\
1 fv0 running\n\
2 fc4 running\n\
3 fc5 running\n\
\n";
return testCompareOutputLit(exp, NULL, argv);
}
@ -177,7 +202,7 @@ static int testCompareDominfoByID(const void *data G_GNUC_UNUSED)
static int testCompareDominfoByUUID(const void *data G_GNUC_UNUSED)
{
const char *const argv[] = { VIRSH_CUSTOM, "dominfo", DOM_UUID, NULL };
const char *const argv[] = { VIRSH_CUSTOM, "dominfo", DOM_FC4_UUID, NULL };
const char *exp = dominfo_fc4;
return testCompareOutputLit(exp, "\nCPU time:", argv);
}
@ -189,6 +214,13 @@ static int testCompareDominfoByName(const void *data G_GNUC_UNUSED)
return testCompareOutputLit(exp, "\nCPU time:", argv);
}
static int testCompareTaintedDominfoByName(const void *data G_GNUC_UNUSED)
{
const char *const argv[] = { VIRSH_CUSTOM, "dominfo", "fc5", NULL };
const char *exp = dominfo_fc5;
return testCompareOutputLit(exp, "\nCPU time:", argv);
}
static int testCompareDomuuidByID(const void *data G_GNUC_UNUSED)
{
const char *const argv[] = { VIRSH_CUSTOM, "domuuid", "2", NULL };
@ -212,7 +244,7 @@ static int testCompareDomidByName(const void *data G_GNUC_UNUSED)
static int testCompareDomidByUUID(const void *data G_GNUC_UNUSED)
{
const char *const argv[] = { VIRSH_CUSTOM, "domid", DOM_UUID, NULL };
const char *const argv[] = { VIRSH_CUSTOM, "domid", DOM_FC4_UUID, NULL };
const char *exp = domid_fc4;
return testCompareOutputLit(exp, NULL, argv);
}
@ -226,7 +258,7 @@ static int testCompareDomnameByID(const void *data G_GNUC_UNUSED)
static int testCompareDomnameByUUID(const void *data G_GNUC_UNUSED)
{
const char *const argv[] = { VIRSH_CUSTOM, "domname", DOM_UUID, NULL };
const char *const argv[] = { VIRSH_CUSTOM, "domname", DOM_FC4_UUID, NULL };
const char *exp = domname_fc4;
return testCompareOutputLit(exp, NULL, argv);
}
@ -240,7 +272,7 @@ static int testCompareDomstateByID(const void *data G_GNUC_UNUSED)
static int testCompareDomstateByUUID(const void *data G_GNUC_UNUSED)
{
const char *const argv[] = { VIRSH_CUSTOM, "domstate", DOM_UUID, NULL };
const char *const argv[] = { VIRSH_CUSTOM, "domstate", DOM_FC4_UUID, NULL };
const char *exp = domstate_fc4;
return testCompareOutputLit(exp, NULL, argv);
}
@ -307,6 +339,10 @@ mymain(void)
testCompareDominfoByName, NULL) != 0)
ret = -1;
if (virTestRun("virsh dominfo (by name, more tainted messages)",
testCompareTaintedDominfoByName, NULL) != 0)
ret = -1;
if (virTestRun("virsh domid (by name)",
testCompareDomidByName, NULL) != 0)
ret = -1;