Can change network interface type
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@ -29,6 +29,12 @@ pub enum VMArchitecture {
|
||||
X86_64,
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
pub enum NetworkInterfaceModelType {
|
||||
Virtio,
|
||||
E1000,
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
pub struct NWFilterParam {
|
||||
name: String,
|
||||
@ -46,6 +52,7 @@ pub struct Network {
|
||||
#[serde(flatten)]
|
||||
r#type: NetworkType,
|
||||
mac: String,
|
||||
model: NetworkInterfaceModelType,
|
||||
nwfilterref: Option<NWFilterRef>,
|
||||
}
|
||||
|
||||
@ -196,7 +203,11 @@ impl VMInfo {
|
||||
};
|
||||
|
||||
let model = Some(NetIntModelXML {
|
||||
r#type: "virtio".to_string(),
|
||||
r#type: match n.model {
|
||||
NetworkInterfaceModelType::Virtio => "virtio",
|
||||
NetworkInterfaceModelType::E1000 => "e1000",
|
||||
}
|
||||
.to_string(),
|
||||
});
|
||||
|
||||
let filterref = if let Some(n) = &n.nwfilterref {
|
||||
@ -518,6 +529,18 @@ impl VMInfo {
|
||||
)));
|
||||
}
|
||||
},
|
||||
model: match d.model.as_ref() {
|
||||
None => NetworkInterfaceModelType::Virtio,
|
||||
Some(model) => match model.r#type.as_str() {
|
||||
"virtio" => NetworkInterfaceModelType::Virtio,
|
||||
"e1000" => NetworkInterfaceModelType::E1000,
|
||||
model => {
|
||||
return Err(LibVirtStructError::DomainExtraction(format!(
|
||||
"Unknown network interface model type: {model}! "
|
||||
)));
|
||||
}
|
||||
},
|
||||
},
|
||||
nwfilterref: d.filterref.as_ref().map(|f| NWFilterRef {
|
||||
name: f.filter.to_string(),
|
||||
parameters: f
|
||||
|
@ -60,6 +60,7 @@ export type VMNetInterface = (
|
||||
|
||||
export interface VMNetInterfaceBase {
|
||||
mac: string;
|
||||
model: "Virtio" | "E1000";
|
||||
nwfilterref?: VMNetInterfaceFilter;
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,7 @@ export function VMNetworksList(p: {
|
||||
const addNew = () => {
|
||||
p.vm.networks.push({
|
||||
type: "UserspaceSLIRPStack",
|
||||
model: "Virtio",
|
||||
mac: randomMacAddress(ServerApi.Config.net_mac_prefix),
|
||||
});
|
||||
p.onChange?.();
|
||||
@ -146,6 +147,7 @@ function NetworkInfoWidget(p: {
|
||||
/>
|
||||
</ListItem>
|
||||
<div style={{ marginLeft: "70px" }}>
|
||||
{/* MAC address input */}
|
||||
<MACInput
|
||||
editable={p.editable}
|
||||
label="MAC Address"
|
||||
@ -156,6 +158,26 @@ function NetworkInfoWidget(p: {
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* NIC model */}
|
||||
<SelectInput
|
||||
editable={p.editable}
|
||||
label="NIC Model"
|
||||
value={p.network.model}
|
||||
onValueChange={(v) => {
|
||||
p.network.model = v as any;
|
||||
p.onChange?.();
|
||||
}}
|
||||
options={[
|
||||
{ label: "e1000", value: "E1000" },
|
||||
{
|
||||
label: "virtio",
|
||||
value: "Virtio",
|
||||
description:
|
||||
"Recommended model, but will require specific drivers on OS that do not support it.",
|
||||
},
|
||||
]}
|
||||
/>
|
||||
|
||||
{/* Defined network selection */}
|
||||
{p.network.type === "DefinedNetwork" && (
|
||||
<SelectInput
|
||||
|
Reference in New Issue
Block a user