lost and found ( for me ? )

Cache DNS : How BIND or unbound handles Auth servers that return SERVFAIL or unreachable

caching server ( BIND 9.9.1 or unbound 1.4.7 )
    |
internal root
    |
internal com
    |
aaaa.com ( two name servers : ns1.aaaa.com and ns2.aaaa.com )

[ when ns1.aaaa is unreachable and ns2.aaaa.com works well ]

- unbound 1.4.7

After unbound detects ns1.aaaa.com is unreachable , unbund does name resolutions for given queries to ns2.aaaa.com

unbound 1.4.7ns1.aaaa.comns2.aaaa.com
unbound sends queries to ns2.aaaa.com and does not send queries to ns1.aaaa.com for 900 seconds.unreachableworks well


Here’s a cap date on ns1.aaaa.com and ns2.aaaa.com

Seen from the cap date , unbound does send queries to a auth server that is unreachable for 900 seconds.

the cap date on ns1.example.com ( unbound 192.168.0.1 , ns1.example.com : 192.168.0.2 )
 0.000000 192.168.0.1 -> 192.168.0.2 DNS 81 Standard query A 3.aaaa.com
 0.300048 192.168.0.1 -> 192.168.0.2 DNS 81 Standard query A 6.aaaa.com
 0.376270 192.168.0.1 -> 192.168.0.2 DNS 81 Standard query A 3.aaaa.com
 0.400006 192.168.0.1 -> 192.168.0.2 DNS 81 Standard query A 7.aaaa.com
 0.499946 192.168.0.1 -> 192.168.0.2 DNS 81 Standard query A 8.aaaa.com
 0.676344 192.168.0.1 -> 192.168.0.2 DNS 81 Standard query A 6.aaaa.com
 0.700079 192.168.0.1 -> 192.168.0.2 DNS 82 Standard query A 10.aaaa.com
 0.776033 192.168.0.1 -> 192.168.0.2 DNS 81 Standard query A 7.aaaa.com
 0.876223 192.168.0.1 -> 192.168.0.2 DNS 81 Standard query A 8.aaaa.com
 1.076093 192.168.0.1 -> 192.168.0.2 DNS 82 Standard query A 10.aaaa.com
900.103775 192.168.0.1 -> 192.168.0.2 DNS 84 Standard query A 9004.aaaa.com
900.202465 192.168.0.1 -> 192.168.0.2 DNS 84 Standard query A 9005.aaaa.com
900.302595 192.168.0.1 -> 192.168.0.2 DNS 84 Standard query A 9006.aaaa.com
900.402598 192.168.0.1 -> 192.168.0.2 DNS 84 Standard query A 9007.aaaa.com
900.478800 192.168.0.1 -> 192.168.0.2 DNS 84 Standard query A 9004.aaaa.com
900.502539 192.168.0.1 -> 192.168.0.2 DNS 84 Standard query A 9008.aaaa.com
900.578741 192.168.0.1 -> 192.168.0.2 DNS 84 Standard query A 9005.aaaa.com
900.678931 192.168.0.1 -> 192.168.0.2 DNS 84 Standard query A 9006.aaaa.com
900.702667 192.168.0.1 -> 192.168.0.2 DNS 84 Standard query A 9010.aaaa.com
900.778874 192.168.0.1 -> 192.168.0.2 DNS 84 Standard query A 9007.aaaa.com
900.802608 192.168.0.1 -> 192.168.0.2 DNS 84 Standard query A 9011.aaaa.com
900.878815 192.168.0.1 -> 192.168.0.2 DNS 84 Standard query A 9008.aaaa.com
901.078945 192.168.0.1 -> 192.168.0.2 DNS 84 Standard query A 9010.aaaa.com
901.178889 192.168.0.1 -> 192.168.0.2 DNS 84 Standard query A 9011.aaaa.com
1801.406816 192.168.0.1 -> 192.168.0.2 DNS 85 Standard query A 18017.aaaa.com
1801.505271 192.168.0.1 -> 192.168.0.2 DNS 85 Standard query A 18018.aaaa.com
1801.705396 192.168.0.1 -> 192.168.0.2 DNS 85 Standard query A 18020.aaaa.com
1801.781352 192.168.0.1 -> 192.168.0.2 DNS 85 Standard query A 18017.aaaa.com
1801.881550 192.168.0.1 -> 192.168.0.2 DNS 85 Standard query A 18018.aaaa.com
1802.005210 192.168.0.1 -> 192.168.0.2 DNS 85 Standard query A 18023.aaaa.com
1802.081428 192.168.0.1 -> 192.168.0.2 DNS 85 Standard query A 18020.aaaa.com
1802.105418 192.168.0.1 -> 192.168.0.2 DNS 85 Standard query A 18024.aaaa.com
1802.381504 192.168.0.1 -> 192.168.0.2 DNS 85 Standard query A 18023.aaaa.com
1802.481444 192.168.0.1 -> 192.168.0.2 DNS 85 Standard query A 18024.aaaa.com


the cap data on ns2.example.com  ( unbound 192.168.0.1 , ns2.example.com : 192.168.0.3 )
1799.914518 192.168.0.3 -> 192.168.0.1 DNS 169 Standard query response A 20.0.0.1
1800.014158 192.168.0.1 -> 192.168.0.3 DNS 85 Standard query A 18000.aaaa.com
1800.014471 192.168.0.3 -> 192.168.0.1 DNS 169 Standard query response A 20.0.0.1
1800.114129 192.168.0.1 -> 192.168.0.3 DNS 85 Standard query A 18001.aaaa.com
1800.114387 192.168.0.3 -> 192.168.0.1 DNS 169 Standard query response A 20.0.0.1
1800.214057 192.168.0.1 -> 192.168.0.3 DNS 85 Standard query A 18002.aaaa.com
1800.214286 192.168.0.3 -> 192.168.0.1 DNS 169 Standard query response A 20.0.0.1
1800.314254 192.168.0.1 -> 192.168.0.3 DNS 85 Standard query A 18003.aaaa.com
1800.314519 192.168.0.3 -> 192.168.0.1 DNS 169 Standard query response A 20.0.0.1
1800.414196 192.168.0.1 -> 192.168.0.3 DNS 85 Standard query A 18004.aaaa.com
1800.414471 192.168.0.3 -> 192.168.0.1 DNS 169 Standard query response A 20.0.0.1


- BIND 9.9.1
BIND 9.9.1ns1.aaaa.comns2.aaaa.com
BIND send queries to ns2.aaaa.com and does not send queries to ns1.aaaa.com for about 26 seconds.unreachableworks well


the cap data on ns1.aaaa.com ( BIND 192.168.0.1 , ns1.aaaa.com 192.168.0.2 )

Seen from the cap data , BIND doesn’t send queries to a auth server that is unreachable for about 26 seconds.
 0.000000 192.168.0.1 -> 192.168.0.2 DNS 81 Standard query A 0.aaaa.com
26.796635 192.168.0.1 -> 192.168.0.2 DNS 83 Standard query A 268.aaaa.com
53.496791 192.168.0.1 -> 192.168.0.2 DNS 83 Standard query A 535.aaaa.com
80.096511 192.168.0.1 -> 192.168.0.2 DNS 83 Standard query A 801.aaaa.com
106.596791 192.168.0.1 -> 192.168.0.2 DNS 84 Standard query A 1066.aaaa.com
132.896935 192.168.0.1 -> 192.168.0.2 DNS 84 Standard query A 1329.aaaa.com


the cap data on ns2.aaaa.com ( BIND 192.168.0.1 , ns2.aaaa.com 192.168.0.3 )
136.896846 192.168.0.1 -> 192.168.0.3 DNS 84 Standard query A 1369.aaaa.com
136.897086 192.168.0.3 -> 192.168.0.1 DNS 168 Standard query response A 20.0.0.1
136.996791 192.168.0.1 -> 192.168.0.3 DNS 84 Standard query A 1370.aaaa.com
136.997040 192.168.0.3 -> 192.168.0.1 DNS 168 Standard query response A 20.0.0.1
137.096980 192.168.0.1 -> 192.168.0.3 DNS 84 Standard query A 1371.aaaa.com
137.097250 192.168.0.3 -> 192.168.0.1 DNS 168 Standard query response A 20.0.0.1
137.196934 192.168.0.1 -> 192.168.0.3 DNS 84 Standard query A 1372.aaaa.com
137.197201 192.168.0.3 -> 192.168.0.1 DNS 168 Standard query response A 20.0.0.1



[ when ns1.aaaa retruns Servfail and ns2.aaaa.com works well ]

- unbound 1.4.7
unbound 1.4.7ns1.aaaa.comns2.aaaa.com
unbound sends queries to both auth servers ( ns1 , ns2 ) servfailworks well


the cap data on ns1.example.com ( unbound 192.168.0.1 , ns1.aaaa.com 192.168.0.2 )
 9.399682 192.168.0.1 -> 192.168.0.2 DNS 82 Standard query A 95.aaaa.com
 9.399781 192.168.0.2 -> 192.168.0.1 DNS 82 Standard query response, Server failure
 9.498891 192.168.0.1 -> 192.168.0.2 DNS 82 Standard query A 96.aaaa.com
 9.499177 192.168.0.2 -> 192.168.0.1 DNS 82 Standard query response, Server failure


the cap data on ns2.example.com ( unbound 192.168.0.1 , ns2.aaaa.com 192.168.0.3 )
 9.497516 192.168.0.1 -> 192.168.0.3 DNS 82 Standard query A 95.aaaa.com
 9.497938 192.168.0.3 -> 192.168.0.1 DNS 166 Standard query response A 1.1.1.1
 9.596960 192.168.0.1 -> 192.168.0.3 DNS 82 Standard query A 96.aaaa.com
 9.597224 192.168.0.3 -> 192.168.0.1 DNS 166 Standard query response A 1.1.1.1


- BIND 9.9.1
BIND 9.9.1ns1.aaaa.comns2.aaaa.com
BIND sends queries to both auth servers ( ns1 , ns2 )servfailworks well


the cap data on ns1.aaaa.com ( BIND 192.168.0.1 , ns1.aaaa.com 192.168.0.2 )
 0.000000 192.168.0.1 -> 192.168.0.2 DNS 81 Standard query A 0.aaaa.com
 0.000386 192.168.0.2 -> 192.168.0.1 DNS 81 Standard query response, Server failure
 0.294828 192.168.0.1 -> 192.168.0.2 DNS 81 Standard query A 3.aaaa.com
 0.295109 192.168.0.2 -> 192.168.0.1 DNS 81 Standard query response, Server failure


the cap data on ns2.aaaa.com  ( BIND 192.168.0.1 , ns1.aaaa.com 192.168.0.3 )
 0.000000 192.168.0.1 -> 192.168.0.3 DNS 81 Standard query A 0.aaaa.com
 0.000339 192.168.0.3 -> 192.168.0.1 DNS 165 Standard query response A 1.1.1.1
 0.093219 192.168.0.1 -> 192.168.0.3 DNS 81 Standard query A 1.aaaa.com
 0.093521 192.168.0.3 -> 192.168.0.1 DNS 165 Standard query response A 1.1.1.1

ldb command : load balancer detector

ldb command detects whether or not a given domain name is using DNS and / or HTTP load balance.

install lbd via yum

[root@fc16 ~]# yum install lbd -y


Here’s a result of “lbd” command.
site nameDNS based load balancingHTTP based load balancing
www.google.comyesno
www.f5.comnoyes
www.facebook.comnoyes
www.cisco.comnoyes
www.amazon.comnoyes

- google



[root@fc16 ~]# lbd www.google.com

lbd - load balancing detector 0.2 - Checks if a given domain uses load-balancing.
                                   Written by Stefan Behte (http://ge.mine.nu)
                                   Proof-of-concept! Might give false positives.

Checking for DNS-Loadbalancing: FOUND
www.l.google.com has address 74.125.235.145
www.l.google.com has address 74.125.235.147
www.l.google.com has address 74.125.235.144
www.l.google.com has address 74.125.235.146
www.l.google.com has address 74.125.235.148

Checking for HTTP-Loadbalancing [Server]:
gws
NOT FOUND

Checking for HTTP-Loadbalancing [Date]: 16:24:41, 16:24:41, 16:24:41, 16:24:41, 16:24:41, 16:24:41, 16:24:41, 16:24:41, 16:24:42, 16:24:42, 16:24:42, 16:24:42, 16:24:42, 16:24:42, 16:24:42, 16:24:42, 16:24:43, 16:24:43, 16:24:43, 16:24:43, 16:24:43, 16:24:43, 16:24:43, 16:24:43, 16:24:43, 16:24:44, 16:24:44, 16:24:44, 16:24:44, 16:24:44, 16:24:44, 16:24:44, 16:24:44, 16:24:44, 16:24:44, 16:24:44, 16:24:45, 16:24:45, 16:24:45, 16:24:45, 16:24:45, 16:24:45, 16:24:45, 16:24:45, 16:24:45, 16:24:45, 16:24:45, 16:24:45, 16:24:46, 16:24:46, NOT FOUND

Checking for HTTP-Loadbalancing [Diff]: NOT FOUND

www.google.com does Load-balancing. Found via Methods: DNS

[root@fc16 ~]#


How can “lbd” detect ??
If a DNS query for a given name returns multiple IP addresses , that site would use DNS based load balancing.
How can “lbd” detect whether a given domain name is using HTTP load balance or not ??

- F5 networks



[root@fc16 ~]# lbd www.f5.com

lbd - load balancing detector 0.2 - Checks if a given domain uses load-balancing.
                                   Written by Stefan Behte (http://ge.mine.nu)
                                   Proof-of-concept! Might give false positives.

Checking for DNS-Loadbalancing: NOT FOUND
Checking for HTTP-Loadbalancing [Server]:
F5
NOT FOUND

Checking for HTTP-Loadbalancing [Date]: 16:35:19, 16:35:19, 16:35:19, 16:35:20, 16:35:20, 16:35:20, 16:35:21, 16:35:21, 16:35:21, 16:35:22, 16:35:22, 16:35:23, 16:35:23, 16:35:23, 16:35:24, 16:35:24, 16:35:24, 16:35:25, 16:35:25, 16:35:26, 16:35:26, 16:35:26, 16:35:27, 16:35:27, 16:35:27, 16:35:28, 16:35:28, 16:35:29, 16:35:29, 16:35:29, 16:35:30, 16:35:30, 16:35:30, 16:35:31, 16:35:31, 16:35:32, 16:35:32, 16:35:32, 16:35:33, 16:35:33, 16:35:33, 16:35:34, 16:35:34, 16:35:34, 16:35:35, 16:35:35, 16:35:35, 16:35:36, 16:35:36, 16:35:37, NOT FOUND

Checking for HTTP-Loadbalancing [Diff]: FOUND
< ETag: "141eb9-5c2f-68c1d600"
> ETag: "12662e-5c2f-68293f80"

www.f5.com does Load-balancing. Found via Methods: HTTP[Diff]

[root@fc16 ~]#

[hattori@fc16 ~]$ dig www.f5.com +short
65.61.115.222

sending many HTTP head requests.
[hattori@fc16 ~]$ tshark -r aa.pcap -R '(ip.addr==65.61.115.222)' | grep -i head
31   3.411521 192.168.11.100 -> 65.61.115.222 HTTP 85 HEAD / HTTP/1.0
41   3.714625 192.168.11.100 -> 65.61.115.222 HTTP 85 HEAD / HTTP/1.0
55   4.023489 192.168.11.100 -> 65.61.115.222 HTTP 85 HEAD / HTTP/1.0
65   4.338639 192.168.11.100 -> 65.61.115.222 HTTP 85 HEAD / HTTP/1.0
75   4.648413 192.168.11.100 -> 65.61.115.222 HTTP 85 HEAD / HTTP/1.0
85   4.955623 192.168.11.100 -> 65.61.115.222 HTTP 85 HEAD / HTTP/1.0
101   5.265392 192.168.11.100 -> 65.61.115.222 HTTP 85 HEAD / HTTP/1.0
113   5.574418 192.168.11.100 -> 65.61.115.222 HTTP 85 HEAD / HTTP/1.0
123   5.888941 192.168.11.100 -> 65.61.115.222 HTTP 85 HEAD / HTTP/1.0
135   6.201406 192.168.11.100 -> 65.61.115.222 HTTP 85 HEAD / HTTP/1.0
<snip>

It seems that lbd determine whether or not there are differences from HTTP responses.

- facebook
[root@fc16 ~]# lbd www.facebook.com

lbd - load balancing detector 0.2 - Checks if a given domain uses load-balancing.
                                   Written by Stefan Behte (http://ge.mine.nu)
                                   Proof-of-concept! Might give false positives.

Checking for DNS-Loadbalancing: NOT FOUND
Checking for HTTP-Loadbalancing [Server]:

NOT FOUND

Checking for HTTP-Loadbalancing [Date]: 16:48:15, 16:48:15, 16:48:16, 16:48:16, 16:48:16, 16:48:18, 16:48:18, 16:48:18, 16:48:19, 16:48:19, 16:48:19, 16:48:20, 16:48:20, 16:48:20, 16:48:21, 16:48:21, 16:48:21, 16:48:21, 16:48:22, 16:48:22, 16:48:22, 16:48:23, 16:48:23, 16:48:23, 16:48:24, 16:48:24, 16:48:24, 16:48:25, 16:48:25, 16:48:25, 16:48:26, 16:48:26, 16:48:26, 16:48:27, 16:48:27, 16:48:27, 16:48:28, 16:48:28, 16:48:28, 16:48:28, 16:48:29, 16:48:29, 16:48:29, 16:48:30, 16:48:30, 16:48:30, 16:48:31, 16:48:31, 16:48:31, 16:48:32, NOT FOUND

Checking for HTTP-Loadbalancing [Diff]: FOUND
< X-FB-Debug: TQFOHei+tR3CroNNzDBmAAtbq+8GyG2pjVeN5d1nBRY=
> X-FB-Debug: IMeU/14zk0Yei85KMmue76iDrKGoj9CmQOJVzsQm/Tw=

www.facebook.com does Load-balancing. Found via Methods: HTTP[Diff]



- Cisco
[root@fc16 ~]# lbd www.cisco.com

lbd - load balancing detector 0.2 - Checks if a given domain uses load-balancing.
                                   Written by Stefan Behte (http://ge.mine.nu)
                                   Proof-of-concept! Might give false positives.

Checking for DNS-Loadbalancing: NOT FOUND
Checking for HTTP-Loadbalancing [Server]:
AkamaiGHost
NOT FOUND

Checking for HTTP-Loadbalancing [Date]: 16:52:17, 16:52:17, 16:52:17, 16:52:17, 16:52:17, 16:52:17, 16:52:17, 16:52:17, 16:52:17, 16:52:17, 16:52:17, 16:52:17, 16:52:17, 16:52:17, 16:52:17, 16:52:17, 16:52:17, 16:52:17, 16:52:17, 16:52:17, 16:52:17, 16:52:18, 16:52:18, 16:52:18, 16:52:18, 16:52:18, 16:52:18, 16:52:18, 16:52:18, 16:52:18, 16:52:18, 16:52:18, 16:52:18, 16:52:18, 16:52:18, 16:52:18, 16:52:18, 16:52:18, 16:52:18, 16:52:18, 16:52:18, 16:52:18, 16:52:18, 16:52:19, 16:52:19, 16:52:19, 16:52:19, 16:52:19, 16:52:19, 16:52:19, NOT FOUND

Checking for HTTP-Loadbalancing [Diff]: FOUND
< Content-Length: 194
> Content-Length: 193

www.cisco.com does Load-balancing. Found via Methods: HTTP[Diff]




- amazon
[root@fc16 ~]# lbd www.amazon.com

lbd - load balancing detector 0.2 - Checks if a given domain uses load-balancing.
                                   Written by Stefan Behte (http://ge.mine.nu)
                                   Proof-of-concept! Might give false positives.

Checking for DNS-Loadbalancing: NOT FOUND
Checking for HTTP-Loadbalancing [Server]:
Server
NOT FOUND

Checking for HTTP-Loadbalancing [Date]: 16:59:57, 16:59:58, 16:59:58, 16:59:59, 17:00:00, 17:00:00, 17:00:01, 17:00:01, 17:00:02, 17:00:03, 17:00:03, 17:00:04, 17:00:04, 17:00:05, 17:00:05, 17:00:06, 17:00:07, 17:00:07, 17:00:08, 17:00:08, 17:00:09, 17:00:10, 17:00:10, 17:00:11, 17:00:11, 17:00:12, 17:00:13, 17:00:13, 17:00:14, 17:00:14, 17:00:15, 17:00:16, 17:00:16, 17:00:16, 17:00:17, 17:00:18, 17:00:18, 17:00:19, 17:00:19, 17:00:20, 17:00:21, 17:00:21, 17:00:22, 17:00:22, 17:00:23, 17:00:23, 17:00:24, 17:00:25, 17:00:25, 17:00:26, NOT FOUND

Checking for HTTP-Loadbalancing [Diff]: FOUND
< x-amz-id-1: 14CJ9V9C9P7ADP0W2VMA
> x-amz-id-1: 1NWV9Q6DB5HB7RVJ5R7C
< x-amz-id-2: 85++P+gkHujo8I+VsUoY0HJ7hLRDeYfJSVj6S0mkzcKcAzL/nj5+vI4RY63geJ45
> x-amz-id-2: UEio6eGIH72xHxxJnHdHT98hRsWuu9AvTPSBoa5zepi0TGoGvW3srWT2+YlnwHAa

www.amazon.com does Load-balancing. Found via Methods: HTTP[Diff]

Fedora 16 : KVM : guestfs browser : browse filesystem in a VM which is not running.

guestfs-browser enables you to browse filesystem in a VM which is not running.
Fedora release 16 (Verne)
[root@fc16 ~]# uname -ri
3.3.7-1.fc16.x86_64 x86_64

install guestfish browser via yum
[root@fc16 ~]# yum install -y guestfs-browser

start guestfs-browser
[root@fc16 ~]# guestfs-browser

connect to a livbirt URI


select a VM in which you’d like to browse filesystem.

The following is an output of Fedora16’s VM’s filesystem.

You can view/ edit / download files

select a file -> view / download



when browsing filesystem in that VM , the following process was running.
[root@fc16 ~]# ps aux | grep -i f16 | grep -v grep
root      5714  1.0  1.9 2848476 151512 pts/0  Sl+  00:47   0:05 /usr/bin/qemu-kvm -global virtio-blk-pci.scsi=off -nodefconfig -nodefaults -nographic -drive file=/var/USB_HDD/Fedora/libvirt/images/jeos-f16-sda.qcow2,snapshot=on,format=qcow2,if=virtio -nodefconfig -machine accel=kvm:tcg -m 500 -no-reboot -no-hpet -device virtio-serial -serial stdio -chardev socket,path=/tmp/libguestfsZZJx0M/guestfsd.sock,id=channel0 -device virtserialport,chardev=channel0,name=org.libguestfs.channel.0 -kernel /var/tmp/.guestfs-0/kernel.5043 -initrd /var/tmp/.guestfs-0/initrd.5043 -append panic=1 console=ttyS0 udevtimeout=300 no_timer_check acpi=off printk.time=1 cgroup_disable=memory selinux=0  TERM=xterm  -drive file=/var/tmp/.guestfs-0/root.5043,snapshot=on,if=virtio,cache=unsafe

nice tool.

KVM : create private virtual switches


# kvm --version
QEMU emulator version 1.0 (qemu-kvm-1.0), Copyright (c) 2003-2008 Fabrice Bellard

# tail -1 /etc/lsb-release
DISTRIB_DESCRIPTION="Ubuntu 12.04 LTS"


make an xml file
# cat private0.xml
<network>
 <name>private0</name>
 <bridge name="privatebr0" />
</network>

define the private0
# virsh
Welcome to virsh, the virtualization interactive terminal.

Type:  'help' for help with commands
      'quit' to quit

virsh # net-define /etc/libvirt/qemu/networks/private0.xml
Network private0 defined from /etc/libvirt/qemu/networks/private0.xml

to use private0 , you need to start it.
virsh # net-list --all
Name                 State      Autostart
-----------------------------------------
default              active     yes
private0             inactive   no

start private0
virsh # net-start private0
Network private0 started

virsh # net-list --all
Name                 State      Autostart
-----------------------------------------
default              active     yes
private0             active     no


[ start private0 automatically when booting a KVM host ]

virsh # net-autostart private0
Network private0 marked as autostarted

virsh #
virsh # net-list --all
Name                 State      Autostart
-----------------------------------------
default              active     yes
private0             active     yes


symbolic files will be created under /etc/libvirt/qemu/networks/autostart directory.
# ls -l /etc/libvirt/qemu/networks/autostart/
total 0
lrwxrwxrwx default.xml -> /etc/libvirt/qemu/networks/default.xml
lrwxrwxrwx private0.xml -> /etc/libvirt/qemu/networks/private0.xml

KVM : how to connect to Fedora VMs which are using grub2 as a boot loader via virsh console or minicom

Here's an explanation of how to connect to VMs which are using grub2 via virsh console or minicom.
KVM host : Fedora 16
VM : Fedora 16 ( boot loader is grub2 not grub )

[ add a serial port to the VM ]

assume that the Fedora VM has a serial port.
you can check whether or not your VM has a serial port as below:

- on the KVM host

# virsh ttyconsole f16-vm1
/dev/pts/2

or


# virsh dumpxml f16-vm1 | grep serial
   <controller type='virtio-serial' index='0'>
     <alias name='virtio-serial0'/>
   <serial type='pty'>
     <alias name='serial0'/>
   </serial>
     <target type='serial' port='0'/>
     <alias name='serial0'/>
     <address type='virtio-serial' controller='0' bus='0' port='1'/>

[ configure a serial port on the VM ( not the KVM host ) ]

- on the VM

add the red lines
[root@localhost ~]# cat /etc/default/grub
GRUB_CMDLINE_LINUX="quiet rhgb biosdevname=0"
GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,9600n8"
GRUB_TERMINAL=serial
GRUB_SERIAL_COMMAND="serial --speed=9600 --unit=0 --word=8 --parity=no --stop=1"

add the following line in /etc/inittab
[root@localhost ~]# tail -1 /etc/inittab
S0:12345:respawn:/sbin/agetty ttyS0 115200

add the following line in /etc/securetty file.
[root@localhost ~]# echo "ttyS0" >> /etc/securetty

update grub.cfg
[root@localhost ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.3.5-2.fc16.x86_64
Found initrd image: /boot/initramfs-3.3.5-2.fc16.x86_64.img
done


[root@localhost ~]# egrep -v ^# /boot/grub2/grub.cfg

if [ -s $prefix/grubenv ]; then
 load_env
fi
set default="0"
if [ "${prev_saved_entry}" ]; then
 set saved_entry="${prev_saved_entry}"
 save_env saved_entry
 set prev_saved_entry=
 save_env prev_saved_entry
 set boot_once=true
fi

function savedefault {
 if [ -z "${boot_once}" ]; then
   saved_entry="${chosen}"
   save_env saved_entry
 fi
}

function load_video {
 insmod vbe
 insmod vga
 insmod video_bochs
 insmod video_cirrus
}

serial --speed=9600 --unit=0 --word=8 --parity=no --stop=1
terminal_input serial
terminal_output serial
set timeout=5

menuentry 'Linux, with Linux 3.3.5-2.fc16.x86_64' --class gnu-linux --class gnu --class os {
load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod ext2
set root='(/dev/vda,gpt2)'
search --no-floppy --fs-uuid --set=root ecdb7a66-7b00-49b9-b507-82e346d4c549
echo 'Loading Linux 3.3.5-2.fc16.x86_64 ...'
linux /boot/vmlinuz-3.3.5-2.fc16.x86_64 root=UUID=ecdb7a66-7b00-49b9-b507-82e346d4c549 ro quiet rhgb biosdevname=0 console=tty0 console=ttyS0,9600n8
echo 'Loading initial ramdisk ...'
initrd /boot/initramfs-3.3.5-2.fc16.x86_64.img
}


reboot the VM

[ connect to the VM from KVM host with virsh console ]

on the KVM host
[root@fc16 ~]# virsh list --all
Id Name                 State
----------------------------------
 1 f16-vm1              running

[root@fc16 ~]# virsh console f16-vm1
Connected to domain f16-vm1
Escape character is ^]

Password:

Login incorrect

login: root
Password:
Last login: Wed May 16 12:02:07 from 192.168.122.1

Appliance: jeos-f16 appliance 1.0
Hostname: localhost
IP Address: 192.168.122.124

[root@localhost ~]#

[ connect to the VM from the KVM host with minicom ]

You can also connect to the VM with minicom.

on the KVM hsot

install minicom
[root@fc16 ~]# yum install -y minicom

check a serial port number of the VM to which you want to connect.
[root@fc16 ~]# virsh ttyconsole f16-vm1
/dev/pts/2

connect to the VM with minicom
[root@fc16 ~]# minicom -op /dev/pts/2


Welcome to minicom 2.5

OPTIONS: I18n
Compiled on Apr  6 2011, 07:59:07.
Port /dev/modem

Press CTRL-A Z for help on special keys


Fedora release 16 (Verne)
Kernel 3.3.5-2.fc16.x86_64 on an x86_64 (ttyS0)

login: root
Password:
Last login: Wed May 16 12:34:59 on ttyS0

Appliance:      jeos-f16 appliance 1.0
Hostname:       localhost                                                       
IP Address:     192.168.122.124                                                 
                                                                               
[root@localhost ~]#


when exiting the VM , press Ctrl A and then press x