diff --git a/libvirt.spec.in b/libvirt.spec.in index dec7af17df..380595f8a6 100644 --- a/libvirt.spec.in +++ b/libvirt.spec.in @@ -1961,7 +1961,6 @@ exit 0 %dir %attr(0700, root, root) %{_localstatedir}/log/libvirt/qemu/ %ghost %dir %attr(0700, root, root) %{_localstatedir}/run/libvirt/qemu/ %dir %attr(0750, %{qemu_user}, %{qemu_group}) %{_localstatedir}/lib/libvirt/qemu/ -%dir %attr(0711, %{qemu_user}, %{qemu_group}) %{_localstatedir}/lib/libvirt/qemu/nvram/ %dir %attr(0750, %{qemu_user}, %{qemu_group}) %{_localstatedir}/cache/libvirt/qemu/ %{_datadir}/augeas/lenses/libvirtd_qemu.aug %{_datadir}/augeas/lenses/tests/test_libvirtd_qemu.aug @@ -2062,7 +2061,6 @@ exit 0 %config(noreplace) %{_sysconfdir}/logrotate.d/libvirtd.qemu %ghost %dir %attr(0700, root, root) %{_localstatedir}/run/libvirt/qemu/ %dir %attr(0750, %{qemu_user}, %{qemu_group}) %{_localstatedir}/lib/libvirt/qemu/ -%dir %attr(0711, %{qemu_user}, %{qemu_group}) %{_localstatedir}/lib/libvirt/qemu/nvram/ %dir %attr(0750, %{qemu_user}, %{qemu_group}) %{_localstatedir}/cache/libvirt/qemu/ %{_datadir}/augeas/lenses/libvirtd_qemu.aug %{_datadir}/augeas/lenses/tests/test_libvirtd_qemu.aug diff --git a/src/Makefile.am b/src/Makefile.am index 805698e923..629df5ea77 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -2685,7 +2685,6 @@ if WITH_SANLOCK endif WITH_SANLOCK if WITH_QEMU $(MKDIR_P) "$(DESTDIR)$(localstatedir)/lib/libvirt/qemu" - $(MKDIR_P) "$(DESTDIR)$(localstatedir)/lib/libvirt/qemu/nvram" $(MKDIR_P) "$(DESTDIR)$(localstatedir)/run/libvirt/qemu" $(MKDIR_P) "$(DESTDIR)$(localstatedir)/cache/libvirt/qemu" $(MKDIR_P) "$(DESTDIR)$(localstatedir)/log/libvirt/qemu" diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index df7407fd85..25ce8023d7 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -208,6 +208,8 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool privileged) if (virAsprintf(&cfg->channelTargetDir, "%s/channel/target", cfg->libDir) < 0) goto error; + if (virAsprintf(&cfg->nvramDir, "%s/nvram", cfg->libDir) < 0) + goto error; } else { char *rundir; char *cachedir; @@ -250,6 +252,9 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool privileged) if (virAsprintf(&cfg->channelTargetDir, "%s/qemu/channel/target", cfg->configBaseDir) < 0) goto error; + if (virAsprintf(&cfg->nvramDir, + "%s/qemu/nvram", cfg->configBaseDir) < 0) + goto error; } if (virAsprintf(&cfg->configDir, "%s/qemu", cfg->configBaseDir) < 0) @@ -349,6 +354,7 @@ static void virQEMUDriverConfigDispose(void *obj) VIR_FREE(cfg->saveDir); VIR_FREE(cfg->snapshotDir); VIR_FREE(cfg->channelTargetDir); + VIR_FREE(cfg->nvramDir); VIR_FREE(cfg->vncTLSx509certdir); VIR_FREE(cfg->vncListen); diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index b8aae1b885..7e2cb941d1 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -105,6 +105,7 @@ struct _virQEMUDriverConfig { char *saveDir; char *snapshotDir; char *channelTargetDir; + char *nvramDir; bool vncAutoUnixSocket; bool vncTLS; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ccaa007375..4c2ac96b59 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -709,6 +709,11 @@ qemuStateInitialize(bool privileged, virStrerror(errno, ebuf, sizeof(ebuf))); goto error; } + if (virFileMakePath(cfg->nvramDir) < 0) { + VIR_ERROR(_("Failed to create nvram dir '%s': %s"), + cfg->nvramDir, virStrerror(errno, ebuf, sizeof(ebuf))); + goto error; + } qemu_driver->qemuImgBinary = virFindFileInPath("kvm-img"); if (!qemu_driver->qemuImgBinary) @@ -825,6 +830,13 @@ qemuStateInitialize(bool privileged, (int) cfg->group); goto error; } + if (chown(cfg->nvramDir, cfg->user, cfg->group) < 0) { + virReportSystemError(errno, + _("unable to set ownership of '%s' to %d:%d"), + cfg->nvramDir, (int) cfg->user, + (int) cfg->group); + goto error; + } run_uid = cfg->user; run_gid = cfg->group; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 515402e1d7..4beb0cf520 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4216,8 +4216,8 @@ qemuPrepareNVRAM(virQEMUDriverConfigPtr cfg, /* Autogenerate nvram path if needed.*/ if (!loader->nvram) { if (virAsprintf(&loader->nvram, - "%s/lib/libvirt/qemu/nvram/%s_VARS.fd", - LOCALSTATEDIR, vm->def->name) < 0) + "%s/%s_VARS.fd", + cfg->nvramDir, vm->def->name) < 0) goto cleanup; generated = true;