The mildness of sweet onions make them ideal for this delicately hearty side.
Preheat oven to 400 degrees. Peel onions; slice 1/2 inch from top of each, and discard. Slice just enough from the root end so that onions stand upright. Using a melon baller, hollow out the insides, leaving a 1/3- to 1/2-inch-thick shell. Set aside. Finely chop removed parts, and set 1 cup chopped onion aside. Discard remaining onion or reserve for another use.
Bring a large pot of water to a boil; add salt. Gently submerge onion shells, and boil 5 minutes. Remove with a slotted spoon; transfer to a wire rack to dry.
Make the stuffing: In a large saute pan, heat 1 tablespoon oil over medium heat. Add reserved chopped onions, and cook until translucent, about 8 minutes. Add mushrooms and ham, and season with salt and pepper; cook until mixture is browned, about 5 minutes. Add Madeira; deglaze pan, stirring with a wooden spoon to loosen any brown bits on bottom. Remove from heat, and transfer to a small mixing bowl; let cool slightly, 2 to 3 minutes. Add parsley and Gruyere cheese, and stir to combine.
Fill boiled onion shells with stuffing. Place in a small roasting pan; drizzle with remaining tablespoon oil. Cover with aluminum foil. Bake until tender, about 50 minutes; remove foil after 40 minutes to allow stuffing to brown.