mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 23:25:24 +00:00
qemu: Build channel autosocket directory at driver startup
Rather than depend on the RPM to put it in place, since this doesn't
cover the qemu:///session case. Currently auto allocated socket path is
completely busted with qemu:///session
https://bugzilla.redhat.com/show_bug.cgi?id=1105274
And because we chown the directory at driver startup now, this also fixes
autosocket startup failures when using user/group=root
https://bugzilla.redhat.com/show_bug.cgi?id=1044561
https://bugzilla.redhat.com/show_bug.cgi?id=1146886
(cherry picked from commit e31ab02fd0
)
This commit is contained in:
parent
c163111b58
commit
9ed89d783b
@ -1961,8 +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(0750, %{qemu_user}, %{qemu_group}) %{_localstatedir}/lib/libvirt/qemu/channel/
|
||||
%dir %attr(0750, %{qemu_user}, %{qemu_group}) %{_localstatedir}/lib/libvirt/qemu/channel/target/
|
||||
%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
|
||||
@ -2064,8 +2062,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(0750, %{qemu_user}, %{qemu_group}) %{_localstatedir}/lib/libvirt/qemu/channel/
|
||||
%dir %attr(0750, %{qemu_user}, %{qemu_group}) %{_localstatedir}/lib/libvirt/qemu/channel/target/
|
||||
%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
|
||||
|
@ -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/channel/target"
|
||||
$(MKDIR_P) "$(DESTDIR)$(localstatedir)/lib/libvirt/qemu/nvram"
|
||||
$(MKDIR_P) "$(DESTDIR)$(localstatedir)/run/libvirt/qemu"
|
||||
$(MKDIR_P) "$(DESTDIR)$(localstatedir)/cache/libvirt/qemu"
|
||||
|
@ -205,6 +205,9 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool privileged)
|
||||
goto error;
|
||||
if (virAsprintf(&cfg->autoDumpPath, "%s/dump", cfg->libDir) < 0)
|
||||
goto error;
|
||||
if (virAsprintf(&cfg->channelTargetDir,
|
||||
"%s/channel/target", cfg->libDir) < 0)
|
||||
goto error;
|
||||
} else {
|
||||
char *rundir;
|
||||
char *cachedir;
|
||||
@ -244,6 +247,9 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool privileged)
|
||||
goto error;
|
||||
if (virAsprintf(&cfg->autoDumpPath, "%s/qemu/dump", cfg->configBaseDir) < 0)
|
||||
goto error;
|
||||
if (virAsprintf(&cfg->channelTargetDir,
|
||||
"%s/qemu/channel/target", cfg->configBaseDir) < 0)
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (virAsprintf(&cfg->configDir, "%s/qemu", cfg->configBaseDir) < 0)
|
||||
@ -342,6 +348,7 @@ static void virQEMUDriverConfigDispose(void *obj)
|
||||
VIR_FREE(cfg->cacheDir);
|
||||
VIR_FREE(cfg->saveDir);
|
||||
VIR_FREE(cfg->snapshotDir);
|
||||
VIR_FREE(cfg->channelTargetDir);
|
||||
|
||||
VIR_FREE(cfg->vncTLSx509certdir);
|
||||
VIR_FREE(cfg->vncListen);
|
||||
|
@ -104,6 +104,7 @@ struct _virQEMUDriverConfig {
|
||||
char *cacheDir;
|
||||
char *saveDir;
|
||||
char *snapshotDir;
|
||||
char *channelTargetDir;
|
||||
|
||||
bool vncAutoUnixSocket;
|
||||
bool vncTLS;
|
||||
|
@ -1151,12 +1151,11 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
|
||||
dev->data.chr->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO &&
|
||||
dev->data.chr->source.type == VIR_DOMAIN_CHR_TYPE_UNIX &&
|
||||
!dev->data.chr->source.data.nix.path && cfg) {
|
||||
|
||||
if (virAsprintf(&dev->data.chr->source.data.nix.path,
|
||||
"%s/channel/target/%s.%s",
|
||||
cfg->libDir, def->name,
|
||||
dev->data.chr->target.name) < 0)
|
||||
if (virAsprintf(&dev->data.chr->source.data.nix.path, "%s/%s.%s",
|
||||
cfg->channelTargetDir,
|
||||
def->name, dev->data.chr->target.name) < 0)
|
||||
goto cleanup;
|
||||
|
||||
dev->data.chr->source.data.nix.listen = true;
|
||||
}
|
||||
|
||||
|
@ -98,6 +98,7 @@
|
||||
#include "domain_capabilities.h"
|
||||
#include "vircgroup.h"
|
||||
#include "virnuma.h"
|
||||
#include "dirname.h"
|
||||
|
||||
#define VIR_FROM_THIS VIR_FROM_QEMU
|
||||
|
||||
@ -702,6 +703,12 @@ qemuStateInitialize(bool privileged,
|
||||
cfg->autoDumpPath, virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
goto error;
|
||||
}
|
||||
if (virFileMakePath(cfg->channelTargetDir) < 0) {
|
||||
VIR_ERROR(_("Failed to create channel target dir '%s': %s"),
|
||||
cfg->channelTargetDir,
|
||||
virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
goto error;
|
||||
}
|
||||
|
||||
qemu_driver->qemuImgBinary = virFindFileInPath("kvm-img");
|
||||
if (!qemu_driver->qemuImgBinary)
|
||||
@ -761,6 +768,8 @@ qemuStateInitialize(bool privileged,
|
||||
goto error;
|
||||
|
||||
if (privileged) {
|
||||
char *channeldir;
|
||||
|
||||
if (chown(cfg->libDir, cfg->user, cfg->group) < 0) {
|
||||
virReportSystemError(errno,
|
||||
_("unable to set ownership of '%s' to user %d:%d"),
|
||||
@ -796,6 +805,26 @@ qemuStateInitialize(bool privileged,
|
||||
(int) cfg->group);
|
||||
goto error;
|
||||
}
|
||||
if (!(channeldir = mdir_name(cfg->channelTargetDir))) {
|
||||
virReportOOMError();
|
||||
goto error;
|
||||
}
|
||||
if (chown(channeldir, cfg->user, cfg->group) < 0) {
|
||||
virReportSystemError(errno,
|
||||
_("unable to set ownership of '%s' to %d:%d"),
|
||||
channeldir, (int) cfg->user,
|
||||
(int) cfg->group);
|
||||
VIR_FREE(channeldir);
|
||||
goto error;
|
||||
}
|
||||
VIR_FREE(channeldir);
|
||||
if (chown(cfg->channelTargetDir, cfg->user, cfg->group) < 0) {
|
||||
virReportSystemError(errno,
|
||||
_("unable to set ownership of '%s' to %d:%d"),
|
||||
cfg->channelTargetDir, (int) cfg->user,
|
||||
(int) cfg->group);
|
||||
goto error;
|
||||
}
|
||||
|
||||
run_uid = cfg->user;
|
||||
run_gid = cfg->group;
|
||||
|
Loading…
Reference in New Issue
Block a user