Automatic driver selection for disks.
This commit is contained in:
parent
f16bb7a1e5
commit
0669aa3daa
2 changed files with 27 additions and 3 deletions
|
|
@ -83,11 +83,14 @@
|
||||||
# There are no default drives. The supported types are "ide-cd"
|
# There are no default drives. The supported types are "ide-cd"
|
||||||
# and "raw". All types support a "bootindex" property.
|
# and "raw". All types support a "bootindex" property.
|
||||||
# Type "raw" can have a property "file" (if backed by a file on
|
# Type "raw" can have a property "file" (if backed by a file on
|
||||||
# the host) or a property "device" (if backed by a device).
|
# the host) or a property "device" (if backed by a device).
|
||||||
|
# Alternatively you can use "resource", which automatically be
|
||||||
|
# interpreted as file or device as appropriate
|
||||||
|
# (see https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/nio/file/Files.html#isRegularFile(java.nio.file.Path,java.nio.file.LinkOption...)).
|
||||||
# "drives":
|
# "drives":
|
||||||
# - "type": "ide-cd"
|
# - "type": "ide-cd"
|
||||||
# "bootindex": (undefined)
|
# "bootindex": (undefined)
|
||||||
# "file": (undefined)
|
# "resource": (undefined)
|
||||||
|
|
||||||
# "spice":
|
# "spice":
|
||||||
# "port": 5900
|
# "port": 5900
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,7 @@ class Configuration implements Dto {
|
||||||
public String rtcClock = "rt";
|
public String rtcClock = "rt";
|
||||||
public int powerdownTimeout = 900;
|
public int powerdownTimeout = 900;
|
||||||
public Network[] network = { new Network() };
|
public Network[] network = { new Network() };
|
||||||
public Drive[] drives;
|
public Drive[] drives = new Drive[0];
|
||||||
public Spice spice;
|
public Spice spice;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -173,6 +173,7 @@ class Configuration implements Dto {
|
||||||
public Integer bootindex;
|
public Integer bootindex;
|
||||||
public String device;
|
public String device;
|
||||||
public String file;
|
public String file;
|
||||||
|
public String resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -202,9 +203,29 @@ class Configuration implements Dto {
|
||||||
vm.maximumCpus = vm.currentCpus;
|
vm.maximumCpus = vm.currentCpus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkDrives();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkDrives() {
|
||||||
|
for (Drive drive : vm.drives) {
|
||||||
|
if (drive.file != null || drive.device != null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (drive.resource == null) {
|
||||||
|
logger.severe(
|
||||||
|
() -> "Drive configuration is missing its resource.");
|
||||||
|
|
||||||
|
}
|
||||||
|
if (Files.isRegularFile(Path.of(drive.resource))) {
|
||||||
|
drive.file = drive.resource;
|
||||||
|
} else {
|
||||||
|
drive.device = drive.resource;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("PMD.AvoidDeeplyNestedIfStmts")
|
@SuppressWarnings("PMD.AvoidDeeplyNestedIfStmts")
|
||||||
private boolean checkRuntimeDir() {
|
private boolean checkRuntimeDir() {
|
||||||
// Runtime directory (sockets)
|
// Runtime directory (sockets)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue