ioemu: Send logs to stderr and have xend redirect stderr to the

correct log file.

At the same time, this patch renames the logfile to be
'qemu-dm-{NAME}.log' instead of qemu-dm-{ID}.log.  This makes it
easier to track/find the QEMU logfile associated with a VM. It will
also save 1 backup qemu-dm-{NAME}.log.1 so if a domain crashes &
restart, you don't loose/overwrite the logfile immediately.

Finally it changes the QEMU monitor prompt back to '(qemu)' instead of
'(HVMXen)' because automated tools /scripts interacting with QEMU's
monitor need a consistent prompt to look for & changing it for Xen
serves no useful purpose.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
Keir Fraser committed 2008-02-28 10:29:25 +00:00
1 parent e8fcc3571a
commit 6a69bb45ed
4 files changed
+32 -7

No files matched your search

+28 -1
View File
@@ -296,7 +296,34 @@ class ImageHandler:
{ 'dom': self.vm.getDomid(), 'read': True, 'write': True })
log.info("spawning device models: %s %s", self.device_model, args)
# keep track of pid and spawned options to kill it later
self.pid = os.spawnve(os.P_NOWAIT, self.device_model, args, env)
logfile = "/var/log/xen/qemu-dm-%s.log" % str(self.vm.info['name_label'])
if os.path.exists(logfile):
if os.path.exists(logfile + ".1"):
os.unlink(logfile + ".1")
os.rename(logfile, logfile + ".1")
null = os.open("/dev/null", os.O_RDONLY)
logfd = os.open(logfile, os.O_WRONLY|os.O_CREAT|os.O_TRUNC)
pid = os.fork()
if pid == 0: #child
try:
os.dup2(null, 0)
os.dup2(logfd, 1)
os.dup2(logfd, 2)
os.close(null)
os.close(logfd)
try:
os.execve(self.device_model, args, env)
except:
os._exit(127)
except:
os._exit(127)
else:
self.pid = pid
os.close(null)
os.close(logfd)
self.vm.storeDom("image/device-model-pid", self.pid)
log.info("device model pid: %d", self.pid)
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.