+++ /dev/null
-diff --git a/vl.c b/vl.c
-index ae32f82..05d12ae 100644
---- a/vl.c
-+++ b/vl.c
-@@ -4598,24 +4598,20 @@ static void select_soundhw (const char *optarg)
- static void select_vgahw (const char *p)
- {
- const char *opts;
-+ std_vga_enabled = 0;
-+ cirrus_vga_enabled = 0;
-+ vmsvga_enabled = 0;
-
-- if (strstart(p, "std", &opts)) {
-+ if (strstart(p, "std", &opts))
- std_vga_enabled = 1;
-- cirrus_vga_enabled = 0;
-- vmsvga_enabled = 0;
-- } else if (strstart(p, "cirrus", &opts)) {
-+ else if (strstart(p, "cirrus", &opts))
- cirrus_vga_enabled = 1;
-- std_vga_enabled = 0;
-- vmsvga_enabled = 0;
-- } else if (strstart(p, "vmware", &opts)) {
-- cirrus_vga_enabled = 0;
-- std_vga_enabled = 0;
-+ else if (strstart(p, "vmware", &opts))
- vmsvga_enabled = 1;
-- } else if (strstart(p, "none", &opts)) {
-- cirrus_vga_enabled = 0;
-- std_vga_enabled = 0;
-- vmsvga_enabled = 0;
-- } else {
-+ else if (strstart(p, "passthrough", &opts))
-+ vga_passthrough = 1;
-+ else if (!strstart(p, "none", &opts))
-+ {
- invalid_vga:
- fprintf(stderr, "Unknown vga type: %s\n", p);
- exit(1);
-@@ -5272,6 +5268,9 @@ int main(int argc, char **argv, char **envp)
- break;
- case QEMU_OPTION_vga_passthrough:
- vga_passthrough = 1;
-+ std_vga_enabled = 0;
-+ cirrus_vga_enabled = 0;
-+ vmsvga_enabled = 0;
- break;
- case QEMU_OPTION_dom0_input:
- dom0_input = optarg;
diff --git a/hw/pass-through.c b/hw/pass-through.c
-index 51a39db..10904c9 100644
+index 51a39db..100be0f 100644
--- a/hw/pass-through.c
+++ b/hw/pass-through.c
@@ -90,6 +90,8 @@
struct php_dev {
struct pt_dev *pt_dev;
uint8_t valid;
+@@ -1008,7 +1010,7 @@ static void pt_iomem_map(PCIDevice *d, int i, uint32_t e_phys, uint32_t e_size,
+ e_phys, (unsigned long)assigned_device->bases[i].access.maddr,
+ type, e_size, i, first_map);
+
+- if ( e_size == 0 )
++ if ( e_size == 0 || !first_map)
+ return;
+
+ if ( !first_map && old_ebase != -1 )
@@ -1573,10 +1575,11 @@ static int pt_dev_is_virtfn(struct pci_dev *dev)
static int pt_register_regions(struct pt_dev *assigned_device)
printf("pci_config_read: %s: addr=%02x val=%08x len=%d\n",
pci_dev->name, config_addr, val, len);
diff --git a/vl.c b/vl.c
-index cdbe2a3..6d79072 100644
+index cdbe2a3..a4b8bd8 100644
--- a/vl.c
+++ b/vl.c
@@ -233,6 +233,7 @@ CharDriverState *virtcon_hds[MAX_VIRTIO_CONSOLES];
#if defined(CONFIG_XEN) && !defined(CONFIG_DM)
{ "xen-domid", HAS_ARG, QEMU_OPTION_xen_domid },
{ "xen-create", 0, QEMU_OPTION_xen_create },
-@@ -5293,6 +5296,9 @@ int main(int argc, char **argv, char **envp)
+@@ -4620,24 +4623,20 @@ static void select_soundhw (const char *optarg)
+ static void select_vgahw (const char *p)
+ {
+ const char *opts;
++ std_vga_enabled = 0;
++ cirrus_vga_enabled = 0;
++ vmsvga_enabled = 0;
+
+- if (strstart(p, "std", &opts)) {
++ if (strstart(p, "std", &opts))
+ std_vga_enabled = 1;
+- cirrus_vga_enabled = 0;
+- vmsvga_enabled = 0;
+- } else if (strstart(p, "cirrus", &opts)) {
++ else if (strstart(p, "cirrus", &opts))
+ cirrus_vga_enabled = 1;
+- std_vga_enabled = 0;
+- vmsvga_enabled = 0;
+- } else if (strstart(p, "vmware", &opts)) {
+- cirrus_vga_enabled = 0;
+- std_vga_enabled = 0;
++ else if (strstart(p, "vmware", &opts))
+ vmsvga_enabled = 1;
+- } else if (strstart(p, "none", &opts)) {
+- cirrus_vga_enabled = 0;
+- std_vga_enabled = 0;
+- vmsvga_enabled = 0;
+- } else {
++ else if (strstart(p, "passthrough", &opts))
++ vga_passthrough = 1;
++ else if (!strstart(p, "none", &opts))
++ {
+ invalid_vga:
+ fprintf(stderr, "Unknown vga type: %s\n", p);
+ exit(1);
+@@ -5293,6 +5292,12 @@ int main(int argc, char **argv, char **envp)
case QEMU_OPTION_disable_opengl:
opengl_enabled = 0;
break;
+ case QEMU_OPTION_vga_passthrough:
+ vga_passthrough = 1;
++ std_vga_enabled = 0;
++ cirrus_vga_enabled = 0;
++ vmsvga_enabled = 0;
+ break;
case QEMU_OPTION_direct_pci:
direct_pci = optarg;