Juergen Keil
2007-Apr-02 09:41 UTC
[qemu-discuss] [PATCH] kqemu becomes unusable, all available instances in use
The Solaris kqemu kernel module does not release a device instance when the /dev/kqemu file is closed. Starting with the 17th open attempt on /dev/kqemu, kqemu becomes unusable, we get ENXIO errors, and the following message is logged to the console and /var/adm/messages: NOTICE: all available instances in use Since kqemu_open() detects a free kqemu instance by searching the kqemu_ssp soft state structure for an unallocated soft state instance, there should be some code that clears the soft state instance when a kqemu device instance is no longer in use. I''m using the fix included below, it frees the soft state from the kqemu_close() entry point. It also removes an extra call to ddi_soft_state_free() in the driver''s attach entry point, which is trying to free something in the error case when nothing has been allocated. diff -ru8 /tmp/kqemu-1.3.0pre11-ben/kqemu-solaris.c kqemu-1.3.0pre11-ben/kqemu-solaris.c --- /tmp/kqemu-1.3.0pre11-ben/kqemu-solaris.c 2007-03-20 20:10:10.000000000 +0100 +++ kqemu-1.3.0pre11-ben/kqemu-solaris.c 2007-03-31 00:52:06.174919073 +0200 @@ -477,16 +477,17 @@ kqemu_log_d("close"); if (ks == NULL) return (ENXIO); if (ks->state) { kqemu_delete(ks->state); ks->state = NULL; } + ddi_soft_state_free(kqemu_ssp, instance); return (0); } /* * Unlike on Linux, a 64-bit SunOS kernel does not imply 64-bit * userland. QEMU will need to be ported to 64-bit for the 64-bit * accelerator to work. 32-bit qemu in accelerated mode on 64-bit * kernel will likely never be supported. @@ -614,17 +615,16 @@ switch(cmd) { char s[16]; case DDI_ATTACH: snprintf(s, sizeof (s), "%d", instance); if (ddi_create_minor_node(dip, s, S_IFCHR, instance, DDI_PSEUDO, 0) != DDI_SUCCESS) { cmn_err(CE_NOTE, "attach(%d): could not add " "character node", instance); - ddi_soft_state_free(kqemu_ssp, instance); return (DDI_FAILURE); } kqemu_dip = dip; atomic_add_32(&kqemu_busy, 1); return (DDI_SUCCESS); default: return (DDI_SUCCESS); }
Ben Taylor
2007-Apr-02 18:40 UTC
[qemu-discuss] Re: [PATCH] kqemu becomes unusable, all available instances in use
> The Solaris kqemu kernel module does not release a > device instance > when the /dev/kqemu file is closed. Starting with > the 17th open > attempt on /dev/kqemu, kqemu becomes unusable, we get > ENXIO errors, > and the following message is logged to the console > and /var/adm/messages: > > NOTICE: all available instances in use > Since kqemu_open() detects a free kqemu instance by > searching the > kqemu_ssp soft state structure for an unallocated > soft state instance, > there should be some code that clears the soft state > instance when a > kqemu device instance is no longer in use.Nice work. definitely seems to fix that problem. I plan on posting the updated kqemu tarball in the next day or so. I need to work out the details on installing both the 32-bit and 64-bit version at the same time. Ben -- This message posted from opensolaris.org