* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
-#include "hw/hw.h"
-#include "hw/boards.h"
-#include "hw/usb.h"
-#include "hw/pcmcia.h"
-#include "hw/pc.h"
-#include "hw/audiodev.h"
-#include "hw/isa.h"
-#include "hw/baum.h"
-#include "hw/bt.h"
-#include "net.h"
-#include "console.h"
-#include "sysemu.h"
-#include "gdbstub.h"
-#include "qemu-timer.h"
-#include "qemu-char.h"
-#include "cache-utils.h"
-#include "block.h"
-#include "audio/audio.h"
-#include "migration.h"
-#include "kvm.h"
-#include "balloon.h"
-
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/time.h>
#include <zlib.h>
+/* Needed early for _BSD etc. */
+#include "config-host.h"
+
#ifndef _WIN32
#include <pwd.h>
#include <sys/times.h>
#include <sys/select.h>
#ifdef _BSD
#include <sys/stat.h>
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__DragonFly__)
#include <libutil.h>
#else
#include <util.h>
#endif
#endif
-#include "qemu_socket.h"
-
-#if defined(CONFIG_SLIRP)
-#include "libslirp.h"
-#endif
-
#if defined(__OpenBSD__)
#include <util.h>
#endif
#define main qemu_main
#endif /* CONFIG_COCOA */
+#include "hw/hw.h"
+#include "hw/boards.h"
+#include "hw/usb.h"
+#include "hw/pcmcia.h"
+#include "hw/pc.h"
+#include "hw/audiodev.h"
+#include "hw/isa.h"
+#include "hw/baum.h"
+#include "hw/bt.h"
+#include "net.h"
+#include "monitor.h"
+#include "console.h"
+#include "sysemu.h"
+#include "gdbstub.h"
+#include "qemu-timer.h"
+#include "qemu-char.h"
+#include "cache-utils.h"
+#include "block.h"
+#include "audio/audio.h"
+#include "migration.h"
+#include "kvm.h"
+#include "balloon.h"
+
#include "disas.h"
#include "exec-all.h"
+#include "qemu_socket.h"
+
+#if defined(CONFIG_SLIRP)
+#include "libslirp.h"
+#endif
+
//#define DEBUG_UNUSED_IOPORT
//#define DEBUG_IOPORT
//#define DEBUG_NET
int nb_nics;
NICInfo nd_table[MAX_NICS];
int vm_running;
+static int autostart;
static int rtc_utc = 1;
static int rtc_date_offset = -1; /* -1 means no change */
int cirrus_vga_enabled = 1;
return qemu_put_mouse_event_current->qemu_put_mouse_event_absolute;
}
-void do_info_mice(void)
+void do_info_mice(Monitor *mon)
{
QEMUPutMouseEntry *cursor;
int index = 0;
if (!qemu_put_mouse_event_head) {
- term_printf("No mouse devices connected\n");
+ monitor_printf(mon, "No mouse devices connected\n");
return;
}
- term_printf("Mouse devices available:\n");
+ monitor_printf(mon, "Mouse devices available:\n");
cursor = qemu_put_mouse_event_head;
while (cursor != NULL) {
- term_printf("%c Mouse #%d: %s\n",
- (cursor == qemu_put_mouse_event_current ? '*' : ' '),
- index, cursor->qemu_put_mouse_event_name);
+ monitor_printf(mon, "%c Mouse #%d: %s\n",
+ (cursor == qemu_put_mouse_event_current ? '*' : ' '),
+ index, cursor->qemu_put_mouse_event_name);
index++;
cursor = cursor->next;
}
}
-void do_mouse_set(int index)
+void do_mouse_set(Monitor *mon, int index)
{
QEMUPutMouseEntry *cursor;
int i = 0;
if (!qemu_put_mouse_event_head) {
- term_printf("No mouse devices connected\n");
+ monitor_printf(mon, "No mouse devices connected\n");
return;
}
if (cursor != NULL)
qemu_put_mouse_event_current = cursor;
else
- term_printf("Mouse at given index not found\n");
+ monitor_printf(mon, "Mouse at given index not found\n");
}
/* compute with 96 bit intermediate result: (a*b)/c */
static void init_get_clock(void)
{
use_rt_clock = 0;
-#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000)
+#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000) \
+ || defined(__DragonFly__)
{
struct timespec ts;
if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) {
static int64_t get_clock(void)
{
-#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000)
+#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000) \
+ || defined(__DragonFly__)
if (use_rt_clock) {
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
}
/* Interrupt execution to force deadline recalculation. */
if (use_icount && cpu_single_env) {
- cpu_interrupt(cpu_single_env, CPU_INTERRUPT_EXIT);
+ cpu_exit(cpu_single_env);
}
}
}
if (env) {
/* stop the currently executing cpu because a timer occured */
- cpu_interrupt(env, CPU_INTERRUPT_EXIT);
+ cpu_exit(env);
#ifdef USE_KQEMU
if (env->kqemu_enabled) {
kqemu_cpu_interrupt(env);
/* QEMU Block devices */
#define HD_ALIAS "index=%d,media=disk"
-#ifdef TARGET_PPC
-#define CDROM_ALIAS "index=1,media=cdrom"
-#else
#define CDROM_ALIAS "index=2,media=cdrom"
-#endif
#define FD_ALIAS "index=%d,if=floppy"
#define PFLASH_ALIAS "if=pflash"
#define MTD_ALIAS "if=mtd"
bdrv_flags |= BDRV_O_CACHE_WB;
else if (cache == 3) /* not specified */
bdrv_flags |= BDRV_O_CACHE_DEF;
- if (bdrv_open2(bdrv, file, bdrv_flags, drv) < 0 || qemu_key_check(bdrv, file)) {
+ if (bdrv_open2(bdrv, file, bdrv_flags, drv) < 0) {
fprintf(stderr, "qemu: could not open disk image %s\n",
file);
return -1;
}
+ if (bdrv_key_required(bdrv))
+ autostart = 0;
return drives_table_idx;
}
return 0;
}
-static int usb_device_add(const char *devname)
+static void usb_msd_password_cb(void *opaque, int err)
+{
+ USBDevice *dev = opaque;
+
+ if (!err)
+ usb_device_add_dev(dev);
+ else
+ dev->handle_destroy(dev);
+}
+
+static int usb_device_add(const char *devname, int is_hotplug)
{
const char *p;
USBDevice *dev;
} else if (!strcmp(devname, "keyboard")) {
dev = usb_keyboard_init();
} else if (strstart(devname, "disk:", &p)) {
+ BlockDriverState *bs;
+
dev = usb_msd_init(p);
+ if (!dev)
+ return -1;
+ bs = usb_msd_get_bdrv(dev);
+ if (bdrv_key_required(bs)) {
+ autostart = 0;
+ if (is_hotplug) {
+ monitor_read_bdrv_key_start(cur_mon, bs, usb_msd_password_cb,
+ dev);
+ return 0;
+ }
+ }
} else if (!strcmp(devname, "wacom-tablet")) {
dev = usb_wacom_init();
} else if (strstart(devname, "serial:", &p)) {
return usb_device_del_addr(bus_num, addr);
}
-void do_usb_add(const char *devname)
+void do_usb_add(Monitor *mon, const char *devname)
{
- usb_device_add(devname);
+ usb_device_add(devname, 1);
}
-void do_usb_del(const char *devname)
+void do_usb_del(Monitor *mon, const char *devname)
{
usb_device_del(devname);
}
-void usb_info(void)
+void usb_info(Monitor *mon)
{
USBDevice *dev;
USBPort *port;
const char *speed_str;
if (!usb_enabled) {
- term_printf("USB support not enabled\n");
+ monitor_printf(mon, "USB support not enabled\n");
return;
}
speed_str = "?";
break;
}
- term_printf(" Device %d.%d, Speed %s Mb/s, Product %s\n",
- 0, dev->addr, speed_str, dev->devname);
+ monitor_printf(mon, " Device %d.%d, Speed %s Mb/s, Product %s\n",
+ 0, dev->addr, speed_str, dev->devname);
}
}
}
}
-void pcmcia_info(void)
+void pcmcia_info(Monitor *mon)
{
struct pcmcia_socket_entry_s *iter;
+
if (!pcmcia_sockets)
- term_printf("No PCMCIA sockets\n");
+ monitor_printf(mon, "No PCMCIA sockets\n");
for (iter = pcmcia_sockets; iter; iter = iter->next)
- term_printf("%s: %s\n", iter->socket->slot_string,
- iter->socket->attached ? iter->socket->card_string :
- "Empty");
+ monitor_printf(mon, "%s: %s\n", iter->socket->slot_string,
+ iter->socket->attached ? iter->socket->card_string :
+ "Empty");
}
/***********************************************************/
{
CPUState *env = cpu_single_env;
if (env) {
- cpu_interrupt(env, CPU_INTERRUPT_EXIT);
+ cpu_exit(env);
#ifdef USE_KQEMU
if (env->kqemu_enabled) {
kqemu_cpu_interrupt(env);
bh->idle = 0;
/* stop the currently executing CPU to execute the BH ASAP */
if (env) {
- cpu_interrupt(env, CPU_INTERRUPT_EXIT);
+ cpu_exit(env);
}
}
reset_requested = 1;
}
if (cpu_single_env)
- cpu_interrupt(cpu_single_env, CPU_INTERRUPT_EXIT);
+ cpu_exit(cpu_single_env);
}
void qemu_system_shutdown_request(void)
{
shutdown_requested = 1;
if (cpu_single_env)
- cpu_interrupt(cpu_single_env, CPU_INTERRUPT_EXIT);
+ cpu_exit(cpu_single_env);
}
void qemu_system_powerdown_request(void)
{
powerdown_requested = 1;
if (cpu_single_env)
- cpu_interrupt(cpu_single_env, CPU_INTERRUPT_EXIT);
+ cpu_exit(cpu_single_env);
}
#ifdef _WIN32
{ NULL },
};
-/* password input */
-
-int qemu_key_check(BlockDriverState *bs, const char *name)
-{
- char password[256];
- int i;
-
- if (!bdrv_is_encrypted(bs))
- return 0;
-
- term_printf("%s is encrypted.\n", name);
- for(i = 0; i < 3; i++) {
- monitor_readline("Password: ", 1, password, sizeof(password));
- if (bdrv_set_key(bs, password) == 0)
- return 0;
- term_printf("invalid password\n");
- }
- return -EPERM;
-}
-
-static BlockDriverState *get_bdrv(int index)
-{
- if (index > nb_drives)
- return NULL;
- return drives_table[index].bdrv;
-}
-
-static void read_passwords(void)
-{
- BlockDriverState *bs;
- int i;
-
- for(i = 0; i < 6; i++) {
- bs = get_bdrv(i);
- if (bs)
- qemu_key_check(bs, bdrv_get_device_name(bs));
- }
-}
-
#ifdef HAS_AUDIO
struct soundhw soundhw[] = {
#ifdef HAS_AUDIO_CHOICE
int fds[2];
int tb_size;
const char *pid_file = NULL;
- int autostart;
const char *incoming = NULL;
int fd = 0;
struct passwd *pwd = NULL;
kernel_cmdline = "";
cyls = heads = secs = 0;
translation = BIOS_ATA_TRANSLATION_AUTO;
- monitor_device = "vc";
+ monitor_device = "vc:80Cx24C";
serial_devices[0] = "vc:80Cx24C";
for(i = 1; i < MAX_SERIAL_PORTS; i++)
/* init USB devices */
if (usb_enabled) {
for(i = 0; i < usb_devices_index; i++) {
- if (usb_device_add(usb_devices[i]) < 0) {
+ if (usb_device_add(usb_devices[i], 0) < 0) {
fprintf(stderr, "Warning: could not add USB device %s\n",
usb_devices[i]);
}
}
text_consoles_set_display(display_state);
+ qemu_chr_initial_reset();
if (monitor_device && monitor_hd)
- monitor_init(monitor_hd, !nographic);
+ monitor_init(monitor_hd, MONITOR_USE_READLINE | MONITOR_IS_DEFAULT);
for(i = 0; i < MAX_SERIAL_PORTS; i++) {
const char *devname = serial_devices[i];
#endif
if (loadvm)
- do_loadvm(loadvm);
+ do_loadvm(cur_mon, loadvm);
if (incoming) {
autostart = 0; /* fixme how to deal with -daemonize */
qemu_start_incoming_migration(incoming);
}
- {
- /* XXX: simplify init */
- read_passwords();
- if (autostart) {
- vm_start();
- }
- }
+ if (autostart)
+ vm_start();
if (daemonize) {
uint8_t status = 0;