Sunday, November 14, 2010

PAM Security explained

PAM Security: http://articles.techrepublic.com.com/5100-10878_11-1055269.html

Login restriction/Limitation based on time schedue

This is how to limit a user (in this case, his name is "Joko") to access computer during weekdays and weekends at certain time duration.

  1. Edit file
    /etc/pam.d/common-account
    and add a line "account required pam_time.so"
  2. Edit file
    /etc/security/time.conf
    and add the following lines to the end of file.

#services  ttys users   times
#
# allow Joko to use computer during weekdays 3 pm-8:30pm OR weekends 9:00am - 9:00pm
* ; * ; joko; Wk1500-2030 | Wk0900-2100

This will not allow joko to login during weekdays before 3 pm or after 8:30 pm or weekends outside 9 am - 9 pm. To disallow certain service, replace '*' in the first entry with a PAM service name (e.g, login, etc.). Files in /etc/pam.d reflect the service names.

On my computer, the following files are the service names can be used:

-rw-r--r-- 1 root root 217 2010-07-05 04:57 atd
-rw-r--r-- 1 root root 167 2010-07-05 06:44 chage
-rw-r--r-- 1 root root 218 2010-07-05 06:44 chfn
-rw-r--r-- 1 root root 218 2010-07-05 06:44 chsh
lrwxrwxrwx 1 root root  17 2010-09-13 10:39 common-account -> common-account-pc
-rw-r--r-- 1 root root 378 2010-07-05 05:15 common-account.pam-config-backup
-rw-r--r-- 1 root root 446 2010-11-14 09:01 common-account-pc
lrwxrwxrwx 1 root root  14 2010-09-13 10:39 common-auth -> common-auth-pc
-rw-r--r-- 1 root root 448 2010-07-05 05:15 common-auth.pam-config-backup
-rw-r--r-- 1 root root 557 2010-11-14 09:01 common-auth-pc
lrwxrwxrwx 1 root root  18 2010-09-13 10:39 common-password -> common-password-pc
-rw-r--r-- 1 root root 855 2010-07-05 05:15 common-password.pam-config-backup
-rw-r--r-- 1 root root 506 2010-11-14 09:01 common-password-pc
lrwxrwxrwx 1 root root  17 2010-09-13 10:39 common-session -> common-session-pc
-rw-r--r-- 1 root root 435 2010-07-05 05:15 common-session.pam-config-backup
-rw-r--r-- 1 root root 573 2010-11-14 09:01 common-session-pc
-rw-r--r-- 1 root root 287 2010-07-05 04:56 crond
-rw-r--r-- 1 root root  56 2010-09-15 13:49 cups
-rw-r--r-- 1 root root 204 2010-07-05 16:24 gdm
-rw-r--r-- 1 root root 206 2010-07-05 16:24 gdm-autologin
-rw-r--r-- 1 root root 239 2010-07-05 08:06 gnomesu-pam
-rw-r--r-- 1 root root 216 2010-07-28 09:45 init
-rw-r--r-- 1 root root 419 2010-07-05 22:36 login
-rw-r--r-- 1 root root 251 2010-07-05 05:15 other
-rw-r--r-- 1 root root 133 2010-07-05 06:44 passwd
-rw-r--r-- 1 root root 165 2010-07-05 06:18 polkit
-rw-r--r-- 1 root root 165 2010-07-05 07:10 polkit-1
-rw-r--r-- 1 root root 173 2010-07-05 14:34 ppp
-rw-r--r-- 1 root root 481 2010-07-05 05:32 remote
-rw-r--r-- 1 root root 165 2010-09-15 14:14 samba
-rw-r--r-- 1 root root 209 2010-07-05 06:44 shadow
-rw-r--r-- 1 root root 165 2010-09-14 07:07 smtp
-rw-r--r-- 1 root root 268 2010-07-05 14:41 sshd
-rw-r--r-- 1 root root 239 2010-07-05 05:00 su
-rw-r--r-- 1 root root 203 2010-09-07 06:01 sudo
-rw-r--r-- 1 root root 239 2010-07-05 05:00 su-l
-rw-r--r-- 1 root root 172 2010-07-05 06:44 useradd
-rw-r--r-- 1 root root 569 2010-07-05 05:58 vsftpd
-rw-r--r-- 1 root root 241 2010-07-29 04:36 wxconsole
-rw-r--r-- 1 root root 204 2008-09-03 08:45 xdm
-rw-r--r-- 1 root root 166 2008-09-03 08:45 xdm-np
-rw-r--r-- 1 root root 265 2010-08-23 16:44 xen-api

A good solution to limit use of computer from kids during school days!

Monday, November 8, 2010

My First Objective-C

List.h:

#import <objc/Object.h>

@interface List : Object                          // List is a subclass of the superclass Object
{
    int list[100];                                // These are instance variables.
    int size;
}


/* Public methods */
- free;
- (int) addEntry: (int) num;
- print;

/* Private methods */
/* Other programs should not use these methods. */

- resetSize;

@end


List.m:

#import "List.h"

@implementation List

+ new                                           // factory method
{
    self = [super new];
    [self resetSize];
    return self;
}


- free
{
    return [super free];
}


- (int) addEntry: (int) num
{
    list[size++] = num;
    return size;
}


- print
{
    int i;

    printf("\n");
    for (i = 0; i < size; ++i)
        printf ("%i ", list[i]);
        puts("");
    return self;                                // Always return self
                                                                                                // if n
othing else makes sense.
}


- resetSize
{
    size = 0;
    return self;
}
Stack.h:
#import <objc/Object.h>

typedef struct StackLink {
        struct StackLink        *next;
        //void                  *data;
        int                     data;
} StackLink;


@interface Stack : Object
{
        StackLink *top;
    unsigned int size;
}

- free;
- push: (int) anInt;
- addEntry: (int) anInt;
- (int) pop;
- (unsigned int) size;

@end
Stack.m:
#import "Stack.h"
#import <stdlib.h>

@implementation Stack

#define NULL_LINK (StackLink *) 0

+ new
{
    self = [super new];
    top = NULL_LINK; //(StackLink *) 0;
    return self;
}


- free
{
    StackLink *next;

    while (top != NULL_LINK)
    {
        next = top->next;
        free ((char *) top);
        top = next;
    }
    return [super free];
}


- push: (int) value
{
    StackLink *newLink;

    newLink = (StackLink *) malloc (sizeof (StackLink));
    if (newLink == 0)
    {
        fprintf(stderr, "Out of memory\n");
        return nil;
    }
    newLink->data = value;
    newLink->next = top;
    top = newLink;
    size++;

    return self;
}


- addEntry: (int) value
{
        return [self push: value];
}

- (int) pop
{
    int value;
    StackLink *topLink;

    if (0 != size)
    {
        topLink = top;
        top = top->next;
        value = topLink->data;
        free (topLink);
        size--;
    }
    else
    {
        value = 0;
    }
    return value;
}


- (unsigned int) size
{
    return size;
}

- print
{
        StackLink *startLink;
        int i = size;

        startLink = top;

        while (startLink) {
                printf("Stack[%d] = %d\n", i, startLink->data);
                startLink = startLink->next;
                i--;
        }
        return self;
}

@end
main.m:
#import <objc/Object.h>
#import "List.h"
#import "Stack.h"

//int main(int argc, char *argv[])

void perform (id obj)
{
        [obj addEntry: 5];
        [obj print];
        [obj addEntry: 6];
        [obj addEntry: 3];
        [obj print];
}

main()
{
        id list;

        list = [List new];
        perform(list);
        [list free];

        id stack;
        stack = [Stack new];
        perform(stack);
        [stack free];
        printf("\n");
        return 0;
}

Makefile:
.SUFFIXES: .o .m

.m.o:
        $(CC) -c $(CFLAGS) $< -o $@

# Macros

CC=gcc

#CFLAGS=-Wall -Wno-import -mtune=core2 -mfpmath=sse -ffast-math -msse3 -fobjc-exceptions
CFLAGS=-Wno-import -mtune=core2 -g

LDFLAGS=-lobjc
SRCS=main.m List.m Stack.m
OBJS=$(SRCS:.m=.o)
EXECUTABLE=main

.PHONY: all

all: $(EXECUTABLE)

$(EXECUTABLE): $(OBJS)
        $(CC) $(LDFLAGS) -o $@ $(OBJS)

#$(OBJS): $(SRCS)
#       echo "$(CC) -c $(CFLAGS) $< -o $@"

clean:
        rm -f *.o $(EXECUTABLE)

TAGS: $(SRCS)
        ctags -R $(SRCS)

Tuesday, November 2, 2010

MiniDuckSimulator.java


import java.io.Console;

/**
 * @author mlutfi
 *
 */
public class MiniDuckSimulator {

 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  Duck mallard = new MallardDuck();
  mallard.display();
  mallard.performQuack();
  mallard.performFly();
  
  Duck model = new ModelDuck();
  model.display();
  model.performFly();
  model.setFlyBehavior(new FlyRocketPowered());
  model.performFly();
 }
}

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