Lay the duck legs on top of the bed of onions and add just enough red wine to barely cover them halfway. Lay a sheet of foil directly on top of the duck and press it to the sides of the pan to create a loose seal. Cover tightly and cook over low heat until the duck meat is falling off the bone, about 1 1/4 to 1 1/2 hours. The heat should be low enough that the liquid barely bubbles. Turn the legs once or twice to make sure they cook evenly.
Remove the legs from the pan, set them aside, and increase the heat to high. Cook until the wine has reduced to just below the top of the onions, about 5 minutes. Stir in the tomato paste and continue cooking over medium-high heat, stirring occasionally, until the paste has thickened again and is a dark brick red, almost brown, 15 to 20 minutes.
Chop the canned tomatoes, drain them again and add to the pan. Cook, stirring occasionally, until the sauce is a dark red and has thickened so that rather than a quiet simmer, it makes distinct popping sounds when the cooking bubbles burst, 20 to 25 minutes. It will want to stick a little during the last 10 minutes, so stir more frequently then.
While the tomatoes are cooking, remove the duck meat from the bones and shred it into large chunks. Discard the bones. When the tomatoes are done, add the meat and the rosemary, replace the foil and close tightly with the lid. Reduce the heat to low and cook until the sauce is quite thick and the meat begins to pull apart in strings when it is stirred, about 30 minutes.