From f0a2f92c288f5b54813ccbecb380f10606924ac0 Mon Sep 17 00:00:00 2001 From: Jean Guyader Date: Thu, 9 Oct 2008 17:52:23 +0100 Subject: [PATCH] - Disable the cirrus graphic card when we passthrough a graphic card as a primary in the guest. --- hw/pc.c | 87 +++++++++++++++++++++++++++++++-------------------------- 1 file changed, 48 insertions(+), 39 deletions(-) diff --git a/hw/pc.c b/hw/pc.c index 656f755b..bd5add73 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -53,6 +53,8 @@ static PITState *pit; static IOAPICState *ioapic; static PCIDevice *i440fx_state; +extern int vga_passthrough; + static void xen_relocator_hook(target_phys_addr_t *prot_addr_upd, uint16_t protocol, const uint8_t header[], int kernel_size, @@ -768,6 +770,7 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size, BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; BlockDriverState *fd[MAX_FD]; int rc; + unsigned long vga_pt_enabled = vga_passthrough; if (ram_size >= 0xe0000000 ) { above_4g_mem_size = ram_size - 0xe0000000; @@ -844,21 +847,24 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size, } /* VGA BIOS load */ - if (cirrus_vga_enabled) { - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_CIRRUS_FILENAME); - } else { - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_FILENAME); - } - vga_bios_size = get_image_size(buf); - if (vga_bios_size <= 0 || vga_bios_size > 65536) - goto vga_bios_error; - vga_bios_offset = qemu_ram_alloc(65536); - - ret = load_image_targphys(buf, vga_bios_offset, vga_bios_size); - if (ret != vga_bios_size) { - vga_bios_error: - fprintf(stderr, "qemu: could not load VGA BIOS '%s'\n", buf); - exit(1); + if (!vga_pt_enabled) + { + if (cirrus_vga_enabled) { + snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_CIRRUS_FILENAME); + } else { + snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_FILENAME); + } + vga_bios_size = get_image_size(buf); + if (vga_bios_size <= 0 || vga_bios_size > 65536) + goto vga_bios_error; + vga_bios_offset = qemu_ram_alloc(65536); + + ret = load_image_targphys(buf, vga_bios_offset, vga_bios_size); + if (ret != vga_bios_size) { +vga_bios_error: + fprintf(stderr, "qemu: could not load VGA BIOS '%s'\n", buf); + exit(1); + } } /* setup basic memory access */ @@ -931,29 +937,32 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size, register_ioport_write(0xf0, 1, 1, ioportF0_write, NULL); - if (cirrus_vga_enabled) { - if (pci_enabled) { - pci_cirrus_vga_init(pci_bus, - ds, phys_ram_base + vga_ram_addr, - vga_ram_addr, vga_ram_size); - } else { - isa_cirrus_vga_init(ds, phys_ram_base + vga_ram_addr, - vga_ram_addr, vga_ram_size); - } - } else if (vmsvga_enabled) { - if (pci_enabled) - pci_vmsvga_init(pci_bus, ds, phys_ram_base + vga_ram_addr, - vga_ram_addr, vga_ram_size); - else - fprintf(stderr, "%s: vmware_vga: no PCI bus\n", __FUNCTION__); - } else { - if (pci_enabled) { - pci_vga_init(pci_bus, ds, phys_ram_base + vga_ram_addr, - vga_ram_addr, vga_ram_size, 0, 0); - } else { - isa_vga_init(ds, phys_ram_base + vga_ram_addr, - vga_ram_addr, vga_ram_size); - } + if (!vga_pt_enabled) + { + if (cirrus_vga_enabled) { + if (pci_enabled) { + pci_cirrus_vga_init(pci_bus, + ds, phys_ram_base + vga_ram_addr, + vga_ram_addr, vga_ram_size); + } else { + isa_cirrus_vga_init(ds, phys_ram_base + vga_ram_addr, + vga_ram_addr, vga_ram_size); + } + } else if (vmsvga_enabled) { + if (pci_enabled) + pci_vmsvga_init(pci_bus, ds, phys_ram_base + vga_ram_addr, + vga_ram_addr, vga_ram_size); + else + fprintf(stderr, "%s: vmware_vga: no PCI bus\n", __FUNCTION__); + } else { + if (pci_enabled) { + pci_vga_init(pci_bus, ds, phys_ram_base + vga_ram_addr, + vga_ram_addr, vga_ram_size, 0, 0); + } else { + isa_vga_init(ds, phys_ram_base + vga_ram_addr, + vga_ram_addr, vga_ram_size); + } + } } #ifdef CONFIG_PASSTHROUGH @@ -965,7 +974,7 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size, rc = pt_init(pci_bus, direct_pci); if ( rc < 0 ) { - fprintf(logfile, "Error: Initialization failed for pass-through devices\n"); + fprintf(stdout, "Error: Initialization failed for pass-through devices\n"); exit(1); } } -- 2.39.5