Intermediate state.
This commit is contained in:
parent
29bc6f539c
commit
68a688c4ce
7 changed files with 83 additions and 53 deletions
|
|
@ -21,8 +21,8 @@
|
||||||
# Defaults for namespace (VM domain)
|
# Defaults for namespace (VM domain)
|
||||||
handlers=java.util.logging.ConsoleHandler
|
handlers=java.util.logging.ConsoleHandler
|
||||||
|
|
||||||
#org.jgrapes.level=FINE
|
org.jgrapes.level=FINE
|
||||||
#org.jgrapes.core.handlerTracking.level=FINER
|
org.jgrapes.core.handlerTracking.level=FINER
|
||||||
|
|
||||||
org.jdrupes.vmoperator.runner.qemu.level=FINEST
|
org.jdrupes.vmoperator.runner.qemu.level=FINEST
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,10 @@ metadata:
|
||||||
|
|
||||||
spec:
|
spec:
|
||||||
image:
|
image:
|
||||||
# pullPolicy: Always
|
source: ghcr.io/mnlipp/org.jdrupes.vmoperator.runner.qemu-arch:3.3.1
|
||||||
# repository: ghcr.io
|
# source: registry.mnl.de/org/jdrupes/vm-operator/org.jdrupes.vmoperator.runner.qemu-arch:feature-login-pool
|
||||||
# path: mnlipp/org.jdrupes.vmoperator.runner.qemu-alpine
|
# source: docker-registry.lan.mnl.de/vmoperator/org.jdrupes.vmoperator.runner.qemu-arch:feature-pools
|
||||||
# version: "3.0.0"
|
# source: docker-registry.lan.mnl.de/vmoperator/org.jdrupes.vmoperator.runner.qemu-arch:fix-race-condition
|
||||||
# source: docker-registry.lan.mnl.de/vm-operator/org.jdrupes.vmoperator.runner.qemu-arch:feature-auto-login
|
|
||||||
source: registry.mnl.de/org/jdrupes/vm-operator/org.jdrupes.vmoperator.runner.qemu-arch:feature-auto-login
|
|
||||||
pullPolicy: Always
|
pullPolicy: Always
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ import org.jdrupes.vmoperator.runner.qemu.commands.QmpSetDisplayPassword;
|
||||||
import org.jdrupes.vmoperator.runner.qemu.commands.QmpSetPasswordExpiry;
|
import org.jdrupes.vmoperator.runner.qemu.commands.QmpSetPasswordExpiry;
|
||||||
import org.jdrupes.vmoperator.runner.qemu.events.ConfigureQemu;
|
import org.jdrupes.vmoperator.runner.qemu.events.ConfigureQemu;
|
||||||
import org.jdrupes.vmoperator.runner.qemu.events.MonitorCommand;
|
import org.jdrupes.vmoperator.runner.qemu.events.MonitorCommand;
|
||||||
|
import org.jdrupes.vmoperator.runner.qemu.events.QmpConfigured;
|
||||||
import org.jdrupes.vmoperator.runner.qemu.events.RunnerStateChange.RunState;
|
import org.jdrupes.vmoperator.runner.qemu.events.RunnerStateChange.RunState;
|
||||||
import org.jdrupes.vmoperator.runner.qemu.events.VmopAgentConnected;
|
import org.jdrupes.vmoperator.runner.qemu.events.VmopAgentConnected;
|
||||||
import org.jdrupes.vmoperator.runner.qemu.events.VmopAgentLogIn;
|
import org.jdrupes.vmoperator.runner.qemu.events.VmopAgentLogIn;
|
||||||
|
|
@ -85,6 +86,19 @@ public class DisplayController extends Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When the monitor is ready, send QEMU its initial configuration.
|
||||||
|
*
|
||||||
|
* @param event the event
|
||||||
|
*/
|
||||||
|
@Handler
|
||||||
|
public void onQmpConfigured(QmpConfigured event) {
|
||||||
|
if (pendingConfig != null) {
|
||||||
|
rep.fire(new ConfigureQemu(pendingConfig, state));
|
||||||
|
pendingConfig = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On vmop agent connected.
|
* On vmop agent connected.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ public class GuestAgentClient extends AgentConnector {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void agentConnected() {
|
protected void agentConnected() {
|
||||||
fire(new GuestAgentCommand(new QmpGuestGetOsinfo()));
|
rep().fire(new GuestAgentCommand(new QmpGuestGetOsinfo()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ public abstract class QemuConnector extends Component {
|
||||||
// qemu running, open socket
|
// qemu running, open socket
|
||||||
fire(new OpenSocketConnection(
|
fire(new OpenSocketConnection(
|
||||||
UnixDomainSocketAddress.of(socketPath))
|
UnixDomainSocketAddress.of(socketPath))
|
||||||
.setAssociated(getClass(), this));
|
.setAssociated(this, this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -137,21 +137,21 @@ public abstract class QemuConnector extends Component {
|
||||||
@Handler
|
@Handler
|
||||||
public void onClientConnected(ClientConnected event,
|
public void onClientConnected(ClientConnected event,
|
||||||
SocketIOChannel channel) {
|
SocketIOChannel channel) {
|
||||||
event.openEvent().associated(getClass()).ifPresent(qm -> {
|
event.openEvent().associated(this, getClass()).ifPresent(qc -> {
|
||||||
qemuChannel = channel;
|
qemuChannel = channel;
|
||||||
channel.setAssociated(getClass(), this);
|
channel.setAssociated(this, this);
|
||||||
channel.setAssociated(Writer.class, new ByteBufferWriter(
|
channel.setAssociated(Writer.class, new ByteBufferWriter(
|
||||||
channel).nativeCharset());
|
channel).nativeCharset());
|
||||||
channel.setAssociated(LineCollector.class,
|
channel.setAssociated(LineCollector.class,
|
||||||
new LineCollector()
|
new LineCollector()
|
||||||
.consumer(line -> {
|
.consumer(line -> {
|
||||||
try {
|
try {
|
||||||
processInput(line);
|
qc.processInput(line);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new UndeclaredThrowableException(e);
|
throw new UndeclaredThrowableException(e);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
socketConnected();
|
qc.socketConnected();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -206,7 +206,7 @@ public abstract class QemuConnector extends Component {
|
||||||
*/
|
*/
|
||||||
@Handler
|
@Handler
|
||||||
public void onConnectError(ConnectError event, SocketIOChannel channel) {
|
public void onConnectError(ConnectError event, SocketIOChannel channel) {
|
||||||
event.event().associated(getClass()).ifPresent(qm -> {
|
event.event().associated(this, getClass()).ifPresent(qc -> {
|
||||||
rep.fire(new Stop());
|
rep.fire(new Stop());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -219,7 +219,7 @@ public abstract class QemuConnector extends Component {
|
||||||
*/
|
*/
|
||||||
@Handler
|
@Handler
|
||||||
public void onInput(Input<?> event, SocketIOChannel channel) {
|
public void onInput(Input<?> event, SocketIOChannel channel) {
|
||||||
if (channel.associated(getClass()).isEmpty()) {
|
if (channel.associated(this, getClass()).isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
channel.associated(LineCollector.class).ifPresent(collector -> {
|
channel.associated(LineCollector.class).ifPresent(collector -> {
|
||||||
|
|
@ -243,7 +243,7 @@ public abstract class QemuConnector extends Component {
|
||||||
*/
|
*/
|
||||||
@Handler
|
@Handler
|
||||||
public void onClosed(Closed<?> event, SocketIOChannel channel) {
|
public void onClosed(Closed<?> event, SocketIOChannel channel) {
|
||||||
channel.associated(getClass()).ifPresent(qm -> {
|
channel.associated(this, getClass()).ifPresent(qm -> {
|
||||||
qemuChannel = null;
|
qemuChannel = null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,7 @@ public class QemuMonitor extends QemuConnector {
|
||||||
private Stop suspendedStop;
|
private Stop suspendedStop;
|
||||||
private Timer powerdownTimer;
|
private Timer powerdownTimer;
|
||||||
private boolean powerdownConfirmed;
|
private boolean powerdownConfirmed;
|
||||||
|
private boolean monitorReady;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new QEMU monitor.
|
* Instantiates a new QEMU monitor.
|
||||||
|
|
@ -99,7 +100,7 @@ public class QemuMonitor extends QemuConnector {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void socketConnected() {
|
protected void socketConnected() {
|
||||||
fire(new MonitorCommand(new QmpCapabilities()));
|
rep().fire(new MonitorCommand(new QmpCapabilities()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -109,6 +110,7 @@ public class QemuMonitor extends QemuConnector {
|
||||||
try {
|
try {
|
||||||
var response = mapper.readValue(line, ObjectNode.class);
|
var response = mapper.readValue(line, ObjectNode.class);
|
||||||
if (response.has("QMP")) {
|
if (response.has("QMP")) {
|
||||||
|
monitorReady = true;
|
||||||
rep().fire(new MonitorReady());
|
rep().fire(new MonitorReady());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -137,8 +139,9 @@ public class QemuMonitor extends QemuConnector {
|
||||||
@SuppressWarnings({ "PMD.AvoidSynchronizedStatement",
|
@SuppressWarnings({ "PMD.AvoidSynchronizedStatement",
|
||||||
"PMD.AvoidDuplicateLiterals" })
|
"PMD.AvoidDuplicateLiterals" })
|
||||||
public void onClosed(Closed<?> event, SocketIOChannel channel) {
|
public void onClosed(Closed<?> event, SocketIOChannel channel) {
|
||||||
|
logger.finer(() -> "Closing QMP socket.");
|
||||||
super.onClosed(event, channel);
|
super.onClosed(event, channel);
|
||||||
channel.associated(QemuMonitor.class).ifPresent(qm -> {
|
channel.associated(this, getClass()).ifPresent(qm -> {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (powerdownTimer != null) {
|
if (powerdownTimer != null) {
|
||||||
powerdownTimer.cancel();
|
powerdownTimer.cancel();
|
||||||
|
|
@ -149,6 +152,7 @@ public class QemuMonitor extends QemuConnector {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
logger.finer(() -> "QMP socket closed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -158,9 +162,14 @@ public class QemuMonitor extends QemuConnector {
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
@Handler
|
@Handler
|
||||||
@SuppressWarnings({ "PMD.AvoidLiteralsInIfCondition",
|
@SuppressWarnings("PMD.AvoidSynchronizedStatement")
|
||||||
"PMD.AvoidSynchronizedStatement" })
|
public void onMonitorCommand(MonitorCommand event) throws IOException {
|
||||||
public void onExecQmpCommand(MonitorCommand event) throws IOException {
|
if (!monitorReady) {
|
||||||
|
logger.severe(() -> "Premature monitor command (not ready): "
|
||||||
|
+ event.command());
|
||||||
|
rep().fire(new Stop());
|
||||||
|
return;
|
||||||
|
}
|
||||||
var command = event.command();
|
var command = event.command();
|
||||||
logger.fine(() -> "monitor(out): " + command.toString());
|
logger.fine(() -> "monitor(out): " + command.toString());
|
||||||
String asText;
|
String asText;
|
||||||
|
|
|
||||||
|
|
@ -192,7 +192,7 @@ import org.jgrapes.util.events.WatchFile;
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({ "PMD.ExcessiveImports", "PMD.AvoidPrintStackTrace",
|
@SuppressWarnings({ "PMD.ExcessiveImports", "PMD.AvoidPrintStackTrace",
|
||||||
"PMD.DataflowAnomalyAnalysis", "PMD.TooManyMethods",
|
"PMD.DataflowAnomalyAnalysis", "PMD.TooManyMethods",
|
||||||
"PMD.CouplingBetweenObjects", "PMD.TooManyFields" })
|
"PMD.CouplingBetweenObjects", "PMD.TooManyFields", "PMD.GodClass" })
|
||||||
public class Runner extends Component {
|
public class Runner extends Component {
|
||||||
|
|
||||||
private static final String QEMU = "qemu";
|
private static final String QEMU = "qemu";
|
||||||
|
|
@ -214,12 +214,14 @@ public class Runner extends Component {
|
||||||
@SuppressWarnings("PMD.UseConcurrentHashMap")
|
@SuppressWarnings("PMD.UseConcurrentHashMap")
|
||||||
private final File configFile;
|
private final File configFile;
|
||||||
private final Path configDir;
|
private final Path configDir;
|
||||||
private Configuration config = new Configuration();
|
private Configuration initialConfig;
|
||||||
|
private Configuration pendingConfig;
|
||||||
private final freemarker.template.Configuration fmConfig;
|
private final freemarker.template.Configuration fmConfig;
|
||||||
private CommandDefinition swtpmDefinition;
|
private CommandDefinition swtpmDefinition;
|
||||||
private CommandDefinition cloudInitImgDefinition;
|
private CommandDefinition cloudInitImgDefinition;
|
||||||
private CommandDefinition qemuDefinition;
|
private CommandDefinition qemuDefinition;
|
||||||
private final QemuMonitor qemuMonitor;
|
private final QemuMonitor qemuMonitor;
|
||||||
|
private boolean qmpConfigured;
|
||||||
private final GuestAgentClient guestAgentClient;
|
private final GuestAgentClient guestAgentClient;
|
||||||
private final VmopAgentClient vmopAgentClient;
|
private final VmopAgentClient vmopAgentClient;
|
||||||
private Integer resetCounter;
|
private Integer resetCounter;
|
||||||
|
|
@ -318,27 +320,33 @@ public class Runner extends Component {
|
||||||
// Special actions for initial configuration (startup)
|
// Special actions for initial configuration (startup)
|
||||||
if (event instanceof InitialConfiguration) {
|
if (event instanceof InitialConfiguration) {
|
||||||
processInitialConfiguration(newConf);
|
processInitialConfiguration(newConf);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
logger.fine(() -> "Updating configuration");
|
|
||||||
rep.fire(new ConfigureQemu(newConf, state));
|
// Check if to be sent immediately or later
|
||||||
|
if (qmpConfigured) {
|
||||||
|
rep.fire(new ConfigureQemu(newConf, state));
|
||||||
|
} else {
|
||||||
|
pendingConfig = newConf;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("PMD.LambdaCanBeMethodReference")
|
@SuppressWarnings("PMD.LambdaCanBeMethodReference")
|
||||||
private void processInitialConfiguration(Configuration newConfig) {
|
private void processInitialConfiguration(Configuration newConfig) {
|
||||||
try {
|
try {
|
||||||
config = newConfig;
|
if (!newConfig.check()) {
|
||||||
if (!config.check()) {
|
|
||||||
// Invalid configuration, not used, problems already logged.
|
// Invalid configuration, not used, problems already logged.
|
||||||
config = null;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare firmware files and add to config
|
// Prepare firmware files and add to config
|
||||||
setFirmwarePaths();
|
setFirmwarePaths(newConfig);
|
||||||
|
|
||||||
// Obtain more context data from template
|
// Obtain more context data from template
|
||||||
var tplData = dataFromTemplate();
|
var tplData = dataFromTemplate(newConfig);
|
||||||
|
initialConfig = newConfig;
|
||||||
|
|
||||||
|
// Configure
|
||||||
swtpmDefinition = Optional.ofNullable(tplData.get(SWTPM))
|
swtpmDefinition = Optional.ofNullable(tplData.get(SWTPM))
|
||||||
.map(d -> new CommandDefinition(SWTPM, d)).orElse(null);
|
.map(d -> new CommandDefinition(SWTPM, d)).orElse(null);
|
||||||
logger.finest(() -> swtpmDefinition.toString());
|
logger.finest(() -> swtpmDefinition.toString());
|
||||||
|
|
@ -352,21 +360,19 @@ public class Runner extends Component {
|
||||||
logger.finest(() -> cloudInitImgDefinition.toString());
|
logger.finest(() -> cloudInitImgDefinition.toString());
|
||||||
|
|
||||||
// Forward some values to child components
|
// Forward some values to child components
|
||||||
qemuMonitor.configure(config.monitorSocket,
|
qemuMonitor.configure(initialConfig.monitorSocket,
|
||||||
config.vm.powerdownTimeout);
|
initialConfig.vm.powerdownTimeout);
|
||||||
configureAgentClient(guestAgentClient, "guest-agent-socket");
|
configureAgentClient(guestAgentClient, "guest-agent-socket");
|
||||||
configureAgentClient(vmopAgentClient, "vmop-agent-socket");
|
configureAgentClient(vmopAgentClient, "vmop-agent-socket");
|
||||||
} catch (IllegalArgumentException | IOException | TemplateException e) {
|
} catch (IllegalArgumentException | IOException | TemplateException e) {
|
||||||
logger.log(Level.SEVERE, e, () -> "Invalid configuration: "
|
logger.log(Level.SEVERE, e, () -> "Invalid configuration: "
|
||||||
+ e.getMessage());
|
+ e.getMessage());
|
||||||
// Don't use default configuration
|
|
||||||
config = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "PMD.CognitiveComplexity",
|
@SuppressWarnings({ "PMD.CognitiveComplexity",
|
||||||
"PMD.DataflowAnomalyAnalysis" })
|
"PMD.DataflowAnomalyAnalysis" })
|
||||||
private void setFirmwarePaths() throws IOException {
|
private void setFirmwarePaths(Configuration config) throws IOException {
|
||||||
JsonNode firmware = defaults.path("firmware").path(config.vm.firmware);
|
JsonNode firmware = defaults.path("firmware").path(config.vm.firmware);
|
||||||
// Get file for firmware ROM
|
// Get file for firmware ROM
|
||||||
JsonNode codePaths = firmware.path("rom");
|
JsonNode codePaths = firmware.path("rom");
|
||||||
|
|
@ -396,7 +402,7 @@ public class Runner extends Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private JsonNode dataFromTemplate()
|
private JsonNode dataFromTemplate(Configuration config)
|
||||||
throws IOException, TemplateNotFoundException,
|
throws IOException, TemplateNotFoundException,
|
||||||
MalformedTemplateNameException, ParseException, TemplateException,
|
MalformedTemplateNameException, ParseException, TemplateException,
|
||||||
JsonProcessingException, JsonMappingException {
|
JsonProcessingException, JsonMappingException {
|
||||||
|
|
@ -442,7 +448,7 @@ public class Runner extends Component {
|
||||||
*/
|
*/
|
||||||
@Handler(priority = 100)
|
@Handler(priority = 100)
|
||||||
public void onStart(Start event) {
|
public void onStart(Start event) {
|
||||||
if (config == null) {
|
if (initialConfig == null) {
|
||||||
// Missing configuration, fail
|
// Missing configuration, fail
|
||||||
event.cancel(true);
|
event.cancel(true);
|
||||||
fire(new Stop());
|
fire(new Stop());
|
||||||
|
|
@ -458,19 +464,19 @@ public class Runner extends Component {
|
||||||
try {
|
try {
|
||||||
// Store process id
|
// Store process id
|
||||||
try (var pidFile = Files.newBufferedWriter(
|
try (var pidFile = Files.newBufferedWriter(
|
||||||
config.runtimeDir.resolve("runner.pid"))) {
|
initialConfig.runtimeDir.resolve("runner.pid"))) {
|
||||||
pidFile.write(ProcessHandle.current().pid() + "\n");
|
pidFile.write(ProcessHandle.current().pid() + "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Files to watch for
|
// Files to watch for
|
||||||
Files.deleteIfExists(config.swtpmSocket);
|
Files.deleteIfExists(initialConfig.swtpmSocket);
|
||||||
fire(new WatchFile(config.swtpmSocket));
|
fire(new WatchFile(initialConfig.swtpmSocket));
|
||||||
|
|
||||||
// Helper files
|
// Helper files
|
||||||
var ticket = Optional.ofNullable(config.vm.display)
|
var ticket = Optional.ofNullable(initialConfig.vm.display)
|
||||||
.map(d -> d.spice).map(s -> s.ticket);
|
.map(d -> d.spice).map(s -> s.ticket);
|
||||||
if (ticket.isPresent()) {
|
if (ticket.isPresent()) {
|
||||||
Files.write(config.runtimeDir.resolve("ticket.txt"),
|
Files.write(initialConfig.runtimeDir.resolve("ticket.txt"),
|
||||||
ticket.get().getBytes());
|
ticket.get().getBytes());
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
@ -522,12 +528,12 @@ public class Runner extends Component {
|
||||||
"Runner has been started"));
|
"Runner has been started"));
|
||||||
// Start first process(es)
|
// Start first process(es)
|
||||||
qemuLatch.add(QemuPreps.Config);
|
qemuLatch.add(QemuPreps.Config);
|
||||||
if (config.vm.useTpm && swtpmDefinition != null) {
|
if (initialConfig.vm.useTpm && swtpmDefinition != null) {
|
||||||
startProcess(swtpmDefinition);
|
startProcess(swtpmDefinition);
|
||||||
qemuLatch.add(QemuPreps.Tpm);
|
qemuLatch.add(QemuPreps.Tpm);
|
||||||
}
|
}
|
||||||
if (config.cloudInit != null) {
|
if (initialConfig.cloudInit != null) {
|
||||||
generateCloudInitImg();
|
generateCloudInitImg(initialConfig);
|
||||||
qemuLatch.add(QemuPreps.CloudInit);
|
qemuLatch.add(QemuPreps.CloudInit);
|
||||||
}
|
}
|
||||||
mayBeStartQemu(QemuPreps.Config);
|
mayBeStartQemu(QemuPreps.Config);
|
||||||
|
|
@ -546,7 +552,7 @@ public class Runner extends Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateCloudInitImg() {
|
private void generateCloudInitImg(Configuration config) {
|
||||||
try {
|
try {
|
||||||
var cloudInitDir = config.dataDir.resolve("cloud-init");
|
var cloudInitDir = config.dataDir.resolve("cloud-init");
|
||||||
cloudInitDir.toFile().mkdir();
|
cloudInitDir.toFile().mkdir();
|
||||||
|
|
@ -583,7 +589,7 @@ public class Runner extends Component {
|
||||||
private boolean startProcess(CommandDefinition toStart) {
|
private boolean startProcess(CommandDefinition toStart) {
|
||||||
logger.info(
|
logger.info(
|
||||||
() -> "Starting process: " + String.join(" ", toStart.command));
|
() -> "Starting process: " + String.join(" ", toStart.command));
|
||||||
fire(new StartProcess(toStart.command)
|
rep.fire(new StartProcess(toStart.command)
|
||||||
.setAssociated(CommandDefinition.class, toStart));
|
.setAssociated(CommandDefinition.class, toStart));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -597,7 +603,7 @@ public class Runner extends Component {
|
||||||
@Handler
|
@Handler
|
||||||
public void onFileChanged(FileChanged event) {
|
public void onFileChanged(FileChanged event) {
|
||||||
if (event.change() == Kind.CREATED
|
if (event.change() == Kind.CREATED
|
||||||
&& event.path().equals(config.swtpmSocket)) {
|
&& event.path().equals(initialConfig.swtpmSocket)) {
|
||||||
// swtpm running, maybe start qemu
|
// swtpm running, maybe start qemu
|
||||||
mayBeStartQemu(QemuPreps.Tpm);
|
mayBeStartQemu(QemuPreps.Tpm);
|
||||||
}
|
}
|
||||||
|
|
@ -620,7 +626,7 @@ public class Runner extends Component {
|
||||||
.ifPresent(procDef -> {
|
.ifPresent(procDef -> {
|
||||||
channel.setAssociated(CommandDefinition.class, procDef);
|
channel.setAssociated(CommandDefinition.class, procDef);
|
||||||
try (var pidFile = Files.newBufferedWriter(
|
try (var pidFile = Files.newBufferedWriter(
|
||||||
config.runtimeDir.resolve(procDef.name + ".pid"))) {
|
initialConfig.runtimeDir.resolve(procDef.name + ".pid"))) {
|
||||||
pidFile.write(channel.process().toHandle().pid() + "\n");
|
pidFile.write(channel.process().toHandle().pid() + "\n");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new UndeclaredThrowableException(e);
|
throw new UndeclaredThrowableException(e);
|
||||||
|
|
@ -659,7 +665,10 @@ public class Runner extends Component {
|
||||||
*/
|
*/
|
||||||
@Handler
|
@Handler
|
||||||
public void onQmpConfigured(QmpConfigured event) {
|
public void onQmpConfigured(QmpConfigured event) {
|
||||||
rep.fire(new ConfigureQemu(config, state));
|
if (pendingConfig != null) {
|
||||||
|
rep.fire(new ConfigureQemu(pendingConfig, state));
|
||||||
|
pendingConfig = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -791,7 +800,7 @@ public class Runner extends Component {
|
||||||
logger.log(Level.WARNING, e, () -> "Proper shutdown failed.");
|
logger.log(Level.WARNING, e, () -> "Proper shutdown failed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional.ofNullable(config).map(c -> c.runtimeDir)
|
Optional.ofNullable(initialConfig).map(c -> c.runtimeDir)
|
||||||
.ifPresent(runtimeDir -> {
|
.ifPresent(runtimeDir -> {
|
||||||
try {
|
try {
|
||||||
Files.walk(runtimeDir).sorted(Comparator.reverseOrder())
|
Files.walk(runtimeDir).sorted(Comparator.reverseOrder())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue