Klemens Nanni <[email protected]> writes:
> On Mon, Apr 24, 2023 at 01:46:17PM +0000, Klemens Nanni wrote:
>> I have on vm.conf, vmd does not need it, but complains:
>> Apr 23 17:12:50 atar vmd[79320]: failed to open /etc/vm.conf: No such file
>> or directory
>>
>> We've fixed the same for dhcpleased a year ago, port the diff from there.
>>
>> Works for me with good, with bad and without /etc/vm.conf.
>> Feedback? OK?
>
> Make it a debug hint, after talking with mlarking.
>
> This keeps /var/log/{messages,daemon} clean on a default install with
> config-less vmd enabled, but will show up under `-vv'.
>
> Nicely quiet:
> # /usr/sbin/vmd -d [-v]
> startup
> ...
>
> Debug:
> # /usr/sbin/vmd -d -vv
> startup
> /etc/vm.conf: missing
> vmd_configure: setting staggered start configuration to parallelism: 12
> and delay: 30
> ...
>
> If passed explicitly, it remains an error:
> # /usr/sbin/vmd -d -f/etc/vm.conf
> startup
> failed to open /etc/vm.conf: No such file or directory
> ...
>
> Non-default paths still behave as expected, just to make sure:
> # /usr/sbin/vmd -d -f/dev/zero
> startup
> ...
>
> # /usr/sbin/vmd -d -f/nonexistent
> startup
> failed to open /nonexistent: No such file or directory
> ...
>
> Feedback? OK?
ok with me.
>
> Index: parse.y
> ===================================================================
> RCS file: /cvs/src/usr.sbin/vmd/parse.y,v
> retrieving revision 1.63
> diff -u -p -r1.63 parse.y
> --- parse.y 28 Jan 2023 14:40:53 -0000 1.63
> +++ parse.y 24 Apr 2023 14:18:07 -0000
> @@ -1181,9 +1181,15 @@ popfile(void)
> int
> parse_config(const char *filename)
> {
> - struct sym *sym, *next;
> + extern const char default_conffile[];
> + struct sym *sym, *next;
>
> if ((file = pushfile(filename, 0)) == NULL) {
> + /* no default config file is fine */
> + if (errno == ENOENT && filename == default_conffile) {
> + log_debug("%s: missing", filename);
> + return (0);
> + }
> log_warn("failed to open %s", filename);
> if (errno == ENOENT)
> return (0);
> Index: vmd.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/vmd/vmd.c,v
> retrieving revision 1.142
> diff -u -p -r1.142 vmd.c
> --- vmd.c 23 Apr 2023 12:11:37 -0000 1.142
> +++ vmd.c 24 Apr 2023 13:39:21 -0000
> @@ -89,6 +89,9 @@ static struct privsep_proc *proc_priv =
> static struct passwd proc_privpw;
> static const uint8_t zero_mac[ETHER_ADDR_LEN];
>
> +const char default_conffile[] = VMD_CONF;
> +const char *conffile = default_conffile;
> +
> int
> vmd_dispatch_control(int fd, struct privsep_proc *p, struct imsg *imsg)
> {
> @@ -767,7 +770,6 @@ main(int argc, char **argv)
> {
> struct privsep *ps;
> int ch;
> - const char *conffile = VMD_CONF;
> enum privsep_procid proc_id = PROC_PARENT;
> int proc_instance = 0, vm_launch = 0, vm_fd = -1;
> const char *errp, *title = NULL;