Message ID | 1452047951-17429-3-git-send-email-caoj.fnst@cn.fujitsu.com |
---|---|
State | New |
Headers | show |
On 01/05/2016 07:39 PM, Cao jin wrote: > To catch the error msg. Also modify the caller > > Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com> > Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> > --- > hw/xen/xen_pt.c | 5 ++++- > hw/xen/xen_pt.h | 3 ++- > hw/xen/xen_pt_graphics.c | 11 ++++++----- > 3 files changed, 12 insertions(+), 7 deletions(-) > > diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c > index 1bd4109..fbce55c 100644 > --- a/hw/xen/xen_pt.c > +++ b/hw/xen/xen_pt.c > @@ -807,7 +807,10 @@ static int xen_pt_initfn(PCIDevice *d) > return -1; > } > > - if (xen_pt_setup_vga(s, &s->real_device) < 0) { > + xen_pt_setup_vga(s, &s->real_device, &local_err); > + if (local_err) { > + error_append_hint(&local_err, "Setup VGA BIOS of passthrough" > + " GFX failed!"); Please no '!' in error messages. We aren't shouting at the user. > XEN_PT_ERR(d, "Setup VGA BIOS of passthrough GFX failed!\n"); Do we still need the XEN_PT_ERR() alongside setting the local error? > xen_host_pci_device_put(&s->real_device); > return -1; This leaks local_err. > @@ -172,13 +173,14 @@ int xen_pt_setup_vga(XenPCIPassthroughState *s, XenHostPCIDevice *dev) > struct pci_data *pd = NULL; > > if (!is_igd_vga_passthrough(dev)) { > - return -1; > + error_setg(errp, "Need to enable igd-passthrough"); > + return; > } > > bios = get_vgabios(s, &bios_size, dev); > if (!bios) { > - XEN_PT_ERR(&s->dev, "VGA: Can't getting VBIOS!\n"); > - return -1; > + error_setg(errp, "VGA: Can't getting VBIOS!"); > + return; Please drop the trailing '!' while touching this
On 01/06/2016 11:53 PM, Eric Blake wrote: > On 01/05/2016 07:39 PM, Cao jin wrote: [...] > > Please no '!' in error messages. We aren't shouting at the user. Interesting, I didn`t think of this kind of questions before. will fix > >> XEN_PT_ERR(d, "Setup VGA BIOS of passthrough GFX failed!\n"); > > Do we still need the XEN_PT_ERR() alongside setting the local error? > this is fixed in "4/4 convert to realize" patch, as I said in last mail, I try to make every patch as small as possible >> xen_host_pci_device_put(&s->real_device); >> return -1; > > This leaks local_err. > > [...]
diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c index 1bd4109..fbce55c 100644 --- a/hw/xen/xen_pt.c +++ b/hw/xen/xen_pt.c @@ -807,7 +807,10 @@ static int xen_pt_initfn(PCIDevice *d) return -1; } - if (xen_pt_setup_vga(s, &s->real_device) < 0) { + xen_pt_setup_vga(s, &s->real_device, &local_err); + if (local_err) { + error_append_hint(&local_err, "Setup VGA BIOS of passthrough" + " GFX failed!"); XEN_PT_ERR(d, "Setup VGA BIOS of passthrough GFX failed!\n"); xen_host_pci_device_put(&s->real_device); return -1; diff --git a/hw/xen/xen_pt.h b/hw/xen/xen_pt.h index c545280..dc74d3e 100644 --- a/hw/xen/xen_pt.h +++ b/hw/xen/xen_pt.h @@ -328,5 +328,6 @@ static inline bool is_igd_vga_passthrough(XenHostPCIDevice *dev) } int xen_pt_register_vga_regions(XenHostPCIDevice *dev); int xen_pt_unregister_vga_regions(XenHostPCIDevice *dev); -int xen_pt_setup_vga(XenPCIPassthroughState *s, XenHostPCIDevice *dev); +void xen_pt_setup_vga(XenPCIPassthroughState *s, XenHostPCIDevice *dev, + Error **errp); #endif /* !XEN_PT_H */ diff --git a/hw/xen/xen_pt_graphics.c b/hw/xen/xen_pt_graphics.c index df6069b..a0a7e9c 100644 --- a/hw/xen/xen_pt_graphics.c +++ b/hw/xen/xen_pt_graphics.c @@ -161,7 +161,8 @@ struct pci_data { uint16_t reserved; } __attribute__((packed)); -int xen_pt_setup_vga(XenPCIPassthroughState *s, XenHostPCIDevice *dev) +void xen_pt_setup_vga(XenPCIPassthroughState *s, XenHostPCIDevice *dev, + Error **errp) { unsigned char *bios = NULL; struct rom_header *rom; @@ -172,13 +173,14 @@ int xen_pt_setup_vga(XenPCIPassthroughState *s, XenHostPCIDevice *dev) struct pci_data *pd = NULL; if (!is_igd_vga_passthrough(dev)) { - return -1; + error_setg(errp, "Need to enable igd-passthrough"); + return; } bios = get_vgabios(s, &bios_size, dev); if (!bios) { - XEN_PT_ERR(&s->dev, "VGA: Can't getting VBIOS!\n"); - return -1; + error_setg(errp, "VGA: Can't getting VBIOS!"); + return; } /* Currently we fixed this address as a primary. */ @@ -203,7 +205,6 @@ int xen_pt_setup_vga(XenPCIPassthroughState *s, XenHostPCIDevice *dev) /* Currently we fixed this address as a primary for legacy BIOS. */ cpu_physical_memory_rw(0xc0000, bios, bios_size, 1); - return 0; } uint32_t igd_read_opregion(XenPCIPassthroughState *s)