From 5b4d0453859e4de1a407592a1c5e3d71cf26aa33 Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Mon, 5 Jul 2010 22:16:54 +0300 Subject: [PATCH] kvm: Cleanup struct boot_params setup Signed-off-by: Pekka Enberg --- tools/kvm/kvm.c | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/tools/kvm/kvm.c b/tools/kvm/kvm.c index 78306e7bd9e0..591f64ecf320 100644 --- a/tools/kvm/kvm.c +++ b/tools/kvm/kvm.c @@ -299,9 +299,10 @@ static const char *BZIMAGE_MAGIC = "HdrS"; static bool load_bzimage(struct kvm *self, int fd, const char *kernel_cmdline) { + struct boot_params *kern_boot; struct real_intr_desc intr; - struct boot_params boot; unsigned long setup_sects; + struct boot_params boot; unsigned int intr_addr; size_t cmdline_size; ssize_t setup_size; @@ -354,26 +355,12 @@ static bool load_bzimage(struct kvm *self, int fd, const char *kernel_cmdline) memcpy(p, kernel_cmdline, cmdline_size - 1); } -#define hdr_offset(member) \ - offsetof(struct boot_params, hdr) + \ - offsetof(struct setup_header, member) -#define guest_hdr(kvm, member) \ - guest_real_to_host(kvm, \ - BOOT_LOADER_SELECTOR, \ - hdr_offset(member)) - - /* some fields in guest header have to be updated */ - p = guest_hdr(self, cmd_line_ptr); - *(uint32_t *)p = BOOT_CMDLINE_OFFSET; - - p = guest_hdr(self, type_of_loader); - *(uint8_t *)p = 0xff; - - p = guest_hdr(self, heap_end_ptr); - *(uint16_t *)p = 0xfe00; + kern_boot = guest_real_to_host(self, BOOT_LOADER_SELECTOR, 0x00); - p = guest_hdr(self, loadflags); - *(uint8_t *)p |= CAN_USE_HEAP; + kern_boot->hdr.cmd_line_ptr = BOOT_CMDLINE_OFFSET; + kern_boot->hdr.type_of_loader = 0xff; + kern_boot->hdr.heap_end_ptr = 0xfe00; + kern_boot->hdr.loadflags |= CAN_USE_HEAP; self->boot_selector = BOOT_LOADER_SELECTOR; /* -- 2.39.5