Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 75 additions & 9 deletions tests/common.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ let
hugepages ? false,
prefault ? false,
serial ? "pty",
# Whether all device will be assigned a static BDF through the XML or only some
all_static_bdf ? false,
# Whether we add a function ID to specific BDFs or not
use_bdf_function ? false,
}:
''
<domain type='kvm' id='21050'>
Expand Down Expand Up @@ -115,15 +119,43 @@ let
<on_crash>destroy</on_crash>
<devices>
<emulator>cloud-hypervisor</emulator>
${
# Add the implicitly created RNG device explicitly
if all_static_bdf then
''
<rng model='virtio'>
<backend model='random'>/dev/urandom</backend>
<alias name='explicit-rng-device'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</rng>
''
else
""
}
<disk type='file' device='disk'>
<source file='${image}'/>
<target dev='vda' bus='virtio'/>
${
# Assign a fixed BDF that would normally be acquired by the implicit RNG device
if all_static_bdf then
if use_bdf_function then
''
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
''
else
''
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
''
else
""
}
</disk>
<interface type='ethernet'>
<mac address='52:54:00:e5:b8:01'/>
<target dev='vnet0'/>
<model type='virtio'/>
<driver queues='1'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</interface>
${
if serial == "pty" then
Expand Down Expand Up @@ -157,14 +189,26 @@ let
'';

# Please keep in sync with documentation in networks.md!
new_interface = ''
<interface type='ethernet'>
<mac address='52:54:00:e5:b8:02'/>
<target dev='vnet1'/>
<model type='virtio'/>
<driver queues='1'/>
</interface>
'';
new_interface =
{
explicit_bdf ? false,
}:
''
<interface type='ethernet'>
<mac address='52:54:00:e5:b8:02'/>
<target dev='vnet1'/>
<model type='virtio'/>
<driver queues='1'/>
${
if explicit_bdf then
''
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
''
else
""
}
</interface>
'';

# Please keep in sync with documentation in networks.md!
new_interface_type_network = ''
Expand Down Expand Up @@ -526,9 +570,31 @@ in
})}";
};
};
"/etc/domain-chv-static-bdf.xml" = {
"C+" = {
argument = "${pkgs.writeText "domain-chv-static-bdf.xml" (virsh_ch_xml {
all_static_bdf = true;
})}";
};
};
"/etc/domain-chv-static-bdf-with-function.xml" = {
"C+" = {
argument = "${pkgs.writeText "domain-chv-static-bdf-with-function.xml" (virsh_ch_xml {
all_static_bdf = true;
use_bdf_function = true;
})}";
};
};
"/etc/new_interface.xml" = {
"C+" = {
argument = "${pkgs.writeText "new_interface.xml" new_interface}";
argument = "${pkgs.writeText "new_interface.xml" (new_interface { })}";
};
};
"/etc/new_interface_explicit_bdf.xml" = {
"C+" = {
argument = "${pkgs.writeText "new_interface_explicit_bdf.xml" (new_interface {
explicit_bdf = true;
})}";
};
};
"/etc/new_interface_type_network.xml" = {
Expand Down
Loading