From: Marcel Apfelbaum <marcel.a@redhat.com>
To: Igor Mammedov <imammedo@redhat.com>
Cc: peter.maydell@linaro.org, ehabkost@redhat.com, mst@redhat.com,
qemu-devel@nongnu.org, blauwirbel@gmail.com,
alex.williamson@redhat.com, anthony@codemonkey.ws,
pbonzini@redhat.com, afaerber@suse.de
Subject: Re: [Qemu-devel] [PATCH 1/7] define hotplug interface
Date: Mon, 09 Dec 2013 10:58:04 +0200 [thread overview]
Message-ID: <1386579484.10879.3.camel@localhost.localdomain> (raw)
In-Reply-To: <1386349395-5710-2-git-send-email-imammedo@redhat.com>
On Fri, 2013-12-06 at 18:03 +0100, Igor Mammedov wrote:
> Provide generic hotplug interface for devices.
> Intended for replacing hotplug mechanism used by
> PCI/PCIE/SHPC code.
>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
> it's scsi-bus like interface, but abstracted from bus altogether
> since all current users care about in hotplug handlers, it's
> hotplug device and hotplugged device and bus only serves
> as a means to get access to hotplug device and it's callbacks.
> ---
> hw/core/Makefile.objs | 1 +
> hw/core/hotplug.c | 25 ++++++++++++++++++++++++
> include/hw/hotplug.h | 50 +++++++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 76 insertions(+), 0 deletions(-)
> create mode 100644 hw/core/hotplug.c
> create mode 100644 include/hw/hotplug.h
>
> diff --git a/hw/core/Makefile.objs b/hw/core/Makefile.objs
> index 950146c..47f6555 100644
> --- a/hw/core/Makefile.objs
> +++ b/hw/core/Makefile.objs
> @@ -10,4 +10,5 @@ common-obj-$(CONFIG_SOFTMMU) += sysbus.o
> common-obj-$(CONFIG_SOFTMMU) += null-machine.o
> common-obj-$(CONFIG_SOFTMMU) += loader.o
> common-obj-$(CONFIG_SOFTMMU) += qdev-properties-system.o
> +common-obj-$(CONFIG_SOFTMMU) += hotplug.o
>
> diff --git a/hw/core/hotplug.c b/hw/core/hotplug.c
> new file mode 100644
> index 0000000..3e84d9c
> --- /dev/null
> +++ b/hw/core/hotplug.c
> @@ -0,0 +1,25 @@
> +/*
> + * Hotplug device interface.
> + *
> + * Copyright (c) 2013 Red Hat Inc.
> + *
> + * Authors:
> + * Igor Mammedov <imammedo@redhat.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 "hw/hotplug.h"
> +
> +static const TypeInfo hotplug_device_info = {
> + .name = TYPE_HOTPLUG_DEVICE,
> + .parent = TYPE_INTERFACE,
> + .class_size = sizeof(HotplugDeviceClass),
> +};
> +
> +static void hotplug_device_register_types(void)
> +{
> + type_register_static(&hotplug_device_info);
> +}
> +
> +type_init(hotplug_device_register_types)
> diff --git a/include/hw/hotplug.h b/include/hw/hotplug.h
> new file mode 100644
> index 0000000..cfa79bb
> --- /dev/null
> +++ b/include/hw/hotplug.h
> @@ -0,0 +1,50 @@
> +/*
> + * Hotplug device interface.
> + *
> + * Copyright (c) 2013 Red Hat Inc.
> + *
> + * Authors:
> + * Igor Mammedov <imammedo@redhat.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.
> + */
> +#ifndef HOTPLUG_H
> +#define HOTPLUG_H
> +
> +#include "hw/qdev-core.h"
> +
> +#define TYPE_HOTPLUG_DEVICE "hotplug-device"
> +
> +#define HOTPLUG_DEVICE_CLASS(klass) \
> + OBJECT_CLASS_CHECK(HotplugDeviceClass, (klass), TYPE_HOTPLUG_DEVICE)
> +#define HOTPLUG_DEVICE_GET_CLASS(obj) \
> + OBJECT_GET_CLASS(HotplugDeviceClass, (obj), TYPE_HOTPLUG_DEVICE)
> +
> +/**
> + * hotplug_fn:
> + * @hotplug_dev: a device performing hotplug/uplug action
/s/uplug/unplug :)
> + * @hotplugged_dev: a device that has been hotplugged
> + * @errp: returns an error if this function fails
> + */
> +typedef void (*hotplug_fn)(DeviceState *hotplug_dev,
> + DeviceState *hotplugged_dev, Error **errp);
> +
> +/**
> + * HotplugDeviceClass:
> + *
> + * Interface to be implemented by a device performing
> + * hardware hotplug/unplug functions.
> + *
> + * @parent: Opaque parent interface.
> + * @hotplug: hotplug callback.
> + * @hot_unplug: hot unplug callback.
> + */
> +typedef struct HotplugDeviceClass {
May I ask why do we call it a class if it is an interface?
I would call it HotplugDeviceInterface, so I will not think
that it is part of the inheritance chain every time I see it in code.
Did I miss something?
Thanks,
Marcel
> + InterfaceClass parent;
> +
> + hotplug_fn hotplug;
> + hotplug_fn hot_unplug;
> +} HotplugDeviceClass;
> +
> +#endif
next prev parent reply other threads:[~2013-12-09 8:58 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-06 17:03 [Qemu-devel] [PATCH 0/7] Refactor PCI/SHPC/PCIE hotplug to use a more generic hotplug API Igor Mammedov
2013-12-06 17:03 ` [Qemu-devel] [PATCH 1/7] define hotplug interface Igor Mammedov
2013-12-06 17:26 ` Paolo Bonzini
2013-12-09 12:42 ` Igor Mammedov
2013-12-09 13:15 ` Paolo Bonzini
2013-12-09 5:40 ` Li Guang
2013-12-09 9:11 ` Marcel Apfelbaum
2013-12-09 12:44 ` Igor Mammedov
2013-12-09 8:58 ` Marcel Apfelbaum [this message]
2013-12-09 12:52 ` Igor Mammedov
2013-12-06 17:03 ` [Qemu-devel] [PATCH 2/7] qdev: add to BusState "hotplug-device" link Igor Mammedov
2013-12-06 17:03 ` [Qemu-devel] [PATCH 3/7] hw/acpi: move typeinfo to the file end Igor Mammedov
2013-12-06 17:03 ` [Qemu-devel] [PATCH 4/7] acpi/piix4pm: convert ACPI PCI hotplug to use hotplug-device interface Igor Mammedov
2013-12-09 9:02 ` Marcel Apfelbaum
2013-12-09 13:24 ` Igor Mammedov
2013-12-06 17:03 ` [Qemu-devel] [PATCH 5/7] pci/shpc: convert SHPC " Igor Mammedov
2013-12-06 17:03 ` [Qemu-devel] [PATCH 6/7] pci/pcie: convert PCIE " Igor Mammedov
2013-12-06 17:03 ` [Qemu-devel] [PATCH 7/7] hw/pci: convert PCI bus to use "hotplug-device" interface Igor Mammedov
2013-12-06 17:29 ` Paolo Bonzini
2013-12-09 13:41 ` Igor Mammedov
2013-12-09 13:47 ` Paolo Bonzini
2013-12-09 14:14 ` Igor Mammedov
2013-12-09 14:36 ` Paolo Bonzini
2013-12-09 15:08 ` Igor Mammedov
2013-12-09 15:16 ` Paolo Bonzini
2013-12-09 16:48 ` Igor Mammedov
2013-12-09 17:18 ` Paolo Bonzini
2013-12-09 21:15 ` Igor Mammedov
2013-12-09 22:28 ` Paolo Bonzini
2013-12-09 9:09 ` Marcel Apfelbaum
2013-12-09 13:55 ` Igor Mammedov
2013-12-09 14:01 ` Marcel Apfelbaum
2013-12-06 17:31 ` [Qemu-devel] [PATCH 0/7] Refactor PCI/SHPC/PCIE hotplug to use a more generic hotplug API Paolo Bonzini
2013-12-09 14:15 ` Igor Mammedov
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=1386579484.10879.3.camel@localhost.localdomain \
--to=marcel.a@redhat.com \
--cc=afaerber@suse.de \
--cc=alex.williamson@redhat.com \
--cc=anthony@codemonkey.ws \
--cc=blauwirbel@gmail.com \
--cc=ehabkost@redhat.com \
--cc=imammedo@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).