mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 10:40:03 +01:00
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:
1 parent
e8fcc3571a
commit
6a69bb45ed
4 files changed
+32
-7
No files matched your search
@@ -126,11 +126,11 @@ static kbd_layout_t *parse_keyboard_layout(const char *language,
|
||||
if (rest && strstr(rest, "numlock")) {
|
||||
add_to_key_range(&k->keypad_range, keycode);
|
||||
add_to_key_range(&k->numlock_range, keysym);
|
||||
fprintf(stderr, "keypad keysym %04x keycode %d\n", keysym, keycode);
|
||||
//fprintf(stderr, "keypad keysym %04x keycode %d\n", keysym, keycode);
|
||||
}
|
||||
if (rest && strstr(rest, "shift")) {
|
||||
add_to_key_range(&k->shift_range, keysym);
|
||||
fprintf(stderr, "shift keysym %04x keycode %d\n", keysym, keycode);
|
||||
//fprintf(stderr, "shift keysym %04x keycode %d\n", keysym, keycode);
|
||||
}
|
||||
|
||||
/* if(keycode&0x80)
|
||||
|
||||
@@ -2520,7 +2520,7 @@ static void monitor_handle_command1(void *opaque, const char *cmdline)
|
||||
|
||||
static void monitor_start_input(void)
|
||||
{
|
||||
readline_start("(HVMXen) ", 0, monitor_handle_command1, NULL);
|
||||
readline_start("(qemu) ", 0, monitor_handle_command1, NULL);
|
||||
}
|
||||
|
||||
static void term_event(void *opaque, int event)
|
||||
|
||||
+1
-3
@@ -7611,9 +7611,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
/* Now send logs to our named config */
|
||||
sprintf(qemu_dm_logfilename, "/var/log/xen/qemu-dm-%d.log", domid);
|
||||
cpu_set_log_filename(qemu_dm_logfilename);
|
||||
cpu_set_log(0);
|
||||
|
||||
#ifndef NO_DAEMONIZE
|
||||
if (daemonize && !nographic && vnc_display == NULL && vncunused == 0) {
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||