summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile11
-rw-r--r--Makefile.target7
-rw-r--r--block-qcow2.c127
-rw-r--r--block-raw-posix.c195
-rw-r--r--block.c58
-rw-r--r--block.h15
-rw-r--r--block_int.h20
-rw-r--r--cutils.c19
-rw-r--r--dma-helpers.c27
-rw-r--r--exec.c11
-rw-r--r--gdbstub.c59
-rw-r--r--hw/boards.h1
-rw-r--r--hw/eepro100.c6
-rw-r--r--hw/firmware_abi.h12
-rw-r--r--hw/mips_jazz.c2
-rw-r--r--hw/mips_malta.c1
-rw-r--r--hw/mips_mipssim.c1
-rw-r--r--hw/mips_r4k.c1
-rw-r--r--hw/musicpal.c3
-rw-r--r--hw/pc.c29
-rw-r--r--hw/pci.h15
-rw-r--r--hw/scsi-generic.c42
-rw-r--r--hw/sun4m.c12
-rw-r--r--hw/sun4u.c3
-rw-r--r--hw/vga.c1
-rw-r--r--hw/virtio-blk.c88
-rw-r--r--hw/virtio.c99
-rw-r--r--hxtool44
-rw-r--r--monitor.c2
-rw-r--r--net.c5
-rw-r--r--posix-aio-compat.c100
-rw-r--r--posix-aio-compat.h7
-rw-r--r--qemu-char.c21
-rw-r--r--qemu-common.h1
-rw-r--r--qemu-doc.texi983
-rw-r--r--qemu-img.c24
-rw-r--r--qemu-img.texi4
-rw-r--r--qemu-options.hx1495
-rw-r--r--target-i386/kvm.c27
-rw-r--r--vl.c505
40 files changed, 2222 insertions, 1861 deletions
diff --git a/Makefile b/Makefile
index 37fa5062b..36c240220 100644
--- a/Makefile
+++ b/Makefile
@@ -290,13 +290,16 @@ cscope:
# documentation
%.html: %.texi
- texi2html -monolithic -number $<
+ texi2html -I=. -monolithic -number $<
%.info: %.texi
- makeinfo $< -o $@
+ makeinfo -I . $< -o $@
%.dvi: %.texi
- texi2dvi $<
+ texi2dvi -I . $<
+
+qemu-options.texi: $(SRC_PATH)/qemu-options.hx
+ sh $(SRC_PATH)/hxtool -t < $< > $@
qemu.1: qemu-doc.texi
perl -Ww -- $(SRC_PATH)/texi2pod.pl $< qemu.pod
@@ -316,7 +319,7 @@ dvi: qemu-doc.dvi qemu-tech.dvi
html: qemu-doc.html qemu-tech.html
-qemu-doc.dvi qemu-doc.html qemu-doc.info: qemu-img.texi qemu-nbd.texi
+qemu-doc.dvi qemu-doc.html qemu-doc.info: qemu-img.texi qemu-nbd.texi qemu-options.texi
VERSION ?= $(shell cat VERSION)
FILE = qemu-$(VERSION)
diff --git a/Makefile.target b/Makefile.target
index df2d4d655..cd6876e97 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -815,6 +815,8 @@ firmware.o: firmware.c
$(CC) $(HELPER_CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $<
endif
+vl.o: qemu-options.h
+
$(QEMU_PROG): LIBS += $(SDL_LIBS) $(COCOA_LIBS) $(CURSES_LIBS) $(BRLAPI_LIBS) $(VDE_LIBS)
$(QEMU_PROG): $(OBJS) ../libqemu_common.a libqemu.a $(DEPLIBS)
@@ -830,8 +832,11 @@ else
$(SHELL) $(SRC_PATH)/feature_to_c.sh $@ $(TARGET_XML_FILES)
endif
+qemu-options.h: $(SRC_PATH)/qemu-options.hx
+ sh $(SRC_PATH)/hxtool -h < $< > $@
+
clean:
- rm -f *.o *.a *~ $(PROGS) nwfpe/*.o fpu/*.o
+ rm -f *.o *.a *~ $(PROGS) nwfpe/*.o fpu/*.o qemu-options.h
rm -f *.d */*.d tcg/*.o
install: all
diff --git a/block-qcow2.c b/block-qcow2.c
index afbf7feb5..7759d34d5 100644
--- a/block-qcow2.c
+++ b/block-qcow2.c
@@ -45,6 +45,7 @@
//#define DEBUG_ALLOC
//#define DEBUG_ALLOC2
+//#define DEBUG_EXT
#define QCOW_MAGIC (('Q' << 24) | ('F' << 16) | ('I' << 8) | 0xfb)
#define QCOW_VERSION 2
@@ -77,6 +78,15 @@ typedef struct QCowHeader {
uint64_t snapshots_offset;
} QCowHeader;
+
+typedef struct {
+ uint32_t magic;
+ uint32_t len;
+} QCowExtension;
+#define QCOW_EXT_MAGIC_END 0
+#define QCOW_EXT_MAGIC_BACKING_FORMAT 0xE2792ACA
+
+
typedef struct __attribute__((packed)) QCowSnapshotHeader {
/* header is 8 byte aligned */
uint64_t l1_table_offset;
@@ -183,11 +193,84 @@ static int qcow_probe(const uint8_t *buf, int buf_size, const char *filename)
return 0;
}
+
+/*
+ * read qcow2 extension and fill bs
+ * start reading from start_offset
+ * finish reading upon magic of value 0 or when end_offset reached
+ * unknown magic is skipped (future extension this version knows nothing about)
+ * return 0 upon success, non-0 otherwise
+ */
+static int qcow_read_extensions(BlockDriverState *bs, uint64_t start_offset,
+ uint64_t end_offset)
+{
+ BDRVQcowState *s = bs->opaque;
+ QCowExtension ext;
+ uint64_t offset;
+
+#ifdef DEBUG_EXT
+ printf("qcow_read_extensions: start=%ld end=%ld\n", start_offset, end_offset);
+#endif
+ offset = start_offset;
+ while (offset < end_offset) {
+
+#ifdef DEBUG_EXT
+ /* Sanity check */
+ if (offset > s->cluster_size)
+ printf("qcow_handle_extension: suspicious offset %lu\n", offset);
+
+ printf("attemting to read extended header in offset %lu\n", offset);
+#endif
+
+ if (bdrv_pread(s->hd, offset, &ext, sizeof(ext)) != sizeof(ext)) {
+ fprintf(stderr, "qcow_handle_extension: ERROR: pread fail from offset %lu\n",
+ offset);
+ return 1;
+ }
+ be32_to_cpus(&ext.magic);
+ be32_to_cpus(&ext.len);
+ offset += sizeof(ext);
+#ifdef DEBUG_EXT
+ printf("ext.magic = 0x%x\n", ext.magic);
+#endif
+ switch (ext.magic) {
+ case QCOW_EXT_MAGIC_END:
+ return 0;
+
+ case QCOW_EXT_MAGIC_BACKING_FORMAT:
+ if (ext.len >= sizeof(bs->backing_format)) {
+ fprintf(stderr, "ERROR: ext_backing_format: len=%u too large"
+ " (>=%lu)\n",
+ ext.len, sizeof(bs->backing_format));
+ return 2;
+ }
+ if (bdrv_pread(s->hd, offset , bs->backing_format,
+ ext.len) != ext.len)
+ return 3;
+ bs->backing_format[ext.len] = '\0';
+#ifdef DEBUG_EXT
+ printf("Qcow2: Got format extension %s\n", bs->backing_format);
+#endif
+ offset += ((ext.len + 7) & ~7);
+ break;
+
+ default:
+ /* unknown magic -- just skip it */
+ offset += ((ext.len + 7) & ~7);
+ break;
+ }
+ }
+
+ return 0;
+}
+
+
static int qcow_open(BlockDriverState *bs, const char *filename, int flags)
{
BDRVQcowState *s = bs->opaque;
int len, i, shift, ret;
QCowHeader header;
+ uint64_t ext_end;
/* Performance is terrible right now with cache=writethrough due mainly
* to reference count updates. If the user does not explicitly specify
@@ -270,6 +353,14 @@ static int qcow_open(BlockDriverState *bs, const char *filename, int flags)
if (refcount_init(bs) < 0)
goto fail;
+ /* read qcow2 extensions */
+ if (header.backing_file_offset)
+ ext_end = header.backing_file_offset;
+ else
+ ext_end = s->cluster_size;
+ if (qcow_read_extensions(bs, sizeof(header), ext_end))
+ goto fail;
+
/* read the backing file name */
if (header.backing_file_offset != 0) {
len = header.backing_file_size;
@@ -1454,13 +1545,18 @@ static void create_refcount_update(QCowCreateState *s,
}
}
-static int qcow_create(const char *filename, int64_t total_size,
- const char *backing_file, int flags)
+static int qcow_create2(const char *filename, int64_t total_size,
+ const char *backing_file, const char *backing_format,
+ int flags)
{
+
int fd, header_size, backing_filename_len, l1_size, i, shift, l2_bits;
+ int backing_format_len = 0;
QCowHeader header;
uint64_t tmp, offset;
QCowCreateState s1, *s = &s1;
+ QCowExtension ext_bf = {0, 0};
+
memset(s, 0, sizeof(*s));
@@ -1474,6 +1570,12 @@ static int qcow_create(const char *filename, int64_t total_size,
header_size = sizeof(header);
backing_filename_len = 0;
if (backing_file) {
+ if (backing_format) {
+ ext_bf.magic = QCOW_EXT_MAGIC_BACKING_FORMAT;
+ backing_format_len = strlen(backing_format);
+ ext_bf.len = (backing_format_len + 7) & ~7;
+ header_size += ((sizeof(ext_bf) + ext_bf.len + 7) & ~7);
+ }
header.backing_file_offset = cpu_to_be64(header_size);
backing_filename_len = strlen(backing_file);
header.backing_file_size = cpu_to_be32(backing_filename_len);
@@ -1518,6 +1620,19 @@ static int qcow_create(const char *filename, int64_t total_size,
/* write all the data */
write(fd, &header, sizeof(header));
if (backing_file) {
+ if (backing_format_len) {
+ char zero[16];
+ int d = ext_bf.len - backing_format_len;
+
+ memset(zero, 0, sizeof(zero));
+ cpu_to_be32s(&ext_bf.magic);
+ cpu_to_be32s(&ext_bf.len);
+ write(fd, &ext_bf, sizeof(ext_bf));
+ write(fd, backing_format, backing_format_len);
+ if (d>0) {
+ write(fd, zero, d);
+ }
+ }
write(fd, backing_file, backing_filename_len);
}
lseek(fd, s->l1_table_offset, SEEK_SET);
@@ -1537,6 +1652,12 @@ static int qcow_create(const char *filename, int64_t total_size,
return 0;
}
+static int qcow_create(const char *filename, int64_t total_size,
+ const char *backing_file, int flags)
+{
+ return qcow_create2(filename, total_size, backing_file, NULL, flags);
+}
+
static int qcow_make_empty(BlockDriverState *bs)
{
#if 0
@@ -2613,4 +2734,6 @@ BlockDriver bdrv_qcow2 = {
.bdrv_snapshot_delete = qcow_snapshot_delete,
.bdrv_snapshot_list = qcow_snapshot_list,
.bdrv_get_info = qcow_get_info,
+
+ .bdrv_create2 = qcow_create2,
};
diff --git a/block-raw-posix.c b/block-raw-posix.c
index 9b1a7ee6b..2c2e48840 100644
--- a/block-raw-posix.c
+++ b/block-raw-posix.c
@@ -56,6 +56,7 @@
#ifdef __FreeBSD__
#include <signal.h>
#include <sys/disk.h>
+#include <sys/cdio.h>
#endif
#ifdef __OpenBSD__
@@ -111,6 +112,9 @@ typedef struct BDRVRawState {
int fd_got_error;
int fd_media_changed;
#endif
+#if defined(__FreeBSD__)
+ int cd_open_flags;
+#endif
uint8_t* aligned_buf;
} BDRVRawState;
@@ -118,6 +122,12 @@ static int posix_aio_init(void);
static int fd_open(BlockDriverState *bs);
+#if defined(__FreeBSD__)
+static int cd_open(BlockDriverState *bs);
+#endif
+
+static int raw_is_inserted(BlockDriverState *bs);
+
static int raw_open(BlockDriverState *bs, const char *filename, int flags)
{
BDRVRawState *s = bs->opaque;
@@ -770,6 +780,9 @@ static int64_t raw_getlength(BlockDriverState *bs)
int64_t size;
#ifdef HOST_BSD
struct stat sb;
+#ifdef __FreeBSD__
+ int reopened = 0;
+#endif
#endif
#ifdef __sun__
struct dk_minfo minfo;
@@ -782,6 +795,9 @@ static int64_t raw_getlength(BlockDriverState *bs)
return ret;
#ifdef HOST_BSD
+#ifdef __FreeBSD__
+again:
+#endif
if (!fstat(fd, &sb) && (S_IFCHR & sb.st_mode)) {
#ifdef DIOCGMEDIASIZE
if (ioctl(fd, DIOCGMEDIASIZE, (off_t *)&size))
@@ -800,6 +816,19 @@ static int64_t raw_getlength(BlockDriverState *bs)
#else
size = lseek(fd, 0LL, SEEK_END);
#endif
+#ifdef __FreeBSD__
+ switch(s->type) {
+ case FTYPE_CD:
+ /* XXX FreeBSD acd returns UINT_MAX sectors for an empty drive */
+ if (size == 2048LL * (unsigned)-1)
+ size = 0;
+ /* XXX no disc? maybe we need to reopen... */
+ if (size <= 0 && !reopened && cd_open(bs) >= 0) {
+ reopened = 1;
+ goto again;
+ }
+ }
+#endif
} else
#endif
#ifdef __sun__
@@ -990,6 +1019,14 @@ static int hdev_open(BlockDriverState *bs, const char *filename, int flags)
bs->sg = 1;
}
#endif
+#if defined(__FreeBSD__)
+ if (strstart(filename, "/dev/cd", NULL) ||
+ strstart(filename, "/dev/acd", NULL)) {
+ s->type = FTYPE_CD;
+ s->cd_open_flags = open_flags;
+ }
+#endif
+ s->fd = -1;
fd = open(filename, open_flags, 0644);
if (fd < 0) {
ret = -errno;
@@ -998,6 +1035,11 @@ static int hdev_open(BlockDriverState *bs, const char *filename, int flags)
return ret;
}
s->fd = fd;
+#if defined(__FreeBSD__)
+ /* make sure the door isnt locked at this time */
+ if (s->type == FTYPE_CD)
+ ioctl (s->fd, CDIOCALLOW);
+#endif
#if defined(__linux__)
/* close fd so that we can reopen it as needed */
if (s->type == FTYPE_FD) {
@@ -1164,16 +1206,76 @@ static int raw_ioctl(BlockDriverState *bs, unsigned long int req, void *buf)
return ioctl(s->fd, req, buf);
}
-#else
+
+static BlockDriverAIOCB *raw_aio_ioctl(BlockDriverState *bs,
+ unsigned long int req, void *buf,
+ BlockDriverCompletionFunc *cb, void *opaque)
+{
+ RawAIOCB *acb;
+
+ acb = raw_aio_setup(bs, 0, buf, 0, cb, opaque);
+ if (!acb)
+ return NULL;
+
+ acb->aiocb.aio_ioctl_cmd = req;
+ if (qemu_paio_ioctl(&acb->aiocb) < 0) {
+ raw_aio_remove(acb);
+ return NULL;
+ }
+
+ return &acb->common;
+}
+
+#elif defined(__FreeBSD__)
static int fd_open(BlockDriverState *bs)
{
+ BDRVRawState *s = bs->opaque;
+
+ /* this is just to ensure s->fd is sane (its called by io ops) */
+ if (s->fd >= 0)
+ return 0;
+ return -EIO;
+}
+
+static int cd_open(BlockDriverState *bs)
+{
+#if defined(__FreeBSD__)
+ BDRVRawState *s = bs->opaque;
+ int fd;
+
+ switch(s->type) {
+ case FTYPE_CD:
+ /* XXX force reread of possibly changed/newly loaded disc,
+ * FreeBSD seems to not notice sometimes... */
+ if (s->fd >= 0)
+ close (s->fd);
+ fd = open(bs->filename, s->cd_open_flags, 0644);
+ if (fd < 0) {
+ s->fd = -1;
+ return -EIO;
+ }
+ s->fd = fd;
+ /* make sure the door isnt locked at this time */
+ ioctl (s->fd, CDIOCALLOW);
+ }
+#endif
return 0;
}
static int raw_is_inserted(BlockDriverState *bs)
{
- return 1;
+ BDRVRawState *s = bs->opaque;
+
+ switch(s->type) {
+ case FTYPE_CD:
+ return (raw_getlength(bs) > 0);
+ case FTYPE_FD:
+ /* XXX handle this */
+ /* FALLTHRU */
+ default:
+ return 1;
+ }
}
static int raw_media_changed(BlockDriverState *bs)
@@ -1183,45 +1285,95 @@ static int raw_media_changed(BlockDriverState *bs)
static int raw_eject(BlockDriverState *bs, int eject_flag)
{
- return -ENOTSUP;
+ BDRVRawState *s = bs->opaque;
+
+ switch(s->type) {
+ case FTYPE_CD:
+ if (s->fd < 0)
+ return -ENOTSUP;
+ (void) ioctl (s->fd, CDIOCALLOW);
+ if (eject_flag) {
+ if (ioctl (s->fd, CDIOCEJECT) < 0)
+ perror("CDIOCEJECT");
+ } else {
+ if (ioctl (s->fd, CDIOCCLOSE) < 0)
+ perror("CDIOCCLOSE");
+ }
+ if (cd_open(bs) < 0)
+ return -ENOTSUP;
+ break;
+ case FTYPE_FD:
+ /* XXX handle this */
+ /* FALLTHRU */
+ default:
+ return -ENOTSUP;
+ }
+ return 0;
}
static int raw_set_locked(BlockDriverState *bs, int locked)
{
- return -ENOTSUP;
+ BDRVRawState *s = bs->opaque;
+
+ switch(s->type) {
+ case FTYPE_CD:
+ if (s->fd < 0)
+ return -ENOTSUP;
+ if (ioctl (s->fd, (locked ? CDIOCPREVENT : CDIOCALLOW)) < 0) {
+ /* Note: an error can happen if the distribution automatically
+ mounts the CD-ROM */
+ // perror("CDROM_LOCKDOOR");
+ }
+ break;
+ default:
+ return -ENOTSUP;
+ }
+ return 0;
}
static int raw_ioctl(BlockDriverState *bs, unsigned long int req, void *buf)
{
return -ENOTSUP;
}
-#endif /* !linux */
+#else /* !linux && !FreeBSD */
+
+static int fd_open(BlockDriverState *bs)
+{
+ return 0;
+}
+
+static int raw_is_inserted(BlockDriverState *bs)
+{
+ return 1;
+}
+
+static int raw_media_changed(BlockDriverState *bs)
+{
+ return -ENOTSUP;
+}
-static int raw_sg_send_command(BlockDriverState *bs, void *buf, int count)
+static int raw_eject(BlockDriverState *bs, int eject_flag)
{
- return raw_pwrite(bs, -1, buf, count);
+ return -ENOTSUP;
}
-static int raw_sg_recv_response(BlockDriverState *bs, void *buf, int count)
+static int raw_set_locked(BlockDriverState *bs, int locked)
{
- return raw_pread(bs, -1, buf, count);
+ return -ENOTSUP;
}
-static BlockDriverAIOCB *raw_sg_aio_read(BlockDriverState *bs,
- void *buf, int count,
- BlockDriverCompletionFunc *cb,
- void *opaque)
+static int raw_ioctl(BlockDriverState *bs, unsigned long int req, void *buf)
{
- return raw_aio_read(bs, 0, buf, -(int64_t)count, cb, opaque);
+ return -ENOTSUP;
}
-static BlockDriverAIOCB *raw_sg_aio_write(BlockDriverState *bs,
- void *buf, int count,
- BlockDriverCompletionFunc *cb,
- void *opaque)
+static BlockDriverAIOCB *raw_aio_ioctl(BlockDriverState *bs,
+ unsigned long int req, void *buf,
+ BlockDriverCompletionFunc *cb, void *opaque)
{
- return raw_aio_write(bs, 0, buf, -(int64_t)count, cb, opaque);
+ return -ENOTSUP;
}
+#endif /* !linux && !FreeBSD */
BlockDriver bdrv_host_device = {
.format_name = "host_device",
@@ -1248,8 +1400,5 @@ BlockDriver bdrv_host_device = {
.bdrv_set_locked = raw_set_locked,
/* generic scsi device */
.bdrv_ioctl = raw_ioctl,
- .bdrv_sg_send_command = raw_sg_send_command,
- .bdrv_sg_recv_response = raw_sg_recv_response,
- .bdrv_sg_aio_read = raw_sg_aio_read,
- .bdrv_sg_aio_write = raw_sg_aio_write,
+ .bdrv_aio_ioctl = raw_aio_ioctl,
};
diff --git a/block.c b/block.c
index 91912c6f7..8733f5e24 100644
--- a/block.c
+++ b/block.c
@@ -182,6 +182,20 @@ BlockDriver *bdrv_find_format(const char *format_name)
return NULL;
}
+int bdrv_create2(BlockDriver *drv,
+ const char *filename, int64_t size_in_sectors,
+ const char *backing_file, const char *backing_format,
+ int flags)
+{
+ if (drv->bdrv_create2)
+ return drv->bdrv_create2(filename, size_in_sectors, backing_file,
+ backing_format, flags);
+ if (drv->bdrv_create)
+ return drv->bdrv_create(filename, size_in_sectors, backing_file,
+ flags);
+ return -ENOTSUP;
+}
+
int bdrv_create(BlockDriver *drv,
const char *filename, int64_t size_in_sectors,
const char *backing_file, int flags)
@@ -358,7 +372,7 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
/* if there is a backing file, use it */
bs1 = bdrv_new("");
- ret = bdrv_open(bs1, filename, 0);
+ ret = bdrv_open2(bs1, filename, 0, drv);
if (ret < 0) {
bdrv_delete(bs1);
return ret;
@@ -379,12 +393,14 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
else
realpath(filename, backing_filename);
- ret = bdrv_create(&bdrv_qcow2, tmp_filename,
- total_size, backing_filename, 0);
+ ret = bdrv_create2(&bdrv_qcow2, tmp_filename,
+ total_size, backing_filename,
+ (drv ? drv->format_name : NULL), 0);
if (ret < 0) {
return ret;
}
filename = tmp_filename;
+ drv = &bdrv_qcow2;
bs->is_temporary = 1;
}
@@ -430,10 +446,14 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
#endif
if (bs->backing_file[0] != '\0') {
/* if there is a backing file, use it */
+ BlockDriver *back_drv = NULL;
bs->backing_hd = bdrv_new("");
path_combine(backing_filename, sizeof(backing_filename),
filename, bs->backing_file);
- ret = bdrv_open(bs->backing_hd, backing_filename, open_flags);
+ if (bs->backing_format[0] != '\0')
+ back_drv = bdrv_find_format(bs->backing_format);
+ ret = bdrv_open2(bs->backing_hd, backing_filename, open_flags,
+ back_drv);
if (ret < 0) {
bdrv_close(bs);
return ret;
@@ -1315,6 +1335,11 @@ static BlockDriverAIOCB *bdrv_aio_rw_vector(BlockDriverState *bs,
s->aiocb = bdrv_aio_read(bs, sector_num, s->bounce, nb_sectors,
bdrv_aio_rw_vector_cb, s);
}
+ if (!s->aiocb) {
+ qemu_vfree(s->bounce);
+ qemu_aio_release(s);
+ return NULL;
+ }
return &s->common;
}
@@ -1637,24 +1662,13 @@ int bdrv_ioctl(BlockDriverState *bs, unsigned long int req, void *buf)
return -ENOTSUP;
}
-int bdrv_sg_send_command(BlockDriverState *bs, void *buf, int count)
-{
- return bs->drv->bdrv_sg_send_command(bs, buf, count);
-}
-
-int bdrv_sg_recv_response(BlockDriverState *bs, void *buf, int count)
-{
- return bs->drv->bdrv_sg_recv_response(bs, buf, count);
-}
-
-BlockDriverAIOCB *bdrv_sg_aio_read(BlockDriverState *bs, void *buf, int count,
- BlockDriverCompletionFunc *cb, void *opaque)
+BlockDriverAIOCB *bdrv_aio_ioctl(BlockDriverState *bs,
+ unsigned long int req, void *buf,
+ BlockDriverCompletionFunc *cb, void *opaque)
{
- return bs->drv->bdrv_sg_aio_read(bs, buf, count, cb, opaque);
-}
+ BlockDriver *drv = bs->drv;
-BlockDriverAIOCB *bdrv_sg_aio_write(BlockDriverState *bs, void *buf, int count,
- BlockDriverCompletionFunc *cb, void *opaque)
-{
- return bs->drv->bdrv_sg_aio_write(bs, buf, count, cb, opaque);
+ if (drv && drv->bdrv_aio_ioctl)
+ return drv->bdrv_aio_ioctl(bs, req, buf, cb, opaque);
+ return NULL;
}
diff --git a/block.h b/block.h
index b0c63ac58..6701d3450 100644
--- a/block.h
+++ b/block.h
@@ -62,6 +62,10 @@ BlockDriver *bdrv_find_format(const char *format_name);
int bdrv_create(BlockDriver *drv,
const char *filename, int64_t size_in_sectors,
const char *backing_file, int flags);
+int bdrv_create2(BlockDriver *drv,
+ const char *filename, int64_t size_in_sectors,
+ const char *backing_file, const char *backing_format,
+ int flags);
BlockDriverState *bdrv_new(const char *device_name);
void bdrv_delete(BlockDriverState *bs);
int bdrv_file_open(BlockDriverState **pbs, const char *filename, int flags);
@@ -102,12 +106,10 @@ BlockDriverAIOCB *bdrv_aio_write(BlockDriverState *bs, int64_t sector_num,
void bdrv_aio_cancel(BlockDriverAIOCB *acb);
/* sg packet commands */
-int bdrv_sg_send_command(BlockDriverState *bs, void *buf, int count);
-int bdrv_sg_recv_response(BlockDriverState *bs, void *buf, int count);
-BlockDriverAIOCB *bdrv_sg_aio_read(BlockDriverState *bs, void *buf, int count,
- BlockDriverCompletionFunc *cb, void *opaque);
-BlockDriverAIOCB *bdrv_sg_aio_write(BlockDriverState *bs, void *buf, int count,
- BlockDriverCompletionFunc *cb, void *opaque);
+int bdrv_ioctl(BlockDriverState *bs, unsigned long int req, void *buf);
+BlockDriverAIOCB *bdrv_aio_ioctl(BlockDriverState *bs,
+ unsigned long int req, void *buf,
+ BlockDriverCompletionFunc *cb, void *opaque);
/* Ensure contents are flushed to disk. */
void bdrv_flush(BlockDriverState *bs);
@@ -169,7 +171,6 @@ int bdrv_snapshot_delete(BlockDriverState *bs, const char *snapshot_id);
int bdrv_snapshot_list(BlockDriverState *bs,
QEMUSnapshotInfo **psn_info);
char *bdrv_snapshot_dump(char *buf, int buf_size, QEMUSnapshotInfo *sn);
-int bdrv_ioctl(BlockDriverState *bs, unsigned long int req, void *buf);
char *get_human_readable_size(char *buf, int buf_size, int64_t size);
int path_is_absolute(const char *path);
diff --git a/block_int.h b/block_int.h
index f2d6dd63e..38bf28047 100644
--- a/block_int.h
+++ b/block_int.h
@@ -86,18 +86,17 @@ struct BlockDriver {
/* to control generic scsi devices */
int (*bdrv_ioctl)(BlockDriverState *bs, unsigned long int req, void *buf);
- int (*bdrv_sg_send_command)(BlockDriverState *bs, void *buf, int count);
- int (*bdrv_sg_recv_response)(BlockDriverState *bs, void *buf, int count);
- BlockDriverAIOCB *(*bdrv_sg_aio_read)(BlockDriverState *bs,
- void *buf, int count,
- BlockDriverCompletionFunc *cb,
- void *opaque);
- BlockDriverAIOCB *(*bdrv_sg_aio_write)(BlockDriverState *bs,
- void *buf, int count,
- BlockDriverCompletionFunc *cb,
- void *opaque);
+ BlockDriverAIOCB *(*bdrv_aio_ioctl)(BlockDriverState *bs,
+ unsigned long int req, void *buf,
+ BlockDriverCompletionFunc *cb, void *opaque);
AIOPool aio_pool;
+
+ /* new create with backing file format */
+ int (*bdrv_create2)(const char *filename, int64_t total_sectors,
+ const char *backing_file, const char *backing_format,
+ int flags);
+
struct BlockDriver *next;
};
@@ -120,6 +119,7 @@ struct BlockDriverState {
char filename[1024];
char backing_file[1024]; /* if non zero, the image is a diff of
this file image */
+ char backing_format[16]; /* if non-zero and backing_file exists */
int is_temporary;
int media_changed;
diff --git a/cutils.c b/cutils.c
index 9f26dd9fc..5b36cc6b6 100644
--- a/cutils.c
+++ b/cutils.c
@@ -23,6 +23,7 @@
*/
#include "qemu-common.h"
#include "host-utils.h"
+#include <assert.h>
void pstrcpy(char *buf, int buf_size, const char *str)
{
@@ -151,8 +152,22 @@ void qemu_iovec_init(QEMUIOVector *qiov, int alloc_hint)
qiov->size = 0;
}
+void qemu_iovec_init_external(QEMUIOVector *qiov, struct iovec *iov, int niov)
+{
+ int i;
+
+ qiov->iov = iov;
+ qiov->niov = niov;
+ qiov->nalloc = -1;
+ qiov->size = 0;
+ for (i = 0; i < niov; i++)
+ qiov->size += iov[i].iov_len;
+}
+
void qemu_iovec_add(QEMUIOVector *qiov, void *base, size_t len)
{
+ assert(qiov->nalloc != -1);
+
if (qiov->niov == qiov->nalloc) {
qiov->nalloc = 2 * qiov->nalloc + 1;
qiov->iov = qemu_realloc(qiov->iov, qiov->nalloc * sizeof(struct iovec));
@@ -165,11 +180,15 @@ void qemu_iovec_add(QEMUIOVector *qiov, void *base, size_t len)
void qemu_iovec_destroy(QEMUIOVector *qiov)
{
+ assert(qiov->nalloc != -1);
+
qemu_free(qiov->iov);
}
void qemu_iovec_reset(QEMUIOVector *qiov)
{
+ assert(qiov->nalloc != -1);
+
qiov->niov = 0;
qiov->size = 0;
}
diff --git a/dma-helpers.c b/dma-helpers.c
index 96a120cf3..1469e34df 100644
--- a/dma-helpers.c
+++ b/dma-helpers.c
@@ -70,20 +70,26 @@ static void continue_after_map_failure(void *opaque)
qemu_bh_schedule(dbs->bh);
}
-static void dma_bdrv_cb(void *opaque, int ret)
+static void dma_bdrv_unmap(DMAAIOCB *dbs)
{
- DMAAIOCB *dbs = (DMAAIOCB *)opaque;
- target_phys_addr_t cur_addr, cur_len;
- void *mem;
int i;
- dbs->acb = NULL;
- dbs->sector_num += dbs->iov.size / 512;
for (i = 0; i < dbs->iov.niov; ++i) {
cpu_physical_memory_unmap(dbs->iov.iov[i].iov_base,
dbs->iov.iov[i].iov_len, !dbs->is_write,
dbs->iov.iov[i].iov_len);
}
+}
+
+void dma_bdrv_cb(void *opaque, int ret)
+{
+ DMAAIOCB *dbs = (DMAAIOCB *)opaque;
+ target_phys_addr_t cur_addr, cur_len;
+ void *mem;
+
+ dbs->acb = NULL;
+ dbs->sector_num += dbs->iov.size / 512;
+ dma_bdrv_unmap(dbs);
qemu_iovec_reset(&dbs->iov);
if (dbs->sg_cur_index == dbs->sg->nsg || ret < 0) {
@@ -119,6 +125,11 @@ static void dma_bdrv_cb(void *opaque, int ret)
dbs->acb = bdrv_aio_readv(dbs->bs, dbs->sector_num, &dbs->iov,
dbs->iov.size / 512, dma_bdrv_cb, dbs);
}
+ if (!dbs->acb) {
+ dma_bdrv_unmap(dbs);
+ qemu_iovec_destroy(&dbs->iov);
+ return;
+ }
}
static BlockDriverAIOCB *dma_bdrv_io(
@@ -138,6 +149,10 @@ static BlockDriverAIOCB *dma_bdrv_io(
dbs->bh = NULL;
qemu_iovec_init(&dbs->iov, sg->nsg);
dma_bdrv_cb(dbs, 0);
+ if (!dbs->acb) {
+ qemu_aio_release(dbs);
+ return NULL;
+ }
return &dbs->common;
}
diff --git a/exec.c b/exec.c
index 67f3fa3da..b77d6b8de 100644
--- a/exec.c
+++ b/exec.c
@@ -3483,7 +3483,7 @@ void stq_phys(target_phys_addr_t addr, uint64_t val)
#endif
-/* virtual memory access for debug */
+/* virtual memory access for debug (includes writing to ROM) */
int cpu_memory_rw_debug(CPUState *env, target_ulong addr,
uint8_t *buf, int len, int is_write)
{
@@ -3500,8 +3500,13 @@ int cpu_memory_rw_debug(CPUState *env, target_ulong addr,
l = (page + TARGET_PAGE_SIZE) - addr;
if (l > len)
l = len;
- cpu_physical_memory_rw(phys_addr + (addr & ~TARGET_PAGE_MASK),
- buf, l, is_write);
+ phys_addr += (addr & ~TARGET_PAGE_MASK);
+#if !defined(CONFIG_USER_ONLY)
+ if (is_write)
+ cpu_physical_memory_write_rom(phys_addr, buf, l);
+ else
+#endif
+ cpu_physical_memory_rw(phys_addr, buf, l, is_write);
len -= l;
buf += l;
addr += l;
diff --git a/gdbstub.c b/gdbstub.c
index b8774a14c..cbd5a7c75 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -266,6 +266,7 @@ typedef struct GDBRegisterState {
} GDBRegisterState;
enum RSState {
+ RS_INACTIVE,
RS_IDLE,
RS_GETLINE,
RS_CHKSUM1,
@@ -1927,7 +1928,7 @@ static void gdb_vm_state_change(void *opaque, int running, int reason)
int ret;
if (running || (reason != EXCP_DEBUG && reason != EXCP_INTERRUPT) ||
- s->state == RS_SYSCALL)
+ s->state == RS_INACTIVE || s->state == RS_SYSCALL)
return;
/* disable single step if it was enable */
@@ -2219,8 +2220,6 @@ static void gdb_accept(void)
setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *)&val, sizeof(val));
s = qemu_mallocz(sizeof(GDBState));
-
- memset (s, 0, sizeof (GDBState));
s->c_cpu = first_cpu;
s->g_cpu = first_cpu;
s->fd = fd;
@@ -2347,36 +2346,50 @@ int gdbserver_start(const char *port)
char gdbstub_port_name[128];
int port_num;
char *p;
- CharDriverState *chr;
+ CharDriverState *chr = NULL;
+ CharDriverState *mon_chr;
if (!port || !*port)
return -1;
+ if (strcmp(port, "none") != 0) {
+ port_num = strtol(port, &p, 10);
+ if (*p == 0) {
+ /* A numeric value is interpreted as a port number. */
+ snprintf(gdbstub_port_name, sizeof(gdbstub_port_name),
+ "tcp::%d,nowait,nodelay,server", port_num);
+ port = gdbstub_port_name;
+ }
- port_num = strtol(port, &p, 10);
- if (*p == 0) {
- /* A numeric value is interpreted as a port number. */
- snprintf(gdbstub_port_name, sizeof(gdbstub_port_name),
- "tcp::%d,nowait,nodelay,server", port_num);
- port = gdbstub_port_name;
+ chr = qemu_chr_open("gdb", port, NULL);
+ if (!chr)
+ return -1;
+
+ qemu_chr_add_handlers(chr, gdb_chr_can_receive, gdb_chr_receive,
+ gdb_chr_event, NULL);
}
- chr = qemu_chr_open("gdb", port, NULL);
- if (!chr)
- return -1;
+ s = gdbserver_state;
+ if (!s) {
+ s = qemu_mallocz(sizeof(GDBState));
+ gdbserver_state = s;
- s = qemu_mallocz(sizeof(GDBState));
+ qemu_add_vm_change_state_handler(gdb_vm_state_change, NULL);
+
+ /* Initialize a monitor terminal for gdb */
+ mon_chr = qemu_mallocz(sizeof(*mon_chr));
+ mon_chr->chr_write = gdb_monitor_write;
+ monitor_init(mon_chr, 0);
+ } else {
+ if (s->chr)
+ qemu_chr_close(s->chr);
+ mon_chr = s->mon_chr;
+ memset(s, 0, sizeof(GDBState));
+ }
s->c_cpu = first_cpu;
s->g_cpu = first_cpu;
s->chr = chr;
- gdbserver_state = s;
- qemu_chr_add_handlers(chr, gdb_chr_can_receive, gdb_chr_receive,
- gdb_chr_event, NULL);
- qemu_add_vm_change_state_handler(gdb_vm_state_change, NULL);
-
- /* Initialize a monitor terminal for gdb */
- s->mon_chr = qemu_mallocz(sizeof(*s->mon_chr));
- s->mon_chr->chr_write = gdb_monitor_write;
- monitor_init(s->mon_chr, 0);
+ s->state = chr ? RS_IDLE : RS_INACTIVE;
+ s->mon_chr = mon_chr;
return 0;
}
diff --git a/hw/boards.h b/hw/boards.h
index fca5fad22..48218ca2a 100644
--- a/hw/boards.h
+++ b/hw/boards.h
@@ -16,7 +16,6 @@ typedef struct QEMUMachine {
QEMUMachineInitFunc *init;
#define RAMSIZE_FIXED (1 << 0)
ram_addr_t ram_require;
- int nodisk_ok;
int use_scsi;
int max_cpus;
struct QEMUMachine *next;
diff --git a/hw/eepro100.c b/hw/eepro100.c
index 84b8b9d4b..59931282c 100644
--- a/hw/eepro100.c
+++ b/hw/eepro100.c
@@ -47,12 +47,6 @@
/* Common declarations for all PCI devices. */
-#define PCI_DEVICE_ID 0x02 /* 16 bits */
-#define PCI_COMMAND 0x04 /* 16 bits */
-#define PCI_STATUS 0x06 /* 16 bits */
-
-#define PCI_REVISION_ID 0x08 /* 8 bits */
-
#define PCI_CONFIG_8(offset, value) \
(pci_conf[offset] = (value))
#define PCI_CONFIG_16(offset, value) \
diff --git a/hw/firmware_abi.h b/hw/firmware_abi.h
index 54702b290..5e6e5d4d3 100644
--- a/hw/firmware_abi.h
+++ b/hw/firmware_abi.h
@@ -43,12 +43,14 @@ OpenBIOS_set_var(uint8_t *nvram, uint32_t addr, const char *str)
}
/* Sun IDPROM structure at the end of NVRAM */
+/* from http://www.squirrel.com/squirrel/sun-nvram-hostid.faq.html */
struct Sun_nvram {
- uint8_t type;
- uint8_t machine_id;
- uint8_t macaddr[6];
- uint8_t unused[7];
- uint8_t checksum;
+ uint8_t type; /* always 01 */
+ uint8_t machine_id; /* first byte of host id (machine type) */
+ uint8_t macaddr[6]; /* 6 byte ethernet address (first 3 bytes 08, 00, 20) */
+ uint8_t date[4]; /* date of manufacture */
+ uint8_t hostid[3]; /* remaining 3 bytes of host id (serial number) */
+ uint8_t checksum; /* bitwise xor of previous bytes */
};
static inline void
diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c
index 9bdb903ee..74755178b 100644
--- a/hw/mips_jazz.c
+++ b/hw/mips_jazz.c
@@ -294,7 +294,6 @@ QEMUMachine mips_magnum_machine = {
.desc = "MIPS Magnum",
.init = mips_magnum_init,
.ram_require = MAGNUM_BIOS_SIZE + VGA_RAM_SIZE,
- .nodisk_ok = 1,
.use_scsi = 1,
};
@@ -303,6 +302,5 @@ QEMUMachine mips_pica61_machine = {
.desc = "Acer Pica 61",
.init = mips_pica61_init,
.ram_require = MAGNUM_BIOS_SIZE + VGA_RAM_SIZE,
- .nodisk_ok = 1,
.use_scsi = 1,
};
diff --git a/hw/mips_malta.c b/hw/mips_malta.c
index af1abb85a..2aba5cb88 100644
--- a/hw/mips_malta.c
+++ b/hw/mips_malta.c
@@ -958,5 +958,4 @@ QEMUMachine mips_malta_machine = {
.desc = "MIPS Malta Core LV",
.init = mips_malta_init,
.ram_require = VGA_RAM_SIZE + BIOS_SIZE,
- .nodisk_ok = 1,
};
diff --git a/hw/mips_mipssim.c b/hw/mips_mipssim.c
index 3f5490069..5fb58e418 100644
--- a/hw/mips_mipssim.c
+++ b/hw/mips_mipssim.c
@@ -185,5 +185,4 @@ QEMUMachine mips_mipssim_machine = {
.desc = "MIPS MIPSsim platform",
.init = mips_mipssim_init,
.ram_require = BIOS_SIZE + VGA_RAM_SIZE /* unused */,
- .nodisk_ok = 1,
};
diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c
index ab0c110f0..e6697e94e 100644
--- a/hw/mips_r4k.c
+++ b/hw/mips_r4k.c
@@ -282,5 +282,4 @@ QEMUMachine mips_machine = {
.desc = "mips r4k platform",
.init = mips_r4k_init,
.ram_require = VGA_RAM_SIZE + BIOS_SIZE,
- .nodisk_ok = 1,
};
diff --git a/hw/musicpal.c b/hw/musicpal.c
index abd3afa9e..8eb13160a 100644
--- a/hw/musicpal.c
+++ b/hw/musicpal.c
@@ -831,7 +831,8 @@ static void lcd_refresh(void *opaque)
break;
LCD_REFRESH(8, rgb_to_pixel8)
LCD_REFRESH(16, rgb_to_pixel16)
- LCD_REFRESH(32, (is_surface_bgr(s->ds) ? rgb_to_pixel32bgr : rgb_to_pixel32))
+ LCD_REFRESH(32, (is_surface_bgr(s->ds->surface) ?
+ rgb_to_pixel32bgr : rgb_to_pixel32))
default:
cpu_abort(cpu_single_env, "unsupported colour depth %i\n",
ds_get_bits_per_pixel(s->ds));
diff --git a/hw/pc.c b/hw/pc.c
index 28ddaddd4..d4a432095 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -812,7 +812,7 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
{
char buf[1024];
int ret, linux_boot, i;
- ram_addr_t ram_addr, vga_ram_addr, bios_offset, vga_bios_offset;
+ ram_addr_t ram_addr, vga_ram_addr, bios_offset, vga_bios_offset, option_rom_start = 0;
ram_addr_t below_4g_mem_size, above_4g_mem_size = 0;
int bios_size, isa_bios_size, vga_bios_size;
int pci_option_rom_offset;
@@ -824,6 +824,7 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
int index;
BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
BlockDriverState *fd[MAX_FD];
+ int using_vga = cirrus_vga_enabled || std_vga_enabled || vmsvga_enabled;
if (ram_size >= 0xe0000000 ) {
above_4g_mem_size = ram_size - 0xe0000000;
@@ -899,7 +900,7 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
exit(1);
}
- if (cirrus_vga_enabled || std_vga_enabled || vmsvga_enabled) {
+ if (using_vga) {
/* VGA BIOS load */
if (cirrus_vga_enabled) {
snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_CIRRUS_FILENAME);
@@ -917,12 +918,21 @@ vga_bios_error:
fprintf(stderr, "qemu: could not load VGA BIOS '%s'\n", buf);
exit(1);
}
+ /* Round up vga bios size to the next 2k boundary */
+ vga_bios_size = (vga_bios_size + 2047) & ~2047;
+ option_rom_start = 0xc0000 + vga_bios_size;
/* setup basic memory access */
- cpu_register_physical_memory(0xc0000, 0x10000,
+ cpu_register_physical_memory(0xc0000, vga_bios_size,
vga_bios_offset | IO_MEM_ROM);
}
+ /* No point in placing option roms before this address, since bochs bios
+ * will only start looking for it at 0xc8000 */
+ if (option_rom_start < 0xc8000)
+ option_rom_start = 0xc8000;
+
+
/* map the last 128KB of the BIOS in ISA space */
isa_bios_size = bios_size;
if (isa_bios_size > (128 * 1024))
@@ -943,14 +953,14 @@ vga_bios_error:
ram_addr_t option_rom_offset;
int size, offset;
- offset = 0;
+ offset = option_rom_start;
if (linux_boot) {
option_rom_offset = qemu_ram_alloc(TARGET_PAGE_SIZE);
load_linux(phys_ram_base + option_rom_offset,
kernel_filename, initrd_filename, kernel_cmdline);
- cpu_register_physical_memory(0xd0000, TARGET_PAGE_SIZE,
+ cpu_register_physical_memory(option_rom_start, TARGET_PAGE_SIZE,
option_rom_offset | IO_MEM_ROM);
- offset = TARGET_PAGE_SIZE;
+ offset += TARGET_PAGE_SIZE;
}
for (i = 0; i < nb_option_roms; i++) {
@@ -960,13 +970,13 @@ vga_bios_error:
option_rom[i]);
exit(1);
}
- if (size > (0x10000 - offset))
+ if (size > (0xe0000 - offset))
goto option_rom_error;
option_rom_offset = qemu_ram_alloc(size);
ret = load_image(option_rom[i], phys_ram_base + option_rom_offset);
if (ret != size) {
option_rom_error:
- fprintf(stderr, "Too many option ROMS\n");
+ fprintf(stderr, "Could not fit %soption roms in available space\n", using_vga ? "VGA bios and " : "");
exit(1);
}
size = (size + 4095) & ~4095;
@@ -974,8 +984,7 @@ vga_bios_error:
initialization, and (optionally) marked readonly by the BIOS
before INT 19h. See the PNPBIOS specification, appendix B.
DDIM support is mandatory for proper PCI expansion ROM support. */
- cpu_register_physical_memory(0xd0000 + offset,
- size, option_rom_offset /* | IO_MEM_ROM */);
+ cpu_register_physical_memory(offset, size, option_rom_offset /* | IO_MEM_ROM */);
option_rom_setup_reset(0xd0000 + offset, size);
offset += size;
}
diff --git a/hw/pci.h b/hw/pci.h
index a7438f25b..ea0bec891 100644
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -58,7 +58,7 @@ extern target_phys_addr_t pci_mem_base;
#define PCI_DEVICE_ID_VMWARE_SCSI 0x0730
#define PCI_DEVICE_ID_VMWARE_IDE 0x1729
-#define PCI_VENDOR_ID_INTEL 0x8086
+/* Intel (0x8086) */
#define PCI_DEVICE_ID_INTEL_82551IT 0x1209
/* Red Hat / Qumranet (for QEMU) -- see pci-ids.txt */
@@ -101,21 +101,28 @@ typedef struct PCIIORegion {
#define PCI_DEVICES_MAX 64
+/* Declarations from linux/pci_regs.h */
#define PCI_VENDOR_ID 0x00 /* 16 bits */
#define PCI_DEVICE_ID 0x02 /* 16 bits */
#define PCI_COMMAND 0x04 /* 16 bits */
#define PCI_COMMAND_IO 0x1 /* Enable response in I/O space */
#define PCI_COMMAND_MEMORY 0x2 /* Enable response in Memory space */
-#define PCI_REVISION 0x08
+#define PCI_STATUS 0x06 /* 16 bits */
+#define PCI_REVISION_ID 0x08 /* 8 bits */
#define PCI_CLASS_DEVICE 0x0a /* Device class */
-#define PCI_SUBVENDOR_ID 0x2c /* 16 bits */
-#define PCI_SUBDEVICE_ID 0x2e /* 16 bits */
+#define PCI_HEADER_TYPE 0x0e /* 8 bits */
+#define PCI_SUBSYSTEM_VENDOR_ID 0x2c /* 16 bits */
+#define PCI_SUBSYSTEM_ID 0x2e /* 16 bits */
#define PCI_CAPABILITY_LIST 0x34
#define PCI_INTERRUPT_LINE 0x3c /* 8 bits */
#define PCI_INTERRUPT_PIN 0x3d /* 8 bits */
#define PCI_MIN_GNT 0x3e /* 8 bits */
#define PCI_MAX_LAT 0x3f /* 8 bits */
+#define PCI_REVISION 0x08 /* obsolete, use PCI_REVISION_ID */
+#define PCI_SUBVENDOR_ID 0x2c /* obsolete, use PCI_SUBSYSTEM_VENDOR_ID */
+#define PCI_SUBDEVICE_ID 0x2e /* obsolete, use PCI_SUBSYSTEM_ID */
+
/* Bits in the PCI Status Register (PCI 2.3 spec) */
#define PCI_STATUS_RESERVED1 0x007
#define PCI_STATUS_INT_STATUS 0x008
diff --git a/hw/scsi-generic.c b/hw/scsi-generic.c
index 53e895127..f4c615b62 100644
--- a/hw/scsi-generic.c
+++ b/hw/scsi-generic.c
@@ -201,8 +201,6 @@ static int execute_command(BlockDriverState *bdrv,
SCSIRequest *r, int direction,
BlockDriverCompletionFunc *complete)
{
- int ret;
-
r->io_header.interface_id = 'S';
r->io_header.dxfer_direction = direction;
r->io_header.dxferp = r->buf;
@@ -215,27 +213,7 @@ static int execute_command(BlockDriverState *bdrv,
r->io_header.usr_ptr = r;
r->io_header.flags |= SG_FLAG_DIRECT_IO;
- ret = bdrv_sg_send_command(bdrv, &r->io_header, sizeof(r->io_header));
- if (ret < 0) {
- BADF("execute_command: write failed ! (%d)\n", errno);
- return -1;
- }
- if (complete == NULL) {
- int ret;
- r->aiocb = NULL;
- while ((ret = bdrv_sg_recv_response(bdrv, &r->io_header,
- sizeof(r->io_header))) < 0 &&
- ret == -EINTR)
- ;
- if (ret < 0) {
- BADF("execute_command: read failed !\n");
- return -1;
- }
- return 0;
- }
-
- r->aiocb = bdrv_sg_aio_read(bdrv, (uint8_t*)&r->io_header,
- sizeof(r->io_header), complete, r);
+ r->aiocb = bdrv_aio_ioctl(bdrv, SG_IO, &r->io_header, complete, r);
if (r->aiocb == NULL) {
BADF("execute_command: read failed !\n");
return -1;
@@ -637,14 +615,7 @@ static int get_blocksize(BlockDriverState *bdrv)
io_header.sbp = sensebuf;
io_header.timeout = 6000; /* XXX */
- ret = bdrv_sg_send_command(bdrv, &io_header, sizeof(io_header));
- if (ret < 0)
- return -1;
-
- while ((ret = bdrv_sg_recv_response(bdrv, &io_header, sizeof(io_header))) < 0 &&
- ret == -EINTR)
- ;
-
+ ret = bdrv_ioctl(bdrv, SG_IO, &io_header);
if (ret < 0)
return -1;
@@ -675,14 +646,7 @@ static int get_stream_blocksize(BlockDriverState *bdrv)
io_header.sbp = sensebuf;
io_header.timeout = 6000; /* XXX */
- ret = bdrv_sg_send_command(bdrv, &io_header, sizeof(io_header));
- if (ret < 0)
- return -1;
-
- while ((ret = bdrv_sg_recv_response(bdrv, &io_header, sizeof(io_header))) < 0 &&
- ret == -EINTR)
- ;
-
+ ret = bdrv_ioctl(bdrv, SG_IO, &io_header);
if (ret < 0)
return -1;
diff --git a/hw/sun4m.c b/hw/sun4m.c
index 681d9736e..9b3bab1de 100644
--- a/hw/sun4m.c
+++ b/hw/sun4m.c
@@ -1030,7 +1030,6 @@ QEMUMachine ss5_machine = {
.desc = "Sun4m platform, SPARCstation 5",
.init = ss5_init,
.ram_require = PROM_SIZE_MAX + TCX_SIZE,
- .nodisk_ok = 1,
.use_scsi = 1,
};
@@ -1039,7 +1038,6 @@ QEMUMachine ss10_machine = {
.desc = "Sun4m platform, SPARCstation 10",
.init = ss10_init,
.ram_require = PROM_SIZE_MAX + TCX_SIZE,
- .nodisk_ok = 1,
.use_scsi = 1,
.max_cpus = 4,
};
@@ -1049,7 +1047,6 @@ QEMUMachine ss600mp_machine = {
.desc = "Sun4m platform, SPARCserver 600MP",
.init = ss600mp_init,
.ram_require = PROM_SIZE_MAX + TCX_SIZE,
- .nodisk_ok = 1,
.use_scsi = 1,
.max_cpus = 4,
};
@@ -1059,7 +1056,6 @@ QEMUMachine ss20_machine = {
.desc = "Sun4m platform, SPARCstation 20",
.init = ss20_init,
.ram_require = PROM_SIZE_MAX + TCX_SIZE,
- .nodisk_ok = 1,
.use_scsi = 1,
.max_cpus = 4,
};
@@ -1069,7 +1065,6 @@ QEMUMachine voyager_machine = {
.desc = "Sun4m platform, SPARCstation Voyager",
.init = vger_init,
.ram_require = PROM_SIZE_MAX + TCX_SIZE,
- .nodisk_ok = 1,
.use_scsi = 1,
};
@@ -1078,7 +1073,6 @@ QEMUMachine ss_lx_machine = {
.desc = "Sun4m platform, SPARCstation LX",
.init = ss_lx_init,
.ram_require = PROM_SIZE_MAX + TCX_SIZE,
- .nodisk_ok = 1,
.use_scsi = 1,
};
@@ -1087,7 +1081,6 @@ QEMUMachine ss4_machine = {
.desc = "Sun4m platform, SPARCstation 4",
.init = ss4_init,
.ram_require = PROM_SIZE_MAX + TCX_SIZE,
- .nodisk_ok = 1,
.use_scsi = 1,
};
@@ -1096,7 +1089,6 @@ QEMUMachine scls_machine = {
.desc = "Sun4m platform, SPARCClassic",
.init = scls_init,
.ram_require = PROM_SIZE_MAX + TCX_SIZE,
- .nodisk_ok = 1,
.use_scsi = 1,
};
@@ -1105,7 +1097,6 @@ QEMUMachine sbook_machine = {
.desc = "Sun4m platform, SPARCbook",
.init = sbook_init,
.ram_require = PROM_SIZE_MAX + TCX_SIZE,
- .nodisk_ok = 1,
.use_scsi = 1,
};
@@ -1360,7 +1351,6 @@ QEMUMachine ss1000_machine = {
.desc = "Sun4d platform, SPARCserver 1000",
.init = ss1000_init,
.ram_require = PROM_SIZE_MAX + TCX_SIZE,
- .nodisk_ok = 1,
.use_scsi = 1,
.max_cpus = 8,
};
@@ -1370,7 +1360,6 @@ QEMUMachine ss2000_machine = {
.desc = "Sun4d platform, SPARCcenter 2000",
.init = ss2000_init,
.ram_require = PROM_SIZE_MAX + TCX_SIZE,
- .nodisk_ok = 1,
.use_scsi = 1,
.max_cpus = 20,
};
@@ -1581,6 +1570,5 @@ QEMUMachine ss2_machine = {
.desc = "Sun4c platform, SPARCstation 2",
.init = ss2_init,
.ram_require = PROM_SIZE_MAX + TCX_SIZE,
- .nodisk_ok = 1,
.use_scsi = 1,
};
diff --git a/hw/sun4u.c b/hw/sun4u.c
index a8c4347e1..a72dea837 100644
--- a/hw/sun4u.c
+++ b/hw/sun4u.c
@@ -597,7 +597,6 @@ QEMUMachine sun4u_machine = {
.desc = "Sun4u platform",
.init = sun4u_init,
.ram_require = PROM_SIZE_MAX + VGA_RAM_SIZE,
- .nodisk_ok = 1,
.max_cpus = 1, // XXX for now
};
@@ -606,7 +605,6 @@ QEMUMachine sun4v_machine = {
.desc = "Sun4v platform",
.init = sun4v_init,
.ram_require = PROM_SIZE_MAX + VGA_RAM_SIZE,
- .nodisk_ok = 1,
.max_cpus = 1, // XXX for now
};
@@ -615,6 +613,5 @@ QEMUMachine niagara_machine = {
.desc = "Sun4v platform, Niagara",
.init = niagara_init,
.ram_require = PROM_SIZE_MAX + VGA_RAM_SIZE,
- .nodisk_ok = 1,
.max_cpus = 1, // XXX for now
};
diff --git a/hw/vga.c b/hw/vga.c
index 5bb22f9cc..1b6af239f 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -2799,6 +2799,7 @@ static void vga_screen_dump_common(VGAState *s, const char *filename,
dcl.dpy_resize = vga_save_dpy_resize;
dcl.dpy_refresh = vga_save_dpy_refresh;
register_displaychangelistener(ds, &dcl);
+ ds->allocator = &default_allocator;
ds->surface = qemu_create_displaysurface(ds, w, h);
s->ds = ds;
diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index 520ad1bf2..51a8e2282 100644
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -35,8 +35,7 @@ typedef struct VirtIOBlockReq
VirtQueueElement elem;
struct virtio_blk_inhdr *in;
struct virtio_blk_outhdr *out;
- size_t size;
- uint8_t *buffer;
+ QEMUIOVector qiov;
struct VirtIOBlockReq *next;
} VirtIOBlockReq;
@@ -45,10 +44,9 @@ static void virtio_blk_req_complete(VirtIOBlockReq *req, int status)
VirtIOBlock *s = req->dev;
req->in->status = status;
- virtqueue_push(s->vq, &req->elem, req->size + sizeof(*req->in));
+ virtqueue_push(s->vq, &req->elem, req->qiov.size + sizeof(*req->in));
virtio_notify(&s->vdev, s->vq);
- qemu_free(req->buffer);
qemu_free(req);
}
@@ -76,24 +74,7 @@ static void virtio_blk_rw_complete(void *opaque, int ret)
{
VirtIOBlockReq *req = opaque;
- /* Copy read data to the guest */
- if (!ret && !(req->out->type & VIRTIO_BLK_T_OUT)) {
- size_t offset = 0;
- int i;
-
- for (i = 0; i < req->elem.in_num - 1; i++) {
- size_t len;
-
- /* Be pretty defensive wrt malicious guests */
- len = MIN(req->elem.in_sg[i].iov_len,
- req->size - offset);
-
- memcpy(req->elem.in_sg[i].iov_base,
- req->buffer + offset,
- len);
- offset += len;
- }
- } else if (ret && (req->out->type & VIRTIO_BLK_T_OUT)) {
+ if (ret && (req->out->type & VIRTIO_BLK_T_OUT)) {
if (virtio_blk_handle_write_error(req, -ret))
return;
}
@@ -122,39 +103,16 @@ static VirtIOBlockReq *virtio_blk_get_request(VirtIOBlock *s)
return req;
}
-static int virtio_blk_handle_write(VirtIOBlockReq *req)
+static void virtio_blk_handle_write(VirtIOBlockReq *req)
{
- if (!req->buffer) {
- size_t offset = 0;
- int i;
-
- for (i = 1; i < req->elem.out_num; i++)
- req->size += req->elem.out_sg[i].iov_len;
-
- req->buffer = qemu_memalign(512, req->size);
- if (req->buffer == NULL) {
- qemu_free(req);
- return -1;
- }
-
- /* We copy the data from the SG list to avoid splitting up the request.
- This helps performance a lot until we can pass full sg lists as AIO
- operations */
- for (i = 1; i < req->elem.out_num; i++) {
- size_t len;
-
- len = MIN(req->elem.out_sg[i].iov_len,
- req->size - offset);
- memcpy(req->buffer + offset,
- req->elem.out_sg[i].iov_base,
- len);
- offset += len;
- }
- }
+ bdrv_aio_writev(req->dev->bs, req->out->sector, &req->qiov,
+ req->qiov.size / 512, virtio_blk_rw_complete, req);
+}
- bdrv_aio_write(req->dev->bs, req->out->sector, req->buffer, req->size / 512,
- virtio_blk_rw_complete, req);
- return 0;
+static void virtio_blk_handle_read(VirtIOBlockReq *req)
+{
+ bdrv_aio_readv(req->dev->bs, req->out->sector, &req->qiov,
+ req->qiov.size / 512, virtio_blk_rw_complete, req);
}
static void virtio_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq)
@@ -163,8 +121,6 @@ static void virtio_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq)
VirtIOBlockReq *req;
while ((req = virtio_blk_get_request(s))) {
- int i;
-
if (req->elem.out_num < 1 || req->elem.in_num < 1) {
fprintf(stderr, "virtio-blk missing headers\n");
exit(1);
@@ -187,23 +143,13 @@ static void virtio_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq)
virtio_notify(vdev, vq);
qemu_free(req);
} else if (req->out->type & VIRTIO_BLK_T_OUT) {
- if (virtio_blk_handle_write(req) < 0)
- break;
+ qemu_iovec_init_external(&req->qiov, &req->elem.out_sg[1],
+ req->elem.out_num - 1);
+ virtio_blk_handle_write(req);
} else {
- for (i = 0; i < req->elem.in_num - 1; i++)
- req->size += req->elem.in_sg[i].iov_len;
-
- req->buffer = qemu_memalign(512, req->size);
- if (req->buffer == NULL) {
- qemu_free(req);
- break;
- }
-
- bdrv_aio_read(s->bs, req->out->sector,
- req->buffer,
- req->size / 512,
- virtio_blk_rw_complete,
- req);
+ qemu_iovec_init_external(&req->qiov, &req->elem.in_sg[0],
+ req->elem.in_num - 1);
+ virtio_blk_handle_read(req);
}
}
/*
diff --git a/hw/virtio.c b/hw/virtio.c
index 577eb5a4b..8a72d8d21 100644
--- a/hw/virtio.c
+++ b/hw/virtio.c
@@ -16,8 +16,6 @@
#include "virtio.h"
#include "sysemu.h"
-#define VIRTIO_ZERO_COPY
-
/* from Linux's linux/virtio_pci.h */
/* A 32-bit r/o bitmask of the features supported by the host */
@@ -113,43 +111,6 @@ struct VirtQueue
#define VIRTIO_PCI_QUEUE_MAX 16
/* virt queue functions */
-#ifdef VIRTIO_ZERO_COPY
-static void *virtio_map_gpa(target_phys_addr_t addr, size_t size)
-{
- ram_addr_t off;
- target_phys_addr_t addr1;
-
- off = cpu_get_physical_page_desc(addr);
- if ((off & ~TARGET_PAGE_MASK) != IO_MEM_RAM) {
- fprintf(stderr, "virtio DMA to IO ram\n");
- exit(1);
- }
-
- off = (off & TARGET_PAGE_MASK) | (addr & ~TARGET_PAGE_MASK);
-
- for (addr1 = addr + TARGET_PAGE_SIZE;
- addr1 < TARGET_PAGE_ALIGN(addr + size);
- addr1 += TARGET_PAGE_SIZE) {
- ram_addr_t off1;
-
- off1 = cpu_get_physical_page_desc(addr1);
- if ((off1 & ~TARGET_PAGE_MASK) != IO_MEM_RAM) {
- fprintf(stderr, "virtio DMA to IO ram\n");
- exit(1);
- }
-
- off1 = (off1 & TARGET_PAGE_MASK) | (addr1 & ~TARGET_PAGE_MASK);
-
- if (off1 != (off + (addr1 - addr))) {
- fprintf(stderr, "discontigous virtio memory\n");
- exit(1);
- }
- }
-
- return phys_ram_base + off;
-}
-#endif
-
static void virtqueue_init(VirtQueue *vq, target_phys_addr_t pa)
{
vq->vring.desc = pa;
@@ -274,35 +235,22 @@ void virtqueue_fill(VirtQueue *vq, const VirtQueueElement *elem,
unsigned int offset;
int i;
-#ifndef VIRTIO_ZERO_COPY
- for (i = 0; i < elem->out_num; i++)
- qemu_free(elem->out_sg[i].iov_base);
-#endif
-
offset = 0;
for (i = 0; i < elem->in_num; i++) {
size_t size = MIN(len - offset, elem->in_sg[i].iov_len);
-#ifdef VIRTIO_ZERO_COPY
- if (size) {
- ram_addr_t addr = (uint8_t *)elem->in_sg[i].iov_base - phys_ram_base;
- ram_addr_t off;
+ cpu_physical_memory_unmap(elem->in_sg[i].iov_base,
+ elem->in_sg[i].iov_len,
+ 1, size);
- for (off = 0; off < size; off += TARGET_PAGE_SIZE)
- cpu_physical_memory_set_dirty(addr + off);
- }
-#else
- if (size)
- cpu_physical_memory_write(elem->in_addr[i],
- elem->in_sg[i].iov_base,
- size);
-
- qemu_free(elem->in_sg[i].iov_base);
-#endif
-
- offset += size;
+ offset += elem->in_sg[i].iov_len;
}
+ for (i = 0; i < elem->out_num; i++)
+ cpu_physical_memory_unmap(elem->out_sg[i].iov_base,
+ elem->out_sg[i].iov_len,
+ 0, elem->out_sg[i].iov_len);
+
idx = (idx + vring_used_idx(vq)) % vq->vring.num;
/* Get a pointer to the next entry in the used ring. */
@@ -414,6 +362,7 @@ int virtqueue_avail_bytes(VirtQueue *vq, int in_bytes, int out_bytes)
int virtqueue_pop(VirtQueue *vq, VirtQueueElement *elem)
{
unsigned int i, head;
+ target_phys_addr_t len;
if (!virtqueue_num_heads(vq, vq->last_avail_idx))
return 0;
@@ -424,37 +373,23 @@ int virtqueue_pop(VirtQueue *vq, VirtQueueElement *elem)
i = head = virtqueue_get_head(vq, vq->last_avail_idx++);
do {
struct iovec *sg;
+ int is_write = 0;
if (vring_desc_flags(vq, i) & VRING_DESC_F_WRITE) {
elem->in_addr[elem->in_num] = vring_desc_addr(vq, i);
sg = &elem->in_sg[elem->in_num++];
+ is_write = 1;
} else
sg = &elem->out_sg[elem->out_num++];
/* Grab the first descriptor, and check it's OK. */
sg->iov_len = vring_desc_len(vq, i);
+ len = sg->iov_len;
-#ifdef VIRTIO_ZERO_COPY
- sg->iov_base = virtio_map_gpa(vring_desc_addr(vq, i), sg->iov_len);
-#else
- /* cap individual scatter element size to prevent unbounded allocations
- of memory from the guest. Practically speaking, no virtio driver
- will ever pass more than a page in each element. We set the cap to
- be 2MB in case for some reason a large page makes it way into the
- sg list. When we implement a zero copy API, this limitation will
- disappear */
- if (sg->iov_len > (2 << 20))
- sg->iov_len = 2 << 20;
-
- sg->iov_base = qemu_malloc(sg->iov_len);
- if (!(vring_desc_flags(vq, i) & VRING_DESC_F_WRITE)) {
- cpu_physical_memory_read(vring_desc_addr(vq, i),
- sg->iov_base,
- sg->iov_len);
- }
-#endif
- if (sg->iov_base == NULL) {
- fprintf(stderr, "Invalid mapping\n");
+ sg->iov_base = cpu_physical_memory_map(vring_desc_addr(vq, i), &len, is_write);
+
+ if (sg->iov_base == NULL || len != sg->iov_len) {
+ fprintf(stderr, "virtio: trying to map MMIO memory\n");
exit(1);
}
diff --git a/hxtool b/hxtool
new file mode 100644
index 000000000..8dbeb76f6
--- /dev/null
+++ b/hxtool
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+hxtoh()
+{
+ flag=1
+ while read str; do
+ case $str in
+ HXCOMM*)
+ ;;
+ STEXI*|ETEXI*) flag=$(($flag^1))
+ ;;
+ *)
+ test $flag -eq 1 && echo $str
+ ;;
+ esac
+ done
+}
+
+hxtotexi()
+{
+ flag=0
+ while read str; do
+ case "$str" in
+ HXCOMM*)
+ ;;
+ STEXI*|ETEXI*) flag=$(($flag^1))
+ ;;
+ DEFHEADING*)
+ echo $(expr "$str" : "DEFHEADING(\(.*\))")
+ ;;
+ *)
+ test $flag -eq 1 && echo $str
+ ;;
+ esac
+ done
+}
+
+case "$1" in
+"-h") hxtoh ;;
+"-t") hxtotexi ;;
+*) exit 1 ;;
+esac
+
+exit 0
diff --git a/monitor.c b/monitor.c
index 76d9f49ef..ab5de15a9 100644
--- a/monitor.c
+++ b/monitor.c
@@ -597,6 +597,8 @@ static void do_gdbserver(Monitor *mon, const char *port)
if (gdbserver_start(port) < 0) {
monitor_printf(mon, "Could not open gdbserver socket on port '%s'\n",
port);
+ } else if (strcmp(port, "none") == 0) {
+ monitor_printf(mon, "Disabled gdbserver\n");
} else {
monitor_printf(mon, "Waiting gdb connection on port '%s'\n", port);
}
diff --git a/net.c b/net.c
index efb64d38e..d753fa0a6 100644
--- a/net.c
+++ b/net.c
@@ -2005,11 +2005,6 @@ void net_host_device_remove(Monitor *mon, int vlan_id, const char *device)
VLANState *vlan;
VLANClientState *vc;
- if (!net_host_check_device(device)) {
- monitor_printf(mon, "invalid host network device %s\n", device);
- return;
- }
-
vlan = qemu_find_vlan(vlan_id);
if (!vlan) {
monitor_printf(mon, "can't find vlan %d\n", vlan_id);
diff --git a/posix-aio-compat.c b/posix-aio-compat.c
index 6b547f41f..65c80ecc3 100644
--- a/posix-aio-compat.c
+++ b/posix-aio-compat.c
@@ -11,6 +11,7 @@
*
*/
+#include <sys/ioctl.h>
#include <pthread.h>
#include <unistd.h>
#include <errno.h>
@@ -75,6 +76,47 @@ static void thread_create(pthread_t *thread, pthread_attr_t *attr,
if (ret) die2(ret, "pthread_create");
}
+static size_t handle_aiocb_readwrite(struct qemu_paiocb *aiocb)
+{
+ size_t offset = 0;
+ ssize_t len;
+
+ while (offset < aiocb->aio_nbytes) {
+ if (aiocb->aio_type == QEMU_PAIO_WRITE)
+ len = pwrite(aiocb->aio_fildes,
+ (const char *)aiocb->aio_buf + offset,
+ aiocb->aio_nbytes - offset,
+ aiocb->aio_offset + offset);
+ else
+ len = pread(aiocb->aio_fildes,
+ (char *)aiocb->aio_buf + offset,
+ aiocb->aio_nbytes - offset,
+ aiocb->aio_offset + offset);
+
+ if (len == -1 && errno == EINTR)
+ continue;
+ else if (len == -1) {
+ offset = -errno;
+ break;
+ } else if (len == 0)
+ break;
+
+ offset += len;
+ }
+
+ return offset;
+}
+
+static size_t handle_aiocb_ioctl(struct qemu_paiocb *aiocb)
+{
+ int ret;
+
+ ret = ioctl(aiocb->aio_fildes, aiocb->aio_ioctl_cmd, aiocb->aio_buf);
+ if (ret == -1)
+ return -errno;
+ return ret;
+}
+
static void *aio_thread(void *unused)
{
pid_t pid;
@@ -88,8 +130,7 @@ static void *aio_thread(void *unused)
while (1) {
struct qemu_paiocb *aiocb;
- size_t offset;
- int ret = 0;
+ size_t ret = 0;
qemu_timeval tv;
struct timespec ts;
@@ -109,40 +150,26 @@ static void *aio_thread(void *unused)
aiocb = TAILQ_FIRST(&request_list);
TAILQ_REMOVE(&request_list, aiocb, node);
-
- offset = 0;
aiocb->active = 1;
-
idle_threads--;
mutex_unlock(&lock);
- while (offset < aiocb->aio_nbytes) {
- ssize_t len;
-
- if (aiocb->is_write)
- len = pwrite(aiocb->aio_fildes,
- (const char *)aiocb->aio_buf + offset,
- aiocb->aio_nbytes - offset,
- aiocb->aio_offset + offset);
- else
- len = pread(aiocb->aio_fildes,
- (char *)aiocb->aio_buf + offset,
- aiocb->aio_nbytes - offset,
- aiocb->aio_offset + offset);
-
- if (len == -1 && errno == EINTR)
- continue;
- else if (len == -1) {
- offset = -errno;
- break;
- } else if (len == 0)
- break;
-
- offset += len;
- }
+ switch (aiocb->aio_type) {
+ case QEMU_PAIO_READ:
+ case QEMU_PAIO_WRITE:
+ ret = handle_aiocb_readwrite(aiocb);
+ break;
+ case QEMU_PAIO_IOCTL:
+ ret = handle_aiocb_ioctl(aiocb);
+ break;
+ default:
+ fprintf(stderr, "invalid aio request (0x%x)\n", aiocb->aio_type);
+ ret = -EINVAL;
+ break;
+ }
mutex_lock(&lock);
- aiocb->ret = offset;
+ aiocb->ret = ret;
idle_threads++;
mutex_unlock(&lock);
@@ -178,9 +205,9 @@ int qemu_paio_init(struct qemu_paioinit *aioinit)
return 0;
}
-static int qemu_paio_submit(struct qemu_paiocb *aiocb, int is_write)
+static int qemu_paio_submit(struct qemu_paiocb *aiocb, int type)
{
- aiocb->is_write = is_write;
+ aiocb->aio_type = type;
aiocb->ret = -EINPROGRESS;
aiocb->active = 0;
mutex_lock(&lock);
@@ -195,12 +222,17 @@ static int qemu_paio_submit(struct qemu_paiocb *aiocb, int is_write)
int qemu_paio_read(struct qemu_paiocb *aiocb)
{
- return qemu_paio_submit(aiocb, 0);
+ return qemu_paio_submit(aiocb, QEMU_PAIO_READ);
}
int qemu_paio_write(struct qemu_paiocb *aiocb)
{
- return qemu_paio_submit(aiocb, 1);
+ return qemu_paio_submit(aiocb, QEMU_PAIO_WRITE);
+}
+
+int qemu_paio_ioctl(struct qemu_paiocb *aiocb)
+{
+ return qemu_paio_submit(aiocb, QEMU_PAIO_IOCTL);
}
ssize_t qemu_paio_return(struct qemu_paiocb *aiocb)
diff --git a/posix-aio-compat.h b/posix-aio-compat.h
index 0bc10f5e0..a1cdfd7f1 100644
--- a/posix-aio-compat.h
+++ b/posix-aio-compat.h
@@ -29,12 +29,16 @@ struct qemu_paiocb
int aio_fildes;
void *aio_buf;
size_t aio_nbytes;
+#define aio_ioctl_cmd aio_nbytes /* for QEMU_PAIO_IOCTL */
int ev_signo;
off_t aio_offset;
/* private */
TAILQ_ENTRY(qemu_paiocb) node;
- int is_write;
+ int aio_type;
+#define QEMU_PAIO_READ 0x01
+#define QEMU_PAIO_WRITE 0x02
+#define QEMU_PAIO_IOCTL 0x03
ssize_t ret;
int active;
};
@@ -49,6 +53,7 @@ struct qemu_paioinit
int qemu_paio_init(struct qemu_paioinit *aioinit);
int qemu_paio_read(struct qemu_paiocb *aiocb);
int qemu_paio_write(struct qemu_paiocb *aiocb);
+int qemu_paio_ioctl(struct qemu_paiocb *aiocb);
int qemu_paio_error(struct qemu_paiocb *aiocb);
ssize_t qemu_paio_return(struct qemu_paiocb *aiocb);
int qemu_paio_cancel(int fd, struct qemu_paiocb *aiocb);
diff --git a/qemu-char.c b/qemu-char.c
index c92507b39..7a852b7ba 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -929,6 +929,8 @@ static void pty_chr_close(struct CharDriverState *chr)
qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL);
close(s->fd);
+ qemu_del_timer(s->timer);
+ qemu_free_timer(s->timer);
qemu_free(s);
}
@@ -1758,6 +1760,16 @@ static void udp_chr_update_read_handler(CharDriverState *chr)
}
}
+static void udp_chr_close(CharDriverState *chr)
+{
+ NetCharDriver *s = chr->opaque;
+ if (s->fd >= 0) {
+ qemu_set_fd_handler(s->fd, NULL, NULL, NULL);
+ closesocket(s->fd);
+ }
+ qemu_free(s);
+}
+
static CharDriverState *qemu_chr_open_udp(const char *def)
{
CharDriverState *chr = NULL;
@@ -1791,6 +1803,7 @@ static CharDriverState *qemu_chr_open_udp(const char *def)
chr->opaque = s;
chr->chr_write = udp_chr_write;
chr->chr_update_read_handler = udp_chr_update_read_handler;
+ chr->chr_close = udp_chr_close;
return chr;
return_err:
@@ -1993,10 +2006,14 @@ static void tcp_chr_accept(void *opaque)
static void tcp_chr_close(CharDriverState *chr)
{
TCPCharDriver *s = chr->opaque;
- if (s->fd >= 0)
+ if (s->fd >= 0) {
+ qemu_set_fd_handler(s->fd, NULL, NULL, NULL);
closesocket(s->fd);
- if (s->listen_fd >= 0)
+ }
+ if (s->listen_fd >= 0) {
+ qemu_set_fd_handler(s->listen_fd, NULL, NULL, NULL);
closesocket(s->listen_fd);
+ }
qemu_free(s);
}
diff --git a/qemu-common.h b/qemu-common.h
index ec7673daf..77d4dddcc 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -204,6 +204,7 @@ typedef struct QEMUIOVector {
} QEMUIOVector;
void qemu_iovec_init(QEMUIOVector *qiov, int alloc_hint);
+void qemu_iovec_init_external(QEMUIOVector *qiov, struct iovec *iov, int niov);
void qemu_iovec_add(QEMUIOVector *qiov, void *base, size_t len);
void qemu_iovec_destroy(QEMUIOVector *qiov);
void qemu_iovec_reset(QEMUIOVector *qiov);
diff --git a/qemu-doc.texi b/qemu-doc.texi
index c7fb50c5a..61a08eeae 100644
--- a/qemu-doc.texi
+++ b/qemu-doc.texi
@@ -224,988 +224,7 @@ usage: qemu [options] [@var{disk_image}]
@var{disk_image} is a raw hard disk image for IDE hard disk 0. Some
targets do not need a disk image.
-General options:
-@table @option
-@item -h
-Display help and exit
-
-@item -M @var{machine}
-Select the emulated @var{machine} (@code{-M ?} for list)
-
-@item -cpu @var{model}
-Select CPU model (-cpu ? for list and additional feature selection)
-
-@item -smp @var{n}
-Simulate an SMP system with @var{n} CPUs. On the PC target, up to 255
-CPUs are supported. On Sparc32 target, Linux limits the number of usable CPUs
-to 4.
-
-@item -fda @var{file}
-@item -fdb @var{file}
-Use @var{file} as floppy disk 0/1 image (@pxref{disk_images}). You can
-use the host floppy by using @file{/dev/fd0} as filename (@pxref{host_drives}).
-
-@item -hda @var{file}
-@item -hdb @var{file}
-@item -hdc @var{file}
-@item -hdd @var{file}
-Use @var{file} as hard disk 0, 1, 2 or 3 image (@pxref{disk_images}).
-
-@item -cdrom @var{file}
-Use @var{file} as CD-ROM image (you cannot use @option{-hdc} and
-@option{-cdrom} at the same time). You can use the host CD-ROM by
-using @file{/dev/cdrom} as filename (@pxref{host_drives}).
-
-@item -drive @var{option}[,@var{option}[,@var{option}[,...]]]
-
-Define a new drive. Valid options are:
-
-@table @code
-@item file=@var{file}
-This option defines which disk image (@pxref{disk_images}) to use with
-this drive. If the filename contains comma, you must double it
-(for instance, "file=my,,file" to use file "my,file").
-@item if=@var{interface}
-This option defines on which type on interface the drive is connected.
-Available types are: ide, scsi, sd, mtd, floppy, pflash, virtio.
-@item bus=@var{bus},unit=@var{unit}
-These options define where is connected the drive by defining the bus number and
-the unit id.
-@item index=@var{index}
-This option defines where is connected the drive by using an index in the list
-of available connectors of a given interface type.
-@item media=@var{media}
-This option defines the type of the media: disk or cdrom.
-@item cyls=@var{c},heads=@var{h},secs=@var{s}[,trans=@var{t}]
-These options have the same definition as they have in @option{-hdachs}.
-@item snapshot=@var{snapshot}
-@var{snapshot} is "on" or "off" and allows to enable snapshot for given drive (see @option{-snapshot}).
-@item cache=@var{cache}
-@var{cache} is "none", "writeback", or "writethrough" and controls how the host cache is used to access block data.
-@item format=@var{format}
-Specify which disk @var{format} will be used rather than detecting
-the format. Can be used to specifiy format=raw to avoid interpreting
-an untrusted format header.
-@item serial=@var{serial}
-This option specifies the serial number to assign to the device.
-@item boot=@var{boot}
-@var{boot} if "on" enables extboot for a given drive so it can be used as a boot drive.
-@end table
-
-By default, writethrough caching is used for all block device. This means that
-the host page cache will be used to read and write data but write notification
-will be sent to the guest only when the data has been reported as written by
-the storage subsystem.
-
-Writeback caching will report data writes as completed as soon as the data is
-present in the host page cache. This is safe as long as you trust your host.
-If your host crashes or loses power, then the guest may experience data
-corruption. When using the @option{-snapshot} option, writeback caching is
-used by default.
-
-The host page can be avoided entirely with @option{cache=none}. This will
-attempt to do disk IO directly to the guests memory. QEMU may still perform
-an internal copy of the data.
-
-Some block drivers perform badly with @option{cache=writethrough}, most notably,
-qcow2. If performance is more important than correctness,
-@option{cache=writeback} should be used with qcow2. By default, if no explicit
-caching is specified for a qcow2 disk image, @option{cache=writeback} will be
-used. For all other disk types, @option{cache=writethrough} is the default.
-
-Instead of @option{-cdrom} you can use:
-@example
-qemu -drive file=file,index=2,media=cdrom
-@end example
-
-Instead of @option{-hda}, @option{-hdb}, @option{-hdc}, @option{-hdd}, you can
-use:
-@example
-qemu -drive file=file,index=0,media=disk
-qemu -drive file=file,index=1,media=disk
-qemu -drive file=file,index=2,media=disk
-qemu -drive file=file,index=3,media=disk
-@end example
-
-You can connect a CDROM to the slave of ide0:
-@example
-qemu -drive file=file,if=ide,index=1,media=cdrom
-@end example
-
-If you don't specify the "file=" argument, you define an empty drive:
-@example
-qemu -drive if=ide,index=1,media=cdrom
-@end example
-
-You can connect a SCSI disk with unit ID 6 on the bus #0:
-@example
-qemu -drive file=file,if=scsi,bus=0,unit=6
-@end example
-
-To boot from a SCSI disk, one would use:
-
-@example
-qemu -drive file=file,if=scsi,boot=on
-@end example
-
-Instead of @option{-fda}, @option{-fdb}, you can use:
-@example
-qemu -drive file=file,index=0,if=floppy
-qemu -drive file=file,index=1,if=floppy
-@end example
-
-By default, @var{interface} is "ide" and @var{index} is automatically
-incremented:
-@example
-qemu -drive file=a -drive file=b"
-@end example
-is interpreted like:
-@example
-qemu -hda a -hdb b
-@end example
-
-@item -mtdblock file
-Use 'file' as on-board Flash memory image.
-
-@item -sd file
-Use 'file' as SecureDigital card image.
-
-@item -pflash file
-Use 'file' as a parallel flash image.
-
-@item -boot [a|c|d|n]
-Boot on floppy (a), hard disk (c), CD-ROM (d), or Etherboot (n). Hard disk boot
-is the default.
-
-@item -snapshot
-Write to temporary files instead of disk image files. In this case,
-the raw disk image you use is not written back. You can however force
-the write back by pressing @key{C-a s} (@pxref{disk_images}).
-
-@item -m @var{megs}
-Set virtual RAM size to @var{megs} megabytes. Default is 128 MiB. Optionally,
-a suffix of ``M'' or ``G'' can be used to signify a value in megabytes or
-gigabytes respectively.
-
-@item -k @var{language}
-
-Use keyboard layout @var{language} (for example @code{fr} for
-French). This option is only needed where it is not easy to get raw PC
-keycodes (e.g. on Macs, with some X11 servers or with a VNC
-display). You don't normally need to use it on PC/Linux or PC/Windows
-hosts.
-
-The available layouts are:
-@example
-ar de-ch es fo fr-ca hu ja mk no pt-br sv
-da en-gb et fr fr-ch is lt nl pl ru th
-de en-us fi fr-be hr it lv nl-be pt sl tr
-@end example
-
-The default is @code{en-us}.
-
-@item -audio-help
-
-Will show the audio subsystem help: list of drivers, tunable
-parameters.
-
-@item -soundhw @var{card1}[,@var{card2},...] or -soundhw all
-
-Enable audio and selected sound hardware. Use ? to print all
-available sound hardware.
-
-@example
-qemu -soundhw sb16,adlib disk.img
-qemu -soundhw es1370 disk.img
-qemu -soundhw ac97 disk.img
-qemu -soundhw all disk.img
-qemu -soundhw ?
-@end example
-
-Note that Linux's i810_audio OSS kernel (for AC97) module might
-require manually specifying clocking.
-
-@example
-modprobe i810_audio clocking=48000
-@end example
-
-@end table
-
-USB options:
-@table @option
-
-@item -usb
-Enable the USB driver (will be the default soon)
-
-@item -usbdevice @var{devname}
-Add the USB device @var{devname}. @xref{usb_devices}.
-
-@table @code
-
-@item mouse
-Virtual Mouse. This will override the PS/2 mouse emulation when activated.
-
-@item tablet
-Pointer device that uses absolute coordinates (like a touchscreen). This
-means qemu is able to report the mouse position without having to grab the
-mouse. Also overrides the PS/2 mouse emulation when activated.
-
-@item disk:[format=@var{format}]:file
-Mass storage device based on file. The optional @var{format} argument
-will be used rather than detecting the format. Can be used to specifiy
-format=raw to avoid interpreting an untrusted format header.
-
-@item host:bus.addr
-Pass through the host device identified by bus.addr (Linux only).
-
-@item host:vendor_id:product_id
-Pass through the host device identified by vendor_id:product_id (Linux only).
-
-@item serial:[vendorid=@var{vendor_id}][,productid=@var{product_id}]:@var{dev}
-Serial converter to host character device @var{dev}, see @code{-serial} for the
-available devices.
-
-@item braille
-Braille device. This will use BrlAPI to display the braille output on a real
-or fake device.
-
-@item net:options
-Network adapter that supports CDC ethernet and RNDIS protocols.
-
-@end table
-
-@item -name @var{name}
-Sets the @var{name} of the guest.
-This name will be displayed in the SDL window caption.
-The @var{name} will also be used for the VNC server.
-
-@item -uuid @var{uuid}
-Set system UUID.
-
-@end table
-
-Display options:
-@table @option
-
-@item -nographic
-
-Normally, QEMU uses SDL to display the VGA output. With this option,
-you can totally disable graphical output so that QEMU is a simple
-command line application. The emulated serial port is redirected on
-the console. Therefore, you can still use QEMU to debug a Linux kernel
-with a serial console.
-
-@item -curses
-
-Normally, QEMU uses SDL to display the VGA output. With this option,
-QEMU can display the VGA output when in text mode using a
-curses/ncurses interface. Nothing is displayed in graphical mode.
-
-@item -no-frame
-
-Do not use decorations for SDL windows and start them using the whole
-available screen space. This makes the using QEMU in a dedicated desktop
-workspace more convenient.
-
-@item -alt-grab
-
-Use Ctrl-Alt-Shift to grab mouse (instead of Ctrl-Alt).
-
-@item -no-quit
-
-Disable SDL window close capability.
-
-@item -sdl
-
-Enable SDL.
-
-@item -portrait
-
-Rotate graphical output 90 deg left (only PXA LCD).
-
-@item -vga @var{type}
-Select type of VGA card to emulate. Valid values for @var{type} are
-@table @code
-@item cirrus
-Cirrus Logic GD5446 Video card. All Windows versions starting from
-Windows 95 should recognize and use this graphic card. For optimal
-performances, use 16 bit color depth in the guest and the host OS.
-(This one is the default)
-@item std
-Standard VGA card with Bochs VBE extensions. If your guest OS
-supports the VESA 2.0 VBE extensions (e.g. Windows XP) and if you want
-to use high resolution modes (>= 1280x1024x16) then you should use
-this option.
-@item vmware
-VMWare SVGA-II compatible adapter. Use it if you have sufficiently
-recent XFree86/XOrg server or Windows guest with a driver for this
-card.
-@item none
-Disable VGA card.
-@end table
-
-@item -full-screen
-Start in full screen.
-
-@item -vnc @var{display}[,@var{option}[,@var{option}[,...]]]
-
-Normally, QEMU uses SDL to display the VGA output. With this option,
-you can have QEMU listen on VNC display @var{display} and redirect the VGA
-display over the VNC session. It is very useful to enable the usb
-tablet device when using this option (option @option{-usbdevice
-tablet}). When using the VNC display, you must use the @option{-k}
-parameter to set the keyboard layout if you are not using en-us. Valid
-syntax for the @var{display} is
-
-@table @code
-
-@item @var{host}:@var{d}
-
-TCP connections will only be allowed from @var{host} on display @var{d}.
-By convention the TCP port is 5900+@var{d}. Optionally, @var{host} can
-be omitted in which case the server will accept connections from any host.
-
-@item @code{unix}:@var{path}
-
-Connections will be allowed over UNIX domain sockets where @var{path} is the
-location of a unix socket to listen for connections on.
-
-@item none
-
-VNC is initialized but not started. The monitor @code{change} command
-can be used to later start the VNC server.
-
-@end table
-
-Following the @var{display} value there may be one or more @var{option} flags
-separated by commas. Valid options are
-
-@table @code
-
-@item reverse
-
-Connect to a listening VNC client via a ``reverse'' connection. The
-client is specified by the @var{display}. For reverse network
-connections (@var{host}:@var{d},@code{reverse}), the @var{d} argument
-is a TCP port number, not a display number.
-
-@item password
-
-Require that password based authentication is used for client connections.
-The password must be set separately using the @code{change} command in the
-@ref{pcsys_monitor}
-
-@item tls
-
-Require that client use TLS when communicating with the VNC server. This
-uses anonymous TLS credentials so is susceptible to a man-in-the-middle
-attack. It is recommended that this option be combined with either the
-@var{x509} or @var{x509verify} options.
-
-@item x509=@var{/path/to/certificate/dir}
-
-Valid if @option{tls} is specified. Require that x509 credentials are used
-for negotiating the TLS session. The server will send its x509 certificate
-to the client. It is recommended that a password be set on the VNC server
-to provide authentication of the client when this is used. The path following
-this option specifies where the x509 certificates are to be loaded from.
-See the @ref{vnc_security} section for details on generating certificates.
-
-@item x509verify=@var{/path/to/certificate/dir}
-
-Valid if @option{tls} is specified. Require that x509 credentials are used
-for negotiating the TLS session. The server will send its x509 certificate
-to the client, and request that the client send its own x509 certificate.
-The server will validate the client's certificate against the CA certificate,
-and reject clients when validation fails. If the certificate authority is
-trusted, this is a sufficient authentication mechanism. You may still wish
-to set a password on the VNC server as a second authentication layer. The
-path following this option specifies where the x509 certificates are to
-be loaded from. See the @ref{vnc_security} section for details on generating
-certificates.
-
-@item sasl
-
-Require that the client use SASL to authenticate with the VNC server.
-The exact choice of authentication method used is controlled from the
-system / user's SASL configuration file for the 'qemu' service. This
-is typically found in /etc/sasl2/qemu.conf. If running QEMU as an
-unprivileged user, an environment variable SASL_CONF_PATH can be used
-to make it search alternate locations for the service config.
-While some SASL auth methods can also provide data encryption (eg GSSAPI),
-it is recommended that SASL always be combined with the 'tls' and
-'x509' settings to enable use of SSL and server certificates. This
-ensures a data encryption preventing compromise of authentication
-credentials. See the @ref{vnc_security} section for details on using
-SASL authentication.
-
-@item acl
-
-Turn on access control lists for checking of the x509 client certificate
-and SASL party. For x509 certs, the ACL check is made against the
-certificate's distinguished name. This is something that looks like
-@code{C=GB,O=ACME,L=Boston,CN=bob}. For SASL party, the ACL check is
-made against the username, which depending on the SASL plugin, may
-include a realm component, eg @code{bob} or @code{bob@@EXAMPLE.COM}.
-When the @option{acl} flag is set, the initial access list will be
-empty, with a @code{deny} policy. Thus no one will be allowed to
-use the VNC server until the ACLs have been loaded. This can be
-achieved using the @code{acl} monitor command.
-
-@end table
-
-@end table
-
-Network options:
-
-@table @option
-
-@item -net nic[,vlan=@var{n}][,macaddr=@var{addr}][,model=@var{type}][,name=@var{name}]
-Create a new Network Interface Card and connect it to VLAN @var{n} (@var{n}
-= 0 is the default). The NIC is an rtl8139 by default on the PC
-target. Optionally, the MAC address can be changed to @var{addr}
-and a @var{name} can be assigned for use in monitor commands. If no
-@option{-net} option is specified, a single NIC is created.
-Qemu can emulate several different models of network card.
-Valid values for @var{type} are
-@code{i82551}, @code{i82557b}, @code{i82559er},
-@code{ne2k_pci}, @code{ne2k_isa}, @code{pcnet}, @code{rtl8139},
-@code{e1000}, @code{smc91c111}, @code{lance} and @code{mcf_fec}.
-Not all devices are supported on all targets. Use -net nic,model=?
-for a list of available devices for your target.
-
-@item -net user[,vlan=@var{n}][,hostname=@var{name}][,name=@var{name}]
-Use the user mode network stack which requires no administrator
-privilege to run. @option{hostname=name} can be used to specify the client
-hostname reported by the builtin DHCP server.
-
-@item -net channel,@var{port}:@var{dev}
-Forward @option{user} TCP connection to port @var{port} to character device @var{dev}
-
-@item -net tap[,vlan=@var{n}][,name=@var{name}][,fd=@var{h}][,ifname=@var{name}][,script=@var{file}][,downscript=@var{dfile}]
-Connect the host TAP network interface @var{name} to VLAN @var{n}, use
-the network script @var{file} to configure it and the network script
-@var{dfile} to deconfigure it. If @var{name} is not provided, the OS
-automatically provides one. @option{fd}=@var{h} can be used to specify
-the handle of an already opened host TAP interface. The default network
-configure script is @file{/etc/qemu-ifup} and the default network
-deconfigure script is @file{/etc/qemu-ifdown}. Use @option{script=no}
-or @option{downscript=no} to disable script execution. Example:
-
-@example
-qemu linux.img -net nic -net tap
-@end example
-
-More complicated example (two NICs, each one connected to a TAP device)
-@example
-qemu linux.img -net nic,vlan=0 -net tap,vlan=0,ifname=tap0 \
- -net nic,vlan=1 -net tap,vlan=1,ifname=tap1
-@end example
-
-
-@item -net socket[,vlan=@var{n}][,name=@var{name}][,fd=@var{h}][,listen=[@var{host}]:@var{port}][,connect=@var{host}:@var{port}]
-
-Connect the VLAN @var{n} to a remote VLAN in another QEMU virtual
-machine using a TCP socket connection. If @option{listen} is
-specified, QEMU waits for incoming connections on @var{port}
-(@var{host} is optional). @option{connect} is used to connect to
-another QEMU instance using the @option{listen} option. @option{fd}=@var{h}
-specifies an already opened TCP socket.
-
-Example:
-@example
-# launch a first QEMU instance
-qemu linux.img -net nic,macaddr=52:54:00:12:34:56 \
- -net socket,listen=:1234
-# connect the VLAN 0 of this instance to the VLAN 0
-# of the first instance
-qemu linux.img -net nic,macaddr=52:54:00:12:34:57 \
- -net socket,connect=127.0.0.1:1234
-@end example
-
-@item -net socket[,vlan=@var{n}][,name=@var{name}][,fd=@var{h}][,mcast=@var{maddr}:@var{port}]
-
-Create a VLAN @var{n} shared with another QEMU virtual
-machines using a UDP multicast socket, effectively making a bus for
-every QEMU with same multicast address @var{maddr} and @var{port}.
-NOTES:
-@enumerate
-@item
-Several QEMU can be running on different hosts and share same bus (assuming
-correct multicast setup for these hosts).
-@item
-mcast support is compatible with User Mode Linux (argument @option{eth@var{N}=mcast}), see
-@url{http://user-mode-linux.sf.net}.
-@item
-Use @option{fd=h} to specify an already opened UDP multicast socket.
-@end enumerate
-
-Example:
-@example
-# launch one QEMU instance
-qemu linux.img -net nic,macaddr=52:54:00:12:34:56 \
- -net socket,mcast=230.0.0.1:1234
-# launch another QEMU instance on same "bus"
-qemu linux.img -net nic,macaddr=52:54:00:12:34:57 \
- -net socket,mcast=230.0.0.1:1234
-# launch yet another QEMU instance on same "bus"
-qemu linux.img -net nic,macaddr=52:54:00:12:34:58 \
- -net socket,mcast=230.0.0.1:1234
-@end example
-
-Example (User Mode Linux compat.):
-@example
-# launch QEMU instance (note mcast address selected
-# is UML's default)
-qemu linux.img -net nic,macaddr=52:54:00:12:34:56 \
- -net socket,mcast=239.192.168.1:1102
-# launch UML
-/path/to/linux ubd0=/path/to/root_fs eth0=mcast
-@end example
-
-@item -net vde[,vlan=@var{n}][,name=@var{name}][,sock=@var{socketpath}][,port=@var{n}][,group=@var{groupname}][,mode=@var{octalmode}]
-Connect VLAN @var{n} to PORT @var{n} of a vde switch running on host and
-listening for incoming connections on @var{socketpath}. Use GROUP @var{groupname}
-and MODE @var{octalmode} to change default ownership and permissions for
-communication port. This option is available only if QEMU has been compiled
-with vde support enabled.
-
-Example:
-@example
-# launch vde switch
-vde_switch -F -sock /tmp/myswitch
-# launch QEMU instance
-qemu linux.img -net nic -net vde,sock=/tmp/myswitch
-@end example
-
-@item -net none
-Indicate that no network devices should be configured. It is used to
-override the default configuration (@option{-net nic -net user}) which
-is activated if no @option{-net} options are provided.
-
-@item -tftp @var{dir}
-When using the user mode network stack, activate a built-in TFTP
-server. The files in @var{dir} will be exposed as the root of a TFTP server.
-The TFTP client on the guest must be configured in binary mode (use the command
-@code{bin} of the Unix TFTP client). The host IP address on the guest is as
-usual 10.0.2.2.
-
-@item -bootp @var{file}
-When using the user mode network stack, broadcast @var{file} as the BOOTP
-filename. In conjunction with @option{-tftp}, this can be used to network boot
-a guest from a local directory.
-
-Example (using pxelinux):
-@example
-qemu -hda linux.img -boot n -tftp /path/to/tftp/files -bootp /pxelinux.0
-@end example
-
-@item -smb @var{dir}
-When using the user mode network stack, activate a built-in SMB
-server so that Windows OSes can access to the host files in @file{@var{dir}}
-transparently.
-
-In the guest Windows OS, the line:
-@example
-10.0.2.4 smbserver
-@end example
-must be added in the file @file{C:\WINDOWS\LMHOSTS} (for windows 9x/Me)
-or @file{C:\WINNT\SYSTEM32\DRIVERS\ETC\LMHOSTS} (Windows NT/2000).
-
-Then @file{@var{dir}} can be accessed in @file{\\smbserver\qemu}.
-
-Note that a SAMBA server must be installed on the host OS in
-@file{/usr/sbin/smbd}. QEMU was tested successfully with smbd version
-2.2.7a from the Red Hat 9 and version 3.0.10-1.fc3 from Fedora Core 3.
-
-@item -redir [tcp|udp]:@var{host-port}:[@var{guest-host}]:@var{guest-port}
-
-When using the user mode network stack, redirect incoming TCP or UDP
-connections to the host port @var{host-port} to the guest
-@var{guest-host} on guest port @var{guest-port}. If @var{guest-host}
-is not specified, its value is 10.0.2.15 (default address given by the
-built-in DHCP server).
-
-For example, to redirect host X11 connection from screen 1 to guest
-screen 0, use the following:
-
-@example
-# on the host
-qemu -redir tcp:6001::6000 [...]
-# this host xterm should open in the guest X11 server
-xterm -display :1
-@end example
-
-To redirect telnet connections from host port 5555 to telnet port on
-the guest, use the following:
-
-@example
-# on the host
-qemu -redir tcp:5555::23 [...]
-telnet localhost 5555
-@end example
-
-Then when you use on the host @code{telnet localhost 5555}, you
-connect to the guest telnet server.
-
-@end table
-
-Bluetooth(R) options:
-@table @option
-
-@item -bt hci[...]
-Defines the function of the corresponding Bluetooth HCI. -bt options
-are matched with the HCIs present in the chosen machine type. For
-example when emulating a machine with only one HCI built into it, only
-the first @code{-bt hci[...]} option is valid and defines the HCI's
-logic. The Transport Layer is decided by the machine type. Currently
-the machines @code{n800} and @code{n810} have one HCI and all other
-machines have none.
-
-@anchor{bt-hcis}
-The following three types are recognized:
-
-@table @code
-@item -bt hci,null
-(default) The corresponding Bluetooth HCI assumes no internal logic
-and will not respond to any HCI commands or emit events.
-
-@item -bt hci,host[:@var{id}]
-(@code{bluez} only) The corresponding HCI passes commands / events
-to / from the physical HCI identified by the name @var{id} (default:
-@code{hci0}) on the computer running QEMU. Only available on @code{bluez}
-capable systems like Linux.
-
-@item -bt hci[,vlan=@var{n}]
-Add a virtual, standard HCI that will participate in the Bluetooth
-scatternet @var{n} (default @code{0}). Similarly to @option{-net}
-VLANs, devices inside a bluetooth network @var{n} can only communicate
-with other devices in the same network (scatternet).
-@end table
-
-@item -bt vhci[,vlan=@var{n}]
-(Linux-host only) Create a HCI in scatternet @var{n} (default 0) attached
-to the host bluetooth stack instead of to the emulated target. This
-allows the host and target machines to participate in a common scatternet
-and communicate. Requires the Linux @code{vhci} driver installed. Can
-be used as following:
-
-@example
-qemu [...OPTIONS...] -bt hci,vlan=5 -bt vhci,vlan=5
-@end example
-
-@item -bt device:@var{dev}[,vlan=@var{n}]
-Emulate a bluetooth device @var{dev} and place it in network @var{n}
-(default @code{0}). QEMU can only emulate one type of bluetooth devices
-currently:
-
-@table @code
-@item keyboard
-Virtual wireless keyboard implementing the HIDP bluetooth profile.
-@end table
-
-@end table
-
-i386 target only:
-
-@table @option
-
-@item -win2k-hack
-Use it when installing Windows 2000 to avoid a disk full bug. After
-Windows 2000 is installed, you no longer need this option (this option
-slows down the IDE transfers).
-
-@item -rtc-td-hack
-Use it if you experience time drift problem in Windows with ACPI HAL.
-This option will try to figure out how many timer interrupts were not
-processed by the Windows guest and will re-inject them.
-
-@item -no-fd-bootchk
-Disable boot signature checking for floppy disks in Bochs BIOS. It may
-be needed to boot from old floppy disks.
-
-@item -no-acpi
-Disable ACPI (Advanced Configuration and Power Interface) support. Use
-it if your guest OS complains about ACPI problems (PC target machine
-only).
-
-@item -no-hpet
-Disable HPET support.
-
-@item -acpitable [sig=@var{str}][,rev=@var{n}][,oem_id=@var{str}][,oem_table_id=@var{str}][,oem_rev=@var{n}] [,asl_compiler_id=@var{str}][,asl_compiler_rev=@var{n}][,data=@var{file1}[:@var{file2}]...]
-Add ACPI table with specified header fields and context from specified files.
-
-@end table
-
-Linux boot specific: When using these options, you can use a given
-Linux kernel without installing it in the disk image. It can be useful
-for easier testing of various kernels.
-
-@table @option
-
-@item -kernel @var{bzImage}
-Use @var{bzImage} as kernel image.
-
-@item -append @var{cmdline}
-Use @var{cmdline} as kernel command line
-
-@item -initrd @var{file}
-Use @var{file} as initial ram disk.
-
-@end table
-
-Debug/Expert options:
-@table @option
-
-@item -serial @var{dev}
-Redirect the virtual serial port to host character device
-@var{dev}. The default device is @code{vc} in graphical mode and
-@code{stdio} in non graphical mode.
-
-This option can be used several times to simulate up to 4 serial
-ports.
-
-Use @code{-serial none} to disable all serial ports.
-
-Available character devices are:
-@table @code
-@item vc[:WxH]
-Virtual console. Optionally, a width and height can be given in pixel with
-@example
-vc:800x600
-@end example
-It is also possible to specify width or height in characters:
-@example
-vc:80Cx24C
-@end example
-@item pty
-[Linux only] Pseudo TTY (a new PTY is automatically allocated)
-@item none
-No device is allocated.
-@item null
-void device
-@item /dev/XXX
-[Linux only] Use host tty, e.g. @file{/dev/ttyS0}. The host serial port
-parameters are set according to the emulated ones.
-@item /dev/parport@var{N}
-[Linux only, parallel port only] Use host parallel port
-@var{N}. Currently SPP and EPP parallel port features can be used.
-@item file:@var{filename}
-Write output to @var{filename}. No character can be read.
-@item stdio
-[Unix only] standard input/output
-@item pipe:@var{filename}
-name pipe @var{filename}
-@item COM@var{n}
-[Windows only] Use host serial port @var{n}
-@item udp:[@var{remote_host}]:@var{remote_port}[@@[@var{src_ip}]:@var{src_port}]
-This implements UDP Net Console.
-When @var{remote_host} or @var{src_ip} are not specified
-they default to @code{0.0.0.0}.
-When not using a specified @var{src_port} a random port is automatically chosen.
-@item msmouse
-Three button serial mouse. Configure the guest to use Microsoft protocol.
-
-If you just want a simple readonly console you can use @code{netcat} or
-@code{nc}, by starting qemu with: @code{-serial udp::4555} and nc as:
-@code{nc -u -l -p 4555}. Any time qemu writes something to that port it
-will appear in the netconsole session.
-
-If you plan to send characters back via netconsole or you want to stop
-and start qemu a lot of times, you should have qemu use the same
-source port each time by using something like @code{-serial
-udp::4555@@:4556} to qemu. Another approach is to use a patched
-version of netcat which can listen to a TCP port and send and receive
-characters via udp. If you have a patched version of netcat which
-activates telnet remote echo and single char transfer, then you can
-use the following options to step up a netcat redirector to allow
-telnet on port 5555 to access the qemu port.
-@table @code
-@item Qemu Options:
--serial udp::4555@@:4556
-@item netcat options:
--u -P 4555 -L 0.0.0.0:4556 -t -p 5555 -I -T
-@item telnet options:
-localhost 5555
-@end table
-
-
-@item tcp:[@var{host}]:@var{port}[,@var{server}][,nowait][,nodelay]
-The TCP Net Console has two modes of operation. It can send the serial
-I/O to a location or wait for a connection from a location. By default
-the TCP Net Console is sent to @var{host} at the @var{port}. If you use
-the @var{server} option QEMU will wait for a client socket application
-to connect to the port before continuing, unless the @code{nowait}
-option was specified. The @code{nodelay} option disables the Nagle buffering
-algorithm. If @var{host} is omitted, 0.0.0.0 is assumed. Only
-one TCP connection at a time is accepted. You can use @code{telnet} to
-connect to the corresponding character device.
-@table @code
-@item Example to send tcp console to 192.168.0.2 port 4444
--serial tcp:192.168.0.2:4444
-@item Example to listen and wait on port 4444 for connection
--serial tcp::4444,server
-@item Example to not wait and listen on ip 192.168.0.100 port 4444
--serial tcp:192.168.0.100:4444,server,nowait
-@end table
-
-@item telnet:@var{host}:@var{port}[,server][,nowait][,nodelay]
-The telnet protocol is used instead of raw tcp sockets. The options
-work the same as if you had specified @code{-serial tcp}. The
-difference is that the port acts like a telnet server or client using
-telnet option negotiation. This will also allow you to send the
-MAGIC_SYSRQ sequence if you use a telnet that supports sending the break
-sequence. Typically in unix telnet you do it with Control-] and then
-type "send break" followed by pressing the enter key.
-
-@item unix:@var{path}[,server][,nowait]
-A unix domain socket is used instead of a tcp socket. The option works the
-same as if you had specified @code{-serial tcp} except the unix domain socket
-@var{path} is used for connections.
-
-@item mon:@var{dev_string}
-This is a special option to allow the monitor to be multiplexed onto
-another serial port. The monitor is accessed with key sequence of
-@key{Control-a} and then pressing @key{c}. See monitor access
-@ref{pcsys_keys} in the -nographic section for more keys.
-@var{dev_string} should be any one of the serial devices specified
-above. An example to multiplex the monitor onto a telnet server
-listening on port 4444 would be:
-@table @code
-@item -serial mon:telnet::4444,server,nowait
-@end table
-
-@item braille
-Braille device. This will use BrlAPI to display the braille output on a real
-or fake device.
-
-@end table
-
-@item -parallel @var{dev}
-Redirect the virtual parallel port to host device @var{dev} (same
-devices as the serial port). On Linux hosts, @file{/dev/parportN} can
-be used to use hardware devices connected on the corresponding host
-parallel port.
-
-This option can be used several times to simulate up to 3 parallel
-ports.
-
-Use @code{-parallel none} to disable all parallel ports.
-
-@item -monitor @var{dev}
-Redirect the monitor to host device @var{dev} (same devices as the
-serial port).
-The default device is @code{vc} in graphical mode and @code{stdio} in
-non graphical mode.
-
-@item -pidfile @var{file}
-Store the QEMU process PID in @var{file}. It is useful if you launch QEMU
-from a script.
-
-@item -S
-Do not start CPU at startup (you must type 'c' in the monitor).
-
-@item -s
-Wait gdb connection to port 1234 (@pxref{gdb_usage}).
-
-@item -p @var{port}
-Change gdb connection port. @var{port} can be either a decimal number
-to specify a TCP port, or a host device (same devices as the serial port).
-
-@item -d
-Output log in /tmp/qemu.log
-@item -hdachs @var{c},@var{h},@var{s},[,@var{t}]
-Force hard disk 0 physical geometry (1 <= @var{c} <= 16383, 1 <=
-@var{h} <= 16, 1 <= @var{s} <= 63) and optionally force the BIOS
-translation mode (@var{t}=none, lba or auto). Usually QEMU can guess
-all those parameters. This option is useful for old MS-DOS disk
-images.
-
-@item -L @var{path}
-Set the directory for the BIOS, VGA BIOS and keymaps.
-
-@item -bios @var{file}
-Set the filename for the BIOS.
-
-@item -kernel-kqemu
-Enable KQEMU full virtualization (default is user mode only).
-
-@item -no-kqemu
-Disable KQEMU kernel module usage. KQEMU options are only available if
-KQEMU support is enabled when compiling.
-
-@item -enable-kvm
-Enable KVM full virtualization support. This option is only available
-if KVM support is enabled when compiling.
-
-@item -no-reboot
-Exit instead of rebooting.
-
-@item -no-shutdown
-Don't exit QEMU on guest shutdown, but instead only stop the emulation.
-This allows for instance switching to monitor to commit changes to the
-disk image.
-
-@item -loadvm @var{file}
-Start right away with a saved state (@code{loadvm} in monitor)
-
-@item -daemonize
-Daemonize the QEMU process after initialization. QEMU will not detach from
-standard IO until it is ready to receive connections on any of its devices.
-This option is a useful way for external programs to launch QEMU without having
-to cope with initialization race conditions.
-
-@item -option-rom @var{file}
-Load the contents of @var{file} as an option ROM.
-This option is useful to load things like EtherBoot.
-
-@item -clock @var{method}
-Force the use of the given methods for timer alarm. To see what timers
-are available use -clock ?.
-
-@item -localtime
-Set the real time clock to local time (the default is to UTC
-time). This option is needed to have correct date in MS-DOS or
-Windows.
-
-@item -startdate @var{date}
-Set the initial date of the real time clock. Valid formats for
-@var{date} are: @code{now} or @code{2006-06-17T16:01:21} or
-@code{2006-06-17}. The default value is @code{now}.
-
-@item -icount [N|auto]
-Enable virtual instruction counter. The virtual cpu will execute one
-instruction every 2^N ns of virtual time. If @code{auto} is specified
-then the virtual cpu speed will be automatically adjusted to keep virtual
-time within a few seconds of real time.
-
-Note that while this option can give deterministic behavior, it does not
-provide cycle accurate emulation. Modern CPUs contain superscalar out of
-order cores with complex cache hierarchies. The number of instructions
-executed often has little or no correlation with actual performance.
-
-@item -echr numeric_ascii_value
-Change the escape character used for switching to the monitor when using
-monitor and serial sharing. The default is @code{0x01} when using the
-@code{-nographic} option. @code{0x01} is equal to pressing
-@code{Control-a}. You can select a different character from the ascii
-control keys where 1 through 26 map to Control-a through Control-z. For
-instance you could use the either of the following to change the escape
-character to Control-t.
-@table @code
-@item -echr 0x14
-@item -echr 20
-@end table
-
-@item -chroot dir
-Immediately before starting guest execution, chroot to the specified
-directory. Especially useful in combination with -runas.
-
-@item -runas user
-Immediately before starting guest execution, drop root privileges, switching
-to the specified user.
-
-@end table
+@include qemu-options.texi
@c man end
diff --git a/qemu-img.c b/qemu-img.c
index 66ec91cc1..ab380c8a4 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -25,6 +25,7 @@
#include "osdep.h"
#include "block_int.h"
#include <assert.h>
+#include <stdio.h>
#ifdef _WIN32
#include <windows.h>
@@ -57,7 +58,7 @@ static void help(void)
"QEMU disk image utility\n"
"\n"
"Command syntax:\n"
- " create [-e] [-6] [-b base_image] [-f fmt] filename [size]\n"
+ " create [-e] [-6] [-F fmt] [-b base_image] [-f fmt] filename [size]\n"
" commit [-f fmt] filename\n"
" convert [-c] [-e] [-6] [-f fmt] [-O output_fmt] [-B output_base_image] filename [filename2 [...]] output_filename\n"
" info [-f fmt] filename\n"
@@ -217,6 +218,7 @@ static int img_create(int argc, char **argv)
{
int c, ret, flags;
const char *fmt = "raw";
+ const char *base_fmt = NULL;
const char *filename;
const char *base_filename = NULL;
uint64_t size;
@@ -226,13 +228,16 @@ static int img_create(int argc, char **argv)
flags = 0;
for(;;) {
- c = getopt(argc, argv, "b:f:he6");
+ c = getopt(argc, argv, "F:b:f:he6");
if (c == -1)
break;
switch(c) {
case 'h':
help();
break;
+ case 'F':
+ base_fmt = optarg;
+ break;
case 'b':
base_filename = optarg;
break;
@@ -253,7 +258,15 @@ static int img_create(int argc, char **argv)
size = 0;
if (base_filename) {
BlockDriverState *bs;
- bs = bdrv_new_open(base_filename, NULL);
+ BlockDriver *base_drv = NULL;
+
+ if (base_fmt) {
+ base_drv = bdrv_find_format(base_fmt);
+ if (base_drv == NULL)
+ error("Unknown basefile format '%s'", base_fmt);
+ }
+
+ bs = bdrv_new_open(base_filename, base_fmt);
bdrv_get_geometry(bs, &size);
size *= 512;
bdrv_delete(bs);
@@ -284,9 +297,12 @@ static int img_create(int argc, char **argv)
if (base_filename) {
printf(", backing_file=%s",
base_filename);
+ if (base_fmt)
+ printf(", backing_fmt=%s",
+ base_fmt);
}
printf(", size=%" PRIu64 " kB\n", size / 1024);
- ret = bdrv_create(drv, filename, size / 512, base_filename, flags);
+ ret = bdrv_create2(drv, filename, size / 512, base_filename, base_fmt, flags);
if (ret < 0) {
if (ret == -ENOTSUP) {
error("Formatting or formatting option not supported for file format '%s'", fmt);
diff --git a/qemu-img.texi b/qemu-img.texi
index a40f84168..deef2ab62 100644
--- a/qemu-img.texi
+++ b/qemu-img.texi
@@ -8,7 +8,7 @@ usage: qemu-img command [command options]
The following commands are supported:
@table @option
-@item create [-e] [-6] [-b @var{base_image}] [-f @var{fmt}] @var{filename} [@var{size}]
+@item create [-e] [-6] [-F @var{base_fmt}] [-b @var{base_image}] [-f @var{fmt}] @var{filename} [@var{size}]
@item commit [-f @var{fmt}] @var{filename}
@item convert [-c] [-e] [-6] [-f @var{fmt}] [-O @var{output_fmt}] [-B @var{output_base_image}] @var{filename} [@var{filename2} [...]] @var{output_filename}
@item info [-f @var{fmt}] @var{filename}
@@ -27,6 +27,8 @@ forces the output image to be created as a copy on write
image of the specified base image; @code{output_base_image} should have the same
content as the input's base image, however the path, image format, etc may
differ
+@item base_fmt
+is the disk image format of @var{base_image}. for more information look at @var{fmt}
@item fmt
is the disk image format. It is guessed automatically in most cases. The following formats are supported:
diff --git a/qemu-options.hx b/qemu-options.hx
new file mode 100644
index 000000000..bb4c8e6ce
--- /dev/null
+++ b/qemu-options.hx
@@ -0,0 +1,1495 @@
+HXCOMM Use DEFHEADING() to define headings in both help text and texi
+HXCOMM Text between STEXI and ETEXI are copied to texi version and
+HXCOMM discarded from C version
+HXCOMM DEF(option, HAS_ARG/0, opt_enum, opt_help) is used to construct
+HXCOMM option structures, enums and help message.
+HXCOMM HXCOMM can be used for comments, discarded from both texi and C
+
+DEFHEADING(Standard options:)
+STEXI
+@table @option
+ETEXI
+
+DEF("help", 0, QEMU_OPTION_h,
+ "-h or -help display this help and exit\n")
+STEXI
+@item -h
+Display help and exit
+ETEXI
+
+DEF("M", HAS_ARG, QEMU_OPTION_M,
+ "-M machine select emulated machine (-M ? for list)\n")
+STEXI
+@item -M @var{machine}
+Select the emulated @var{machine} (@code{-M ?} for list)
+ETEXI
+
+DEF("cpu", HAS_ARG, QEMU_OPTION_cpu,
+ "-cpu cpu select CPU (-cpu ? for list)\n")
+STEXI
+@item -cpu @var{model}
+Select CPU model (-cpu ? for list and additional feature selection)
+ETEXI
+
+DEF("smp", HAS_ARG, QEMU_OPTION_smp,
+ "-smp n set the number of CPUs to 'n' [default=1]\n")
+STEXI
+@item -smp @var{n}
+Simulate an SMP system with @var{n} CPUs. On the PC target, up to 255
+CPUs are supported. On Sparc32 target, Linux limits the number of usable CPUs
+to 4.
+ETEXI
+
+DEF("fda", HAS_ARG, QEMU_OPTION_fda,
+ "-fda/-fdb file use 'file' as floppy disk 0/1 image\n")
+DEF("fdb", HAS_ARG, QEMU_OPTION_fdb, "")
+STEXI
+@item -fda @var{file}
+@item -fdb @var{file}
+Use @var{file} as floppy disk 0/1 image (@pxref{disk_images}). You can
+use the host floppy by using @file{/dev/fd0} as filename (@pxref{host_drives}).
+ETEXI
+
+DEF("hda", HAS_ARG, QEMU_OPTION_hda,
+ "-hda/-hdb file use 'file' as IDE hard disk 0/1 image\n")
+DEF("hdb", HAS_ARG, QEMU_OPTION_hdb, "")
+DEF("hdc", HAS_ARG, QEMU_OPTION_hdc,
+ "-hdc/-hdd file use 'file' as IDE hard disk 2/3 image\n")
+DEF("hdd", HAS_ARG, QEMU_OPTION_hdd, "")
+STEXI
+@item -hda @var{file}
+@item -hdb @var{file}
+@item -hdc @var{file}
+@item -hdd @var{file}
+Use @var{file} as hard disk 0, 1, 2 or 3 image (@pxref{disk_images}).
+ETEXI
+
+DEF("cdrom", HAS_ARG, QEMU_OPTION_cdrom,
+ "-cdrom file use 'file' as IDE cdrom image (cdrom is ide1 master)\n")
+STEXI
+@item -cdrom @var{file}
+Use @var{file} as CD-ROM image (you cannot use @option{-hdc} and
+@option{-cdrom} at the same time). You can use the host CD-ROM by
+using @file{/dev/cdrom} as filename (@pxref{host_drives}).
+ETEXI
+
+DEF("drive", HAS_ARG, QEMU_OPTION_drive,
+ "-drive [file=file][,if=type][,bus=n][,unit=m][,media=d][,index=i]\n"
+ " [,cyls=c,heads=h,secs=s[,trans=t]][,snapshot=on|off]\n"
+ " [,cache=writethrough|writeback|none][,format=f][,serial=s]\n"
+ " use 'file' as a drive image\n")
+STEXI
+@item -drive @var{option}[,@var{option}[,@var{option}[,...]]]
+
+Define a new drive. Valid options are:
+
+@table @code
+@item file=@var{file}
+This option defines which disk image (@pxref{disk_images}) to use with
+this drive. If the filename contains comma, you must double it
+(for instance, "file=my,,file" to use file "my,file").
+@item if=@var{interface}
+This option defines on which type on interface the drive is connected.
+Available types are: ide, scsi, sd, mtd, floppy, pflash, virtio.
+@item bus=@var{bus},unit=@var{unit}
+These options define where is connected the drive by defining the bus number and
+the unit id.
+@item index=@var{index}
+This option defines where is connected the drive by using an index in the list
+of available connectors of a given interface type.
+@item media=@var{media}
+This option defines the type of the media: disk or cdrom.
+@item cyls=@var{c},heads=@var{h},secs=@var{s}[,trans=@var{t}]
+These options have the same definition as they have in @option{-hdachs}.
+@item snapshot=@var{snapshot}
+@var{snapshot} is "on" or "off" and allows to enable snapshot for given drive (see @option{-snapshot}).
+@item cache=@var{cache}
+@var{cache} is "none", "writeback", or "writethrough" and controls how the host cache is used to access block data.
+@item format=@var{format}
+Specify which disk @var{format} will be used rather than detecting
+the format. Can be used to specifiy format=raw to avoid interpreting
+an untrusted format header.
+@item serial=@var{serial}
+This option specifies the serial number to assign to the device.
+@end table
+
+By default, writethrough caching is used for all block device. This means that
+the host page cache will be used to read and write data but write notification
+will be sent to the guest only when the data has been reported as written by
+the storage subsystem.
+
+Writeback caching will report data writes as completed as soon as the data is
+present in the host page cache. This is safe as long as you trust your host.
+If your host crashes or loses power, then the guest may experience data
+corruption. When using the @option{-snapshot} option, writeback caching is
+used by default.
+
+The host page can be avoided entirely with @option{cache=none}. This will
+attempt to do disk IO directly to the guests memory. QEMU may still perform
+an internal copy of the data.
+
+Some block drivers perform badly with @option{cache=writethrough}, most notably,
+qcow2. If performance is more important than correctness,
+@option{cache=writeback} should be used with qcow2. By default, if no explicit
+caching is specified for a qcow2 disk image, @option{cache=writeback} will be
+used. For all other disk types, @option{cache=writethrough} is the default.
+
+Instead of @option{-cdrom} you can use:
+@example
+qemu -drive file=file,index=2,media=cdrom
+@end example
+
+Instead of @option{-hda}, @option{-hdb}, @option{-hdc}, @option{-hdd}, you can
+use:
+@example
+qemu -drive file=file,index=0,media=disk
+qemu -drive file=file,index=1,media=disk
+qemu -drive file=file,index=2,media=disk
+qemu -drive file=file,index=3,media=disk
+@end example
+
+You can connect a CDROM to the slave of ide0:
+@example
+qemu -drive file=file,if=ide,index=1,media=cdrom
+@end example
+
+If you don't specify the "file=" argument, you define an empty drive:
+@example
+qemu -drive if=ide,index=1,media=cdrom
+@end example
+
+You can connect a SCSI disk with unit ID 6 on the bus #0:
+@example
+qemu -drive file=file,if=scsi,bus=0,unit=6
+@end example
+
+Instead of @option{-fda}, @option{-fdb}, you can use:
+@example
+qemu -drive file=file,index=0,if=floppy
+qemu -drive file=file,index=1,if=floppy
+@end example
+
+By default, @var{interface} is "ide" and @var{index} is automatically
+incremented:
+@example
+qemu -drive file=a -drive file=b"
+@end example
+is interpreted like:
+@example
+qemu -hda a -hdb b
+@end example
+ETEXI
+
+DEF("mtdblock", HAS_ARG, QEMU_OPTION_mtdblock,
+ "-mtdblock file use 'file' as on-board Flash memory image\n")
+STEXI
+
+@item -mtdblock file
+Use 'file' as on-board Flash memory image.
+ETEXI
+
+DEF("sd", HAS_ARG, QEMU_OPTION_sd,
+ "-sd file use 'file' as SecureDigital card image\n")
+STEXI
+@item -sd file
+Use 'file' as SecureDigital card image.
+ETEXI
+
+DEF("pflash", HAS_ARG, QEMU_OPTION_pflash,
+ "-pflash file use 'file' as a parallel flash image\n")
+STEXI
+@item -pflash file
+Use 'file' as a parallel flash image.
+ETEXI
+
+DEF("boot", HAS_ARG, QEMU_OPTION_boot,
+ "-boot [a|c|d|n] boot on floppy (a), hard disk (c), CD-ROM (d), or network (n)\n")
+STEXI
+@item -boot [a|c|d|n]
+Boot on floppy (a), hard disk (c), CD-ROM (d), or Etherboot (n). Hard disk boot
+is the default.
+ETEXI
+
+DEF("snapshot", 0, QEMU_OPTION_snapshot,
+ "-snapshot write to temporary files instead of disk image files\n")
+STEXI
+@item -snapshot
+Write to temporary files instead of disk image files. In this case,
+the raw disk image you use is not written back. You can however force
+the write back by pressing @key{C-a s} (@pxref{disk_images}).
+ETEXI
+
+DEF("m", HAS_ARG, QEMU_OPTION_m,
+ "-m megs set virtual RAM size to megs MB [default=%d]\n")
+STEXI
+@item -m @var{megs}
+Set virtual RAM size to @var{megs} megabytes. Default is 128 MiB. Optionally,
+a suffix of ``M'' or ``G'' can be used to signify a value in megabytes or
+gigabytes respectively.
+ETEXI
+
+#ifndef _WIN32
+DEF("k", HAS_ARG, QEMU_OPTION_k,
+ "-k language use keyboard layout (for example 'fr' for French)\n")
+#endif
+STEXI
+@item -k @var{language}
+
+Use keyboard layout @var{language} (for example @code{fr} for
+French). This option is only needed where it is not easy to get raw PC
+keycodes (e.g. on Macs, with some X11 servers or with a VNC
+display). You don't normally need to use it on PC/Linux or PC/Windows
+hosts.
+
+The available layouts are:
+@example
+ar de-ch es fo fr-ca hu ja mk no pt-br sv
+da en-gb et fr fr-ch is lt nl pl ru th
+de en-us fi fr-be hr it lv nl-be pt sl tr
+@end example
+
+The default is @code{en-us}.
+ETEXI
+
+
+#ifdef HAS_AUDIO
+DEF("audio-help", 0, QEMU_OPTION_audio_help,
+ "-audio-help print list of audio drivers and their options\n")
+#endif
+STEXI
+@item -audio-help
+
+Will show the audio subsystem help: list of drivers, tunable
+parameters.
+ETEXI
+
+#ifdef HAS_AUDIO
+DEF("soundhw", HAS_ARG, QEMU_OPTION_soundhw,
+ "-soundhw c1,... enable audio support\n"
+ " and only specified sound cards (comma separated list)\n"
+ " use -soundhw ? to get the list of supported cards\n"
+ " use -soundhw all to enable all of them\n")
+#endif
+STEXI
+@item -soundhw @var{card1}[,@var{card2},...] or -soundhw all
+
+Enable audio and selected sound hardware. Use ? to print all
+available sound hardware.
+
+@example
+qemu -soundhw sb16,adlib disk.img
+qemu -soundhw es1370 disk.img
+qemu -soundhw ac97 disk.img
+qemu -soundhw all disk.img
+qemu -soundhw ?
+@end example
+
+Note that Linux's i810_audio OSS kernel (for AC97) module might
+require manually specifying clocking.
+
+@example
+modprobe i810_audio clocking=48000
+@end example
+ETEXI
+
+STEXI
+@end table
+ETEXI
+
+DEF("usb", 0, QEMU_OPTION_usb,
+ "-usb enable the USB driver (will be the default soon)\n")
+STEXI
+USB options:
+@table @option
+
+@item -usb
+Enable the USB driver (will be the default soon)
+ETEXI
+
+DEF("usbdevice", HAS_ARG, QEMU_OPTION_usbdevice,
+ "-usbdevice name add the host or guest USB device 'name'\n")
+STEXI
+
+@item -usbdevice @var{devname}
+Add the USB device @var{devname}. @xref{usb_devices}.
+
+@table @code
+
+@item mouse
+Virtual Mouse. This will override the PS/2 mouse emulation when activated.
+
+@item tablet
+Pointer device that uses absolute coordinates (like a touchscreen). This
+means qemu is able to report the mouse position without having to grab the
+mouse. Also overrides the PS/2 mouse emulation when activated.
+
+@item disk:[format=@var{format}]:file
+Mass storage device based on file. The optional @var{format} argument
+will be used rather than detecting the format. Can be used to specifiy
+format=raw to avoid interpreting an untrusted format header.
+
+@item host:bus.addr
+Pass through the host device identified by bus.addr (Linux only).
+
+@item host:vendor_id:product_id
+Pass through the host device identified by vendor_id:product_id (Linux only).
+
+@item serial:[vendorid=@var{vendor_id}][,productid=@var{product_id}]:@var{dev}
+Serial converter to host character device @var{dev}, see @code{-serial} for the
+available devices.
+
+@item braille
+Braille device. This will use BrlAPI to display the braille output on a real
+or fake device.
+
+@item net:options
+Network adapter that supports CDC ethernet and RNDIS protocols.
+
+@end table
+ETEXI
+
+DEF("name", HAS_ARG, QEMU_OPTION_name,
+ "-name string set the name of the guest\n")
+STEXI
+@item -name @var{name}
+Sets the @var{name} of the guest.
+This name will be displayed in the SDL window caption.
+The @var{name} will also be used for the VNC server.
+ETEXI
+
+DEF("uuid", HAS_ARG, QEMU_OPTION_uuid,
+ "-uuid %%08x-%%04x-%%04x-%%04x-%%012x\n"
+ " specify machine UUID\n")
+STEXI
+@item -uuid @var{uuid}
+Set system UUID.
+ETEXI
+
+STEXI
+@end table
+ETEXI
+
+DEFHEADING()
+
+DEFHEADING(Display options:)
+
+STEXI
+@table @option
+ETEXI
+
+DEF("nographic", 0, QEMU_OPTION_nographic,
+ "-nographic disable graphical output and redirect serial I/Os to console\n")
+STEXI
+@item -nographic
+
+Normally, QEMU uses SDL to display the VGA output. With this option,
+you can totally disable graphical output so that QEMU is a simple
+command line application. The emulated serial port is redirected on
+the console. Therefore, you can still use QEMU to debug a Linux kernel
+with a serial console.
+ETEXI
+
+#ifdef CONFIG_CURSES
+DEF("curses", 0, QEMU_OPTION_curses,
+ "-curses use a curses/ncurses interface instead of SDL\n")
+#endif
+STEXI
+@item -curses
+
+Normally, QEMU uses SDL to display the VGA output. With this option,
+QEMU can display the VGA output when in text mode using a
+curses/ncurses interface. Nothing is displayed in graphical mode.
+ETEXI
+
+#ifdef CONFIG_SDL
+DEF("no-frame", 0, QEMU_OPTION_no_frame,
+ "-no-frame open SDL window without a frame and window decorations\n")
+#endif
+STEXI
+@item -no-frame
+
+Do not use decorations for SDL windows and start them using the whole
+available screen space. This makes the using QEMU in a dedicated desktop
+workspace more convenient.
+ETEXI
+
+#ifdef CONFIG_SDL
+DEF("alt-grab", 0, QEMU_OPTION_alt_grab,
+ "-alt-grab use Ctrl-Alt-Shift to grab mouse (instead of Ctrl-Alt)\n")
+#endif
+STEXI
+@item -alt-grab
+
+Use Ctrl-Alt-Shift to grab mouse (instead of Ctrl-Alt).
+ETEXI
+
+#ifdef CONFIG_SDL
+DEF("no-quit", 0, QEMU_OPTION_no_quit,
+ "-no-quit disable SDL window close capability\n")
+#endif
+STEXI
+@item -no-quit
+
+Disable SDL window close capability.
+ETEXI
+
+#ifdef CONFIG_SDL
+DEF("sdl", 0, QEMU_OPTION_sdl,
+ "-sdl enable SDL\n")
+#endif
+STEXI
+@item -sdl
+
+Enable SDL.
+ETEXI
+
+DEF("portrait", 0, QEMU_OPTION_portrait,
+ "-portrait rotate graphical output 90 deg left (only PXA LCD)\n")
+STEXI
+@item -portrait
+
+Rotate graphical output 90 deg left (only PXA LCD).
+ETEXI
+
+DEF("vga", HAS_ARG, QEMU_OPTION_vga,
+ "-vga [std|cirrus|vmware|none]\n"
+ " select video card type\n")
+STEXI
+@item -vga @var{type}
+Select type of VGA card to emulate. Valid values for @var{type} are
+@table @code
+@item cirrus
+Cirrus Logic GD5446 Video card. All Windows versions starting from
+Windows 95 should recognize and use this graphic card. For optimal
+performances, use 16 bit color depth in the guest and the host OS.
+(This one is the default)
+@item std
+Standard VGA card with Bochs VBE extensions. If your guest OS
+supports the VESA 2.0 VBE extensions (e.g. Windows XP) and if you want
+to use high resolution modes (>= 1280x1024x16) then you should use
+this option.
+@item vmware
+VMWare SVGA-II compatible adapter. Use it if you have sufficiently
+recent XFree86/XOrg server or Windows guest with a driver for this
+card.
+@item none
+Disable VGA card.
+@end table
+ETEXI
+
+DEF("full-screen", 0, QEMU_OPTION_full_screen,
+ "-full-screen start in full screen\n")
+STEXI
+@item -full-screen
+Start in full screen.
+ETEXI
+
+#if defined(TARGET_PPC) || defined(TARGET_SPARC)
+DEF("g", 1, QEMU_OPTION_g ,
+ "-g WxH[xDEPTH] Set the initial graphical resolution and depth\n")
+#endif
+STEXI
+ETEXI
+
+DEF("vnc", HAS_ARG, QEMU_OPTION_vnc ,
+ "-vnc display start a VNC server on display\n")
+STEXI
+@item -vnc @var{display}[,@var{option}[,@var{option}[,...]]]
+
+Normally, QEMU uses SDL to display the VGA output. With this option,
+you can have QEMU listen on VNC display @var{display} and redirect the VGA
+display over the VNC session. It is very useful to enable the usb
+tablet device when using this option (option @option{-usbdevice
+tablet}). When using the VNC display, you must use the @option{-k}
+parameter to set the keyboard layout if you are not using en-us. Valid
+syntax for the @var{display} is
+
+@table @code
+
+@item @var{host}:@var{d}
+
+TCP connections will only be allowed from @var{host} on display @var{d}.
+By convention the TCP port is 5900+@var{d}. Optionally, @var{host} can
+be omitted in which case the server will accept connections from any host.
+
+@item @code{unix}:@var{path}
+
+Connections will be allowed over UNIX domain sockets where @var{path} is the
+location of a unix socket to listen for connections on.
+
+@item none
+
+VNC is initialized but not started. The monitor @code{change} command
+can be used to later start the VNC server.
+
+@end table
+
+Following the @var{display} value there may be one or more @var{option} flags
+separated by commas. Valid options are
+
+@table @code
+
+@item reverse
+
+Connect to a listening VNC client via a ``reverse'' connection. The
+client is specified by the @var{display}. For reverse network
+connections (@var{host}:@var{d},@code{reverse}), the @var{d} argument
+is a TCP port number, not a display number.
+
+@item password
+
+Require that password based authentication is used for client connections.
+The password must be set separately using the @code{change} command in the
+@ref{pcsys_monitor}
+
+@item tls
+
+Require that client use TLS when communicating with the VNC server. This
+uses anonymous TLS credentials so is susceptible to a man-in-the-middle
+attack. It is recommended that this option be combined with either the
+@var{x509} or @var{x509verify} options.
+
+@item x509=@var{/path/to/certificate/dir}
+
+Valid if @option{tls} is specified. Require that x509 credentials are used
+for negotiating the TLS session. The server will send its x509 certificate
+to the client. It is recommended that a password be set on the VNC server
+to provide authentication of the client when this is used. The path following
+this option specifies where the x509 certificates are to be loaded from.
+See the @ref{vnc_security} section for details on generating certificates.
+
+@item x509verify=@var{/path/to/certificate/dir}
+
+Valid if @option{tls} is specified. Require that x509 credentials are used
+for negotiating the TLS session. The server will send its x509 certificate
+to the client, and request that the client send its own x509 certificate.
+The server will validate the client's certificate against the CA certificate,
+and reject clients when validation fails. If the certificate authority is
+trusted, this is a sufficient authentication mechanism. You may still wish
+to set a password on the VNC server as a second authentication layer. The
+path following this option specifies where the x509 certificates are to
+be loaded from. See the @ref{vnc_security} section for details on generating
+certificates.
+
+@item sasl
+
+Require that the client use SASL to authenticate with the VNC server.
+The exact choice of authentication method used is controlled from the
+system / user's SASL configuration file for the 'qemu' service. This
+is typically found in /etc/sasl2/qemu.conf. If running QEMU as an
+unprivileged user, an environment variable SASL_CONF_PATH can be used
+to make it search alternate locations for the service config.
+While some SASL auth methods can also provide data encryption (eg GSSAPI),
+it is recommended that SASL always be combined with the 'tls' and
+'x509' settings to enable use of SSL and server certificates. This
+ensures a data encryption preventing compromise of authentication
+credentials. See the @ref{vnc_security} section for details on using
+SASL authentication.
+
+@item acl
+
+Turn on access control lists for checking of the x509 client certificate
+and SASL party. For x509 certs, the ACL check is made against the
+certificate's distinguished name. This is something that looks like
+@code{C=GB,O=ACME,L=Boston,CN=bob}. For SASL party, the ACL check is
+made against the username, which depending on the SASL plugin, may
+include a realm component, eg @code{bob} or @code{bob@@EXAMPLE.COM}.
+When the @option{acl} flag is set, the initial access list will be
+empty, with a @code{deny} policy. Thus no one will be allowed to
+use the VNC server until the ACLs have been loaded. This can be
+achieved using the @code{acl} monitor command.
+
+@end table
+ETEXI
+
+STEXI
+@end table
+ETEXI
+
+DEFHEADING()
+
+#ifdef TARGET_I386
+DEFHEADING(i386 target only:)
+#endif
+STEXI
+@table @option
+ETEXI
+
+#ifdef TARGET_I386
+DEF("win2k-hack", 0, QEMU_OPTION_win2k_hack,
+ "-win2k-hack use it when installing Windows 2000 to avoid a disk full bug\n")
+#endif
+STEXI
+@item -win2k-hack
+Use it when installing Windows 2000 to avoid a disk full bug. After
+Windows 2000 is installed, you no longer need this option (this option
+slows down the IDE transfers).
+ETEXI
+
+#ifdef TARGET_I386
+DEF("rtc-td-hack", 0, QEMU_OPTION_rtc_td_hack,
+ "-rtc-td-hack use it to fix time drift in Windows ACPI HAL\n")
+#endif
+STEXI
+@item -rtc-td-hack
+Use it if you experience time drift problem in Windows with ACPI HAL.
+This option will try to figure out how many timer interrupts were not
+processed by the Windows guest and will re-inject them.
+ETEXI
+
+#ifdef TARGET_I386
+DEF("no-fd-bootchk", 0, QEMU_OPTION_no_fd_bootchk,
+ "-no-fd-bootchk disable boot signature checking for floppy disks\n")
+#endif
+STEXI
+@item -no-fd-bootchk
+Disable boot signature checking for floppy disks in Bochs BIOS. It may
+be needed to boot from old floppy disks.
+ETEXI
+
+#ifdef TARGET_I386
+DEF("no-acpi", 0, QEMU_OPTION_no_acpi,
+ "-no-acpi disable ACPI\n")
+#endif
+STEXI
+@item -no-acpi
+Disable ACPI (Advanced Configuration and Power Interface) support. Use
+it if your guest OS complains about ACPI problems (PC target machine
+only).
+ETEXI
+
+#ifdef TARGET_I386
+DEF("no-hpet", 0, QEMU_OPTION_no_hpet,
+ "-no-hpet disable HPET\n")
+#endif
+STEXI
+@item -no-hpet
+Disable HPET support.
+ETEXI
+
+#ifdef TARGET_I386
+DEF("acpitable", HAS_ARG, QEMU_OPTION_acpitable,
+ "-acpitable [sig=str][,rev=n][,oem_id=str][,oem_table_id=str][,oem_rev=n][,asl_compiler_id=str][,asl_compiler_rev=n][,data=file1[:file2]...]\n"
+ " ACPI table description\n")
+#endif
+STEXI
+@item -acpitable [sig=@var{str}][,rev=@var{n}][,oem_id=@var{str}][,oem_table_id=@var{str}][,oem_rev=@var{n}] [,asl_compiler_id=@var{str}][,asl_compiler_rev=@var{n}][,data=@var{file1}[:@var{file2}]...]
+Add ACPI table with specified header fields and context from specified files.
+ETEXI
+
+#ifdef TARGET_I386
+DEFHEADING()
+#endif
+STEXI
+@end table
+ETEXI
+
+DEFHEADING(Network options:)
+STEXI
+@table @option
+ETEXI
+
+DEF("net", HAS_ARG, QEMU_OPTION_net, \
+ "-net nic[,vlan=n][,macaddr=addr][,model=type][,name=str]\n"
+ " create a new Network Interface Card and connect it to VLAN 'n'\n"
+#ifdef CONFIG_SLIRP
+ "-net user[,vlan=n][,name=str][,hostname=host]\n"
+ " connect the user mode network stack to VLAN 'n' and send\n"
+ " hostname 'host' to DHCP clients\n"
+#endif
+#ifdef _WIN32
+ "-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]\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 'fd=h' to connect to an already opened TAP interface\n"
+#endif
+ "-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][,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][,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"
+ " ownership and permissions for communication port.\n"
+#endif
+ "-net none use it alone to have zero network devices; if no -net option\n"
+ " is provided, the default is '-net nic -net user'\n")
+STEXI
+@item -net nic[,vlan=@var{n}][,macaddr=@var{addr}][,model=@var{type}][,name=@var{name}]
+Create a new Network Interface Card and connect it to VLAN @var{n} (@var{n}
+= 0 is the default). The NIC is an ne2k_pci by default on the PC
+target. Optionally, the MAC address can be changed to @var{addr}
+and a @var{name} can be assigned for use in monitor commands. If no
+@option{-net} option is specified, a single NIC is created.
+Qemu can emulate several different models of network card.
+Valid values for @var{type} are
+@code{i82551}, @code{i82557b}, @code{i82559er},
+@code{ne2k_pci}, @code{ne2k_isa}, @code{pcnet}, @code{rtl8139},
+@code{e1000}, @code{smc91c111}, @code{lance} and @code{mcf_fec}.
+Not all devices are supported on all targets. Use -net nic,model=?
+for a list of available devices for your target.
+
+@item -net user[,vlan=@var{n}][,hostname=@var{name}][,name=@var{name}]
+Use the user mode network stack which requires no administrator
+privilege to run. @option{hostname=name} can be used to specify the client
+hostname reported by the builtin DHCP server.
+
+@item -net channel,@var{port}:@var{dev}
+Forward @option{user} TCP connection to port @var{port} to character device @var{dev}
+
+@item -net tap[,vlan=@var{n}][,name=@var{name}][,fd=@var{h}][,ifname=@var{name}][,script=@var{file}][,downscript=@var{dfile}]
+Connect the host TAP network interface @var{name} to VLAN @var{n}, use
+the network script @var{file} to configure it and the network script
+@var{dfile} to deconfigure it. If @var{name} is not provided, the OS
+automatically provides one. @option{fd}=@var{h} can be used to specify
+the handle of an already opened host TAP interface. The default network
+configure script is @file{/etc/qemu-ifup} and the default network
+deconfigure script is @file{/etc/qemu-ifdown}. Use @option{script=no}
+or @option{downscript=no} to disable script execution. Example:
+
+@example
+qemu linux.img -net nic -net tap
+@end example
+
+More complicated example (two NICs, each one connected to a TAP device)
+@example
+qemu linux.img -net nic,vlan=0 -net tap,vlan=0,ifname=tap0 \
+ -net nic,vlan=1 -net tap,vlan=1,ifname=tap1
+@end example
+
+@item -net socket[,vlan=@var{n}][,name=@var{name}][,fd=@var{h}][,listen=[@var{host}]:@var{port}][,connect=@var{host}:@var{port}]
+
+Connect the VLAN @var{n} to a remote VLAN in another QEMU virtual
+machine using a TCP socket connection. If @option{listen} is
+specified, QEMU waits for incoming connections on @var{port}
+(@var{host} is optional). @option{connect} is used to connect to
+another QEMU instance using the @option{listen} option. @option{fd}=@var{h}
+specifies an already opened TCP socket.
+
+Example:
+@example
+# launch a first QEMU instance
+qemu linux.img -net nic,macaddr=52:54:00:12:34:56 \
+ -net socket,listen=:1234
+# connect the VLAN 0 of this instance to the VLAN 0
+# of the first instance
+qemu linux.img -net nic,macaddr=52:54:00:12:34:57 \
+ -net socket,connect=127.0.0.1:1234
+@end example
+
+@item -net socket[,vlan=@var{n}][,name=@var{name}][,fd=@var{h}][,mcast=@var{maddr}:@var{port}]
+
+Create a VLAN @var{n} shared with another QEMU virtual
+machines using a UDP multicast socket, effectively making a bus for
+every QEMU with same multicast address @var{maddr} and @var{port}.
+NOTES:
+@enumerate
+@item
+Several QEMU can be running on different hosts and share same bus (assuming
+correct multicast setup for these hosts).
+@item
+mcast support is compatible with User Mode Linux (argument @option{eth@var{N}=mcast}), see
+@url{http://user-mode-linux.sf.net}.
+@item
+Use @option{fd=h} to specify an already opened UDP multicast socket.
+@end enumerate
+
+Example:
+@example
+# launch one QEMU instance
+qemu linux.img -net nic,macaddr=52:54:00:12:34:56 \
+ -net socket,mcast=230.0.0.1:1234
+# launch another QEMU instance on same "bus"
+qemu linux.img -net nic,macaddr=52:54:00:12:34:57 \
+ -net socket,mcast=230.0.0.1:1234
+# launch yet another QEMU instance on same "bus"
+qemu linux.img -net nic,macaddr=52:54:00:12:34:58 \
+ -net socket,mcast=230.0.0.1:1234
+@end example
+
+Example (User Mode Linux compat.):
+@example
+# launch QEMU instance (note mcast address selected
+# is UML's default)
+qemu linux.img -net nic,macaddr=52:54:00:12:34:56 \
+ -net socket,mcast=239.192.168.1:1102
+# launch UML
+/path/to/linux ubd0=/path/to/root_fs eth0=mcast
+@end example
+
+@item -net vde[,vlan=@var{n}][,name=@var{name}][,sock=@var{socketpath}][,port=@var{n}][,group=@var{groupname}][,mode=@var{octalmode}]
+Connect VLAN @var{n} to PORT @var{n} of a vde switch running on host and
+listening for incoming connections on @var{socketpath}. Use GROUP @var{groupname}
+and MODE @var{octalmode} to change default ownership and permissions for
+communication port. This option is available only if QEMU has been compiled
+with vde support enabled.
+
+Example:
+@example
+# launch vde switch
+vde_switch -F -sock /tmp/myswitch
+# launch QEMU instance
+qemu linux.img -net nic -net vde,sock=/tmp/myswitch
+@end example
+
+@item -net none
+Indicate that no network devices should be configured. It is used to
+override the default configuration (@option{-net nic -net user}) which
+is activated if no @option{-net} options are provided.
+ETEXI
+
+#ifdef CONFIG_SLIRP
+DEF("tftp", HAS_ARG, QEMU_OPTION_tftp, \
+ "-tftp dir allow tftp access to files in dir [-net user]\n")
+#endif
+STEXI
+@item -tftp @var{dir}
+When using the user mode network stack, activate a built-in TFTP
+server. The files in @var{dir} will be exposed as the root of a TFTP server.
+The TFTP client on the guest must be configured in binary mode (use the command
+@code{bin} of the Unix TFTP client). The host IP address on the guest is as
+usual 10.0.2.2.
+ETEXI
+
+#ifdef CONFIG_SLIRP
+DEF("bootp", HAS_ARG, QEMU_OPTION_bootp, \
+ "-bootp file advertise file in BOOTP replies\n")
+#endif
+STEXI
+@item -bootp @var{file}
+When using the user mode network stack, broadcast @var{file} as the BOOTP
+filename. In conjunction with @option{-tftp}, this can be used to network boot
+a guest from a local directory.
+
+Example (using pxelinux):
+@example
+qemu -hda linux.img -boot n -tftp /path/to/tftp/files -bootp /pxelinux.0
+@end example
+ETEXI
+
+#ifndef _WIN32
+DEF("smb", HAS_ARG, QEMU_OPTION_smb, \
+ "-smb dir allow SMB access to files in 'dir' [-net user]\n")
+#endif
+STEXI
+@item -smb @var{dir}
+When using the user mode network stack, activate a built-in SMB
+server so that Windows OSes can access to the host files in @file{@var{dir}}
+transparently.
+
+In the guest Windows OS, the line:
+@example
+10.0.2.4 smbserver
+@end example
+must be added in the file @file{C:\WINDOWS\LMHOSTS} (for windows 9x/Me)
+or @file{C:\WINNT\SYSTEM32\DRIVERS\ETC\LMHOSTS} (Windows NT/2000).
+
+Then @file{@var{dir}} can be accessed in @file{\\smbserver\qemu}.
+
+Note that a SAMBA server must be installed on the host OS in
+@file{/usr/sbin/smbd}. QEMU was tested successfully with smbd version
+2.2.7a from the Red Hat 9 and version 3.0.10-1.fc3 from Fedora Core 3.
+ETEXI
+
+#ifdef CONFIG_SLIRP
+DEF("redir", HAS_ARG, QEMU_OPTION_redir, \
+ "-redir [tcp|udp]:host-port:[guest-host]:guest-port\n" \
+ " redirect TCP or UDP connections from host to guest [-net user]\n")
+#endif
+STEXI
+@item -redir [tcp|udp]:@var{host-port}:[@var{guest-host}]:@var{guest-port}
+
+When using the user mode network stack, redirect incoming TCP or UDP
+connections to the host port @var{host-port} to the guest
+@var{guest-host} on guest port @var{guest-port}. If @var{guest-host}
+is not specified, its value is 10.0.2.15 (default address given by the
+built-in DHCP server).
+
+For example, to redirect host X11 connection from screen 1 to guest
+screen 0, use the following:
+
+@example
+# on the host
+qemu -redir tcp:6001::6000 [...]
+# this host xterm should open in the guest X11 server
+xterm -display :1
+@end example
+
+To redirect telnet connections from host port 5555 to telnet port on
+the guest, use the following:
+
+@example
+# on the host
+qemu -redir tcp:5555::23 [...]
+telnet localhost 5555
+@end example
+
+Then when you use on the host @code{telnet localhost 5555}, you
+connect to the guest telnet server.
+
+@end table
+ETEXI
+
+DEF("bt", HAS_ARG, QEMU_OPTION_bt, \
+ "\n" \
+ "-bt hci,null dumb bluetooth HCI - doesn't respond to commands\n" \
+ "-bt hci,host[:id]\n" \
+ " use host's HCI with the given name\n" \
+ "-bt hci[,vlan=n]\n" \
+ " emulate a standard HCI in virtual scatternet 'n'\n" \
+ "-bt vhci[,vlan=n]\n" \
+ " add host computer to virtual scatternet 'n' using VHCI\n" \
+ "-bt device:dev[,vlan=n]\n" \
+ " emulate a bluetooth device 'dev' in scatternet 'n'\n")
+STEXI
+Bluetooth(R) options:
+@table @option
+
+@item -bt hci[...]
+Defines the function of the corresponding Bluetooth HCI. -bt options
+are matched with the HCIs present in the chosen machine type. For
+example when emulating a machine with only one HCI built into it, only
+the first @code{-bt hci[...]} option is valid and defines the HCI's
+logic. The Transport Layer is decided by the machine type. Currently
+the machines @code{n800} and @code{n810} have one HCI and all other
+machines have none.
+
+@anchor{bt-hcis}
+The following three types are recognized:
+
+@table @code
+@item -bt hci,null
+(default) The corresponding Bluetooth HCI assumes no internal logic
+and will not respond to any HCI commands or emit events.
+
+@item -bt hci,host[:@var{id}]
+(@code{bluez} only) The corresponding HCI passes commands / events
+to / from the physical HCI identified by the name @var{id} (default:
+@code{hci0}) on the computer running QEMU. Only available on @code{bluez}
+capable systems like Linux.
+
+@item -bt hci[,vlan=@var{n}]
+Add a virtual, standard HCI that will participate in the Bluetooth
+scatternet @var{n} (default @code{0}). Similarly to @option{-net}
+VLANs, devices inside a bluetooth network @var{n} can only communicate
+with other devices in the same network (scatternet).
+@end table
+
+@item -bt vhci[,vlan=@var{n}]
+(Linux-host only) Create a HCI in scatternet @var{n} (default 0) attached
+to the host bluetooth stack instead of to the emulated target. This
+allows the host and target machines to participate in a common scatternet
+and communicate. Requires the Linux @code{vhci} driver installed. Can
+be used as following:
+
+@example
+qemu [...OPTIONS...] -bt hci,vlan=5 -bt vhci,vlan=5
+@end example
+
+@item -bt device:@var{dev}[,vlan=@var{n}]
+Emulate a bluetooth device @var{dev} and place it in network @var{n}
+(default @code{0}). QEMU can only emulate one type of bluetooth devices
+currently:
+
+@table @code
+@item keyboard
+Virtual wireless keyboard implementing the HIDP bluetooth profile.
+@end table
+@end table
+ETEXI
+
+DEFHEADING()
+
+DEFHEADING(Linux boot specific:)
+STEXI
+When using these options, you can use a given
+Linux kernel without installing it in the disk image. It can be useful
+for easier testing of various kernels.
+
+@table @option
+ETEXI
+
+DEF("kernel", HAS_ARG, QEMU_OPTION_kernel, \
+ "-kernel bzImage use 'bzImage' as kernel image\n")
+STEXI
+@item -kernel @var{bzImage}
+Use @var{bzImage} as kernel image.
+ETEXI
+
+DEF("append", HAS_ARG, QEMU_OPTION_append, \
+ "-append cmdline use 'cmdline' as kernel command line\n")
+STEXI
+@item -append @var{cmdline}
+Use @var{cmdline} as kernel command line
+ETEXI
+
+DEF("initrd", HAS_ARG, QEMU_OPTION_initrd, \
+ "-initrd file use 'file' as initial ram disk\n")
+STEXI
+@item -initrd @var{file}
+Use @var{file} as initial ram disk.
+ETEXI
+
+STEXI
+@end table
+ETEXI
+
+DEFHEADING()
+
+DEFHEADING(Debug/Expert options:)
+
+STEXI
+@table @option
+ETEXI
+
+DEF("serial", HAS_ARG, QEMU_OPTION_serial, \
+ "-serial dev redirect the serial port to char device 'dev'\n")
+STEXI
+@item -serial @var{dev}
+Redirect the virtual serial port to host character device
+@var{dev}. The default device is @code{vc} in graphical mode and
+@code{stdio} in non graphical mode.
+
+This option can be used several times to simulate up to 4 serial
+ports.
+
+Use @code{-serial none} to disable all serial ports.
+
+Available character devices are:
+@table @code
+@item vc[:WxH]
+Virtual console. Optionally, a width and height can be given in pixel with
+@example
+vc:800x600
+@end example
+It is also possible to specify width or height in characters:
+@example
+vc:80Cx24C
+@end example
+@item pty
+[Linux only] Pseudo TTY (a new PTY is automatically allocated)
+@item none
+No device is allocated.
+@item null
+void device
+@item /dev/XXX
+[Linux only] Use host tty, e.g. @file{/dev/ttyS0}. The host serial port
+parameters are set according to the emulated ones.
+@item /dev/parport@var{N}
+[Linux only, parallel port only] Use host parallel port
+@var{N}. Currently SPP and EPP parallel port features can be used.
+@item file:@var{filename}
+Write output to @var{filename}. No character can be read.
+@item stdio
+[Unix only] standard input/output
+@item pipe:@var{filename}
+name pipe @var{filename}
+@item COM@var{n}
+[Windows only] Use host serial port @var{n}
+@item udp:[@var{remote_host}]:@var{remote_port}[@@[@var{src_ip}]:@var{src_port}]
+This implements UDP Net Console.
+When @var{remote_host} or @var{src_ip} are not specified
+they default to @code{0.0.0.0}.
+When not using a specified @var{src_port} a random port is automatically chosen.
+@item msmouse
+Three button serial mouse. Configure the guest to use Microsoft protocol.
+
+If you just want a simple readonly console you can use @code{netcat} or
+@code{nc}, by starting qemu with: @code{-serial udp::4555} and nc as:
+@code{nc -u -l -p 4555}. Any time qemu writes something to that port it
+will appear in the netconsole session.
+
+If you plan to send characters back via netconsole or you want to stop
+and start qemu a lot of times, you should have qemu use the same
+source port each time by using something like @code{-serial
+udp::4555@@:4556} to qemu. Another approach is to use a patched
+version of netcat which can listen to a TCP port and send and receive
+characters via udp. If you have a patched version of netcat which
+activates telnet remote echo and single char transfer, then you can
+use the following options to step up a netcat redirector to allow
+telnet on port 5555 to access the qemu port.
+@table @code
+@item Qemu Options:
+-serial udp::4555@@:4556
+@item netcat options:
+-u -P 4555 -L 0.0.0.0:4556 -t -p 5555 -I -T
+@item telnet options:
+localhost 5555
+@end table
+
+@item tcp:[@var{host}]:@var{port}[,@var{server}][,nowait][,nodelay]
+The TCP Net Console has two modes of operation. It can send the serial
+I/O to a location or wait for a connection from a location. By default
+the TCP Net Console is sent to @var{host} at the @var{port}. If you use
+the @var{server} option QEMU will wait for a client socket application
+to connect to the port before continuing, unless the @code{nowait}
+option was specified. The @code{nodelay} option disables the Nagle buffering
+algorithm. If @var{host} is omitted, 0.0.0.0 is assumed. Only
+one TCP connection at a time is accepted. You can use @code{telnet} to
+connect to the corresponding character device.
+@table @code
+@item Example to send tcp console to 192.168.0.2 port 4444
+-serial tcp:192.168.0.2:4444
+@item Example to listen and wait on port 4444 for connection
+-serial tcp::4444,server
+@item Example to not wait and listen on ip 192.168.0.100 port 4444
+-serial tcp:192.168.0.100:4444,server,nowait
+@end table
+
+@item telnet:@var{host}:@var{port}[,server][,nowait][,nodelay]
+The telnet protocol is used instead of raw tcp sockets. The options
+work the same as if you had specified @code{-serial tcp}. The
+difference is that the port acts like a telnet server or client using
+telnet option negotiation. This will also allow you to send the
+MAGIC_SYSRQ sequence if you use a telnet that supports sending the break
+sequence. Typically in unix telnet you do it with Control-] and then
+type "send break" followed by pressing the enter key.
+
+@item unix:@var{path}[,server][,nowait]
+A unix domain socket is used instead of a tcp socket. The option works the
+same as if you had specified @code{-serial tcp} except the unix domain socket
+@var{path} is used for connections.
+
+@item mon:@var{dev_string}
+This is a special option to allow the monitor to be multiplexed onto
+another serial port. The monitor is accessed with key sequence of
+@key{Control-a} and then pressing @key{c}. See monitor access
+@ref{pcsys_keys} in the -nographic section for more keys.
+@var{dev_string} should be any one of the serial devices specified
+above. An example to multiplex the monitor onto a telnet server
+listening on port 4444 would be:
+@table @code
+@item -serial mon:telnet::4444,server,nowait
+@end table
+
+@item braille
+Braille device. This will use BrlAPI to display the braille output on a real
+or fake device.
+
+@end table
+ETEXI
+
+DEF("parallel", HAS_ARG, QEMU_OPTION_parallel, \
+ "-parallel dev redirect the parallel port to char device 'dev'\n")
+STEXI
+@item -parallel @var{dev}
+Redirect the virtual parallel port to host device @var{dev} (same
+devices as the serial port). On Linux hosts, @file{/dev/parportN} can
+be used to use hardware devices connected on the corresponding host
+parallel port.
+
+This option can be used several times to simulate up to 3 parallel
+ports.
+
+Use @code{-parallel none} to disable all parallel ports.
+ETEXI
+
+DEF("monitor", HAS_ARG, QEMU_OPTION_monitor, \
+ "-monitor dev redirect the monitor to char device 'dev'\n")
+STEXI
+@item -monitor @var{dev}
+Redirect the monitor to host device @var{dev} (same devices as the
+serial port).
+The default device is @code{vc} in graphical mode and @code{stdio} in
+non graphical mode.
+ETEXI
+
+DEF("pidfile", HAS_ARG, QEMU_OPTION_pidfile, \
+ "-pidfile file write PID to 'file'\n")
+STEXI
+@item -pidfile @var{file}
+Store the QEMU process PID in @var{file}. It is useful if you launch QEMU
+from a script.
+ETEXI
+
+DEF("S", 0, QEMU_OPTION_S, \
+ "-S freeze CPU at startup (use 'c' to start execution)\n")
+STEXI
+@item -S
+Do not start CPU at startup (you must type 'c' in the monitor).
+ETEXI
+
+DEF("s", 0, QEMU_OPTION_s, \
+ "-s wait gdb connection to port\n")
+STEXI
+@item -s
+Wait gdb connection to port 1234 (@pxref{gdb_usage}).
+ETEXI
+
+DEF("p", HAS_ARG, QEMU_OPTION_p, \
+ "-p port set gdb connection port [default=%s]\n")
+STEXI
+@item -p @var{port}
+Change gdb connection port. @var{port} can be either a decimal number
+to specify a TCP port, or a host device (same devices as the serial port).
+ETEXI
+
+DEF("d", HAS_ARG, QEMU_OPTION_d, \
+ "-d item1,... output log to %s (use -d ? for a list of log items)\n")
+STEXI
+@item -d
+Output log in /tmp/qemu.log
+ETEXI
+
+DEF("hdachs", HAS_ARG, QEMU_OPTION_hdachs, \
+ "-hdachs c,h,s[,t]\n" \
+ " force hard disk 0 physical geometry and the optional BIOS\n" \
+ " translation (t=none or lba) (usually qemu can guess them)\n")
+STEXI
+@item -hdachs @var{c},@var{h},@var{s},[,@var{t}]
+Force hard disk 0 physical geometry (1 <= @var{c} <= 16383, 1 <=
+@var{h} <= 16, 1 <= @var{s} <= 63) and optionally force the BIOS
+translation mode (@var{t}=none, lba or auto). Usually QEMU can guess
+all those parameters. This option is useful for old MS-DOS disk
+images.
+ETEXI
+
+DEF("L", HAS_ARG, QEMU_OPTION_L, \
+ "-L path set the directory for the BIOS, VGA BIOS and keymaps\n")
+STEXI
+@item -L @var{path}
+Set the directory for the BIOS, VGA BIOS and keymaps.
+ETEXI
+
+DEF("bios", HAS_ARG, QEMU_OPTION_bios, \
+ "-bios file set the filename for the BIOS\n")
+STEXI
+@item -bios @var{file}
+Set the filename for the BIOS.
+ETEXI
+
+#ifdef USE_KQEMU
+DEF("kernel-kqemu", 0, QEMU_OPTION_kernel_kqemu, \
+ "-kernel-kqemu enable KQEMU full virtualization (default is user mode only)\n")
+#endif
+STEXI
+@item -kernel-kqemu
+Enable KQEMU full virtualization (default is user mode only).
+ETEXI
+
+#ifdef USE_KQEMU
+DEF("no-kqemu", 0, QEMU_OPTION_no_kqemu, \
+ "-no-kqemu disable KQEMU kernel module usage\n")
+#endif
+STEXI
+@item -no-kqemu
+Disable KQEMU kernel module usage. KQEMU options are only available if
+KQEMU support is enabled when compiling.
+ETEXI
+
+#ifdef CONFIG_KVM
+DEF("enable-kvm", 0, QEMU_OPTION_enable_kvm, \
+ "-enable-kvm enable KVM full virtualization support\n")
+#endif
+STEXI
+@item -enable-kvm
+Enable KVM full virtualization support. This option is only available
+if KVM support is enabled when compiling.
+ETEXI
+
+DEF("no-reboot", 0, QEMU_OPTION_no_reboot, \
+ "-no-reboot exit instead of rebooting\n")
+STEXI
+@item -no-reboot
+Exit instead of rebooting.
+ETEXI
+
+DEF("no-shutdown", 0, QEMU_OPTION_no_shutdown, \
+ "-no-shutdown stop before shutdown\n")
+STEXI
+@item -no-shutdown
+Don't exit QEMU on guest shutdown, but instead only stop the emulation.
+This allows for instance switching to monitor to commit changes to the
+disk image.
+ETEXI
+
+DEF("loadvm", HAS_ARG, QEMU_OPTION_loadvm, \
+ "-loadvm [tag|id]\n" \
+ " start right away with a saved state (loadvm in monitor)\n")
+STEXI
+@item -loadvm @var{file}
+Start right away with a saved state (@code{loadvm} in monitor)
+ETEXI
+
+#ifndef _WIN32
+DEF("daemonize", 0, QEMU_OPTION_daemonize, \
+ "-daemonize daemonize QEMU after initializing\n")
+#endif
+STEXI
+@item -daemonize
+Daemonize the QEMU process after initialization. QEMU will not detach from
+standard IO until it is ready to receive connections on any of its devices.
+This option is a useful way for external programs to launch QEMU without having
+to cope with initialization race conditions.
+ETEXI
+
+DEF("option-rom", HAS_ARG, QEMU_OPTION_option_rom, \
+ "-option-rom rom load a file, rom, into the option ROM space\n")
+STEXI
+@item -option-rom @var{file}
+Load the contents of @var{file} as an option ROM.
+This option is useful to load things like EtherBoot.
+ETEXI
+
+DEF("clock", HAS_ARG, QEMU_OPTION_clock, \
+ "-clock force the use of the given methods for timer alarm.\n" \
+ " To see what timers are available use -clock ?\n")
+STEXI
+@item -clock @var{method}
+Force the use of the given methods for timer alarm. To see what timers
+are available use -clock ?.
+ETEXI
+
+DEF("localtime", 0, QEMU_OPTION_localtime, \
+ "-localtime set the real time clock to local time [default=utc]\n")
+STEXI
+@item -localtime
+Set the real time clock to local time (the default is to UTC
+time). This option is needed to have correct date in MS-DOS or
+Windows.
+ETEXI
+
+DEF("startdate", HAS_ARG, QEMU_OPTION_startdate, \
+ "-startdate select initial date of the clock\n")
+STEXI
+
+@item -startdate @var{date}
+Set the initial date of the real time clock. Valid formats for
+@var{date} are: @code{now} or @code{2006-06-17T16:01:21} or
+@code{2006-06-17}. The default value is @code{now}.
+ETEXI
+
+DEF("icount", HAS_ARG, QEMU_OPTION_icount, \
+ "-icount [N|auto]\n" \
+ " enable virtual instruction counter with 2^N clock ticks per instruction\n")
+STEXI
+@item -icount [N|auto]
+Enable virtual instruction counter. The virtual cpu will execute one
+instruction every 2^N ns of virtual time. If @code{auto} is specified
+then the virtual cpu speed will be automatically adjusted to keep virtual
+time within a few seconds of real time.
+
+Note that while this option can give deterministic behavior, it does not
+provide cycle accurate emulation. Modern CPUs contain superscalar out of
+order cores with complex cache hierarchies. The number of instructions
+executed often has little or no correlation with actual performance.
+ETEXI
+
+DEF("echr", HAS_ARG, QEMU_OPTION_echr, \
+ "-echr chr set terminal escape character instead of ctrl-a\n")
+STEXI
+
+@item -echr numeric_ascii_value
+Change the escape character used for switching to the monitor when using
+monitor and serial sharing. The default is @code{0x01} when using the
+@code{-nographic} option. @code{0x01} is equal to pressing
+@code{Control-a}. You can select a different character from the ascii
+control keys where 1 through 26 map to Control-a through Control-z. For
+instance you could use the either of the following to change the escape
+character to Control-t.
+@table @code
+@item -echr 0x14
+@item -echr 20
+@end table
+ETEXI
+
+DEF("virtioconsole", HAS_ARG, QEMU_OPTION_virtiocon, \
+ "-virtioconsole c\n" \
+ " set virtio console\n")
+STEXI
+@item -virtioconsole @var{c}
+Set virtio console.
+ETEXI
+
+DEF("show-cursor", 0, QEMU_OPTION_show_cursor, \
+ "-show-cursor show cursor\n")
+STEXI
+ETEXI
+
+DEF("tb-size", HAS_ARG, QEMU_OPTION_tb_size, \
+ "-tb-size n set TB size\n")
+STEXI
+ETEXI
+
+DEF("incoming", HAS_ARG, QEMU_OPTION_incoming, \
+ "-incoming p prepare for incoming migration, listen on port p\n")
+STEXI
+ETEXI
+
+#ifndef _WIN32
+DEF("chroot", HAS_ARG, QEMU_OPTION_chroot, \
+ "-chroot dir Chroot to dir just before starting the VM.\n")
+#endif
+STEXI
+@item -chroot dir
+Immediately before starting guest execution, chroot to the specified
+directory. Especially useful in combination with -runas.
+ETEXI
+
+#ifndef _WIN32
+DEF("runas", HAS_ARG, QEMU_OPTION_runas, \
+ "-runas user Change to user id user just before starting the VM.\n")
+#endif
+STEXI
+@item -runas user
+Immediately before starting guest execution, drop root privileges, switching
+to the specified user.
+ETEXI
+
+STEXI
+@end table
+ETEXI
+
+#if defined(TARGET_SPARC) || defined(TARGET_PPC)
+DEF("prom-env", HAS_ARG, QEMU_OPTION_prom_env,
+ "-prom-env variable=value\n"
+ " set OpenBIOS nvram variables\n")
+#endif
+#if defined(TARGET_ARM) || defined(TARGET_M68K)
+DEF("semihosting", 0, QEMU_OPTION_semihosting,
+ "-semihosting semihosting mode\n")
+#endif
+#if defined(TARGET_ARM)
+DEF("old-param", 0, QEMU_OPTION_old_param,
+ "-old-param old param mode\n")
+#endif
+
+DEF("no-kvm", 0, QEMU_OPTION_no_kvm,
+ "-no-kvm disable KVM hardware virtualization\n")
+DEF("no-kvm-irqchip", 0, QEMU_OPTION_no_kvm_irqchip,
+ "-no-kvm-irqchip disable KVM kernel mode PIC/IOAPIC/LAPIC\n")
+DEF("no-kvm-pit", 0, QEMU_OPTION_no_kvm_pit,
+ "-no-kvm-pit disable KVM kernel mode PIT\n")
+DEF("no-kvm-pit-reinjection", 0, QEMU_OPTION_no_kvm_pit_reinjection,
+ "-no-kvm-pit-reinjection disable KVM kernel mode PIT interrupt reinjection\n")
+#if defined(TARGET_I386) || defined(TARGET_X86_64) || defined(TARGET_IA64) || defined(__linux__)
+DEF("pcidevice", HAS_ARG, QEMU_OPTION_pcidevice,
+ "-pcidevice host=bus:dev.func[,dma=none][,name=string]\n"
+ " expose a PCI device to the guest OS.\n"
+ " dma=none: don't perform any dma translations (default is to use an iommu)\n"
+ " 'string' is used in log output.\n")
+#endif
+DEF("enable-nesting", 0, QEMU_OPTION_enable_nesting,
+ "-enable-nesting enable support for running a VM inside the VM (AMD only)\n")
+DEF("cpu-vendor", HAS_ARG, QEMU_OPTION_cpu_vendor,
+ "-cpu-vendor STRING override the cpuid vendor string\n")
+DEF("nvram", HAS_ARG, QEMU_OPTION_nvram,
+ "-nvram FILE provide ia64 nvram contents\n")
+DEF("tdf", 0, QEMU_OPTION_tdf,
+ "-tdf enable guest time drift compensation\n")
+DEF("kvm-shadow-memory", HAS_ARG, QEMU_OPTION_kvm_shadow_memory,
+ "-kvm-shadow-memory MEGABYTES\n"
+ " allocate MEGABYTES for kvm mmu shadowing\n")
+DEF("mempath", HAS_ARG, QEMU_OPTION_mempath,
+ "-mempath FILE provide backing storage for guest RAM\n")
+#ifdef MAP_POPULATE
+DEF("mem-prealloc", 0, QEMU_OPTION_mem_prealloc,
+ "-mem-prealloc preallocate guest memory (use with -mempath)\n")
+#endif
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index a00d34fd1..31a134411 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -691,31 +691,12 @@ int kvm_arch_handle_exit(CPUState *env, struct kvm_run *run)
}
#ifdef KVM_CAP_SET_GUEST_DEBUG
-static int kvm_patch_opcode_byte(CPUState *env, target_ulong addr, uint8_t val)
-{
- target_phys_addr_t phys_page_addr;
- unsigned long pd;
- uint8_t *ptr;
-
- phys_page_addr = cpu_get_phys_page_debug(env, addr & TARGET_PAGE_MASK);
- if (phys_page_addr == -1)
- return -EINVAL;
-
- pd = cpu_get_physical_page_desc(phys_page_addr);
- if ((pd & ~TARGET_PAGE_MASK) != IO_MEM_RAM &&
- (pd & ~TARGET_PAGE_MASK) != IO_MEM_ROM && !(pd & IO_MEM_ROMD))
- return -EINVAL;
-
- ptr = phys_ram_base + (pd & TARGET_PAGE_MASK)
- + (addr & ~TARGET_PAGE_MASK);
- *ptr = val;
- return 0;
-}
-
int kvm_arch_insert_sw_breakpoint(CPUState *env, struct kvm_sw_breakpoint *bp)
{
+ const static uint8_t int3 = 0xcc;
+
if (cpu_memory_rw_debug(env, bp->pc, (uint8_t *)&bp->saved_insn, 1, 0) ||
- kvm_patch_opcode_byte(env, bp->pc, 0xcc))
+ cpu_memory_rw_debug(env, bp->pc, (uint8_t *)&int3, 1, 1))
return -EINVAL;
return 0;
}
@@ -725,7 +706,7 @@ int kvm_arch_remove_sw_breakpoint(CPUState *env, struct kvm_sw_breakpoint *bp)
uint8_t int3;
if (cpu_memory_rw_debug(env, bp->pc, &int3, 1, 0) || int3 != 0xcc ||
- kvm_patch_opcode_byte(env, bp->pc, bp->saved_insn))
+ cpu_memory_rw_debug(env, bp->pc, (uint8_t *)&bp->saved_insn, 1, 1))
return -EINVAL;
return 0;
}
diff --git a/vl.c b/vl.c
index c52d2d73d..6d39f37fc 100644
--- a/vl.c
+++ b/vl.c
@@ -149,6 +149,7 @@ int main(int argc, char **argv)
#include "qemu-char.h"
#include "cache-utils.h"
#include "block.h"
+#include "dma.h"
#include "audio/audio.h"
#include "migration.h"
#include "kvm.h"
@@ -4022,221 +4023,19 @@ static int main_loop(void)
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 " (" KVM_VERSION ")"
- ", Copyright (c) 2003-2008 Fabrice Bellard\n"
+ ", Copyright (c) 2003-2008 Fabrice Bellard\n"
"usage: %s [options] [disk_image]\n"
"\n"
"'disk_image' is a raw hard image image for IDE hard disk 0\n"
"\n"
- "Standard options:\n"
- "-h or -help display this help and exit\n"
- "-M machine select emulated machine (-M ? for list)\n"
- "-cpu cpu select CPU (-cpu ? for list)\n"
- "-smp n set the number of CPUs to 'n' [default=1]\n"
- "-fda/-fdb file use 'file' as floppy disk 0/1 image\n"
- "-hda/-hdb file use 'file' as IDE hard disk 0/1 image\n"
- "-hdc/-hdd file use 'file' as IDE hard disk 2/3 image\n"
- "-cdrom file use 'file' as IDE cdrom image (cdrom is ide1 master)\n"
- "-drive [file=file][,if=type][,bus=n][,unit=m][,media=d][,index=i]\n"
- " [,cyls=c,heads=h,secs=s[,trans=t]][,snapshot=on|off]\n"
- " [,cache=writethrough|writeback|none][,format=f][,serial=s]\n"
- " [,boot=on|off]\n"
- " use 'file' as a drive image\n"
- "-mtdblock file use 'file' as on-board Flash memory image\n"
- "-sd file use 'file' as SecureDigital card image\n"
- "-pflash file use 'file' as a parallel flash image\n"
- "-boot [a|c|d|n] boot on floppy (a), hard disk (c), CD-ROM (d), or network (n)\n"
- "-snapshot write to temporary files instead of disk image files\n"
- "-m megs set virtual RAM size to megs MB [default=%d]\n"
-#ifndef _WIN32
- "-k language use keyboard layout (for example \"fr\" for French)\n"
-#endif
-#ifdef HAS_AUDIO
- "-audio-help print list of audio drivers and their options\n"
- "-soundhw c1,... enable audio support\n"
- " and only specified sound cards (comma separated list)\n"
- " use -soundhw ? to get the list of supported cards\n"
- " use -soundhw all to enable all of them\n"
-#endif
- "-usb enable the USB driver (will be the default soon)\n"
- "-usbdevice name add the host or guest USB device 'name'\n"
- "-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
- "-vnc display start a VNC server on display\n"
-#ifdef TARGET_IA64
- "-nvram file use 'file' to save or load nvram image\n"
-#endif
- "-name string set the name of the guest\n"
- "-uuid %%08x-%%04x-%%04x-%%04x-%%012x specify machine UUID\n"
- "\n"
- "Network options:\n"
- "-net nic[,vlan=n][,macaddr=addr][,model=type][,name=str]\n"
- " create a new Network Interface Card and connect it to VLAN 'n'\n"
-#ifdef CONFIG_SLIRP
- "-net user[,vlan=n][,name=str][,hostname=host]\n"
- " connect the user mode network stack to VLAN 'n' and send\n"
- " hostname 'host' to DHCP clients\n"
-#endif
-#ifdef _WIN32
- "-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]\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 'fd=h' to connect to an already opened TAP interface\n"
-#endif
- "-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][,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][,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"
- " ownership and permissions for communication port.\n"
-#endif
- "-net none use it alone to have zero network devices; if no -net option\n"
- " is provided, the default is '-net nic -net user'\n"
-#ifdef CONFIG_SLIRP
- "-tftp dir allow tftp access to files in dir [-net user]\n"
- "-bootp file advertise file in BOOTP replies\n"
-#ifndef _WIN32
- "-smb dir allow SMB access to files in 'dir' [-net user]\n"
-#endif
- "-redir [tcp|udp]:host-port:[guest-host]:guest-port\n"
- " redirect TCP or UDP connections from host to guest [-net user]\n"
-#endif
- "\n"
- "-bt hci,null dumb bluetooth HCI - doesn't respond to commands\n"
- "-bt hci,host[:id]\n"
- " use host's HCI with the given name\n"
- "-bt hci[,vlan=n]\n"
- " emulate a standard HCI in virtual scatternet 'n'\n"
- "-bt vhci[,vlan=n]\n"
- " add host computer to virtual scatternet 'n' using VHCI\n"
- "-bt device:dev[,vlan=n]\n"
- " emulate a bluetooth device 'dev' in scatternet 'n'\n"
- "\n"
-#ifdef TARGET_I386
- "\n"
- "i386 target only:\n"
- "-win2k-hack use it when installing Windows 2000 to avoid a disk full bug\n"
- "-rtc-td-hack use it to fix time drift in Windows ACPI HAL\n"
- "-no-fd-bootchk disable boot signature checking for floppy disks\n"
- "-no-acpi disable ACPI\n"
- "-no-hpet disable HPET\n"
- "-acpitable [sig=str][,rev=n][,oem_id=str][,oem_table_id=str][,oem_rev=n][,asl_compiler_id=str][,asl_compiler_rev=n][,data=file1[:file2]...]\n"
- " ACPI table description\n"
-#endif
- "Linux boot specific:\n"
- "-kernel bzImage use 'bzImage' as kernel image\n"
- "-append cmdline use 'cmdline' as kernel command line\n"
- "-initrd file use 'file' as initial ram disk\n"
- "\n"
- "Debug/Expert options:\n"
- "-serial dev redirect the serial port to char device 'dev'\n"
- "-parallel dev redirect the parallel port to char device 'dev'\n"
- "-monitor dev redirect the monitor to char device 'dev'\n"
- "-pidfile file write PID to 'file'\n"
- "-S freeze CPU at startup (use 'c' to start execution)\n"
- "-s wait gdb connection to port\n"
- "-p port set gdb connection port [default=%s]\n"
- "-d item1,... output log to %s (use -d ? for a list of log items)\n"
- "-hdachs c,h,s[,t]\n"
- " force hard disk 0 physical geometry and the optional BIOS\n"
- " translation (t=none or lba) (usually qemu can guess them)\n"
- "-L path set the directory for the BIOS, VGA BIOS and keymaps\n"
- "-bios file set the filename for the BIOS\n"
-#ifdef USE_KQEMU
- "-kernel-kqemu enable KQEMU full virtualization (default is user mode only)\n"
- "-no-kqemu disable KQEMU kernel module usage\n"
-#endif
-#ifdef CONFIG_KVM
- "-enable-kvm enable KVM full virtualization support\n"
-#endif
-#ifdef USE_KVM
-#ifndef NO_CPU_EMULATION
- "-no-kvm disable KVM hardware virtualization\n"
-#endif
- "-no-kvm-irqchip disable KVM kernel mode PIC/IOAPIC/LAPIC\n"
- "-no-kvm-pit disable KVM kernel mode PIT\n"
- "-no-kvm-pit-reinjection disable KVM kernel mode PIT interrupt reinjection\n"
- "-enable-nesting enable support for running a VM inside the VM (AMD only)\n"
-#if defined(TARGET_I386) || defined(TARGET_X86_64) || defined(TARGET_IA64) || defined(__linux__)
- "-pcidevice host=bus:dev.func[,dma=none][,name=string]\n"
- " expose a PCI device to the guest OS.\n"
- " dma=none: don't perform any dma translations (default is to use an iommu)\n"
- " 'string' is used in log output.\n"
-#endif
-#endif
- "-no-reboot exit instead of rebooting\n"
- "-no-shutdown stop before shutdown\n"
- "-loadvm [tag|id]\n"
- " start right away with a saved state (loadvm in monitor)\n"
-#ifndef _WIN32
- "-daemonize daemonize QEMU after initializing\n"
-#endif
- "-tdf inject timer interrupts that got lost\n"
- "-kvm-shadow-memory megs set the amount of shadow pages to be allocated\n"
- "-mem-path set the path to hugetlbfs/tmpfs mounted directory, also\n"
- " enables allocation of guest memory with huge pages\n"
-#ifdef MAP_POPULATE
- "-mem-prealloc toggles preallocation of -mem-path backed physical memory\n"
- " at startup. Default is enabled.\n"
-#endif
- "-option-rom rom load a file, rom, into the option ROM space\n"
-#if defined(TARGET_SPARC) || defined(TARGET_PPC)
- "-prom-env variable=value\n"
- " set OpenBIOS nvram variables\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"
- "-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"
-#ifndef _WIN32
- "-chroot dir Chroot to dir just before starting the VM.\n"
- "-runas user Change to user id user just before starting the VM.\n"
-#endif
+#define DEF(option, opt_arg, opt_enum, opt_help) \
+ opt_help
+#define DEFHEADING(text) stringify(text) "\n"
+#include "qemu-options.h"
+#undef DEF
+#undef DEFHEADING
+#undef GEN_DOCS
"\n"
"During emulation, the following keys are useful:\n"
"ctrl-alt-f toggle full screen\n"
@@ -4259,119 +4058,13 @@ static void help(int exitcode)
#define HAS_ARG 0x0001
enum {
- /* Please keep in synch with help, qemu_options[] and
- qemu-doc.texi */
- /* Standard options: */
- QEMU_OPTION_h,
- QEMU_OPTION_M,
- QEMU_OPTION_cpu,
- QEMU_OPTION_smp,
- QEMU_OPTION_fda,
- QEMU_OPTION_fdb,
- QEMU_OPTION_hda,
- QEMU_OPTION_hdb,
- QEMU_OPTION_hdc,
- QEMU_OPTION_hdd,
- QEMU_OPTION_cdrom,
- QEMU_OPTION_drive,
- QEMU_OPTION_mtdblock,
- QEMU_OPTION_sd,
- QEMU_OPTION_pflash,
- QEMU_OPTION_boot,
- QEMU_OPTION_snapshot,
- QEMU_OPTION_m,
- QEMU_OPTION_k,
- QEMU_OPTION_audio_help,
- QEMU_OPTION_soundhw,
- QEMU_OPTION_usb,
- QEMU_OPTION_usbdevice,
- QEMU_OPTION_name,
- QEMU_OPTION_uuid,
-
- /* Display options: */
- QEMU_OPTION_nographic,
- QEMU_OPTION_curses,
- QEMU_OPTION_no_frame,
- QEMU_OPTION_alt_grab,
- QEMU_OPTION_no_quit,
- QEMU_OPTION_sdl,
- QEMU_OPTION_portrait,
- QEMU_OPTION_vga,
- QEMU_OPTION_full_screen,
- QEMU_OPTION_g,
- QEMU_OPTION_vnc,
-
- /* Network options: */
- QEMU_OPTION_net,
- QEMU_OPTION_tftp,
- QEMU_OPTION_bootp,
- QEMU_OPTION_smb,
- QEMU_OPTION_redir,
- QEMU_OPTION_bt,
-
- /* i386 target only: */
- QEMU_OPTION_win2k_hack,
- QEMU_OPTION_rtc_td_hack,
- QEMU_OPTION_no_fd_bootchk,
- QEMU_OPTION_no_acpi,
- QEMU_OPTION_no_hpet,
- QEMU_OPTION_acpitable,
-
- /* Linux boot specific: */
- QEMU_OPTION_kernel,
- QEMU_OPTION_append,
- QEMU_OPTION_initrd,
-
- /* Debug/Expert options: */
- QEMU_OPTION_serial,
- QEMU_OPTION_parallel,
- QEMU_OPTION_monitor,
- QEMU_OPTION_pidfile,
- QEMU_OPTION_S,
- QEMU_OPTION_s,
- QEMU_OPTION_p,
- QEMU_OPTION_d,
- QEMU_OPTION_hdachs,
- QEMU_OPTION_L,
- QEMU_OPTION_bios,
- QEMU_OPTION_kernel_kqemu,
- QEMU_OPTION_no_kqemu,
- QEMU_OPTION_enable_kvm,
- QEMU_OPTION_enable_nesting,
- QEMU_OPTION_no_kvm,
- QEMU_OPTION_no_kvm_irqchip,
- QEMU_OPTION_no_kvm_pit,
- QEMU_OPTION_no_kvm_pit_reinjection,
-#if defined(TARGET_I386) || defined(TARGET_X86_64) || defined(TARGET_IA64) || defined(__linux__)
- QEMU_OPTION_pcidevice,
-#endif
- QEMU_OPTION_no_reboot,
- QEMU_OPTION_no_shutdown,
- QEMU_OPTION_loadvm,
- QEMU_OPTION_daemonize,
- QEMU_OPTION_option_rom,
- QEMU_OPTION_cpu_vendor,
- QEMU_OPTION_nvram,
- QEMU_OPTION_prom_env,
- QEMU_OPTION_clock,
- QEMU_OPTION_localtime,
- QEMU_OPTION_startdate,
- QEMU_OPTION_icount,
- QEMU_OPTION_echr,
- QEMU_OPTION_virtiocon,
- QEMU_OPTION_show_cursor,
- QEMU_OPTION_semihosting,
- QEMU_OPTION_old_param,
- QEMU_OPTION_tb_size,
- QEMU_OPTION_incoming,
- QEMU_OPTION_chroot,
- QEMU_OPTION_runas,
- QEMU_OPTION_tdf,
- QEMU_OPTION_kvm_shadow_memory,
- QEMU_OPTION_mempath,
-#ifdef MAP_POPULATE
- QEMU_OPTION_mem_prealloc,
-#endif
+#define DEF(option, opt_arg, opt_enum, opt_help) \
+ opt_enum,
+#define DEFHEADING(text)
+#include "qemu-options.h"
+#undef DEF
+#undef DEFHEADING
+#undef GEN_DOCS
};
typedef struct QEMUOption {
@@ -4381,149 +4074,14 @@ typedef struct QEMUOption {
} QEMUOption;
static const QEMUOption qemu_options[] = {
- /* Please keep in synch with help, QEMU_OPTION_ enums, and
- qemu-doc.texi */
- /* Standard options: */
{ "h", 0, QEMU_OPTION_h },
- { "help", 0, QEMU_OPTION_h },
- { "M", HAS_ARG, QEMU_OPTION_M },
- { "cpu", HAS_ARG, QEMU_OPTION_cpu },
- { "smp", HAS_ARG, QEMU_OPTION_smp },
- { "fda", HAS_ARG, QEMU_OPTION_fda },
- { "fdb", HAS_ARG, QEMU_OPTION_fdb },
- { "hda", HAS_ARG, QEMU_OPTION_hda },
- { "hdb", HAS_ARG, QEMU_OPTION_hdb },
- { "hdc", HAS_ARG, QEMU_OPTION_hdc },
- { "hdd", HAS_ARG, QEMU_OPTION_hdd },
- { "cdrom", HAS_ARG, QEMU_OPTION_cdrom },
- { "drive", HAS_ARG, QEMU_OPTION_drive },
- { "mtdblock", HAS_ARG, QEMU_OPTION_mtdblock },
- { "sd", HAS_ARG, QEMU_OPTION_sd },
- { "pflash", HAS_ARG, QEMU_OPTION_pflash },
- { "boot", HAS_ARG, QEMU_OPTION_boot },
- { "snapshot", 0, QEMU_OPTION_snapshot },
- { "m", HAS_ARG, QEMU_OPTION_m },
-#ifndef _WIN32
- { "k", HAS_ARG, QEMU_OPTION_k },
-#endif
-#ifdef HAS_AUDIO
- { "audio-help", 0, QEMU_OPTION_audio_help },
- { "soundhw", HAS_ARG, QEMU_OPTION_soundhw },
-#endif
- { "usb", 0, QEMU_OPTION_usb },
- { "usbdevice", HAS_ARG, QEMU_OPTION_usbdevice },
- { "name", HAS_ARG, QEMU_OPTION_name },
- { "uuid", HAS_ARG, QEMU_OPTION_uuid },
-
- /* Display options: */
- { "nographic", 0, QEMU_OPTION_nographic },
-#ifdef CONFIG_CURSES
- { "curses", 0, QEMU_OPTION_curses },
-#endif
-#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
- { "portrait", 0, QEMU_OPTION_portrait },
- { "vga", HAS_ARG, QEMU_OPTION_vga },
- { "full-screen", 0, QEMU_OPTION_full_screen },
-#if defined(TARGET_PPC) || defined(TARGET_SPARC)
- { "g", 1, QEMU_OPTION_g },
-#endif
- { "vnc", HAS_ARG, QEMU_OPTION_vnc },
-
- /* Network options: */
- { "net", HAS_ARG, QEMU_OPTION_net},
-#ifdef CONFIG_SLIRP
- { "tftp", HAS_ARG, QEMU_OPTION_tftp },
- { "bootp", HAS_ARG, QEMU_OPTION_bootp },
-#ifndef _WIN32
- { "smb", HAS_ARG, QEMU_OPTION_smb },
-#endif
- { "redir", HAS_ARG, QEMU_OPTION_redir },
-#endif
- { "bt", HAS_ARG, QEMU_OPTION_bt },
-#ifdef TARGET_I386
- /* i386 target only: */
- { "win2k-hack", 0, QEMU_OPTION_win2k_hack },
- { "rtc-td-hack", 0, QEMU_OPTION_rtc_td_hack },
- { "no-fd-bootchk", 0, QEMU_OPTION_no_fd_bootchk },
- { "no-acpi", 0, QEMU_OPTION_no_acpi },
- { "no-hpet", 0, QEMU_OPTION_no_hpet },
- { "acpitable", HAS_ARG, QEMU_OPTION_acpitable },
-#endif
-
- /* Linux boot specific: */
- { "kernel", HAS_ARG, QEMU_OPTION_kernel },
- { "append", HAS_ARG, QEMU_OPTION_append },
- { "initrd", HAS_ARG, QEMU_OPTION_initrd },
-
- /* Debug/Expert options: */
- { "serial", HAS_ARG, QEMU_OPTION_serial },
- { "parallel", HAS_ARG, QEMU_OPTION_parallel },
- { "monitor", HAS_ARG, QEMU_OPTION_monitor },
- { "pidfile", HAS_ARG, QEMU_OPTION_pidfile },
- { "S", 0, QEMU_OPTION_S },
- { "s", 0, QEMU_OPTION_s },
- { "p", HAS_ARG, QEMU_OPTION_p },
- { "d", HAS_ARG, QEMU_OPTION_d },
- { "hdachs", HAS_ARG, QEMU_OPTION_hdachs },
- { "L", HAS_ARG, QEMU_OPTION_L },
- { "bios", HAS_ARG, QEMU_OPTION_bios },
-#ifdef USE_KQEMU
- { "kernel-kqemu", 0, QEMU_OPTION_kernel_kqemu },
- { "no-kqemu", 0, QEMU_OPTION_no_kqemu },
-#endif
-#ifdef CONFIG_KVM
- { "enable-kvm", 0, QEMU_OPTION_enable_kvm },
-#endif
-#ifdef USE_KVM
-#ifndef NO_CPU_EMULATION
- { "no-kvm", 0, QEMU_OPTION_no_kvm },
-#endif
- { "no-kvm-irqchip", 0, QEMU_OPTION_no_kvm_irqchip },
- { "no-kvm-pit", 0, QEMU_OPTION_no_kvm_pit },
- { "no-kvm-pit-reinjection", 0, QEMU_OPTION_no_kvm_pit_reinjection },
- { "enable-nesting", 0, QEMU_OPTION_enable_nesting },
-#if defined(TARGET_I386) || defined(TARGET_X86_64) || defined(TARGET_IA64) || defined(__linux__)
- { "pcidevice", HAS_ARG, QEMU_OPTION_pcidevice },
-#endif
-#endif
- { "no-reboot", 0, QEMU_OPTION_no_reboot },
- { "no-shutdown", 0, QEMU_OPTION_no_shutdown },
- { "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
- { "tdf", 0, QEMU_OPTION_tdf }, /* enable time drift fix */
- { "kvm-shadow-memory", HAS_ARG, QEMU_OPTION_kvm_shadow_memory },
- { "nvram", HAS_ARG, QEMU_OPTION_nvram },
- { "cpu-vendor", HAS_ARG, QEMU_OPTION_cpu_vendor },
-#if defined(TARGET_ARM)
- { "old-param", 0, QEMU_OPTION_old_param },
-#endif
- { "tb-size", HAS_ARG, QEMU_OPTION_tb_size },
- { "incoming", HAS_ARG, QEMU_OPTION_incoming },
- { "chroot", HAS_ARG, QEMU_OPTION_chroot },
- { "runas", HAS_ARG, QEMU_OPTION_runas },
- { "mem-path", HAS_ARG, QEMU_OPTION_mempath },
-#ifdef MAP_POPULATE
- { "mem-prealloc", 0, QEMU_OPTION_mem_prealloc },
-#endif
+#define DEF(option, opt_arg, opt_enum, opt_help) \
+ { option, opt_arg, opt_enum },
+#define DEFHEADING(text)
+#include "qemu-options.h"
+#undef DEF
+#undef DEFHEADING
+#undef GEN_DOCS
{ NULL },
};
@@ -5308,15 +4866,18 @@ int main(int argc, char **argv, char **envp)
case QEMU_OPTION_S:
autostart = 0;
break;
+#ifndef _WIN32
case QEMU_OPTION_k:
keyboard_layout = optarg;
break;
+#endif
case QEMU_OPTION_localtime:
rtc_utc = 0;
break;
case QEMU_OPTION_vga:
select_vgahw (optarg);
break;
+#if defined(TARGET_PPC) || defined(TARGET_SPARC)
case QEMU_OPTION_g:
{
const char *p;
@@ -5351,6 +4912,7 @@ int main(int argc, char **argv, char **envp)
graphic_depth = depth;
}
break;
+#endif
case QEMU_OPTION_echr:
{
char *r;
@@ -5493,12 +5055,14 @@ int main(int argc, char **argv, char **envp)
case QEMU_OPTION_vnc:
vnc_display = optarg;
break;
+#ifdef TARGET_I386
case QEMU_OPTION_no_acpi:
acpi_enabled = 0;
break;
case QEMU_OPTION_no_hpet:
no_hpet = 1;
break;
+#endif
case QEMU_OPTION_no_reboot:
no_reboot = 1;
break;
@@ -5515,9 +5079,11 @@ int main(int argc, char **argv, char **envp)
exit(1);
}
break;
+#ifndef _WIN32
case QEMU_OPTION_daemonize:
daemonize = 1;
break;
+#endif
case QEMU_OPTION_option_rom:
if (nb_option_roms >= MAX_OPTION_ROMS) {
fprintf(stderr, "Too many option ROMs\n");
@@ -5526,9 +5092,11 @@ int main(int argc, char **argv, char **envp)
option_rom[nb_option_roms] = optarg;
nb_option_roms++;
break;
+#if defined(TARGET_ARM) || defined(TARGET_M68K)
case QEMU_OPTION_semihosting:
semihosting_enabled = 1;
break;
+#endif
case QEMU_OPTION_tdf:
time_drift_fix = 1;
break;
@@ -5621,14 +5189,17 @@ int main(int argc, char **argv, char **envp)
case QEMU_OPTION_incoming:
incoming = optarg;
break;
+#ifndef _WIN32
case QEMU_OPTION_chroot:
chroot_dir = optarg;
break;
case QEMU_OPTION_runas:
run_as = optarg;
+ break;
case QEMU_OPTION_nvram:
nvram = optarg;
break;
+#endif
}
}
}
@@ -5732,10 +5303,6 @@ int main(int argc, char **argv, char **envp)
linux_boot = (kernel_filename != NULL);
net_boot = (boot_devices_bitmap >> ('n' - 'a')) & 0xF;
- if (!linux_boot && net_boot == 0 &&
- !machine->nodisk_ok && nb_drives_opt == 0)
- help(1);
-
if (!linux_boot && *kernel_cmdline != '\0') {
fprintf(stderr, "-append only allowed with -kernel option\n");
exit(1);