2009-07-31 12:25:35 +02:00
|
|
|
#include "qemu-common.h"
|
2012-12-17 18:20:00 +01:00
|
|
|
#include "qemu/error-report.h"
|
|
|
|
#include "qemu/option.h"
|
|
|
|
#include "qemu/config-file.h"
|
2009-12-08 13:11:34 +01:00
|
|
|
#include "hw/qdev.h"
|
2012-12-17 18:19:43 +01:00
|
|
|
#include "qapi/error.h"
|
2009-07-31 12:25:35 +02:00
|
|
|
|
2010-08-20 13:52:01 +02:00
|
|
|
static QemuOptsList qemu_drive_opts = {
|
2009-07-31 12:25:35 +02:00
|
|
|
.name = "drive",
|
2009-09-12 09:36:22 +02:00
|
|
|
.head = QTAILQ_HEAD_INITIALIZER(qemu_drive_opts.head),
|
2009-07-31 12:25:35 +02:00
|
|
|
.desc = {
|
|
|
|
{
|
|
|
|
.name = "bus",
|
|
|
|
.type = QEMU_OPT_NUMBER,
|
|
|
|
.help = "bus number",
|
|
|
|
},{
|
|
|
|
.name = "unit",
|
|
|
|
.type = QEMU_OPT_NUMBER,
|
|
|
|
.help = "unit number (i.e. lun for scsi)",
|
|
|
|
},{
|
|
|
|
.name = "if",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "interface (ide, scsi, sd, mtd, floppy, pflash, virtio)",
|
|
|
|
},{
|
|
|
|
.name = "index",
|
|
|
|
.type = QEMU_OPT_NUMBER,
|
2011-07-12 22:35:09 +02:00
|
|
|
.help = "index number",
|
2009-07-31 12:25:35 +02:00
|
|
|
},{
|
|
|
|
.name = "cyls",
|
|
|
|
.type = QEMU_OPT_NUMBER,
|
|
|
|
.help = "number of cylinders (ide disk geometry)",
|
|
|
|
},{
|
|
|
|
.name = "heads",
|
|
|
|
.type = QEMU_OPT_NUMBER,
|
|
|
|
.help = "number of heads (ide disk geometry)",
|
|
|
|
},{
|
|
|
|
.name = "secs",
|
|
|
|
.type = QEMU_OPT_NUMBER,
|
|
|
|
.help = "number of sectors (ide disk geometry)",
|
|
|
|
},{
|
|
|
|
.name = "trans",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "chs translation (auto, lba. none)",
|
|
|
|
},{
|
|
|
|
.name = "media",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "media type (disk, cdrom)",
|
|
|
|
},{
|
|
|
|
.name = "snapshot",
|
|
|
|
.type = QEMU_OPT_BOOL,
|
2011-07-12 22:35:09 +02:00
|
|
|
.help = "enable/disable snapshot mode",
|
2009-07-31 12:25:35 +02:00
|
|
|
},{
|
|
|
|
.name = "file",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "disk image",
|
|
|
|
},{
|
|
|
|
.name = "cache",
|
|
|
|
.type = QEMU_OPT_STRING,
|
2011-08-04 13:26:52 +02:00
|
|
|
.help = "host cache usage (none, writeback, writethrough, "
|
|
|
|
"directsync, unsafe)",
|
2009-08-20 16:58:35 +02:00
|
|
|
},{
|
|
|
|
.name = "aio",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "host AIO implementation (threads, native)",
|
2009-07-31 12:25:35 +02:00
|
|
|
},{
|
|
|
|
.name = "format",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "disk format (raw, qcow2, ...)",
|
|
|
|
},{
|
|
|
|
.name = "serial",
|
|
|
|
.type = QEMU_OPT_STRING,
|
2011-07-12 22:35:09 +02:00
|
|
|
.help = "disk serial number",
|
2009-11-27 13:25:37 +01:00
|
|
|
},{
|
|
|
|
.name = "rerror",
|
|
|
|
.type = QEMU_OPT_STRING,
|
2011-07-12 22:35:09 +02:00
|
|
|
.help = "read error action",
|
2009-07-31 12:25:35 +02:00
|
|
|
},{
|
|
|
|
.name = "werror",
|
|
|
|
.type = QEMU_OPT_STRING,
|
2011-07-12 22:35:09 +02:00
|
|
|
.help = "write error action",
|
2009-07-31 12:25:35 +02:00
|
|
|
},{
|
|
|
|
.name = "addr",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "pci address (virtio only)",
|
2009-10-26 15:25:16 +01:00
|
|
|
},{
|
|
|
|
.name = "readonly",
|
|
|
|
.type = QEMU_OPT_BOOL,
|
2011-07-12 22:35:09 +02:00
|
|
|
.help = "open drive file as read-only",
|
2011-11-03 09:57:25 +01:00
|
|
|
},{
|
|
|
|
.name = "iops",
|
|
|
|
.type = QEMU_OPT_NUMBER,
|
|
|
|
.help = "limit total I/O operations per second",
|
|
|
|
},{
|
|
|
|
.name = "iops_rd",
|
|
|
|
.type = QEMU_OPT_NUMBER,
|
|
|
|
.help = "limit read operations per second",
|
|
|
|
},{
|
|
|
|
.name = "iops_wr",
|
|
|
|
.type = QEMU_OPT_NUMBER,
|
|
|
|
.help = "limit write operations per second",
|
|
|
|
},{
|
|
|
|
.name = "bps",
|
|
|
|
.type = QEMU_OPT_NUMBER,
|
|
|
|
.help = "limit total bytes per second",
|
|
|
|
},{
|
|
|
|
.name = "bps_rd",
|
|
|
|
.type = QEMU_OPT_NUMBER,
|
|
|
|
.help = "limit read bytes per second",
|
|
|
|
},{
|
|
|
|
.name = "bps_wr",
|
|
|
|
.type = QEMU_OPT_NUMBER,
|
|
|
|
.help = "limit write bytes per second",
|
2011-11-17 14:40:32 +01:00
|
|
|
},{
|
|
|
|
.name = "copy-on-read",
|
|
|
|
.type = QEMU_OPT_BOOL,
|
|
|
|
.help = "copy read data from backing file into image file",
|
2012-10-05 19:51:43 +02:00
|
|
|
},{
|
|
|
|
.name = "boot",
|
|
|
|
.type = QEMU_OPT_BOOL,
|
|
|
|
.help = "(deprecated, ignored)",
|
2009-07-31 12:25:35 +02:00
|
|
|
},
|
2010-08-31 09:30:35 +02:00
|
|
|
{ /* end of list */ }
|
2009-07-31 12:25:35 +02:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2012-01-25 23:39:02 +01:00
|
|
|
static QemuOptsList qemu_iscsi_opts = {
|
|
|
|
.name = "iscsi",
|
|
|
|
.head = QTAILQ_HEAD_INITIALIZER(qemu_iscsi_opts.head),
|
|
|
|
.desc = {
|
|
|
|
{
|
|
|
|
.name = "user",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "username for CHAP authentication to target",
|
|
|
|
},{
|
|
|
|
.name = "password",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "password for CHAP authentication to target",
|
|
|
|
},{
|
|
|
|
.name = "header-digest",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "HeaderDigest setting. "
|
|
|
|
"{CRC32C|CRC32C-NONE|NONE-CRC32C|NONE}",
|
|
|
|
},{
|
|
|
|
.name = "initiator-name",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "Initiator iqn name to use when connecting",
|
|
|
|
},
|
|
|
|
{ /* end of list */ }
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2010-08-20 13:52:01 +02:00
|
|
|
static QemuOptsList qemu_chardev_opts = {
|
2009-09-10 10:58:35 +02:00
|
|
|
.name = "chardev",
|
2010-02-10 19:52:18 +01:00
|
|
|
.implied_opt_name = "backend",
|
2009-09-12 09:36:22 +02:00
|
|
|
.head = QTAILQ_HEAD_INITIALIZER(qemu_chardev_opts.head),
|
2009-09-10 10:58:35 +02:00
|
|
|
.desc = {
|
2009-09-10 10:58:36 +02:00
|
|
|
{
|
|
|
|
.name = "backend",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
},{
|
|
|
|
.name = "path",
|
|
|
|
.type = QEMU_OPT_STRING,
|
2009-09-10 10:58:42 +02:00
|
|
|
},{
|
|
|
|
.name = "host",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
},{
|
|
|
|
.name = "port",
|
|
|
|
.type = QEMU_OPT_STRING,
|
2009-09-10 10:58:51 +02:00
|
|
|
},{
|
|
|
|
.name = "localaddr",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
},{
|
|
|
|
.name = "localport",
|
|
|
|
.type = QEMU_OPT_STRING,
|
2009-09-10 10:58:42 +02:00
|
|
|
},{
|
|
|
|
.name = "to",
|
|
|
|
.type = QEMU_OPT_NUMBER,
|
|
|
|
},{
|
|
|
|
.name = "ipv4",
|
|
|
|
.type = QEMU_OPT_BOOL,
|
|
|
|
},{
|
|
|
|
.name = "ipv6",
|
|
|
|
.type = QEMU_OPT_BOOL,
|
|
|
|
},{
|
|
|
|
.name = "wait",
|
|
|
|
.type = QEMU_OPT_BOOL,
|
|
|
|
},{
|
|
|
|
.name = "server",
|
|
|
|
.type = QEMU_OPT_BOOL,
|
|
|
|
},{
|
|
|
|
.name = "delay",
|
|
|
|
.type = QEMU_OPT_BOOL,
|
|
|
|
},{
|
|
|
|
.name = "telnet",
|
|
|
|
.type = QEMU_OPT_BOOL,
|
2009-09-10 10:58:49 +02:00
|
|
|
},{
|
|
|
|
.name = "width",
|
|
|
|
.type = QEMU_OPT_NUMBER,
|
|
|
|
},{
|
|
|
|
.name = "height",
|
|
|
|
.type = QEMU_OPT_NUMBER,
|
|
|
|
},{
|
|
|
|
.name = "cols",
|
|
|
|
.type = QEMU_OPT_NUMBER,
|
|
|
|
},{
|
|
|
|
.name = "rows",
|
|
|
|
.type = QEMU_OPT_NUMBER,
|
2009-09-10 10:58:52 +02:00
|
|
|
},{
|
|
|
|
.name = "mux",
|
|
|
|
.type = QEMU_OPT_BOOL,
|
2009-10-16 15:31:38 +02:00
|
|
|
},{
|
|
|
|
.name = "signal",
|
|
|
|
.type = QEMU_OPT_BOOL,
|
2011-01-19 09:49:50 +01:00
|
|
|
},{
|
|
|
|
.name = "name",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
},{
|
|
|
|
.name = "debug",
|
|
|
|
.type = QEMU_OPT_NUMBER,
|
2009-09-10 10:58:36 +02:00
|
|
|
},
|
2010-08-31 09:30:35 +02:00
|
|
|
{ /* end of list */ }
|
2009-09-10 10:58:35 +02:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2010-04-29 14:14:43 +02:00
|
|
|
QemuOptsList qemu_fsdev_opts = {
|
|
|
|
.name = "fsdev",
|
2011-10-13 08:58:04 +02:00
|
|
|
.implied_opt_name = "fsdriver",
|
2010-04-29 14:14:43 +02:00
|
|
|
.head = QTAILQ_HEAD_INITIALIZER(qemu_fsdev_opts.head),
|
|
|
|
.desc = {
|
|
|
|
{
|
2011-10-13 08:58:04 +02:00
|
|
|
.name = "fsdriver",
|
2010-04-29 14:14:43 +02:00
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
}, {
|
|
|
|
.name = "path",
|
|
|
|
.type = QEMU_OPT_STRING,
|
2010-06-14 22:34:40 +02:00
|
|
|
}, {
|
|
|
|
.name = "security_model",
|
|
|
|
.type = QEMU_OPT_STRING,
|
2011-10-12 15:41:23 +02:00
|
|
|
}, {
|
|
|
|
.name = "writeout",
|
|
|
|
.type = QEMU_OPT_STRING,
|
2011-10-25 08:40:39 +02:00
|
|
|
}, {
|
|
|
|
.name = "readonly",
|
|
|
|
.type = QEMU_OPT_BOOL,
|
2011-12-14 09:28:47 +01:00
|
|
|
|
|
|
|
}, {
|
|
|
|
.name = "socket",
|
|
|
|
.type = QEMU_OPT_STRING,
|
2011-12-14 09:19:28 +01:00
|
|
|
}, {
|
|
|
|
.name = "sock_fd",
|
|
|
|
.type = QEMU_OPT_NUMBER,
|
2010-04-29 14:14:43 +02:00
|
|
|
},
|
2011-10-25 08:40:39 +02:00
|
|
|
|
2010-04-29 14:14:43 +02:00
|
|
|
{ /*End of list */ }
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
virtio-9p: Create a syntactic shortcut for the file-system pass-thru
Currently the commandline to create a virtual-filesystem pass-through between
the guest and the host is as follows:
#qemu -fsdev fstype,id=ID,path=path/to/share \
-device virtio-9p-pci,fsdev=ID,mount_tag=tag \
This patch provides a syntactic short-cut to achieve the same as follows:
#qemu -virtfs fstype,path=path/to/share,mount_tag=tag
This will be internally expanded as:
#qemu -fsdev fstype,id=tag,path=path/to/share, \
-device virtio-9p-pci,fsdev=tag,mount_tag=tag \
Signed-off-by: Gautham R Shenoy <ego@in.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-04-29 14:15:03 +02:00
|
|
|
QemuOptsList qemu_virtfs_opts = {
|
|
|
|
.name = "virtfs",
|
2011-10-13 08:58:04 +02:00
|
|
|
.implied_opt_name = "fsdriver",
|
virtio-9p: Create a syntactic shortcut for the file-system pass-thru
Currently the commandline to create a virtual-filesystem pass-through between
the guest and the host is as follows:
#qemu -fsdev fstype,id=ID,path=path/to/share \
-device virtio-9p-pci,fsdev=ID,mount_tag=tag \
This patch provides a syntactic short-cut to achieve the same as follows:
#qemu -virtfs fstype,path=path/to/share,mount_tag=tag
This will be internally expanded as:
#qemu -fsdev fstype,id=tag,path=path/to/share, \
-device virtio-9p-pci,fsdev=tag,mount_tag=tag \
Signed-off-by: Gautham R Shenoy <ego@in.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-04-29 14:15:03 +02:00
|
|
|
.head = QTAILQ_HEAD_INITIALIZER(qemu_virtfs_opts.head),
|
|
|
|
.desc = {
|
|
|
|
{
|
2011-10-13 08:58:04 +02:00
|
|
|
.name = "fsdriver",
|
virtio-9p: Create a syntactic shortcut for the file-system pass-thru
Currently the commandline to create a virtual-filesystem pass-through between
the guest and the host is as follows:
#qemu -fsdev fstype,id=ID,path=path/to/share \
-device virtio-9p-pci,fsdev=ID,mount_tag=tag \
This patch provides a syntactic short-cut to achieve the same as follows:
#qemu -virtfs fstype,path=path/to/share,mount_tag=tag
This will be internally expanded as:
#qemu -fsdev fstype,id=tag,path=path/to/share, \
-device virtio-9p-pci,fsdev=tag,mount_tag=tag \
Signed-off-by: Gautham R Shenoy <ego@in.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-04-29 14:15:03 +02:00
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
}, {
|
|
|
|
.name = "path",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
}, {
|
|
|
|
.name = "mount_tag",
|
|
|
|
.type = QEMU_OPT_STRING,
|
2010-06-14 22:34:40 +02:00
|
|
|
}, {
|
|
|
|
.name = "security_model",
|
|
|
|
.type = QEMU_OPT_STRING,
|
2011-10-12 15:41:23 +02:00
|
|
|
}, {
|
|
|
|
.name = "writeout",
|
|
|
|
.type = QEMU_OPT_STRING,
|
2011-10-25 08:40:39 +02:00
|
|
|
}, {
|
|
|
|
.name = "readonly",
|
|
|
|
.type = QEMU_OPT_BOOL,
|
2011-12-14 09:28:47 +01:00
|
|
|
}, {
|
|
|
|
.name = "socket",
|
|
|
|
.type = QEMU_OPT_STRING,
|
2011-12-14 09:19:28 +01:00
|
|
|
}, {
|
|
|
|
.name = "sock_fd",
|
|
|
|
.type = QEMU_OPT_NUMBER,
|
virtio-9p: Create a syntactic shortcut for the file-system pass-thru
Currently the commandline to create a virtual-filesystem pass-through between
the guest and the host is as follows:
#qemu -fsdev fstype,id=ID,path=path/to/share \
-device virtio-9p-pci,fsdev=ID,mount_tag=tag \
This patch provides a syntactic short-cut to achieve the same as follows:
#qemu -virtfs fstype,path=path/to/share,mount_tag=tag
This will be internally expanded as:
#qemu -fsdev fstype,id=tag,path=path/to/share, \
-device virtio-9p-pci,fsdev=tag,mount_tag=tag \
Signed-off-by: Gautham R Shenoy <ego@in.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-04-29 14:15:03 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
{ /*End of list */ }
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2010-08-20 13:52:01 +02:00
|
|
|
static QemuOptsList qemu_device_opts = {
|
2009-07-31 12:25:37 +02:00
|
|
|
.name = "device",
|
2010-02-10 19:52:18 +01:00
|
|
|
.implied_opt_name = "driver",
|
2009-09-12 09:36:22 +02:00
|
|
|
.head = QTAILQ_HEAD_INITIALIZER(qemu_device_opts.head),
|
2009-07-31 12:25:37 +02:00
|
|
|
.desc = {
|
|
|
|
/*
|
|
|
|
* no elements => accept any
|
|
|
|
* sanity checking will happen later
|
|
|
|
* when setting device properties
|
|
|
|
*/
|
2010-08-31 09:30:35 +02:00
|
|
|
{ /* end of list */ }
|
2009-07-31 12:25:37 +02:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2010-08-20 13:52:01 +02:00
|
|
|
static QemuOptsList qemu_netdev_opts = {
|
2009-10-08 20:58:26 +02:00
|
|
|
.name = "netdev",
|
2010-02-10 19:52:18 +01:00
|
|
|
.implied_opt_name = "type",
|
2009-10-08 20:58:26 +02:00
|
|
|
.head = QTAILQ_HEAD_INITIALIZER(qemu_netdev_opts.head),
|
|
|
|
.desc = {
|
|
|
|
/*
|
|
|
|
* no elements => accept any params
|
|
|
|
* validation will happen later
|
|
|
|
*/
|
|
|
|
{ /* end of list */ }
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2010-08-20 13:52:01 +02:00
|
|
|
static QemuOptsList qemu_net_opts = {
|
2009-10-06 13:17:05 +02:00
|
|
|
.name = "net",
|
2010-02-10 19:52:18 +01:00
|
|
|
.implied_opt_name = "type",
|
2009-10-06 13:17:05 +02:00
|
|
|
.head = QTAILQ_HEAD_INITIALIZER(qemu_net_opts.head),
|
|
|
|
.desc = {
|
|
|
|
/*
|
|
|
|
* no elements => accept any params
|
|
|
|
* validation will happen later
|
|
|
|
*/
|
|
|
|
{ /* end of list */ }
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2010-08-20 13:52:01 +02:00
|
|
|
static QemuOptsList qemu_rtc_opts = {
|
2009-09-15 13:36:04 +02:00
|
|
|
.name = "rtc",
|
|
|
|
.head = QTAILQ_HEAD_INITIALIZER(qemu_rtc_opts.head),
|
|
|
|
.desc = {
|
|
|
|
{
|
|
|
|
.name = "base",
|
|
|
|
.type = QEMU_OPT_STRING,
|
2009-09-15 13:36:04 +02:00
|
|
|
},{
|
|
|
|
.name = "clock",
|
|
|
|
.type = QEMU_OPT_STRING,
|
2009-09-15 13:36:04 +02:00
|
|
|
},{
|
|
|
|
.name = "driftfix",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
},
|
2010-08-31 09:30:35 +02:00
|
|
|
{ /* end of list */ }
|
2009-09-15 13:36:04 +02:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2010-08-20 13:52:01 +02:00
|
|
|
static QemuOptsList qemu_global_opts = {
|
2009-12-08 13:11:34 +01:00
|
|
|
.name = "global",
|
|
|
|
.head = QTAILQ_HEAD_INITIALIZER(qemu_global_opts.head),
|
|
|
|
.desc = {
|
|
|
|
{
|
|
|
|
.name = "driver",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
},{
|
|
|
|
.name = "property",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
},{
|
|
|
|
.name = "value",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
},
|
2010-08-31 09:30:35 +02:00
|
|
|
{ /* end of list */ }
|
2009-12-08 13:11:34 +01:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2012-08-14 23:44:08 +02:00
|
|
|
QemuOptsList qemu_sandbox_opts = {
|
|
|
|
.name = "sandbox",
|
|
|
|
.implied_opt_name = "enable",
|
|
|
|
.head = QTAILQ_HEAD_INITIALIZER(qemu_sandbox_opts.head),
|
|
|
|
.desc = {
|
|
|
|
{
|
|
|
|
.name = "enable",
|
|
|
|
.type = QEMU_OPT_BOOL,
|
|
|
|
},
|
|
|
|
{ /* end of list */ }
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2010-08-20 13:52:01 +02:00
|
|
|
static QemuOptsList qemu_mon_opts = {
|
2009-12-08 13:11:50 +01:00
|
|
|
.name = "mon",
|
2010-02-10 19:52:18 +01:00
|
|
|
.implied_opt_name = "chardev",
|
2009-12-08 13:11:50 +01:00
|
|
|
.head = QTAILQ_HEAD_INITIALIZER(qemu_mon_opts.head),
|
|
|
|
.desc = {
|
|
|
|
{
|
|
|
|
.name = "mode",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
},{
|
|
|
|
.name = "chardev",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
},{
|
|
|
|
.name = "default",
|
|
|
|
.type = QEMU_OPT_BOOL,
|
2010-06-07 16:42:31 +02:00
|
|
|
},{
|
|
|
|
.name = "pretty",
|
|
|
|
.type = QEMU_OPT_BOOL,
|
2009-12-08 13:11:50 +01:00
|
|
|
},
|
2010-08-31 09:30:35 +02:00
|
|
|
{ /* end of list */ }
|
2009-12-08 13:11:50 +01:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2010-08-09 12:48:32 +02:00
|
|
|
static QemuOptsList qemu_trace_opts = {
|
|
|
|
.name = "trace",
|
|
|
|
.implied_opt_name = "trace",
|
|
|
|
.head = QTAILQ_HEAD_INITIALIZER(qemu_trace_opts.head),
|
|
|
|
.desc = {
|
|
|
|
{
|
2011-08-31 20:31:31 +02:00
|
|
|
.name = "events",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
},{
|
2010-08-09 12:48:32 +02:00
|
|
|
.name = "file",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
},
|
2011-05-17 10:40:43 +02:00
|
|
|
{ /* end of list */ }
|
2010-08-09 12:48:32 +02:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2010-03-11 15:13:27 +01:00
|
|
|
QemuOptsList qemu_spice_opts = {
|
|
|
|
.name = "spice",
|
|
|
|
.head = QTAILQ_HEAD_INITIALIZER(qemu_spice_opts.head),
|
|
|
|
.desc = {
|
|
|
|
{
|
|
|
|
.name = "port",
|
|
|
|
.type = QEMU_OPT_NUMBER,
|
2010-03-11 15:13:32 +01:00
|
|
|
},{
|
|
|
|
.name = "tls-port",
|
|
|
|
.type = QEMU_OPT_NUMBER,
|
2010-08-27 14:29:16 +02:00
|
|
|
},{
|
|
|
|
.name = "addr",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
},{
|
|
|
|
.name = "ipv4",
|
|
|
|
.type = QEMU_OPT_BOOL,
|
|
|
|
},{
|
|
|
|
.name = "ipv6",
|
|
|
|
.type = QEMU_OPT_BOOL,
|
2010-03-11 15:13:27 +01:00
|
|
|
},{
|
|
|
|
.name = "password",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
},{
|
|
|
|
.name = "disable-ticketing",
|
|
|
|
.type = QEMU_OPT_BOOL,
|
2011-03-27 16:43:54 +02:00
|
|
|
},{
|
|
|
|
.name = "disable-copy-paste",
|
|
|
|
.type = QEMU_OPT_BOOL,
|
2011-05-17 10:40:33 +02:00
|
|
|
},{
|
|
|
|
.name = "sasl",
|
|
|
|
.type = QEMU_OPT_BOOL,
|
2010-03-11 15:13:32 +01:00
|
|
|
},{
|
|
|
|
.name = "x509-dir",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
},{
|
|
|
|
.name = "x509-key-file",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
},{
|
|
|
|
.name = "x509-key-password",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
},{
|
|
|
|
.name = "x509-cert-file",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
},{
|
|
|
|
.name = "x509-cacert-file",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
},{
|
|
|
|
.name = "x509-dh-key-file",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
},{
|
|
|
|
.name = "tls-ciphers",
|
|
|
|
.type = QEMU_OPT_STRING,
|
2010-08-27 14:09:56 +02:00
|
|
|
},{
|
|
|
|
.name = "tls-channel",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
},{
|
|
|
|
.name = "plaintext-channel",
|
|
|
|
.type = QEMU_OPT_STRING,
|
2010-07-14 12:26:34 +02:00
|
|
|
},{
|
|
|
|
.name = "image-compression",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
},{
|
|
|
|
.name = "jpeg-wan-compression",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
},{
|
|
|
|
.name = "zlib-glz-wan-compression",
|
|
|
|
.type = QEMU_OPT_STRING,
|
2010-08-30 16:36:53 +02:00
|
|
|
},{
|
|
|
|
.name = "streaming-video",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
},{
|
|
|
|
.name = "agent-mouse",
|
|
|
|
.type = QEMU_OPT_BOOL,
|
|
|
|
},{
|
|
|
|
.name = "playback-compression",
|
|
|
|
.type = QEMU_OPT_BOOL,
|
2012-08-21 10:51:59 +02:00
|
|
|
}, {
|
|
|
|
.name = "seamless-migration",
|
|
|
|
.type = QEMU_OPT_BOOL,
|
2010-03-11 15:13:27 +01:00
|
|
|
},
|
2011-05-17 10:40:43 +02:00
|
|
|
{ /* end of list */ }
|
2010-03-11 15:13:27 +01:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2010-12-08 12:35:07 +01:00
|
|
|
QemuOptsList qemu_option_rom_opts = {
|
|
|
|
.name = "option-rom",
|
|
|
|
.implied_opt_name = "romfile",
|
|
|
|
.head = QTAILQ_HEAD_INITIALIZER(qemu_option_rom_opts.head),
|
|
|
|
.desc = {
|
|
|
|
{
|
|
|
|
.name = "bootindex",
|
|
|
|
.type = QEMU_OPT_NUMBER,
|
|
|
|
}, {
|
|
|
|
.name = "romfile",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
},
|
2011-05-17 10:40:43 +02:00
|
|
|
{ /* end of list */ }
|
2010-12-08 12:35:07 +01:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2010-09-21 21:05:31 +02:00
|
|
|
static QemuOptsList qemu_machine_opts = {
|
|
|
|
.name = "machine",
|
2011-07-23 12:38:37 +02:00
|
|
|
.implied_opt_name = "type",
|
2012-02-08 06:41:38 +01:00
|
|
|
.merge_lists = true,
|
2010-09-21 21:05:31 +02:00
|
|
|
.head = QTAILQ_HEAD_INITIALIZER(qemu_machine_opts.head),
|
|
|
|
.desc = {
|
|
|
|
{
|
2011-07-23 12:38:37 +02:00
|
|
|
.name = "type",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "emulated machine"
|
|
|
|
}, {
|
2010-09-21 21:05:31 +02:00
|
|
|
.name = "accel",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "accelerator list",
|
2011-10-15 13:43:48 +02:00
|
|
|
}, {
|
|
|
|
.name = "kernel_irqchip",
|
|
|
|
.type = QEMU_OPT_BOOL,
|
|
|
|
.help = "use KVM in-kernel irqchip",
|
2012-01-25 18:14:15 +01:00
|
|
|
}, {
|
|
|
|
.name = "kvm_shadow_mem",
|
|
|
|
.type = QEMU_OPT_SIZE,
|
|
|
|
.help = "KVM shadow MMU size",
|
2012-02-08 06:41:39 +01:00
|
|
|
}, {
|
|
|
|
.name = "kernel",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "Linux kernel image file",
|
|
|
|
}, {
|
|
|
|
.name = "initrd",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "Linux initial ramdisk file",
|
|
|
|
}, {
|
|
|
|
.name = "append",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "Linux kernel command line",
|
2012-03-02 12:56:38 +01:00
|
|
|
}, {
|
|
|
|
.name = "dtb",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "Linux kernel device tree file",
|
2012-05-18 00:11:33 +02:00
|
|
|
}, {
|
|
|
|
.name = "dumpdtb",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "Dump current dtb to a file and quit",
|
2012-06-06 01:01:23 +02:00
|
|
|
}, {
|
|
|
|
.name = "phandle_start",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "The first phandle ID we may generate dynamically",
|
2012-06-20 20:46:22 +02:00
|
|
|
}, {
|
|
|
|
.name = "dt_compatible",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "Overrides the \"compatible\" property of the dt root node",
|
2012-08-02 21:44:16 +02:00
|
|
|
}, {
|
|
|
|
.name = "dump-guest-core",
|
|
|
|
.type = QEMU_OPT_BOOL,
|
|
|
|
.help = "Include guest memory in a core dump",
|
2012-09-05 21:50:16 +02:00
|
|
|
}, {
|
|
|
|
.name = "mem-merge",
|
|
|
|
.type = QEMU_OPT_BOOL,
|
|
|
|
.help = "enable/disable memory merge support",
|
2012-09-02 21:25:28 +02:00
|
|
|
},{
|
|
|
|
.name = "usb",
|
|
|
|
.type = QEMU_OPT_BOOL,
|
|
|
|
.help = "Set on/off to enable/disable usb",
|
2012-11-12 17:46:57 +01:00
|
|
|
}, {
|
|
|
|
.name = "nvram",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "Drive backing persistent NVRAM",
|
2010-09-21 21:05:31 +02:00
|
|
|
},
|
|
|
|
{ /* End of list */ }
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2011-07-27 12:04:55 +02:00
|
|
|
QemuOptsList qemu_boot_opts = {
|
|
|
|
.name = "boot-opts",
|
|
|
|
.head = QTAILQ_HEAD_INITIALIZER(qemu_boot_opts.head),
|
|
|
|
.desc = {
|
|
|
|
/* the three names below are not used now */
|
|
|
|
{
|
|
|
|
.name = "order",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
}, {
|
|
|
|
.name = "once",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
}, {
|
|
|
|
.name = "menu",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
/* following are really used */
|
|
|
|
}, {
|
|
|
|
.name = "splash",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
}, {
|
|
|
|
.name = "splash-time",
|
|
|
|
.type = QEMU_OPT_STRING,
|
add a boot parameter to set reboot timeout
Added an option to let qemu transfer a configuration file to bios,
"etc/boot-fail-wait", which could be specified by command
-boot reboot-timeout=T
T have a max value of 0xffff, unit is ms.
With this option, guest will wait for a given time if not find
bootabled device, then reboot. If reboot-timeout is '-1', guest
will not reboot, qemu passes '-1' to bios by default.
This feature need the new seabios's support.
Seabios pulls the value from the fwcfg "file" interface, this
interface is used because SeaBIOS needs a reliable way of
obtaining a name, value size, and value. It in no way requires
that there be a real file on the user's host machine.
Signed-off-by: Amos Kong <akong@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-09-07 05:11:03 +02:00
|
|
|
}, {
|
|
|
|
.name = "reboot-timeout",
|
|
|
|
.type = QEMU_OPT_STRING,
|
2011-07-27 12:04:55 +02:00
|
|
|
},
|
|
|
|
{ /*End of list */ }
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2012-10-18 21:19:34 +02:00
|
|
|
static QemuOptsList qemu_add_fd_opts = {
|
|
|
|
.name = "add-fd",
|
|
|
|
.head = QTAILQ_HEAD_INITIALIZER(qemu_add_fd_opts.head),
|
|
|
|
.desc = {
|
|
|
|
{
|
|
|
|
.name = "fd",
|
|
|
|
.type = QEMU_OPT_NUMBER,
|
|
|
|
.help = "file descriptor of which a duplicate is added to fd set",
|
|
|
|
},{
|
|
|
|
.name = "set",
|
|
|
|
.type = QEMU_OPT_NUMBER,
|
|
|
|
.help = "ID of the fd set to add fd to",
|
|
|
|
},{
|
|
|
|
.name = "opaque",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "free-form string used to describe fd",
|
|
|
|
},
|
|
|
|
{ /* end of list */ }
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2012-06-25 21:36:33 +02:00
|
|
|
static QemuOptsList qemu_object_opts = {
|
|
|
|
.name = "object",
|
|
|
|
.implied_opt_name = "qom-type",
|
|
|
|
.head = QTAILQ_HEAD_INITIALIZER(qemu_object_opts.head),
|
|
|
|
.desc = {
|
|
|
|
{ }
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2010-08-20 13:52:00 +02:00
|
|
|
static QemuOptsList *vm_config_groups[32] = {
|
2009-07-31 12:25:36 +02:00
|
|
|
&qemu_drive_opts,
|
2009-09-10 10:58:35 +02:00
|
|
|
&qemu_chardev_opts,
|
2009-07-31 12:25:37 +02:00
|
|
|
&qemu_device_opts,
|
2009-10-08 20:58:26 +02:00
|
|
|
&qemu_netdev_opts,
|
2009-10-06 13:17:05 +02:00
|
|
|
&qemu_net_opts,
|
2009-10-06 13:16:50 +02:00
|
|
|
&qemu_rtc_opts,
|
2009-12-08 13:11:34 +01:00
|
|
|
&qemu_global_opts,
|
2009-12-08 13:11:50 +01:00
|
|
|
&qemu_mon_opts,
|
2010-08-09 12:48:32 +02:00
|
|
|
&qemu_trace_opts,
|
2010-12-08 12:35:07 +01:00
|
|
|
&qemu_option_rom_opts,
|
2010-09-21 21:05:31 +02:00
|
|
|
&qemu_machine_opts,
|
2011-07-27 12:04:55 +02:00
|
|
|
&qemu_boot_opts,
|
2012-01-25 23:39:02 +01:00
|
|
|
&qemu_iscsi_opts,
|
2012-08-14 23:44:08 +02:00
|
|
|
&qemu_sandbox_opts,
|
2012-10-18 21:19:34 +02:00
|
|
|
&qemu_add_fd_opts,
|
2012-06-25 21:36:33 +02:00
|
|
|
&qemu_object_opts,
|
2009-07-31 12:25:36 +02:00
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
2012-03-28 19:14:17 +02:00
|
|
|
static QemuOptsList *find_list(QemuOptsList **lists, const char *group,
|
|
|
|
Error **errp)
|
2009-10-14 10:39:25 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; lists[i] != NULL; i++) {
|
|
|
|
if (strcmp(lists[i]->name, group) == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (lists[i] == NULL) {
|
2012-03-28 19:14:17 +02:00
|
|
|
error_set(errp, QERR_INVALID_OPTION_GROUP, group);
|
2009-10-14 10:39:25 +02:00
|
|
|
}
|
|
|
|
return lists[i];
|
|
|
|
}
|
|
|
|
|
2010-03-05 18:21:56 +01:00
|
|
|
QemuOptsList *qemu_find_opts(const char *group)
|
|
|
|
{
|
2012-03-28 19:14:17 +02:00
|
|
|
QemuOptsList *ret;
|
|
|
|
Error *local_err = NULL;
|
|
|
|
|
|
|
|
ret = find_list(vm_config_groups, group, &local_err);
|
|
|
|
if (error_is_set(&local_err)) {
|
|
|
|
error_report("%s\n", error_get_pretty(local_err));
|
|
|
|
error_free(local_err);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2010-03-05 18:21:56 +01:00
|
|
|
}
|
|
|
|
|
2012-03-28 19:16:37 +02:00
|
|
|
QemuOptsList *qemu_find_opts_err(const char *group, Error **errp)
|
|
|
|
{
|
|
|
|
return find_list(vm_config_groups, group, errp);
|
|
|
|
}
|
|
|
|
|
2010-08-20 13:52:00 +02:00
|
|
|
void qemu_add_opts(QemuOptsList *list)
|
|
|
|
{
|
|
|
|
int entries, i;
|
|
|
|
|
|
|
|
entries = ARRAY_SIZE(vm_config_groups);
|
|
|
|
entries--; /* keep list NULL terminated */
|
|
|
|
for (i = 0; i < entries; i++) {
|
|
|
|
if (vm_config_groups[i] == NULL) {
|
|
|
|
vm_config_groups[i] = list;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fprintf(stderr, "ran out of space in vm_config_groups");
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
2009-07-31 12:25:36 +02:00
|
|
|
int qemu_set_option(const char *str)
|
|
|
|
{
|
|
|
|
char group[64], id[64], arg[64];
|
2009-10-14 10:39:25 +02:00
|
|
|
QemuOptsList *list;
|
2009-07-31 12:25:36 +02:00
|
|
|
QemuOpts *opts;
|
2009-10-14 10:39:25 +02:00
|
|
|
int rc, offset;
|
2009-07-31 12:25:36 +02:00
|
|
|
|
|
|
|
rc = sscanf(str, "%63[^.].%63[^.].%63[^=]%n", group, id, arg, &offset);
|
|
|
|
if (rc < 3 || str[offset] != '=') {
|
2010-02-18 17:25:24 +01:00
|
|
|
error_report("can't parse: \"%s\"", str);
|
2009-07-31 12:25:36 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2010-02-10 20:09:14 +01:00
|
|
|
list = qemu_find_opts(group);
|
2009-10-14 10:39:25 +02:00
|
|
|
if (list == NULL) {
|
2009-07-31 12:25:36 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-10-14 10:39:25 +02:00
|
|
|
opts = qemu_opts_find(list, id);
|
2009-07-31 12:25:36 +02:00
|
|
|
if (!opts) {
|
2010-02-18 17:25:24 +01:00
|
|
|
error_report("there is no %s \"%s\" defined",
|
|
|
|
list->name, id);
|
2009-07-31 12:25:36 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-09-23 12:24:05 +02:00
|
|
|
if (qemu_opt_set(opts, arg, str+offset+1) == -1) {
|
2009-07-31 12:25:36 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-12-08 13:11:34 +01:00
|
|
|
int qemu_global_option(const char *str)
|
|
|
|
{
|
|
|
|
char driver[64], property[64];
|
|
|
|
QemuOpts *opts;
|
|
|
|
int rc, offset;
|
|
|
|
|
|
|
|
rc = sscanf(str, "%63[^.].%63[^=]%n", driver, property, &offset);
|
|
|
|
if (rc < 2 || str[offset] != '=') {
|
2010-02-18 17:25:24 +01:00
|
|
|
error_report("can't parse: \"%s\"", str);
|
2009-12-08 13:11:34 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-12-06 07:47:22 +01:00
|
|
|
opts = qemu_opts_create_nofail(&qemu_global_opts);
|
2009-12-08 13:11:34 +01:00
|
|
|
qemu_opt_set(opts, "driver", driver);
|
|
|
|
qemu_opt_set(opts, "property", property);
|
|
|
|
qemu_opt_set(opts, "value", str+offset+1);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-10-14 10:39:26 +02:00
|
|
|
struct ConfigWriteData {
|
|
|
|
QemuOptsList *list;
|
|
|
|
FILE *fp;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int config_write_opt(const char *name, const char *value, void *opaque)
|
|
|
|
{
|
|
|
|
struct ConfigWriteData *data = opaque;
|
|
|
|
|
|
|
|
fprintf(data->fp, " %s = \"%s\"\n", name, value);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int config_write_opts(QemuOpts *opts, void *opaque)
|
|
|
|
{
|
|
|
|
struct ConfigWriteData *data = opaque;
|
|
|
|
const char *id = qemu_opts_id(opts);
|
|
|
|
|
|
|
|
if (id) {
|
|
|
|
fprintf(data->fp, "[%s \"%s\"]\n", data->list->name, id);
|
|
|
|
} else {
|
|
|
|
fprintf(data->fp, "[%s]\n", data->list->name);
|
|
|
|
}
|
|
|
|
qemu_opt_foreach(opts, config_write_opt, data, 0);
|
|
|
|
fprintf(data->fp, "\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void qemu_config_write(FILE *fp)
|
|
|
|
{
|
|
|
|
struct ConfigWriteData data = { .fp = fp };
|
2010-03-05 18:21:56 +01:00
|
|
|
QemuOptsList **lists = vm_config_groups;
|
2009-10-14 10:39:26 +02:00
|
|
|
int i;
|
|
|
|
|
|
|
|
fprintf(fp, "# qemu config file\n\n");
|
|
|
|
for (i = 0; lists[i] != NULL; i++) {
|
|
|
|
data.list = lists[i];
|
|
|
|
qemu_opts_foreach(data.list, config_write_opts, &data, 0);
|
|
|
|
}
|
|
|
|
}
|
2009-10-14 10:39:27 +02:00
|
|
|
|
2010-03-05 18:21:56 +01:00
|
|
|
int qemu_config_parse(FILE *fp, QemuOptsList **lists, const char *fname)
|
2009-10-14 10:39:27 +02:00
|
|
|
{
|
|
|
|
char line[1024], group[64], id[64], arg[64], value[1024];
|
2010-02-18 19:48:33 +01:00
|
|
|
Location loc;
|
2009-10-14 10:39:27 +02:00
|
|
|
QemuOptsList *list = NULL;
|
2012-03-28 19:14:17 +02:00
|
|
|
Error *local_err = NULL;
|
2009-10-14 10:39:27 +02:00
|
|
|
QemuOpts *opts = NULL;
|
2010-02-18 19:48:33 +01:00
|
|
|
int res = -1, lno = 0;
|
2009-10-14 10:39:27 +02:00
|
|
|
|
2010-02-18 19:48:33 +01:00
|
|
|
loc_push_none(&loc);
|
2009-10-14 10:39:27 +02:00
|
|
|
while (fgets(line, sizeof(line), fp) != NULL) {
|
2010-02-18 19:48:33 +01:00
|
|
|
loc_set_file(fname, ++lno);
|
2009-10-14 10:39:27 +02:00
|
|
|
if (line[0] == '\n') {
|
|
|
|
/* skip empty lines */
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (line[0] == '#') {
|
|
|
|
/* comment */
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (sscanf(line, "[%63s \"%63[^\"]\"]", group, id) == 2) {
|
|
|
|
/* group with id */
|
2012-03-28 19:14:17 +02:00
|
|
|
list = find_list(lists, group, &local_err);
|
|
|
|
if (error_is_set(&local_err)) {
|
|
|
|
error_report("%s\n", error_get_pretty(local_err));
|
|
|
|
error_free(local_err);
|
2010-02-18 19:48:33 +01:00
|
|
|
goto out;
|
2012-03-28 19:14:17 +02:00
|
|
|
}
|
2012-03-20 19:51:57 +01:00
|
|
|
opts = qemu_opts_create(list, id, 1, NULL);
|
2009-10-14 10:39:27 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (sscanf(line, "[%63[^]]]", group) == 1) {
|
|
|
|
/* group without id */
|
2012-03-28 19:14:17 +02:00
|
|
|
list = find_list(lists, group, &local_err);
|
|
|
|
if (error_is_set(&local_err)) {
|
|
|
|
error_report("%s\n", error_get_pretty(local_err));
|
|
|
|
error_free(local_err);
|
2010-02-18 19:48:33 +01:00
|
|
|
goto out;
|
2012-03-28 19:14:17 +02:00
|
|
|
}
|
2012-12-06 07:47:22 +01:00
|
|
|
opts = qemu_opts_create_nofail(list);
|
2009-10-14 10:39:27 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (sscanf(line, " %63s = \"%1023[^\"]\"", arg, value) == 2) {
|
|
|
|
/* arg = value */
|
|
|
|
if (opts == NULL) {
|
2010-02-18 19:48:33 +01:00
|
|
|
error_report("no group defined");
|
|
|
|
goto out;
|
2009-10-14 10:39:27 +02:00
|
|
|
}
|
|
|
|
if (qemu_opt_set(opts, arg, value) != 0) {
|
2010-02-18 19:48:33 +01:00
|
|
|
goto out;
|
2009-10-14 10:39:27 +02:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
2010-02-18 19:48:33 +01:00
|
|
|
error_report("parse error");
|
|
|
|
goto out;
|
2009-10-14 10:39:27 +02:00
|
|
|
}
|
2010-02-18 19:56:01 +01:00
|
|
|
if (ferror(fp)) {
|
|
|
|
error_report("error reading file");
|
|
|
|
goto out;
|
|
|
|
}
|
2010-02-18 19:48:33 +01:00
|
|
|
res = 0;
|
|
|
|
out:
|
|
|
|
loc_pop(&loc);
|
|
|
|
return res;
|
2009-10-14 10:39:27 +02:00
|
|
|
}
|
2010-03-05 17:25:55 +01:00
|
|
|
|
|
|
|
int qemu_read_config_file(const char *filename)
|
|
|
|
{
|
|
|
|
FILE *f = fopen(filename, "r");
|
2010-05-17 10:36:47 +02:00
|
|
|
int ret;
|
|
|
|
|
2010-03-05 17:25:55 +01:00
|
|
|
if (f == NULL) {
|
|
|
|
return -errno;
|
|
|
|
}
|
|
|
|
|
2010-05-17 10:36:47 +02:00
|
|
|
ret = qemu_config_parse(f, vm_config_groups, filename);
|
2010-03-05 17:25:55 +01:00
|
|
|
fclose(f);
|
|
|
|
|
2010-05-17 10:36:47 +02:00
|
|
|
if (ret == 0) {
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2010-03-05 17:25:55 +01:00
|
|
|
}
|