On Fri, Feb 27, 2015 at 8:41 AM, Michael Roth <mdr...@linux.vnet.ibm.com> wrote: > +static void attach(sPAPRDRConnector *drc, DeviceState *d, void *fdt, > + int fdt_start_offset, bool coldplug, Error **errp) > +{ > + DPRINTFN("drc: %x, attach", get_index(drc)); > + > + if (drc->isolation_state != SPAPR_DR_ISOLATION_STATE_ISOLATED) { > + error_setg(errp, "an attached device is still awaiting release"); > + return; > + } > + g_assert(drc->allocation_state == SPAPR_DR_ALLOCATION_STATE_UNUSABLE); > + g_assert(fdt || coldplug); > + > + /* NOTE: setting initial isolation state to UNISOLATED means we can't > + * detach unless guest has a userspace/kernel that moves this state > + * back to ISOLATED in response to an unplug event, or this is done > + * manually by the admin prior. if we force things while the guest > + * may be accessing the device, we can easily crash the guest, so we > + * we defer completion of removal in such cases to the reset() hook. > + */ > + drc->isolation_state = SPAPR_DR_ISOLATION_STATE_UNISOLATED; > + drc->allocation_state = SPAPR_DR_ALLOCATION_STATE_USABLE;
BTW shouldn't isolation_state and allocation_state be set to UNISOLATED and USABLE in response to guest's rtas-set-indicator calls ? At least, that is how it is done/expected for CPU hotplug case. Ref: kernel code arch/powerpc/platforms/pseries/dlpar.c: dlpar_acquire[release]_drc(). Same question for detach(). Regards, Bharata.