[libvirt] [PATCH v2 00/12] Various bhyve driver improvements for FreeBSD

The main changes are: * Add support for standard hooks in bhyve backend: - prepare - start - started - stopped - release * Some code cleanup & general housekeeping in bhyve backend * Add support for reboot in bhyve backend, both from within the VM and from the host Ryan Moeller (12): Add hooks for bhyve backend Fix build errors on FreeBSD Simplify bhyve driver caps helpers Remove redundant parameter to virBhyveProcessStart() Factor out conn Fix indentation Eliminate rc variable Make bhyveMonitor a virClass Don't bother seeking to the end of a file opened O_APPEND Add reboot support for bhyve backend Fix bhyvexml2argvtest Add missing virtlogd.init for OpenRC src/bhyve/bhyve_command.c | 40 ++++----- src/bhyve/bhyve_command.h | 4 +- src/bhyve/bhyve_driver.c | 67 ++++++++++---- src/bhyve/bhyve_driver.h | 4 +- src/bhyve/bhyve_monitor.c | 165 +++++++++++++++++++++++------------ src/bhyve/bhyve_monitor.h | 2 + src/bhyve/bhyve_process.c | 106 +++++++++++++++------- src/bhyve/bhyve_process.h | 4 +- src/conf/virnetworkobj.c | 7 +- src/logging/Makefile.inc.am | 10 +++ src/logging/virtlogd.init.in | 14 +++ src/util/virhook.c | 15 ++++ src/util/virhook.h | 11 +++ tests/bhyvexml2argvtest.c | 4 +- 14 files changed, 319 insertions(+), 134 deletions(-) create mode 100644 src/logging/virtlogd.init.in -- 2.23.0

From: Ryan Moeller <ryan@freqlabs.com> Don't free the file string until after it has been used to print the error message. Simplify PCI bus parsing to eliminate an unannotated switch fallthrough. Signed-off-by: Ryan Moeller <ryan@iXsystems.com> --- src/conf/virnetworkobj.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c index 5daf4a8cb1..5c45f49be0 100644 --- a/src/conf/virnetworkobj.c +++ b/src/conf/virnetworkobj.c @@ -1895,13 +1895,14 @@ virNetworkObjLoadAllPorts(virNetworkObjPtr net, file = g_strdup_printf("%s/%s.xml", dir, de->d_name); portdef = virNetworkPortDefParseFile(file); - VIR_FREE(file); - file = NULL; - if (!portdef) { VIR_WARN("Cannot parse port %s", file); + VIR_FREE(file); + file = NULL; continue; } + VIR_FREE(file); + file = NULL; virUUIDFormat(portdef->uuid, uuidstr); if (virHashAddEntry(net->ports, uuidstr, portdef) < 0) -- 2.23.0

On Thu, Jan 02, 2020 at 05:46:25PM +0000, Ryan Moeller wrote:
From: Ryan Moeller <ryan@freqlabs.com>
Don't free the file string until after it has been used to print the error message.
Simplify PCI bus parsing to eliminate an unannotated switch fallthrough.
Signed-off-by: Ryan Moeller <ryan@iXsystems.com> --- src/conf/virnetworkobj.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

On 1/2/20 12:46 PM, Ryan Moeller wrote:
From: Ryan Moeller <ryan@freqlabs.com>
Don't free the file string until after it has been used to print the error message.
Simplify PCI bus parsing to eliminate an unannotated switch fallthrough.
I don't think this^^^ comment belongs with this patch...
Signed-off-by: Ryan Moeller <ryan@iXsystems.com> --- src/conf/virnetworkobj.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c index 5daf4a8cb1..5c45f49be0 100644 --- a/src/conf/virnetworkobj.c +++ b/src/conf/virnetworkobj.c @@ -1895,13 +1895,14 @@ virNetworkObjLoadAllPorts(virNetworkObjPtr net, file = g_strdup_printf("%s/%s.xml", dir, de->d_name);
portdef = virNetworkPortDefParseFile(file); - VIR_FREE(file); - file = NULL; - if (!portdef) { VIR_WARN("Cannot parse port %s", file); + VIR_FREE(file); + file = NULL;
"file = NULL;" is superfluous, since it is already set to NULL by virFree() (which is called by VIR_FREE()).
continue; } + VIR_FREE(file); + file = NULL;
Same here.
virUUIDFormat(portdef->uuid, uuidstr); if (virHashAddEntry(net->ports, uuidstr, portdef) < 0)

Signed-off-by: Ryan Moeller <ryan@iXsystems.com> --- src/bhyve/bhyve_command.c | 40 +++++++++++++++++++-------------------- src/bhyve/bhyve_command.h | 4 ++-- src/bhyve/bhyve_driver.c | 21 +++++++++----------- src/bhyve/bhyve_driver.h | 4 ++-- src/bhyve/bhyve_process.c | 8 +++----- 5 files changed, 35 insertions(+), 42 deletions(-) diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index 48336ffa1b..c8424063b7 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -44,7 +44,7 @@ VIR_LOG_INIT("bhyve.bhyve_command"); static int -bhyveBuildNetArgStr(virConnectPtr conn, +bhyveBuildNetArgStr(bhyveConnPtr driver, const virDomainDef *def, virDomainNetDefPtr net, virCommandPtr cmd, @@ -60,7 +60,7 @@ bhyveBuildNetArgStr(virConnectPtr conn, if (net->model == VIR_DOMAIN_NET_MODEL_VIRTIO) { nic_model = g_strdup("virtio-net"); } else if (net->model == VIR_DOMAIN_NET_MODEL_E1000) { - if ((bhyveDriverGetCaps(conn) & BHYVE_CAP_NET_E1000) != 0) { + if ((bhyveDriverGetBhyveCaps(driver) & BHYVE_CAP_NET_E1000) != 0) { nic_model = g_strdup("e1000"); } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", @@ -166,7 +166,7 @@ bhyveBuildConsoleArgStr(const virDomainDef *def, virCommandPtr cmd) static int bhyveBuildAHCIControllerArgStr(const virDomainDef *def, virDomainControllerDefPtr controller, - virConnectPtr conn, + bhyveConnPtr driver, virCommandPtr cmd) { virBuffer buf = VIR_BUFFER_INITIALIZER; @@ -207,13 +207,13 @@ bhyveBuildAHCIControllerArgStr(const virDomainDef *def, switch (disk->device) { case VIR_DOMAIN_DISK_DEVICE_DISK: - if ((bhyveDriverGetCaps(conn) & BHYVE_CAP_AHCI32SLOT)) + if ((bhyveDriverGetBhyveCaps(driver) & BHYVE_CAP_AHCI32SLOT)) virBufferAsprintf(&device, ",hd:%s", disk_source); else virBufferAsprintf(&device, "-hd,%s", disk_source); break; case VIR_DOMAIN_DISK_DEVICE_CDROM: - if ((bhyveDriverGetCaps(conn) & BHYVE_CAP_AHCI32SLOT)) + if ((bhyveDriverGetBhyveCaps(driver) & BHYVE_CAP_AHCI32SLOT)) virBufferAsprintf(&device, ",cd:%s", disk_source); else virBufferAsprintf(&device, "-cd,%s", disk_source); @@ -322,7 +322,7 @@ static int bhyveBuildGraphicsArgStr(const virDomainDef *def, virDomainGraphicsDefPtr graphics, virDomainVideoDefPtr video, - virConnectPtr conn, + bhyveConnPtr driver, virCommandPtr cmd, bool dryRun) { @@ -331,9 +331,7 @@ bhyveBuildGraphicsArgStr(const virDomainDef *def, bool escapeAddr; unsigned short port; - bhyveConnPtr driver = conn->privateData; - - if (!(bhyveDriverGetCaps(conn) & BHYVE_CAP_LPC_BOOTROM) || + if (!(bhyveDriverGetBhyveCaps(driver) & BHYVE_CAP_LPC_BOOTROM) || def->os.bootloader || !def->os.loader) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", @@ -342,7 +340,7 @@ bhyveBuildGraphicsArgStr(const virDomainDef *def, return -1; } - if (!(bhyveDriverGetCaps(conn) & BHYVE_CAP_FBUF)) { + if (!(bhyveDriverGetBhyveCaps(driver) & BHYVE_CAP_FBUF)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Bhyve version does not support framebuffer")); return -1; @@ -433,7 +431,7 @@ bhyveBuildGraphicsArgStr(const virDomainDef *def, } virCommandPtr -virBhyveProcessBuildBhyveCmd(virConnectPtr conn, +virBhyveProcessBuildBhyveCmd(bhyveConnPtr driver, virDomainDefPtr def, bool dryRun) { /* @@ -461,7 +459,7 @@ virBhyveProcessBuildBhyveCmd(virConnectPtr conn, goto error; } - if ((bhyveDriverGetCaps(conn) & BHYVE_CAP_CPUTOPOLOGY) != 0) { + if ((bhyveDriverGetBhyveCaps(driver) & BHYVE_CAP_CPUTOPOLOGY) != 0) { virCommandAddArgFormat(cmd, "cpus=%d,sockets=%d,cores=%d,threads=%d", nvcpus, def->cpu->sockets, @@ -500,7 +498,7 @@ virBhyveProcessBuildBhyveCmd(virConnectPtr conn, /* used by default in bhyve */ break; case VIR_DOMAIN_CLOCK_OFFSET_UTC: - if ((bhyveDriverGetCaps(conn) & BHYVE_CAP_RTC_UTC) != 0) { + if ((bhyveDriverGetBhyveCaps(driver) & BHYVE_CAP_RTC_UTC) != 0) { virCommandAddArg(cmd, "-u"); } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", @@ -534,7 +532,7 @@ virBhyveProcessBuildBhyveCmd(virConnectPtr conn, if (def->os.bootloader == NULL && def->os.loader) { - if ((bhyveDriverGetCaps(conn) & BHYVE_CAP_LPC_BOOTROM)) { + if ((bhyveDriverGetBhyveCaps(driver) & BHYVE_CAP_LPC_BOOTROM)) { virCommandAddArg(cmd, "-l"); virCommandAddArgFormat(cmd, "bootrom,%s", def->os.loader->path); } else { @@ -557,7 +555,7 @@ virBhyveProcessBuildBhyveCmd(virConnectPtr conn, } break; case VIR_DOMAIN_CONTROLLER_TYPE_SATA: - if (bhyveBuildAHCIControllerArgStr(def, controller, conn, cmd) < 0) + if (bhyveBuildAHCIControllerArgStr(def, controller, driver, cmd) < 0) goto error; break; case VIR_DOMAIN_CONTROLLER_TYPE_USB: @@ -574,7 +572,7 @@ virBhyveProcessBuildBhyveCmd(virConnectPtr conn, } for (i = 0; i < def->nnets; i++) { virDomainNetDefPtr net = def->nets[i]; - if (bhyveBuildNetArgStr(conn, def, net, cmd, dryRun) < 0) + if (bhyveBuildNetArgStr(driver, def, net, cmd, dryRun) < 0) goto error; } for (i = 0; i < def->ndisks; i++) { @@ -598,7 +596,7 @@ virBhyveProcessBuildBhyveCmd(virConnectPtr conn, if (def->ngraphics && def->nvideos) { if (def->ngraphics == 1 && def->nvideos == 1) { if (bhyveBuildGraphicsArgStr(def, def->graphics[0], def->videos[0], - conn, cmd, dryRun) < 0) + driver, cmd, dryRun) < 0) goto error; } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", @@ -741,7 +739,7 @@ virBhyveFormatGrubDevice(virBufferPtr devicemap, virDomainDiskDefPtr def) static virCommandPtr virBhyveProcessBuildGrubbhyveCmd(virDomainDefPtr def, - virConnectPtr conn, + bhyveConnPtr driver, const char *devmap_file, char **devicesmap_out) { @@ -824,7 +822,7 @@ virBhyveProcessBuildGrubbhyveCmd(virDomainDefPtr def, virCommandAddArgFormat(cmd, "%llu", VIR_DIV_UP(virDomainDefGetMemoryInitial(def), 1024)); - if ((bhyveDriverGetGrubCaps(conn) & BHYVE_GRUB_CAP_CONSDEV) != 0 && + if ((bhyveDriverGetGrubCaps(driver) & BHYVE_GRUB_CAP_CONSDEV) != 0 && def->nserials > 0) { virDomainChrDefPtr chr; @@ -933,7 +931,7 @@ virBhyveGetBootDisk(virDomainDefPtr def) } virCommandPtr -virBhyveProcessBuildLoadCmd(virConnectPtr conn, virDomainDefPtr def, +virBhyveProcessBuildLoadCmd(bhyveConnPtr driver, virDomainDefPtr def, const char *devmap_file, char **devicesmap_out) { virDomainDiskDefPtr disk = NULL; @@ -946,7 +944,7 @@ virBhyveProcessBuildLoadCmd(virConnectPtr conn, virDomainDefPtr def, return virBhyveProcessBuildBhyveloadCmd(def, disk); } else if (strstr(def->os.bootloader, "grub-bhyve") != NULL) { - return virBhyveProcessBuildGrubbhyveCmd(def, conn, devmap_file, + return virBhyveProcessBuildGrubbhyveCmd(def, driver, devmap_file, devicesmap_out); } else { return virBhyveProcessBuildCustomLoaderCmd(def); diff --git a/src/bhyve/bhyve_command.h b/src/bhyve/bhyve_command.h index 8c39f4eb2f..5a934c4883 100644 --- a/src/bhyve/bhyve_command.h +++ b/src/bhyve/bhyve_command.h @@ -29,7 +29,7 @@ #define BHYVE_CONFIG_FORMAT_ARGV "bhyve-argv" -virCommandPtr virBhyveProcessBuildBhyveCmd(virConnectPtr conn, +virCommandPtr virBhyveProcessBuildBhyveCmd(bhyveConnPtr driver, virDomainDefPtr def, bool dryRun); @@ -38,5 +38,5 @@ virBhyveProcessBuildDestroyCmd(bhyveConnPtr driver, virDomainDefPtr def); virCommandPtr -virBhyveProcessBuildLoadCmd(virConnectPtr conn, virDomainDefPtr def, +virBhyveProcessBuildLoadCmd(bhyveConnPtr driver, virDomainDefPtr def, const char *devmap_file, char **devicesmap_out); diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index a764b4d4ed..760619a5a6 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -711,22 +711,22 @@ bhyveConnectDomainXMLToNative(virConnectPtr conn, goto cleanup; } - if ((bhyveDriverGetCaps(conn) & BHYVE_CAP_LPC_BOOTROM) == 0) { + if ((bhyveDriverGetBhyveCaps(privconn) & BHYVE_CAP_LPC_BOOTROM) == 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Installed bhyve binary does not support " "bootrom")); goto cleanup; } } else { - if (!(loadcmd = virBhyveProcessBuildLoadCmd(conn, def, "<device.map>", - NULL))) + if (!(loadcmd = virBhyveProcessBuildLoadCmd(privconn, def, + "<device.map>", NULL))) goto cleanup; virBufferAdd(&buf, virCommandToString(loadcmd, false), -1); virBufferAddChar(&buf, '\n'); } - if (!(cmd = virBhyveProcessBuildBhyveCmd(conn, def, true))) + if (!(cmd = virBhyveProcessBuildBhyveCmd(privconn, def, true))) goto cleanup; virBufferAdd(&buf, virCommandToString(cmd, false), -1); @@ -1276,20 +1276,16 @@ bhyveStateInitialize(bool privileged, } unsigned -bhyveDriverGetCaps(virConnectPtr conn) +bhyveDriverGetBhyveCaps(bhyveConnPtr driver) { - bhyveConnPtr driver = conn->privateData; - if (driver != NULL) return driver->bhyvecaps; return 0; } unsigned -bhyveDriverGetGrubCaps(virConnectPtr conn) +bhyveDriverGetGrubCaps(bhyveConnPtr driver) { - bhyveConnPtr driver = conn->privateData; - if (driver != NULL) return driver->grubcaps; return 0; @@ -1537,7 +1533,7 @@ bhyveConnectDomainXMLFromNative(virConnectPtr conn, char *xml = NULL; virDomainDefPtr def = NULL; bhyveConnPtr privconn = conn->privateData; - unsigned caps = bhyveDriverGetCaps(conn); + unsigned bhyveCaps = bhyveDriverGetBhyveCaps(privconn); virCheckFlags(0, NULL); @@ -1550,7 +1546,8 @@ bhyveConnectDomainXMLFromNative(virConnectPtr conn, goto cleanup; } - def = bhyveParseCommandLineString(nativeConfig, caps, privconn->xmlopt); + def = bhyveParseCommandLineString(nativeConfig, bhyveCaps, + privconn->xmlopt); if (def == NULL) goto cleanup; diff --git a/src/bhyve/bhyve_driver.h b/src/bhyve/bhyve_driver.h index 98e75039a3..75a63e0233 100644 --- a/src/bhyve/bhyve_driver.h +++ b/src/bhyve/bhyve_driver.h @@ -25,8 +25,8 @@ int bhyveRegister(void); -unsigned bhyveDriverGetCaps(virConnectPtr conn); +unsigned bhyveDriverGetBhyveCaps(bhyveConnPtr driver); -unsigned bhyveDriverGetGrubCaps(virConnectPtr conn); +unsigned bhyveDriverGetGrubCaps(bhyveConnPtr driver); virCapsPtr bhyveDriverGetCapabilities(bhyveConnPtr driver); diff --git a/src/bhyve/bhyve_process.c b/src/bhyve/bhyve_process.c index d9815851de..bddd4e9461 100644 --- a/src/bhyve/bhyve_process.c +++ b/src/bhyve/bhyve_process.c @@ -164,9 +164,7 @@ virBhyveProcessStart(virConnectPtr conn, goto cleanup; /* Call bhyve to start the VM */ - if (!(cmd = virBhyveProcessBuildBhyveCmd(conn, - vm->def, - false))) + if (!(cmd = virBhyveProcessBuildBhyveCmd(driver, vm->def, false))) goto cleanup; virCommandSetOutputFD(cmd, &logfd); @@ -182,8 +180,8 @@ virBhyveProcessStart(virConnectPtr conn, virBhyveFormatDevMapFile(vm->def->name, &devmap_file); - if (!(load_cmd = virBhyveProcessBuildLoadCmd(conn, vm->def, devmap_file, - &devicemap))) + if (!(load_cmd = virBhyveProcessBuildLoadCmd(driver, vm->def, + devmap_file, &devicemap))) goto cleanup; virCommandSetOutputFD(load_cmd, &logfd); virCommandSetErrorFD(load_cmd, &logfd); -- 2.23.0

On Thu, Jan 02, 2020 at 05:46:26PM +0000, Ryan Moeller wrote:
Signed-off-by: Ryan Moeller <ryan@iXsystems.com> --- src/bhyve/bhyve_command.c | 40 +++++++++++++++++++-------------------- src/bhyve/bhyve_command.h | 4 ++-- src/bhyve/bhyve_driver.c | 21 +++++++++----------- src/bhyve/bhyve_driver.h | 4 ++-- src/bhyve/bhyve_process.c | 8 +++----- 5 files changed, 35 insertions(+), 42 deletions(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

Signed-off-by: Ryan Moeller <ryan@iXsystems.com> --- src/bhyve/bhyve_driver.c | 6 +++--- src/bhyve/bhyve_process.c | 16 +++++++--------- src/bhyve/bhyve_process.h | 1 - 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index 760619a5a6..d591ff63e3 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -89,7 +89,7 @@ bhyveAutostartDomain(virDomainObjPtr vm, void *opaque) virObjectLock(vm); if (vm->autostart && !virDomainObjIsActive(vm)) { virResetLastError(); - ret = virBhyveProcessStart(data->conn, data->driver, vm, + ret = virBhyveProcessStart(data->conn, vm, VIR_DOMAIN_RUNNING_BOOTED, 0); if (ret < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -862,7 +862,7 @@ bhyveDomainCreateWithFlags(virDomainPtr dom, goto cleanup; } - ret = virBhyveProcessStart(dom->conn, privconn, vm, + ret = virBhyveProcessStart(dom->conn, vm, VIR_DOMAIN_RUNNING_BOOTED, start_flags); @@ -921,7 +921,7 @@ bhyveDomainCreateXML(virConnectPtr conn, goto cleanup; def = NULL; - if (virBhyveProcessStart(conn, privconn, vm, + if (virBhyveProcessStart(conn, vm, VIR_DOMAIN_RUNNING_BOOTED, start_flags) < 0) { /* If domain is not persistent, remove its data */ diff --git a/src/bhyve/bhyve_process.c b/src/bhyve/bhyve_process.c index bddd4e9461..9352baf172 100644 --- a/src/bhyve/bhyve_process.c +++ b/src/bhyve/bhyve_process.c @@ -113,7 +113,6 @@ bhyveProcessStopHook(virDomainObjPtr vm, virHookBhyveOpType op) int virBhyveProcessStart(virConnectPtr conn, - bhyveConnPtr driver, virDomainObjPtr vm, virDomainRunningReason reason, unsigned int flags) @@ -126,12 +125,11 @@ virBhyveProcessStart(virConnectPtr conn, char ebuf[1024]; virCommandPtr cmd = NULL; virCommandPtr load_cmd = NULL; - bhyveConnPtr privconn = conn->privateData; + bhyveConnPtr driver = conn->privateData; bhyveDomainObjPrivatePtr priv = vm->privateData; int ret = -1, rc; logfile = g_strdup_printf("%s/%s.log", BHYVE_LOG_DIR, vm->def->name); - if ((logfd = open(logfile, O_WRONLY | O_APPEND | O_CREAT, S_IRUSR | S_IWUSR)) < 0) { virReportSystemError(errno, @@ -140,19 +138,19 @@ virBhyveProcessStart(virConnectPtr conn, goto cleanup; } - VIR_FREE(privconn->pidfile); - if (!(privconn->pidfile = virPidFileBuildPath(BHYVE_STATE_DIR, + VIR_FREE(driver->pidfile); + if (!(driver->pidfile = virPidFileBuildPath(BHYVE_STATE_DIR, vm->def->name))) { virReportSystemError(errno, "%s", _("Failed to build pidfile path")); goto cleanup; } - if (unlink(privconn->pidfile) < 0 && + if (unlink(driver->pidfile) < 0 && errno != ENOENT) { virReportSystemError(errno, _("Cannot remove state PID file %s"), - privconn->pidfile); + driver->pidfile); goto cleanup; } @@ -170,7 +168,7 @@ virBhyveProcessStart(virConnectPtr conn, virCommandSetOutputFD(cmd, &logfd); virCommandSetErrorFD(cmd, &logfd); virCommandWriteArgLog(cmd, logfd); - virCommandSetPidFile(cmd, privconn->pidfile); + virCommandSetPidFile(cmd, driver->pidfile); virCommandDaemonize(cmd); if (vm->def->os.loader == NULL) { @@ -215,7 +213,7 @@ virBhyveProcessStart(virConnectPtr conn, if (virCommandRun(cmd, NULL) < 0) goto cleanup; - if (virPidFileReadPath(privconn->pidfile, &vm->pid) < 0) { + if (virPidFileReadPath(driver->pidfile, &vm->pid) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Domain %s didn't show up"), vm->def->name); goto cleanup; diff --git a/src/bhyve/bhyve_process.h b/src/bhyve/bhyve_process.h index 4f62f6be4b..8419e44faa 100644 --- a/src/bhyve/bhyve_process.h +++ b/src/bhyve/bhyve_process.h @@ -24,7 +24,6 @@ #include "bhyve_utils.h" int virBhyveProcessStart(virConnectPtr conn, - bhyveConnPtr driver, virDomainObjPtr vm, virDomainRunningReason reason, unsigned int flags); -- 2.23.0

On Thu, Jan 02, 2020 at 05:46:27PM +0000, Ryan Moeller wrote:
Signed-off-by: Ryan Moeller <ryan@iXsystems.com> --- src/bhyve/bhyve_driver.c | 6 +++--- src/bhyve/bhyve_process.c | 16 +++++++--------- src/bhyve/bhyve_process.h | 1 - 3 files changed, 10 insertions(+), 13 deletions(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
@@ -140,19 +138,19 @@ virBhyveProcessStart(virConnectPtr conn, goto cleanup; }
- VIR_FREE(privconn->pidfile); - if (!(privconn->pidfile = virPidFileBuildPath(BHYVE_STATE_DIR, + VIR_FREE(driver->pidfile); + if (!(driver->pidfile = virPidFileBuildPath(BHYVE_STATE_DIR, vm->def->name))) {
Indent is off here. Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

Signed-off-by: Ryan Moeller <ryan@iXsystems.com> --- src/bhyve/bhyve_driver.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index d591ff63e3..a862921c87 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -947,7 +947,8 @@ bhyveDomainCreateXML(virConnectPtr conn, static int bhyveDomainDestroyFlags(virDomainPtr dom, unsigned int flags) { - bhyveConnPtr privconn = dom->conn->privateData; + virConnectPtr conn = dom->conn; + bhyveConnPtr privconn = conn->privateData; virDomainObjPtr vm; virObjectEventPtr event = NULL; int ret = -1; @@ -957,7 +958,7 @@ bhyveDomainDestroyFlags(virDomainPtr dom, unsigned int flags) if (!(vm = bhyveDomObjFromDomain(dom))) goto cleanup; - if (virDomainDestroyFlagsEnsureACL(dom->conn, vm->def) < 0) + if (virDomainDestroyFlagsEnsureACL(conn, vm->def) < 0) goto cleanup; if (virDomainObjCheckActive(vm) < 0) @@ -1061,7 +1062,8 @@ bhyveDomainSetMetadata(virDomainPtr dom, const char *uri, unsigned int flags) { - bhyveConnPtr privconn = dom->conn->privateData; + virConnectPtr conn = dom->conn; + bhyveConnPtr privconn = conn->privateData; virDomainObjPtr vm; int ret = -1; @@ -1071,7 +1073,7 @@ bhyveDomainSetMetadata(virDomainPtr dom, if (!(vm = bhyveDomObjFromDomain(dom))) return -1; - if (virDomainSetMetadataEnsureACL(dom->conn, vm->def, flags) < 0) + if (virDomainSetMetadataEnsureACL(conn, vm->def, flags) < 0) goto cleanup; ret = virDomainObjSetMetadata(vm, type, metadata, key, uri, -- 2.23.0

On Thu, Jan 02, 2020 at 05:46:28PM +0000, Ryan Moeller wrote:
Signed-off-by: Ryan Moeller <ryan@iXsystems.com> --- src/bhyve/bhyve_driver.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

Signed-off-by: Ryan Moeller <ryan@iXsystems.com> --- src/bhyve/bhyve_monitor.c | 4 ++-- src/bhyve/bhyve_process.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bhyve/bhyve_monitor.c b/src/bhyve/bhyve_monitor.c index ad6977e562..b9ad4520d9 100644 --- a/src/bhyve/bhyve_monitor.c +++ b/src/bhyve/bhyve_monitor.c @@ -77,8 +77,8 @@ bhyveMonitorIO(int watch, int kq, int events G_GNUC_UNUSED, void *opaque) if (kev.filter == EVFILT_PROC && (kev.fflags & NOTE_EXIT) != 0) { if ((pid_t)kev.ident != vm->pid) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("event from unexpected proc %ju!=%ju"), - (uintmax_t)vm->pid, (uintmax_t)kev.ident); + _("event from unexpected proc %ju!=%ju"), + (uintmax_t)vm->pid, (uintmax_t)kev.ident); return; } diff --git a/src/bhyve/bhyve_process.c b/src/bhyve/bhyve_process.c index 9352baf172..4da2a702e6 100644 --- a/src/bhyve/bhyve_process.c +++ b/src/bhyve/bhyve_process.c @@ -140,7 +140,7 @@ virBhyveProcessStart(virConnectPtr conn, VIR_FREE(driver->pidfile); if (!(driver->pidfile = virPidFileBuildPath(BHYVE_STATE_DIR, - vm->def->name))) { + vm->def->name))) { virReportSystemError(errno, "%s", _("Failed to build pidfile path")); goto cleanup; -- 2.23.0

On Thu, Jan 02, 2020 at 05:46:29PM +0000, Ryan Moeller wrote:
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
BTW, is it intentional that you have capital 'X' here, but not in your email From headers ?
--- src/bhyve/bhyve_monitor.c | 4 ++-- src/bhyve/bhyve_process.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

Signed-off-by: Ryan Moeller <ryan@iXsystems.com> --- src/bhyve/bhyve_monitor.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/bhyve/bhyve_monitor.c b/src/bhyve/bhyve_monitor.c index b9ad4520d9..0e55e19772 100644 --- a/src/bhyve/bhyve_monitor.c +++ b/src/bhyve/bhyve_monitor.c @@ -130,7 +130,6 @@ bhyveMonitorOpen(virDomainObjPtr vm, bhyveConnPtr driver) { bhyveMonitorPtr mon = NULL; struct kevent kev; - int rc; if (VIR_ALLOC(mon) < 0) return NULL; @@ -145,8 +144,7 @@ bhyveMonitorOpen(virDomainObjPtr vm, bhyveConnPtr driver) } EV_SET(&kev, vm->pid, EVFILT_PROC, EV_ADD, NOTE_EXIT, 0, mon); - rc = kevent(mon->kq, &kev, 1, NULL, 0, NULL); - if (rc < 0) { + if (kevent(mon->kq, &kev, 1, NULL, 0, NULL) < 0) { virReportError(VIR_ERR_SYSTEM_ERROR, "%s", _("Unable to register process kevent")); goto cleanup; -- 2.23.0

On Thu, Jan 02, 2020 at 05:46:30PM +0000, Ryan Moeller wrote:
Signed-off-by: Ryan Moeller <ryan@iXsystems.com> --- src/bhyve/bhyve_monitor.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

Signed-off-by: Ryan Moeller <ryan@iXsystems.com> --- src/bhyve/bhyve_monitor.c | 144 ++++++++++++++++++++++++++------------ 1 file changed, 98 insertions(+), 46 deletions(-) diff --git a/src/bhyve/bhyve_monitor.c b/src/bhyve/bhyve_monitor.c index 0e55e19772..566c672ba0 100644 --- a/src/bhyve/bhyve_monitor.c +++ b/src/bhyve/bhyve_monitor.c @@ -32,24 +32,82 @@ #include "virerror.h" #include "virfile.h" #include "virlog.h" +#include "virobject.h" #define VIR_FROM_THIS VIR_FROM_BHYVE VIR_LOG_INIT("bhyve.bhyve_monitor"); struct _bhyveMonitor { + virObject parent; + int kq; int watch; bhyveConnPtr driver; + virDomainObjPtr vm; }; +static virClassPtr bhyveMonitorClass; + +static void +bhyveMonitorDispose(void *obj) +{ + bhyveMonitorPtr mon = obj; + + VIR_FORCE_CLOSE(mon->kq); + virObjectUnref(mon->vm); +} + +static int +bhyveMonitorOnceInit(void) +{ + if (!VIR_CLASS_NEW(bhyveMonitor, virClassForObject())) + return -1; + + return 0; +} + +VIR_ONCE_GLOBAL_INIT(bhyveMonitor); + +static void bhyveMonitorIO(int, int, int, void *); + +static bool +bhyveMonitorRegister(bhyveMonitorPtr mon) +{ + virObjectRef(mon); + mon->watch = virEventAddHandle(mon->kq, + VIR_EVENT_HANDLE_READABLE | + VIR_EVENT_HANDLE_ERROR | + VIR_EVENT_HANDLE_HANGUP, + bhyveMonitorIO, + mon, + virObjectFreeCallback); + if (mon->watch < 0) { + VIR_DEBUG("failed to add event handle for mon %p", mon); + virObjectUnref(mon); + return false; + } + return true; +} + +static void +bhyveMonitorUnregister(bhyveMonitorPtr mon) +{ + if (mon->watch < 0) + return; + + virEventRemoveHandle(mon->watch); + mon->watch = -1; +} + static void bhyveMonitorIO(int watch, int kq, int events G_GNUC_UNUSED, void *opaque) { const struct timespec zerowait = { 0, 0 }; - virDomainObjPtr vm = opaque; - bhyveDomainObjPrivatePtr priv = vm->privateData; - bhyveMonitorPtr mon = priv->mon; + bhyveMonitorPtr mon = opaque; + virDomainObjPtr vm = mon->vm; + bhyveConnPtr driver = mon->driver; + const char *name; struct kevent kev; int rc, status; @@ -82,60 +140,49 @@ bhyveMonitorIO(int watch, int kq, int events G_GNUC_UNUSED, void *opaque) return; } + name = vm->def->name; status = kev.data; if (WIFSIGNALED(status) && WCOREDUMP(status)) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Guest %s got signal %d and crashed"), - vm->def->name, - WTERMSIG(status)); - virBhyveProcessStop(mon->driver, vm, - VIR_DOMAIN_SHUTOFF_CRASHED); + name, WTERMSIG(status)); + virBhyveProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_CRASHED); } else if (WIFEXITED(status)) { if (WEXITSTATUS(status) == 0) { /* 0 - reboot */ /* TODO: Implementing reboot is a little more complicated. */ - VIR_INFO("Guest %s rebooted; destroying domain.", - vm->def->name); - virBhyveProcessStop(mon->driver, vm, - VIR_DOMAIN_SHUTOFF_SHUTDOWN); + VIR_INFO("Guest %s rebooted; restarting domain.", name); + virBhyveProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_SHUTDOWN); } else if (WEXITSTATUS(status) < 3) { /* 1 - shutdown, 2 - halt, 3 - triple fault. others - error */ - VIR_INFO("Guest %s shut itself down; destroying domain.", - vm->def->name); - virBhyveProcessStop(mon->driver, vm, - VIR_DOMAIN_SHUTOFF_SHUTDOWN); + VIR_INFO("Guest %s shut itself down; destroying domain.", name); + virBhyveProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_SHUTDOWN); } else { VIR_INFO("Guest %s had an error and exited with status %d; destroying domain.", - vm->def->name, WEXITSTATUS(status)); - virBhyveProcessStop(mon->driver, vm, - VIR_DOMAIN_SHUTOFF_UNKNOWN); + name, WEXITSTATUS(status)); + virBhyveProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_UNKNOWN); } } } } -static void -bhyveMonitorRelease(void *opaque) -{ - virDomainObjPtr vm = opaque; - bhyveDomainObjPrivatePtr priv = vm->privateData; - bhyveMonitorPtr mon = priv->mon; - - VIR_FORCE_CLOSE(mon->kq); - VIR_FREE(mon); -} - -bhyveMonitorPtr -bhyveMonitorOpen(virDomainObjPtr vm, bhyveConnPtr driver) +static bhyveMonitorPtr +bhyveMonitorOpenImpl(virDomainObjPtr vm, bhyveConnPtr driver) { - bhyveMonitorPtr mon = NULL; + bhyveMonitorPtr mon; struct kevent kev; - if (VIR_ALLOC(mon) < 0) + if (bhyveMonitorInitialize() < 0) + return NULL; + + if (!(mon = virObjectNew(bhyveMonitorClass))) return NULL; mon->driver = driver; + virObjectRef(vm); + mon->vm = vm; + mon->kq = kqueue(); if (mon->kq < 0) { virReportError(VIR_ERR_SYSTEM_ERROR, "%s", @@ -150,14 +197,7 @@ bhyveMonitorOpen(virDomainObjPtr vm, bhyveConnPtr driver) goto cleanup; } - mon->watch = virEventAddHandle(mon->kq, - VIR_EVENT_HANDLE_READABLE | - VIR_EVENT_HANDLE_ERROR | - VIR_EVENT_HANDLE_HANGUP, - bhyveMonitorIO, - vm, - bhyveMonitorRelease); - if (mon->watch < 0) { + if (!bhyveMonitorRegister(mon)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("unable to register monitor events")); goto cleanup; @@ -166,18 +206,30 @@ bhyveMonitorOpen(virDomainObjPtr vm, bhyveConnPtr driver) return mon; cleanup: - bhyveMonitorRelease(mon); + bhyveMonitorClose(mon); return NULL; } +bhyveMonitorPtr +bhyveMonitorOpen(virDomainObjPtr vm, bhyveConnPtr driver) +{ + bhyveMonitorPtr mon; + + virObjectRef(vm); + mon = bhyveMonitorOpenImpl(vm, driver); + virObjectUnref(vm); + + return mon; +} + void bhyveMonitorClose(bhyveMonitorPtr mon) { if (mon == NULL) return; - if (mon->watch > 0) - virEventRemoveHandle(mon->watch); - else - bhyveMonitorRelease(mon); + VIR_DEBUG("cleaning up bhyveMonitor %p", mon); + + bhyveMonitorUnregister(mon); + virObjectUnref(mon); } -- 2.23.0

On Thu, Jan 02, 2020 at 05:46:31PM +0000, Ryan Moeller wrote:
Signed-off-by: Ryan Moeller <ryan@iXsystems.com> --- src/bhyve/bhyve_monitor.c | 144 ++++++++++++++++++++++++++------------ 1 file changed, 98 insertions(+), 46 deletions(-)
FWIW, we're aiming to replace virClass with GObject, but since you've already done the work here I'm not going to reject it for that reason.
diff --git a/src/bhyve/bhyve_monitor.c b/src/bhyve/bhyve_monitor.c index 0e55e19772..566c672ba0 100644 --- a/src/bhyve/bhyve_monitor.c +++ b/src/bhyve/bhyve_monitor.c @@ -32,24 +32,82 @@ #include "virerror.h" #include "virfile.h" #include "virlog.h" +#include "virobject.h"
#define VIR_FROM_THIS VIR_FROM_BHYVE
VIR_LOG_INIT("bhyve.bhyve_monitor");
struct _bhyveMonitor { + virObject parent; + int kq; int watch; bhyveConnPtr driver; + virDomainObjPtr vm; };
+static virClassPtr bhyveMonitorClass; + +static void +bhyveMonitorDispose(void *obj) +{ + bhyveMonitorPtr mon = obj; + + VIR_FORCE_CLOSE(mon->kq); + virObjectUnref(mon->vm); +} + +static int +bhyveMonitorOnceInit(void) +{ + if (!VIR_CLASS_NEW(bhyveMonitor, virClassForObject())) + return -1; + + return 0; +} + +VIR_ONCE_GLOBAL_INIT(bhyveMonitor); + +static void bhyveMonitorIO(int, int, int, void *); + +static bool +bhyveMonitorRegister(bhyveMonitorPtr mon) +{ + virObjectRef(mon); + mon->watch = virEventAddHandle(mon->kq, + VIR_EVENT_HANDLE_READABLE | + VIR_EVENT_HANDLE_ERROR | + VIR_EVENT_HANDLE_HANGUP, + bhyveMonitorIO, + mon, + virObjectFreeCallback); + if (mon->watch < 0) { + VIR_DEBUG("failed to add event handle for mon %p", mon); + virObjectUnref(mon); + return false; + } + return true; +} + +static void +bhyveMonitorUnregister(bhyveMonitorPtr mon) +{ + if (mon->watch < 0) + return; + + virEventRemoveHandle(mon->watch); + mon->watch = -1; +}
These two new methods are really separate refactoring from the introduction of virClass. So as a future note, we'd generally prefer if this had been two patches, but I'm fine merging this one now. Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

Signed-off-by: Ryan Moeller <ryan@iXsystems.com> --- src/bhyve/bhyve_process.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/bhyve/bhyve_process.c b/src/bhyve/bhyve_process.c index 4da2a702e6..75e12c8a8f 100644 --- a/src/bhyve/bhyve_process.c +++ b/src/bhyve/bhyve_process.c @@ -121,8 +121,6 @@ virBhyveProcessStart(virConnectPtr conn, char *devicemap = NULL; char *logfile = NULL; int logfd = -1; - off_t pos = -1; - char ebuf[1024]; virCommandPtr cmd = NULL; virCommandPtr load_cmd = NULL; bhyveConnPtr driver = conn->privateData; @@ -196,9 +194,6 @@ virBhyveProcessStart(virConnectPtr conn, /* Log generated command line */ virCommandWriteArgLog(load_cmd, logfd); - if ((pos = lseek(logfd, 0, SEEK_END)) < 0) - VIR_WARN("Unable to seek to end of logfile: %s", - virStrerror(errno, ebuf, sizeof(ebuf))); VIR_DEBUG("Loading domain '%s'", vm->def->name); if (virCommandRun(load_cmd, NULL) < 0) -- 2.23.0

On Thu, Jan 02, 2020 at 05:46:32PM +0000, Ryan Moeller wrote:
Signed-off-by: Ryan Moeller <ryan@iXsystems.com> --- src/bhyve/bhyve_process.c | 5 ----- 1 file changed, 5 deletions(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

Signed-off-by: Ryan Moeller <ryan@iXsystems.com> --- tests/bhyvexml2argvtest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c index 3c9c61f024..9e7eb218b8 100644 --- a/tests/bhyvexml2argvtest.c +++ b/tests/bhyvexml2argvtest.c @@ -51,11 +51,11 @@ static int testCompareXMLToArgvFiles(const char *xml, conn->privateData = &driver; - cmd = virBhyveProcessBuildBhyveCmd(conn, vmdef, false); + cmd = virBhyveProcessBuildBhyveCmd(&driver, vmdef, false); if (vmdef->os.loader) ldcmd = virCommandNew("dummy"); else - ldcmd = virBhyveProcessBuildLoadCmd(conn, vmdef, "<device.map>", + ldcmd = virBhyveProcessBuildLoadCmd(&driver, vmdef, "<device.map>", &actualdm); if ((cmd == NULL) || (ldcmd == NULL)) { -- 2.23.0

On Thu, Jan 02, 2020 at 05:46:34PM +0000, Ryan Moeller wrote:
Signed-off-by: Ryan Moeller <ryan@iXsystems.com> --- tests/bhyvexml2argvtest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c index 3c9c61f024..9e7eb218b8 100644 --- a/tests/bhyvexml2argvtest.c +++ b/tests/bhyvexml2argvtest.c @@ -51,11 +51,11 @@ static int testCompareXMLToArgvFiles(const char *xml,
conn->privateData = &driver;
- cmd = virBhyveProcessBuildBhyveCmd(conn, vmdef, false); + cmd = virBhyveProcessBuildBhyveCmd(&driver, vmdef, false); if (vmdef->os.loader) ldcmd = virCommandNew("dummy"); else - ldcmd = virBhyveProcessBuildLoadCmd(conn, vmdef, "<device.map>", + ldcmd = virBhyveProcessBuildLoadCmd(&driver, vmdef, "<device.map>", &actualdm);
if ((cmd == NULL) || (ldcmd == NULL)) {
We need tests to be successfully buildable at every step, so that "git bisect" can wrk reliably. So this needs squashing into patch 2 which first introduced the test build failure Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

From: Ryan Moeller <ryan@ixsystems.com> Signed-off-by: Ryan Moeller <ryan@iXsystems.com> --- src/logging/Makefile.inc.am | 10 ++++++++++ src/logging/virtlogd.init.in | 14 ++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 src/logging/virtlogd.init.in diff --git a/src/logging/Makefile.inc.am b/src/logging/Makefile.inc.am index 0f7ffa73b3..8e6ea08f36 100644 --- a/src/logging/Makefile.inc.am +++ b/src/logging/Makefile.inc.am @@ -55,6 +55,13 @@ VIRTLOGD_UNIT_FILES_IN = \ SYSTEMD_UNIT_FILES += $(notdir $(VIRTLOGD_UNIT_FILES_IN:%.in=%)) SYSTEMD_UNIT_FILES_IN += $(VIRTLOGD_UNIT_FILES_IN) +OPENRC_INIT_FILES += \ + virtlogd.init \ + $(NULL) +OPENRC_INIT_FILES_IN += \ + virtlogd.init.in \ + $(NULL) + noinst_LTLIBRARIES += libvirt_driver_log.la libvirt_la_BUILT_LIBADD += libvirt_driver_log.la @@ -128,6 +135,9 @@ logging/log_daemon_dispatch_stubs.h: $(LOG_PROTOCOL) \ virLogManagerProtocol VIR_LOG_MANAGER_PROTOCOL \ $(LOG_PROTOCOL) > logging/log_daemon_dispatch_stubs.h +virtlogd.init: logging/virtlogd.init.in $(top_builddir)/config.status + $(AM_V_GEN)$(SED) $(COMMON_UNIT_VARS) $< > $@-t && mv $@-t $@ + virtlogd.service: logging/virtlogd.service.in $(top_builddir)/config.status $(AM_V_GEN)sed $(COMMON_UNIT_VARS) $< > $@-t && mv $@-t $@ diff --git a/src/logging/virtlogd.init.in b/src/logging/virtlogd.init.in new file mode 100644 index 0000000000..61e41f7689 --- /dev/null +++ b/src/logging/virtlogd.init.in @@ -0,0 +1,14 @@ +#!/sbin/openrc-run + +name=virtlogd + +command=@sbindir@/virtlogd +pidfile="@runstatedir@/virtlogd.pid" +command_args="--daemon --pid-file=${pidfile}" +PATH="${PATH}:@sbindir@:@bindir@" +supervisor=supervise-daemon + +depend() { + provide virtlogd + keyword -shutdown +} -- 2.23.0

On Thu, Jan 02, 2020 at 05:46:35PM +0000, Ryan Moeller wrote:
From: Ryan Moeller <ryan@ixsystems.com>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com> --- src/logging/Makefile.inc.am | 10 ++++++++++ src/logging/virtlogd.init.in | 14 ++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 src/logging/virtlogd.init.in
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> The same thing is missing for virtlockd in src/locking if you fancy sending an equiv patch for that. Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

On Thu, Jan 02, 2020 at 05:46:23PM +0000, Ryan Moeller wrote:
The main changes are: * Add support for standard hooks in bhyve backend: - prepare - start - started - stopped - release * Some code cleanup & general housekeeping in bhyve backend * Add support for reboot in bhyve backend, both from within the VM and from the host
Ryan Moeller (12): Add hooks for bhyve backend
I don't know what has happened, but we seem to be missing this patch from the list
Fix build errors on FreeBSD Simplify bhyve driver caps helpers Remove redundant parameter to virBhyveProcessStart() Factor out conn Fix indentation Eliminate rc variable Make bhyveMonitor a virClass Don't bother seeking to the end of a file opened O_APPEND Add reboot support for bhyve backend
And this patch too.
Fix bhyvexml2argvtest Add missing virtlogd.init for OpenRC
Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
participants (3)
-
Daniel P. Berrangé
-
Laine Stump
-
Ryan Moeller