#include "gdbstub.h"
#include "qemu-timer.h"
#include "qemu-char.h"
+#include "cache-utils.h"
#include "block.h"
#include "audio/audio.h"
-#include "qemu-xen.h"
#include "migration.h"
+#include "kvm.h"
+#include "balloon.h"
- #include "hw/pci.h"
- #include "hw/xen.h"
- #include <stdlib.h>
-
#include <unistd.h>
-#include <stdlib.h>
#include <fcntl.h>
#include <signal.h>
#include <time.h>
uint8_t qemu_uuid[16];
-#define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)
-
--#include "xen-vl-extra.c"
-
-typedef struct IOHandlerRecord {
- int fd;
- IOCanRWHandler *fd_read_poll;
- IOHandler *fd_read;
- IOHandler *fd_write;
- int deleted;
- void *opaque;
- /* temporary data */
- struct pollfd *ufd;
- struct IOHandlerRecord *next;
-} IOHandlerRecord;
-
-static IOHandlerRecord *first_io_handler;
--
/***********************************************************/
/* x86 ISA bus support */
fprintf(stderr, "\n");
for(env = first_cpu; env != NULL; env = env->next_cpu) {
fprintf(stderr, "CPU #%d:\n", env->cpu_index);
--#if defined(TARGET_I386) && !defined(CONFIG_DM)
++#ifdef TARGET_I386
cpu_dump_state(env, stderr, fprintf, X86_DUMP_FPU);
#else
cpu_dump_state(env, stderr, fprintf, 0);
static int unix_start_timer(struct qemu_alarm_timer *t);
static void unix_stop_timer(struct qemu_alarm_timer *t);
--#if defined(__linux__) && !defined(CONFIG_DM)
++#ifdef __linux__
static int dynticks_start_timer(struct qemu_alarm_timer *t);
static void dynticks_stop_timer(struct qemu_alarm_timer *t);
static struct qemu_alarm_timer alarm_timers[] = {
#ifndef _WIN32
--#if defined(__linux__) && !defined(CONFIG_DM)
++#ifdef __linux__
{"dynticks", ALARM_FLAG_DYNTICKS, dynticks_start_timer,
dynticks_stop_timer, dynticks_rearm_timer, NULL},
/* HPET - if available - is preferred */
}
}
--void qemu_advance_timer(QEMUTimer *ts, int64_t expire_time)
--{
-- if (ts->expire_time > expire_time)
-- qemu_mod_timer(ts, expire_time);
--}
--
/* modify the current timer so that it will be fired when current_time
>= expire_time. The corresponding callback will be called. */
void qemu_mod_timer(QEMUTimer *ts, int64_t expire_time)
}
}
--/* run the specified timer */
--void qemu_run_one_timer(QEMUTimer *ts)
--{
-- uint64_t current_time;
--
-- /* remove timer from the list before calling the callback */
-- qemu_del_timer(ts);
--
-- while ((current_time = qemu_get_clock(rt_clock)) < ts->expire_time)
-- /* sleep until the expire time */
-- usleep((ts->expire_time - current_time) * 1000);
--
-- /* run the callback */
-- ts->cb(ts->opaque);
--}
--
static void timer_save(QEMUFile *f, void *opaque)
{
if (cpu_ticks_enabled) {
hw_error("cannot save state if virtual timers are running");
}
--#ifndef CONFIG_DM
qemu_put_be64(f, cpu_ticks_offset);
qemu_put_be64(f, ticks_per_sec);
--#endif
qemu_put_be64(f, cpu_clock_offset);
}
if (cpu_ticks_enabled) {
return -EINVAL;
}
--#ifndef CONFIG_DM
cpu_ticks_offset=qemu_get_be64(f);
ticks_per_sec=qemu_get_be64(f);
if (version_id == 2) {
--#else
-- if (version_id == 1 || version_id == 2) {
--#endif
cpu_clock_offset=qemu_get_be64(f);
}
return 0;
}
- #ifndef CONFIG_DM /* ends after end of win32_rearm_timer */
-#ifndef CONFIG_DM
#ifdef _WIN32
void CALLBACK host_alarm_handler(UINT uTimerID, UINT uMsg,
DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2)
}
#endif /* _WIN32 */
--#endif /* !CONFIG_DM */
-static void init_timer_alarm(void)
+static int init_timer_alarm(void)
{
struct qemu_alarm_timer *t = NULL;
int i, err = -1;
return 0;
}
-int qemu_savevm_state(QEMUFile *f)
+static int usb_device_del(const char *devname)
{
- int saved_vm_running;
- int ret;
-
- saved_vm_running = vm_running;
- vm_stop(0);
-
- bdrv_flush_all();
-
- ret = qemu_savevm_state_begin(f);
- if (ret < 0)
- goto out;
-
- do {
- ret = qemu_savevm_state_iterate(f);
- if (ret < 0)
- goto out;
- } while (ret == 0);
+ int bus_num, addr;
+ const char *p;
- ret = qemu_savevm_state_complete(f);
+ if (strstart(devname, "host:", &p))
+ return usb_host_device_close(p);
-out:
- if (qemu_file_has_error(f))
- ret = -EIO;
+ if (!used_usb_ports)
+ return -1;
- if (!ret && saved_vm_running)
- vm_start();
+ p = strchr(devname, '.');
+ if (!p)
+ return -1;
+ bus_num = strtoul(devname, NULL, 0);
+ addr = strtoul(p + 1, NULL, 0);
- return ret;
+ return usb_device_del_addr(bus_num, addr);
}
-static SaveStateEntry *find_se(const char *idstr, int instance_id)
+void do_usb_add(const char *devname)
{
- SaveStateEntry *se;
-
- for(se = first_se; se != NULL; se = se->next) {
- if (!strcmp(se->idstr, idstr) &&
- instance_id == se->instance_id)
- return se;
- }
- return NULL;
+ usb_device_add(devname);
}
-typedef struct LoadStateEntry {
- SaveStateEntry *se;
- int section_id;
- int version_id;
- struct LoadStateEntry *next;
-} LoadStateEntry;
+void do_usb_del(const char *devname)
+{
+ usb_device_del(devname);
+}
-static int qemu_loadvm_state_v2(QEMUFile *f)
+void usb_info(void)
{
- SaveStateEntry *se;
- int len, ret, instance_id, record_len, version_id;
- int64_t total_len, end_pos, cur_pos;
- char idstr[256];
+ USBDevice *dev;
+ USBPort *port;
+ const char *speed_str;
- total_len = qemu_get_be64(f);
- end_pos = total_len + qemu_ftell(f);
- for(;;) {
- if (qemu_ftell(f) >= end_pos)
+ if (!usb_enabled) {
+ term_printf("USB support not enabled\n");
+ return;
+ }
+
+ for (port = used_usb_ports; port; port = port->next) {
+ dev = port->dev;
+ if (!dev)
+ continue;
+ switch(dev->speed) {
+ case USB_SPEED_LOW:
+ speed_str = "1.5";
+ break;
+ case USB_SPEED_FULL:
+ speed_str = "12";
+ break;
+ case USB_SPEED_HIGH:
+ speed_str = "480";
+ break;
+ default:
+ speed_str = "?";
break;
- len = qemu_get_byte(f);
- qemu_get_buffer(f, (uint8_t *)idstr, len);
- idstr[len] = '\0';
- instance_id = qemu_get_be32(f);
- version_id = qemu_get_be32(f);
- record_len = qemu_get_be32(f);
- cur_pos = qemu_ftell(f);
- se = find_se(idstr, instance_id);
- if (!se) {
- fprintf(stderr, "qemu: warning: instance 0x%x of device '%s' not present in current VM\n",
- instance_id, idstr);
- } else {
- ret = se->load_state(f, se->opaque, version_id);
- if (ret < 0) {
- fprintf(stderr, "qemu: warning: error while loading state for instance 0x%x of device '%s'\n",
- instance_id, idstr);
- }
}
- /* always seek to exact end of record */
- qemu_fseek(f, cur_pos + record_len, SEEK_SET);
+ term_printf(" Device %d.%d, Speed %s Mb/s, Product %s\n",
+ 0, dev->addr, speed_str, dev->devname);
}
-
- if (qemu_file_has_error(f))
- return -EIO;
-
- return 0;
}
-int qemu_loadvm_state(QEMUFile *f)
-{
- LoadStateEntry *first_le = NULL;
- uint8_t section_type;
- unsigned int v;
- int ret;
-
- v = qemu_get_be32(f);
- if (v != QEMU_VM_FILE_MAGIC)
- return -EINVAL;
-
- v = qemu_get_be32(f);
- if (v == QEMU_VM_FILE_VERSION_COMPAT)
- return qemu_loadvm_state_v2(f);
- if (v != QEMU_VM_FILE_VERSION)
- return -ENOTSUP;
-
- while ((section_type = qemu_get_byte(f)) != QEMU_VM_EOF) {
- uint32_t instance_id, version_id, section_id;
- LoadStateEntry *le;
- SaveStateEntry *se;
- char idstr[257];
- int len;
-
- switch (section_type) {
- case QEMU_VM_SECTION_START:
- case QEMU_VM_SECTION_FULL:
- /* Read section start */
- section_id = qemu_get_be32(f);
- len = qemu_get_byte(f);
- qemu_get_buffer(f, (uint8_t *)idstr, len);
- idstr[len] = 0;
- instance_id = qemu_get_be32(f);
- version_id = qemu_get_be32(f);
-
- /* Find savevm section */
- se = find_se(idstr, instance_id);
- if (se == NULL) {
- fprintf(stderr, "Unknown savevm section or instance '%s' %d\n", idstr, instance_id);
- ret = -EINVAL;
- goto out;
- }
+/***********************************************************/
+/* PCMCIA/Cardbus */
- /* Validate version */
- if (version_id > se->version_id) {
- fprintf(stderr, "savevm: unsupported version %d for '%s' v%d\n",
- version_id, idstr, se->version_id);
- ret = -EINVAL;
- goto out;
- }
+static struct pcmcia_socket_entry_s {
+ struct pcmcia_socket_s *socket;
+ struct pcmcia_socket_entry_s *next;
+} *pcmcia_sockets = 0;
- /* Add entry */
- le = qemu_mallocz(sizeof(*le));
- if (le == NULL) {
- ret = -ENOMEM;
- goto out;
- }
+void pcmcia_socket_register(struct pcmcia_socket_s *socket)
+{
+ struct pcmcia_socket_entry_s *entry;
- le->se = se;
- le->section_id = section_id;
- le->version_id = version_id;
- le->next = first_le;
- first_le = le;
+ entry = qemu_malloc(sizeof(struct pcmcia_socket_entry_s));
+ entry->socket = socket;
+ entry->next = pcmcia_sockets;
+ pcmcia_sockets = entry;
+}
- le->se->load_state(f, le->se->opaque, le->version_id);
- break;
- case QEMU_VM_SECTION_PART:
- case QEMU_VM_SECTION_END:
- section_id = qemu_get_be32(f);
-
- for (le = first_le; le && le->section_id != section_id; le = le->next);
- if (le == NULL) {
- fprintf(stderr, "Unknown savevm section %d\n", section_id);
- ret = -EINVAL;
- goto out;
- }
+void pcmcia_socket_unregister(struct pcmcia_socket_s *socket)
+{
+ struct pcmcia_socket_entry_s *entry, **ptr;
- le->se->load_state(f, le->se->opaque, le->version_id);
- break;
- default:
- fprintf(stderr, "Unknown savevm section type %d\n", section_type);
- ret = -EINVAL;
- goto out;
+ ptr = &pcmcia_sockets;
+ for (entry = *ptr; entry; ptr = &entry->next, entry = *ptr)
+ if (entry->socket == socket) {
+ *ptr = entry->next;
+ qemu_free(entry);
}
- }
+}
- ret = 0;
+void pcmcia_info(void)
+{
+ struct pcmcia_socket_entry_s *iter;
+ if (!pcmcia_sockets)
+ term_printf("No PCMCIA sockets\n");
-out:
- while (first_le) {
- LoadStateEntry *le = first_le;
- first_le = first_le->next;
- qemu_free(le);
- }
+ 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");
+}
- if (qemu_file_has_error(f))
- ret = -EIO;
+/***********************************************************/
+/* register display */
- return ret;
-}
++struct DisplayAllocator default_allocator = {
++ defaultallocator_create_displaysurface,
++ defaultallocator_resize_displaysurface,
++ defaultallocator_free_displaysurface
++};
+
-/* device can contain snapshots */
-static int bdrv_can_snapshot(BlockDriverState *bs)
+void register_displaystate(DisplayState *ds)
{
- return (bs &&
- !bdrv_is_removable(bs) &&
- !bdrv_is_read_only(bs));
+ DisplayState **s;
+ s = &display_state;
+ while (*s != NULL)
+ s = &(*s)->next;
+ ds->next = NULL;
+ *s = ds;
}
-/* device must be snapshots in order to have a reliable snapshot */
-static int bdrv_has_snapshot(BlockDriverState *bs)
+DisplayState *get_displaystate(void)
{
- return (bs &&
- !bdrv_is_removable(bs) &&
- !bdrv_is_read_only(bs));
+ return display_state;
}
-static BlockDriverState *get_bs_snapshots(void)
++DisplayAllocator *register_displayallocator(DisplayState *ds, DisplayAllocator *da)
+ {
- BlockDriverState *bs;
- int i;
++ if(ds->allocator == &default_allocator) ds->allocator = da;
++ return ds->allocator;
++}
+
- if (bs_snapshots)
- return bs_snapshots;
- for(i = 0; i <= nb_drives; i++) {
- bs = drives_table[i].bdrv;
- if (bdrv_can_snapshot(bs))
- goto ok;
- }
- return NULL;
- ok:
- bs_snapshots = bs;
- return bs;
-}
-
-static int bdrv_snapshot_find(BlockDriverState *bs, QEMUSnapshotInfo *sn_info,
- const char *name)
-{
- QEMUSnapshotInfo *sn_tab, *sn;
- int nb_sns, i, ret;
-
- ret = -ENOENT;
- nb_sns = bdrv_snapshot_list(bs, &sn_tab);
- if (nb_sns < 0)
- return ret;
- for(i = 0; i < nb_sns; i++) {
- sn = &sn_tab[i];
- if (!strcmp(sn->id_str, name) || !strcmp(sn->name, name)) {
- *sn_info = *sn;
- ret = 0;
- break;
- }
+/* dumb display */
+
+static void dumb_display_init(void)
+{
+ DisplayState *ds = qemu_mallocz(sizeof(DisplayState));
+ if (ds == NULL) {
+ fprintf(stderr, "dumb_display_init: DisplayState allocation failed\n");
+ exit(1);
}
- ds->surface = qemu_create_displaysurface(640, 480, 32, 640 * 4);
- qemu_free(sn_tab);
- return ret;
++ ds->allocator = &default_allocator;
++ ds->surface = qemu_create_displaysurface(ds, 640, 480, 32, 640 * 4);
+ register_displaystate(ds);
}
-#ifndef CONFIG_DM
+/***********************************************************/
+/* I/O handling */
-void do_savevm(const char *name)
-{
- BlockDriverState *bs, *bs1;
- QEMUSnapshotInfo sn1, *sn = &sn1, old_sn1, *old_sn = &old_sn1;
- int must_delete, ret, i;
- BlockDriverInfo bdi1, *bdi = &bdi1;
- QEMUFile *f;
- int saved_vm_running;
-#ifdef _WIN32
- struct _timeb tb;
-#else
- struct timeval tv;
-#endif
+#define MAX_IO_HANDLERS 64
- bs = get_bs_snapshots();
- if (!bs) {
- term_printf("No block device can accept snapshots\n");
- return;
- }
+typedef struct IOHandlerRecord {
+ int fd;
+ IOCanRWHandler *fd_read_poll;
+ IOHandler *fd_read;
+ IOHandler *fd_write;
+ int deleted;
+ void *opaque;
+ /* temporary data */
+ struct pollfd *ufd;
+ struct IOHandlerRecord *next;
+} IOHandlerRecord;
- /* ??? Should this occur after vm_stop? */
- qemu_aio_flush();
+static IOHandlerRecord *first_io_handler;
- saved_vm_running = vm_running;
- vm_stop(0);
+/* XXX: fd_read_poll should be suppressed, but an API change is
+ necessary in the character devices to suppress fd_can_read(). */
+int qemu_set_fd_handler2(int fd,
+ IOCanRWHandler *fd_read_poll,
+ IOHandler *fd_read,
+ IOHandler *fd_write,
+ void *opaque)
+{
+ IOHandlerRecord **pioh, *ioh;
- must_delete = 0;
- if (name) {
- ret = bdrv_snapshot_find(bs, old_sn, name);
- if (ret >= 0) {
- must_delete = 1;
+ if (!fd_read && !fd_write) {
+ pioh = &first_io_handler;
+ for(;;) {
+ ioh = *pioh;
+ if (ioh == NULL)
+ break;
+ if (ioh->fd == fd) {
+ ioh->deleted = 1;
+ break;
+ }
+ pioh = &ioh->next;
}
- }
- memset(sn, 0, sizeof(*sn));
- if (must_delete) {
- pstrcpy(sn->name, sizeof(sn->name), old_sn->name);
- pstrcpy(sn->id_str, sizeof(sn->id_str), old_sn->id_str);
} else {
- if (name)
- pstrcpy(sn->name, sizeof(sn->name), name);
- }
-
- /* fill auxiliary fields */
-#ifdef _WIN32
- _ftime(&tb);
- sn->date_sec = tb.time;
- sn->date_nsec = tb.millitm * 1000000;
-#else
- gettimeofday(&tv, NULL);
- sn->date_sec = tv.tv_sec;
- sn->date_nsec = tv.tv_usec * 1000;
-#endif
- sn->vm_clock_nsec = qemu_get_clock(vm_clock);
-
- if (bdrv_get_info(bs, bdi) < 0 || bdi->vm_state_offset <= 0) {
- term_printf("Device %s does not support VM state snapshots\n",
- bdrv_get_device_name(bs));
- goto the_end;
- }
-
- /* save the VM state */
- f = qemu_fopen_bdrv(bs, bdi->vm_state_offset, 1);
- if (!f) {
- term_printf("Could not open VM state file\n");
- goto the_end;
- }
- ret = qemu_savevm_state(f);
- sn->vm_state_size = qemu_ftell(f);
- qemu_fclose(f);
- if (ret < 0) {
- term_printf("Error %d while writing VM\n", ret);
- goto the_end;
- }
-
- /* create the snapshots */
-
- for(i = 0; i < nb_drives; i++) {
- bs1 = drives_table[i].bdrv;
- if (bdrv_has_snapshot(bs1)) {
- if (must_delete) {
- ret = bdrv_snapshot_delete(bs1, old_sn->id_str);
- if (ret < 0) {
- term_printf("Error while deleting snapshot on '%s'\n",
- bdrv_get_device_name(bs1));
- }
- }
- ret = bdrv_snapshot_create(bs1, sn);
- if (ret < 0) {
- term_printf("Error while creating snapshot on '%s'\n",
- bdrv_get_device_name(bs1));
- }
+ for(ioh = first_io_handler; ioh != NULL; ioh = ioh->next) {
+ if (ioh->fd == fd)
+ goto found;
}
+ ioh = qemu_mallocz(sizeof(IOHandlerRecord));
+ if (!ioh)
+ return -1;
+ ioh->next = first_io_handler;
+ first_io_handler = ioh;
+ found:
+ ioh->fd = fd;
+ ioh->fd_read_poll = fd_read_poll;
+ ioh->fd_read = fd_read;
+ ioh->fd_write = fd_write;
+ ioh->opaque = opaque;
+ ioh->deleted = 0;
}
-
- the_end:
- if (saved_vm_running)
- vm_start();
+ return 0;
}
-void do_loadvm(const char *name)
+int qemu_set_fd_handler(int fd,
+ IOHandler *fd_read,
+ IOHandler *fd_write,
+ void *opaque)
{
- BlockDriverState *bs, *bs1;
- BlockDriverInfo bdi1, *bdi = &bdi1;
- QEMUFile *f;
- int i, ret;
- int saved_vm_running;
+ return qemu_set_fd_handler2(fd, NULL, fd_read, fd_write, opaque);
+}
+
+#ifdef _WIN32
+/***********************************************************/
+/* Polling handling */
- bs = get_bs_snapshots();
- if (!bs) {
- term_printf("No block device supports snapshots\n");
- return;
- }
+typedef struct PollingEntry {
+ PollingFunc *func;
+ void *opaque;
+ struct PollingEntry *next;
+} PollingEntry;
- /* Flush all IO requests so they don't interfere with the new state. */
- qemu_aio_flush();
+static PollingEntry *first_polling_entry;
- saved_vm_running = vm_running;
- vm_stop(0);
+int qemu_add_polling_cb(PollingFunc *func, void *opaque)
+{
+ PollingEntry **ppe, *pe;
+ pe = qemu_mallocz(sizeof(PollingEntry));
+ if (!pe)
+ return -1;
+ pe->func = func;
+ pe->opaque = opaque;
+ for(ppe = &first_polling_entry; *ppe != NULL; ppe = &(*ppe)->next);
+ *ppe = pe;
+ return 0;
+}
- for(i = 0; i <= nb_drives; i++) {
- bs1 = drives_table[i].bdrv;
- if (bdrv_has_snapshot(bs1)) {
- ret = bdrv_snapshot_goto(bs1, name);
- if (ret < 0) {
- if (bs != bs1)
- term_printf("Warning: ");
- switch(ret) {
- case -ENOTSUP:
- term_printf("Snapshots not supported on device '%s'\n",
- bdrv_get_device_name(bs1));
- break;
- case -ENOENT:
- term_printf("Could not find snapshot '%s' on device '%s'\n",
- name, bdrv_get_device_name(bs1));
- break;
- default:
- term_printf("Error %d while activating snapshot on '%s'\n",
- ret, bdrv_get_device_name(bs1));
- break;
- }
- /* fatal on snapshot block device */
- if (bs == bs1)
- goto the_end;
- }
+void qemu_del_polling_cb(PollingFunc *func, void *opaque)
+{
+ PollingEntry **ppe, *pe;
+ for(ppe = &first_polling_entry; *ppe != NULL; ppe = &(*ppe)->next) {
+ pe = *ppe;
+ if (pe->func == func && pe->opaque == opaque) {
+ *ppe = pe->next;
+ qemu_free(pe);
+ break;
}
}
-
- if (bdrv_get_info(bs, bdi) < 0 || bdi->vm_state_offset <= 0) {
- term_printf("Device %s does not support VM state snapshots\n",
- bdrv_get_device_name(bs));
- return;
- }
-
- /* restore the VM state */
- f = qemu_fopen_bdrv(bs, bdi->vm_state_offset, 0);
- if (!f) {
- term_printf("Could not open VM state file\n");
- goto the_end;
- }
- ret = qemu_loadvm_state(f);
- qemu_fclose(f);
- if (ret < 0) {
- term_printf("Error %d while loading VM state\n", ret);
- }
- the_end:
- if (saved_vm_running)
- vm_start();
}
-#endif /* !CONFIG_DM */
+/***********************************************************/
+/* Wait objects support */
+typedef struct WaitObjects {
+ int num;
+ HANDLE events[MAXIMUM_WAIT_OBJECTS + 1];
+ WaitObjectFunc *func[MAXIMUM_WAIT_OBJECTS + 1];
+ void *opaque[MAXIMUM_WAIT_OBJECTS + 1];
+} WaitObjects;
+
+static WaitObjects wait_objects = {0};
-void do_delvm(const char *name)
+int qemu_add_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque)
{
- BlockDriverState *bs, *bs1;
- int i, ret;
-
- bs = get_bs_snapshots();
- if (!bs) {
- term_printf("No block device supports snapshots\n");
- return;
- }
+ WaitObjects *w = &wait_objects;
- for(i = 0; i <= nb_drives; i++) {
- bs1 = drives_table[i].bdrv;
- if (bdrv_has_snapshot(bs1)) {
- ret = bdrv_snapshot_delete(bs1, name);
- if (ret < 0) {
- if (ret == -ENOTSUP)
- term_printf("Snapshots not supported on device '%s'\n",
- bdrv_get_device_name(bs1));
- else
- term_printf("Error %d while deleting snapshot on '%s'\n",
- ret, bdrv_get_device_name(bs1));
- }
- }
- }
+ if (w->num >= MAXIMUM_WAIT_OBJECTS)
+ return -1;
+ w->events[w->num] = handle;
+ w->func[w->num] = func;
+ w->opaque[w->num] = opaque;
+ w->num++;
+ return 0;
}
-void do_info_snapshots(void)
+void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque)
{
- BlockDriverState *bs, *bs1;
- QEMUSnapshotInfo *sn_tab, *sn;
- int nb_sns, i;
- char buf[256];
+ int i, found;
+ WaitObjects *w = &wait_objects;
- bs = get_bs_snapshots();
- if (!bs) {
- term_printf("No available block device supports snapshots\n");
- return;
- }
- term_printf("Snapshot devices:");
- for(i = 0; i <= nb_drives; i++) {
- bs1 = drives_table[i].bdrv;
- if (bdrv_has_snapshot(bs1)) {
- if (bs == bs1)
- term_printf(" %s", bdrv_get_device_name(bs1));
+ found = 0;
+ for (i = 0; i < w->num; i++) {
+ if (w->events[i] == handle)
+ found = 1;
+ if (found) {
+ w->events[i] = w->events[i + 1];
+ w->func[i] = w->func[i + 1];
+ w->opaque[i] = w->opaque[i + 1];
}
}
- term_printf("\n");
-
- nb_sns = bdrv_snapshot_list(bs, &sn_tab);
- if (nb_sns < 0) {
- term_printf("bdrv_snapshot_list: error %d\n", nb_sns);
- return;
- }
- term_printf("Snapshot list (from %s):\n", bdrv_get_device_name(bs));
- term_printf("%s\n", bdrv_snapshot_dump(buf, sizeof(buf), NULL));
- for(i = 0; i < nb_sns; i++) {
- sn = &sn_tab[i];
- term_printf("%s\n", bdrv_snapshot_dump(buf, sizeof(buf), sn));
- }
- qemu_free(sn_tab);
+ if (found)
+ w->num--;
}
+#endif
/***********************************************************/
/* ram save/restore */
--#ifdef CONFIG_DM
--static int ram_save_live(QEMUFile *f, int stage, void *opaque) { return 1; }
--static int ram_load(QEMUFile *f, void *opaque, int version_id) { return 0; }
--#else /* !CONFIG_DM */
--
static int ram_get_page(QEMUFile *f, uint8_t *buf, int len)
{
int v;
return 0;
}
--#endif /* !CONFIG_DM */
--
void qemu_service_io(void)
{
CPUState *env = cpu_single_env;
}
--#ifndef CONFIG_DM
--
static int main_loop(void)
{
int ret, timeout;
return ret;
}
--#else /* CONFIG_DM */
--void main_loop_prepare(void) {
-- cur_cpu = first_cpu;
--}
--#endif /* !CONFIG_DM */
--
static void help(int exitcode)
{
+ /* Please keep in synch with QEMU_OPTION_ enums, qemu_options[]
+ and qemu-doc.texi */
printf("QEMU PC emulator version " QEMU_VERSION ", Copyright (c) 2003-2008 Fabrice Bellard\n"
"usage: %s [options] [disk_image]\n"
"\n"
#endif
"-usb enable the USB driver (will be the default soon)\n"
"-usbdevice name add the host or guest USB device 'name'\n"
- #ifdef CONFIG_OPENGL
- "-disable-opengl disable OpenGL rendering, using SDL"
- #endif
+ "-name string set the name of the guest\n"
+ "-uuid %%08x-%%04x-%%04x-%%04x-%%012x\n"
+ " specify machine UUID\n"
+ "\n"
+ "Display options:\n"
+ "-nographic disable graphical output and redirect serial I/Os to console\n"
+#ifdef CONFIG_CURSES
+ "-curses use a curses/ncurses interface instead of SDL\n"
+#endif
+#ifdef CONFIG_SDL
+ "-no-frame open SDL window without a frame and window decorations\n"
+ "-alt-grab use Ctrl-Alt-Shift to grab mouse (instead of Ctrl-Alt)\n"
+ "-no-quit disable SDL window close capability\n"
+ "-sdl enable SDL\n"
+#endif
+ "-portrait rotate graphical output 90 deg left (only PXA LCD)\n"
+ "-vga [std|cirrus|vmware|none]\n"
+ " select video card type\n"
+ "-full-screen start in full screen\n"
#if defined(TARGET_PPC) || defined(TARGET_SPARC)
"-g WxH[xDEPTH] Set the initial graphical resolution and depth\n"
#endif
" hostname 'host' to DHCP clients\n"
#endif
#ifdef _WIN32
- "-net tap[,vlan=n],ifname=name\n"
+ "-net tap[,vlan=n][,name=str],ifname=name\n"
" connect the host TAP network interface to VLAN 'n'\n"
#else
- "-net tap[,vlan=n][,name=str][,fd=h][,ifname=name][,script=file][,downscript=dfile][,scriptarg=extraargument]\n"
- "-net tap[,vlan=n][,fd=h][,ifname=name][,script=file][,downscript=dfile][,scriptarg=extraargument]\n"
++ "-net tap[,vlan=n][,name=str][,fd=h][,ifname=name][,script=file][,downscript=dfile]\n"
" connect the host TAP network interface to VLAN 'n' and use the\n"
" network scripts 'file' (default=%s)\n"
" and 'dfile' (default=%s);\n"
" use '[down]script=no' to disable script execution;\n"
-- " use 'scriptarg=...' to pass an additional (nonempty) argument;\n"
" use 'fd=h' to connect to an already opened TAP interface\n"
#endif
- "-net socket[,vlan=n][,fd=h][,listen=[host]:port][,connect=host:port]\n"
+ "-net socket[,vlan=n][,name=str][,fd=h][,listen=[host]:port][,connect=host:port]\n"
" connect the vlan 'n' to another VLAN using a socket connection\n"
- "-net socket[,vlan=n][,fd=h][,mcast=maddr:port]\n"
+ "-net socket[,vlan=n][,name=str][,fd=h][,mcast=maddr:port]\n"
" connect the vlan 'n' to multicast maddr and port\n"
#ifdef CONFIG_VDE
- "-net vde[,vlan=n][,sock=socketpath][,port=n][,group=groupname][,mode=octalmode]\n"
+ "-net vde[,vlan=n][,name=str][,sock=socketpath][,port=n][,group=groupname][,mode=octalmode]\n"
" connect the vlan 'n' to port 'n' of a vde switch running\n"
" on host and listening for incoming connections on 'socketpath'.\n"
" Use group 'groupname' and mode 'octalmode' to change default\n"
#endif
"-clock force the use of the given methods for timer alarm.\n"
" To see what timers are available use -clock ?\n"
+ "-localtime set the real time clock to local time [default=utc]\n"
"-startdate select initial date of the clock\n"
"-icount [N|auto]\n"
- " Enable virtual instruction counter with 2^N clock ticks per instruction\n"
+ " enable virtual instruction counter with 2^N clock ticks per instruction\n"
+ "-echr chr set terminal escape character instead of ctrl-a\n"
+ "-virtioconsole c\n"
+ " set virtio console\n"
+ "-show-cursor show cursor\n"
+#if defined(TARGET_ARM) || defined(TARGET_M68K)
+ "-semihosting semihosting mode\n"
+#endif
+#if defined(TARGET_ARM)
+ "-old-param old param mode\n"
+#endif
+ "-tb-size n set TB size\n"
+ "-incoming p prepare for incoming migration, listen on port p\n"
"\n"
- "Options specific to the Xen version:\n"
- "-videoram set amount of memory available to virtual video adapter\n"
- "-direct-pci s specify pci passthrough, with configuration string s\n"
- "-pciemulation name:vendorid:deviceid:command:status:revision:classcode:headertype:subvendorid:subsystemid:interruputline:interruputpin\n"
- "-vncunused bind the VNC server to an unused port\n"
- "-std-vga alias for -vga std\n"
- "\n"
"During emulation, the following keys are useful:\n"
"ctrl-alt-f toggle full screen\n"
"ctrl-alt-n switch to virtual console 'n'\n"
QEMU_OPTION_append,
QEMU_OPTION_initrd,
- /* Xen tree: */
- QEMU_OPTION_disable_opengl,
- QEMU_OPTION_direct_pci,
- QEMU_OPTION_pci_emulation,
- QEMU_OPTION_vncunused,
- QEMU_OPTION_videoram,
- QEMU_OPTION_std_vga,
-
+ /* Debug/Expert options: */
+ QEMU_OPTION_serial,
+ QEMU_OPTION_parallel,
+ QEMU_OPTION_monitor,
+ QEMU_OPTION_pidfile,
QEMU_OPTION_S,
QEMU_OPTION_s,
QEMU_OPTION_p,
{ "L", HAS_ARG, QEMU_OPTION_L },
{ "bios", HAS_ARG, QEMU_OPTION_bios },
#ifdef USE_KQEMU
- { "no-kqemu", 0, QEMU_OPTION_no_kqemu },
{ "kernel-kqemu", 0, QEMU_OPTION_kernel_kqemu },
+ { "no-kqemu", 0, QEMU_OPTION_no_kqemu },
#endif
-#if defined(TARGET_PPC) || defined(TARGET_SPARC)
- { "g", 1, QEMU_OPTION_g },
-#endif
- { "localtime", 0, QEMU_OPTION_localtime },
- { "std-vga", 0, QEMU_OPTION_std_vga },
- { "videoram", HAS_ARG, QEMU_OPTION_videoram },
- { "vga", HAS_ARG, QEMU_OPTION_vga },
- { "echr", HAS_ARG, QEMU_OPTION_echr },
- { "monitor", HAS_ARG, QEMU_OPTION_monitor },
- { "domain-name", 1, QEMU_OPTION_domainname },
- { "serial", HAS_ARG, QEMU_OPTION_serial },
- { "parallel", HAS_ARG, QEMU_OPTION_parallel },
- { "loadvm", HAS_ARG, QEMU_OPTION_loadvm },
- { "full-screen", 0, QEMU_OPTION_full_screen },
-#ifdef CONFIG_SDL
- { "no-frame", 0, QEMU_OPTION_no_frame },
- { "alt-grab", 0, QEMU_OPTION_alt_grab },
- { "no-quit", 0, QEMU_OPTION_no_quit },
- { "sdl", 0, QEMU_OPTION_sdl },
-#endif
-#ifdef CONFIG_OPENGL
- { "disable-opengl", 0, QEMU_OPTION_disable_opengl },
-#endif
- { "vcpus", 1, QEMU_OPTION_vcpus },
- { "acpi", 0, QEMU_OPTION_acpi }, /* deprecated, for xend compatibility */
- { "direct_pci", HAS_ARG, QEMU_OPTION_direct_pci },
- { "pciemulation", HAS_ARG, QEMU_OPTION_pci_emulation },
- { "pidfile", HAS_ARG, QEMU_OPTION_pidfile },
- { "win2k-hack", 0, QEMU_OPTION_win2k_hack },
- { "usbdevice", HAS_ARG, QEMU_OPTION_usbdevice },
- { "smp", HAS_ARG, QEMU_OPTION_smp },
- { "vnc", HAS_ARG, QEMU_OPTION_vnc },
- { "vncunused", 0, QEMU_OPTION_vncunused },
-#ifdef CONFIG_CURSES
- { "curses", 0, QEMU_OPTION_curses },
-#endif
- { "uuid", HAS_ARG, QEMU_OPTION_uuid },
-#ifdef CONFIG_XEN
- { "xen-domid", HAS_ARG, QEMU_OPTION_xen_domid },
- { "xen-create", 0, QEMU_OPTION_xen_create },
- { "xen-attach", 0, QEMU_OPTION_xen_attach },
+#ifdef CONFIG_KVM
+ { "enable-kvm", 0, QEMU_OPTION_enable_kvm },
#endif
-
- /* temporary options */
- { "usb", 0, QEMU_OPTION_usb },
- { "no-acpi", 0, QEMU_OPTION_no_acpi },
{ "no-reboot", 0, QEMU_OPTION_no_reboot },
{ "no-shutdown", 0, QEMU_OPTION_no_shutdown },
- { "show-cursor", 0, QEMU_OPTION_show_cursor },
+ { "loadvm", HAS_ARG, QEMU_OPTION_loadvm },
{ "daemonize", 0, QEMU_OPTION_daemonize },
{ "option-rom", HAS_ARG, QEMU_OPTION_option_rom },
+#if defined(TARGET_SPARC) || defined(TARGET_PPC)
+ { "prom-env", HAS_ARG, QEMU_OPTION_prom_env },
+#endif
+ { "clock", HAS_ARG, QEMU_OPTION_clock },
+ { "localtime", 0, QEMU_OPTION_localtime },
+ { "startdate", HAS_ARG, QEMU_OPTION_startdate },
+ { "icount", HAS_ARG, QEMU_OPTION_icount },
+ { "echr", HAS_ARG, QEMU_OPTION_echr },
+ { "virtioconsole", HAS_ARG, QEMU_OPTION_virtiocon },
+ { "show-cursor", 0, QEMU_OPTION_show_cursor },
#if defined(TARGET_ARM) || defined(TARGET_M68K)
{ "semihosting", 0, QEMU_OPTION_semihosting },
-#endif
- { "name", HAS_ARG, QEMU_OPTION_name },
-#if defined(TARGET_SPARC)
- { "prom-env", HAS_ARG, QEMU_OPTION_prom_env },
#endif
-
- /* Xen tree options: */
- { "std-vga", 0, QEMU_OPTION_std_vga },
- { "videoram", HAS_ARG, QEMU_OPTION_videoram },
- { "d", HAS_ARG, QEMU_OPTION_domid }, /* deprecated; for xend compatibility */
- { "domid", HAS_ARG, QEMU_OPTION_domid },
- { "domain-name", 1, QEMU_OPTION_domainname },
- #ifdef CONFIG_OPENGL
- { "disable-opengl", 0, QEMU_OPTION_disable_opengl },
- #endif
- { "acpi", 0, QEMU_OPTION_acpi }, /* deprecated, for xend compatibility */
- { "direct_pci", HAS_ARG, QEMU_OPTION_direct_pci },
- { "pciemulation", HAS_ARG, QEMU_OPTION_pci_emulation },
- { "vncunused", 0, QEMU_OPTION_vncunused },
- #ifdef CONFIG_XEN
- { "xen-domid", HAS_ARG, QEMU_OPTION_xen_domid },
- { "xen-create", 0, QEMU_OPTION_xen_create },
- { "xen-attach", 0, QEMU_OPTION_xen_attach },
- #endif
-
#if defined(TARGET_ARM)
{ "old-param", 0, QEMU_OPTION_old_param },
#endif
#ifdef HAS_AUDIO
struct soundhw soundhw[] = {
#ifdef HAS_AUDIO_CHOICE
--#if (defined(TARGET_I386) || defined(TARGET_MIPS)) && !defined(CONFIG_DM)
++#if defined(TARGET_I386) || defined(TARGET_MIPS)
{
"pcspk",
"PC speaker",
int autostart;
const char *incoming = NULL;
- logfile = stderr; /* initial value */
-
-#if !defined(__sun__) && !defined(CONFIG_STUBDOM)
- /* Maximise rlimits. Needed where default constraints are tight (*BSD). */
- if (getrlimit(RLIMIT_STACK, &rl) != 0) {
- perror("getrlimit(RLIMIT_STACK)");
- exit(1);
- }
- rl.rlim_cur = rl.rlim_max;
- if (setrlimit(RLIMIT_STACK, &rl) != 0)
- perror("setrlimit(RLIMIT_STACK)");
- if (getrlimit(RLIMIT_DATA, &rl) != 0) {
- perror("getrlimit(RLIMIT_DATA)");
- exit(1);
- }
- rl.rlim_cur = rl.rlim_max;
- if (setrlimit(RLIMIT_DATA, &rl) != 0)
- perror("setrlimit(RLIMIT_DATA)");
- rl.rlim_cur = RLIM_INFINITY;
- rl.rlim_max = RLIM_INFINITY;
- if (setrlimit(RLIMIT_RSS, &rl) != 0)
- perror("setrlimit(RLIMIT_RSS)");
- rl.rlim_cur = RLIM_INFINITY;
- rl.rlim_max = RLIM_INFINITY;
- if (setrlimit(RLIMIT_MEMLOCK, &rl) != 0)
- perror("setrlimit(RLIMIT_MEMLOCK)");
- #endif
-
+ qemu_cache_utils_init(envp);
- logfile = stderr; /* initial value */
-
- #if !defined(__sun__) && !defined(CONFIG_STUBDOM)
- /* Maximise rlimits. Needed where default constraints are tight (*BSD). */
- if (getrlimit(RLIMIT_STACK, &rl) != 0) {
- perror("getrlimit(RLIMIT_STACK)");
- exit(1);
- }
- rl.rlim_cur = rl.rlim_max;
- if (setrlimit(RLIMIT_STACK, &rl) != 0)
- perror("setrlimit(RLIMIT_STACK)");
- if (getrlimit(RLIMIT_DATA, &rl) != 0) {
- perror("getrlimit(RLIMIT_DATA)");
- exit(1);
- }
- rl.rlim_cur = rl.rlim_max;
- if (setrlimit(RLIMIT_DATA, &rl) != 0)
- perror("setrlimit(RLIMIT_DATA)");
- rl.rlim_cur = RLIM_INFINITY;
- rl.rlim_max = RLIM_INFINITY;
- if (setrlimit(RLIMIT_RSS, &rl) != 0)
- perror("setrlimit(RLIMIT_RSS)");
- rl.rlim_cur = RLIM_INFINITY;
- rl.rlim_max = RLIM_INFINITY;
- if (setrlimit(RLIMIT_MEMLOCK, &rl) != 0)
- perror("setrlimit(RLIMIT_MEMLOCK)");
- #endif
+
LIST_INIT (&vm_change_state_head);
#ifndef _WIN32
{
machine = first_machine;
cpu_model = NULL;
initrd_filename = NULL;
- ram_size = VGA_RAM_SIZE;
+ ram_size = 0;
++ vga_ram_size = VGA_RAM_SIZE;
#ifdef CONFIG_GDBSTUB
use_gdbstub = 0;
gdbstub_port = DEFAULT_GDBSTUB_PORT;
break;
case QEMU_OPTION_loadvm:
loadvm = optarg;
- restore = 1;
- restore = 1;
break;
case QEMU_OPTION_full_screen:
full_screen = 1;
sdl = 1;
break;
#endif
-
- case QEMU_OPTION_pci_emulation:
- if (nb_pci_emulation >= MAX_PCI_EMULATION) {
- fprintf(stderr, "Too many PCI emulations\n");
- exit(1);
- }
- pstrcpy(pci_emulation_config_text[nb_pci_emulation],
- sizeof(pci_emulation_config_text[0]),
- optarg);
- nb_pci_emulation++;
- break;
- case QEMU_OPTION_domid: /* depricated, use -xen-* instead */
- xen_domid = domid = atoi(optarg);
- xen_mode = XEN_ATTACH;
- fprintf(logfile, "domid: %d\n", domid);
- break;
- case QEMU_OPTION_videoram:
- {
- char *ptr;
- vga_ram_size = strtol(optarg,&ptr,10);
- vga_ram_size *= 1024 * 1024;
- }
- break;
- case QEMU_OPTION_std_vga:
- cirrus_vga_enabled = 0;
- vmsvga_enabled = 0;
- break;
-- case QEMU_OPTION_disable_opengl:
-- opengl_enabled = 0;
-- break;
-- case QEMU_OPTION_direct_pci:
- direct_pci = optarg;
- direct_pci = optarg;
-- break;
-- case QEMU_OPTION_vcpus:
-- vcpus = atoi(optarg);
-- fprintf(logfile, "qemu: the number of cpus is %d\n", vcpus);
-- break;
-- case QEMU_OPTION_acpi:
-- acpi_enabled = 1;
- break;
- case QEMU_OPTION_vncunused:
- vncunused = 1;
- break;
- #ifdef CONFIG_XEN
- case QEMU_OPTION_xen_domid:
- xen_domid = domid = atoi(optarg);
- break;
- case QEMU_OPTION_xen_create:
- xen_mode = XEN_CREATE;
- break;
- case QEMU_OPTION_xen_attach:
- xen_mode = XEN_ATTACH;
-- break;
- #endif
-
case QEMU_OPTION_pidfile:
pid_file = optarg;
break;
case QEMU_OPTION_semihosting:
semihosting_enabled = 1;
break;
-- case QEMU_OPTION_domainname: /* depricated, use -name instead */
case QEMU_OPTION_name:
- snprintf(domain_name, sizeof(domain_name),
- "Xen-%s", optarg);
qemu_name = optarg;
- snprintf(domain_name, sizeof(domain_name),
- "Xen-%s", optarg);
break;
-#ifdef TARGET_SPARC
+#if defined(TARGET_SPARC) || defined(TARGET_PPC)
case QEMU_OPTION_prom_env:
if (nb_prom_envs >= MAX_PROM_ENVS) {
fprintf(stderr, "Too many prom variables\n");
exit(1);
}
}
-
#endif
--#if defined (__ia64__)
-- if (ram_size > VGA_IO_START)
-- ram_size += VGA_IO_SIZE; /* skip VGA I/O hole */
-- if (ram_size > MMIO_START)
-- ram_size += 1 * MEM_G; /* skip 3G-4G MMIO, LEGACY_IO_SPACE etc. */
--#endif
-
+ /* init the bluetooth world */
+ for (i = 0; i < nb_bt_opts; i++)
+ if (bt_parse(bt_opts[i]))
+ exit(1);
/* init the memory */
--
-- /* If we're on cirrus, set vga_ram_size to 4M whatever the videoram option might have set it to */
-- if ( cirrus_vga_enabled && vga_ram_size != 4 * 1024 * 1024 )
-- {
-- fprintf(stderr,"-videoram option does not work with cirrus vga device model. Videoram set to 4M.\n");
-- vga_ram_size = 4 * 1024 * 1024;
-- }
--
-- phys_ram_size = (machine->ram_require + vga_ram_size) & ~RAMSIZE_FIXED;
++ phys_ram_size = machine->ram_require & ~RAMSIZE_FIXED;
if (machine->ram_require & RAMSIZE_FIXED) {
if (ram_size > 0) {
phys_ram_size += ram_size;
}
--#ifndef CONFIG_DM
phys_ram_base = qemu_vmalloc(phys_ram_size);
if (!phys_ram_base) {
fprintf(stderr, "Could not allocate physical memory\n");
exit(1);
}
--#endif
/* init the dynamic translator */
cpu_exec_init_all(tb_size * 1024 * 1024);
bdrv_init();
-- xc_handle = xc_interface_open();
--#ifdef CONFIG_STUBDOM
-- {
-- char *domid_s, *msg;
-- if ((msg = xenbus_read(XBT_NIL, "domid", &domid_s)))
-- fprintf(stderr,"Can not read our own domid: %s\n", msg);
-- else
-- xenstore_parse_domain_config(atoi(domid_s));
-- }
--#else
-- xenstore_parse_domain_config(domid);
--#endif /* CONFIG_STUBDOM */
--
/* we always create the cdrom drive, even if no disk is there */
--#ifndef CONFIG_DM
if (nb_drives_opt < MAX_DRIVES)
drive_add(NULL, CDROM_ALIAS);
--#endif
/* we always create at least one floppy */
}
}
+ for(i = 0; i < MAX_VIRTIO_CONSOLES; i++) {
+ const char *devname = virtio_consoles[i];
+ if (devname && strcmp(devname, "none")) {
+ char label[32];
+ snprintf(label, sizeof(label), "virtcon%d", i);
+ virtcon_hds[i] = qemu_chr_open(label, devname, NULL);
+ if (!virtcon_hds[i]) {
+ fprintf(stderr, "qemu: could not open virtio console '%s'\n",
+ devname);
+ exit(1);
+ }
+ }
+ }
+
machine->init(ram_size, vga_ram_size, boot_devices,
-- kernel_filename, kernel_cmdline, initrd_filename, cpu_model,
-- direct_pci);
++ kernel_filename, kernel_cmdline, initrd_filename, cpu_model);
+
+ /* Set KVM's vcpu state to qemu's initial CPUState. */
+ if (kvm_enabled()) {
+ int ret;
+
+ ret = kvm_sync_vcpus();
+ if (ret < 0) {
+ fprintf(stderr, "failed to initialize vcpus\n");
+ exit(1);
+ }
+ }
+ if (loadvm)
+ do_loadvm(loadvm);
+
/* init USB devices */
if (usb_enabled) {
for(i = 0; i < usb_devices_index; i++) {
/* just use the first displaystate for the moment */
ds = display_state;
/* terminal init */
- +#ifdef CONFIG_STUBDOM
- + if (xenfb_pv_display_init(ds) == 0) {
- + } else
- +#endif
-#ifdef CONFIG_STUBDOM
- if (xenfb_pv_display_init(ds) == 0) {
- } else
-#endif
if (nographic) {
if (curses) {
fprintf(stderr, "fatal: -nographic can't be used with -curses\n");
exit(1);
}
- } else {
+ } else {
#if defined(CONFIG_CURSES)
- if (curses) {
- /* At the moment curses cannot be used with other displays */
- curses_display_init(ds, full_screen);
- } else
+ if (curses) {
+ /* At the moment curses cannot be used with other displays */
+ curses_display_init(ds, full_screen);
+ } else
#endif
- {
- if (vnc_display != NULL || vncunused != 0) {
- int vnc_display_port;
- char password[20];
- vnc_display_init(ds);
- xenstore_read_vncpasswd(domid, password, sizeof(password));
- vnc_display_password(ds, password);
- vnc_display_port = vnc_display_open(ds, vnc_display, vncunused);
- if (vnc_display_port < 0)
- exit(1);
- xenstore_write_vncport(vnc_display_port);
- }
+ {
- if (vnc_display != NULL || vncunused != 0) {
- int vnc_display_port;
- char password[20];
- vnc_display_init(ds, vncunused);
- xenstore_read_vncpasswd(domid, password, sizeof(password));
- vnc_display_password(ds, password);
- vnc_display_port = vnc_display_open(ds, vnc_display, vncunused);
- if (vnc_display_port < 0)
++ if (vnc_display != NULL) {
++ vnc_display_init(ds);
++ if (vnc_display_open(ds, vnc_display) < 0)
+ exit(1);
- xenstore_write_vncport(vnc_display_port);
+ }
#if defined(CONFIG_SDL)
- if (sdl || !vnc_display)
- sdl_display_init(ds, full_screen, no_frame, opengl_enabled);
+ if (sdl || !vnc_display)
- sdl_display_init(ds, full_screen, no_frame, opengl_enabled);
++ sdl_display_init(ds, full_screen, no_frame);
#elif defined(CONFIG_COCOA)
- if (sdl || !vnc_display)
- cocoa_display_init(ds, full_screen);
+ if (sdl || !vnc_display)
+ cocoa_display_init(ds, full_screen);
#endif
- }
+ }
}
dpy_resize(ds);
}
}
-- for (i = 0; i < nb_pci_emulation; i++) {
-- if(pci_emulation_add(pci_emulation_config_text[i]) < 0) {
-- fprintf(stderr, "Warning: could not add PCI device %s\n",
-- pci_emulation_config_text[i]);
- }
- }
-
- if (strlen(direct_pci_str) > 0)
- direct_pci = direct_pci_str;
-
+ for(i = 0; i < MAX_VIRTIO_CONSOLES; i++) {
+ const char *devname = virtio_consoles[i];
+ if (virtcon_hds[i] && devname) {
+ char label[32];
+ snprintf(label, sizeof(label), "virtcon%d", i);
+ if (strstart(devname, "vc", 0))
+ qemu_chr_printf(virtcon_hds[i], "virtio console%d\r\n", i);
}
}