]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm tools: Trivial cleanup
authorSasha Levin <levinsasha928@gmail.com>
Fri, 16 Dec 2011 08:40:06 +0000 (10:40 +0200)
committerPekka Enberg <penberg@kernel.org>
Sat, 17 Dec 2011 07:29:43 +0000 (09:29 +0200)
Acked-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
16 files changed:
tools/kvm/disk/qcow.c
tools/kvm/ioport.c
tools/kvm/pci.c
tools/kvm/symbol.c
tools/kvm/term.c
tools/kvm/util/util.c
tools/kvm/virtio/balloon.c
tools/kvm/virtio/core.c
tools/kvm/virtio/net.c
tools/kvm/virtio/pci.c
tools/kvm/virtio/rng.c
tools/kvm/x86/bios.c
tools/kvm/x86/cpuid.c
tools/kvm/x86/interrupt.c
tools/kvm/x86/kvm-cpu.c
tools/kvm/x86/kvm.c

index b2dae663a8e88b09602218cc28eb40b5b34dcbed..712f81100cd61d0e4862bae00f54fd7758270b39 100644 (file)
@@ -335,18 +335,16 @@ static ssize_t qcow1_read_cluster(struct qcow *q, u64 offset,
                csize &= (q->cluster_size - 1);
 
                if (pread_in_full(q->fd, q->cluster_data, csize,
-                                 coffset) < 0) {
+                                 coffset) < 0)
                        goto out_error;
-               }
 
                if (qcow_decompress_buffer(q->cluster_cache, q->cluster_size,
-                                       q->cluster_data, csize) < 0) {
+                                       q->cluster_data, csize) < 0)
                        goto out_error;
-               }
 
                memcpy(dst, q->cluster_cache + clust_offset, length);
                mutex_unlock(&q->mutex);
-       } else{
+       } else {
                if (!clust_start)
                        goto zero_cluster;
 
@@ -441,7 +439,7 @@ static ssize_t qcow2_read_cluster(struct qcow *q, u64 offset,
 
                memcpy(dst, q->cluster_cache + clust_offset, length);
                mutex_unlock(&q->mutex);
-       } else{
+       } else {
                clust_start &= QCOW2_OFFSET_MASK;
                if (!clust_start)
                        goto zero_cluster;
@@ -476,11 +474,11 @@ static ssize_t qcow_read_sector_single(struct disk_image *disk, u64 sector,
        char *buf;
        u32 nr;
 
-       buf             = dst;
-       nr_read         = 0;
+       buf = dst;
+       nr_read = 0;
 
        while (nr_read < dst_len) {
-               offset          = sector << SECTOR_SHIFT;
+               offset = sector << SECTOR_SHIFT;
                if (offset >= header->size)
                        return -1;
 
@@ -494,9 +492,9 @@ static ssize_t qcow_read_sector_single(struct disk_image *disk, u64 sector,
                if (nr <= 0)
                        return -1;
 
-               nr_read         += nr;
-               buf             += nr;
-               sector          += (nr >> SECTOR_SHIFT);
+               nr_read += nr;
+               buf     += nr;
+               sector  += (nr >> SECTOR_SHIFT);
        }
 
        return dst_len;
@@ -514,9 +512,9 @@ static ssize_t qcow_read_sector(struct disk_image *disk, u64 sector,
                        return -1;
                }
 
-               sector  += iov->iov_len >> SECTOR_SHIFT;
+               sector += iov->iov_len >> SECTOR_SHIFT;
+               total += nr;
                iov++;
-               total   += nr;
        }
 
        return total;
index 965cfc2eb08696c5512cf61f538d2e23812b626c..b4179424013c5663458b020f7d29908936bef6e1 100644 (file)
@@ -111,13 +111,10 @@ bool kvm__emulate_io(struct kvm *kvm, u16 port, void *data, int direction, int s
        ops     = entry->ops;
 
        while (count--) {
-               if (direction == KVM_EXIT_IO_IN) {
-                       if (ops->io_in)
+               if (direction == KVM_EXIT_IO_IN && ops->io_in)
                                ret = ops->io_in(entry, kvm, port, ptr, size);
-               } else {
-                       if (ops->io_out)
+               else if (ops->io_out)
                                ret = ops->io_out(entry, kvm, port, ptr, size);
-               }
 
                ptr += size;
        }
index 59b2618dc07e14fcf3c91089e025af0e355845cb..06eea0f674bdb7654f530efcd9294133ddd09216 100644 (file)
@@ -160,10 +160,12 @@ void pci__config_rd(struct kvm *kvm, union pci_config_address addr, void *data,
                        void *p = pci_devices[dev_num];
 
                        memcpy(data, p + offset, size);
-               } else
+               } else {
                        memset(data, 0x00, size);
-       } else
+               }
+       } else {
                memset(data, 0xff, size);
+       }
 }
 
 void pci__register(struct pci_device_header *dev, u8 dev_num)
index 56dd346c4af813d329a624bc16a1e67e186abf49..a2b1e67032ce087a7cea7d2649f6183f1c47d51d 100644 (file)
@@ -7,7 +7,7 @@
 #include <stdio.h>
 #include <bfd.h>
 
-static bfd             *abfd;
+static bfd *abfd;
 
 void symbol__init(const char *vmlinux)
 {
@@ -16,7 +16,7 @@ void symbol__init(const char *vmlinux)
 
        bfd_init();
 
-       abfd            = bfd_openr(vmlinux, NULL);
+       abfd = bfd_openr(vmlinux, NULL);
 }
 
 static asymbol *lookup(asymbol **symbols, int nr_symbols, const char *symbol_name)
@@ -53,17 +53,17 @@ char *symbol__lookup(struct kvm *kvm, unsigned long addr, char *sym, size_t size
        if (!bfd_check_format(abfd, bfd_object))
                goto not_found;
 
-       symtab_size     = bfd_get_symtab_upper_bound(abfd);
+       symtab_size = bfd_get_symtab_upper_bound(abfd);
        if (!symtab_size)
                goto not_found;
 
-       syms            = malloc(symtab_size);
+       syms = malloc(symtab_size);
        if (!syms)
                goto not_found;
 
-       nr_syms         = bfd_canonicalize_symtab(abfd, syms);
+       nr_syms = bfd_canonicalize_symtab(abfd, syms);
 
-       section         = bfd_get_section_by_name(abfd, ".debug_aranges");
+       section = bfd_get_section_by_name(abfd, ".debug_aranges");
        if (!section)
                goto not_found;
 
@@ -73,13 +73,13 @@ char *symbol__lookup(struct kvm *kvm, unsigned long addr, char *sym, size_t size
        if (!func)
                goto not_found;
 
-       symbol          = lookup(syms, nr_syms, func);
+       symbol = lookup(syms, nr_syms, func);
        if (!symbol)
                goto not_found;
 
-       sym_start       = bfd_asymbol_value(symbol);
+       sym_start = bfd_asymbol_value(symbol);
 
-       sym_offset      = addr - sym_start;
+       sym_offset = addr - sym_start;
 
        snprintf(sym, size, "%s+%llx (%s:%i)", func, (long long) sym_offset, filename, line);
 
index b7d8934294210955fb8b23409b4a12ff142d38b2..cc0c5a588c899deb7d9fa03c2c62381ffcec1e91 100644 (file)
@@ -14,7 +14,6 @@
 #include "kvm/kvm.h"
 #include "kvm/kvm-cpu.h"
 
-
 #define TERM_FD_IN      0
 #define TERM_FD_OUT     1
 
index 00f73155a55d9a4a0623068624c06a2c5c3a1f41..4e14fd9c9c6bb0423f4c880272133f02e4a524bc 100644 (file)
@@ -91,9 +91,8 @@ void *mmap_hugetlbfs(const char *htlbfs_path, u64 size)
        if (statfs(htlbfs_path, &sfs) < 0)
                die("Can't stat %s\n", htlbfs_path);
 
-       if ((unsigned int)sfs.f_type != HUGETLBFS_MAGIC) {
+       if ((unsigned int)sfs.f_type != HUGETLBFS_MAGIC)
                die("%s is not hugetlbfs!\n", htlbfs_path);
-       }
 
        blk_size = (unsigned long)sfs.f_bsize;
        if (sfs.f_bsize == 0 || blk_size > size) {
index 07fd97654dda2889c35db9dd98e664dc82db5b93..556f0ec5d302daafa1f4d11336b32a5af99a2fed 100644 (file)
@@ -59,9 +59,9 @@ static bool virtio_bln_do_io_request(struct kvm *kvm, struct bln_dev *bdev, stru
        u16 out, in, head;
        u32 *ptrs, i;
 
-       head            = virt_queue__get_iov(queue, iov, &out, &in, kvm);
-       ptrs            = iov[0].iov_base;
-       len             = iov[0].iov_len / sizeof(u32);
+       head    = virt_queue__get_iov(queue, iov, &out, &in, kvm);
+       ptrs    = iov[0].iov_base;
+       len     = iov[0].iov_len / sizeof(u32);
 
        for (i = 0 ; i < len ; i++) {
                void *guest_ptr;
index 5dc767a3ed39af88aca0a09d26024662fe821aed..c68572cf02d7143e178b7d50a14c6e10bc361f5f 100644 (file)
@@ -67,7 +67,6 @@ u16 virt_queue__get_head_iov(struct virt_queue *vq, struct iovec iov[], u16 *out
        desc = vq->vring.desc;
 
        if (desc[idx].flags & VRING_DESC_F_INDIRECT) {
-
                max = desc[idx].len / sizeof(struct vring_desc);
                desc = guest_flat_to_host(kvm, desc[idx].addr);
                idx = 0;
index 9b93c5d271e5f74a3fbec14d7fbc36c0711924c7..bb97a7edbd4f7fa1c8b86efcdc6102884e57b8b1 100644 (file)
@@ -87,18 +87,14 @@ static void *virtio_net_rx_thread(void *p)
        vq      = &ndev->vqs[VIRTIO_NET_RX_QUEUE];
 
        while (1) {
-
                mutex_lock(&ndev->io_rx_lock);
                if (!virt_queue__available(vq))
                        pthread_cond_wait(&ndev->io_rx_cond, &ndev->io_rx_lock);
                mutex_unlock(&ndev->io_rx_lock);
 
                while (virt_queue__available(vq)) {
-
                        head = virt_queue__get_iov(vq, iov, &out, &in, kvm);
-
                        len = ndev->ops->rx(iov, in, ndev);
-
                        virt_queue__set_used_elem(vq, head, len);
 
                        /* We should interrupt guest right now, otherwise latency is huge. */
@@ -106,7 +102,6 @@ static void *virtio_net_rx_thread(void *p)
                                ndev->vtrans.trans_ops->signal_vq(kvm, &ndev->vtrans,
                                                                VIRTIO_NET_RX_QUEUE);
                }
-
        }
 
        pthread_exit(NULL);
@@ -134,11 +129,8 @@ static void *virtio_net_tx_thread(void *p)
                mutex_unlock(&ndev->io_tx_lock);
 
                while (virt_queue__available(vq)) {
-
                        head = virt_queue__get_iov(vq, iov, &out, &in, kvm);
-
                        len = ndev->ops->tx(iov, out, ndev);
-
                        virt_queue__set_used_elem(vq, head, len);
                }
 
@@ -346,9 +338,9 @@ static int init_vq(struct kvm *kvm, void *dev, u32 vq, u32 pfn)
 
        compat__remove_message(compat_id);
 
-       queue                   = &ndev->vqs[vq];
-       queue->pfn              = pfn;
-       p                       = guest_pfn_to_host(kvm, queue->pfn);
+       queue           = &ndev->vqs[vq];
+       queue->pfn      = pfn;
+       p               = guest_pfn_to_host(kvm, queue->pfn);
 
        vring_init(&queue->vring, VIRTIO_NET_QUEUE_SIZE, p, VIRTIO_PCI_VRING_ALIGN);
 
index 2ffa5de36ad270c6320c5b1ddcd3dd5c6bead612..305131453fea663504ad1c55dc7792e07457a828 100644 (file)
@@ -150,7 +150,7 @@ static bool virtio_pci__specific_io_out(struct kvm *kvm, struct virtio_trans *vt
 
                        vpci->config_gsi = gsi;
                        break;
-               case VIRTIO_MSI_QUEUE_VECTOR: {
+               case VIRTIO_MSI_QUEUE_VECTOR:
                        vec = vpci->vq_vector[vpci->queue_selector] = ioport__read16(data);
 
                        gsi = irq__add_msix_route(kvm, &vpci->msix_table[vec].msg);
@@ -159,7 +159,6 @@ static bool virtio_pci__specific_io_out(struct kvm *kvm, struct virtio_trans *vt
                                vtrans->virtio_ops->notify_vq_gsi(kvm, vpci->dev,
                                                        vpci->queue_selector, gsi);
                        break;
-               }
                };
 
                return true;
@@ -195,14 +194,14 @@ static bool virtio_pci__io_out(struct ioport *ioport, struct kvm *kvm, u16 port,
                vtrans->virtio_ops->init_vq(kvm, vpci->dev, vpci->queue_selector, val);
                break;
        case VIRTIO_PCI_QUEUE_SEL:
-               vpci->queue_selector    = ioport__read16(data);
+               vpci->queue_selector = ioport__read16(data);
                break;
        case VIRTIO_PCI_QUEUE_NOTIFY:
-               val                     = ioport__read16(data);
+               val = ioport__read16(data);
                vtrans->virtio_ops->notify_vq(kvm, vpci->dev, val);
                break;
        case VIRTIO_PCI_STATUS:
-               vpci->status            = ioport__read8(data);
+               vpci->status = ioport__read8(data);
                break;
        default:
                ret = virtio_pci__specific_io_out(kvm, vtrans, port, data, size, offset);
index c333e6bd3094962474938d0e0523b328ecb172d1..c9430cb128ba848294409441f68632940e5be282 100644 (file)
@@ -70,8 +70,8 @@ static bool virtio_rng_do_io_request(struct kvm *kvm, struct rng_dev *rdev, stru
        unsigned int len = 0;
        u16 out, in, head;
 
-       head            = virt_queue__get_iov(queue, iov, &out, &in, kvm);
-       len             = readv(rdev->fd, iov, in);
+       head    = virt_queue__get_iov(queue, iov, &out, &in, kvm);
+       len     = readv(rdev->fd, iov, in);
 
        virt_queue__set_used_elem(queue, head, len);
 
@@ -80,9 +80,9 @@ static bool virtio_rng_do_io_request(struct kvm *kvm, struct rng_dev *rdev, stru
 
 static void virtio_rng_do_io(struct kvm *kvm, void *param)
 {
-       struct rng_dev_job *job = param;
-       struct virt_queue *vq = job->vq;
-       struct rng_dev *rdev = job->rdev;
+       struct rng_dev_job *job = param;
+       struct virt_queue *vq   = job->vq;
+       struct rng_dev *rdev    = job->rdev;
 
        while (virt_queue__available(vq))
                virtio_rng_do_io_request(kvm, rdev, vq);
@@ -99,17 +99,17 @@ static int init_vq(struct kvm *kvm, void *dev, u32 vq, u32 pfn)
 
        compat__remove_message(compat_id);
 
-       queue                   = &rdev->vqs[vq];
-       queue->pfn              = pfn;
-       p                       = guest_pfn_to_host(kvm, queue->pfn);
+       queue           = &rdev->vqs[vq];
+       queue->pfn      = pfn;
+       p               = guest_pfn_to_host(kvm, queue->pfn);
 
        job = &rdev->jobs[vq];
 
        vring_init(&queue->vring, VIRTIO_RNG_QUEUE_SIZE, p, VIRTIO_PCI_VRING_ALIGN);
 
-       *job            = (struct rng_dev_job) {
-               .vq             = queue,
-               .rdev           = rdev,
+       *job = (struct rng_dev_job) {
+               .vq     = queue,
+               .rdev   = rdev,
        };
 
        thread_pool__init_job(&job->job_id, kvm, virtio_rng_do_io, job);
@@ -179,10 +179,9 @@ void virtio_rng__init(struct kvm *kvm)
 
 void virtio_rng__delete_all(struct kvm *kvm)
 {
-       while (!list_empty(&rdevs)) {
-               struct rng_dev *rdev;
+       struct rng_dev *rdev, *tmp;
 
-               rdev = list_first_entry(&rdevs, struct rng_dev, list);
+       list_for_each_entry_safe(rdev, tmp, &rdevs, list) {
                list_del(&rdev->list);
                free(rdev);
        }
index 47b1f5445d1d353615ab0fe10c6d9383ac23b26e..ded07176191cb3e85fcaa052379a994c8aad37d3 100644 (file)
@@ -38,7 +38,7 @@ static void setup_irq_handler(struct kvm *kvm, struct irq_handler *handler)
        struct real_intr_desc intr_desc;
        void *p;
 
-       p       = guest_flat_to_host(kvm, handler->address);
+       p = guest_flat_to_host(kvm, handler->address);
        memcpy(p, handler->handler, handler->size);
 
        intr_desc = (struct real_intr_desc) {
@@ -46,7 +46,7 @@ static void setup_irq_handler(struct kvm *kvm, struct irq_handler *handler)
                .offset         = handler->address - MB_BIOS_BEGIN,
        };
 
-       DIE_IF((handler->address - MB_BIOS_BEGIN) > (unsigned long)0xffff);
+       DIE_IF((handler->address - MB_BIOS_BEGIN) > 0xffffUL);
 
        interrupt_table__set(&kvm->interrupt_table, &intr_desc, handler->irq);
 }
@@ -100,7 +100,7 @@ static void e820_setup(struct kvm *kvm)
 
        BUILD_BUG_ON(i > E820_X_MAX);
 
-       e820->nr_map                    = i;
+       e820->nr_map = i;
 }
 
 static void setup_vga_rom(struct kvm *kvm)
index 64d31a3294090bee260fe9b923349f23d81ce110..644f37f309829e0a904fb36ee68974bec1e8383a 100644 (file)
@@ -24,10 +24,10 @@ static void filter_cpuid(struct kvm_cpuid2 *kvm_cpuid)
                switch (entry->function) {
                case 6:
                        /* Clear presence of IA32_ENERGY_PERF_BIAS */
-                       entry->ecx      = entry->ecx & ~(1 << 3);
+                       entry->ecx = entry->ecx & ~(1 << 3);
                        break;
                case CPUID_FUNC_PERFMON:
-                       entry->eax      = 0x00; /* disable it */
+                       entry->eax = 0x00; /* disable it */
                        break;
                default:
                        /* Keep the CPUID function as -is */
@@ -40,7 +40,8 @@ void kvm_cpu__setup_cpuid(struct kvm_cpu *vcpu)
 {
        struct kvm_cpuid2 *kvm_cpuid;
 
-       kvm_cpuid = calloc(1, sizeof(*kvm_cpuid) + MAX_KVM_CPUID_ENTRIES * sizeof(*kvm_cpuid->entries));
+       kvm_cpuid = calloc(1, sizeof(*kvm_cpuid) +
+                               MAX_KVM_CPUID_ENTRIES * sizeof(*kvm_cpuid->entries));
 
        kvm_cpuid->nent = MAX_KVM_CPUID_ENTRIES;
        if (ioctl(vcpu->kvm->sys_fd, KVM_GET_SUPPORTED_CPUID, kvm_cpuid) < 0)
index e4636c485b0af14368f5c6864c987d35f2db394e..7d478690fb54b15a8eb1c7089d8c6969b1392703 100644 (file)
@@ -20,7 +20,8 @@ void interrupt_table__setup(struct interrupt_table *itable, struct real_intr_des
                itable->entries[i] = *entry;
 }
 
-void interrupt_table__set(struct interrupt_table *itable, struct real_intr_desc *entry, unsigned int num)
+void interrupt_table__set(struct interrupt_table *itable,
+                               struct real_intr_desc *entry, unsigned int num)
 {
        if (num < REAL_INTR_VECTORS)
                itable->entries[num] = *entry;
index 30f1ad6379364856defcaa13a504770498a94671..051699f3fe8c40780d876fc44ab9c04af0ef157c 100644 (file)
@@ -53,18 +53,18 @@ static inline u32 selector_to_base(u16 selector)
        /*
         * KVM on Intel requires 'base' to be 'selector * 16' in real mode.
         */
-       return (u32)selector * 16;
+       return (u32)selector << 4;
 }
 
 static struct kvm_cpu *kvm_cpu__new(struct kvm *kvm)
 {
        struct kvm_cpu *vcpu;
 
-       vcpu            = calloc(1, sizeof *vcpu);
+       vcpu = calloc(1, sizeof(*vcpu));
        if (!vcpu)
                return NULL;
 
-       vcpu->kvm       = kvm;
+       vcpu->kvm = kvm;
 
        return vcpu;
 }
@@ -96,11 +96,11 @@ struct kvm_cpu *kvm_cpu__init(struct kvm *kvm, unsigned long cpu_id)
        int mmap_size;
        int coalesced_offset;
 
-       vcpu            = kvm_cpu__new(kvm);
+       vcpu = kvm_cpu__new(kvm);
        if (!vcpu)
                return NULL;
 
-       vcpu->cpu_id    = cpu_id;
+       vcpu->cpu_id = cpu_id;
 
        vcpu->vcpu_fd = ioctl(vcpu->kvm->vm_fd, KVM_CREATE_VCPU, cpu_id);
        if (vcpu->vcpu_fd < 0)
@@ -159,7 +159,7 @@ static void kvm_cpu__setup_msrs(struct kvm_cpu *vcpu)
        vcpu->msrs->entries[ndx++] = KVM_MSR_ENTRY(MSR_IA32_MISC_ENABLE,
                                                MSR_IA32_MISC_ENABLE_FAST_STRING);
 
-       vcpu->msrs->nmsrs       = ndx;
+       vcpu->msrs->nmsrs = ndx;
 
        if (ioctl(vcpu->vcpu_fd, KVM_SET_MSRS, vcpu->msrs) < 0)
                die_perror("KVM_SET_MSRS failed");
@@ -168,8 +168,8 @@ static void kvm_cpu__setup_msrs(struct kvm_cpu *vcpu)
 static void kvm_cpu__setup_fpu(struct kvm_cpu *vcpu)
 {
        vcpu->fpu = (struct kvm_fpu) {
-               .fcw            = 0x37f,
-               .mxcsr          = 0x1f80,
+               .fcw    = 0x37f,
+               .mxcsr  = 0x1f80,
        };
 
        if (ioctl(vcpu->vcpu_fd, KVM_SET_FPU, &vcpu->fpu) < 0)
@@ -180,15 +180,15 @@ static void kvm_cpu__setup_regs(struct kvm_cpu *vcpu)
 {
        vcpu->regs = (struct kvm_regs) {
                /* We start the guest in 16-bit real mode  */
-               .rflags         = 0x0000000000000002ULL,
+               .rflags = 0x0000000000000002ULL,
 
-               .rip            = vcpu->kvm->boot_ip,
-               .rsp            = vcpu->kvm->boot_sp,
-               .rbp            = vcpu->kvm->boot_sp,
+               .rip    = vcpu->kvm->boot_ip,
+               .rsp    = vcpu->kvm->boot_sp,
+               .rbp    = vcpu->kvm->boot_sp,
        };
 
        if (vcpu->regs.rip > USHRT_MAX)
-               die("ip 0x%llx is too high for real mode", (u64) vcpu->regs.rip);
+               die("ip 0x%llx is too high for real mode", (u64)vcpu->regs.rip);
 
        if (ioctl(vcpu->vcpu_fd, KVM_SET_REGS, &vcpu->regs) < 0)
                die_perror("KVM_SET_REGS failed");
@@ -196,7 +196,6 @@ static void kvm_cpu__setup_regs(struct kvm_cpu *vcpu)
 
 static void kvm_cpu__setup_sregs(struct kvm_cpu *vcpu)
 {
-
        if (ioctl(vcpu->vcpu_fd, KVM_GET_SREGS, &vcpu->sregs) < 0)
                die_perror("KVM_GET_SREGS failed");
 
@@ -318,12 +317,12 @@ void kvm_cpu__show_registers(struct kvm_cpu *vcpu)
        dprintf(debug_fd, "\n");
 }
 
-#define MAX_SYM_LEN            128
+#define MAX_SYM_LEN 128
 
 void kvm_cpu__show_code(struct kvm_cpu *vcpu)
 {
        unsigned int code_bytes = 64;
-       unsigned int code_prologue = code_bytes * 43 / 64;
+       unsigned int code_prologue = 43;
        unsigned int code_len = code_bytes;
        char sym[MAX_SYM_LEN];
        unsigned char c;
@@ -377,19 +376,19 @@ void kvm_cpu__show_page_tables(struct kvm_cpu *vcpu)
        if (ioctl(vcpu->vcpu_fd, KVM_GET_SREGS, &vcpu->sregs) < 0)
                die("KVM_GET_SREGS failed");
 
-       pte4    = guest_flat_to_host(vcpu->kvm, vcpu->sregs.cr3);
+       pte4 = guest_flat_to_host(vcpu->kvm, vcpu->sregs.cr3);
        if (!host_ptr_in_ram(vcpu->kvm, pte4))
                return;
 
-       pte3    = guest_flat_to_host(vcpu->kvm, (*pte4 & ~0xfff));
+       pte3 = guest_flat_to_host(vcpu->kvm, (*pte4 & ~0xfff));
        if (!host_ptr_in_ram(vcpu->kvm, pte3))
                return;
 
-       pte2    = guest_flat_to_host(vcpu->kvm, (*pte3 & ~0xfff));
+       pte2 = guest_flat_to_host(vcpu->kvm, (*pte3 & ~0xfff));
        if (!host_ptr_in_ram(vcpu->kvm, pte2))
                return;
 
-       pte1    = guest_flat_to_host(vcpu->kvm, (*pte2 & ~0xfff));
+       pte1 = guest_flat_to_host(vcpu->kvm, (*pte2 & ~0xfff));
        if (!host_ptr_in_ram(vcpu->kvm, pte1))
                return;
 
index bc52ef3998462d3a8ea3a2e04f94fe57ff93ab82..d2fbbe2be18704c99f5f400b2f7b14e752a242a6 100644 (file)
@@ -21,7 +21,6 @@
 #include <unistd.h>
 #include <stdio.h>
 #include <fcntl.h>
-#include <asm/unistd.h>
 
 struct kvm_ext kvm_req_ext[] = {
        { DEFINE_KVM_EXT(KVM_CAP_COALESCED_MMIO) },
@@ -124,24 +123,23 @@ void kvm__arch_set_cmdline(char *cmdline, bool video)
 {
        strcpy(cmdline, "noapic noacpi pci=conf1 reboot=k panic=1 i8042.direct=1 "
                                "i8042.dumbkbd=1 i8042.nopnp=1");
-       if (video) {
+       if (video)
                strcat(cmdline, " video=vesafb console=tty0");
-       else
+       else
                strcat(cmdline, " console=ttyS0 earlyprintk=serial i8042.noaux=1");
 }
 
 /* This function wraps the decision between hugetlbfs map (if requested) or normal mmap */
 static void *mmap_anon_or_hugetlbfs(const char *hugetlbfs_path, u64 size)
 {
-       if (hugetlbfs_path) {
+       if (hugetlbfs_path)
                /*
                 * We don't /need/ to map guest RAM from hugetlbfs, but we do so
                 * if the user specifies a hugetlbfs path.
                 */
                return mmap_hugetlbfs(hugetlbfs_path, size);
-       } else {
+       else
                return mmap(NULL, size, PROT_RW, MAP_ANON_NORESERVE, -1, 0);
-       }
 }
 
 /* Architecture-specific KVM init */
@@ -158,19 +156,18 @@ void kvm__arch_init(struct kvm *kvm, const char *kvm_dev, const char *hugetlbfs_
        if (ret < 0)
                die_perror("KVM_CREATE_PIT2 ioctl");
 
-       kvm->ram_size           = ram_size;
+       kvm->ram_size = ram_size;
 
        if (kvm->ram_size < KVM_32BIT_GAP_START) {
                kvm->ram_start = mmap_anon_or_hugetlbfs(hugetlbfs_path, ram_size);
        } else {
                kvm->ram_start = mmap_anon_or_hugetlbfs(hugetlbfs_path, ram_size + KVM_32BIT_GAP_SIZE);
-               if (kvm->ram_start != MAP_FAILED) {
+               if (kvm->ram_start != MAP_FAILED)
                        /*
                         * We mprotect the gap (see kvm__init_ram() for details) PROT_NONE so that
                         * if we accidently write to it, we will know.
                         */
                        mprotect(kvm->ram_start + KVM_32BIT_GAP_START, KVM_32BIT_GAP_SIZE, PROT_NONE);
-               }
        }
        if (kvm->ram_start == MAP_FAILED)
                die("out of memory");
@@ -238,7 +235,7 @@ int load_flat_binary(struct kvm *kvm, int fd_kernel, int fd_initrd, const char *
        return true;
 }
 
-static const char *BZIMAGE_MAGIC       = "HdrS";
+static const char *BZIMAGE_MAGIC = "HdrS";
 
 bool load_bzimage(struct kvm *kvm, int fd_kernel,
                  int fd_initrd, const char *kernel_cmdline, u16 vidmode)
@@ -334,13 +331,13 @@ bool load_bzimage(struct kvm *kvm, int fd_kernel,
                kern_boot->hdr.ramdisk_size     = initrd_stat.st_size;
        }
 
-       kvm->boot_selector      = BOOT_LOADER_SELECTOR;
+       kvm->boot_selector = BOOT_LOADER_SELECTOR;
        /*
         * The real-mode setup code starts at offset 0x200 of a bzImage. See
         * Documentation/x86/boot.txt for details.
         */
-       kvm->boot_ip            = BOOT_LOADER_IP + 0x200;
-       kvm->boot_sp            = BOOT_LOADER_SP;
+       kvm->boot_ip = BOOT_LOADER_IP + 0x200;
+       kvm->boot_sp = BOOT_LOADER_SP;
 
        return true;
 }