Similar to what was done for the channel socket in the previous commit.
---
libvirt.spec.in | 2 --
src/Makefile.am | 1 -
src/qemu/qemu_conf.c | 6 ++++++
src/qemu/qemu_conf.h | 1 +
src/qemu/qemu_driver.c | 12 ++++++++++++
src/qemu/qemu_process.c | 4 ++--
6 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 2f19c7f..20af502 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -1985,7 +1985,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
@@ -2089,7 +2088,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 dd41b45..33ee723 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2705,7 +2705,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 4b5fa39..16ae6ab 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 6e9f815..2ba4ce7 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 25e7939..b3f718e 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 276837e..3a38db1 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4144,8 +4144,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;
--
2.3.5