aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MAINTAINERS1
-rw-r--r--audio/meson.build2
-rw-r--r--block/sheepdog.c14
-rw-r--r--chardev/meson.build7
-rw-r--r--chardev/spice.c37
-rwxr-xr-xconfigure5
-rw-r--r--docs/system/deprecated.rst15
-rw-r--r--hw/core/machine.c12
-rw-r--r--hw/i386/fw_cfg.c2
-rw-r--r--hw/i386/kvm/apic.c5
-rw-r--r--hw/i386/kvm/ioapic.c33
-rw-r--r--hw/i386/microvm.c2
-rw-r--r--hw/i386/pc.c2
-rw-r--r--include/chardev/spice.h4
-rw-r--r--include/hw/core/cpu.h3
-rw-r--r--include/qemu/help_option.h11
-rw-r--r--include/qemu/module.h8
-rw-r--r--include/qemu/option.h2
-rw-r--r--include/qom/object_interfaces.h21
-rw-r--r--include/sysemu/kvm.h19
-rw-r--r--include/ui/qemu-spice.h1
-rw-r--r--meson.build2
-rw-r--r--monitor/meson.build2
-rw-r--r--monitor/monitor.c33
-rw-r--r--qapi/machine-target.json7
-rw-r--r--qapi/qobject-input-visitor.c2
-rw-r--r--qom/object_interfaces.c99
-rw-r--r--softmmu/qtest.c2
-rw-r--r--softmmu/vl.c9
-rw-r--r--storage-daemon/qemu-storage-daemon.c15
-rw-r--r--target/i386/cpu.c32
-rw-r--r--target/i386/kvm-stub.c5
-rw-r--r--target/i386/kvm.c19
-rw-r--r--target/i386/kvm_i386.h1
-rw-r--r--tests/test-keyval.c186
-rw-r--r--ui/meson.build2
-rw-r--r--ui/spice-app.c34
-rw-r--r--ui/spice-core.c2
-rw-r--r--util/keyval.c103
-rw-r--r--util/module.c26
40 files changed, 491 insertions, 296 deletions
diff --git a/MAINTAINERS b/MAINTAINERS
index 47dd38a8cc..99ab02bbab 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2881,7 +2881,6 @@ F: block/rbd.c
Sheepdog
M: Liu Yuan <namei.unix@gmail.com>
L: qemu-block@nongnu.org
-L: sheepdog@lists.wpkg.org
S: Odd Fixes
F: block/sheepdog.c
diff --git a/audio/meson.build b/audio/meson.build
index 18a831129e..7d53b0f920 100644
--- a/audio/meson.build
+++ b/audio/meson.build
@@ -1,5 +1,5 @@
+softmmu_ss.add([spice_headers, files('audio.c')])
softmmu_ss.add(files(
- 'audio.c',
'audio_legacy.c',
'mixeng.c',
'noaudio.c',
diff --git a/block/sheepdog.c b/block/sheepdog.c
index 25111d5a70..a45c73826d 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -242,6 +242,16 @@ typedef struct SheepdogInode {
*/
#define FNV1A_64_INIT ((uint64_t)0xcbf29ce484222325ULL)
+static void deprecation_warning(void)
+{
+ static bool warned;
+
+ if (!warned) {
+ warn_report("the sheepdog block driver is deprecated");
+ warned = true;
+ }
+}
+
/*
* 64 bit Fowler/Noll/Vo FNV-1a hash code
*/
@@ -1548,6 +1558,8 @@ static int sd_open(BlockDriverState *bs, QDict *options, int flags,
char *buf = NULL;
QemuOpts *opts;
+ deprecation_warning();
+
s->bs = bs;
s->aio_context = bdrv_get_aio_context(bs);
@@ -2007,6 +2019,8 @@ static int sd_co_create(BlockdevCreateOptions *options, Error **errp)
assert(options->driver == BLOCKDEV_DRIVER_SHEEPDOG);
+ deprecation_warning();
+
s = g_new0(BDRVSheepdogState, 1);
/* Steal SocketAddress from QAPI, set NULL to prevent double free */
diff --git a/chardev/meson.build b/chardev/meson.build
index dd2699a11b..859d8b04d4 100644
--- a/chardev/meson.build
+++ b/chardev/meson.build
@@ -26,7 +26,6 @@ chardev_ss.add(when: 'CONFIG_WIN32', if_true: files(
chardev_ss = chardev_ss.apply(config_host, strict: false)
softmmu_ss.add(files('chardev-sysemu.c', 'msmouse.c', 'wctablet.c', 'testdev.c'))
-softmmu_ss.add(when: ['CONFIG_SPICE', spice], if_true: files('spice.c'))
chardev_modules = {}
@@ -36,4 +35,10 @@ if config_host.has_key('CONFIG_BRLAPI')
chardev_modules += { 'baum': module_ss }
endif
+if config_host.has_key('CONFIG_SPICE')
+ module_ss = ss.source_set()
+ module_ss.add(when: [spice], if_true: files('spice.c'))
+ chardev_modules += { 'spice': module_ss }
+endif
+
modules += { 'chardev': chardev_modules }
diff --git a/chardev/spice.c b/chardev/spice.c
index bf7ea1e294..7d1fb17718 100644
--- a/chardev/spice.c
+++ b/chardev/spice.c
@@ -14,9 +14,6 @@ typedef struct SpiceCharSource {
SpiceChardev *scd;
} SpiceCharSource;
-static QLIST_HEAD(, SpiceChardev) spice_chars =
- QLIST_HEAD_INITIALIZER(spice_chars);
-
static int vmc_write(SpiceCharDeviceInstance *sin, const uint8_t *buf, int len)
{
SpiceChardev *scd = container_of(sin, SpiceChardev, sin);
@@ -216,8 +213,6 @@ static void char_spice_finalize(Object *obj)
vmc_unregister_interface(s);
- QLIST_SAFE_REMOVE(s, next);
-
g_free((char *)s->sin.subtype);
g_free((char *)s->sin.portname);
}
@@ -256,8 +251,6 @@ static void chr_open(Chardev *chr, const char *subtype)
s->active = false;
s->sin.subtype = g_strdup(subtype);
-
- QLIST_INSERT_HEAD(&spice_chars, s, next);
}
static void qemu_chr_open_spice_vmc(Chardev *chr,
@@ -296,10 +289,10 @@ static void qemu_chr_open_spice_vmc(Chardev *chr,
chr_open(chr, type);
}
-void qemu_chr_open_spice_port(Chardev *chr,
- ChardevBackend *backend,
- bool *be_opened,
- Error **errp)
+static void qemu_chr_open_spice_port(Chardev *chr,
+ ChardevBackend *backend,
+ bool *be_opened,
+ Error **errp)
{
ChardevSpicePort *spiceport = backend->u.spiceport.data;
const char *name = spiceport->fqdn;
@@ -310,28 +303,18 @@ void qemu_chr_open_spice_port(Chardev *chr,
return;
}
+ if (!using_spice) {
+ error_setg(errp, "spice not enabled");
+ return;
+ }
+
chr_open(chr, "port");
*be_opened = false;
s = SPICE_CHARDEV(chr);
s->sin.portname = g_strdup(name);
- if (using_spice) {
- /* spice server already created */
- vmc_register_interface(s);
- }
-}
-
-void qemu_spice_register_ports(void)
-{
- SpiceChardev *s;
-
- QLIST_FOREACH(s, &spice_chars, next) {
- if (s->sin.portname == NULL) {
- continue;
- }
- vmc_register_interface(s);
- }
+ vmc_register_interface(s);
}
static void qemu_chr_parse_spice_vmc(QemuOpts *opts, ChardevBackend *backend,
diff --git a/configure b/configure
index 7b0589a0c4..a73fb8756e 100755
--- a/configure
+++ b/configure
@@ -434,7 +434,7 @@ vdi="yes"
vvfat="yes"
qed="yes"
parallels="yes"
-sheepdog="yes"
+sheepdog="no"
libxml2=""
debug_mutex="no"
libpmem=""
@@ -1824,7 +1824,7 @@ disabled with --disable-FEATURE, default is enabled if available:
vvfat vvfat image format support
qed qed image format support
parallels parallels image format support
- sheepdog sheepdog block driver support
+ sheepdog sheepdog block driver support (deprecated)
crypto-afalg Linux AF_ALG crypto backend driver
capstone capstone disassembler support
debug-mutex mutex debugging support
@@ -6683,6 +6683,7 @@ if test "$parallels" = "yes" ; then
echo "CONFIG_PARALLELS=y" >> $config_host_mak
fi
if test "$sheepdog" = "yes" ; then
+ add_to deprecated_features "sheepdog"
echo "CONFIG_SHEEPDOG=y" >> $config_host_mak
fi
if test "$pty_h" = "yes" ; then
diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
index 09ec8b1ae8..905628f3a0 100644
--- a/docs/system/deprecated.rst
+++ b/docs/system/deprecated.rst
@@ -314,6 +314,12 @@ a future version of QEMU. Support for this CPU was removed from the
upstream Linux kernel, and there is no available upstream toolchain
to build binaries for it.
+``Icelake-Client`` CPU Model (since 5.2.0)
+''''''''''''''''''''''''''''''''''''''''''
+
+``Icelake-Client`` CPU Models are deprecated. Use ``Icelake-Server`` CPU
+Models instead.
+
System emulator devices
-----------------------
@@ -390,6 +396,15 @@ The above, converted to the current supported format::
json:{"file.driver":"rbd", "file.pool":"rbd", "file.image":"name"}
+``sheepdog`` driver (since 5.2.0)
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The ``sheepdog`` block device driver is deprecated. The corresponding upstream
+server project is no longer actively maintained. Users are recommended to switch
+to an alternative distributed block device driver such as RBD. The
+``qemu-img convert`` command can be used to liberate existing data by moving
+it out of sheepdog volumes into an alternative storage backend.
+
linux-user mode CPUs
--------------------
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 7e2f4ec08e..d740a7e963 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -1087,6 +1087,8 @@ MemoryRegion *machine_consume_memdev(MachineState *machine,
void machine_run_board_init(MachineState *machine)
{
MachineClass *machine_class = MACHINE_GET_CLASS(machine);
+ ObjectClass *oc = object_class_by_name(machine->cpu_type);
+ CPUClass *cc;
if (machine->ram_memdev_id) {
Object *o;
@@ -1106,11 +1108,10 @@ void machine_run_board_init(MachineState *machine)
* specified a CPU with -cpu check here that the user CPU is supported.
*/
if (machine_class->valid_cpu_types && machine->cpu_type) {
- ObjectClass *class = object_class_by_name(machine->cpu_type);
int i;
for (i = 0; machine_class->valid_cpu_types[i]; i++) {
- if (object_class_dynamic_cast(class,
+ if (object_class_dynamic_cast(oc,
machine_class->valid_cpu_types[i])) {
/* The user specificed CPU is in the valid field, we are
* good to go.
@@ -1133,6 +1134,13 @@ void machine_run_board_init(MachineState *machine)
}
}
+ /* Check if CPU type is deprecated and warn if so */
+ cc = CPU_CLASS(oc);
+ if (cc && cc->deprecation_note) {
+ warn_report("CPU model %s is deprecated -- %s", machine->cpu_type,
+ cc->deprecation_note);
+ }
+
machine_class->init(machine);
}
diff --git a/hw/i386/fw_cfg.c b/hw/i386/fw_cfg.c
index 33441ad484..e06579490c 100644
--- a/hw/i386/fw_cfg.c
+++ b/hw/i386/fw_cfg.c
@@ -123,7 +123,7 @@ FWCfgState *fw_cfg_arch_create(MachineState *ms,
fw_cfg_add_bytes(fw_cfg, FW_CFG_ACPI_TABLES,
acpi_tables, acpi_tables_len);
#endif
- fw_cfg_add_i32(fw_cfg, FW_CFG_IRQ0_OVERRIDE, kvm_allows_irq0_override());
+ fw_cfg_add_i32(fw_cfg, FW_CFG_IRQ0_OVERRIDE, 1);
fw_cfg_add_bytes(fw_cfg, FW_CFG_E820_TABLE,
&e820_reserve, sizeof(e820_reserve));
diff --git a/hw/i386/kvm/apic.c b/hw/i386/kvm/apic.c
index 4eb2d77b87..dd29906061 100644
--- a/hw/i386/kvm/apic.c
+++ b/hw/i386/kvm/apic.c
@@ -225,9 +225,8 @@ static void kvm_apic_realize(DeviceState *dev, Error **errp)
memory_region_init_io(&s->io_memory, OBJECT(s), &kvm_apic_io_ops, s,
"kvm-apic-msi", APIC_SPACE_SIZE);
- if (kvm_has_gsi_routing()) {
- msi_nonbroken = true;
- }
+ assert(kvm_has_gsi_routing());
+ msi_nonbroken = true;
}
static void kvm_apic_unrealize(DeviceState *dev)
diff --git a/hw/i386/kvm/ioapic.c b/hw/i386/kvm/ioapic.c
index c5528df942..dfc3c98005 100644
--- a/hw/i386/kvm/ioapic.c
+++ b/hw/i386/kvm/ioapic.c
@@ -25,27 +25,26 @@ void kvm_pc_setup_irq_routing(bool pci_enabled)
KVMState *s = kvm_state;
int i;
- if (kvm_check_extension(s, KVM_CAP_IRQ_ROUTING)) {
- for (i = 0; i < 8; ++i) {
- if (i == 2) {
- continue;
- }
- kvm_irqchip_add_irq_route(s, i, KVM_IRQCHIP_PIC_MASTER, i);
- }
- for (i = 8; i < 16; ++i) {
- kvm_irqchip_add_irq_route(s, i, KVM_IRQCHIP_PIC_SLAVE, i - 8);
+ assert(kvm_has_gsi_routing());
+ for (i = 0; i < 8; ++i) {
+ if (i == 2) {
+ continue;
}
- if (pci_enabled) {
- for (i = 0; i < 24; ++i) {
- if (i == 0) {
- kvm_irqchip_add_irq_route(s, i, KVM_IRQCHIP_IOAPIC, 2);
- } else if (i != 2) {
- kvm_irqchip_add_irq_route(s, i, KVM_IRQCHIP_IOAPIC, i);
- }
+ kvm_irqchip_add_irq_route(s, i, KVM_IRQCHIP_PIC_MASTER, i);
+ }
+ for (i = 8; i < 16; ++i) {
+ kvm_irqchip_add_irq_route(s, i, KVM_IRQCHIP_PIC_SLAVE, i - 8);
+ }
+ if (pci_enabled) {
+ for (i = 0; i < 24; ++i) {
+ if (i == 0) {
+ kvm_irqchip_add_irq_route(s, i, KVM_IRQCHIP_IOAPIC, 2);
+ } else if (i != 2) {
+ kvm_irqchip_add_irq_route(s, i, KVM_IRQCHIP_IOAPIC, i);
}
}
- kvm_irqchip_commit_routes(s);
}
+ kvm_irqchip_commit_routes(s);
}
typedef struct KVMIOAPICState KVMIOAPICState;
diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c
index 73a7a142b4..68a7f424ac 100644
--- a/hw/i386/microvm.c
+++ b/hw/i386/microvm.c
@@ -290,7 +290,7 @@ static void microvm_memory_init(MicrovmMachineState *mms)
fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, machine->smp.cpus);
fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, machine->smp.max_cpus);
fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)machine->ram_size);
- fw_cfg_add_i32(fw_cfg, FW_CFG_IRQ0_OVERRIDE, kvm_allows_irq0_override());
+ fw_cfg_add_i32(fw_cfg, FW_CFG_IRQ0_OVERRIDE, 1);
fw_cfg_add_bytes(fw_cfg, FW_CFG_E820_TABLE,
&e820_reserve, sizeof(e820_reserve));
fw_cfg_add_file(fw_cfg, "etc/e820", e820_table,
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index e87be5d29a..4e323755d0 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -827,7 +827,7 @@ void pc_guest_info_init(PCMachineState *pcms)
MachineState *ms = MACHINE(pcms);
X86MachineState *x86ms = X86_MACHINE(pcms);
- x86ms->apic_xrupt_override = kvm_allows_irq0_override();
+ x86ms->apic_xrupt_override = true;
pcms->numa_nodes = ms->numa_state->num_nodes;
pcms->node_mem = g_malloc0(pcms->numa_nodes *
sizeof *pcms->node_mem);
diff --git a/include/chardev/spice.h b/include/chardev/spice.h
index 99f26aedde..58e5b727e9 100644
--- a/include/chardev/spice.h
+++ b/include/chardev/spice.h
@@ -13,7 +13,6 @@ struct SpiceChardev {
bool blocked;
const uint8_t *datapos;
int datalen;
- QLIST_ENTRY(SpiceChardev) next;
};
typedef struct SpiceChardev SpiceChardev;
@@ -24,7 +23,4 @@ typedef struct SpiceChardev SpiceChardev;
DECLARE_INSTANCE_CHECKER(SpiceChardev, SPICE_CHARDEV,
TYPE_CHARDEV_SPICE)
-void qemu_chr_open_spice_port(Chardev *chr, ChardevBackend *backend,
- bool *be_opened, Error **errp);
-
#endif
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index 4879f25026..9c3a45ad7b 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -155,6 +155,8 @@ struct TranslationBlock;
* @disas_set_info: Setup architecture specific components of disassembly info
* @adjust_watchpoint_address: Perform a target-specific adjustment to an
* address before attempting to match it against watchpoints.
+ * @deprecation_note: If this CPUClass is deprecated, this field provides
+ * related information.
*
* Represents a CPU family or model.
*/
@@ -221,6 +223,7 @@ struct CPUClass {
vaddr (*adjust_watchpoint_address)(CPUState *cpu, vaddr addr, int len);
void (*tcg_initialize)(void);
+ const char *deprecation_note;
/* Keep non-pointer data at the end to minimize holes. */
int gdb_num_core_regs;
bool gdb_stop_before_watchpoint;
diff --git a/include/qemu/help_option.h b/include/qemu/help_option.h
index 328d2a89fd..ca6389a154 100644
--- a/include/qemu/help_option.h
+++ b/include/qemu/help_option.h
@@ -19,4 +19,15 @@ static inline bool is_help_option(const char *s)
return !strcmp(s, "?") || !strcmp(s, "help");
}
+static inline int starts_with_help_option(const char *s)
+{
+ if (*s == '?') {
+ return 1;
+ }
+ if (g_str_has_prefix(s, "help")) {
+ return 4;
+ }
+ return 0;
+}
+
#endif
diff --git a/include/qemu/module.h b/include/qemu/module.h
index 9121a475c1..944d403cbd 100644
--- a/include/qemu/module.h
+++ b/include/qemu/module.h
@@ -61,15 +61,15 @@ typedef enum {
#define fuzz_target_init(function) module_init(function, \
MODULE_INIT_FUZZ_TARGET)
#define migration_init(function) module_init(function, MODULE_INIT_MIGRATION)
-#define block_module_load_one(lib) module_load_one("block-", lib)
-#define ui_module_load_one(lib) module_load_one("ui-", lib)
-#define audio_module_load_one(lib) module_load_one("audio-", lib)
+#define block_module_load_one(lib) module_load_one("block-", lib, false)
+#define ui_module_load_one(lib) module_load_one("ui-", lib, false)
+#define audio_module_load_one(lib) module_load_one("audio-", lib, false)
void register_module_init(void (*fn)(void), module_init_type type);
void register_dso_module_init(void (*fn)(void), module_init_type type);
void module_call_init(module_init_type type);
-bool module_load_one(const char *prefix, const char *lib_name);
+bool module_load_one(const char *prefix, const char *lib_name, bool mayfail);
void module_load_qom_one(const char *type);
void module_load_qom_all(void);
diff --git a/include/qemu/option.h b/include/qemu/option.h
index 05e8a15c73..ac69352e0e 100644
--- a/include/qemu/option.h
+++ b/include/qemu/option.h
@@ -149,6 +149,6 @@ void qemu_opts_free(QemuOptsList *list);
QemuOptsList *qemu_opts_append(QemuOptsList *dst, QemuOptsList *list);
QDict *keyval_parse(const char *params, const char *implied_key,
- Error **errp);
+ bool *help, Error **errp);
#endif
diff --git a/include/qom/object_interfaces.h b/include/qom/object_interfaces.h
index f118fb516b..07d5cc8832 100644
--- a/include/qom/object_interfaces.h
+++ b/include/qom/object_interfaces.h
@@ -154,14 +154,29 @@ int user_creatable_add_opts_foreach(void *opaque,
* @type: the QOM type to be added
* @opts: options to create
*
- * Prints help if requested in @opts.
+ * Prints help if requested in @type or @opts. Note that if @type is neither
+ * "help"/"?" nor a valid user creatable type, no help will be printed
+ * regardless of @opts.
*
- * Returns: true if @opts contained a help option and help was printed, false
- * if no help option was found.
+ * Returns: true if a help option was found and help was printed, false
+ * otherwise.
*/
bool user_creatable_print_help(const char *type, QemuOpts *opts);
/**
+ * user_creatable_print_help_from_qdict:
+ * @args: options to create
+ *
+ * Prints help considering the other options given in @args (if "qom-type" is
+ * given and valid, print properties for the type, otherwise print valid types)
+ *
+ * In contrast to user_creatable_print_help(), this function can't return that
+ * no help was requested. It should only be called if we know that help is
+ * requested and it will always print some help.
+ */
+void user_creatable_print_help_from_qdict(QDict *args);
+
+/**
* user_creatable_del:
* @id: the unique ID for the object
* @errp: if an error occurs, a pointer to an area to store the error
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index fe7dab1466..bb5d5cf497 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -51,23 +51,22 @@ extern bool kvm_msi_use_devid;
/**
* kvm_irqchip_in_kernel:
*
- * Returns: true if the user asked us to create an in-kernel
- * irqchip via the "kernel_irqchip=on" machine option.
+ * Returns: true if an in-kernel irqchip was created.
* What this actually means is architecture and machine model
- * specific: on PC, for instance, it means that the LAPIC,
- * IOAPIC and PIT are all in kernel. This function should never
- * be used from generic target-independent code: use one of the
- * following functions or some other specific check instead.
+ * specific: on PC, for instance, it means that the LAPIC
+ * is in kernel. This function should never be used from generic
+ * target-independent code: use one of the following functions or
+ * some other specific check instead.
*/
#define kvm_irqchip_in_kernel() (kvm_kernel_irqchip)
/**
* kvm_irqchip_is_split:
*
- * Returns: true if the user asked us to split the irqchip
- * implementation between user and kernel space. The details are
- * architecture and machine specific. On PC, it means that the PIC,
- * IOAPIC, and PIT are in user space while the LAPIC is in the kernel.
+ * Returns: true if the irqchip implementation is split between
+ * user and kernel space. The details are architecture and
+ * machine specific. On PC, it means that the PIC, IOAPIC, and
+ * PIT are in user space while the LAPIC is in the kernel.
*/
#define kvm_irqchip_is_split() (kvm_split_irqchip)
diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h
index 12474d88f4..0e8ec3f0d7 100644
--- a/include/ui/qemu-spice.h
+++ b/include/ui/qemu-spice.h
@@ -45,7 +45,6 @@ int qemu_spice_migrate_info(const char *hostname, int port, int tls_port,
#else
#define SPICE_NEEDS_SET_MM_TIME 0
#endif
-void qemu_spice_register_ports(void);
#else /* CONFIG_SPICE */
diff --git a/meson.build b/meson.build
index 05fb59a00b..7627a0ae46 100644
--- a/meson.build
+++ b/meson.build
@@ -349,9 +349,11 @@ if 'CONFIG_LIBJACK' in config_host
jack = declare_dependency(link_args: config_host['JACK_LIBS'].split())
endif
spice = not_found
+spice_headers = not_found
if 'CONFIG_SPICE' in config_host
spice = declare_dependency(compile_args: config_host['SPICE_CFLAGS'].split(),
link_args: config_host['SPICE_LIBS'].split())
+ spice_headers = declare_dependency(compile_args: config_host['SPICE_CFLAGS'].split())
endif
rt = cc.find_library('rt', required: false)
libdl = not_found
diff --git a/monitor/meson.build b/monitor/meson.build
index eb2a534fdc..6d00985ace 100644
--- a/monitor/meson.build
+++ b/monitor/meson.build
@@ -3,7 +3,7 @@ qmp_ss.add(files('monitor.c', 'qmp.c', 'qmp-cmds-control.c'))
softmmu_ss.add(files(
'hmp-cmds.c',
'hmp.c',
- 'qmp-cmds.c',
))
+softmmu_ss.add([spice_headers, files('qmp-cmds.c')])
specific_ss.add(when: 'CONFIG_SOFTMMU', if_true: [files('misc.c'), spice])
diff --git a/monitor/monitor.c b/monitor/monitor.c
index ceffe1a83b..84222cd130 100644
--- a/monitor/monitor.c
+++ b/monitor/monitor.c
@@ -632,23 +632,9 @@ void monitor_cleanup(void)
iothread_stop(mon_iothread);
}
- /* Flush output buffers and destroy monitors */
- qemu_mutex_lock(&monitor_lock);
- monitor_destroyed = true;
- while (!QTAILQ_EMPTY(&mon_list)) {
- Monitor *mon = QTAILQ_FIRST(&mon_list);
- QTAILQ_REMOVE(&mon_list, mon, entry);
- /* Permit QAPI event emission from character frontend release */
- qemu_mutex_unlock(&monitor_lock);
- monitor_flush(mon);
- monitor_data_destroy(mon);
- qemu_mutex_lock(&monitor_lock);
- g_free(mon);
- }
- qemu_mutex_unlock(&monitor_lock);
-
/*
- * The dispatcher needs to stop before destroying the I/O thread.
+ * The dispatcher needs to stop before destroying the monitor and
+ * the I/O thread.
*
* We need to poll both qemu_aio_context and iohandler_ctx to make
* sure that the dispatcher coroutine keeps making progress and
@@ -665,6 +651,21 @@ void monitor_cleanup(void)
(aio_poll(iohandler_get_aio_context(), false),
qatomic_mb_read(&qmp_dispatcher_co_busy)));
+ /* Flush output buffers and destroy monitors */
+ qemu_mutex_lock(&monitor_lock);
+ monitor_destroyed = true;
+ while (!QTAILQ_EMPTY(&mon_list)) {
+ Monitor *mon = QTAILQ_FIRST(&mon_list);
+ QTAILQ_REMOVE(&mon_list, mon, entry);
+ /* Permit QAPI event emission from character frontend release */
+ qemu_mutex_unlock(&monitor_lock);
+ monitor_flush(mon);
+ monitor_data_destroy(mon);
+ qemu_mutex_lock(&monitor_lock);
+ g_free(mon);
+ }
+ qemu_mutex_unlock(&monitor_lock);
+
if (mon_iothread) {
iothread_destroy(mon_iothread);
mon_iothread = NULL;
diff --git a/qapi/machine-target.json b/qapi/machine-target.json
index 698850cc78..fec3bb8679 100644
--- a/qapi/machine-target.json
+++ b/qapi/machine-target.json
@@ -286,6 +286,10 @@
# in the VM configuration, because aliases may stop being
# migration-safe in the future (since 4.1)
#
+# @deprecated: If true, this CPU model is deprecated and may be removed in
+# in some future version of QEMU according to the QEMU deprecation
+# policy. (since 5.2)
+#
# @unavailable-features is a list of QOM property names that
# represent CPU model attributes that prevent the CPU from running.
# If the QOM property is read-only, that means there's no known
@@ -310,7 +314,8 @@
'static': 'bool',
'*unavailable-features': [ 'str' ],
'typename': 'str',
- '*alias-of' : 'str' },
+ '*alias-of' : 'str',
+ 'deprecated' : 'bool' },
'if': 'defined(TARGET_PPC) || defined(TARGET_ARM) || defined(TARGET_I386) || defined(TARGET_S390X) || defined(TARGET_MIPS)' }
##
diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c
index f918a05e5f..7b184b50a7 100644
--- a/qapi/qobject-input-visitor.c
+++ b/qapi/qobject-input-visitor.c
@@ -757,7 +757,7 @@ Visitor *qobject_input_visitor_new_str(const char *str,
assert(args);
v = qobject_input_visitor_new(QOBJECT(args));
} else {
- args = keyval_parse(str, implied_key, errp);
+ args = keyval_parse(str, implied_key, NULL, errp);
if (!args) {
return NULL;
}
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index e8e1523960..ed896fe764 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -214,57 +214,80 @@ char *object_property_help(const char *name, const char *type,
return g_string_free(str, false);
}
-bool user_creatable_print_help(const char *type, QemuOpts *opts)
+static void user_creatable_print_types(void)
+{
+ GSList *l, *list;
+
+ printf("List of user creatable objects:\n");
+ list = object_class_get_list_sorted(TYPE_USER_CREATABLE, false);
+ for (l = list; l != NULL; l = l->next) {
+ ObjectClass *oc = OBJECT_CLASS(l->data);
+ printf(" %s\n", object_class_get_name(oc));
+ }
+ g_slist_free(list);
+}
+
+static bool user_creatable_print_type_properites(const char *type)
{
ObjectClass *klass;
+ ObjectPropertyIterator iter;
+ ObjectProperty *prop;
+ GPtrArray *array;
+ int i;
- if (is_help_option(type)) {
- GSList *l, *list;
+ klass = object_class_by_name(type);
+ if (!klass) {
+ return false;
+ }
- printf("List of user creatable objects:\n");
- list = object_class_get_list_sorted(TYPE_USER_CREATABLE, false);
- for (l = list; l != NULL; l = l->next) {
- ObjectClass *oc = OBJECT_CLASS(l->data);
- printf(" %s\n", object_class_get_name(oc));
+ array = g_ptr_array_new();
+ object_class_property_iter_init(&iter, klass);
+ while ((prop = object_property_iter_next(&iter))) {
+ if (!prop->set) {
+ continue;
}
- g_slist_free(list);
- return true;
+
+ g_ptr_array_add(array,
+ object_property_help(prop->name, prop->type,
+ prop->defval, prop->description));
+ }
+ g_ptr_array_sort(array, (GCompareFunc)qemu_pstrcmp0);
+ if (array->len > 0) {
+ printf("%s options:\n", type);
+ } else {
+ printf("There are no options for %s.\n", type);
+ }
+ for (i = 0; i < array->len; i++) {
+ printf("%s\n", (char *)array->pdata[i]);
}
+ g_ptr_array_set_free_func(array, g_free);
+ g_ptr_array_free(array, true);
+ return true;
+}
- klass = object_class_by_name(type);
- if (klass && qemu_opt_has_help_opt(opts)) {
- ObjectPropertyIterator iter;
- ObjectProperty *prop;
- GPtrArray *array = g_ptr_array_new();
- int i;
-
- object_class_property_iter_init(&iter, klass);
- while ((prop = object_property_iter_next(&iter))) {
- if (!prop->set) {
- continue;
- }
-
- g_ptr_array_add(array,
- object_property_help(prop->name, prop->type,
- prop->defval, prop->description));
- }
- g_ptr_array_sort(array, (GCompareFunc)qemu_pstrcmp0);
- if (array->len > 0) {
- printf("%s options:\n", type);
- } else {
- printf("There are no options for %s.\n", type);
- }
- for (i = 0; i < array->len; i++) {
- printf("%s\n", (char *)array->pdata[i]);
- }
- g_ptr_array_set_free_func(array, g_free);
- g_ptr_array_free(array, true);
+bool user_creatable_print_help(const char *type, QemuOpts *opts)
+{
+ if (is_help_option(type)) {
+ user_creatable_print_types();
return true;
}
+ if (qemu_opt_has_help_opt(opts)) {
+ return user_creatable_print_type_properites(type);
+ }
+
return false;
}
+void user_creatable_print_help_from_qdict(QDict *args)
+{
+ const char *type = qdict_get_try_str(args, "qom-type");
+
+ if (!type || !user_creatable_print_type_properites(type)) {
+ user_creatable_print_types();
+ }
+}
+
bool user_creatable_del(const char *id, Error **errp)
{
Object *container;
diff --git a/softmmu/qtest.c b/softmmu/qtest.c
index 2c6e8dc858..7965dc9a16 100644
--- a/softmmu/qtest.c
+++ b/softmmu/qtest.c
@@ -757,7 +757,7 @@ static void qtest_process_command(CharBackend *chr, gchar **words)
g_assert(words[1] && words[2]);
qtest_send_prefix(chr);
- if (module_load_one(words[1], words[2])) {
+ if (module_load_one(words[1], words[2], false)) {
qtest_sendf(chr, "OK\n");
} else {
qtest_sendf(chr, "FAIL\n");
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 254ee5e525..cb476aa70b 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -4148,6 +4148,11 @@ void qemu_init(int argc, char **argv, char **envp)
user_creatable_add_opts_foreach,
object_create_initial, &error_fatal);
+ /* spice needs the timers to be initialized by this point */
+ /* spice must initialize before audio as it changes the default auiodev */
+ /* spice must initialize before chardevs (for spicevmc and spiceport) */
+ qemu_spice_init();
+
qemu_opts_foreach(qemu_find_opts("chardev"),
chardev_init_func, NULL, &error_fatal);
@@ -4156,10 +4161,6 @@ void qemu_init(int argc, char **argv, char **envp)
fsdev_init_func, NULL, &error_fatal);
#endif
- /* spice needs the timers to be initialized by this point */
- /* spice must initialize before audio as it changes the default auiodev */
- qemu_spice_init();
-
/*
* Note: we need to create audio and block backends before
* machine_set_property(), so machine properties can refer to
diff --git a/storage-daemon/qemu-storage-daemon.c b/storage-daemon/qemu-storage-daemon.c
index 1ae1cda481..e419ba9f19 100644
--- a/storage-daemon/qemu-storage-daemon.c
+++ b/storage-daemon/qemu-storage-daemon.c
@@ -264,21 +264,14 @@ static void process_options(int argc, char *argv[])
}
case OPTION_OBJECT:
{
- QemuOpts *opts;
- const char *type;
QDict *args;
+ bool help;
- /* FIXME The keyval parser rejects 'help' arguments, so we must
- * unconditionall try QemuOpts first. */
- opts = qemu_opts_parse(&qemu_object_opts,
- optarg, true, &error_fatal);
- type = qemu_opt_get(opts, "qom-type");
- if (type && user_creatable_print_help(type, opts)) {
+ args = keyval_parse(optarg, "qom-type", &help, &error_fatal);
+ if (help) {
+ user_creatable_print_help_from_qdict(args);
exit(EXIT_SUCCESS);
}
- qemu_opts_del(opts);
-
- args = keyval_parse(optarg, "qom-type", &error_fatal);
user_creatable_add_dict(args, true, &error_fatal);
qobject_unref(args);
break;
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 5d713c8528..0d8606958e 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -1633,6 +1633,7 @@ typedef struct X86CPUDefinition {
* If NULL, version 1 will be registered automatically.
*/
const X86CPUVersionDefinition *versions;
+ const char *deprecation_note;
} X86CPUDefinition;
/* Reference to a specific CPU model version */
@@ -3357,10 +3358,13 @@ static X86CPUDefinition builtin_x86_defs[] = {
.xlevel = 0x80000008,
.model_id = "Intel Core Processor (Icelake)",
.versions = (X86CPUVersionDefinition[]) {
- { .version = 1 },
+ {
+ .version = 1,
+ .note = "deprecated"
+ },
{
.version = 2,
- .note = "no TSX",
+ .note = "no TSX, deprecated",
.alias = "Icelake-Client-noTSX",
.props = (PropValue[]) {
{ "hle", "off" },
@@ -3369,7 +3373,8 @@ static X86CPUDefinition builtin_x86_defs[] = {
},
},
{ /* end of list */ }
- }
+ },
+ .deprecation_note = "use Icelake-Server instead"
},
{
.name = "Icelake-Server",
@@ -4180,9 +4185,6 @@ void x86_cpu_change_kvm_default(const char *prop, const char *value)
assert(pv->prop);
}
-static uint64_t x86_cpu_get_supported_feature_word(FeatureWord w,
- bool migratable_only);
-
static bool lmce_supported(void)
{
uint64_t mce_cap = 0;
@@ -4993,6 +4995,11 @@ static void x86_cpu_definition_entry(gpointer data, gpointer user_data)
info->migration_safe = cc->migration_safe;
info->has_migration_safe = true;
info->q_static = cc->static_model;
+ if (cc->model && cc->model->cpudef->deprecation_note) {
+ info->deprecated = true;
+ } else {
+ info->deprecated = false;
+ }
/*
* Old machine types won't report aliases, so that alias translation
* doesn't break compatibility with previous QEMU versions.
@@ -5383,9 +5390,11 @@ static void x86_cpu_cpudef_class_init(ObjectClass *oc, void *data)
{
X86CPUModel *model = data;
X86CPUClass *xcc = X86_CPU_CLASS(oc);
+ CPUClass *cc = CPU_CLASS(oc);
xcc->model = model;
xcc->migration_safe = true;
+ cc->deprecation_note = model->cpudef->deprecation_note;
}
static void x86_register_cpu_model_type(const char *name, X86CPUModel *model)
@@ -5913,9 +5922,14 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
}
break;
case 0x8000001E:
- assert(cpu->core_id <= 255);
- encode_topo_cpuid8000001e(cpu, &topo_info,
- eax, ebx, ecx, edx);
+ if (cpu->core_id <= 255) {
+ encode_topo_cpuid8000001e(cpu, &topo_info, eax, ebx, ecx, edx);
+ } else {
+ *eax = 0;
+ *ebx = 0;
+ *ecx = 0;
+ *edx = 0;
+ }
break;
case 0xC0000000:
*eax = env->cpuid_xlevel2;
diff --git a/target/i386/kvm-stub.c b/target/i386/kvm-stub.c
index 872ef7df4c..92f49121b8 100644
--- a/target/i386/kvm-stub.c
+++ b/target/i386/kvm-stub.c
@@ -13,11 +13,6 @@
#include "cpu.h"
#include "kvm_i386.h"
-bool kvm_allows_irq0_override(void)
-{
- return 1;
-}
-
#ifndef __OPTIMIZE__
bool kvm_has_smm(void)
{
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index 8b12387d30..cf46259534 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -154,11 +154,6 @@ bool kvm_has_exception_payload(void)
return has_exception_payload;
}
-bool kvm_allows_irq0_override(void)
-{
- return !kvm_irqchip_in_kernel() || kvm_has_gsi_routing();
-}
-
static bool kvm_x2apic_api_set_flags(uint64_t flags)
{
KVMState *s = KVM_STATE(current_accel());
@@ -1214,7 +1209,7 @@ static int hyperv_handle_properties(CPUState *cs,
if (c) {
env->features[FEAT_HYPERV_EAX] = c->eax;
env->features[FEAT_HYPERV_EBX] = c->ebx;
- env->features[FEAT_HYPERV_EDX] = c->eax;
+ env->features[FEAT_HYPERV_EDX] = c->edx;
}
c = cpuid_find_entry(cpuid, HV_CPUID_ENLIGHTMENT_INFO, 0);
if (c) {
@@ -2114,6 +2109,11 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
int ret;
struct utsname utsname;
+ if (!kvm_check_extension(s, KVM_CAP_IRQ_ROUTING)) {
+ error_report("kvm: KVM_CAP_IRQ_ROUTING not supported by KVM");
+ return -ENOTSUP;
+ }
+
has_xsave = kvm_check_extension(s, KVM_CAP_XSAVE);
has_xcrs = kvm_check_extension(s, KVM_CAP_XCRS);
has_pit_state2 = kvm_check_extension(s, KVM_CAP_PIT_STATE2);
@@ -4547,13 +4547,6 @@ bool kvm_arch_stop_on_emulation_error(CPUState *cs)
void kvm_arch_init_irq_routing(KVMState *s)
{
- if (!kvm_check_extension(s, KVM_CAP_IRQ_ROUTING)) {
- /* If kernel can't do irq routing, interrupt source
- * override 0->2 cannot be set up as required by HPET.
- * So we have to disable it.
- */
- no_hpet = 1;
- }
/* We know at this point that we're using the in-kernel
* irqchip, so we can use irqfds, and on x86 we know
* we can use msi via irqfd and GSI routing.
diff --git a/target/i386/kvm_i386.h b/target/i386/kvm_i386.h
index 0fce4e51d2..a4a619cebb 100644
--- a/target/i386/kvm_i386.h
+++ b/target/i386/kvm_i386.h
@@ -32,7 +32,6 @@
#endif /* CONFIG_KVM */
-bool kvm_allows_irq0_override(void);
bool kvm_has_smm(void);
bool kvm_has_adjust_clock(void);
bool kvm_has_adjust_clock_stable(void);
diff --git a/tests/test-keyval.c b/tests/test-keyval.c
index e331a84149..ee927fe4e4 100644
--- a/tests/test-keyval.c
+++ b/tests/test-keyval.c
@@ -27,27 +27,28 @@ static void test_keyval_parse(void)
QDict *qdict, *sub_qdict;
char long_key[129];
char *params;
+ bool help;
/* Nothing */
- qdict = keyval_parse("", NULL, &error_abort);
+ qdict = keyval_parse("", NULL, NULL, &error_abort);
g_assert_cmpuint(qdict_size(qdict), ==, 0);
qobject_unref(qdict);
/* Empty key (qemu_opts_parse() accepts this) */
- qdict = keyval_parse("=val", NULL, &err);
+ qdict = keyval_parse("=val", NULL, NULL, &err);
error_free_or_abort(&err);
g_assert(!qdict);
/* Empty key fragment */
- qdict = keyval_parse(".", NULL, &err);
+ qdict = keyval_parse(".", NULL, NULL, &err);
error_free_or_abort(&err);
g_assert(!qdict);
- qdict = keyval_parse("key.", NULL, &err);
+ qdict = keyval_parse("key.", NULL, NULL, &err);
error_free_or_abort(&err);
g_assert(!qdict);
/* Invalid non-empty key (qemu_opts_parse() doesn't care) */
- qdict = keyval_parse("7up=val", NULL, &err);
+ qdict = keyval_parse("7up=val", NULL, NULL, &err);
error_free_or_abort(&err);
g_assert(!qdict);
@@ -56,25 +57,25 @@ static void test_keyval_parse(void)
long_key[127] = 'z';
long_key[128] = 0;
params = g_strdup_printf("k.%s=v", long_key);
- qdict = keyval_parse(params + 2, NULL, &err);
+ qdict = keyval_parse(params + 2, NULL, NULL, &err);
error_free_or_abort(&err);
g_assert(!qdict);
/* Overlong key fragment */
- qdict = keyval_parse(params, NULL, &err);
+ qdict = keyval_parse(params, NULL, NULL, &err);
error_free_or_abort(&err);
g_assert(!qdict);
g_free(params);
/* Long key (qemu_opts_parse() accepts and truncates silently) */
params = g_strdup_printf("k.%s=v", long_key + 1);
- qdict = keyval_parse(params + 2, NULL, &error_abort);
+ qdict = keyval_parse(params + 2, NULL, NULL, &error_abort);
g_assert_cmpuint(qdict_size(qdict), ==, 1);
g_assert_cmpstr(qdict_get_try_str(qdict, long_key + 1), ==, "v");
qobject_unref(qdict);
/* Long key fragment */
- qdict = keyval_parse(params, NULL, &error_abort);
+ qdict = keyval_parse(params, NULL, NULL, &error_abort);
g_assert_cmpuint(qdict_size(qdict), ==, 1);
sub_qdict = qdict_get_qdict(qdict, "k");
g_assert(sub_qdict);
@@ -84,25 +85,25 @@ static void test_keyval_parse(void)
g_free(params);
/* Crap after valid key */
- qdict = keyval_parse("key[0]=val", NULL, &err);
+ qdict = keyval_parse("key[0]=val", NULL, NULL, &err);
error_free_or_abort(&err);
g_assert(!qdict);
/* Multiple keys, last one wins */
- qdict = keyval_parse("a=1,b=2,,x,a=3", NULL, &error_abort);
+ qdict = keyval_parse("a=1,b=2,,x,a=3", NULL, NULL, &error_abort);
g_assert_cmpuint(qdict_size(qdict), ==, 2);
g_assert_cmpstr(qdict_get_try_str(qdict, "a"), ==, "3");
g_assert_cmpstr(qdict_get_try_str(qdict, "b"), ==, "2,x");
qobject_unref(qdict);
/* Even when it doesn't in qemu_opts_parse() */
- qdict = keyval_parse("id=foo,id=bar", NULL, &error_abort);
+ qdict = keyval_parse("id=foo,id=bar", NULL, NULL, &error_abort);
g_assert_cmpuint(qdict_size(qdict), ==, 1);
g_assert_cmpstr(qdict_get_try_str(qdict, "id"), ==, "bar");
qobject_unref(qdict);
/* Dotted keys */
- qdict = keyval_parse("a.b.c=1,a.b.c=2,d=3", NULL, &error_abort);
+ qdict = keyval_parse("a.b.c=1,a.b.c=2,d=3", NULL, NULL, &error_abort);
g_assert_cmpuint(qdict_size(qdict), ==, 2);
sub_qdict = qdict_get_qdict(qdict, "a");
g_assert(sub_qdict);
@@ -115,48 +116,48 @@ static void test_keyval_parse(void)
qobject_unref(qdict);
/* Inconsistent dotted keys */
- qdict = keyval_parse("a.b=1,a=2", NULL, &err);
+ qdict = keyval_parse("a.b=1,a=2", NULL, NULL, &err);
error_free_or_abort(&err);
g_assert(!qdict);
- qdict = keyval_parse("a.b=1,a.b.c=2", NULL, &err);
+ qdict = keyval_parse("a.b=1,a.b.c=2", NULL, NULL, &err);
error_free_or_abort(&err);
g_assert(!qdict);
/* Trailing comma is ignored */
- qdict = keyval_parse("x=y,", NULL, &error_abort);
+ qdict = keyval_parse("x=y,", NULL, NULL, &error_abort);
g_assert_cmpuint(qdict_size(qdict), ==, 1);
g_assert_cmpstr(qdict_get_try_str(qdict, "x"), ==, "y");
qobject_unref(qdict);
/* Except when it isn't */
- qdict = keyval_parse(",", NULL, &err);
+ qdict = keyval_parse(",", NULL, NULL, &err);
error_free_or_abort(&err);
g_assert(!qdict);
/* Value containing ,id= not misinterpreted as qemu_opts_parse() does */
- qdict = keyval_parse("x=,,id=bar", NULL, &error_abort);
+ qdict = keyval_parse("x=,,id=bar", NULL, NULL, &error_abort);
g_assert_cmpuint(qdict_size(qdict), ==, 1);
g_assert_cmpstr(qdict_get_try_str(qdict, "x"), ==, ",id=bar");
qobject_unref(qdict);
/* Anti-social ID is left to caller (qemu_opts_parse() rejects it) */
- qdict = keyval_parse("id=666", NULL, &error_abort);
+ qdict = keyval_parse("id=666", NULL, NULL, &error_abort);
g_assert_cmpuint(qdict_size(qdict), ==, 1);
g_assert_cmpstr(qdict_get_try_str(qdict, "id"), ==, "666");
qobject_unref(qdict);
/* Implied value not supported (unlike qemu_opts_parse()) */
- qdict = keyval_parse("an,noaus,noaus=", NULL, &err);
+ qdict = keyval_parse("an,noaus,noaus=", NULL, NULL, &err);
error_free_or_abort(&err);
g_assert(!qdict);
/* Implied value, key "no" (qemu_opts_parse(): negated empty key) */
- qdict = keyval_parse("no", NULL, &err);
+ qdict = keyval_parse("no", NULL, NULL, &err);
error_free_or_abort(&err);
g_assert(!qdict);
/* Implied key */
- qdict = keyval_parse("an,aus=off,noaus=", "implied", &error_abort);
+ qdict = keyval_parse("an,aus=off,noaus=", "implied", NULL, &error_abort);
g_assert_cmpuint(qdict_size(qdict), ==, 3);
g_assert_cmpstr(qdict_get_try_str(qdict, "implied"), ==, "an");
g_assert_cmpstr(qdict_get_try_str(qdict, "aus"), ==, "off");
@@ -164,7 +165,7 @@ static void test_keyval_parse(void)
qobject_unref(qdict);
/* Implied dotted key */
- qdict = keyval_parse("val", "eins.zwei", &error_abort);
+ qdict = keyval_parse("val", "eins.zwei", NULL, &error_abort);
g_assert_cmpuint(qdict_size(qdict), ==, 1);
sub_qdict = qdict_get_qdict(qdict, "eins");
g_assert(sub_qdict);
@@ -173,19 +174,81 @@ static void test_keyval_parse(void)
qobject_unref(qdict);
/* Implied key with empty value (qemu_opts_parse() accepts this) */
- qdict = keyval_parse(",", "implied", &err);
+ qdict = keyval_parse(",", "implied", NULL, &err);
error_free_or_abort(&err);
g_assert(!qdict);
/* Likewise (qemu_opts_parse(): implied key with comma value) */
- qdict = keyval_parse(",,,a=1", "implied", &err);
+ qdict = keyval_parse(",,,a=1", "implied", NULL, &err);
+ error_free_or_abort(&err);
+ g_assert(!qdict);
+
+ /* Implied key's value can't have comma (qemu_opts_parse(): it can) */
+ qdict = keyval_parse("val,,ue", "implied", NULL, &err);
error_free_or_abort(&err);
g_assert(!qdict);
/* Empty key is not an implied key */
- qdict = keyval_parse("=val", "implied", &err);
+ qdict = keyval_parse("=val", "implied", NULL, &err);
+ error_free_or_abort(&err);
+ g_assert(!qdict);
+
+ /* "help" by itself, without implied key */
+ qdict = keyval_parse("help", NULL, &help, &error_abort);
+ g_assert_cmpuint(qdict_size(qdict), ==, 0);
+ g_assert(help);
+ qobject_unref(qdict);
+
+ /* "help" by itself, with implied key */
+ qdict = keyval_parse("help", "implied", &help, &error_abort);
+ g_assert_cmpuint(qdict_size(qdict), ==, 0);
+ g_assert(help);
+ qobject_unref(qdict);
+
+ /* "help" when no help is available, without implied key */
+ qdict = keyval_parse("help", NULL, NULL, &err);
+ error_free_or_abort(&err);
+ g_assert(!qdict);
+
+ /* "help" when no help is available, with implied key */
+ qdict = keyval_parse("help", "implied", NULL, &err);
+ error_free_or_abort(&err);
+ g_assert(!qdict);
+
+ /* Key "help" */
+ qdict = keyval_parse("help=on", NULL, &help, &error_abort);
+ g_assert_cmpuint(qdict_size(qdict), ==, 1);
+ g_assert_cmpstr(qdict_get_try_str(qdict, "help"), ==, "on");
+ g_assert(!help);
+ qobject_unref(qdict);
+
+ /* "help" followed by crap, without implied key */
+ qdict = keyval_parse("help.abc", NULL, &help, &err);
error_free_or_abort(&err);
g_assert(!qdict);
+
+ /* "help" followed by crap, with implied key */
+ qdict = keyval_parse("help.abc", "implied", &help, &err);
+ g_assert_cmpuint(qdict_size(qdict), ==, 1);
+ g_assert_cmpstr(qdict_get_try_str(qdict, "implied"), ==, "help.abc");
+ g_assert(!help);
+ qobject_unref(qdict);
+
+ /* "help" with other stuff, without implied key */
+ qdict = keyval_parse("number=42,help,foo=bar", NULL, &help, &error_abort);
+ g_assert_cmpuint(qdict_size(qdict), ==, 2);
+ g_assert_cmpstr(qdict_get_try_str(qdict, "number"), ==, "42");
+ g_assert_cmpstr(qdict_get_try_str(qdict, "foo"), ==, "bar");
+ g_assert(help);
+ qobject_unref(qdict);
+
+ /* "help" with other stuff, with implied key */
+ qdict = keyval_parse("val,help,foo=bar", "implied", &help, &error_abort);
+ g_assert_cmpuint(qdict_size(qdict), ==, 2);
+ g_assert_cmpstr(qdict_get_try_str(qdict, "implied"), ==, "val");
+ g_assert_cmpstr(qdict_get_try_str(qdict, "foo"), ==, "bar");
+ g_assert(help);
+ qobject_unref(qdict);
}
static void check_list012(QList *qlist)
@@ -210,26 +273,26 @@ static void test_keyval_parse_list(void)
QDict *qdict, *sub_qdict;
/* Root can't be a list */
- qdict = keyval_parse("0=1", NULL, &err);
+ qdict = keyval_parse("0=1", NULL, NULL, &err);
error_free_or_abort(&err);
g_assert(!qdict);
/* List elements need not be in order */
- qdict = keyval_parse("list.0=null,list.2=zwei,list.1=eins",
- NULL, &error_abort);
+ qdict = keyval_parse("list.0=null,list.2=zwei,list.1=eins", NULL, NULL,
+ &error_abort);
g_assert_cmpint(qdict_size(qdict), ==, 1);
check_list012(qdict_get_qlist(qdict, "list"));
qobject_unref(qdict);
/* Multiple indexes, last one wins */
qdict = keyval_parse("list.1=goner,list.0=null,list.01=eins,list.2=zwei",
- NULL, &error_abort);
+ NULL, NULL, &error_abort);
g_assert_cmpint(qdict_size(qdict), ==, 1);
check_list012(qdict_get_qlist(qdict, "list"));
qobject_unref(qdict);
/* List at deeper nesting */
- qdict = keyval_parse("a.list.1=eins,a.list.00=null,a.list.2=zwei",
+ qdict = keyval_parse("a.list.1=eins,a.list.00=null,a.list.2=zwei", NULL,
NULL, &error_abort);
g_assert_cmpint(qdict_size(qdict), ==, 1);
sub_qdict = qdict_get_qdict(qdict, "a");
@@ -238,18 +301,19 @@ static void test_keyval_parse_list(void)
qobject_unref(qdict);
/* Inconsistent dotted keys: both list and dictionary */
- qdict = keyval_parse("a.b.c=1,a.b.0=2", NULL, &err);
+ qdict = keyval_parse("a.b.c=1,a.b.0=2", NULL, NULL, &err);
error_free_or_abort(&err);
g_assert(!qdict);
- qdict = keyval_parse("a.0.c=1,a.b.c=2", NULL, &err);
+ qdict = keyval_parse("a.0.c=1,a.b.c=2", NULL, NULL, &err);
error_free_or_abort(&err);
g_assert(!qdict);
/* Missing list indexes */
- qdict = keyval_parse("list.1=lonely", NULL, &err);
+ qdict = keyval_parse("list.1=lonely", NULL, NULL, &err);
error_free_or_abort(&err);
g_assert(!qdict);
- qdict = keyval_parse("list.0=null,list.2=eins,list.02=zwei", NULL, &err);
+ qdict = keyval_parse("list.0=null,list.2=eins,list.02=zwei", NULL, NULL,
+ &err);
error_free_or_abort(&err);
g_assert(!qdict);
}
@@ -261,7 +325,7 @@ static void test_keyval_visit_bool(void)
QDict *qdict;
bool b;
- qdict = keyval_parse("bool1=on,bool2=off", NULL, &error_abort);
+ qdict = keyval_parse("bool1=on,bool2=off", NULL, NULL, &error_abort);
v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
qobject_unref(qdict);
visit_start_struct(v, NULL, NULL, 0, &error_abort);
@@ -273,7 +337,7 @@ static void test_keyval_visit_bool(void)
visit_end_struct(v, NULL);
visit_free(v);
- qdict = keyval_parse("bool1=offer", NULL, &error_abort);
+ qdict = keyval_parse("bool1=offer", NULL, NULL, &error_abort);
v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
qobject_unref(qdict);
visit_start_struct(v, NULL, NULL, 0, &error_abort);
@@ -291,7 +355,7 @@ static void test_keyval_visit_number(void)
uint64_t u;
/* Lower limit zero */
- qdict = keyval_parse("number1=0", NULL, &error_abort);
+ qdict = keyval_parse("number1=0", NULL, NULL, &error_abort);
v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
qobject_unref(qdict);
visit_start_struct(v, NULL, NULL, 0, &error_abort);
@@ -302,7 +366,7 @@ static void test_keyval_visit_number(void)
visit_free(v);
/* Upper limit 2^64-1 */
- qdict = keyval_parse("number1=18446744073709551615,number2=-1",
+ qdict = keyval_parse("number1=18446744073709551615,number2=-1", NULL,
NULL, &error_abort);
v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
qobject_unref(qdict);
@@ -316,8 +380,8 @@ static void test_keyval_visit_number(void)
visit_free(v);
/* Above upper limit */
- qdict = keyval_parse("number1=18446744073709551616",
- NULL, &error_abort);
+ qdict = keyval_parse("number1=18446744073709551616", NULL, NULL,
+ &error_abort);
v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
qobject_unref(qdict);
visit_start_struct(v, NULL, NULL, 0, &error_abort);
@@ -327,8 +391,8 @@ static void test_keyval_visit_number(void)
visit_free(v);
/* Below lower limit */
- qdict = keyval_parse("number1=-18446744073709551616",
- NULL, &error_abort);
+ qdict = keyval_parse("number1=-18446744073709551616", NULL, NULL,
+ &error_abort);
v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
qobject_unref(qdict);
visit_start_struct(v, NULL, NULL, 0, &error_abort);
@@ -338,8 +402,7 @@ static void test_keyval_visit_number(void)
visit_free(v);
/* Hex and octal */
- qdict = keyval_parse("number1=0x2a,number2=052",
- NULL, &error_abort);
+ qdict = keyval_parse("number1=0x2a,number2=052", NULL, NULL, &error_abort);
v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
qobject_unref(qdict);
visit_start_struct(v, NULL, NULL, 0, &error_abort);
@@ -352,8 +415,7 @@ static void test_keyval_visit_number(void)
visit_free(v);
/* Trailing crap */
- qdict = keyval_parse("number1=3.14,number2=08",
- NULL, &error_abort);
+ qdict = keyval_parse("number1=3.14,number2=08", NULL, NULL, &error_abort);
v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
qobject_unref(qdict);
visit_start_struct(v, NULL, NULL, 0, &error_abort);
@@ -373,7 +435,7 @@ static void test_keyval_visit_size(void)
uint64_t sz;
/* Lower limit zero */
- qdict = keyval_parse("sz1=0", NULL, &error_abort);
+ qdict = keyval_parse("sz1=0", NULL, NULL, &error_abort);
v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
qobject_unref(qdict);
visit_start_struct(v, NULL, NULL, 0, &error_abort);
@@ -389,7 +451,7 @@ static void test_keyval_visit_size(void)
qdict = keyval_parse("sz1=9007199254740991,"
"sz2=9007199254740992,"
"sz3=9007199254740993",
- NULL, &error_abort);
+ NULL, NULL, &error_abort);
v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
qobject_unref(qdict);
visit_start_struct(v, NULL, NULL, 0, &error_abort);
@@ -406,7 +468,7 @@ static void test_keyval_visit_size(void)
/* Close to signed upper limit 0x7ffffffffffffc00 (53 msbs set) */
qdict = keyval_parse("sz1=9223372036854774784," /* 7ffffffffffffc00 */
"sz2=9223372036854775295", /* 7ffffffffffffdff */
- NULL, &error_abort);
+ NULL, NULL, &error_abort);
v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
qobject_unref(qdict);
visit_start_struct(v, NULL, NULL, 0, &error_abort);
@@ -421,7 +483,7 @@ static void test_keyval_visit_size(void)
/* Close to actual upper limit 0xfffffffffffff800 (53 msbs set) */
qdict = keyval_parse("sz1=18446744073709549568," /* fffffffffffff800 */
"sz2=18446744073709550591", /* fffffffffffffbff */
- NULL, &error_abort);
+ NULL, NULL, &error_abort);
v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
qobject_unref(qdict);
visit_start_struct(v, NULL, NULL, 0, &error_abort);
@@ -436,7 +498,7 @@ static void test_keyval_visit_size(void)
/* Beyond limits */
qdict = keyval_parse("sz1=-1,"
"sz2=18446744073709550592", /* fffffffffffffc00 */
- NULL, &error_abort);
+ NULL, NULL, &error_abort);
v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
qobject_unref(qdict);
visit_start_struct(v, NULL, NULL, 0, &error_abort);
@@ -449,7 +511,7 @@ static void test_keyval_visit_size(void)
/* Suffixes */
qdict = keyval_parse("sz1=8b,sz2=1.5k,sz3=2M,sz4=0.1G,sz5=16777215T",
- NULL, &error_abort);
+ NULL, NULL, &error_abort);
v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
qobject_unref(qdict);
visit_start_struct(v, NULL, NULL, 0, &error_abort);
@@ -468,7 +530,7 @@ static void test_keyval_visit_size(void)
visit_free(v);
/* Beyond limit with suffix */
- qdict = keyval_parse("sz1=16777216T", NULL, &error_abort);
+ qdict = keyval_parse("sz1=16777216T", NULL, NULL, &error_abort);
v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
qobject_unref(qdict);
visit_start_struct(v, NULL, NULL, 0, &error_abort);
@@ -478,7 +540,7 @@ static void test_keyval_visit_size(void)
visit_free(v);
/* Trailing crap */
- qdict = keyval_parse("sz1=0Z,sz2=16Gi", NULL, &error_abort);
+ qdict = keyval_parse("sz1=0Z,sz2=16Gi", NULL, NULL, &error_abort);
v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
qobject_unref(qdict);
visit_start_struct(v, NULL, NULL, 0, &error_abort);
@@ -497,7 +559,7 @@ static void test_keyval_visit_dict(void)
QDict *qdict;
int64_t i;
- qdict = keyval_parse("a.b.c=1,a.b.c=2,d=3", NULL, &error_abort);
+ qdict = keyval_parse("a.b.c=1,a.b.c=2,d=3", NULL, NULL, &error_abort);
v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
qobject_unref(qdict);
visit_start_struct(v, NULL, NULL, 0, &error_abort);
@@ -515,7 +577,7 @@ static void test_keyval_visit_dict(void)
visit_end_struct(v, NULL);
visit_free(v);
- qdict = keyval_parse("a.b=", NULL, &error_abort);
+ qdict = keyval_parse("a.b=", NULL, NULL, &error_abort);
v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
qobject_unref(qdict);
visit_start_struct(v, NULL, NULL, 0, &error_abort);
@@ -537,7 +599,7 @@ static void test_keyval_visit_list(void)
QDict *qdict;
char *s;
- qdict = keyval_parse("a.0=,a.1=I,a.2.0=II", NULL, &error_abort);
+ qdict = keyval_parse("a.0=,a.1=I,a.2.0=II", NULL, NULL, &error_abort);
/* TODO empty list */
v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
qobject_unref(qdict);
@@ -561,7 +623,7 @@ static void test_keyval_visit_list(void)
visit_end_struct(v, NULL);
visit_free(v);
- qdict = keyval_parse("a.0=,b.0.0=head", NULL, &error_abort);
+ qdict = keyval_parse("a.0=,b.0.0=head", NULL, NULL, &error_abort);
v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
qobject_unref(qdict);
visit_start_struct(v, NULL, NULL, 0, &error_abort);
@@ -590,7 +652,7 @@ static void test_keyval_visit_optional(void)
bool present;
int64_t i;
- qdict = keyval_parse("a.b=1", NULL, &error_abort);
+ qdict = keyval_parse("a.b=1", NULL, NULL, &error_abort);
v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
qobject_unref(qdict);
visit_start_struct(v, NULL, NULL, 0, &error_abort);
@@ -626,7 +688,7 @@ static void test_keyval_visit_alternate(void)
* the string variant if there is one, else an error.
* TODO make it work for unambiguous cases like AltEnumBool below
*/
- qdict = keyval_parse("a=1,b=2,c=on", NULL, &error_abort);
+ qdict = keyval_parse("a=1,b=2,c=on", NULL, NULL, &error_abort);
v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
qobject_unref(qdict);
visit_start_struct(v, NULL, NULL, 0, &error_abort);
@@ -650,7 +712,7 @@ static void test_keyval_visit_any(void)
QList *qlist;
QString *qstr;
- qdict = keyval_parse("a.0=null,a.1=1", NULL, &error_abort);
+ qdict = keyval_parse("a.0=null,a.1=1", NULL, NULL, &error_abort);
v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
qobject_unref(qdict);
visit_start_struct(v, NULL, NULL, 0, &error_abort);
diff --git a/ui/meson.build b/ui/meson.build
index fb36d305ca..ab4de98b38 100644
--- a/ui/meson.build
+++ b/ui/meson.build
@@ -14,7 +14,7 @@ softmmu_ss.add(files(
))
softmmu_ss.add(when: 'CONFIG_LINUX', if_true: files('input-linux.c'))
-softmmu_ss.add(when: 'CONFIG_SPICE', if_true: files('spice-core.c', 'spice-input.c', 'spice-display.c'))
+softmmu_ss.add(when: [spice, 'CONFIG_SPICE'], if_true: files('spice-core.c', 'spice-input.c', 'spice-display.c'))
softmmu_ss.add(when: cocoa, if_true: files('cocoa.m'))
vnc_ss = ss.source_set()
diff --git a/ui/spice-app.c b/ui/spice-app.c
index 93e105c6ee..026124ef56 100644
--- a/ui/spice-app.c
+++ b/ui/spice-app.c
@@ -44,11 +44,15 @@ static char *sock_path;
struct VCChardev {
SpiceChardev parent;
};
-typedef struct VCChardev VCChardev;
+
+struct VCChardevClass {
+ ChardevClass parent;
+ void (*parent_open)(Chardev *chr, ChardevBackend *backend,
+ bool *be_opened, Error **errp);
+};
#define TYPE_CHARDEV_VC "chardev-vc"
-DECLARE_INSTANCE_CHECKER(VCChardev, VC_CHARDEV,
- TYPE_CHARDEV_VC)
+OBJECT_DECLARE_TYPE(VCChardev, VCChardevClass, CHARDEV_VC)
static ChardevBackend *
chr_spice_backend_new(void)
@@ -66,6 +70,7 @@ static void vc_chr_open(Chardev *chr,
bool *be_opened,
Error **errp)
{
+ VCChardevClass *vc = CHARDEV_VC_GET_CLASS(chr);
ChardevBackend *be;
const char *fqdn = NULL;
@@ -80,7 +85,7 @@ static void vc_chr_open(Chardev *chr,
be = chr_spice_backend_new();
be->u.spiceport.data->fqdn = fqdn ?
g_strdup(fqdn) : g_strdup_printf("org.qemu.console.%s", chr->label);
- qemu_chr_open_spice_port(chr, be, be_opened, errp);
+ vc->parent_open(chr, be, be_opened, errp);
qapi_free_ChardevBackend(be);
}
@@ -91,8 +96,11 @@ static void vc_chr_set_echo(Chardev *chr, bool echo)
static void char_vc_class_init(ObjectClass *oc, void *data)
{
+ VCChardevClass *vc = CHARDEV_VC_CLASS(oc);
ChardevClass *cc = CHARDEV_CLASS(oc);
+ vc->parent_open = cc->open;
+
cc->parse = qemu_chr_parse_vc;
cc->open = vc_chr_open;
cc->chr_set_echo = vc_chr_set_echo;
@@ -103,6 +111,7 @@ static const TypeInfo char_vc_type_info = {
.parent = TYPE_CHARDEV_SPICEPORT,
.instance_size = sizeof(VCChardev),
.class_init = char_vc_class_init,
+ .class_size = sizeof(VCChardevClass),
};
static void spice_app_atexit(void)
@@ -120,7 +129,6 @@ static void spice_app_atexit(void)
static void spice_app_display_early_init(DisplayOptions *opts)
{
QemuOpts *qopts;
- ChardevBackend *be = chr_spice_backend_new();
GError *err = NULL;
if (opts->has_full_screen) {
@@ -165,6 +173,15 @@ static void spice_app_display_early_init(DisplayOptions *opts)
qemu_opt_set(qopts, "gl", opts->has_gl ? "on" : "off", &error_abort);
display_opengl = opts->has_gl;
#endif
+}
+
+static void spice_app_display_init(DisplayState *ds, DisplayOptions *opts)
+{
+ ChardevBackend *be = chr_spice_backend_new();
+ QemuOpts *qopts;
+ GError *err = NULL;
+ gchar *uri;
+
be->u.spiceport.data->fqdn = g_strdup("org.qemu.monitor.qmp.0");
qemu_chardev_new("org.qemu.monitor.qmp", TYPE_CHARDEV_SPICEPORT,
be, NULL, &error_abort);
@@ -174,13 +191,6 @@ static void spice_app_display_early_init(DisplayOptions *opts)
qemu_opt_set(qopts, "mode", "control", &error_abort);
qapi_free_ChardevBackend(be);
-}
-
-static void spice_app_display_init(DisplayState *ds, DisplayOptions *opts)
-{
- GError *err = NULL;
- gchar *uri;
-
uri = g_strjoin("", "spice+unix://", app_dir, "/", "spice.sock", NULL);
info_report("Launching display with URI: %s", uri);
g_app_info_launch_default_for_uri(uri, NULL, &err);
diff --git a/ui/spice-core.c b/ui/spice-core.c
index 10aa309f78..47700b2200 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -812,8 +812,6 @@ void qemu_spice_init(void)
g_free(x509_cert_file);
g_free(x509_cacert_file);
- qemu_spice_register_ports();
-
#ifdef HAVE_SPICE_GL
if (qemu_opt_get_bool(opts, "gl", 0)) {
if ((port != 0) || (tls_port != 0)) {
diff --git a/util/keyval.c b/util/keyval.c
index 13def4af54..7f625ad33c 100644
--- a/util/keyval.c
+++ b/util/keyval.c
@@ -14,10 +14,11 @@
* KEY=VALUE,... syntax:
*
* key-vals = [ key-val { ',' key-val } [ ',' ] ]
- * key-val = key '=' val
+ * key-val = key '=' val | help
* key = key-fragment { '.' key-fragment }
- * key-fragment = / [^=,.]* /
- * val = { / [^,]* / | ',,' }
+ * key-fragment = / [^=,.]+ /
+ * val = { / [^,]+ / | ',,' }
+ * help = 'help' | '?'
*
* Semantics defined by reduction to JSON:
*
@@ -54,6 +55,9 @@
*
* The length of any key-fragment must be between 1 and 127.
*
+ * If any key-val is help, the object is to be treated as a help
+ * request.
+ *
* Design flaw: there is no way to denote an empty array or non-root
* object. While interpreting "key absent" as empty seems natural
* (removing a key-val from the input string removes the member when
@@ -71,12 +75,16 @@
* Awkward. Note that we carefully restrict alternate types to avoid
* similar ambiguity.
*
- * Additional syntax for use with an implied key:
+ * Alternative syntax for use with an implied key:
+ *
+ * key-vals = [ key-val-1st { ',' key-val } [ ',' ] ]
+ * key-val-1st = val-no-key | key-val
+ * val-no-key = / [^=,]+ / - help
*
- * key-vals-ik = val-no-key [ ',' key-vals ]
- * val-no-key = / [^=,]* /
+ * where val-no-key is syntactic sugar for implied-key=val-no-key.
*
- * where no-key is syntactic sugar for implied-key=val-no-key.
+ * Note that you can't use the sugared form when the value contains
+ * '=' or ','.
*/
#include "qemu/osdep.h"
@@ -85,6 +93,7 @@
#include "qapi/qmp/qlist.h"
#include "qapi/qmp/qstring.h"
#include "qemu/cutils.h"
+#include "qemu/help_option.h"
#include "qemu/option.h"
/*
@@ -158,18 +167,23 @@ static QObject *keyval_parse_put(QDict *cur,
}
/*
- * Parse one KEY=VALUE from @params, store result in @qdict.
+ * Parse one parameter from @params.
+ *
+ * If we're looking at KEY=VALUE, store result in @qdict.
* The first fragment of KEY applies to @qdict. Subsequent fragments
* apply to nested QDicts, which are created on demand. @implied_key
* is as in keyval_parse().
- * On success, return a pointer to the next KEY=VALUE, or else to '\0'.
+ *
+ * If we're looking at "help" or "?", set *help to true.
+ *
+ * On success, return a pointer to the next parameter, or else to '\0'.
* On failure, return NULL.
*/
static const char *keyval_parse_one(QDict *qdict, const char *params,
- const char *implied_key,
+ const char *implied_key, bool *help,
Error **errp)
{
- const char *key, *key_end, *s, *end;
+ const char *key, *key_end, *val_end, *s, *end;
size_t len;
char key_in_cur[128];
QDict *cur;
@@ -178,11 +192,23 @@ static const char *keyval_parse_one(QDict *qdict, const char *params,
QString *val;
key = params;
+ val_end = NULL;
len = strcspn(params, "=,");
- if (implied_key && len && key[len] != '=') {
- /* Desugar implied key */
- key = implied_key;
- len = strlen(implied_key);
+ if (len && key[len] != '=') {
+ if (starts_with_help_option(key) == len) {
+ *help = true;
+ s = key + len;
+ if (*s == ',') {
+ s++;
+ }
+ return s;
+ }
+ if (implied_key) {
+ /* Desugar implied key */
+ key = implied_key;
+ val_end = params + len;
+ len = strlen(implied_key);
+ }
}
key_end = key + len;
@@ -237,7 +263,11 @@ static const char *keyval_parse_one(QDict *qdict, const char *params,
if (key == implied_key) {
assert(!*s);
- s = params;
+ val = qstring_from_substr(params, 0, val_end - params);
+ s = val_end;
+ if (*s == ',') {
+ s++;
+ }
} else {
if (*s != '=') {
error_setg(errp, "Expected '=' after parameter '%.*s'",
@@ -245,19 +275,19 @@ static const char *keyval_parse_one(QDict *qdict, const char *params,
return NULL;
}
s++;
- }
- val = qstring_new();
- for (;;) {
- if (!*s) {
- break;
- } else if (*s == ',') {
- s++;
- if (*s != ',') {
+ val = qstring_new();
+ for (;;) {
+ if (!*s) {
break;
+ } else if (*s == ',') {
+ s++;
+ if (*s != ',') {
+ break;
+ }
}
+ qstring_append_chr(val, *s++);
}
- qstring_append_chr(val, *s++);
}
if (!keyval_parse_put(cur, key_in_cur, val, key, key_end, errp)) {
@@ -388,21 +418,32 @@ static QObject *keyval_listify(QDict *cur, GSList *key_of_cur, Error **errp)
/*
* Parse @params in QEMU's traditional KEY=VALUE,... syntax.
+ *
* If @implied_key, the first KEY= can be omitted. @implied_key is
* implied then, and VALUE can't be empty or contain ',' or '='.
+ *
+ * A parameter "help" or "?" without a value isn't added to the
+ * resulting dictionary, but instead is interpreted as help request.
+ * All other options are parsed and returned normally so that context
+ * specific help can be printed.
+ *
+ * If @p_help is not NULL, store whether help is requested there.
+ * If @p_help is NULL and help is requested, fail.
+ *
* On success, return a dictionary of the parsed keys and values.
* On failure, store an error through @errp and return NULL.
*/
QDict *keyval_parse(const char *params, const char *implied_key,
- Error **errp)
+ bool *p_help, Error **errp)
{
QDict *qdict = qdict_new();
QObject *listified;
const char *s;
+ bool help = false;
s = params;
while (*s) {
- s = keyval_parse_one(qdict, s, implied_key, errp);
+ s = keyval_parse_one(qdict, s, implied_key, &help, errp);
if (!s) {
qobject_unref(qdict);
return NULL;
@@ -410,6 +451,14 @@ QDict *keyval_parse(const char *params, const char *implied_key,
implied_key = NULL;
}
+ if (p_help) {
+ *p_help = help;
+ } else if (help) {
+ error_setg(errp, "Help is not available for this option");
+ qobject_unref(qdict);
+ return NULL;
+ }
+
listified = keyval_listify(qdict, NULL, errp);
if (!listified) {
qobject_unref(qdict);
diff --git a/util/module.c b/util/module.c
index a44ec38d93..f0ed05fbd0 100644
--- a/util/module.c
+++ b/util/module.c
@@ -110,7 +110,7 @@ void module_call_init(module_init_type type)
}
#ifdef CONFIG_MODULES
-static int module_load_file(const char *fname)
+static int module_load_file(const char *fname, bool mayfail)
{
GModule *g_module;
void (*sym)(void);
@@ -134,8 +134,10 @@ static int module_load_file(const char *fname)
g_module = g_module_open(fname, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
if (!g_module) {
- fprintf(stderr, "Failed to open module: %s\n",
- g_module_error());
+ if (!mayfail) {
+ fprintf(stderr, "Failed to open module: %s\n",
+ g_module_error());
+ }
ret = -EINVAL;
goto out;
}
@@ -167,7 +169,7 @@ out:
}
#endif
-bool module_load_one(const char *prefix, const char *lib_name)
+bool module_load_one(const char *prefix, const char *lib_name, bool mayfail)
{
bool success = false;
@@ -218,7 +220,7 @@ bool module_load_one(const char *prefix, const char *lib_name)
for (i = 0; i < n_dirs; i++) {
fname = g_strdup_printf("%s/%s%s",
dirs[i], module_name, CONFIG_HOST_DSOSUF);
- ret = module_load_file(fname);
+ ret = module_load_file(fname, mayfail);
g_free(fname);
fname = NULL;
/* Try loading until loaded a module file */
@@ -248,8 +250,10 @@ bool module_load_one(const char *prefix, const char *lib_name)
* only a very few devices & objects.
*
* So with the expectation that this will be rather the exception than
- * to rule and the list will not gain that many entries go with a
+ * the rule and the list will not gain that many entries, go with a
* simple manually maintained list for now.
+ *
+ * The list must be sorted by module (module_load_qom_all() needs this).
*/
static struct {
const char *type;
@@ -264,6 +268,8 @@ static struct {
{ "virtio-gpu-device", "hw-", "display-virtio-gpu" },
{ "vhost-user-gpu", "hw-", "display-virtio-gpu" },
{ "chardev-braille", "chardev-", "baum" },
+ { "chardev-spicevmc", "chardev-", "spice" },
+ { "chardev-spiceport", "chardev-", "spice" },
};
static bool module_loaded_qom_all;
@@ -275,13 +281,11 @@ void module_load_qom_one(const char *type)
if (!type) {
return;
}
- if (module_loaded_qom_all) {
- return;
- }
for (i = 0; i < ARRAY_SIZE(qom_modules); i++) {
if (strcmp(qom_modules[i].type, type) == 0) {
module_load_one(qom_modules[i].prefix,
- qom_modules[i].module);
+ qom_modules[i].module,
+ false);
return;
}
}
@@ -302,7 +306,7 @@ void module_load_qom_all(void)
/* one module implementing multiple types -> load only once */
continue;
}
- module_load_one(qom_modules[i].prefix, qom_modules[i].module);
+ module_load_one(qom_modules[i].prefix, qom_modules[i].module, true);
}
module_loaded_qom_all = true;
}