2014年4月28日 星期一

Linux kernel編譯問題

kernel make 時出現這鬼錯:


/home/qemutest/linux-2.6.32.61/usr/include/asm/ptrace.h:5: included file 'linux/linkage.h' is not exported
make[2]: *** [/home/qemutest/linux-2.6.32.61/usr/include/asm/.check] Error 123
make[1]: *** [headers_check] Error 2

make: *** [vmlinux] Error 2

解決辦法:

vim arch/x86/include/asm/ptrace.h
註釋掉
#include

146行的
extern asmregparm long syscall_trace_enter(struct pt_regs *);
extern asmregparm void syscall_trace_leave(struct pt_regs *);
再新增下面兩行
extern long syscall_trace_enter(struct pt_regs *);
extern void syscall_trace_leave(struct pt_regs *);  


改好後再來make


2014年4月23日 星期三

改qemu記錄

/home/qemutest/qemu-1.7.1/include/hw/pci
#define PCI_DEVICE_ID_VIRTIO_MYDEVICE    0x1006 //cocotion modify


virtio-pci.c 有改  ==> 現在再改

./hw/virtio/virtio-pci.h 有改



/home/qemutest/qemu-1.7.1/hw/virtio/virtio-pci.c

改了這些:

mydevice_pci_stats_get_all
mydevice_pci_stats_get_poll_interval
mydevice_pci_stats_set_poll_interval
 Property virtio_mydevice_pci_properties[]
virtio_mydevice_pci_init
virtio_mydevice_pci_class_init
virtio_mydevice_pci_instance_init
TypeInfo virtio_mydevice_pci_info 

新增
/home/qemutest/qemu-1.7.1/hw/virtio/virtio-mydevice.c
此檔為balloon的copy, 之後開始來trace他
===========================================

改./include/hw/virtio/virtio-mydevice.h


typedef struct VirtIOmydevice {
    VirtIODevice parent_obj;
    VirtQueue *ivq, *dvq, *svq;
    uint32_t num_pages;
    uint32_t actual;
    uint64_t stats[VIRTIO_MYDEVICE_S_NR];
    VirtQueueElement stats_vq_elem;
    size_t stats_vq_offset;
    QEMUTimer *stats_timer;
    int64_t stats_last_update;
    int64_t stats_poll_interval;

} VirtIOmydevice;


原本的VirtIODevice 放在./include/hw/virtio/virtio.h


struct VirtIODevice
{
    DeviceState parent_obj;
    const char *name;
    uint8_t status;
    uint8_t isr;
    uint16_t queue_sel;
    uint32_t guest_features;
    size_t config_len;
    void *config;
    uint16_t config_vector;
    int nvectors;
    VirtQueue *vq;
    uint16_t device_id;
    bool vm_running;
    VMChangeStateEntry *vmstate;
    char *bus_name;

};

以及operation:

typedef struct VirtioDeviceClass {
    /* This is what a VirtioDevice must implement */
    DeviceClass parent;
    int (*init)(VirtIODevice *vdev);
    void (*exit)(VirtIODevice *vdev);
    uint32_t (*get_features)(VirtIODevice *vdev, uint32_t requested_features);
    uint32_t (*bad_features)(VirtIODevice *vdev);
    void (*set_features)(VirtIODevice *vdev, uint32_t val);
    void (*get_config)(VirtIODevice *vdev, uint8_t *config);
    void (*set_config)(VirtIODevice *vdev, const uint8_t *config);
    void (*reset)(VirtIODevice *vdev);
    void (*set_status)(VirtIODevice *vdev, uint8_t val);
    /* Test and clear event pending status.
     * Should be called after unmask to avoid losing events.
     * If backend does not support masking,
     * must check in frontend instead.
     */
    bool (*guest_notifier_pending)(VirtIODevice *vdev, int n); 
    /* Mask/unmask events from this vq. Any events reported
     * while masked will become pending.
     * If backend does not support masking,
     * must mask in frontend instead.
     */
    void (*guest_notifier_mask)(VirtIODevice *vdev, int n, bool mask);

} VirtioDeviceClass;


VIRTIOQUEUE 相關:


typedef struct VirtQueueElement
{
    unsigned int index;
    unsigned int out_num;
    unsigned int in_num;
    hwaddr in_addr[VIRTQUEUE_MAX_SIZE];
    hwaddr out_addr[VIRTQUEUE_MAX_SIZE];
    struct iovec in_sg[VIRTQUEUE_MAX_SIZE];
    struct iovec out_sg[VIRTQUEUE_MAX_SIZE];

} VirtQueueElement;





之後在./hw/virtio/virtio-mydevice.c

讓自己產生的device operation指向VirtioDeviceClass 以及相關class, 像是繼承:


static void virtio_mydevice_class_init(ObjectClass *klass, void *data)
{
    DeviceClass *dc = DEVICE_CLASS(klass);
    VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
    dc->props = virtio_mydevice_properties;
    set_bit(DEVICE_CATEGORY_MISC, dc->categories);
    vdc->init = virtio_mydevice_device_init;
    vdc->exit = virtio_mydevice_device_exit;
    vdc->get_config = virtio_mydevice_get_config;
    vdc->set_config = virtio_mydevice_set_config;
    vdc->get_features = virtio_mydevice_get_features;
}



另外在./include/hw/virtio/virtio-mydevice.h改了virtio_mydevice_config:


struct virtio_mydevice_config
{
    int config; //cocotion test
    /* Number of pages host wants Guest to give up. */
    uint32_t num_pages;
    /* Number of pages we've actually got in balloon. */
    uint32_t actual;

};











2014年4月20日 星期日

QEMU TAP 網路



TAP 網路

qemu-ifup:

#!/bin/sh  
/sbin/ifconfig $1 192.168.1.1 netmask 255.255.255.0 up  
sleep 2 

qemu-ifdown:

#!/bin/sh  
/sbin/ifconfig $1 down 
sleep 2

以上這兩個權限記得改


# qemu-system-x86_64 --enable-kvm image_file -m 2048 -smp 2  -net nic,model=virtio,macaddr=52:54:00:12:34:57 -net tap,ifname=tap0,script=/home/qemutest/qemu-1.7.1/qemu-ifup,downscript=/home/qemutest/qemu-1.7.1/qemu-ifdown

#vncviewer :5900

quest裏面:
# ifconfig eth1 192.168.1.10


之後發現host(192.168.1.1)可以連quest(102.168.1.10),但反之卻有問題,尚未解決

2014年4月14日 星期一

安裝QEMU

download: http://wiki.qemu.org/Download

Environment: CentOS 6

before install:

# yum install glib2-devel
# yum install autoconf
# yum install automake
# yum install bison
# yum install libtool
# yum install zlib-devel


install:

# ./configure

RDMA support      no
TCG interpreter   no
fdt support       yes
preadv support    yes
fdatasync         yes
madvise           yes
posix_madvise     yes
sigev_thread_id   yes
uuid support      no
libcap-ng support no
vhost-net support yes
vhost-scsi support yes
Trace backend     nop
Trace output file trace-
spice support     no
rbd support       no
xfsctl support    no
nss used          no
libusb            no
usb net redir     no
GLX support       no
libiscsi support  no
libnfs support    no
build guest agent yes
QGA VSS support   no
seccomp support   no
coroutine backend ucontext
coroutine pool    yes
GlusterFS support no
virtio-blk-data-plane no
gcov              gcov
gcov enabled      no
TPM support       no
libssh2 support   no
TPM passthrough   no
QOM debugging     yes
vhdx              no
Quorum            no

# make -j 8
# make install