Am 07.08.2013 09:03, schrieb Alexey Kardashevskiy: > On 08/06/2013 08:12 PM, Andreas Färber wrote: >>> + /* Call emulated XICS implementation for consistency */ >>> + assert(xics_info && xics_info->cpu_setup); >>> + xics_info->cpu_setup(icp, cpu); >>> +} >>> + >>> +void xics_kvm_set_nr_irqs(XICSState *icp, uint32_t nr_irqs) >>> +{ >>> + icp->ics = ICS(object_new(TYPE_ICS_KVM)); >>> + object_property_add_child(OBJECT(icp), "ics", OBJECT(icp->ics), NULL); >>> + icp->ics->icp = icp; >> >> instance_init + object_initialize()? > > Create ICS_KVM in instance_init of XICS_KVM and initialize it here? Why split?
Answered on 5/6 (mail bounced at first due to kernel.crashing.org). >>> + icp->nr_irqs = icp->ics->nr_irqs = nr_irqs; >>> +} >>> + >>> +void xics_kvm_set_nr_servers(XICSState *icp, uint32_t nr_servers) >>> +{ >>> + int i; >>> + >>> + icp->nr_servers = nr_servers; >>> + >>> + icp->ss = g_malloc0(icp->nr_servers*sizeof(ICPState)); >>> + for (i = 0; i < icp->nr_servers; i++) { >>> + char buffer[32]; >>> + object_initialize(&icp->ss[i], TYPE_ICP_KVM); >>> + snprintf(buffer, sizeof(buffer), "icp[%d]", i); >>> + object_property_add_child(OBJECT(icp), buffer, >>> OBJECT(&icp->ss[i]), NULL); >>> + } >>> +} [...] >>> +static void xics_kvm_realize(DeviceState *dev, Error **errp) >>> +{ >>> + KVMXICSState *icpkvm = KVM_XICS(dev); >>> + XICSState *icp = XICS_COMMON(dev); >>> + int i, rc; >>> + Error *error = NULL; >>> + struct kvm_create_device xics_create_device = { >>> + .type = KVM_DEV_TYPE_XICS, >>> + .flags = 0, >>> + }; >>> + >>> + assert(kvm_enabled()); >>> + assert(kvm_check_extension(kvm_state, KVM_CAP_IRQ_XICS)); >> >> error_setg() - if device can be created without accel=kvm (which it >> looks as if it can) then you should just error out the nice way here. > > > I check kvm_enabled() (I thought I check both but was wrong, will fix it) > where I try to create XICS_KVM so we should not be here if that check failed. -device, -object and patch Anthony's patch QMP are other ways to instantiate the same type. :) Andreas -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg