Qwerty it's not known before the pools are over, but come the last round of games you can probably have a good guess.
Qualifying works like this: The top team in each of the 6 pools qualify, then the 2 runners up with the most points qualify also.
After that the 8 qualifiers are ranked 1 to 8 based on the number of points they got in the pool stage. Bonus points and tries scored are used for teams who got the same total points.
Once the ranking is known then it's:
Game 1: 1v8,
Game 2: 2v7,
Game 3: 3v6,
Game 4: 4v5
With those ranked 1-4 getting home advantage. This is crucial as every year almost like clockwork 3 of the 4 home quaterfinalist win, but leaves that chance for the other teams that they'll be the one to win away.
The one that the loses at home are generally unlucky to draw a true powerhouse that had one bad weekend and normally they make things worse for themselves by moving it to a bigger stadium which their opponents are more than happy to fill. Doing this at home to say Munster in a quarter final is basically making it a home game for them.
In the semi final it's
Winner of Game 1 v winner of Game 3
Winner of Game 2 v Winner of Game 4
Winners of Game 1 & 2 have home country advantage for the semi final.
The ranking format makes the final weekend more exciting because it means those teams that have already qualified for the quarters field a strong team in the hope of securing a top 4 rank and therefore a home draw.