On 03/13/2017 07:02 PM, Roman Bogorodskiy wrote: > Introduce config file support for the bhyve driver. The only available > setting at present is 'firmware_dir' for specifying a directory with > UEFI firmware files. > --- > src/Makefile.am | 25 +++++++- > src/bhyve/bhyve.conf | 7 +++ > src/bhyve/bhyve_capabilities.c | 9 ++- > src/bhyve/bhyve_capabilities.h | 5 +- > src/bhyve/bhyve_conf.c | 112 +++++++++++++++++++++++++++++++++++ > src/bhyve/bhyve_conf.h | 32 ++++++++++ > src/bhyve/bhyve_driver.c | 11 +++- > src/bhyve/bhyve_utils.h | 12 ++++ > src/bhyve/libvirtd_bhyve.aug | 39 ++++++++++++ > src/bhyve/test_libvirtd_bhyve.aug.in | 5 ++ > 10 files changed, 252 insertions(+), 5 deletions(-) > create mode 100644 src/bhyve/bhyve.conf > create mode 100644 src/bhyve/bhyve_conf.c > create mode 100644 src/bhyve/bhyve_conf.h > create mode 100644 src/bhyve/libvirtd_bhyve.aug > create mode 100644 src/bhyve/test_libvirtd_bhyve.aug.in > > diff --git a/src/Makefile.am b/src/Makefile.am > index 02579659a..f0d8efe50 100644 > --- a/src/Makefile.am > +++ b/src/Makefile.am > @@ -930,6 +930,8 @@ BHYVE_DRIVER_SOURCES = \ > bhyve/bhyve_capabilities.h \ > bhyve/bhyve_command.c \ > bhyve/bhyve_command.h \ > + bhyve/bhyve_conf.c \ > + bhyve/bhyve_conf.h \ > bhyve/bhyve_parse_command.c \ > bhyve/bhyve_parse_command.h \ > bhyve/bhyve_device.c \ > @@ -1575,7 +1577,14 @@ libvirt_driver_bhyve_impl_la_CFLAGS = \ > $(AM_CFLAGS) > libvirt_driver_bhyve_impl_la_LDFLAGS = $(AM_LDFLAGS) > libvirt_driver_bhyve_impl_la_SOURCES = $(BHYVE_DRIVER_SOURCES) > + > +conf_DATA += bhyve/bhyve.conf > +augeas_DATA += bhyve/libvirtd_bhyve.aug > +augeastest_DATA += test_libvirtd_bhyve.aug > endif WITH_BHYVE > +EXTRA_DIST += bhyve/bhyve.conf \ > + bhyve/libvirtd_bhyve.aug \ > + bhyve/test_libvirtd_bhyve.aug.in > > if WITH_NETWORK > noinst_LTLIBRARIES += libvirt_driver_network_impl.la > @@ -2125,11 +2134,12 @@ check-local: check-augeas > check-augeas-sanlock \ > check-augeas-lockd \ > check-augeas-libxl \ > + check-augeas-bhyve \ > $(NULL) > > check-augeas: check-augeas-qemu check-augeas-lxc check-augeas-sanlock \ > check-augeas-lockd check-augeas-virtlockd check-augeas-libxl \ > - check-augeas-virtlogd > + check-augeas-bhyve check-augeas-virtlogd > > AUG_GENTEST = $(PERL) $(top_srcdir)/build-aux/augeas-gentest.pl > EXTRA_DIST += $(top_srcdir)/build-aux/augeas-gentest.pl > @@ -2212,6 +2222,19 @@ else ! WITH_LIBXL > check-augeas-libxl: > endif ! WITH_LIBXL > > +if WITH_BHYVE > +test_libvirtd_bhyve.aug: bhyve/test_libvirtd_bhyve.aug.in \ > + $(srcdir)/bhyve/bhyve.conf $(AUG_GENTEST) > + $(AM_V_GEN)$(AUG_GENTEST) $(srcdir)/bhyve/bhyve.conf $< $@ > + > +check-augeas-bhyve: test_libvirtd_bhyve.aug > + $(AM_V_GEN)if test -x '$(AUGPARSE)'; then \ > + '$(AUGPARSE)' -I $(srcdir)/bhyve test_libvirtd_bhyve.aug; \ > + fi > +else ! WITH_BHYVE > +check-augeas-bhyve: > +endif ! WITH_BHYVE > + > test_virtlogd.aug: logging/test_virtlogd.aug.in \ > logging/virtlogd.conf $(AUG_GENTEST) > $(AM_V_GEN)$(AUG_GENTEST) $(srcdir)/logging/virtlogd.conf $< $@ > diff --git a/src/bhyve/bhyve.conf b/src/bhyve/bhyve.conf > new file mode 100644 > index 000000000..2a8baacff > --- /dev/null > +++ b/src/bhyve/bhyve.conf > @@ -0,0 +1,7 @@ > +# Master configuration file for the bhyve driver. > +# All settings described here are optional - if omitted, sensible > +# defaults are used. > + > +# Path to a directory with firmware files. By default it's pointing > +# to the directory that sysutils/bhyve-firmware installs files into. > +#firmware_dir = "/usr/local/share/uefi-firmware" > diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c > index 5e6094e3c..da06ba711 100644 > --- a/src/bhyve/bhyve_capabilities.c > +++ b/src/bhyve/bhyve_capabilities.c > @@ -111,7 +111,8 @@ virBhyveCapsBuild(void) > } > > virDomainCapsPtr > -virBhyveDomainCapsBuild(const char *emulatorbin, > +virBhyveDomainCapsBuild(bhyveConnPtr conn, > + const char *emulatorbin, > const char *machine, > virArch arch, > virDomainVirtType virttype) > @@ -120,8 +121,9 @@ virBhyveDomainCapsBuild(const char *emulatorbin, > unsigned int bhyve_caps = 0; > DIR *dir; > struct dirent *entry; > - const char *firmware_dir = "/usr/local/share/uefi-firmware"; > size_t firmwares_alloc = 0; > + virBhyveDriverConfigPtr cfg = virBhyveDriverGetConfig(conn); You need to unref @cfg. > + const char *firmware_dir = cfg->firmwareDir; > > if (!(caps = virDomainCapsNew(emulatorbin, machine, arch, virttype))) > goto cleanup; > @@ -152,7 +154,10 @@ virBhyveDomainCapsBuild(const char *emulatorbin, > > caps->os.loader.values.nvalues++; > } > + } else { > + VIR_WARN("Cannot open firmware directory %s", firmware_dir); > } > + > caps->disk.supported = true; > VIR_DOMAIN_CAPS_ENUM_SET(caps->disk.diskDevice, > VIR_DOMAIN_DISK_DEVICE_DISK, > diff --git a/src/bhyve/bhyve_capabilities.h b/src/bhyve/bhyve_capabilities.h > index 8fb97d730..3d8edb490 100644 > --- a/src/bhyve/bhyve_capabilities.h > +++ b/src/bhyve/bhyve_capabilities.h > @@ -25,8 +25,11 @@ > # include "capabilities.h" > # include "conf/domain_capabilities.h" > > +# include "bhyve_conf.h" > + This include is because of bhyveConnPtr type I assume. Well, that one is defined in bhyve_utils.h which is the file you should be including. After you've done that you'll find that bhyve_capabilities needs to include bhyve_conf.h" because of virBhyveDriverGetConfig call. But that's okay - you can replace include of bhyve_utils.h there with bhyve_conf.h: diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c index 0b7881d60..4672170b3 100644 --- a/src/bhyve/bhyve_capabilities.c +++ b/src/bhyve/bhyve_capabilities.c @@ -32,10 +32,10 @@ #include "virstring.h" #include "cpu/cpu.h" #include "nodeinfo.h" -#include "bhyve_utils.h" #include "domain_conf.h" #include "vircommand.h" #include "bhyve_capabilities.h" +#include "bhyve_conf.h" #define VIR_FROM_THIS VIR_FROM_BHYVE diff --git a/src/bhyve/bhyve_capabilities.h b/src/bhyve/bhyve_capabilities.h index 3d8edb490..e6d934bc2 100644 --- a/src/bhyve/bhyve_capabilities.h +++ b/src/bhyve/bhyve_capabilities.h @@ -24,8 +24,7 @@ # include "capabilities.h" # include "conf/domain_capabilities.h" - -# include "bhyve_conf.h" +# include "bhyve_utils.h" virCapsPtr virBhyveCapsBuild(void); virDomainCapsPtr virBhyveDomainCapsBuild(bhyveConnPtr, > virCapsPtr virBhyveCapsBuild(void); > -virDomainCapsPtr virBhyveDomainCapsBuild(const char *emulatorbin, > +virDomainCapsPtr virBhyveDomainCapsBuild(bhyveConnPtr, > + const char *emulatorbin, > const char *machine, > virArch arch, > virDomainVirtType virttype); With that squashed in, and unrefing @cfg you have my ACK. Michal -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list