goto cleanup;
}
- if (dev->data.chr->target.name) {
- if (virAsprintf(&dev->data.chr->source.data.nix.path, "%s/%s.%s",
- cfg->channelTargetDir,
- def->name, dev->data.chr->target.name) < 0)
- goto cleanup;
- } else {
- if (virAsprintf(&dev->data.chr->source.data.nix.path, "%s/%s",
- cfg->channelTargetDir, def->name) < 0)
- goto cleanup;
- }
+ if (virAsprintf(&dev->data.chr->source.data.nix.path,
+ "%s/domain-%s/%s",
+ cfg->channelTargetDir, def->name,
+ dev->data.chr->target.name ? dev->data.chr->target.name
+ : "unknown.sock") < 0)
+ goto cleanup;
dev->data.chr->source.data.nix.listen = true;
}
#include "cpu/cpu.h"
#include "datatypes.h"
+#include "dirname.h"
#include "virlog.h"
#include "virerror.h"
#include "viralloc.h"
monConfig->type = VIR_DOMAIN_CHR_TYPE_UNIX;
monConfig->data.nix.listen = true;
- if (virAsprintf(&monConfig->data.nix.path, "%s/%s.monitor",
+ if (virAsprintf(&monConfig->data.nix.path, "%s/domain-%s/monitor.sock",
cfg->libDir, vm) < 0)
return -1;
return 0;
unsigned int hostdev_flags = 0;
size_t nnicindexes = 0;
int *nicindexes = NULL;
+ char *tmppath = NULL, *tmpdirpath = NULL;
VIR_DEBUG("vm=%p name=%s id=%d asyncJob=%d migrateFrom=%s stdin_fd=%d "
"stdin_path=%s snapshot=%p vmop=%d flags=0x%x",
&nnicindexes, &nicindexes)))
goto cleanup;
+
+ /*
+ * Create all per-domain directories in order to make sure domain
+ * with any possible seclabels can access it.
+ */
+ if (virAsprintf(&tmppath, "%s/domain-%s", cfg->libDir, vm->def->name) < 0)
+ goto cleanup;
+
+ if (virFileMakePath(tmppath) < 0)
+ goto cleanup;
+
+ if (!(tmpdirpath = mdir_name(tmppath)))
+ goto cleanup;
+
+ if (virSecurityManagerDomainSetDirLabel(driver->securityManager,
+ vm->def, tmpdirpath) < 0)
+ goto cleanup;
+
+ VIR_FREE(tmppath);
+ VIR_FREE(tmpdirpath);
+
+ if (virAsprintf(&tmppath, "%s/domain-%s",
+ cfg->channelTargetDir, vm->def->name) < 0)
+ goto cleanup;
+
+ if (virFileMakePath(tmppath) < 0)
+ goto cleanup;
+
+ if (!(tmpdirpath = mdir_name(tmppath)))
+ goto cleanup;
+
+ if (virSecurityManagerDomainSetDirLabel(driver->securityManager,
+ vm->def, tmpdirpath) < 0)
+ goto cleanup;
+
+ VIR_FREE(tmpdirpath);
+ VIR_FREE(tmppath);
+
/* now that we know it is about to start call the hook if present */
if (virHookPresent(VIR_HOOK_DRIVER_QEMU)) {
char *xml = qemuDomainDefFormatXML(driver, vm->def, 0);
/* We jump here if we failed to start the VM for any reason, or
* if we failed to initialize the now running VM. kill it off and
* pretend we never started it */
+ VIR_FREE(tmppath);
+ VIR_FREE(tmpdirpath);
VIR_FREE(nodeset);
virCommandFree(cmd);
VIR_FORCE_CLOSE(logfile);
size_t i;
int logfile = -1;
char *timestamp;
+ char *tmppath = NULL;
char ebuf[1024];
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
priv->monConfig = NULL;
}
+ ignore_value(virAsprintf(&tmppath, "%s/domain-%s",
+ cfg->libDir, vm->def->name));
+ if (tmppath)
+ virFileDeleteTree(tmppath);
+ VIR_FREE(tmppath);
+
+ ignore_value(virAsprintf(&tmppath, "%s/domain-%s",
+ cfg->channelTargetDir, vm->def->name));
+ if (tmppath)
+ virFileDeleteTree(tmppath);
+ VIR_FREE(tmppath);
+
ignore_value(virDomainChrDefForeach(vm->def,
false,
qemuProcessCleanupChardevDevice,
-usb \
-hda /dev/HostVG/QEMUGuest1 \
-chardev socket,id=charchannel0,path=\
-/tmp/QEMUGuest1.org.qemu.guest_agent.0,server,nowait \
+/tmp/domain-QEMUGuest1/org.qemu.guest_agent.0,server,nowait \
-device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,\
name=org.qemu.guest_agent.0 \
--chardev socket,id=charchannel1,path=/tmp/QEMUGuest1,server,nowait \
+-chardev \
+socket,id=charchannel1,path=/tmp/domain-QEMUGuest1/unknown.sock,server,nowait \
-device virtserialport,bus=virtio-serial0.0,nr=2,chardev=charchannel1,id=channel1 \
--chardev socket,id=charchannel2,path=/tmp/QEMUGuest1.ble,server,nowait \
+-chardev socket,id=charchannel2,path=/tmp/domain-QEMUGuest1/ble,server,nowait \
-device virtserialport,bus=virtio-serial0.0,nr=3,chardev=charchannel2,id=channel2,\
name=ble