From 41a2544311df44f9b4a86f23a6cc2581723ef07e Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost@redhat.com>
Date: Mon, 14 Feb 2011 18:54:56 -0200
Subject: [PATCH 06/10] Add CONFIG_VMWARE_VGA (v2)

RH-Author: Eduardo Habkost <ehabkost@redhat.com>
Message-id: <1297709699-2894-3-git-send-email-ehabkost@redhat.com>
Patchwork-id: 18173
O-Subject: [RHEL6 qemu-kvm PATCH 2/5] Add CONFIG_VMWARE_VGA (v2)
Bugzilla: 616187
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: john cooper <john.cooper@redhat.com>
RH-Acked-by: Alex Williamson <alex.williamson@redhat.com>

Based on upstream commit 57448a975e0aa32b8466caf48ff247e567647c4e,
but our Makefile code is different from upstream, so I just implemented
the equivalent changes manually.

This includes the following change, that I submitted upstream
today:

	skip pci_vmsvga_init() calls if CONFIG_VMWARE_VGA is disabled

	I was planning to add the check for CONFIG_VMWARE to the command-line
	parsing code in vl.c, but vl.c is not built by Makefile.target, so we
	can't test for a per-target config option there.

	It is not the best solution, but it is better than simply having a
	CONFIG_VMWARE_VGA option that doesn't work and can't be disabled. I
	don't see a good way to implement it that wouldn't involve heavily
	refactoring completely the '-vga' option parsing code.

Bugzilla: 616187

Changes v1 -> v2:
	- instead of using #ifdef around pci_vmsvga_init() calls,
	  redefine it at vmware_vga.h to print the warning message

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 Makefile.target                    |    4 +++-
 default-configs/i386-softmmu.mak   |    2 ++
 default-configs/x86_64-softmmu.mak |    2 ++
 hw/vmware_vga.h                    |    6 ++++++
 4 files changed, 13 insertions(+), 1 deletions(-)

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 Makefile.target                    |    4 +++-
 default-configs/i386-softmmu.mak   |    2 ++
 default-configs/x86_64-softmmu.mak |    2 ++
 hw/vmware_vga.h                    |    6 ++++++
 4 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/Makefile.target b/Makefile.target
index 8677508..3010ccb 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -231,7 +231,7 @@ obj-i386-y += pckbd.o $(sound-obj-y) dma.o
 obj-i386-y += vga.o vga-pci.o vga-isa.o
 obj-i386-y += fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o pc.o
 obj-i386-y += cirrus_vga.o apic.o ioapic.o parallel.o acpi.o piix_pci.o
-obj-i386-y += usb-uhci.o vmmouse.o vmport.o vmware_vga.o hpet.o
+obj-i386-y += usb-uhci.o vmmouse.o vmport.o hpet.o
 obj-i386-y += device-hotplug.o smbios.o wdt_ib700.o
 obj-i386-y += extboot.o
 obj-i386-y += ne2000-isa.o
@@ -248,6 +248,8 @@ obj-ia64-y += usb-uhci.o
 obj-ia64-$(CONFIG_KVM_DEVICE_ASSIGNMENT) += device-assignment.o
 obj-i386-$(CONFIG_SPICE) += qxl.o qxl-logger.o qxl-render.o
 
+obj-i386-$(CONFIG_VMWARE_VGA) += vmware_vga.o
+
 # shared objects
 obj-ppc-y = ppc.o ide/core.o ide/qdev.o ide/isa.o ide/pci.o ide/macio.o
 obj-ppc-y += ide/cmd646.o
diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmmu.mak
index 15586a0..5948b4a 100644
--- a/default-configs/i386-softmmu.mak
+++ b/default-configs/i386-softmmu.mak
@@ -1 +1,3 @@
 # Default configuration for i386-softmmu
+
+CONFIG_VMWARE_VGA=y
diff --git a/default-configs/x86_64-softmmu.mak b/default-configs/x86_64-softmmu.mak
index ec98af2..7cc250c 100644
--- a/default-configs/x86_64-softmmu.mak
+++ b/default-configs/x86_64-softmmu.mak
@@ -1 +1,3 @@
 # Default configuration for x86_64-softmmu
+
+CONFIG_VMWARE_VGA=y
diff --git a/hw/vmware_vga.h b/hw/vmware_vga.h
index 2e0813c..11e4c66 100644
--- a/hw/vmware_vga.h
+++ b/hw/vmware_vga.h
@@ -4,6 +4,12 @@
 #include "qemu-common.h"
 
 /* vmware_vga.c */
+#ifdef CONFIG_VMWARE_VGA
 void pci_vmsvga_init(PCIBus *bus);
+#else
+#define pci_vmsvga_init(bus) do { \
+		fprintf(stderr, "%s: vmware_vga support is not compiled in\n", __FUNCTION__); \
+	} while (0)
+#endif
 
 #endif
-- 
1.7.4.rc1.16.gd2f15e

