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

Commit

Permalink
Use -w by default
Browse files Browse the repository at this point in the history
Booting OpenBSD in bhyve on AMD still seems to require the -w flag,
even though that appears to be described as "fixed" here:

  http://freebsd.1045724.x6.nabble.com/OpenBSD-guest-in-bhyve-on-AMD-CPU-td5987830.html

Using -w at all times appears to be harmless, so it's now the new
default. This also completes the vm-set command to allow setting
all of the available configuration flags.

Fix: #31
  • Loading branch information
io7m committed Jul 30, 2020
1 parent 80947b0 commit 2d49c3a
Show file tree
Hide file tree
Showing 13 changed files with 441 additions and 31 deletions.
Expand Up @@ -864,6 +864,7 @@ private void configureBhyveFlags(
configureBhyveFlag(cmd, flags.generateACPITables(), "-A");
configureBhyveFlag(cmd, flags.guestAPICIsX2APIC(), "-x");
configureBhyveFlag(cmd, flags.includeGuestMemoryInCoreFiles(), "-C");
configureBhyveFlag(cmd, flags.ignoreUnimplementedModelSpecificRegisters(), "-w");
configureBhyveFlag(cmd, flags.realTimeClockIsUTC(), "-u");
configureBhyveFlag(cmd, flags.wireGuestMemory(), "-S");
configureBhyveFlag(cmd, flags.yieldCPUOnHLT(), "-H");
Expand Down
Expand Up @@ -19,6 +19,7 @@
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import com.io7m.claypot.core.CLPCommandContextType;
import com.io7m.waxmill.machines.WXMFlags;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -48,6 +49,69 @@ public final class WXMCommandVMSet extends WXMAbstractCommandWithConfiguration
)
private Boolean wireGuestMemory;

@Parameter(
names = "--include-guest-memory-cores",
description = "Include guest memory in core files.",
arity = 1
)
private Boolean includeGuestMemoryInCoreFiles;

@Parameter(
names = "--yield-on-HLT",
description = "Yield the virtual CPU thread when a HLT instruction is detected.",
arity = 1
)
private Boolean yieldOnHLT;

@Parameter(
names = "--exit-on-PAUSE",
description = "Force the guest virtual CPU to exit when a PAUSE instruction is detected.",
arity = 1
)
private Boolean exitOnPAUSE;

@Parameter(
names = "--generate-acpi-tables",
description = "Generate ACPI tables. Required for FreeBSD/amd64 guests.",
arity = 1
)
private Boolean generateACPITables;

@Parameter(
names = "--disable-mptable-generation",
description = "Disable MP table generation.",
arity = 1
)
private Boolean disableMPTableGeneration;

@Parameter(
names = "--force-msi-interrupts",
description = "Force virtio PCI device emulations to use MSI interrupts instead of MSI-X interrupts.",
arity = 1
)
private Boolean forceMSIInterrupts;

@Parameter(
names = "--guest-apic-is-x2apic",
description = "The guest's local APIC is configured in x2APIC mode.",
arity = 1
)
private Boolean guestAPICIsX2APIC;

@Parameter(
names = "--rtc-is-utc",
description = "RTC keeps UTC time.",
arity = 1
)
private Boolean realTimeClockIsUTC;

@Parameter(
names = "--ignore-unimplemented-msr",
description = "Ignore accesses to unimplemented Model Specific Registers.",
arity = 1
)
private Boolean ignoreUnimplementedModelSpecificRegisters;

/**
* Construct a command.
*
Expand Down Expand Up @@ -80,13 +144,67 @@ protected Status executeActualWithConfiguration(
try (var client = WXMServices.clients().open(configurationPath)) {
final var machine = client.vmFind(this.id);

var flags = machine.flags();
if (this.wireGuestMemory != null) {
flags = flags.withWireGuestMemory(this.wireGuestMemory.booleanValue());
}
final var flagBuilder =
WXMFlags.builder()
.from(machine.flags());

client.vmUpdate(machine.withFlags(flags));
handleFlag(
this.disableMPTableGeneration,
flagBuilder::setDisableMPTableGeneration
);
handleFlag(
this.exitOnPAUSE,
flagBuilder::setExitOnPAUSE
);
handleFlag(
this.forceMSIInterrupts,
flagBuilder::setForceVirtualIOPCIToUseMSI
);
handleFlag(
this.generateACPITables,
flagBuilder::setGenerateACPITables
);
handleFlag(
this.guestAPICIsX2APIC,
flagBuilder::setGuestAPICIsX2APIC
);
handleFlag(
this.ignoreUnimplementedModelSpecificRegisters,
flagBuilder::setIgnoreUnimplementedModelSpecificRegisters
);
handleFlag(
this.includeGuestMemoryInCoreFiles,
flagBuilder::setIncludeGuestMemoryInCoreFiles
);
handleFlag(
this.realTimeClockIsUTC,
flagBuilder::setRealTimeClockIsUTC
);
handleFlag(
this.wireGuestMemory,
flagBuilder::setWireGuestMemory
);
handleFlag(
this.yieldOnHLT,
flagBuilder::setYieldCPUOnHLT
);

client.vmUpdate(machine.withFlags(flagBuilder.build()));
}
return SUCCESS;
}

interface FlagSetterType
{
void set(boolean flag);
}

private static void handleFlag(
final Boolean flag,
final FlagSetterType flagSetter)
{
if (flag != null) {
flagSetter.set(flag.booleanValue());
}
}
}
Expand Up @@ -62,6 +62,114 @@
</Cell>
<Cell>Set the minimum logging verbosity level.</Cell>
</Row>
<Row>
<Cell>
<Term type="parameter">--include-guest-memory-cores</Term>
</Cell>
<Cell>
<Term type="parameterType">Boolean</Term>
</Cell>
<Cell>
<Term type="constant">false</Term>
</Cell>
<Cell>Include guest memory in core files.</Cell>
</Row>
<Row>
<Cell>
<Term type="parameter">--yield-on-HLT</Term>
</Cell>
<Cell>
<Term type="parameterType">Boolean</Term>
</Cell>
<Cell>
<Term type="constant">false</Term>
</Cell>
<Cell>Yield the virtual CPU thread when a HLT instruction is detected.</Cell>
</Row>
<Row>
<Cell>
<Term type="parameter">--exit-on-PAUSE</Term>
</Cell>
<Cell>
<Term type="parameterType">Boolean</Term>
</Cell>
<Cell>
<Term type="constant">false</Term>
</Cell>
<Cell>Force the guest virtual CPU to exit when a PAUSE instruction is detected.</Cell>
</Row>
<Row>
<Cell>
<Term type="parameter">--generate-acpi-tables</Term>
</Cell>
<Cell>
<Term type="parameterType">Boolean</Term>
</Cell>
<Cell>
<Term type="constant">false</Term>
</Cell>
<Cell>Generate ACPI tables. Required for FreeBSD/amd64 guests.</Cell>
</Row>
<Row>
<Cell>
<Term type="parameter">--disable-mptable-generation</Term>
</Cell>
<Cell>
<Term type="parameterType">Boolean</Term>
</Cell>
<Cell>
<Term type="constant">false</Term>
</Cell>
<Cell>Disable MP table generation.</Cell>
</Row>
<Row>
<Cell>
<Term type="parameter">--force-msi-interrupts</Term>
</Cell>
<Cell>
<Term type="parameterType">Boolean</Term>
</Cell>
<Cell>
<Term type="constant">false</Term>
</Cell>
<Cell>Force virtio PCI device emulations to use MSI interrupts instead of MSI-X interrupts.</Cell>
</Row>
<Row>
<Cell>
<Term type="parameter">--guest-apic-is-x2apic</Term>
</Cell>
<Cell>
<Term type="parameterType">Boolean</Term>
</Cell>
<Cell>
<Term type="constant">false</Term>
</Cell>
<Cell>The guest's local APIC is configured in x2APIC mode.</Cell>
</Row>
<Row>
<Cell>
<Term type="parameter">--rtc-is-utc</Term>
</Cell>
<Cell>
<Term type="parameterType">Boolean</Term>
</Cell>
<Cell>
<Term type="constant">false</Term>
</Cell>
<Cell>RTC keeps UTC time.</Cell>
</Row>
<Row>
<Cell>
<Term type="parameter">--ignore-unimplemented-msr</Term>
</Cell>
<Cell>
<Term type="parameterType">Boolean</Term>
</Cell>
<Cell>
<Term type="constant">false</Term>
</Cell>
<Cell>Ignore accesses to unimplemented Model Specific Registers.</Cell>
</Row>
<Row>
<Cell>
<Term type="parameter">--wire-guest-memory</Term>
Expand Down
Expand Up @@ -31,6 +31,8 @@ public interface WXMFlagsType
* Include guest memory in core files.
*
* @return {@code true} if guest memory should appear in core files.
*
* @see "-C option to bhyve"
*/

@Value.Default
Expand All @@ -45,6 +47,8 @@ default boolean includeGuestMemoryInCoreFiles()
* use 100% of a host CPU.
*
* @return {@code true} if the virtual CPU should yield on HLT
*
* @see "-H option to bhyve"
*/

@Value.Default
Expand All @@ -58,6 +62,8 @@ default boolean yieldCPUOnHLT()
* is detected.
*
* @return {@code true} if the virtual CPU should exit on PAUSE
*
* @see "-P option to bhyve"
*/

@Value.Default
Expand All @@ -70,6 +76,8 @@ default boolean exitOnPAUSE()
* Generate ACPI tables. Required for FreeBSD/amd64 guests.
*
* @return {@code true} if ACPI tables should be generated.
*
* @see "-A option to bhyve"
*/

@Value.Default
Expand All @@ -82,6 +90,8 @@ default boolean generateACPITables()
* Disable MP table generation.
*
* @return {@code true} if generation should be disabled
*
* @see "-Y option to bhyve"
*/

@Value.Default
Expand All @@ -95,6 +105,8 @@ default boolean disableMPTableGeneration()
* instead of MSI-X interrupts.
*
* @return {@code true} if MSI interrupts should be used
*
* @see "-W option to bhyve"
*/

@Value.Default
Expand All @@ -107,6 +119,8 @@ default boolean forceVirtualIOPCIToUseMSI()
* The guest's local APIC is configured in x2APIC mode.
*
* @return {@code true} if the guest's local APIC is configured in x2APIC mode.
*
* @see "-x option to bhyve"
*/

@Value.Default
Expand All @@ -119,6 +133,8 @@ default boolean guestAPICIsX2APIC()
* Wire guest memory.
*
* @return {@code true} if the guest's memory should be wired
*
* @see "-S option to bhyve"
*/

@Value.Default
Expand All @@ -131,11 +147,28 @@ default boolean wireGuestMemory()
* RTC keeps UTC time.
*
* @return {@code true} if the guest's RTC keeps UTC time.
*
* @see "-u option to bhyve"
*/

@Value.Default
default boolean realTimeClockIsUTC()
{
return false;
}

/**
* Ignore accesses to unimplemented Model Specific Registers
* (MSRs). This is intended for debug purposes.
*
* @return {@code true} if unimplemented accesses should be ignored
*
* @see "-w option to bhyve"
*/

@Value.Default
default boolean ignoreUnimplementedModelSpecificRegisters()
{
return true;
}
}

0 comments on commit 2d49c3a

Please sign in to comment.