Skip to content
This repository has been archived by the owner on Apr 20, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release/0.0.3'
Browse files Browse the repository at this point in the history
Release: com.io7m.waxmill 0.0.3
Change: Automatically create virtual machine filesystems (Ticket: #23)
Change: Fix LPC bootrom formatting (Ticket: #26)
Change: Add --replace options to device commands (Ticket: #25)
Change: Add support for interface groups (Ticket: #24)
  • Loading branch information
io7m committed Jul 25, 2020
2 parents 1de92a4 + 0830e4f commit c1d519e
Show file tree
Hide file tree
Showing 95 changed files with 2,699 additions and 445 deletions.
28 changes: 26 additions & 2 deletions README-CHANGES.xml
Expand Up @@ -6,9 +6,33 @@
<c:change date="2020-07-11T00:00:00+00:00" summary="Initial testing release"/>
</c:changes>
</c:release>
<c:release date="2020-07-11T18:36:10+00:00" ticket-system="com.github.io7m.waxmill" version="0.0.2">
<c:release date="2020-07-11T00:00:00+00:00" ticket-system="com.github.io7m.waxmill" version="0.0.2">
<c:changes>
<c:change date="2020-07-11T18:36:10+00:00" summary="Add the vm-kill command"/>
<c:change date="2020-07-11T00:00:00+00:00" summary="Add the vm-kill command"/>
</c:changes>
</c:release>
<c:release date="2020-07-25T09:00:46+00:00" ticket-system="com.github.io7m.waxmill" version="0.0.3">
<c:changes>
<c:change date="2020-07-25T00:00:00+00:00" summary="Add support for interface groups">
<c:tickets>
<c:ticket id="24"/>
</c:tickets>
</c:change>
<c:change date="2020-07-25T00:00:00+00:00" summary="Add --replace options to device commands">
<c:tickets>
<c:ticket id="25"/>
</c:tickets>
</c:change>
<c:change date="2020-07-25T00:00:00+00:00" summary="Fix LPC bootrom formatting">
<c:tickets>
<c:ticket id="26"/>
</c:tickets>
</c:change>
<c:change date="2020-07-25T09:00:46+00:00" summary="Automatically create virtual machine filesystems">
<c:tickets>
<c:ticket id="23"/>
</c:tickets>
</c:change>
</c:changes>
</c:release>
</c:releases>
Expand Down
2 changes: 1 addition & 1 deletion com.io7m.waxmill.boot/pom.xml
Expand Up @@ -9,7 +9,7 @@
<parent>
<artifactId>com.io7m.waxmill</artifactId>
<groupId>com.io7m.waxmill</groupId>
<version>0.0.2</version>
<version>0.0.3</version>
</parent>

<artifactId>com.io7m.waxmill.boot</artifactId>
Expand Down
Expand Up @@ -47,6 +47,7 @@
import com.io7m.waxmill.machines.WXMEvaluatedBootConfigurationUEFI;
import com.io7m.waxmill.machines.WXMGRUBKernelLinux;
import com.io7m.waxmill.machines.WXMGRUBKernelOpenBSD;
import com.io7m.waxmill.machines.WXMNetworkDeviceBackendType;
import com.io7m.waxmill.machines.WXMOpenOption;
import com.io7m.waxmill.machines.WXMStorageBackendFile;
import com.io7m.waxmill.machines.WXMStorageBackends;
Expand All @@ -70,7 +71,6 @@
import java.util.stream.Collectors;

import static com.io7m.waxmill.machines.WXMBootConfigurationType.WXMEvaluatedBootConfigurationType;
import static com.io7m.waxmill.machines.WXMDeviceType.WXMDeviceVirtioNetworkType.WXMNetworkDeviceBackendType;
import static com.io7m.waxmill.machines.WXMDeviceType.WXMDeviceVirtioNetworkType.WXMTTYBackendType;
import static com.io7m.waxmill.machines.WXMDeviceType.WXMStorageBackendType;
import static com.io7m.waxmill.machines.WXMTTYBackends.NMDMSide.NMDM_HOST;
Expand Down Expand Up @@ -368,11 +368,119 @@ private WXMEvaluatedBootCommands generateGRUBBhyveCommands(
this.generateBhyveCommand(bootConfiguration, attachments);

return WXMEvaluatedBootCommands.builder()
.addAllConfigurationCommands(this.networkDeviceCommands())
.addConfigurationCommands(grubBhyveCommand)
.setLastExecution(bhyve)
.build();
}

private Iterable<WXMCommandExecution> networkDeviceCommands()
{
final var commands = new ArrayList<WXMCommandExecution>();

for (final var device : this.machine.devices()) {
switch (device.kind()) {
case WXM_HOSTBRIDGE:
case WXM_VIRTIO_BLOCK:
case WXM_AHCI_HD:
case WXM_AHCI_CD:
case WXM_LPC:
case WXM_PASSTHRU:
case WXM_FRAMEBUFFER:
break;

case WXM_E1000: {
final var e1000 = (WXMDeviceE1000) device;
this.networkDeviceBackendCommands(commands, e1000.backend());
break;
}
case WXM_VIRTIO_NETWORK: {
final var vio = (WXMDeviceVirtioNetwork) device;
this.networkDeviceBackendCommands(commands, vio.backend());
break;
}
}
}
return commands;
}

private void networkDeviceBackendCommands(
final ArrayList<WXMCommandExecution> commands,
final WXMNetworkDeviceBackendType backend)
{
final var ifconfig = this.clientConfiguration.ifconfigExecutable();

switch (backend.kind()) {
case WXM_TAP: {
final var tap = (WXMTap) backend;
final var tapName = tap.name().value();
commands.add(
WXMCommandExecution.builder()
.setExecutable(ifconfig)
.addArguments(tapName)
.addArguments("create")
.setIgnoreFailure(true)
.build()
);

commands.add(
WXMCommandExecution.builder()
.setExecutable(ifconfig)
.addArguments(tapName)
.addArguments("ether")
.addArguments(tap.address().value())
.build()
);

for (final var group : tap.groups()) {
commands.add(
WXMCommandExecution.builder()
.setExecutable(ifconfig)
.addArguments(tapName)
.addArguments("group")
.addArguments(group.value())
.build()
);
}
break;
}
case WXM_VMNET: {
final var vmNet = (WXMVMNet) backend;
final String vmNetName = vmNet.name().value();

commands.add(
WXMCommandExecution.builder()
.setExecutable(ifconfig)
.addArguments(vmNetName)
.addArguments("create")
.setIgnoreFailure(true)
.build()
);

commands.add(
WXMCommandExecution.builder()
.setExecutable(ifconfig)
.addArguments(vmNetName)
.addArguments("ether")
.addArguments(vmNet.address().value())
.build()
);

for (final var group : vmNet.groups()) {
commands.add(
WXMCommandExecution.builder()
.setExecutable(ifconfig)
.addArguments(vmNetName)
.addArguments("group")
.addArguments(group.value())
.build()
);
}
break;
}
}
}

private WXMCommandExecution generateGRUBBhyveCommand()
{
final var machineId =
Expand Down Expand Up @@ -429,8 +537,9 @@ private WXMCommandExecution generateBhyveCommand(
}
case UEFI: {
final var uefi = (WXMBootConfigurationUEFI) bootConfiguration;
commandBuilder.addArguments("-l");
commandBuilder.addArguments(
String.format("-l bootrom,%s", uefi.firmware())
String.format("bootrom,%s", uefi.firmware())
);
break;
}
Expand Down Expand Up @@ -749,19 +858,19 @@ private void configureBhyveFlags(
}

private WXMEvaluatedBootConfigurationGRUBBhyve evaluateGRUBConfigurationOpenBSD(
final WXMBootConfigurationType bootConfiguration,
final WXMBootConfigurationType config,
final WXMDeviceMap deviceMap,
final WXMGRUBKernelOpenBSD openBSD)
{
Objects.requireNonNull(openBSD, "openBSD");

final var configLines =
generateGRUBConfigLinesOpenBSD(deviceMap, openBSD);
final var commands =
this.generateGRUBBhyveCommands(config, deviceMap.attachments());

return WXMEvaluatedBootConfigurationGRUBBhyve.builder()
.setCommands(this.generateGRUBBhyveCommands(
bootConfiguration,
deviceMap.attachments()))
.setCommands(commands)
.setRequiredPaths(deviceMap.paths())
.setDeviceMap(deviceMap.serialize())
.setDeviceMapFile(this.grubDeviceMapPath())
Expand Down Expand Up @@ -881,24 +990,26 @@ private WXMEvaluatedBootCommands generateUEFICommands(
this.generateBhyveCommand(bootConfiguration, attachments);

return WXMEvaluatedBootCommands.builder()
.addAllConfigurationCommands(this.networkDeviceCommands())
.setLastExecution(bhyve)
.build();
}

private WXMEvaluatedBootConfigurationUEFI evaluateUEFIConfiguration(
final WXMBootConfigurationUEFI configuration,
final WXMBootConfigurationUEFI config,
final WXMDeviceMap deviceMap)
{
final var requiredPaths = new ArrayList<Path>();
requiredPaths.add(configuration.firmware());
requiredPaths.add(config.firmware());
requiredPaths.addAll(deviceMap.paths());

final var commands =
this.generateUEFICommands(config, config.diskAttachmentMap());

return WXMEvaluatedBootConfigurationUEFI.builder()
.setRequiredPaths(requiredPaths)
.setRequiredNMDMs(deviceMap.nmdmPaths())
.setCommands(this.generateUEFICommands(
configuration,
configuration.diskAttachmentMap()))
.setCommands(commands)
.build();
}

Expand Down
Expand Up @@ -301,7 +301,13 @@ private void executeAndWait(
.addAllArguments(command.arguments())
.build();

this.processes.processStartAndWait(processDescription);
try {
this.processes.processStartAndWait(processDescription);
} catch (final Exception e) {
if (!command.ignoreFailure()) {
throw e;
}
}
}

private String errorRequiredPathsMissing(
Expand Down
2 changes: 1 addition & 1 deletion com.io7m.waxmill.client.api/pom.xml
Expand Up @@ -9,7 +9,7 @@
<parent>
<artifactId>com.io7m.waxmill</artifactId>
<groupId>com.io7m.waxmill</groupId>
<version>0.0.2</version>
<version>0.0.3</version>
</parent>

<artifactId>com.io7m.waxmill.client.api</artifactId>
Expand Down
Expand Up @@ -97,6 +97,18 @@ default Path zfsExecutable()
.getPath("/sbin/zfs");
}

/**
* @return The "ifconfig" executable path, such as {@code /sbin/ifconfig}
*/

@Value.Default
default Path ifconfigExecutable()
{
return this.virtualMachineConfigurationDirectory()
.getFileSystem()
.getPath("/sbin/ifconfig");
}

/**
* @return The "cu" executable path, such as {@code /usr/bin/cu}
*/
Expand Down Expand Up @@ -152,6 +164,12 @@ default void checkPreconditions()
path -> "zfs executable path must be absolute"
);

Preconditions.checkPrecondition(
this.ifconfigExecutable(),
Path::isAbsolute,
path -> "ifconfig executable path must be absolute"
);

Preconditions.checkPrecondition(
this.virtualMachineConfigurationDirectory(),
Path::isAbsolute,
Expand Down
2 changes: 1 addition & 1 deletion com.io7m.waxmill.client.vanilla/pom.xml
Expand Up @@ -9,7 +9,7 @@
<parent>
<artifactId>com.io7m.waxmill</artifactId>
<groupId>com.io7m.waxmill</groupId>
<version>0.0.2</version>
<version>0.0.3</version>
</parent>

<artifactId>com.io7m.waxmill.client.vanilla</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion com.io7m.waxmill.cmdline/pom.xml
Expand Up @@ -9,7 +9,7 @@
<parent>
<artifactId>com.io7m.waxmill</artifactId>
<groupId>com.io7m.waxmill</groupId>
<version>0.0.2</version>
<version>0.0.3</version>
</parent>

<artifactId>com.io7m.waxmill.cmdline</artifactId>
Expand Down
Expand Up @@ -23,13 +23,13 @@
import com.io7m.waxmill.client.api.WXMClientType;
import com.io7m.waxmill.machines.WXMDeviceAHCIDisk;
import com.io7m.waxmill.machines.WXMDeviceSlot;
import com.io7m.waxmill.machines.WXMDeviceSlots;
import com.io7m.waxmill.machines.WXMDeviceType;
import com.io7m.waxmill.machines.WXMMachineMessages;
import com.io7m.waxmill.machines.WXMOpenOption;
import com.io7m.waxmill.machines.WXMStorageBackendFile;
import com.io7m.waxmill.machines.WXMStorageBackendZFSVolume;
import com.io7m.waxmill.machines.WXMVirtualMachine;
import com.io7m.waxmill.machines.WXMVirtualMachines;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -87,6 +87,14 @@ public final class WXMCommandVMAddAHCIDisk extends
)
private WXMStorageBackendType backend;

@Parameter(
names = "--replace",
description = "Replace an existing device, if one exists",
required = false,
arity = 1
)
private boolean replace;

/**
* Construct a command.
*
Expand Down Expand Up @@ -163,12 +171,6 @@ protected Status executeActualWithConfiguration(
{
try (var client = WXMServices.clients().open(configurationPath)) {
final var machine = client.vmFind(this.id);
this.deviceSlot =
WXMDeviceSlots.checkDeviceSlotNotUsed(
WXMMachineMessages.create(),
machine,
this.deviceSlot
);

switch (this.backend.kind()) {
case WXM_STORAGE_FILE:
Expand Down Expand Up @@ -198,10 +200,12 @@ protected Status executeActualWithConfiguration(
.build();

final var updatedMachine =
WXMVirtualMachine.builder()
.from(machine)
.addDevices(disk)
.build();
WXMVirtualMachines.updateWithDevice(
WXMMachineMessages.create(),
machine,
disk,
this.replace
);

client.vmUpdate(updatedMachine);
this.showCreated(client, machine);
Expand Down

0 comments on commit c1d519e

Please sign in to comment.