Skip to content

Commit

Permalink
-machine vmport=auto: Fix handling of VMWare ioport emulation for xen
Browse files Browse the repository at this point in the history
c/s 9b23cfb

or

c/s b154537

moved the testing of xen_enabled() from pc_init1() to
pc_machine_initfn().

xen_enabled() does not return the correct value in
pc_machine_initfn().

Changed vmport from a bool to an enum.  Added the value "auto" to do
the old way.  Move check of xen_enabled() back to pc_init1().

Acked-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Don Slutz <dslutz@verizon.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
Don Slutz authored and bonzini committed Nov 26, 2014
1 parent 2528043 commit d1048be
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 16 deletions.
22 changes: 13 additions & 9 deletions hw/i386/pc.c
Expand Up @@ -61,6 +61,7 @@
#include "hw/mem/pc-dimm.h"
#include "trace.h"
#include "qapi/visitor.h"
#include "qapi-visit.h"

/* debug PC/ISA interrupts */
//#define DEBUG_IRQ
Expand Down Expand Up @@ -1772,18 +1773,21 @@ static void pc_machine_set_max_ram_below_4g(Object *obj, Visitor *v,
pcms->max_ram_below_4g = value;
}

static bool pc_machine_get_vmport(Object *obj, Error **errp)
static void pc_machine_get_vmport(Object *obj, Visitor *v, void *opaque,
const char *name, Error **errp)
{
PCMachineState *pcms = PC_MACHINE(obj);
OnOffAuto vmport = pcms->vmport;

return pcms->vmport;
visit_type_OnOffAuto(v, &vmport, name, errp);
}

static void pc_machine_set_vmport(Object *obj, bool value, Error **errp)
static void pc_machine_set_vmport(Object *obj, Visitor *v, void *opaque,
const char *name, Error **errp)
{
PCMachineState *pcms = PC_MACHINE(obj);

pcms->vmport = value;
visit_type_OnOffAuto(v, &pcms->vmport, name, errp);
}

static bool pc_machine_get_aligned_dimm(Object *obj, Error **errp)
Expand All @@ -1806,11 +1810,11 @@ static void pc_machine_initfn(Object *obj)
pc_machine_set_max_ram_below_4g,
NULL, NULL, NULL);

pcms->vmport = !xen_enabled();
object_property_add_bool(obj, PC_MACHINE_VMPORT,
pc_machine_get_vmport,
pc_machine_set_vmport,
NULL);
pcms->vmport = ON_OFF_AUTO_AUTO;
object_property_add(obj, PC_MACHINE_VMPORT, "OnOffAuto",
pc_machine_get_vmport,
pc_machine_set_vmport,
NULL, NULL, NULL);

pcms->enforce_aligned_dimm = true;
object_property_add_bool(obj, PC_MACHINE_ENFORCE_ALIGNED_DIMM,
Expand Down
7 changes: 6 additions & 1 deletion hw/i386/pc_piix.c
Expand Up @@ -234,9 +234,14 @@ static void pc_init1(MachineState *machine,

pc_vga_init(isa_bus, pci_enabled ? pci_bus : NULL);

assert(pc_machine->vmport != ON_OFF_AUTO_MAX);
if (pc_machine->vmport == ON_OFF_AUTO_AUTO) {
pc_machine->vmport = xen_enabled() ? ON_OFF_AUTO_OFF : ON_OFF_AUTO_ON;
}

/* init basic PC hardware */
pc_basic_device_init(isa_bus, gsi, &rtc_state, &floppy,
!pc_machine->vmport, 0x4);
(pc_machine->vmport != ON_OFF_AUTO_ON), 0x4);

pc_nic_init(isa_bus, pci_bus);

Expand Down
7 changes: 6 additions & 1 deletion hw/i386/pc_q35.c
Expand Up @@ -242,9 +242,14 @@ static void pc_q35_init(MachineState *machine)

pc_register_ferr_irq(gsi[13]);

assert(pc_machine->vmport != ON_OFF_AUTO_MAX);
if (pc_machine->vmport == ON_OFF_AUTO_AUTO) {
pc_machine->vmport = xen_enabled() ? ON_OFF_AUTO_OFF : ON_OFF_AUTO_ON;
}

/* init basic PC hardware */
pc_basic_device_init(isa_bus, gsi, &rtc_state, &floppy,
!pc_machine->vmport, 0xff0104);
(pc_machine->vmport != ON_OFF_AUTO_ON), 0xff0104);

/* connect pm stuff to lpc */
ich9_lpc_pm_init(lpc);
Expand Down
2 changes: 1 addition & 1 deletion include/hw/i386/pc.h
Expand Up @@ -39,7 +39,7 @@ struct PCMachineState {
ISADevice *rtc;

uint64_t max_ram_below_4g;
bool vmport;
OnOffAuto vmport;
bool enforce_aligned_dimm;
};

Expand Down
15 changes: 15 additions & 0 deletions qapi/common.json
Expand Up @@ -87,3 +87,18 @@
##
{ 'command': 'query-commands', 'returns': ['CommandInfo'] }

##
# @OnOffAuto
#
# An enumeration of three options: on, off, and auto
#
# @auto: QEMU selects the value between on and off
#
# @on: Enabled
#
# @off: Disabled
#
# Since: 2.2
##
{ 'enum': 'OnOffAuto',
'data': [ 'auto', 'on', 'off' ] }
8 changes: 5 additions & 3 deletions qemu-options.hx
Expand Up @@ -33,7 +33,7 @@ DEF("machine", HAS_ARG, QEMU_OPTION_machine, \
" property accel=accel1[:accel2[:...]] selects accelerator\n"
" supported accelerators are kvm, xen, tcg (default: tcg)\n"
" kernel_irqchip=on|off controls accelerated irqchip support\n"
" vmport=on|off controls emulation of vmport (default: on)\n"
" vmport=on|off|auto controls emulation of vmport (default: auto)\n"
" kvm_shadow_mem=size of KVM shadow MMU\n"
" dump-guest-core=on|off include guest memory in a core dump (default=on)\n"
" mem-merge=on|off controls memory merge support (default: on)\n"
Expand All @@ -52,8 +52,10 @@ than one accelerator specified, the next one is used if the previous one fails
to initialize.
@item kernel_irqchip=on|off
Enables in-kernel irqchip support for the chosen accelerator when available.
@item vmport=on|off
Enables emulation of VMWare IO port, for vmmouse etc. (enabled by default)
@item vmport=on|off|auto
Enables emulation of VMWare IO port, for vmmouse etc. auto says to select the
value based on accel. For accel=xen the default is off otherwise the default
is on.
@item kvm_shadow_mem=size
Defines the size of the KVM shadow MMU.
@item dump-guest-core=on|off
Expand Down
2 changes: 1 addition & 1 deletion vl.c
Expand Up @@ -381,7 +381,7 @@ static QemuOptsList qemu_machine_opts = {
.help = "maximum ram below the 4G boundary (32bit boundary)",
}, {
.name = PC_MACHINE_VMPORT,
.type = QEMU_OPT_BOOL,
.type = QEMU_OPT_STRING,
.help = "Enable vmport (pc & q35)",
},{
.name = "iommu",
Expand Down

0 comments on commit d1048be

Please sign in to comment.