11 Commits

Author SHA1 Message Date
115728d9c9 Update Rust crate reqwest to 0.12.19
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2025-06-10 00:26:02 +00:00
0de15af10e Normalize disk size input
All checks were successful
continuous-integration/drone/push Build is passing
2025-06-09 18:11:49 +02:00
d4bc92f562 Do not offer to expand disk if disk deletion is request by user
Some checks failed
continuous-integration/drone/push Build is failing
2025-06-09 18:09:55 +02:00
a1439689dd Can resize existing disks
Some checks failed
continuous-integration/drone/push Build is failing
2025-06-09 18:00:23 +02:00
63126c75fa Prevent shrinking attempts
All checks were successful
continuous-integration/drone/push Build is passing
2025-06-09 17:48:17 +02:00
940302a825 Can resize disk image when adding a new disk image to a VM
All checks were successful
continuous-integration/drone/push Build is passing
2025-06-09 17:42:36 +02:00
9c374f849b Shwo a message when some lists are empty
All checks were successful
continuous-integration/drone/push Build is passing
2025-06-09 17:17:54 +02:00
2fa4d0e11b Can compress XZ files
All checks were successful
continuous-integration/drone/push Build is passing
2025-06-09 17:05:47 +02:00
d7796e1459 Can decompress XZ files 2025-06-09 17:04:35 +02:00
759361d9f6 Add qcow2.xz file format support 2025-06-09 16:58:21 +02:00
b2529c250a Minor improvements
All checks were successful
continuous-integration/drone/push Build is passing
2025-06-09 16:43:27 +02:00
13 changed files with 375 additions and 115 deletions

View File

@ -1622,18 +1622,23 @@ version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf9f1e950e0d9d1d3c47184416723cf29c0d1f93bd8cccf37e4beb6b44f31710"
dependencies = [
"base64 0.22.1",
"bytes",
"futures-channel",
"futures-util",
"http 1.3.1",
"http-body",
"hyper",
"ipnet",
"libc",
"percent-encoding",
"pin-project-lite",
"socket2",
"system-configuration",
"tokio",
"tower-service",
"tracing",
"windows-registry",
]
[[package]]
@ -1839,6 +1844,16 @@ dependencies = [
"serde",
]
[[package]]
name = "iri-string"
version = "0.7.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dbc5ebe9c3a1a7a5127f920a418f7585e9e758e911d0466ed004f393b0e380b2"
dependencies = [
"memchr",
"serde",
]
[[package]]
name = "is_terminal_polyfill"
version = "1.70.1"
@ -2773,9 +2788,9 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
[[package]]
name = "reqwest"
version = "0.12.15"
version = "0.12.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d19c46a6fdd48bc4dab94b6103fccc55d34c67cc0ad04653aad4ea2a07cd7bbb"
checksum = "a2f8e5513d63f2e5b386eb5106dc67eaf3f84e95258e210489136b8b92ad6119"
dependencies = [
"base64 0.22.1",
"bytes",
@ -2798,23 +2813,22 @@ dependencies = [
"once_cell",
"percent-encoding",
"pin-project-lite",
"rustls-pemfile",
"rustls-pki-types",
"serde",
"serde_json",
"serde_urlencoded",
"sync_wrapper",
"system-configuration",
"tokio",
"tokio-native-tls",
"tokio-util",
"tower",
"tower-http",
"tower-service",
"url",
"wasm-bindgen",
"wasm-bindgen-futures",
"wasm-streams",
"web-sys",
"windows-registry",
]
[[package]]
@ -2923,15 +2937,6 @@ dependencies = [
"zeroize",
]
[[package]]
name = "rustls-pemfile"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50"
dependencies = [
"rustls-pki-types",
]
[[package]]
name = "rustls-pki-types"
version = "1.12.0"
@ -3522,6 +3527,24 @@ dependencies = [
"tower-service",
]
[[package]]
name = "tower-http"
version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "adc82fd73de2a9722ac5da747f12383d2bfdb93591ee6c58486e0097890f05f2"
dependencies = [
"bitflags 2.9.1",
"bytes",
"futures-util",
"http 1.3.1",
"http-body",
"iri-string",
"pin-project-lite",
"tower",
"tower-layer",
"tower-service",
]
[[package]]
name = "tower-layer"
version = "0.3.3"

View File

@ -27,7 +27,7 @@ futures-util = "0.3.31"
anyhow = "1.0.98"
actix-multipart = "0.7.2"
tempfile = "3.20.0"
reqwest = { version = "0.12.15", features = ["stream"] }
reqwest = { version = "0.12.19", features = ["stream"] }
url = "2.5.4"
virt = "0.4.2"
sysinfo = { version = "0.35.1", features = ["serde"] }

View File

@ -137,6 +137,9 @@ pub const PROGRAM_COPY: &str = "/bin/cp";
/// Gzip program path
pub const PROGRAM_GZIP: &str = "/usr/bin/gzip";
/// XZ program path
pub const PROGRAM_XZ: &str = "/usr/bin/xz";
/// Bash program
pub const PROGRAM_BASH: &str = "/usr/bin/bash";

View File

@ -28,8 +28,10 @@ pub enum DiskFileFormat {
#[serde(default)]
virtual_size: FileSize,
},
CompressedRaw,
CompressedQCow2,
GzCompressedRaw,
GzCompressedQCow2,
XzCompressedRaw,
XzCompressedQCow2,
}
impl DiskFileFormat {
@ -37,8 +39,10 @@ impl DiskFileFormat {
match self {
DiskFileFormat::Raw { .. } => &["raw", ""],
DiskFileFormat::QCow2 { .. } => &["qcow2"],
DiskFileFormat::CompressedRaw => &["raw.gz"],
DiskFileFormat::CompressedQCow2 => &["qcow2.gz"],
DiskFileFormat::GzCompressedRaw => &["raw.gz"],
DiskFileFormat::GzCompressedQCow2 => &["qcow2.gz"],
DiskFileFormat::XzCompressedRaw => &["raw.xz"],
DiskFileFormat::XzCompressedQCow2 => &["qcow2.xz"],
}
}
}
@ -81,9 +85,14 @@ impl DiskFileInfo {
},
"gz" if name.ends_with(".qcow2") => {
name = name.strip_suffix(".qcow2").unwrap_or(&name).to_string();
DiskFileFormat::CompressedQCow2
DiskFileFormat::GzCompressedQCow2
}
"gz" => DiskFileFormat::CompressedRaw,
"gz" => DiskFileFormat::GzCompressedRaw,
"xz" if name.ends_with(".qcow2") => {
name = name.strip_suffix(".qcow2").unwrap_or(&name).to_string();
DiskFileFormat::XzCompressedQCow2
}
"xz" => DiskFileFormat::XzCompressedRaw,
_ => anyhow::bail!("Unsupported disk extension: {ext}!"),
};
@ -159,8 +168,8 @@ impl DiskFileInfo {
// Prepare the conversion
let mut cmd = match (self.format, dest_format) {
// Decompress QCow2
(DiskFileFormat::CompressedQCow2, DiskFileFormat::QCow2 { .. }) => {
// Decompress QCow2 (GZIP)
(DiskFileFormat::GzCompressedQCow2, DiskFileFormat::QCow2 { .. }) => {
let mut cmd = Command::new(constants::PROGRAM_GZIP);
cmd.arg("--keep")
.arg("--decompress")
@ -170,8 +179,19 @@ impl DiskFileInfo {
cmd
}
// Compress QCow2
(DiskFileFormat::QCow2 { .. }, DiskFileFormat::CompressedQCow2) => {
// Decompress QCow2 (XZ)
(DiskFileFormat::XzCompressedQCow2, DiskFileFormat::QCow2 { .. }) => {
let mut cmd = Command::new(constants::PROGRAM_XZ);
cmd.arg("--stdout")
.arg("--keep")
.arg("--decompress")
.arg(&self.file_path)
.stdout(File::create(&temp_file)?);
cmd
}
// Compress QCow2 (Gzip)
(DiskFileFormat::QCow2 { .. }, DiskFileFormat::GzCompressedQCow2) => {
let mut cmd = Command::new(constants::PROGRAM_GZIP);
cmd.arg("--keep")
.arg("--to-stdout")
@ -180,6 +200,16 @@ impl DiskFileInfo {
cmd
}
// Compress QCow2 (Xz)
(DiskFileFormat::QCow2 { .. }, DiskFileFormat::XzCompressedQCow2) => {
let mut cmd = Command::new(constants::PROGRAM_XZ);
cmd.arg("--keep")
.arg("--to-stdout")
.arg(&self.file_path)
.stdout(File::create(&temp_file)?);
cmd
}
// Convert QCow2 to Raw file
(DiskFileFormat::QCow2 { .. }, DiskFileFormat::Raw { is_sparse }) => {
let mut cmd = Command::new(constants::PROGRAM_QEMU_IMAGE);
@ -244,8 +274,8 @@ impl DiskFileInfo {
cmd
}
// Compress Raw
(DiskFileFormat::Raw { .. }, DiskFileFormat::CompressedRaw) => {
// Compress Raw (Gz)
(DiskFileFormat::Raw { .. }, DiskFileFormat::GzCompressedRaw) => {
let mut cmd = Command::new(constants::PROGRAM_GZIP);
cmd.arg("--keep")
.arg("--to-stdout")
@ -254,8 +284,18 @@ impl DiskFileInfo {
cmd
}
// Decompress Raw to not sparse file
(DiskFileFormat::CompressedRaw, DiskFileFormat::Raw { is_sparse: false }) => {
// Compress Raw (Xz)
(DiskFileFormat::Raw { .. }, DiskFileFormat::XzCompressedRaw) => {
let mut cmd = Command::new(constants::PROGRAM_XZ);
cmd.arg("--keep")
.arg("--to-stdout")
.arg(&self.file_path)
.stdout(File::create(&temp_file)?);
cmd
}
// Decompress Raw (Gz) to not sparse file
(DiskFileFormat::GzCompressedRaw, DiskFileFormat::Raw { is_sparse: false }) => {
let mut cmd = Command::new(constants::PROGRAM_GZIP);
cmd.arg("--keep")
.arg("--decompress")
@ -264,13 +304,23 @@ impl DiskFileInfo {
.stdout(File::create(&temp_file)?);
cmd
}
// Decompress Raw (Xz) to not sparse file
(DiskFileFormat::XzCompressedRaw, DiskFileFormat::Raw { is_sparse: false }) => {
let mut cmd = Command::new(constants::PROGRAM_XZ);
cmd.arg("--keep")
.arg("--decompress")
.arg("--to-stdout")
.arg(&self.file_path)
.stdout(File::create(&temp_file)?);
cmd
}
// Decompress Raw to sparse file
// Decompress Raw (Gz) to sparse file
// https://benou.fr/www/ben/decompressing-sparse-files.html
(DiskFileFormat::CompressedRaw, DiskFileFormat::Raw { is_sparse: true }) => {
(DiskFileFormat::GzCompressedRaw, DiskFileFormat::Raw { is_sparse: true }) => {
let mut cmd = Command::new(constants::PROGRAM_BASH);
cmd.arg("-c").arg(format!(
"{} -d -c {} | {} conv=sparse of={}",
"{} --decompress --to-stdout {} | {} conv=sparse of={}",
constants::PROGRAM_GZIP,
self.file_path.display(),
constants::PROGRAM_DD,
@ -279,6 +329,20 @@ impl DiskFileInfo {
cmd
}
// Decompress Raw (XZ) to sparse file
// https://benou.fr/www/ben/decompressing-sparse-files.html
(DiskFileFormat::XzCompressedRaw, DiskFileFormat::Raw { is_sparse: true }) => {
let mut cmd = Command::new(constants::PROGRAM_BASH);
cmd.arg("-c").arg(format!(
"{} --decompress --to-stdout {} | {} conv=sparse of={}",
constants::PROGRAM_XZ,
self.file_path.display(),
constants::PROGRAM_DD,
temp_file.display()
));
cmd
}
// Dumb copy of file
(a, b) if a == b => {
let mut cmd = Command::new(constants::PROGRAM_COPY);
@ -330,6 +394,44 @@ impl DiskFileInfo {
Ok(())
}
/// Get disk virtual size, if available
pub fn virtual_size(&self) -> Option<FileSize> {
match self.format {
DiskFileFormat::Raw { .. } => Some(self.file_size),
DiskFileFormat::QCow2 { virtual_size } => Some(virtual_size),
_ => None,
}
}
/// Resize disk
pub fn resize(&self, new_size: FileSize) -> anyhow::Result<()> {
if new_size <= self.virtual_size().unwrap_or(new_size) {
anyhow::bail!("Shrinking disk image file is not supported!");
}
let mut cmd = Command::new(constants::PROGRAM_QEMU_IMAGE);
cmd.arg("resize")
.arg("-f")
.arg(match self.format {
DiskFileFormat::QCow2 { .. } => "qcow2",
DiskFileFormat::Raw { .. } => "raw",
f => anyhow::bail!("Unsupported disk format for resize: {f:?}"),
})
.arg(&self.file_path)
.arg(new_size.as_bytes().to_string());
let output = cmd.output()?;
if !output.status.success() {
anyhow::bail!(
"{} info failed, status: {}, stderr: {}",
constants::PROGRAM_QEMU_IMAGE,
output.status,
String::from_utf8_lossy(&output.stderr)
);
}
Ok(())
}
}
#[derive(serde::Deserialize)]

View File

@ -44,6 +44,9 @@ pub struct VMFileDisk {
/// When creating a new disk, specify the disk image template to use
#[serde(skip_serializing_if = "Option::is_none")]
pub from_image: Option<String>,
/// Set this variable to true to resize disk image
#[serde(skip_serializing_if = "Option::is_none")]
pub resize: Option<bool>,
/// Set this variable to true to delete the disk
pub delete: bool,
}
@ -78,6 +81,7 @@ impl VMFileDisk {
delete: false,
from_image: None,
resize: None,
})
}
@ -144,28 +148,40 @@ impl VMFileDisk {
if file.exists() {
log::debug!("File {file:?} does not exists, so it was not touched");
return Ok(());
}
// Create disk if required
else {
// Determine file format
let format = match self.format {
VMDiskFormat::Raw { is_sparse } => DiskFileFormat::Raw { is_sparse },
VMDiskFormat::QCow2 => DiskFileFormat::QCow2 {
virtual_size: self.size,
},
};
// Create / Restore disk file
match &self.from_image {
// Create disk file
None => {
DiskFileInfo::create(&file, format, self.size)?;
}
// Restore disk image template
Some(disk_img) => {
let src_file =
DiskFileInfo::load_file(&AppConfig::get().disk_images_file_path(disk_img))?;
src_file.convert(&file, format)?;
}
}
}
let format = match self.format {
VMDiskFormat::Raw { is_sparse } => DiskFileFormat::Raw { is_sparse },
VMDiskFormat::QCow2 => DiskFileFormat::QCow2 {
virtual_size: self.size,
},
};
// Resize disk file if requested
if self.resize == Some(true) {
let disk = DiskFileInfo::load_file(&file)?;
// Create / Restore disk file
match &self.from_image {
// Create disk file
None => {
DiskFileInfo::create(&file, format, self.size)?;
}
// Restore disk image template
Some(disk_img) => {
let src_file =
DiskFileInfo::load_file(&AppConfig::get().disk_images_file_path(disk_img))?;
src_file.convert(&file, format)?;
// Can only increase disk size
if let Err(e) = disk.resize(self.size) {
log::error!("Failed to resize disk file {}: {e:?}", self.name);
}
}

View File

@ -4,8 +4,10 @@ import { VMFileDisk, VMInfo } from "./VMApi";
export type DiskImageFormat =
| { format: "Raw"; is_sparse: boolean }
| { format: "QCow2"; virtual_size?: number }
| { format: "CompressedQCow2" }
| { format: "CompressedRaw" };
| { format: "GzCompressedQCow2" }
| { format: "GzCompressedRaw" }
| { format: "XzCompressedQCow2" }
| { format: "XzCompressedRaw" };
export type DiskImage = {
file_size: number;

View File

@ -31,8 +31,12 @@ export interface BaseFileVMDisk {
// For new disk only
from_image?: string;
// Resize disk image after clone
resize?: boolean;
// application attributes
new?: boolean;
originalSize?: number;
deleteType?: "keepfile" | "deletefile";
}

View File

@ -42,13 +42,15 @@ export function ConvertDiskImageDialog(
setFormat({ format: value ?? ("QCow2" as any) });
if (value === "QCow2") setFilename(`${origFilename}.qcow2`);
if (value === "CompressedQCow2") setFilename(`${origFilename}.qcow2.gz`);
if (value === "GzCompressedQCow2") setFilename(`${origFilename}.qcow2.gz`);
if (value === "XzCompressedQCow2") setFilename(`${origFilename}.qcow2.xz`);
if (value === "Raw") {
setFilename(`${origFilename}.raw`);
// Check sparse checkbox by default
setFormat({ format: "Raw", is_sparse: true });
}
if (value === "CompressedRaw") setFilename(`${origFilename}.raw.gz`);
if (value === "GzCompressedRaw") setFilename(`${origFilename}.raw.gz`);
if (value === "XzCompressedRaw") setFilename(`${origFilename}.raw.xz`);
};
const handleSubmit = async () => {
@ -104,8 +106,10 @@ export function ConvertDiskImageDialog(
options={[
{ value: "QCow2" },
{ value: "Raw" },
{ value: "CompressedRaw" },
{ value: "CompressedQCow2" },
{ value: "GzCompressedRaw" },
{ value: "XzCompressedRaw" },
{ value: "GzCompressedQCow2" },
{ value: "XzCompressedQCow2" },
]}
/>

View File

@ -1,5 +1,5 @@
import VisibilityIcon from '@mui/icons-material/Visibility';
import VisibilityOffIcon from '@mui/icons-material/VisibilityOff';
import VisibilityIcon from "@mui/icons-material/Visibility";
import VisibilityOffIcon from "@mui/icons-material/VisibilityOff";
import {
Alert,
CircularProgress,
@ -36,7 +36,9 @@ export function LoginRoute(): React.ReactElement {
const canSubmit = username.length > 0 && password.length > 0;
const [showPassword, setShowPassword] = React.useState(false);
const handleClickShowPassword = () => { setShowPassword((show) => !show); };
const handleClickShowPassword = () => {
setShowPassword((show) => !show);
};
const handleMouseDownPassword = (
event: React.MouseEvent<HTMLButtonElement>
@ -105,12 +107,14 @@ export function LoginRoute(): React.ReactElement {
label="Username"
name="username"
value={username}
onChange={(e) => { setUsername(e.target.value); }}
onChange={(e) => {
setUsername(e.target.value);
}}
autoComplete="username"
autoFocus
/>
<FormControl fullWidth variant="outlined">
<FormControl required fullWidth variant="outlined">
<InputLabel htmlFor="password">Password</InputLabel>
<OutlinedInput
required
@ -120,7 +124,9 @@ export function LoginRoute(): React.ReactElement {
type={showPassword ? "text" : "password"}
id="password"
value={password}
onChange={(e) => { setPassword(e.target.value); }}
onChange={(e) => {
setPassword(e.target.value);
}}
autoComplete="current-password"
endAdornment={
<InputAdornment position="end">
@ -131,7 +137,11 @@ export function LoginRoute(): React.ReactElement {
onMouseDown={handleMouseDownPassword}
edge="end"
>
{showPassword ? <VisibilityOffIcon /> : <VisibilityIcon />}
{showPassword ? (
<VisibilityOffIcon />
) : (
<VisibilityIcon />
)}
</IconButton>
</Tooltip>
</InputAdornment>

View File

@ -0,0 +1,25 @@
import { ServerApi } from "../../api/ServerApi";
import { TextInput } from "./TextInput";
export function DiskSizeInput(p: {
editable: boolean;
label?: string;
value: number;
onChange?: (size: number) => void;
}): React.ReactElement {
return (
<TextInput
editable={p.editable}
label={p.label ?? "Disk size (GB)"}
size={{
min: ServerApi.Config.constraints.disk_size.min / (1000 * 1000 * 1000),
max: ServerApi.Config.constraints.disk_size.max / (1000 * 1000 * 1000),
}}
value={(p.value / (1000 * 1000 * 1000)).toString()}
onValueChange={(v) => {
p.onChange?.(Number(v ?? "0") * 1000 * 1000 * 1000);
}}
type="number"
/>
);
}

View File

@ -25,6 +25,8 @@ export function OEMStringFormWidget(p: {
p.onChange?.();
};
if (!p.editable && p.vm.oem_strings.length === 0) return <></>;
return (
<EditSection
title="SMBIOS OEM Strings"

View File

@ -2,7 +2,8 @@ import { mdiHarddiskPlus } from "@mdi/js";
import Icon from "@mdi/react";
import CheckCircleIcon from "@mui/icons-material/CheckCircle";
import DeleteIcon from "@mui/icons-material/Delete";
import { Button, IconButton, Paper, Tooltip } from "@mui/material";
import ExpandIcon from "@mui/icons-material/Expand";
import { Button, IconButton, Paper, Tooltip, Typography } from "@mui/material";
import React from "react";
import { DiskImage } from "../../api/DiskImageApi";
import { ServerApi } from "../../api/ServerApi";
@ -13,6 +14,7 @@ import { VMDiskFileWidget } from "../vms/VMDiskFileWidget";
import { CheckboxInput } from "./CheckboxInput";
import { DiskBusSelect } from "./DiskBusSelect";
import { DiskImageSelect } from "./DiskImageSelect";
import { DiskSizeInput } from "./DiskSizeInput";
import { SelectInput } from "./SelectInput";
import { TextInput } from "./TextInput";
@ -67,6 +69,12 @@ export function VMDisksList(p: {
/>
))}
{p.vm.file_disks.length === 0 && (
<Typography style={{ textAlign: "center", paddingTop: "25px" }}>
No disk file yet!
</Typography>
)}
{p.editable && <Button onClick={addNewDisk}>Add new disk</Button>}
{/* Disk backup */}
@ -93,6 +101,19 @@ function DiskInfo(p: {
diskImagesList: DiskImage[];
}): React.ReactElement {
const confirm = useConfirm();
const expandDisk = () => {
if (p.disk.resize === true) {
p.disk.resize = false;
p.disk.size = p.disk.originalSize!;
} else {
p.disk.resize = true;
p.disk.originalSize = p.disk.size!;
}
p.onChange?.();
};
const deleteDisk = async () => {
if (p.disk.deleteType) {
p.disk.deleteType = undefined;
@ -115,42 +136,75 @@ function DiskInfo(p: {
if (!p.editable || !p.disk.new)
return (
<VMDiskFileWidget
{...p}
secondaryAction={
<>
{p.editable && (
<IconButton
edge="end"
aria-label="delete disk"
onClick={deleteDisk}
>
{p.disk.deleteType ? (
<Tooltip title="Cancel disk removal">
<CheckCircleIcon />
</Tooltip>
) : (
<Tooltip title="Remove disk">
<DeleteIcon />
</Tooltip>
)}
</IconButton>
)}
{p.canBackup && (
<Tooltip title="Backup this disk">
<>
<VMDiskFileWidget
{...p}
secondaryAction={
<>
{p.editable && !p.disk.deleteType && (
<IconButton
onClick={() => {
p.onRequestBackup(p.disk);
}}
edge="end"
aria-label="expand disk"
onClick={expandDisk}
>
<Icon path={mdiHarddiskPlus} size={1} />
{p.disk.resize === true ? (
<Tooltip title="Cancel disk expansion">
<ExpandIcon color="error" />
</Tooltip>
) : (
<Tooltip title="Increase disk size">
<ExpandIcon />
</Tooltip>
)}
</IconButton>
</Tooltip>
)}
</>
}
/>
)}
{p.editable && (
<IconButton
edge="end"
aria-label="delete disk"
onClick={deleteDisk}
>
{p.disk.deleteType ? (
<Tooltip title="Cancel disk removal">
<CheckCircleIcon />
</Tooltip>
) : (
<Tooltip title="Remove disk">
<DeleteIcon />
</Tooltip>
)}
</IconButton>
)}
{p.canBackup && (
<Tooltip title="Backup this disk">
<IconButton
onClick={() => {
p.onRequestBackup(p.disk);
}}
>
<Icon path={mdiHarddiskPlus} size={1} />
</IconButton>
</Tooltip>
)}
</>
}
/>
{/* New disk size*/}
{p.disk.resize && !p.disk.deleteType && (
<DiskSizeInput
editable
label="New disk size (GB)"
value={p.disk.size}
onChange={(v) => {
p.disk.size = v;
p.onChange?.();
}}
/>
)}
</>
);
return (
@ -212,24 +266,32 @@ function DiskInfo(p: {
/>
)}
<TextInput
editable={true}
label="Disk size (GB)"
size={{
min:
ServerApi.Config.constraints.disk_size.min / (1000 * 1000 * 1000),
max:
ServerApi.Config.constraints.disk_size.max / (1000 * 1000 * 1000),
}}
value={(p.disk.size / (1000 * 1000 * 1000)).toString()}
onValueChange={(v) => {
p.disk.size = Number(v ?? "0") * 1000 * 1000 * 1000;
p.onChange?.();
}}
type="number"
disabled={!!p.disk.from_image}
/>
{/* Resize disk image */}
{!!p.disk.from_image && (
<CheckboxInput
editable
checked={p.disk.resize}
label="Resize disk file"
onValueChange={(v) => {
p.disk.resize = v;
p.onChange?.();
}}
/>
)}
{/* Disk size */}
{(!p.disk.from_image || p.disk.resize === true) && (
<DiskSizeInput
editable
value={p.disk.size}
onChange={(v) => {
p.disk.size = v;
p.onChange?.();
}}
/>
)}
{/* Disk image selection */}
<DiskImageSelect
label="Use disk image as template"
list={p.diskImagesList}

View File

@ -10,6 +10,7 @@ import {
ListItemAvatar,
ListItemText,
Tooltip,
Typography,
} from "@mui/material";
import Grid from "@mui/material/Grid";
import { NWFilter } from "../../api/NWFilterApi";
@ -49,6 +50,12 @@ export function VMNetworksList(p: {
</div>
)}
{p.vm.networks.length === 0 && (
<Typography style={{ textAlign: "center", paddingTop: "25px" }}>
No network interface defined yet!
</Typography>
)}
<Grid container spacing={2}>
{/* networks list */}
{p.vm.networks.map((n, num) => (