Cook the pasta in salted boiling water until al dente, according to package instructions.
While the pasta is cooking, heat the olive oil in a large skillet over medium heat.
Add the sliced onions to the skillet and stir to coat them in the oil.
Reduce the heat to low and cook the onions for 30-40 minutes, stirring occasionally until they are deeply golden brown and caramelized.
Once the pasta is cooked, drain it, reserving about a cup of pasta water, and add it to the skillet with the caramelized onions.
Drizzle the chili oil over the pasta, adding salt and pepper to taste, and toss well to combine.
Serve hot, garnished with grated Parmesan cheese if desired.