VIR_FREE(binary);
return ret;
}
+
+int
+virBhyveProbeCaps(unsigned int *caps)
+{
+ char *binary, *help;
+ virCommandPtr cmd = NULL;
+ int ret = 0, exit;
+
+ binary = virFindFileInPath("bhyve");
+ if (binary == NULL)
+ goto out;
+ if (!virFileIsExecutable(binary))
+ goto out;
+
+ cmd = virCommandNew(binary);
+ virCommandAddArg(cmd, "-h");
+ virCommandSetErrorBuffer(cmd, &help);
+ if (virCommandRun(cmd, &exit) < 0) {
+ ret = -1;
+ goto out;
+ }
+
+ if (strstr(help, "-u:") != NULL)
+ *caps |= BHYVE_CAP_RTC_UTC;
+
+ out:
+ VIR_FREE(help);
+ virCommandFree(cmd);
+ VIR_FREE(binary);
+ return ret;
+}
BHYVE_GRUB_CAP_CONSDEV = 1,
} virBhyveGrubCapsFlags;
+typedef enum {
+ BHYVE_CAP_RTC_UTC = 1,
+} virBhyveCapsFlags;
+
int virBhyveProbeGrubCaps(virBhyveGrubCapsFlags *caps);
+int virBhyveProbeCaps(unsigned int *caps);
#endif
if (def->features[VIR_DOMAIN_FEATURE_APIC] == VIR_TRISTATE_SWITCH_ON)
virCommandAddArg(cmd, "-I"); /* Present ioapic to the guest */
+ switch (def->clock.offset) {
+ case VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME:
+ /* used by default in bhyve */
+ break;
+ case VIR_DOMAIN_CLOCK_OFFSET_UTC:
+ if ((bhyveDriverGetCaps(conn) & BHYVE_CAP_RTC_UTC) != 0) {
+ virCommandAddArg(cmd, "-u");
+ } else {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Installed bhyve binary does not support "
+ "UTC clock"));
+ goto error;
+ }
+ break;
+ default:
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unsupported clock offset '%s'"),
+ virDomainClockOffsetTypeToString(def->clock.offset));
+ goto error;
+ }
+
/* Clarification about -H and -P flags from Peter Grehan:
* -H and -P flags force the guest to exit when it executes IA32 HLT and PAUSE
* instructions respectively.
if (!(bhyve_driver->caps = virBhyveCapsBuild()))
goto cleanup;
+ if (virBhyveProbeCaps(&bhyve_driver->bhyvecaps) < 0)
+ goto cleanup;
+
if (virBhyveProbeGrubCaps(&bhyve_driver->grubcaps) < 0)
goto cleanup;
return -1;
}
+unsigned
+bhyveDriverGetCaps(virConnectPtr conn)
+{
+ bhyveConnPtr driver = conn->privateData;
+
+ if (driver != NULL)
+ return driver->bhyvecaps;
+ return 0;
+}
+
unsigned
bhyveDriverGetGrubCaps(virConnectPtr conn)
{
int bhyveRegister(void);
+unsigned bhyveDriverGetCaps(virConnectPtr conn);
+
unsigned bhyveDriverGetGrubCaps(virConnectPtr conn);
#endif /* __BHYVE_DRIVER_H__ */
virCloseCallbacksPtr closeCallbacks;
+ unsigned bhyvecaps;
unsigned grubcaps;
};
-/usr/sbin/bhyve -c 1 -m 214 -A -I -H -P -s 0:0,hostbridge \
+/usr/sbin/bhyve -c 1 -m 214 -A -I -u -H -P -s 0:0,hostbridge \
-s 3:0,virtio-net,faketapdev,mac=52:54:00:00:00:00 \
-s 2:0,ahci-hd,/tmp/freebsd.img bhyve
-/usr/sbin/bhyve -c 1 -m 214 -H -P -s 0:0,hostbridge \
+/usr/sbin/bhyve -c 1 -m 214 -u -H -P -s 0:0,hostbridge \
-s 3:0,virtio-net,faketapdev,mac=52:54:00:00:00:00 \
-s 2:0,ahci-hd,/tmp/freebsd.img bhyve
-/usr/sbin/bhyve -c 1 -m 214 -H -P -s 0:0,hostbridge \
+/usr/sbin/bhyve -c 1 -m 214 -u -H -P -s 0:0,hostbridge \
-s 3:0,virtio-net,faketapdev,mac=52:54:00:00:00:00 \
-s 2:0,ahci-hd,/tmp/freebsd.img bhyve
-/usr/sbin/bhyve -c 1 -m 214 -H -P -s 0:0,hostbridge \
+/usr/sbin/bhyve -c 1 -m 214 -u -H -P -s 0:0,hostbridge \
-s 3:0,virtio-net,faketapdev,mac=52:54:00:00:00:00 \
-s 2:0,ahci-hd,/tmp/freebsd.img \
-s 1,lpc -l com1,/dev/nmdm0A bhyve
-/usr/sbin/bhyve -c 1 -m 214 -H -P -s 0:0,hostbridge \
+/usr/sbin/bhyve -c 1 -m 214 -u -H -P -s 0:0,hostbridge \
-s 3:0,virtio-net,faketapdev,mac=52:54:00:00:00:00 \
-s 2:0,ahci-hd,/tmp/freebsd.img bhyve
-/usr/sbin/bhyve -c 1 -m 214 -H -P -s 0:0,hostbridge \
+/usr/sbin/bhyve -c 1 -m 214 -u -H -P -s 0:0,hostbridge \
-s 3:0,virtio-net,faketapdev,mac=52:54:00:00:00:00 \
-s 2:0,ahci-cd,/tmp/cdrom.iso bhyve
-/usr/sbin/bhyve -c 1 -m 214 -H -P -s 0:0,hostbridge \
+/usr/sbin/bhyve -c 1 -m 214 -u -H -P -s 0:0,hostbridge \
-s 3:0,virtio-net,faketapdev,mac=52:54:00:00:00:00 \
-s 2:0,ahci-cd,/tmp/cdrom.iso bhyve
-/usr/sbin/bhyve -c 1 -m 214 -H -P -s 0:0,hostbridge \
+/usr/sbin/bhyve -c 1 -m 214 -u -H -P -s 0:0,hostbridge \
-s 3:0,virtio-net,faketapdev,mac=52:54:00:00:00:00 \
-s 2:0,virtio-blk,/tmp/freebsd.img bhyve
-/usr/sbin/bhyve -c 1 -m 214 -H -P -s 0:0,hostbridge \
+/usr/sbin/bhyve -c 1 -m 214 -u -H -P -s 0:0,hostbridge \
-s 3:0,virtio-net,faketapdev,mac=52:54:00:00:00:00 \
-s 2:0,ahci-hd,/tmp/freebsd1.img \
-s 2:0,ahci-hd,/tmp/freebsd2.img \
-/usr/sbin/bhyve -c 1 -m 214 -H -P -s 0:0,hostbridge \
+/usr/sbin/bhyve -c 1 -m 214 -u -H -P -s 0:0,hostbridge \
-s 3:0,virtio-net,faketapdev,mac=52:54:00:00:00:00 \
-s 2:0,ahci-hd,/tmp/freebsd1.img \
-s 2:0,ahci-hd,/tmp/freebsd2.img \
-/usr/sbin/bhyve -c 1 -m 214 -H -P -s 0:0,hostbridge \
+/usr/sbin/bhyve -c 1 -m 214 -u -H -P -s 0:0,hostbridge \
-s 3:0,virtio-net,faketapdev,mac=52:54:00:00:00:00 \
-s 2:0,ahci-hd,/tmp/freebsd.img bhyve
--- /dev/null
+/usr/sbin/bhyve -c 1 -m 214 -H -P -s 0:0,hostbridge \
+-s 3:0,virtio-net,faketapdev,mac=52:54:00:00:00:00 \
+-s 2:0,ahci-hd,/tmp/freebsd.img bhyve
--- /dev/null
+/usr/sbin/bhyveload -m 214 -d /tmp/freebsd.img bhyve
--- /dev/null
+<domain type='bhyve'>
+ <name>bhyve</name>
+ <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
+ <memory>219136</memory>
+ <vcpu>1</vcpu>
+ <os>
+ <type>hvm</type>
+ </os>
+ <clock offset='localtime'/>
+ <devices>
+ <disk type='file'>
+ <driver name='file' type='raw'/>
+ <source file='/tmp/freebsd.img'/>
+ <target dev='hda' bus='sata'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+ </disk>
+ <interface type='bridge'>
+ <model type='virtio'/>
+ <source bridge="virbr0"/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </interface>
+ </devices>
+</domain>
-/usr/sbin/bhyve -c 1 -m 214 -H -P -s 0:0,hostbridge \
+/usr/sbin/bhyve -c 1 -m 214 -u -H -P -s 0:0,hostbridge \
-s 3:0,virtio-net,faketapdev,mac=52:54:00:22:ee:11 \
-s 2:0,ahci-hd,/tmp/freebsd.img bhyve
-/usr/sbin/bhyve -c 1 -m 214 -H -P -s 0:0,hostbridge \
+/usr/sbin/bhyve -c 1 -m 214 -u -H -P -s 0:0,hostbridge \
-s 3:0,virtio-net,faketapdev,mac=52:54:00:00:00:00 \
-s 2:0,ahci-hd,/tmp/freebsd.img \
-s 1,lpc -l com1,/dev/nmdm0A bhyve
-/usr/sbin/bhyve -c 1 -m 214 -H -P -s 0:0,hostbridge \
+/usr/sbin/bhyve -c 1 -m 214 -u -H -P -s 0:0,hostbridge \
-s 3:0,virtio-net,faketapdev,mac=52:54:00:00:00:00 \
-s 2:0,ahci-hd,/tmp/freebsd.img \
-s 1,lpc -l com1,/dev/nmdm0A bhyve
-/usr/sbin/bhyve -c 1 -m 214 -H -P -s 0:0,hostbridge \
+/usr/sbin/bhyve -c 1 -m 214 -u -H -P -s 0:0,hostbridge \
-s 3:0,virtio-net,faketapdev,mac=52:54:00:00:00:00 \
-s 2:0,ahci-hd,/tmp/freebsd.img \
-s 1,lpc -l com1,/dev/nmdm0A bhyve
} while (0)
driver.grubcaps = BHYVE_GRUB_CAP_CONSDEV;
+ driver.bhyvecaps = BHYVE_CAP_RTC_UTC;
DO_TEST("base");
DO_TEST("acpiapic");
DO_TEST("custom-loader");
DO_TEST("disk-cdrom-grub");
DO_TEST("serial-grub");
+ DO_TEST("localtime");
driver.grubcaps = 0;