Unfortunately, of course, the way the war would end, under any scenario that I can imagine, would be a tremendous morale booster for the other side.
However, I tend to think that the benefits of ending U.S. involvement in Iraq would outweigh the harm it might do to Afghanistan because of the resources that it would free up. As well, to some extent, the United States in particular--and perhaps it would require a new administration to do that--could signal a different policy and thereby recover some of the legitimacy that the intervention has lost in Afghanistan as a result of the intervention in Iraq.
I do know that Iranian intelligence officials and diplomats are very concerned, however, that some of the Arab al-Qaeda fighters in Iraq might decide to come to Afghanistan and try to start sectarian conflict there. And they would very much like to share that information and that concern with the United States and other western countries, but they're having difficulty doing so at present.