QemuOpts: make most qemu_*_opts static
Switch tree to lookup-by-name using qemu_find_opts(). Also hook up virtfs options so qemu_find_opts works for them too. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
		
							parent
							
								
									dfe795e71f
								
							
						
					
					
						commit
						3329f07b7a
					
				| 
						 | 
					@ -50,7 +50,7 @@ QemuOpts *drive_add(const char *file, const char *fmt, ...)
 | 
				
			||||||
    vsnprintf(optstr, sizeof(optstr), fmt, ap);
 | 
					    vsnprintf(optstr, sizeof(optstr), fmt, ap);
 | 
				
			||||||
    va_end(ap);
 | 
					    va_end(ap);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    opts = qemu_opts_parse(&qemu_drive_opts, optstr, 0);
 | 
					    opts = qemu_opts_parse(qemu_find_opts("drive"), optstr, 0);
 | 
				
			||||||
    if (!opts) {
 | 
					    if (!opts) {
 | 
				
			||||||
        return NULL;
 | 
					        return NULL;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -451,7 +451,7 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi, int *fatal_error)
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
    case IF_VIRTIO:
 | 
					    case IF_VIRTIO:
 | 
				
			||||||
        /* add virtio block device */
 | 
					        /* add virtio block device */
 | 
				
			||||||
        opts = qemu_opts_create(&qemu_device_opts, NULL, 0);
 | 
					        opts = qemu_opts_create(qemu_find_opts("device"), NULL, 0);
 | 
				
			||||||
        qemu_opt_set(opts, "driver", "virtio-blk-pci");
 | 
					        qemu_opt_set(opts, "driver", "virtio-blk-pci");
 | 
				
			||||||
        qemu_opt_set(opts, "drive", dinfo->id);
 | 
					        qemu_opt_set(opts, "drive", dinfo->id);
 | 
				
			||||||
        if (devaddr)
 | 
					        if (devaddr)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -51,7 +51,7 @@ static PCIDevice *qemu_pci_hot_add_nic(Monitor *mon,
 | 
				
			||||||
        return NULL;
 | 
					        return NULL;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    opts = qemu_opts_parse(&qemu_net_opts, opts_str ? opts_str : "", 0);
 | 
					    opts = qemu_opts_parse(qemu_find_opts("net"), opts_str ? opts_str : "", 0);
 | 
				
			||||||
    if (!opts) {
 | 
					    if (!opts) {
 | 
				
			||||||
        return NULL;
 | 
					        return NULL;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -772,5 +772,5 @@ static int qdev_add_one_global(QemuOpts *opts, void *opaque)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void qemu_add_globals(void)
 | 
					void qemu_add_globals(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    qemu_opts_foreach(&qemu_global_opts, qdev_add_one_global, NULL, 0);
 | 
					    qemu_opts_foreach(qemu_find_opts("global"), qdev_add_one_global, NULL, 0);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -792,7 +792,7 @@ int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    QemuOpts *opts;
 | 
					    QemuOpts *opts;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    opts = qemu_opts_from_qdict(&qemu_device_opts, qdict);
 | 
					    opts = qemu_opts_from_qdict(qemu_find_opts("device"), qdict);
 | 
				
			||||||
    if (!opts) {
 | 
					    if (!opts) {
 | 
				
			||||||
        return -1;
 | 
					        return -1;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -575,7 +575,7 @@ static USBDevice *usb_msd_init(const char *filename)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* parse -usbdevice disk: syntax into drive opts */
 | 
					    /* parse -usbdevice disk: syntax into drive opts */
 | 
				
			||||||
    snprintf(id, sizeof(id), "usb%d", nr++);
 | 
					    snprintf(id, sizeof(id), "usb%d", nr++);
 | 
				
			||||||
    opts = qemu_opts_create(&qemu_drive_opts, id, 0);
 | 
					    opts = qemu_opts_create(qemu_find_opts("drive"), id, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    p1 = strchr(filename, ':');
 | 
					    p1 = strchr(filename, ':');
 | 
				
			||||||
    if (p1++) {
 | 
					    if (p1++) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1472,7 +1472,7 @@ static USBDevice *usb_net_init(const char *cmdline)
 | 
				
			||||||
    QemuOpts *opts;
 | 
					    QemuOpts *opts;
 | 
				
			||||||
    int idx;
 | 
					    int idx;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    opts = qemu_opts_parse(&qemu_net_opts, cmdline, 0);
 | 
					    opts = qemu_opts_parse(qemu_find_opts("net"), cmdline, 0);
 | 
				
			||||||
    if (!opts) {
 | 
					    if (!opts) {
 | 
				
			||||||
        return NULL;
 | 
					        return NULL;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -66,7 +66,7 @@ int select_watchdog(const char *p)
 | 
				
			||||||
    QLIST_FOREACH(model, &watchdog_list, entry) {
 | 
					    QLIST_FOREACH(model, &watchdog_list, entry) {
 | 
				
			||||||
        if (strcasecmp(model->wdt_name, p) == 0) {
 | 
					        if (strcasecmp(model->wdt_name, p) == 0) {
 | 
				
			||||||
            /* add the device */
 | 
					            /* add the device */
 | 
				
			||||||
            opts = qemu_opts_create(&qemu_device_opts, NULL, 0);
 | 
					            opts = qemu_opts_create(qemu_find_opts("device"), NULL, 0);
 | 
				
			||||||
            qemu_opt_set(opts, "driver", p);
 | 
					            qemu_opt_set(opts, "driver", p);
 | 
				
			||||||
            return 0;
 | 
					            return 0;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										16
									
								
								net.c
								
								
								
								
							
							
						
						
									
										16
									
								
								net.c
								
								
								
								
							| 
						 | 
					@ -1168,7 +1168,7 @@ void net_host_device_add(Monitor *mon, const QDict *qdict)
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    opts = qemu_opts_parse(&qemu_net_opts, opts_str ? opts_str : "", 0);
 | 
					    opts = qemu_opts_parse(qemu_find_opts("net"), opts_str ? opts_str : "", 0);
 | 
				
			||||||
    if (!opts) {
 | 
					    if (!opts) {
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -1202,7 +1202,7 @@ int do_netdev_add(Monitor *mon, const QDict *qdict, QObject **ret_data)
 | 
				
			||||||
    QemuOpts *opts;
 | 
					    QemuOpts *opts;
 | 
				
			||||||
    int res;
 | 
					    int res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    opts = qemu_opts_from_qdict(&qemu_netdev_opts, qdict);
 | 
					    opts = qemu_opts_from_qdict(qemu_find_opts("netdev"), qdict);
 | 
				
			||||||
    if (!opts) {
 | 
					    if (!opts) {
 | 
				
			||||||
        return -1;
 | 
					        return -1;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -1226,7 +1226,7 @@ int do_netdev_del(Monitor *mon, const QDict *qdict, QObject **ret_data)
 | 
				
			||||||
        return -1;
 | 
					        return -1;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    qemu_del_vlan_client(vc);
 | 
					    qemu_del_vlan_client(vc);
 | 
				
			||||||
    qemu_opts_del(qemu_opts_find(&qemu_netdev_opts, id));
 | 
					    qemu_opts_del(qemu_opts_find(qemu_find_opts("netdev"), id));
 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1349,21 +1349,23 @@ static int net_init_netdev(QemuOpts *opts, void *dummy)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int net_init_clients(void)
 | 
					int net_init_clients(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    QemuOptsList *net = qemu_find_opts("net");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (default_net) {
 | 
					    if (default_net) {
 | 
				
			||||||
        /* if no clients, we use a default config */
 | 
					        /* if no clients, we use a default config */
 | 
				
			||||||
        qemu_opts_set(&qemu_net_opts, NULL, "type", "nic");
 | 
					        qemu_opts_set(net, NULL, "type", "nic");
 | 
				
			||||||
#ifdef CONFIG_SLIRP
 | 
					#ifdef CONFIG_SLIRP
 | 
				
			||||||
        qemu_opts_set(&qemu_net_opts, NULL, "type", "user");
 | 
					        qemu_opts_set(net, NULL, "type", "user");
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QTAILQ_INIT(&vlans);
 | 
					    QTAILQ_INIT(&vlans);
 | 
				
			||||||
    QTAILQ_INIT(&non_vlan_clients);
 | 
					    QTAILQ_INIT(&non_vlan_clients);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (qemu_opts_foreach(&qemu_netdev_opts, net_init_netdev, NULL, 1) == -1)
 | 
					    if (qemu_opts_foreach(qemu_find_opts("netdev"), net_init_netdev, NULL, 1) == -1)
 | 
				
			||||||
        return -1;
 | 
					        return -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (qemu_opts_foreach(&qemu_net_opts, net_init_client, NULL, 1) == -1) {
 | 
					    if (qemu_opts_foreach(net, net_init_client, NULL, 1) == -1) {
 | 
				
			||||||
        return -1;
 | 
					        return -1;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2286,7 +2286,7 @@ QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename)
 | 
				
			||||||
    const char *p;
 | 
					    const char *p;
 | 
				
			||||||
    QemuOpts *opts;
 | 
					    QemuOpts *opts;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    opts = qemu_opts_create(&qemu_chardev_opts, label, 1);
 | 
					    opts = qemu_opts_create(qemu_find_opts("chardev"), label, 1);
 | 
				
			||||||
    if (NULL == opts)
 | 
					    if (NULL == opts)
 | 
				
			||||||
        return NULL;
 | 
					        return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,7 +5,7 @@
 | 
				
			||||||
#include "sysemu.h"
 | 
					#include "sysemu.h"
 | 
				
			||||||
#include "hw/qdev.h"
 | 
					#include "hw/qdev.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QemuOptsList qemu_drive_opts = {
 | 
					static QemuOptsList qemu_drive_opts = {
 | 
				
			||||||
    .name = "drive",
 | 
					    .name = "drive",
 | 
				
			||||||
    .head = QTAILQ_HEAD_INITIALIZER(qemu_drive_opts.head),
 | 
					    .head = QTAILQ_HEAD_INITIALIZER(qemu_drive_opts.head),
 | 
				
			||||||
    .desc = {
 | 
					    .desc = {
 | 
				
			||||||
| 
						 | 
					@ -84,7 +84,7 @@ QemuOptsList qemu_drive_opts = {
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QemuOptsList qemu_chardev_opts = {
 | 
					static QemuOptsList qemu_chardev_opts = {
 | 
				
			||||||
    .name = "chardev",
 | 
					    .name = "chardev",
 | 
				
			||||||
    .implied_opt_name = "backend",
 | 
					    .implied_opt_name = "backend",
 | 
				
			||||||
    .head = QTAILQ_HEAD_INITIALIZER(qemu_chardev_opts.head),
 | 
					    .head = QTAILQ_HEAD_INITIALIZER(qemu_chardev_opts.head),
 | 
				
			||||||
| 
						 | 
					@ -151,7 +151,6 @@ QemuOptsList qemu_chardev_opts = {
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef CONFIG_LINUX
 | 
					 | 
				
			||||||
QemuOptsList qemu_fsdev_opts = {
 | 
					QemuOptsList qemu_fsdev_opts = {
 | 
				
			||||||
    .name = "fsdev",
 | 
					    .name = "fsdev",
 | 
				
			||||||
    .implied_opt_name = "fstype",
 | 
					    .implied_opt_name = "fstype",
 | 
				
			||||||
| 
						 | 
					@ -170,9 +169,7 @@ QemuOptsList qemu_fsdev_opts = {
 | 
				
			||||||
        { /*End of list */ }
 | 
					        { /*End of list */ }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef CONFIG_LINUX
 | 
					 | 
				
			||||||
QemuOptsList qemu_virtfs_opts = {
 | 
					QemuOptsList qemu_virtfs_opts = {
 | 
				
			||||||
    .name = "virtfs",
 | 
					    .name = "virtfs",
 | 
				
			||||||
    .implied_opt_name = "fstype",
 | 
					    .implied_opt_name = "fstype",
 | 
				
			||||||
| 
						 | 
					@ -195,9 +192,8 @@ QemuOptsList qemu_virtfs_opts = {
 | 
				
			||||||
        { /*End of list */ }
 | 
					        { /*End of list */ }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
QemuOptsList qemu_device_opts = {
 | 
					static QemuOptsList qemu_device_opts = {
 | 
				
			||||||
    .name = "device",
 | 
					    .name = "device",
 | 
				
			||||||
    .implied_opt_name = "driver",
 | 
					    .implied_opt_name = "driver",
 | 
				
			||||||
    .head = QTAILQ_HEAD_INITIALIZER(qemu_device_opts.head),
 | 
					    .head = QTAILQ_HEAD_INITIALIZER(qemu_device_opts.head),
 | 
				
			||||||
| 
						 | 
					@ -211,7 +207,7 @@ QemuOptsList qemu_device_opts = {
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QemuOptsList qemu_netdev_opts = {
 | 
					static QemuOptsList qemu_netdev_opts = {
 | 
				
			||||||
    .name = "netdev",
 | 
					    .name = "netdev",
 | 
				
			||||||
    .implied_opt_name = "type",
 | 
					    .implied_opt_name = "type",
 | 
				
			||||||
    .head = QTAILQ_HEAD_INITIALIZER(qemu_netdev_opts.head),
 | 
					    .head = QTAILQ_HEAD_INITIALIZER(qemu_netdev_opts.head),
 | 
				
			||||||
| 
						 | 
					@ -224,7 +220,7 @@ QemuOptsList qemu_netdev_opts = {
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QemuOptsList qemu_net_opts = {
 | 
					static QemuOptsList qemu_net_opts = {
 | 
				
			||||||
    .name = "net",
 | 
					    .name = "net",
 | 
				
			||||||
    .implied_opt_name = "type",
 | 
					    .implied_opt_name = "type",
 | 
				
			||||||
    .head = QTAILQ_HEAD_INITIALIZER(qemu_net_opts.head),
 | 
					    .head = QTAILQ_HEAD_INITIALIZER(qemu_net_opts.head),
 | 
				
			||||||
| 
						 | 
					@ -237,7 +233,7 @@ QemuOptsList qemu_net_opts = {
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QemuOptsList qemu_rtc_opts = {
 | 
					static QemuOptsList qemu_rtc_opts = {
 | 
				
			||||||
    .name = "rtc",
 | 
					    .name = "rtc",
 | 
				
			||||||
    .head = QTAILQ_HEAD_INITIALIZER(qemu_rtc_opts.head),
 | 
					    .head = QTAILQ_HEAD_INITIALIZER(qemu_rtc_opts.head),
 | 
				
			||||||
    .desc = {
 | 
					    .desc = {
 | 
				
			||||||
| 
						 | 
					@ -255,7 +251,7 @@ QemuOptsList qemu_rtc_opts = {
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QemuOptsList qemu_global_opts = {
 | 
					static QemuOptsList qemu_global_opts = {
 | 
				
			||||||
    .name = "global",
 | 
					    .name = "global",
 | 
				
			||||||
    .head = QTAILQ_HEAD_INITIALIZER(qemu_global_opts.head),
 | 
					    .head = QTAILQ_HEAD_INITIALIZER(qemu_global_opts.head),
 | 
				
			||||||
    .desc = {
 | 
					    .desc = {
 | 
				
			||||||
| 
						 | 
					@ -273,7 +269,7 @@ QemuOptsList qemu_global_opts = {
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QemuOptsList qemu_mon_opts = {
 | 
					static QemuOptsList qemu_mon_opts = {
 | 
				
			||||||
    .name = "mon",
 | 
					    .name = "mon",
 | 
				
			||||||
    .implied_opt_name = "chardev",
 | 
					    .implied_opt_name = "chardev",
 | 
				
			||||||
    .head = QTAILQ_HEAD_INITIALIZER(qemu_mon_opts.head),
 | 
					    .head = QTAILQ_HEAD_INITIALIZER(qemu_mon_opts.head),
 | 
				
			||||||
| 
						 | 
					@ -292,7 +288,7 @@ QemuOptsList qemu_mon_opts = {
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QemuOptsList qemu_cpudef_opts = {
 | 
					static QemuOptsList qemu_cpudef_opts = {
 | 
				
			||||||
    .name = "cpudef",
 | 
					    .name = "cpudef",
 | 
				
			||||||
    .head = QTAILQ_HEAD_INITIALIZER(qemu_cpudef_opts.head),
 | 
					    .head = QTAILQ_HEAD_INITIALIZER(qemu_cpudef_opts.head),
 | 
				
			||||||
    .desc = {
 | 
					    .desc = {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,19 +1,8 @@
 | 
				
			||||||
#ifndef QEMU_CONFIG_H
 | 
					#ifndef QEMU_CONFIG_H
 | 
				
			||||||
#define QEMU_CONFIG_H
 | 
					#define QEMU_CONFIG_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern QemuOptsList qemu_drive_opts;
 | 
					 | 
				
			||||||
extern QemuOptsList qemu_chardev_opts;
 | 
					 | 
				
			||||||
#ifdef CONFIG_LINUX
 | 
					 | 
				
			||||||
extern QemuOptsList qemu_fsdev_opts;
 | 
					extern QemuOptsList qemu_fsdev_opts;
 | 
				
			||||||
extern QemuOptsList qemu_virtfs_opts;
 | 
					extern QemuOptsList qemu_virtfs_opts;
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
extern QemuOptsList qemu_device_opts;
 | 
					 | 
				
			||||||
extern QemuOptsList qemu_netdev_opts;
 | 
					 | 
				
			||||||
extern QemuOptsList qemu_net_opts;
 | 
					 | 
				
			||||||
extern QemuOptsList qemu_rtc_opts;
 | 
					 | 
				
			||||||
extern QemuOptsList qemu_global_opts;
 | 
					 | 
				
			||||||
extern QemuOptsList qemu_mon_opts;
 | 
					 | 
				
			||||||
extern QemuOptsList qemu_cpudef_opts;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
QemuOptsList *qemu_find_opts(const char *group);
 | 
					QemuOptsList *qemu_find_opts(const char *group);
 | 
				
			||||||
void qemu_add_opts(QemuOptsList *list);
 | 
					void qemu_add_opts(QemuOptsList *list);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -965,7 +965,7 @@ void x86_cpudef_setup(void)
 | 
				
			||||||
        x86_defs = &builtin_x86_defs[i];
 | 
					        x86_defs = &builtin_x86_defs[i];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
#if !defined(CONFIG_USER_ONLY)
 | 
					#if !defined(CONFIG_USER_ONLY)
 | 
				
			||||||
    qemu_opts_foreach(&qemu_cpudef_opts, cpudef_register, NULL, 0);
 | 
					    qemu_opts_foreach(qemu_find_opts("cpudef"), cpudef_register, NULL, 0);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										56
									
								
								vl.c
								
								
								
								
							
							
						
						
									
										56
									
								
								vl.c
								
								
								
								
							| 
						 | 
					@ -1461,12 +1461,12 @@ static int balloon_parse(const char *arg)
 | 
				
			||||||
    if (!strncmp(arg, "virtio", 6)) {
 | 
					    if (!strncmp(arg, "virtio", 6)) {
 | 
				
			||||||
        if (arg[6] == ',') {
 | 
					        if (arg[6] == ',') {
 | 
				
			||||||
            /* have params -> parse them */
 | 
					            /* have params -> parse them */
 | 
				
			||||||
            opts = qemu_opts_parse(&qemu_device_opts, arg+7, 0);
 | 
					            opts = qemu_opts_parse(qemu_find_opts("device"), arg+7, 0);
 | 
				
			||||||
            if (!opts)
 | 
					            if (!opts)
 | 
				
			||||||
                return  -1;
 | 
					                return  -1;
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            /* create empty opts */
 | 
					            /* create empty opts */
 | 
				
			||||||
            opts = qemu_opts_create(&qemu_device_opts, NULL, 0);
 | 
					            opts = qemu_opts_create(qemu_find_opts("device"), NULL, 0);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        qemu_opt_set(opts, "driver", "virtio-balloon-pci");
 | 
					        qemu_opt_set(opts, "driver", "virtio-balloon-pci");
 | 
				
			||||||
        return 0;
 | 
					        return 0;
 | 
				
			||||||
| 
						 | 
					@ -1598,7 +1598,7 @@ static void monitor_parse(const char *optarg, const char *mode)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    opts = qemu_opts_create(&qemu_mon_opts, label, 1);
 | 
					    opts = qemu_opts_create(qemu_find_opts("mon"), label, 1);
 | 
				
			||||||
    if (!opts) {
 | 
					    if (!opts) {
 | 
				
			||||||
        fprintf(stderr, "duplicate chardev: %s\n", label);
 | 
					        fprintf(stderr, "duplicate chardev: %s\n", label);
 | 
				
			||||||
        exit(1);
 | 
					        exit(1);
 | 
				
			||||||
| 
						 | 
					@ -1695,6 +1695,7 @@ static int parallel_parse(const char *devname)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int virtcon_parse(const char *devname)
 | 
					static int virtcon_parse(const char *devname)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    QemuOptsList *device = qemu_find_opts("device");
 | 
				
			||||||
    static int index = 0;
 | 
					    static int index = 0;
 | 
				
			||||||
    char label[32];
 | 
					    char label[32];
 | 
				
			||||||
    QemuOpts *bus_opts, *dev_opts;
 | 
					    QemuOpts *bus_opts, *dev_opts;
 | 
				
			||||||
| 
						 | 
					@ -1706,10 +1707,10 @@ static int virtcon_parse(const char *devname)
 | 
				
			||||||
        exit(1);
 | 
					        exit(1);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    bus_opts = qemu_opts_create(&qemu_device_opts, NULL, 0);
 | 
					    bus_opts = qemu_opts_create(device, NULL, 0);
 | 
				
			||||||
    qemu_opt_set(bus_opts, "driver", "virtio-serial");
 | 
					    qemu_opt_set(bus_opts, "driver", "virtio-serial");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    dev_opts = qemu_opts_create(&qemu_device_opts, NULL, 0);
 | 
					    dev_opts = qemu_opts_create(device, NULL, 0);
 | 
				
			||||||
    qemu_opt_set(dev_opts, "driver", "virtconsole");
 | 
					    qemu_opt_set(dev_opts, "driver", "virtconsole");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    snprintf(label, sizeof(label), "virtcon%d", index);
 | 
					    snprintf(label, sizeof(label), "virtcon%d", index);
 | 
				
			||||||
| 
						 | 
					@ -1732,7 +1733,7 @@ static int debugcon_parse(const char *devname)
 | 
				
			||||||
    if (!qemu_chr_open("debugcon", devname, NULL)) {
 | 
					    if (!qemu_chr_open("debugcon", devname, NULL)) {
 | 
				
			||||||
        exit(1);
 | 
					        exit(1);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    opts = qemu_opts_create(&qemu_device_opts, "debugcon", 1);
 | 
					    opts = qemu_opts_create(qemu_find_opts("device"), "debugcon", 1);
 | 
				
			||||||
    if (!opts) {
 | 
					    if (!opts) {
 | 
				
			||||||
        fprintf(stderr, "qemu: already have a debugcon device\n");
 | 
					        fprintf(stderr, "qemu: already have a debugcon device\n");
 | 
				
			||||||
        exit(1);
 | 
					        exit(1);
 | 
				
			||||||
| 
						 | 
					@ -1853,6 +1854,11 @@ int main(int argc, char **argv, char **envp)
 | 
				
			||||||
    tb_size = 0;
 | 
					    tb_size = 0;
 | 
				
			||||||
    autostart= 1;
 | 
					    autostart= 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef CONFIG_VIRTFS
 | 
				
			||||||
 | 
					    qemu_add_opts(&qemu_fsdev_opts);
 | 
				
			||||||
 | 
					    qemu_add_opts(&qemu_virtfs_opts);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* first pass of option parsing */
 | 
					    /* first pass of option parsing */
 | 
				
			||||||
    optind = 1;
 | 
					    optind = 1;
 | 
				
			||||||
    while (optind < argc) {
 | 
					    while (optind < argc) {
 | 
				
			||||||
| 
						 | 
					@ -2104,12 +2110,12 @@ int main(int argc, char **argv, char **envp)
 | 
				
			||||||
                fd_bootchk = 0;
 | 
					                fd_bootchk = 0;
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            case QEMU_OPTION_netdev:
 | 
					            case QEMU_OPTION_netdev:
 | 
				
			||||||
                if (net_client_parse(&qemu_netdev_opts, optarg) == -1) {
 | 
					                if (net_client_parse(qemu_find_opts("netdev"), optarg) == -1) {
 | 
				
			||||||
                    exit(1);
 | 
					                    exit(1);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            case QEMU_OPTION_net:
 | 
					            case QEMU_OPTION_net:
 | 
				
			||||||
                if (net_client_parse(&qemu_net_opts, optarg) == -1) {
 | 
					                if (net_client_parse(qemu_find_opts("net"), optarg) == -1) {
 | 
				
			||||||
                    exit(1);
 | 
					                    exit(1);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
| 
						 | 
					@ -2268,21 +2274,21 @@ int main(int argc, char **argv, char **envp)
 | 
				
			||||||
                default_monitor = 0;
 | 
					                default_monitor = 0;
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            case QEMU_OPTION_mon:
 | 
					            case QEMU_OPTION_mon:
 | 
				
			||||||
                opts = qemu_opts_parse(&qemu_mon_opts, optarg, 1);
 | 
					                opts = qemu_opts_parse(qemu_find_opts("mon"), optarg, 1);
 | 
				
			||||||
                if (!opts) {
 | 
					                if (!opts) {
 | 
				
			||||||
                    exit(1);
 | 
					                    exit(1);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                default_monitor = 0;
 | 
					                default_monitor = 0;
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            case QEMU_OPTION_chardev:
 | 
					            case QEMU_OPTION_chardev:
 | 
				
			||||||
                opts = qemu_opts_parse(&qemu_chardev_opts, optarg, 1);
 | 
					                opts = qemu_opts_parse(qemu_find_opts("chardev"), optarg, 1);
 | 
				
			||||||
                if (!opts) {
 | 
					                if (!opts) {
 | 
				
			||||||
                    exit(1);
 | 
					                    exit(1);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
#ifdef CONFIG_VIRTFS
 | 
					#ifdef CONFIG_VIRTFS
 | 
				
			||||||
            case QEMU_OPTION_fsdev:
 | 
					            case QEMU_OPTION_fsdev:
 | 
				
			||||||
                opts = qemu_opts_parse(&qemu_fsdev_opts, optarg, 1);
 | 
					                opts = qemu_opts_parse(qemu_find_opts("fsdev"), optarg, 1);
 | 
				
			||||||
                if (!opts) {
 | 
					                if (!opts) {
 | 
				
			||||||
                    fprintf(stderr, "parse error: %s\n", optarg);
 | 
					                    fprintf(stderr, "parse error: %s\n", optarg);
 | 
				
			||||||
                    exit(1);
 | 
					                    exit(1);
 | 
				
			||||||
| 
						 | 
					@ -2293,7 +2299,7 @@ int main(int argc, char **argv, char **envp)
 | 
				
			||||||
                char *arg_9p = NULL;
 | 
					                char *arg_9p = NULL;
 | 
				
			||||||
                int len = 0;
 | 
					                int len = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                opts = qemu_opts_parse(&qemu_virtfs_opts, optarg, 1);
 | 
					                opts = qemu_opts_parse(qemu_find_opts("virtfs"), optarg, 1);
 | 
				
			||||||
                if (!opts) {
 | 
					                if (!opts) {
 | 
				
			||||||
                    fprintf(stderr, "parse error: %s\n", optarg);
 | 
					                    fprintf(stderr, "parse error: %s\n", optarg);
 | 
				
			||||||
                    exit(1);
 | 
					                    exit(1);
 | 
				
			||||||
| 
						 | 
					@ -2330,12 +2336,12 @@ int main(int argc, char **argv, char **envp)
 | 
				
			||||||
                                qemu_opt_get(opts, "mount_tag"),
 | 
					                                qemu_opt_get(opts, "mount_tag"),
 | 
				
			||||||
                                qemu_opt_get(opts, "mount_tag"));
 | 
					                                qemu_opt_get(opts, "mount_tag"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (!qemu_opts_parse(&qemu_fsdev_opts, arg_fsdev, 1)) {
 | 
					                if (!qemu_opts_parse(qemu_find_opts("fsdev"), arg_fsdev, 1)) {
 | 
				
			||||||
                    fprintf(stderr, "parse error [fsdev]: %s\n", optarg);
 | 
					                    fprintf(stderr, "parse error [fsdev]: %s\n", optarg);
 | 
				
			||||||
                    exit(1);
 | 
					                    exit(1);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (!qemu_opts_parse(&qemu_device_opts, arg_9p, 1)) {
 | 
					                if (!qemu_opts_parse(qemu_find_opts("device"), arg_9p, 1)) {
 | 
				
			||||||
                    fprintf(stderr, "parse error [device]: %s\n", optarg);
 | 
					                    fprintf(stderr, "parse error [device]: %s\n", optarg);
 | 
				
			||||||
                    exit(1);
 | 
					                    exit(1);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
| 
						 | 
					@ -2432,7 +2438,7 @@ int main(int argc, char **argv, char **envp)
 | 
				
			||||||
                add_device_config(DEV_USB, optarg);
 | 
					                add_device_config(DEV_USB, optarg);
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            case QEMU_OPTION_device:
 | 
					            case QEMU_OPTION_device:
 | 
				
			||||||
                if (!qemu_opts_parse(&qemu_device_opts, optarg, 1)) {
 | 
					                if (!qemu_opts_parse(qemu_find_opts("device"), optarg, 1)) {
 | 
				
			||||||
                    exit(1);
 | 
					                    exit(1);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
| 
						 | 
					@ -2528,7 +2534,7 @@ int main(int argc, char **argv, char **envp)
 | 
				
			||||||
                configure_rtc_date_offset(optarg, 1);
 | 
					                configure_rtc_date_offset(optarg, 1);
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            case QEMU_OPTION_rtc:
 | 
					            case QEMU_OPTION_rtc:
 | 
				
			||||||
                opts = qemu_opts_parse(&qemu_rtc_opts, optarg, 0);
 | 
					                opts = qemu_opts_parse(qemu_find_opts("rtc"), optarg, 0);
 | 
				
			||||||
                if (!opts) {
 | 
					                if (!opts) {
 | 
				
			||||||
                    exit(1);
 | 
					                    exit(1);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
| 
						 | 
					@ -2636,8 +2642,8 @@ int main(int argc, char **argv, char **envp)
 | 
				
			||||||
        exit(1);
 | 
					        exit(1);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    qemu_opts_foreach(&qemu_device_opts, default_driver_check, NULL, 0);
 | 
					    qemu_opts_foreach(qemu_find_opts("device"), default_driver_check, NULL, 0);
 | 
				
			||||||
    qemu_opts_foreach(&qemu_global_opts, default_driver_check, NULL, 0);
 | 
					    qemu_opts_foreach(qemu_find_opts("global"), default_driver_check, NULL, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (machine->no_serial) {
 | 
					    if (machine->no_serial) {
 | 
				
			||||||
        default_serial = 0;
 | 
					        default_serial = 0;
 | 
				
			||||||
| 
						 | 
					@ -2691,10 +2697,10 @@ int main(int argc, char **argv, char **envp)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    socket_init();
 | 
					    socket_init();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (qemu_opts_foreach(&qemu_chardev_opts, chardev_init_func, NULL, 1) != 0)
 | 
					    if (qemu_opts_foreach(qemu_find_opts("chardev"), chardev_init_func, NULL, 1) != 0)
 | 
				
			||||||
        exit(1);
 | 
					        exit(1);
 | 
				
			||||||
#ifdef CONFIG_VIRTFS
 | 
					#ifdef CONFIG_VIRTFS
 | 
				
			||||||
    if (qemu_opts_foreach(&qemu_fsdev_opts, fsdev_init_func, NULL, 1) != 0) {
 | 
					    if (qemu_opts_foreach(qemu_find_opts("fsdev"), fsdev_init_func, NULL, 1) != 0) {
 | 
				
			||||||
        exit(1);
 | 
					        exit(1);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					@ -2778,8 +2784,8 @@ int main(int argc, char **argv, char **envp)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* open the virtual block devices */
 | 
					    /* open the virtual block devices */
 | 
				
			||||||
    if (snapshot)
 | 
					    if (snapshot)
 | 
				
			||||||
        qemu_opts_foreach(&qemu_drive_opts, drive_enable_snapshot, NULL, 0);
 | 
					        qemu_opts_foreach(qemu_find_opts("drive"), drive_enable_snapshot, NULL, 0);
 | 
				
			||||||
    if (qemu_opts_foreach(&qemu_drive_opts, drive_init_func, &machine->use_scsi, 1) != 0)
 | 
					    if (qemu_opts_foreach(qemu_find_opts("drive"), drive_init_func, &machine->use_scsi, 1) != 0)
 | 
				
			||||||
        exit(1);
 | 
					        exit(1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    register_savevm_live(NULL, "ram", 0, 4, NULL, ram_save_live, NULL,
 | 
					    register_savevm_live(NULL, "ram", 0, 4, NULL, ram_save_live, NULL,
 | 
				
			||||||
| 
						 | 
					@ -2827,7 +2833,7 @@ int main(int argc, char **argv, char **envp)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (qemu_opts_foreach(&qemu_mon_opts, mon_init_func, NULL, 1) != 0) {
 | 
					    if (qemu_opts_foreach(qemu_find_opts("mon"), mon_init_func, NULL, 1) != 0) {
 | 
				
			||||||
        exit(1);
 | 
					        exit(1);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2842,7 +2848,7 @@ int main(int argc, char **argv, char **envp)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    module_call_init(MODULE_INIT_DEVICE);
 | 
					    module_call_init(MODULE_INIT_DEVICE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (qemu_opts_foreach(&qemu_device_opts, device_help_func, NULL, 0) != 0)
 | 
					    if (qemu_opts_foreach(qemu_find_opts("device"), device_help_func, NULL, 0) != 0)
 | 
				
			||||||
        exit(0);
 | 
					        exit(0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (watchdog) {
 | 
					    if (watchdog) {
 | 
				
			||||||
| 
						 | 
					@ -2875,7 +2881,7 @@ int main(int argc, char **argv, char **envp)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* init generic devices */
 | 
					    /* init generic devices */
 | 
				
			||||||
    if (qemu_opts_foreach(&qemu_device_opts, device_init_func, NULL, 1) != 0)
 | 
					    if (qemu_opts_foreach(qemu_find_opts("device"), device_init_func, NULL, 1) != 0)
 | 
				
			||||||
        exit(1);
 | 
					        exit(1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    net_check_clients();
 | 
					    net_check_clients();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue