This is probably borderline ASB, but what about Carlos dividing his realm up in his will? I know it requires a personality change on his part (partially). The reason he went with the French get everything was in part because they were the senior heirs, and in part because he had been madly in love with his first (French) wife. Plus, according to one of the books I read, it was also thanks to French bribery of the pope, who persuaded Carlos to name a French successor. The Habsburgs weren't helped by the fact that their ambassador at Madrid was an ass and hat he was a cheapskate in comparison to his more adroit French counterpart. Add to that that the pro-Austrian queen ruled Carlos "like a strict governess", and one can understand why he is in favour of the French.
So, say Carlos still names a French prince as his heir, but only in Spain and the New World. Naples and the (Southern) Netherlands goes to Austria (and another French prince might get Naples if Austria doesn't agree), while the middling powers of Lorraine, Bavaria and Savoy (who all have claims to somewhere) get the rest of it divvied up. I'm not sure how the Austrians could swing it to get this right, but could it either avert the war? Or would whoever (France/Austria) try to have the will set aside (I'm not sure if there's precedent for it in the Spanish monarchy), and claim the whole thing. I'm sure it probably requires either a capable valido in Madrid to get this right, or Carlos to have enough grey matter to realize that leaving everything to Austria or France is going to result in a war Spain can't afford.