Revision 5fafdf24 vl.c

b/vl.c
1 1
/*
2 2
 * QEMU System Emulator
3
 * 
3
 *
4 4
 * Copyright (c) 2003-2007 Fabrice Bellard
5
 * 
5
 *
6 6
 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 7
 * of this software and associated documentation files (the "Software"), to deal
8 8
 * in the Software without restriction, including without limitation the rights
......
287 287
}
288 288

  
289 289
/* size is the word size in byte */
290
int register_ioport_read(int start, int length, int size, 
290
int register_ioport_read(int start, int length, int size,
291 291
                         IOPortReadFunc *func, void *opaque)
292 292
{
293 293
    int i, bsize;
......
312 312
}
313 313

  
314 314
/* size is the word size in byte */
315
int register_ioport_write(int start, int length, int size, 
315
int register_ioport_write(int start, int length, int size,
316 316
                          IOPortWriteFunc *func, void *opaque)
317 317
{
318 318
    int i, bsize;
......
358 358
#ifdef DEBUG_IOPORT
359 359
    if (loglevel & CPU_LOG_IOPORT)
360 360
        fprintf(logfile, "outb: %04x %02x\n", addr, val);
361
#endif    
361
#endif   
362 362
    ioport_write_table[0][addr](ioport_opaque[addr], addr, val);
363 363
#ifdef USE_KQEMU
364 364
    if (env)
......
371 371
#ifdef DEBUG_IOPORT
372 372
    if (loglevel & CPU_LOG_IOPORT)
373 373
        fprintf(logfile, "outw: %04x %04x\n", addr, val);
374
#endif    
374
#endif   
375 375
    ioport_write_table[1][addr](ioport_opaque[addr], addr, val);
376 376
#ifdef USE_KQEMU
377 377
    if (env)
......
634 634
            uint32_t high, low;
635 635
#else
636 636
            uint32_t low, high;
637
#endif            
637
#endif           
638 638
        } l;
639 639
    } u, res;
640 640
    uint64_t rl, rh;
......
700 700
        struct timespec ts;
701 701
        clock_gettime(CLOCK_MONOTONIC, &ts);
702 702
        return ts.tv_sec * 1000000000LL + ts.tv_nsec;
703
    } else 
703
    } else
704 704
#endif
705 705
    {
706 706
        /* XXX: using gettimeofday leads to problems if the date
......
774 774

  
775 775
/***********************************************************/
776 776
/* timers */
777
 
777

  
778 778
#define QEMU_TIMER_REALTIME 0
779 779
#define QEMU_TIMER_VIRTUAL  1
780 780

  
......
1008 1008
        t = *pt;
1009 1009
        if (!t)
1010 1010
            break;
1011
        if (t->expire_time > expire_time) 
1011
        if (t->expire_time > expire_time)
1012 1012
            break;
1013 1013
        pt = &t->next;
1014 1014
    }
......
1037 1037
static void qemu_run_timers(QEMUTimer **ptimer_head, int64_t current_time)
1038 1038
{
1039 1039
    QEMUTimer *ts;
1040
    
1040
   
1041 1041
    for(;;) {
1042 1042
        ts = *ptimer_head;
1043 1043
        if (!ts || ts->expire_time > current_time)
......
1045 1045
        /* remove timer from the list before calling the callback */
1046 1046
        *ptimer_head = ts->next;
1047 1047
        ts->next = NULL;
1048
        
1048
       
1049 1049
        /* run the callback (the timer list can be modified) */
1050 1050
        ts->cb(ts->opaque);
1051 1051
    }
......
1122 1122
}
1123 1123

  
1124 1124
#ifdef _WIN32
1125
void CALLBACK host_alarm_handler(UINT uTimerID, UINT uMsg, 
1125
void CALLBACK host_alarm_handler(UINT uTimerID, UINT uMsg,
1126 1126
                                 DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2)
1127 1127
#else
1128 1128
static void host_alarm_handler(int host_signum)
......
1606 1606
        s->chr_send_event(s, event);
1607 1607
}
1608 1608

  
1609
void qemu_chr_add_handlers(CharDriverState *s, 
1610
                           IOCanRWHandler *fd_can_read, 
1609
void qemu_chr_add_handlers(CharDriverState *s,
1610
                           IOCanRWHandler *fd_can_read,
1611 1611
                           IOReadHandler *fd_read,
1612 1612
                           IOEventHandler *fd_event,
1613 1613
                           void *opaque)
......
1619 1619
    if (s->chr_update_read_handler)
1620 1620
        s->chr_update_read_handler(s);
1621 1621
}
1622
             
1622
            
1623 1623
static int null_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
1624 1624
{
1625 1625
    return len;
......
1874 1874
static int send_all(int fd, const uint8_t *buf, int len1)
1875 1875
{
1876 1876
    int ret, len;
1877
    
1877
   
1878 1878
    len = len1;
1879 1879
    while (len > 0) {
1880 1880
        ret = send(fd, buf, len, 0);
......
1964 1964
    FDCharDriver *s = chr->opaque;
1965 1965
    int size, len;
1966 1966
    uint8_t buf[1024];
1967
    
1967
   
1968 1968
    len = sizeof(buf);
1969 1969
    if (len > s->max_size)
1970 1970
        len = s->max_size;
......
1988 1988
    if (s->fd_in >= 0) {
1989 1989
        if (nographic && s->fd_in == 0) {
1990 1990
        } else {
1991
            qemu_set_fd_handler2(s->fd_in, fd_chr_read_poll, 
1991
            qemu_set_fd_handler2(s->fd_in, fd_chr_read_poll,
1992 1992
                                 fd_chr_read, NULL, chr);
1993 1993
        }
1994 1994
    }
......
2125 2125
    tty.c_cflag |= CS8;
2126 2126
    tty.c_cc[VMIN] = 1;
2127 2127
    tty.c_cc[VTIME] = 0;
2128
    
2128
   
2129 2129
    tcsetattr (0, TCSANOW, &tty);
2130 2130

  
2131 2131
    atexit(term_exit);
......
2153 2153
    struct termios tty;
2154 2154
    char slave_name[1024];
2155 2155
    int master_fd, slave_fd;
2156
    
2156
   
2157 2157
#if defined(__linux__)
2158 2158
    /* Not satisfying */
2159 2159
    if (openpty(&master_fd, &slave_fd, slave_name, NULL, NULL) < 0) {
2160 2160
        return NULL;
2161 2161
    }
2162 2162
#endif
2163
    
2163
   
2164 2164
    /* Disabling local echo and line-buffered output */
2165 2165
    tcgetattr (master_fd, &tty);
2166 2166
    tty.c_lflag &= ~(ECHO|ICANON|ISIG);
......
2172 2172
    return qemu_chr_open_fd(master_fd, master_fd);
2173 2173
}
2174 2174

  
2175
static void tty_serial_init(int fd, int speed, 
2175
static void tty_serial_init(int fd, int speed,
2176 2176
                            int parity, int data_bits, int stop_bits)
2177 2177
{
2178 2178
    struct termios tty;
2179 2179
    speed_t spd;
2180 2180

  
2181 2181
#if 0
2182
    printf("tty_serial_init: speed=%d parity=%c data=%d stop=%d\n", 
2182
    printf("tty_serial_init: speed=%d parity=%c data=%d stop=%d\n",
2183 2183
           speed, parity, data_bits, stop_bits);
2184 2184
#endif
2185 2185
    tcgetattr (fd, &tty);
......
2260 2260
    }
2261 2261
    if (stop_bits == 2)
2262 2262
        tty.c_cflag |= CSTOPB;
2263
    
2263
   
2264 2264
    tcsetattr (fd, TCSANOW, &tty);
2265 2265
}
2266 2266

  
2267 2267
static int tty_serial_ioctl(CharDriverState *chr, int cmd, void *arg)
2268 2268
{
2269 2269
    FDCharDriver *s = chr->opaque;
2270
    
2270
   
2271 2271
    switch(cmd) {
2272 2272
    case CHR_IOCTL_SERIAL_SET_PARAMS:
2273 2273
        {
2274 2274
            QEMUSerialSetParams *ssp = arg;
2275
            tty_serial_init(s->fd_in, ssp->speed, ssp->parity, 
2275
            tty_serial_init(s->fd_in, ssp->speed, ssp->parity,
2276 2276
                            ssp->data_bits, ssp->stop_bits);
2277 2277
        }
2278 2278
        break;
......
2506 2506
    COMSTAT comstat;
2507 2507
    DWORD size;
2508 2508
    DWORD err;
2509
    
2509
   
2510 2510
    s->hsend = CreateEvent(NULL, TRUE, FALSE, NULL);
2511 2511
    if (!s->hsend) {
2512 2512
        fprintf(stderr, "Failed CreateEvent\n");
......
2525 2525
        s->hcom = NULL;
2526 2526
        goto fail;
2527 2527
    }
2528
    
2528
   
2529 2529
    if (!SetupComm(s->hcom, NRECVBUF, NSENDBUF)) {
2530 2530
        fprintf(stderr, "Failed SetupComm\n");
2531 2531
        goto fail;
2532 2532
    }
2533
    
2533
   
2534 2534
    ZeroMemory(&comcfg, sizeof(COMMCONFIG));
2535 2535
    size = sizeof(COMMCONFIG);
2536 2536
    GetDefaultCommConfig(filename, &comcfg, &size);
......
2552 2552
        fprintf(stderr, "Failed SetCommTimeouts\n");
2553 2553
        goto fail;
2554 2554
    }
2555
    
2555
   
2556 2556
    if (!ClearCommError(s->hcom, &err, &comstat)) {
2557 2557
        fprintf(stderr, "Failed ClearCommError\n");
2558 2558
        goto fail;
......
2613 2613
    int ret, err;
2614 2614
    uint8_t buf[1024];
2615 2615
    DWORD size;
2616
    
2616
   
2617 2617
    ZeroMemory(&s->orecv, sizeof(s->orecv));
2618 2618
    s->orecv.hEvent = s->hrecv;
2619 2619
    ret = ReadFile(s->hcom, buf, s->len, &size, &s->orecv);
......
2637 2637
        s->len = s->max_size;
2638 2638
    if (s->len == 0)
2639 2639
        return;
2640
    
2640
   
2641 2641
    win_chr_readfile(chr);
2642 2642
}
2643 2643

  
......
2647 2647
    WinCharState *s = chr->opaque;
2648 2648
    COMSTAT status;
2649 2649
    DWORD comerr;
2650
    
2650
   
2651 2651
    ClearCommError(s->hcom, &comerr, &status);
2652 2652
    if (status.cbInQue > 0) {
2653 2653
        s->len = status.cbInQue;
......
2662 2662
{
2663 2663
    CharDriverState *chr;
2664 2664
    WinCharState *s;
2665
    
2665
   
2666 2666
    chr = qemu_mallocz(sizeof(CharDriverState));
2667 2667
    if (!chr)
2668 2668
        return NULL;
......
2707 2707
    int ret;
2708 2708
    DWORD size;
2709 2709
    char openname[256];
2710
    
2710
   
2711 2711
    s->fpipe = TRUE;
2712 2712

  
2713 2713
    s->hsend = CreateEvent(NULL, TRUE, FALSE, NULL);
......
2720 2720
        fprintf(stderr, "Failed CreateEvent\n");
2721 2721
        goto fail;
2722 2722
    }
2723
    
2723
   
2724 2724
    snprintf(openname, sizeof(openname), "\\\\.\\pipe\\%s", filename);
2725 2725
    s->hcom = CreateNamedPipe(openname, PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
2726 2726
                              PIPE_TYPE_BYTE | PIPE_READMODE_BYTE |
......
2779 2779
    chr->opaque = s;
2780 2780
    chr->chr_write = win_chr_write;
2781 2781
    chr->chr_close = win_chr_close;
2782
    
2782
   
2783 2783
    if (win_chr_pipe_init(chr, filename) < 0) {
2784 2784
        free(s);
2785 2785
        free(chr);
......
2817 2817
static CharDriverState *qemu_chr_open_win_file_out(const char *file_out)
2818 2818
{
2819 2819
    HANDLE fd_out;
2820
    
2820
   
2821 2821
    fd_out = CreateFile(file_out, GENERIC_WRITE, FILE_SHARE_READ, NULL,
2822 2822
                        OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
2823 2823
    if (fd_out == INVALID_HANDLE_VALUE)
......
3149 3149
    qemu_free(s);
3150 3150
}
3151 3151

  
3152
static CharDriverState *qemu_chr_open_tcp(const char *host_str, 
3152
static CharDriverState *qemu_chr_open_tcp(const char *host_str,
3153 3153
                                          int is_telnet,
3154 3154
					  int is_unix)
3155 3155
{
......
3212 3212
    else
3213 3213
#endif
3214 3214
	fd = socket(PF_INET, SOCK_STREAM, 0);
3215
	
3216
    if (fd < 0) 
3215

  
3216
    if (fd < 0)
3217 3217
        goto fail;
3218 3218

  
3219 3219
    if (!is_waitconnect)
......
3243 3243
	    val = 1;
3244 3244
	    setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (const char *)&val, sizeof(val));
3245 3245
	}
3246
        
3246
       
3247 3247
        ret = bind(fd, addr, addrlen);
3248 3248
        if (ret < 0)
3249 3249
            goto fail;
......
3283 3283
        else
3284 3284
            qemu_set_fd_handler(s->fd, NULL, tcp_chr_connect, chr);
3285 3285
    }
3286
    
3286
   
3287 3287
    if (is_listen && is_waitconnect) {
3288 3288
        printf("QEMU waiting for connection on: %s\n", host_str);
3289 3289
        tcp_chr_accept(chr);
......
3309 3309
        return text_console_init(&display_state, p);
3310 3310
    } else if (!strcmp(filename, "null")) {
3311 3311
        return qemu_chr_open_null();
3312
    } else 
3312
    } else
3313 3313
    if (strstart(filename, "tcp:", &p)) {
3314 3314
        return qemu_chr_open_tcp(p, 0, 0);
3315 3315
    } else
......
3340 3340
        return qemu_chr_open_pty();
3341 3341
    } else if (!strcmp(filename, "stdio")) {
3342 3342
        return qemu_chr_open_stdio();
3343
    } else 
3343
    } else
3344 3344
#if defined(__linux__)
3345 3345
    if (strstart(filename, "/dev/parport", NULL)) {
3346 3346
        return qemu_chr_open_pp(filename);
3347
    } else 
3347
    } else
3348 3348
#endif
3349 3349
#if defined(__linux__) || defined(__sun__)
3350 3350
    if (strstart(filename, "/dev/", NULL)) {
......
3411 3411
    for(i = 0; i < 6; i++) {
3412 3412
        macaddr[i] = strtol(p, (char **)&p, 16);
3413 3413
        if (i == 5) {
3414
            if (*p != '\0') 
3414
            if (*p != '\0')
3415 3415
                return -1;
3416 3416
        } else {
3417
            if (*p != ':') 
3417
            if (*p != ':')
3418 3418
                return -1;
3419 3419
            p++;
3420 3420
        }
......
3641 3641
        slirp_inited = 1;
3642 3642
        slirp_init();
3643 3643
    }
3644
    slirp_vc = qemu_new_vlan_client(vlan, 
3644
    slirp_vc = qemu_new_vlan_client(vlan,
3645 3645
                                    slirp_receive, NULL, NULL);
3646 3646
    snprintf(slirp_vc->info_str, sizeof(slirp_vc->info_str), "user redirector");
3647 3647
    return 0;
......
3654 3654
    const char *p;
3655 3655
    struct in_addr guest_addr;
3656 3656
    int host_port, guest_port;
3657
    
3657
   
3658 3658
    if (!slirp_inited) {
3659 3659
        slirp_inited = 1;
3660 3660
        slirp_init();
......
3684 3684
    }
3685 3685
    if (!inet_aton(buf, &guest_addr))
3686 3686
        goto fail;
3687
    
3687
   
3688 3688
    guest_port = strtol(p, &r, 0);
3689 3689
    if (r == p)
3690 3690
        goto fail;
3691
    
3691
   
3692 3692
    if (slirp_redir(is_udp, host_port, guest_addr, guest_port) < 0) {
3693 3693
        fprintf(stderr, "qemu: could not set up redirection\n");
3694 3694
        exit(1);
......
3698 3698
    fprintf(stderr, "qemu: syntax: -redir [tcp|udp]:host-port:[guest-host]:guest-port\n");
3699 3699
    exit(1);
3700 3700
}
3701
    
3701
   
3702 3702
#ifndef _WIN32
3703 3703

  
3704 3704
char smb_dir[1024];
......
3717 3717
            break;
3718 3718
        if (strcmp(de->d_name, ".") != 0 &&
3719 3719
            strcmp(de->d_name, "..") != 0) {
3720
            snprintf(filename, sizeof(filename), "%s/%s", 
3720
            snprintf(filename, sizeof(filename), "%s/%s",
3721 3721
                     smb_dir, de->d_name);
3722 3722
            unlink(filename);
3723 3723
        }
......
3745 3745
        exit(1);
3746 3746
    }
3747 3747
    snprintf(smb_conf, sizeof(smb_conf), "%s/%s", smb_dir, "smb.conf");
3748
    
3748
   
3749 3749
    f = fopen(smb_conf, "w");
3750 3750
    if (!f) {
3751 3751
        fprintf(stderr, "qemu: could not create samba server configuration file '%s'\n", smb_conf);
3752 3752
        exit(1);
3753 3753
    }
3754
    fprintf(f, 
3754
    fprintf(f,
3755 3755
            "[global]\n"
3756 3756
            "private dir=%s\n"
3757 3757
            "smb ports=0\n"
......
3777 3777

  
3778 3778
    snprintf(smb_cmdline, sizeof(smb_cmdline), "%s -s %s",
3779 3779
             SMBD_COMMAND, smb_conf);
3780
    
3780
   
3781 3781
    slirp_add_exec(0, smb_cmdline, 4, 139);
3782 3782
}
3783 3783

  
......
3863 3863
}
3864 3864
#elif defined(__sun__)
3865 3865
#define TUNNEWPPA       (('T'<<16) | 0x0001)
3866
/* 
3867
 * Allocate TAP device, returns opened fd. 
3866
/*
3867
 * Allocate TAP device, returns opened fd.
3868 3868
 * Stores dev name in the first arg(must be large enough).
3869
 */  
3869
 */ 
3870 3870
int tap_alloc(char *dev)
3871 3871
{
3872 3872
    int tap_fd, if_fd, ppa = -1;
......
3883 3883
    memset(&ifr, 0x0, sizeof(ifr));
3884 3884

  
3885 3885
    if( *dev ){
3886
       ptr = dev;	
3887
       while( *ptr && !isdigit((int)*ptr) ) ptr++; 
3886
       ptr = dev;
3887
       while( *ptr && !isdigit((int)*ptr) ) ptr++;
3888 3888
       ppa = atoi(ptr);
3889 3889
    }
3890 3890

  
......
4001 4001
{
4002 4002
    struct ifreq ifr;
4003 4003
    int fd, ret;
4004
    
4004
   
4005 4005
    TFR(fd = open("/dev/net/tun", O_RDWR));
4006 4006
    if (fd < 0) {
4007 4007
        fprintf(stderr, "warning: could not open /dev/net/tun: no virtual network emulation\n");
......
4076 4076
    s = net_tap_fd_init(vlan, fd);
4077 4077
    if (!s)
4078 4078
        return -1;
4079
    snprintf(s->vc->info_str, sizeof(s->vc->info_str), 
4079
    snprintf(s->vc->info_str, sizeof(s->vc->info_str),
4080 4080
             "tap: ifname=%s setup_script=%s", ifname, setup_script);
4081 4081
    return 0;
4082 4082
}
......
4113 4113
static void net_socket_receive_dgram(void *opaque, const uint8_t *buf, int size)
4114 4114
{
4115 4115
    NetSocketState *s = opaque;
4116
    sendto(s->fd, buf, size, 0, 
4116
    sendto(s->fd, buf, size, 0,
4117 4117
           (struct sockaddr *)&s->dgram_dst, sizeof(s->dgram_dst));
4118 4118
}
4119 4119

  
......
4127 4127
    size = recv(s->fd, buf1, sizeof(buf1), 0);
4128 4128
    if (size < 0) {
4129 4129
        err = socket_error();
4130
        if (err != EWOULDBLOCK) 
4130
        if (err != EWOULDBLOCK)
4131 4131
            goto eoc;
4132 4132
    } else if (size == 0) {
4133 4133
        /* end of connection */
......
4179 4179
    int size;
4180 4180

  
4181 4181
    size = recv(s->fd, s->buf, sizeof(s->buf), 0);
4182
    if (size < 0) 
4182
    if (size < 0)
4183 4183
        return;
4184 4184
    if (size == 0) {
4185 4185
        /* end of connection */
......
4196 4196
    int val, ret;
4197 4197
    if (!IN_MULTICAST(ntohl(mcastaddr->sin_addr.s_addr))) {
4198 4198
	fprintf(stderr, "qemu: error: specified mcastaddr \"%s\" (0x%08x) does not contain a multicast address\n",
4199
		inet_ntoa(mcastaddr->sin_addr), 
4199
		inet_ntoa(mcastaddr->sin_addr),
4200 4200
                (int)ntohl(mcastaddr->sin_addr.s_addr));
4201 4201
	return -1;
4202 4202

  
......
4208 4208
    }
4209 4209

  
4210 4210
    val = 1;
4211
    ret=setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, 
4211
    ret=setsockopt(fd, SOL_SOCKET, SO_REUSEADDR,
4212 4212
                   (const char *)&val, sizeof(val));
4213 4213
    if (ret < 0) {
4214 4214
	perror("setsockopt(SOL_SOCKET, SO_REUSEADDR)");
......
4220 4220
        perror("bind");
4221 4221
        goto fail;
4222 4222
    }
4223
    
4223
   
4224 4224
    /* Add host to multicast group */
4225 4225
    imr.imr_multiaddr = mcastaddr->sin_addr;
4226 4226
    imr.imr_interface.s_addr = htonl(INADDR_ANY);
4227 4227

  
4228
    ret = setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, 
4228
    ret = setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP,
4229 4229
                     (const char *)&imr, sizeof(struct ip_mreq));
4230 4230
    if (ret < 0) {
4231 4231
	perror("setsockopt(IP_ADD_MEMBERSHIP)");
......
4234 4234

  
4235 4235
    /* Force mcast msgs to loopback (eg. several QEMUs in same host */
4236 4236
    val = 1;
4237
    ret=setsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP, 
4237
    ret=setsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP,
4238 4238
                   (const char *)&val, sizeof(val));
4239 4239
    if (ret < 0) {
4240 4240
	perror("setsockopt(SOL_IP, IP_MULTICAST_LOOP)");
......
4244 4244
    socket_set_nonblock(fd);
4245 4245
    return fd;
4246 4246
fail:
4247
    if (fd >= 0) 
4247
    if (fd >= 0)
4248 4248
        closesocket(fd);
4249 4249
    return -1;
4250 4250
}
4251 4251

  
4252
static NetSocketState *net_socket_fd_init_dgram(VLANState *vlan, int fd, 
4252
static NetSocketState *net_socket_fd_init_dgram(VLANState *vlan, int fd,
4253 4253
                                          int is_connected)
4254 4254
{
4255 4255
    struct sockaddr_in saddr;
......
4258 4258
    NetSocketState *s;
4259 4259

  
4260 4260
    /* fd passed: multicast: "learn" dgram_dst address from bound address and save it
4261
     * Because this may be "shared" socket from a "master" process, datagrams would be recv() 
4261
     * Because this may be "shared" socket from a "master" process, datagrams would be recv()
4262 4262
     * by ONLY ONE process: we must "clone" this dgram socket --jjo
4263 4263
     */
4264 4264

  
......
4280 4280
	    /* clone newfd to fd, close newfd */
4281 4281
	    dup2(newfd, fd);
4282 4282
	    close(newfd);
4283
	
4283

  
4284 4284
	} else {
4285 4285
	    fprintf(stderr, "qemu: error: init_dgram: fd=%d failed getsockname(): %s\n",
4286 4286
		    fd, strerror(errno));
......
4300 4300
    if (is_connected) s->dgram_dst=saddr;
4301 4301

  
4302 4302
    snprintf(s->vc->info_str, sizeof(s->vc->info_str),
4303
	    "socket: fd=%d (%s mcast=%s:%d)", 
4303
	    "socket: fd=%d (%s mcast=%s:%d)",
4304 4304
	    fd, is_connected? "cloned" : "",
4305 4305
	    inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
4306 4306
    return s;
......
4312 4312
    qemu_set_fd_handler(s->fd, net_socket_send, NULL, s);
4313 4313
}
4314 4314

  
4315
static NetSocketState *net_socket_fd_init_stream(VLANState *vlan, int fd, 
4315
static NetSocketState *net_socket_fd_init_stream(VLANState *vlan, int fd,
4316 4316
                                          int is_connected)
4317 4317
{
4318 4318
    NetSocketState *s;
......
4320 4320
    if (!s)
4321 4321
        return NULL;
4322 4322
    s->fd = fd;
4323
    s->vc = qemu_new_vlan_client(vlan, 
4323
    s->vc = qemu_new_vlan_client(vlan,
4324 4324
                                 net_socket_receive, NULL, s);
4325 4325
    snprintf(s->vc->info_str, sizeof(s->vc->info_str),
4326 4326
             "socket: fd=%d", fd);
......
4332 4332
    return s;
4333 4333
}
4334 4334

  
4335
static NetSocketState *net_socket_fd_init(VLANState *vlan, int fd, 
4335
static NetSocketState *net_socket_fd_init(VLANState *vlan, int fd,
4336 4336
                                          int is_connected)
4337 4337
{
4338 4338
    int so_type=-1, optlen=sizeof(so_type);
......
4356 4356

  
4357 4357
static void net_socket_accept(void *opaque)
4358 4358
{
4359
    NetSocketListenState *s = opaque;    
4359
    NetSocketListenState *s = opaque;   
4360 4360
    NetSocketState *s1;
4361 4361
    struct sockaddr_in saddr;
4362 4362
    socklen_t len;
......
4371 4371
            break;
4372 4372
        }
4373 4373
    }
4374
    s1 = net_socket_fd_init(s->vlan, fd, 1); 
4374
    s1 = net_socket_fd_init(s->vlan, fd, 1);
4375 4375
    if (!s1) {
4376 4376
        closesocket(fd);
4377 4377
    } else {
4378 4378
        snprintf(s1->vc->info_str, sizeof(s1->vc->info_str),
4379
                 "socket: connection from %s:%d", 
4379
                 "socket: connection from %s:%d",
4380 4380
                 inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
4381 4381
    }
4382 4382
}
......
4389 4389

  
4390 4390
    if (parse_host_port(&saddr, host_str) < 0)
4391 4391
        return -1;
4392
    
4392
   
4393 4393
    s = qemu_mallocz(sizeof(NetSocketListenState));
4394 4394
    if (!s)
4395 4395
        return -1;
......
4404 4404
    /* allow fast reuse */
4405 4405
    val = 1;
4406 4406
    setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (const char *)&val, sizeof(val));
4407
    
4407
   
4408 4408
    ret = bind(fd, (struct sockaddr *)&saddr, sizeof(saddr));
4409 4409
    if (ret < 0) {
4410 4410
        perror("bind");
......
4463 4463
    if (!s)
4464 4464
        return -1;
4465 4465
    snprintf(s->vc->info_str, sizeof(s->vc->info_str),
4466
             "socket: connect to %s:%d", 
4466
             "socket: connect to %s:%d",
4467 4467
             inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
4468 4468
    return 0;
4469 4469
}
......
4487 4487
        return -1;
4488 4488

  
4489 4489
    s->dgram_dst = saddr;
4490
    
4490
   
4491 4491
    snprintf(s->vc->info_str, sizeof(s->vc->info_str),
4492
             "socket: mcast=%s:%d", 
4492
             "socket: mcast=%s:%d",
4493 4493
             inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
4494 4494
    return 0;
4495 4495

  
......
4666 4666
    if (ret < 0) {
4667 4667
        fprintf(stderr, "Could not initialize device '%s'\n", device);
4668 4668
    }
4669
    
4669
   
4670 4670
    return ret;
4671 4671
}
4672 4672

  
......
4760 4760
        return -1;
4761 4761

  
4762 4762
    p = strchr(devname, '.');
4763
    if (!p) 
4763
    if (!p)
4764 4764
        return -1;
4765 4765
    bus_num = strtoul(devname, NULL, 0);
4766 4766
    addr = strtoul(p + 1, NULL, 0);
......
4790 4790
{
4791 4791
    int ret;
4792 4792
    ret = usb_device_add(devname);
4793
    if (ret < 0) 
4793
    if (ret < 0)
4794 4794
        term_printf("Could not add USB device '%s'\n", devname);
4795 4795
}
4796 4796

  
......
4798 4798
{
4799 4799
    int ret;
4800 4800
    ret = usb_device_del(devname);
4801
    if (ret < 0) 
4801
    if (ret < 0)
4802 4802
        term_printf("Could not remove USB device '%s'\n", devname);
4803 4803
}
4804 4804

  
......
4818 4818
        if (!dev)
4819 4819
            continue;
4820 4820
        switch(dev->speed) {
4821
        case USB_SPEED_LOW: 
4822
            speed_str = "1.5"; 
4821
        case USB_SPEED_LOW:
4822
            speed_str = "1.5";
4823 4823
            break;
4824
        case USB_SPEED_FULL: 
4825
            speed_str = "12"; 
4824
        case USB_SPEED_FULL:
4825
            speed_str = "12";
4826 4826
            break;
4827
        case USB_SPEED_HIGH: 
4828
            speed_str = "480"; 
4827
        case USB_SPEED_HIGH:
4828
            speed_str = "480";
4829 4829
            break;
4830 4830
        default:
4831
            speed_str = "?"; 
4831
            speed_str = "?";
4832 4832
            break;
4833 4833
        }
4834
        term_printf("  Device %d.%d, Speed %s Mb/s, Product %s\n", 
4834
        term_printf("  Device %d.%d, Speed %s Mb/s, Product %s\n",
4835 4835
                    0, dev->addr, speed_str, dev->devname);
4836 4836
    }
4837 4837
}
......
4927 4927

  
4928 4928
/* XXX: fd_read_poll should be suppressed, but an API change is
4929 4929
   necessary in the character devices to suppress fd_can_read(). */
4930
int qemu_set_fd_handler2(int fd, 
4931
                         IOCanRWHandler *fd_read_poll, 
4932
                         IOHandler *fd_read, 
4933
                         IOHandler *fd_write, 
4930
int qemu_set_fd_handler2(int fd,
4931
                         IOCanRWHandler *fd_read_poll,
4932
                         IOHandler *fd_read,
4933
                         IOHandler *fd_write,
4934 4934
                         void *opaque)
4935 4935
{
4936 4936
    IOHandlerRecord **pioh, *ioh;
......
4968 4968
    return 0;
4969 4969
}
4970 4970

  
4971
int qemu_set_fd_handler(int fd, 
4972
                        IOHandler *fd_read, 
4973
                        IOHandler *fd_write, 
4971
int qemu_set_fd_handler(int fd,
4972
                        IOHandler *fd_read,
4973
                        IOHandler *fd_write,
4974 4974
                        void *opaque)
4975 4975
{
4976 4976
    return qemu_set_fd_handler2(fd, NULL, fd_read, fd_write, opaque);
......
5024 5024
} WaitObjects;
5025 5025

  
5026 5026
static WaitObjects wait_objects = {0};
5027
    
5027
   
5028 5028
int qemu_add_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque)
5029 5029
{
5030 5030
    WaitObjects *w = &wait_objects;
......
5051 5051
            w->events[i] = w->events[i + 1];
5052 5052
            w->func[i] = w->func[i + 1];
5053 5053
            w->opaque[i] = w->opaque[i + 1];
5054
        }            
5054
        }           
5055 5055
    }
5056 5056
    if (found)
5057 5057
        w->num--;
......
5125 5125
            fseek(f->outfile, f->buf_offset, SEEK_SET);
5126 5126
            fwrite(f->buf, 1, f->buf_index, f->outfile);
5127 5127
        } else {
5128
            bdrv_pwrite(f->bs, f->base_offset + f->buf_offset, 
5128
            bdrv_pwrite(f->bs, f->base_offset + f->buf_offset,
5129 5129
                        f->buf, f->buf_index);
5130 5130
        }
5131 5131
        f->buf_offset += f->buf_index;
......
5145 5145
        if (len < 0)
5146 5146
            len = 0;
5147 5147
    } else {
5148
        len = bdrv_pread(f->bs, f->base_offset + f->buf_offset, 
5148
        len = bdrv_pread(f->bs, f->base_offset + f->buf_offset,
5149 5149
                         f->buf, IO_BUF_SIZE);
5150 5150
        if (len < 0)
5151 5151
            len = 0;
......
5305 5305

  
5306 5306
static SaveStateEntry *first_se;
5307 5307

  
5308
int register_savevm(const char *idstr, 
5309
                    int instance_id, 
5308
int register_savevm(const char *idstr,
5309
                    int instance_id,
5310 5310
                    int version_id,
5311 5311
                    SaveStateHandler *save_state,
5312 5312
                    LoadStateHandler *load_state,
......
5359 5359
        /* record size: filled later */
5360 5360
        len_pos = qemu_ftell(f);
5361 5361
        qemu_put_be32(f, 0);
5362
        
5362
       
5363 5363
        se->save_state(f, se->opaque);
5364 5364

  
5365 5365
        /* fill record size */
......
5383 5383
    SaveStateEntry *se;
5384 5384

  
5385 5385
    for(se = first_se; se != NULL; se = se->next) {
5386
        if (!strcmp(se->idstr, idstr) && 
5386
        if (!strcmp(se->idstr, idstr) &&
5387 5387
            instance_id == se->instance_id)
5388 5388
            return se;
5389 5389
    }
......
5397 5397
    int64_t total_len, end_pos, cur_pos;
5398 5398
    unsigned int v;
5399 5399
    char idstr[256];
5400
    
5400
   
5401 5401
    v = qemu_get_be32(f);
5402 5402
    if (v != QEMU_VM_FILE_MAGIC)
5403 5403
        goto fail;
......
5419 5419
        version_id = qemu_get_be32(f);
5420 5420
        record_len = qemu_get_be32(f);
5421 5421
#if 0
5422
        printf("idstr=%s instance=0x%x version=%d len=%d\n", 
5422
        printf("idstr=%s instance=0x%x version=%d len=%d\n",
5423 5423
               idstr, instance_id, version_id, record_len);
5424 5424
#endif
5425 5425
        cur_pos = qemu_ftell(f);
5426 5426
        se = find_se(idstr, instance_id);
5427 5427
        if (!se) {
5428
            fprintf(stderr, "qemu: warning: instance 0x%x of device '%s' not present in current VM\n", 
5428
            fprintf(stderr, "qemu: warning: instance 0x%x of device '%s' not present in current VM\n",
5429 5429
                    instance_id, idstr);
5430 5430
        } else {
5431 5431
            ret = se->load_state(f, se->opaque, version_id);
5432 5432
            if (ret < 0) {
5433
                fprintf(stderr, "qemu: warning: error while loading state for instance 0x%x of device '%s'\n", 
5433
                fprintf(stderr, "qemu: warning: error while loading state for instance 0x%x of device '%s'\n",
5434 5434
                        instance_id, idstr);
5435 5435
            }
5436 5436
        }
......
5481 5481
{
5482 5482
    QEMUSnapshotInfo *sn_tab, *sn;
5483 5483
    int nb_sns, i, ret;
5484
    
5484
   
5485 5485
    ret = -ENOENT;
5486 5486
    nb_sns = bdrv_snapshot_list(bs, &sn_tab);
5487 5487
    if (nb_sns < 0)
......
5523 5523

  
5524 5524
    saved_vm_running = vm_running;
5525 5525
    vm_stop(0);
5526
    
5526
   
5527 5527
    must_delete = 0;
5528 5528
    if (name) {
5529 5529
        ret = bdrv_snapshot_find(bs, old_sn, name);
......
5551 5551
    sn->date_nsec = tv.tv_usec * 1000;
5552 5552
#endif
5553 5553
    sn->vm_clock_nsec = qemu_get_clock(vm_clock);
5554
    
5554
   
5555 5555
    if (bdrv_get_info(bs, bdi) < 0 || bdi->vm_state_offset <= 0) {
5556 5556
        term_printf("Device %s does not support VM state snapshots\n",
5557 5557
                    bdrv_get_device_name(bs));
5558 5558
        goto the_end;
5559 5559
    }
5560
    
5560
   
5561 5561
    /* save the VM state */
5562 5562
    f = qemu_fopen_bdrv(bs, bdi->vm_state_offset, 1);
5563 5563
    if (!f) {
......
5571 5571
        term_printf("Error %d while writing VM\n", ret);
5572 5572
        goto the_end;
5573 5573
    }
5574
    
5574
   
5575 5575
    /* create the snapshots */
5576 5576

  
5577 5577
    for(i = 0; i < MAX_DISKS; i++) {
......
5610 5610
        term_printf("No block device supports snapshots\n");
5611 5611
        return;
5612 5612
    }
5613
    
5613
   
5614 5614
    /* Flush all IO requests so they don't interfere with the new state.  */
5615 5615
    qemu_aio_flush();
5616 5616

  
......
5650 5650
                    bdrv_get_device_name(bs));
5651 5651
        return;
5652 5652
    }
5653
    
5653
   
5654 5654
    /* restore the VM state */
5655 5655
    f = qemu_fopen_bdrv(bs, bdi->vm_state_offset, 0);
5656 5656
    if (!f) {
......
5677 5677
        term_printf("No block device supports snapshots\n");
5678 5678
        return;
5679 5679
    }
5680
    
5680
   
5681 5681
    for(i = 0; i <= MAX_DISKS; i++) {
5682 5682
        bs1 = bs_table[i];
5683 5683
        if (bdrv_has_snapshot(bs1)) {
......
5757 5757
    uint16_t fptag, fpus, fpuc, fpregs_format;
5758 5758
    uint32_t hflags;
5759 5759
    int i;
5760
    
5760
   
5761 5761
    for(i = 0; i < CPU_NB_REGS; i++)
5762 5762
        qemu_put_betls(f, &env->regs[i]);
5763 5763
    qemu_put_betls(f, &env->eip);
5764 5764
    qemu_put_betls(f, &env->eflags);
5765 5765
    hflags = env->hflags; /* XXX: suppress most of the redundant hflags */
5766 5766
    qemu_put_be32s(f, &hflags);
5767
    
5767
   
5768 5768
    /* FPU */
5769 5769
    fpuc = env->fpuc;
5770 5770
    fpus = (env->fpus & ~0x3800) | (env->fpstt & 0x7) << 11;
......
5772 5772
    for(i = 0; i < 8; i++) {
5773 5773
        fptag |= ((!env->fptags[i]) << i);
5774 5774
    }
5775
    
5775
   
5776 5776
    qemu_put_be16s(f, &fpuc);
5777 5777
    qemu_put_be16s(f, &fpus);
5778 5778
    qemu_put_be16s(f, &fptag);
......
5783 5783
    fpregs_format = 1;
5784 5784
#endif
5785 5785
    qemu_put_be16s(f, &fpregs_format);
5786
    
5786
   
5787 5787
    for(i = 0; i < 8; i++) {
5788 5788
#ifdef USE_X86LDOUBLE
5789 5789
        {
......
5810 5810
    cpu_put_seg(f, &env->tr);
5811 5811
    cpu_put_seg(f, &env->gdt);
5812 5812
    cpu_put_seg(f, &env->idt);
5813
    
5813
   
5814 5814
    qemu_put_be32s(f, &env->sysenter_cs);
5815 5815
    qemu_put_be32s(f, &env->sysenter_esp);
5816 5816
    qemu_put_be32s(f, &env->sysenter_eip);
5817
    
5817
   
5818 5818
    qemu_put_betls(f, &env->cr[0]);
5819 5819
    qemu_put_betls(f, &env->cr[2]);
5820 5820
    qemu_put_betls(f, &env->cr[3]);
5821 5821
    qemu_put_betls(f, &env->cr[4]);
5822
    
5822
   
5823 5823
    for(i = 0; i < 8; i++)
5824 5824
        qemu_put_betls(f, &env->dr[i]);
5825 5825

  
......
5887 5887
    qemu_get_be16s(f, &fpus);
5888 5888
    qemu_get_be16s(f, &fptag);
5889 5889
    qemu_get_be16s(f, &fpregs_format);
5890
    
5890
   
5891 5891
    /* NOTE: we cannot always restore the FPU state if the image come
5892 5892
       from a host with a different 'USE_X86LDOUBLE' define. We guess
5893 5893
       if we are in an MMX state to restore correctly in that case. */
......
5895 5895
    for(i = 0; i < 8; i++) {
5896 5896
        uint64_t mant;
5897 5897
        uint16_t exp;
5898
        
5898
       
5899 5899
        switch(fpregs_format) {
5900 5900
        case 0:
5901 5901
            mant = qemu_get_be64(f);
......
5926 5926
            }
5927 5927
#else
5928 5928
            env->fpregs[i].mmx.MMX_Q(0) = mant;
5929
#endif            
5929
#endif           
5930 5930
            break;
5931 5931
        default:
5932 5932
            return -EINVAL;
......
5941 5941
    for(i = 0; i < 8; i++) {
5942 5942
        env->fptags[i] = (fptag >> i) & 1;
5943 5943
    }
5944
    
5944
   
5945 5945
    for(i = 0; i < 6; i++)
5946 5946
        cpu_get_seg(f, &env->segs[i]);
5947 5947
    cpu_get_seg(f, &env->ldt);
5948 5948
    cpu_get_seg(f, &env->tr);
5949 5949
    cpu_get_seg(f, &env->gdt);
5950 5950
    cpu_get_seg(f, &env->idt);
5951
    
5951
   
5952 5952
    qemu_get_be32s(f, &env->sysenter_cs);
5953 5953
    qemu_get_be32s(f, &env->sysenter_esp);
5954 5954
    qemu_get_be32s(f, &env->sysenter_eip);
5955
    
5955
   
5956 5956
    qemu_get_betls(f, &env->cr[0]);
5957 5957
    qemu_get_betls(f, &env->cr[2]);
5958 5958
    qemu_get_betls(f, &env->cr[3]);
5959 5959
    qemu_get_betls(f, &env->cr[4]);
5960
    
5960
   
5961 5961
    for(i = 0; i < 8; i++)
5962 5962
        qemu_get_betls(f, &env->dr[i]);
5963 5963

  
......
5978 5978
    qemu_get_be64s(f, &env->fmask);
5979 5979
    qemu_get_be64s(f, &env->kernelgsbase);
5980 5980
#endif
5981
    if (version_id >= 4) 
5981
    if (version_id >= 4)
5982 5982
        qemu_get_be32s(f, &env->smbase);
5983 5983

  
5984 5984
    /* XXX: compute hflags from scratch, except for CPL and IIF */
......
6288 6288
    memset(s, 0, sizeof(*s));
6289 6289
    s->f = f;
6290 6290
    ret = deflateInit2(&s->zstream, 1,
6291
                       Z_DEFLATED, 15, 
6291
                       Z_DEFLATED, 15,
6292 6292
                       9, Z_DEFAULT_STRATEGY);
6293 6293
    if (ret != Z_OK)
6294 6294
        return -1;
......
6399 6399
    int i;
6400 6400
    RamCompressState s1, *s = &s1;
6401 6401
    uint8_t buf[10];
6402
    
6402
   
6403 6403
    qemu_put_be32(f, phys_ram_size);
6404 6404
    if (ram_compress_open(s, f) < 0)
6405 6405
        return;
......
6414 6414
            sector_num = -1;
6415 6415
            for(j = 0; j < MAX_DISKS; j++) {
6416 6416
                if (bs_table[j]) {
6417
                    sector_num = bdrv_hash_find(bs_table[j], 
6417
                    sector_num = bdrv_hash_find(bs_table[j],
6418 6418
                                                phys_ram_base + i, BDRV_HASH_BLOCK_SIZE);
6419 6419
                    if (sector_num >= 0)
6420 6420
                        break;
......
6426 6426
            buf[1] = j;
6427 6427
            cpu_to_be64wu((uint64_t *)(buf + 2), sector_num);
6428 6428
            ram_compress_buf(s, buf, 10);
6429
        } else 
6429
        } else
6430 6430
#endif
6431 6431
        {
6432 6432
            //        normal_compress:
......
6462 6462
                fprintf(stderr, "Error while reading ram block address=0x%08x", i);
6463 6463
                goto error;
6464 6464
            }
6465
        } else 
6465
        } else
6466 6466
#if 0
6467 6467
        if (buf[0] == 1) {
6468 6468
            int bs_index;
......
6475 6475
                fprintf(stderr, "Invalid block device index %d\n", bs_index);
6476 6476
                goto error;
6477 6477
            }
6478
            if (bdrv_read(bs_table[bs_index], sector_num, phys_ram_base + i, 
6478
            if (bdrv_read(bs_table[bs_index], sector_num, phys_ram_base + i,
6479 6479
                          BDRV_HASH_BLOCK_SIZE / 512) < 0) {
6480
                fprintf(stderr, "Error while reading sector %d:%" PRId64 "\n", 
6480
                fprintf(stderr, "Error while reading sector %d:%" PRId64 "\n",
6481 6481
                        bs_index, sector_num);
6482 6482
                goto error;
6483 6483
            }
6484
        } else 
6484
        } else
6485 6485
#endif
6486 6486
        {
6487 6487
        error:
......
6669 6669
    }
6670 6670
}
6671 6671

  
6672
void vm_stop(int reason) 
6672
void vm_stop(int reason)
6673 6673
{
6674 6674
    if (vm_running) {
6675 6675
        cpu_disable_ticks();
......
6766 6766
    if (ret == 0) {
6767 6767
        int err;
6768 6768
        WaitObjects *w = &wait_objects;
6769
        
6769
       
6770 6770
        ret = WaitForMultipleObjects(w->num, w->events, FALSE, timeout);
6771 6771
        if (WAIT_OBJECT_0 + 0 <= ret && ret <= WAIT_OBJECT_0 + w->num - 1) {
6772 6772
            if (w->func[ret - WAIT_OBJECT_0])
6773 6773
                w->func[ret - WAIT_OBJECT_0](w->opaque[ret - WAIT_OBJECT_0]);
6774
                
6775
            /* Check for additional signaled events */ 
6774
               
6775
            /* Check for additional signaled events */
6776 6776
            for(i = (ret - WAIT_OBJECT_0 + 1); i < w->num; i++) {
6777
                                
6777
                               
6778 6778
                /* Check if event is signaled */
6779 6779
                ret2 = WaitForSingleObject(w->events[i], 0);
6780 6780
                if(ret2 == WAIT_OBJECT_0) {
......
6784 6784
                } else {
6785 6785
                    err = GetLastError();
6786 6786
                    fprintf(stderr, "WaitForSingleObject error %d %d\n", i, err);
6787
                }                
6788
            }                 
6787
                }               
6788
            }                
6789 6789
        } else if (ret == WAIT_TIMEOUT) {
6790 6790
        } else {
6791 6791
            err = GetLastError();
......
6815 6815
                nfds = ioh->fd;
6816 6816
        }
6817 6817
    }
6818
    
6818
   
6819 6819
    tv.tv_sec = 0;
6820 6820
#ifdef _WIN32
6821 6821
    tv.tv_usec = 0;
......
6847 6847
            if (ioh->deleted) {
6848 6848
                *pioh = ioh->next;
6849 6849
                qemu_free(ioh);
6850
            } else 
6850
            } else
6851 6851
                pioh = &ioh->next;
6852 6852
        }
6853 6853
    }
......
6864 6864
    qemu_aio_poll();
6865 6865

  
6866 6866
    if (vm_running) {
6867
        qemu_run_timers(&active_timers[QEMU_TIMER_VIRTUAL], 
6867
        qemu_run_timers(&active_timers[QEMU_TIMER_VIRTUAL],
6868 6868
                        qemu_get_clock(vm_clock));
6869 6869
        /* run dma transfers, if any */
6870 6870
        DMA_run();
6871 6871
    }
6872 6872

  
6873 6873
    /* real time timers */
6874
    qemu_run_timers(&active_timers[QEMU_TIMER_REALTIME], 
6874
    qemu_run_timers(&active_timers[QEMU_TIMER_REALTIME],
6875 6875
                    qemu_get_clock(rt_clock));
6876 6876

  
6877 6877
    /* Check bottom-halves last in case any of the earlier events triggered
6878 6878
       them.  */
6879 6879
    qemu_bh_poll();
6880
    
6880
   
6881 6881
}
6882 6882

  
6883 6883
static CPUState *cur_cpu;
......
7620 7620
    for(i = 1; i < MAX_SERIAL_PORTS; i++)
7621 7621
        serial_devices[i][0] = '\0';
7622 7622
    serial_device_index = 0;
7623
    
7623
   
7624 7624
    pstrcpy(parallel_devices[0], sizeof(parallel_devices[0]), "vc");
7625 7625
    for(i = 1; i < MAX_PARALLEL_PORTS; i++)
7626 7626
        parallel_devices[i][0] = '\0';
7627 7627
    parallel_device_index = 0;
7628
    
7628
   
7629 7629
    usb_devices_index = 0;
7630
    
7630
   
7631 7631
    nb_net_clients = 0;
7632 7632

  
7633 7633
    nb_nics = 0;
7634 7634
    /* default mac address of the first network interface */
7635
    
7635
   
7636 7636
    optind = 1;
7637 7637
    for(;;) {
7638 7638
        if (optind >= argc)
......
7650 7650
            popt = qemu_options;
7651 7651
            for(;;) {
7652 7652
                if (!popt->name) {
7653
                    fprintf(stderr, "%s: invalid option -- '%s'\n", 
7653
                    fprintf(stderr, "%s: invalid option -- '%s'\n",
7654 7654
                            argv[0], r);
7655 7655
                    exit(1);
7656 7656
                }
......
7677 7677
                    printf("Supported machines are:\n");
7678 7678
                    for(m = first_machine; m != NULL; m = m->next) {
7679 7679
                        printf("%-10s %s%s\n",
7680
                               m->name, m->desc, 
7680
                               m->name, m->desc,
7681 7681
                               m == first_machine ? " (default)" : "");
7682 7682
                    }
7683 7683
                    exit(*optarg != '?');
......
7789 7789
                break;
7790 7790
            case QEMU_OPTION_boot:
7791 7791
                boot_device = optarg[0];
7792
                if (boot_device != 'a' && 
7792
                if (boot_device != 'a' &&
7793 7793
#if defined(TARGET_SPARC) || defined(TARGET_I386)
7794 7794
		    // Network boot
7795 7795
		    boot_device != 'n' &&
......
7836 7836
                break;
7837 7837
#endif
7838 7838
            case QEMU_OPTION_redir:
7839
                net_slirp_redir(optarg);                
7839
                net_slirp_redir(optarg);               
7840 7840
                break;
7841 7841
#endif
7842 7842
#ifdef HAS_AUDIO
......
7865 7865
                {
7866 7866
                    int mask;
7867 7867
                    CPULogItem *item;
7868
                    
7868
                   
7869 7869
                    mask = cpu_str_to_log_mask(optarg);
7870 7870
                    if (!mask) {
7871 7871
                        printf("Log items (comma separated):\n");
......
7929 7929
                    if (*p == 'x') {
7930 7930
                        p++;
7931 7931
                        depth = strtol(p, (char **)&p, 10);
7932
                        if (depth != 8 && depth != 15 && depth != 16 && 
7932
                        if (depth != 8 && depth != 15 && depth != 16 &&
7933 7933
                            depth != 24 && depth != 32)
7934 7934
                            goto graphic_error;
7935 7935
                    } else if (*p == '\0') {
......
7937 7937
                    } else {
7938 7938
                        goto graphic_error;
7939 7939
                    }
7940
                    
7940
                   
7941 7941
                    graphic_width = w;
7942 7942
                    graphic_height = h;
7943 7943
                    graphic_depth = depth;
......
7959 7959
                    fprintf(stderr, "qemu: too many serial ports\n");
7960 7960
                    exit(1);
7961 7961
                }
7962
                pstrcpy(serial_devices[serial_device_index], 
7962
                pstrcpy(serial_devices[serial_device_index],
7963 7963
                        sizeof(serial_devices[0]), optarg);
7964 7964
                serial_device_index++;
7965 7965
                break;
......
7968 7968
                    fprintf(stderr, "qemu: too many parallel ports\n");
7969 7969
                    exit(1);
7970 7970
                }
7971
                pstrcpy(parallel_devices[parallel_device_index], 
7971
                pstrcpy(parallel_devices[parallel_device_index],
7972 7972
                        sizeof(parallel_devices[0]), optarg);
7973 7973
                parallel_device_index++;
7974 7974
                break;
......
8144 8144

  
8145 8145
    if (!linux_boot &&
8146 8146
        boot_device != 'n' &&
8147
        hd_filename[0] == '\0' && 
8147
        hd_filename[0] == '\0' &&
8148 8148
        (cdrom_index >= 0 && hd_filename[cdrom_index] == '\0') &&
8149 8149
        fd_filename[0] == '\0')
8150 8150
        help(1);
......
8158 8158
    }
8159 8159

  
8160 8160
    setvbuf(stdout, NULL, _IOLBF, 0);
8161
    
8161
   
8162 8162
    init_timers();
8163 8163
    init_timer_alarm();
8164 8164
    qemu_aio_init();
......
8365 8365
        if (devname[0] != '\0' && strcmp(devname, "none")) {
8366 8366
            serial_hds[i] = qemu_chr_open(devname);
8367 8367
            if (!serial_hds[i]) {
8368
                fprintf(stderr, "qemu: could not open serial device '%s'\n", 
8368
                fprintf(stderr, "qemu: could not open serial device '%s'\n",
8369 8369
                        devname);
8370 8370
                exit(1);
8371 8371
            }
......
8379 8379
        if (devname[0] != '\0' && strcmp(devname, "none")) {
8380 8380
            parallel_hds[i] = qemu_chr_open(devname);
8381 8381
            if (!parallel_hds[i]) {
8382
                fprintf(stderr, "qemu: could not open parallel device '%s'\n", 
8382
                fprintf(stderr, "qemu: could not open parallel device '%s'\n",
8383 8383
                        devname);
8384 8384
                exit(1);
8385 8385
            }

Also available in: Unified diff