From: "Andreas Färber" <afaerber@suse.de>
To: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
Cc: Igor Mammedov <imammedo@redhat.com>,
qemu-devel@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [RFC][PATCH 6/6] i386: implement cpu interface 'cpu_common_unrealizefn'
Date: Thu, 29 Aug 2013 07:21:38 +0200 [thread overview]
Message-ID: <521EDA62.4010803@suse.de> (raw)
In-Reply-To: <e37070ab039896e827d4be6a7bc4237e1b9afc08.1377691274.git.chen.fan.fnst@cn.fujitsu.com>
Am 29.08.2013 04:09, schrieb Chen Fan:
> Implement cpu interface 'cpu_common_unrealizefn' for emiting vcpu-remove
> notifier to ACPI, then ACPI could send sci interrupt to OS for hot-remove
> vcpu.
>
> Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
> ---
> hw/i386/pc.c | 19 ++++++++++++++++++-
> qom/cpu.c | 13 +++++++++++++
> 2 files changed, 31 insertions(+), 1 deletion(-)
>
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index 75fc9bb..9a87ac0 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -960,7 +960,24 @@ void pc_hot_add_cpu(const int64_t id, Error **errp)
>
> void pc_hot_del_cpu(const int64_t id, Error **errp)
> {
> - /* TODO: hot remove VCPU. */
> + CPUState *s = NULL;
"cs" since this is in PC code, to free the "s" identifier.
> + X86CPU *cpu = NULL;
> + DeviceState *ds = NULL;
"dev" please for consistency.
> + DeviceClass *dc = NULL;
> +
> + s = qemu_get_cpu(id);
Same question as on 2/6, whether id == cpu_index here.
> + if (s == NULL) {
> + error_setg(errp, "Unable to find cpu-index: %" PRIi64
> + ",it non-exists or has been deleted.", id);
Space after comma please in English language and "doesn't exist".
> + return;
> + }
> +
> + cpu = X86_CPU(s);
> + ds = DEVICE(cpu);
> + dc = DEVICE_GET_CLASS(ds);
> + if (dc->unrealize) {
> + dc->unrealize(ds, errp);
> + }
Never call this directly, this is missing important device cleanups such
as VMState. What you want is:
object_property_set_bool(OBJECT(cs), false, "realized", errp);
> }
>
> void pc_cpus_init(const char *cpu_model, DeviceState *icc_bridge)
> diff --git a/qom/cpu.c b/qom/cpu.c
> index 3439c5d..d2b0c9e 100644
> --- a/qom/cpu.c
> +++ b/qom/cpu.c
> @@ -239,6 +239,18 @@ static void cpu_common_realizefn(DeviceState *dev, Error **errp)
> }
> }
>
> +static void cpu_common_unrealizefn(DeviceState *dev, Error **errp)
> +{
> + CPUNotifier notifier;
> +
> + notifier.dev = dev;
> + notifier.type = UNPLUG;
> +
> + if (dev->hotplugged) {
> + notifier_list_notify(&cpu_hotplug_notifiers, ¬ifier);
> + }
Apart from the misindentation this looks wrong. If we initialize a
machine with -smp 2 we should be allowed to hot-unplug CPU 1 IMO. Are
there any reasons not to allow that?
I would simply drop the dev->hotplugged check and always emit the
notification. When QEMU is shut down, the unrealizefn and finalizers are
not called, I believe.
Regards,
Andreas
> +}
> +
> static void cpu_common_initfn(Object *obj)
> {
> CPUState *cpu = CPU(obj);
> @@ -269,6 +281,7 @@ static void cpu_class_init(ObjectClass *klass, void *data)
> k->gdb_read_register = cpu_common_gdb_read_register;
> k->gdb_write_register = cpu_common_gdb_write_register;
> dc->realize = cpu_common_realizefn;
> + dc->unrealize = cpu_common_unrealizefn;
> dc->no_user = 1;
> }
>
>
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
prev parent reply other threads:[~2013-08-29 5:21 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-29 2:09 [Qemu-devel] [RFC][PATCH 0/6] i386: add cpu hot remove support Chen Fan
2013-08-29 2:09 ` [Qemu-devel] [RFC][PATCH 1/6] piix4: implement function 'cpu_status_write' for vcpu ejection Chen Fan
2013-08-29 2:09 ` [Qemu-devel] [RFC][PATCH 2/6] cpus: release allocated vcpu objects and exit vcpu thread Chen Fan
2013-08-29 5:10 ` Andreas Färber
2013-08-29 5:10 ` [Qemu-devel] " Andreas Färber
2013-08-29 10:08 ` chenfan
2013-08-29 2:09 ` [Qemu-devel] [RFC][PATCH 3/6] qom cpu: rename variable 'cpu_added_notifier' to 'cpu_hotplug_notifier' Chen Fan
2013-08-29 2:09 ` [Qemu-devel] [RFC][PATCH 4/6] qmp: add 'cpu-del' command support Chen Fan
2013-08-29 12:28 ` Eric Blake
2013-08-29 2:09 ` [Qemu-devel] [RFC][PATCH 5/6] qom cpu: add struct CPUNotifier for supporting PLUG and UNPLUG cpu notifier Chen Fan
2013-08-29 2:09 ` [Qemu-devel] [RFC][PATCH 6/6] i386: implement cpu interface 'cpu_common_unrealizefn' Chen Fan
2013-08-29 5:21 ` Andreas Färber [this message]
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=521EDA62.4010803@suse.de \
--to=afaerber@suse.de \
--cc=chen.fan.fnst@cn.fujitsu.com \
--cc=imammedo@redhat.com \
--cc=pbonzini@redhat.com \
--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 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.