ia64/xen-unstable

changeset 17143:e44c6b67a483

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>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Feb 28 10:29:25 2008 +0000 (2008-02-28)
parents b6cda88a3da6
children c19044cad1a3
files tools/ioemu/keymaps.c tools/ioemu/monitor.c tools/ioemu/vl.c tools/python/xen/xend/image.py
line diff
     1.1 --- a/tools/ioemu/keymaps.c	Thu Feb 28 10:21:21 2008 +0000
     1.2 +++ b/tools/ioemu/keymaps.c	Thu Feb 28 10:29:25 2008 +0000
     1.3 @@ -126,11 +126,11 @@ static kbd_layout_t *parse_keyboard_layo
     1.4  		    if (rest && strstr(rest, "numlock")) {
     1.5  			add_to_key_range(&k->keypad_range, keycode);
     1.6  			add_to_key_range(&k->numlock_range, keysym);
     1.7 -			fprintf(stderr, "keypad keysym %04x keycode %d\n", keysym, keycode);
     1.8 +			//fprintf(stderr, "keypad keysym %04x keycode %d\n", keysym, keycode);
     1.9  		    }
    1.10  		    if (rest && strstr(rest, "shift")) {
    1.11  			add_to_key_range(&k->shift_range, keysym);
    1.12 -			fprintf(stderr, "shift keysym %04x keycode %d\n", keysym, keycode);
    1.13 +			//fprintf(stderr, "shift keysym %04x keycode %d\n", keysym, keycode);
    1.14  		    }
    1.15  
    1.16  		    /* if(keycode&0x80)
     2.1 --- a/tools/ioemu/monitor.c	Thu Feb 28 10:21:21 2008 +0000
     2.2 +++ b/tools/ioemu/monitor.c	Thu Feb 28 10:29:25 2008 +0000
     2.3 @@ -2520,7 +2520,7 @@ static void monitor_handle_command1(void
     2.4  
     2.5  static void monitor_start_input(void)
     2.6  {
     2.7 -    readline_start("(HVMXen) ", 0, monitor_handle_command1, NULL);
     2.8 +    readline_start("(qemu) ", 0, monitor_handle_command1, NULL);
     2.9  }
    2.10  
    2.11  static void term_event(void *opaque, int event)
     3.1 --- a/tools/ioemu/vl.c	Thu Feb 28 10:21:21 2008 +0000
     3.2 +++ b/tools/ioemu/vl.c	Thu Feb 28 10:29:25 2008 +0000
     3.3 @@ -7611,9 +7611,7 @@ int main(int argc, char **argv)
     3.4          }
     3.5      }
     3.6  
     3.7 -    /* Now send logs to our named config */
     3.8 -    sprintf(qemu_dm_logfilename, "/var/log/xen/qemu-dm-%d.log", domid);
     3.9 -    cpu_set_log_filename(qemu_dm_logfilename);
    3.10 +    cpu_set_log(0);
    3.11  
    3.12  #ifndef NO_DAEMONIZE
    3.13      if (daemonize && !nographic && vnc_display == NULL && vncunused == 0) {
     4.1 --- a/tools/python/xen/xend/image.py	Thu Feb 28 10:21:21 2008 +0000
     4.2 +++ b/tools/python/xen/xend/image.py	Thu Feb 28 10:29:25 2008 +0000
     4.3 @@ -296,7 +296,34 @@ class ImageHandler:
     4.4                          { 'dom': self.vm.getDomid(), 'read': True, 'write': True })
     4.5          log.info("spawning device models: %s %s", self.device_model, args)
     4.6          # keep track of pid and spawned options to kill it later
     4.7 -        self.pid = os.spawnve(os.P_NOWAIT, self.device_model, args, env)
     4.8 +
     4.9 +        logfile = "/var/log/xen/qemu-dm-%s.log" %  str(self.vm.info['name_label'])
    4.10 +        if os.path.exists(logfile):
    4.11 +            if os.path.exists(logfile + ".1"):
    4.12 +                os.unlink(logfile + ".1")
    4.13 +            os.rename(logfile, logfile + ".1")
    4.14 +
    4.15 +        null = os.open("/dev/null", os.O_RDONLY)
    4.16 +        logfd = os.open(logfile, os.O_WRONLY|os.O_CREAT|os.O_TRUNC)
    4.17 +        
    4.18 +        pid = os.fork()
    4.19 +        if pid == 0: #child
    4.20 +            try:
    4.21 +                os.dup2(null, 0)
    4.22 +                os.dup2(logfd, 1)
    4.23 +                os.dup2(logfd, 2)
    4.24 +                os.close(null)
    4.25 +                os.close(logfd)
    4.26 +                try:
    4.27 +                    os.execve(self.device_model, args, env)
    4.28 +                except:
    4.29 +                    os._exit(127)
    4.30 +            except:
    4.31 +                os._exit(127)
    4.32 +        else:
    4.33 +            self.pid = pid
    4.34 +            os.close(null)
    4.35 +            os.close(logfd)
    4.36          self.vm.storeDom("image/device-model-pid", self.pid)
    4.37          log.info("device model pid: %d", self.pid)
    4.38