From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:47412) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RFhUI-0007z6-UM for qemu-devel@nongnu.org; Mon, 17 Oct 2011 03:19:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RFhUF-00076M-Du for qemu-devel@nongnu.org; Mon, 17 Oct 2011 03:19:54 -0400 Received: from fmmailgate03.web.de ([217.72.192.234]:38243) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RFhUE-00075g-MC for qemu-devel@nongnu.org; Mon, 17 Oct 2011 03:19:51 -0400 Received: from moweb001.kundenserver.de (moweb001.kundenserver.de [172.19.20.114]) by fmmailgate03.web.de (Postfix) with ESMTP id 419941A3A24F3 for ; Mon, 17 Oct 2011 09:17:13 +0200 (CEST) Message-ID: <4E9BD674.5050302@web.de> Date: Mon, 17 Oct 2011 09:17:08 +0200 From: Jan Kiszka MIME-Version: 1.0 References: In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigBB3D2D10318A5E9E43465397" Subject: Re: [Qemu-devel] [PATCH v3 1/4] vga: make PCI devices optional List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Blue Swirl Cc: qemu-devel This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigBB3D2D10318A5E9E43465397 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 2011-10-16 23:21, Blue Swirl wrote: > Improve VGA selection logic, push check for device availabilty to vl.c.= > Make PCI VGA devices optional. >=20 > Signed-off-by: Blue Swirl > --- > hw/cirrus_vga.c | 5 ----- > hw/pc.c | 6 +----- > hw/pc.h | 33 +++++++++++++++++++++++++++------ > hw/pci.c | 18 ++++++++++++++++++ > hw/pci.h | 4 ++++ > hw/qdev.c | 5 +++++ > hw/qdev.h | 1 + > hw/vga-pci.c | 6 ------ > vl.c | 33 +++++++++++++++++++++++++++------ > 9 files changed, 83 insertions(+), 28 deletions(-) >=20 > diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c > index c7e365b..a11444c 100644 > --- a/hw/cirrus_vga.c > +++ b/hw/cirrus_vga.c > @@ -2955,11 +2955,6 @@ static int pci_cirrus_vga_initfn(PCIDevice *dev)= > return 0; > } >=20 > -void pci_cirrus_vga_init(PCIBus *bus) > -{ > - pci_create_simple(bus, -1, "cirrus-vga"); > -} > - > static PCIDeviceInfo cirrus_vga_info =3D { > .qdev.name =3D "cirrus-vga", > .qdev.desc =3D "Cirrus CLGD 54xx VGA", > diff --git a/hw/pc.c b/hw/pc.c > index f0802b7..057eb9c 100644 > --- a/hw/pc.c > +++ b/hw/pc.c > @@ -1080,11 +1080,7 @@ void pc_vga_init(PCIBus *pci_bus) > } > } else if (vmsvga_enabled) { > if (pci_bus) { > - if (!pci_vmsvga_init(pci_bus)) { > - fprintf(stderr, "Warning: vmware_vga not available," > - " using standard VGA instead\n"); > - pci_vga_init(pci_bus); > - } > + pci_vmsvga_init(pci_bus); > } else { > fprintf(stderr, "%s: vmware_vga: no PCI bus\n", __FUNCTION= __); > } > diff --git a/hw/pc.h b/hw/pc.h > index b8ad9a3..6c951e8 100644 > --- a/hw/pc.h > +++ b/hw/pc.h > @@ -9,6 +9,7 @@ > #include "net.h" > #include "memory.h" > #include "ioapic.h" > +#include "pci.h" >=20 > /* PC-style peripherals (also used by other machines). */ >=20 > @@ -203,26 +204,46 @@ enum vga_retrace_method { >=20 > extern enum vga_retrace_method vga_retrace_method; >=20 > -static inline int isa_vga_init(void) > +static inline bool isa_vga_init(void) > { > ISADevice *dev; >=20 > dev =3D isa_try_create("isa-vga"); > if (!dev) { > - fprintf(stderr, "Warning: isa-vga not available\n"); > - return 0; > + return false; > } > qdev_init_nofail(&dev->qdev); > - return 1; > + return true; > +} > + > +/* vga-pci.c */ > +static inline bool pci_vga_init(PCIBus *bus) > +{ > + PCIDevice *dev; > + > + dev =3D pci_try_create_simple(bus, -1, "VGA"); > + if (!dev) { > + return false; > + } > + return true; > } >=20 > -int pci_vga_init(PCIBus *bus); > int isa_vga_mm_init(target_phys_addr_t vram_base, > target_phys_addr_t ctrl_base, int it_shift, > MemoryRegion *address_space); >=20 > /* cirrus_vga.c */ > -void pci_cirrus_vga_init(PCIBus *bus); > +static inline bool pci_cirrus_vga_init(PCIBus *bus) > +{ > + PCIDevice *dev; > + > + dev =3D pci_try_create_simple(bus, -1, "cirrus-vga"); > + if (!dev) { > + return false; > + } > + return true; > +} > + > void isa_cirrus_vga_init(MemoryRegion *address_space); >=20 > /* ne2000.c */ > diff --git a/hw/pci.c b/hw/pci.c > index 749e8d8..46c01ac 100644 > --- a/hw/pci.c > +++ b/hw/pci.c > @@ -1687,6 +1687,19 @@ PCIDevice > *pci_create_simple_multifunction(PCIBus *bus, int devfn, > return dev; > } >=20 > +PCIDevice *pci_try_create_simple_multifunction(PCIBus *bus, int devfn,= > + bool multifunction, > + const char *name) > +{ > + PCIDevice *dev =3D pci_try_create_multifunction(bus, devfn, multif= unction, > + name); > + if (!dev) { > + return NULL; > + } > + qdev_init_nofail(&dev->qdev); > + return dev; > +} > + > PCIDevice *pci_create(PCIBus *bus, int devfn, const char *name) > { > return pci_create_multifunction(bus, devfn, false, name); > @@ -1702,6 +1715,11 @@ PCIDevice *pci_try_create(PCIBus *bus, int > devfn, const char *name) > return pci_try_create_multifunction(bus, devfn, false, name); > } >=20 > +PCIDevice *pci_try_create_simple(PCIBus *bus, int devfn, const char *n= ame) > +{ > + return pci_try_create_simple_multifunction(bus, devfn, false, name= ); > +} > + > static int pci_find_space(PCIDevice *pdev, uint8_t size) > { > int config_size =3D pci_config_size(pdev); > diff --git a/hw/pci.h b/hw/pci.h > index 86a81c8..aa2e040 100644 > --- a/hw/pci.h > +++ b/hw/pci.h > @@ -473,9 +473,13 @@ PCIDevice *pci_create_simple_multifunction(PCIBus > *bus, int devfn, > PCIDevice *pci_try_create_multifunction(PCIBus *bus, int devfn, > bool multifunction, > const char *name); > +PCIDevice *pci_try_create_simple_multifunction(PCIBus *bus, int devfn,= > + bool multifunction, > + const char *name); > PCIDevice *pci_create(PCIBus *bus, int devfn, const char *name); > PCIDevice *pci_create_simple(PCIBus *bus, int devfn, const char *name)= ; > PCIDevice *pci_try_create(PCIBus *bus, int devfn, const char *name); > +PCIDevice *pci_try_create_simple(PCIBus *bus, int devfn, const char *n= ame); >=20 > static inline int pci_is_express(const PCIDevice *d) > { > diff --git a/hw/qdev.c b/hw/qdev.c > index a223d41..dc0aa1c 100644 > --- a/hw/qdev.c > +++ b/hw/qdev.c > @@ -80,6 +80,11 @@ static DeviceInfo *qdev_find_info(BusInfo > *bus_info, const char *name) > return NULL; > } >=20 > +bool qdev_exists(const char *name) > +{ > + return !!qdev_find_info(NULL, name); > +} > + > static DeviceState *qdev_create_from_info(BusState *bus, DeviceInfo *i= nfo) > { > DeviceState *dev; > diff --git a/hw/qdev.h b/hw/qdev.h > index aa7ae36..a53ccb1 100644 > --- a/hw/qdev.h > +++ b/hw/qdev.h > @@ -123,6 +123,7 @@ typedef struct GlobalProperty { >=20 > DeviceState *qdev_create(BusState *bus, const char *name); > DeviceState *qdev_try_create(BusState *bus, const char *name); > +bool qdev_exists(const char *name); > int qdev_device_help(QemuOpts *opts); > DeviceState *qdev_device_add(QemuOpts *opts); > int qdev_init(DeviceState *dev) QEMU_WARN_UNUSED_RESULT; > diff --git a/hw/vga-pci.c b/hw/vga-pci.c > index 14bfadb..68fddd9 100644 > --- a/hw/vga-pci.c > +++ b/hw/vga-pci.c > @@ -70,12 +70,6 @@ static int pci_vga_initfn(PCIDevice *dev) > return 0; > } >=20 > -int pci_vga_init(PCIBus *bus) > -{ > - pci_create_simple(bus, -1, "VGA"); > - return 0; > -} > - > static PCIDeviceInfo vga_info =3D { > .qdev.name =3D "VGA", > .qdev.size =3D sizeof(PCIVGAState), > diff --git a/vl.c b/vl.c > index 2dce3ae..15fb0d1 100644 > --- a/vl.c > +++ b/vl.c > @@ -1654,11 +1654,26 @@ static void select_vgahw (const char *p) > default_vga =3D 0; > vga_interface_type =3D VGA_NONE; > if (strstart(p, "std", &opts)) { > - vga_interface_type =3D VGA_STD; > + if (qdev_exists("VGA") || qdev_exists("isa-vga")) { > + vga_interface_type =3D VGA_STD; > + } else { > + fprintf(stderr, "Error: standard VGA not available\n"); > + exit(0); > + } > } else if (strstart(p, "cirrus", &opts)) { > - vga_interface_type =3D VGA_CIRRUS; > + if (qdev_exists("cirrus-vga") || qdev_exists("isa-cirrus-vga")= ) { > + vga_interface_type =3D VGA_CIRRUS; > + } else { > + fprintf(stderr, "Error: Cirrus VGA not available\n"); > + exit(0); > + } > } else if (strstart(p, "vmware", &opts)) { > - vga_interface_type =3D VGA_VMWARE; > + if (qdev_exists("vmware-svga")) { > + vga_interface_type =3D VGA_VMWARE; > + } else { > + fprintf(stderr, "Error: VMWare SVGA not available\n"); > + exit(0); > + } > } else if (strstart(p, "xenfb", &opts)) { > vga_interface_type =3D VGA_XENFB; > } else if (strstart(p, "qxl", &opts)) { > @@ -2277,6 +2292,7 @@ int main(int argc, char **argv, char **envp) > const char *loadvm =3D NULL; > QEMUMachine *machine; > const char *cpu_model; > + const char *vga_model =3D NULL; > const char *pid_file =3D NULL; > const char *incoming =3D NULL; > #ifdef CONFIG_VNC > @@ -2694,7 +2710,7 @@ int main(int argc, char **argv, char **envp) > rtc_utc =3D 0; > break; > case QEMU_OPTION_vga: > - select_vgahw (optarg); > + vga_model =3D optarg; > break; > case QEMU_OPTION_g: > { > @@ -3252,8 +3268,6 @@ int main(int argc, char **argv, char **envp) > if (default_virtcon) > add_device_config(DEV_VIRTCON, "vc:80Cx24C"); > } > - if (default_vga) > - vga_interface_type =3D VGA_CIRRUS; >=20 > socket_init(); >=20 > @@ -3398,6 +3412,13 @@ int main(int argc, char **argv, char **envp) >=20 > module_call_init(MODULE_INIT_DEVICE); >=20 > + /* must be after qdev registration but before machine init */ > + if (vga_model) { > + select_vgahw(vga_model); > + } else if (default_vga) { > + select_vgahw("cirrus"); > + } Nice change, except maybe for this detail: If the default model is disabled, we will bail out, no? Would it make sense to handle this case gracefully as well? Jan --------------enigBB3D2D10318A5E9E43465397 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk6b1ncACgkQitSsb3rl5xQ6zgCffNR3zkLU4WRjPzvKml3x+ayk IFAAn1fjcg9Q9QrPPvxZzAedlrpg1Eat =o2hU -----END PGP SIGNATURE----- --------------enigBB3D2D10318A5E9E43465397--