diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c index 3a558793db0538b32fd69ff01be9713fcd1998c7..d2970a2315feecefd195bc1fe6967fbd250f54b1 100644 --- a/src/bhyve/bhyve_capabilities.c +++ b/src/bhyve/bhyve_capabilities.c @@ -141,3 +141,34 @@ virBhyveProbeGrubCaps(virBhyveGrubCapsFlags *caps) 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; +} diff --git a/src/bhyve/bhyve_capabilities.h b/src/bhyve/bhyve_capabilities.h index ccd8eb6cf23c3d946928afe60af04a13725d3e31..0eb22a40de7e09905108c8d176dde4894e545a33 100644 --- a/src/bhyve/bhyve_capabilities.h +++ b/src/bhyve/bhyve_capabilities.h @@ -31,6 +31,11 @@ typedef enum { BHYVE_GRUB_CAP_CONSDEV = 1, } virBhyveGrubCapsFlags; +typedef enum { + BHYVE_CAP_RTC_UTC = 1, +} virBhyveCapsFlags; + int virBhyveProbeGrubCaps(virBhyveGrubCapsFlags *caps); +int virBhyveProbeCaps(unsigned int *caps); #endif diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index 5e31ca6434b8117348d582ee3ebe1d9cc2013121..65760299288b08d71c83a0312d4607ec986aa93e 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -245,6 +245,27 @@ virBhyveProcessBuildBhyveCmd(virConnectPtr conn, 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. diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index 85b7c8f537def78283a27475ed2ae61497f45d8d..7f365b1f24467893ce7db7d2d14a51488384fb74 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -1181,6 +1181,9 @@ bhyveStateInitialize(bool privileged, if (!(bhyve_driver->caps = virBhyveCapsBuild())) goto cleanup; + if (virBhyveProbeCaps(&bhyve_driver->bhyvecaps) < 0) + goto cleanup; + if (virBhyveProbeGrubCaps(&bhyve_driver->grubcaps) < 0) goto cleanup; @@ -1239,6 +1242,16 @@ bhyveStateInitialize(bool privileged, return -1; } +unsigned +bhyveDriverGetCaps(virConnectPtr conn) +{ + bhyveConnPtr driver = conn->privateData; + + if (driver != NULL) + return driver->bhyvecaps; + return 0; +} + unsigned bhyveDriverGetGrubCaps(virConnectPtr conn) { diff --git a/src/bhyve/bhyve_driver.h b/src/bhyve/bhyve_driver.h index af2424ad3d1c760b4775bf0851c3fb87e0e40726..221d5a0566ac342863c18b2fbb60da57a1d04640 100644 --- a/src/bhyve/bhyve_driver.h +++ b/src/bhyve/bhyve_driver.h @@ -25,6 +25,8 @@ int bhyveRegister(void); +unsigned bhyveDriverGetCaps(virConnectPtr conn); + unsigned bhyveDriverGetGrubCaps(virConnectPtr conn); #endif /* __BHYVE_DRIVER_H__ */ diff --git a/src/bhyve/bhyve_utils.h b/src/bhyve/bhyve_utils.h index bbaa3a35fa578d9a428e73efdd76733fa8f8dbd1..4bccdccd970528fcebfb80bf28b58f83b2453e06 100644 --- a/src/bhyve/bhyve_utils.h +++ b/src/bhyve/bhyve_utils.h @@ -46,6 +46,7 @@ struct _bhyveConn { virCloseCallbacksPtr closeCallbacks; + unsigned bhyvecaps; unsigned grubcaps; }; diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-acpiapic.args b/tests/bhyvexml2argvdata/bhyvexml2argv-acpiapic.args index 79f8e88613df4a31bcc88a86d1cefbd14525eb39..6b269648129f1f0c324f74c19fe0d45d23c36590 100644 --- a/tests/bhyvexml2argvdata/bhyvexml2argv-acpiapic.args +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-acpiapic.args @@ -1,3 +1,3 @@ -/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 diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-base.args b/tests/bhyvexml2argvdata/bhyvexml2argv-base.args index 4122e627b0abc8223052985969bf688e4058fb80..118735e1f44ebd631ccb59b46753a5821e7cabcc 100644 --- a/tests/bhyvexml2argvdata/bhyvexml2argv-base.args +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-base.args @@ -1,3 +1,3 @@ -/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 diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.args b/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.args index 4122e627b0abc8223052985969bf688e4058fb80..118735e1f44ebd631ccb59b46753a5821e7cabcc 100644 --- a/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.args +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.args @@ -1,3 +1,3 @@ -/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 diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-console.args b/tests/bhyvexml2argvdata/bhyvexml2argv-console.args index df502902142b64c5d7a8afea5cd9ea7b3634a215..311977705b1140bde2c1038676ed2a287462cf20 100644 --- a/tests/bhyvexml2argvdata/bhyvexml2argv-console.args +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-console.args @@ -1,4 +1,4 @@ -/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 diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.args b/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.args index 4122e627b0abc8223052985969bf688e4058fb80..118735e1f44ebd631ccb59b46753a5821e7cabcc 100644 --- a/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.args +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.args @@ -1,3 +1,3 @@ -/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 diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.args b/tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.args index eb38969e12d2e5251dabec80e7e3560d306ce5f6..2b1281f06f2e704661c0419ac4c457a644b7ef44 100644 --- a/tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.args +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.args @@ -1,3 +1,3 @@ -/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 diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom.args b/tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom.args index eb38969e12d2e5251dabec80e7e3560d306ce5f6..2b1281f06f2e704661c0419ac4c457a644b7ef44 100644 --- a/tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom.args +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom.args @@ -1,3 +1,3 @@ -/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 diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-disk-virtio.args b/tests/bhyvexml2argvdata/bhyvexml2argv-disk-virtio.args index 1638d540b42b21cc2a72abe1fe6d1a9cc1b1daa9..da0577c186ad97539d4519d166c494de02d6d692 100644 --- a/tests/bhyvexml2argvdata/bhyvexml2argv-disk-virtio.args +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-disk-virtio.args @@ -1,3 +1,3 @@ -/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 diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-grub-bootorder.args b/tests/bhyvexml2argvdata/bhyvexml2argv-grub-bootorder.args index eaba3708a1a586d8281bdf90541ee5684e29d7e6..fc0522de18c553c942a47340298bf09c26dab9fb 100644 --- a/tests/bhyvexml2argvdata/bhyvexml2argv-grub-bootorder.args +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-grub-bootorder.args @@ -1,4 +1,4 @@ -/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 \ diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-grub-bootorder2.args b/tests/bhyvexml2argvdata/bhyvexml2argv-grub-bootorder2.args index eaba3708a1a586d8281bdf90541ee5684e29d7e6..fc0522de18c553c942a47340298bf09c26dab9fb 100644 --- a/tests/bhyvexml2argvdata/bhyvexml2argv-grub-bootorder2.args +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-grub-bootorder2.args @@ -1,4 +1,4 @@ -/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 \ diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-grub-defaults.args b/tests/bhyvexml2argvdata/bhyvexml2argv-grub-defaults.args index 4122e627b0abc8223052985969bf688e4058fb80..118735e1f44ebd631ccb59b46753a5821e7cabcc 100644 --- a/tests/bhyvexml2argvdata/bhyvexml2argv-grub-defaults.args +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-grub-defaults.args @@ -1,3 +1,3 @@ -/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 diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-localtime.args b/tests/bhyvexml2argvdata/bhyvexml2argv-localtime.args new file mode 100644 index 0000000000000000000000000000000000000000..4122e627b0abc8223052985969bf688e4058fb80 --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-localtime.args @@ -0,0 +1,3 @@ +/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 diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-localtime.ldargs b/tests/bhyvexml2argvdata/bhyvexml2argv-localtime.ldargs new file mode 100644 index 0000000000000000000000000000000000000000..215d65fb25dc8b6c06572408515f3f3059e1ac96 --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-localtime.ldargs @@ -0,0 +1 @@ +/usr/sbin/bhyveload -m 214 -d /tmp/freebsd.img bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-localtime.xml b/tests/bhyvexml2argvdata/bhyvexml2argv-localtime.xml new file mode 100644 index 0000000000000000000000000000000000000000..f62c6261c9cee851d54c4d0c15b2c0cce2670450 --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-localtime.xml @@ -0,0 +1,23 @@ + + bhyve + df3be7e7-a104-11e3-aeb0-50e5492bd3dc + 219136 + 1 + + hvm + + + + + + + +
+ + + + +
+ + + diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-macaddr.args b/tests/bhyvexml2argvdata/bhyvexml2argv-macaddr.args index f91486502e4a0bfb8e17bfcfad8654ca874af530..77c3a17ba26697a82c3d17cb9981a52737d3cc4c 100644 --- a/tests/bhyvexml2argvdata/bhyvexml2argv-macaddr.args +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-macaddr.args @@ -1,3 +1,3 @@ -/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 diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.args b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.args index df502902142b64c5d7a8afea5cd9ea7b3634a215..311977705b1140bde2c1038676ed2a287462cf20 100644 --- a/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.args +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.args @@ -1,4 +1,4 @@ -/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 diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.args b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.args index df502902142b64c5d7a8afea5cd9ea7b3634a215..311977705b1140bde2c1038676ed2a287462cf20 100644 --- a/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.args +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.args @@ -1,4 +1,4 @@ -/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 diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-serial.args b/tests/bhyvexml2argvdata/bhyvexml2argv-serial.args index df502902142b64c5d7a8afea5cd9ea7b3634a215..311977705b1140bde2c1038676ed2a287462cf20 100644 --- a/tests/bhyvexml2argvdata/bhyvexml2argv-serial.args +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-serial.args @@ -1,4 +1,4 @@ -/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 diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c index fa6f87f8c68c675e07d1e49313baf96ba5098c48..3e57a78e101bc5da5ad3c1d725c5485c31cd1798 100644 --- a/tests/bhyvexml2argvtest.c +++ b/tests/bhyvexml2argvtest.c @@ -118,6 +118,7 @@ mymain(void) } while (0) driver.grubcaps = BHYVE_GRUB_CAP_CONSDEV; + driver.bhyvecaps = BHYVE_CAP_RTC_UTC; DO_TEST("base"); DO_TEST("acpiapic"); @@ -133,6 +134,7 @@ mymain(void) DO_TEST("custom-loader"); DO_TEST("disk-cdrom-grub"); DO_TEST("serial-grub"); + DO_TEST("localtime"); driver.grubcaps = 0;