From patchwork Sun Apr 10 15:05:26 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asias He X-Patchwork-Id: 696581 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p3AF6gg3028745 for ; Sun, 10 Apr 2011 15:06:42 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753867Ab1DJPGi (ORCPT ); Sun, 10 Apr 2011 11:06:38 -0400 Received: from mail-pv0-f174.google.com ([74.125.83.174]:47165 "EHLO mail-pv0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753720Ab1DJPGh (ORCPT ); Sun, 10 Apr 2011 11:06:37 -0400 Received: by pvg12 with SMTP id 12so1739233pvg.19 for ; Sun, 10 Apr 2011 08:06:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer; bh=gfLJpaDk4iYufv740S8QiyhXhZACyauqFu3nFwAlEmg=; b=dUvDqKwizaFB75NYWEbWKzAGnc//D26xlkDcVdk/mbvcwWx9UA4hBHSYJtDVxYREQ/ xOgFGuaYGoIyQ6xQRbujKS53wpS7qwPb22yh1KVnnO88M3eDMrM47cxZZdTD5cyXwZmg MPEGIDafCklobVcKQjznCDm2vv3SnN7ml1mfk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=S6NRJ7G+XDr7Bnqxb/57uUEC6+i+lvxlJiUwFge8UiCnqiUQZCHU/YMcNQJL+ejDZe aOB+KpJFe6zdzpG0Sz1NCS+lPCaKS+cyAaebkbBek29Q5nEzYx7X5lMg+mUai2IYlB9y ZwfTX5QpXPyv9zRLw+jvrU8pSsg5rNTDUc7mA= Received: by 10.142.147.13 with SMTP id u13mr4275216wfd.435.1302447996319; Sun, 10 Apr 2011 08:06:36 -0700 (PDT) Received: from localhost.localdomain ([202.112.128.131]) by mx.google.com with ESMTPS id 25sm6853905wfb.10.2011.04.10.08.06.30 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 10 Apr 2011 08:06:35 -0700 (PDT) From: Asias He To: Pekka Enberg , Cyrill Gorcunov , Ingo Molnar Cc: kvm@vger.kernel.org, Asias He Subject: [PATCH] kvm tools: Get rid of the double underscore name convension Date: Sun, 10 Apr 2011 23:05:26 +0800 Message-Id: <1302447926-12686-1-git-send-email-asias.hejun@gmail.com> X-Mailer: git-send-email 1.7.4.1 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Sun, 10 Apr 2011 15:06:43 +0000 (UTC) This patch converts double underscore name convension to single underscore name convension project wide. Signed-off-by: Asias He --- tools/kvm/8250-serial.c | 68 ++++++++++++++++---------------- tools/kvm/bios.c | 12 +++--- tools/kvm/bios/gen-offsets.sh | 2 +- tools/kvm/cpuid.c | 2 +- tools/kvm/disk-image.c | 28 +++++++------- tools/kvm/include/kvm/8250-serial.h | 6 +- tools/kvm/include/kvm/cpufeature.h | 6 +- tools/kvm/include/kvm/disk-image.h | 10 ++-- tools/kvm/include/kvm/interrupt.h | 6 +- tools/kvm/include/kvm/ioport.h | 16 ++++---- tools/kvm/include/kvm/kvm-cpu.h | 22 +++++----- tools/kvm/include/kvm/kvm.h | 20 +++++----- tools/kvm/include/kvm/pci.h | 4 +- tools/kvm/include/kvm/virtio-blk.h | 2 +- tools/kvm/include/kvm/virtio-console.h | 4 +- tools/kvm/include/kvm/virtio.h | 10 ++-- tools/kvm/interrupt.c | 6 +- tools/kvm/ioport.c | 44 ++++++++++---------- tools/kvm/kvm-cpu.c | 60 ++++++++++++++-------------- tools/kvm/kvm-run.c | 48 +++++++++++----------- tools/kvm/kvm.c | 40 +++++++++--------- tools/kvm/mmio.c | 2 +- tools/kvm/pci.c | 8 ++-- tools/kvm/virtio-blk.c | 44 ++++++++++---------- tools/kvm/virtio-console.c | 50 ++++++++++++------------ tools/kvm/virtio.c | 8 ++-- 26 files changed, 264 insertions(+), 264 deletions(-) diff --git a/tools/kvm/8250-serial.c b/tools/kvm/8250-serial.c index 6d4b216..1814514 100644 --- a/tools/kvm/8250-serial.c +++ b/tools/kvm/8250-serial.c @@ -69,7 +69,7 @@ static struct serial8250_device devices[] = { static int sysrq_pending; -static void serial8250__sysrq(struct kvm *self, struct serial8250_device *dev) +static void serial8250_sysrq(struct kvm *self, struct serial8250_device *dev) { switch (sysrq_pending) { case SYSRQ_PENDING_BREAK: @@ -86,7 +86,7 @@ static void serial8250__sysrq(struct kvm *self, struct serial8250_device *dev) } } -static void serial8250__receive(struct kvm *self, struct serial8250_device *dev) +static void serial8250_receive(struct kvm *self, struct serial8250_device *dev) { int c; @@ -94,7 +94,7 @@ static void serial8250__receive(struct kvm *self, struct serial8250_device *dev) return; if (sysrq_pending) { - serial8250__sysrq(self, dev); + serial8250_sysrq(self, dev); return; } @@ -113,13 +113,13 @@ static void serial8250__receive(struct kvm *self, struct serial8250_device *dev) /* * Interrupts are injected for ttyS0 only. */ -void serial8250__inject_interrupt(struct kvm *self) +void serial8250_inject_interrupt(struct kvm *self) { struct serial8250_device *dev = &devices[0]; mutex_lock(&dev->mutex); - serial8250__receive(self, dev); + serial8250_receive(self, dev); if (dev->ier & UART_IER_RDI && dev->lsr & UART_LSR_DR) dev->iir = UART_IIR_RDI; @@ -129,14 +129,14 @@ void serial8250__inject_interrupt(struct kvm *self) dev->iir = UART_IIR_NO_INT; if (dev->iir != UART_IIR_NO_INT) { - kvm__irq_line(self, dev->irq, 0); - kvm__irq_line(self, dev->irq, 1); + kvm_irq_line(self, dev->irq, 0); + kvm_irq_line(self, dev->irq, 1); } mutex_unlock(&dev->mutex); } -void serial8250__inject_sysrq(struct kvm *self) +void serial8250_inject_sysrq(struct kvm *self) { sysrq_pending = SYSRQ_PENDING_BREAK; } @@ -171,19 +171,19 @@ static bool serial8250_out(struct kvm *self, uint16_t port, void *data, int size if (dev->lcr & UART_LCR_DLAB) { switch (offset) { case UART_DLL: - dev->dll = ioport__read8(data); + dev->dll = ioport_read8(data); break; case UART_DLM: - dev->dlm = ioport__read8(data); + dev->dlm = ioport_read8(data); break; case UART_FCR: - dev->fcr = ioport__read8(data); + dev->fcr = ioport_read8(data); break; case UART_LCR: - dev->lcr = ioport__read8(data); + dev->lcr = ioport_read8(data); break; case UART_MCR: - dev->mcr = ioport__read8(data); + dev->mcr = ioport_read8(data); break; case UART_LSR: /* Factory test */ @@ -192,7 +192,7 @@ static bool serial8250_out(struct kvm *self, uint16_t port, void *data, int size /* Not used */ break; case UART_SCR: - dev->scr = ioport__read8(data); + dev->scr = ioport_read8(data); break; default: ret = false; @@ -210,16 +210,16 @@ static bool serial8250_out(struct kvm *self, uint16_t port, void *data, int size break; } case UART_FCR: - dev->fcr = ioport__read8(data); + dev->fcr = ioport_read8(data); break; case UART_IER: - dev->ier = ioport__read8(data) & 0x3f; + dev->ier = ioport_read8(data) & 0x3f; break; case UART_LCR: - dev->lcr = ioport__read8(data); + dev->lcr = ioport_read8(data); break; case UART_MCR: - dev->mcr = ioport__read8(data); + dev->mcr = ioport_read8(data); break; case UART_LSR: /* Factory test */ @@ -228,7 +228,7 @@ static bool serial8250_out(struct kvm *self, uint16_t port, void *data, int size /* Not used */ break; case UART_SCR: - dev->scr = ioport__read8(data); + dev->scr = ioport_read8(data); break; default: ret = false; @@ -259,11 +259,11 @@ static bool serial8250_in(struct kvm *self, uint16_t port, void *data, int size, if (dev->lcr & UART_LCR_DLAB) { switch (offset) { case UART_DLL: - ioport__write8(data, dev->dll); + ioport_write8(data, dev->dll); goto out_unlock; case UART_DLM: - ioport__write8(data, dev->dlm); + ioport_write8(data, dev->dlm); goto out_unlock; default: @@ -272,13 +272,13 @@ static bool serial8250_in(struct kvm *self, uint16_t port, void *data, int size, } else { switch (offset) { case UART_RX: - ioport__write8(data, dev->rbr); + ioport_write8(data, dev->rbr); dev->lsr &= ~UART_LSR_DR; dev->iir = UART_IIR_NO_INT; goto out_unlock; case UART_IER: - ioport__write8(data, dev->ier); + ioport_write8(data, dev->ier); goto out_unlock; default: @@ -293,24 +293,24 @@ static bool serial8250_in(struct kvm *self, uint16_t port, void *data, int size, if (dev->fcr & UART_FCR_ENABLE_FIFO) iir |= 0xc0; - ioport__write8(data, iir); + ioport_write8(data, iir); break; } case UART_LCR: - ioport__write8(data, dev->lcr); + ioport_write8(data, dev->lcr); break; case UART_MCR: - ioport__write8(data, dev->mcr); + ioport_write8(data, dev->mcr); break; case UART_LSR: - ioport__write8(data, dev->lsr); + ioport_write8(data, dev->lsr); dev->lsr &= ~(UART_LSR_OE|UART_LSR_PE|UART_LSR_FE|UART_LSR_BI); break; case UART_MSR: - ioport__write8(data, dev->msr); + ioport_write8(data, dev->msr); break; case UART_SCR: - ioport__write8(data, dev->scr); + ioport_write8(data, dev->scr); break; default: ret = false; @@ -327,19 +327,19 @@ static struct ioport_operations serial8250_ops = { .io_out = serial8250_out, }; -static void serial8250__device_init(struct kvm *kvm, struct serial8250_device *dev) +static void serial8250_device_init(struct kvm *kvm, struct serial8250_device *dev) { - ioport__register(dev->iobase, &serial8250_ops, 8); - kvm__irq_line(kvm, dev->irq, 0); + ioport_register(dev->iobase, &serial8250_ops, 8); + kvm_irq_line(kvm, dev->irq, 0); } -void serial8250__init(struct kvm *kvm) +void serial8250_init(struct kvm *kvm) { unsigned int i; for (i = 0; i < ARRAY_SIZE(devices); i++) { struct serial8250_device *dev = &devices[i]; - serial8250__device_init(kvm, dev); + serial8250_device_init(kvm, dev); } } diff --git a/tools/kvm/bios.c b/tools/kvm/bios.c index 2199c0c..f8cd575 100644 --- a/tools/kvm/bios.c +++ b/tools/kvm/bios.c @@ -15,9 +15,9 @@ struct irq_handler { size_t size; }; -#define BIOS_IRQ_ADDR(name) (MB_BIOS_BEGIN + BIOS_OFFSET__##name) -#define BIOS_IRQ_FUNC(name) ((char *)&bios_rom[BIOS_OFFSET__##name]) -#define BIOS_IRQ_SIZE(name) (BIOS_ENTRY_SIZE(BIOS_OFFSET__##name)) +#define BIOS_IRQ_ADDR(name) (MB_BIOS_BEGIN + BIOS_OFFSET_##name) +#define BIOS_IRQ_FUNC(name) ((char *)&bios_rom[BIOS_OFFSET_##name]) +#define BIOS_IRQ_SIZE(name) (BIOS_ENTRY_SIZE(BIOS_OFFSET_##name)) #define DEFINE_BIOS_IRQ_HANDLER(_irq, _handler) \ { \ @@ -45,7 +45,7 @@ static void setup_irq_handler(struct kvm *kvm, struct irq_handler *handler) .offset = REAL_OFFSET(handler->address), }; - interrupt_table__set(&kvm->interrupt_table, &intr_desc, handler->irq); + interrupt_table_set(&kvm->interrupt_table, &intr_desc, handler->irq); } /** @@ -130,12 +130,12 @@ void setup_bios(struct kvm *kvm) .segment = REAL_SEGMENT(address), .offset = REAL_OFFSET(address), }; - interrupt_table__setup(&kvm->interrupt_table, &intr_desc); + interrupt_table_setup(&kvm->interrupt_table, &intr_desc); for (i = 0; i < ARRAY_SIZE(bios_irq_handlers); i++) setup_irq_handler(kvm, &bios_irq_handlers[i]); /* we almost done */ p = guest_flat_to_host(kvm, 0); - interrupt_table__copy(&kvm->interrupt_table, p, REAL_INTR_SIZE); + interrupt_table_copy(&kvm->interrupt_table, p, REAL_INTR_SIZE); } diff --git a/tools/kvm/bios/gen-offsets.sh b/tools/kvm/bios/gen-offsets.sh index 9a6e322..1061457 100644 --- a/tools/kvm/bios/gen-offsets.sh +++ b/tools/kvm/bios/gen-offsets.sh @@ -8,6 +8,6 @@ echo "" echo "#define BIOS_ENTRY_SIZE(name) (name##_end - name)" echo "" -nm bios-rom.bin.elf | grep ' [Tt] ' | awk '{ print "#define BIOS_OFFSET__" $3 " 0x" $1; }' +nm bios-rom.bin.elf | grep ' [Tt] ' | awk '{ print "#define BIOS_OFFSET_" $3 " 0x" $1; }' echo "#endif" diff --git a/tools/kvm/cpuid.c b/tools/kvm/cpuid.c index 0b26eb1..847f959 100644 --- a/tools/kvm/cpuid.c +++ b/tools/kvm/cpuid.c @@ -32,7 +32,7 @@ static void filter_cpuid(struct kvm_cpuid2 *kvm_cpuid) } } -void kvm_cpu__setup_cpuid(struct kvm_cpu *self) +void kvm_cpu_setup_cpuid(struct kvm_cpu *self) { struct kvm_cpuid2 *kvm_cpuid; diff --git a/tools/kvm/disk-image.c b/tools/kvm/disk-image.c index d94057a..b6fada7 100644 --- a/tools/kvm/disk-image.c +++ b/tools/kvm/disk-image.c @@ -13,7 +13,7 @@ #include #include -static int raw_image__read_sector_mmap(struct disk_image *self, uint64_t sector, void *dst, uint32_t dst_len) +static int raw_image_read_sector_mmap(struct disk_image *self, uint64_t sector, void *dst, uint32_t dst_len) { uint64_t offset = sector << SECTOR_SHIFT; @@ -25,7 +25,7 @@ static int raw_image__read_sector_mmap(struct disk_image *self, uint64_t sector, return 0; } -static int raw_image__write_sector_mmap(struct disk_image *self, uint64_t sector, void *src, uint32_t src_len) +static int raw_image_write_sector_mmap(struct disk_image *self, uint64_t sector, void *src, uint32_t src_len) { uint64_t offset = sector << SECTOR_SHIFT; @@ -38,7 +38,7 @@ static int raw_image__write_sector_mmap(struct disk_image *self, uint64_t sector } -static int raw_image__read_sector(struct disk_image *self, uint64_t sector, void *dst, uint32_t dst_len) +static int raw_image_read_sector(struct disk_image *self, uint64_t sector, void *dst, uint32_t dst_len) { uint64_t offset = sector << SECTOR_SHIFT; @@ -51,7 +51,7 @@ static int raw_image__read_sector(struct disk_image *self, uint64_t sector, void return 0; } -static int raw_image__write_sector(struct disk_image *self, uint64_t sector, void *src, uint32_t src_len) +static int raw_image_write_sector(struct disk_image *self, uint64_t sector, void *src, uint32_t src_len) { uint64_t offset = sector << SECTOR_SHIFT; @@ -65,16 +65,16 @@ static int raw_image__write_sector(struct disk_image *self, uint64_t sector, voi } static struct disk_image_operations raw_image_ops = { - .read_sector = raw_image__read_sector, - .write_sector = raw_image__write_sector, + .read_sector = raw_image_read_sector, + .write_sector = raw_image_write_sector, }; static struct disk_image_operations raw_image_mmap_ops = { - .read_sector = raw_image__read_sector_mmap, - .write_sector = raw_image__write_sector_mmap, + .read_sector = raw_image_read_sector_mmap, + .write_sector = raw_image_write_sector_mmap, }; -struct disk_image *disk_image__new(int fd, uint64_t size) +struct disk_image *disk_image_new(int fd, uint64_t size) { struct disk_image *self; @@ -90,17 +90,17 @@ struct disk_image *disk_image__new(int fd, uint64_t size) return self; } -static struct disk_image *raw_image__probe(int fd) +static struct disk_image *raw_image_probe(int fd) { struct stat st; if (fstat(fd, &st) < 0) return NULL; - return disk_image__new(fd, st.st_size); + return disk_image_new(fd, st.st_size); } -struct disk_image *disk_image__open(const char *filename) +struct disk_image *disk_image_open(const char *filename) { struct disk_image *self; int fd; @@ -109,7 +109,7 @@ struct disk_image *disk_image__open(const char *filename) if (fd < 0) return NULL; - self = raw_image__probe(fd); + self = raw_image_probe(fd); if (self) return self; @@ -119,7 +119,7 @@ struct disk_image *disk_image__open(const char *filename) return NULL; } -void disk_image__close(struct disk_image *self) +void disk_image_close(struct disk_image *self) { /* If there was no disk image then there's nothing to do: */ if (!self) diff --git a/tools/kvm/include/kvm/8250-serial.h b/tools/kvm/include/kvm/8250-serial.h index 7a6d3f3..39ba0ab 100644 --- a/tools/kvm/include/kvm/8250-serial.h +++ b/tools/kvm/include/kvm/8250-serial.h @@ -3,8 +3,8 @@ struct kvm; -void serial8250__init(struct kvm *kvm); -void serial8250__inject_interrupt(struct kvm *kvm); -void serial8250__inject_sysrq(struct kvm *kvm); +void serial8250_init(struct kvm *kvm); +void serial8250_inject_interrupt(struct kvm *kvm); +void serial8250_inject_sysrq(struct kvm *kvm); #endif /* KVM__8250_SERIAL_H */ diff --git a/tools/kvm/include/kvm/cpufeature.h b/tools/kvm/include/kvm/cpufeature.h index 92abb87..c0dce6b 100644 --- a/tools/kvm/include/kvm/cpufeature.h +++ b/tools/kvm/include/kvm/cpufeature.h @@ -12,9 +12,9 @@ /* * CPUID flags we need to deal with */ -#define KVM__X86_FEATURE_VMX 5 /* Hardware virtualization */ -#define KVM__X86_FEATURE_SVM 2 /* Secure virtual machine */ -#define KVM__X86_FEATURE_XSAVE 26 /* XSAVE/XRSTOR/XSETBV/XGETBV */ +#define KVM_X86_FEATURE_VMX 5 /* Hardware virtualization */ +#define KVM_X86_FEATURE_SVM 2 /* Secure virtual machine */ +#define KVM_X86_FEATURE_XSAVE 26 /* XSAVE/XRSTOR/XSETBV/XGETBV */ #define cpu_feature_disable(reg, feature) \ ((reg) & ~(1 << (feature))) diff --git a/tools/kvm/include/kvm/disk-image.h b/tools/kvm/include/kvm/disk-image.h index 8b78657..0b4eb64 100644 --- a/tools/kvm/include/kvm/disk-image.h +++ b/tools/kvm/include/kvm/disk-image.h @@ -21,16 +21,16 @@ struct disk_image { void *priv; }; -struct disk_image *disk_image__open(const char *filename); -struct disk_image *disk_image__new(int fd, uint64_t size); -void disk_image__close(struct disk_image *self); +struct disk_image *disk_image_open(const char *filename); +struct disk_image *disk_image_new(int fd, uint64_t size); +void disk_image_close(struct disk_image *self); -static inline int disk_image__read_sector(struct disk_image *self, uint64_t sector, void *dst, uint32_t dst_len) +static inline int disk_image_read_sector(struct disk_image *self, uint64_t sector, void *dst, uint32_t dst_len) { return self->ops->read_sector(self, sector, dst, dst_len); } -static inline int disk_image__write_sector(struct disk_image *self, uint64_t sector, void *src, uint32_t src_len) +static inline int disk_image_write_sector(struct disk_image *self, uint64_t sector, void *src, uint32_t src_len) { return self->ops->write_sector(self, sector, src, src_len); } diff --git a/tools/kvm/include/kvm/interrupt.h b/tools/kvm/include/kvm/interrupt.h index 0169bba..e03c686 100644 --- a/tools/kvm/include/kvm/interrupt.h +++ b/tools/kvm/include/kvm/interrupt.h @@ -19,8 +19,8 @@ struct interrupt_table { struct real_intr_desc entries[REAL_INTR_VECTORS]; }; -void interrupt_table__copy(struct interrupt_table *self, void *dst, unsigned int size); -void interrupt_table__setup(struct interrupt_table *self, struct real_intr_desc *entry); -void interrupt_table__set(struct interrupt_table *self, struct real_intr_desc *entry, unsigned int num); +void interrupt_table_copy(struct interrupt_table *self, void *dst, unsigned int size); +void interrupt_table_setup(struct interrupt_table *self, struct real_intr_desc *entry); +void interrupt_table_set(struct interrupt_table *self, struct real_intr_desc *entry, unsigned int num); #endif /* KVM__INTERRUPT_H */ diff --git a/tools/kvm/include/kvm/ioport.h b/tools/kvm/include/kvm/ioport.h index 0218329..70f3c58 100644 --- a/tools/kvm/include/kvm/ioport.h +++ b/tools/kvm/include/kvm/ioport.h @@ -18,36 +18,36 @@ struct ioport_operations { bool (*io_out)(struct kvm *self, uint16_t port, void *data, int size, uint32_t count); }; -void ioport__setup_legacy(void); +void ioport_setup_legacy(void); -void ioport__register(uint16_t port, struct ioport_operations *ops, int count); +void ioport_register(uint16_t port, struct ioport_operations *ops, int count); -static inline uint8_t ioport__read8(uint8_t *data) +static inline uint8_t ioport_read8(uint8_t *data) { return *data; } -static inline uint16_t ioport__read16(uint16_t *data) +static inline uint16_t ioport_read16(uint16_t *data) { return *data; } -static inline uint32_t ioport__read32(uint32_t *data) +static inline uint32_t ioport_read32(uint32_t *data) { return *data; } -static inline void ioport__write8(uint8_t *data, uint8_t value) +static inline void ioport_write8(uint8_t *data, uint8_t value) { *data = value; } -static inline void ioport__write16(uint16_t *data, uint16_t value) +static inline void ioport_write16(uint16_t *data, uint16_t value) { *data = value; } -static inline void ioport__write32(uint32_t *data, uint32_t value) +static inline void ioport_write32(uint32_t *data, uint32_t value) { *data = value; } diff --git a/tools/kvm/include/kvm/kvm-cpu.h b/tools/kvm/include/kvm/kvm-cpu.h index 0d0881e..4e4335c 100644 --- a/tools/kvm/include/kvm/kvm-cpu.h +++ b/tools/kvm/include/kvm/kvm-cpu.h @@ -24,16 +24,16 @@ struct kvm_cpu { struct kvm_msrs *msrs; /* dynamically allocated */ }; -struct kvm_cpu *kvm_cpu__init(struct kvm *kvm, unsigned long cpu_id); -void kvm_cpu__delete(struct kvm_cpu *self); -void kvm_cpu__reset_vcpu(struct kvm_cpu *self); -void kvm_cpu__setup_cpuid(struct kvm_cpu *self); -void kvm_cpu__enable_singlestep(struct kvm_cpu *self); -void kvm_cpu__run(struct kvm_cpu *self); -int kvm_cpu__start(struct kvm_cpu *cpu); - -void kvm_cpu__show_code(struct kvm_cpu *self); -void kvm_cpu__show_registers(struct kvm_cpu *self); -void kvm_cpu__show_page_tables(struct kvm_cpu *self); +struct kvm_cpu *kvm_cpu_init(struct kvm *kvm, unsigned long cpu_id); +void kvm_cpu_delete(struct kvm_cpu *self); +void kvm_cpu_reset_vcpu(struct kvm_cpu *self); +void kvm_cpu_setup_cpuid(struct kvm_cpu *self); +void kvm_cpu_enable_singlestep(struct kvm_cpu *self); +void kvm_cpu_run(struct kvm_cpu *self); +int kvm_cpu_start(struct kvm_cpu *cpu); + +void kvm_cpu_show_code(struct kvm_cpu *self); +void kvm_cpu_show_registers(struct kvm_cpu *self); +void kvm_cpu_show_page_tables(struct kvm_cpu *self); #endif /* KVM__KVM_CPU_H */ diff --git a/tools/kvm/include/kvm/kvm.h b/tools/kvm/include/kvm/kvm.h index 7af98f9..8f5e2e3 100644 --- a/tools/kvm/include/kvm/kvm.h +++ b/tools/kvm/include/kvm/kvm.h @@ -25,21 +25,21 @@ struct kvm { struct interrupt_table interrupt_table; }; -struct kvm *kvm__init(const char *kvm_dev, unsigned long ram_size); -void kvm__delete(struct kvm *self); -bool kvm__load_kernel(struct kvm *kvm, const char *kernel_filename, +struct kvm *kvm_init(const char *kvm_dev, unsigned long ram_size); +void kvm_delete(struct kvm *self); +bool kvm_load_kernel(struct kvm *kvm, const char *kernel_filename, const char *initrd_filename, const char *kernel_cmdline); -void kvm__setup_bios(struct kvm *self); -void kvm__start_timer(struct kvm *self); -void kvm__stop_timer(struct kvm *self); -void kvm__irq_line(struct kvm *self, int irq, int level); -bool kvm__emulate_io(struct kvm *self, uint16_t port, void *data, int direction, int size, uint32_t count); -bool kvm__emulate_mmio(struct kvm *self, uint64_t phys_addr, uint8_t *data, uint32_t len, uint8_t is_write); +void kvm_setup_bios(struct kvm *self); +void kvm_start_timer(struct kvm *self); +void kvm_stop_timer(struct kvm *self); +void kvm_irq_line(struct kvm *self, int irq, int level); +bool kvm_emulate_io(struct kvm *self, uint16_t port, void *data, int direction, int size, uint32_t count); +bool kvm_emulate_mmio(struct kvm *self, uint64_t phys_addr, uint8_t *data, uint32_t len, uint8_t is_write); /* * Debugging */ -void kvm__dump_mem(struct kvm *self, unsigned long addr, unsigned long size); +void kvm_dump_mem(struct kvm *self, unsigned long addr, unsigned long size); extern const char *kvm_exit_reasons[]; diff --git a/tools/kvm/include/kvm/pci.h b/tools/kvm/include/kvm/pci.h index c352803..ab70fe9 100644 --- a/tools/kvm/include/kvm/pci.h +++ b/tools/kvm/include/kvm/pci.h @@ -49,7 +49,7 @@ struct pci_device_header { uint8_t max_lat; }; -void pci__init(void); -void pci__register(struct pci_device_header *dev, uint8_t dev_num); +void pci_init(void); +void pci_register(struct pci_device_header *dev, uint8_t dev_num); #endif /* KVM__PCI_H */ diff --git a/tools/kvm/include/kvm/virtio-blk.h b/tools/kvm/include/kvm/virtio-blk.h index f82bbc7..98ee95a 100644 --- a/tools/kvm/include/kvm/virtio-blk.h +++ b/tools/kvm/include/kvm/virtio-blk.h @@ -3,6 +3,6 @@ struct kvm; -void virtio_blk__init(struct kvm *self); +void virtio_blk_init(struct kvm *self); #endif /* KVM__BLK_VIRTIO_H */ diff --git a/tools/kvm/include/kvm/virtio-console.h b/tools/kvm/include/kvm/virtio-console.h index d2e5d19..b745435 100644 --- a/tools/kvm/include/kvm/virtio-console.h +++ b/tools/kvm/include/kvm/virtio-console.h @@ -3,7 +3,7 @@ struct kvm; -void virtio_console__init(struct kvm *self); -void virtio_console__inject_interrupt(struct kvm *self); +void virtio_console_init(struct kvm *self); +void virtio_console_inject_interrupt(struct kvm *self); #endif /* KVM__CONSOLE_VIRTIO_H */ diff --git a/tools/kvm/include/kvm/virtio.h b/tools/kvm/include/kvm/virtio.h index 7903a74..00e42be 100644 --- a/tools/kvm/include/kvm/virtio.h +++ b/tools/kvm/include/kvm/virtio.h @@ -16,25 +16,25 @@ struct virt_queue { uint16_t last_avail_idx; }; -static inline uint16_t virt_queue__pop(struct virt_queue *queue) +static inline uint16_t virt_queue_pop(struct virt_queue *queue) { return queue->vring.avail->ring[queue->last_avail_idx++ % queue->vring.num]; } -static inline struct vring_desc *virt_queue__get_desc(struct virt_queue *queue, uint16_t desc_ndx) +static inline struct vring_desc *virt_queue_get_desc(struct virt_queue *queue, uint16_t desc_ndx) { return &queue->vring.desc[desc_ndx]; } -static inline bool virt_queue__available(struct virt_queue *vq) +static inline bool virt_queue_available(struct virt_queue *vq) { if (!vq->vring.avail) return 0; return vq->vring.avail->idx != vq->last_avail_idx; } -struct vring_used_elem *virt_queue__set_used_elem(struct virt_queue *queue, uint32_t head, uint32_t len); +struct vring_used_elem *virt_queue_set_used_elem(struct virt_queue *queue, uint32_t head, uint32_t len); -uint16_t virt_queue__get_iov(struct virt_queue *queue, struct iovec iov[], uint16_t *out, uint16_t *in, struct kvm *kvm); +uint16_t virt_queue_get_iov(struct virt_queue *queue, struct iovec iov[], uint16_t *out, uint16_t *in, struct kvm *kvm); #endif /* KVM__VIRTIO_H */ diff --git a/tools/kvm/interrupt.c b/tools/kvm/interrupt.c index fbf4ecd..e600792 100644 --- a/tools/kvm/interrupt.c +++ b/tools/kvm/interrupt.c @@ -4,7 +4,7 @@ #include -void interrupt_table__copy(struct interrupt_table *self, void *dst, unsigned int size) +void interrupt_table_copy(struct interrupt_table *self, void *dst, unsigned int size) { if (size < sizeof(self->entries)) die("An attempt to overwrite host memory"); @@ -12,7 +12,7 @@ void interrupt_table__copy(struct interrupt_table *self, void *dst, unsigned int memcpy(dst, self->entries, sizeof(self->entries)); } -void interrupt_table__setup(struct interrupt_table *self, struct real_intr_desc *entry) +void interrupt_table_setup(struct interrupt_table *self, struct real_intr_desc *entry) { unsigned int i; @@ -20,7 +20,7 @@ void interrupt_table__setup(struct interrupt_table *self, struct real_intr_desc self->entries[i] = *entry; } -void interrupt_table__set(struct interrupt_table *self, struct real_intr_desc *entry, unsigned int num) +void interrupt_table_set(struct interrupt_table *self, struct real_intr_desc *entry, unsigned int num) { if (num < REAL_INTR_VECTORS) self->entries[num] = *entry; diff --git a/tools/kvm/ioport.c b/tools/kvm/ioport.c index e3f67fc..76e68a5 100644 --- a/tools/kvm/ioport.c +++ b/tools/kvm/ioport.c @@ -64,7 +64,7 @@ static struct ioport_operations dummy_write_only_ioport_ops = { static struct ioport_operations *ioport_ops[USHRT_MAX]; -void ioport__register(uint16_t port, struct ioport_operations *ops, int count) +void ioport_register(uint16_t port, struct ioport_operations *ops, int count) { int i; @@ -85,7 +85,7 @@ static void ioport_error(uint16_t port, void *data, int direction, int size, uin fprintf(stderr, "IO error: %s port=%x, size=%d, count=%" PRIu32 "\n", to_direction(direction), port, size, count); } -bool kvm__emulate_io(struct kvm *self, uint16_t port, void *data, int direction, int size, uint32_t count) +bool kvm_emulate_io(struct kvm *self, uint16_t port, void *data, int direction, int size, uint32_t count) { struct ioport_operations *ops = ioport_ops[port]; bool ret; @@ -116,53 +116,53 @@ error: return !ioport_debug; } -void ioport__setup_legacy(void) +void ioport_setup_legacy(void) { /* 0x0020 - 0x003F - 8259A PIC 1 */ - ioport__register(0x0020, &dummy_read_write_ioport_ops, 2); + ioport_register(0x0020, &dummy_read_write_ioport_ops, 2); /* PORT 0040-005F - PIT - PROGRAMMABLE INTERVAL TIMER (8253, 8254) */ - ioport__register(0x0040, &dummy_read_write_ioport_ops, 4); + ioport_register(0x0040, &dummy_read_write_ioport_ops, 4); /* PORT 0060-006F - KEYBOARD CONTROLLER 804x (8041, 8042) (or PPI (8255) on PC,XT) */ - ioport__register(0x0060, &dummy_read_write_ioport_ops, 2); - ioport__register(0x0064, &dummy_read_write_ioport_ops, 1); + ioport_register(0x0060, &dummy_read_write_ioport_ops, 2); + ioport_register(0x0064, &dummy_read_write_ioport_ops, 1); /* PORT 0070-007F - CMOS RAM/RTC (REAL TIME CLOCK) */ - ioport__register(0x0070, &cmos_ram_rtc_ops, 1); - ioport__register(0x0071, &dummy_read_write_ioport_ops, 1); + ioport_register(0x0070, &cmos_ram_rtc_ops, 1); + ioport_register(0x0071, &dummy_read_write_ioport_ops, 1); /* 0x00A0 - 0x00AF - 8259A PIC 2 */ - ioport__register(0x00A0, &dummy_read_write_ioport_ops, 2); + ioport_register(0x00A0, &dummy_read_write_ioport_ops, 2); /* PORT 00E0-00EF are 'motherboard specific' so we use them for our internal debugging purposes. */ - ioport__register(IOPORT_DBG, &debug_ops, 1); + ioport_register(IOPORT_DBG, &debug_ops, 1); /* PORT 00ED - DUMMY PORT FOR DELAY??? */ - ioport__register(0x00ED, &dummy_write_only_ioport_ops, 1); + ioport_register(0x00ED, &dummy_write_only_ioport_ops, 1); /* 0x00F0 - 0x00FF - Math co-processor */ - ioport__register(0x00F0, &dummy_write_only_ioport_ops, 2); + ioport_register(0x00F0, &dummy_write_only_ioport_ops, 2); /* PORT 02E8-02EF - serial port, same as 02F8, 03E8 and 03F8 (COM4) */ - ioport__register(0x02E8, &dummy_read_write_ioport_ops, 7); + ioport_register(0x02E8, &dummy_read_write_ioport_ops, 7); /* PORT 02F8-02FF - serial port, same as 02E8, 03E8 and 03F8 (COM2) */ - ioport__register(0x02F8, &dummy_read_write_ioport_ops, 7); + ioport_register(0x02F8, &dummy_read_write_ioport_ops, 7); /* PORT 03D4-03D5 - COLOR VIDEO - CRT CONTROL REGISTERS */ - ioport__register(0x03D4, &dummy_read_write_ioport_ops, 1); - ioport__register(0x03D5, &dummy_write_only_ioport_ops, 1); + ioport_register(0x03D4, &dummy_read_write_ioport_ops, 1); + ioport_register(0x03D5, &dummy_write_only_ioport_ops, 1); /* PORT 03E8-03EF - serial port, same as 02E8, 02F8 and 03F8 (COM3) */ - ioport__register(0x03E8, &dummy_read_write_ioport_ops, 7); + ioport_register(0x03E8, &dummy_read_write_ioport_ops, 7); /* PORT 03F8-03FF - Serial port (8250,8250A,8251,16450,16550,16550A,etc.) COM1 */ - ioport__register(0x03F8, &dummy_read_write_ioport_ops, 7); + ioport_register(0x03F8, &dummy_read_write_ioport_ops, 7); /* PORT 0CF8-0CFF - PCI Configuration Mechanism 1 - Configuration Registers */ - ioport__register(0x0CF8, &dummy_write_only_ioport_ops, 1); - ioport__register(0x0CFC, &dummy_read_write_ioport_ops, 1); - ioport__register(0x0CFE, &dummy_read_write_ioport_ops, 1); + ioport_register(0x0CF8, &dummy_write_only_ioport_ops, 1); + ioport_register(0x0CFC, &dummy_read_write_ioport_ops, 1); + ioport_register(0x0CFE, &dummy_read_write_ioport_ops, 1); } diff --git a/tools/kvm/kvm-cpu.c b/tools/kvm/kvm-cpu.c index dc40b42..31f6cbb 100644 --- a/tools/kvm/kvm-cpu.c +++ b/tools/kvm/kvm-cpu.c @@ -39,7 +39,7 @@ static inline uint32_t selector_to_base(uint16_t selector) return (uint32_t)selector * 16; } -static struct kvm_cpu *kvm_cpu__new(struct kvm *kvm) +static struct kvm_cpu *kvm_cpu_new(struct kvm *kvm) { struct kvm_cpu *self; @@ -52,7 +52,7 @@ static struct kvm_cpu *kvm_cpu__new(struct kvm *kvm) return self; } -void kvm_cpu__delete(struct kvm_cpu *self) +void kvm_cpu_delete(struct kvm_cpu *self) { if (self->msrs) free(self->msrs); @@ -60,12 +60,12 @@ void kvm_cpu__delete(struct kvm_cpu *self) free(self); } -struct kvm_cpu *kvm_cpu__init(struct kvm *kvm, unsigned long cpu_id) +struct kvm_cpu *kvm_cpu_init(struct kvm *kvm, unsigned long cpu_id) { struct kvm_cpu *self; int mmap_size; - self = kvm_cpu__new(kvm); + self = kvm_cpu_new(kvm); if (!self) return NULL; @@ -86,7 +86,7 @@ struct kvm_cpu *kvm_cpu__init(struct kvm *kvm, unsigned long cpu_id) return self; } -void kvm_cpu__enable_singlestep(struct kvm_cpu *self) +void kvm_cpu_enable_singlestep(struct kvm_cpu *self) { struct kvm_guest_debug debug = { .control = KVM_GUESTDBG_ENABLE | KVM_GUESTDBG_SINGLESTEP, @@ -96,7 +96,7 @@ void kvm_cpu__enable_singlestep(struct kvm_cpu *self) warning("KVM_SET_GUEST_DEBUG failed"); } -static struct kvm_msrs *kvm_msrs__new(size_t nmsrs) +static struct kvm_msrs *kvm_msrs_new(size_t nmsrs) { struct kvm_msrs *self = calloc(1, sizeof(*self) + (sizeof(struct kvm_msr_entry) * nmsrs)); @@ -121,11 +121,11 @@ static struct kvm_msrs *kvm_msrs__new(size_t nmsrs) #define KVM_MSR_ENTRY(_index, _data) \ (struct kvm_msr_entry) { .index = _index, .data = _data } -static void kvm_cpu__setup_msrs(struct kvm_cpu *self) +static void kvm_cpu_setup_msrs(struct kvm_cpu *self) { unsigned long ndx = 0; - self->msrs = kvm_msrs__new(100); + self->msrs = kvm_msrs_new(100); self->msrs->entries[ndx++] = KVM_MSR_ENTRY(MSR_IA32_SYSENTER_CS, 0x0); self->msrs->entries[ndx++] = KVM_MSR_ENTRY(MSR_IA32_SYSENTER_ESP, 0x0); @@ -145,7 +145,7 @@ static void kvm_cpu__setup_msrs(struct kvm_cpu *self) die_perror("KVM_SET_MSRS failed"); } -static void kvm_cpu__setup_fpu(struct kvm_cpu *self) +static void kvm_cpu_setup_fpu(struct kvm_cpu *self) { self->fpu = (struct kvm_fpu) { .fcw = 0x37f, @@ -156,7 +156,7 @@ static void kvm_cpu__setup_fpu(struct kvm_cpu *self) die_perror("KVM_SET_FPU failed"); } -static void kvm_cpu__setup_regs(struct kvm_cpu *self) +static void kvm_cpu_setup_regs(struct kvm_cpu *self) { self->regs = (struct kvm_regs) { /* We start the guest in 16-bit real mode */ @@ -174,7 +174,7 @@ static void kvm_cpu__setup_regs(struct kvm_cpu *self) die_perror("KVM_SET_REGS failed"); } -static void kvm_cpu__setup_sregs(struct kvm_cpu *self) +static void kvm_cpu_setup_sregs(struct kvm_cpu *self) { if (ioctl(self->vcpu_fd, KVM_GET_SREGS, &self->sregs) < 0) @@ -198,14 +198,14 @@ static void kvm_cpu__setup_sregs(struct kvm_cpu *self) } /** - * kvm_cpu__reset_vcpu - reset virtual CPU to a known state + * kvm_cpu_reset_vcpu - reset virtual CPU to a known state */ -void kvm_cpu__reset_vcpu(struct kvm_cpu *self) +void kvm_cpu_reset_vcpu(struct kvm_cpu *self) { - kvm_cpu__setup_sregs(self); - kvm_cpu__setup_regs(self); - kvm_cpu__setup_fpu(self); - kvm_cpu__setup_msrs(self); + kvm_cpu_setup_sregs(self); + kvm_cpu_setup_regs(self); + kvm_cpu_setup_fpu(self); + kvm_cpu_setup_msrs(self); } static void print_dtable(const char *name, struct kvm_dtable *dtable) @@ -221,7 +221,7 @@ static void print_segment(const char *name, struct kvm_segment *seg) (uint8_t) seg->type, seg->present, seg->dpl, seg->db, seg->s, seg->l, seg->g, seg->avl); } -void kvm_cpu__show_registers(struct kvm_cpu *self) +void kvm_cpu_show_registers(struct kvm_cpu *self) { unsigned long cr0, cr2, cr3; unsigned long cr4, cr8; @@ -286,7 +286,7 @@ void kvm_cpu__show_registers(struct kvm_cpu *self) printf("\n"); } -void kvm_cpu__show_code(struct kvm_cpu *self) +void kvm_cpu_show_code(struct kvm_cpu *self) { unsigned int code_bytes = 64; unsigned int code_prologue = code_bytes * 43 / 64; @@ -320,10 +320,10 @@ void kvm_cpu__show_code(struct kvm_cpu *self) printf("\n"); printf("Stack:\n"); - kvm__dump_mem(self->kvm, self->regs.rsp, 32); + kvm_dump_mem(self->kvm, self->regs.rsp, 32); } -void kvm_cpu__show_page_tables(struct kvm_cpu *self) +void kvm_cpu_show_page_tables(struct kvm_cpu *self) { uint64_t *pte1; uint64_t *pte2; @@ -363,7 +363,7 @@ void kvm_cpu__show_page_tables(struct kvm_cpu *self) *pte4, *pte3, *pte2, *pte1); } -void kvm_cpu__run(struct kvm_cpu *self) +void kvm_cpu_run(struct kvm_cpu *self) { int err; @@ -372,7 +372,7 @@ void kvm_cpu__run(struct kvm_cpu *self) die_perror("KVM_RUN failed"); } -int kvm_cpu__start(struct kvm_cpu *cpu) +int kvm_cpu_start(struct kvm_cpu *cpu) { sigset_t sigset; @@ -381,21 +381,21 @@ int kvm_cpu__start(struct kvm_cpu *cpu) pthread_sigmask(SIG_BLOCK, &sigset, NULL); - kvm_cpu__setup_cpuid(cpu); - kvm_cpu__reset_vcpu(cpu); + kvm_cpu_setup_cpuid(cpu); + kvm_cpu_reset_vcpu(cpu); for (;;) { - kvm_cpu__run(cpu); + kvm_cpu_run(cpu); switch (cpu->kvm_run->exit_reason) { case KVM_EXIT_DEBUG: - kvm_cpu__show_registers(cpu); - kvm_cpu__show_code(cpu); + kvm_cpu_show_registers(cpu); + kvm_cpu_show_code(cpu); break; case KVM_EXIT_IO: { bool ret; - ret = kvm__emulate_io(cpu->kvm, + ret = kvm_emulate_io(cpu->kvm, cpu->kvm_run->io.port, (uint8_t *)cpu->kvm_run + cpu->kvm_run->io.data_offset, @@ -410,7 +410,7 @@ int kvm_cpu__start(struct kvm_cpu *cpu) case KVM_EXIT_MMIO: { bool ret; - ret = kvm__emulate_mmio(cpu->kvm, + ret = kvm_emulate_mmio(cpu->kvm, cpu->kvm_run->mmio.phys_addr, cpu->kvm_run->mmio.data, cpu->kvm_run->mmio.len, diff --git a/tools/kvm/kvm-run.c b/tools/kvm/kvm-run.c index 1944307..e1992fa 100644 --- a/tools/kvm/kvm-run.c +++ b/tools/kvm/kvm-run.c @@ -43,13 +43,13 @@ static void handle_sigint(int sig) static void handle_sigquit(int sig) { - serial8250__inject_sysrq(kvm); + serial8250_inject_sysrq(kvm); } static void handle_sigalrm(int sig) { - serial8250__inject_interrupt(kvm); - virtio_console__inject_interrupt(kvm); + serial8250_inject_interrupt(kvm); + virtio_console_inject_interrupt(kvm); } static u64 ram_size = MIN_RAM_SIZE_MB; @@ -94,10 +94,10 @@ static void *kvm_cpu_thread(void *arg) { current_kvm_cpu = arg; - if (kvm_cpu__start(current_kvm_cpu)) + if (kvm_cpu_start(current_kvm_cpu)) goto panic_kvm; - kvm_cpu__delete(current_kvm_cpu); + kvm_cpu_delete(current_kvm_cpu); return (void *) (intptr_t) 0; @@ -108,12 +108,12 @@ panic_kvm: if (current_kvm_cpu->kvm_run->exit_reason == KVM_EXIT_UNKNOWN) fprintf(stderr, "KVM exit code: 0x%Lu\n", current_kvm_cpu->kvm_run->hw.hardware_exit_reason); - disk_image__close(kvm->disk_image); - kvm_cpu__show_registers(current_kvm_cpu); - kvm_cpu__show_code(current_kvm_cpu); - kvm_cpu__show_page_tables(current_kvm_cpu); + disk_image_close(kvm->disk_image); + kvm_cpu_show_registers(current_kvm_cpu); + kvm_cpu_show_code(current_kvm_cpu); + kvm_cpu_show_page_tables(current_kvm_cpu); - kvm_cpu__delete(current_kvm_cpu); + kvm_cpu_delete(current_kvm_cpu); return (void *) (intptr_t) 1; } @@ -174,10 +174,10 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix) term_init(); - kvm = kvm__init(kvm_dev, ram_size); + kvm = kvm_init(kvm_dev, ram_size); if (image_filename) { - kvm->disk_image = disk_image__open(image_filename); + kvm->disk_image = disk_image_open(image_filename); if (!kvm->disk_image) die("unable to load disk image %s", image_filename); } @@ -193,31 +193,31 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix) real_cmdline[sizeof(real_cmdline)-1] = '\0'; } - if (!kvm__load_kernel(kvm, kernel_filename, initrd_filename, + if (!kvm_load_kernel(kvm, kernel_filename, initrd_filename, real_cmdline)) die("unable to load kernel %s", kernel_filename); - ioport__setup_legacy(); + ioport_setup_legacy(); - kvm__setup_bios(kvm); + kvm_setup_bios(kvm); - serial8250__init(kvm); + serial8250_init(kvm); - pci__init(); + pci_init(); - virtio_blk__init(kvm); + virtio_blk_init(kvm); - virtio_console__init(kvm); + virtio_console_init(kvm); - kvm__start_timer(kvm); + kvm_start_timer(kvm); for (i = 0; i < nrcpus; i++) { - kvm_cpus[i] = kvm_cpu__init(kvm, i); + kvm_cpus[i] = kvm_cpu_init(kvm, i); if (!kvm_cpus[i]) die("unable to initialize KVM VCPU"); if (single_step) - kvm_cpu__enable_singlestep(kvm_cpus[i]); + kvm_cpu_enable_singlestep(kvm_cpus[i]); if (pthread_create(&kvm_cpus[i]->thread, NULL, kvm_cpu_thread, kvm_cpus[i]) != 0) die("unable to create KVM VCPU thread"); @@ -233,8 +233,8 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix) exit_code = 1; } - disk_image__close(kvm->disk_image); - kvm__delete(kvm); + disk_image_close(kvm->disk_image); + kvm_delete(kvm); if (!exit_code) printf("\n # KVM session ended normally.\n"); diff --git a/tools/kvm/kvm.c b/tools/kvm/kvm.c index 08ff63c..32481a4 100644 --- a/tools/kvm/kvm.c +++ b/tools/kvm/kvm.c @@ -67,7 +67,7 @@ struct { { DEFINE_KVM_EXT(KVM_CAP_EXT_CPUID) }, }; -static bool kvm__supports_extension(struct kvm *self, unsigned int extension) +static bool kvm_supports_extension(struct kvm *self, unsigned int extension) { int ret; @@ -78,12 +78,12 @@ static bool kvm__supports_extension(struct kvm *self, unsigned int extension) return ret; } -static int kvm__check_extensions(struct kvm *self) +static int kvm_check_extensions(struct kvm *self) { unsigned int i; for (i = 0; i < ARRAY_SIZE(kvm_req_ext); i++) { - if (!kvm__supports_extension(self, kvm_req_ext[i].code)) { + if (!kvm_supports_extension(self, kvm_req_ext[i].code)) { error("Unsuppored KVM extension detected: %s", kvm_req_ext[i].name); return (int)-i; @@ -93,7 +93,7 @@ static int kvm__check_extensions(struct kvm *self) return 0; } -static struct kvm *kvm__new(void) +static struct kvm *kvm_new(void) { struct kvm *self = calloc(1, sizeof *self); @@ -103,15 +103,15 @@ static struct kvm *kvm__new(void) return self; } -void kvm__delete(struct kvm *self) +void kvm_delete(struct kvm *self) { - kvm__stop_timer(self); + kvm_stop_timer(self); free(self->ram_start); free(self); } -static bool kvm__cpu_supports_vm(void) +static bool kvm_cpu_supports_vm(void) { struct cpuid_regs regs; uint32_t eax_base; @@ -125,12 +125,12 @@ static bool kvm__cpu_supports_vm(void) switch (regs.ebx) { case CPUID_VENDOR_INTEL_1: eax_base = 0x00; - feature = KVM__X86_FEATURE_VMX; + feature = KVM_X86_FEATURE_VMX; break; case CPUID_VENDOR_AMD_1: eax_base = 0x80000000; - feature = KVM__X86_FEATURE_SVM; + feature = KVM_X86_FEATURE_SVM; break; default: @@ -153,7 +153,7 @@ static bool kvm__cpu_supports_vm(void) return regs.ecx & (1 << feature); } -struct kvm *kvm__init(const char *kvm_dev, unsigned long ram_size) +struct kvm *kvm_init(const char *kvm_dev, unsigned long ram_size) { struct kvm_userspace_memory_region mem; struct kvm_pit_config pit_config = { .flags = 0, }; @@ -161,10 +161,10 @@ struct kvm *kvm__init(const char *kvm_dev, unsigned long ram_size) long page_size; int ret; - if (!kvm__cpu_supports_vm()) + if (!kvm_cpu_supports_vm()) die("Your CPU does not support hardware virtualization"); - self = kvm__new(); + self = kvm_new(); self->sys_fd = open(kvm_dev, O_RDWR); if (self->sys_fd < 0) { @@ -186,7 +186,7 @@ struct kvm *kvm__init(const char *kvm_dev, unsigned long ram_size) if (self->vm_fd < 0) die_perror("KVM_CREATE_VM ioctl"); - if (kvm__check_extensions(self)) + if (kvm_check_extensions(self)) die("A required KVM extention is not supported by OS"); ret = ioctl(self->vm_fd, KVM_SET_TSS_ADDR, 0xfffbd000); @@ -355,7 +355,7 @@ static bool load_bzimage(struct kvm *self, int fd_kernel, return true; } -bool kvm__load_kernel(struct kvm *kvm, const char *kernel_filename, +bool kvm_load_kernel(struct kvm *kvm, const char *kernel_filename, const char *initrd_filename, const char *kernel_cmdline) { bool ret; @@ -396,13 +396,13 @@ found_kernel: } /** - * kvm__setup_bios - inject BIOS into guest system memory + * kvm_setup_bios - inject BIOS into guest system memory * @self - guest system descriptor * * This function is a main routine where we poke guest memory * and install BIOS there. */ -void kvm__setup_bios(struct kvm *self) +void kvm_setup_bios(struct kvm *self) { /* standart minimal configuration */ setup_bios(self); @@ -417,7 +417,7 @@ void kvm__setup_bios(struct kvm *self) * userspace hypervisor into the guest at periodical intervals. Please note * that clock interrupt, for example, is not handled here. */ -void kvm__start_timer(struct kvm *self) +void kvm_start_timer(struct kvm *self) { struct itimerspec its; struct sigevent sev; @@ -439,7 +439,7 @@ void kvm__start_timer(struct kvm *self) die("timer_settime()"); } -void kvm__stop_timer(struct kvm *self) +void kvm_stop_timer(struct kvm *self) { if (self->timerid) if (timer_delete(self->timerid) < 0) @@ -448,7 +448,7 @@ void kvm__stop_timer(struct kvm *self) self->timerid = 0; } -void kvm__irq_line(struct kvm *self, int irq, int level) +void kvm_irq_line(struct kvm *self, int irq, int level) { struct kvm_irq_level irq_level; @@ -463,7 +463,7 @@ void kvm__irq_line(struct kvm *self, int irq, int level) die_perror("KVM_IRQ_LINE failed"); } -void kvm__dump_mem(struct kvm *self, unsigned long addr, unsigned long size) +void kvm_dump_mem(struct kvm *self, unsigned long addr, unsigned long size) { unsigned char *p; unsigned long n; diff --git a/tools/kvm/mmio.c b/tools/kvm/mmio.c index 095d2c9..0af7ac6 100644 --- a/tools/kvm/mmio.c +++ b/tools/kvm/mmio.c @@ -10,7 +10,7 @@ static const char *to_direction(uint8_t is_write) return "read"; } -bool kvm__emulate_mmio(struct kvm *self, uint64_t phys_addr, uint8_t *data, uint32_t len, uint8_t is_write) +bool kvm_emulate_mmio(struct kvm *self, uint64_t phys_addr, uint8_t *data, uint32_t len, uint8_t is_write) { fprintf(stderr, "Warning: Ignoring MMIO %s at %016" PRIx64 " (length %" PRIu32 ")\n", to_direction(is_write), phys_addr, len); diff --git a/tools/kvm/pci.c b/tools/kvm/pci.c index 0b96990..9c46832 100644 --- a/tools/kvm/pci.c +++ b/tools/kvm/pci.c @@ -102,15 +102,15 @@ static struct ioport_operations pci_config_data_ops = { .io_out = pci_config_data_out, }; -void pci__register(struct pci_device_header *dev, uint8_t dev_num) +void pci_register(struct pci_device_header *dev, uint8_t dev_num) { assert(dev_num < PCI_MAX_DEVICES); pci_devices[dev_num] = dev; } -void pci__init(void) +void pci_init(void) { - ioport__register(PCI_CONFIG_DATA + 0, &pci_config_data_ops, 4); - ioport__register(PCI_CONFIG_ADDRESS + 0, &pci_config_address_ops, 4); + ioport_register(PCI_CONFIG_DATA + 0, &pci_config_data_ops, 4); + ioport_register(PCI_CONFIG_ADDRESS + 0, &pci_config_address_ops, 4); } diff --git a/tools/kvm/virtio-blk.c b/tools/kvm/virtio-blk.c index cb344d08..39da0d5 100644 --- a/tools/kvm/virtio-blk.c +++ b/tools/kvm/virtio-blk.c @@ -61,7 +61,7 @@ static bool virtio_blk_pci_io_device_specific_in(void *data, unsigned long offse if (size != 1 || count != 1) return false; - ioport__write8(data, config_space[offset - VIRTIO_PCI_CONFIG_NOMSI]); + ioport_write8(data, config_space[offset - VIRTIO_PCI_CONFIG_NOMSI]); return true; } @@ -77,30 +77,30 @@ static bool virtio_blk_pci_io_in(struct kvm *self, uint16_t port, void *data, in switch (offset) { case VIRTIO_PCI_HOST_FEATURES: - ioport__write32(data, blk_device.host_features); + ioport_write32(data, blk_device.host_features); break; case VIRTIO_PCI_GUEST_FEATURES: ret = false; break; case VIRTIO_PCI_QUEUE_PFN: - ioport__write32(data, blk_device.vqs[blk_device.queue_selector].pfn); + ioport_write32(data, blk_device.vqs[blk_device.queue_selector].pfn); break; case VIRTIO_PCI_QUEUE_NUM: - ioport__write16(data, VIRTIO_BLK_QUEUE_SIZE); + ioport_write16(data, VIRTIO_BLK_QUEUE_SIZE); break; case VIRTIO_PCI_QUEUE_SEL: case VIRTIO_PCI_QUEUE_NOTIFY: ret = false; break; case VIRTIO_PCI_STATUS: - ioport__write8(data, blk_device.status); + ioport_write8(data, blk_device.status); break; case VIRTIO_PCI_ISR: - ioport__write8(data, 0x1); - kvm__irq_line(self, VIRTIO_BLK_IRQ, 0); + ioport_write8(data, 0x1); + kvm_irq_line(self, VIRTIO_BLK_IRQ, 0); break; case VIRTIO_MSI_CONFIG_VECTOR: - ioport__write16(data, blk_device.config_vector); + ioport_write16(data, blk_device.config_vector); break; default: ret = virtio_blk_pci_io_device_specific_in(data, offset, size, count); @@ -124,7 +124,7 @@ static bool virtio_blk_do_io_request(struct kvm *self, struct virt_queue *queue) io_error = false; - head = virt_queue__get_iov(queue, iov, &out, &in, self); + head = virt_queue_get_iov(queue, iov, &out, &in, self); /* head */ req = iov[0].iov_base; @@ -138,12 +138,12 @@ static bool virtio_blk_do_io_request(struct kvm *self, struct virt_queue *queue) switch (req->type) { case VIRTIO_BLK_T_IN: - err = disk_image__read_sector(self->disk_image, req->sector, block, block_len); + err = disk_image_read_sector(self->disk_image, req->sector, block, block_len); if (err) io_error = true; break; case VIRTIO_BLK_T_OUT: - err = disk_image__write_sector(self->disk_image, req->sector, block, block_len); + err = disk_image_write_sector(self->disk_image, req->sector, block, block_len); if (err) io_error = true; break; @@ -160,7 +160,7 @@ static bool virtio_blk_do_io_request(struct kvm *self, struct virt_queue *queue) status = iov[out + in - 1].iov_base; *status = io_error ? VIRTIO_BLK_S_IOERR : VIRTIO_BLK_S_OK; - virt_queue__set_used_elem(queue, head, block_cnt); + virt_queue_set_used_elem(queue, head, block_cnt); return true; } @@ -169,10 +169,10 @@ static void virtio_blk_handle_callback(struct kvm *self, uint16_t queue_index) { struct virt_queue *vq = &blk_device.vqs[queue_index]; - while (virt_queue__available(vq)) + while (virt_queue_available(vq)) virtio_blk_do_io_request(self, vq); - kvm__irq_line(self, VIRTIO_BLK_IRQ, 1); + kvm_irq_line(self, VIRTIO_BLK_IRQ, 1); } @@ -187,7 +187,7 @@ static bool virtio_blk_pci_io_out(struct kvm *self, uint16_t port, void *data, i switch (offset) { case VIRTIO_PCI_GUEST_FEATURES: - blk_device.guest_features = ioport__read32(data); + blk_device.guest_features = ioport_read32(data); break; case VIRTIO_PCI_QUEUE_PFN: { struct virt_queue *queue; @@ -195,7 +195,7 @@ static bool virtio_blk_pci_io_out(struct kvm *self, uint16_t port, void *data, i queue = &blk_device.vqs[blk_device.queue_selector]; - queue->pfn = ioport__read32(data); + queue->pfn = ioport_read32(data); p = guest_flat_to_host(self, queue->pfn << 12); @@ -204,16 +204,16 @@ static bool virtio_blk_pci_io_out(struct kvm *self, uint16_t port, void *data, i break; } case VIRTIO_PCI_QUEUE_SEL: - blk_device.queue_selector = ioport__read16(data); + blk_device.queue_selector = ioport_read16(data); break; case VIRTIO_PCI_QUEUE_NOTIFY: { uint16_t queue_index; - queue_index = ioport__read16(data); + queue_index = ioport_read16(data); virtio_blk_handle_callback(self, queue_index); break; } case VIRTIO_PCI_STATUS: - blk_device.status = ioport__read8(data); + blk_device.status = ioport_read8(data); break; case VIRTIO_MSI_CONFIG_VECTOR: blk_device.config_vector = VIRTIO_MSI_NO_VECTOR; @@ -254,14 +254,14 @@ static struct pci_device_header virtio_blk_pci_device = { #define PCI_VIRTIO_BLK_DEVNUM 1 -void virtio_blk__init(struct kvm *self) +void virtio_blk_init(struct kvm *self) { if (!self->disk_image) return; blk_device.blk_config.capacity = self->disk_image->size / SECTOR_SIZE; - pci__register(&virtio_blk_pci_device, PCI_VIRTIO_BLK_DEVNUM); + pci_register(&virtio_blk_pci_device, PCI_VIRTIO_BLK_DEVNUM); - ioport__register(IOPORT_VIRTIO_BLK, &virtio_blk_io_ops, IOPORT_VIRTIO_BLK_SIZE); + ioport_register(IOPORT_VIRTIO_BLK, &virtio_blk_io_ops, IOPORT_VIRTIO_BLK_SIZE); } diff --git a/tools/kvm/virtio-console.c b/tools/kvm/virtio-console.c index a140aea..5c19540 100644 --- a/tools/kvm/virtio-console.c +++ b/tools/kvm/virtio-console.c @@ -56,7 +56,7 @@ static struct console_device console_device = { /* * Interrupts are injected for hvc0 only. */ -void virtio_console__inject_interrupt(struct kvm *self) +void virtio_console_inject_interrupt(struct kvm *self) { struct iovec iov[VIRTIO_CONSOLE_QUEUE_SIZE]; struct virt_queue *vq; @@ -68,11 +68,11 @@ void virtio_console__inject_interrupt(struct kvm *self) vq = &console_device.vqs[VIRTIO_CONSOLE_RX_QUEUE]; - if (term_readable(CONSOLE_VIRTIO) && virt_queue__available(vq)) { - head = virt_queue__get_iov(vq, iov, &out, &in, self); + if (term_readable(CONSOLE_VIRTIO) && virt_queue_available(vq)) { + head = virt_queue_get_iov(vq, iov, &out, &in, self); len = term_getc_iov(CONSOLE_VIRTIO, iov, in); - virt_queue__set_used_elem(vq, head, len); - kvm__irq_line(self, VIRTIO_CONSOLE_IRQ, 1); + virt_queue_set_used_elem(vq, head, len); + kvm_irq_line(self, VIRTIO_CONSOLE_IRQ, 1); } mutex_unlock(&console_device.mutex); @@ -88,7 +88,7 @@ static bool virtio_console_pci_io_device_specific_in(void *data, unsigned long o if ((offset - VIRTIO_PCI_CONFIG_NOMSI) > sizeof(struct virtio_console_config)) error("config offset is too big: %li", offset - VIRTIO_PCI_CONFIG_NOMSI); - ioport__write8(data, config_space[offset - VIRTIO_PCI_CONFIG_NOMSI]); + ioport_write8(data, config_space[offset - VIRTIO_PCI_CONFIG_NOMSI]); return true; } @@ -102,30 +102,30 @@ static bool virtio_console_pci_io_in(struct kvm *self, uint16_t port, void *data switch (offset) { case VIRTIO_PCI_HOST_FEATURES: - ioport__write32(data, console_device.host_features); + ioport_write32(data, console_device.host_features); break; case VIRTIO_PCI_GUEST_FEATURES: ret = false; break; case VIRTIO_PCI_QUEUE_PFN: - ioport__write32(data, console_device.vqs[console_device.queue_selector].pfn); + ioport_write32(data, console_device.vqs[console_device.queue_selector].pfn); break; case VIRTIO_PCI_QUEUE_NUM: - ioport__write16(data, VIRTIO_CONSOLE_QUEUE_SIZE); + ioport_write16(data, VIRTIO_CONSOLE_QUEUE_SIZE); break; case VIRTIO_PCI_QUEUE_SEL: case VIRTIO_PCI_QUEUE_NOTIFY: ret = false; break; case VIRTIO_PCI_STATUS: - ioport__write8(data, console_device.status); + ioport_write8(data, console_device.status); break; case VIRTIO_PCI_ISR: - ioport__write8(data, 0x1); - kvm__irq_line(self, VIRTIO_CONSOLE_IRQ, 0); + ioport_write8(data, 0x1); + kvm_irq_line(self, VIRTIO_CONSOLE_IRQ, 0); break; case VIRTIO_MSI_CONFIG_VECTOR: - ioport__write16(data, console_device.config_vector); + ioport_write16(data, console_device.config_vector); break; default: ret = virtio_console_pci_io_device_specific_in(data, offset, size, count); @@ -148,13 +148,13 @@ static void virtio_console_handle_callback(struct kvm *self, uint16_t queue_inde if (queue_index == VIRTIO_CONSOLE_TX_QUEUE) { - while (virt_queue__available(vq)) { - head = virt_queue__get_iov(vq, iov, &out, &in, self); + while (virt_queue_available(vq)) { + head = virt_queue_get_iov(vq, iov, &out, &in, self); len = term_putc_iov(CONSOLE_VIRTIO, iov, out); - virt_queue__set_used_elem(vq, head, len); + virt_queue_set_used_elem(vq, head, len); } - kvm__irq_line(self, VIRTIO_CONSOLE_IRQ, 1); + kvm_irq_line(self, VIRTIO_CONSOLE_IRQ, 1); } } @@ -165,7 +165,7 @@ static bool virtio_console_pci_io_out(struct kvm *self, uint16_t port, void *dat switch (offset) { case VIRTIO_PCI_GUEST_FEATURES: - console_device.guest_features = ioport__read32(data); + console_device.guest_features = ioport_read32(data); break; case VIRTIO_PCI_QUEUE_PFN: { struct virt_queue *queue; @@ -174,7 +174,7 @@ static bool virtio_console_pci_io_out(struct kvm *self, uint16_t port, void *dat assert(console_device.queue_selector < VIRTIO_CONSOLE_NUM_QUEUES); queue = &console_device.vqs[console_device.queue_selector]; - queue->pfn = ioport__read32(data); + queue->pfn = ioport_read32(data); p = guest_flat_to_host(self, queue->pfn << 12); vring_init(&queue->vring, VIRTIO_CONSOLE_QUEUE_SIZE, p, 4096); @@ -182,16 +182,16 @@ static bool virtio_console_pci_io_out(struct kvm *self, uint16_t port, void *dat break; } case VIRTIO_PCI_QUEUE_SEL: - console_device.queue_selector = ioport__read16(data); + console_device.queue_selector = ioport_read16(data); break; case VIRTIO_PCI_QUEUE_NOTIFY: { uint16_t queue_index; - queue_index = ioport__read16(data); + queue_index = ioport_read16(data); virtio_console_handle_callback(self, queue_index); break; } case VIRTIO_PCI_STATUS: - console_device.status = ioport__read8(data); + console_device.status = ioport_read8(data); break; case VIRTIO_MSI_CONFIG_VECTOR: console_device.config_vector = VIRTIO_MSI_NO_VECTOR; @@ -229,8 +229,8 @@ static struct pci_device_header virtio_console_pci_device = { .irq_line = VIRTIO_CONSOLE_IRQ, }; -void virtio_console__init(struct kvm *self) +void virtio_console_init(struct kvm *self) { - pci__register(&virtio_console_pci_device, PCI_VIRTIO_CONSOLE_DEVNUM); - ioport__register(IOPORT_VIRTIO_CONSOLE, &virtio_console_io_ops, IOPORT_VIRTIO_CONSOLE_SIZE); + pci_register(&virtio_console_pci_device, PCI_VIRTIO_CONSOLE_DEVNUM); + ioport_register(IOPORT_VIRTIO_CONSOLE, &virtio_console_io_ops, IOPORT_VIRTIO_CONSOLE_SIZE); } diff --git a/tools/kvm/virtio.c b/tools/kvm/virtio.c index 6249521..778c382 100644 --- a/tools/kvm/virtio.c +++ b/tools/kvm/virtio.c @@ -4,7 +4,7 @@ #include "kvm/kvm.h" #include "kvm/virtio.h" -struct vring_used_elem *virt_queue__set_used_elem(struct virt_queue *queue, uint32_t head, uint32_t len) +struct vring_used_elem *virt_queue_set_used_elem(struct virt_queue *queue, uint32_t head, uint32_t len) { struct vring_used_elem *used_elem; used_elem = &queue->vring.used->ring[queue->vring.used->idx++ % queue->vring.num]; @@ -13,16 +13,16 @@ struct vring_used_elem *virt_queue__set_used_elem(struct virt_queue *queue, uint return used_elem; } -uint16_t virt_queue__get_iov(struct virt_queue *queue, struct iovec iov[], uint16_t *out, uint16_t *in, struct kvm *kvm) +uint16_t virt_queue_get_iov(struct virt_queue *queue, struct iovec iov[], uint16_t *out, uint16_t *in, struct kvm *kvm) { struct vring_desc *desc; uint16_t head, idx; - idx = head = virt_queue__pop(queue); + idx = head = virt_queue_pop(queue); *out = *in = 0; do { - desc = virt_queue__get_desc(queue, idx); + desc = virt_queue_get_desc(queue, idx); iov[*out + *in].iov_base = guest_flat_to_host(kvm, desc->addr); iov[*out + *in].iov_len = desc->len; if (desc->flags & VRING_DESC_F_WRITE)