Sunday, October 31, 2010

How to block certain inbound IP addresses

Create a file /etc/iptables/blockip.sh:

#!/bin/bash
# Simple iptables IP/subnet block script
# -------------------------------------------------------------------------
IPT=`which iptables`
SPAMLIST="spamlist"
SPAMDROPMSG="SPAM LIST DROP"
BADIPS=$(egrep -v -e "^#|^$" /etc/iptables/blocked.ips)

# create a new iptables list
$IPT -N $SPAMLIST

for ipblock in $BADIPS
do
   $IPT -A $SPAMLIST -s $ipblock -j LOG --log-prefix "$SPAMDROPMSG"
   $IPT -A $SPAMLIST -s $ipblock -j DROP
done

$IPT -I INPUT -j $SPAMLIST
$IPT -I OUTPUT -j $SPAMLIST
$IPT -I FORWARD -j $SPAMLIST

Create a file /etc/iptables/blocked.ips:

put IP addresses here! (one per line)


edit file /etc/boot.local and add this line:

/etc/iptables/blockip.sh

Saturday, October 30, 2010

Error in compiling QEMU-XEN

The following errors occurs when I did "make tool". For some reason, the file "cpu.h" in subdir
+ test -d git://xenbits.xensource.com/qemu-xen-4.0-testing.git
+ '[' '!' -d ioemu-remote ']'
+ rm -f ioemu-dir
+ ln -sf ioemu-remote ioemu-dir
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c: In function `kvm_arch_init_vcpu':
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:47:5: warning: implicit declaration of function `cpu_x86_cpuid'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c: In function `kvm_has_msr_star':
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:159:49: error: `MSR_STAR' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:159:49: note: each undeclared identifier is reported only once for each function it appears in
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c: In function `set_seg':
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:219:27: error: `DESC_TYPE_SHIFT' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:220:29: error: `DESC_P_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:222:25: error: `DESC_B_SHIFT' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:223:23: error: `DESC_S_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:224:24: error: `DESC_L_SHIFT' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:225:23: error: `DESC_G_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:226:25: error: `DESC_AVL_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c: In function `get_seg':
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:236:16: error: `DESC_TYPE_SHIFT' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:237:20: error: `DESC_P_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:238:17: error: `DESC_DPL_SHIFT' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:239:16: error: `DESC_B_SHIFT' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:240:14: error: `DESC_S_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:241:15: error: `DESC_L_SHIFT' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:242:14: error: `DESC_G_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:243:16: error: `DESC_AVL_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c: In function `kvm_getput_regs':
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:265:35: error: `CPUX86State' has no member named `regs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:265:42: error: `R_EAX' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:266:35: error: `CPUX86State' has no member named `regs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:266:42: error: `R_EBX' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:267:35: error: `CPUX86State' has no member named `regs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:267:42: error: `R_ECX' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:268:35: error: `CPUX86State' has no member named `regs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:268:42: error: `R_EDX' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:269:35: error: `CPUX86State' has no member named `regs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:269:42: error: `R_ESI' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:270:35: error: `CPUX86State' has no member named `regs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:270:42: error: `R_EDI' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:271:35: error: `CPUX86State' has no member named `regs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:271:42: error: `R_ESP' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:272:35: error: `CPUX86State' has no member named `regs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:272:42: error: `R_EBP' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:284:38: error: `CPUX86State' has no member named `eflags'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:285:35: error: `CPUX86State' has no member named `eip'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c: In function `kvm_put_fpu':
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:299:18: error: `CPUX86State' has no member named `fpus'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:300:20: error: `CPUX86State' has no member named `fpstt'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:301:18: error: `CPUX86State' has no member named `fpuc'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:303:19: error: `CPUX86State' has no member named `fptags'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:304:24: error: `CPUX86State' has no member named `fpregs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:304:44: error: `CPUX86State' has no member named `fpregs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:305:24: error: `CPUX86State' has no member named `xmm_regs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:305:46: error: `CPUX86State' has no member named `xmm_regs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:306:20: error: `CPUX86State' has no member named `mxcsr'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c: In function `kvm_put_sregs':
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:316:15: error: `CPUX86State' has no member named `interrupt_bitmap'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:319:13: error: `CPUX86State' has no member named `eflags'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:319:24: error: `VM_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:320:35: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:320:42: error: `R_CS' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:321:35: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:321:42: error: `R_DS' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:322:35: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:322:42: error: `R_ES' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:323:35: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:323:42: error: `R_FS' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:324:35: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:324:42: error: `R_GS' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:325:35: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:325:42: error: `R_SS' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:327:29: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:328:29: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:329:29: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:330:29: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:331:29: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:332:29: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:334:13: error: `CPUX86State' has no member named `cr'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:334:23: error: `CR0_PE_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:342:28: error: `CPUX86State' has no member named `tr'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:343:29: error: `CPUX86State' has no member named `ldt'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:345:26: error: `CPUX86State' has no member named `idt'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:346:25: error: `CPUX86State' has no member named `idt'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:347:26: error: `CPUX86State' has no member named `gdt'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:348:25: error: `CPUX86State' has no member named `gdt'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:350:20: error: `CPUX86State' has no member named `cr'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:351:20: error: `CPUX86State' has no member named `cr'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:352:20: error: `CPUX86State' has no member named `cr'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:353:20: error: `CPUX86State' has no member named `cr'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:355:5: warning: implicit declaration of function `cpu_get_apic_tpr'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:356:5: warning: implicit declaration of function `cpu_get_apic_base'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:358:21: error: `CPUX86State' has no member named `efer'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c: In function `kvm_put_msrs':
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:379:35: error: `MSR_IA32_SYSENTER_CS' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:379:60: error: `CPUX86State' has no member named `sysenter_cs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:380:35: error: `MSR_IA32_SYSENTER_ESP' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:380:61: error: `CPUX86State' has no member named `sysenter_esp'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:381:35: error: `MSR_IA32_SYSENTER_EIP' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:381:61: error: `CPUX86State' has no member named `sysenter_eip'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:383:32: error: `MSR_STAR' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:383:45: error: `CPUX86State' has no member named `star'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:384:35: error: `MSR_IA32_TSC' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:384:52: error: `CPUX86State' has no member named `tsc'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c: In function `kvm_get_fpu':
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:408:8: error: `CPUX86State' has no member named `fpstt'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:409:8: error: `CPUX86State' has no member named `fpus'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:410:8: error: `CPUX86State' has no member named `fpuc'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:412:5: error: `CPUX86State' has no member named `fptags'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:413:15: error: `CPUX86State' has no member named `fpregs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:413:44: error: `CPUX86State' has no member named `fpregs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:414:15: error: `CPUX86State' has no member named `xmm_regs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:414:46: error: `CPUX86State' has no member named `xmm_regs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:415:8: error: `CPUX86State' has no member named `mxcsr'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c: In function `kvm_get_sregs': 
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:430:15: error: `CPUX86State' has no member named `interrupt_bitmap'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:434:17: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:434:24: error: `R_CS' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:435:17: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:435:24: error: `R_DS' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:436:17: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:436:24: error: `R_ES' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:437:17: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:437:24: error: `R_FS' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:438:17: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:438:24: error: `R_GS' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:439:17: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:439:24: error: `R_SS' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:441:17: error: `CPUX86State' has no member named `tr'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:442:17: error: `CPUX86State' has no member named `ldt'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:444:8: error: `CPUX86State' has no member named `idt'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:445:8: error: `CPUX86State' has no member named `idt'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:446:8: error: `CPUX86State' has no member named `gdt'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:447:8: error: `CPUX86State' has no member named `gdt'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:449:8: error: `CPUX86State' has no member named `cr'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:450:8: error: `CPUX86State' has no member named `cr'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:451:8: error: `CPUX86State' has no member named `cr'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:452:8: error: `CPUX86State' has no member named `cr'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:454:5: warning: implicit declaration of function `cpu_set_apic_base'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:456:8: error: `CPUX86State' has no member named `efer'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:467:18: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:467:40: error: `DESC_DPL_SHIFT' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:467:58: error: `HF_CPL_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:468:19: error: `CPUX86State' has no member named `cr'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:468:29: error: `CR0_PE_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:468:46: error: `HF_PE_SHIFT' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:468:60: error: `CR0_PE_SHIFT' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:469:19: error: `CPUX86State' has no member named `cr'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:469:31: error: `HF_MP_SHIFT' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:469:45: error: `CR0_MP_SHIFT' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:470:7: error: `HF_MP_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:470:20: error: `HF_EM_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:470:33: error: `HF_TS_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:471:19: error: `CPUX86State' has no member named `eflags'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:471:31: error: `HF_TF_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:471:44: error: `HF_VM_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:471:57: error: `HF_IOPL_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:472:19: error: `CPUX86State' has no member named `cr'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:472:29: error: `CR4_OSFXSR_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:473:7: error: `HF_OSFXSR_SHIFT' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:473:25: error: `CR4_OSFXSR_SHIFT'  undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:475:12: error: `CPUX86State' has no member named `efer'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:475:21: error: `MSR_EFER_LMA' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:476:19: error: `HF_LMA_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:479:39: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:479:60: error: `DESC_L_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:480:19: error: `HF_CS32_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:480:34: error: `HF_SS32_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:480:49: error: `HF_CS64_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:482:23: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:482:44: error: `DESC_B_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:483:4: error: `DESC_B_SHIFT' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:483:19: error: `HF_CS32_SHIFT' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:484:23: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:485:19: error: `HF_SS32_SHIFT' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:486:18: error: `CPUX86State' has no member named `cr'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:487:24: error: `CPUX86State' has no member named `eflags'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:487:35: error: `VM_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:489:27: error: `HF_ADDSEG_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:491:32: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:492:36: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:493:36: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:494:21: error: `HF_ADDSEG_SHIFT' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:497:8: error: `CPUX86State' has no member named `hflags'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:497:23: error: `CPUX86State' has no member named `hflags'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:497:34: error: `HF_PE_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:497:34: error: `HF_OSFXSR_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c: In function `kvm_get_msrs':
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:512:23: error: `MSR_IA32_SYSENTER_CS' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:513:23: error: `MSR_IA32_SYSENTER_ESP' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:514:23: error: `MSR_IA32_SYSENTER_EIP' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:516:20: error: `MSR_STAR' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:517:23: error: `MSR_IA32_TSC' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:533:16: error: `CPUX86State' has no member named `sysenter_cs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:536:16: error: `CPUX86State' has no member named `sysenter_esp'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:539:16: error: `CPUX86State' has no member named `sysenter_eip'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:542:16: error: `CPUX86State' has no member named `star'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:559:16: error: `CPUX86State' has no member named `tsc'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c: In function `kvm_arch_pre_run':
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:618:13: error: `CPUX86State' has no member named `eflags'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:618:24: error: `IF_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c: In function `kvm_arch_post_run':
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:650:12: error: `CPUX86State' has no member named `eflags'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:650:24: error: `IF_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:652:12: error: `CPUX86State' has no member named `eflags'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:654:5: warning: implicit declaration of function `cpu_set_apic_tpr'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c: In function `kvm_handle_halt':
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:663:15: error: `CPUX86State' has no member named `eflags'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:663:26: error: `IF_MASK' undeclared (first use in this function)
make[3]: *** [kvm.o] Error 1
make[2]: *** [subdir-i386-dm] Error 2
make[1]: *** [subdir-all-ioemu-dir] Error 2
make: *** [subdirs-all] Error 2
'

Quick fix: goto dir "target-i386" and perform:

myname@linux-bvhg:~/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386> gcc -I. -I.. -I/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386 -I/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir -MMD -MT kvm.o -MP -DNEED_CPU_H -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -I/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/tcg -I/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/tcg/x86_64 -I/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/fpu  -DHAS_AUDIO -DHAS_AUDIO_CHOICE -DHAS_AUDIO -I/home/myname/src/xen-4.0-testing.hg//tools/libxc -I/home/myname/src/xen-4.0-testing.hg//tools/xenstore -I/home/myname/src/xen-4.0-testing.hg//tools/include -I/home/myname/src/xen-4.0-testing.hg//tools/blktap/lib -mtune=core2 -msse3 -O2 -m64 -mfpmath=sse -ffast-math -O2 -fomit-frame-pointer -m64 
 -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wno-unused-value -Wdeclaration-after-statement  -D__XEN_TOOLS__ -MMD -MF .subdirs-all.d  -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE  -O2 -fomit-frame-pointer -m64 -fno-strict-aliasing -std=gnu99 -Wall  -Wstrict-prototypes -Wno-unused-value -Wdeclaration-after-statement  -D__XEN_TOOLS__ -MMD -MF .ioemu-dir-find.d  -D_LARGEFILE_SOURCE -D_LARGEFILE64 _SOURCE  -O2 -g -fno-strict-aliasing -Wall -Wundef -W endif-labels -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -O2 -fomit-frame-pointer -m64 -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wno-unused-value -Wdeclaration-after-statement  -D__XEN_TOOLS__ -MMD -MF .kvm.o.d  -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE  -Wno-unused -Wno-declaration-after-statement -Wno-pointer-sign  -DCONFIG_PASSTHROUGH  -I../hw  -m64 -Wno-unused -Wno-declaration-after-statement -Wno-pointer-sign  -DCONFIG_PASSTHROUGH   -c -o kvm.o /home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c

Xen Installation & Compilation


Installation from source

Xen 4.0 source code mercurial (hg) repository and changelog: http://xenbits.xen.org/xen-4.0-testing.hg
You can get Xen 4.0 with mercurial using the following command:
hg clone http://xenbits.xen.org/xen-4.0-testing.hg
Note that this will give you the LATEST version in xen-4.0-testing.hg repository! It might be a release candidate for next release or just some developer snapshot. See the changelog above for current status. You can also get a specific 'tag' from the repository like this:
hg clone -r RELEASE-4.0.1 http://xenbits.xen.org/xen-4.0-testing.hg
Alternatively you can download the Xen 4.0.x source tarball from http://www.xen.org/products/xen_source.html . Note that if you're planning to use Xen 4.0.0 tarball please see the Known Issues below for a note about supported pvops dom0 kernel versions.
NOTE!! during the Xen build process outbound git-protocol needs to be open in your network firewall! Xen build scripts need to access git:// repositories on git.kernel.org and xenbits.xen.org. Some people have reported issues accessing the remote repositories - these problems are most often caused by a broken Internet connection, broken firewall, or a broken NAT router you use.
This example will only build the new Xen 4.0 hypervisor and tools. This method does NOT download or build a (dom0) kernel from the xen.git repository. "make tools" part will download the xen qemu-dm ioemu for hvm guests from xenbits git repository and tools tarballs (unless you've already downloaded them yourself before building).
cd xen-4.0-testing.hg 
make xen 
make tools 
make stubdom
When the compilation process finishes you'll have the Xen hypervisor/tools binaries in "dist/" directory ready for installation:
make install-xen 
make install-tools 
make install-stubdom
And then compile your chosen new dom0 kernel, or use your existing dom0 kernel. Also update grub.conf to use the newly installed Xen 4.0 hypervisor.
See XenDom0Kernels wiki page for information about all the available Xen Dom0 capable kernels, and XenParavirtOps wiki page for more detailed information about Xen pvops dom0 kernels.
You can also compile Xen 4.0 together with the new default pvops dom0 kernel (Linux 2.6.32.x in Xen 4.0.1 and newer versions). This method downloads the kernel sources from xen.git repository during the build process:
make world
This will download the latest pvops dom0 kernel 2.6.32.x from Jeremy's xen.git repository during the build process. See the XenParavirtOps wiki page for more information about different pvops dom0 kernel versions. Also see the Known Issues below for supported pvops dom0 kernel versions.
NOTE about the old Xenlinux linux-2.6.18-xen kernels:
make kernels KERNELS="linux-2.6-xen0 linux-2.6-xenU"

Xen compilation

When I was trying to compile Xen-4.0.1, I got these messages:

make[1]: Entering directory `/xen-4.0-testing.hg/xen'
make -f Rules.mk _install
make[2]: Entering directory `/xen-4.0-testing.hg/xen'
make -C tools
make[3]: Entering directory `/xen-4.0-testing.hg/xen/tools'
[ -d figlet ] && make -C figlet
make[4]: Entering directory `/xen-4.0-testing.hg/xen/tools/figlet'
make[4]: `figlet' is up to date.
make[4]: Leaving directory `/xen-4.0-testing.hg/xen/tools/figlet'
make symbols
make[4]: Entering directory `/xen-4.0-testing.hg/xen/tools'
make[4]: `symbols' is up to date.
make[4]: Leaving directory `/xen-4.0-testing.hg/xen/tools'
make[3]: Leaving directory `/xen-4.0-testing.hg/xen/tools'
make -f /xen-4.0-testing.hg/xen/Rules.mk include/xen/compile.h
make[3]: Entering directory `/xen-4.0-testing.hg/xen'
 __  __            _  _    ___   ____              _                   
 \ \/ /___ _ __   | || |  / _ \ |___ \    _ __ ___/ |   _ __  _ __ ___ 
  \  // _ \ '_ \  | || |_| | | |  __) |__| '__/ __| |__| '_ \| '__/ _ \
  /  \  __/ | | | |__   _| |_| | / __/|__| | | (__| |__| |_) | | |  __/
 /_/\_\___|_| |_|    |_|(_)___(_)_____|  |_|  \___|_|  | .__/|_|  \___|
                                                       |_|             
make[3]: Leaving directory `/xen-4.0-testing.hg/xen'
[ -e include/asm ] || ln -sf asm-x86 include/asm
make -f /xen-4.0-testing.hg/xen/Rules.mk -C include
make[3]: Entering directory `/xen-4.0-testing.hg/xen/include'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/xen-4.0-testing.hg/xen/include'
make -f /xen-4.0-testing.hg/xen/Rules.mk -C arch/x86 asm-offsets.s
make[3]: Entering directory `/xen-4.0-testing.hg/xen/arch/x86'
make[3]: `asm-offsets.s' is up to date.
make[3]: Leaving directory `/xen-4.0-testing.hg/xen/arch/x86'
make -f /xen-4.0-testing.hg/xen/Rules.mk include/asm-x86/asm-offsets.h
make[3]: Entering directory `/xen-4.0-testing.hg/xen'
make[3]: `include/asm-x86/asm-offsets.h' is up to date.
make[3]: Leaving directory `/xen-4.0-testing.hg/xen'
make -f /xen-4.0-testing.hg/xen/Rules.mk -C arch/x86 /xen-4.0-testing.hg/xen/xen
make[3]: Entering directory `/xen-4.0-testing.hg/xen/arch/x86'
make -f /xen-4.0-testing.hg/xen/Rules.mk -C /xen-4.0-testing.hg/xen/arch/x86/boot built_in.o
make[4]: Entering directory `/xen-4.0-testing.hg/xen/arch/x86/boot'
RELOC=0x7c000 XEN_BITSPERLONG=64 make -f build32.mk reloc.S
make[5]: Entering directory `/xen-4.0-testing.hg/xen/arch/x86/boot'
make[5]: *** ../../../../.config: Is a directory.  Stop.
make[5]: Leaving directory `/xen-4.0-testing.hg/xen/arch/x86/boot'
make[4]: *** [reloc.S] Error 2
make[4]: Leaving directory `/xen-4.0-testing.hg/xen/arch/x86/boot'
make[3]: *** [/xen-4.0-testing.hg/xen/arch/x86/boot/built_in.o] Error 2
make[3]: Leaving directory `/xen-4.0-testing.hg/xen/arch/x86'
make[2]: *** [/xen-4.0-testing.hg/xen/xen] Error 2
make[2]: Leaving directory `/xen-4.0-testing.hg/xen'
make[1]: *** [install] Error 2
make[1]: Leaving directory `/xen-4.0-testing.hg/xen'
make: *** [install-xen] Error 2

The message showed me that it was expecting the .config exist in the root folder. I copied the file from /usr/src/linux (kernel source) and recompile. it worked!

USB plug-in rule for TI MSP-EXP43xx LaunchPad Kit

Content of file /etc/udev/rules.d/udev/46-TI_launchpad.rules:

ATTRS{idVendor}=="0451", ATTRS{idProduct}=="2036", MODE="0660", GROUP="plugdev"
ATTRS{idVendor}=="0451", ATTRS{idProduct}=="F432", MODE="0660", GROUP="plugdev"

Friday, October 29, 2010

Script to remove tailing "(00)" in filenames

#!/usr/bin/tclsh

foreach f [glob *.*] {
    if {[regexp -all -nocase {(.*)\.(.*)} $f dummy fullname ext] } {
        if { [regexp -all -nocase {(.*)\(00\)} $fullname dummy name ] } {
             set cmd "file rename -force \"$f\" \"$name.$ext\""
             puts $cmd
             eval $cmd
        }
    }
}