You have to run QEMU and GDB in separate terminals. 'Attach' means to connect GDB to QEMU (command: 'target remote tcp::1234'). To do simple test, run 'qemu-system-i386 -s -S'. It should say 'Paused' in title bar and not initialize its display. This means that it's waiting for GDB. Then start GDB in other terminal and type 'target remote tcp::1234'.
GDB should output something like this:
Code:
0x0000fff0 in ?? ()
(gdb) _
GDB doesn't work well with 16 bit code and without debugging information, so you won't be able to disassemble. But you should be able to view registers (using 'info registers' command), step by instructions (using 'nexti' command), set breakpoints etc. You will need to translate addresses between 16 and 32 bit modes yourself if you plan to debug real mode code (as said before, GDB doesn't work well with 16 bit code). And DO NOT use KVM. It will make debugging unreliable.
BTW. You can also use QEMUs built-in monitor. Press CTRL+ALT+2 in QEMU to see it. There you can view registers, Disassemble some code, view memory and much more. You can't set breakpoints there, but you can add some traps in your code and work with that.