All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Borntraeger <borntraeger@de.ibm.com>
To: Hu Tao <hutao@cn.fujitsu.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Gleb Natapov <gleb@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Jan Kiszka <jan.kiszka@siemens.com>,
	qemu-devel <qemu-devel@nongnu.org>,
	Luiz Capitulino <lcapitulino@redhat.com>,
	Blue Swirl <blauwirbel@gmail.com>,
	Orit Wasserman <owasserm@redhat.com>,
	kvm list <kvm@vger.kernel.org>,
	Juan Quintela <quintela@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	Jens Freimann <jfrei@linux.vnet.ibm.com>,
	Andrew Jones <drjones@redhat.com>,
	Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>,
	Alex Williamson <alex.williamson@redhat.com>,
	Sasha Levin <levinsasha928@gmail.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
	Kevin Wolf <kwolf@redhat.com>, Alexander Graf <agraf@suse.de>,
	Anthony Liguori <aliguori@us.ibm.com>,
	Marcelo Tosatti <mtosatti@redhat.com>, "linux-kernel@vger.kernel.
Subject: Re: [PATCH v13 6/8] introduce a new qom device to deal with panicked event
Date: Mon, 04 Mar 2013 11:10:18 +0100	[thread overview]
Message-ID: <5134730A.2050406@de.ibm.com> (raw)
In-Reply-To: <d7b92bed37f3669194b45acd8736b4b7ac71cc95.1362051582.git.hutao@cn.fujitsu.com>

On 28/02/13 13:13, Hu Tao wrote:
> If the target is x86/x86_64, the guest's kernel will write 0x01 to the
> port KVM_PV_EVENT_PORT when it is panciked. This patch introduces a new
> qom device kvm_pv_ioport to listen this I/O port, and deal with panicked
> event according to panicked_action's value. The possible actions are:
> 1. emit QEVENT_GUEST_PANICKED only
> 2. emit QEVENT_GUEST_PANICKED and pause the guest
> 3. emit QEVENT_GUEST_PANICKED and poweroff the guest
> 4. emit QEVENT_GUEST_PANICKED and reset the guest
> 
> I/O ports does not work for some targets(for example: s390). And you
> can implement another qom device, and include it's code into pv_event.c
> for such target.


Hmm, I am tempted to just reuse the disabled wait state on s390. This is
a state were all CPUs are disabled for interrupts and a wait PSW is loaded.
This is commonly used on all s390 operating systems as a state of attention
(some OSes even use the instruction address as a code). The Linux kernel
also uses disabled wait on Panic.

Right now we have some special handling on disabled wait:
- non-disabled wait (all cpus stopped): quit qemu
- disabled wait: put last cpu in halted state to allow a memory dump

So we could just use a simplified version

--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -759,6 +759,11 @@ static int handle_intercept(S390CPU *cpu)
                 is_special_wait_psw(cs)) {
                 qemu_system_shutdown_request();
             }
+            //disabled wait: we either
+            //do a
+            //monitor_protocol_event(QEVENT_GUEST_PANICKED, whatever);
+            //or
+            //or call into pvevent
             r = EXCP_HALTED;
             break;
         case ICPT_CPU_STOP:


I would prefer to just use the monitor_protocol_event, on the other hand
a call into pvent could make it configurable.

Christian

> 
> Note: if we emit QEVENT_GUEST_PANICKED only, and the management
> application does not receive this event(the management may not
> run when the event is emitted), the management won't know the
> guest is panicked.
> 
> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
> Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
> ---
>  hw/kvm/Makefile.objs |   2 +-
>  hw/kvm/pv_event.c    | 198 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  hw/pc_piix.c         |   5 ++
>  include/sysemu/kvm.h |   2 +
>  kvm-stub.c           |   4 ++
>  5 files changed, 210 insertions(+), 1 deletion(-)
>  create mode 100644 hw/kvm/pv_event.c
> 
> diff --git a/hw/kvm/Makefile.objs b/hw/kvm/Makefile.objs
> index f620d7f..cf93199 100644
> --- a/hw/kvm/Makefile.objs
> +++ b/hw/kvm/Makefile.objs
> @@ -1 +1 @@
> -obj-$(CONFIG_KVM) += clock.o apic.o i8259.o ioapic.o i8254.o pci-assign.o
> +obj-$(CONFIG_KVM) += clock.o apic.o i8259.o ioapic.o i8254.o pci-assign.o pv_event.o
> diff --git a/hw/kvm/pv_event.c b/hw/kvm/pv_event.c
> new file mode 100644
> index 0000000..5e68190
> --- /dev/null
> +++ b/hw/kvm/pv_event.c
> @@ -0,0 +1,198 @@
> +/*
> + * QEMU KVM support, paravirtual event device
> + *
> + * Copyright Fujitsu, Corp. 2012
> + *
> + * Authors:
> + *     Wen Congyang <wency@cn.fujitsu.com>
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2 or later.
> + * See the COPYING file in the top-level directory.
> + *
> + */
> +
> +#include <linux/kvm_para.h>
> +#include <asm/kvm_para.h>
> +#include <qapi/qmp/qobject.h>
> +#include <qapi/qmp/qjson.h>
> +#include <monitor/monitor.h>
> +#include <sysemu/sysemu.h>
> +#include <sysemu/kvm.h>
> +
> +/* Possible values for action parameter. */
> +#define PANICKED_REPORT     1   /* emit QEVENT_GUEST_PANICKED only */
> +#define PANICKED_PAUSE      2   /* emit QEVENT_GUEST_PANICKED and pause VM */
> +#define PANICKED_POWEROFF   3   /* emit QEVENT_GUEST_PANICKED and quit VM */
> +#define PANICKED_RESET      4   /* emit QEVENT_GUEST_PANICKED and reset VM */
> +
> +#define PV_EVENT_DRIVER     "kvm_pv_event"
> +#define PV_IOPORT(obj)      OBJECT_CHECK(PVIOPortState, (obj), PV_EVENT_DRIVER)
> +
> +struct PVEventAction {
> +    char *panicked_action;
> +    int panicked_action_value;
> +};
> +
> +#define DEFINE_PV_EVENT_PROPERTIES(_state, _conf)   \
> +    DEFINE_PROP_STRING("panicked_action", _state, _conf.panicked_action)
> +
> +static void panicked_mon_event(const char *action)
> +{
> +    QObject *data;
> +
> +    data = qobject_from_jsonf("{ 'action': %s }", action);
> +    monitor_protocol_event(QEVENT_GUEST_PANICKED, data);
> +    qobject_decref(data);
> +}
> +
> +static void panicked_perform_action(uint32_t panicked_action)
> +{
> +    switch (panicked_action) {
> +    case PANICKED_REPORT:
> +        panicked_mon_event("report");
> +        break;
> +
> +    case PANICKED_PAUSE:
> +        panicked_mon_event("pause");
> +        vm_stop(RUN_STATE_GUEST_PANICKED);
> +        break;
> +
> +    case PANICKED_POWEROFF:
> +        panicked_mon_event("poweroff");
> +        qemu_system_shutdown_request();
> +        break;
> +
> +    case PANICKED_RESET:
> +        panicked_mon_event("reset");
> +        qemu_system_reset_request();
> +        break;
> +    }
> +}
> +
> +static uint64_t supported_event(void)
> +{
> +    return 1 << KVM_PV_FEATURE_PANICKED;
> +}
> +
> +static void handle_event(int event, struct PVEventAction *conf)
> +{
> +    if (event == KVM_PV_EVENT_PANICKED) {
> +        panicked_perform_action(conf->panicked_action_value);
> +    }
> +}
> +
> +static int pv_event_init(struct PVEventAction *conf)
> +{
> +    if (!conf->panicked_action) {
> +        conf->panicked_action_value = PANICKED_REPORT;
> +    } else if (strcasecmp(conf->panicked_action, "none") == 0) {
> +        conf->panicked_action_value = PANICKED_REPORT;
> +    } else if (strcasecmp(conf->panicked_action, "pause") == 0) {
> +        conf->panicked_action_value = PANICKED_PAUSE;
> +    } else if (strcasecmp(conf->panicked_action, "poweroff") == 0) {
> +        conf->panicked_action_value = PANICKED_POWEROFF;
> +    } else if (strcasecmp(conf->panicked_action, "reset") == 0) {
> +        conf->panicked_action_value = PANICKED_RESET;
> +    } else {
> +        return -1;
> +    }
> +
> +    return 0;
> +}
> +
> +#if defined(KVM_PV_EVENT_PORT)
> +
> +#include "hw/isa.h"
> +
> +typedef struct {
> +    ISADevice dev;
> +    struct PVEventAction conf;
> +    MemoryRegion ioport;
> +} PVIOPortState;
> +
> +static uint64_t pv_io_read(void *opaque, hwaddr addr, unsigned size)
> +{
> +    return supported_event();
> +}
> +
> +static void pv_io_write(void *opaque, hwaddr addr, uint64_t val,
> +                        unsigned size)
> +{
> +    PVIOPortState *s = opaque;
> +
> +    handle_event(val, &s->conf);
> +}
> +
> +static const MemoryRegionOps pv_io_ops = {
> +    .read = pv_io_read,
> +    .write = pv_io_write,
> +    .impl = {
> +        .min_access_size = 4,
> +        .max_access_size = 4,
> +    },
> +};
> +
> +static int pv_ioport_initfn(ISADevice *dev)
> +{
> +    PVIOPortState *s = PV_IOPORT(dev);
> +
> +    if (pv_event_init(&s->conf) < 0) {
> +        return -1;
> +    }
> +
> +    memory_region_init_io(&s->ioport, &pv_io_ops, s, "pv_event", 4);
> +    isa_register_ioport(dev, &s->ioport, KVM_PV_EVENT_PORT);
> +
> +    return 0;
> +}
> +
> +static Property pv_ioport_properties[] = {
> +    DEFINE_PV_EVENT_PROPERTIES(PVIOPortState, conf),
> +    DEFINE_PROP_END_OF_LIST(),
> +};
> +
> +static void pv_ioport_class_init(ObjectClass *klass, void *data)
> +{
> +    DeviceClass *dc = DEVICE_CLASS(klass);
> +    ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
> +
> +    ic->init = pv_ioport_initfn;
> +    dc->no_user = 1;
> +    dc->props = pv_ioport_properties;
> +}
> +
> +static TypeInfo pv_ioport_info = {
> +    .name          = PV_EVENT_DRIVER,
> +    .parent        = TYPE_ISA_DEVICE,
> +    .instance_size = sizeof(PVIOPortState),
> +    .class_init    = pv_ioport_class_init,
> +};
> +
> +static void pv_ioport_register_types(void)
> +{
> +    type_register_static(&pv_ioport_info);
> +}
> +
> +type_init(pv_ioport_register_types)
> +
> +void kvm_pv_event_init(void *opaque)
> +{
> +    ISABus *bus = opaque;
> +    ISADevice *dev;
> +
> +    dev = isa_create(bus, PV_EVENT_DRIVER);
> +    qdev_init_nofail(&dev->qdev);
> +}
> +
> +#else
> +
> +/*
> + * If you need a qom device to handle pv event, this device should
> + * be created and initialized in kvm_pv_event_init().
> + *
> + * The parameter opaque is the device's parent bus.
> + */
> +void kvm_pv_event_init(void *opaque)
> +{
> +}
> +#endif
> diff --git a/hw/pc_piix.c b/hw/pc_piix.c
> index aa9cc81..24a9bf3 100644
> --- a/hw/pc_piix.c
> +++ b/hw/pc_piix.c
> @@ -47,6 +47,7 @@
>  #ifdef CONFIG_XEN
>  #  include <xen/hvm/hvm_info_table.h>
>  #endif
> +#include <linux/kvm_para.h>
> 
>  #define MAX_IDE_BUS 2
> 
> @@ -216,6 +217,10 @@ static void pc_init1(MemoryRegion *system_memory,
>      if (pci_enabled) {
>          pc_pci_device_init(pci_bus);
>      }
> +
> +    if (kvm_enabled()) {
> +        kvm_pv_event_init(isa_bus);
> +    }
>  }
> 
>  static void pc_init_pci(QEMUMachineInitArgs *args)
> diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
> index f2d97b5..97d3daf 100644
> --- a/include/sysemu/kvm.h
> +++ b/include/sysemu/kvm.h
> @@ -296,4 +296,6 @@ int kvm_irqchip_add_irqfd_notifier(KVMState *s, EventNotifier *n, int virq);
>  int kvm_irqchip_remove_irqfd_notifier(KVMState *s, EventNotifier *n, int virq);
>  void kvm_pc_gsi_handler(void *opaque, int n, int level);
>  void kvm_pc_setup_irq_routing(bool pci_enabled);
> +
> +void kvm_pv_event_init(void *opaque);
>  #endif
> diff --git a/kvm-stub.c b/kvm-stub.c
> index 760aadc..f543fa2 100644
> --- a/kvm-stub.c
> +++ b/kvm-stub.c
> @@ -145,3 +145,7 @@ int kvm_irqchip_remove_irqfd_notifier(KVMState *s, EventNotifier *n, int virq)
>  {
>      return -ENOSYS;
>  }
> +
> +void kvm_pv_event_init(void *opaque)
> +{
> +}
> 

WARNING: multiple messages have this Message-ID (diff)
From: Christian Borntraeger <borntraeger@de.ibm.com>
To: Hu Tao <hutao@cn.fujitsu.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Gleb Natapov <gleb@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Jan Kiszka <jan.kiszka@siemens.com>,
	qemu-devel <qemu-devel@nongnu.org>,
	Luiz Capitulino <lcapitulino@redhat.com>,
	Blue Swirl <blauwirbel@gmail.com>,
	Orit Wasserman <owasserm@redhat.com>,
	kvm list <kvm@vger.kernel.org>,
	Juan Quintela <quintela@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	Jens Freimann <jfrei@linux.vnet.ibm.com>,
	Andrew Jones <drjones@redhat.com>,
	Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>,
	Alex Williamson <alex.williamson@redhat.com>,
	Sasha Levin <levinsasha928@gmail.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
	Kevin Wolf <kwolf@redhat.com>, Alexander Graf <agraf@suse.de>,
	Anthony Liguori <aliguori@us.ibm.com>,
	Marcelo Tosatti <mtosatti@redhat.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Einar Lueck <elelueck@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] [PATCH v13 6/8] introduce a new qom device to deal with panicked event
Date: Mon, 04 Mar 2013 11:10:18 +0100	[thread overview]
Message-ID: <5134730A.2050406@de.ibm.com> (raw)
In-Reply-To: <d7b92bed37f3669194b45acd8736b4b7ac71cc95.1362051582.git.hutao@cn.fujitsu.com>

On 28/02/13 13:13, Hu Tao wrote:
> If the target is x86/x86_64, the guest's kernel will write 0x01 to the
> port KVM_PV_EVENT_PORT when it is panciked. This patch introduces a new
> qom device kvm_pv_ioport to listen this I/O port, and deal with panicked
> event according to panicked_action's value. The possible actions are:
> 1. emit QEVENT_GUEST_PANICKED only
> 2. emit QEVENT_GUEST_PANICKED and pause the guest
> 3. emit QEVENT_GUEST_PANICKED and poweroff the guest
> 4. emit QEVENT_GUEST_PANICKED and reset the guest
> 
> I/O ports does not work for some targets(for example: s390). And you
> can implement another qom device, and include it's code into pv_event.c
> for such target.


Hmm, I am tempted to just reuse the disabled wait state on s390. This is
a state were all CPUs are disabled for interrupts and a wait PSW is loaded.
This is commonly used on all s390 operating systems as a state of attention
(some OSes even use the instruction address as a code). The Linux kernel
also uses disabled wait on Panic.

Right now we have some special handling on disabled wait:
- non-disabled wait (all cpus stopped): quit qemu
- disabled wait: put last cpu in halted state to allow a memory dump

So we could just use a simplified version

--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -759,6 +759,11 @@ static int handle_intercept(S390CPU *cpu)
                 is_special_wait_psw(cs)) {
                 qemu_system_shutdown_request();
             }
+            //disabled wait: we either
+            //do a
+            //monitor_protocol_event(QEVENT_GUEST_PANICKED, whatever);
+            //or
+            //or call into pvevent
             r = EXCP_HALTED;
             break;
         case ICPT_CPU_STOP:


I would prefer to just use the monitor_protocol_event, on the other hand
a call into pvent could make it configurable.

Christian

> 
> Note: if we emit QEVENT_GUEST_PANICKED only, and the management
> application does not receive this event(the management may not
> run when the event is emitted), the management won't know the
> guest is panicked.
> 
> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
> Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
> ---
>  hw/kvm/Makefile.objs |   2 +-
>  hw/kvm/pv_event.c    | 198 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  hw/pc_piix.c         |   5 ++
>  include/sysemu/kvm.h |   2 +
>  kvm-stub.c           |   4 ++
>  5 files changed, 210 insertions(+), 1 deletion(-)
>  create mode 100644 hw/kvm/pv_event.c
> 
> diff --git a/hw/kvm/Makefile.objs b/hw/kvm/Makefile.objs
> index f620d7f..cf93199 100644
> --- a/hw/kvm/Makefile.objs
> +++ b/hw/kvm/Makefile.objs
> @@ -1 +1 @@
> -obj-$(CONFIG_KVM) += clock.o apic.o i8259.o ioapic.o i8254.o pci-assign.o
> +obj-$(CONFIG_KVM) += clock.o apic.o i8259.o ioapic.o i8254.o pci-assign.o pv_event.o
> diff --git a/hw/kvm/pv_event.c b/hw/kvm/pv_event.c
> new file mode 100644
> index 0000000..5e68190
> --- /dev/null
> +++ b/hw/kvm/pv_event.c
> @@ -0,0 +1,198 @@
> +/*
> + * QEMU KVM support, paravirtual event device
> + *
> + * Copyright Fujitsu, Corp. 2012
> + *
> + * Authors:
> + *     Wen Congyang <wency@cn.fujitsu.com>
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2 or later.
> + * See the COPYING file in the top-level directory.
> + *
> + */
> +
> +#include <linux/kvm_para.h>
> +#include <asm/kvm_para.h>
> +#include <qapi/qmp/qobject.h>
> +#include <qapi/qmp/qjson.h>
> +#include <monitor/monitor.h>
> +#include <sysemu/sysemu.h>
> +#include <sysemu/kvm.h>
> +
> +/* Possible values for action parameter. */
> +#define PANICKED_REPORT     1   /* emit QEVENT_GUEST_PANICKED only */
> +#define PANICKED_PAUSE      2   /* emit QEVENT_GUEST_PANICKED and pause VM */
> +#define PANICKED_POWEROFF   3   /* emit QEVENT_GUEST_PANICKED and quit VM */
> +#define PANICKED_RESET      4   /* emit QEVENT_GUEST_PANICKED and reset VM */
> +
> +#define PV_EVENT_DRIVER     "kvm_pv_event"
> +#define PV_IOPORT(obj)      OBJECT_CHECK(PVIOPortState, (obj), PV_EVENT_DRIVER)
> +
> +struct PVEventAction {
> +    char *panicked_action;
> +    int panicked_action_value;
> +};
> +
> +#define DEFINE_PV_EVENT_PROPERTIES(_state, _conf)   \
> +    DEFINE_PROP_STRING("panicked_action", _state, _conf.panicked_action)
> +
> +static void panicked_mon_event(const char *action)
> +{
> +    QObject *data;
> +
> +    data = qobject_from_jsonf("{ 'action': %s }", action);
> +    monitor_protocol_event(QEVENT_GUEST_PANICKED, data);
> +    qobject_decref(data);
> +}
> +
> +static void panicked_perform_action(uint32_t panicked_action)
> +{
> +    switch (panicked_action) {
> +    case PANICKED_REPORT:
> +        panicked_mon_event("report");
> +        break;
> +
> +    case PANICKED_PAUSE:
> +        panicked_mon_event("pause");
> +        vm_stop(RUN_STATE_GUEST_PANICKED);
> +        break;
> +
> +    case PANICKED_POWEROFF:
> +        panicked_mon_event("poweroff");
> +        qemu_system_shutdown_request();
> +        break;
> +
> +    case PANICKED_RESET:
> +        panicked_mon_event("reset");
> +        qemu_system_reset_request();
> +        break;
> +    }
> +}
> +
> +static uint64_t supported_event(void)
> +{
> +    return 1 << KVM_PV_FEATURE_PANICKED;
> +}
> +
> +static void handle_event(int event, struct PVEventAction *conf)
> +{
> +    if (event == KVM_PV_EVENT_PANICKED) {
> +        panicked_perform_action(conf->panicked_action_value);
> +    }
> +}
> +
> +static int pv_event_init(struct PVEventAction *conf)
> +{
> +    if (!conf->panicked_action) {
> +        conf->panicked_action_value = PANICKED_REPORT;
> +    } else if (strcasecmp(conf->panicked_action, "none") == 0) {
> +        conf->panicked_action_value = PANICKED_REPORT;
> +    } else if (strcasecmp(conf->panicked_action, "pause") == 0) {
> +        conf->panicked_action_value = PANICKED_PAUSE;
> +    } else if (strcasecmp(conf->panicked_action, "poweroff") == 0) {
> +        conf->panicked_action_value = PANICKED_POWEROFF;
> +    } else if (strcasecmp(conf->panicked_action, "reset") == 0) {
> +        conf->panicked_action_value = PANICKED_RESET;
> +    } else {
> +        return -1;
> +    }
> +
> +    return 0;
> +}
> +
> +#if defined(KVM_PV_EVENT_PORT)
> +
> +#include "hw/isa.h"
> +
> +typedef struct {
> +    ISADevice dev;
> +    struct PVEventAction conf;
> +    MemoryRegion ioport;
> +} PVIOPortState;
> +
> +static uint64_t pv_io_read(void *opaque, hwaddr addr, unsigned size)
> +{
> +    return supported_event();
> +}
> +
> +static void pv_io_write(void *opaque, hwaddr addr, uint64_t val,
> +                        unsigned size)
> +{
> +    PVIOPortState *s = opaque;
> +
> +    handle_event(val, &s->conf);
> +}
> +
> +static const MemoryRegionOps pv_io_ops = {
> +    .read = pv_io_read,
> +    .write = pv_io_write,
> +    .impl = {
> +        .min_access_size = 4,
> +        .max_access_size = 4,
> +    },
> +};
> +
> +static int pv_ioport_initfn(ISADevice *dev)
> +{
> +    PVIOPortState *s = PV_IOPORT(dev);
> +
> +    if (pv_event_init(&s->conf) < 0) {
> +        return -1;
> +    }
> +
> +    memory_region_init_io(&s->ioport, &pv_io_ops, s, "pv_event", 4);
> +    isa_register_ioport(dev, &s->ioport, KVM_PV_EVENT_PORT);
> +
> +    return 0;
> +}
> +
> +static Property pv_ioport_properties[] = {
> +    DEFINE_PV_EVENT_PROPERTIES(PVIOPortState, conf),
> +    DEFINE_PROP_END_OF_LIST(),
> +};
> +
> +static void pv_ioport_class_init(ObjectClass *klass, void *data)
> +{
> +    DeviceClass *dc = DEVICE_CLASS(klass);
> +    ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
> +
> +    ic->init = pv_ioport_initfn;
> +    dc->no_user = 1;
> +    dc->props = pv_ioport_properties;
> +}
> +
> +static TypeInfo pv_ioport_info = {
> +    .name          = PV_EVENT_DRIVER,
> +    .parent        = TYPE_ISA_DEVICE,
> +    .instance_size = sizeof(PVIOPortState),
> +    .class_init    = pv_ioport_class_init,
> +};
> +
> +static void pv_ioport_register_types(void)
> +{
> +    type_register_static(&pv_ioport_info);
> +}
> +
> +type_init(pv_ioport_register_types)
> +
> +void kvm_pv_event_init(void *opaque)
> +{
> +    ISABus *bus = opaque;
> +    ISADevice *dev;
> +
> +    dev = isa_create(bus, PV_EVENT_DRIVER);
> +    qdev_init_nofail(&dev->qdev);
> +}
> +
> +#else
> +
> +/*
> + * If you need a qom device to handle pv event, this device should
> + * be created and initialized in kvm_pv_event_init().
> + *
> + * The parameter opaque is the device's parent bus.
> + */
> +void kvm_pv_event_init(void *opaque)
> +{
> +}
> +#endif
> diff --git a/hw/pc_piix.c b/hw/pc_piix.c
> index aa9cc81..24a9bf3 100644
> --- a/hw/pc_piix.c
> +++ b/hw/pc_piix.c
> @@ -47,6 +47,7 @@
>  #ifdef CONFIG_XEN
>  #  include <xen/hvm/hvm_info_table.h>
>  #endif
> +#include <linux/kvm_para.h>
> 
>  #define MAX_IDE_BUS 2
> 
> @@ -216,6 +217,10 @@ static void pc_init1(MemoryRegion *system_memory,
>      if (pci_enabled) {
>          pc_pci_device_init(pci_bus);
>      }
> +
> +    if (kvm_enabled()) {
> +        kvm_pv_event_init(isa_bus);
> +    }
>  }
> 
>  static void pc_init_pci(QEMUMachineInitArgs *args)
> diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
> index f2d97b5..97d3daf 100644
> --- a/include/sysemu/kvm.h
> +++ b/include/sysemu/kvm.h
> @@ -296,4 +296,6 @@ int kvm_irqchip_add_irqfd_notifier(KVMState *s, EventNotifier *n, int virq);
>  int kvm_irqchip_remove_irqfd_notifier(KVMState *s, EventNotifier *n, int virq);
>  void kvm_pc_gsi_handler(void *opaque, int n, int level);
>  void kvm_pc_setup_irq_routing(bool pci_enabled);
> +
> +void kvm_pv_event_init(void *opaque);
>  #endif
> diff --git a/kvm-stub.c b/kvm-stub.c
> index 760aadc..f543fa2 100644
> --- a/kvm-stub.c
> +++ b/kvm-stub.c
> @@ -145,3 +145,7 @@ int kvm_irqchip_remove_irqfd_notifier(KVMState *s, EventNotifier *n, int virq)
>  {
>      return -ENOSYS;
>  }
> +
> +void kvm_pv_event_init(void *opaque)
> +{
> +}
> 

  parent reply	other threads:[~2013-03-04 10:10 UTC|newest]

Thread overview: 136+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-28 12:13 [PATCH v13 0/8] pv event interface between host and guest Hu Tao
2013-02-28 12:13 ` Hu Tao
2013-02-28 12:13 ` [PATCH v13] kvm: notify host when the guest is panicked Hu Tao
2013-02-28 12:13   ` Hu Tao
2013-02-28 12:13 ` [PATCH v13 1/8] save/load cpu runstate Hu Tao
2013-02-28 12:13   ` Hu Tao
2013-02-28 21:12   ` Eric Blake
2013-02-28 21:12     ` Eric Blake
2013-03-01  7:36     ` Hu Tao
2013-03-01  7:36       ` [Qemu-devel] " Hu Tao
2013-03-01  7:36       ` Hu Tao
2013-03-01 16:29       ` Eric Blake
2013-03-01 16:29         ` [Qemu-devel] " Eric Blake
2013-03-01 16:29         ` Eric Blake
2013-03-04  9:30   ` Paolo Bonzini
2013-03-04  9:30     ` [Qemu-devel] " Paolo Bonzini
2013-03-04  9:30     ` Paolo Bonzini
2013-03-05  2:33     ` Hu Tao
2013-03-05  2:33       ` [Qemu-devel] " Hu Tao
2013-03-05  2:33       ` Hu Tao
2013-03-05  8:24       ` Paolo Bonzini
2013-03-05  8:24         ` [Qemu-devel] " Paolo Bonzini
2013-03-05  8:24         ` Paolo Bonzini
2013-02-28 12:13 ` [PATCH v13 2/8] start vm after resetting it Hu Tao
2013-02-28 12:13   ` Hu Tao
2013-02-28 13:23   ` Jan Kiszka
2013-02-28 13:23     ` Jan Kiszka
2013-03-05  3:05     ` Hu Tao
2013-03-05  3:05       ` [Qemu-devel] " Hu Tao
2013-03-05  3:05       ` Hu Tao
2013-03-04  9:32   ` Paolo Bonzini
2013-03-04  9:32     ` [Qemu-devel] " Paolo Bonzini
2013-03-04  9:32     ` Paolo Bonzini
2013-03-05  3:06     ` Hu Tao
2013-03-05  3:06       ` [Qemu-devel] " Hu Tao
2013-03-05  3:06       ` Hu Tao
2013-02-28 12:13 ` [PATCH v13 3/8] update kernel headers Hu Tao
2013-02-28 12:13   ` Hu Tao
2013-02-28 12:13 ` [PATCH v13 4/8] add a new runstate: RUN_STATE_GUEST_PANICKED Hu Tao
2013-02-28 12:13   ` Hu Tao
2013-03-04  9:40   ` Paolo Bonzini
2013-03-04  9:40     ` [Qemu-devel] " Paolo Bonzini
2013-03-04  9:40     ` Paolo Bonzini
2013-03-05  3:17     ` Hu Tao
2013-03-05  3:17       ` [Qemu-devel] " Hu Tao
2013-03-05  3:17       ` Hu Tao
2013-03-05  8:26       ` Paolo Bonzini
2013-03-05  8:26         ` [Qemu-devel] " Paolo Bonzini
2013-03-05  8:26         ` Paolo Bonzini
2013-03-06  9:03         ` Hu Tao
2013-03-06  9:03           ` [Qemu-devel] " Hu Tao
2013-03-06  9:03           ` Hu Tao
2013-02-28 12:13 ` [PATCH v13 5/8] add a new qevent: QEVENT_GUEST_PANICKED Hu Tao
2013-02-28 12:13   ` Hu Tao
2013-03-01 16:31   ` Eric Blake
2013-03-01 16:31     ` [Qemu-devel] " Eric Blake
2013-03-01 16:31     ` Eric Blake
2013-03-05  3:17     ` Hu Tao
2013-03-05  3:17       ` [Qemu-devel] " Hu Tao
2013-03-05  3:17       ` Hu Tao
2013-03-04  9:40   ` Paolo Bonzini
2013-03-04  9:40     ` [Qemu-devel] " Paolo Bonzini
2013-03-04  9:40     ` Paolo Bonzini
2013-02-28 12:13 ` [PATCH v13 6/8] introduce a new qom device to deal with panicked event Hu Tao
2013-02-28 12:13   ` Hu Tao
2013-03-04  9:42   ` Paolo Bonzini
2013-03-04  9:42     ` [Qemu-devel] " Paolo Bonzini
2013-03-04  9:42     ` Paolo Bonzini
2013-03-04 10:10   ` Christian Borntraeger [this message]
2013-03-04 10:10     ` [Qemu-devel] " Christian Borntraeger
2013-03-04 10:21     ` Paolo Bonzini
2013-03-04 10:21       ` [Qemu-devel] " Paolo Bonzini
2013-02-28 12:13 ` [PATCH v13 7/8] allower the user to disable pv event support Hu Tao
2013-02-28 12:13   ` Hu Tao
2013-03-04  9:47   ` Paolo Bonzini
2013-03-04  9:47     ` [Qemu-devel] " Paolo Bonzini
2013-03-04  9:47     ` Paolo Bonzini
2013-02-28 12:13 ` [PATCH v13 8/8] pv event: add document to describe the usage Hu Tao
2013-02-28 12:13   ` Hu Tao
2013-03-03  9:17 ` [PATCH v13 0/8] pv event interface between host and guest Gleb Natapov
2013-03-03  9:17   ` [Qemu-devel] " Gleb Natapov
2013-03-03  9:17   ` Gleb Natapov
2013-03-04 10:05   ` Paolo Bonzini
2013-03-04 10:05     ` [Qemu-devel] " Paolo Bonzini
2013-03-04 10:05     ` Paolo Bonzini
2013-03-04 10:21     ` Gleb Natapov
2013-03-04 10:21       ` [Qemu-devel] " Gleb Natapov
2013-03-04 10:21       ` Gleb Natapov
2013-03-04 10:28       ` Paolo Bonzini
2013-03-04 10:28         ` [Qemu-devel] " Paolo Bonzini
2013-03-04 10:43         ` Gleb Natapov
2013-03-04 10:43           ` [Qemu-devel] " Gleb Natapov
2013-03-04 10:43           ` Gleb Natapov
2013-03-04 10:49           ` Paolo Bonzini
2013-03-04 10:49             ` [Qemu-devel] " Paolo Bonzini
2013-03-04 10:49             ` Paolo Bonzini
2013-03-04 10:59             ` Gleb Natapov
2013-03-04 10:59               ` [Qemu-devel] " Gleb Natapov
2013-03-04 10:59               ` Gleb Natapov
2013-03-04 11:10               ` Paolo Bonzini
2013-03-04 11:10                 ` [Qemu-devel] " Paolo Bonzini
2013-03-04 11:10                 ` Paolo Bonzini
2013-03-04 11:20                 ` Gleb Natapov
2013-03-04 11:20                   ` [Qemu-devel] " Gleb Natapov
2013-03-04 11:20                   ` Gleb Natapov
2013-03-04 11:35                   ` Paolo Bonzini
2013-03-04 11:35                     ` [Qemu-devel] " Paolo Bonzini
2013-03-04 11:35                     ` Paolo Bonzini
2013-03-04 11:52                     ` Gleb Natapov
2013-03-04 11:52                       ` [Qemu-devel] " Gleb Natapov
2013-03-04 11:52                       ` Gleb Natapov
2013-03-04 12:21                       ` Paolo Bonzini
2013-03-04 12:21                         ` [Qemu-devel] " Paolo Bonzini
2013-03-04 12:21                         ` Paolo Bonzini
2013-03-06  8:56     ` Hu Tao
2013-03-06  8:56       ` [Qemu-devel] " Hu Tao
2013-03-06  8:56       ` Hu Tao
2013-03-06  9:07       ` Paolo Bonzini
2013-03-06  9:07         ` [Qemu-devel] " Paolo Bonzini
2013-03-06  9:28         ` li guang
2013-03-06  9:28           ` li guang
2013-03-06  9:38         ` Gleb Natapov
2013-03-06  9:38           ` [Qemu-devel] " Gleb Natapov
2013-03-06  9:38           ` Gleb Natapov
2013-03-06  9:48           ` Paolo Bonzini
2013-03-06  9:48             ` [Qemu-devel] " Paolo Bonzini
2013-03-06  9:48             ` Paolo Bonzini
2013-03-06  9:59             ` Gleb Natapov
2013-03-06  9:59               ` [Qemu-devel] " Gleb Natapov
2013-03-06  9:59               ` Gleb Natapov
2013-03-06  8:46   ` Hu Tao
2013-03-06  8:46     ` [Qemu-devel] " Hu Tao
2013-03-06  8:46     ` Hu Tao
2013-03-06  9:37     ` Gleb Natapov
2013-03-06  9:37       ` [Qemu-devel] " Gleb Natapov
2013-03-06  9:37       ` Gleb Natapov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5134730A.2050406@de.ibm.com \
    --to=borntraeger@de.ibm.com \
    --cc=agraf@suse.de \
    --cc=alex.williamson@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=armbru@redhat.com \
    --cc=blauwirbel@gmail.com \
    --cc=drjones@redhat.com \
    --cc=gleb@redhat.com \
    --cc=hutao@cn.fujitsu.com \
    --cc=jan.kiszka@siemens.com \
    --cc=jfrei@linux.vnet.ibm.com \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=kvm@vger.kernel.org \
    --cc=kwolf@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=levinsasha928@gmail.com \
    --cc=mihajlov@linux.vnet.ibm.com \
    --cc=mst@redhat.com \
    --cc=mtosatti@redhat.com \
    --cc=owasserm@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.