[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PATCH v5 1/3] spapr: manage hotplugged devices while the VM
From: |
Greg Kurz |
Subject: |
[Qemu-ppc] [PATCH v5 1/3] spapr: manage hotplugged devices while the VM is not started |
Date: |
Wed, 14 Jun 2017 15:29:00 +0200 |
User-agent: |
StGit/0.17.1-20-gc0b1b-dirty |
From: Laurent Vivier <address@hidden>
For QEMU, a hotlugged device is a device added using the HMP/QMP
interface.
For SPAPR, a hotplugged device is a device added while the
machine is running. In this case QEMU doesn't update internal
state but relies on the OS for this part
In the case of migration, when we (libvirt) hotplug a device
on the source guest, we (libvirt) generally hotplug the same
device on the destination guest. But in this case, the machine
is stopped (RUN_STATE_INMIGRATE) and QEMU must not expect
the OS will manage it as an hotplugged device as it will
be "imported" by the migration.
This patch changes the meaning of "hotplugged" in spapr.c
to manage a QEMU hotplugged device like a "coldplugged" one
when the machine is awaiting an incoming migration.
Signed-off-by: Laurent Vivier <address@hidden>
Reviewed-by: Greg Kurz <address@hidden>
Reviewed-by: Daniel Barboza <address@hidden>
Tested-by: Daniel Barboza <address@hidden>
[groug: rebased to latest ppc-for-2.10]
Signed-off-by: Greg Kurz <address@hidden>
---
hw/ppc/spapr.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 1df642f4f5cf..1e13880ecb7c 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -2566,6 +2566,12 @@ static void spapr_nmi(NMIState *n, int cpu_index, Error
**errp)
}
}
+static bool spapr_coldplugged(DeviceState *dev)
+{
+ return runstate_check(RUN_STATE_INMIGRATE) ||
+ !dev->hotplugged;
+}
+
static void spapr_add_lmbs(DeviceState *dev, uint64_t addr_start, uint64_t
size,
uint32_t node, bool dedicated_hp_event_source,
Error **errp)
@@ -2575,6 +2581,7 @@ static void spapr_add_lmbs(DeviceState *dev, uint64_t
addr_start, uint64_t size,
int i, fdt_offset, fdt_size;
void *fdt;
uint64_t addr = addr_start;
+ bool coldplugged = spapr_coldplugged(dev);
for (i = 0; i < nr_lmbs; i++) {
drc = spapr_drc_by_id(TYPE_SPAPR_DRC_LMB,
@@ -2585,9 +2592,9 @@ static void spapr_add_lmbs(DeviceState *dev, uint64_t
addr_start, uint64_t size,
fdt_offset = spapr_populate_memory_node(fdt, node, addr,
SPAPR_MEMORY_BLOCK_SIZE);
- spapr_drc_attach(drc, dev, fdt, fdt_offset, !dev->hotplugged, errp);
+ spapr_drc_attach(drc, dev, fdt, fdt_offset, coldplugged, errp);
addr += SPAPR_MEMORY_BLOCK_SIZE;
- if (!dev->hotplugged) {
+ if (coldplugged) {
sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
/* guests expect coldplugged LMBs to be pre-allocated */
drck->set_allocation_state(drc, SPAPR_DR_ALLOCATION_STATE_USABLE);
@@ -2597,7 +2604,7 @@ static void spapr_add_lmbs(DeviceState *dev, uint64_t
addr_start, uint64_t size,
/* send hotplug notification to the
* guest only in case of hotplugged memory
*/
- if (dev->hotplugged) {
+ if (!coldplugged) {
if (dedicated_hp_event_source) {
drc = spapr_drc_by_id(TYPE_SPAPR_DRC_LMB,
addr_start / SPAPR_MEMORY_BLOCK_SIZE);
@@ -2908,6 +2915,7 @@ static void spapr_core_plug(HotplugHandler *hotplug_dev,
DeviceState *dev,
int smt = kvmppc_smt_threads();
CPUArchId *core_slot;
int index;
+ bool coldplugged = spapr_coldplugged(dev);
core_slot = spapr_find_cpu_slot(MACHINE(hotplug_dev), cc->core_id, &index);
if (!core_slot) {
@@ -2928,8 +2936,7 @@ static void spapr_core_plug(HotplugHandler *hotplug_dev,
DeviceState *dev,
}
if (drc) {
- spapr_drc_attach(drc, dev, fdt, fdt_offset, !dev->hotplugged,
- &local_err);
+ spapr_drc_attach(drc, dev, fdt, fdt_offset, coldplugged, &local_err);
if (local_err) {
g_free(fdt);
error_propagate(errp, local_err);
@@ -2937,7 +2944,7 @@ static void spapr_core_plug(HotplugHandler *hotplug_dev,
DeviceState *dev,
}
}
- if (dev->hotplugged) {
+ if (!coldplugged) {
/*
* Send hotplug notification interrupt to the guest only in case
* of hotplugged CPUs.
- [Qemu-ppc] [PATCH v5 0/3] spapr/xics: fix migration of older machine types, Greg Kurz, 2017/06/14
- [Qemu-ppc] [PATCH v5 1/3] spapr: manage hotplugged devices while the VM is not started,
Greg Kurz <=
- [Qemu-ppc] [PATCH v5 2/3] xics: directly register ICPState objects to vmstate, Greg Kurz, 2017/06/14
- [Qemu-ppc] [PATCH v5 3/3] spapr: fix migration of ICPState objects from/to older QEMU, Greg Kurz, 2017/06/14
- Re: [Qemu-ppc] [Qemu-devel] [PATCH v5 0/3] spapr/xics: fix migration of older machine types, no-reply, 2017/06/14
- Re: [Qemu-ppc] [PATCH v5 0/3] spapr/xics: fix migration of older machine types, David Gibson, 2017/06/14
- Re: [Qemu-ppc] [PATCH v5 0/3] spapr/xics: fix migration of older machine types, Cédric Le Goater, 2017/06/15