Permalink
Browse files

merged conflicts

  • Loading branch information...
2 parents e3e24cc + f5105ef commit 880e5aeaae182e0898d727d7906723a6679310c7 @floren committed May 13, 2011
View
@@ -70,7 +70,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 *kvm, struct serial8250_device *dev)
{
switch (sysrq_pending) {
case SYSRQ_PENDING_BREAK:
@@ -87,15 +87,15 @@ 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 *kvm, struct serial8250_device *dev)
{
int c;
if (dev->lsr & UART_LSR_DR)
return;
if (sysrq_pending) {
- serial8250__sysrq(self, dev);
+ serial8250__sysrq(kvm, dev);
return;
}
@@ -114,13 +114,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 *kvm)
{
struct serial8250_device *dev = &devices[0];
mutex_lock(&dev->mutex);
- serial8250__receive(self, dev);
+ serial8250__receive(kvm, dev);
if (dev->ier & UART_IER_RDI && dev->lsr & UART_LSR_DR)
dev->iir = UART_IIR_RDI;
@@ -130,14 +130,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(kvm, dev->irq, 0);
+ kvm__irq_line(kvm, dev->irq, 1);
}
mutex_unlock(&dev->mutex);
}
-void serial8250__inject_sysrq(struct kvm *self)
+void serial8250__inject_sysrq(struct kvm *kvm)
{
sysrq_pending = SYSRQ_PENDING_BREAK;
}
@@ -155,7 +155,7 @@ static struct serial8250_device *find_device(u16 port)
return NULL;
}
-static bool serial8250_out(struct kvm *self, u16 port, void *data, int size, u32 count)
+static bool serial8250_out(struct kvm *kvm, u16 port, void *data, int size, u32 count)
{
struct serial8250_device *dev;
u16 offset;
@@ -243,7 +243,7 @@ static bool serial8250_out(struct kvm *self, u16 port, void *data, int size, u32
return ret;
}
-static bool serial8250_in(struct kvm *self, u16 port, void *data, int size, u32 count)
+static bool serial8250_in(struct kvm *kvm, u16 port, void *data, int size, u32 count)
{
struct serial8250_device *dev;
u16 offset;
@@ -55,6 +55,9 @@ OPTIONS
--cpus::
The number of virtual CPUs to run.
+--debug::
+ Enable debug messages.
+
SEE ALSO
--------
linkkvm:
View
@@ -26,6 +26,7 @@ OBJS += main.o
OBJS += mmio.o
OBJS += pci.o
OBJS += rtc.o
+OBJS += symbol.o
OBJS += term.o
OBJS += util.o
OBJS += virtio/blk.o
@@ -53,6 +54,7 @@ OBJS += bios/bios.o
LIBS += -lrt
LIBS += -lpthread
LIBS += -lvncserver
+LIBS += -lbfd
# Additional ARCH settings for x86
ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
View
@@ -61,8 +61,6 @@ static void e820_setup(struct kvm *kvm)
size = guest_flat_to_host(kvm, E820_MAP_SIZE);
mem_map = guest_flat_to_host(kvm, E820_MAP_START);
- *size = E820_MEM_AREAS;
-
mem_map[i++] = (struct e820_entry) {
.addr = REAL_MODE_IVT_BEGIN,
.size = EBDA_START - REAL_MODE_IVT_BEGIN,
@@ -78,13 +76,28 @@ static void e820_setup(struct kvm *kvm)
.size = MB_BIOS_END - MB_BIOS_BEGIN,
.type = E820_MEM_RESERVED,
};
- mem_map[i++] = (struct e820_entry) {
- .addr = BZ_KERNEL_START,
- .size = kvm->ram_size - BZ_KERNEL_START,
- .type = E820_MEM_USABLE,
- };
+ if (kvm->ram_size < KVM_32BIT_GAP_START) {
+ mem_map[i++] = (struct e820_entry) {
+ .addr = BZ_KERNEL_START,
+ .size = kvm->ram_size - BZ_KERNEL_START,
+ .type = E820_MEM_USABLE,
+ };
+ } else {
+ mem_map[i++] = (struct e820_entry) {
+ .addr = BZ_KERNEL_START,
+ .size = KVM_32BIT_GAP_START - BZ_KERNEL_START,
+ .type = E820_MEM_USABLE,
+ };
+ mem_map[i++] = (struct e820_entry) {
+ .addr = 0x100000000ULL,
+ .size = kvm->ram_size - KVM_32BIT_GAP_START,
+ .type = E820_MEM_USABLE,
+ };
+ }
BUILD_BUG_ON(i > E820_MEM_AREAS);
+
+ *size = i;
}
/**
View
@@ -32,19 +32,19 @@ 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 *vcpu)
{
struct kvm_cpuid2 *kvm_cpuid;
kvm_cpuid = calloc(1, sizeof(*kvm_cpuid) + MAX_KVM_CPUID_ENTRIES * sizeof(*kvm_cpuid->entries));
kvm_cpuid->nent = MAX_KVM_CPUID_ENTRIES;
- if (ioctl(self->kvm->sys_fd, KVM_GET_SUPPORTED_CPUID, kvm_cpuid) < 0)
+ if (ioctl(vcpu->kvm->sys_fd, KVM_GET_SUPPORTED_CPUID, kvm_cpuid) < 0)
die_perror("KVM_GET_SUPPORTED_CPUID failed");
filter_cpuid(kvm_cpuid);
- if (ioctl(self->vcpu_fd, KVM_SET_CPUID2, kvm_cpuid) < 0)
+ if (ioctl(vcpu->vcpu_fd, KVM_SET_CPUID2, kvm_cpuid) < 0)
die_perror("KVM_SET_CPUID2 failed");
free(kvm_cpuid);
View
@@ -19,74 +19,74 @@
struct disk_image *disk_image__new(int fd, u64 size, struct disk_image_operations *ops)
{
- struct disk_image *self;
+ struct disk_image *disk;
- self = malloc(sizeof *self);
- if (!self)
+ disk = malloc(sizeof *disk);
+ if (!disk)
return NULL;
- self->fd = fd;
- self->size = size;
- self->ops = ops;
- return self;
+ disk->fd = fd;
+ disk->size = size;
+ disk->ops = ops;
+ return disk;
}
struct disk_image *disk_image__new_readonly(int fd, u64 size, struct disk_image_operations *ops)
{
- struct disk_image *self;
+ struct disk_image *disk;
- self = disk_image__new(fd, size, ops);
- if (!self)
+ disk = disk_image__new(fd, size, ops);
+ if (!disk)
return NULL;
- self->priv = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_NORESERVE, fd, 0);
- if (self->priv == MAP_FAILED)
+ disk->priv = mmap(NULL, size, PROT_RW, MAP_PRIVATE | MAP_NORESERVE, fd, 0);
+ if (disk->priv == MAP_FAILED)
die("mmap() failed");
- return self;
+ return disk;
}
-static ssize_t raw_image__read_sector_iov(struct disk_image *self, u64 sector, const struct iovec *iov, int iovcount)
+static ssize_t raw_image__read_sector_iov(struct disk_image *disk, u64 sector, const struct iovec *iov, int iovcount)
{
u64 offset = sector << SECTOR_SHIFT;
- return preadv_in_full(self->fd, iov, iovcount, offset);
+ return preadv_in_full(disk->fd, iov, iovcount, offset);
}
-static ssize_t raw_image__write_sector_iov(struct disk_image *self, u64 sector, const struct iovec *iov, int iovcount)
+static ssize_t raw_image__write_sector_iov(struct disk_image *disk, u64 sector, const struct iovec *iov, int iovcount)
{
u64 offset = sector << SECTOR_SHIFT;
- return pwritev_in_full(self->fd, iov, iovcount, offset);
+ return pwritev_in_full(disk->fd, iov, iovcount, offset);
}
-static int raw_image__read_sector_ro_mmap(struct disk_image *self, u64 sector, void *dst, u32 dst_len)
+static int raw_image__read_sector_ro_mmap(struct disk_image *disk, u64 sector, void *dst, u32 dst_len)
{
u64 offset = sector << SECTOR_SHIFT;
- if (offset + dst_len > self->size)
+ if (offset + dst_len > disk->size)
return -1;
- memcpy(dst, self->priv + offset, dst_len);
+ memcpy(dst, disk->priv + offset, dst_len);
return 0;
}
-static int raw_image__write_sector_ro_mmap(struct disk_image *self, u64 sector, void *src, u32 src_len)
+static int raw_image__write_sector_ro_mmap(struct disk_image *disk, u64 sector, void *src, u32 src_len)
{
u64 offset = sector << SECTOR_SHIFT;
- if (offset + src_len > self->size)
+ if (offset + src_len > disk->size)
return -1;
- memcpy(self->priv + offset, src, src_len);
+ memcpy(disk->priv + offset, src, src_len);
return 0;
}
-static void raw_image__close_ro_mmap(struct disk_image *self)
+static void raw_image__close_ro_mmap(struct disk_image *disk)
{
- if (self->priv != MAP_FAILED)
- munmap(self->priv, self->size);
+ if (disk->priv != MAP_FAILED)
+ munmap(disk->priv, disk->size);
}
static struct disk_image_operations raw_image_ops = {
@@ -130,7 +130,7 @@ static struct disk_image *blkdev__probe(const char *filename, struct stat *st)
struct disk_image *disk_image__open(const char *filename, bool readonly)
{
- struct disk_image *self;
+ struct disk_image *disk;
struct stat st;
int fd;
@@ -144,31 +144,31 @@ struct disk_image *disk_image__open(const char *filename, bool readonly)
if (fd < 0)
return NULL;
- self = qcow_probe(fd);
- if (self)
- return self;
+ disk = qcow_probe(fd, readonly);
+ if (disk)
+ return disk;
- self = raw_image__probe(fd, &st, readonly);
- if (self)
- return self;
+ disk = raw_image__probe(fd, &st, readonly);
+ if (disk)
+ return disk;
if (close(fd) < 0)
warning("close() failed");
return NULL;
}
-void disk_image__close(struct disk_image *self)
+void disk_image__close(struct disk_image *disk)
{
/* If there was no disk image then there's nothing to do: */
- if (!self)
+ if (!disk)
return;
- if (self->ops->close)
- self->ops->close(self);
+ if (disk->ops->close)
+ disk->ops->close(disk);
- if (close(self->fd) < 0)
+ if (close(disk->fd) < 0)
warning("close() failed");
- free(self);
+ free(disk);
}
@@ -11,11 +11,11 @@
struct disk_image;
struct disk_image_operations {
- int (*read_sector)(struct disk_image *self, u64 sector, void *dst, u32 dst_len);
- int (*write_sector)(struct disk_image *self, u64 sector, void *src, u32 src_len);
- ssize_t (*read_sector_iov)(struct disk_image *self, u64 sector, const struct iovec *iov, int iovcount);
- ssize_t (*write_sector_iov)(struct disk_image *self, u64 sector, const struct iovec *iov, int iovcount);
- void (*close)(struct disk_image *self);
+ int (*read_sector)(struct disk_image *disk, u64 sector, void *dst, u32 dst_len);
+ int (*write_sector)(struct disk_image *disk, u64 sector, void *src, u32 src_len);
+ ssize_t (*read_sector_iov)(struct disk_image *disk, u64 sector, const struct iovec *iov, int iovcount);
+ ssize_t (*write_sector_iov)(struct disk_image *disk, u64 sector, const struct iovec *iov, int iovcount);
+ void (*close)(struct disk_image *disk);
};
struct disk_image {
@@ -28,39 +28,43 @@ struct disk_image {
struct disk_image *disk_image__open(const char *filename, bool readonly);
struct disk_image *disk_image__new(int fd, u64 size, struct disk_image_operations *ops);
struct disk_image *disk_image__new_readonly(int fd, u64 size, struct disk_image_operations *ops);
-void disk_image__close(struct disk_image *self);
+void disk_image__close(struct disk_image *disk);
-static inline int disk_image__read_sector(struct disk_image *self, u64 sector, void *dst, u32 dst_len)
+static inline int disk_image__read_sector(struct disk_image *disk, u64 sector, void *dst, u32 dst_len)
{
- return self->ops->read_sector(self, sector, dst, dst_len);
+ return disk->ops->read_sector(disk, sector, dst, dst_len);
}
-static inline int disk_image__write_sector(struct disk_image *self, u64 sector, void *src, u32 src_len)
+static inline int disk_image__write_sector(struct disk_image *disk, u64 sector, void *src, u32 src_len)
{
- return self->ops->write_sector(self, sector, src, src_len);
+ return disk->ops->write_sector(disk, sector, src, src_len);
}
-static inline ssize_t disk_image__read_sector_iov(struct disk_image *self, u64 sector, const struct iovec *iov, int iovcount)
+static inline ssize_t disk_image__read_sector_iov(struct disk_image *disk, u64 sector, const struct iovec *iov, int iovcount)
{
- if (self->ops->read_sector_iov)
- return self->ops->read_sector_iov(self, sector, iov, iovcount);
+ if (disk->ops->read_sector_iov)
+ return disk->ops->read_sector_iov(disk, sector, iov, iovcount);
while (iovcount--) {
- self->ops->read_sector(self, sector, iov->iov_base, iov->iov_len);
+ if (disk->ops->read_sector(disk, sector, iov->iov_base, iov->iov_len) < 0)
+ return -1;
+
sector += iov->iov_len >> SECTOR_SHIFT;
iov++;
}
return sector << SECTOR_SHIFT;
}
-static inline ssize_t disk_image__write_sector_iov(struct disk_image *self, u64 sector, const struct iovec *iov, int iovcount)
+static inline ssize_t disk_image__write_sector_iov(struct disk_image *disk, u64 sector, const struct iovec *iov, int iovcount)
{
- if (self->ops->write_sector_iov)
- return self->ops->write_sector_iov(self, sector, iov, iovcount);
+ if (disk->ops->write_sector_iov)
+ return disk->ops->write_sector_iov(disk, sector, iov, iovcount);
while (iovcount--) {
- self->ops->write_sector(self, sector, iov->iov_base, iov->iov_len);
+ if (disk->ops->write_sector(disk, sector, iov->iov_base, iov->iov_len) < 0)
+ return -1;
+
sector += iov->iov_len >> SECTOR_SHIFT;
iov++;
}
Oops, something went wrong.

0 comments on commit 880e5ae

Please sign in to comment.